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. This
33 # appears only to be BSD UNIX systems (Mac OS X has no support and Linux
34 # requires -pthreads for static libdb).
37 CFLAGS += -g -DHAVE_CONFIG_H -DVERSION="\"$(VERSION)\""
38 CFLAGS += -W -Wall -Wstrict-prototypes -Wno-unused-parameter -Wwrite-strings
41 HTDOCDIR = $(WWWPREFIX)/htdocs
42 CGIBINDIR = $(WWWPREFIX)/cgi-bin
43 BINDIR = $(PREFIX)/bin
44 INCLUDEDIR = $(PREFIX)/include/mandoc
45 LIBDIR = $(PREFIX)/lib/mandoc
46 MANDIR = $(PREFIX)/man
47 EXAMPLEDIR = $(PREFIX)/share/examples/mandoc
49 INSTALL_PROGRAM = $(INSTALL) -m 0755
50 INSTALL_DATA = $(INSTALL) -m 0444
51 INSTALL_LIB = $(INSTALL) -m 0644
52 INSTALL_SOURCE = $(INSTALL) -m 0644
53 INSTALL_MAN = $(INSTALL_DATA)
55 # Non-BSD systems (Linux, etc.) need -ldb to compile mandocdb and
57 # However, if you don't have -ldb at all (or it's not native), then
58 # comment out apropos and mandocdb.
61 DBBIN = apropos mandocdb man.cgi catman whatis
62 DBLN = llib-lapropos.ln llib-lmandocdb.ln llib-lman.cgi.ln llib-lcatman.ln
64 all: mandoc preconv demandoc $(DBBIN)
173 LIBMAN_OBJS = man.o \
177 LIBMAN_LNS = man.ln \
182 LIBMDOC_OBJS = arch.o \
192 LIBMDOC_LNS = arch.ln \
203 LIBROFF_OBJS = eqn.o \
209 LIBROFF_LNS = eqn.ln \
216 LIBMANDOC_OBJS = $(LIBMAN_OBJS) \
223 LIBMANDOC_LNS = $(LIBMAN_LNS) \
231 COMPAT_OBJS = compat_fgetln.o \
235 COMPAT_LNS = compat_fgetln.ln \
236 compat_getsubopt.ln \
240 arch.o arch.ln: arch.in
242 chars.o chars.ln: chars.in
244 msec.o msec.ln: msec.in
245 roff.o roff.ln: predefs.in
249 $(LIBMAN_OBJS) $(LIBMAN_LNS): libman.h
250 $(LIBMDOC_OBJS) $(LIBMDOC_LNS): libmdoc.h
251 $(LIBROFF_OBJS) $(LIBROFF_LNS): libroff.h
252 $(LIBMANDOC_OBJS) $(LIBMANDOC_LNS): mandoc.h mdoc.h man.h libmandoc.h config.h
254 $(COMPAT_OBJS) $(COMPAT_LNS): config.h
256 MANDOC_HTML_OBJS = eqn_html.o \
261 MANDOC_HTML_LNS = eqn_html.ln \
267 MANDOC_MAN_OBJS = mdoc_man.o
268 MANDOC_MAN_LNS = mdoc_man.ln
270 MANDOC_TERM_OBJS = eqn_term.o \
277 MANDOC_TERM_LNS = eqn_term.ln \
285 MANDOC_OBJS = $(MANDOC_HTML_OBJS) \
287 $(MANDOC_TERM_OBJS) \
291 MANDOC_LNS = $(MANDOC_HTML_LNS) \
298 $(MANDOC_HTML_OBJS) $(MANDOC_HTML_LNS): html.h
299 $(MANDOC_TERM_OBJS) $(MANDOC_TERM_LNS): term.h
300 $(MANDOC_OBJS) $(MANDOC_LNS): main.h mandoc.h mdoc.h man.h config.h out.h
302 MANDOCDB_OBJS = mandocdb.o manpath.o
303 MANDOCDB_LNS = mandocdb.ln manpath.ln
305 $(MANDOCDB_OBJS) $(MANDOCDB_LNS): mandocdb.h mandoc.h mdoc.h man.h config.h manpath.h
307 PRECONV_OBJS = preconv.o
308 PRECONV_LNS = preconv.ln
310 $(PRECONV_OBJS) $(PRECONV_LNS): config.h
312 APROPOS_OBJS = apropos.o apropos_db.o manpath.o
313 APROPOS_LNS = apropos.ln apropos_db.ln manpath.ln
315 $(APROPOS_OBJS) $(APROPOS_LNS): config.h mandoc.h apropos_db.h manpath.h mandocdb.h
317 CGI_OBJS = $(MANDOC_HTML_OBJS) \
319 $(MANDOC_TERM_OBJS) \
326 CGI_LNS = $(MANDOC_HTML_LNS) \
335 $(CGI_OBJS) $(CGI_LNS): main.h mdoc.h man.h out.h config.h mandoc.h apropos_db.h manpath.h mandocdb.h
337 CATMAN_OBJS = catman.o manpath.o
338 CATMAN_LNS = catman.ln manpath.ln
340 $(CATMAN_OBJS) $(CATMAN_LNS): config.h mandoc.h manpath.h mandocdb.h
342 DEMANDOC_OBJS = demandoc.o
343 DEMANDOC_LNS = demandoc.ln
345 $(DEMANDOC_OBJS) $(DEMANDOC_LNS): config.h
347 INDEX_MANS = apropos.1.html \
393 mandoc_char.7.xhtml \
423 $(INDEX_MANS): mandoc
425 INDEX_OBJS = $(INDEX_MANS) \
434 lint: llib-lmandoc.ln llib-lpreconv.ln llib-ldemandoc.ln $(DBLN)
437 rm -f libmandoc.a $(LIBMANDOC_OBJS)
438 rm -f llib-llibmandoc.ln $(LIBMANDOC_LNS)
439 rm -f mandocdb $(MANDOCDB_OBJS)
440 rm -f llib-lmandocdb.ln $(MANDOCDB_LNS)
441 rm -f preconv $(PRECONV_OBJS)
442 rm -f llib-lpreconv.ln $(PRECONV_LNS)
443 rm -f apropos whatis $(APROPOS_OBJS)
444 rm -f llib-lapropos.ln $(APROPOS_LNS)
445 rm -f man.cgi $(CGI_OBJS)
446 rm -f llib-lman.cgi.ln $(CGI_LNS)
447 rm -f catman $(CATMAN_OBJS)
448 rm -f llib-lcatman.ln $(CATMAN_LNS)
449 rm -f demandoc $(DEMANDOC_OBJS)
450 rm -f llib-ldemandoc.ln $(DEMANDOC_LNS)
451 rm -f mandoc $(MANDOC_OBJS)
452 rm -f llib-lmandoc.ln $(MANDOC_LNS)
453 rm -f config.h config.log $(COMPAT_OBJS) $(COMPAT_LNS)
454 rm -f mdocml.tar.gz mdocml-win32.zip mdocml-win64.zip mdocml-macosx.zip
455 rm -f index.html $(INDEX_OBJS)
456 rm -rf test-fgetln.DSYM
457 rm -rf test-strlcpy.DSYM
458 rm -rf test-strlcat.DSYM
459 rm -rf test-strptime.DSYM
460 rm -rf test-mmap.DSYM
461 rm -rf test-getsubopt.DSYM
464 mkdir -p $(DESTDIR)$(BINDIR)
465 mkdir -p $(DESTDIR)$(EXAMPLEDIR)
466 mkdir -p $(DESTDIR)$(LIBDIR)
467 mkdir -p $(DESTDIR)$(INCLUDEDIR)
468 mkdir -p $(DESTDIR)$(MANDIR)/man1
469 mkdir -p $(DESTDIR)$(MANDIR)/man3
470 mkdir -p $(DESTDIR)$(MANDIR)/man7
471 $(INSTALL_PROGRAM) mandoc preconv demandoc $(DESTDIR)$(BINDIR)
472 $(INSTALL_LIB) libmandoc.a $(DESTDIR)$(LIBDIR)
473 $(INSTALL_LIB) man.h mdoc.h mandoc.h $(DESTDIR)$(INCLUDEDIR)
474 $(INSTALL_MAN) mandoc.1 preconv.1 demandoc.1 $(DESTDIR)$(MANDIR)/man1
475 $(INSTALL_MAN) mandoc.3 $(DESTDIR)$(MANDIR)/man3
476 $(INSTALL_MAN) man.7 mdoc.7 roff.7 eqn.7 tbl.7 mandoc_char.7 $(DESTDIR)$(MANDIR)/man7
477 $(INSTALL_DATA) example.style.css $(DESTDIR)$(EXAMPLEDIR)
480 mkdir -p $(DESTDIR)$(CGIBINDIR)
481 mkdir -p $(DESTDIR)$(HTDOCDIR)
482 $(INSTALL_PROGRAM) man.cgi $(DESTDIR)$(CGIBINDIR)
483 $(INSTALL_DATA) example.style.css $(DESTDIR)$(HTDOCDIR)/man.css
484 $(INSTALL_DATA) man-cgi.css $(DESTDIR)$(HTDOCDIR)
487 mkdir -p $(PREFIX)/snapshots
488 mkdir -p $(PREFIX)/binaries
489 $(INSTALL_DATA) index.html external.png index.css $(PREFIX)
490 $(INSTALL_DATA) $(INDEX_MANS) style.css $(PREFIX)
491 $(INSTALL_DATA) mandoc.h.html man.h.html mdoc.h.html $(PREFIX)
492 $(INSTALL_DATA) mdocml.tar.gz $(PREFIX)/snapshots
493 $(INSTALL_DATA) mdocml.md5 $(PREFIX)/snapshots
494 $(INSTALL_DATA) mdocml.tar.gz $(PREFIX)/snapshots/mdocml-$(VERSION).tar.gz
495 $(INSTALL_DATA) mdocml.md5 $(PREFIX)/snapshots/mdocml-$(VERSION).md5
497 libmandoc.a: $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
498 $(AR) rs $@ $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
500 llib-llibmandoc.ln: $(COMPAT_LNS) $(LIBMANDOC_LNS)
501 $(LINT) $(LINTFLAGS) -Clibmandoc $(COMPAT_LNS) $(LIBMANDOC_LNS)
503 mandoc: $(MANDOC_OBJS) libmandoc.a
504 $(CC) $(LDFLAGS) -o $@ $(MANDOC_OBJS) libmandoc.a
506 llib-lmandoc.ln: $(MANDOC_LNS) llib-llibmandoc.ln
507 $(LINT) $(LINTFLAGS) -Cmandoc $(MANDOC_LNS) llib-llibmandoc.ln
509 mandocdb: $(MANDOCDB_OBJS) libmandoc.a
510 $(CC) $(LDFLAGS) -o $@ $(MANDOCDB_OBJS) libmandoc.a $(DBLIB)
512 llib-lmandocdb.ln: $(MANDOCDB_LNS) llib-llibmandoc.ln
513 $(LINT) $(LINTFLAGS) -Cmandocdb $(MANDOCDB_LNS) llib-llibmandoc.ln
515 preconv: $(PRECONV_OBJS)
516 $(CC) $(LDFLAGS) -o $@ $(PRECONV_OBJS)
518 llib-lpreconv.ln: $(PRECONV_LNS) llib-llibmandoc.ln
519 $(LINT) $(LINTFLAGS) -Cpreconv $(PRECONV_LNS) llib-llibmandoc.ln
524 apropos: $(APROPOS_OBJS) libmandoc.a
525 $(CC) $(LDFLAGS) -o $@ $(APROPOS_OBJS) libmandoc.a $(DBLIB)
527 llib-lapropos.ln: $(APROPOS_LNS) llib-llibmandoc.ln
528 $(LINT) $(LINTFLAGS) -Capropos $(APROPOS_LNS) llib-llibmandoc.ln
530 catman: $(CATMAN_OBJS) libmandoc.a
531 $(CC) $(LDFLAGS) -o $@ $(CATMAN_OBJS) libmandoc.a $(DBLIB)
533 llib-lcatman.ln: $(CATMAN_LNS) llib-llibmandoc.ln
534 $(LINT) $(LINTFLAGS) -Ccatman $(CATMAN_LNS) llib-llibmandoc.ln
536 man.cgi: $(CGI_OBJS) libmandoc.a
537 $(CC) $(LDFLAGS) $(STATIC) -o $@ $(CGI_OBJS) libmandoc.a $(DBLIB)
539 llib-lman.cgi.ln: $(CGI_LNS) llib-llibmandoc.ln
540 $(LINT) $(LINTFLAGS) -Cman.cgi $(CGI_LNS) llib-llibmandoc.ln
542 demandoc: $(DEMANDOC_OBJS) libmandoc.a
543 $(CC) $(LDFLAGS) -o $@ $(DEMANDOC_OBJS) libmandoc.a
545 llib-ldemandoc.ln: $(DEMANDOC_LNS) llib-llibmandoc.ln
546 $(LINT) $(LINTFLAGS) -Cdemandoc $(DEMANDOC_LNS) llib-llibmandoc.ln
548 mdocml.md5: mdocml.tar.gz
549 md5 mdocml.tar.gz >$@
551 mdocml.tar.gz: $(SRCS)
552 mkdir -p .dist/mdocml-$(VERSION)/
553 $(INSTALL_SOURCE) $(SRCS) .dist/mdocml-$(VERSION)
554 ( cd .dist/ && tar zcf ../$@ ./ )
557 mdocml-win32.zip: $(SRCS)
558 mkdir -p .win32/mdocml-$(VERSION)/
559 $(INSTALL_SOURCE) $(SRCS) .win32
560 cp .win32/Makefile .win32/Makefile.old
561 egrep -v -e DUSE_WCHAR -e ^DBBIN .win32/Makefile.old >.win32/Makefile
563 CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar CFLAGS='-DOSNAME=\"Windows\"' make; \
564 make install PREFIX=mdocml-$(VERSION) ; \
565 zip -r ../$@ mdocml-$(VERSION) )
568 mdocml-win64.zip: $(SRCS)
569 mkdir -p .win64/mdocml-$(VERSION)/
570 $(INSTALL_SOURCE) $(SRCS) .win64
571 cp .win64/Makefile .win64/Makefile.old
572 egrep -v -e DUSE_WCHAR -e ^DBBIN .win64/Makefile.old >.win64/Makefile
574 CC=x86_64-w64-mingw32-gcc AR=x86_64-w64-mingw32-ar CFLAGS='-DOSNAME=\"Windows\"' make; \
575 make install PREFIX=mdocml-$(VERSION) ; \
576 zip -r ../$@ mdocml-$(VERSION) )
579 mdocml-macosx.zip: $(SRCS)
580 mkdir -p .macosx/mdocml-$(VERSION)/
581 $(INSTALL_SOURCE) $(SRCS) .macosx
583 CFLAGS="-arch i386 -arch x86_64 -arch ppc" LDFLAGS="-arch i386 -arch x86_64 -arch ppc" make; \
584 make install PREFIX=mdocml-$(VERSION) ; \
585 zip -r ../$@ mdocml-$(VERSION) )
588 index.html: $(INDEX_OBJS)
590 config.h: config.h.pre config.h.post
592 ( cat config.h.pre; \
594 if $(CC) $(CFLAGS) -Werror -o test-fgetln test-fgetln.c >> config.log 2>&1; then \
595 echo '#define HAVE_FGETLN'; \
598 if $(CC) $(CFLAGS) -Werror -o test-strptime test-strptime.c >> config.log 2>&1; then \
599 echo '#define HAVE_STRPTIME'; \
602 if $(CC) $(CFLAGS) -Werror -o test-getsubopt test-getsubopt.c >> config.log 2>&1; then \
603 echo '#define HAVE_GETSUBOPT'; \
606 if $(CC) $(CFLAGS) -Werror -o test-strlcat test-strlcat.c >> config.log 2>&1; then \
607 echo '#define HAVE_STRLCAT'; \
610 if $(CC) $(CFLAGS) -Werror -o test-mmap test-mmap.c >> config.log 2>&1; then \
611 echo '#define HAVE_MMAP'; \
614 if $(CC) $(CFLAGS) -Werror -o test-strlcpy test-strlcpy.c >> config.log 2>&1; then \
615 echo '#define HAVE_STRLCPY'; \
625 .1.1.txt .3.3.txt .7.7.txt .8.8.txt:
626 ./mandoc -Tascii -Wall,stop $< | col -b >$@
628 .1.1.html .3.3.html .7.7.html .8.8.html:
629 ./mandoc -Thtml -Wall,stop -Ostyle=style.css,man=%N.%S.html,includes=%I.html $< >$@
631 .1.1.ps .3.3.ps .7.7.ps .8.8.ps:
632 ./mandoc -Tps -Wall,stop $< >$@
634 .1.1.xhtml .3.3.xhtml .7.7.xhtml .8.8.xhtml:
635 ./mandoc -Txhtml -Wall,stop -Ostyle=style.css,man=%N.%S.xhtml,includes=%I.html $< >$@
637 .1.1.pdf .3.3.pdf .7.7.pdf .8.8.pdf:
638 ./mandoc -Tpdf -Wall,stop $< >$@
642 sed -e "s!@VERSION@!$(VERSION)!" -e "s!@VDATE@!$(VDATE)!" $< >$@