Fix how we build pjproject.
authorJason Parker <jparker@digium.com>
Mon, 4 Feb 2013 19:52:14 +0000 (19:52 +0000)
committerJason Parker <jparker@digium.com>
Mon, 4 Feb 2013 19:52:14 +0000 (19:52 +0000)
Allow parallel builds, better tolerate failures, build faster.

This also stops running dependencies before top-level configure has been run.

(closes issue ASTERISK-20815)

Review: https://reviewboard.asterisk.org/r/2292/
........

Merged revisions 380816 from http://svn.asterisk.org/svn/asterisk/branches/11

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@380817 65c4cc65-6c06-0410-ace0-fbb531ad65f3

Makefile
res/Makefile
res/pjproject/aconfigure
res/pjproject/aconfigure.ac
res/pjproject/build/common.mak
res/pjproject/build/os-auto.mak.in

index 26f0081..76e68c4 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -98,12 +98,7 @@ 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
-# exist (other rules will force it to be built if needed)
-ifneq ($(wildcard makeopts),)
-  include makeopts
-endif
+-include makeopts
 
 # start the primary CFLAGS and LDFLAGS with any that were provided
 # to the configure script
@@ -302,7 +297,7 @@ else
        mK=" make"
 endif
 
-all: _cleantest_all
+all: _all
        @echo " +--------- Asterisk Build Complete ---------+"
        @echo " + Asterisk has successfully been built, and +"
        @echo " + can be installed by running:              +"
@@ -310,7 +305,7 @@ all: _cleantest_all
        @echo " +               $(mK) install               +"
        @echo " +-------------------------------------------+"
 
-full: _cleantest_all_full
+full: _full
        @echo " +--------- Asterisk Build Complete ---------+"
        @echo " + Asterisk has successfully been built, and +"
        @echo " + can be installed by running:              +"
@@ -319,19 +314,9 @@ full: _cleantest_all_full
        @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)
+_full: makeopts $(SUBDIRS) doc/full-en_US.xml $(ADDL_TARGETS)
 
 makeopts: configure
        @echo "****"
@@ -366,7 +351,7 @@ makeopts.embed_rules: menuselect.makeopts
        +@$(SUBMAKE) $(MOD_SUBDIRS_EMBED_LDFLAGS)
        +@$(SUBMAKE) $(MOD_SUBDIRS_EMBED_LIBS)
 
-$(SUBDIRS): main/version.c include/asterisk/build.h include/asterisk/buildopts.h defaults.h makeopts.embed_rules
+$(SUBDIRS): makeopts cleantest main/version.c include/asterisk/build.h include/asterisk/buildopts.h defaults.h makeopts.embed_rules
 
 ifeq ($(findstring $(OSARCH), mingw32 cygwin ),)
     # Non-windows:
@@ -386,10 +371,10 @@ $(D1): res
 res:   main
 endif
 
-$(MOD_SUBDIRS):
+$(MOD_SUBDIRS): makeopts
        +@_ASTCFLAGS="$(MOD_SUBDIR_CFLAGS) $(_ASTCFLAGS)" ASTCFLAGS="$(ASTCFLAGS)" _ASTLDFLAGS="$(_ASTLDFLAGS)" ASTLDFLAGS="$(ASTLDFLAGS)" $(SUBMAKE) --no-builtin-rules -C $@ SUBDIR=$@ all
 
-$(OTHER_SUBDIRS):
+$(OTHER_SUBDIRS): makeopts
        +@_ASTCFLAGS="$(OTHER_SUBDIR_CFLAGS) $(_ASTCFLAGS)" ASTCFLAGS="$(ASTCFLAGS)" _ASTLDFLAGS="$(_ASTLDFLAGS)" ASTLDFLAGS="$(ASTLDFLAGS)" $(SUBMAKE) --no-builtin-rules -C $@ SUBDIR=$@ all
 
 defaults.h: makeopts build_tools/make_defaults_h
@@ -443,7 +428,7 @@ distclean: $(SUBDIRS_DIST_CLEAN) _clean
        rm -rf doc/api
        rm -f build_tools/menuselect-deps
 
-datafiles: _cleantest_all doc/core-en_US.xml
+datafiles: _all doc/core-en_US.xml
        CFLAGS="$(_ASTCFLAGS) $(ASTCFLAGS)" build_tools/mkpkgconfig "$(DESTDIR)$(libdir)/pkgconfig";
 # Should static HTTP be installed during make samples or even with its own target ala
 # webvoicemail?  There are portions here that *could* be customized but might also be
@@ -464,7 +449,7 @@ datafiles: _cleantest_all doc/core-en_US.xml
        done
        $(MAKE) -C sounds install
 
-doc/core-en_US.xml: $(foreach dir,$(MOD_SUBDIRS),$(shell $(GREP) -l "language=\"en_US\"" $(dir)/*.c $(dir)/*.cc 2>/dev/null))
+doc/core-en_US.xml: makeopts $(foreach dir,$(MOD_SUBDIRS),$(shell $(GREP) -l "language=\"en_US\"" $(dir)/*.c $(dir)/*.cc 2>/dev/null))
        @printf "Building Documentation For: "
        @echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > $@
        @echo "<!DOCTYPE docs SYSTEM \"appdocsxml.dtd\">" >> $@
@@ -478,7 +463,7 @@ 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))
+doc/full-en_US.xml: makeopts $(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           ---"
@@ -552,7 +537,7 @@ installdirs:
 main-bininstall:
        +@DESTDIR="$(DESTDIR)" ASTSBINDIR="$(ASTSBINDIR)" ASTLIBDIR="$(ASTLIBDIR)" $(SUBMAKE) -C main bininstall
 
-bininstall: _cleantest_all installdirs $(SUBDIRS_INSTALL) main-bininstall
+bininstall: _all installdirs $(SUBDIRS_INSTALL) main-bininstall
        $(INSTALL) -m 755 contrib/scripts/astgenkey "$(DESTDIR)$(ASTSBINDIR)/"
        $(INSTALL) -m 755 contrib/scripts/autosupport "$(DESTDIR)$(ASTSBINDIR)/"
        if [ ! -f "$(DESTDIR)$(ASTSBINDIR)/safe_asterisk" -a ! -f /sbin/launchd ]; then \
@@ -928,19 +913,19 @@ 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
+menuselect/menuselect: menuselect/makeopts cleantest
        +$(MAKE_MENUSELECT) menuselect
 
-menuselect/cmenuselect: menuselect/makeopts
+menuselect/cmenuselect: menuselect/makeopts cleantest
        +$(MAKE_MENUSELECT) cmenuselect
 
-menuselect/gmenuselect: menuselect/makeopts
+menuselect/gmenuselect: menuselect/makeopts cleantest
        +$(MAKE_MENUSELECT) gmenuselect
 
-menuselect/nmenuselect: menuselect/makeopts
+menuselect/nmenuselect: menuselect/makeopts cleantest
        +$(MAKE_MENUSELECT) nmenuselect
 
-menuselect/makeopts: makeopts
+menuselect/makeopts: makeopts cleantest
        +$(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
@@ -968,7 +953,8 @@ menuselect-tree: $(foreach dir,$(filter-out main,$(MOD_SUBDIRS)),$(wildcard $(di
 .PHONY: distclean
 .PHONY: all
 .PHONY: _all
-.PHONY: _cleantest_all
+.PHONY: full
+.PHONY: _full
 .PHONY: prereqs
 .PHONY: cleantest
 .PHONY: uninstall
index 3258867..c4692a6 100644 (file)
@@ -67,21 +67,25 @@ endif
 ael/pval.o: ael/pval.c
 
 clean::
-       $(MAKE) -C pjproject realclean
+       @if [ -f pjproject/build.mak ]; then $(MAKE) -C pjproject realclean; fi
        rm -f snmp/*.o snmp/*.i ael/*.o ael/*.i ais/*.o ais/*.i
 
-pjproject/build.mak:
-       cd pjproject && ./configure AR="" CFLAGS=-fPIC  --disable-floating-point --disable-sound --disable-oss --disable-speex-aec --disable-l16-codec --disable-gsm-codec --disable-g722-codec --disable-g7221-codec --disable-speex-codec --disable-ilbc-codec --disable-g711-codec
+dist-clean::
+       rm -f pjproject/build.mak
 
-.PHONY : pjproject
-pjproject: pjproject/build.mak
-       # Make sure we always build pjproject with a single job.
-       $(MAKE) -j1 -C pjproject dep
-       $(MAKE) -j1 -C pjproject
+pjproject/build.mak: pjproject/aconfigure
+       (cd pjproject && CFLAGS="-fPIC" ./configure --build=$(BUILD_PLATFORM) --host=$(HOST_PLATFORM) --disable-floating-point --disable-sound --disable-oss --disable-speex-aec --disable-l16-codec --disable-gsm-codec --disable-g722-codec --disable-g7221-codec --disable-speex-codec --disable-ilbc-codec --disable-g711-codec)
 
-include pjproject/build.mak
+ifneq ($(findstring $(MAKECMDGOALS),all),)
+-include pjproject/build.mak
+endif
+
+.PHONY: FORCE
+FORCE:
+
+$(PJ_LIB_FILES): FORCE
+       $(MAKE) -C $(patsubst %/lib/,%,$(dir $@))/build/ ../lib/$(notdir $@)
 
-$(PJ_LIB_FILES): pjproject
 res_rtp_asterisk.o: $(PJ_LIB_FILES)
 res_rtp_asterisk.o: _ASTCFLAGS+=$(PJ_CFLAGS)
 res_rtp_asterisk.so: _ASTLDFLAGS+=$(PJ_LDFLAGS)
index babbff7..749ebf0 100755 (executable)
@@ -2403,7 +2403,7 @@ test -n "$target_alias" &&
   program_prefix=${target_alias}-
 ac_config_headers="$ac_config_headers pjlib/include/pj/compat/os_auto.h pjlib/include/pj/compat/m_auto.h pjmedia/include/pjmedia/config_auto.h pjmedia/include/pjmedia-codec/config_auto.h pjsip/include/pjsip/sip_autoconf.h"
 
-ac_config_files="$ac_config_files build.mak build/os-auto.mak pjlib/build/os-auto.mak pjlib-util/build/os-auto.mak pjmedia/build/os-auto.mak pjsip/build/os-auto.mak third_party/build/os-auto.mak third_party/build/portaudio/os-auto.mak"
+ac_config_files="$ac_config_files build.mak build/os-auto.mak build/cc-auto.mak pjlib/build/os-auto.mak pjlib-util/build/os-auto.mak pjmedia/build/os-auto.mak pjsip/build/os-auto.mak third_party/build/os-auto.mak third_party/build/portaudio/os-auto.mak"
 
 
 
@@ -7988,6 +7988,7 @@ do
     "pjsip/include/pjsip/sip_autoconf.h") CONFIG_HEADERS="$CONFIG_HEADERS pjsip/include/pjsip/sip_autoconf.h" ;;
     "build.mak") CONFIG_FILES="$CONFIG_FILES build.mak" ;;
     "build/os-auto.mak") CONFIG_FILES="$CONFIG_FILES build/os-auto.mak" ;;
+    "build/cc-auto.mak") CONFIG_FILES="$CONFIG_FILES build/cc-auto.mak" ;;
     "pjlib/build/os-auto.mak") CONFIG_FILES="$CONFIG_FILES pjlib/build/os-auto.mak" ;;
     "pjlib-util/build/os-auto.mak") CONFIG_FILES="$CONFIG_FILES pjlib-util/build/os-auto.mak" ;;
     "pjmedia/build/os-auto.mak") CONFIG_FILES="$CONFIG_FILES pjmedia/build/os-auto.mak" ;;
index e0ec1f9..15ef7da 100644 (file)
@@ -13,6 +13,7 @@ AC_CONFIG_HEADER([pjlib/include/pj/compat/os_auto.h
                 ])
 AC_CONFIG_FILES([build.mak 
                 build/os-auto.mak 
+                build/cc-auto.mak
                 pjlib/build/os-auto.mak 
                 pjlib-util/build/os-auto.mak 
                 pjmedia/build/os-auto.mak
index d600007..ad6df03 100644 (file)
@@ -17,6 +17,15 @@ include $(PJDIR)/build/cc-$(CC_NAME).mak
 -include cc-$(CC_NAME).mak
 
 #
+# Include auto configured compiler specification.
+# This will override the compiler settings above.
+# Currently this is made OPTIONAL, to prevent people
+# from getting errors because they don't re-run ./configure
+# after downloading new PJSIP.
+#
+-include $(PJDIR)/build/cc-auto.mak
+
+#
 # Include global machine specific definitions
 #
 include $(PJDIR)/build/m-$(MACHINE_NAME).mak
index fe7c1b6..3d99927 100644 (file)
@@ -1,8 +1,8 @@
 # @configure_input@
 
-export OS_CFLAGS   := $(CC_DEF)PJ_AUTOCONF=1 @CFLAGS@ -g
+export OS_CFLAGS   := $(CC_DEF)PJ_AUTOCONF=1 @CFLAGS@
 
-export OS_CXXFLAGS := $(CC_DEF)PJ_AUTOCONF=1 @CXXFLAGS@ -g
+export OS_CXXFLAGS := $(CC_DEF)PJ_AUTOCONF=1 @CXXFLAGS@
 
 export OS_LDFLAGS  := @LDFLAGS@ @LIBS@