]> git.cameronkatri.com Git - mandoc.git/blob - Makefile
Clean-ups in -T[x]html: inline print_num(), as it was just a single
[mandoc.git] / Makefile
1 .PHONY: clean install installwww
2 .SUFFIXES: .sgml .html .md5 .h .h.html
3 .SUFFIXES: .1 .3 .7
4 .SUFFIXES: .1.txt .3.txt .7.txt
5 .SUFFIXES: .1.pdf .3.pdf .7.pdf
6 .SUFFIXES: .1.ps .3.ps .7.ps
7 .SUFFIXES: .1.html .3.html .7.html
8 .SUFFIXES: .1.xhtml .3.xhtml .7.xhtml
9
10 # Specify this if you want to hard-code the operating system to appear
11 # in the lower-left hand corner of -mdoc manuals.
12 # CFLAGS += -DOSNAME="\"OpenBSD 4.5\""
13
14 VERSION = 1.11.2
15 VDATE = 12 May 2011
16 CFLAGS += -g -DHAVE_CONFIG_H -DVERSION="\"$(VERSION)\""
17 CFLAGS += -W -Wall -Wstrict-prototypes -Wno-unused-parameter -Wwrite-strings
18 PREFIX = /usr/local
19 BINDIR = $(PREFIX)/bin
20 INCLUDEDIR = $(PREFIX)/include/mandoc
21 LIBDIR = $(PREFIX)/lib/mandoc
22 MANDIR = $(PREFIX)/man
23 EXAMPLEDIR = $(PREFIX)/share/examples/mandoc
24 INSTALL = install
25 INSTALL_PROGRAM = $(INSTALL) -m 0755
26 INSTALL_DATA = $(INSTALL) -m 0444
27 INSTALL_LIB = $(INSTALL) -m 0644
28 INSTALL_MAN = $(INSTALL_DATA)
29
30 all: mandoc
31
32 SRCS = Makefile \
33 arch.c \
34 arch.in \
35 att.c \
36 att.in \
37 chars.c \
38 chars.in \
39 compat.c \
40 config.h.post \
41 config.h.pre \
42 eqn.7 \
43 eqn.c \
44 example.style.css \
45 external.png \
46 html.c \
47 html.h \
48 index.css \
49 index.sgml \
50 lib.c \
51 lib.in \
52 libman.h \
53 libmandoc.h \
54 libmdoc.h \
55 libroff.h \
56 main.c \
57 main.h \
58 man.h \
59 man.7 \
60 man.c \
61 man_hash.c \
62 man_html.c \
63 man_macro.c \
64 man_term.c \
65 man_validate.c \
66 mandoc.1 \
67 mandoc.3 \
68 mandoc.c \
69 mandoc.h \
70 makewhatis.1 \
71 makewhatis.c \
72 mandoc_char.7 \
73 mdoc.h \
74 mdoc.7 \
75 mdoc.c \
76 mdoc_argv.c \
77 mdoc_hash.c \
78 mdoc_html.c \
79 mdoc_macro.c \
80 mdoc_term.c \
81 mdoc_validate.c \
82 msec.c \
83 msec.in \
84 out.c \
85 out.h \
86 read.c \
87 roff.7 \
88 roff.c \
89 st.c \
90 st.in \
91 style.css \
92 tbl.7 \
93 tbl.c \
94 tbl_data.c \
95 tbl_html.c \
96 tbl_layout.c \
97 tbl_opts.c \
98 tbl_term.c \
99 term.c \
100 term.h \
101 term_ascii.c \
102 term_ps.c \
103 test-strlcat.c \
104 test-strlcpy.c \
105 tree.c \
106 vol.c \
107 vol.in
108
109 LIBMAN_OBJS = man.o \
110 man_hash.o \
111 man_macro.o \
112 man_validate.o
113 LIBMAN_LNS = man.ln \
114 man_hash.ln \
115 man_macro.ln \
116 man_validate.ln
117
118 LIBMDOC_OBJS = arch.o \
119 att.o \
120 lib.o \
121 mdoc.o \
122 mdoc_argv.o \
123 mdoc_hash.o \
124 mdoc_macro.o \
125 mdoc_validate.o \
126 msec.o \
127 st.o \
128 vol.o
129 LIBMDOC_LNS = arch.ln \
130 att.ln \
131 lib.ln \
132 mdoc.ln \
133 mdoc_argv.ln \
134 mdoc_hash.ln \
135 mdoc_macro.ln \
136 mdoc_validate.ln \
137 msec.ln \
138 st.ln \
139 vol.ln
140
141 LIBROFF_OBJS = eqn.o \
142 roff.o \
143 tbl.o \
144 tbl_data.o \
145 tbl_layout.o \
146 tbl_opts.o
147 LIBROFF_LNS = eqn.ln \
148 roff.ln \
149 tbl.ln \
150 tbl_data.ln \
151 tbl_layout.ln \
152 tbl_opts.ln
153
154 LIBMANDOC_OBJS = $(LIBMAN_OBJS) \
155 $(LIBMDOC_OBJS) \
156 $(LIBROFF_OBJS) \
157 chars.o \
158 mandoc.o \
159 read.o
160 LIBMANDOC_LNS = $(LIBMAN_LNS) \
161 $(LIBMDOC_LNS) \
162 $(LIBROFF_LNS) \
163 chars.ln \
164 mandoc.ln \
165 read.ln
166
167 arch.o arch.ln: arch.in
168 att.o att.ln: att.in
169 chars.o chars.ln: chars.in
170 lib.o lib.ln: lib.in
171 msec.o msec.ln: msec.in
172 st.o st.ln: st.in
173 vol.o vol.ln: vol.in
174
175 $(LIBMAN_OBJS) $(LIBMAN_LNS): libman.h
176 $(LIBMDOC_OBJS) $(LIBMDOC_LNS): libmdoc.h
177 $(LIBROFF_OBJS) $(LIBROFF_LNS): libroff.h
178 $(LIBMANDOC_OBJS) $(LIBMANDOC_LNS): mandoc.h mdoc.h man.h libmandoc.h config.h
179
180 MANDOC_HTML_OBJS = html.o \
181 man_html.o \
182 mdoc_html.o \
183 tbl_html.o
184 MANDOC_HTML_LNS = html.ln \
185 man_html.ln \
186 mdoc_html.ln \
187 tbl_html.ln
188
189 MANDOC_TERM_OBJS = man_term.o \
190 mdoc_term.o \
191 term.o \
192 term_ascii.o \
193 term_ps.o \
194 tbl_term.o
195 MANDOC_TERM_LNS = man_term.ln \
196 mdoc_term.ln \
197 term.ln \
198 term_ascii.ln \
199 term_ps.ln \
200 tbl_term.ln
201
202 MANDOC_OBJS = $(MANDOC_HTML_OBJS) \
203 $(MANDOC_TERM_OBJS) \
204 main.o \
205 out.o \
206 tree.o
207 MANDOC_LNS = $(MANDOC_HTML_LNS) \
208 $(MANDOC_TERM_LNS) \
209 main.ln \
210 out.ln \
211 tree.ln
212
213 $(MANDOC_HTML_OBJS) $(MANDOC_HTML_LNS): html.h
214 $(MANDOC_TERM_OBJS) $(MANDOC_TERM_LNS): term.h
215 $(MANDOC_OBJS) $(MANDOC_LNS): main.h mandoc.h mdoc.h man.h config.h out.h
216
217 compat.o compat.ln: config.h
218
219 MAKEWHATIS_OBJS = makewhatis.o
220 MAKEWHATIS_LNS = makewhatis.ln
221
222 $(MAKEWHATIS_OBJS) $(MAKEWHATIS_LNS): mandoc.h mdoc.h man.h config.h
223
224 INDEX_MANS = makewhatis.1.html \
225 makewhatis.1.xhtml \
226 makewhatis.1.ps \
227 makewhatis.1.pdf \
228 makewhatis.1.txt \
229 mandoc.1.html \
230 mandoc.1.xhtml \
231 mandoc.1.ps \
232 mandoc.1.pdf \
233 mandoc.1.txt \
234 mandoc.3.html \
235 mandoc.3.xhtml \
236 mandoc.3.ps \
237 mandoc.3.pdf \
238 mandoc.3.txt \
239 eqn.7.html \
240 eqn.7.xhtml \
241 eqn.7.ps \
242 eqn.7.pdf \
243 eqn.7.txt \
244 man.7.html \
245 man.7.xhtml \
246 man.7.ps \
247 man.7.pdf \
248 man.7.txt \
249 mandoc_char.7.html \
250 mandoc_char.7.xhtml \
251 mandoc_char.7.ps \
252 mandoc_char.7.pdf \
253 mandoc_char.7.txt \
254 mdoc.7.html \
255 mdoc.7.xhtml \
256 mdoc.7.ps \
257 mdoc.7.pdf \
258 mdoc.7.txt \
259 roff.7.html \
260 roff.7.xhtml \
261 roff.7.ps \
262 roff.7.pdf \
263 roff.7.txt \
264 tbl.7.html \
265 tbl.7.xhtml \
266 tbl.7.ps \
267 tbl.7.pdf \
268 tbl.7.txt
269
270 $(INDEX_MANS): mandoc
271
272 INDEX_OBJS = $(INDEX_MANS) \
273 man.h.html \
274 mandoc.h.html \
275 mdoc.h.html \
276 mdocml.tar.gz \
277 mdocml.md5
278
279 www: index.html
280
281 lint: llib-llibmandoc.ln llib-lmandoc.ln
282
283 clean:
284 rm -f libmandoc.a $(LIBMANDOC_OBJS)
285 rm -f llib-llibmandoc.ln $(LIBMANDOC_LNS)
286 rm -f makewhatis $(MAKEWHATIS_OBJS)
287 rm -f llib-lmakewhatis.ln $(MAKEWHATIS_LNS)
288 rm -f mandoc $(MANDOC_OBJS)
289 rm -f llib-lmandoc.ln $(MANDOC_LNS)
290 rm -f config.h config.log compat.o compat.ln
291 rm -f mdocml.tar.gz
292 rm -f index.html $(INDEX_OBJS)
293
294 install: all
295 mkdir -p $(DESTDIR)$(BINDIR)
296 mkdir -p $(DESTDIR)$(EXAMPLEDIR)
297 mkdir -p $(DESTDIR)$(LIBDIR)
298 mkdir -p $(DESTDIR)$(INCLUDEDIR)
299 mkdir -p $(DESTDIR)$(MANDIR)/man1
300 mkdir -p $(DESTDIR)$(MANDIR)/man3
301 mkdir -p $(DESTDIR)$(MANDIR)/man7
302 $(INSTALL_PROGRAM) mandoc $(DESTDIR)$(BINDIR)
303 $(INSTALL_LIB) libmandoc.a $(DESTDIR)$(LIBDIR)
304 $(INSTALL_LIB) mandoc.h $(DESTDIR)$(INCLUDEDIR)
305 $(INSTALL_MAN) mandoc.1 $(DESTDIR)$(MANDIR)/man1
306 $(INSTALL_MAN) mandoc.3 $(DESTDIR)$(MANDIR)/man3
307 $(INSTALL_MAN) man.7 mdoc.7 roff.7 eqn.7 tbl.7 mandoc_char.7 $(DESTDIR)$(MANDIR)/man7
308 $(INSTALL_DATA) example.style.css $(DESTDIR)$(EXAMPLEDIR)
309
310 installwww: www
311 mkdir -p $(PREFIX)/snapshots
312 $(INSTALL_DATA) index.html external.png index.css $(PREFIX)
313 $(INSTALL_DATA) $(INDEX_MANS) style.css $(PREFIX)
314 $(INSTALL_DATA) mandoc.h.html man.h.html mdoc.h.html $(PREFIX)
315 $(INSTALL_DATA) mdocml.tar.gz $(PREFIX)/snapshots
316 $(INSTALL_DATA) mdocml.md5 $(PREFIX)/snapshots
317 $(INSTALL_DATA) mdocml.tar.gz $(PREFIX)/snapshots/mdocml-$(VERSION).tar.gz
318 $(INSTALL_DATA) mdocml.md5 $(PREFIX)/snapshots/mdocml-$(VERSION).md5
319
320 libmandoc.a: compat.o $(LIBMANDOC_OBJS)
321 $(AR) rs $@ compat.o $(LIBMANDOC_OBJS)
322
323 llib-llibmandoc.ln: compat.ln $(LIBMANDOC_LNS)
324 $(LINT) $(LINTFLAGS) -Clibmandoc compat.ln $(LIBMANDOC_LNS)
325
326 mandoc: $(MANDOC_OBJS) libmandoc.a
327 $(CC) -o $@ $(MANDOC_OBJS) libmandoc.a
328
329 # You'll need -ldb for Linux.
330 makewhatis: $(MAKEWHATIS_OBJS) libmandoc.a
331 $(CC) -o $@ $(MAKEWHATIS_OBJS) libmandoc.a
332
333 llib-lmandoc.ln: $(MANDOC_LNS)
334 $(LINT) $(LINTFLAGS) -Cmandoc $(MANDOC_LNS)
335
336 llib-lmakewhatis.ln: $(MAKEWHATIS_LNS)
337 $(LINT) $(LINTFLAGS) -Cmakewhatis $(MAKEWHATIS_LNS)
338
339 mdocml.md5: mdocml.tar.gz
340 md5 mdocml.tar.gz >$@
341
342 mdocml.tar.gz: $(SRCS)
343 mkdir -p .dist/mdocml-$(VERSION)/
344 $(INSTALL) -m 0444 $(SRCS) .dist/mdocml-$(VERSION)
345 ( cd .dist/ && tar zcf ../$@ ./ )
346 rm -rf .dist/
347
348 index.html: $(INDEX_OBJS)
349
350 config.h: config.h.pre config.h.post
351 rm -f config.log
352 ( cat config.h.pre; \
353 echo; \
354 if $(CC) $(CFLAGS) -Werror -o test-strlcat test-strlcat.c >> config.log 2>&1; then \
355 echo '#define HAVE_STRLCAT'; \
356 rm test-strlcat; \
357 fi; \
358 if $(CC) $(CFLAGS) -Werror -o test-strlcpy test-strlcpy.c >> config.log 2>&1; then \
359 echo '#define HAVE_STRLCPY'; \
360 rm test-strlcpy; \
361 fi; \
362 echo; \
363 cat config.h.post \
364 ) > $@
365
366 .h.h.html:
367 highlight -I $< >$@
368
369 .1.1.txt .3.3.txt .7.7.txt:
370 ./mandoc -Tascii -Wall,stop $< | col -b >$@
371
372 .1.1.html .3.3.html .7.7.html:
373 ./mandoc -Thtml -Wall,stop -Ostyle=style.css,man=%N.%S.html,includes=%I.html $< >$@
374
375 .1.1.ps .3.3.ps .7.7.ps:
376 ./mandoc -Tps -Wall,stop $< >$@
377
378 .1.1.xhtml .3.3.xhtml .7.7.xhtml:
379 ./mandoc -Txhtml -Wall,stop -Ostyle=style.css,man=%N.%S.xhtml,includes=%I.html $< >$@
380
381 .1.1.pdf .3.3.pdf .7.7.pdf:
382 ./mandoc -Tpdf -Wall,stop $< >$@
383
384 .sgml.html:
385 validate --warn $<
386 sed -e "s!@VERSION@!$(VERSION)!" -e "s!@VDATE@!$(VDATE)!" $< >$@