diff options
author | M.A <mordbz@gmail.com> | 2020-04-19 20:41:25 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-19 20:41:25 +0300 |
commit | e7bedf19483f0925e90aefa35f481fb7c3582c0a (patch) | |
tree | a4292e511b2345055b26c2bb8c346f19158bda0d /Makefile | |
parent | 16de0d1dd63c15454e6d1af4ecf1f70b8034a745 (diff) | |
parent | b1c106f3f9ebe54458ccf3c2da6639e4ff21c8e2 (diff) |
Merge branch 'master' into master
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 55 |
1 files changed, 47 insertions, 8 deletions
@@ -1,9 +1,33 @@ # Makefile to build Pokemon Diamond image +.PHONY: clean tidy all default patch_mwasmarm + +# Try to include devkitarm if installed +TOOLCHAIN := $(DEVKITARM) + +ifneq (,$(wildcard $(TOOLCHAIN)/base_tools)) +include $(TOOLCHAIN)/base_tools +endif + ### Default target ### default: all +# If you are using WSL, it is recommended you build with NOWINE=1. +NOWINE ?= 0 + +ifeq ($(OS),Windows_NT) +EXE := .exe +WINE := +else +EXE := +WINE := wine +endif + +ifeq ($(NOWINE),1) +WINE := +endif + ################ Target Executable and Sources ############### BUILD_DIR := build @@ -24,12 +48,20 @@ S_FILES := $(foreach dir,$(ASM_DIRS),$(wildcard $(dir)/*.s)) # Object files O_FILES := $(foreach file,$(C_FILES),$(BUILD_DIR)/$(file:.c=.o)) \ $(foreach file,$(S_FILES),$(BUILD_DIR)/$(file:.s=.o)) \ + +################### Universal Dependencies ################### + +# Make tools if out of date +DUMMY != make -s -C tools/mwasmarm_patcher >&2 || echo FAIL +ifeq ($(DUMMY),FAIL) + $(error Failed to build tools) +endif ##################### Compiler Options ####################### MWCCVERSION := 2.0/base -CROSS := arm-linux-gnueabi- +CROSS := arm-none-eabi- MWCCARM := tools/mwccarm/$(MWCCVERSION)/mwccarm.exe # Argh... due to EABI version shenanigans, we can't use GNU LD to link together @@ -40,10 +72,10 @@ MWCCARM := tools/mwccarm/$(MWCCVERSION)/mwccarm.exe MWLDARM := tools/mwccarm/$(MWCCVERSION)/mwldarm.exe MWASMARM := tools/mwccarm/$(MWCCVERSION)/mwasmarm.exe -AS := $(MWASMARM) -CC := $(MWCCARM) +AS := $(WINE) $(MWASMARM) +CC := $(WINE) $(MWCCARM) CPP := cpp -P -LD := $(MWLDARM) +LD := $(WINE) $(MWLDARM) AR := $(CROSS)ar OBJDUMP := $(CROSS)objdump OBJCOPY := $(CROSS)objcopy @@ -51,22 +83,29 @@ OBJCOPY := $(CROSS)objcopy # ./tools/mwccarm/2.0/base/mwasmarm.exe -proc arm5te asm/arm9_thumb.s -o arm9.o ASFLAGS = -proc arm5te CFLAGS = -O4,p -proc v5te -thumb -fp soft -lang c -Cpp_exceptions off -LDFLAGS = -nodead -w off -proc v5te -interworking +LDFLAGS = -map -nodead -w off -proc v5te -interworking ####################### Other Tools ######################### # DS TOOLS TOOLS_DIR = tools SHA1SUM = sha1sum +MWASMARM_PATCHER = tools/mwasmarm_patcher/mwasmarm_patcher$(EXE) ######################### Targets ########################### -all: $(ROM) +all: patch_mwasmarm $(ROM) @$(SHA1SUM) -c $(TARGET).sha1 -clean: +clean: tidy + make -C tools/mwasmarm_patcher clean + +tidy: $(RM) -r $(BUILD_DIR) +patch_mwasmarm: + $(MWASMARM_PATCHER) $(MWASMARM) + ALL_DIRS := $(BUILD_DIR) $(addprefix $(BUILD_DIR)/,$(SRC_DIRS) $(ASM_DIRS)) $(BUILD_DIR)/%.o: %.c @@ -75,7 +114,7 @@ $(BUILD_DIR)/%.o: %.c $(BUILD_DIR)/%.o: %.s $(AS) $(ASFLAGS) $< -o $@ -$(BUILD_DIR)/$(LD_SCRIPT): $(LD_SCRIPT) +$(BUILD_DIR)/$(LD_SCRIPT): $(LD_SCRIPT) undefined_syms.txt $(CPP) $(VERSION_CFLAGS) -MMD -MP -MT $@ -MF $@.d -I include/ -I . -DBUILD_DIR=$(BUILD_DIR) -o $@ $< $(ELF): $(O_FILES) $(BUILD_DIR)/$(LD_SCRIPT) |