summary refs log tree commit diff
path: root/bin/Makefile
blob: 428ce7eee57a7500e562f1ac920c6e9ff002b03a (plain) (blame)
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
PREFIX ?= ~/.local
MANDIR ?= ${PREFIX}/share/man

LIBS_PREFIX ?= /usr/local
CFLAGS += -I${LIBS_PREFIX}/include
LDFLAGS += -L${LIBS_PREFIX}/lib

CFLAGS += -Wall -Wextra -Wpedantic -Wno-gnu-case-range

BINS += beef
BINS += bibsort
BINS += bit
BINS += c
BINS += dehtml
BINS += dtch
BINS += enc
BINS += git-comment
BINS += git-import
BINS += glitch
BINS += hilex
BINS += htagml
BINS += modem
BINS += mtags
BINS += nudge
BINS += order
BINS += pbd
BINS += pngo
BINS += psf2png
BINS += ptee
BINS += qf
BINS += quick
BINS += scheme
BINS += shotty
BINS += sup
BINS += title
BINS += up
BINS += when
BINS += xx

BSD += ever

GAMES += freecell

TLS += downgrade
TLS += relay

MANS = ${BINS:%=man1/%.1}
MANS.BSD = ${BSD:%=man1/%.1}
MANS.GAMES = ${GAMES:%=man6/%.6}
MANS.TLS = ${TLS:%=man1/%.1}

LDLIBS.downgrade = -ltls
LDLIBS.dtch = -lutil
LDLIBS.fbclock = -lz
LDLIBS.freecell = -lcurses
LDLIBS.glitch = -lz
LDLIBS.modem = -lutil
LDLIBS.pngo = -lz
LDLIBS.ptee = -lutil
LDLIBS.qf = -lcurses
LDLIBS.relay = -ltls
LDLIBS.scheme = -lm
LDLIBS.title = -lcurl
LDLIBS.typer = -ltls

ALL ?= meta any

-include config.mk

all: ${ALL}

meta: .gitignore tags

any: ${BINS}

bsd: ${BSD}

games: ${GAMES}

tls: ${TLS}

IGNORE = *.o *.html
IGNORE += ${BINS} ${BSD} ${GAMES} ${TLS}
IGNORE += tags htmltags

.gitignore: Makefile
	echo config.mk '${IGNORE}' | tr ' ' '\n' | sort > $@

tags: *.[chly]
	ctags -w *.[chly]

clean:
	rm -f ${IGNORE}

install: ${ALL:%=install-%}

install-meta:
	install -d ${PREFIX}/bin ${MANDIR}/man1

install-any: install-meta ${BINS} ${MANS}
	install ${BINS} ${PREFIX}/bin
	install -m 644 ${MANS} ${MANDIR}/man1

install-bsd: install-meta ${BSD} ${MANS.BSD}
	install ${BSD} ${PREFIX}/bin
	install -m 644 ${MANS.BSD} ${MANDIR}/man1

install-games: install-meta ${GAMES} ${MANS.GAMES}
	install ${GAMES} ${PREFIX}/bin
	install -m 644 ${MANS.GAMES} ${MANDIR}/man6

install-tls: install-meta ${TLS} ${MANS.TLS}
	install ${TLS} ${PREFIX}/bin
	install -m 644 ${MANS.TLS} ${MANDIR}/man1

uninstall:
	rm -f ${BINS:%=${PREFIX}/bin/%} ${MANS:%=${MANDIR}/%}
	rm -f ${BSD:%=${PREFIX}/bin/%} ${MANS.BSD:%=${MANDIR}/%}
	rm -f ${GAMES:%=${PREFIX}/bin/%} ${MANS.GAMES:%=${MANDIR}/%}
	rm -f ${TLS:%=${PREFIX}/bin/%} ${MANS.TLS:%=${MANDIR}/%}

.SUFFIXES: .pl

.c:
	${CC} ${CFLAGS} ${LDFLAGS} $< ${LDLIBS.$@} -o $@

.o:
	${CC} ${LDFLAGS} $< ${LDLIBS.$@} -o $@

.pl:
	cp -f $< $@
	chmod a+x $@

OBJS.hilex = c11.o hilex.o make.o mdoc.o sh.o

hilex: ${OBJS.hilex}
	${CC} ${LDFLAGS} ${OBJS.$@} ${LDLIBS.$@} -o $@

${OBJS.hilex}: hilex.h

psf2png.o scheme.o: png.h

include html.mk