1 # $Id: Makefile,v 1.527 2018/12/14 01:18:25 schwarze Exp $
3 # Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
4 # Copyright (c) 2011, 2013-2018 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-be32toh.c \
24 test-dirent-namlen.c \
42 test-recallocarray.c \
69 compat_reallocarray.c \
70 compat_recallocarray.c \
138 DISTFILES = INSTALL \
149 compat_stringlist.h \
151 configure.local.example \
214 LIBMAN_OBJS = man.o \
218 LIBMDOC_OBJS = att.o \
227 LIBROFF_OBJS = eqn.o \
235 LIBMANDOC_OBJS = $(LIBMAN_OBJS) \
248 COMPAT_OBJS = compat_err.o \
256 compat_reallocarray.o \
257 compat_recallocarray.o \
258 compat_strcasestr.o \
266 MANDOC_HTML_OBJS = eqn_html.o \
273 MANDOC_TERM_OBJS = eqn_term.o \
293 MAIN_OBJS = $(MANDOC_HTML_OBJS) \
295 $(MANDOC_TERM_OBJS) \
306 CGI_OBJS = $(MANDOC_HTML_OBJS) \
311 MANDOCD_OBJS = $(MANDOC_HTML_OBJS) \
312 $(MANDOC_TERM_OBJS) \
317 DEMANDOC_OBJS = demandoc.o
319 SOELIM_OBJS = soelim.o \
323 compat_reallocarray.o \
326 WWW_MANS = apropos.1.html \
334 mandoc_escape.3.html \
335 mandoc_headers.3.html \
337 mandoc_malloc.3.html \
339 mchars_alloc.3.html \
354 WWW_INCS = eqn.h.html \
359 mandoc_parse.h.html \
365 # === USER CONFIGURATION ===============================================
367 include Makefile.local
369 # === DEPENDENCY HANDLING ==============================================
371 all: mandoc demandoc soelim $(BUILD_TARGETS) Makefile.local
373 install: base-install $(INSTALL_TARGETS)
375 www: $(WWW_MANS) $(WWW_INCS)
377 $(WWW_MANS) $(WWW_INCS): mandoc
379 .PHONY: base-install cgi-install install www-install
380 .PHONY: clean distclean depend
382 include Makefile.depend
384 # === TARGETS CONTAINING SHELL COMMANDS ================================
387 rm -f Makefile.local config.h config.h.old config.log config.log.old
390 rm -f libmandoc.a $(LIBMANDOC_OBJS) $(COMPAT_OBJS)
391 rm -f mandoc $(MAIN_OBJS)
392 rm -f man.cgi $(CGI_OBJS)
393 rm -f mandocd catman catman.o $(MANDOCD_OBJS)
394 rm -f demandoc $(DEMANDOC_OBJS)
395 rm -f soelim $(SOELIM_OBJS)
396 rm -f $(WWW_MANS) $(WWW_INCS) mandoc*.tar.gz mandoc*.sha256
399 base-install: mandoc demandoc soelim
400 mkdir -p $(DESTDIR)$(BINDIR)
401 mkdir -p $(DESTDIR)$(SBINDIR)
402 mkdir -p $(DESTDIR)$(MANDIR)/man1
403 mkdir -p $(DESTDIR)$(MANDIR)/man5
404 mkdir -p $(DESTDIR)$(MANDIR)/man7
405 mkdir -p $(DESTDIR)$(MANDIR)/man8
406 $(INSTALL_PROGRAM) mandoc demandoc $(DESTDIR)$(BINDIR)
407 $(INSTALL_PROGRAM) soelim $(DESTDIR)$(BINDIR)/$(BINM_SOELIM)
408 cd $(DESTDIR)$(BINDIR) && $(LN) mandoc $(BINM_MAN)
409 cd $(DESTDIR)$(BINDIR) && $(LN) mandoc $(BINM_APROPOS)
410 cd $(DESTDIR)$(BINDIR) && $(LN) mandoc $(BINM_WHATIS)
411 cd $(DESTDIR)$(SBINDIR) && \
412 $(LN) ${BIN_FROM_SBIN}/mandoc $(BINM_MAKEWHATIS)
413 $(INSTALL_MAN) mandoc.1 demandoc.1 $(DESTDIR)$(MANDIR)/man1
414 $(INSTALL_MAN) soelim.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_SOELIM).1
415 $(INSTALL_MAN) man.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_MAN).1
416 $(INSTALL_MAN) apropos.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_APROPOS).1
417 cd $(DESTDIR)$(MANDIR)/man1 && $(LN) $(BINM_APROPOS).1 $(BINM_WHATIS).1
418 $(INSTALL_MAN) man.conf.5 $(DESTDIR)$(MANDIR)/man5/$(MANM_MANCONF).5
419 $(INSTALL_MAN) mandoc.db.5 $(DESTDIR)$(MANDIR)/man5
420 $(INSTALL_MAN) man.7 $(DESTDIR)$(MANDIR)/man7/$(MANM_MAN).7
421 $(INSTALL_MAN) mdoc.7 $(DESTDIR)$(MANDIR)/man7/$(MANM_MDOC).7
422 $(INSTALL_MAN) roff.7 $(DESTDIR)$(MANDIR)/man7/$(MANM_ROFF).7
423 $(INSTALL_MAN) eqn.7 $(DESTDIR)$(MANDIR)/man7/$(MANM_EQN).7
424 $(INSTALL_MAN) tbl.7 $(DESTDIR)$(MANDIR)/man7/$(MANM_TBL).7
425 $(INSTALL_MAN) mandoc_char.7 $(DESTDIR)$(MANDIR)/man7
426 $(INSTALL_MAN) makewhatis.8 \
427 $(DESTDIR)$(MANDIR)/man8/$(BINM_MAKEWHATIS).8
429 lib-install: libmandoc.a
430 mkdir -p $(DESTDIR)$(LIBDIR)
431 mkdir -p $(DESTDIR)$(INCLUDEDIR)
432 mkdir -p $(DESTDIR)$(MANDIR)/man3
433 $(INSTALL_LIB) libmandoc.a $(DESTDIR)$(LIBDIR)
434 $(INSTALL_LIB) eqn.h man.h mandoc.h mandoc_aux.h mandoc_parse.h \
435 mdoc.h roff.h tbl.h $(DESTDIR)$(INCLUDEDIR)
436 $(INSTALL_MAN) mandoc.3 mandoc_escape.3 mandoc_malloc.3 \
437 mansearch.3 mchars_alloc.3 tbl.3 $(DESTDIR)$(MANDIR)/man3
440 mkdir -p $(DESTDIR)$(CGIBINDIR)
441 mkdir -p $(DESTDIR)$(HTDOCDIR)
442 $(INSTALL_PROGRAM) man.cgi $(DESTDIR)$(CGIBINDIR)
443 $(INSTALL_DATA) mandoc.css $(DESTDIR)$(HTDOCDIR)
445 catman-install: mandocd catman
446 mkdir -p $(DESTDIR)$(SBINDIR)
447 mkdir -p $(DESTDIR)$(MANDIR)/man8
448 $(INSTALL_PROGRAM) mandocd $(DESTDIR)$(SBINDIR)
449 $(INSTALL_PROGRAM) catman $(DESTDIR)$(SBINDIR)/$(BINM_CATMAN)
450 $(INSTALL_MAN) mandocd.8 $(DESTDIR)$(MANDIR)/man8
451 $(INSTALL_MAN) catman.8 $(DESTDIR)$(MANDIR)/man8/$(BINM_CATMAN).8
454 rm -f $(DESTDIR)$(BINDIR)/mandoc
455 rm -f $(DESTDIR)$(BINDIR)/demandoc
456 rm -f $(DESTDIR)$(BINDIR)/$(BINM_SOELIM)
457 rm -f $(DESTDIR)$(BINDIR)/$(BINM_MAN)
458 rm -f $(DESTDIR)$(BINDIR)/$(BINM_APROPOS)
459 rm -f $(DESTDIR)$(BINDIR)/$(BINM_WHATIS)
460 rm -f $(DESTDIR)$(SBINDIR)/$(BINM_MAKEWHATIS)
461 rm -f $(DESTDIR)$(MANDIR)/man1/mandoc.1
462 rm -f $(DESTDIR)$(MANDIR)/man1/demandoc.1
463 rm -f $(DESTDIR)$(MANDIR)/man1/$(BINM_SOELIM).1
464 rm -f $(DESTDIR)$(MANDIR)/man1/$(BINM_MAN).1
465 rm -f $(DESTDIR)$(MANDIR)/man1/$(BINM_APROPOS).1
466 rm -f $(DESTDIR)$(MANDIR)/man1/$(BINM_WHATIS).1
467 rm -f $(DESTDIR)$(MANDIR)/man5/$(MANM_MANCONF).5
468 rm -f $(DESTDIR)$(MANDIR)/man5/mandoc.db.5
469 rm -f $(DESTDIR)$(MANDIR)/man7/$(MANM_MAN).7
470 rm -f $(DESTDIR)$(MANDIR)/man7/$(MANM_MDOC).7
471 rm -f $(DESTDIR)$(MANDIR)/man7/$(MANM_ROFF).7
472 rm -f $(DESTDIR)$(MANDIR)/man7/$(MANM_EQN).7
473 rm -f $(DESTDIR)$(MANDIR)/man7/$(MANM_TBL).7
474 rm -f $(DESTDIR)$(MANDIR)/man7/mandoc_char.7
475 rm -f $(DESTDIR)$(MANDIR)/man8/$(BINM_MAKEWHATIS).8
476 rm -f $(DESTDIR)$(CGIBINDIR)/man.cgi
477 rm -f $(DESTDIR)$(HTDOCDIR)/mandoc.css
478 rm -f $(DESTDIR)$(SBINDIR)/mandocd
479 rm -f $(DESTDIR)$(SBINDIR)/$(BINM_CATMAN)
480 rm -f $(DESTDIR)$(MANDIR)/man8/mandocd.8
481 rm -f $(DESTDIR)$(MANDIR)/man8/$(BINM_CATMAN).8
482 rm -f $(DESTDIR)$(LIBDIR)/libmandoc.a
483 rm -f $(DESTDIR)$(MANDIR)/man3/mandoc.3
484 rm -f $(DESTDIR)$(MANDIR)/man3/mandoc_escape.3
485 rm -f $(DESTDIR)$(MANDIR)/man3/mandoc_malloc.3
486 rm -f $(DESTDIR)$(MANDIR)/man3/mansearch.3
487 rm -f $(DESTDIR)$(MANDIR)/man3/mchars_alloc.3
488 rm -f $(DESTDIR)$(MANDIR)/man3/tbl.3
489 rm -f $(DESTDIR)$(INCLUDEDIR)/eqn.h
490 rm -f $(DESTDIR)$(INCLUDEDIR)/man.h
491 rm -f $(DESTDIR)$(INCLUDEDIR)/mandoc.h
492 rm -f $(DESTDIR)$(INCLUDEDIR)/mandoc_aux.h
493 rm -f $(DESTDIR)$(INCLUDEDIR)/mandoc_parse.h
494 rm -f $(DESTDIR)$(INCLUDEDIR)/mdoc.h
495 rm -f $(DESTDIR)$(INCLUDEDIR)/roff.h
496 rm -f $(DESTDIR)$(INCLUDEDIR)/tbl.h
497 [ ! -e $(DESTDIR)$(INCLUDEDIR) ] || rmdir $(DESTDIR)$(INCLUDEDIR)
500 cd regress && ./regress.pl
503 cd regress && ./regress.pl . clean
505 Makefile.local config.h: configure $(TESTSRCS)
506 @echo "$@ is out of date; please run ./configure"
509 libmandoc.a: $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
510 ar rs $@ $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
512 mandoc: $(MAIN_OBJS) libmandoc.a
513 $(CC) -o $@ $(LDFLAGS) $(MAIN_OBJS) libmandoc.a $(LDADD)
515 man.cgi: $(CGI_OBJS) libmandoc.a
516 $(CC) $(STATIC) -o $@ $(LDFLAGS) $(CGI_OBJS) libmandoc.a $(LDADD)
518 mandocd: $(MANDOCD_OBJS) libmandoc.a
519 $(CC) -o $@ $(LDFLAGS) $(MANDOCD_OBJS) libmandoc.a $(LDADD)
521 catman: catman.o libmandoc.a
522 $(CC) -o $@ $(LDFLAGS) catman.o libmandoc.a $(LDADD)
524 demandoc: $(DEMANDOC_OBJS) libmandoc.a
525 $(CC) -o $@ $(LDFLAGS) $(DEMANDOC_OBJS) libmandoc.a $(LDADD)
527 soelim: $(SOELIM_OBJS)
528 $(CC) -o $@ $(LDFLAGS) $(SOELIM_OBJS)
530 # --- maintainer targets ---
533 $(INSTALL_DATA) mandoc.css $(HTDOCDIR)
534 $(INSTALL_DATA) $(WWW_MANS) $(HTDOCDIR)/man
535 $(INSTALL_DATA) $(WWW_INCS) $(HTDOCDIR)/includes
538 mkdep -f Makefile.depend $(CFLAGS) $(SRCS)
539 perl -e 'undef $$/; $$_ = <>; s|/usr/include/\S+||g; \
540 s|\\\n||g; s| +| |g; s| $$||mg; print;' \
541 Makefile.depend > Makefile.tmp
542 mv Makefile.tmp Makefile.depend
553 @find regress ! -type d ! -type f
554 @find regress -type f \
557 ! -name Makefile.inc \
559 ! -name '*.out_ascii' \
560 ! -name '*.out_utf8' \
561 ! -name '*.out_html' \
562 ! -name '*.out_markdown' \
563 ! -name '*.out_lint' \
564 ! -path regress/regress.pl \
565 ! -path regress/regress.pl.1
567 dist: mandoc-$(VERSION).sha256
569 mandoc-$(VERSION).sha256: mandoc-$(VERSION).tar.gz
570 sha256 mandoc-$(VERSION).tar.gz > $@
572 mandoc-$(VERSION).tar.gz: $(DISTFILES)
573 ls regress/*/*/*.mandoc_* && exit 1 || true
574 mkdir -p .dist/mandoc-$(VERSION)/
575 $(INSTALL) -m 0644 $(DISTFILES) .dist/mandoc-$(VERSION)
576 cp -pR regress .dist/mandoc-$(VERSION)
577 find .dist/mandoc-$(VERSION)/regress \
578 -type d -name CVS -print0 | xargs -0 rm -rf
579 chmod 755 .dist/mandoc-$(VERSION)/configure
580 ( cd .dist/ && tar zcf ../$@ mandoc-$(VERSION) )
583 # === SUFFIX RULES =====================================================
585 .SUFFIXES: .1 .3 .5 .7 .8 .h
586 .SUFFIXES: .1.html .3.html .5.html .7.html .8.html .h.html
591 .1.1.html .3.3.html .5.5.html .7.7.html .8.8.html: mandoc
593 style=/mandoc.css,man=/man/%N.%S.html,includes=/includes/%I.html \