1 # $Id: Makefile,v 1.542 2022/05/19 15:37:47 schwarze Exp $
3 # Copyright (c) 2011, 2013-2022 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 \
145 DISTFILES = INSTALL \
156 compat_stringlist.h \
158 configure.local.example \
224 LIBMAN_OBJS = man.o \
228 LIBMDOC_OBJS = att.o \
237 LIBROFF_OBJS = eqn.o \
246 LIBMANDOC_OBJS = $(LIBMAN_OBJS) \
262 ALL_COBJS = compat_err.o \
271 compat_reallocarray.o \
272 compat_recallocarray.o \
273 compat_strcasestr.o \
274 compat_stringlist.o \
282 MANDOC_HTML_OBJS = eqn_html.o \
289 MANDOC_TERM_OBJS = eqn_term.o \
310 MAIN_OBJS = $(MANDOC_HTML_OBJS) \
312 $(MANDOC_TERM_OBJS) \
322 CGI_OBJS = $(MANDOC_HTML_OBJS) \
327 MANDOCD_OBJS = $(MANDOC_HTML_OBJS) \
328 $(MANDOC_TERM_OBJS) \
332 DEMANDOC_OBJS = demandoc.o
334 WWW_MANS = apropos.1.html \
342 mandoc_dbg_init.3.html \
343 mandoc_escape.3.html \
344 mandoc_headers.3.html \
346 mandoc_malloc.3.html \
348 mchars_alloc.3.html \
363 WWW_INCS = eqn.h.html \
369 mandoc_parse.h.html \
377 # === USER CONFIGURATION ===============================================
379 include Makefile.local
381 # === DEPENDENCY HANDLING ==============================================
383 all: mandoc man demandoc soelim $(BUILD_TARGETS) Makefile.local
385 install: base-install $(INSTALL_TARGETS)
387 www: $(WWW_MANS) $(WWW_INCS)
389 $(WWW_MANS) $(WWW_INCS): mandoc
391 .PHONY: base-install cgi-install install www-install
392 .PHONY: clean distclean depend
394 include Makefile.depend
396 # === TARGETS CONTAINING SHELL COMMANDS ================================
399 rm -f Makefile.local config.h config.h.old config.log config.log.old
402 rm -f libmandoc.a $(LIBMANDOC_OBJS) $(ALL_COBJS)
403 rm -f mandoc man $(MAIN_OBJS)
404 rm -f man.cgi $(CGI_OBJS)
405 rm -f mandocd catman catman.o $(MANDOCD_OBJS)
406 rm -f demandoc $(DEMANDOC_OBJS)
407 rm -f soelim soelim.o
408 rm -f $(WWW_MANS) $(WWW_INCS) mandoc*.tar.gz mandoc*.sha256
409 rm -f Makefile.tmp1 Makefile.tmp2
412 base-install: mandoc demandoc soelim
413 mkdir -p $(DESTDIR)$(BINDIR)
414 mkdir -p $(DESTDIR)$(SBINDIR)
415 mkdir -p $(DESTDIR)$(MANDIR)/man1
416 mkdir -p $(DESTDIR)$(MANDIR)/man5
417 mkdir -p $(DESTDIR)$(MANDIR)/man7
418 mkdir -p $(DESTDIR)$(MANDIR)/man8
419 $(INSTALL_PROGRAM) mandoc demandoc $(DESTDIR)$(BINDIR)
420 $(INSTALL_PROGRAM) soelim $(DESTDIR)$(BINDIR)/$(BINM_SOELIM)
421 cd $(DESTDIR)$(BINDIR) && $(LN) mandoc $(BINM_MAN)
422 cd $(DESTDIR)$(BINDIR) && $(LN) mandoc $(BINM_APROPOS)
423 cd $(DESTDIR)$(BINDIR) && $(LN) mandoc $(BINM_WHATIS)
424 cd $(DESTDIR)$(SBINDIR) && \
425 $(LN) ${BIN_FROM_SBIN}/mandoc $(BINM_MAKEWHATIS)
426 $(INSTALL_MAN) mandoc.1 demandoc.1 $(DESTDIR)$(MANDIR)/man1
427 $(INSTALL_MAN) soelim.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_SOELIM).1
428 $(INSTALL_MAN) man.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_MAN).1
429 $(INSTALL_MAN) apropos.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_APROPOS).1
430 cd $(DESTDIR)$(MANDIR)/man1 && $(LN) $(BINM_APROPOS).1 $(BINM_WHATIS).1
431 $(INSTALL_MAN) man.conf.5 $(DESTDIR)$(MANDIR)/man5/$(MANM_MANCONF).5
432 $(INSTALL_MAN) mandoc.db.5 $(DESTDIR)$(MANDIR)/man5
433 $(INSTALL_MAN) man.7 $(DESTDIR)$(MANDIR)/man7/$(MANM_MAN).7
434 $(INSTALL_MAN) mdoc.7 $(DESTDIR)$(MANDIR)/man7/$(MANM_MDOC).7
435 $(INSTALL_MAN) roff.7 $(DESTDIR)$(MANDIR)/man7/$(MANM_ROFF).7
436 $(INSTALL_MAN) eqn.7 $(DESTDIR)$(MANDIR)/man7/$(MANM_EQN).7
437 $(INSTALL_MAN) tbl.7 $(DESTDIR)$(MANDIR)/man7/$(MANM_TBL).7
438 $(INSTALL_MAN) mandoc_char.7 $(DESTDIR)$(MANDIR)/man7
439 $(INSTALL_MAN) makewhatis.8 \
440 $(DESTDIR)$(MANDIR)/man8/$(BINM_MAKEWHATIS).8
442 lib-install: libmandoc.a
443 mkdir -p $(DESTDIR)$(LIBDIR)
444 mkdir -p $(DESTDIR)$(INCLUDEDIR)
445 mkdir -p $(DESTDIR)$(MANDIR)/man3
446 $(INSTALL_LIB) libmandoc.a $(DESTDIR)$(LIBDIR)
447 $(INSTALL_LIB) eqn.h man.h mandoc.h mandoc_aux.h mandoc_parse.h \
448 mdoc.h roff.h tbl.h $(DESTDIR)$(INCLUDEDIR)
449 $(INSTALL_MAN) mandoc.3 mandoc_escape.3 mandoc_malloc.3 \
450 mansearch.3 mchars_alloc.3 tbl.3 $(DESTDIR)$(MANDIR)/man3
453 mkdir -p $(DESTDIR)$(CGIBINDIR)
454 mkdir -p $(DESTDIR)$(HTDOCDIR)
455 $(INSTALL_PROGRAM) man.cgi $(DESTDIR)$(CGIBINDIR)
456 $(INSTALL_DATA) mandoc.css $(DESTDIR)$(HTDOCDIR)
458 catman-install: mandocd catman
459 mkdir -p $(DESTDIR)$(SBINDIR)
460 mkdir -p $(DESTDIR)$(MANDIR)/man8
461 $(INSTALL_PROGRAM) mandocd $(DESTDIR)$(SBINDIR)
462 $(INSTALL_PROGRAM) catman $(DESTDIR)$(SBINDIR)/$(BINM_CATMAN)
463 $(INSTALL_MAN) mandocd.8 $(DESTDIR)$(MANDIR)/man8
464 $(INSTALL_MAN) catman.8 $(DESTDIR)$(MANDIR)/man8/$(BINM_CATMAN).8
467 rm -f $(DESTDIR)$(BINDIR)/mandoc
468 rm -f $(DESTDIR)$(BINDIR)/demandoc
469 rm -f $(DESTDIR)$(BINDIR)/$(BINM_SOELIM)
470 rm -f $(DESTDIR)$(BINDIR)/$(BINM_MAN)
471 rm -f $(DESTDIR)$(BINDIR)/$(BINM_APROPOS)
472 rm -f $(DESTDIR)$(BINDIR)/$(BINM_WHATIS)
473 rm -f $(DESTDIR)$(SBINDIR)/$(BINM_MAKEWHATIS)
474 rm -f $(DESTDIR)$(MANDIR)/man1/mandoc.1
475 rm -f $(DESTDIR)$(MANDIR)/man1/demandoc.1
476 rm -f $(DESTDIR)$(MANDIR)/man1/$(BINM_SOELIM).1
477 rm -f $(DESTDIR)$(MANDIR)/man1/$(BINM_MAN).1
478 rm -f $(DESTDIR)$(MANDIR)/man1/$(BINM_APROPOS).1
479 rm -f $(DESTDIR)$(MANDIR)/man1/$(BINM_WHATIS).1
480 rm -f $(DESTDIR)$(MANDIR)/man5/$(MANM_MANCONF).5
481 rm -f $(DESTDIR)$(MANDIR)/man5/mandoc.db.5
482 rm -f $(DESTDIR)$(MANDIR)/man7/$(MANM_MAN).7
483 rm -f $(DESTDIR)$(MANDIR)/man7/$(MANM_MDOC).7
484 rm -f $(DESTDIR)$(MANDIR)/man7/$(MANM_ROFF).7
485 rm -f $(DESTDIR)$(MANDIR)/man7/$(MANM_EQN).7
486 rm -f $(DESTDIR)$(MANDIR)/man7/$(MANM_TBL).7
487 rm -f $(DESTDIR)$(MANDIR)/man7/mandoc_char.7
488 rm -f $(DESTDIR)$(MANDIR)/man8/$(BINM_MAKEWHATIS).8
489 rm -f $(DESTDIR)$(CGIBINDIR)/man.cgi
490 rm -f $(DESTDIR)$(HTDOCDIR)/mandoc.css
491 rm -f $(DESTDIR)$(SBINDIR)/mandocd
492 rm -f $(DESTDIR)$(SBINDIR)/$(BINM_CATMAN)
493 rm -f $(DESTDIR)$(MANDIR)/man8/mandocd.8
494 rm -f $(DESTDIR)$(MANDIR)/man8/$(BINM_CATMAN).8
495 rm -f $(DESTDIR)$(LIBDIR)/libmandoc.a
496 rm -f $(DESTDIR)$(MANDIR)/man3/mandoc.3
497 rm -f $(DESTDIR)$(MANDIR)/man3/mandoc_escape.3
498 rm -f $(DESTDIR)$(MANDIR)/man3/mandoc_malloc.3
499 rm -f $(DESTDIR)$(MANDIR)/man3/mansearch.3
500 rm -f $(DESTDIR)$(MANDIR)/man3/mchars_alloc.3
501 rm -f $(DESTDIR)$(MANDIR)/man3/tbl.3
502 rm -f $(DESTDIR)$(INCLUDEDIR)/eqn.h
503 rm -f $(DESTDIR)$(INCLUDEDIR)/man.h
504 rm -f $(DESTDIR)$(INCLUDEDIR)/mandoc.h
505 rm -f $(DESTDIR)$(INCLUDEDIR)/mandoc_aux.h
506 rm -f $(DESTDIR)$(INCLUDEDIR)/mandoc_parse.h
507 rm -f $(DESTDIR)$(INCLUDEDIR)/mdoc.h
508 rm -f $(DESTDIR)$(INCLUDEDIR)/roff.h
509 rm -f $(DESTDIR)$(INCLUDEDIR)/tbl.h
510 [ ! -e $(DESTDIR)$(INCLUDEDIR) ] || rmdir $(DESTDIR)$(INCLUDEDIR)
513 cd regress && ./regress.pl
516 cd regress && ./regress.pl . clean
518 Makefile.local config.h: configure $(TESTSRCS)
519 @echo "$@ is out of date; please run ./configure"
522 libmandoc.a: $(MANDOC_COBJS) $(LIBMANDOC_OBJS)
523 $(AR) rs $@ $(MANDOC_COBJS) $(LIBMANDOC_OBJS)
525 mandoc: $(MAIN_OBJS) libmandoc.a
526 $(CC) -o $@ $(LDFLAGS) $(MAIN_OBJS) libmandoc.a $(LDADD)
531 man.cgi: $(CGI_OBJS) libmandoc.a
532 $(CC) $(STATIC) -o $@ $(LDFLAGS) $(CGI_OBJS) libmandoc.a $(LDADD)
534 mandocd: $(MANDOCD_OBJS) libmandoc.a
535 $(CC) -o $@ $(LDFLAGS) $(MANDOCD_OBJS) libmandoc.a $(LDADD)
537 catman: catman.o libmandoc.a
538 $(CC) -o $@ $(LDFLAGS) catman.o libmandoc.a $(LDADD)
540 demandoc: $(DEMANDOC_OBJS) libmandoc.a
541 $(CC) -o $@ $(LDFLAGS) $(DEMANDOC_OBJS) libmandoc.a $(LDADD)
543 soelim: $(SOELIM_COBJS) soelim.o
544 $(CC) -o $@ $(LDFLAGS) $(SOELIM_COBJS) soelim.o
546 # --- maintainer targets ---
549 $(INSTALL_DATA) mandoc.css $(HTDOCDIR)
550 $(INSTALL_DATA) $(WWW_MANS) $(HTDOCDIR)/man
551 $(INSTALL_DATA) $(WWW_INCS) $(HTDOCDIR)/includes
555 mkdep -f Makefile.tmp1 $(CFLAGS) $(SRCS)
556 perl -e 'undef $$/; $$_ = <>; s|/usr/include/\S+||g; \
557 s|\\\n||g; s| +| |g; s| $$||mg; print;' \
558 Makefile.tmp1 > Makefile.tmp2
560 mv Makefile.tmp2 Makefile.depend
571 @find regress ! -type d ! -type f
572 @find regress -type f \
575 ! -name Makefile.inc \
577 ! -name '*.out_ascii' \
578 ! -name '*.out_utf8' \
579 ! -name '*.out_html' \
580 ! -name '*.out_markdown' \
581 ! -name '*.out_lint' \
582 ! -path regress/regress.pl \
583 ! -path regress/regress.pl.1
585 dist: mandoc-$(VERSION).sha256
587 mandoc-$(VERSION).sha256: mandoc-$(VERSION).tar.gz
588 sha256 mandoc-$(VERSION).tar.gz > $@
590 mandoc-$(VERSION).tar.gz: $(DISTFILES)
591 ls regress/*/*/*.mandoc_* && exit 1 || true
592 mkdir -p .dist/mandoc-$(VERSION)/
593 $(INSTALL) -m 0644 $(DISTFILES) .dist/mandoc-$(VERSION)
594 cp -pR regress .dist/mandoc-$(VERSION)
595 find .dist/mandoc-$(VERSION)/regress \
596 -type d -name CVS -print0 | xargs -0 rm -rf
597 chmod 755 .dist/mandoc-$(VERSION)/configure
598 ( cd .dist/ && tar zcf ../$@ mandoc-$(VERSION) )
602 $(INSTALL_DATA) mandoc-$(VERSION).tar.gz mandoc-$(VERSION).sha256 \
603 $(HTDOCDIR)/snapshots
605 # === SUFFIX RULES =====================================================
607 .SUFFIXES: .1 .3 .5 .7 .8 .h
608 .SUFFIXES: .1.html .3.html .5.html .7.html .8.html .h.html
613 .1.1.html .3.3.html .5.5.html .7.7.html .8.8.html:
614 ./mandoc -Thtml -Wwarning,stop \
615 -O 'style=/mandoc.css,man=/man/%N.%S.html;https://man.openbsd.org/%N.%S,includes=/includes/%I.html' \