From e6fca950b79ec7561ac5cf52dcab14c84928a03f Mon Sep 17 00:00:00 2001 From: Yanis <35189056+Yanis002@users.noreply.github.com> Date: Tue, 7 Jan 2025 17:38:46 +0100 Subject: [PATCH] Clean up terminal output (#163) * cleanup terminal output * fixes --- .make_hackeroot.mk | 20 +---- Makefile | 126 ++++++++++++++++--------------- tools/Flips/Makefile | 43 ++++++----- tools/Makefile | 61 +++++++++------ tools/ZAPD/ExporterTest/Makefile | 12 ++- tools/ZAPD/Makefile | 34 +++++---- tools/ZAPD/ZAPDUtils/Makefile | 13 +++- tools/ZAPD/lib/libgfxd/Makefile | 10 ++- tools/audio/Makefile | 18 +++-- tools/audio/sampleconv/Makefile | 12 ++- tools/extract_assets.py | 13 +++- tools/fado/Makefile | 16 ++-- tools/gzinject/Makefile.in | 17 +++-- tools/print_rules.mk | 26 +++++++ tools/z64compress/Makefile | 11 ++- 15 files changed, 254 insertions(+), 178 deletions(-) create mode 100644 tools/print_rules.mk diff --git a/.make_hackeroot.mk b/.make_hackeroot.mk index cd7247dde..885729fc1 100644 --- a/.make_hackeroot.mk +++ b/.make_hackeroot.mk @@ -20,25 +20,7 @@ else $(error Unable to detect a suitable MIPS toolchain installed) endif -# Verbose toggle -V := @ -ifeq (VERBOSE, 1) - V= -endif - -# Colors -NO_COL := \033[0m -GREEN := \033[0;32m -BLUE := \033[0;36m -YELLOW := \033[0;33m -BLINK := \033[32;5m - -PRINT := printf - -# Generic print function for make rules -define print - $(V)echo -e "$(GREEN)$(1) $(YELLOW)$(2)$(GREEN) -> $(BLUE)$(3)$(NO_COL)" -endef +-include tools/print_rules.mk # Enable optimization flags to use GDB on Ares ARES_GDB := 1 diff --git a/Makefile b/Makefile index acb30c9f3..343c9dd98 100644 --- a/Makefile +++ b/Makefile @@ -650,31 +650,31 @@ endif all: rom rom: - $(call print,Building the rom...) + $(call print_no_args,Building the rom...) $(V)python3 tools/mod_assets.py --oot-version $(VERSION) $(V)$(MAKE) $(ROM) compress: - $(call print,Compressing the rom...) + $(call print_no_args,Compressing the rom...) # make sure z_std_dma.c and spec are up-to-date $(V)$(shell touch spec) $(V)$(shell touch src/boot/z_std_dma.c) $(V)$(MAKE) $(ROMC) - $(call print,Success!) + $(call print_no_args,Success!) wad: - $(call print,Patching WAD...) + $(call print_no_args,Patching WAD...) ifeq ("$(wildcard baseroms/$(VERSION)/common-key.bin)", "") $(error Please provide the common-key.bin file.) endif $(V)$(MAKE) compress TARGET=wad $(V)$(GZINJECT) -a inject -r 1 -k baseroms/$(VERSION)/common-key.bin -w baseroms/$(VERSION)/basewad.wad -m $(ROMC) -o $(WAD) -t "HackerOoT" -i NHOE -p tools/gzinject/patches/NACE.gzi -p tools/gzinject/patches/gz_default_remap.gzi $(V)$(RM) -r wadextract/ - $(call print,Success!) + $(call print_no_args,Success!) iso: $(V)$(MAKE) compress TARGET=iso - $(call print,Patching ISO...) + $(call print_no_args,Patching ISO...) $(V)$(PYTHON) tools/gc_utility.py -v $(VERSION) -c $(COMPRESSION) $(V)$(GZINJECT) -a extract -s baseroms/$(VERSION)/baseiso.iso $(V)cp $(BUILD_DIR)/$(DMA_CONFIG_FILE) isoextract/zlj_f.tgc/$(DMA_CONFIG_FILE) @@ -683,44 +683,44 @@ iso: $(V)$(FLIPS) --apply tools/gamecube.bps isoextract/zlj_f.tgc/main.dol isoextract/zlj_f.tgc/main.dol $(V)$(GZINJECT) -a pack -s $(ISO) $(V)$(RM) -r isoextract/ - $(call print,Success!) + $(call print_no_args,Success!) clean: $(V)$(RM) -r $(BUILD_DIR) - $(call print,Success!) + $(call print_no_args,Success!) assetclean: $(V)$(RM) -r $(EXTRACTED_DIR) - $(call print,Success!) + $(call print_no_args,Success!) distclean: $(V)$(RM) -r extracted/ $(V)$(RM) -r build/ $(V)$(MAKE) -C tools distclean $(V)$(RM) -r F3DEX3/*.code F3DEX3/*.data - $(call print,Success!) + $(call print_no_args,Success!) venv: # Create the virtual environment if it doesn't exist. # Delete the virtual environment directory if creation fails. - $(call print,Preparing the virtual environment...) + $(call print_no_args,Preparing the virtual environment...) $(V)test -d $(VENV) || python3 -m venv $(VENV) || { rm -rf $(VENV); false; } $(V)$(PYTHON) -m pip install -U pip $(V)$(PYTHON) -m pip install -U -r requirements.txt - $(call print,Success!) + $(call print_no_args,Success!) setup: venv - $(call print,Setup in progress...) + $(call print_no_args,Setup in progress...) $(V)$(MAKE) -C tools - $(call print,Tools: Done!) + $(call print_no_args,Tools: Done!) $(V)$(PYTHON) tools/decompress_baserom.py $(VERSION) - $(call print,Decompressing baserom: Done!) + $(call print_no_args,Decompressing baserom: Done!) $(V)$(PYTHON) tools/extract_baserom.py $(BASEROM_DIR)/baserom-decompressed.z64 $(EXTRACTED_DIR)/baserom -v $(VERSION) $(V)$(PYTHON) tools/extract_incbins.py $(EXTRACTED_DIR)/baserom $(EXTRACTED_DIR)/incbin -v $(VERSION) $(V)$(PYTHON) tools/extract_text.py $(EXTRACTED_DIR)/baserom $(EXTRACTED_DIR)/text -v $(VERSION) $(V)$(PYTHON) tools/extract_assets.py $(EXTRACTED_DIR)/baserom $(EXTRACTED_DIR)/assets -v $(VERSION) -j$(N_THREADS) $(V)$(PYTHON) tools/extract_audio.py -o $(EXTRACTED_DIR) -v $(VERSION) --read-xml - $(call print,Extracting files: Done!) + $(call print_no_args,Extracting files: Done!) run: rom ifeq ($(N64_EMULATOR),) @@ -729,12 +729,12 @@ endif $(N64_EMULATOR) $(ROM) patch: - $(call print,Creating BPS patch...) + $(call print_no_args,Creating BPS patch...) $(V)$(FLIPS) --create --bps $(BASEROM_PATCH) $(ROM) $(BPS) - $(call print,Success!) + $(call print_no_args,Success!) create_f3dex3_patches: F3DEX3/f3dzex2.code F3DEX3/f3dzex2.data - $(call print,Creating F3DEX3 patches...) + $(call print_no_args,Creating F3DEX3 patches...) $(V)$(FLIPS) --create --bps F3DEX3/f3dzex2.code F3DEX3/F3DEX3_BrW.code F3DEX3/F3DEX3_BrW.code.bps $(V)$(FLIPS) --create --bps F3DEX3/f3dzex2.data F3DEX3/F3DEX3_BrW.data F3DEX3/F3DEX3_BrW.data.bps $(V)$(FLIPS) --create --bps F3DEX3/f3dzex2.code F3DEX3/F3DEX3_BrW_PA.code F3DEX3/F3DEX3_BrW_PA.code.bps @@ -751,7 +751,7 @@ create_f3dex3_patches: F3DEX3/f3dzex2.code F3DEX3/f3dzex2.data $(V)$(FLIPS) --create --bps F3DEX3/f3dzex2.data F3DEX3/F3DEX3_BrW_NOC_PB.data F3DEX3/F3DEX3_BrW_NOC_PB.data.bps $(V)$(FLIPS) --create --bps F3DEX3/f3dzex2.code F3DEX3/F3DEX3_BrW_NOC_PC.code F3DEX3/F3DEX3_BrW_NOC_PC.code.bps $(V)$(FLIPS) --create --bps F3DEX3/f3dzex2.data F3DEX3/F3DEX3_BrW_NOC_PC.data F3DEX3/F3DEX3_BrW_NOC_PC.data.bps - $(call print,Success!) + $(call print_no_args,Success!) verify: $(V)$(MAKE) clean @@ -770,6 +770,8 @@ $(ROM): $(ELF) @$(PRINT) "==== Build Options ====$(NO_COL)\n" @$(PRINT) "${GREEN}OoT Version: $(BLUE)$(VERSION)$(NO_COL)\n" @$(PRINT) "${GREEN}Code Version: $(BLUE)$(PACKAGE_VERSION)$(NO_COL)\n" + @$(PRINT) "${GREEN}Build Author: $(BLUE)$(PACKAGE_AUTHOR)$(NO_COL)\n" + @$(PRINT) "${GREEN}Commit Author: $(BLUE)$(PACKAGE_COMMIT_AUTHOR)$(NO_COL)\n" ifeq ($(PLATFORM),IQUE) COMPRESS_ARGS := --format gzip --pad-to 0x4000 @@ -790,7 +792,7 @@ endif $(ELF): $(TEXTURE_FILES_OUT) $(ASSET_FILES_OUT) $(O_FILES) $(OVL_RELOC_FILES) $(UCODE_O_FILES) $(LDSCRIPT) $(BUILD_DIR)/linker_scripts/makerom.ld $(BUILD_DIR)/undefined_syms.txt \ $(SAMPLEBANK_O_FILES) $(SOUNDFONT_O_FILES) $(SEQUENCE_O_FILES) \ $(BUILD_DIR)/assets/audio/sequence_font_table.o $(BUILD_DIR)/assets/audio/audiobank_padding.o - $(call print,Linking:,,$@) + $(call print_one_arg,Linking:,$@) $(V)$(LD) -T $(LDSCRIPT) -T $(BUILD_DIR)/linker_scripts/makerom.ld -T $(BUILD_DIR)/undefined_syms.txt --no-check-sections --accept-unknown-input-arch --emit-relocs -Map $(MAP) -o $@ $(BUILD_DIR)/linker_scripts/makerom.ld: linker_scripts/makerom.ld @@ -809,28 +811,28 @@ $(O_FILES): | asset_files .PHONY: o_files asset_files $(BUILD_DIR)/$(SPEC): $(SPEC) - $(call print,Preprocessing:,$<,$@) + $(call print_two_args,Preprocessing:,$<,$@) $(V)$(CPP) $(CPPFLAGS) $< | $(BUILD_DIR_REPLACE) > $@ $(LDSCRIPT): $(BUILD_DIR)/$(SPEC) - $(call print,Creating linker script:,$<,$@) + $(call print_two_args,Creating linker script:,$<,$@) $(V)$(MKLDSCRIPT) $< $@ $(BUILD_DIR)/undefined_syms.txt: undefined_syms.txt - $(call print,Preprocessing:,$<,$@) + $(call print_two_args,Preprocessing:,$<,$@) $(V)$(CPP) $(CPPFLAGS) $< > $@ $(BUILD_DIR)/baserom/%.o: $(EXTRACTED_DIR)/baserom/% - $(call print,Wrapping binary to ELF:,$<,$@) + $(call print_two_args,Wrapping binary to ELF:,$<,$@) $(V)$(OBJCOPY) -I binary -O elf32-big $< $@ $(BUILD_DIR)/F3DEX3/%.o: F3DEX3/% - $(call print,Wrapping binary to ELF:,$<,$@) + $(call print_two_args,Wrapping binary to ELF:,$<,$@) $(V)mkdir -p $(BUILD_DIR)/F3DEX3 $(V)$(OBJCOPY) -I binary -O elf32-big $< $@ $(BUILD_DIR)/data/%.o: data/%.s - $(call print,Assembling:,$<,$@) + $(call print_two_args,Assembling:,$<,$@) $(V)$(CPP) $(CPPFLAGS) -Iinclude $< | $(AS) $(ASFLAGS) -o $@ ifeq ($(PLATFORM),IQUE) @@ -840,11 +842,11 @@ else endif $(BUILD_DIR)/assets/text/%.enc.nes.h: assets/text/%.h $(EXTRACTED_DIR)/text/%.h $(NES_CHARMAP) - $(call print,Encoding:,$<,$@) + $(call print_two_args,Encoding:,$<,$@) $(V)$(CPP) $(CPPFLAGS) -I$(EXTRACTED_DIR) $< | $(PYTHON) tools/msgenc.py --encoding utf-8 --charmap $(NES_CHARMAP) - $@ $(BUILD_DIR)/assets/text/%.enc.jpn.h: assets/text/%.h $(EXTRACTED_DIR)/text/%.h assets/text/charmap.jpn.txt - $(call print,Encoding:,$<,$@) + $(call print_two_args,Encoding:,$<,$@) $(V)$(CPP) $(CPPFLAGS) -I$(EXTRACTED_DIR) $< | $(PYTHON) tools/msgenc.py --encoding SHIFT-JIS --wchar --charmap assets/text/charmap.jpn.txt - $@ # Dependencies for files including message data headers @@ -857,7 +859,7 @@ $(BUILD_DIR)/assets/text/staff_message_data_static.o: $(BUILD_DIR)/assets/text/m $(BUILD_DIR)/src/code/z_message.o: assets/text/message_data.h assets/text/message_data_staff.h $(BUILD_DIR)/assets/text/%.o: assets/text/%.c - $(call print,Compiling:,$<,$@) + $(call print_two_args,Compiling:,$<,$@) $(V)$(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $< $(V)$(OBJCOPY) -O binary --only-section .rodata $@ $@.bin @@ -867,7 +869,7 @@ $(BUILD_DIR)/assets/%.o: assets/%.c $(V)$(OBJCOPY_CMD) $(BUILD_DIR)/assets/%.o: $(EXTRACTED_DIR)/assets/%.c - $(call print,Compiling:,$<,$@) + $(call print_two_args,Compiling:,$<,$@) $(V)$(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $< $(V)$(OBJCOPY_CMD) @@ -882,7 +884,7 @@ $(BUILD_DIR)/src/makerom/ipl3.o: $(EXTRACTED_DIR)/incbin/ipl3 $(V)$(OBJCOPY) -I binary -O elf32-big --rename-section .data=.text $< $@ $(BUILD_DIR)/src/%.o: src/%.s - $(call print,Compiling:,$<,$@) + $(call print_two_args,Compiling:,$<,$@) $(V)$(CCAS) -c $(CCASFLAGS) $(MIPS_VERSION) $(ASOPTFLAGS) -o $@ $< $(V)$(POSTPROCESS_OBJ) $@ $(V)$(OBJDUMP_CMD) @@ -914,7 +916,7 @@ $(BUILD_DIR)/src/%.o: src/%.c ifneq ($(RUN_CC_CHECK),0) $(V)$(CC_CHECK) $< endif - $(call print,Compiling:,$<,$@) + $(call print_two_args,Compiling:,$<,$@) $(V)$(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $< $(V)$(POSTPROCESS_OBJ) $@ $(V)$(OBJDUMP_CMD) @@ -923,13 +925,13 @@ $(BUILD_DIR)/src/audio/session_init.o: src/audio/session_init.c $(BUILD_DIR)/ass ifneq ($(RUN_CC_CHECK),0) $(V)$(CC_CHECK) $< endif - $(call print,Compiling:,$<,$@) + $(call print_two_args,Compiling:,$<,$@) $(V)$(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $(@:.o=.tmp) $< $(V)$(LD) -r -T linker_scripts/data_with_rodata.ld -o $@ $(@:.o=.tmp) $(V)$(OBJDUMP) $(OBJDUMP_FLAGS) $@ > $(@:.o=.s) $(BUILD_DIR)/src/overlays/%_reloc.o: $(BUILD_DIR)/$(SPEC) - $(call print,Generating Relocation:,$<,$@) + $(call print_two_args,Generating Relocation:,$<,$@) $(V)$(FADO) $$(tools/reloc_prereq $< $(notdir $*)) -n $(notdir $*) -o $(@:.o=.s) -M $(@:.o=.d) $(V)$(AS) $(ASFLAGS) $(@:.o=.s) -o $@ @@ -979,22 +981,22 @@ endif .PRECIOUS: $(BUILD_DIR)/assets/audio/samples/%.half.aifc $(BUILD_DIR)/assets/audio/samples/%.half.aifc: assets/audio/samples/%.half.wav - $(call print,Building Sample:,$<,$@) + $(call print_two_args,Building Sample:,$<,$@) $(V)$(SAMPLECONV) vadpcm-half $< $@ $(BUILD_DIR)/assets/audio/samples/%.half.aifc: $(EXTRACTED_DIR)/assets/audio/samples/%.half.wav - $(call print,Building Sample:,$<,$@) + $(call print_two_args,Building Sample:,$<,$@) $(V)$(SAMPLECONV) vadpcm-half $< $@ ifeq ($(AUDIO_BUILD_DEBUG),1) @(cmp $( $@ + $(V)cat $< | $(BUILD_DIR_REPLACE) > $@ $(BUILD_DIR)/assets/audio/soundfonts/%.xml: $(EXTRACTED_DIR)/assets/audio/soundfonts/%.xml - cat $< | $(BUILD_DIR_REPLACE) > $@ + $(V)cat $< | $(BUILD_DIR_REPLACE) > $@ .PRECIOUS: $(BUILD_DIR)/assets/audio/soundfonts/%.c $(BUILD_DIR)/assets/audio/soundfonts/%.h $(BUILD_DIR)/assets/audio/soundfonts/%.name $(BUILD_DIR)/assets/audio/soundfonts/%.c $(BUILD_DIR)/assets/audio/soundfonts/%.h $(BUILD_DIR)/assets/audio/soundfonts/%.name: $(BUILD_DIR)/assets/audio/soundfonts/%.xml | $(SAMPLEBANK_BUILD_XMLS) $(AIFC_FILES) # This rule can be triggered for either the .c or .h file, so $@ may refer to either the .c or .h file. A simple # substitution $(@:.c=.h) will fail ~50% of the time with -j. Instead, don't assume anything about the suffix of $@. - $(SFC) $(SFCFLAGS) --makedepend $(basename $@).d $< $(basename $@).c $(basename $@).h $(basename $@).name + $(V)$(SFC) $(SFCFLAGS) --makedepend $(basename $@).d $< $(basename $@).c $(basename $@).h $(basename $@).name -include $(SOUNDFONT_DEP_FILES) $(BUILD_DIR)/assets/audio/soundfonts/%.o: $(BUILD_DIR)/assets/audio/soundfonts/%.c $(BUILD_DIR)/assets/audio/soundfonts/%.name # compile c to unlinked object - $(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -I include/audio -o $(@:.o=.tmp) $< + $(V)$(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -I include/audio -o $(@:.o=.tmp) $< # partial link - $(LD) -r -T linker_scripts/soundfont.ld $(@:.o=.tmp) -o $(@:.o=.tmp2) + $(V)$(LD) -r -T linker_scripts/soundfont.ld $(@:.o=.tmp) -o $(@:.o=.tmp2) # patch defined symbols to be ABS symbols so that they remain file-relative offsets forever - $(SFPATCH) $(@:.o=.tmp2) $(@:.o=.tmp2) + $(V)$(SFPATCH) $(@:.o=.tmp2) $(@:.o=.tmp2) # write start and size symbols afterwards, filename != symbolic name so source symbolic name from the .name file written by sfc # also write a .note.name section containing the symbolic name of the soundfont - $(OBJCOPY) --add-symbol $$(cat $(<:.c=.name) | tr -d '\0')_Start=.rodata:0,global --redefine-sym __LEN__=$$(cat $(<:.c=.name) | tr -d '\0')_Size --add-section .note.name=$(<:.c=.name) $(@:.o=.tmp2) $@ + $(V)$(OBJCOPY) --add-symbol $$(cat $(<:.c=.name) | tr -d '\0')_Start=.rodata:0,global --redefine-sym __LEN__=$$(cat $(<:.c=.name) | tr -d '\0')_Size --add-section .note.name=$(<:.c=.name) $(@:.o=.tmp2) $@ # cleanup temp files @$(RM) $(@:.o=.tmp) $(@:.o=.tmp2) ifeq ($(AUDIO_BUILD_DEBUG),1) - $(LD) $(foreach f,$(SAMPLEBANK_O_FILES),-R $f) -T linker_scripts/soundfont.ld $@ -o $(@:.o=.elf) - $(OBJCOPY) -O binary -j.rodata $(@:.o=.elf) $(@:.o=.bin) + $(V)$(LD) $(foreach f,$(SAMPLEBANK_O_FILES),-R $f) -T linker_scripts/soundfont.ld $@ -o $(@:.o=.elf) + $(V)$(OBJCOPY) -O binary -j.rodata $(@:.o=.elf) $(@:.o=.bin) @(cmp $(@:.o=.bin) $(patsubst $(BUILD_DIR)/assets/audio/soundfonts/%,$(EXTRACTED_DIR)/baserom_audiotest/audiobank_files/%,$(@:.o=.bin)) && echo "$( rodata @@ -1107,19 +1109,19 @@ endif @$(RM) $(@:.o=.tmp) $(BUILD_DIR)/assets/audio/sequence_font_table.o: $(BUILD_DIR)/assets/audio/sequence_font_table.s - $(AS) $(ASFLAGS) $< -o $@ + $(V)$(AS) $(ASFLAGS) $< -o $@ # make headers with file sizes and amounts $(BUILD_DIR)/assets/audio/soundfont_sizes.h: $(SOUNDFONT_O_FILES) - $(AFILE_SIZES) $@ NUM_SOUNDFONTS SOUNDFONT_SIZES .rodata $^ + $(V)$(AFILE_SIZES) $@ NUM_SOUNDFONTS SOUNDFONT_SIZES .rodata $^ $(BUILD_DIR)/assets/audio/sequence_sizes.h: $(SEQUENCE_O_FILES) - $(AFILE_SIZES) $@ NUM_SEQUENCES SEQUENCE_SIZES .data $^ + $(V)$(AFILE_SIZES) $@ NUM_SEQUENCES SEQUENCE_SIZES .data $^ # Extra audiobank padding that doesn't belong to any soundfont file $(BUILD_DIR)/assets/audio/audiobank_padding.o: - echo ".section .rodata; .fill 0x20" | $(AS) $(ASFLAGS) -o $@ + $(V)echo ".section .rodata; .fill 0x20" | $(AS) $(ASFLAGS) -o $@ -include $(DEP_FILES) diff --git a/tools/Flips/Makefile b/tools/Flips/Makefile index b3d5aeb07..b82aefbd9 100644 --- a/tools/Flips/Makefile +++ b/tools/Flips/Makefile @@ -1,3 +1,5 @@ +MAKEFLAGS += --no-builtin-rules --no-print-directory + #This script creates a debug-optimized binary by default. If you're on Linux, you'll get a faster binary from make.sh. SRCDIR := $(abspath $(patsubst %/,%,$(dir $(abspath $(lastword $(MAKEFILE_LIST)))))) @@ -69,11 +71,13 @@ ifeq ($(TARGET),gtk) endif endif +-include ../print_rules.mk + all: $(FNAME_$(TARGET)) obj: - mkdir obj + $(V)mkdir obj clean: | obj - rm obj/* || true + $(V)rm obj/* || true ifeq ($(TARGET),windows) XFILES += obj/rc.o @@ -92,28 +96,29 @@ ifeq ($(TARGET),gtk) endif $(FNAME_$(TARGET)): $(SOURCES) $(XFILES) - $(CXX) $^ -std=c++98 $(CFLAGS_G) $(MOREFLAGS) $(CPPFLAGS) $(CFLAGS) $(CXXFLAGS) $(LFLAGS) -o$@ + $(call print_two_args,Compiling:,$<,$@) + $(V)$(CXX) $^ -std=c++98 $(CFLAGS_G) $(MOREFLAGS) $(CPPFLAGS) $(CFLAGS) $(CXXFLAGS) $(LFLAGS) -o$@ ifeq ($(CFLAGS),-g) - echo 'Compiled Floating IPS in debug mode; for better performance, use ./make.sh instead' + $(V)echo 'Compiled Floating IPS in debug mode; for better performance, use ./make.sh instead' endif ifeq ($(TARGET),gtk) install: all - mkdir -p $(DESTDIR)$(BINDIR) - mkdir -p $(DESTDIR)$(DATAROOTDIR)/applications - mkdir -p $(DESTDIR)$(DATAROOTDIR)/icons/hicolor/scalable/apps - mkdir -p $(DESTDIR)$(DATAROOTDIR)/icons/hicolor/symbolic/apps - mkdir -p $(DESTDIR)$(DATAROOTDIR)/metainfo - install -p -m755 $(FNAME_$(TARGET)) $(DESTDIR)$(BINDIR) - install -p -m755 $(SRCDIR)/data/com.github.Alcaro.Flips.desktop $(DESTDIR)$(DATAROOTDIR)/applications - install -p -m644 $(SRCDIR)/data/com.github.Alcaro.Flips.svg $(DESTDIR)$(DATAROOTDIR)/icons/hicolor/scalable/apps - install -p -m644 $(SRCDIR)/data/com.github.Alcaro.Flips-symbolic.svg $(DESTDIR)$(DATAROOTDIR)/icons/hicolor/symbolic/apps - install -p -m644 $(SRCDIR)/data/com.github.Alcaro.Flips.metainfo.xml $(DESTDIR)$(DATAROOTDIR)/metainfo + $(V)mkdir -p $(DESTDIR)$(BINDIR) + $(V)mkdir -p $(DESTDIR)$(DATAROOTDIR)/applications + $(V)mkdir -p $(DESTDIR)$(DATAROOTDIR)/icons/hicolor/scalable/apps + $(V)mkdir -p $(DESTDIR)$(DATAROOTDIR)/icons/hicolor/symbolic/apps + $(V)mkdir -p $(DESTDIR)$(DATAROOTDIR)/metainfo + $(V)install -p -m755 $(FNAME_$(TARGET)) $(DESTDIR)$(BINDIR) + $(V)install -p -m755 $(SRCDIR)/data/com.github.Alcaro.Flips.desktop $(DESTDIR)$(DATAROOTDIR)/applications + $(V)install -p -m644 $(SRCDIR)/data/com.github.Alcaro.Flips.svg $(DESTDIR)$(DATAROOTDIR)/icons/hicolor/scalable/apps + $(V)install -p -m644 $(SRCDIR)/data/com.github.Alcaro.Flips-symbolic.svg $(DESTDIR)$(DATAROOTDIR)/icons/hicolor/symbolic/apps + $(V)install -p -m644 $(SRCDIR)/data/com.github.Alcaro.Flips.metainfo.xml $(DESTDIR)$(DATAROOTDIR)/metainfo uninstall: - rm -f $(DESTDIR)$(BINDIR)/$(FNAME_$(TARGET)) - rm -f $(DESTDIR)$(DATAROOTDIR)/applications/com.github.Alcaro.Flips.desktop - rm -f $(DESTDIR)$(DATAROOTDIR)/icons/hicolor/scalable/apps/com.github.Alcaro.Flips.svg - rm -f $(DESTDIR)$(DATAROOTDIR)/icons/hicolor/symbolic/apps/com.github.Alcaro.Flips-symbolic.svg - rm -f $(DESTDIR)$(DATAROOTDIR)/metainfo/com.github.Alcaro.Flips.metainfo.xml + $(V)rm -f $(DESTDIR)$(BINDIR)/$(FNAME_$(TARGET)) + $(V)rm -f $(DESTDIR)$(DATAROOTDIR)/applications/com.github.Alcaro.Flips.desktop + $(V)rm -f $(DESTDIR)$(DATAROOTDIR)/icons/hicolor/scalable/apps/com.github.Alcaro.Flips.svg + $(V)rm -f $(DESTDIR)$(DATAROOTDIR)/icons/hicolor/symbolic/apps/com.github.Alcaro.Flips-symbolic.svg + $(V)rm -f $(DESTDIR)$(DATAROOTDIR)/metainfo/com.github.Alcaro.Flips.metainfo.xml endif diff --git a/tools/Makefile b/tools/Makefile index c591fa583..be3e54473 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -1,3 +1,5 @@ +MAKEFLAGS += --no-builtin-rules --no-print-directory + CFLAGS := -Wall -Wextra -pedantic -std=c99 -g -O2 PROGRAMS := elf2rom makeromfs mkdmadata mkldscript preprocess_pragmas reloc_prereq @@ -34,32 +36,40 @@ ifneq ($(LLD),0) CFLAGS += -fuse-ld=lld endif +-include print_rules.mk + all: $(PROGRAMS) $(IDO_RECOMP_5_3_DIR) $(IDO_RECOMP_7_1_DIR) $(EGCS_DIR) - $(MAKE) -C ZAPD - $(MAKE) -C fado + $(call print_no_args,Building ZAPD...) + $(V)$(MAKE) -C ZAPD + $(call print_no_args,Building fado...) + $(V)$(MAKE) -C fado + $(call print_no_args,Building gzinject...) ifeq ($(wildcard ./gzinject/Makefile),) - cd ./gzinject && ./configure + $(V)cd ./gzinject && ./configure endif - $(MAKE) -C gzinject - $(MAKE) -C z64compress - $(MAKE) -C Flips TARGET=cli - $(MAKE) -C audio + $(V)$(MAKE) -C gzinject + $(call print_no_args,Building z64compress...) + $(V)$(MAKE) -C z64compress + $(call print_no_args,Building Flips...) + $(V)$(MAKE) -C Flips TARGET=cli + $(call print_no_args,Building audio tools...) + $(V)$(MAKE) -C audio clean: - $(RM) $(PROGRAMS) $(addsuffix .exe,$(PROGRAMS)) - $(RM) -r ido_recomp egcs - $(MAKE) -C ZAPD clean - $(MAKE) -C fado clean + $(V)$(RM) $(PROGRAMS) $(addsuffix .exe,$(PROGRAMS)) + $(V)$(RM) -r ido_recomp egcs + $(V)$(MAKE) -C ZAPD clean + $(V)$(MAKE) -C fado clean ifneq ($(wildcard ./gzinject/Makefile),) - $(MAKE) -C gzinject clean + $(V)$(MAKE) -C gzinject distclean endif - $(MAKE) -C z64compress clean - $(MAKE) -C Flips clean - rm Flips/flips - $(MAKE) -C audio clean + $(V)$(MAKE) -C z64compress clean + $(V)$(MAKE) -C Flips clean + $(V)rm Flips/flips + $(V)$(MAKE) -C audio clean distclean: clean - $(MAKE) -C audio distclean + $(V)$(MAKE) -C audio distclean .PHONY: all clean distclean @@ -73,20 +83,21 @@ reloc_prereq_SOURCES := reloc_prereq.c spec.c util.c define COMPILE = $(1): $($1_SOURCES) - $(CC) $(CFLAGS) $$^ -o $$@ + $(call print_two_args,Compiling:,$$^,$$@) + $(V)$(CC) $(CFLAGS) $$^ -o $$@ endef $(foreach p,$(PROGRAMS),$(eval $(call COMPILE,$(p)))) $(IDO_RECOMP_5_3_DIR): - mkdir -p $@ - curl -sL https://github.com/decompals/ido-static-recomp/releases/download/$(IDO_RECOMP_VERSION)/ido-5.3-recomp-$(DETECTED_OS).tar.gz | tar xz -C $@ + $(V)mkdir -p $@ + $(V)curl -sL https://github.com/decompals/ido-static-recomp/releases/download/$(IDO_RECOMP_VERSION)/ido-5.3-recomp-$(DETECTED_OS).tar.gz | tar xz -C $@ $(IDO_RECOMP_7_1_DIR): - mkdir -p $@ - curl -sL https://github.com/decompals/ido-static-recomp/releases/download/$(IDO_RECOMP_VERSION)/ido-7.1-recomp-$(DETECTED_OS).tar.gz | tar xz -C $@ + $(V)mkdir -p $@ + $(V)curl -sL https://github.com/decompals/ido-static-recomp/releases/download/$(IDO_RECOMP_VERSION)/ido-7.1-recomp-$(DETECTED_OS).tar.gz | tar xz -C $@ $(EGCS_DIR): - mkdir -p $@ - curl -sL https://github.com/decompals/mips-binutils-egcs-2.9.5/releases/download/$(EGCS_BINUTILS_VERSION)/mips-binutils-egcs-2.9.5-$(DETECTED_OS).tar.gz | tar xz -C $@ - curl -sL https://github.com/decompals/mips-gcc-egcs-2.91.66/releases/download/$(EGCS_GCC_VERSION)/mips-gcc-egcs-2.91.66-$(DETECTED_OS).tar.gz | tar xz -C $@ + $(V)mkdir -p $@ + $(V)curl -sL https://github.com/decompals/mips-binutils-egcs-2.9.5/releases/download/$(EGCS_BINUTILS_VERSION)/mips-binutils-egcs-2.9.5-$(DETECTED_OS).tar.gz | tar xz -C $@ + $(V)curl -sL https://github.com/decompals/mips-gcc-egcs-2.91.66/releases/download/$(EGCS_GCC_VERSION)/mips-gcc-egcs-2.91.66-$(DETECTED_OS).tar.gz | tar xz -C $@ diff --git a/tools/ZAPD/ExporterTest/Makefile b/tools/ZAPD/ExporterTest/Makefile index 98e047525..3bfe8550a 100644 --- a/tools/ZAPD/ExporterTest/Makefile +++ b/tools/ZAPD/ExporterTest/Makefile @@ -1,3 +1,5 @@ +MAKEFLAGS += --no-builtin-rules --no-print-directory + # Only used for standalone compilation, usually inherits these from the main makefile CXXFLAGS ?= -Wall -Wextra -O2 -g -std=c++17 @@ -11,18 +13,20 @@ LIB := ExporterTest.a # create build directories $(shell mkdir -p $(foreach dir,$(SRC_DIRS),build/$(dir))) +-include ../../print_rules.mk + all: $(LIB) clean: - rm -rf build $(LIB) + $(V)rm -rf build $(LIB) format: - clang-format-14 -i $(CPP_FILES) $(H_FILES) + $(V)clang-format-14 -i $(CPP_FILES) $(H_FILES) .PHONY: all clean format build/%.o: %.cpp - $(CXX) $(CXXFLAGS) $(OPTFLAGS) -I ./ -I ../ZAPD -I ../ZAPDUtils -I ../lib/tinyxml2 -c $(OUTPUT_OPTION) $< + $(V)$(CXX) $(CXXFLAGS) $(OPTFLAGS) -I ./ -I ../ZAPD -I ../ZAPDUtils -I ../lib/tinyxml2 -c $(OUTPUT_OPTION) $< $(LIB): $(O_FILES) - $(AR) rcs $@ $^ + $(V)$(AR) rcs $@ $^ diff --git a/tools/ZAPD/Makefile b/tools/ZAPD/Makefile index 36331937a..3f2e4706c 100644 --- a/tools/ZAPD/Makefile +++ b/tools/ZAPD/Makefile @@ -1,3 +1,5 @@ +MAKEFLAGS += --no-builtin-rules --no-print-directory + # use variables in submakes export OPTIMIZATION_ON ?= 1 @@ -103,49 +105,51 @@ O_FILES += build/ZAPD/BuildInfo.o # create build directories $(shell mkdir -p $(foreach dir,$(SRC_DIRS),build/$(dir))) +-include ../print_rules.mk # Main targets all: ZAPD.out copycheck build/ZAPD/BuildInfo.o: - python3 ZAPD/genbuildinfo.py $(COPYCHECK_ARGS) - $(CXX) $(CXXFLAGS) $(OPTFLAGS) $(INC) -c $(OUTPUT_OPTION) build/ZAPD/BuildInfo.cpp + $(V)python3 ZAPD/genbuildinfo.py $(COPYCHECK_ARGS) + $(V)$(CXX) $(CXXFLAGS) $(OPTFLAGS) $(INC) -c $(OUTPUT_OPTION) build/ZAPD/BuildInfo.cpp copycheck: ZAPD.out - python3 copycheck.py + $(V)python3 copycheck.py clean: - rm -rf build ZAPD.out - $(MAKE) -C lib/libgfxd clean - $(MAKE) -C ZAPDUtils clean - $(MAKE) -C ExporterTest clean + $(V)rm -rf build ZAPD.out + $(V)$(MAKE) -C lib/libgfxd clean + $(V)$(MAKE) -C ZAPDUtils clean + $(V)$(MAKE) -C ExporterTest clean rebuild: clean all format: - clang-format-14 -i $(ZAPD_CPP_FILES) $(ZAPD_H_FILES) - $(MAKE) -C ZAPDUtils format - $(MAKE) -C ExporterTest format + $(V)clang-format-14 -i $(ZAPD_CPP_FILES) $(ZAPD_H_FILES) + $(V)$(MAKE) -C ZAPDUtils format + $(V)$(MAKE) -C ExporterTest format .PHONY: all build/ZAPD/BuildInfo.o copycheck clean rebuild format build/%.o: %.cpp - $(CXX) $(CXXFLAGS) $(OPTFLAGS) $(INC) -c $(OUTPUT_OPTION) $< + $(call print_two_args,Compiling:,$<,$@) + $(V)$(CXX) $(CXXFLAGS) $(OPTFLAGS) $(INC) -c $(OUTPUT_OPTION) $< # Submakes lib/libgfxd/libgfxd.a: - $(MAKE) -C lib/libgfxd + $(V)$(MAKE) -C lib/libgfxd .PHONY: ExporterTest ExporterTest: - $(MAKE) -C ExporterTest + $(V)$(MAKE) -C ExporterTest .PHONY: ZAPDUtils ZAPDUtils: - $(MAKE) -C ZAPDUtils + $(V)$(MAKE) -C ZAPDUtils # Linking ZAPD.out: $(O_FILES) lib/libgfxd/libgfxd.a ExporterTest ZAPDUtils - $(CXX) $(CXXFLAGS) $(O_FILES) lib/libgfxd/libgfxd.a ZAPDUtils/ZAPDUtils.a $(EXPORTERS) $(LDFLAGS) $(OUTPUT_OPTION) + $(V)$(CXX) $(CXXFLAGS) $(O_FILES) lib/libgfxd/libgfxd.a ZAPDUtils/ZAPDUtils.a $(EXPORTERS) $(LDFLAGS) $(OUTPUT_OPTION) diff --git a/tools/ZAPD/ZAPDUtils/Makefile b/tools/ZAPD/ZAPDUtils/Makefile index c0f818bdf..b85be62dd 100644 --- a/tools/ZAPD/ZAPDUtils/Makefile +++ b/tools/ZAPD/ZAPDUtils/Makefile @@ -1,3 +1,5 @@ +MAKEFLAGS += --no-builtin-rules --no-print-directory + # Only used for standalone compilation, usually inherits these from the main makefile CXXFLAGS ?= -Wall -Wextra -O2 -g -std=c++17 @@ -11,18 +13,21 @@ LIB := ZAPDUtils.a # create build directories $(shell mkdir -p $(foreach dir,$(SRC_DIRS),build/$(dir))) +-include ../../print_rules.mk + all: $(LIB) clean: - rm -rf build $(LIB) + $(V)rm -rf build $(LIB) format: - clang-format-14 -i $(CPP_FILES) $(H_FILES) + $(V)clang-format-14 -i $(CPP_FILES) $(H_FILES) .PHONY: all clean format build/%.o: %.cpp - $(CXX) $(CXXFLAGS) $(OPTFLAGS) -c $(OUTPUT_OPTION) $< + $(call print_two_args,Compiling:,$<,$@) + $(V)$(CXX) $(CXXFLAGS) $(OPTFLAGS) -c $(OUTPUT_OPTION) $< $(LIB): $(O_FILES) - $(AR) rcs $@ $^ + $(V)$(AR) rcs $@ $^ diff --git a/tools/ZAPD/lib/libgfxd/Makefile b/tools/ZAPD/lib/libgfxd/Makefile index b340ff5c0..59b2d88d0 100644 --- a/tools/ZAPD/lib/libgfxd/Makefile +++ b/tools/ZAPD/lib/libgfxd/Makefile @@ -1,3 +1,5 @@ +MAKEFLAGS += --no-builtin-rules --no-print-directory + CFLAGS = -Wall -O2 -g UC_OBJ = uc_f3d.o uc_f3db.o uc_f3dex.o uc_f3dexb.o uc_f3dex2.o OBJ = gfxd.o $(UC_OBJ) @@ -6,12 +8,14 @@ LIB = libgfxd.a CPPFLAGS-$(MT) += -DCONFIG_MT CPPFLAGS += $(CPPFLAGS-y) +-include ../../print_rules.mk + .PHONY: all all: $(LIB) .PHONY: clean clean: - rm -f $(OBJ) $(LIB) + $(V)rm -f $(OBJ) $(LIB) .INTERMEDIATE: $(OBJ) @@ -19,7 +23,7 @@ $(OBJ): gbi.h gfxd.h priv.h $(UC_OBJ): uc.c uc_argfn.c uc_argtbl.c uc_macrofn.c uc_macrotbl.c $(LIB): $(OBJ) - $(AR) rcs $@ $^ + $(V)$(AR) rcs $@ $^ %.o: %.c - $(COMPILE.c) $(OUTPUT_OPTION) $< + $(V)$(COMPILE.c) $(OUTPUT_OPTION) $< diff --git a/tools/audio/Makefile b/tools/audio/Makefile index fa74b8c8a..509450a4d 100644 --- a/tools/audio/Makefile +++ b/tools/audio/Makefile @@ -1,3 +1,5 @@ +MAKEFLAGS += --no-builtin-rules --no-print-directory + PROGRAMS := afile_sizes atblgen sbc sfc sfpatch ifeq ($(shell which xml2-config),) @@ -14,21 +16,23 @@ OPTFLAGS := -O2 XML_CFLAGS := $(shell xml2-config --cflags) XML_LDFLAGS := $(shell xml2-config --libs) +-include ../print_rules.mk + .PHONY: all clean distclean format all: $(PROGRAMS) - $(MAKE) -C sampleconv + $(V)$(MAKE) -C sampleconv clean: - $(RM) $(PROGRAMS) - $(MAKE) -C sampleconv clean + $(V)$(RM) $(PROGRAMS) + $(V)$(MAKE) -C sampleconv clean distclean: clean - $(MAKE) -C sampleconv distclean + $(V)$(MAKE) -C sampleconv distclean format: - $(CLANG_FORMAT) $(FORMAT_ARGS) $(shell find . -maxdepth 1 -type f -name "*.[ch]") - $(MAKE) -C sampleconv format + $(V)$(CLANG_FORMAT) $(FORMAT_ARGS) $(shell find . -maxdepth 1 -type f -name "*.[ch]") + $(V)$(MAKE) -C sampleconv format afile_sizes_SOURCES := afile_sizes.c util.c atblgen_SOURCES := audio_tablegen.c samplebank.c soundfont.c xml.c util.c @@ -46,7 +50,7 @@ sfc_LDFLAGS := $(XML_LDFLAGS) define COMPILE = $(1): $($1_SOURCES) - $(CC) $(CFLAGS) $($1_CFLAGS) $$^ $($1_LDFLAGS) -o $$@ + $(V)$(CC) $(CFLAGS) $($1_CFLAGS) $$^ $($1_LDFLAGS) -o $$@ endef $(foreach p,$(PROGRAMS),$(eval $(call COMPILE,$(p)))) diff --git a/tools/audio/sampleconv/Makefile b/tools/audio/sampleconv/Makefile index d30578543..3c65fc3de 100644 --- a/tools/audio/sampleconv/Makefile +++ b/tools/audio/sampleconv/Makefile @@ -1,3 +1,4 @@ +MAKEFLAGS += --no-builtin-rules --no-print-directory CC := gcc CFLAGS := -Wall -Wextra -MMD @@ -15,22 +16,25 @@ DEP_FILES := $(foreach f,$(C_FILES:.c=.d),build/$f) $(shell mkdir -p build $(foreach dir,$(SRC_DIRS),build/$(dir))) +-include ../../print_rules.mk + .PHONY: all clean distclean format all: sampleconv clean: - $(RM) -rf build sampleconv + $(V)$(RM) -rf build sampleconv distclean: clean format: - $(CLANG_FORMAT) $(FORMAT_ARGS) $(C_FILES) $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.h)) + $(V)$(CLANG_FORMAT) $(FORMAT_ARGS) $(C_FILES) $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.h)) sampleconv: $(O_FILES) - $(CC) $(LDFLAGS) $(O_FILES) -lm -o $@ + $(V)$(CC) $(LDFLAGS) $(O_FILES) -lm -o $@ build/src/%.o: src/%.c - $(CC) -c $(CFLAGS) $(OPTFLAGS) $< -o $@ + $(call print_two_args,Compiling:,$<,$@) + $(V)$(CC) -c $(CFLAGS) $(OPTFLAGS) $< -o $@ -include $(DEP_FILES) diff --git a/tools/extract_assets.py b/tools/extract_assets.py index 09519cb1e..313d6ab80 100755 --- a/tools/extract_assets.py +++ b/tools/extract_assets.py @@ -10,6 +10,11 @@ from pathlib import Path import version_config +VERBOSE = False + +def log(s): + if VERBOSE: + print(s) def SignalHandler(sig, frame): print(f'Signal {sig} received. Aborting...') @@ -49,7 +54,7 @@ def ExtractFile(assetConfig: version_config.AssetConfig, outputPath: Path, outpu if globalUnaccounted: execStr += " -Wunaccounted" - print(execStr) + log(execStr) exitValue = os.system(execStr) if exitValue != 0: globalAbort.set() @@ -110,7 +115,7 @@ def processZAPDArgs(argsZ): exit(1) ZAPDArgs = " ".join(f"-{z}" for z in argsZ) - print("Using extra ZAPD arguments: " + ZAPDArgs) + log("Using extra ZAPD arguments: " + ZAPDArgs) return ZAPDArgs def main(): @@ -131,8 +136,12 @@ def main(): parser.add_argument("-j", "--jobs", help="Number of cpu cores to extract with.") parser.add_argument("-u", "--unaccounted", help="Enables ZAPD unaccounted detector warning system.", action="store_true") parser.add_argument("-Z", help="Pass the argument on to ZAPD, e.g. `-ZWunaccounted` to warn about unaccounted blocks in XMLs. Each argument should be passed separately, *without* the leading dash.", metavar="ZAPD_ARG", action="append") + parser.add_argument("--verbose", help="verbose output", action="store_true", default=False) args = parser.parse_args() + global VERBOSE + VERBOSE = args.verbose + baseromSegmentsDir: Path = args.baserom_segments_dir version: str = args.oot_version outputDir: Path = args.output_dir diff --git a/tools/fado/Makefile b/tools/fado/Makefile index d637d45fd..84fc603d5 100644 --- a/tools/fado/Makefile +++ b/tools/fado/Makefile @@ -1,3 +1,5 @@ +MAKEFLAGS += --no-builtin-rules --no-print-directory + DEBUG ?= 0 LLD ?= 0 ASAN ?= 0 @@ -42,14 +44,16 @@ LIB_DIRS := $(shell find lib -type d) C_LIB_FILES := $(filter-out lib/vc_vector/vc_vector_test.c, $(foreach dir,$(LIB_DIRS),$(wildcard $(dir)/*.c))) O_LIB_FILES := $(foreach f,$(C_LIB_FILES:.c=.o),build/$f) +-include ../print_rules.mk + # Main targets all: $(ELF) clean: - $(RM) -r build $(ELF) + $(V)$(RM) -r build $(ELF) format: - clang-format-14 -i $(C_FILES) $(H_FILES) lib/fairy/* + $(V)clang-format-14 -i $(C_FILES) $(H_FILES) lib/fairy/* .PHONY: all clean format @@ -57,10 +61,12 @@ format: $(shell mkdir -p $(foreach dir,$(SRC_DIRS),build/$(dir)) $(foreach dir,$(LIB_DIRS),build/$(dir))) $(ELF): $(O_FILES) $(O_LIB_FILES) - $(CC) $(INC) $(WARNINGS) $(CFLAGS) $(OPTFLAGS) $(LDFLAGS) -o $@ $^ + $(V)$(CC) $(INC) $(WARNINGS) $(CFLAGS) $(OPTFLAGS) $(LDFLAGS) -o $@ $^ build/%.o: %.c $(H_FILES) - $(CC) -c $(INC) $(WARNINGS) $(CFLAGS) $(OPTFLAGS) -o $@ $< + $(call print_two_args,Compiling:,$<,$@) + $(V)$(CC) -c $(INC) $(WARNINGS) $(CFLAGS) $(OPTFLAGS) -o $@ $< build/lib/%.o: lib/%.c - $(CC) -c $(INC) $(WARNINGS) $(CFLAGS) $(OPTFLAGS) -o $@ $< + $(call print_two_args,Compiling:,$<,$@) + $(V)$(CC) -c $(INC) $(WARNINGS) $(CFLAGS) $(OPTFLAGS) -o $@ $< diff --git a/tools/gzinject/Makefile.in b/tools/gzinject/Makefile.in index 92b57f7ca..2570d811e 100644 --- a/tools/gzinject/Makefile.in +++ b/tools/gzinject/Makefile.in @@ -1,3 +1,5 @@ +MAKEFLAGS += --no-builtin-rules --no-print-directory + CC = @CC@ LD = @CC@ INSTALL = @INSTALL@ @@ -16,24 +18,27 @@ LIBS = OBJDIR = obj OUTDIR = $(OBJDIR) +-include ../print_rules.mk + .PHONY : all install clean distclean all : $(PROGNAME) clean : - rm -rf $(PROGNAME) obj + $(V)rm -rf $(PROGNAME) obj distclean : clean - rm -f Makefile + $(V)rm -f Makefile install : $(PROGNAME) - $(INSTALL) -p -D --target-directory=$(DESTDIR)$(bindir) $(PROGNAME) + $(V)$(INSTALL) -p -D --target-directory=$(DESTDIR)$(bindir) $(PROGNAME) $(PROGNAME) : $(COBJ) - $(LD) $(LDFLAGS) $^ -o $@ $(LIBS) + $(V)$(LD) $(LDFLAGS) $^ -o $@ $(LIBS) $(OUTDIR) : - mkdir -p $@ + $(V)mkdir -p $@ $(COBJ) : $(OBJDIR)/%.o: $(SRCDIR)/% | $(OBJDIR) - $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ + $(call print_files,Compiling:,$<,$@) + $(V)$(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ diff --git a/tools/print_rules.mk b/tools/print_rules.mk new file mode 100644 index 000000000..d7abac650 --- /dev/null +++ b/tools/print_rules.mk @@ -0,0 +1,26 @@ +# Verbose toggle +V := @ +ifeq (VERBOSE, 1) + V= +endif + +# Colors +NO_COL := \033[0m +GREEN := \033[0;32m +BLUE := \033[0;36m +YELLOW := \033[0;33m +BLINK := \033[32;5m + +PRINT := printf + +define print_no_args + $(V)$(PRINT) "$(GREEN)$(1)$(NO_COL)\n" +endef + +define print_one_arg + $(V)$(PRINT) "$(GREEN)$(1) $(BLUE)$(2)$(NO_COL)\n" +endef + +define print_two_args + $(V)$(PRINT) "$(GREEN)$(1) $(YELLOW)$(2)$(GREEN) -> $(BLUE)$(3)$(NO_COL)\n" +endef diff --git a/tools/z64compress/Makefile b/tools/z64compress/Makefile index 7a83c6190..8cc8b733b 100644 --- a/tools/z64compress/Makefile +++ b/tools/z64compress/Makefile @@ -1,3 +1,5 @@ +MAKEFLAGS += --no-builtin-rules --no-print-directory + CC := gcc CFLAGS := -DNDEBUG -s -Os -flto -Wall -Wextra @@ -32,6 +34,8 @@ C_FILES := $(foreach dir,$(C_DIRS),$(wildcard $(dir)/*.c)) C_FILES += src/enc/libdeflate/lib/deflate_compress.c src/enc/libdeflate/lib/utils.c O_FILES := $(foreach f,$(C_FILES:.c=.o),$(OBJ_DIR)/$f) +-include ../print_rules.mk + # Make build directories $(shell mkdir -p $(foreach dir,$(SRC_DIRS),$(OBJ_DIR)/$(dir))) @@ -40,10 +44,11 @@ $(shell mkdir -p $(foreach dir,$(SRC_DIRS),$(OBJ_DIR)/$(dir))) all: z64compress z64compress: $(O_FILES) - $(CC) $(TARGET_CFLAGS) $(CFLAGS) $(O_FILES) -lm -lpthread -lz $(TARGET_LIBS) -o z64compress + $(V)$(CC) $(TARGET_CFLAGS) $(CFLAGS) $(O_FILES) -lm -lpthread -lz $(TARGET_LIBS) -o z64compress $(OBJ_DIR)/%.o: %.c - $(CC) -c $(TARGET_CFLAGS) $(CFLAGS) $< -o $@ + $(call print_two_args,Compiling:,$<,$@) + $(V)$(CC) -c $(TARGET_CFLAGS) $(CFLAGS) $< -o $@ clean: - $(RM) -rf z64compress bin o + $(V)$(RM) -rf z64compress bin o