2016-01-07 09:45:06 +01:00
|
|
|
AS := pokeas
|
|
|
|
ASFLAGS := -mcpu=arm7tdmi
|
|
|
|
|
|
|
|
CC := gbacc
|
|
|
|
CFLAGS := -mthumb-interwork -O2 -Iinclude
|
2015-11-14 06:57:22 +01:00
|
|
|
|
|
|
|
SHA1 := sha1sum -c
|
|
|
|
|
2016-01-07 09:45:06 +01:00
|
|
|
GFX := @tools/gbagfx/gbagfx
|
|
|
|
|
|
|
|
SCANINC := tools/scaninc/scaninc
|
|
|
|
|
2015-11-14 06:57:22 +01:00
|
|
|
# Clear the default suffixes.
|
|
|
|
.SUFFIXES:
|
|
|
|
|
|
|
|
# Secondary expansion is required for dependency variables in object rules.
|
|
|
|
.SECONDEXPANSION:
|
|
|
|
|
|
|
|
.PRECIOUS: %.1bpp %.4bpp %.8bpp %.gbapal %.lz
|
|
|
|
|
2016-01-07 09:45:06 +01:00
|
|
|
.PHONY: rom tools gbagfx scaninc clean compare deps
|
2015-11-14 06:57:22 +01:00
|
|
|
|
2016-01-07 09:45:06 +01:00
|
|
|
CSRCS := $(wildcard src/*.c)
|
|
|
|
OBJS := asm/emerald.o
|
2015-11-14 06:57:22 +01:00
|
|
|
|
2016-01-07 09:45:06 +01:00
|
|
|
ROM := pokeemerald.gba
|
|
|
|
ELF := $(ROM:.gba=.elf)
|
2015-11-14 06:57:22 +01:00
|
|
|
|
2016-01-07 09:45:06 +01:00
|
|
|
rom: $(ROM)
|
2015-11-14 06:57:22 +01:00
|
|
|
|
2015-11-14 07:20:00 +01:00
|
|
|
tools: gbagfx scaninc
|
|
|
|
|
|
|
|
gbagfx:
|
|
|
|
cd tools/gbagfx && make
|
|
|
|
|
|
|
|
scaninc:
|
|
|
|
cd tools/scaninc && make
|
2015-11-14 06:57:22 +01:00
|
|
|
|
|
|
|
# For contributors to make sure a change didn't affect the contents of the ROM.
|
2016-01-07 09:45:06 +01:00
|
|
|
compare: $(ROM)
|
2015-11-14 06:57:22 +01:00
|
|
|
@$(SHA1) rom.sha1
|
|
|
|
|
|
|
|
clean:
|
2016-01-07 09:45:06 +01:00
|
|
|
$(RM) $(ROM) $(ELF) $(OBJS)
|
|
|
|
$(RM) genasm/*
|
2015-11-24 03:31:37 +01:00
|
|
|
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 {} +
|
2015-11-14 06:57:22 +01:00
|
|
|
|
|
|
|
include graphics_file_rules.mk
|
|
|
|
|
|
|
|
%.png: ;
|
|
|
|
%.pal: ;
|
2016-01-07 09:45:06 +01:00
|
|
|
%.1bpp: %.png ; $(GFX) $< $@
|
|
|
|
%.4bpp: %.png ; $(GFX) $< $@
|
|
|
|
%.8bpp: %.png ; $(GFX) $< $@
|
|
|
|
%.gbapal: %.pal ; $(GFX) $< $@
|
|
|
|
%.lz: % ; $(GFX) $< $@
|
|
|
|
|
|
|
|
deps: $(CSRCS:src/%.c=genasm/%.s)
|
|
|
|
$(foreach obj, $(OBJS), \
|
|
|
|
$(eval $(obj)_deps := $(shell $(SCANINC) $(obj:.o=.s))) \
|
|
|
|
)
|
|
|
|
|
|
|
|
$(OBJS): deps
|
|
|
|
|
|
|
|
# TODO: fix this .syntax hack
|
|
|
|
|
|
|
|
genasm/prefix.tmp:
|
|
|
|
echo -e "\t.syntax divided" >$@
|
|
|
|
|
|
|
|
genasm/suffix.tmp:
|
|
|
|
echo -e "\t.syntax unified" >$@
|
|
|
|
|
|
|
|
genasm/%.s: src/%.c genasm/prefix.tmp genasm/suffix.tmp
|
|
|
|
mkdir -p genasm
|
|
|
|
$(CC) $(CFLAGS) -o $@.tmp $< -S
|
|
|
|
cat genasm/prefix.tmp $@.tmp genasm/suffix.tmp >$@
|
|
|
|
$(RM) $@.tmp
|
2015-11-14 06:57:22 +01:00
|
|
|
|
|
|
|
%.o: %.s $$($$@_deps)
|
|
|
|
$(AS) $(ASFLAGS) -o $@ $<
|
|
|
|
|
|
|
|
# Link objects to produce the ROM.
|
2016-01-07 09:45:06 +01:00
|
|
|
$(ROM): $(OBJS)
|
|
|
|
./pokeld -T ld_script.txt -T wram_syms.txt -o $(ELF) $(OBJS)
|
|
|
|
./pokeobjcopy -O binary $(ELF) $(ROM)
|