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\""
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, manpage(1) and
28 # mandocdb(8) will use manpath(1) to get the MANPATH variable.
29 #CFLAGS += -DUSE_MANPATH
31 # If your system supports static binaries only, uncomment this. This
32 # appears only to be BSD UNIX systems (Mac OS X has no support and Linux
33 # requires -pthreads for static libdb).
36 CFLAGS += -I/usr/local/include -g -DHAVE_CONFIG_H -DVERSION="\"$(VERSION)\""
37 CFLAGS += -W -Wall -Wstrict-prototypes -Wno-unused-parameter -Wwrite-strings
40 HTDOCDIR = $(WWWPREFIX)/htdocs
41 CGIBINDIR = $(WWWPREFIX)/cgi-bin
42 BINDIR = $(PREFIX)/bin
43 INCLUDEDIR = $(PREFIX)/include/mandoc
44 LIBDIR = $(PREFIX)/lib/mandoc
45 MANDIR = $(PREFIX)/man
46 EXAMPLEDIR = $(PREFIX)/share/examples/mandoc
48 INSTALL_PROGRAM = $(INSTALL) -m 0755
49 INSTALL_DATA = $(INSTALL) -m 0444
50 INSTALL_LIB = $(INSTALL) -m 0644
51 INSTALL_SOURCE = $(INSTALL) -m 0644
52 INSTALL_MAN = $(INSTALL_DATA)
54 DBLIB = -L/usr/local/lib -lsqlite3
55 DBBIN = mandocdb manpage apropos
57 all: mandoc preconv demandoc $(DBBIN)
157 LIBMAN_OBJS = man.o \
162 LIBMDOC_OBJS = arch.o \
173 LIBROFF_OBJS = eqn.o \
180 LIBMANDOC_OBJS = $(LIBMAN_OBJS) \
188 COMPAT_OBJS = compat_fgetln.o \
203 $(LIBMAN_OBJS): libman.h
204 $(LIBMDOC_OBJS): libmdoc.h
205 $(LIBROFF_OBJS): libroff.h
206 $(LIBMANDOC_OBJS): mandoc.h mdoc.h man.h libmandoc.h config.h
207 $(COMPAT_OBJS): config.h compat_ohash.h
209 MANDOC_HTML_OBJS = eqn_html.o \
214 $(MANDOC_HTML_OBJS): html.h
216 MANDOC_MAN_OBJS = mdoc_man.o
218 MANDOC_TERM_OBJS = eqn_term.o \
225 $(MANDOC_TERM_OBJS): term.h
227 MANDOC_OBJS = $(MANDOC_HTML_OBJS) \
229 $(MANDOC_TERM_OBJS) \
233 $(MANDOC_OBJS): main.h mandoc.h mdoc.h man.h config.h out.h
235 MANDOCDB_OBJS = mandocdb.o manpath.o
236 $(MANDOCDB_OBJS): mansearch.h mandoc.h mdoc.h man.h config.h manpath.h
238 PRECONV_OBJS = preconv.o
239 $(PRECONV_OBJS): config.h
241 APROPOS_OBJS = apropos.o mansearch.o manpath.o
242 $(APROPOS_OBJS): config.h manpath.h mansearch.h
244 MANPAGE_OBJS = manpage.o mansearch.o manpath.o
245 $(MANPAGE_OBJS): config.h manpath.h mansearch.h
247 DEMANDOC_OBJS = demandoc.o
248 $(DEMANDOC_OBJS): config.h
250 INDEX_MANS = demandoc.1.html \
276 mandoc_char.7.xhtml \
306 $(INDEX_MANS): mandoc
308 INDEX_OBJS = $(INDEX_MANS) \
318 rm -f libmandoc.a $(LIBMANDOC_OBJS)
319 rm -f apropos $(APROPOS_OBJS)
320 rm -f mandocdb $(MANDOCDB_OBJS)
321 rm -f preconv $(PRECONV_OBJS)
322 rm -f manpage $(MANPAGE_OBJS)
323 rm -f demandoc $(DEMANDOC_OBJS)
324 rm -f mandoc $(MANDOC_OBJS)
325 rm -f config.h config.log $(COMPAT_OBJS)
327 rm -f index.html $(INDEX_OBJS)
331 mkdir -p $(DESTDIR)$(BINDIR)
332 mkdir -p $(DESTDIR)$(EXAMPLEDIR)
333 mkdir -p $(DESTDIR)$(LIBDIR)
334 mkdir -p $(DESTDIR)$(INCLUDEDIR)
335 mkdir -p $(DESTDIR)$(MANDIR)/man1
336 mkdir -p $(DESTDIR)$(MANDIR)/man3
337 mkdir -p $(DESTDIR)$(MANDIR)/man7
338 $(INSTALL_PROGRAM) mandoc preconv demandoc $(DESTDIR)$(BINDIR)
339 $(INSTALL_LIB) libmandoc.a $(DESTDIR)$(LIBDIR)
340 $(INSTALL_LIB) man.h mdoc.h mandoc.h $(DESTDIR)$(INCLUDEDIR)
341 $(INSTALL_MAN) mandoc.1 preconv.1 demandoc.1 $(DESTDIR)$(MANDIR)/man1
342 $(INSTALL_MAN) mandoc.3 $(DESTDIR)$(MANDIR)/man3
343 $(INSTALL_MAN) man.7 mdoc.7 roff.7 eqn.7 tbl.7 mandoc_char.7 $(DESTDIR)$(MANDIR)/man7
344 $(INSTALL_DATA) example.style.css $(DESTDIR)$(EXAMPLEDIR)
347 mkdir -p $(DESTDIR)$(CGIBINDIR)
348 mkdir -p $(DESTDIR)$(HTDOCDIR)
349 #$(INSTALL_PROGRAM) man.cgi $(DESTDIR)$(CGIBINDIR)
350 $(INSTALL_DATA) example.style.css $(DESTDIR)$(HTDOCDIR)/man.css
351 $(INSTALL_DATA) man-cgi.css $(DESTDIR)$(HTDOCDIR)
354 mkdir -p $(PREFIX)/snapshots
355 mkdir -p $(PREFIX)/binaries
356 $(INSTALL_DATA) index.html external.png index.css $(PREFIX)
357 $(INSTALL_DATA) $(INDEX_MANS) style.css $(PREFIX)
358 $(INSTALL_DATA) mandoc.h.html man.h.html mdoc.h.html $(PREFIX)
359 $(INSTALL_DATA) mdocml.tar.gz $(PREFIX)/snapshots
360 $(INSTALL_DATA) mdocml.md5 $(PREFIX)/snapshots
361 $(INSTALL_DATA) mdocml.tar.gz $(PREFIX)/snapshots/mdocml-$(VERSION).tar.gz
362 $(INSTALL_DATA) mdocml.md5 $(PREFIX)/snapshots/mdocml-$(VERSION).md5
364 libmandoc.a: $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
365 $(AR) rs $@ $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
367 mandoc: $(MANDOC_OBJS) libmandoc.a
368 $(CC) $(LDFLAGS) -o $@ $(MANDOC_OBJS) libmandoc.a
370 mandocdb: $(MANDOCDB_OBJS) libmandoc.a
371 $(CC) $(LDFLAGS) -o $@ $(MANDOCDB_OBJS) libmandoc.a $(DBLIB)
373 preconv: $(PRECONV_OBJS)
374 $(CC) $(LDFLAGS) -o $@ $(PRECONV_OBJS)
376 manpage: $(MANPAGE_OBJS) libmandoc.a
377 $(CC) $(LDFLAGS) -o $@ $(MANPAGE_OBJS) libmandoc.a $(DBLIB)
379 apropos: $(APROPOS_OBJS) libmandoc.a
380 $(CC) $(LDFLAGS) -o $@ $(APROPOS_OBJS) libmandoc.a $(DBLIB)
382 demandoc: $(DEMANDOC_OBJS) libmandoc.a
383 $(CC) $(LDFLAGS) -o $@ $(DEMANDOC_OBJS) libmandoc.a
385 mdocml.md5: mdocml.tar.gz
386 md5 mdocml.tar.gz >$@
388 mdocml.tar.gz: $(SRCS)
389 mkdir -p .dist/mdocml-$(VERSION)/
390 $(INSTALL_SOURCE) $(SRCS) .dist/mdocml-$(VERSION)
391 ( cd .dist/ && tar zcf ../$@ ./ )
394 index.html: $(INDEX_OBJS)
396 config.h: config.h.pre config.h.post
398 ( cat config.h.pre; \
400 if $(CC) $(CFLAGS) -Werror -o test-ohash test-ohash.c >> config.log 2>&1; then \
401 echo '#define HAVE_OHASH'; \
404 if $(CC) $(CFLAGS) -Werror -o test-fgetln test-fgetln.c >> config.log 2>&1; then \
405 echo '#define HAVE_FGETLN'; \
408 if $(CC) $(CFLAGS) -Werror -o test-strptime test-strptime.c >> config.log 2>&1; then \
409 echo '#define HAVE_STRPTIME'; \
412 if $(CC) $(CFLAGS) -Werror -o test-getsubopt test-getsubopt.c >> config.log 2>&1; then \
413 echo '#define HAVE_GETSUBOPT'; \
416 if $(CC) $(CFLAGS) -Werror -o test-strlcat test-strlcat.c >> config.log 2>&1; then \
417 echo '#define HAVE_STRLCAT'; \
420 if $(CC) $(CFLAGS) -Werror -o test-mmap test-mmap.c >> config.log 2>&1; then \
421 echo '#define HAVE_MMAP'; \
424 if $(CC) $(CFLAGS) -Werror -o test-strlcpy test-strlcpy.c >> config.log 2>&1; then \
425 echo '#define HAVE_STRLCPY'; \
435 .1.1.txt .3.3.txt .7.7.txt .8.8.txt:
436 ./mandoc -Tascii -Wall,stop $< | col -b >$@
438 .1.1.html .3.3.html .7.7.html .8.8.html:
439 ./mandoc -Thtml -Wall,stop -Ostyle=style.css,man=%N.%S.html,includes=%I.html $< >$@
441 .1.1.ps .3.3.ps .7.7.ps .8.8.ps:
442 ./mandoc -Tps -Wall,stop $< >$@
444 .1.1.xhtml .3.3.xhtml .7.7.xhtml .8.8.xhtml:
445 ./mandoc -Txhtml -Wall,stop -Ostyle=style.css,man=%N.%S.xhtml,includes=%I.html $< >$@
447 .1.1.pdf .3.3.pdf .7.7.pdf .8.8.pdf:
448 ./mandoc -Tpdf -Wall,stop $< >$@
452 sed -e "s!@VERSION@!$(VERSION)!" -e "s!@VDATE@!$(VDATE)!" $< >$@