aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: 9fb8a1d6d476cb77aea866a810de8e9d420cf696 (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

# 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
DOCDIR=$(PREFIX)/share/doc/bw-atari8-tools

# 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 xfd2atr atr2xfd blob2c cart2xex fenders xexsplit xexcat atrsize rom2cart unmac65 axe blob2xex xexamine
SCRIPTS=dasm2atasm a8utf8
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 a8utf8.1 blob2xex.1 xexamine.1
DOCS=README equates.inc *.dasm

# 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

a8eol: a8eol.c
	$(CC) $(CFLAGS) -o a8eol a8eol.c

xfd2atr: xfd2atr.c
	$(CC) $(CFLAGS) -o xfd2atr xfd2atr.c

atr2xfd: atr2xfd.c
	$(CC) $(CFLAGS) -o atr2xfd atr2xfd.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
	$(CC) $(CFLAGS) -o 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.c fenders_bin.c fenders_bin.h fenders_offsets.h \
		fendersdbl_bin.c fendersdbl_bin.h fendersdbl_offsets.h
	$(CC) $(CFLAGS) -o fenders fenders.c fenders_bin.c fendersdbl_bin.c

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
	$(CC) $(CFLAGS) -o cart2xex cart2xex.c loadscreen_bin.c get_address.o cart.o

rom2cart: rom2cart.c cart.o
	$(CC) $(CFLAGS) -o rom2cart rom2cart.c cart.o

cart.o: cart.c cart.h
	$(CC) $(CFLAGS) -c cart.c

get_address.o: get_address.c get_address.h
	$(CC) $(CFLAGS) -c get_address.c

xex.o: xex.c xex.h
	$(CC) $(CFLAGS) -c xex.c

xextest: xextest.c xex.o
	$(CC) $(CFLAGS) -o xextest xextest.c xex.o

xexsplit: xexsplit.c xex.o
	$(CC) $(CFLAGS) -o xexsplit xexsplit.c xex.o

xexcat: xexcat.c xex.o get_address.o
	$(CC) $(CFLAGS) -o xexcat xexcat.c xex.o get_address.o

blob2xex: blob2xex.c get_address.o
	$(CC) $(CFLAGS) -o blob2xex blob2xex.c xex.o get_address.o

# This is a work-in-progress, not ready yet.
xexamine: xexamine.c xex.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

manpages: $(MANS)

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

# "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)

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

realclean: distclean
	rm -f *.bin *_bin.[ch] *_offsets.h *.1

install: all
	mkdir -p $(DESTDIR)/$(BINDIR) $(DESTDIR)/$(MAN1DIR) $(DESTDIR)/$(DOCDIR)
	strip $(BINS)
	for i in $(BINS) $(SCRIPTS) ; do \
		install -m0755 -oroot -groot $$i   $(DESTDIR)/$(BINDIR) ; \
		install -m0644 -oroot -groot $$i.1 $(DESTDIR)/$(MAN1DIR) ; \
		if [ "$(GZIP_MAN)" = "y" ]; then \
			gzip $(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 )
	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 -oroot -groot $(DOCS) $(DESTDIR)/$(DOCDIR)