1 # $Id: Makefile,v 1.538 2021/09/20 10:14:34 schwarze Exp $
3 # Copyright (c) 2011, 2013-2021 Ingo Schwarze <schwarze@openbsd.org>
4 # Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
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-attribute.c \
25 test-dirent-namlen.c \
43 test-recallocarray.c \
73 compat_reallocarray.c \
74 compat_recallocarray.c \
143 DISTFILES = INSTALL \
154 compat_stringlist.h \
156 configure.local.example \
220 LIBMAN_OBJS = man.o \
224 LIBMDOC_OBJS = att.o \
233 LIBROFF_OBJS = eqn.o \
241 LIBMANDOC_OBJS = $(LIBMAN_OBJS) \
256 ALL_COBJS = compat_err.o \
265 compat_reallocarray.o \
266 compat_recallocarray.o \
267 compat_strcasestr.o \
268 compat_stringlist.o \
276 MANDOC_HTML_OBJS = eqn_html.o \
283 MANDOC_TERM_OBJS = eqn_term.o \
304 MAIN_OBJS = $(MANDOC_HTML_OBJS) \
306 $(MANDOC_TERM_OBJS) \
316 CGI_OBJS = $(MANDOC_HTML_OBJS) \
321 MANDOCD_OBJS = $(MANDOC_HTML_OBJS) \
322 $(MANDOC_TERM_OBJS) \
326 DEMANDOC_OBJS = demandoc.o
328 WWW_MANS = apropos.1.html \
336 mandoc_escape.3.html \
337 mandoc_headers.3.html \
339 mandoc_malloc.3.html \
341 mchars_alloc.3.html \
356 WWW_INCS = eqn.h.html \
362 mandoc_parse.h.html \
370 # === USER CONFIGURATION ===============================================
372 include Makefile.local
374 # === DEPENDENCY HANDLING ==============================================
376 all: mandoc man demandoc soelim $(BUILD_TARGETS) Makefile.local
378 install: base-install $(INSTALL_TARGETS)
380 www: $(WWW_MANS) $(WWW_INCS)
382 $(WWW_MANS) $(WWW_INCS): mandoc
384 .PHONY: base-install cgi-install install www-install
385 .PHONY: clean distclean depend
387 include Makefile.depend
389 # === TARGETS CONTAINING SHELL COMMANDS ================================
392 rm -f Makefile.local config.h config.h.old config.log config.log.old
395 rm -f libmandoc.a $(LIBMANDOC_OBJS) $(ALL_COBJS)
396 rm -f mandoc man $(MAIN_OBJS)
397 rm -f man.cgi $(CGI_OBJS)
398 rm -f mandocd catman catman.o $(MANDOCD_OBJS)
399 rm -f demandoc $(DEMANDOC_OBJS)
400 rm -f soelim soelim.o
401 rm -f $(WWW_MANS) $(WWW_INCS) mandoc*.tar.gz mandoc*.sha256
402 rm -f Makefile.tmp1 Makefile.tmp2
405 base-install: mandoc demandoc soelim
406 mkdir -p $(DESTDIR)$(BINDIR)
407 mkdir -p $(DESTDIR)$(SBINDIR)
408 mkdir -p $(DESTDIR)$(MANDIR)/man1
409 mkdir -p $(DESTDIR)$(MANDIR)/man5
410 mkdir -p $(DESTDIR)$(MANDIR)/man7
411 mkdir -p $(DESTDIR)$(MANDIR)/man8
412 $(INSTALL_PROGRAM) mandoc demandoc $(DESTDIR)$(BINDIR)
413 $(INSTALL_PROGRAM) soelim $(DESTDIR)$(BINDIR)/$(BINM_SOELIM)
414 cd $(DESTDIR)$(BINDIR) && $(LN) mandoc $(BINM_MAN)
415 cd $(DESTDIR)$(BINDIR) && $(LN) mandoc $(BINM_APROPOS)
416 cd $(DESTDIR)$(BINDIR) && $(LN) mandoc $(BINM_WHATIS)
417 cd $(DESTDIR)$(SBINDIR) && \
418 $(LN) ${BIN_FROM_SBIN}/mandoc $(BINM_MAKEWHATIS)
419 $(INSTALL_MAN) mandoc.1 demandoc.1 $(DESTDIR)$(MANDIR)/man1
420 $(INSTALL_MAN) soelim.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_SOELIM).1
421 $(INSTALL_MAN) man.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_MAN).1
422 $(INSTALL_MAN) apropos.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_APROPOS).1
423 cd $(DESTDIR)$(MANDIR)/man1 && $(LN) $(BINM_APROPOS).1 $(BINM_WHATIS).1
424 $(INSTALL_MAN) man.conf.5 $(DESTDIR)$(MANDIR)/man5/$(MANM_MANCONF).5
425 $(INSTALL_MAN) mandoc.db.5 $(DESTDIR)$(MANDIR)/man5
426 $(INSTALL_MAN) man.7 $(DESTDIR)$(MANDIR)/man7/$(MANM_MAN).7
427 $(INSTALL_MAN) mdoc.7 $(DESTDIR)$(MANDIR)/man7/$(MANM_MDOC).7
428 $(INSTALL_MAN) roff.7 $(DESTDIR)$(MANDIR)/man7/$(MANM_ROFF).7
429 $(INSTALL_MAN) eqn.7 $(DESTDIR)$(MANDIR)/man7/$(MANM_EQN).7
430 $(INSTALL_MAN) tbl.7 $(DESTDIR)$(MANDIR)/man7/$(MANM_TBL).7
431 $(INSTALL_MAN) mandoc_char.7 $(DESTDIR)$(MANDIR)/man7
432 $(INSTALL_MAN) makewhatis.8 \
433 $(DESTDIR)$(MANDIR)/man8/$(BINM_MAKEWHATIS).8
435 lib-install: libmandoc.a
436 mkdir -p $(DESTDIR)$(LIBDIR)
437 mkdir -p $(DESTDIR)$(INCLUDEDIR)
438 mkdir -p $(DESTDIR)$(MANDIR)/man3
439 $(INSTALL_LIB) libmandoc.a $(DESTDIR)$(LIBDIR)
440 $(INSTALL_LIB) eqn.h man.h mandoc.h mandoc_aux.h mandoc_parse.h \
441 mdoc.h roff.h tbl.h $(DESTDIR)$(INCLUDEDIR)
442 $(INSTALL_MAN) mandoc.3 mandoc_escape.3 mandoc_malloc.3 \
443 mansearch.3 mchars_alloc.3 tbl.3 $(DESTDIR)$(MANDIR)/man3
446 mkdir -p $(DESTDIR)$(CGIBINDIR)
447 mkdir -p $(DESTDIR)$(HTDOCDIR)
448 $(INSTALL_PROGRAM) man.cgi $(DESTDIR)$(CGIBINDIR)
449 $(INSTALL_DATA) mandoc.css $(DESTDIR)$(HTDOCDIR)
451 catman-install: mandocd catman
452 mkdir -p $(DESTDIR)$(SBINDIR)
453 mkdir -p $(DESTDIR)$(MANDIR)/man8
454 $(INSTALL_PROGRAM) mandocd $(DESTDIR)$(SBINDIR)
455 $(INSTALL_PROGRAM) catman $(DESTDIR)$(SBINDIR)/$(BINM_CATMAN)
456 $(INSTALL_MAN) mandocd.8 $(DESTDIR)$(MANDIR)/man8
457 $(INSTALL_MAN) catman.8 $(DESTDIR)$(MANDIR)/man8/$(BINM_CATMAN).8
460 rm -f $(DESTDIR)$(BINDIR)/mandoc
461 rm -f $(DESTDIR)$(BINDIR)/demandoc
462 rm -f $(DESTDIR)$(BINDIR)/$(BINM_SOELIM)
463 rm -f $(DESTDIR)$(BINDIR)/$(BINM_MAN)
464 rm -f $(DESTDIR)$(BINDIR)/$(BINM_APROPOS)
465 rm -f $(DESTDIR)$(BINDIR)/$(BINM_WHATIS)
466 rm -f $(DESTDIR)$(SBINDIR)/$(BINM_MAKEWHATIS)
467 rm -f $(DESTDIR)$(MANDIR)/man1/mandoc.1
468 rm -f $(DESTDIR)$(MANDIR)/man1/demandoc.1
469 rm -f $(DESTDIR)$(MANDIR)/man1/$(BINM_SOELIM).1
470 rm -f $(DESTDIR)$(MANDIR)/man1/$(BINM_MAN).1
471 rm -f $(DESTDIR)$(MANDIR)/man1/$(BINM_APROPOS).1
472 rm -f $(DESTDIR)$(MANDIR)/man1/$(BINM_WHATIS).1
473 rm -f $(DESTDIR)$(MANDIR)/man5/$(MANM_MANCONF).5
474 rm -f $(DESTDIR)$(MANDIR)/man5/mandoc.db.5
475 rm -f $(DESTDIR)$(MANDIR)/man7/$(MANM_MAN).7
476 rm -f $(DESTDIR)$(MANDIR)/man7/$(MANM_MDOC).7
477 rm -f $(DESTDIR)$(MANDIR)/man7/$(MANM_ROFF).7
478 rm -f $(DESTDIR)$(MANDIR)/man7/$(MANM_EQN).7
479 rm -f $(DESTDIR)$(MANDIR)/man7/$(MANM_TBL).7
480 rm -f $(DESTDIR)$(MANDIR)/man7/mandoc_char.7
481 rm -f $(DESTDIR)$(MANDIR)/man8/$(BINM_MAKEWHATIS).8
482 rm -f $(DESTDIR)$(CGIBINDIR)/man.cgi
483 rm -f $(DESTDIR)$(HTDOCDIR)/mandoc.css
484 rm -f $(DESTDIR)$(SBINDIR)/mandocd
485 rm -f $(DESTDIR)$(SBINDIR)/$(BINM_CATMAN)
486 rm -f $(DESTDIR)$(MANDIR)/man8/mandocd.8
487 rm -f $(DESTDIR)$(MANDIR)/man8/$(BINM_CATMAN).8
488 rm -f $(DESTDIR)$(LIBDIR)/libmandoc.a
489 rm -f $(DESTDIR)$(MANDIR)/man3/mandoc.3
490 rm -f $(DESTDIR)$(MANDIR)/man3/mandoc_escape.3
491 rm -f $(DESTDIR)$(MANDIR)/man3/mandoc_malloc.3
492 rm -f $(DESTDIR)$(MANDIR)/man3/mansearch.3
493 rm -f $(DESTDIR)$(MANDIR)/man3/mchars_alloc.3
494 rm -f $(DESTDIR)$(MANDIR)/man3/tbl.3
495 rm -f $(DESTDIR)$(INCLUDEDIR)/eqn.h
496 rm -f $(DESTDIR)$(INCLUDEDIR)/man.h
497 rm -f $(DESTDIR)$(INCLUDEDIR)/mandoc.h
498 rm -f $(DESTDIR)$(INCLUDEDIR)/mandoc_aux.h
499 rm -f $(DESTDIR)$(INCLUDEDIR)/mandoc_parse.h
500 rm -f $(DESTDIR)$(INCLUDEDIR)/mdoc.h
501 rm -f $(DESTDIR)$(INCLUDEDIR)/roff.h
502 rm -f $(DESTDIR)$(INCLUDEDIR)/tbl.h
503 [ ! -e $(DESTDIR)$(INCLUDEDIR) ] || rmdir $(DESTDIR)$(INCLUDEDIR)
506 cd regress && ./regress.pl
509 cd regress && ./regress.pl . clean
511 Makefile.local config.h: configure $(TESTSRCS)
512 @echo "$@ is out of date; please run ./configure"
515 libmandoc.a: $(MANDOC_COBJS) $(LIBMANDOC_OBJS)
516 ar rs $@ $(MANDOC_COBJS) $(LIBMANDOC_OBJS)
518 mandoc: $(MAIN_OBJS) libmandoc.a
519 $(CC) -o $@ $(LDFLAGS) $(MAIN_OBJS) libmandoc.a $(LDADD)
524 man.cgi: $(CGI_OBJS) libmandoc.a
525 $(CC) $(STATIC) -o $@ $(LDFLAGS) $(CGI_OBJS) libmandoc.a $(LDADD)
527 mandocd: $(MANDOCD_OBJS) libmandoc.a
528 $(CC) -o $@ $(LDFLAGS) $(MANDOCD_OBJS) libmandoc.a $(LDADD)
530 catman: catman.o libmandoc.a
531 $(CC) -o $@ $(LDFLAGS) catman.o libmandoc.a $(LDADD)
533 demandoc: $(DEMANDOC_OBJS) libmandoc.a
534 $(CC) -o $@ $(LDFLAGS) $(DEMANDOC_OBJS) libmandoc.a $(LDADD)
536 soelim: $(SOELIM_COBJS) soelim.o
537 $(CC) -o $@ $(LDFLAGS) $(SOELIM_COBJS) soelim.o
539 # --- maintainer targets ---
542 $(INSTALL_DATA) mandoc.css $(HTDOCDIR)
543 $(INSTALL_DATA) $(WWW_MANS) $(HTDOCDIR)/man
544 $(INSTALL_DATA) $(WWW_INCS) $(HTDOCDIR)/includes
548 mkdep -f Makefile.tmp1 $(CFLAGS) $(SRCS)
549 perl -e 'undef $$/; $$_ = <>; s|/usr/include/\S+||g; \
550 s|\\\n||g; s| +| |g; s| $$||mg; print;' \
551 Makefile.tmp1 > Makefile.tmp2
553 mv Makefile.tmp2 Makefile.depend
564 @find regress ! -type d ! -type f
565 @find regress -type f \
568 ! -name Makefile.inc \
570 ! -name '*.out_ascii' \
571 ! -name '*.out_utf8' \
572 ! -name '*.out_html' \
573 ! -name '*.out_markdown' \
574 ! -name '*.out_lint' \
575 ! -path regress/regress.pl \
576 ! -path regress/regress.pl.1
578 dist: mandoc-$(VERSION).sha256
580 mandoc-$(VERSION).sha256: mandoc-$(VERSION).tar.gz
581 sha256 mandoc-$(VERSION).tar.gz > $@
583 mandoc-$(VERSION).tar.gz: $(DISTFILES)
584 ls regress/*/*/*.mandoc_* && exit 1 || true
585 mkdir -p .dist/mandoc-$(VERSION)/
586 $(INSTALL) -m 0644 $(DISTFILES) .dist/mandoc-$(VERSION)
587 cp -pR regress .dist/mandoc-$(VERSION)
588 find .dist/mandoc-$(VERSION)/regress \
589 -type d -name CVS -print0 | xargs -0 rm -rf
590 chmod 755 .dist/mandoc-$(VERSION)/configure
591 ( cd .dist/ && tar zcf ../$@ mandoc-$(VERSION) )
595 $(INSTALL_DATA) mandoc-$(VERSION).tar.gz mandoc-$(VERSION).sha256 \
596 $(HTDOCDIR)/snapshots
598 # === SUFFIX RULES =====================================================
600 .SUFFIXES: .1 .3 .5 .7 .8 .h
601 .SUFFIXES: .1.html .3.html .5.html .7.html .8.html .h.html
606 .1.1.html .3.3.html .5.5.html .7.7.html .8.8.html: mandoc
607 mandoc -Thtml -Wwarning,stop \
608 -O 'style=/mandoc.css,man=/man/%N.%S.html;https://man.openbsd.org/%N.%S,includes=/includes/%I.html' \