-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile
89 lines (62 loc) · 1.81 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
GAME=from_below
SONGS=MUSIC/songs.s
SOUNDS=MUSIC/sounds.s
CC=cc65
CA=ca65
LD=ld65
text2data=text2data
nsf2data=nsf2data
CFLAGS=-Oirs
DBGFLAGS=-g --add-source
ADBGFLAGS=-g
VSON=-D VS_SYS_ENABLED=1 -D VS_SRAM_ENABLED=0
VSOFF=-D VS_SYS_ENABLED=0 -D VS_SRAM_ENABLED=0
LDFLAGS=-C nrom_32k_vert.cfg --dbgfile main.dbg -Ln labels.txt
GIT_COMMIT:=$(if $(shell git log -1 2>/dev/null),_$(shell git log -1 --date=format:%Y_%m_%d --pretty=format:"%ad" 2>/dev/null),)
all: audio nes vssys
default: nes vssys
nes = BUILD/$(GAME)$(GIT_COMMIT).nes
vssys = BUILD/$(GAME)_vs$(GIT_COMMIT).nes
nes: $(nes)
vssys: $(vssys)
$(SONGS):
$(text2data) MUSIC/songs.txt -ca65
$(SOUNDS):
$(nsf2data) MUSIC/sounds.nsf -ca65
AUDIO = $(SONGS) $(SOUNDS)
audio: $(AUDIO)
$(GAME).s:
$(CC) -o $@ $(DBGFLAGS) $(CFLAGS) $(VSOFF) main.c
$(GAME)_vs.s:
$(CC) -o $@ $(DBGFLAGS) $(CFLAGS) $(VSON) main.c
crt0.o: crt0.s $(AUDIO)
$(CA) -o $@ $(VSOFF) crt0.s
crt0_vs.o: crt0.s $(AUDIO)
$(CA) -o $@ $(VSON) crt0.s
$(GAME).o: $(GAME).s
$(CA) -o $@ $(GAME).s $(ADBGFLAGS)
$(GAME)_vs.o: $(GAME)_vs.s
$(CA) -o $@ from_below_vs.s $(ADBGFLAGS)
nes_obj = crt0.o $(GAME).o
vs_obj = crt0_vs.o $(GAME)_vs.o
BUILD/$(GAME)$(GIT_COMMIT).nes: $(nes_obj)
-mkdir -p BUILD
$(LD) -o $@ $(LDFLAGS) $(nes_obj) nes.lib
BUILD/$(GAME)_vs$(GIT_COMMIT).nes: $(vs_obj)
-mkdir -p BUILD
$(LD) -o $@ $(LDFLAGS) $(vs_obj) nes.lib
clean-audio:
-rm $(SONGS) $(SOUNDS)
clean-nes:
rm -f crt0.o $(GAME).o $(GAME).s *.dbg $(nes) labels.txt
-rmdir BUILD || true
clean-vs:
rm -f crt0_vs.o $(GAME)_vs.o $(GAME)_vs.s *.dbg $(vssys) labels.txt
-rmdir BUILD || true
clean-obj-nes:
rm -f crt0.o $(GAME).o $(GAME).s *.dbg labels.txt
clean-obj-vs:
rm -f crt0_vs.o $(GAME)_vs.o $(GAME)_vs.s *.dbg labels.txt
clean-obj: clean-obj-nes clean-obj-vs
clean: clean-nes clean-vs
clean-all: clean-audio clean