diff options
| author | YamaArashi <shadow962@live.com> | 2016-04-22 18:25:40 -0700 |
|---|---|---|
| committer | YamaArashi <shadow962@live.com> | 2016-04-22 18:25:40 -0700 |
| commit | 0df6676bfccb1d68aa741997702d2a558110d322 (patch) | |
| tree | 440a7906ea6e75e17079ff1aed44900942b1e85a /Makefile | |
| parent | 0601fb4d0013bd0f2508364b313acbdc371da674 (diff) | |
use preprocessor
Diffstat (limited to 'Makefile')
| -rw-r--r-- | Makefile | 45 |
1 files changed, 28 insertions, 17 deletions
@@ -10,6 +10,8 @@ GFX := @tools/gbagfx/gbagfx SCANINC := tools/scaninc/scaninc +PREPROC := tools/preproc/preproc + # Clear the default suffixes. .SUFFIXES: @@ -20,19 +22,22 @@ SCANINC := tools/scaninc/scaninc .PHONY: rom tools gbagfx scaninc clean compare deps -CSRCS := $(wildcard src/*.c) -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 \ - src/string_util.o src/rtc.o src/play_time.o src/task.o \ - src/agb_flash.o src/agb_flash_1m.o src/agb_flash_mx.o src/siirtc.o \ - data/data1.o data/data2.o +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) ROM := pokeruby.gba ELF := $(ROM:.gba=.elf) rom: $(ROM) -tools: gbagfx scaninc +tools: gbagfx scaninc preproc gbagfx: cd tools/gbagfx && make @@ -40,6 +45,9 @@ gbagfx: scaninc: cd tools/scaninc && make +preproc: + cd tools/preproc && make + # For contributors to make sure a change didn't affect the contents of the ROM. compare: $(ROM) @$(SHA1) rom.sha1 @@ -59,22 +67,25 @@ include tilesets.mk %.gbapal: %.pal ; $(GFX) $< $@ %.lz: % ; $(GFX) $< $@ -$(OBJS): $(CSRCS:src/%.c=src/%.s) +src/siirtc.o: CFLAGS := -mthumb-interwork -Iinclude -src/siirtc.s: CFLAGS := -mthumb-interwork -Iinclude +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 -src/agb_flash.s: CFLAGS := -O -mthumb-interwork -Iinclude -src/agb_flash_1m.s: CFLAGS := -O -mthumb-interwork -Iinclude -src/agb_flash_mx.s: CFLAGS := -O -mthumb-interwork -Iinclude +$(C_OBJS): %.o : %.c + $(CC) $(CFLAGS) -o $*.s $< -S + echo -e ".text\n\t.align\t2, 0\n" >> $*.s + $(AS) $(ASFLAGS) -o $@ $*.s -src/%.s: src/%.c - $(CC) $(CFLAGS) -o $@ $< -S - echo -e ".text\n\t.align\t2, 0\n" >> $@ +%.o : dep = $(shell $(SCANINC) $*.s) -%.o: dep = $(shell $(SCANINC) $(@D)/$*.s) -%.o: %.s $$(dep) +$(ASM_OBJS): %.o: %.s $$(dep) $(AS) $(ASFLAGS) -o $@ $< +$(DATA_ASM_OBJS): %.o: %.s $$(dep) + $(PREPROC) $< charmap.txt | $(AS) $(ASFLAGS) -o $@ + # Link objects to produce the ROM. $(ROM): $(OBJS) ./pokeld -T ld_script.txt -T iwram_syms.txt -T ewram_syms.txt -o $(ELF) $(OBJS) |
