1 .PHONY: clean install installwww
2 .SUFFIXES: .sgml .html .md5 .h .h.html
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
10 # Specify this if you want to hard-code the operating system to appear
11 # in the lower-left hand corner of -mdoc manuals.
13 # CFLAGS += -DOSNAME="\"OpenBSD 4.5\""
16 VDATE = 8 October 2011
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.
26 # If your system has manpath(1), uncomment this. This is most any
27 # system that's not OpenBSD or NetBSD. If uncommented, apropos(1),
28 # mandocdb(8), and man.cgi will popen(3) manpath(1) to get the MANPATH
30 #CFLAGS += -DUSE_MANPATH
32 # If your system supports static binaries only, uncomment this.
35 CFLAGS += -g -DHAVE_CONFIG_H -DVERSION="\"$(VERSION)\""
36 CFLAGS += -W -Wall -Wstrict-prototypes -Wno-unused-parameter -Wwrite-strings
39 HTDOCDIR = $(WWWPREFIX)/htdocs
40 CGIBINDIR = $(WWWPREFIX)/cgi-bin
41 BINDIR = $(PREFIX)/bin
42 INCLUDEDIR = $(PREFIX)/include/mandoc
43 LIBDIR = $(PREFIX)/lib/mandoc
44 MANDIR = $(PREFIX)/man
45 EXAMPLEDIR = $(PREFIX)/share/examples/mandoc
47 INSTALL_PROGRAM = $(INSTALL) -m 0755
48 INSTALL_DATA = $(INSTALL) -m 0444
49 INSTALL_LIB = $(INSTALL) -m 0644
50 INSTALL_SOURCE = $(INSTALL) -m 0644
51 INSTALL_MAN = $(INSTALL_DATA)
53 # Non-BSD systems (Linux, etc.) need -ldb to compile mandocdb and
55 # However, if you don't have -ldb at all (or it's not native), then
56 # comment out apropos and mandocdb.
59 DBBIN = apropos mandocdb man.cgi catman whatis
60 DBLN = llib-lapropos.ln llib-lmandocdb.ln llib-lman.cgi.ln llib-lcatman.ln
62 all: mandoc preconv demandoc $(DBBIN)
162 LIBMAN_OBJS = man.o \
166 LIBMAN_LNS = man.ln \
171 LIBMDOC_OBJS = arch.o \
181 LIBMDOC_LNS = arch.ln \
192 LIBROFF_OBJS = eqn.o \
198 LIBROFF_LNS = eqn.ln \
205 LIBMANDOC_OBJS = $(LIBMAN_OBJS) \
212 LIBMANDOC_LNS = $(LIBMAN_LNS) \
220 COMPAT_OBJS = compat_getsubopt.o \
223 COMPAT_LNS = compat_getsubopt.ln \
227 arch.o arch.ln: arch.in
229 chars.o chars.ln: chars.in
231 msec.o msec.ln: msec.in
232 roff.o roff.ln: predefs.in
236 $(LIBMAN_OBJS) $(LIBMAN_LNS): libman.h
237 $(LIBMDOC_OBJS) $(LIBMDOC_LNS): libmdoc.h
238 $(LIBROFF_OBJS) $(LIBROFF_LNS): libroff.h
239 $(LIBMANDOC_OBJS) $(LIBMANDOC_LNS): mandoc.h mdoc.h man.h libmandoc.h config.h
241 $(COMPAT_OBJS) $(COMPAT_LNS): config.h
243 MANDOC_HTML_OBJS = eqn_html.o \
248 MANDOC_HTML_LNS = eqn_html.ln \
254 MANDOC_MAN_OBJS = mdoc_man.o
255 MANDOC_MAN_LNS = mdoc_man.ln
257 MANDOC_TERM_OBJS = eqn_term.o \
264 MANDOC_TERM_LNS = eqn_term.ln \
272 MANDOC_OBJS = $(MANDOC_HTML_OBJS) \
274 $(MANDOC_TERM_OBJS) \
278 MANDOC_LNS = $(MANDOC_HTML_LNS) \
285 $(MANDOC_HTML_OBJS) $(MANDOC_HTML_LNS): html.h
286 $(MANDOC_TERM_OBJS) $(MANDOC_TERM_LNS): term.h
287 $(MANDOC_OBJS) $(MANDOC_LNS): main.h mandoc.h mdoc.h man.h config.h out.h
289 MANDOCDB_OBJS = mandocdb.o manpath.o
290 MANDOCDB_LNS = mandocdb.ln manpath.ln
292 $(MANDOCDB_OBJS) $(MANDOCDB_LNS): mandocdb.h mandoc.h mdoc.h man.h config.h manpath.h
294 PRECONV_OBJS = preconv.o
295 PRECONV_LNS = preconv.ln
297 $(PRECONV_OBJS) $(PRECONV_LNS): config.h
299 APROPOS_OBJS = apropos.o apropos_db.o manpath.o
300 APROPOS_LNS = apropos.ln apropos_db.ln manpath.ln
302 $(APROPOS_OBJS) $(APROPOS_LNS): config.h mandoc.h apropos_db.h manpath.h mandocdb.h
304 CGI_OBJS = $(MANDOC_HTML_OBJS) \
306 $(MANDOC_TERM_OBJS) \
313 CGI_LNS = $(MANDOC_HTML_LNS) \
322 $(CGI_OBJS) $(CGI_LNS): main.h mdoc.h man.h out.h config.h mandoc.h apropos_db.h manpath.h mandocdb.h
324 CATMAN_OBJS = catman.o manpath.o
325 CATMAN_LNS = catman.ln manpath.ln
327 $(CATMAN_OBJS) $(CATMAN_LNS): config.h mandoc.h manpath.h
329 DEMANDOC_OBJS = demandoc.o
330 DEMANDOC_LNS = demandoc.ln
332 $(DEMANDOC_OBJS) $(DEMANDOC_LNS): config.h
334 INDEX_MANS = apropos.1.html \
365 mandoc_char.7.xhtml \
395 $(INDEX_MANS): mandoc
397 INDEX_OBJS = $(INDEX_MANS) \
406 lint: llib-lmandoc.ln llib-lpreconv.ln llib-ldemandoc.ln $(DBLN)
409 rm -f libmandoc.a $(LIBMANDOC_OBJS)
410 rm -f llib-llibmandoc.ln $(LIBMANDOC_LNS)
411 rm -f mandocdb $(MANDOCDB_OBJS)
412 rm -f llib-lmandocdb.ln $(MANDOCDB_LNS)
413 rm -f preconv $(PRECONV_OBJS)
414 rm -f llib-lpreconv.ln $(PRECONV_LNS)
415 rm -f apropos $(APROPOS_OBJS)
416 rm -f llib-lapropos.ln $(APROPOS_LNS)
417 rm -f man.cgi $(CGI_OBJS)
418 rm -f llib-lman.cgi.ln $(CGI_LNS)
419 rm -f catman $(CATMAN_OBJS)
420 rm -f llib-lcatman.ln $(CATMAN_LNS)
421 rm -f demandoc $(DEMANDOC_OBJS)
422 rm -f llib-ldemandoc.ln $(DEMANDOC_LNS)
423 rm -f mandoc $(MANDOC_OBJS)
424 rm -f llib-lmandoc.ln $(MANDOC_LNS)
425 rm -f config.h config.log $(COMPAT_OBJS) $(COMPAT_LNS)
426 rm -f mdocml.tar.gz mdocml-win32.zip mdocml-win64.zip mdocml-macosx.zip
427 rm -f index.html $(INDEX_OBJS)
428 rm -rf test-strlcpy.DSYM
429 rm -rf test-strlcat.DSYM
430 rm -rf test-strptime.DSYM
431 rm -rf test-mmap.DSYM
432 rm -rf test-getsubopt.DSYM
435 mkdir -p $(DESTDIR)$(BINDIR)
436 mkdir -p $(DESTDIR)$(EXAMPLEDIR)
437 mkdir -p $(DESTDIR)$(LIBDIR)
438 mkdir -p $(DESTDIR)$(INCLUDEDIR)
439 mkdir -p $(DESTDIR)$(MANDIR)/man1
440 mkdir -p $(DESTDIR)$(MANDIR)/man3
441 mkdir -p $(DESTDIR)$(MANDIR)/man7
442 mkdir -p $(DESTDIR)$(MANDIR)/man8
443 $(INSTALL_PROGRAM) mandoc preconv demandoc $(DESTDIR)$(BINDIR)
444 $(INSTALL_LIB) libmandoc.a $(DESTDIR)$(LIBDIR)
445 $(INSTALL_LIB) man.h mdoc.h mandoc.h $(DESTDIR)$(INCLUDEDIR)
446 $(INSTALL_MAN) mandoc.1 preconv.1 demandoc.1 $(DESTDIR)$(MANDIR)/man1
447 $(INSTALL_MAN) mandoc.3 $(DESTDIR)$(MANDIR)/man3
448 $(INSTALL_MAN) man.7 mdoc.7 roff.7 eqn.7 tbl.7 mandoc_char.7 $(DESTDIR)$(MANDIR)/man7
449 $(INSTALL_DATA) example.style.css $(DESTDIR)$(EXAMPLEDIR)
452 mkdir -p $(DESTDIR)$(CGIBINDIR)
453 mkdir -p $(DESTDIR)$(HTDOCDIR)
454 $(INSTALL_PROGRAM) man.cgi $(DESTDIR)$(CGIBINDIR)
455 $(INSTALL_DATA) example.style.css $(DESTDIR)$(HTDOCDIR)/man.css
456 $(INSTALL_DATA) man.cgi.css $(DESTDIR)$(HTDOCDIR)
459 mkdir -p $(PREFIX)/snapshots
460 mkdir -p $(PREFIX)/binaries
461 $(INSTALL_DATA) index.html external.png index.css $(PREFIX)
462 $(INSTALL_DATA) $(INDEX_MANS) style.css $(PREFIX)
463 $(INSTALL_DATA) mandoc.h.html man.h.html mdoc.h.html $(PREFIX)
464 $(INSTALL_DATA) mdocml.tar.gz $(PREFIX)/snapshots
465 $(INSTALL_DATA) mdocml.md5 $(PREFIX)/snapshots
466 $(INSTALL_DATA) mdocml.tar.gz $(PREFIX)/snapshots/mdocml-$(VERSION).tar.gz
467 $(INSTALL_DATA) mdocml.md5 $(PREFIX)/snapshots/mdocml-$(VERSION).md5
469 libmandoc.a: $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
470 $(AR) rs $@ $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
472 llib-llibmandoc.ln: $(COMPAT_LNS) $(LIBMANDOC_LNS)
473 $(LINT) $(LINTFLAGS) -Clibmandoc $(COMPAT_LNS) $(LIBMANDOC_LNS)
475 mandoc: $(MANDOC_OBJS) libmandoc.a
476 $(CC) $(LDFLAGS) -o $@ $(MANDOC_OBJS) libmandoc.a
478 llib-lmandoc.ln: $(MANDOC_LNS) llib-llibmandoc.ln
479 $(LINT) $(LINTFLAGS) -Cmandoc $(MANDOC_LNS) llib-llibmandoc.ln
481 mandocdb: $(MANDOCDB_OBJS) libmandoc.a
482 $(CC) $(LDFLAGS) -o $@ $(MANDOCDB_OBJS) libmandoc.a $(DBLIB)
484 llib-lmandocdb.ln: $(MANDOCDB_LNS) llib-llibmandoc.ln
485 $(LINT) $(LINTFLAGS) -Cmandocdb $(MANDOCDB_LNS) llib-llibmandoc.ln
487 preconv: $(PRECONV_OBJS)
488 $(CC) $(LDFLAGS) -o $@ $(PRECONV_OBJS)
490 llib-lpreconv.ln: $(PRECONV_LNS) llib-llibmandoc.ln
491 $(LINT) $(LINTFLAGS) -Cpreconv $(PRECONV_LNS) llib-llibmandoc.ln
496 apropos: $(APROPOS_OBJS) libmandoc.a
497 $(CC) $(LDFLAGS) -o $@ $(APROPOS_OBJS) libmandoc.a $(DBLIB)
499 llib-lapropos.ln: $(APROPOS_LNS) llib-llibmandoc.ln
500 $(LINT) $(LINTFLAGS) -Capropos $(APROPOS_LNS) llib-llibmandoc.ln
502 catman: $(CATMAN_OBJS) libmandoc.a
503 $(CC) $(LDFLAGS) -o $@ $(CATMAN_OBJS) libmandoc.a $(DBLIB)
505 llib-lcatman.ln: $(CATMAN_LNS) llib-llibmandoc.ln
506 $(LINT) $(LINTFLAGS) -Ccatman $(CATMAN_LNS) llib-llibmandoc.ln
508 man.cgi: $(CGI_OBJS) libmandoc.a
509 $(CC) $(LDFLAGS) $(STATIC) -o $@ $(CGI_OBJS) libmandoc.a $(DBLIB)
511 llib-lman.cgi.ln: $(CGI_LNS) llib-llibmandoc.ln
512 $(LINT) $(LINTFLAGS) -Cman.cgi $(CGI_LNS) llib-llibmandoc.ln
514 demandoc: $(DEMANDOC_OBJS) libmandoc.a
515 $(CC) $(LDFLAGS) -o $@ $(DEMANDOC_OBJS) libmandoc.a
517 llib-ldemandoc.ln: $(DEMANDOC_LNS) llib-llibmandoc.ln
518 $(LINT) $(LINTFLAGS) -Cdemandoc $(DEMANDOC_LNS) llib-llibmandoc.ln
520 mdocml.md5: mdocml.tar.gz
521 md5 mdocml.tar.gz >$@
523 mdocml.tar.gz: $(SRCS)
524 mkdir -p .dist/mdocml-$(VERSION)/
525 $(INSTALL_SOURCE) $(SRCS) .dist/mdocml-$(VERSION)
526 ( cd .dist/ && tar zcf ../$@ ./ )
529 mdocml-win32.zip: $(SRCS)
530 mkdir -p .win32/mdocml-$(VERSION)/
531 $(INSTALL_SOURCE) $(SRCS) .win32
532 cp .win32/Makefile .win32/Makefile.old
533 egrep -v -e DUSE_WCHAR -e ^DBBIN .win32/Makefile.old >.win32/Makefile
535 CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar CFLAGS='-DOSNAME=\"Windows\"' make; \
536 make install PREFIX=mdocml-$(VERSION) ; \
537 zip -r ../$@ mdocml-$(VERSION) )
540 mdocml-win64.zip: $(SRCS)
541 mkdir -p .win64/mdocml-$(VERSION)/
542 $(INSTALL_SOURCE) $(SRCS) .win64
543 cp .win64/Makefile .win64/Makefile.old
544 egrep -v -e DUSE_WCHAR -e ^DBBIN .win64/Makefile.old >.win64/Makefile
546 CC=x86_64-w64-mingw32-gcc AR=x86_64-w64-mingw32-ar CFLAGS='-DOSNAME=\"Windows\"' make; \
547 make install PREFIX=mdocml-$(VERSION) ; \
548 zip -r ../$@ mdocml-$(VERSION) )
551 mdocml-macosx.zip: $(SRCS)
552 mkdir -p .macosx/mdocml-$(VERSION)/
553 $(INSTALL_SOURCE) $(SRCS) .macosx
555 CFLAGS="-arch i386 -arch x86_64 -arch ppc" LDFLAGS="-arch i386 -arch x86_64 -arch ppc" make; \
556 make install PREFIX=mdocml-$(VERSION) ; \
557 zip -r ../$@ mdocml-$(VERSION) )
560 index.html: $(INDEX_OBJS)
562 config.h: config.h.pre config.h.post
564 ( cat config.h.pre; \
566 if $(CC) $(CFLAGS) -Werror -o test-strptime test-strptime.c >> config.log 2>&1; then \
567 echo '#define HAVE_STRPTIME'; \
570 if $(CC) $(CFLAGS) -Werror -o test-getsubopt test-getsubopt.c >> config.log 2>&1; then \
571 echo '#define HAVE_GETSUBOPT'; \
574 if $(CC) $(CFLAGS) -Werror -o test-strlcat test-strlcat.c >> config.log 2>&1; then \
575 echo '#define HAVE_STRLCAT'; \
578 if $(CC) $(CFLAGS) -Werror -o test-mmap test-mmap.c >> config.log 2>&1; then \
579 echo '#define HAVE_MMAP'; \
582 if $(CC) $(CFLAGS) -Werror -o test-strlcpy test-strlcpy.c >> config.log 2>&1; then \
583 echo '#define HAVE_STRLCPY'; \
593 .1.1.txt .3.3.txt .7.7.txt .8.8.txt:
594 ./mandoc -Tascii -Wall,stop $< | col -b >$@
596 .1.1.html .3.3.html .7.7.html .8.8.html:
597 ./mandoc -Thtml -Wall,stop -Ostyle=style.css,man=%N.%S.html,includes=%I.html $< >$@
599 .1.1.ps .3.3.ps .7.7.ps .8.8.ps:
600 ./mandoc -Tps -Wall,stop $< >$@
602 .1.1.xhtml .3.3.xhtml .7.7.xhtml .8.8.xhtml:
603 ./mandoc -Txhtml -Wall,stop -Ostyle=style.css,man=%N.%S.xhtml,includes=%I.html $< >$@
605 .1.1.pdf .3.3.pdf .7.7.pdf .8.8.pdf:
606 ./mandoc -Tpdf -Wall,stop $< >$@
610 sed -e "s!@VERSION@!$(VERSION)!" -e "s!@VDATE@!$(VDATE)!" $< >$@