Merge "pjproject_bundled: Add MALLOC_DEBUG capability"
[asterisk/asterisk.git] / Makefile
index 5bc6570..992e1d3 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -100,7 +100,10 @@ export LDCONFIG
 export LDCONFIG_FLAGS
 export PYTHON
 
--include makeopts
+# makeopts is required unless the goal is clean or distclean
+ifeq ($(findstring clean,$(MAKECMDGOALS)),)
+include makeopts
+endif
 
 # start the primary CFLAGS and LDFLAGS with any that were provided
 # to the configure script
@@ -246,7 +249,7 @@ endif
 
 _ASTCFLAGS+=$(OPTIONS)
 
-MOD_SUBDIRS:=channels pbx apps codecs formats cdr cel bridges funcs tests main res addons $(LOCAL_MOD_SUBDIRS)
+MOD_SUBDIRS:=third-party channels pbx apps codecs formats cdr cel bridges funcs tests main res addons $(LOCAL_MOD_SUBDIRS)
 OTHER_SUBDIRS:=utils agi contrib
 SUBDIRS:=$(OTHER_SUBDIRS) $(MOD_SUBDIRS)
 SUBDIRS_INSTALL:=$(SUBDIRS:%=%-install)
@@ -374,8 +377,10 @@ ifeq ($(findstring $(OSARCH), mingw32 cygwin ),)
     # directories containing them must be completed before the main Asterisk
     # binary can be built.
     # If MENUSELECT_EMBED is empty, we don't need this and allow 'main' to be
-    # be built without building all dependencies first.
+    # be built with only third_party first.
 main: $(filter-out main,$(MOD_SUBDIRS))
+  else
+main: third-party
   endif
 else
     # Windows: we need to build main (i.e. the asterisk dll) first,
@@ -399,7 +404,7 @@ defaults.h: makeopts .lastclean build_tools/make_defaults_h
        @cmp -s $@.tmp $@ || mv $@.tmp $@
        @rm -f $@.tmp
 
-main/version.c: FORCE .lastclean
+main/version.c: FORCE menuselect.makeopts .lastclean
        @build_tools/make_version_c > $@.tmp
        @cmp -s $@.tmp $@ || mv $@.tmp $@
        @rm -f $@.tmp
@@ -486,7 +491,7 @@ doc/core-en_US.xml: makeopts .lastclean $(XML_core_en_US)
        @printf "Building Documentation For: "
        @echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > $@
        @echo "<!DOCTYPE docs SYSTEM \"appdocsxml.dtd\">" >> $@
-       @echo "<?xml-stylesheet type=\"text/xsl\" href=\"appdocsxml.xslt\"?>" > $@
+       @echo "<?xml-stylesheet type=\"text/xsl\" href=\"appdocsxml.xslt\"?>" >> $@
        @echo "<docs xmlns:xi=\"http://www.w3.org/2001/XInclude\">" >> $@
        @for x in $(MOD_SUBDIRS); do \
                printf "$$x " ; \
@@ -510,7 +515,7 @@ else
        @printf "Building Documentation For: "
        @echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > $@
        @echo "<!DOCTYPE docs SYSTEM \"appdocsxml.dtd\">" >> $@
-       @echo "<?xml-stylesheet type=\"text/xsl\" href=\"appdocsxml.xslt\"?>" > $@
+       @echo "<?xml-stylesheet type=\"text/xsl\" href=\"appdocsxml.xslt\"?>" >> $@
        @echo "<docs xmlns:xi=\"http://www.w3.org/2001/XInclude\">" >> $@
        @for x in $(MOD_SUBDIRS); do \
                printf "$$x " ; \
@@ -565,7 +570,8 @@ INSTALLDIRS="$(ASTLIBDIR)" "$(ASTMODDIR)" "$(ASTSBINDIR)" "$(ASTETCDIR)" "$(ASTV
        "$(ASTDATADIR)/documentation/thirdparty" "$(ASTDATADIR)/firmware" \
        "$(ASTDATADIR)/firmware/iax" "$(ASTDATADIR)/images" "$(ASTDATADIR)/keys" \
        "$(ASTDATADIR)/phoneprov" "$(ASTDATADIR)/rest-api" "$(ASTDATADIR)/static-http" \
-       "$(ASTDATADIR)/sounds" "$(ASTDATADIR)/moh" "$(ASTMANDIR)/man8" "$(AGI_DIR)" "$(ASTDBDIR)"
+       "$(ASTDATADIR)/sounds" "$(ASTDATADIR)/moh" "$(ASTMANDIR)/man8" "$(AGI_DIR)" "$(ASTDBDIR)" \
+       "$(ASTDATADIR)/third-party"
 
 installdirs:
        @for i in $(INSTALLDIRS); do \
@@ -608,13 +614,14 @@ ifeq ($(HAVE_DAHDI),1)
 endif
 
 $(SUBDIRS_INSTALL):
-       +@DESTDIR="$(DESTDIR)" ASTSBINDIR="$(ASTSBINDIR)" $(SUBMAKE) -C $(@:-install=) install
+       +@DESTDIR="$(DESTDIR)" ASTSBINDIR="$(ASTSBINDIR)" ASTDATADIR="$(ASTDATADIR)" $(SUBMAKE) -C $(@:-install=) install
 
 NEWMODS:=$(foreach d,$(MOD_SUBDIRS),$(notdir $(wildcard $(d)/*.so)))
 OLDMODS=$(filter-out $(NEWMODS) $(notdir $(DESTDIR)$(ASTMODDIR)),$(notdir $(wildcard $(DESTDIR)$(ASTMODDIR)/*.so)))
+BADMODS=$(strip $(filter-out $(shell ./build_tools/list_valid_installed_externals),$(OLDMODS)))
 
 oldmodcheck:
-       @if [ -n "$(OLDMODS)" ]; then \
+       @if [ -n "$(BADMODS)" ]; then \
                echo " WARNING WARNING WARNING" ;\
                echo "" ;\
                echo " Your Asterisk modules directory, located at" ;\
@@ -624,7 +631,7 @@ oldmodcheck:
                echo " modules are compatible with this version before" ;\
                echo " attempting to run Asterisk." ;\
                echo "" ;\
-               for f in $(OLDMODS); do \
+               for f in $(BADMODS); do \
                        echo "    $$f" ;\
                done ;\
                echo "" ;\
@@ -818,60 +825,56 @@ install-logrotate:
        rm -f contrib/scripts/asterisk.logrotate.tmp
 
 config:
-       @if [ "${OSARCH}" = "linux-gnu" -o "${OSARCH}" = "kfreebsd-gnu" ]; then \
-               if [ -f /etc/redhat-release -o -f /etc/fedora-release ]; then \
-                       ./build_tools/install_subst contrib/init.d/rc.redhat.asterisk  "$(DESTDIR)/etc/rc.d/init.d/asterisk"; \
-                       if [ ! -f "$(DESTDIR)/etc/sysconfig/asterisk" ] ; then \
-                               $(INSTALL) -m 644 contrib/init.d/etc_default_asterisk "$(DESTDIR)/etc/sysconfig/asterisk" ; \
-                       fi ; \
-                       if [ -z "$(DESTDIR)" ] ; then \
-                               /sbin/chkconfig --add asterisk ; \
-                       fi ; \
-               elif [ -f /etc/debian_version ] ; then \
-                       ./build_tools/install_subst contrib/init.d/rc.debian.asterisk  "$(DESTDIR)/etc/init.d/asterisk"; \
-                       if [ ! -f "$(DESTDIR)/etc/default/asterisk" ] ; then \
-                               $(INSTALL) -m 644 contrib/init.d/etc_default_asterisk "$(DESTDIR)/etc/default/asterisk" ; \
-                       fi ; \
-                       if [ -z "$(DESTDIR)" ] ; then \
-                               /usr/sbin/update-rc.d asterisk defaults 50 91 ; \
-                       fi ; \
-               elif [ -f /etc/gentoo-release ] ; then \
-                       ./build_tools/install_subst contrib/init.d/rc.gentoo.asterisk  "$(DESTDIR)/etc/init.d/asterisk"; \
-                       if [ -z "$(DESTDIR)" ] ; then \
-                               /sbin/rc-update add asterisk default ; \
-                       fi ; \
-               elif [ -f /etc/mandrake-release -o -f /etc/mandriva-release ] ; then \
-                       ./build_tools/install_subst contrib/init.d/rc.mandriva.asterisk  "$(DESTDIR)/etc/rc.d/init.d/asterisk"; \
-                       if [ ! -f /etc/sysconfig/asterisk ] ; then \
-                               $(INSTALL) -m 644 contrib/init.d/etc_default_asterisk "$(DESTDIR)/etc/sysconfig/asterisk" ; \
-                       fi ; \
-                       if [ -z "$(DESTDIR)" ] ; then \
-                               /sbin/chkconfig --add asterisk ; \
-                       fi ; \
-               elif [ -f /etc/SuSE-release -o -f /etc/novell-release ] ; then \
-                       ./build_tools/install_subst contrib/init.d/rc.suse.asterisk  "$(DESTDIR)/etc/init.d/asterisk"; \
-                       if [ ! -f /etc/sysconfig/asterisk ] ; then \
-                               $(INSTALL) -m 644 contrib/init.d/etc_default_asterisk "$(DESTDIR)/etc/sysconfig/asterisk" ; \
-                       fi ; \
-                       if [ -z "$(DESTDIR)" ] ; then \
-                               /sbin/chkconfig --add asterisk ; \
-                       fi ; \
-               elif [ -f /etc/arch-release -o -f /etc/arch-release ] ; then \
-                       ./build_tools/install_subst contrib/init.d/rc.archlinux.asterisk  "$(DESTDIR)/etc/init.d/asterisk"; \
-               elif [ -d "$(DESTDIR)/Library/LaunchDaemons" ]; then \
-                       if [ ! -f "$(DESTDIR)/Library/LaunchDaemons/org.asterisk.asterisk.plist" ]; then \
-                               ./build_tools/install_subst contrib/init.d/org.asterisk.asterisk.plist "$(DESTDIR)/Library/LaunchDaemons/org.asterisk.asterisk.plist"; \
-                       fi; \
-                       if [ ! -f "$(DESTDIR)/Library/LaunchDaemons/org.asterisk.muted.plist" ]; then \
-                               ./build_tools/install_subst contrib/init.d/org.asterisk.muted.plist "$(DESTDIR)/Library/LaunchDaemons/org.asterisk.muted.plist"; \
-                       fi; \
-               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 \
+       @if [ -f /etc/redhat-release -o -f /etc/fedora-release ]; then \
+               ./build_tools/install_subst contrib/init.d/rc.redhat.asterisk  "$(DESTDIR)/etc/rc.d/init.d/asterisk"; \
+               if [ ! -f "$(DESTDIR)/etc/sysconfig/asterisk" ] ; then \
+                       $(INSTALL) -m 644 contrib/init.d/etc_default_asterisk "$(DESTDIR)/etc/sysconfig/asterisk" ; \
+               fi ; \
+               if [ -z "$(DESTDIR)" ] ; then \
+                       /sbin/chkconfig --add asterisk ; \
+               fi ; \
+       elif [ -f /etc/debian_version ] ; then \
+               ./build_tools/install_subst contrib/init.d/rc.debian.asterisk  "$(DESTDIR)/etc/init.d/asterisk"; \
+               if [ ! -f "$(DESTDIR)/etc/default/asterisk" ] ; then \
+                       $(INSTALL) -m 644 contrib/init.d/etc_default_asterisk "$(DESTDIR)/etc/default/asterisk" ; \
+               fi ; \
+               if [ -z "$(DESTDIR)" ] ; then \
+                       /usr/sbin/update-rc.d asterisk defaults 50 91 ; \
+               fi ; \
+       elif [ -f /etc/gentoo-release ] ; then \
+               ./build_tools/install_subst contrib/init.d/rc.gentoo.asterisk  "$(DESTDIR)/etc/init.d/asterisk"; \
+               if [ -z "$(DESTDIR)" ] ; then \
+                       /sbin/rc-update add asterisk default ; \
+               fi ; \
+       elif [ -f /etc/mandrake-release -o -f /etc/mandriva-release ] ; then \
+               ./build_tools/install_subst contrib/init.d/rc.mandriva.asterisk  "$(DESTDIR)/etc/rc.d/init.d/asterisk"; \
+               if [ ! -f /etc/sysconfig/asterisk ] ; then \
+                       $(INSTALL) -m 644 contrib/init.d/etc_default_asterisk "$(DESTDIR)/etc/sysconfig/asterisk" ; \
+               fi ; \
+               if [ -z "$(DESTDIR)" ] ; then \
+                       /sbin/chkconfig --add asterisk ; \
+               fi ; \
+       elif [ -f /etc/SuSE-release -o -f /etc/novell-release ] ; then \
+               ./build_tools/install_subst contrib/init.d/rc.suse.asterisk  "$(DESTDIR)/etc/init.d/asterisk"; \
+               if [ ! -f /etc/sysconfig/asterisk ] ; then \
+                       $(INSTALL) -m 644 contrib/init.d/etc_default_asterisk "$(DESTDIR)/etc/sysconfig/asterisk" ; \
+               fi ; \
+               if [ -z "$(DESTDIR)" ] ; then \
+                       /sbin/chkconfig --add asterisk ; \
+               fi ; \
+       elif [ -f /etc/arch-release -o -f /etc/arch-release ] ; then \
+               ./build_tools/install_subst contrib/init.d/rc.archlinux.asterisk  "$(DESTDIR)/etc/init.d/asterisk"; \
+       elif [ -d "$(DESTDIR)/Library/LaunchDaemons" ]; then \
+               if [ ! -f "$(DESTDIR)/Library/LaunchDaemons/org.asterisk.asterisk.plist" ]; then \
+                       ./build_tools/install_subst contrib/init.d/org.asterisk.asterisk.plist "$(DESTDIR)/Library/LaunchDaemons/org.asterisk.asterisk.plist"; \
+               fi; \
+               if [ ! -f "$(DESTDIR)/Library/LaunchDaemons/org.asterisk.muted.plist" ]; then \
+                       ./build_tools/install_subst contrib/init.d/org.asterisk.muted.plist "$(DESTDIR)/Library/LaunchDaemons/org.asterisk.muted.plist"; \
+               fi; \
+       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 operating system." ; \
+               echo "We could not install init scripts for your distribution." ; \
        fi
 
 sounds:
@@ -886,7 +889,7 @@ sounds:
        @[ -f "$(DESTDIR)$(ASTDBDIR)/astdb.sqlite3" ] || [ ! -f "$(DESTDIR)$(ASTDBDIR)/astdb" ] || [ ! -f menuselect.makeopts ] || grep -q MENUSELECT_UTILS=.*astdb2sqlite3 menuselect.makeopts || (sed -i.orig -e's/MENUSELECT_UTILS=\(.*\)/MENUSELECT_UTILS=\1 astdb2sqlite3/' menuselect.makeopts && echo "Updating menuselect.makeopts to include astdb2sqlite3" && echo "Original version backed up to menuselect.makeopts.orig")
 
 $(SUBDIRS_UNINSTALL):
-       +@$(SUBMAKE) -C $(@:-uninstall=) uninstall
+       +@DESTDIR="$(DESTDIR)" ASTSBINDIR="$(ASTSBINDIR)" ASTDATADIR="$(ASTDATADIR)" $(SUBMAKE) -C $(@:-uninstall=) uninstall
 
 main-binuninstall:
        +@DESTDIR="$(DESTDIR)" ASTSBINDIR="$(ASTSBINDIR)" ASTLIBDIR="$(ASTLIBDIR)" $(SUBMAKE) -C main binuninstall
@@ -978,7 +981,7 @@ menuselect/nmenuselect: menuselect/makeopts .lastclean
 menuselect/makeopts: makeopts .lastclean
        +$(MAKE_MENUSELECT) makeopts
 
-menuselect-tree: $(foreach dir,$(filter-out main,$(MOD_SUBDIRS)),$(wildcard $(dir)/*.c) $(wildcard $(dir)/*.cc)) build_tools/cflags.xml build_tools/cflags-devmode.xml sounds/sounds.xml build_tools/embed_modules.xml utils/utils.xml agi/agi.xml configure makeopts
+menuselect-tree: $(foreach dir,$(filter-out main,$(MOD_SUBDIRS)),$(wildcard $(dir)/*.c) $(wildcard $(dir)/*.cc) $(wildcard $(dir)/*.xml)) build_tools/cflags.xml build_tools/cflags-devmode.xml sounds/sounds.xml build_tools/embed_modules.xml utils/utils.xml agi/agi.xml configure makeopts
        @echo "Generating input for menuselect ..."
        @echo "<?xml version=\"1.0\"?>" > $@
        @echo >> $@
@@ -1009,6 +1012,10 @@ else
                rest-api/resources.json .
 endif
 
+check-alembic: makeopts
+       @find contrib/ast-db-manage/ -name '*.pyc' -delete
+       @ALEMBIC=$(ALEMBIC) build_tools/make_check_alembic config cdr voicemail >&2
+
 .PHONY: menuselect
 .PHONY: main
 .PHONY: sounds
@@ -1030,6 +1037,7 @@ endif
 .PHONY: _clean
 .PHONY: ari-stubs
 .PHONY: basic-pbx
+.PHONY: check-alembic
 .PHONY: $(SUBDIRS_INSTALL)
 .PHONY: $(SUBDIRS_DIST_CLEAN)
 .PHONY: $(SUBDIRS_CLEAN)