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 CFLAGS += -g -DHAVE_CONFIG_H -DVERSION="\"$(VERSION)\""
27 CFLAGS += -W -Wall -Wstrict-prototypes -Wno-unused-parameter -Wwrite-strings
29 BINDIR = $(PREFIX)/bin
30 INCLUDEDIR = $(PREFIX)/include/mandoc
31 LIBDIR = $(PREFIX)/lib/mandoc
32 MANDIR = $(PREFIX)/man
33 EXAMPLEDIR = $(PREFIX)/share/examples/mandoc
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)
41 # Non-BSD systems (Linux, etc.) need -ldb to compile mandocdb and
43 # However, if you don't have -ldb at all (or it's not native), then
44 # comment out apropos and mandocdb.
47 DBBIN = apropos mandocdb man.cgi
48 DBLN = llib-lapropos.ln llib-lmandocdb.ln llib-lman.cgi.ln
50 all: mandoc preconv demandoc $(DBBIN)
144 LIBMAN_OBJS = man.o \
148 LIBMAN_LNS = man.ln \
153 LIBMDOC_OBJS = arch.o \
164 LIBMDOC_LNS = arch.ln \
176 LIBROFF_OBJS = eqn.o \
182 LIBROFF_LNS = eqn.ln \
189 LIBMANDOC_OBJS = $(LIBMAN_OBJS) \
195 LIBMANDOC_LNS = $(LIBMAN_LNS) \
202 COMPAT_OBJS = compat_getsubopt.o \
205 COMPAT_LNS = compat_getsubopt.ln \
209 arch.o arch.ln: arch.in
211 chars.o chars.ln: chars.in
213 msec.o msec.ln: msec.in
214 roff.o roff.ln: predefs.in
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
223 $(COMPAT_OBJS) $(COMPAT_LNS): config.h
225 MANDOC_HTML_OBJS = eqn_html.o \
230 MANDOC_HTML_LNS = eqn_html.ln \
236 MANDOC_MAN_OBJS = mdoc_man.o
237 MANDOC_MAN_LNS = mdoc_man.ln
239 MANDOC_TERM_OBJS = eqn_term.o \
246 MANDOC_TERM_LNS = eqn_term.ln \
254 MANDOC_OBJS = $(MANDOC_HTML_OBJS) \
256 $(MANDOC_TERM_OBJS) \
260 MANDOC_LNS = $(MANDOC_HTML_LNS) \
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
271 MANDOCDB_OBJS = mandocdb.o
272 MANDOCDB_LNS = mandocdb.ln
274 $(MANDOCDB_OBJS) $(MANDOCDB_LNS): mandoc.h mdoc.h man.h config.h
276 PRECONV_OBJS = preconv.o
277 PRECONV_LNS = preconv.ln
279 $(PRECONV_OBJS) $(PRECONV_LNS): config.h
281 APROPOS_OBJS = apropos.o db.o
282 APROPOS_LNS = apropos.ln db.ln
284 $(APROPOS_OBJS) $(APROPOS_LNS): config.h mandoc.h apropos.h
286 CGI_OBJS = cgi.o db.o
287 CGI_LNS = cgi.ln db.ln
289 $(CGI_OBJS) $(CGI_LNS): config.h mandoc.h apropos.h
291 DEMANDOC_OBJS = demandoc.o
292 DEMANDOC_LNS = demandoc.ln
294 $(DEMANDOC_OBJS) $(DEMANDOC_LNS): config.h
296 INDEX_MANS = apropos.1.html \
327 mandoc_char.7.xhtml \
357 $(INDEX_MANS): mandoc
359 INDEX_OBJS = $(INDEX_MANS) \
368 lint: llib-lmandoc.ln llib-lpreconv.ln llib-ldemandoc.ln $(DBLN)
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
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)
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
422 libmandoc.a: $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
423 $(AR) rs $@ $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
425 llib-llibmandoc.ln: $(COMPAT_LNS) $(LIBMANDOC_LNS)
426 $(LINT) $(LINTFLAGS) -Clibmandoc $(COMPAT_LNS) $(LIBMANDOC_LNS)
428 mandoc: $(MANDOC_OBJS) libmandoc.a
429 $(CC) $(LDFLAGS) -o $@ $(MANDOC_OBJS) libmandoc.a
431 llib-lmandoc.ln: $(MANDOC_LNS) llib-llibmandoc.ln
432 $(LINT) $(LINTFLAGS) -Cmandoc $(MANDOC_LNS) llib-llibmandoc.ln
434 mandocdb: $(MANDOCDB_OBJS) libmandoc.a
435 $(CC) $(LDFLAGS) -o $@ $(MANDOCDB_OBJS) libmandoc.a $(DBLIB)
437 llib-lmandocdb.ln: $(MANDOCDB_LNS) llib-llibmandoc.ln
438 $(LINT) $(LINTFLAGS) -Cmandocdb $(MANDOCDB_LNS) llib-llibmandoc.ln
440 preconv: $(PRECONV_OBJS)
441 $(CC) $(LDFLAGS) -o $@ $(PRECONV_OBJS)
443 llib-lpreconv.ln: $(PRECONV_LNS) llib-llibmandoc.ln
444 $(LINT) $(LINTFLAGS) -Cpreconv $(PRECONV_LNS) llib-llibmandoc.ln
446 apropos: $(APROPOS_OBJS) libmandoc.a
447 $(CC) $(LDFLAGS) -o $@ $(APROPOS_OBJS) libmandoc.a $(DBLIB)
449 llib-lapropos.ln: $(APROPOS_LNS) llib-llibmandoc.ln
450 $(LINT) $(LINTFLAGS) -Capropos $(APROPOS_LNS) llib-llibmandoc.ln
452 man.cgi: $(CGI_OBJS) libmandoc.a
453 $(CC) $(LDFLAGS) -o $@ $(CGI_OBJS) libmandoc.a $(DBLIB)
455 llib-lman.cgi.ln: $(CGI_LNS) llib-llibmandoc.ln
456 $(LINT) $(LINTFLAGS) -Cman.cgi $(CGI_LNS) llib-llibmandoc.ln
458 demandoc: $(DEMANDOC_OBJS) libmandoc.a
459 $(CC) $(LDFLAGS) -o $@ $(DEMANDOC_OBJS) libmandoc.a
461 llib-ldemandoc.ln: $(DEMANDOC_LNS) llib-llibmandoc.ln
462 $(LINT) $(LINTFLAGS) -Cdemandoc $(DEMANDOC_LNS) llib-llibmandoc.ln
464 mdocml.md5: mdocml.tar.gz
465 md5 mdocml.tar.gz >$@
467 mdocml.tar.gz: $(SRCS)
468 mkdir -p .dist/mdocml-$(VERSION)/
469 $(INSTALL_SOURCE) $(SRCS) .dist/mdocml-$(VERSION)
470 ( cd .dist/ && tar zcf ../$@ ./ )
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
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) )
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
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) )
495 mdocml-macosx.zip: $(SRCS)
496 mkdir -p .macosx/mdocml-$(VERSION)/
497 $(INSTALL_SOURCE) $(SRCS) .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) )
504 index.html: $(INDEX_OBJS)
506 config.h: config.h.pre config.h.post
508 ( cat config.h.pre; \
510 if $(CC) $(CFLAGS) -Werror -o test-strptime test-strptime.c >> config.log 2>&1; then \
511 echo '#define HAVE_STRPTIME'; \
514 if $(CC) $(CFLAGS) -Werror -o test-getsubopt test-getsubopt.c >> config.log 2>&1; then \
515 echo '#define HAVE_GETSUBOPT'; \
518 if $(CC) $(CFLAGS) -Werror -o test-strlcat test-strlcat.c >> config.log 2>&1; then \
519 echo '#define HAVE_STRLCAT'; \
522 if $(CC) $(CFLAGS) -Werror -o test-mmap test-mmap.c >> config.log 2>&1; then \
523 echo '#define HAVE_MMAP'; \
526 if $(CC) $(CFLAGS) -Werror -o test-strlcpy test-strlcpy.c >> config.log 2>&1; then \
527 echo '#define HAVE_STRLCPY'; \
537 .1.1.txt .3.3.txt .7.7.txt .8.8.txt:
538 ./mandoc -Tascii -Wall,stop $< | col -b >$@
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 $< >$@
543 .1.1.ps .3.3.ps .7.7.ps .8.8.ps:
544 ./mandoc -Tps -Wall,stop $< >$@
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 $< >$@
549 .1.1.pdf .3.3.pdf .7.7.pdf .8.8.pdf:
550 ./mandoc -Tpdf -Wall,stop $< >$@
554 sed -e "s!@VERSION@!$(VERSION)!" -e "s!@VDATE@!$(VDATE)!" $< >$@