]> git.cameronkatri.com Git - mandoc.git/blob - Makefile
Split apropos.c into db.c and apropos.h with simpler code (re-written, but
[mandoc.git] / Makefile
1 .PHONY: clean install installwww
2 .SUFFIXES: .sgml .html .md5 .h .h.html
3 .SUFFIXES: .1 .3 .7 .8
4 .SUFFIXES: .1.txt .3.txt .7.txt .8.txt
5 .SUFFIXES: .1.pdf .3.pdf .7.pdf .8.pdf
6 .SUFFIXES: .1.ps .3.ps .7.ps .8.ps
7 .SUFFIXES: .1.html .3.html .7.html .8.html
8 .SUFFIXES: .1.xhtml .3.xhtml .7.xhtml .8.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 #
13 # CFLAGS += -DOSNAME="\"OpenBSD 4.5\""
14
15 VERSION = 1.12.0
16 VDATE = 8 October 2011
17
18 # IFF your system supports multi-byte functions (setlocale(), wcwidth(),
19 # putwchar()) AND has __STDC_ISO_10646__ (that is, wchar_t is simply a
20 # UCS-4 value) should you define USE_WCHAR. If you define it and your
21 # system DOESN'T support this, -Tlocale will produce garbage.
22 # If you don't define it, -Tlocale is a synonym for -Tacsii.
23 #
24 CFLAGS += -DUSE_WCHAR
25
26 CFLAGS += -g -DHAVE_CONFIG_H -DVERSION="\"$(VERSION)\""
27 CFLAGS += -W -Wall -Wstrict-prototypes -Wno-unused-parameter -Wwrite-strings
28 PREFIX = /usr/local
29 BINDIR = $(PREFIX)/bin
30 INCLUDEDIR = $(PREFIX)/include/mandoc
31 LIBDIR = $(PREFIX)/lib/mandoc
32 MANDIR = $(PREFIX)/man
33 EXAMPLEDIR = $(PREFIX)/share/examples/mandoc
34 INSTALL = install
35 INSTALL_PROGRAM = $(INSTALL) -m 0755
36 INSTALL_DATA = $(INSTALL) -m 0444
37 INSTALL_LIB = $(INSTALL) -m 0644
38 INSTALL_SOURCE = $(INSTALL) -m 0644
39 INSTALL_MAN = $(INSTALL_DATA)
40
41 # Non-BSD systems (Linux, etc.) need -ldb to compile mandocdb and
42 # apropos.
43 # However, if you don't have -ldb at all (or it's not native), then
44 # comment out apropos and mandocdb.
45 #
46 #DBLIB = -ldb
47 DBBIN = apropos mandocdb man.cgi
48 DBLN = llib-lapropos.ln llib-lmandocdb.ln llib-lman.cgi.ln
49
50 all: mandoc preconv demandoc $(DBBIN)
51
52 SRCS = Makefile \
53 apropos.1 \
54 apropos.c \
55 arch.c \
56 arch.in \
57 att.c \
58 att.in \
59 chars.c \
60 chars.in \
61 compat_getsubopt.c \
62 compat_strlcat.c \
63 compat_strlcpy.c \
64 config.h.post \
65 config.h.pre \
66 demandoc.c \
67 demandoc.1 \
68 eqn.7 \
69 eqn.c \
70 eqn_html.c \
71 eqn_term.c \
72 example.style.css \
73 external.png \
74 html.c \
75 html.h \
76 index.css \
77 index.sgml \
78 lib.c \
79 lib.in \
80 libman.h \
81 libmandoc.h \
82 libmdoc.h \
83 libroff.h \
84 main.c \
85 main.h \
86 man.h \
87 man.7 \
88 man.c \
89 man_hash.c \
90 man_html.c \
91 man_macro.c \
92 man_term.c \
93 man_validate.c \
94 mandoc.1 \
95 mandoc.3 \
96 mandoc.c \
97 mandoc.h \
98 mandocdb.8 \
99 mandocdb.c \
100 mandoc_char.7 \
101 mdoc.h \
102 mdoc.7 \
103 mdoc.c \
104 mdoc_argv.c \
105 mdoc_hash.c \
106 mdoc_html.c \
107 mdoc_macro.c \
108 mdoc_man.c \
109 mdoc_term.c \
110 mdoc_validate.c \
111 msec.c \
112 msec.in \
113 out.c \
114 out.h \
115 preconv.1 \
116 preconv.c \
117 predefs.in \
118 read.c \
119 roff.7 \
120 roff.c \
121 st.c \
122 st.in \
123 style.css \
124 tbl.7 \
125 tbl.c \
126 tbl_data.c \
127 tbl_html.c \
128 tbl_layout.c \
129 tbl_opts.c \
130 tbl_term.c \
131 term.c \
132 term.h \
133 term_ascii.c \
134 term_ps.c \
135 test-getsubopt.c \
136 test-mmap.c \
137 test-strlcat.c \
138 test-strlcpy.c \
139 test-strptime.c \
140 tree.c \
141 vol.c \
142 vol.in
143
144 LIBMAN_OBJS = man.o \
145 man_hash.o \
146 man_macro.o \
147 man_validate.o
148 LIBMAN_LNS = man.ln \
149 man_hash.ln \
150 man_macro.ln \
151 man_validate.ln
152
153 LIBMDOC_OBJS = arch.o \
154 att.o \
155 lib.o \
156 mdoc.o \
157 mdoc_argv.o \
158 mdoc_hash.o \
159 mdoc_macro.o \
160 mdoc_validate.o \
161 msec.o \
162 st.o \
163 vol.o
164 LIBMDOC_LNS = arch.ln \
165 att.ln \
166 lib.ln \
167 mdoc.ln \
168 mdoc_argv.ln \
169 mdoc_hash.ln \
170 mdoc_macro.ln \
171 mdoc_validate.ln \
172 msec.ln \
173 st.ln \
174 vol.ln
175
176 LIBROFF_OBJS = eqn.o \
177 roff.o \
178 tbl.o \
179 tbl_data.o \
180 tbl_layout.o \
181 tbl_opts.o
182 LIBROFF_LNS = eqn.ln \
183 roff.ln \
184 tbl.ln \
185 tbl_data.ln \
186 tbl_layout.ln \
187 tbl_opts.ln
188
189 LIBMANDOC_OBJS = $(LIBMAN_OBJS) \
190 $(LIBMDOC_OBJS) \
191 $(LIBROFF_OBJS) \
192 chars.o \
193 mandoc.o \
194 read.o
195 LIBMANDOC_LNS = $(LIBMAN_LNS) \
196 $(LIBMDOC_LNS) \
197 $(LIBROFF_LNS) \
198 chars.ln \
199 mandoc.ln \
200 read.ln
201
202 COMPAT_OBJS = compat_getsubopt.o \
203 compat_strlcat.o \
204 compat_strlcpy.o
205 COMPAT_LNS = compat_getsubopt.ln \
206 compat_strlcat.ln \
207 compat_strlcpy.ln
208
209 arch.o arch.ln: arch.in
210 att.o att.ln: att.in
211 chars.o chars.ln: chars.in
212 lib.o lib.ln: lib.in
213 msec.o msec.ln: msec.in
214 roff.o roff.ln: predefs.in
215 st.o st.ln: st.in
216 vol.o vol.ln: vol.in
217
218 $(LIBMAN_OBJS) $(LIBMAN_LNS): libman.h
219 $(LIBMDOC_OBJS) $(LIBMDOC_LNS): libmdoc.h
220 $(LIBROFF_OBJS) $(LIBROFF_LNS): libroff.h
221 $(LIBMANDOC_OBJS) $(LIBMANDOC_LNS): mandoc.h mdoc.h man.h libmandoc.h config.h
222
223 $(COMPAT_OBJS) $(COMPAT_LNS): config.h
224
225 MANDOC_HTML_OBJS = eqn_html.o \
226 html.o \
227 man_html.o \
228 mdoc_html.o \
229 tbl_html.o
230 MANDOC_HTML_LNS = eqn_html.ln \
231 html.ln \
232 man_html.ln \
233 mdoc_html.ln \
234 tbl_html.ln
235
236 MANDOC_MAN_OBJS = mdoc_man.o
237 MANDOC_MAN_LNS = mdoc_man.ln
238
239 MANDOC_TERM_OBJS = eqn_term.o \
240 man_term.o \
241 mdoc_term.o \
242 term.o \
243 term_ascii.o \
244 term_ps.o \
245 tbl_term.o
246 MANDOC_TERM_LNS = eqn_term.ln \
247 man_term.ln \
248 mdoc_term.ln \
249 term.ln \
250 term_ascii.ln \
251 term_ps.ln \
252 tbl_term.ln
253
254 MANDOC_OBJS = $(MANDOC_HTML_OBJS) \
255 $(MANDOC_MAN_OBJS) \
256 $(MANDOC_TERM_OBJS) \
257 main.o \
258 out.o \
259 tree.o
260 MANDOC_LNS = $(MANDOC_HTML_LNS) \
261 $(MANDOC_MAN_LNS) \
262 $(MANDOC_TERM_LNS) \
263 main.ln \
264 out.ln \
265 tree.ln
266
267 $(MANDOC_HTML_OBJS) $(MANDOC_HTML_LNS): html.h
268 $(MANDOC_TERM_OBJS) $(MANDOC_TERM_LNS): term.h
269 $(MANDOC_OBJS) $(MANDOC_LNS): main.h mandoc.h mdoc.h man.h config.h out.h
270
271 MANDOCDB_OBJS = mandocdb.o
272 MANDOCDB_LNS = mandocdb.ln
273
274 $(MANDOCDB_OBJS) $(MANDOCDB_LNS): mandoc.h mdoc.h man.h config.h
275
276 PRECONV_OBJS = preconv.o
277 PRECONV_LNS = preconv.ln
278
279 $(PRECONV_OBJS) $(PRECONV_LNS): config.h
280
281 APROPOS_OBJS = apropos.o db.o
282 APROPOS_LNS = apropos.ln db.ln
283
284 $(APROPOS_OBJS) $(APROPOS_LNS): config.h mandoc.h apropos.h
285
286 CGI_OBJS = cgi.o db.o
287 CGI_LNS = cgi.ln db.ln
288
289 $(CGI_OBJS) $(CGI_LNS): config.h mandoc.h apropos.h
290
291 DEMANDOC_OBJS = demandoc.o
292 DEMANDOC_LNS = demandoc.ln
293
294 $(DEMANDOC_OBJS) $(DEMANDOC_LNS): config.h
295
296 INDEX_MANS = apropos.1.html \
297 apropos.1.xhtml \
298 apropos.1.ps \
299 apropos.1.pdf \
300 apropos.1.txt \
301 demandoc.1.html \
302 demandoc.1.xhtml \
303 demandoc.1.ps \
304 demandoc.1.pdf \
305 demandoc.1.txt \
306 mandoc.1.html \
307 mandoc.1.xhtml \
308 mandoc.1.ps \
309 mandoc.1.pdf \
310 mandoc.1.txt \
311 mandoc.3.html \
312 mandoc.3.xhtml \
313 mandoc.3.ps \
314 mandoc.3.pdf \
315 mandoc.3.txt \
316 eqn.7.html \
317 eqn.7.xhtml \
318 eqn.7.ps \
319 eqn.7.pdf \
320 eqn.7.txt \
321 man.7.html \
322 man.7.xhtml \
323 man.7.ps \
324 man.7.pdf \
325 man.7.txt \
326 mandoc_char.7.html \
327 mandoc_char.7.xhtml \
328 mandoc_char.7.ps \
329 mandoc_char.7.pdf \
330 mandoc_char.7.txt \
331 mdoc.7.html \
332 mdoc.7.xhtml \
333 mdoc.7.ps \
334 mdoc.7.pdf \
335 mdoc.7.txt \
336 preconv.1.html \
337 preconv.1.xhtml \
338 preconv.1.ps \
339 preconv.1.pdf \
340 preconv.1.txt \
341 roff.7.html \
342 roff.7.xhtml \
343 roff.7.ps \
344 roff.7.pdf \
345 roff.7.txt \
346 tbl.7.html \
347 tbl.7.xhtml \
348 tbl.7.ps \
349 tbl.7.pdf \
350 tbl.7.txt \
351 mandocdb.8.html \
352 mandocdb.8.xhtml \
353 mandocdb.8.ps \
354 mandocdb.8.pdf \
355 mandocdb.8.txt
356
357 $(INDEX_MANS): mandoc
358
359 INDEX_OBJS = $(INDEX_MANS) \
360 man.h.html \
361 mandoc.h.html \
362 mdoc.h.html \
363 mdocml.tar.gz \
364 mdocml.md5
365
366 www: index.html
367
368 lint: llib-lmandoc.ln llib-lpreconv.ln llib-ldemandoc.ln $(DBLN)
369
370 clean:
371 rm -f libmandoc.a $(LIBMANDOC_OBJS)
372 rm -f llib-llibmandoc.ln $(LIBMANDOC_LNS)
373 rm -f mandocdb $(MANDOCDB_OBJS)
374 rm -f llib-lmandocdb.ln $(MANDOCDB_LNS)
375 rm -f preconv $(PRECONV_OBJS)
376 rm -f llib-lpreconv.ln $(PRECONV_LNS)
377 rm -f apropos $(APROPOS_OBJS)
378 rm -f llib-lapropos.ln $(APROPOS_LNS)
379 rm -f man.cgi $(CGI_OBJS)
380 rm -f llib-lman.cgi.ln $(CGI_LNS)
381 rm -f demandoc $(DEMANDOC_OBJS)
382 rm -f llib-ldemandoc.ln $(DEMANDOC_LNS)
383 rm -f mandoc $(MANDOC_OBJS)
384 rm -f llib-lmandoc.ln $(MANDOC_LNS)
385 rm -f config.h config.log $(COMPAT_OBJS) $(COMPAT_LNS)
386 rm -f mdocml.tar.gz mdocml-win32.zip mdocml-win64.zip mdocml-macosx.zip
387 rm -f index.html $(INDEX_OBJS)
388 rm -rf test-strlcpy.DSYM
389 rm -rf test-strlcat.DSYM
390 rm -rf test-strptime.DSYM
391 rm -rf test-mmap.DSYM
392 rm -rf test-getsubopt.DSYM
393
394 install: all
395 mkdir -p $(DESTDIR)$(BINDIR)
396 mkdir -p $(DESTDIR)$(EXAMPLEDIR)
397 mkdir -p $(DESTDIR)$(LIBDIR)
398 mkdir -p $(DESTDIR)$(INCLUDEDIR)
399 mkdir -p $(DESTDIR)$(MANDIR)/man1
400 mkdir -p $(DESTDIR)$(MANDIR)/man3
401 mkdir -p $(DESTDIR)$(MANDIR)/man7
402 mkdir -p $(DESTDIR)$(MANDIR)/man8
403 $(INSTALL_PROGRAM) mandoc preconv demandoc $(DESTDIR)$(BINDIR)
404 $(INSTALL_LIB) libmandoc.a $(DESTDIR)$(LIBDIR)
405 $(INSTALL_LIB) man.h mdoc.h mandoc.h $(DESTDIR)$(INCLUDEDIR)
406 $(INSTALL_MAN) mandoc.1 preconv.1 demandoc.1 $(DESTDIR)$(MANDIR)/man1
407 $(INSTALL_MAN) mandoc.3 $(DESTDIR)$(MANDIR)/man3
408 $(INSTALL_MAN) man.7 mdoc.7 roff.7 eqn.7 tbl.7 mandoc_char.7 $(DESTDIR)$(MANDIR)/man7
409 $(INSTALL_DATA) example.style.css $(DESTDIR)$(EXAMPLEDIR)
410
411 installwww: www
412 mkdir -p $(PREFIX)/snapshots
413 mkdir -p $(PREFIX)/binaries
414 $(INSTALL_DATA) index.html external.png index.css $(PREFIX)
415 $(INSTALL_DATA) $(INDEX_MANS) style.css $(PREFIX)
416 $(INSTALL_DATA) mandoc.h.html man.h.html mdoc.h.html $(PREFIX)
417 $(INSTALL_DATA) mdocml.tar.gz $(PREFIX)/snapshots
418 $(INSTALL_DATA) mdocml.md5 $(PREFIX)/snapshots
419 $(INSTALL_DATA) mdocml.tar.gz $(PREFIX)/snapshots/mdocml-$(VERSION).tar.gz
420 $(INSTALL_DATA) mdocml.md5 $(PREFIX)/snapshots/mdocml-$(VERSION).md5
421
422 libmandoc.a: $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
423 $(AR) rs $@ $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
424
425 llib-llibmandoc.ln: $(COMPAT_LNS) $(LIBMANDOC_LNS)
426 $(LINT) $(LINTFLAGS) -Clibmandoc $(COMPAT_LNS) $(LIBMANDOC_LNS)
427
428 mandoc: $(MANDOC_OBJS) libmandoc.a
429 $(CC) $(LDFLAGS) -o $@ $(MANDOC_OBJS) libmandoc.a
430
431 llib-lmandoc.ln: $(MANDOC_LNS) llib-llibmandoc.ln
432 $(LINT) $(LINTFLAGS) -Cmandoc $(MANDOC_LNS) llib-llibmandoc.ln
433
434 mandocdb: $(MANDOCDB_OBJS) libmandoc.a
435 $(CC) $(LDFLAGS) -o $@ $(MANDOCDB_OBJS) libmandoc.a $(DBLIB)
436
437 llib-lmandocdb.ln: $(MANDOCDB_LNS) llib-llibmandoc.ln
438 $(LINT) $(LINTFLAGS) -Cmandocdb $(MANDOCDB_LNS) llib-llibmandoc.ln
439
440 preconv: $(PRECONV_OBJS)
441 $(CC) $(LDFLAGS) -o $@ $(PRECONV_OBJS)
442
443 llib-lpreconv.ln: $(PRECONV_LNS) llib-llibmandoc.ln
444 $(LINT) $(LINTFLAGS) -Cpreconv $(PRECONV_LNS) llib-llibmandoc.ln
445
446 apropos: $(APROPOS_OBJS) libmandoc.a
447 $(CC) $(LDFLAGS) -o $@ $(APROPOS_OBJS) libmandoc.a $(DBLIB)
448
449 llib-lapropos.ln: $(APROPOS_LNS) llib-llibmandoc.ln
450 $(LINT) $(LINTFLAGS) -Capropos $(APROPOS_LNS) llib-llibmandoc.ln
451
452 man.cgi: $(CGI_OBJS) libmandoc.a
453 $(CC) $(LDFLAGS) -o $@ $(CGI_OBJS) libmandoc.a $(DBLIB)
454
455 llib-lman.cgi.ln: $(CGI_LNS) llib-llibmandoc.ln
456 $(LINT) $(LINTFLAGS) -Cman.cgi $(CGI_LNS) llib-llibmandoc.ln
457
458 demandoc: $(DEMANDOC_OBJS) libmandoc.a
459 $(CC) $(LDFLAGS) -o $@ $(DEMANDOC_OBJS) libmandoc.a
460
461 llib-ldemandoc.ln: $(DEMANDOC_LNS) llib-llibmandoc.ln
462 $(LINT) $(LINTFLAGS) -Cdemandoc $(DEMANDOC_LNS) llib-llibmandoc.ln
463
464 mdocml.md5: mdocml.tar.gz
465 md5 mdocml.tar.gz >$@
466
467 mdocml.tar.gz: $(SRCS)
468 mkdir -p .dist/mdocml-$(VERSION)/
469 $(INSTALL_SOURCE) $(SRCS) .dist/mdocml-$(VERSION)
470 ( cd .dist/ && tar zcf ../$@ ./ )
471 rm -rf .dist/
472
473 mdocml-win32.zip: $(SRCS)
474 mkdir -p .win32/mdocml-$(VERSION)/
475 $(INSTALL_SOURCE) $(SRCS) .win32
476 cp .win32/Makefile .win32/Makefile.old
477 egrep -v -e DUSE_WCHAR -e ^DBBIN .win32/Makefile.old >.win32/Makefile
478 ( cd .win32; \
479 CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar CFLAGS='-DOSNAME=\"Windows\"' make; \
480 make install PREFIX=mdocml-$(VERSION) ; \
481 zip -r ../$@ mdocml-$(VERSION) )
482 rm -rf .win32
483
484 mdocml-win64.zip: $(SRCS)
485 mkdir -p .win64/mdocml-$(VERSION)/
486 $(INSTALL_SOURCE) $(SRCS) .win64
487 cp .win64/Makefile .win64/Makefile.old
488 egrep -v -e DUSE_WCHAR -e ^DBBIN .win64/Makefile.old >.win64/Makefile
489 ( cd .win64; \
490 CC=x86_64-w64-mingw32-gcc AR=x86_64-w64-mingw32-ar CFLAGS='-DOSNAME=\"Windows\"' make; \
491 make install PREFIX=mdocml-$(VERSION) ; \
492 zip -r ../$@ mdocml-$(VERSION) )
493 rm -rf .win64
494
495 mdocml-macosx.zip: $(SRCS)
496 mkdir -p .macosx/mdocml-$(VERSION)/
497 $(INSTALL_SOURCE) $(SRCS) .macosx
498 ( cd .macosx; \
499 CFLAGS="-arch i386 -arch x86_64 -arch ppc" LDFLAGS="-arch i386 -arch x86_64 -arch ppc" make; \
500 make install PREFIX=mdocml-$(VERSION) ; \
501 zip -r ../$@ mdocml-$(VERSION) )
502 rm -rf .macosx
503
504 index.html: $(INDEX_OBJS)
505
506 config.h: config.h.pre config.h.post
507 rm -f config.log
508 ( cat config.h.pre; \
509 echo; \
510 if $(CC) $(CFLAGS) -Werror -o test-strptime test-strptime.c >> config.log 2>&1; then \
511 echo '#define HAVE_STRPTIME'; \
512 rm test-strptime; \
513 fi; \
514 if $(CC) $(CFLAGS) -Werror -o test-getsubopt test-getsubopt.c >> config.log 2>&1; then \
515 echo '#define HAVE_GETSUBOPT'; \
516 rm test-getsubopt; \
517 fi; \
518 if $(CC) $(CFLAGS) -Werror -o test-strlcat test-strlcat.c >> config.log 2>&1; then \
519 echo '#define HAVE_STRLCAT'; \
520 rm test-strlcat; \
521 fi; \
522 if $(CC) $(CFLAGS) -Werror -o test-mmap test-mmap.c >> config.log 2>&1; then \
523 echo '#define HAVE_MMAP'; \
524 rm test-mmap; \
525 fi; \
526 if $(CC) $(CFLAGS) -Werror -o test-strlcpy test-strlcpy.c >> config.log 2>&1; then \
527 echo '#define HAVE_STRLCPY'; \
528 rm test-strlcpy; \
529 fi; \
530 echo; \
531 cat config.h.post \
532 ) > $@
533
534 .h.h.html:
535 highlight -I $< >$@
536
537 .1.1.txt .3.3.txt .7.7.txt .8.8.txt:
538 ./mandoc -Tascii -Wall,stop $< | col -b >$@
539
540 .1.1.html .3.3.html .7.7.html .8.8.html:
541 ./mandoc -Thtml -Wall,stop -Ostyle=style.css,man=%N.%S.html,includes=%I.html $< >$@
542
543 .1.1.ps .3.3.ps .7.7.ps .8.8.ps:
544 ./mandoc -Tps -Wall,stop $< >$@
545
546 .1.1.xhtml .3.3.xhtml .7.7.xhtml .8.8.xhtml:
547 ./mandoc -Txhtml -Wall,stop -Ostyle=style.css,man=%N.%S.xhtml,includes=%I.html $< >$@
548
549 .1.1.pdf .3.3.pdf .7.7.pdf .8.8.pdf:
550 ./mandoc -Tpdf -Wall,stop $< >$@
551
552 .sgml.html:
553 validate --warn $<
554 sed -e "s!@VERSION@!$(VERSION)!" -e "s!@VDATE@!$(VDATE)!" $< >$@