aboutsummaryrefslogtreecommitdiff
path: root/src/Makefile
blob: 8f8607f2a439e440ea25b67f6db953a663271d75 (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
# Makefile for unalf, by B. Watson. WTFPL.
# Tested with GNU make. Does not work with BSD make, sorry.

### Override these variables as needed. Don't override CFLAGS; use
#   COPT instead.
COPT=-O3
INSTALL=install
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/unalf-$(VERSION)
DESTDIR=
INSTALL_DATA=$(INSTALL) -m0644
INSTALL_PROGRAM=$(INSTALL) -s -m0755
GZIP=gzip -9
GZIP_MAN=yes

#
### No user-serviceable parts below.

VERSION=0.1.0

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

.PHONY: all clean install

all: unalf unalf.1 alfsum alfsum.1

unalf: unalf.o io.o listalf.o extract.o ../f65/f65.o glob.o opts.o usage.o

usage.o: usage.c

usage.c: mkusage.pl unalf.rst
	perl mkusage.pl unalf.rst > usage.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

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

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

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

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

clean:
	rm -rf *.o unalf alfsum ../f65/f65.o *.exe wintmp \
		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

install: all
	mkdir -p $(DESTDIR)$(BINDIR) $(DESTDIR)$(MAN1DIR) $(DESTDIR)$(DOCDIR)
	$(INSTALL_DATA) unalf.1 $(DESTDIR)$(MAN1DIR)
	$(INSTALL_DATA) alfsum.1 $(DESTDIR)$(MAN1DIR)
	[ "$(GZIP_MAN)" = "yes" ] && $(GZIP) $(DESTDIR)$(MAN1DIR)/unalf.1 || true
	[ "$(GZIP_MAN)" = "yes" ] && $(GZIP) $(DESTDIR)$(MAN1DIR)/alfsum.1 || true
	$(INSTALL_PROGRAM) unalf $(DESTDIR)$(BINDIR)
	$(INSTALL_PROGRAM) alfsum $(DESTDIR)$(BINDIR)
	cp -r ../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

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

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

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