diff options
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 26 |
1 files changed, 23 insertions, 3 deletions
@@ -1,4 +1,8 @@ +ifneq (,$(DEVKITARM)) include $(DEVKITARM)/base_tools +else +PREFIX := $(CURDIR)/tools/binutils/bin/arm-none-eabi- +endif include config.mk ifeq ($(OS),Windows_NT) @@ -13,7 +17,7 @@ endif SHELL := /bin/bash -o pipefail AS := $(PREFIX)as CC1 := tools/agbcc/bin/agbcc$(EXE) -CPP := $(PREFIX)cpp +CPP := $(CC) -E -std=gnu99 LD := $(PREFIX)ld OBJCOPY := $(PREFIX)objcopy SHA1SUM := sha1sum -c @@ -31,6 +35,15 @@ ASFLAGS := -mcpu=arm7tdmi -I include --defsym $(GAME_VERSION)=1 --defsym REVISI CC1FLAGS := -mthumb-interwork -Wimplicit -Wparentheses -Wunused -Werror -O2 -fhex-asm CPPFLAGS := -I tools/agbcc/include -iquote include -nostdinc -undef -Werror -Wno-trigraphs -D $(GAME_VERSION) -D REVISION=$(GAME_REVISION) -D $(GAME_LANGUAGE) -D DEBUG=$(DEBUG) +CPPVERSION := $(shell $(CPP) --version 2>/dev/null || true) + +# Clang's cpp has some issues. +ifneq (,$(filter $(CPPVERSION),clang llvm LLVM Clang)) +override CPP += -Wno-unicode +CLANG_CPP := 1 +else +CLANG_CPP := +endif #### Files #### @@ -62,6 +75,7 @@ LD_SCRIPT := $(BUILD_DIR)/ld_script.ld %src/libs/m4a.o: CC1 := tools/agbcc/bin/old_agbcc$(EXE) %src/libs/libisagbprn.o: CC1 := tools/agbcc/bin/old_agbcc$(EXE) %src/libs/libisagbprn.o: CC1FLAGS := -mthumb-interwork +$(BUILD_DIR)/data/%.o: data/%.s #### Main Rules #### @@ -89,6 +103,10 @@ ifeq ($(NODEP),) $(BUILD_DIR)/data/%.o: ASM_DEP = $(shell $(SCANINC) data/$(*F).s) endif +ifneq (,$(CLANG_CPP)) + $(BUILD_DIR)/data/%.o: override CPP += -P +endif + MAKEFLAGS += --no-print-directory # Secondary expansion is required for dependency variables in object rules. .SECONDEXPANSION: @@ -150,7 +168,7 @@ $(ROM): %.gba: %.elf $(LD_SCRIPT): ld_script.txt $(BUILD_DIR)/sym_common.ld $(BUILD_DIR)/sym_ewram.ld $(BUILD_DIR)/sym_bss.ld cd $(BUILD_DIR) && sed -e "s#tools/#../../tools/#g" ../../ld_script.txt >ld_script.ld $(BUILD_DIR)/sym_%.ld: sym_%.txt - $(CPP) -P $(CPPFLAGS) $< | sed -e "s#tools/#../../tools/#g" > $@ + $(CPP) -P -xc $(CPPFLAGS) $< | sed -e "s#tools/#../../tools/#g" > $@ $(C_OBJECTS): $(BUILD_DIR)/%.o: %.c $$(C_DEP) $(CPP) $(CPPFLAGS) $< -o $(BUILD_DIR)/$*.i @@ -160,7 +178,9 @@ $(C_OBJECTS): $(BUILD_DIR)/%.o: %.c $$(C_DEP) # Only .s files in data need preproc $(BUILD_DIR)/data/%.o: data/%.s $$(ASM_DEP) - $(PREPROC) $< charmap.txt | $(CPP) -I include | $(AS) $(ASFLAGS) -o $@ + $(PREPROC) $< charmap.txt | $(CPP) - -I include | $(AS) $(ASFLAGS) -o $@ + + $(BUILD_DIR)/%.o: %.s $$(ASM_DEP) $(AS) $(ASFLAGS) $< -o $@ |