From: bones_was_here Date: Mon, 18 Dec 2023 02:59:10 +0000 (+1000) Subject: Makefile: improve robustness X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=584edbe3c5a1f0ab189d84d4d7b4a921f8064160;p=xonotic%2Fxonotic.git Makefile: improve robustness Defines all build stages in terms of files generated/required instead of using PHONY targets. Ensures `clean` target completes before build targets start and that no other targets can run while a clean or update target is running. Works around d0_blind_id autotools flakiness. Fixes clean targets failing and causing an abort if the d0_blind_id Makefile doesn't exist. --- diff --git a/Makefile b/Makefile index 2300f386..1ab3dc2b 100644 --- a/Makefile +++ b/Makefile @@ -44,7 +44,7 @@ help: @echo " make clean Delete engine builds and build objects" @echo @echo " make update-stable Update to the latest stable release via rsync" - @echo " make update-beta Update to the latest daily autobuild via rsync" + @echo " make update-beta Update to the latest beta autobuild via rsync" @echo @printf " make server Compile \e[1m$(SERVER)\e[m\n" @printf " make client Compile \e[1m$(CLIENT)\e[m\n" @@ -56,12 +56,17 @@ ifdef GIT $(error $(GIT)) endif -.EXTRA_PREREQS := $(findstring update-stable,$(MAKECMDGOALS)) $(findstring update-beta,$(MAKECMDGOALS)) + +# If requested, these targets must always run first: +.EXTRA_PREREQS := $(filter clean update-stable update-beta, $(MAKECMDGOALS)) +# It makes sense to `clean-sources` after building if requested. +.NOTPARALLEL: $(.EXTRA_PREREQS) clean-sources .PHONY: clean-sources clean-sources: $(MAKE) -C $(DPSRC) clean - $(MAKE) -C $(D0SRC) clean + ( $(MAKE) -C $(D0SRC) clean || true ) # autotools may not have created the Makefile yet +clean-sources: .EXTRA_PREREQS = # prevents circular dependency .PHONY: clean clean: clean-sources @@ -75,22 +80,28 @@ update-stable: update-beta: misc/tools/rsync-updater/update-to-autobuild.sh -$(D0SRC)/Makefile: - ( cd $(D0SRC) && ./autogen.sh && ./configure --enable-static --disable-shared ) -.PHONY: d0_blind_id -d0_blind_id: $(D0SRC)/Makefile +$(D0SRC)/.libs/libd0_blind_id.a $(D0SRC)/.libs/libd0_rijndael.a: + ( cd $(D0SRC) && ./autogen.sh && ./configure --enable-static --disable-shared ) + $(MAKE) -C $(D0SRC) clean # ensures missing .a files are created FIXME WORKAROUND $(MAKE) -C $(D0SRC) -.PHONY: server -server: d0_blind_id +$(DPSRC)/darkplaces-dedicated: $(D0SRC)/.libs/libd0_blind_id.a $(D0SRC)/.libs/libd0_rijndael.a $(MAKE) -C $(DPSRC) sv-release - cp -v $(DPSRC)/darkplaces-dedicated $(SERVER) +$(SERVER): $(DPSRC)/darkplaces-dedicated + cp $(DPSRC)/darkplaces-dedicated $(SERVER) -.PHONY: client -client: d0_blind_id +$(DPSRC)/darkplaces-sdl: $(D0SRC)/.libs/libd0_blind_id.a $(D0SRC)/.libs/libd0_rijndael.a $(MAKE) -C $(DPSRC) sdl-release - cp -v $(DPSRC)/darkplaces-sdl $(CLIENT) +$(CLIENT): $(DPSRC)/darkplaces-sdl + cp $(DPSRC)/darkplaces-sdl $(CLIENT) + + +.PHONY: server +server: $(SERVER) + +.PHONY: client +client: $(CLIENT) .PHONY: both both: client server