Fix basic makefile not issuing a job server due to variable expansion not working as expected

This commit is contained in:
rexy712 2020-01-06 12:49:12 -08:00
parent 8ac6068b8d
commit fd0dd378f4

View File

@ -31,6 +31,7 @@ LANG::=$(EXT)
MAIN_EXECUTABLE::=tester MAIN_EXECUTABLE::=tester
PRE_TARGETS::= PRE_TARGETS::=
POST_TARGETS::= POST_TARGETS::=
CLEAN_TARGETS::=
RELEASE?=0 RELEASE?=0
MEMCHK?=0 MEMCHK?=0
@ -58,7 +59,7 @@ else #windows
AS::=$(MINGW_PREFIX)as AS::=$(MINGW_PREFIX)as
endif #windows endif #windows
#Put your custom targets for PRE_TARGETS and POST_TARGETS here: #Put your custom targets for PRE_TARGETS, POST_TARGETS, and CLEAN_TARGETS here:
@ -118,19 +119,20 @@ THIS_MAKEFILE_NAME::=$(lastword $(MAKEFILE_LIST))
SOURCES::=$(foreach source,$(SOURCE_DIRS),$(foreach ext,$(EXT),$(wildcard $(source)/*.$(ext)))) SOURCES::=$(foreach source,$(SOURCE_DIRS),$(foreach ext,$(EXT),$(wildcard $(source)/*.$(ext))))
OBJECTS::=$(addprefix $(OBJDIR)/,$(subst \,.,$(subst /,.,$(addsuffix .o,$(SOURCES))))) OBJECTS::=$(addprefix $(OBJDIR)/,$(subst \,.,$(subst /,.,$(addsuffix .o,$(SOURCES)))))
#generate a command to run a submake using this same makefile without printing "Entering directory" stuff #Arguments to make submake use this makefile without "Entering directory" stuff
#note: the empty line is required in this definition SUBMAKE_ARGUMENTS::=--no-print-directory -f "$(THIS_MAKEFILE_NAME)"
define RUN_SUBMAKE_TARGET #just a variable for a newline
@$(MAKE) --no-print-directory -f "$(THIS_MAKEFILE_NAME)" "$(1)" define \n
endef endef
#default target: run targets in PRE_TARGETS, then the main executable, then POST_TARGETS #default target: run targets in PRE_TARGETS, then the main executable, then POST_TARGETS
.PHONY: all .PHONY: all
all: all:
$(foreach target,$(PRE_TARGETS),$(call RUN_SUBMAKE_TARGET,$(target))) $(foreach target,$(PRE_TARGETS),@$(MAKE) $(SUBMAKE_ARGUMENTS) "$(target)"$(\n))
$(call RUN_SUBMAKE_TARGET,$(MAIN_EXECUTABLE)) @$(MAKE) $(SUBMAKE_ARGUMENTS) "$(MAIN_EXECUTABLE)"
$(foreach target,$(POST_TARGETS),$(call RUN_SUBMAKE_TARGET,$(target))) $(foreach target,$(POST_TARGETS),@$(MAKE) $(SUBMAKE_ARGUMENTS) "$(target)")
#Called in POST_TARGETS when RELEASE=1 #Called in POST_TARGETS when RELEASE=1
.PHONY: do_strip .PHONY: do_strip
@ -159,6 +161,7 @@ $(DEPDIR):
.PHONY: clean .PHONY: clean
clean: clean:
$(foreach target,$(CLEAN_TARGETS),@$(MAKE) $(SUBMAKE_ARGUMENTS) "$(target)"$(\n))
$(call rmdir,"$(DEPDIR)") $(call rmdir,"$(DEPDIR)")
$(call rmdir,"$(OBJDIR)") $(call rmdir,"$(OBJDIR)")
$(call rm,"$(MAIN_EXECUTABLE)") $(call rm,"$(MAIN_EXECUTABLE)")