pokeemerald/Makefile

86 lines
1.8 KiB
Makefile
Raw Normal View History

AS := pokeas
ASFLAGS := -mcpu=arm7tdmi
CC := gbacc
CFLAGS := -mthumb-interwork -O2 -Iinclude
2015-11-14 05:57:22 +00:00
SHA1 := sha1sum -c
GFX := @tools/gbagfx/gbagfx
SCANINC := tools/scaninc/scaninc
2015-11-14 05:57:22 +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
2015-11-14 05:57:22 +00:00
CSRCS := $(wildcard src/*.c)
OBJS := asm/emerald.o
2015-11-14 05:57:22 +00:00
ROM := pokeemerald.gba
ELF := $(ROM:.gba=.elf)
2015-11-14 05:57:22 +00:00
rom: $(ROM)
2015-11-14 05:57:22 +00:00
2015-11-14 06:20:00 +00:00
tools: gbagfx scaninc
gbagfx:
cd tools/gbagfx && make
scaninc:
cd tools/scaninc && make
2015-11-14 05:57:22 +00:00
# For contributors to make sure a change didn't affect the contents of the ROM.
compare: $(ROM)
2015-11-14 05:57:22 +00:00
@$(SHA1) rom.sha1
clean:
$(RM) $(ROM) $(ELF) $(OBJS)
$(RM) genasm/*
2015-11-24 02:31:37 +00: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 05:57:22 +00:00
include graphics_file_rules.mk
%.png: ;
%.pal: ;
%.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 05:57:22 +00:00
%.o: %.s $$($$@_deps)
$(AS) $(ASFLAGS) -o $@ $<
# Link objects to produce the ROM.
$(ROM): $(OBJS)
./pokeld -T ld_script.txt -T wram_syms.txt -o $(ELF) $(OBJS)
./pokeobjcopy -O binary $(ELF) $(ROM)