-
Notifications
You must be signed in to change notification settings - Fork 1
/
makefile
131 lines (102 loc) · 3.94 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
#!/usr/bin/make -f
#
# Makefile for Zapper tech demo for NES
# Copyright 2011, 2014 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 = ruder
version = 0.03a
# Space-separated list of assembly language files that make up the
# PRG ROM. If it gets too long for one line, you can add a backslash
# (the \ character) at the end of the line and continue on the next.
objlist := zapkernels main ppuclear title menu testpatterns \
drawball kinematics tennis tennisgfx axe \
pentlysound pentlymusic musicseq ntscPeriods \
bcd math pads unpkb
objlistnsf := nsfshell pentlysound pentlymusic musicseq ntscPeriods
AS65 := ca65
LD65 := ld65
CFLAGS65 := -DZAPPER_TO_A_BUTTON=1 -DPENTLY_USE_PAL_ADJUST=0 \
-DPENTLY_USE_ROW_CALLBACK=1
objdir := obj/nes
srcdir := src
imgdir := tilesets
EMU := Mesen
# other options for EMU are start (Windows) or gnome-open (GNOME)
# Occasionally, you need to make "build tools", or programs that run
# on a PC that convert, compress, or otherwise translate PC data
# files into the format that the NES program expects. Some people
# write their build tools in C or C++; others prefer to write them in
# Perl, PHP, or Python. This program doesn't use any C build tools,
# but if yours does, it might include definitions of variables that
# Make uses to call a C compiler.
CC := gcc
CFLAGS := -std=gnu99 -Wall -DNDEBUG -O
# Windows needs .exe suffixed to the names of executables; UNIX does
# not. COMSPEC will be set to the name of the shell on Windows and
# not defined on UNIX.
ifdef COMSPEC
DOTEXE:=.exe
PY:=py
else
DOTEXE:=
PY:=python3
endif
.PHONY: run debug all dist zip clean
run: $(title).nes
$(EMU) $<
# packaging
# Actually this depends on every file in zip.in, but currently we use
# changes to the ROM, makefile, and README as a heuristic for when
# something was changed. Limitation: it won't see changes to docs or
# tools unless there is a corresponding makefile change.
all: $(title).nes $(title).nsf
dist: zip
zip: $(title)-$(version).zip
$(title)-$(version).zip: zip.in $(title).nes $(title).nsf \
README.md CHANGES.txt $(objdir)/index.txt
zip -9 -u $@ -@ < $<
# Build zip.in from the list of files in the Git tree
zip.in:
git ls-files | grep -e "^[^.]" > $@
echo zip.in >> $@
echo $(title).nes >> $@
echo $(title).nsf >> $@
clean:
$(RM) $(objdir)/*.o $(objdir)/*.s $(objdir)/*.chr
$(objdir)/index.txt: makefile
echo Files produced by build tools go here, but caulk goes where? > $@
# Rules for PRG ROM
objlistntsc := $(foreach o,$(objlist),$(objdir)/$(o).o)
objlistnsf := $(foreach o,$(objlistnsf),$(objdir)/$(o).o)
map.txt $(title).nes: nrom128.cfg $(objlistntsc)
$(LD65) -C $^ -m map.txt -o $(title).nes
nsfmap.txt $(title).nsf: nsf.cfg $(objlistnsf)
$(LD65) -C $^ -m nsfmap.txt -o $(title).nsf
$(objdir)/%.o: $(srcdir)/%.s $(srcdir)/nes.inc $(srcdir)/global.inc
$(AS65) $(CFLAGS65) $< -o $@
$(objdir)/%.o: $(objdir)/%.s
$(AS65) $(CFLAGS65) $< -o $@
# Files that depend on .incbin'd files or on other headers
$(objdir)/main.o: $(objdir)/bggfx.chr $(objdir)/spritegfx.chr
$(objdir)/testpatterns.o: $(srcdir)/ballbg.pkb $(srcdir)/fullbright.pkb \
$(srcdir)/hlines.pkb $(srcdir)/menu.pkb $(srcdir)/vlines.pkb \
$(srcdir)/pulltrigger.pkb
$(objdir)/tennis.o: $(srcdir)/tennis.inc
$(objdir)/tennisgfx.o: $(srcdir)/tennis.inc $(srcdir)/tennis_title.pkb
$(objdir)/math.o: $(srcdir)/tennis.inc
$(objdir)/kinematics.o: $(srcdir)/tennis.inc
$(objdir)/title.o: $(srcdir)/title.pkb
# Generate lookup tables at build time
$(objdir)/ntscPeriods.s: tools/mktables.py
$(PY) $< period $@
# Rules for CHR ROM
$(objdir)/%.chr: $(imgdir)/%.png
$(PY) tools/pilbmp2nes.py $< $@
$(objdir)/%16.chr: $(imgdir)/%.png
$(PY) tools/pilbmp2nes.py -H 16 $< $@