diff --git a/Makefile b/Makefile index fcb3e3c78f..29e352d8ee 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,7 @@ BASEROM = baserom.z64 TARGET = papermario COMPARE = 1 NON_MATCHING = 0 +WATCH_INCLUDES = 1 -include settings.mk @@ -57,7 +58,7 @@ CPP := cpp LD := $(CROSS)ld OBJCOPY := $(CROSS)objcopy -CPPFLAGS := -Iinclude -Isrc -D _LANGUAGE_C -ffreestanding -DF3DEX_GBI_2 -D_MIPS_SZLONG=0 -Wundef -Wcomment +CPPFLAGS := -Iinclude -Isrc -D _LANGUAGE_C -ffreestanding -DF3DEX_GBI_2 -D_MIPS_SZLONG=0 -Wundef -Wcomment -MM -MP ASFLAGS := -EB -Iinclude -march=vr4300 -mtune=vr4300 OLDASFLAGS := -EB -Iinclude -G 0 CFLAGS := -O2 -quiet -G 0 -mcpu=vr4300 -mfix4300 -mips3 -mgp32 -mfp32 -Wimplicit -Wuninitialized -Wshadow @@ -72,6 +73,10 @@ endif include sources.mk +ifeq ($(WATCH_INCLUDES),1) +-include $(foreach $(obj), $(OBJECTS), $(BUILD_DIR)/$(obj).mk) +endif + ### Targets ### @@ -126,12 +131,12 @@ $(BUILD_DIR)/%.Yay0.o: $(BUILD_DIR)/%.bin.Yay0 # Compile C files $(BUILD_DIR)/%.c.o: %.c @mkdir -p $(shell dirname $@) - $(CPP) $(CPPFLAGS) -o - $< | $(CC) $(CFLAGS) -o - - | $(OLD_AS) $(OLDASFLAGS) -o $@ - + $(CPP) $(CPPFLAGS) -MF $@.mk -MT $< -o - $< | $(CC) $(CFLAGS) -o - - | $(OLD_AS) $(OLDASFLAGS) -o $@ - # Compile C files (with DSL macros) $(foreach cfile, $(DSL_C_FILES), $(BUILD_DIR)/$(cfile).o): $(BUILD_DIR)/%.c.o: %.c @mkdir -p $(shell dirname $@) - $(CPP) $(CPPFLAGS) -o - $< | tools/compile_dsl_macros.py | $(CC) $(CFLAGS) -o - - | $(OLD_AS) $(OLDASFLAGS) -o $@ - + $(CPP) $(CPPFLAGS) -MF $@.mk -MT $< -o - $< | tools/compile_dsl_macros.py | $(CC) $(CFLAGS) -o - - | $(OLD_AS) $(OLDASFLAGS) -o $@ - # Assemble handwritten ASM $(BUILD_DIR)/%.s.o: %.s diff --git a/README.md b/README.md index 5f375e3b78..2bdc2c9a1b 100644 --- a/README.md +++ b/README.md @@ -54,12 +54,6 @@ We provide [windows_terminal.bat](tools/windows_terminal.bat) to open a [Windows ### Rebuilding -Setting the `PM_HEADER_REBUILD` environment variable will cause `make` to rebuild all `.c` files whenever a `.h` file is modified. - -```sh -$ PM_HEADER_REBUILD=1 make -``` - If you use Visual Studio Code, you can use _Run Build Task_ (Ctrl+Shift+B) to run `make`. Any errors or warnings generated by the compiler will show up in the _Problems_ tab. ### Matching a function diff --git a/diff_settings.py b/diff_settings.py index eb14aca999..52c1cfe713 100644 --- a/diff_settings.py +++ b/diff_settings.py @@ -5,4 +5,4 @@ def apply(config, args): config['myimg'] = 'papermario.z64' config['mapfile'] = 'build/papermario.map' config['source_directories'] = ['.'] - config['makeflags'] = ['COMPARE=0'] + config['makeflags'] = ['COMPARE=0', 'WATCH_INCLUDES=0']