1 # $Id: Makefile,v 1.535 2020/06/22 20:00:38 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-attribute.c \
25 test-dirent-namlen.c \
42 test-recallocarray.c \
71 compat_reallocarray.c \
72 compat_recallocarray.c \
141 DISTFILES = INSTALL \
152 compat_stringlist.h \
154 configure.local.example \
218 LIBMAN_OBJS = man.o \
222 LIBMDOC_OBJS = att.o \
231 LIBROFF_OBJS = eqn.o \
239 LIBMANDOC_OBJS = $(LIBMAN_OBJS) \
254 ALL_COBJS = compat_err.o \
262 compat_reallocarray.o \
263 compat_recallocarray.o \
264 compat_strcasestr.o \
265 compat_stringlist.o \
273 MANDOC_HTML_OBJS = eqn_html.o \
280 MANDOC_TERM_OBJS = eqn_term.o \
301 MAIN_OBJS = $(MANDOC_HTML_OBJS) \
303 $(MANDOC_TERM_OBJS) \
313 CGI_OBJS = $(MANDOC_HTML_OBJS) \
318 MANDOCD_OBJS = $(MANDOC_HTML_OBJS) \
319 $(MANDOC_TERM_OBJS) \
323 DEMANDOC_OBJS = demandoc.o
325 WWW_MANS = apropos.1.html \
333 mandoc_escape.3.html \
334 mandoc_headers.3.html \
336 mandoc_malloc.3.html \
338 mchars_alloc.3.html \
353 WWW_INCS = eqn.h.html \
359 mandoc_parse.h.html \
367 # === USER CONFIGURATION ===============================================
369 include Makefile.local
371 # === DEPENDENCY HANDLING ==============================================
373 all: mandoc demandoc soelim $(BUILD_TARGETS) Makefile.local
375 install: base-install $(INSTALL_TARGETS)
377 www: $(WWW_MANS) $(WWW_INCS)
379 $(WWW_MANS) $(WWW_INCS): mandoc
381 .PHONY: base-install cgi-install install www-install
382 .PHONY: clean distclean depend
384 include Makefile.depend
386 # === TARGETS CONTAINING SHELL COMMANDS ================================
389 rm -f Makefile.local config.h config.h.old config.log config.log.old
392 rm -f libmandoc.a $(LIBMANDOC_OBJS) $(ALL_COBJS)
393 rm -f mandoc man $(MAIN_OBJS)
394 rm -f man.cgi $(CGI_OBJS)
395 rm -f mandocd catman catman.o $(MANDOCD_OBJS)
396 rm -f demandoc $(DEMANDOC_OBJS)
397 rm -f soelim soelim.o
398 rm -f $(WWW_MANS) $(WWW_INCS) mandoc*.tar.gz mandoc*.sha256
399 rm -f Makefile.tmp1 Makefile.tmp2
402 base-install: mandoc demandoc soelim
403 mkdir -p $(DESTDIR)$(BINDIR)
404 mkdir -p $(DESTDIR)$(SBINDIR)
405 mkdir -p $(DESTDIR)$(MANDIR)/man1
406 mkdir -p $(DESTDIR)$(MANDIR)/man5
407 mkdir -p $(DESTDIR)$(MANDIR)/man7
408 mkdir -p $(DESTDIR)$(MANDIR)/man8
409 $(INSTALL_PROGRAM) mandoc demandoc $(DESTDIR)$(BINDIR)
410 $(INSTALL_PROGRAM) soelim $(DESTDIR)$(BINDIR)/$(BINM_SOELIM)
411 cd $(DESTDIR)$(BINDIR) && $(LN) mandoc $(BINM_MAN)
412 cd $(DESTDIR)$(BINDIR) && $(LN) mandoc $(BINM_APROPOS)
413 cd $(DESTDIR)$(BINDIR) && $(LN) mandoc $(BINM_WHATIS)
414 cd $(DESTDIR)$(SBINDIR) && \
415 $(LN) ${BIN_FROM_SBIN}/mandoc $(BINM_MAKEWHATIS)
416 $(INSTALL_MAN) mandoc.1 demandoc.1 $(DESTDIR)$(MANDIR)/man1
417 $(INSTALL_MAN) soelim.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_SOELIM).1
418 $(INSTALL_MAN) man.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_MAN).1
419 $(INSTALL_MAN) apropos.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_APROPOS).1
420 cd $(DESTDIR)$(MANDIR)/man1 && $(LN) $(BINM_APROPOS).1 $(BINM_WHATIS).1
421 $(INSTALL_MAN) man.conf.5 $(DESTDIR)$(MANDIR)/man5/$(MANM_MANCONF).5
422 $(INSTALL_MAN) mandoc.db.5 $(DESTDIR)$(MANDIR)/man5
423 $(INSTALL_MAN) man.7 $(DESTDIR)$(MANDIR)/man7/$(MANM_MAN).7
424 $(INSTALL_MAN) mdoc.7 $(DESTDIR)$(MANDIR)/man7/$(MANM_MDOC).7
425 $(INSTALL_MAN) roff.7 $(DESTDIR)$(MANDIR)/man7/$(MANM_ROFF).7
426 $(INSTALL_MAN) eqn.7 $(DESTDIR)$(MANDIR)/man7/$(MANM_EQN).7
427 $(INSTALL_MAN) tbl.7 $(DESTDIR)$(MANDIR)/man7/$(MANM_TBL).7
428 $(INSTALL_MAN) mandoc_char.7 $(DESTDIR)$(MANDIR)/man7
429 $(INSTALL_MAN) makewhatis.8 \
430 $(DESTDIR)$(MANDIR)/man8/$(BINM_MAKEWHATIS).8
432 lib-install: libmandoc.a
433 mkdir -p $(DESTDIR)$(LIBDIR)
434 mkdir -p $(DESTDIR)$(INCLUDEDIR)
435 mkdir -p $(DESTDIR)$(MANDIR)/man3
436 $(INSTALL_LIB) libmandoc.a $(DESTDIR)$(LIBDIR)
437 $(INSTALL_LIB) eqn.h man.h mandoc.h mandoc_aux.h mandoc_parse.h \
438 mdoc.h roff.h tbl.h $(DESTDIR)$(INCLUDEDIR)
439 $(INSTALL_MAN) mandoc.3 mandoc_escape.3 mandoc_malloc.3 \
440 mansearch.3 mchars_alloc.3 tbl.3 $(DESTDIR)$(MANDIR)/man3
443 mkdir -p $(DESTDIR)$(CGIBINDIR)
444 mkdir -p $(DESTDIR)$(HTDOCDIR)
445 $(INSTALL_PROGRAM) man.cgi $(DESTDIR)$(CGIBINDIR)
446 $(INSTALL_DATA) mandoc.css $(DESTDIR)$(HTDOCDIR)
448 catman-install: mandocd catman
449 mkdir -p $(DESTDIR)$(SBINDIR)
450 mkdir -p $(DESTDIR)$(MANDIR)/man8
451 $(INSTALL_PROGRAM) mandocd $(DESTDIR)$(SBINDIR)
452 $(INSTALL_PROGRAM) catman $(DESTDIR)$(SBINDIR)/$(BINM_CATMAN)
453 $(INSTALL_MAN) mandocd.8 $(DESTDIR)$(MANDIR)/man8
454 $(INSTALL_MAN) catman.8 $(DESTDIR)$(MANDIR)/man8/$(BINM_CATMAN).8
457 rm -f $(DESTDIR)$(BINDIR)/mandoc
458 rm -f $(DESTDIR)$(BINDIR)/demandoc
459 rm -f $(DESTDIR)$(BINDIR)/$(BINM_SOELIM)
460 rm -f $(DESTDIR)$(BINDIR)/$(BINM_MAN)
461 rm -f $(DESTDIR)$(BINDIR)/$(BINM_APROPOS)
462 rm -f $(DESTDIR)$(BINDIR)/$(BINM_WHATIS)
463 rm -f $(DESTDIR)$(SBINDIR)/$(BINM_MAKEWHATIS)
464 rm -f $(DESTDIR)$(MANDIR)/man1/mandoc.1
465 rm -f $(DESTDIR)$(MANDIR)/man1/demandoc.1
466 rm -f $(DESTDIR)$(MANDIR)/man1/$(BINM_SOELIM).1
467 rm -f $(DESTDIR)$(MANDIR)/man1/$(BINM_MAN).1
468 rm -f $(DESTDIR)$(MANDIR)/man1/$(BINM_APROPOS).1
469 rm -f $(DESTDIR)$(MANDIR)/man1/$(BINM_WHATIS).1
470 rm -f $(DESTDIR)$(MANDIR)/man5/$(MANM_MANCONF).5
471 rm -f $(DESTDIR)$(MANDIR)/man5/mandoc.db.5
472 rm -f $(DESTDIR)$(MANDIR)/man7/$(MANM_MAN).7
473 rm -f $(DESTDIR)$(MANDIR)/man7/$(MANM_MDOC).7
474 rm -f $(DESTDIR)$(MANDIR)/man7/$(MANM_ROFF).7
475 rm -f $(DESTDIR)$(MANDIR)/man7/$(MANM_EQN).7
476 rm -f $(DESTDIR)$(MANDIR)/man7/$(MANM_TBL).7
477 rm -f $(DESTDIR)$(MANDIR)/man7/mandoc_char.7
478 rm -f $(DESTDIR)$(MANDIR)/man8/$(BINM_MAKEWHATIS).8
479 rm -f $(DESTDIR)$(CGIBINDIR)/man.cgi
480 rm -f $(DESTDIR)$(HTDOCDIR)/mandoc.css
481 rm -f $(DESTDIR)$(SBINDIR)/mandocd
482 rm -f $(DESTDIR)$(SBINDIR)/$(BINM_CATMAN)
483 rm -f $(DESTDIR)$(MANDIR)/man8/mandocd.8
484 rm -f $(DESTDIR)$(MANDIR)/man8/$(BINM_CATMAN).8
485 rm -f $(DESTDIR)$(LIBDIR)/libmandoc.a
486 rm -f $(DESTDIR)$(MANDIR)/man3/mandoc.3
487 rm -f $(DESTDIR)$(MANDIR)/man3/mandoc_escape.3
488 rm -f $(DESTDIR)$(MANDIR)/man3/mandoc_malloc.3
489 rm -f $(DESTDIR)$(MANDIR)/man3/mansearch.3
490 rm -f $(DESTDIR)$(MANDIR)/man3/mchars_alloc.3
491 rm -f $(DESTDIR)$(MANDIR)/man3/tbl.3
492 rm -f $(DESTDIR)$(INCLUDEDIR)/eqn.h
493 rm -f $(DESTDIR)$(INCLUDEDIR)/man.h
494 rm -f $(DESTDIR)$(INCLUDEDIR)/mandoc.h
495 rm -f $(DESTDIR)$(INCLUDEDIR)/mandoc_aux.h
496 rm -f $(DESTDIR)$(INCLUDEDIR)/mandoc_parse.h
497 rm -f $(DESTDIR)$(INCLUDEDIR)/mdoc.h
498 rm -f $(DESTDIR)$(INCLUDEDIR)/roff.h
499 rm -f $(DESTDIR)$(INCLUDEDIR)/tbl.h
500 [ ! -e $(DESTDIR)$(INCLUDEDIR) ] || rmdir $(DESTDIR)$(INCLUDEDIR)
503 cd regress && ./regress.pl
506 cd regress && ./regress.pl . clean
508 Makefile.local config.h: configure $(TESTSRCS)
509 @echo "$@ is out of date; please run ./configure"
512 libmandoc.a: $(MANDOC_COBJS) $(LIBMANDOC_OBJS)
513 ar rs $@ $(MANDOC_COBJS) $(LIBMANDOC_OBJS)
515 mandoc: $(MAIN_OBJS) libmandoc.a
516 $(CC) -o $@ $(LDFLAGS) $(MAIN_OBJS) libmandoc.a $(LDADD)
521 man.cgi: $(CGI_OBJS) libmandoc.a
522 $(CC) $(STATIC) -o $@ $(LDFLAGS) $(CGI_OBJS) libmandoc.a $(LDADD)
524 mandocd: $(MANDOCD_OBJS) libmandoc.a
525 $(CC) -o $@ $(LDFLAGS) $(MANDOCD_OBJS) libmandoc.a $(LDADD)
527 catman: catman.o libmandoc.a
528 $(CC) -o $@ $(LDFLAGS) catman.o libmandoc.a $(LDADD)
530 demandoc: $(DEMANDOC_OBJS) libmandoc.a
531 $(CC) -o $@ $(LDFLAGS) $(DEMANDOC_OBJS) libmandoc.a $(LDADD)
533 soelim: $(SOELIM_COBJS) soelim.o
534 $(CC) -o $@ $(LDFLAGS) $(SOELIM_COBJS) soelim.o
536 # --- maintainer targets ---
539 $(INSTALL_DATA) mandoc.css $(HTDOCDIR)
540 $(INSTALL_DATA) $(WWW_MANS) $(HTDOCDIR)/man
541 $(INSTALL_DATA) $(WWW_INCS) $(HTDOCDIR)/includes
545 mkdep -f Makefile.tmp1 $(CFLAGS) $(SRCS)
546 perl -e 'undef $$/; $$_ = <>; s|/usr/include/\S+||g; \
547 s|\\\n||g; s| +| |g; s| $$||mg; print;' \
548 Makefile.tmp1 > Makefile.tmp2
550 mv Makefile.tmp2 Makefile.depend
561 @find regress ! -type d ! -type f
562 @find regress -type f \
565 ! -name Makefile.inc \
567 ! -name '*.out_ascii' \
568 ! -name '*.out_utf8' \
569 ! -name '*.out_html' \
570 ! -name '*.out_markdown' \
571 ! -name '*.out_lint' \
572 ! -path regress/regress.pl \
573 ! -path regress/regress.pl.1
575 dist: mandoc-$(VERSION).sha256
577 mandoc-$(VERSION).sha256: mandoc-$(VERSION).tar.gz
578 sha256 mandoc-$(VERSION).tar.gz > $@
580 mandoc-$(VERSION).tar.gz: $(DISTFILES)
581 ls regress/*/*/*.mandoc_* && exit 1 || true
582 mkdir -p .dist/mandoc-$(VERSION)/
583 $(INSTALL) -m 0644 $(DISTFILES) .dist/mandoc-$(VERSION)
584 cp -pR regress .dist/mandoc-$(VERSION)
585 find .dist/mandoc-$(VERSION)/regress \
586 -type d -name CVS -print0 | xargs -0 rm -rf
587 chmod 755 .dist/mandoc-$(VERSION)/configure
588 ( cd .dist/ && tar zcf ../$@ mandoc-$(VERSION) )
592 $(INSTALL_DATA) mandoc-$(VERSION).tar.gz mandoc-$(VERSION).sha256 \
593 $(HTDOCDIR)/snapshots
595 # === SUFFIX RULES =====================================================
597 .SUFFIXES: .1 .3 .5 .7 .8 .h
598 .SUFFIXES: .1.html .3.html .5.html .7.html .8.html .h.html
603 .1.1.html .3.3.html .5.5.html .7.7.html .8.8.html: mandoc
604 mandoc -Thtml -Wwarning,stop \
605 -O 'style=/mandoc.css,man=/man/%N.%S.html;https://man.openbsd.org/%N.%S,includes=/includes/%I.html' \