pokeruby/Makefile

151 lines
4.9 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
2016-06-29 03:38:22 +00:00
pokeruby_LDFLAGS := -T ld_script_ruby.txt -T iwram_syms.txt -T ewram_syms.txt -Map pokeruby.map
pokesapphire_LDFLAGS := -T ld_script_sapphire.txt -T iwram_syms.txt -T ewram_syms.txt -Map pokesapphire.map
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:
2016-07-24 14:18:38 +00:00
.PRECIOUS: %.1bpp %.4bpp %.8bpp %.gbapal %.lz %.rl
2016-01-24 11:44:21 +00:00
.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-07-25 05:56:03 +00:00
ASM_OBJS := asm/crt0.o asm/rom3.o asm/rom_8040EB4.o asm/rom4.o asm/rom_8074BAC.o asm/rom5.o \
2016-07-23 19:18:19 +00:00
asm/libgcnmultiboot.o asm/m4a_1.o asm/m4a_3.o asm/libagbsyscall.o
2016-04-23 01:25:40 +00:00
2016-08-13 03:15:53 +00:00
DATA_ASM_OBJS := data/data2.o data/graphics.o data/sound_data.o \
2016-08-13 08:00:46 +00:00
data/event_scripts.o data/battle_anim_scripts.o \
2016-08-13 03:15:53 +00:00
data/battle_scripts_1.o data/battle_scripts_2.o data/field_effect_scripts.o \
2016-08-13 08:00:46 +00:00
data/battle_ai_scripts.o data/contest_ai_scripts.o data/script_funcs.o
2016-04-23 01:25:40 +00:00
2016-08-30 04:30:01 +00:00
SONG_SRCS := $(wildcard sound/songs/*.s)
SONG_OBJS := $(SONG_SRCS:%.s=%.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:
2016-06-29 03:38:22 +00:00
rm -f $(ROM) $(ELF) $(OBJS) $(pokeruby_OBJS) $(pokesapphire_OBJS) $(C_SRCS:%.c=%.i) pokeruby.map pokesapphire.map
2016-07-24 14:18:38 +00:00
find . \( -iname '*.1bpp' -o -iname '*.4bpp' -o -iname '*.8bpp' -o -iname '*.gbapal' -o -iname '*.lz' -o -iname '*.rl' \) -exec rm {} +
2016-01-24 11:44:21 +00:00
tidy:
2016-08-30 04:30:01 +00:00
rm -f $(ROM) $(ELF) $(OBJS) $(pokeruby_OBJS) $(pokesapphire_OBJS) $(C_SRCS:%.c=%.i) pokeruby.map pokesapphire.map ld_script_ruby.txt ld_script_sapphire.txt
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
%.s: ;
%.bin: ;
2016-01-24 11:44:21 +00:00
%.png: ;
%.pal: ;
%.1bpp: %.png ; $(GFX) $< $@
%.4bpp: %.png ; $(GFX) $< $@
%.8bpp: %.png ; $(GFX) $< $@
%.gbapal: %.pal ; $(GFX) $< $@
%.lz: % ; $(GFX) $< $@
2016-07-24 14:18:38 +00:00
%.rl: % ; $(GFX) $< $@
2016-01-24 11:44:21 +00:00
2016-07-23 19:18:19 +00:00
src/libc_ruby.o src/libc_sapphire.o: CC1 := tools/agbcc/bin/old_agbcc
src/libc_ruby.o src/libc_sapphire.o: CFLAGS := -O2
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
2016-06-29 05:33:31 +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 $@ $<
2016-06-29 05:33:31 +00:00
asm/%_sapphire.o: asm/%.s $$(dep)
$(AS) $(ASFLAGS) --defsym SAPPHIRE=1 -o $@ $<
2016-06-29 05:33:31 +00:00
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 $@
2016-06-29 05:33:31 +00:00
data/%_sapphire.o: data/%.s $$(dep)
$(PREPROC) $< charmap.txt | $(AS) $(ASFLAGS) --defsym SAPPHIRE=1 -o $@
2016-01-24 11:44:21 +00:00
2016-08-30 04:30:01 +00:00
$(SONG_OBJS): %.o: %.s
$(AS) $(ASFLAGS) -I sound -o $@ $<
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
2016-08-30 04:30:01 +00:00
pokeruby.elf: ld_script_ruby.txt $(pokeruby_OBJS) $(SONG_OBJS)
$(LD) $(pokeruby_LDFLAGS) -o $@ $(pokeruby_OBJS) $(SONG_OBJS) $(LIBGCC)
pokesapphire.elf: ld_script_sapphire.txt $(pokesapphire_OBJS) $(SONG_OBJS)
$(LD) $(pokesapphire_LDFLAGS) -o $@ $(pokesapphire_OBJS) $(SONG_OBJS) $(LIBGCC)
2016-04-23 01:25:40 +00:00
%.gba: %.elf
$(OBJCOPY) -O binary --gap-fill 0xFF --pad-to 0x9000000 $< $@