1 .PHONY: clean install installwww
2 .SUFFIXES: .sgml .html .md5 .h .h.html
4 .SUFFIXES: .1.html .3.html .7.html .8.html
6 # Specify this if you want to hard-code the operating system to appear
7 # in the lower-left hand corner of -mdoc manuals.
9 # CFLAGS += -DOSNAME="\"OpenBSD 5.4\""
12 VDATE = 4 January 2014
14 # IFF your system supports multi-byte functions (setlocale(), wcwidth(),
15 # putwchar()) AND has __STDC_ISO_10646__ (that is, wchar_t is simply a
16 # UCS-4 value) should you define USE_WCHAR. If you define it and your
17 # system DOESN'T support this, -Tlocale will produce garbage.
18 # If you don't define it, -Tlocale is a synonym for -Tacsii.
22 # If your system has manpath(1), uncomment this. This is most any
23 # system that's not OpenBSD or NetBSD. If uncommented, manpage(1) and
24 # mandocdb(8) will use manpath(1) to get the MANPATH variable.
25 #CFLAGS += -DUSE_MANPATH
27 # If your system does not support static binaries, comment this,
28 # for example on Mac OS X.
30 # Linux requires -pthread to statically link with libdb.
33 CFLAGS += -I/usr/local/include -g -DHAVE_CONFIG_H
34 CFLAGS += -W -Wall -Wstrict-prototypes -Wno-unused-parameter -Wwrite-strings
37 HTDOCDIR = $(WWWPREFIX)/htdocs
38 CGIBINDIR = $(WWWPREFIX)/cgi-bin
39 BINDIR = $(PREFIX)/bin
40 INCLUDEDIR = $(PREFIX)/include/mandoc
41 LIBDIR = $(PREFIX)/lib/mandoc
42 MANDIR = $(PREFIX)/man
43 EXAMPLEDIR = $(PREFIX)/share/examples/mandoc
45 INSTALL_PROGRAM = $(INSTALL) -m 0755
46 INSTALL_DATA = $(INSTALL) -m 0444
47 INSTALL_LIB = $(INSTALL) -m 0644
48 INSTALL_SOURCE = $(INSTALL) -m 0644
49 INSTALL_MAN = $(INSTALL_DATA)
51 DBLIB = -L/usr/local/lib -lsqlite3
52 DBBIN = mandocdb manpage apropos
54 all: mandoc preconv demandoc $(DBBIN)
56 TESTSRCS = test-fgetln.c \
172 LIBMAN_OBJS = man.o \
177 LIBMDOC_OBJS = arch.o \
188 LIBROFF_OBJS = eqn.o \
195 LIBMANDOC_OBJS = $(LIBMAN_OBJS) \
203 COMPAT_OBJS = compat_fgetln.o \
206 compat_strcasestr.o \
221 $(LIBMAN_OBJS): libman.h
222 $(LIBMDOC_OBJS): libmdoc.h
223 $(LIBROFF_OBJS): libroff.h
224 $(LIBMANDOC_OBJS): mandoc.h mdoc.h man.h libmandoc.h config.h
225 $(COMPAT_OBJS): config.h compat_ohash.h
227 MANDOC_HTML_OBJS = eqn_html.o \
232 $(MANDOC_HTML_OBJS): html.h
234 MANDOC_MAN_OBJS = mdoc_man.o
236 MANDOC_TERM_OBJS = eqn_term.o \
243 $(MANDOC_TERM_OBJS): term.h
245 MANDOC_OBJS = $(MANDOC_HTML_OBJS) \
247 $(MANDOC_TERM_OBJS) \
251 $(MANDOC_OBJS): main.h mandoc.h mdoc.h man.h config.h out.h
253 MANDOCDB_OBJS = mandocdb.o mansearch_const.o manpath.o
254 $(MANDOCDB_OBJS): mansearch.h mandoc.h mdoc.h man.h config.h manpath.h
256 PRECONV_OBJS = preconv.o
257 $(PRECONV_OBJS): config.h
259 APROPOS_OBJS = apropos.o mansearch.o mansearch_const.o manpath.o
260 $(APROPOS_OBJS): config.h manpath.h mansearch.h
262 MANPAGE_OBJS = manpage.o mansearch.o mansearch_const.o manpath.o
263 $(MANPAGE_OBJS): config.h manpath.h mansearch.h
265 DEMANDOC_OBJS = demandoc.o
266 $(DEMANDOC_OBJS): config.h
268 INDEX_MANS = apropos.1.html \
282 $(INDEX_MANS): mandoc
284 INDEX_OBJS = $(INDEX_MANS) \
294 rm -f libmandoc.a $(LIBMANDOC_OBJS)
295 rm -f apropos $(APROPOS_OBJS)
296 rm -f mandocdb $(MANDOCDB_OBJS)
297 rm -f preconv $(PRECONV_OBJS)
298 rm -f manpage $(MANPAGE_OBJS)
299 rm -f demandoc $(DEMANDOC_OBJS)
300 rm -f mandoc $(MANDOC_OBJS)
301 rm -f config.h config.log $(COMPAT_OBJS)
303 rm -f index.html $(INDEX_OBJS)
307 mkdir -p $(DESTDIR)$(BINDIR)
308 mkdir -p $(DESTDIR)$(EXAMPLEDIR)
309 mkdir -p $(DESTDIR)$(LIBDIR)
310 mkdir -p $(DESTDIR)$(INCLUDEDIR)
311 mkdir -p $(DESTDIR)$(MANDIR)/man1
312 mkdir -p $(DESTDIR)$(MANDIR)/man3
313 mkdir -p $(DESTDIR)$(MANDIR)/man7
314 $(INSTALL_PROGRAM) mandoc preconv demandoc $(DESTDIR)$(BINDIR)
315 $(INSTALL_LIB) libmandoc.a $(DESTDIR)$(LIBDIR)
316 $(INSTALL_LIB) man.h mdoc.h mandoc.h $(DESTDIR)$(INCLUDEDIR)
317 $(INSTALL_MAN) mandoc.1 preconv.1 demandoc.1 $(DESTDIR)$(MANDIR)/man1
318 $(INSTALL_MAN) mandoc.3 tbl.3 $(DESTDIR)$(MANDIR)/man3
319 $(INSTALL_MAN) man.7 mdoc.7 roff.7 eqn.7 tbl.7 mandoc_char.7 $(DESTDIR)$(MANDIR)/man7
320 $(INSTALL_DATA) example.style.css $(DESTDIR)$(EXAMPLEDIR)
323 mkdir -p $(DESTDIR)$(CGIBINDIR)
324 mkdir -p $(DESTDIR)$(HTDOCDIR)
325 #$(INSTALL_PROGRAM) man.cgi $(DESTDIR)$(CGIBINDIR)
326 $(INSTALL_DATA) example.style.css $(DESTDIR)$(HTDOCDIR)/man.css
327 $(INSTALL_DATA) man-cgi.css $(DESTDIR)$(HTDOCDIR)
330 mkdir -p $(PREFIX)/snapshots
331 mkdir -p $(PREFIX)/binaries
332 $(INSTALL_DATA) index.html external.png index.css $(PREFIX)
333 $(INSTALL_DATA) $(INDEX_MANS) style.css $(PREFIX)
334 $(INSTALL_DATA) mandoc.h.html man.h.html mdoc.h.html $(PREFIX)
335 $(INSTALL_DATA) mdocml.tar.gz $(PREFIX)/snapshots
336 $(INSTALL_DATA) mdocml.md5 $(PREFIX)/snapshots
337 $(INSTALL_DATA) mdocml.tar.gz $(PREFIX)/snapshots/mdocml-$(VERSION).tar.gz
338 $(INSTALL_DATA) mdocml.md5 $(PREFIX)/snapshots/mdocml-$(VERSION).md5
340 libmandoc.a: $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
341 $(AR) rs $@ $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
343 mandoc: $(MANDOC_OBJS) libmandoc.a
344 $(CC) $(LDFLAGS) -o $@ $(MANDOC_OBJS) libmandoc.a
346 mandocdb: $(MANDOCDB_OBJS) libmandoc.a
347 $(CC) $(LDFLAGS) -o $@ $(MANDOCDB_OBJS) libmandoc.a $(DBLIB)
349 preconv: $(PRECONV_OBJS)
350 $(CC) $(LDFLAGS) -o $@ $(PRECONV_OBJS)
352 manpage: $(MANPAGE_OBJS) libmandoc.a
353 $(CC) $(LDFLAGS) -o $@ $(MANPAGE_OBJS) libmandoc.a $(DBLIB)
355 apropos: $(APROPOS_OBJS) libmandoc.a
356 $(CC) $(LDFLAGS) -o $@ $(APROPOS_OBJS) libmandoc.a $(DBLIB)
358 demandoc: $(DEMANDOC_OBJS) libmandoc.a
359 $(CC) $(LDFLAGS) -o $@ $(DEMANDOC_OBJS) libmandoc.a
361 mdocml.md5: mdocml.tar.gz
362 md5 mdocml.tar.gz >$@
364 mdocml.tar.gz: $(SRCS)
365 mkdir -p .dist/mdocml-$(VERSION)/
366 $(INSTALL_SOURCE) $(SRCS) .dist/mdocml-$(VERSION)
367 chmod 755 .dist/mdocml-$(VERSION)/configure
368 ( cd .dist/ && tar zcf ../$@ mdocml-$(VERSION) )
371 index.html: $(INDEX_OBJS)
373 config.h: configure config.h.pre config.h.post $(TESTSRCS)
375 CC="$(CC)" CFLAGS="$(CFLAGS)" VERSION="$(VERSION)" ./configure
380 .1.1.html .3.3.html .7.7.html .8.8.html:
381 ./mandoc -Thtml -Wall,stop -Ostyle=style.css,man=%N.%S.html,includes=%I.html $< >$@
385 sed -e "s!@VERSION@!$(VERSION)!" -e "s!@VDATE@!$(VDATE)!" $< >$@