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
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 mkdir -p $(DESTDIR)$(MANDIR)/man8
472 $(INSTALL_PROGRAM) mandoc preconv demandoc $(DESTDIR)$(BINDIR)
473 $(INSTALL_LIB) libmandoc.a $(DESTDIR)$(LIBDIR)
474 $(INSTALL_LIB) man.h mdoc.h mandoc.h $(DESTDIR)$(INCLUDEDIR)
475 $(INSTALL_MAN) mandoc.1 preconv.1 demandoc.1 $(DESTDIR)$(MANDIR)/man1
476 $(INSTALL_MAN) mandoc.3 $(DESTDIR)$(MANDIR)/man3
477 $(INSTALL_MAN) man.7 mdoc.7 roff.7 eqn.7 tbl.7 mandoc_char.7 $(DESTDIR)$(MANDIR)/man7
478 $(INSTALL_DATA) example.style.css $(DESTDIR)$(EXAMPLEDIR)
481 mkdir -p $(DESTDIR)$(CGIBINDIR)
482 mkdir -p $(DESTDIR)$(HTDOCDIR)
483 $(INSTALL_PROGRAM) man.cgi $(DESTDIR)$(CGIBINDIR)
484 $(INSTALL_DATA) example.style.css $(DESTDIR)$(HTDOCDIR)/man.css
485 $(INSTALL_DATA) man-cgi.css $(DESTDIR)$(HTDOCDIR)
488 mkdir -p $(PREFIX)/snapshots
489 mkdir -p $(PREFIX)/binaries
490 $(INSTALL_DATA) index.html external.png index.css $(PREFIX)
491 $(INSTALL_DATA) $(INDEX_MANS) style.css $(PREFIX)
492 $(INSTALL_DATA) mandoc.h.html man.h.html mdoc.h.html $(PREFIX)
493 $(INSTALL_DATA) mdocml.tar.gz $(PREFIX)/snapshots
494 $(INSTALL_DATA) mdocml.md5 $(PREFIX)/snapshots
495 $(INSTALL_DATA) mdocml.tar.gz $(PREFIX)/snapshots/mdocml-$(VERSION).tar.gz
496 $(INSTALL_DATA) mdocml.md5 $(PREFIX)/snapshots/mdocml-$(VERSION).md5
498 libmandoc.a: $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
499 $(AR) rs $@ $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
501 llib-llibmandoc.ln: $(COMPAT_LNS) $(LIBMANDOC_LNS)
502 $(LINT) $(LINTFLAGS) -Clibmandoc $(COMPAT_LNS) $(LIBMANDOC_LNS)
504 mandoc: $(MANDOC_OBJS) libmandoc.a
505 $(CC) $(LDFLAGS) -o $@ $(MANDOC_OBJS) libmandoc.a
507 llib-lmandoc.ln: $(MANDOC_LNS) llib-llibmandoc.ln
508 $(LINT) $(LINTFLAGS) -Cmandoc $(MANDOC_LNS) llib-llibmandoc.ln
510 mandocdb: $(MANDOCDB_OBJS) libmandoc.a
511 $(CC) $(LDFLAGS) -o $@ $(MANDOCDB_OBJS) libmandoc.a $(DBLIB)
513 llib-lmandocdb.ln: $(MANDOCDB_LNS) llib-llibmandoc.ln
514 $(LINT) $(LINTFLAGS) -Cmandocdb $(MANDOCDB_LNS) llib-llibmandoc.ln
516 preconv: $(PRECONV_OBJS)
517 $(CC) $(LDFLAGS) -o $@ $(PRECONV_OBJS)
519 llib-lpreconv.ln: $(PRECONV_LNS) llib-llibmandoc.ln
520 $(LINT) $(LINTFLAGS) -Cpreconv $(PRECONV_LNS) llib-llibmandoc.ln
525 apropos: $(APROPOS_OBJS) libmandoc.a
526 $(CC) $(LDFLAGS) -o $@ $(APROPOS_OBJS) libmandoc.a $(DBLIB)
528 llib-lapropos.ln: $(APROPOS_LNS) llib-llibmandoc.ln
529 $(LINT) $(LINTFLAGS) -Capropos $(APROPOS_LNS) llib-llibmandoc.ln
531 catman: $(CATMAN_OBJS) libmandoc.a
532 $(CC) $(LDFLAGS) -o $@ $(CATMAN_OBJS) libmandoc.a $(DBLIB)
534 llib-lcatman.ln: $(CATMAN_LNS) llib-llibmandoc.ln
535 $(LINT) $(LINTFLAGS) -Ccatman $(CATMAN_LNS) llib-llibmandoc.ln
537 man.cgi: $(CGI_OBJS) libmandoc.a
538 $(CC) $(LDFLAGS) $(STATIC) -o $@ $(CGI_OBJS) libmandoc.a $(DBLIB)
540 llib-lman.cgi.ln: $(CGI_LNS) llib-llibmandoc.ln
541 $(LINT) $(LINTFLAGS) -Cman.cgi $(CGI_LNS) llib-llibmandoc.ln
543 demandoc: $(DEMANDOC_OBJS) libmandoc.a
544 $(CC) $(LDFLAGS) -o $@ $(DEMANDOC_OBJS) libmandoc.a
546 llib-ldemandoc.ln: $(DEMANDOC_LNS) llib-llibmandoc.ln
547 $(LINT) $(LINTFLAGS) -Cdemandoc $(DEMANDOC_LNS) llib-llibmandoc.ln
549 mdocml.md5: mdocml.tar.gz
550 md5 mdocml.tar.gz >$@
552 mdocml.tar.gz: $(SRCS)
553 mkdir -p .dist/mdocml-$(VERSION)/
554 $(INSTALL_SOURCE) $(SRCS) .dist/mdocml-$(VERSION)
555 ( cd .dist/ && tar zcf ../$@ ./ )
558 mdocml-win32.zip: $(SRCS)
559 mkdir -p .win32/mdocml-$(VERSION)/
560 $(INSTALL_SOURCE) $(SRCS) .win32
561 cp .win32/Makefile .win32/Makefile.old
562 egrep -v -e DUSE_WCHAR -e ^DBBIN .win32/Makefile.old >.win32/Makefile
564 CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar CFLAGS='-DOSNAME=\"Windows\"' make; \
565 make install PREFIX=mdocml-$(VERSION) ; \
566 zip -r ../$@ mdocml-$(VERSION) )
569 mdocml-win64.zip: $(SRCS)
570 mkdir -p .win64/mdocml-$(VERSION)/
571 $(INSTALL_SOURCE) $(SRCS) .win64
572 cp .win64/Makefile .win64/Makefile.old
573 egrep -v -e DUSE_WCHAR -e ^DBBIN .win64/Makefile.old >.win64/Makefile
575 CC=x86_64-w64-mingw32-gcc AR=x86_64-w64-mingw32-ar CFLAGS='-DOSNAME=\"Windows\"' make; \
576 make install PREFIX=mdocml-$(VERSION) ; \
577 zip -r ../$@ mdocml-$(VERSION) )
580 mdocml-macosx.zip: $(SRCS)
581 mkdir -p .macosx/mdocml-$(VERSION)/
582 $(INSTALL_SOURCE) $(SRCS) .macosx
584 CFLAGS="-arch i386 -arch x86_64 -arch ppc" LDFLAGS="-arch i386 -arch x86_64 -arch ppc" make; \
585 make install PREFIX=mdocml-$(VERSION) ; \
586 zip -r ../$@ mdocml-$(VERSION) )
589 index.html: $(INDEX_OBJS)
591 config.h: config.h.pre config.h.post
593 ( cat config.h.pre; \
595 if $(CC) $(CFLAGS) -Werror -o test-fgetln test-fgetln.c >> config.log 2>&1; then \
596 echo '#define HAVE_FGETLN'; \
599 if $(CC) $(CFLAGS) -Werror -o test-strptime test-strptime.c >> config.log 2>&1; then \
600 echo '#define HAVE_STRPTIME'; \
603 if $(CC) $(CFLAGS) -Werror -o test-getsubopt test-getsubopt.c >> config.log 2>&1; then \
604 echo '#define HAVE_GETSUBOPT'; \
607 if $(CC) $(CFLAGS) -Werror -o test-strlcat test-strlcat.c >> config.log 2>&1; then \
608 echo '#define HAVE_STRLCAT'; \
611 if $(CC) $(CFLAGS) -Werror -o test-mmap test-mmap.c >> config.log 2>&1; then \
612 echo '#define HAVE_MMAP'; \
615 if $(CC) $(CFLAGS) -Werror -o test-strlcpy test-strlcpy.c >> config.log 2>&1; then \
616 echo '#define HAVE_STRLCPY'; \
626 .1.1.txt .3.3.txt .7.7.txt .8.8.txt:
627 ./mandoc -Tascii -Wall,stop $< | col -b >$@
629 .1.1.html .3.3.html .7.7.html .8.8.html:
630 ./mandoc -Thtml -Wall,stop -Ostyle=style.css,man=%N.%S.html,includes=%I.html $< >$@
632 .1.1.ps .3.3.ps .7.7.ps .8.8.ps:
633 ./mandoc -Tps -Wall,stop $< >$@
635 .1.1.xhtml .3.3.xhtml .7.7.xhtml .8.8.xhtml:
636 ./mandoc -Txhtml -Wall,stop -Ostyle=style.css,man=%N.%S.xhtml,includes=%I.html $< >$@
638 .1.1.pdf .3.3.pdf .7.7.pdf .8.8.pdf:
639 ./mandoc -Tpdf -Wall,stop $< >$@
643 sed -e "s!@VERSION@!$(VERSION)!" -e "s!@VDATE@!$(VDATE)!" $< >$@