1 # $Id: Makefile,v 1.419 2014/04/24 00:29:45 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 # === END OF USER SETTINGS =============================================
71 ALLBIN = mandoc preconv demandoc $(DBBIN)
75 TESTSRCS = test-fgetln.c \
102 compat_reallocarray.c \
103 compat_strcasestr.c \
195 LIBMAN_OBJS = man.o \
200 LIBMDOC_OBJS = arch.o \
211 LIBROFF_OBJS = eqn.o \
218 LIBMANDOC_OBJS = $(LIBMAN_OBJS) \
227 COMPAT_OBJS = compat_fgetln.o \
230 compat_reallocarray.o \
231 compat_strcasestr.o \
237 # === DEPENDENCY HANDLING ==============================================
248 $(LIBMAN_OBJS): libman.h
249 $(LIBMDOC_OBJS): libmdoc.h
250 $(LIBROFF_OBJS): libroff.h
251 $(LIBMANDOC_OBJS): mandoc.h mandoc_aux.h mdoc.h man.h libmandoc.h config.h
252 $(COMPAT_OBJS): config.h compat_ohash.h
254 MANDOC_HTML_OBJS = eqn_html.o \
259 $(MANDOC_HTML_OBJS): html.h
261 MANDOC_MAN_OBJS = mdoc_man.o
263 MANDOC_TERM_OBJS = eqn_term.o \
270 $(MANDOC_TERM_OBJS): term.h
272 MANDOC_OBJS = $(MANDOC_HTML_OBJS) \
274 $(MANDOC_TERM_OBJS) \
278 $(MANDOC_OBJS): main.h mandoc.h mandoc_aux.h mdoc.h man.h config.h out.h
280 MAKEWHATIS_OBJS = mandocdb.o mansearch_const.o manpath.o
281 $(MAKEWHATIS_OBJS): mansearch.h mandoc.h mandoc_aux.h \
282 mdoc.h man.h config.h manpath.h
284 PRECONV_OBJS = preconv.o
285 $(PRECONV_OBJS): config.h
287 APROPOS_OBJS = apropos.o mansearch.o mansearch_const.o manpath.o
288 $(APROPOS_OBJS): config.h mandoc.h mandoc_aux.h manpath.h mansearch.h
290 MANPAGE_OBJS = manpage.o mansearch.o mansearch_const.o manpath.o
291 $(MANPAGE_OBJS): config.h mandoc.h mandoc_aux.h manpath.h mansearch.h
293 DEMANDOC_OBJS = demandoc.o
294 $(DEMANDOC_OBJS): config.h mandoc.h man.h mdoc.h
296 WWW_MANS = apropos.1.html \
318 WWW_OBJS = mdocml.tar.gz \
321 www: $(WWW_OBJS) $(WWW_MANS)
323 # === TARGETS CONTAINING SHELL COMMANDS ================================
326 rm -f libmandoc.a $(LIBMANDOC_OBJS)
327 rm -f apropos $(APROPOS_OBJS)
328 rm -f makewhatis $(MAKEWHATIS_OBJS)
329 rm -f preconv $(PRECONV_OBJS)
330 rm -f manpage $(MANPAGE_OBJS)
331 rm -f demandoc $(DEMANDOC_OBJS)
332 rm -f mandoc $(MANDOC_OBJS)
333 rm -f config.h config.log $(COMPAT_OBJS)
334 rm -f $(WWW_MANS) $(WWW_OBJS)
338 mkdir -p $(DESTDIR)$(BINDIR)
339 mkdir -p $(DESTDIR)$(EXAMPLEDIR)
340 mkdir -p $(DESTDIR)$(LIBDIR)
341 mkdir -p $(DESTDIR)$(INCLUDEDIR)
342 mkdir -p $(DESTDIR)$(MANDIR)/man1
343 mkdir -p $(DESTDIR)$(MANDIR)/man3
344 mkdir -p $(DESTDIR)$(MANDIR)/man5
345 mkdir -p $(DESTDIR)$(MANDIR)/man7
346 $(INSTALL_PROGRAM) $(ALLBIN) $(DESTDIR)$(BINDIR)
347 $(INSTALL_LIB) libmandoc.a $(DESTDIR)$(LIBDIR)
348 $(INSTALL_LIB) man.h mdoc.h mandoc.h $(DESTDIR)$(INCLUDEDIR)
349 $(INSTALL_MAN) mandoc.1 preconv.1 demandoc.1 $(DESTDIR)$(MANDIR)/man1
350 $(INSTALL_MAN) mandoc.3 mansearch.3 tbl.3 $(DESTDIR)$(MANDIR)/man3
351 $(INSTALL_MAN) mandoc.db.5 $(DESTDIR)$(MANDIR)/man5
352 $(INSTALL_MAN) man.7 mdoc.7 roff.7 eqn.7 tbl.7 mandoc_char.7 \
353 $(DESTDIR)$(MANDIR)/man7
354 $(INSTALL_DATA) example.style.css $(DESTDIR)$(EXAMPLEDIR)
357 mkdir -p $(DESTDIR)$(CGIBINDIR)
358 mkdir -p $(DESTDIR)$(HTDOCDIR)
359 #$(INSTALL_PROGRAM) man.cgi $(DESTDIR)$(CGIBINDIR)
360 $(INSTALL_DATA) example.style.css $(DESTDIR)$(HTDOCDIR)/man.css
361 $(INSTALL_DATA) man-cgi.css $(DESTDIR)$(HTDOCDIR)
364 mkdir -p $(DESTDIR)$(HTDOCDIR)/snapshots
365 $(INSTALL_DATA) $(WWW_MANS) style.css $(DESTDIR)$(HTDOCDIR)
366 $(INSTALL_DATA) $(WWW_OBJS) $(DESTDIR)$(HTDOCDIR)/snapshots
367 $(INSTALL_DATA) mdocml.tar.gz \
368 $(DESTDIR)$(HTDOCDIR)/snapshots/mdocml-$(VERSION).tar.gz
369 $(INSTALL_DATA) mdocml.sha256 \
370 $(DESTDIR)$(HTDOCDIR)/snapshots/mdocml-$(VERSION).sha256
372 libmandoc.a: $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
373 $(AR) rs $@ $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
375 mandoc: $(MANDOC_OBJS) libmandoc.a
376 $(CC) $(LDFLAGS) -o $@ $(MANDOC_OBJS) libmandoc.a
378 makewhatis: $(MAKEWHATIS_OBJS) libmandoc.a
379 $(CC) $(LDFLAGS) -o $@ $(MAKEWHATIS_OBJS) libmandoc.a $(DBLIB)
381 preconv: $(PRECONV_OBJS)
382 $(CC) $(LDFLAGS) -o $@ $(PRECONV_OBJS)
384 manpage: $(MANPAGE_OBJS) libmandoc.a
385 $(CC) $(LDFLAGS) -o $@ $(MANPAGE_OBJS) libmandoc.a $(DBLIB)
387 apropos: $(APROPOS_OBJS) libmandoc.a
388 $(CC) $(LDFLAGS) -o $@ $(APROPOS_OBJS) libmandoc.a $(DBLIB)
390 demandoc: $(DEMANDOC_OBJS) libmandoc.a
391 $(CC) $(LDFLAGS) -o $@ $(DEMANDOC_OBJS) libmandoc.a
393 mdocml.sha256: mdocml.tar.gz
394 sha256 mdocml.tar.gz > $@
396 mdocml.tar.gz: $(SRCS)
397 mkdir -p .dist/mdocml-$(VERSION)/
398 $(INSTALL_SOURCE) $(SRCS) .dist/mdocml-$(VERSION)
399 chmod 755 .dist/mdocml-$(VERSION)/configure
400 ( cd .dist/ && tar zcf ../$@ mdocml-$(VERSION) )
403 config.h: configure config.h.pre config.h.post $(TESTSRCS)
405 CC="$(CC)" CFLAGS="$(CFLAGS)" VERSION="$(VERSION)" ./configure
407 .PHONY: clean install installcgi installwww
408 .SUFFIXES: .1 .3 .5 .7 .8 .h
409 .SUFFIXES: .1.html .3.html .5.html .7.html .8.html .h.html
414 .1.1.html .3.3.html .5.5.html .7.7.html .8.8.html: mandoc
415 ./mandoc -Thtml -Wall,stop \
416 -Ostyle=style.css,man=%N.%S.html,includes=%I.html $< > $@