Cleanup indications on exit.
[asterisk/asterisk.git] / Makefile
index 9038aa8..5788322 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
 #
-# Asterisk -- A telephony toolkit for Linux.
+# Asterisk -- An open source telephony toolkit.
 #
 # Top level Makefile
 #
@@ -66,12 +66,12 @@ export ASTCONFPATH
 export ASTKEYDIR
 
 export OSARCH             # Operating system
-export PROC               # Processor type
 
 export NOISY_BUILD        # Used in Makefile.rules
 export MENUSELECT_CFLAGS  # Options selected in menuselect.
 export AST_DEVMODE        # Set to "yes" for additional compiler
                           # and runtime checks
+export AST_DEVMODE_STRICT # Enables shadow warnings (-Wshadow)
 
 export _SOLINK            # linker flags for all shared objects
 export SOLINK             # linker flags for loadable modules
@@ -96,6 +96,7 @@ export MD5
 export WGET_EXTRA_ARGS
 export LDCONFIG
 export LDCONFIG_FLAGS
+export PYTHON
 
 # even though we could use '-include makeopts' here, use a wildcard
 # lookup anyway, so that make won't try to build makeopts if it doesn't
@@ -169,36 +170,6 @@ OTHER_SUBDIR_CFLAGS="-I$(ASTTOPDIR)/include"
 OPTIONS=
 
 ifeq ($(OSARCH),linux-gnu)
-  ifeq ($(PROC),x86_64)
-    # You must have GCC 3.4 to use k8, otherwise use athlon
-    PROC=k8
-    #PROC=athlon
-  endif
-
-  ifeq ($(PROC),sparc64)
-    #The problem with sparc is the best stuff is in newer versions of gcc (post 3.0) only.
-    #This works for even old (2.96) versions of gcc and provides a small boost either way.
-    #A ultrasparc cpu is really v9 but the stock debian stable 3.0 gcc doesn't support it.
-    #So we go lowest common available by gcc and go a step down, still a step up from
-    #the default as we now have a better instruction set to work with. - Belgarath
-    PROC=ultrasparc
-    OPTIONS+=$(shell if $(CC) -mtune=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-mtune=$(PROC)"; fi)
-    OPTIONS+=$(shell if $(CC) -mcpu=v8 -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-mcpu=v8"; fi)
-    OPTIONS+=-fomit-frame-pointer
-  endif
-
-  ifeq ($(PROC),arm)
-    # The Cirrus logic is the only heavily shipping arm processor with a real floating point unit
-    ifeq ($(SUB_PROC),maverick)
-      OPTIONS+=-fsigned-char -mcpu=ep9312
-    else
-      ifeq ($(SUB_PROC),xscale)
-        OPTIONS+=-fsigned-char -mcpu=xscale
-      else
-        OPTIONS+=-fsigned-char
-      endif
-    endif
-  endif
   # flag to tell 'ldconfig' to only process specified directories
   LDCONFIG_FLAGS=-n
 endif
@@ -213,7 +184,7 @@ ifeq ($(findstring -Wall,$(_ASTCFLAGS) $(ASTCFLAGS)),)
   _ASTCFLAGS+=-Wall
 endif
 
-_ASTCFLAGS+=-Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(DEBUG)
+_ASTCFLAGS+=-Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(AST_NESTED_FUNCTIONS) $(DEBUG)
 ADDL_TARGETS=
 
 ifeq ($(AST_DEVMODE),yes)
@@ -221,9 +192,13 @@ ifeq ($(AST_DEVMODE),yes)
   _ASTCFLAGS+=-Wunused
   _ASTCFLAGS+=$(AST_DECLARATION_AFTER_STATEMENT)
   _ASTCFLAGS+=$(AST_FORTIFY_SOURCE)
+  _ASTCFLAGS+=$(AST_TRAMPOLINES)
   _ASTCFLAGS+=-Wundef
   _ASTCFLAGS+=-Wmissing-format-attribute
   _ASTCFLAGS+=-Wformat=2
+  ifeq ($(AST_DEVMODE_STRICT),yes)
+    _ASTCFLAGS+=-Wshadow
+  endif
   ADDL_TARGETS+=validate-docs
 endif
 
@@ -231,26 +206,7 @@ ifneq ($(findstring BSD,$(OSARCH)),)
   _ASTCFLAGS+=-isystem /usr/local/include
 endif
 
-ifeq ($(findstring -march,$(_ASTCFLAGS) $(ASTCFLAGS)),)
-  ifneq ($(AST_MARCH_NATIVE),)
-    _ASTCFLAGS+=$(AST_MARCH_NATIVE)
-  else
-    ifneq ($(PROC),ultrasparc)
-      _ASTCFLAGS+=$(shell if $(CC) -march=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-march=$(PROC)"; fi)
-    endif
-  endif
-endif
-
-ifeq ($(PROC),ppc)
-  _ASTCFLAGS+=-fsigned-char
-endif
-
 ifeq ($(OSARCH),FreeBSD)
-  ifeq ($(findstring -march,$(_ASTCFLAGS) $(ASTCFLAGS)),)
-    ifeq ($(PROC),i386)
-      _ASTCFLAGS+=-march=i686
-    endif
-  endif
   # -V is understood by BSD Make, not by GNU make.
   BSDVERSION=$(shell make -V OSVERSION -f /usr/share/mk/bsd.port.subdir.mk)
   _ASTCFLAGS+=$(shell if test $(BSDVERSION) -lt 500016 ; then echo "-D_THREAD_SAFE"; fi)
@@ -270,7 +226,7 @@ ifeq ($(OSARCH),SunOS)
   _ASTCFLAGS+=-Wcast-align -DSOLARIS -I../include/solaris-compat -I/opt/ssl/include -I/usr/local/ssl/include -D_XPG4_2 -D__EXTENSIONS__
 endif
 
-ASTERISKVERSION:=$(shell GREP=$(GREP) AWK=$(AWK) build_tools/make_version .)
+ASTERISKVERSION:=$(shell GREP=$(GREP) AWK=$(AWK) GIT=$(GIT) build_tools/make_version .)
 
 ifneq ($(wildcard .version),)
   ASTERISKVERSIONNUM:=$(shell $(AWK) -F. '{printf "%01d%02d%02d", $$1, $$2, $$3}' .version)
@@ -336,13 +292,6 @@ else
 SUBMAKE:=$(MAKE) --quiet --no-print-directory
 endif
 
-# This is used when generating the doxygen documentation
-ifneq ($(DOT),:)
-  HAVEDOT=yes
-else
-  HAVEDOT=no
-endif
-
 # $(MAKE) is printed in several places, and we want it to be a
 # fixed size string. Define a variable whose name has also the
 # same size, so we can easily align text.
@@ -360,13 +309,29 @@ all: _cleantest_all
        @echo " +               $(mK) install               +"
        @echo " +-------------------------------------------+"
 
+full: _cleantest_all_full
+       @echo " +--------- Asterisk Build Complete ---------+"
+       @echo " + Asterisk has successfully been built, and +"
+       @echo " + can be installed by running:              +"
+       @echo " +                                           +"
+       @echo " +               $(mK) install               +"
+       @echo " +-------------------------------------------+"
+
+
 # For parallel builds, we must call cleantest *before* running the
 # other dependencies on _all.
 _cleantest_all: cleantest
        @$(MAKE) _all
 
+# For parallel builds, we must call cleantest *before* running the
+# other dependencies on _all.
+_cleantest_all_full: cleantest
+       @$(MAKE) _all_full
+
 _all: makeopts $(SUBDIRS) doc/core-en_US.xml $(ADDL_TARGETS)
 
+_all_full: makeopts $(SUBDIRS) doc/full-en_US.xml $(ADDL_TARGETS)
+
 makeopts: configure
        @echo "****"
        @echo "**** The configure script must be executed before running '$(MAKE)'."
@@ -458,6 +423,8 @@ _clean:
        rm -f defaults.h
        rm -f include/asterisk/build.h
        rm -f main/version.c
+       rm -f doc/core-en_US.xml
+       rm -f doc/full-en_US.xml
        @$(MAKE) -C menuselect clean
        cp -f .cleancount .lastclean
 
@@ -510,6 +477,27 @@ doc/core-en_US.xml: $(foreach dir,$(MOD_SUBDIRS),$(shell $(GREP) -l "language=\"
        @echo
        @echo "</docs>" >> $@
 
+doc/full-en_US.xml: $(foreach dir,$(MOD_SUBDIRS),$(shell $(GREP) -l "language=\"en_US\"" $(dir)/*.c $(dir)/*.cc 2>/dev/null))
+ifeq ($(PYTHON),:)
+       @echo "--------------------------------------------------------------------------"
+       @echo "---        Please install python to build full documentation           ---"
+       @echo "--------------------------------------------------------------------------"
+else
+       @printf "Building Documentation For: "
+       @echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > $@
+       @echo "<!DOCTYPE docs SYSTEM \"appdocsxml.dtd\">" >> $@
+       @echo "<docs xmlns:xi=\"http://www.w3.org/2001/XInclude\">" >> $@
+       @for x in $(MOD_SUBDIRS); do \
+               printf "$$x " ; \
+               for i in $$x/*.c; do \
+                       $(PYTHON) build_tools/get_documentation.py < $$i >> $@ ; \
+               done ; \
+       done
+       @echo
+       @echo "</docs>" >> $@
+       @$(PYTHON) build_tools/post_process_documentation.py -i $@ -o "doc/core-en_US.xml"
+endif
+
 validate-docs: doc/core-en_US.xml
 ifeq ($(XMLSTARLET)$(XMLLINT),::)
        @echo "--------------------------------------------------------------------------"
@@ -542,40 +530,23 @@ update:
 
 NEWHEADERS=$(notdir $(wildcard include/asterisk/*.h))
 OLDHEADERS=$(filter-out $(NEWHEADERS) $(notdir $(DESTDIR)$(ASTHEADERDIR)),$(notdir $(wildcard $(DESTDIR)$(ASTHEADERDIR)/*.h)))
+INSTALLDIRS="$(ASTLIBDIR)" "$(ASTMODDIR)" "$(ASTSBINDIR)" "$(ASTETCDIR)" "$(ASTVARRUNDIR)" \
+       "$(ASTSPOOLDIR)" "$(ASTSPOOLDIR)/dictate" "$(ASTSPOOLDIR)/meetme" \
+       "$(ASTSPOOLDIR)/monitor" "$(ASTSPOOLDIR)/system" "$(ASTSPOOLDIR)/tmp" \
+       "$(ASTSPOOLDIR)/voicemail" "$(ASTHEADERDIR)" "$(ASTHEADERDIR)/doxygen" \
+       "$(ASTLOGDIR)" "$(ASTLOGDIR)/cdr-csv" "$(ASTLOGDIR)/cdr-custom" \
+       "$(ASTLOGDIR)/cel-custom" "$(ASTDATADIR)" "$(ASTDATADIR)/documentation" \
+       "$(ASTDATADIR)/documentation/thirdparty" "$(ASTDATADIR)/firmware" \
+       "$(ASTDATADIR)/firmware/iax" "$(ASTDATADIR)/images" "$(ASTDATADIR)/keys" \
+       "$(ASTDATADIR)/phoneprov" "$(ASTDATADIR)/static-http" "$(ASTDATADIR)/sounds" \
+       "$(ASTDATADIR)/moh" "$(ASTMANDIR)/man8" "$(AGI_DIR)" "$(ASTDBDIR)"
 
 installdirs:
-       $(INSTALL) -d "$(DESTDIR)$(ASTLIBDIR)"
-       $(INSTALL) -d "$(DESTDIR)$(ASTMODDIR)"
-       $(INSTALL) -d "$(DESTDIR)$(ASTSBINDIR)"
-       $(INSTALL) -d "$(DESTDIR)$(ASTETCDIR)"
-       $(INSTALL) -d "$(DESTDIR)$(ASTVARRUNDIR)"
-       $(INSTALL) -d "$(DESTDIR)$(ASTSPOOLDIR)"
-       $(INSTALL) -d "$(DESTDIR)$(ASTSPOOLDIR)/dictate"
-       $(INSTALL) -d "$(DESTDIR)$(ASTSPOOLDIR)/meetme"
-       $(INSTALL) -d "$(DESTDIR)$(ASTSPOOLDIR)/monitor"
-       $(INSTALL) -d "$(DESTDIR)$(ASTSPOOLDIR)/system"
-       $(INSTALL) -d "$(DESTDIR)$(ASTSPOOLDIR)/tmp"
-       $(INSTALL) -d "$(DESTDIR)$(ASTSPOOLDIR)/voicemail"
-       $(INSTALL) -d "$(DESTDIR)$(ASTHEADERDIR)"
-       $(INSTALL) -d "$(DESTDIR)$(ASTHEADERDIR)/doxygen"
-       $(INSTALL) -d "$(DESTDIR)$(ASTLOGDIR)"
-       $(INSTALL) -d "$(DESTDIR)$(ASTLOGDIR)/cdr-csv"
-       $(INSTALL) -d "$(DESTDIR)$(ASTLOGDIR)/cdr-custom"
-       $(INSTALL) -d "$(DESTDIR)$(ASTLOGDIR)/cel-custom"
-       $(INSTALL) -d "$(DESTDIR)$(ASTDATADIR)"
-       $(INSTALL) -d "$(DESTDIR)$(ASTDATADIR)/documentation"
-       $(INSTALL) -d "$(DESTDIR)$(ASTDATADIR)/documentation/thirdparty"
-       $(INSTALL) -d "$(DESTDIR)$(ASTDATADIR)/firmware"
-       $(INSTALL) -d "$(DESTDIR)$(ASTDATADIR)/firmware/iax"
-       $(INSTALL) -d "$(DESTDIR)$(ASTDATADIR)/images"
-       $(INSTALL) -d "$(DESTDIR)$(ASTDATADIR)/keys"
-       $(INSTALL) -d "$(DESTDIR)$(ASTDATADIR)/phoneprov"
-       $(INSTALL) -d "$(DESTDIR)$(ASTDATADIR)/static-http"
-       $(INSTALL) -d "$(DESTDIR)$(ASTDATADIR)/sounds"
-       $(INSTALL) -d "$(DESTDIR)$(ASTDATADIR)/moh"
-       $(INSTALL) -d "$(DESTDIR)$(ASTMANDIR)/man8"
-       $(INSTALL) -d "$(DESTDIR)$(AGI_DIR)"
-       $(INSTALL) -d "$(DESTDIR)$(ASTDBDIR)"
+       @for i in $(INSTALLDIRS); do \
+               if [ ! -z "$${i}" -a ! -d "$(DESTDIR)$${i}" ]; then \
+                       $(INSTALL) -d "$(DESTDIR)$${i}"; \
+               fi; \
+       done
 
 main-bininstall:
        +@DESTDIR="$(DESTDIR)" ASTSBINDIR="$(ASTSBINDIR)" ASTLIBDIR="$(ASTLIBDIR)" $(SUBMAKE) -C main bininstall
@@ -712,6 +683,7 @@ samples: adsi
                        -e 's|^astspooldir.*$$|astspooldir => $(ASTSPOOLDIR)|' \
                        -e 's|^astrundir.*$$|astrundir => $(ASTVARRUNDIR)|' \
                        -e 's|^astlogdir.*$$|astlogdir => $(ASTLOGDIR)|' \
+                       -e 's|^astsbindir.*$$|astsbindir => $(ASTSBINDIR)|' \
                        "$(DESTDIR)$(ASTCONFPATH)" > "$(DESTDIR)$(ASTCONFPATH).tmp" ; \
                $(INSTALL) -m 644 "$(DESTDIR)$(ASTCONFPATH).tmp" "$(DESTDIR)$(ASTCONFPATH)" ; \
                rm -f "$(DESTDIR)$(ASTCONFPATH).tmp" ; \
@@ -764,8 +736,29 @@ webvmail:
        @echo " +-------------------------------------------+"
 
 progdocs:
-       (cat contrib/asterisk-ng-doxygen; echo "HAVE_DOT=$(HAVEDOT)"; \
-       echo "PROJECT_NUMBER=$(ASTERISKVERSION)") | doxygen -
+       # Note, Makefile conditionals must not be tabbed out. Wasted hours with that.
+ifeq ($(DOXYGEN),:)
+       @echo "Doxygen is not installed.  Please install and re-run the configuration script."
+else
+ifeq ($(DOT),:)
+       @echo "DOT is not installed. Doxygen will not produce any diagrams. Please install and re-run the configuration script."
+else
+       # Enable DOT
+       @echo "HAVE_DOT = YES" >> contrib/asterisk-ng-doxygen
+endif
+       # Set Doxygen PROJECT_NUMBER variable
+ifneq ($(ASTERISKVERSION),UNKNOWN__and_probably_unsupported)
+       @echo "PROJECT_NUMBER = $(ASTERISKVERSION)" >> contrib/asterisk-ng-doxygen
+else
+       echo "Asterisk Version is unknown, not configuring Doxygen PROJECT_NUMBER."
+endif
+       # Validate Doxygen Configuration
+       @doxygen -u contrib/asterisk-ng-doxygen
+       # Run Doxygen
+       @doxygen contrib/asterisk-ng-doxygen
+       # Remove configuration backup file
+       @rm -f contrib/asterisk-ng-doxygen.bak
+endif
 
 install-logrotate:
        if [ ! -d "$(DESTDIR)$(ASTETCDIR)/../logrotate.d" ]; then \
@@ -930,7 +923,9 @@ nmenuselect: menuselect/nmenuselect menuselect-tree menuselect.makeopts
        -@menuselect/nmenuselect menuselect.makeopts && (echo "menuselect changes saved!"; rm -f channels/h323/Makefile.ast main/asterisk) || echo "menuselect changes NOT saved!"
 
 # options for make in menuselect/
-MAKE_MENUSELECT=CC="$(BUILD_CC)" CXX="" LD="" AR="" RANLIB="" CFLAGS="" $(MAKE) -C menuselect CONFIGURE_SILENT="--silent"
+MAKE_MENUSELECT=CC="$(BUILD_CC)" CXX="" LD="" AR="" RANLIB="" \
+               CFLAGS="$(BUILD_CFLAGS)" LDFLAGS="$(BUILD_LDFLAGS)" \
+               $(MAKE) -C menuselect CONFIGURE_SILENT="--silent"
 
 menuselect/menuselect: menuselect/makeopts
        +$(MAKE_MENUSELECT) menuselect