aboutsummaryrefslogtreecommitdiff
path: root/src/Makefile
blob: da19876751217774a17d9d474f2eec9409a44c72 (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
# Makefile for alftools, by B. Watson. WTFPL.
# Tested with GNU make, BSD make, makepp, and Schily's dmake.

### Override these variables as needed. Don't override CFLAGS; use
#   COPT instead.

# C compiler to use. PATH is searched unless you give an absolute path.
CC=cc

# C compiler options (flags):
COPT=-O3

# Path to the GNU or BSD 'install' program.
INSTALL=install

# Path to the rst2man command. Only needed if modifying/rebuilding the
# man pages and/or windows HTML docs.
RST2MAN=rst2man

#   These only affect the 'install' target (they don't get compiled
#   into the binary).

PREFIX=/usr
MANDIR=$(PREFIX)/man
MAN1DIR=$(MANDIR)/man1
BINDIR=$(PREFIX)/bin
DOCDIR=$(PREFIX)/doc/$(PROJ)-$(VERSION)
DESTDIR=
INSTALL_DATA=$(INSTALL) -m0644
INSTALL_PROGRAM=$(INSTALL) -m0755
GZIP=gzip -9
GZIP_MAN=yes
STRIP=yes

#
### No user-serviceable parts below.

PROJ=alftools
VERSION=0.2.0

CFLAGS=-DVERSION='"$(VERSION)"' -Wall -I../f65 $(COPT)

BINS=alf alfsum unalf
MANS=alf.1 alfsum.1 unalf.1

UNALF_OBJS=unalf.o io.o listalf.o extract.o f65.o glob.o opts.o usage.o self.o asmcode.o
ALFSUM_OBJS=alfsum.o self.o
ALF_OBJS=alf.o self.o alfusage.o

.PHONY: all clean install crosswin windows windows-upload realclean

all: $(BINS) $(MANS)

# unalf and alfsum need explicit rules for BSD make compatibility.
# without them, bmake tries to run "cc -o unalf unalf.c" which ain't
# gonna ever work.
unalf: $(UNALF_OBJS)
	$(CC) $(LDFLAGS) -o $@ $(UNALF_OBJS)

alfsum: $(ALFSUM_OBJS)
	$(CC) $(LDFLAGS) -o $@ $(ALFSUM_OBJS)

alf: $(ALF_OBJS)
	$(CC) $(LDFLAGS) -o $@ $(ALF_OBJS)

usage.o: usage.c

alfusage.o: usage.c

f65.o: ../f65/f65.c ../f65/f65.h
	$(CC) $(CFLAGS) -c -o f65.o ../f65/f65.c

usage.c: mkusage.pl unalf.rst
	perl mkusage.pl unalf.rst > usage.c

alfusage.c: mkusage.pl alf.rst
	perl mkusage.pl alf.rst > alfusage.c

unalf.o: unalf.c unalf.h ../f65/f65.h

glob.o: glob.c unalf.h

opts.o: opts.c unalf.h

io.o: io.c unalf.h addrs.h ../f65/f65.h

listalf.o: listalf.c addrs.h unalf.h ../f65/f65.h

extract.o: extract.c addrs.h unalf.h ../f65/f65.h

ver.rst:
	echo '.. |version| replace:: $(VERSION)' > ver.rst

unalf.1: unalf.rst ver.rst manftr.rst
	$(RST2MAN) unalf.rst > unalf.1

alfsum.1: alfsum.rst ver.rst manftr.rst
	$(RST2MAN) alfsum.rst > alfsum.1

alf.1: alf.rst ver.rst manftr.rst
	$(RST2MAN) alf.rst > alf.1

clean:
	rm -rf *.o $(BINS) *.exe wintmp \
		alf.html unalf.html alfsum.html *.aarch64.elf *.com.dbg

# these are generated files, but they *are* checked into git.
realclean: clean
	rm -f unalf.1 alfsum.1 usage.c alfusage.c

install: all
	[ "$(STRIP)" = "yes" ] && strip alf unalf alfsum || true
	mkdir -p $(DESTDIR)$(BINDIR) $(DESTDIR)$(MAN1DIR) $(DESTDIR)$(DOCDIR)
	$(INSTALL_DATA) alf.1 $(DESTDIR)$(MAN1DIR)
	$(INSTALL_DATA) unalf.1 $(DESTDIR)$(MAN1DIR)
	$(INSTALL_DATA) alfsum.1 $(DESTDIR)$(MAN1DIR)
	[ "$(GZIP_MAN)" = "yes" ] && $(GZIP) $(DESTDIR)$(MAN1DIR)/alf.1 || true
	[ "$(GZIP_MAN)" = "yes" ] && $(GZIP) $(DESTDIR)$(MAN1DIR)/unalf.1 || true
	[ "$(GZIP_MAN)" = "yes" ] && $(GZIP) $(DESTDIR)$(MAN1DIR)/alfsum.1 || true
	$(INSTALL_PROGRAM) alf $(DESTDIR)$(BINDIR)
	$(INSTALL_PROGRAM) unalf $(DESTDIR)$(BINDIR)
	$(INSTALL_PROGRAM) alfsum $(DESTDIR)$(BINDIR)
	cp -r ../README.txt ../LICENSE.txt ../TODO.txt ../doc ../examples $(DESTDIR)$(DOCDIR)

crosswin: clean
	$(MAKE) CC=~/x-tools/x86_64-w64-mingw32/bin/x86_64-w64-mingw32-gcc

html: alfsum.html unalf.html alf.html

alf.html: alf.rst
	rst2html alf.rst > alf.html

alfsum.html: alfsum.rst
	rst2html alfsum.rst > alfsum.html

unalf.html: unalf.rst
	rst2html unalf.rst > unalf.html

windows: crosswin html
	rm -rf wintmp ../$(PROJ)-$(VERSION)-win64.zip
	mkdir -p wintmp/{doc,examples}
	cp alf.exe unalf.exe alfsum.exe wintmp
	cd .. ; for i in README.txt TODO.txt doc/*.txt doc/Arcinfo examples/*.txt; do perl -pe 's,\n,\r\n,;' $$i > src/wintmp/$$i; done
	perl -p -e 's,\n,\r\n,;' -e 's,\@VERSION\@,$(VERSION),g;' README_Windows.txt.in > wintmp/README_Windows.txt
	cp ../examples/*.alf wintmp/examples
	cp alfsum.html unalf.html alf.html wintmp
	cd wintmp ; zip -r ../../$(PROJ)-$(VERSION)-win64.zip *

windows-upload: windows
	scp ../$(PROJ)-$(VERSION)-win64.zip sluk:public_html/html/$(PROJ)4win/