pokeruby/Makefile

135 lines
4.3 KiB
Makefile
Raw Normal View History

2016-04-30 11:19:00 +00:00
AS := $(DEVKITARM)/bin/arm-none-eabi-as
2016-01-24 11:44:21 +00:00
ASFLAGS := -mcpu=arm7tdmi
2016-04-30 11:19:00 +00:00
CC1 := tools/agbcc/bin/agbcc
CFLAGS := -mthumb-interwork -O2
2016-05-11 04:39:46 +00:00
CPP := $(DEVKITARM)/bin/arm-none-eabi-cpp
2016-04-30 19:11:28 +00:00
CPPFLAGS := -I tools/agbcc/include -iquote include -nostdinc -undef
2016-04-30 11:19:00 +00:00
LD := $(DEVKITARM)/bin/arm-none-eabi-ld
pokeruby_LDFLAGS := -T ld_script_ruby.txt -T iwram_syms.txt -T ewram_syms.txt
pokesapphire_LDFLAGS := -T ld_script_sapphire.txt -T iwram_syms.txt -T ewram_syms.txt
2016-04-30 11:19:00 +00:00
OBJCOPY := $(DEVKITARM)/bin/arm-none-eabi-objcopy
LIBGCC := tools/agbcc/lib/libgcc.a
2016-01-24 11:44:21 +00:00
SHA1 := sha1sum -c
GFX := @tools/gbagfx/gbagfx
SCANINC := tools/scaninc/scaninc
2016-04-23 01:25:40 +00:00
PREPROC := tools/preproc/preproc
2016-01-24 11:44:21 +00:00
# Clear the default suffixes.
.SUFFIXES:
# Secondary expansion is required for dependency variables in object rules.
.SECONDEXPANSION:
.PRECIOUS: %.1bpp %.4bpp %.8bpp %.gbapal %.lz
.PHONY: all clean compare ruby sapphire
2016-01-24 11:44:21 +00:00
2016-04-23 01:25:40 +00:00
C_SRCS := $(wildcard src/*.c)
C_OBJS := $(C_SRCS:%.c=%.o)
2016-06-10 10:32:55 +00:00
ASM_OBJS := asm/crt0.o asm/rom3.o asm/rom4.o asm/rom_8074BAC.o asm/rom5.o \
2016-05-13 06:30:01 +00:00
asm/libgcnmultiboot.o asm/m4a_1.o asm/m4a_3.o asm/libagbsyscall.o asm/libc.o
2016-04-23 01:25:40 +00:00
2016-06-20 02:25:21 +00:00
DATA_ASM_OBJS := data/data1.o data/data2.o data/graphics.o data/sound_data.o \
data/event_scripts.o
2016-04-23 01:25:40 +00:00
OBJS := $(C_OBJS) $(ASM_OBJS) $(DATA_ASM_OBJS)
pokeruby_OBJS := $(OBJS:.o=_ruby.o)
pokesapphire_OBJS := $(OBJS:.o=_sapphire.o)
2016-01-24 11:44:21 +00:00
ROM := pokeruby.gba pokesapphire.gba
2016-01-24 11:44:21 +00:00
ELF := $(ROM:.gba=.elf)
all: ruby
@:
both: ruby sapphire
@:
ruby: pokeruby.gba
@:
sapphire: pokesapphire.gba
@:
2016-01-24 11:44:21 +00:00
# For contributors to make sure a change didn't affect the contents of the ROM.
compare: both
2016-01-24 11:44:21 +00:00
@$(SHA1) rom.sha1
clean:
rm -f $(ROM) $(ELF) $(OBJS) $(pokeruby_OBJS) $(pokesapphire_OBJS) $(C_SRCS:%.c=%.i)
2016-05-27 22:08:48 +00:00
find . \( -iname '*.1bpp' -o -iname '*.4bpp' -o -iname '*.8bpp' -o -iname '*.gbapal' -o -iname '*.lz' \) -exec rm {} +
2016-01-24 11:44:21 +00:00
tidy:
rm -f $(ROM) $(ELF) $(OBJS) $(pokeruby_OBJS) $(pokesapphire_OBJS) $(C_SRCS:%.c=%.i)
2016-01-29 11:55:59 +00:00
include castform.mk
include tilesets.mk
2016-05-27 22:08:48 +00:00
include fonts.mk
include generated.mk
include misc.mk
2016-01-24 11:44:21 +00:00
%.png: ;
%.pal: ;
%.1bpp: %.png ; $(GFX) $< $@
%.4bpp: %.png ; $(GFX) $< $@
%.8bpp: %.png ; $(GFX) $< $@
%.gbapal: %.pal ; $(GFX) $< $@
%.lz: % ; $(GFX) $< $@
src/siirtc_ruby.o src/siirtc_sapphire.o: CFLAGS := -mthumb-interwork
2016-01-24 11:44:21 +00:00
2016-06-19 02:06:21 +00:00
src/agb_flash_ruby.o src/agb_flash_sapphire.o: CFLAGS := -O -mthumb-interwork
src/agb_flash_1m_ruby.o src/agb_flash_1m_sapphire.o: CFLAGS := -O -mthumb-interwork
src/agb_flash_mx_ruby.o src/agb_flash_mx_sapphire.o: CFLAGS := -O -mthumb-interwork
2016-01-24 11:44:21 +00:00
src/m4a_2_ruby.o src/m4a_2_sapphire.o: CC1 := tools/agbcc/bin/old_agbcc
2016-06-19 08:56:37 +00:00
src/m4a_4_ruby.o src/m4a_4_sapphire.o: CC1 := tools/agbcc/bin/old_agbcc
2016-05-13 06:30:01 +00:00
src/text_ruby.o src/text_sapphire.o: src/text.c $(GEN_FONT_HEADERS)
src/link_ruby.o src/link_sapphire.o: src/link.c $(GEN_LINK_HEADERS)
src/%_ruby.o: src/%.c
@$(CPP) $(CPPFLAGS) -D RUBY $< -o src/$*_ruby.i
@$(PREPROC) src/$*_ruby.i charmap.txt | $(CC1) $(CFLAGS) -o src/$*_ruby.s
@printf ".text\n\t.align\t2, 0\n" >> src/$*_ruby.s
$(AS) $(ASFLAGS) -o $@ src/$*_ruby.s
src/%_sapphire.o: src/%.c
@$(CPP) $(CPPFLAGS) -D SAPPHIRE $< -o src/$*_sapphire.i
@$(PREPROC) src/$*_sapphire.i charmap.txt | $(CC1) $(CFLAGS) -o src/$*_sapphire.s
@printf ".text\n\t.align\t2, 0\n" >> src/$*_sapphire.s
$(AS) $(ASFLAGS) -o $@ src/$*_sapphire.s
2016-01-24 11:44:21 +00:00
asm/%_ruby.o: $*_dep = $(shell $(SCANINC) asm/$*.s)
asm/%_sapphire.o: $*_dep = $(shell $(SCANINC) asm/$*.s)
asm/%_ruby.o: asm/%.s $$(%_dep)
$(AS) $(ASFLAGS) --defsym RUBY=1 -o $@ $<
asm/%_sapphire.o: asm/%.s $$(%_dep)
$(AS) $(ASFLAGS) --defsym SAPPHIRE=1 -o $@ $<
data/%_ruby.o: $*_dep = $(shell $(SCANINC) data/$*.s)
data/%_sapphire.o: $*_dep = $(shell $(SCANINC) data/$*.s)
data/%_ruby.o: data/%.s $$(%_dep)
$(PREPROC) $< charmap.txt | $(AS) $(ASFLAGS) --defsym RUBY=1 -o $@
data/%_sapphire.o: data/%.s $$(%_dep)
$(PREPROC) $< charmap.txt | $(AS) $(ASFLAGS) --defsym SAPPHIRE=1 -o $@
2016-01-24 11:44:21 +00:00
ld_script_ruby.txt: ld_script.txt
2016-06-19 06:50:35 +00:00
@sed 's#\(\(src\|asm\|data\)/.*\)\.o#\1_ruby.o#g' $< > $@
ld_script_sapphire.txt: ld_script.txt
2016-06-19 06:50:35 +00:00
@sed 's#\(\(src\|asm\|data\)/.*\)\.o#\1_sapphire.o#g' $< > $@
2016-01-24 11:44:21 +00:00
pokeruby.elf: ld_script_ruby.txt $(pokeruby_OBJS)
$(LD) $(pokeruby_LDFLAGS) -o $@ $(pokeruby_OBJS) $(LIBGCC)
pokesapphire.elf: ld_script_sapphire.txt $(pokesapphire_OBJS)
$(LD) $(pokesapphire_LDFLAGS) -o $@ $(pokesapphire_OBJS) $(LIBGCC)
2016-04-23 01:25:40 +00:00
%.gba: %.elf
$(OBJCOPY) -O binary --gap-fill 0xFF --pad-to 0x9000000 $< $@