aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: 186a5e15c2a8bfc1159d371dd731821209bc1299 (plain)
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263

# Install paths. DESTDIR is used for installing to an alternate location,
# for people making RPM/deb/tgz/etc packages.
DESTDIR=
PREFIX=/usr/local
BINDIR=$(PREFIX)/bin
MANDIR=$(PREFIX)/share/man
MAN1DIR=$(MANDIR)/man1
MAN5DIR=$(MANDIR)/man5
MAN7DIR=$(MANDIR)/man7
DOCDIR=$(PREFIX)/share/doc/bw-atari8-tools
PSFDIR=$(PREFIX)/share/kbd/consolefonts
BDFDIR=$(PREFIX)/share/share/fonts/misc
TTFDIR=$(PREFIX)/share/share/fonts/TTF

# Compiler stuff
COPT=-O2
CC=gcc
CFLAGS=-Wall $(COPT) -ansi -D_GNU_SOURCE -DVERSION=\"$(VERSION)\"

# BINS and SCRIPTS go in $BINDIR, DOCS go in $DOCDIR
BINS=a8eol atr2xfd atrsize axe blob2c blob2xex cart2xex cxrefbas dumpbas fenders protbas renumbas rom2cart unmac65 unprotbas vxrefbas xex1to2 xexamine xexcat xexsplit xfd2atr listbas a8cat a8xd whichbas bas2aplus
SCRIPTS=dasm2atasm diffbas a8diff
MANS=a8eol.1 xfd2atr.1 atr2xfd.1 blob2c.1 cart2xex.1 fenders.1 xexsplit.1 xexcat.1 atrsize.1 rom2cart.1 unmac65.1 axe.1 dasm2atasm.1 blob2xex.1 xexamine.1 xex1to2.1 unprotbas.1 protbas.1 renumbas.1 dumpbas.1 vxrefbas.1 cxrefbas.1 listbas.1 a8cat.1 a8xd.1 whichbas.1 diffbas.1 a8diff.1 bas2aplus.1
MAN5S=xex.5
MAN7S=atascii.7 fauxtari.7
DOCS=README.txt equates.inc *.dasm LICENSE ksiders/atr.txt
PSFS=fonts/fauxtari-8.psf fonts/fauxtari-16.psf fonts/fauxtari-24.psf
BDFS=fonts/fauxtari-8.bdf fonts/fauxtari-16.bdf fonts/fauxtari-24.bdf
TTF=fonts/FauxtariScalableMono.ttf

SUBDIRS=ksiders jindroush

# All the programs share this version number...
VERSION=0.2.1

# If your system doesn't support gzipped man pages, comment this out:
GZIP_MAN=y

# unmac65 can be built for Atari 8-bit. Don't do it by default, but
# these variables are used for cross-compiling:
CC65=cl65
CC65FLAGS=-O -t atari

# Some distros have this with a .py extension, some don't. Only needed
# if you're rebuilding the man pages (users shouldn't have to).
# RST2MAN=rst2man.py
RST2MAN=rst2man

# Targets below. You probably don't need to edit below this point.
# WARNING: Don't do a "make realclean" unless you have the DASM or
# Atasm 6502 cross assembler installed!
# "make clean" and "make distclean" will not delete the 6502 object
# code (the *.bin files), but "make realclean" will.

all: $(BINS) manpages symlinks subdirs $(TTF)

unprotbas: bas.o

protbas: bas.o

renumbas: bas.o bcdfp.o linetab.o

dumpbas: bas.o

whichbas: bas.o

vxrefbas: bas.o

cxrefbas: bas.o bcdfp.o linetab.o

bas2aplus: bas.o

listbas: listbas.c bas.o bcdfp.o tokens.o atables.o turbo_tokens.o aplus_tokens.o bxl_tokens.o bxe_tokens.o
	$(CC) $(CFLAGS) -o listbas listbas.c bas.o bcdfp.o tokens.o atables.o turbo_tokens.o aplus_tokens.o bxl_tokens.o bxe_tokens.o -lm

bas.o: bas.c bas.h

wtable.o: wtable.c wtable.h

atables.o: atables.c atables.h

a8cat: a8cat.c atables.o wtable.o

a8xd: a8xd.c atables.o

subdirs:
	for dir in $(SUBDIRS); do make -C $$dir COPT="$(COPT)"; done

a8eol: a8eol.c

xfd2atr: xfd2atr.c

atr2xfd: atr2xfd.c

atables.c: mkatables.pl
	perl mkatables.pl > atables.c

# note to cross-compiler users: If you're building the *.bin targets,
# blob2c needs to be executable on the build host. It'd also be nice
# to build a blob2c for the target platform... Probably you can do
# something like this:

# make blob2c CC=/usr/bin/cc          # build host blob2c
# make CC=/path/to/cross/cc           # build everything else (uses blob2c)
# rm -f blob2c                        # get rid of host blob2c so we can...
# make blob2c CC=/path/to/cross/cc    # build the target system's blob2c
# make install DESTDIR=/tmp/whatever...

# Note that this is only needed if you're building the 6502 object code,
# which you don't need to do unless you've modified it (the distribution
# tarball comes with prebuilt *.bin files).

blob2c: blob2c.c

fenders.bin: fenders.dasm asmwrapper.sh
	sh asmwrapper.sh fenders

fenders_bin.c: fenders.bin blob2c
	./blob2c fenders.bin > fenders_bin.c 2>fenders_bin.h

fenders_offsets.h: fenders.bin fenders_offsets.pl
	perl fenders_offsets.pl < fenders.syms > fenders_offsets.h

fenders: fenders.o fenders_bin.c fendersdbl_bin.c

fenders.o: fenders.c fenders_bin.h fenders_offsets.h fendersdbl_bin.h fendersdbl_offsets.h

fendersdbl.bin: fendersdbl.dasm asmwrapper.sh
	sh asmwrapper.sh fendersdbl

fendersdbl_bin.c: fendersdbl.bin blob2c
	./blob2c fendersdbl.bin > fendersdbl_bin.c 2>fendersdbl_bin.h

fendersdbl_offsets.h: fendersdbl.bin fenders_offsets.pl
	perl fenders_offsets.pl < fendersdbl.syms > fendersdbl_offsets.h

loadscreen.bin: loadscreen.dasm asmwrapper.sh
	sh asmwrapper.sh loadscreen

loadscreen_bin.c: loadscreen.bin blob2c
	./blob2c loadscreen.bin > loadscreen_bin.c 2>loadscreen_bin.h

cart2xex: cart2xex.c loadscreen_bin.c get_address.o cart.o

rom2cart: rom2cart.c cart.o

cart.o: cart.c cart.h

get_address.o: get_address.c get_address.h

xex.o: xex.c xex.h

xextest: xextest.c xex.o

xexsplit: xexsplit.c xex.o

xexcat: xexcat.c xex.o get_address.o

blob2xex: blob2xex.c xex.o get_address.o

xexamine: xexamine.c xex.o get_address.o

unmac65.xex: unmac65.c
	@rm -f unmac65.o
	$(CC65) $(CC65FLAGS) -DVERSION=\"$(VERSION)\" -DTAG=\"$(TAG)\" -t atari -o unmac65.xex unmac65.c
	@rm -f unmac65.o

axe: axe.c axe.h axelib.c

symlinks: atrcheck cart2rom

atrcheck: atr2xfd
	ln -s atr2xfd atrcheck

cart2rom: rom2cart
	ln -s rom2cart cart2rom

manpages: $(MANS) $(MAN5S) $(MAN7S)

%.1: %.rst manhdr.rst manftr.rst genopts.rst
	$(RST2MAN) $< > $@

%.5: %.rst manhdr5.rst manftr.rst
	$(RST2MAN) $< > $@

%.7: %.rst manhdr7.rst manftr.rst
	$(RST2MAN) $< > $@

fonts/fauxtari-8.bdf: fonts/mkpsf.pl
	( cd fonts && perl mkpsf.pl )

$(TTF): fonts/fauxtari-8.bdf
	bitmapfont2ttf --family-name "Fauxtari Scalable Mono" fonts/fauxtari-8.bdf $(TTF)

# "make clean" does NOT remove the .bin or _bin.[ch] files. This is
# for people who don't have either dasm or atasm installed.
# also, it doesn't remove the man pages. these are checked into git, even.
clean:
	rm -f core *.o *~ $(BINS)
	for dir in $(SUBDIRS); do make -C $$dir clean; done

distclean: clean
	rm -rf *.syms *.atr 1 2 3 *.xex *.rom *.atasm *.m65 atrcheck cart2rom

realclean: distclean
	rm -f *.bin *_bin.[ch] *_offsets.h $(MANS) $(MAN5S) $(MAN7S)

install: all install-subdirs
	mkdir -p $(DESTDIR)/$(BINDIR) $(DESTDIR)/$(MAN1DIR) $(DESTDIR)/$(MAN5DIR) $(DESTDIR)/$(MAN7DIR) $(DESTDIR)/$(DOCDIR)
	strip $(BINS)
	for i in $(BINS) $(SCRIPTS) ; do \
		install -m0755 $$i   $(DESTDIR)/$(BINDIR) ; \
		install -m0644 $$i.1 $(DESTDIR)/$(MAN1DIR) ; \
		if [ "$(GZIP_MAN)" = "y" ]; then \
			gzip -f $(DESTDIR)/$(MAN1DIR)/$$i.1 ; \
		fi ; \
	done
	( cd $(DESTDIR)/$(BINDIR) && rm -f atrcheck && ln -s atr2xfd atrcheck )
	( cd $(DESTDIR)/$(BINDIR) && rm -f cart2rom && ln -s rom2cart cart2rom )
	for i in $(MAN5S) ; do \
		install -m0644 $$i $(DESTDIR)/$(MAN5DIR) ; \
		if [ "$(GZIP_MAN)" = "y" ]; then \
			gzip -f $(DESTDIR)/$(MAN5DIR)/$$i ; \
		fi ; \
	done
	for i in $(MAN7S) ; do \
		install -m0644 $$i $(DESTDIR)/$(MAN7DIR) ; \
		if [ "$(GZIP_MAN)" = "y" ]; then \
			gzip -f $(DESTDIR)/$(MAN7DIR)/$$i ; \
		fi ; \
	done
	if [ "$(GZIP_MAN)" = "y" ]; then \
		cd $(DESTDIR)/$(MAN1DIR) && rm -f atrcheck.1.gz && ln -s atr2xfd.1.gz atrcheck.1.gz ; \
		cd $(DESTDIR)/$(MAN1DIR) && rm -f cart2rom.1.gz && ln -s rom2cart.1.gz cart2rom.1.gz ; \
	else \
		cd $(DESTDIR)/$(MAN1DIR) && rm -f cart2rom.1 && ln -s rom2cart.1 cart2rom.1 ; \
	fi
	install -m0644 $(DOCS) $(DESTDIR)/$(DOCDIR)
	install -m0644 ksiders/README.txt $(DESTDIR)/$(DOCDIR)/README_ksiders.txt

install-subdirs: subdirs
	for dir in $(SUBDIRS); do \
		make -C $$dir DESTDIR=$(DESTDIR) PREFIX=$(PREFIX) BINDIR=$(BINDIR) MAN1DIR=$(MAN1DIR) GZIP_MAN=$(GZIP_MAN) DOCDIR=$(DOCDIR) install; \
	done

install-fonts: all
	sh install-fonts.sh "$(DESTDIR)" "$(BDFDIR)" "$(TTFDIR)"

user-font: user-fonts

user-fonts:
	$(MAKE) install-fonts BDFDIR=$(HOME)/.fonts TTFDIR=$(HOME)/.fonts

user-symlinks: all
	SRC=$$( pwd ) ; \
	mkdir -p ~/bin ; \
	cd ~/bin && \
	for i in $(BINS) $(SCRIPTS) \
		ksiders/atrdir ksiders/atrextr ksiders/makeatr ksiders/sortatr ksiders/unmakatr \
		jindroush/chkrom/chkrom jindroush/chkbas/chkbas jindroush/bas2boot/bas2boot \
		jindroush/chkexe/chkexe jindroush/adir/adir jindroush/acvt/acvt jindroush/aext/aext \
		; do rm -f $$i; ln -sf $$SRC/$$i . ; done