From d241e7f3262aa71ca5693bf5308727d1484a5766 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Thu, 16 Jan 2014 06:30:15 +0000 Subject: [PATCH] build: Fix 'make -j' handling. Some build targets create multiple outputs, which can cause problems when doing parallel builds. Clean up the build system so that all subdir invocations come from the top-level Makefile and use $(MAKE). Also fix the FREEDOOM/FREEDM lumps to really include the version number by using $(shell ...) syntax. --- Makefile | 32 ++++++++++++++++++++++---------- graphics/text/Makefile | 17 +++++++++++++++-- lumps/Makefile | 30 ------------------------------ lumps/textures/Makefile | 16 +++++++--------- 4 files changed, 44 insertions(+), 51 deletions(-) delete mode 100644 lumps/Makefile diff --git a/Makefile b/Makefile index c85a1551..126559d9 100644 --- a/Makefile +++ b/Makefile @@ -27,7 +27,7 @@ # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -VERSION!=git describe +VERSION=$(shell git describe) WADS=wads CPP=scripts/simplecpp DEUTEX=deutex @@ -43,14 +43,21 @@ OBJS=$(FREEDM) $(FREEDOOM1) $(FREEDOOM2) all: $(OBJS) subdirs: - make -C graphics/text - make -C graphics/titlepic - make -C lumps + $(MAKE) -C graphics/text + $(MAKE) -C graphics/titlepic + $(MAKE) -C lumps/cph/misc-lumps + $(MAKE) -C lumps/genmidi + $(MAKE) -C lumps/dmxgus + $(MAKE) -C lumps/textures + # this is a useless dependency to force builds force: +lumps/freedoom.lmp lumps/freedm.lmp: force + echo $(VERSION) > $@ + pnames.txt: scripts/extract-pnames.py -a > $@ @@ -78,7 +85,7 @@ wadinfo_freedm.txt : buildcfg.txt force pnames.txt #--------------------------------------------------------- # freedm iwad -$(FREEDM): wadinfo_freedm.txt subdirs force +$(FREEDM): wadinfo_freedm.txt subdirs lumps/freedm.lmp @mkdir -p $(WADS) rm -f $@ $(DEUTEX) $(DEUTEX_ARGS) -iwad -build wadinfo_freedm.txt $@ @@ -86,7 +93,7 @@ $(FREEDM): wadinfo_freedm.txt subdirs force #--------------------------------------------------------- # phase 1 (udoom) iwad -$(FREEDOOM1): wadinfo_phase1.txt subdirs force +$(FREEDOOM1): wadinfo_phase1.txt subdirs lumps/freedoom.lmp @mkdir -p $(WADS) rm -f $@ $(DEUTEX) $(DEUTEX_ARGS) -iwad -lumps -patch -flats -sounds -musics -graphics -sprites -levels -build wadinfo_phase1.txt $@ @@ -94,7 +101,7 @@ $(FREEDOOM1): wadinfo_phase1.txt subdirs force #--------------------------------------------------------- # phase 2 (doom2) iwad -$(FREEDOOM2): wadinfo_phase2.txt subdirs force +$(FREEDOOM2): wadinfo_phase2.txt subdirs lumps/freedoom.lmp @mkdir -p $(WADS) rm -f $@ $(DEUTEX) $(DEUTEX_ARGS) -iwad -lumps -patch -flats -sounds -musics -graphics -sprites -levels -build wadinfo_phase2.txt $@ @@ -119,6 +126,11 @@ clean: pnames.txt -rmdir $(WADS) - make -C lumps clean - make -C graphics/text clean - make -C graphics/titlepic clean + $(MAKE) -C lumps clean + $(MAKE) -C graphics/text clean + $(MAKE) -C graphics/titlepic clean + $(MAKE) -C lumps/cph/misc-lumps clean + $(MAKE) -C lumps/genmidi clean + $(MAKE) -C lumps/dmxgus clean + $(MAKE) -C lumps/textures clean + diff --git a/graphics/text/Makefile b/graphics/text/Makefile index 6f340197..a1bd428f 100644 --- a/graphics/text/Makefile +++ b/graphics/text/Makefile @@ -39,9 +39,22 @@ GRAPHICS = \ all: $(GRAPHICS) -$(GRAPHICS): config.py fontchars ../../lumps/fraggle/freedoom.bex +# textgen creates multiple outputs, which is awkward to express in +# make. Use a witness file (graphics.stamp) as suggested in the +# automake manual: "Handling Tools that Produce Many Outputs" + +$(GRAPHICS): graphics.stamp + @if test -f $@; then :; else \ + rm -f graphics.stamp; \ + $(MAKE) data.stamp; \ + fi + +graphics.stamp: config.py fontchars ../../lumps/fraggle/freedoom.bex + @rm -f graphics.tmp + @touch graphics.tmp ./textgen + @mv graphics.tmp $@ clean: - rm -f $(GRAPHICS) + rm -f $(GRAPHICS) graphics.stamp diff --git a/lumps/Makefile b/lumps/Makefile deleted file mode 100644 index da34ee03..00000000 --- a/lumps/Makefile +++ /dev/null @@ -1,30 +0,0 @@ - -all : freedoom.lmp freedm.lmp misc-lumps genmidi-lump dmxgus.lmp \ - fd1txtr1.lmp fd2txtr1.lmp fdmtxtr1.lmp - -misc-lumps: - make -C cph/misc-lumps - -genmidi-lump: - make -C genmidi - -dmxgus.lmp: - make -C dmxgus - -fd1txtr1.lmp fd2txtr1.lmp fdmtxtr1.lmp: - make -C textures - -freedoom.lmp: force - echo $(VERSION) > freedoom.lmp - -freedm.lmp: force - echo $(VERSION) > freedm.lmp - -force: - -clean: - make -C cph/misc-lumps clean - make -C genmidi clean - make -C dmxgus clean - make -C textures clean - diff --git a/lumps/textures/Makefile b/lumps/textures/Makefile index fbcb881d..e122c3fc 100644 --- a/lumps/textures/Makefile +++ b/lumps/textures/Makefile @@ -1,13 +1,9 @@ CPP=../../scripts/simplecpp -PHASE1_OUTPUTS = phase1/texture1.lmp phase1/texture2.lmp \ - phase1/pnames.lmp -PHASE2_OUTPUTS = phase2/texture1.lmp phase2/pnames.lmp -FREEDM_OUTPUTS = freedm/texture1.lmp freedm/pnames.lmp -all: $(PHASE1_OUTPUTS) $(PHASE2_OUTPUTS) $(FREEDM_OUTPUTS) +all: phase1/texture1.lmp phase2/texture1.lmp freedm/texture1.lmp -$(PHASE1_OUTPUTS): textures.cfg +phase1/texture1.lmp: $(CPP) -DDOOM1 -DULTDOOM < textures.cfg | \ ./build-textures -compat_texture1=doom1/texture1.txt \ -compat_texture2=doom1/texture2.txt \ @@ -16,14 +12,14 @@ $(PHASE1_OUTPUTS): textures.cfg -output_texture2=phase1/texture2.lmp \ -output_pnames=phase1/pnames.lmp -$(PHASE2_OUTPUTS): textures.cfg +phase2/texture1.lmp: $(CPP) -DDOOM1 -DDOOM2 < textures.cfg | \ ./build-textures -compat_texture1=doom2/texture1.txt \ -compat_pnames=doom2/pnames.txt \ -output_texture1=phase2/texture1.lmp \ -output_pnames=phase2/pnames.lmp -$(FREEDM_OUTPUTS): textures.cfg +freedm/texture1.lmp: $(CPP) -DDOOM1 -DDOOM2 -DFREEDM < textures.cfg | \ ./build-textures -compat_texture1=doom2/texture1.txt \ -compat_pnames=doom2/pnames.txt \ @@ -32,5 +28,7 @@ $(FREEDM_OUTPUTS): textures.cfg clean: - rm -f $(PHASE1_OUTPUTS) $(PHASE2_OUTPUTS) $(FREEDM_OUTPUTS) + rm -f phase1/texture1.lmp phase1/texture2.lmp phase1/pnames.lmp \ + phase2/texture1.lmp phase2/pnames.lmp \ + freedm/texture1.lmp freedm/pnames.lmp