added readme and license
[gba_blender] / Makefile
1 src = $(wildcard src/*.c)
2 ssrc = $(wildcard src/*.s)
3 obj = $(src:.c=.o) $(ssrc:.s=.o) $(dataobj)
4 dep = $(src:.c=.d)
5 name = blender
6 elf = $(name).elf
7 bin = $(name).gba
8
9 data = data/bg.raw data/bg.pal \
10            data/sprites.raw \
11            data/sprites1.pal \
12            data/sprites2.pal \
13            data/sprites3.pal \
14            data/sprites4.pal \
15            data/sprites5.pal \
16            data/sprites6.pal
17
18 ARCH = arm-none-eabi-
19
20 CPP = $(ARCH)cpp
21 CC = $(ARCH)gcc
22 AS = $(ARCH)as
23 OBJCOPY = $(ARCH)objcopy
24 EMU = vbam
25
26 opt = -O3 -fomit-frame-pointer -mcpu=arm7tdmi -mtune=arm7tdmi -mthumb -mthumb-interwork
27 #dbg = -g
28 def = -DALT_LCLIP
29
30 CFLAGS = $(opt) $(dbg) -pedantic -Wall -MMD $(def)
31 ASFLAGS = -mthumb-interwork
32 LDFLAGS = -mthumb -mthumb-interwork -lm
33 EMUFLAGS = -T 100 -f 1 --agb-print
34
35
36 .PHONY: all
37 all: $(bin) $(bin_mb)
38
39 $(bin): $(elf)
40         $(OBJCOPY) -O binary $(elf) $(bin)
41         gbafix $(bin)
42
43 $(elf): $(obj)
44         $(CC) -o $(elf) $(obj) -specs=gba.specs $(LDFLAGS)
45
46 -include $(dep)
47
48 src/data.o: src/data.s $(data)
49
50 tools/pngdump/pngdump:
51         $(MAKE) -C tools/pngdump
52
53 data/sprites.raw: data/sprites1.png data/sprites2.png data/sprites3.png data/sprites4.png data/sprites5.png data/sprites6.png
54         tools/pngdump/pngdump -o $@ -n $^
55
56 %.raw: %.png tools/pngdump/pngdump
57         tools/pngdump/pngdump -o $@ -n $<
58
59 %.pal: %.png tools/pngdump/pngdump
60         tools/pngdump/pngdump -o $@ -c $<
61
62 .PHONY: clean
63 clean:
64         rm -f $(obj) $(bin) $(bin_mb) $(elf) $(elf_mb)
65
66 .PHONY: cleandep
67 cleandep:
68         rm -f $(dep)
69
70 .PHONY: install
71 install: $(bin)
72         if2a -n -f -W $<
73
74 .PHONY: run
75 run: $(bin_mb)
76         if2a -m $<
77
78 .PHONY: simrun
79 simrun: $(bin)
80         $(EMU) $(EMUFLAGS) $(bin)
81
82 .PHONY: disasm
83 disasm: $(elf)
84         $(ARCH)objdump -d $< >$@