silly people that don't want to install/run autoconf :-)
[asterisk/asterisk.git] / Makefile
index b6aab06..87c9bfd 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -196,8 +196,9 @@ ifneq ($(wildcard makeopts),)
 endif
 
 ASTCFLAGS+=$(MENUSELECT_CFLAGS)
-TOPDIR_CFLAGS=-include include/autoconfig.h
-MOD_SUBDIR_CFLAGS=-include ../include/autoconfig.h
+TOPDIR_CFLAGS=-include include/autoconfig.h -Iinclude
+MOD_SUBDIR_CFLAGS=-include ../include/autoconfig.h -I../include -I..
+OTHER_SUBDIR_CFLAGS=-include ../include/autoconfig.h -I../include -I..
 
 #   *CLI> show memory allocations [filename]
 #   *CLI> show memory summary [filename]
@@ -213,7 +214,6 @@ ifeq ($(OSARCH),Linux)
     # You must have GCC 3.4 to use k8, otherwise use athlon
     PROC=k8
     #PROC=athlon
-    OPTIONS+=-m64
   endif
 
   ifeq ($(PROC),sparc64)
@@ -234,9 +234,9 @@ ifeq ($(OSARCH),Linux)
       OPTIONS+=-fsigned-char -mcpu=ep9312
     else
       ifeq ($(SUB_PROC),xscale)
-        OPTIONS+=-fsigned-char -msoft-float -mcpu=xscale
+        OPTIONS+=-fsigned-char -mcpu=xscale
       else
-        OPTIONS+=-fsigned-char -msoft-float 
+        OPTIONS+=-fsigned-char 
       endif
     endif
   endif
@@ -252,7 +252,6 @@ ifeq ($(OSARCH),SunOS)
   ID=/usr/xpg4/bin/id
 endif
 
-INCLUDE+=-Iinclude -I../include
 ASTCFLAGS+=-pipe  -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(DEBUG) $(INCLUDE) #-DMAKE_VALGRIND_HAPPY
 ASTCFLAGS+=$(OPTIMIZE)
 
@@ -366,9 +365,9 @@ ifeq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/dlfcn.h),)
 endif
 
 ifeq ($(OSARCH),Linux)
-  LIBS+=-ldl -lpthread -lncurses -lm -lresolv  #-lnjamd
+  LIBS+=-ldl -lpthread $(EDITLINE_LIBS) -lm -lresolv  #-lnjamd
 else
-  LIBS+=-lncurses -lm
+  LIBS+=$(EDITLINE_LIBS) -lm
 endif
 
 ifeq ($(OSARCH),Darwin)
@@ -396,11 +395,11 @@ ifeq ($(OSARCH),FreeBSD)
 endif
 
 ifeq ($(OSARCH),NetBSD)
-  LIBS+=-lpthread -lcrypto -lm -L$(CROSS_COMPILE_TARGET)/usr/pkg/lib -lncurses
+  LIBS+=-lpthread -lcrypto -lm -L$(CROSS_COMPILE_TARGET)/usr/pkg/lib $(EDITLINE_LIBS)
 endif
 
 ifeq ($(OSARCH),OpenBSD)
-  LIBS+=-lcrypto -lpthread -lm -lncurses
+  LIBS+=-lcrypto -lpthread -lm $(EDITLINE_LIBS)
 endif
 
 ifeq ($(OSARCH),SunOS)
@@ -411,7 +410,7 @@ ifeq ($(OSARCH),SunOS)
 endif
 
 ifeq ($(MAKETOPLEVEL),$(MAKELEVEL))
-  CFLAGS+=$(ASTCFLAGS) $(TOPDIR_CFLAGS)
+  CFLAGS+=$(TOPDIR_CFLAGS) $(ASTCFLAGS)
 endif
 
 # This is used when generating the doxygen documentation
@@ -432,12 +431,12 @@ _all: all
        @echo " +               make install                +"  
        @echo " +-------------------------------------------+"  
 
-all: include/autoconfig.h menuselect.makeopts cleantest depend asterisk subdirs
+all: config.status menuselect.makeopts cleantest depend asterisk subdirs
 
 configure:
        -@./bootstrap.sh
 
-include/autoconfig.h: configure
+config.status: configure
        @CFLAGS="" ./configure
        @echo "****"
        @echo "**** The configure script was just executed, so 'make' needs to be"
@@ -465,10 +464,10 @@ all: TAGS
 endif
 
 editline/config.h:
-       cd editline && unset CFLAGS LIBS && ./configure ; \
+       cd editline && unset CFLAGS LIBS && CFLAGS="$(OPTIMIZE)" ./configure ; \
 
 editline/libedit.a:
-       cd editline && unset CFLAGS LIBS && test -f config.h || ./configure
+       cd editline && unset CFLAGS LIBS && test -f config.h || CFLAGS="$(OPTIMIZE)" ./configure
        $(MAKE) -C editline libedit.a
 
 db1-ast/libdb1.a:
@@ -483,10 +482,10 @@ ifneq ($(wildcard .tags-depend),)
 endif
 
 ast_expr2.c:
-       bison -d --name-prefix=ast_yy ast_expr2.y -o ast_expr2.c
+       bison -o $@ -d --name-prefix=ast_yy ast_expr2.y
 
 ast_expr2f.c:
-       flex --full ast_expr2.fl
+       flex -o $@ --full ast_expr2.fl
 
 testexpr2: ast_expr2f.c ast_expr2.c ast_expr2.h
        gcc -g -c -DSTANDALONE ast_expr2f.c
@@ -545,8 +544,8 @@ muted: muted.o
 
 subdirs: 
        for x in $(MOD_SUBDIRS); do CFLAGS="$(ASTCFLAGS) $(MOD_SUBDIR_CFLAGS)" $(MAKE) -C $$x || exit 1 ; done
-       CFLAGS="$(ASTCFLAGS)" $(MAKE) -C utils
-       CFLAGS="$(ASTCFLAGS) -include ../include/autoconfig.h" $(MAKE) -C agi
+       CFLAGS="$(ASTCFLAGS) $(OTHER_SUBDIR_CFLAGS)" $(MAKE) -C utils
+       CFLAGS="$(ASTCFLAGS) $(OTHER_SUBDIR_CFLAGS)" $(MAKE) -C agi
 
 clean-depend:
        for x in $(SUBDIRS); do $(MAKE) -C $$x clean-depend || exit 1 ; done
@@ -580,7 +579,7 @@ datafiles: all
 # improved a lot.  I'll put it here for now.
        mkdir -p $(DESTDIR)$(ASTDATADIR)/static-http
        for x in static-http/*; do \
-               install -m 644 $$x $(DESTDIR)$(ASTDATADIR)/static-http ; \
+               $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/static-http ; \
        done
        mkdir -p $(DESTDIR)$(ASTDATADIR)/sounds/digits
        mkdir -p $(DESTDIR)$(ASTDATADIR)/sounds/priv-callerintros
@@ -885,14 +884,32 @@ mpg123:
        $(MAKE) -C mpg123-0.59r $(MPG123TARG)
 
 config:
-       if [ -d /etc/rc.d/init.d ]; then \
-               $(INSTALL) -m 755 contrib/init.d/rc.redhat.asterisk /etc/rc.d/init.d/asterisk; \
-               /sbin/chkconfig --add asterisk; \
-       elif [ -d /etc/init.d ]; then \
-               $(INSTALL) -m 755 init.asterisk /etc/init.d/asterisk; \
-       fi 
+       @if [ "${OSARCH}" = "Linux" ]; then \
+               if [ -f /etc/redhat-release -o -f /etc/fedora-release ]; then \
+                       $(INSTALL) -m 755 contrib/init.d/rc.redhat.asterisk /etc/rc.d/init.d/asterisk; \
+                       /sbin/chkconfig --add asterisk; \
+               elif [ -f /etc/debian_version ]; then \
+                       $(INSTALL) -m 755 contrib/init.d/rc.debian.asterisk /etc/init.d/asterisk; \
+                       /usr/sbin/update-rc.d asterisk start 10 2 3 4 5 . stop 91 2 3 4 5 .; \
+               elif [ -f /etc/gentoo-release ]; then \
+                       $(INSTALL) -m 755 contrib/init.d/rc.gentoo.asterisk /etc/init.d/asterisk; \
+                       /sbin/rc-update add asterisk default; \
+               elif [ -f /etc/mandrake-release ]; then \
+                       $(INSTALL) -m 755 contrib/init.d/rc.mandrake.asterisk /etc/rc.d/init.d/asterisk; \
+                       /sbin/chkconfig --add asterisk; \
+               elif [ -f /etc/SuSE-release -o -f /etc/novell-release ]; then \
+                       $(INSTALL) -m 755 contrib/init.d/rc.suse.asterisk /etc/init.d/asterisk; \
+                       /sbin/chkconfig --add asterisk; \
+               elif [ -f /etc/slackware-version ]; then \
+                       echo "Slackware is not currently supported, although an init script does exist for it." \
+               else \
+                       echo "We could not install init scripts for your distribution."; \
+               fi \
+       else \
+               echo "We could not install init scripts for your operating system."; \
+       fi
 
-dont-optimize: install
+dont-optimize: _all
 
 valgrind: dont-optimize