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.
master
Simon Howard 2014-01-16 06:30:15 +00:00
parent d9b4c2530a
commit d241e7f326
4 changed files with 44 additions and 51 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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