2016-04-23 03:44:21 +00:00
|
|
|
AS := arm-none-eabi-as
|
2016-01-24 11:44:21 +00:00
|
|
|
ASFLAGS := -mcpu=arm7tdmi
|
|
|
|
|
|
|
|
CC := gbacc
|
|
|
|
CFLAGS := -mthumb-interwork -O2 -Iinclude
|
|
|
|
|
|
|
|
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: rom tools gbagfx scaninc clean compare deps
|
|
|
|
|
2016-04-23 01:25:40 +00:00
|
|
|
C_SRCS := $(wildcard src/*.c)
|
|
|
|
C_OBJS := $(C_SRCS:%.c=%.o)
|
|
|
|
|
|
|
|
ASM_OBJS := asm/crt0.o asm/rom1.o asm/rom2.o asm/rom3.o asm/rom4.o asm/rom5.o \
|
|
|
|
asm/libgcnmultiboot.o asm/libmks4agb.o asm/libagbsyscall.o asm/libgcc.o
|
|
|
|
|
|
|
|
DATA_ASM_OBJS := data/data1.o data/data2.o
|
|
|
|
|
|
|
|
OBJS := $(C_OBJS) $(ASM_OBJS) $(DATA_ASM_OBJS)
|
2016-01-24 11:44:21 +00:00
|
|
|
|
|
|
|
ROM := pokeruby.gba
|
|
|
|
ELF := $(ROM:.gba=.elf)
|
|
|
|
|
|
|
|
rom: $(ROM)
|
|
|
|
|
2016-04-23 01:25:40 +00:00
|
|
|
tools: gbagfx scaninc preproc
|
2016-01-24 11:44:21 +00:00
|
|
|
|
|
|
|
gbagfx:
|
|
|
|
cd tools/gbagfx && make
|
|
|
|
|
|
|
|
scaninc:
|
|
|
|
cd tools/scaninc && make
|
|
|
|
|
2016-04-23 01:25:40 +00:00
|
|
|
preproc:
|
|
|
|
cd tools/preproc && make
|
|
|
|
|
2016-01-24 11:44:21 +00:00
|
|
|
# For contributors to make sure a change didn't affect the contents of the ROM.
|
|
|
|
compare: $(ROM)
|
|
|
|
@$(SHA1) rom.sha1
|
|
|
|
|
|
|
|
clean:
|
|
|
|
$(RM) $(ROM) $(ELF) $(OBJS)
|
|
|
|
find . \( -iname '*.1bpp' -o -iname '*.4bpp' -o -iname '*.8bpp' -o -iname '*.gbapal' -o -iname '*.lz' -o -iname '*.latfont' -o -iname '*.hwjpnfont' -o -iname '*.fwjpnfont' \) -exec rm {} +
|
|
|
|
|
2016-01-29 11:55:59 +00:00
|
|
|
include castform.mk
|
|
|
|
include tilesets.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) $< $@
|
|
|
|
|
2016-04-23 01:25:40 +00:00
|
|
|
src/siirtc.o: CFLAGS := -mthumb-interwork -Iinclude
|
2016-01-24 11:44:21 +00:00
|
|
|
|
2016-04-23 01:25:40 +00:00
|
|
|
src/agb_flash.o: CFLAGS := -O -mthumb-interwork -Iinclude
|
|
|
|
src/agb_flash_1m.o: CFLAGS := -O -mthumb-interwork -Iinclude
|
|
|
|
src/agb_flash_mx.o: CFLAGS := -O -mthumb-interwork -Iinclude
|
2016-01-24 11:44:21 +00:00
|
|
|
|
2016-04-23 01:25:40 +00:00
|
|
|
$(C_OBJS): %.o : %.c
|
|
|
|
$(CC) $(CFLAGS) -o $*.s $< -S
|
|
|
|
echo -e ".text\n\t.align\t2, 0\n" >> $*.s
|
|
|
|
$(AS) $(ASFLAGS) -o $@ $*.s
|
2016-01-24 11:44:21 +00:00
|
|
|
|
2016-04-23 01:25:40 +00:00
|
|
|
%.o : dep = $(shell $(SCANINC) $*.s)
|
2016-01-24 11:44:21 +00:00
|
|
|
|
2016-04-23 01:25:40 +00:00
|
|
|
$(ASM_OBJS): %.o: %.s $$(dep)
|
2016-01-24 11:44:21 +00:00
|
|
|
$(AS) $(ASFLAGS) -o $@ $<
|
|
|
|
|
2016-04-23 01:25:40 +00:00
|
|
|
$(DATA_ASM_OBJS): %.o: %.s $$(dep)
|
|
|
|
$(PREPROC) $< charmap.txt | $(AS) $(ASFLAGS) -o $@
|
|
|
|
|
2016-01-24 11:44:21 +00:00
|
|
|
# Link objects to produce the ROM.
|
|
|
|
$(ROM): $(OBJS)
|
2016-04-23 03:44:21 +00:00
|
|
|
arm-none-eabi-ld -T ld_script.txt -T iwram_syms.txt -T ewram_syms.txt -o $(ELF) $(OBJS)
|
|
|
|
arm-none-eabi-objcopy -O binary $(ELF) $(ROM)
|