1 # $Id: Makefile,v 1.466 2015/07/19 06:05:16 schwarze Exp $
3 # Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
4 # Copyright (c) 2011, 2013, 2014, 2015 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 # === LIST OF FILES ====================================================
22 TESTSRCS = test-dirent-namlen.c \
32 test-sqlite3_errstr.c \
52 compat_reallocarray.c \
53 compat_sqlite3_errstr.c \
108 DISTFILES = INSTALL \
119 compat_stringlist.h \
121 configure.local.example \
171 LIBMAN_OBJS = man.o \
176 LIBMDOC_OBJS = att.o \
185 LIBROFF_OBJS = eqn.o \
192 LIBMANDOC_OBJS = $(LIBMAN_OBJS) \
202 COMPAT_OBJS = compat_fgetln.o \
208 compat_reallocarray.o \
209 compat_sqlite3_errstr.o \
210 compat_strcasestr.o \
217 MANDOC_HTML_OBJS = eqn_html.o \
223 MANDOC_MAN_OBJS = mdoc_man.o
225 MANDOC_TERM_OBJS = eqn_term.o \
233 BASE_OBJS = $(MANDOC_HTML_OBJS) \
235 $(MANDOC_TERM_OBJS) \
242 MAIN_OBJS = $(BASE_OBJS)
244 DB_OBJS = mandocdb.o \
248 CGI_OBJS = $(MANDOC_HTML_OBJS) \
254 MANPAGE_OBJS = manpage.o mansearch.o mansearch_const.o manpath.o
256 DEMANDOC_OBJS = demandoc.o
258 SOELIM_OBJS = soelim.o compat_stringlist.o
260 WWW_MANS = apropos.1.html \
266 mandoc_escape.3.html \
267 mandoc_headers.3.html \
269 mandoc_malloc.3.html \
271 mchars_alloc.3.html \
291 WWW_OBJS = mdocml.tar.gz \
294 # === USER CONFIGURATION ===============================================
296 include Makefile.local
298 # === DEPENDENCY HANDLING ==============================================
300 all: base-build $(BUILD_TARGETS) Makefile.local
302 base-build: mandoc demandoc soelim
306 install: base-install $(INSTALL_TARGETS)
308 www: $(WWW_OBJS) $(WWW_MANS)
312 .PHONY: base-install cgi-install db-install install www-install
313 .PHONY: clean distclean depend
315 include Makefile.depend
317 # === TARGETS CONTAINING SHELL COMMANDS ================================
320 rm -f Makefile.local config.h config.h.old config.log config.log.old
323 rm -f libmandoc.a $(LIBMANDOC_OBJS) $(COMPAT_OBJS)
324 rm -f mandoc $(BASE_OBJS) $(DB_OBJS)
325 rm -f man.cgi $(CGI_OBJS)
326 rm -f manpage $(MANPAGE_OBJS)
327 rm -f demandoc $(DEMANDOC_OBJS)
328 rm -f soelim $(SOELIM_OBJS)
329 rm -f $(WWW_MANS) $(WWW_OBJS)
332 base-install: base-build
333 mkdir -p $(DESTDIR)$(BINDIR)
334 mkdir -p $(DESTDIR)$(EXAMPLEDIR)
335 mkdir -p $(DESTDIR)$(LIBDIR)
336 mkdir -p $(DESTDIR)$(INCLUDEDIR)
337 mkdir -p $(DESTDIR)$(MANDIR)/man1
338 mkdir -p $(DESTDIR)$(MANDIR)/man3
339 mkdir -p $(DESTDIR)$(MANDIR)/man5
340 mkdir -p $(DESTDIR)$(MANDIR)/man7
341 $(INSTALL_PROGRAM) mandoc demandoc soelim $(DESTDIR)$(BINDIR)
342 ln -f $(DESTDIR)$(BINDIR)/mandoc $(DESTDIR)$(BINDIR)/$(BINM_MAN)
343 $(INSTALL_LIB) libmandoc.a $(DESTDIR)$(LIBDIR)
344 $(INSTALL_LIB) man.h mandoc.h mandoc_aux.h mdoc.h roff.h \
345 $(DESTDIR)$(INCLUDEDIR)
346 $(INSTALL_MAN) mandoc.1 demandoc.1 soelim.1 $(DESTDIR)$(MANDIR)/man1
347 $(INSTALL_MAN) man.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_MAN).1
348 $(INSTALL_MAN) mandoc.3 mandoc_escape.3 mandoc_malloc.3 \
349 mchars_alloc.3 tbl.3 $(DESTDIR)$(MANDIR)/man3
350 $(INSTALL_MAN) man.conf.5 $(DESTDIR)$(MANDIR)/man5/${MANM_MANCONF}.5
351 $(INSTALL_MAN) man.7 $(DESTDIR)$(MANDIR)/man7/${MANM_MAN}.7
352 $(INSTALL_MAN) mdoc.7 $(DESTDIR)$(MANDIR)/man7/${MANM_MDOC}.7
353 $(INSTALL_MAN) roff.7 $(DESTDIR)$(MANDIR)/man7/${MANM_ROFF}.7
354 $(INSTALL_MAN) eqn.7 $(DESTDIR)$(MANDIR)/man7/${MANM_EQN}.7
355 $(INSTALL_MAN) tbl.7 $(DESTDIR)$(MANDIR)/man7/${MANM_TBL}.7
356 $(INSTALL_MAN) mandoc_char.7 $(DESTDIR)$(MANDIR)/man7
357 $(INSTALL_DATA) example.style.css $(DESTDIR)$(EXAMPLEDIR)
359 db-install: base-build
360 mkdir -p $(DESTDIR)$(BINDIR)
361 mkdir -p $(DESTDIR)$(SBINDIR)
362 mkdir -p $(DESTDIR)$(MANDIR)/man1
363 mkdir -p $(DESTDIR)$(MANDIR)/man3
364 mkdir -p $(DESTDIR)$(MANDIR)/man5
365 mkdir -p $(DESTDIR)$(MANDIR)/man8
366 ln -f $(DESTDIR)$(BINDIR)/mandoc $(DESTDIR)$(BINDIR)/$(BINM_APROPOS)
367 ln -f $(DESTDIR)$(BINDIR)/mandoc $(DESTDIR)$(BINDIR)/$(BINM_WHATIS)
368 ln -f $(DESTDIR)$(BINDIR)/mandoc \
369 $(DESTDIR)$(SBINDIR)/$(BINM_MAKEWHATIS)
370 $(INSTALL_MAN) apropos.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_APROPOS).1
371 ln -f $(DESTDIR)$(MANDIR)/man1/$(BINM_APROPOS).1 \
372 $(DESTDIR)$(MANDIR)/man1/$(BINM_WHATIS).1
373 $(INSTALL_MAN) mansearch.3 $(DESTDIR)$(MANDIR)/man3
374 $(INSTALL_MAN) mandoc.db.5 $(DESTDIR)$(MANDIR)/man5
375 $(INSTALL_MAN) makewhatis.8 \
376 $(DESTDIR)$(MANDIR)/man8/$(BINM_MAKEWHATIS).8
378 cgi-install: cgi-build
379 mkdir -p $(DESTDIR)$(CGIBINDIR)
380 mkdir -p $(DESTDIR)$(HTDOCDIR)
381 mkdir -p $(DESTDIR)$(WWWPREFIX)/man/mandoc/man1
382 mkdir -p $(DESTDIR)$(WWWPREFIX)/man/mandoc/man8
383 $(INSTALL_PROGRAM) man.cgi $(DESTDIR)$(CGIBINDIR)
384 $(INSTALL_DATA) example.style.css $(DESTDIR)$(HTDOCDIR)/man.css
385 $(INSTALL_DATA) man-cgi.css $(DESTDIR)$(HTDOCDIR)
386 $(INSTALL_MAN) apropos.1 $(DESTDIR)$(WWWPREFIX)/man/mandoc/man1/
387 $(INSTALL_MAN) man.cgi.8 $(DESTDIR)$(WWWPREFIX)/man/mandoc/man8/
389 Makefile.local config.h: configure ${TESTSRCS}
390 @echo "$@ is out of date; please run ./configure"
393 libmandoc.a: $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
394 $(AR) rs $@ $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
396 mandoc: $(MAIN_OBJS) libmandoc.a
397 $(CC) $(LDFLAGS) -o $@ $(MAIN_OBJS) libmandoc.a $(DBLIB)
399 manpage: $(MANPAGE_OBJS) libmandoc.a
400 $(CC) $(LDFLAGS) -o $@ $(MANPAGE_OBJS) libmandoc.a $(DBLIB)
402 man.cgi: $(CGI_OBJS) libmandoc.a
403 $(CC) $(LDFLAGS) $(STATIC) -o $@ $(CGI_OBJS) libmandoc.a $(DBLIB)
405 demandoc: $(DEMANDOC_OBJS) libmandoc.a
406 $(CC) $(LDFLAGS) -o $@ $(DEMANDOC_OBJS) libmandoc.a -lz
408 soelim: $(SOELIM_OBJS) compat_reallocarray.o
409 $(CC) $(LDFLAGS) -o $@ $(SOELIM_OBJS) compat_reallocarray.o
411 # --- maintainer targets ---
414 mkdir -p $(HTDOCDIR)/snapshots
415 $(INSTALL_DATA) $(WWW_MANS) style.css $(HTDOCDIR)
416 $(INSTALL_DATA) $(WWW_OBJS) $(HTDOCDIR)/snapshots
417 $(INSTALL_DATA) mdocml.tar.gz \
418 $(HTDOCDIR)/snapshots/mdocml-$(VERSION).tar.gz
419 $(INSTALL_DATA) mdocml.sha256 \
420 $(HTDOCDIR)/snapshots/mdocml-$(VERSION).sha256
423 mkdep -f Makefile.depend $(CFLAGS) $(SRCS)
424 perl -e 'undef $$/; $$_ = <>; s|/usr/include/\S+||g; \
425 s|\\\n||g; s| +| |g; s| $$||mg; print;' \
426 Makefile.depend > Makefile.tmp
427 mv Makefile.tmp Makefile.depend
429 mdocml.sha256: mdocml.tar.gz
430 sha256 mdocml.tar.gz > $@
432 mdocml.tar.gz: $(DISTFILES)
433 mkdir -p .dist/mdocml-$(VERSION)/
434 $(INSTALL) -m 0644 $(DISTFILES) .dist/mdocml-$(VERSION)
435 chmod 755 .dist/mdocml-$(VERSION)/configure
436 ( cd .dist/ && tar zcf ../$@ mdocml-$(VERSION) )
439 # === SUFFIX RULES =====================================================
441 .SUFFIXES: .1 .3 .5 .7 .8 .h
442 .SUFFIXES: .1.html .3.html .5.html .7.html .8.html .h.html
447 .1.1.html .3.3.html .5.5.html .7.7.html .8.8.html: mandoc
448 ./mandoc -Thtml -Wall,stop \
449 -Ostyle=style.css,man=%N.%S.html,includes=%I.html $< > $@