1 # $Id: Makefile,v 1.424 2014/07/13 09:39:32 schwarze Exp $
3 # Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
4 # Copyright (c) 2011, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
6 # Permission to use, copy, modify, and distribute this software for any
7 # purpose with or without fee is hereby granted, provided that the above
8 # copyright notice and this permission notice appear in all copies.
10 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 # === USER SETTINGS ====================================================
22 # Specify this if you want to hard-code the operating system to appear
23 # in the lower-left hand corner of -mdoc manuals.
25 # CFLAGS += -DOSNAME="\"OpenBSD 5.5\""
27 # IFF your system supports multi-byte functions (setlocale(), wcwidth(),
28 # putwchar()) AND has __STDC_ISO_10646__ (that is, wchar_t is simply a
29 # UCS-4 value) should you define USE_WCHAR. If you define it and your
30 # system DOESN'T support this, -Tlocale will produce garbage.
31 # If you don't define it, -Tlocale is a synonym for -Tacsii.
35 # If your system has manpath(1), uncomment this. This is most any
36 # system that's not OpenBSD or NetBSD. If uncommented, manpage(1) and
37 # makewhatis(8) will use manpath(1) to get the MANPATH variable.
38 #CFLAGS += -DUSE_MANPATH
40 # If your system does not support static binaries, comment this,
41 # for example on Mac OS X.
43 # Linux requires -pthread to statically link with libdb.
46 CFLAGS += -I/usr/local/include -g -DHAVE_CONFIG_H
47 CFLAGS += -W -Wall -Wstrict-prototypes -Wno-unused-parameter -Wwrite-strings
50 HTDOCDIR = $(WWWPREFIX)/htdocs
51 CGIBINDIR = $(WWWPREFIX)/cgi-bin
52 BINDIR = $(PREFIX)/bin
53 INCLUDEDIR = $(PREFIX)/include/mandoc
54 LIBDIR = $(PREFIX)/lib/mandoc
55 MANDIR = $(PREFIX)/man
56 EXAMPLEDIR = $(PREFIX)/share/examples/mandoc
58 INSTALL_PROGRAM = $(INSTALL) -m 0755
59 INSTALL_DATA = $(INSTALL) -m 0444
60 INSTALL_LIB = $(INSTALL) -m 0644
61 INSTALL_SOURCE = $(INSTALL) -m 0644
62 INSTALL_MAN = $(INSTALL_DATA)
64 # If you want to build without database support, for example to avoid
65 # the dependency on SQLite3, comment the following two lines.
66 DBLIB = -L/usr/local/lib -lsqlite3
67 DBBIN = makewhatis manpage apropos
69 # To build man.cgi, copy cgi.h.example to cgi.h, edit it, and
70 # either enable the following line or run "make man.cgi" by hand.
73 # OpenBSD has the ohash functions in libutil.
74 # Comment the following line if your system doesn't.
77 # === END OF USER SETTINGS =============================================
79 ALLBIN = mandoc preconv demandoc $(DBBIN)
83 TESTSRCS = test-fgetln.c \
110 compat_reallocarray.c \
111 compat_strcasestr.c \
204 LIBMAN_OBJS = man.o \
209 LIBMDOC_OBJS = arch.o \
220 LIBROFF_OBJS = eqn.o \
227 LIBMANDOC_OBJS = $(LIBMAN_OBJS) \
236 COMPAT_OBJS = compat_fgetln.o \
239 compat_reallocarray.o \
240 compat_strcasestr.o \
246 # === DEPENDENCY HANDLING ==============================================
258 $(LIBMAN_OBJS): libman.h
259 $(LIBMDOC_OBJS): libmdoc.h
260 $(LIBROFF_OBJS): libroff.h
261 $(LIBMANDOC_OBJS): mandoc.h mandoc_aux.h mdoc.h man.h libmandoc.h config.h
262 $(COMPAT_OBJS): config.h compat_ohash.h
264 MANDOC_HTML_OBJS = eqn_html.o \
269 $(MANDOC_HTML_OBJS): html.h
271 MANDOC_MAN_OBJS = mdoc_man.o
273 MANDOC_TERM_OBJS = eqn_term.o \
280 $(MANDOC_TERM_OBJS): term.h
282 MANDOC_OBJS = $(MANDOC_HTML_OBJS) \
284 $(MANDOC_TERM_OBJS) \
288 $(MANDOC_OBJS): main.h mandoc.h mandoc_aux.h mdoc.h man.h config.h out.h
290 MAKEWHATIS_OBJS = mandocdb.o mansearch_const.o manpath.o
291 $(MAKEWHATIS_OBJS): mansearch.h mandoc.h mandoc_aux.h \
292 mdoc.h man.h config.h manpath.h
294 PRECONV_OBJS = preconv.o
295 $(PRECONV_OBJS): config.h
297 APROPOS_OBJS = apropos.o mansearch.o mansearch_const.o manpath.o
298 $(APROPOS_OBJS): config.h mandoc.h mandoc_aux.h manpath.h mansearch.h
300 CGI_OBJS = $(MANDOC_HTML_OBJS) \
305 $(CGI_OBJS): main.h out.h config.h mandoc.h mandoc_aux.h \
306 manpath.h mansearch.h
308 MANPAGE_OBJS = manpage.o mansearch.o mansearch_const.o manpath.o
309 $(MANPAGE_OBJS): config.h mandoc.h mandoc_aux.h manpath.h mansearch.h
311 DEMANDOC_OBJS = demandoc.o
312 $(DEMANDOC_OBJS): config.h mandoc.h man.h mdoc.h
314 WWW_MANS = apropos.1.html \
337 WWW_OBJS = mdocml.tar.gz \
340 www: $(WWW_OBJS) $(WWW_MANS)
342 # === TARGETS CONTAINING SHELL COMMANDS ================================
345 rm -f libmandoc.a $(LIBMANDOC_OBJS)
346 rm -f apropos $(APROPOS_OBJS)
347 rm -f makewhatis $(MAKEWHATIS_OBJS)
348 rm -f preconv $(PRECONV_OBJS)
349 rm -f man.cgi $(CGI_OBJS)
350 rm -f manpage $(MANPAGE_OBJS)
351 rm -f demandoc $(DEMANDOC_OBJS)
352 rm -f mandoc $(MANDOC_OBJS)
353 rm -f config.h config.log $(COMPAT_OBJS)
354 rm -f $(WWW_MANS) $(WWW_OBJS)
358 mkdir -p $(DESTDIR)$(BINDIR)
359 mkdir -p $(DESTDIR)$(EXAMPLEDIR)
360 mkdir -p $(DESTDIR)$(LIBDIR)
361 mkdir -p $(DESTDIR)$(INCLUDEDIR)
362 mkdir -p $(DESTDIR)$(MANDIR)/man1
363 mkdir -p $(DESTDIR)$(MANDIR)/man3
364 mkdir -p $(DESTDIR)$(MANDIR)/man5
365 mkdir -p $(DESTDIR)$(MANDIR)/man7
366 $(INSTALL_PROGRAM) $(ALLBIN) $(DESTDIR)$(BINDIR)
367 $(INSTALL_LIB) libmandoc.a $(DESTDIR)$(LIBDIR)
368 $(INSTALL_LIB) man.h mdoc.h mandoc.h $(DESTDIR)$(INCLUDEDIR)
369 $(INSTALL_MAN) mandoc.1 preconv.1 demandoc.1 $(DESTDIR)$(MANDIR)/man1
370 $(INSTALL_MAN) mandoc.3 mansearch.3 tbl.3 $(DESTDIR)$(MANDIR)/man3
371 $(INSTALL_MAN) mandoc.db.5 $(DESTDIR)$(MANDIR)/man5
372 $(INSTALL_MAN) man.7 mdoc.7 roff.7 eqn.7 tbl.7 mandoc_char.7 \
373 $(DESTDIR)$(MANDIR)/man7
374 $(INSTALL_DATA) example.style.css $(DESTDIR)$(EXAMPLEDIR)
377 mkdir -p $(DESTDIR)$(CGIBINDIR)
378 mkdir -p $(DESTDIR)$(HTDOCDIR)
379 mkdir -p $(DESTDIR)$(WWWPREFIX)/man/mandoc/man1
380 mkdir -p $(DESTDIR)$(WWWPREFIX)/man/mandoc/man8
381 $(INSTALL_PROGRAM) man.cgi $(DESTDIR)$(CGIBINDIR)
382 $(INSTALL_DATA) example.style.css $(DESTDIR)$(HTDOCDIR)/man.css
383 $(INSTALL_DATA) man-cgi.css $(DESTDIR)$(HTDOCDIR)
384 $(INSTALL_MAN) apropos.1 $(DESTDIR)$(WWWPREFIX)/man/mandoc/man1/
385 $(INSTALL_MAN) man.cgi.8 $(DESTDIR)$(WWWPREFIX)/man/mandoc/man8/
388 mkdir -p $(DESTDIR)$(HTDOCDIR)/snapshots
389 $(INSTALL_DATA) $(WWW_MANS) style.css $(DESTDIR)$(HTDOCDIR)
390 $(INSTALL_DATA) $(WWW_OBJS) $(DESTDIR)$(HTDOCDIR)/snapshots
391 $(INSTALL_DATA) mdocml.tar.gz \
392 $(DESTDIR)$(HTDOCDIR)/snapshots/mdocml-$(VERSION).tar.gz
393 $(INSTALL_DATA) mdocml.sha256 \
394 $(DESTDIR)$(HTDOCDIR)/snapshots/mdocml-$(VERSION).sha256
396 libmandoc.a: $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
397 $(AR) rs $@ $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
399 mandoc: $(MANDOC_OBJS) libmandoc.a
400 $(CC) $(LDFLAGS) -o $@ $(MANDOC_OBJS) libmandoc.a
402 makewhatis: $(MAKEWHATIS_OBJS) libmandoc.a
403 $(CC) $(LDFLAGS) -o $@ $(MAKEWHATIS_OBJS) libmandoc.a $(DBLIB)
405 preconv: $(PRECONV_OBJS)
406 $(CC) $(LDFLAGS) -o $@ $(PRECONV_OBJS)
408 manpage: $(MANPAGE_OBJS) libmandoc.a
409 $(CC) $(LDFLAGS) -o $@ $(MANPAGE_OBJS) libmandoc.a $(DBLIB)
411 apropos: $(APROPOS_OBJS) libmandoc.a
412 $(CC) $(LDFLAGS) -o $@ $(APROPOS_OBJS) libmandoc.a $(DBLIB)
414 man.cgi: $(CGI_OBJS) libmandoc.a
415 $(CC) $(LDFLAGS) $(STATIC) -o $@ $(CGI_OBJS) libmandoc.a $(DBLIB)
417 demandoc: $(DEMANDOC_OBJS) libmandoc.a
418 $(CC) $(LDFLAGS) -o $@ $(DEMANDOC_OBJS) libmandoc.a
420 mdocml.sha256: mdocml.tar.gz
421 sha256 mdocml.tar.gz > $@
423 mdocml.tar.gz: $(SRCS)
424 mkdir -p .dist/mdocml-$(VERSION)/
425 $(INSTALL_SOURCE) $(SRCS) .dist/mdocml-$(VERSION)
426 chmod 755 .dist/mdocml-$(VERSION)/configure
427 ( cd .dist/ && tar zcf ../$@ mdocml-$(VERSION) )
430 config.h: configure config.h.pre config.h.post $(TESTSRCS)
432 CC="$(CC)" CFLAGS="$(CFLAGS)" VERSION="$(VERSION)" ./configure
434 .PHONY: clean install installcgi installwww
435 .SUFFIXES: .1 .3 .5 .7 .8 .h
436 .SUFFIXES: .1.html .3.html .5.html .7.html .8.html .h.html
441 .1.1.html .3.3.html .5.5.html .7.7.html .8.8.html: mandoc
442 ./mandoc -Thtml -Wall,stop \
443 -Ostyle=style.css,man=%N.%S.html,includes=%I.html $< > $@