-
Notifications
You must be signed in to change notification settings - Fork 4
/
makefile
196 lines (159 loc) · 6.45 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
#!/usr/bin/make -f
#
# Makefile for Pently music engine
# Copyright 2012-2020 Damian Yerrick
#
# Copying and distribution of this file, with or without
# modification, are permitted in any medium without royalty
# provided the copyright notice and this notice are preserved.
# This file is offered as-is, without any warranty.
#
# These are used in the title of the NES program and the zip file.
title := pently
version := 0.05wip12
# Name of Pently score for main targets "pently.nes" and "pently.nsf"
# is audio/$(scorename).pently, such as audio/musicseq.pently.
# To make a ROM or NSF based on a different score, such as
# audio/pino-a53.pently, use "make pino-a53.nsf".
scorename := musicseq
# Space-separated list of asm files that make up the ROM,
# whether source code or generated
objlist := main \
pads ppuclear paldetect math bpmmath profiler vis \
pentlysound pentlymusic
objlistnsf := pentlysound pentlymusic
# List of documents included in zipfile
docs_md := usage bytecode pentlyas famitracker
AS65 := ca65
ASFLAGS65 :=
LD65 := ld65
objdir := obj/nes
srcdir := src
imgdir := tilesets
DEFAULT_FAMITRACKER := wine "$(HOME)"'/.wine/drive_c/Program Files/FamiTracker/Dn-FamiTracker.exe'
DEFAULT_FT2P := ../ft2pently/ft2p
DEFAULT_EMU := fceux --input1 GamePad.0
DEFAULT_DEBUGEMU := wine "$(HOME)"'/.wine/drive_c/Program Files (x86)/FCEUX/fceux.exe'
# other options for EMU are start "" (Windows) or xdg-open (*n?x) or Mesen.exe
# Allow overriding these with environment variables
# Example 1:
# EMU=Mesen.exe make
# Example 2:
# make EMU=Mesen.exe
# Example 3:
# export FAMITRACKER='C:\Program Files\FamiTracker\0CC-FamiTracker.exe'
# make
# FAMITRACKER and FT2P are needed for automatic .ftm/.0cc to .pently conversion
FAMITRACKER := $(if $(FAMITRACKER),"$(FAMITRACKER)",$(DEFAULT_FAMITRACKER))
FT2P := $(if $(FT2P),$(FT2P),$(DEFAULT_FT2P))
EMU := $(if $(EMU),$(EMU),$(DEFAULT_EMU))
DEBUGEMU := $(if $(DEBUGEMU),$(DEBUGEMU),$(DEFAULT_DEBUGEMU))
# Work around a quirk of how the Python 3 for Windows installer
# sets up the PATH
ifdef COMSPEC
PY:=py -3
else
PY:=python3
endif
.PHONY: run debug clean dist zip all zip.in
run: $(title).nes
$(EMU) $<
debug: $(title).nes
$(DEBUGEMU) $<
clean:
-rm $(objdir)/*.o $(objdir)/*.s $(objdir)/*.chr $(objdir)/*.inc
-rm $(objdir)/*.ftm.txt $(objdir)/*.pently
# Rule to create or update the distribution zipfile by adding all
# files listed in zip.in. Actually the zipfile depends on every
# single file in zip.in, but currently we use changes to the compiled
# program, makefile, and README as a heuristic for when something was
# changed. It won't see changes to docs or tools, but usually when
# docs changes, README also changes, and when tools changes, the
# makefile changes.
dist: zip
zip: $(title)-$(version).zip
$(title)-$(version).zip: zip.in all CHANGES.txt \
README.md CHANGES.txt $(foreach o,$(docs_md),docs/$(o).md) \
$(objdir)/index.txt
zip -9 -u $@ -@ < $<
# Build zip.in from the list of files in the Git tree
zip.in: winbuild.bat
git ls-files | grep -e "^[^.]" > $@
echo pently.nes >> $@
echo pently.nsf >> $@
echo pently.nsfe >> $@
echo zip.in >> $@
echo winbuild.bat >> $@
# This recipe is not parallel-safe! Run make winbuild before make dist
winbuild.bat: tools/makewinbuild.py makefile
$(MAKE) clean
$(MAKE) -n COMSPEC=cmd pently.nes | $(PY) $<
$(objdir)/index.txt: makefile
echo "This file forces the creation of the folder for object files. You may delete it." > $@
# Rules for PRG ROM
objlisto := $(foreach o,$(objlist),$(objdir)/$(o).o)
objlistnsf := $(foreach o,$(objlistnsf),$(objdir)/$(o).o)
all: $(title).nes $(title).nsf $(title).nsfe
# These two build the main binary target
map.txt $(title).nes: nrom128.cfg $(objlisto) $(objdir)/tracknames-$(scorename).o $(objdir)/$(scorename)-rmarks.o
$(LD65) -o $(title).nes -C $^ -m map.txt
nsfmap.txt $(title).nsf: nsf.cfg $(objdir)/nsfshell-$(scorename).o $(objlistnsf) $(objdir)/$(scorename).o
$(LD65) -o $(title).nsf -C $^ -m nsfmap.txt
nsfemap.txt $(title).nsfe: nsfe.cfg $(objdir)/nsfeshell-$(scorename).o $(objlistnsf) $(objdir)/$(scorename).o
$(LD65) -o $(title).nsfe -C $^ -m nsfemap.txt
# These two are for "make pino-a53.nsf" functionality
%.nes: nrom128.cfg $(objlisto) $(objdir)/tracknames-%.o $(objdir)/%-rmarks.o
$(LD65) -o $@ -C $^
%.nsf: nsf.cfg $(objdir)/nsfshell-%.o $(objlistnsf) $(objdir)/%.o
$(LD65) -o $@ -C $^
%.nsfe: nsfe.cfg $(objdir)/nsfeshell-%.o $(objlistnsf) $(objdir)/%.o
$(LD65) -o $@ -C $^
$(objdir)/%.o: \
$(srcdir)/%.s $(srcdir)/nes.inc $(srcdir)/shell.inc $(srcdir)/pently.inc
$(AS65) $(ASFLAGS65) $< -o $@
$(objdir)/%.o: $(objdir)/%.s
$(AS65) $(ASFLAGS65) $< -o $@
# Files that depend on additional headers
$(objdir)/musicseq.o $(objdir)/pentlymusic.o: $(srcdir)/pentlyseq.inc
$(objdir)/pentlysound.o $(objdir)/pentlymusic.o \
$(objdir)/bpmmath.o $(objdir)/vis.o $(objdir)/main.o: \
$(srcdir)/pentlyconfig.inc
$(objdir)/nsfeshell-%.o $(objdir)/nsfshell-%.o: \
$(srcdir)/pentlyconfig.inc $(srcdir)/nsfechunks.inc
$(objdir)/pentlymusic.o: $(objdir)/pentlybss.inc
# Files that depend on .incbin'd files
$(objdir)/main.o: \
$(srcdir)/pentlyconfig.inc $(objdir)/bggfx.chr $(objdir)/spritegfx.chr
# Build RAM map
$(objdir)/pentlybss.inc: tools/pentlybss.py $(srcdir)/pentlyconfig.inc
$(PY) $^ pentlymusicbase -o $@
# Translate music project
$(objdir)/%.s: tools/pentlyas.py audio/%.pently
$(PY) $^ -o $@ --write-inc $(@:.s=-titles.inc) --periods 76
$(objdir)/%-titles.inc: $(objdir)/%.s
touch $@
$(objdir)/nsfshell-%.s: $(objdir)/%-titles.inc $(srcdir)/nsfshell.s
cat $^ > $@
$(objdir)/nsfeshell-%.s: $(objdir)/%-titles.inc $(srcdir)/nsfeshell.s
cat $^ > $@
# Translate music project with bookmarks/rehearsal marks
$(objdir)/%-rmarks.s: tools/pentlyas.py audio/%.pently
$(PY) $^ -o $@ --write-inc $(@:-rmarks.s=-titles.inc) --periods 76 --rehearse
$(objdir)/tracknames-%.s: $(objdir)/%-titles.inc $(srcdir)/tracknames.s
cat $^ > $@
# Translate FamiTracker music project
$(objdir)/%.ftm.txt: audio/%.0cc
$(FAMITRACKER) $< -export $@
$(objdir)/%.ftm.txt: audio/%.ftm
$(FAMITRACKER) $< -export $@
$(objdir)/%.ftm.txt: audio/%.0cc
$(FAMITRACKER) $< -export $@
$(objdir)/%.pently: $(objdir)/%.ftm.txt
$(FT2P) -i $< -o $@
$(objdir)/%.s: tools/pentlyas.py $(objdir)/%.pently
$(PY) $^ -o $@ --write-inc $(@:.s=-titles.inc) --periods 76
$(objdir)/%-rmarks.s: tools/pentlyas.py $(objdir)/%.pently
$(PY) $^ -o $@ --write-inc $(@:-rmarks.s=-titles.inc) --periods 76 --rehearse
# Rules for CHR ROM
$(objdir)/%.chr: $(imgdir)/%.png
$(PY) tools/pilbmp2nes.py $< $@