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 06:57:22 +01:00
SHA1 := sha1sum -c
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
.PHONY: rom tools gbagfx scaninc clean compare deps
2015-11-14 06:57:22 +01:00
CSRCS := $(wildcard src/*.c)
OBJS := asm/emerald.o
2015-11-14 06:57:22 +01:00
2016-01-08 10:08:16 +01:00
$(foreach obj, $(OBJS), \
$(eval $(obj)_deps := $(shell $(SCANINC) $(obj:.o=.s))) \
)
ROM := pokeemerald.gba
ELF := $(ROM:.gba=.elf)
2015-11-14 06:57:22 +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.
compare: $(ROM)
2015-11-14 06:57:22 +01:00
@$(SHA1) rom.sha1
clean:
$(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: ;
%.1bpp: %.png ; $(GFX) $< $@
%.4bpp: %.png ; $(GFX) $< $@
%.8bpp: %.png ; $(GFX) $< $@
%.gbapal: %.pal ; $(GFX) $< $@
%.lz: % ; $(GFX) $< $@
2016-01-08 10:08:16 +01:00
$(OBJS): $(CSRCS:src/%.c=genasm/%.s)
# 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
2016-01-08 10:08:16 +01:00
cat genasm/prefix.tmp $@.tmp genasm/suffix.tmp >$@.tmp2
perl fix_local_labels.pl $@.tmp2 $@
$(RM) $@.tmp $@.tmp2
2015-11-14 06:57:22 +01: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)