From 92152e45e226b797a5ca10cff0e9e55d2a66a3d8 Mon Sep 17 00:00:00 2001 From: luckytyphlosion <10688458+luckytyphlosion@users.noreply.github.com> Date: Tue, 1 Jun 2021 23:22:15 -0400 Subject: [PATCH] Fixes to makefile. Merge C_ASM_DEP and DATA_ASM_DEP, NODEP and SCAN_DEPS can be overridden, add --no-print-directory to MAKEFLAGS in make_tools.mk (also removed some unused variables), add newline to help message in preproc. --- Makefile | 23 +++++++++-------------- make_tools.mk | 5 ++--- tools/preproc/preproc.cpp | 2 +- 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index a2b0139269..5741977ec5 100644 --- a/Makefile +++ b/Makefile @@ -157,19 +157,19 @@ infoshell = $(foreach line, $(shell $1 | sed "s/ /__SPACE__/g"), $(info $(subst ifeq (,$(filter-out all rom compare modern berry_fix libagbsyscall,$(MAKECMDGOALS))) $(call infoshell, $(MAKE) -f make_tools.mk) else -NODEP := 1 +NODEP ?= 1 endif # check if we need to scan dependencies based on the rule ifeq (,$(MAKECMDGOALS)) - SCAN_DEPS := 1 + SCAN_DEPS ?= 1 else # clean, tidy, tools, mostlyclean, clean-tools, $(TOOLDIRS), tidymodern, tidynonmodern don't even build the ROM # berry_fix and libagbsyscall do their own thing ifeq (,$(filter-out clean tidy tools mostlyclean clean-tools $(TOOLDIRS) tidymodern tidynonmodern berry_fix libagbsyscall,$(MAKECMDGOALS))) - SCAN_DEPS := 0 + SCAN_DEPS ?= 0 else - SCAN_DEPS := 1 + SCAN_DEPS ?= 1 endif endif @@ -365,11 +365,11 @@ ifeq ($(NODEP),1) $(C_BUILDDIR)/%.o: $(C_SUBDIR)/%.s $(AS) $(ASFLAGS) -o $@ $< else -define C_ASM_DEP -$1: $2 $$(shell $(SCANINC) -I "" $2) - $$(AS) $$(ASFLAGS) -o $$@ $$< +define SRC_ASM_DATA_DEP +$1: $2 $$(shell $(SCANINC) -I include -I "" $2) + $$(PREPROC) $$< charmap.txt | $$(CPP) -I include - | $$(AS) $$(ASFLAGS) -o $$@ endef -$(foreach src, $(C_ASM_SRCS), $(eval $(call C_ASM_DEP,$(patsubst $(C_SUBDIR)/%.s,$(C_BUILDDIR)/%.o, $(src)),$(src)))) +$(foreach src, $(C_ASM_SRCS), $(eval $(call SRC_ASM_DATA_DEP,$(patsubst $(C_SUBDIR)/%.s,$(C_BUILDDIR)/%.o, $(src)),$(src)))) endif ifeq ($(NODEP),1) @@ -387,12 +387,7 @@ ifeq ($(NODEP),1) $(DATA_ASM_BUILDDIR)/%.o: $(DATA_ASM_SUBDIR)/%.s $(PREPROC) $< charmap.txt | $(CPP) -I include - | $(AS) $(ASFLAGS) -o $@ else -define DATA_ASM_DEP -$1: $2 $$(shell $(SCANINC) -I include -I "" $2) - $$(PREPROC) $$< charmap.txt | $$(CPP) -I include - | $$(AS) $$(ASFLAGS) -o $$@ -endef -$(foreach src, $(REGULAR_DATA_ASM_SRCS), $(eval $(call DATA_ASM_DEP,$(patsubst $(DATA_ASM_SUBDIR)/%.s,$(DATA_ASM_BUILDDIR)/%.o, $(src)),$(src)))) -$(foreach src, $(C_ASM_SRCS), $(eval $(call DATA_ASM_DEP,$(patsubst $(C_SUBDIR)/%.s,$(C_BUILDDIR)/%.o, $(src)),$(src)))) +$(foreach src, $(REGULAR_DATA_ASM_SRCS), $(eval $(call SRC_ASM_DATA_DEP,$(patsubst $(DATA_ASM_SUBDIR)/%.s,$(DATA_ASM_BUILDDIR)/%.o, $(src)),$(src)))) endif $(info Scanning deps end $(shell date +%s%3N)) endif diff --git a/make_tools.mk b/make_tools.mk index 82a482bca7..697897a693 100644 --- a/make_tools.mk +++ b/make_tools.mk @@ -1,12 +1,11 @@ +MAKEFLAGS += --no-print-directory + TOOLDIRS := $(filter-out tools/agbcc tools/binutils,$(wildcard tools/*)) -TOOLBASE = $(TOOLDIRS:tools/%=%) -TOOLS = $(foreach tool,$(TOOLBASE),tools/$(tool)/$(tool)$(EXE)) .PHONY: all $(TOOLDIRS) all: $(TOOLDIRS) - @: $(TOOLDIRS): @$(MAKE) -C $@ diff --git a/tools/preproc/preproc.cpp b/tools/preproc/preproc.cpp index 02950a2963..eb2d4c8a23 100644 --- a/tools/preproc/preproc.cpp +++ b/tools/preproc/preproc.cpp @@ -134,7 +134,7 @@ int main(int argc, char **argv) { if (argc < 3 || argc > 4) { - std::fprintf(stderr, "Usage: %s SRC_FILE CHARMAP_FILE [-i]\nwhere -i denotes if input is from stdin", argv[0]); + std::fprintf(stderr, "Usage: %s SRC_FILE CHARMAP_FILE [-i]\nwhere -i denotes if input is from stdin\n", argv[0]); return 1; }