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
38 BINDIR = $(PREFIX)/bin
39 INCLUDEDIR = $(PREFIX)/include/mandoc
40 LIBDIR = $(PREFIX)/lib/mandoc
41 MANDIR = $(PREFIX)/man
42 EXAMPLEDIR = $(PREFIX)/share/examples/mandoc
44 INSTALL_PROGRAM = $(INSTALL) -m 0755
45 INSTALL_DATA = $(INSTALL) -m 0444
46 INSTALL_LIB = $(INSTALL) -m 0644
47 INSTALL_SOURCE = $(INSTALL) -m 0644
48 INSTALL_MAN = $(INSTALL_DATA)
50 # Non-BSD systems (Linux, etc.) need -ldb to compile mandocdb and
52 # However, if you don't have -ldb at all (or it's not native), then
53 # comment out apropos and mandocdb.
56 DBBIN = apropos mandocdb man.cgi catman whatis
57 DBLN = llib-lapropos.ln llib-lmandocdb.ln llib-lman.cgi.ln llib-lcatman.ln
59 all: mandoc preconv demandoc $(DBBIN)
159 LIBMAN_OBJS = man.o \
163 LIBMAN_LNS = man.ln \
168 LIBMDOC_OBJS = arch.o \
178 LIBMDOC_LNS = arch.ln \
189 LIBROFF_OBJS = eqn.o \
195 LIBROFF_LNS = eqn.ln \
202 LIBMANDOC_OBJS = $(LIBMAN_OBJS) \
209 LIBMANDOC_LNS = $(LIBMAN_LNS) \
217 COMPAT_OBJS = compat_getsubopt.o \
220 COMPAT_LNS = compat_getsubopt.ln \
224 arch.o arch.ln: arch.in
226 chars.o chars.ln: chars.in
228 msec.o msec.ln: msec.in
229 roff.o roff.ln: predefs.in
233 $(LIBMAN_OBJS) $(LIBMAN_LNS): libman.h
234 $(LIBMDOC_OBJS) $(LIBMDOC_LNS): libmdoc.h
235 $(LIBROFF_OBJS) $(LIBROFF_LNS): libroff.h
236 $(LIBMANDOC_OBJS) $(LIBMANDOC_LNS): mandoc.h mdoc.h man.h libmandoc.h config.h
238 $(COMPAT_OBJS) $(COMPAT_LNS): config.h
240 MANDOC_HTML_OBJS = eqn_html.o \
245 MANDOC_HTML_LNS = eqn_html.ln \
251 MANDOC_MAN_OBJS = mdoc_man.o
252 MANDOC_MAN_LNS = mdoc_man.ln
254 MANDOC_TERM_OBJS = eqn_term.o \
261 MANDOC_TERM_LNS = eqn_term.ln \
269 MANDOC_OBJS = $(MANDOC_HTML_OBJS) \
271 $(MANDOC_TERM_OBJS) \
275 MANDOC_LNS = $(MANDOC_HTML_LNS) \
282 $(MANDOC_HTML_OBJS) $(MANDOC_HTML_LNS): html.h
283 $(MANDOC_TERM_OBJS) $(MANDOC_TERM_LNS): term.h
284 $(MANDOC_OBJS) $(MANDOC_LNS): main.h mandoc.h mdoc.h man.h config.h out.h
286 MANDOCDB_OBJS = mandocdb.o manpath.o
287 MANDOCDB_LNS = mandocdb.ln manpath.ln
289 $(MANDOCDB_OBJS) $(MANDOCDB_LNS): mandocdb.h mandoc.h mdoc.h man.h config.h manpath.h
291 PRECONV_OBJS = preconv.o
292 PRECONV_LNS = preconv.ln
294 $(PRECONV_OBJS) $(PRECONV_LNS): config.h
296 APROPOS_OBJS = apropos.o apropos_db.o manpath.o
297 APROPOS_LNS = apropos.ln apropos_db.ln manpath.ln
299 $(APROPOS_OBJS) $(APROPOS_LNS): config.h mandoc.h apropos_db.h manpath.h mandocdb.h
301 CGI_OBJS = $(MANDOC_HTML_OBJS) \
303 $(MANDOC_TERM_OBJS) \
310 CGI_LNS = $(MANDOC_HTML_LNS) \
319 $(CGI_OBJS) $(CGI_LNS): main.h mdoc.h man.h out.h config.h mandoc.h apropos_db.h manpath.h mandocdb.h
321 CATMAN_OBJS = catman.o manpath.o
322 CATMAN_LNS = catman.ln manpath.ln
324 $(CATMAN_OBJS) $(CATMAN_LNS): config.h mandoc.h manpath.h
326 DEMANDOC_OBJS = demandoc.o
327 DEMANDOC_LNS = demandoc.ln
329 $(DEMANDOC_OBJS) $(DEMANDOC_LNS): config.h
331 INDEX_MANS = apropos.1.html \
362 mandoc_char.7.xhtml \
392 $(INDEX_MANS): mandoc
394 INDEX_OBJS = $(INDEX_MANS) \
403 lint: llib-lmandoc.ln llib-lpreconv.ln llib-ldemandoc.ln $(DBLN)
406 rm -f libmandoc.a $(LIBMANDOC_OBJS)
407 rm -f llib-llibmandoc.ln $(LIBMANDOC_LNS)
408 rm -f mandocdb $(MANDOCDB_OBJS)
409 rm -f llib-lmandocdb.ln $(MANDOCDB_LNS)
410 rm -f preconv $(PRECONV_OBJS)
411 rm -f llib-lpreconv.ln $(PRECONV_LNS)
412 rm -f apropos $(APROPOS_OBJS)
413 rm -f llib-lapropos.ln $(APROPOS_LNS)
414 rm -f man.cgi $(CGI_OBJS)
415 rm -f llib-lman.cgi.ln $(CGI_LNS)
416 rm -f catman $(CATMAN_OBJS)
417 rm -f llib-lcatman.ln $(CATMAN_LNS)
418 rm -f demandoc $(DEMANDOC_OBJS)
419 rm -f llib-ldemandoc.ln $(DEMANDOC_LNS)
420 rm -f mandoc $(MANDOC_OBJS)
421 rm -f llib-lmandoc.ln $(MANDOC_LNS)
422 rm -f config.h config.log $(COMPAT_OBJS) $(COMPAT_LNS)
423 rm -f mdocml.tar.gz mdocml-win32.zip mdocml-win64.zip mdocml-macosx.zip
424 rm -f index.html $(INDEX_OBJS)
425 rm -rf test-strlcpy.DSYM
426 rm -rf test-strlcat.DSYM
427 rm -rf test-strptime.DSYM
428 rm -rf test-mmap.DSYM
429 rm -rf test-getsubopt.DSYM
432 mkdir -p $(DESTDIR)$(BINDIR)
433 mkdir -p $(DESTDIR)$(EXAMPLEDIR)
434 mkdir -p $(DESTDIR)$(LIBDIR)
435 mkdir -p $(DESTDIR)$(INCLUDEDIR)
436 mkdir -p $(DESTDIR)$(MANDIR)/man1
437 mkdir -p $(DESTDIR)$(MANDIR)/man3
438 mkdir -p $(DESTDIR)$(MANDIR)/man7
439 mkdir -p $(DESTDIR)$(MANDIR)/man8
440 $(INSTALL_PROGRAM) mandoc preconv demandoc $(DESTDIR)$(BINDIR)
441 $(INSTALL_LIB) libmandoc.a $(DESTDIR)$(LIBDIR)
442 $(INSTALL_LIB) man.h mdoc.h mandoc.h $(DESTDIR)$(INCLUDEDIR)
443 $(INSTALL_MAN) mandoc.1 preconv.1 demandoc.1 $(DESTDIR)$(MANDIR)/man1
444 $(INSTALL_MAN) mandoc.3 $(DESTDIR)$(MANDIR)/man3
445 $(INSTALL_MAN) man.7 mdoc.7 roff.7 eqn.7 tbl.7 mandoc_char.7 $(DESTDIR)$(MANDIR)/man7
446 $(INSTALL_DATA) example.style.css $(DESTDIR)$(EXAMPLEDIR)
449 mkdir -p $(PREFIX)/snapshots
450 mkdir -p $(PREFIX)/binaries
451 $(INSTALL_DATA) index.html external.png index.css $(PREFIX)
452 $(INSTALL_DATA) $(INDEX_MANS) style.css $(PREFIX)
453 $(INSTALL_DATA) mandoc.h.html man.h.html mdoc.h.html $(PREFIX)
454 $(INSTALL_DATA) mdocml.tar.gz $(PREFIX)/snapshots
455 $(INSTALL_DATA) mdocml.md5 $(PREFIX)/snapshots
456 $(INSTALL_DATA) mdocml.tar.gz $(PREFIX)/snapshots/mdocml-$(VERSION).tar.gz
457 $(INSTALL_DATA) mdocml.md5 $(PREFIX)/snapshots/mdocml-$(VERSION).md5
459 libmandoc.a: $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
460 $(AR) rs $@ $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
462 llib-llibmandoc.ln: $(COMPAT_LNS) $(LIBMANDOC_LNS)
463 $(LINT) $(LINTFLAGS) -Clibmandoc $(COMPAT_LNS) $(LIBMANDOC_LNS)
465 mandoc: $(MANDOC_OBJS) libmandoc.a
466 $(CC) $(LDFLAGS) -o $@ $(MANDOC_OBJS) libmandoc.a
468 llib-lmandoc.ln: $(MANDOC_LNS) llib-llibmandoc.ln
469 $(LINT) $(LINTFLAGS) -Cmandoc $(MANDOC_LNS) llib-llibmandoc.ln
471 mandocdb: $(MANDOCDB_OBJS) libmandoc.a
472 $(CC) $(LDFLAGS) -o $@ $(MANDOCDB_OBJS) libmandoc.a $(DBLIB)
474 llib-lmandocdb.ln: $(MANDOCDB_LNS) llib-llibmandoc.ln
475 $(LINT) $(LINTFLAGS) -Cmandocdb $(MANDOCDB_LNS) llib-llibmandoc.ln
477 preconv: $(PRECONV_OBJS)
478 $(CC) $(LDFLAGS) -o $@ $(PRECONV_OBJS)
480 llib-lpreconv.ln: $(PRECONV_LNS) llib-llibmandoc.ln
481 $(LINT) $(LINTFLAGS) -Cpreconv $(PRECONV_LNS) llib-llibmandoc.ln
486 apropos: $(APROPOS_OBJS) libmandoc.a
487 $(CC) $(LDFLAGS) -o $@ $(APROPOS_OBJS) libmandoc.a $(DBLIB)
489 llib-lapropos.ln: $(APROPOS_LNS) llib-llibmandoc.ln
490 $(LINT) $(LINTFLAGS) -Capropos $(APROPOS_LNS) llib-llibmandoc.ln
492 catman: $(CATMAN_OBJS) libmandoc.a
493 $(CC) $(LDFLAGS) -o $@ $(CATMAN_OBJS) libmandoc.a $(DBLIB)
495 llib-lcatman.ln: $(CATMAN_LNS) llib-llibmandoc.ln
496 $(LINT) $(LINTFLAGS) -Ccatman $(CATMAN_LNS) llib-llibmandoc.ln
498 man.cgi: $(CGI_OBJS) libmandoc.a
499 $(CC) $(LDFLAGS) $(STATIC) -o $@ $(CGI_OBJS) libmandoc.a $(DBLIB)
501 llib-lman.cgi.ln: $(CGI_LNS) llib-llibmandoc.ln
502 $(LINT) $(LINTFLAGS) -Cman.cgi $(CGI_LNS) llib-llibmandoc.ln
504 demandoc: $(DEMANDOC_OBJS) libmandoc.a
505 $(CC) $(LDFLAGS) -o $@ $(DEMANDOC_OBJS) libmandoc.a
507 llib-ldemandoc.ln: $(DEMANDOC_LNS) llib-llibmandoc.ln
508 $(LINT) $(LINTFLAGS) -Cdemandoc $(DEMANDOC_LNS) llib-llibmandoc.ln
510 mdocml.md5: mdocml.tar.gz
511 md5 mdocml.tar.gz >$@
513 mdocml.tar.gz: $(SRCS)
514 mkdir -p .dist/mdocml-$(VERSION)/
515 $(INSTALL_SOURCE) $(SRCS) .dist/mdocml-$(VERSION)
516 ( cd .dist/ && tar zcf ../$@ ./ )
519 mdocml-win32.zip: $(SRCS)
520 mkdir -p .win32/mdocml-$(VERSION)/
521 $(INSTALL_SOURCE) $(SRCS) .win32
522 cp .win32/Makefile .win32/Makefile.old
523 egrep -v -e DUSE_WCHAR -e ^DBBIN .win32/Makefile.old >.win32/Makefile
525 CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar CFLAGS='-DOSNAME=\"Windows\"' make; \
526 make install PREFIX=mdocml-$(VERSION) ; \
527 zip -r ../$@ mdocml-$(VERSION) )
530 mdocml-win64.zip: $(SRCS)
531 mkdir -p .win64/mdocml-$(VERSION)/
532 $(INSTALL_SOURCE) $(SRCS) .win64
533 cp .win64/Makefile .win64/Makefile.old
534 egrep -v -e DUSE_WCHAR -e ^DBBIN .win64/Makefile.old >.win64/Makefile
536 CC=x86_64-w64-mingw32-gcc AR=x86_64-w64-mingw32-ar CFLAGS='-DOSNAME=\"Windows\"' make; \
537 make install PREFIX=mdocml-$(VERSION) ; \
538 zip -r ../$@ mdocml-$(VERSION) )
541 mdocml-macosx.zip: $(SRCS)
542 mkdir -p .macosx/mdocml-$(VERSION)/
543 $(INSTALL_SOURCE) $(SRCS) .macosx
545 CFLAGS="-arch i386 -arch x86_64 -arch ppc" LDFLAGS="-arch i386 -arch x86_64 -arch ppc" make; \
546 make install PREFIX=mdocml-$(VERSION) ; \
547 zip -r ../$@ mdocml-$(VERSION) )
550 index.html: $(INDEX_OBJS)
552 config.h: config.h.pre config.h.post
554 ( cat config.h.pre; \
556 if $(CC) $(CFLAGS) -Werror -o test-strptime test-strptime.c >> config.log 2>&1; then \
557 echo '#define HAVE_STRPTIME'; \
560 if $(CC) $(CFLAGS) -Werror -o test-getsubopt test-getsubopt.c >> config.log 2>&1; then \
561 echo '#define HAVE_GETSUBOPT'; \
564 if $(CC) $(CFLAGS) -Werror -o test-strlcat test-strlcat.c >> config.log 2>&1; then \
565 echo '#define HAVE_STRLCAT'; \
568 if $(CC) $(CFLAGS) -Werror -o test-mmap test-mmap.c >> config.log 2>&1; then \
569 echo '#define HAVE_MMAP'; \
572 if $(CC) $(CFLAGS) -Werror -o test-strlcpy test-strlcpy.c >> config.log 2>&1; then \
573 echo '#define HAVE_STRLCPY'; \
583 .1.1.txt .3.3.txt .7.7.txt .8.8.txt:
584 ./mandoc -Tascii -Wall,stop $< | col -b >$@
586 .1.1.html .3.3.html .7.7.html .8.8.html:
587 ./mandoc -Thtml -Wall,stop -Ostyle=style.css,man=%N.%S.html,includes=%I.html $< >$@
589 .1.1.ps .3.3.ps .7.7.ps .8.8.ps:
590 ./mandoc -Tps -Wall,stop $< >$@
592 .1.1.xhtml .3.3.xhtml .7.7.xhtml .8.8.xhtml:
593 ./mandoc -Txhtml -Wall,stop -Ostyle=style.css,man=%N.%S.xhtml,includes=%I.html $< >$@
595 .1.1.pdf .3.3.pdf .7.7.pdf .8.8.pdf:
596 ./mandoc -Tpdf -Wall,stop $< >$@
600 sed -e "s!@VERSION@!$(VERSION)!" -e "s!@VDATE@!$(VDATE)!" $< >$@