1 # $Id: Makefile,v 1.532 2020/03/13 17:31:44 schwarze Exp $
3 # Copyright (c) 2011, 2013-2020 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-be32toh.c \
24 test-dirent-namlen.c \
41 test-recallocarray.c \
70 compat_reallocarray.c \
71 compat_recallocarray.c \
140 DISTFILES = INSTALL \
151 compat_stringlist.h \
153 configure.local.example \
217 LIBMAN_OBJS = man.o \
221 LIBMDOC_OBJS = att.o \
230 LIBROFF_OBJS = eqn.o \
238 LIBMANDOC_OBJS = $(LIBMAN_OBJS) \
253 COMPAT_OBJS = compat_err.o \
261 compat_reallocarray.o \
262 compat_recallocarray.o \
263 compat_strcasestr.o \
271 MANDOC_HTML_OBJS = eqn_html.o \
278 MANDOC_TERM_OBJS = eqn_term.o \
299 MAIN_OBJS = $(MANDOC_HTML_OBJS) \
301 $(MANDOC_TERM_OBJS) \
311 CGI_OBJS = $(MANDOC_HTML_OBJS) \
316 MANDOCD_OBJS = $(MANDOC_HTML_OBJS) \
317 $(MANDOC_TERM_OBJS) \
321 DEMANDOC_OBJS = demandoc.o
323 SOELIM_OBJS = soelim.o \
327 compat_reallocarray.o \
330 WWW_MANS = apropos.1.html \
338 mandoc_escape.3.html \
339 mandoc_headers.3.html \
341 mandoc_malloc.3.html \
343 mchars_alloc.3.html \
358 WWW_INCS = eqn.h.html \
364 mandoc_parse.h.html \
372 # === USER CONFIGURATION ===============================================
374 include Makefile.local
376 # === DEPENDENCY HANDLING ==============================================
378 all: mandoc demandoc soelim $(BUILD_TARGETS) Makefile.local
380 install: base-install $(INSTALL_TARGETS)
382 www: $(WWW_MANS) $(WWW_INCS)
384 $(WWW_MANS) $(WWW_INCS): mandoc
386 .PHONY: base-install cgi-install install www-install
387 .PHONY: clean distclean depend
389 include Makefile.depend
391 # === TARGETS CONTAINING SHELL COMMANDS ================================
394 rm -f Makefile.local config.h config.h.old config.log config.log.old
397 rm -f libmandoc.a $(LIBMANDOC_OBJS) $(COMPAT_OBJS)
398 rm -f mandoc man $(MAIN_OBJS)
399 rm -f man.cgi $(CGI_OBJS)
400 rm -f mandocd catman catman.o $(MANDOCD_OBJS)
401 rm -f demandoc $(DEMANDOC_OBJS)
402 rm -f soelim $(SOELIM_OBJS)
403 rm -f $(WWW_MANS) $(WWW_INCS) mandoc*.tar.gz mandoc*.sha256
404 rm -f Makefile.tmp1 Makefile.tmp2
407 base-install: mandoc demandoc soelim
408 mkdir -p $(DESTDIR)$(BINDIR)
409 mkdir -p $(DESTDIR)$(SBINDIR)
410 mkdir -p $(DESTDIR)$(MANDIR)/man1
411 mkdir -p $(DESTDIR)$(MANDIR)/man5
412 mkdir -p $(DESTDIR)$(MANDIR)/man7
413 mkdir -p $(DESTDIR)$(MANDIR)/man8
414 $(INSTALL_PROGRAM) mandoc demandoc $(DESTDIR)$(BINDIR)
415 $(INSTALL_PROGRAM) soelim $(DESTDIR)$(BINDIR)/$(BINM_SOELIM)
416 cd $(DESTDIR)$(BINDIR) && $(LN) mandoc $(BINM_MAN)
417 cd $(DESTDIR)$(BINDIR) && $(LN) mandoc $(BINM_APROPOS)
418 cd $(DESTDIR)$(BINDIR) && $(LN) mandoc $(BINM_WHATIS)
419 cd $(DESTDIR)$(SBINDIR) && \
420 $(LN) ${BIN_FROM_SBIN}/mandoc $(BINM_MAKEWHATIS)
421 $(INSTALL_MAN) mandoc.1 demandoc.1 $(DESTDIR)$(MANDIR)/man1
422 $(INSTALL_MAN) soelim.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_SOELIM).1
423 $(INSTALL_MAN) man.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_MAN).1
424 $(INSTALL_MAN) apropos.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_APROPOS).1
425 cd $(DESTDIR)$(MANDIR)/man1 && $(LN) $(BINM_APROPOS).1 $(BINM_WHATIS).1
426 $(INSTALL_MAN) man.conf.5 $(DESTDIR)$(MANDIR)/man5/$(MANM_MANCONF).5
427 $(INSTALL_MAN) mandoc.db.5 $(DESTDIR)$(MANDIR)/man5
428 $(INSTALL_MAN) man.7 $(DESTDIR)$(MANDIR)/man7/$(MANM_MAN).7
429 $(INSTALL_MAN) mdoc.7 $(DESTDIR)$(MANDIR)/man7/$(MANM_MDOC).7
430 $(INSTALL_MAN) roff.7 $(DESTDIR)$(MANDIR)/man7/$(MANM_ROFF).7
431 $(INSTALL_MAN) eqn.7 $(DESTDIR)$(MANDIR)/man7/$(MANM_EQN).7
432 $(INSTALL_MAN) tbl.7 $(DESTDIR)$(MANDIR)/man7/$(MANM_TBL).7
433 $(INSTALL_MAN) mandoc_char.7 $(DESTDIR)$(MANDIR)/man7
434 $(INSTALL_MAN) makewhatis.8 \
435 $(DESTDIR)$(MANDIR)/man8/$(BINM_MAKEWHATIS).8
437 lib-install: libmandoc.a
438 mkdir -p $(DESTDIR)$(LIBDIR)
439 mkdir -p $(DESTDIR)$(INCLUDEDIR)
440 mkdir -p $(DESTDIR)$(MANDIR)/man3
441 $(INSTALL_LIB) libmandoc.a $(DESTDIR)$(LIBDIR)
442 $(INSTALL_LIB) eqn.h man.h mandoc.h mandoc_aux.h mandoc_parse.h \
443 mdoc.h roff.h tbl.h $(DESTDIR)$(INCLUDEDIR)
444 $(INSTALL_MAN) mandoc.3 mandoc_escape.3 mandoc_malloc.3 \
445 mansearch.3 mchars_alloc.3 tbl.3 $(DESTDIR)$(MANDIR)/man3
448 mkdir -p $(DESTDIR)$(CGIBINDIR)
449 mkdir -p $(DESTDIR)$(HTDOCDIR)
450 $(INSTALL_PROGRAM) man.cgi $(DESTDIR)$(CGIBINDIR)
451 $(INSTALL_DATA) mandoc.css $(DESTDIR)$(HTDOCDIR)
453 catman-install: mandocd catman
454 mkdir -p $(DESTDIR)$(SBINDIR)
455 mkdir -p $(DESTDIR)$(MANDIR)/man8
456 $(INSTALL_PROGRAM) mandocd $(DESTDIR)$(SBINDIR)
457 $(INSTALL_PROGRAM) catman $(DESTDIR)$(SBINDIR)/$(BINM_CATMAN)
458 $(INSTALL_MAN) mandocd.8 $(DESTDIR)$(MANDIR)/man8
459 $(INSTALL_MAN) catman.8 $(DESTDIR)$(MANDIR)/man8/$(BINM_CATMAN).8
462 rm -f $(DESTDIR)$(BINDIR)/mandoc
463 rm -f $(DESTDIR)$(BINDIR)/demandoc
464 rm -f $(DESTDIR)$(BINDIR)/$(BINM_SOELIM)
465 rm -f $(DESTDIR)$(BINDIR)/$(BINM_MAN)
466 rm -f $(DESTDIR)$(BINDIR)/$(BINM_APROPOS)
467 rm -f $(DESTDIR)$(BINDIR)/$(BINM_WHATIS)
468 rm -f $(DESTDIR)$(SBINDIR)/$(BINM_MAKEWHATIS)
469 rm -f $(DESTDIR)$(MANDIR)/man1/mandoc.1
470 rm -f $(DESTDIR)$(MANDIR)/man1/demandoc.1
471 rm -f $(DESTDIR)$(MANDIR)/man1/$(BINM_SOELIM).1
472 rm -f $(DESTDIR)$(MANDIR)/man1/$(BINM_MAN).1
473 rm -f $(DESTDIR)$(MANDIR)/man1/$(BINM_APROPOS).1
474 rm -f $(DESTDIR)$(MANDIR)/man1/$(BINM_WHATIS).1
475 rm -f $(DESTDIR)$(MANDIR)/man5/$(MANM_MANCONF).5
476 rm -f $(DESTDIR)$(MANDIR)/man5/mandoc.db.5
477 rm -f $(DESTDIR)$(MANDIR)/man7/$(MANM_MAN).7
478 rm -f $(DESTDIR)$(MANDIR)/man7/$(MANM_MDOC).7
479 rm -f $(DESTDIR)$(MANDIR)/man7/$(MANM_ROFF).7
480 rm -f $(DESTDIR)$(MANDIR)/man7/$(MANM_EQN).7
481 rm -f $(DESTDIR)$(MANDIR)/man7/$(MANM_TBL).7
482 rm -f $(DESTDIR)$(MANDIR)/man7/mandoc_char.7
483 rm -f $(DESTDIR)$(MANDIR)/man8/$(BINM_MAKEWHATIS).8
484 rm -f $(DESTDIR)$(CGIBINDIR)/man.cgi
485 rm -f $(DESTDIR)$(HTDOCDIR)/mandoc.css
486 rm -f $(DESTDIR)$(SBINDIR)/mandocd
487 rm -f $(DESTDIR)$(SBINDIR)/$(BINM_CATMAN)
488 rm -f $(DESTDIR)$(MANDIR)/man8/mandocd.8
489 rm -f $(DESTDIR)$(MANDIR)/man8/$(BINM_CATMAN).8
490 rm -f $(DESTDIR)$(LIBDIR)/libmandoc.a
491 rm -f $(DESTDIR)$(MANDIR)/man3/mandoc.3
492 rm -f $(DESTDIR)$(MANDIR)/man3/mandoc_escape.3
493 rm -f $(DESTDIR)$(MANDIR)/man3/mandoc_malloc.3
494 rm -f $(DESTDIR)$(MANDIR)/man3/mansearch.3
495 rm -f $(DESTDIR)$(MANDIR)/man3/mchars_alloc.3
496 rm -f $(DESTDIR)$(MANDIR)/man3/tbl.3
497 rm -f $(DESTDIR)$(INCLUDEDIR)/eqn.h
498 rm -f $(DESTDIR)$(INCLUDEDIR)/man.h
499 rm -f $(DESTDIR)$(INCLUDEDIR)/mandoc.h
500 rm -f $(DESTDIR)$(INCLUDEDIR)/mandoc_aux.h
501 rm -f $(DESTDIR)$(INCLUDEDIR)/mandoc_parse.h
502 rm -f $(DESTDIR)$(INCLUDEDIR)/mdoc.h
503 rm -f $(DESTDIR)$(INCLUDEDIR)/roff.h
504 rm -f $(DESTDIR)$(INCLUDEDIR)/tbl.h
505 [ ! -e $(DESTDIR)$(INCLUDEDIR) ] || rmdir $(DESTDIR)$(INCLUDEDIR)
508 cd regress && ./regress.pl
511 cd regress && ./regress.pl . clean
513 Makefile.local config.h: configure $(TESTSRCS)
514 @echo "$@ is out of date; please run ./configure"
517 libmandoc.a: $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
518 ar rs $@ $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
520 mandoc: $(MAIN_OBJS) libmandoc.a
521 $(CC) -o $@ $(LDFLAGS) $(MAIN_OBJS) libmandoc.a $(LDADD)
526 man.cgi: $(CGI_OBJS) libmandoc.a
527 $(CC) $(STATIC) -o $@ $(LDFLAGS) $(CGI_OBJS) libmandoc.a $(LDADD)
529 mandocd: $(MANDOCD_OBJS) libmandoc.a
530 $(CC) -o $@ $(LDFLAGS) $(MANDOCD_OBJS) libmandoc.a $(LDADD)
532 catman: catman.o libmandoc.a
533 $(CC) -o $@ $(LDFLAGS) catman.o libmandoc.a $(LDADD)
535 demandoc: $(DEMANDOC_OBJS) libmandoc.a
536 $(CC) -o $@ $(LDFLAGS) $(DEMANDOC_OBJS) libmandoc.a $(LDADD)
538 soelim: $(SOELIM_OBJS)
539 $(CC) -o $@ $(LDFLAGS) $(SOELIM_OBJS)
541 # --- maintainer targets ---
544 $(INSTALL_DATA) mandoc.css $(HTDOCDIR)
545 $(INSTALL_DATA) $(WWW_MANS) $(HTDOCDIR)/man
546 $(INSTALL_DATA) $(WWW_INCS) $(HTDOCDIR)/includes
550 mkdep -f Makefile.tmp1 $(CFLAGS) $(SRCS)
551 perl -e 'undef $$/; $$_ = <>; s|/usr/include/\S+||g; \
552 s|\\\n||g; s| +| |g; s| $$||mg; print;' \
553 Makefile.tmp1 > Makefile.tmp2
555 mv Makefile.tmp2 Makefile.depend
566 @find regress ! -type d ! -type f
567 @find regress -type f \
570 ! -name Makefile.inc \
572 ! -name '*.out_ascii' \
573 ! -name '*.out_utf8' \
574 ! -name '*.out_html' \
575 ! -name '*.out_markdown' \
576 ! -name '*.out_lint' \
577 ! -path regress/regress.pl \
578 ! -path regress/regress.pl.1
580 dist: mandoc-$(VERSION).sha256
582 mandoc-$(VERSION).sha256: mandoc-$(VERSION).tar.gz
583 sha256 mandoc-$(VERSION).tar.gz > $@
585 mandoc-$(VERSION).tar.gz: $(DISTFILES)
586 ls regress/*/*/*.mandoc_* && exit 1 || true
587 mkdir -p .dist/mandoc-$(VERSION)/
588 $(INSTALL) -m 0644 $(DISTFILES) .dist/mandoc-$(VERSION)
589 cp -pR regress .dist/mandoc-$(VERSION)
590 find .dist/mandoc-$(VERSION)/regress \
591 -type d -name CVS -print0 | xargs -0 rm -rf
592 chmod 755 .dist/mandoc-$(VERSION)/configure
593 ( cd .dist/ && tar zcf ../$@ mandoc-$(VERSION) )
597 $(INSTALL_DATA) mandoc-$(VERSION).tar.gz mandoc-$(VERSION).sha256 \
598 $(HTDOCDIR)/snapshots
600 # === SUFFIX RULES =====================================================
602 .SUFFIXES: .1 .3 .5 .7 .8 .h
603 .SUFFIXES: .1.html .3.html .5.html .7.html .8.html .h.html
608 .1.1.html .3.3.html .5.5.html .7.7.html .8.8.html: mandoc
609 mandoc -Thtml -Wwarning,stop \
610 -O 'style=/mandoc.css,man=/man/%N.%S.html;https://man.openbsd.org/%N.%S,includes=/includes/%I.html' \