From a9698d02418ad6c8043170985cf70a8ce20cbad6 Mon Sep 17 00:00:00 2001 From: Walter Doekes Date: Tue, 17 Jan 2012 19:45:19 +0000 Subject: [PATCH] Fix support for parallel building with make (-j). Previously make -j would cause a race between doing cleanup of certain files (defaults.h, menuselect, ...) and creating them anew. Add a new target that depends on cleanup only and has a submake doing the rest as command string. This way the cleanup goes first. (closes issue ASTERISK-18751) Tested by: Jeremy Kister Reviewed by: Paul Belanger Review: https://reviewboard.asterisk.org/r/1660 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@351360 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- Makefile | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index f0fbad7fe0..dfa1757f48 100644 --- a/Makefile +++ b/Makefile @@ -338,7 +338,7 @@ else mK=" make" endif -all: _all +all: _cleantest_all @echo " +--------- Asterisk Build Complete ---------+" @echo " + Asterisk has successfully been built, and +" @echo " + can be installed by running: +" @@ -346,7 +346,12 @@ all: _all @echo " + $(mK) install +" @echo " +-------------------------------------------+" -_all: cleantest makeopts $(SUBDIRS) doc/core-en_US.xml $(ADDL_TARGETS) +# For parallel builds, we must call cleantest *before* running the +# other dependencies on _all. +_cleantest_all: cleantest + @$(MAKE) _all + +_all: makeopts $(SUBDIRS) doc/core-en_US.xml $(ADDL_TARGETS) makeopts: configure @echo "****" @@ -462,7 +467,7 @@ distclean: $(SUBDIRS_DIST_CLEAN) _clean rm -rf doc/api rm -f build_tools/menuselect-deps -datafiles: _all doc/core-en_US.xml +datafiles: _cleantest_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 @@ -563,7 +568,7 @@ installdirs: $(INSTALL) -d "$(DESTDIR)$(AGI_DIR)" $(INSTALL) -d "$(DESTDIR)$(ASTDBDIR)" -bininstall: _all installdirs $(SUBDIRS_INSTALL) +bininstall: _cleantest_all installdirs $(SUBDIRS_INSTALL) $(INSTALL) -m 755 main/asterisk "$(DESTDIR)$(ASTSBINDIR)/" $(LN) -sf asterisk "$(DESTDIR)$(ASTSBINDIR)/rasterisk" $(INSTALL) -m 755 contrib/scripts/astgenkey "$(DESTDIR)$(ASTSBINDIR)/" @@ -954,6 +959,8 @@ menuselect-tree: $(foreach dir,$(filter-out main,$(MOD_SUBDIRS)),$(wildcard $(di .PHONY: dist-clean .PHONY: distclean .PHONY: all +.PHONY: _all +.PHONY: _cleantest_all .PHONY: prereqs .PHONY: cleantest .PHONY: uninstall