123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- AS := arm-none-eabi-as
- LD := arm-none-eabi-ld
- OBJCOPY := arm-none-eabi-objcopy
- GRIT := grit
- CC := arm-none-eabi-gcc
- ARS := armips
- MAKE := make
- NM := arm-none-eabi-nm
-
- export PATH := $(realpath ../tools):$(PATH)
-
- DEFINES := -DBPRE -DSOFTWARE_VERSION=0
- ASFLAGS := -mthumb
- CFLAGS := -mthumb -mno-thumb-interwork -mcpu=arm7tdmi -fno-inline -mlong-calls -march=armv4t -O3 -std=gnu99 -Isrc/include $(DEFINES)
- GRITFLAGS := -ftc -fa
- LDFLAGS := -z muldefs
- BLDPATH := object
- OUTPATH := build
- SOURCEDIR := src
-
- MAIN_OBJ := $(BLDPATH)/linked.o
- SPRITES := $(BLDPATH)/pkmn_sprites.o
- ICONS_AR := $(BLDPATH)/pkmn_icons.a
- DYN_OVER := built/dynamic_overworld.o
-
- SND_ROOT := sots-private/sound
- MUSIC_AR := $(SND_ROOT)/Music/music.a
- SMPL_AR := $(SND_ROOT)/Samples/sample.a
- VOICE_AR := $(SND_ROOT)/Voicegroup/voice.a
- LIST_AR := $(SND_ROOT)/Songtable/songlist.a
- CRY_AR := $(SND_ROOT)/Crys/cry.a
-
- rwildcard=$(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2))
-
- ASM_SRC_PP := $(call rwildcard,src/,*.S)
- ASM_SRC := $(call rwildcard,src/,*.s)
- C_SRC := $(call rwildcard,src/,*.c)
- DATA_SRC_PP := $(call rwildcard,data/,*.S)
- DATA_SRC := $(call rwildcard,data/,*.s)
-
- ASM_OBJ_PP := $(ASM_SRC_PP:%.S=$(BLDPATH)/%.o)
- ASM_OBJ := $(ASM_SRC:%.s=$(BLDPATH)/%.o)
- C_OBJ := $(C_SRC:%.c=$(BLDPATH)/%.o)
- DATA_OBJ_PP := $(DATA_SRC_PP:%.S=$(BLDPATH)/%.o)
- DATA_OBJ := $(DATA_SRC:%.s=$(BLDPATH)/%.o)
- ALL_OBJ := $(C_OBJ) $(ASM_OBJ_PP) $(ASM_OBJ) $(DATA_OBJ_PP) $(DATA_OBJ)
-
-
- $(BLDPATH)/%.o: %.c $(ASSETS)
- $(shell mkdir -p $(dir $@))
- $(CC) $(CFLAGS) -c $< -o $@
-
- $(BLDPATH)/%.o: %.S
- $(shell mkdir -p $(dir $@))
- $(CC) $(CFLAGS) -c $< -o $@
-
- $(BLDPATH)/%.o: %.s
- $(shell mkdir -p $(dir $@))
- $(AS) $(ASFLAGS) $< -o $@
-
- all: rom
-
- .PHONY: rom
- rom: main.asm $(MAIN_OBJ)
- $(ARS) $<
- $(NM) $(BLDPATH)/linked.o -n -g --defined-only | \
- sed -e '{s/^/0x/g};{/.*\sA\s.*/d};{s/\sT\s/ /g}' > $(OUTPATH)/__symbols.sym
- @echo "*** SUCCESSFULLY BUILT PROJECT ***"
-
- $(MAIN_OBJ): $(ALL_OBJ) $(ICONS_AR) $(SPRITES) $(DYN_OVER) $(MUSIC_AR) $(SMPL_AR) $(VOICE_AR) $(LIST_AR) $(CRY_AR)
- $(LD) $(LDFLAGS) -T linker.ld -T bpre.sym --whole-archive -r -o $@ --start-group $^ --end-group
-
- .PHONY: clean
- clean:
- rm -R -f build/*
- rm -R -f object/*
- $(MAKE) -C $(dir $(MUSIC_AR)) clean
- $(MAKE) -C $(dir $(SMPL_AR)) clean
- $(MAKE) -C $(dir $(VOICE_AR)) clean
- $(MAKE) -C $(dir $(LIST_AR)) clean
- $(MAKE) -C $(dir $(CRY_AR)) clean
- $(MAKE) -f sprites.makefile clean
- $(MAKE) -f icons.makefile clean
-
- .PHONY: $(ASSETS)
- $(ASSETS):
- $(MAKE) -f assets.makefile
-
- .PHONY: $(SPRITES)
- $(SPRITES):
- $(MAKE) -f sprites.makefile
-
- .PHONY: $(ICONS_AR)
- $(ICONS_AR):
- $(MAKE) -f icons.makefile
-
- .PHONY: $(MUSIC_AR)
- $(MUSIC_AR):
- $(MAKE) -C $(dir $@) all
-
- .PHONY: $(SMPL_AR)
- $(SMPL_AR):
- $(MAKE) -C $(dir $@) all
-
- .PHONY: $(VOICE_AR)
- $(VOICE_AR):
- $(MAKE) -C $(dir $@) all
-
- .PHONY: $(LIST_AR)
- $(LIST_AR):
- $(MAKE) -C $(dir $@) all
-
- .PHONY: $(CRY_AR)
- $(CRY_AR):
- $(MAKE) -C $(dir $@) all
|