Skip to content

Commit a4b5e94

Browse files
Build cleanups/fixes
* Use absolute path for ndstool in case devKitPro is not in $PATH * Allow adpcm-xq to overwrite files, fixes partial builds in some cases * Create proper Makefile dependencies for ARM7/ARM9 binaries with output consistent with the rest of the build system
1 parent 206263f commit a4b5e94

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

Makefile

+16-5
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ ifeq ($(TARGET_NDS),1)
6464
COMPILER := gcc
6565
DEVKITPRO ?= /opt/devkitpro
6666
DEVKITARM ?= $(DEVKITPRO)/devkitARM
67+
NDSTOOL ?= $(DEVKITPRO)/tools/bin/ndstool
6768
endif
6869

6970
TARGET := sm64.$(VERSION)
@@ -216,6 +217,8 @@ BUILD_DIR_BASE := build
216217
# BUILD_DIR is the location where all build artifacts are placed
217218
ifeq ($(TARGET_NDS),1)
218219
BUILD_DIR := $(BUILD_DIR_BASE)/$(VERSION)_nds
220+
ARM7 := $(BUILD_DIR)/$(TARGET).arm7.elf
221+
ARM9 := $(BUILD_DIR)/$(TARGET).arm9.elf
219222
ROM := $(BUILD_DIR)/$(TARGET).nds
220223
else
221224
BUILD_DIR := $(BUILD_DIR_BASE)/$(VERSION)
@@ -649,7 +652,7 @@ $(BUILD_DIR)/%.wav: %.aiff
649652

650653
$(BUILD_DIR)/%.ima: $(BUILD_DIR)/%.wav
651654
$(call print,Encoding IMA:,$<,$@)
652-
$(V)$(ADPCM_XQ) -q -r -b15 $^ $@
655+
$(V)$(ADPCM_XQ) -y -q -r -b15 $^ $@
653656

654657
else
655658
$(BUILD_DIR)/%.table: %.aiff
@@ -836,10 +839,18 @@ $(BUILD_DIR)/rsp/%.bin $(BUILD_DIR)/rsp/%_data.bin: rsp/%.s
836839

837840
# Build NDS ROM
838841
ifeq ($(TARGET_NDS),1)
839-
$(ROM): $(O_FILES) $(ARM7_O_FILES) $(MIO0_FILES:.mio0=.o) $(ULTRA_O_FILES) $(GODDARD_O_FILES)
840-
$(LD) -L $(BUILD_DIR) -o $@.arm9.elf $(O_FILES) $(ULTRA_O_FILES) $(GODDARD_O_FILES) $(LDFLAGS)
841-
$(LD) -L $(BUILD_DIR) -o $@.arm7.elf $(ARM7_O_FILES) $(ARM7_LDFLAGS)
842-
ndstool -c $@ -9 $@.arm9.elf -7 $@.arm7.elf
842+
843+
$(ARM7): $(ARM7_O_FILES)
844+
@$(PRINT) "$(GREEN)Linking ARM7 binary: $(BLUE)$@ $(NO_COL)\n"
845+
$(V)$(LD) -L $(BUILD_DIR) -o $@ $(ARM7_O_FILES) $(ARM7_LDFLAGS)
846+
847+
$(ARM9): $(O_FILES) $(MIO0_FILES:.mio0=.o) $(ULTRA_O_FILES) $(GODDARD_O_FILES)
848+
@$(PRINT) "$(GREEN)Linking ARM9 binary: $(BLUE)$@ $(NO_COL)\n"
849+
$(V)$(LD) -L $(BUILD_DIR) -o $@ $(O_FILES) $(ULTRA_O_FILES) $(GODDARD_O_FILES) $(LDFLAGS)
850+
851+
$(ROM): $(ARM7) $(ARM9)
852+
@$(PRINT) "$(GREEN)Building ROM: $(BLUE)$@ $(NO_COL)\n"
853+
$(V)$(NDSTOOL) -c $@ -9 $(ARM9) -7 $(ARM7)
843854
else
844855

845856
# Run linker script through the C preprocessor

0 commit comments

Comments
 (0)