1 # $Id: Makefile,v 1.530 2019/03/06 16:08:41 schwarze Exp $
3 # Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
4 # Copyright (c) 2011, 2013-2019 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 \
41 test-recallocarray.c \
70 compat_reallocarray.c \
71 compat_recallocarray.c \
139 DISTFILES = INSTALL \
150 compat_stringlist.h \
152 configure.local.example \
215 LIBMAN_OBJS = man.o \
219 LIBMDOC_OBJS = att.o \
228 LIBROFF_OBJS = eqn.o \
236 LIBMANDOC_OBJS = $(LIBMAN_OBJS) \
250 COMPAT_OBJS = compat_err.o \
258 compat_reallocarray.o \
259 compat_recallocarray.o \
260 compat_strcasestr.o \
268 MANDOC_HTML_OBJS = eqn_html.o \
275 MANDOC_TERM_OBJS = eqn_term.o \
295 MAIN_OBJS = $(MANDOC_HTML_OBJS) \
297 $(MANDOC_TERM_OBJS) \
308 CGI_OBJS = $(MANDOC_HTML_OBJS) \
313 MANDOCD_OBJS = $(MANDOC_HTML_OBJS) \
314 $(MANDOC_TERM_OBJS) \
319 DEMANDOC_OBJS = demandoc.o
321 SOELIM_OBJS = soelim.o \
325 compat_reallocarray.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 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) $(COMPAT_OBJS)
396 rm -f mandoc $(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_OBJS)
401 rm -f $(WWW_MANS) $(WWW_INCS) mandoc*.tar.gz mandoc*.sha256
404 base-install: mandoc demandoc soelim
405 mkdir -p $(DESTDIR)$(BINDIR)
406 mkdir -p $(DESTDIR)$(SBINDIR)
407 mkdir -p $(DESTDIR)$(MANDIR)/man1
408 mkdir -p $(DESTDIR)$(MANDIR)/man5
409 mkdir -p $(DESTDIR)$(MANDIR)/man7
410 mkdir -p $(DESTDIR)$(MANDIR)/man8
411 $(INSTALL_PROGRAM) mandoc demandoc $(DESTDIR)$(BINDIR)
412 $(INSTALL_PROGRAM) soelim $(DESTDIR)$(BINDIR)/$(BINM_SOELIM)
413 cd $(DESTDIR)$(BINDIR) && $(LN) mandoc $(BINM_MAN)
414 cd $(DESTDIR)$(BINDIR) && $(LN) mandoc $(BINM_APROPOS)
415 cd $(DESTDIR)$(BINDIR) && $(LN) mandoc $(BINM_WHATIS)
416 cd $(DESTDIR)$(SBINDIR) && \
417 $(LN) ${BIN_FROM_SBIN}/mandoc $(BINM_MAKEWHATIS)
418 $(INSTALL_MAN) mandoc.1 demandoc.1 $(DESTDIR)$(MANDIR)/man1
419 $(INSTALL_MAN) soelim.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_SOELIM).1
420 $(INSTALL_MAN) man.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_MAN).1
421 $(INSTALL_MAN) apropos.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_APROPOS).1
422 cd $(DESTDIR)$(MANDIR)/man1 && $(LN) $(BINM_APROPOS).1 $(BINM_WHATIS).1
423 $(INSTALL_MAN) man.conf.5 $(DESTDIR)$(MANDIR)/man5/$(MANM_MANCONF).5
424 $(INSTALL_MAN) mandoc.db.5 $(DESTDIR)$(MANDIR)/man5
425 $(INSTALL_MAN) man.7 $(DESTDIR)$(MANDIR)/man7/$(MANM_MAN).7
426 $(INSTALL_MAN) mdoc.7 $(DESTDIR)$(MANDIR)/man7/$(MANM_MDOC).7
427 $(INSTALL_MAN) roff.7 $(DESTDIR)$(MANDIR)/man7/$(MANM_ROFF).7
428 $(INSTALL_MAN) eqn.7 $(DESTDIR)$(MANDIR)/man7/$(MANM_EQN).7
429 $(INSTALL_MAN) tbl.7 $(DESTDIR)$(MANDIR)/man7/$(MANM_TBL).7
430 $(INSTALL_MAN) mandoc_char.7 $(DESTDIR)$(MANDIR)/man7
431 $(INSTALL_MAN) makewhatis.8 \
432 $(DESTDIR)$(MANDIR)/man8/$(BINM_MAKEWHATIS).8
434 lib-install: libmandoc.a
435 mkdir -p $(DESTDIR)$(LIBDIR)
436 mkdir -p $(DESTDIR)$(INCLUDEDIR)
437 mkdir -p $(DESTDIR)$(MANDIR)/man3
438 $(INSTALL_LIB) libmandoc.a $(DESTDIR)$(LIBDIR)
439 $(INSTALL_LIB) eqn.h man.h mandoc.h mandoc_aux.h mandoc_parse.h \
440 mdoc.h roff.h tbl.h $(DESTDIR)$(INCLUDEDIR)
441 $(INSTALL_MAN) mandoc.3 mandoc_escape.3 mandoc_malloc.3 \
442 mansearch.3 mchars_alloc.3 tbl.3 $(DESTDIR)$(MANDIR)/man3
445 mkdir -p $(DESTDIR)$(CGIBINDIR)
446 mkdir -p $(DESTDIR)$(HTDOCDIR)
447 $(INSTALL_PROGRAM) man.cgi $(DESTDIR)$(CGIBINDIR)
448 $(INSTALL_DATA) mandoc.css $(DESTDIR)$(HTDOCDIR)
450 catman-install: mandocd catman
451 mkdir -p $(DESTDIR)$(SBINDIR)
452 mkdir -p $(DESTDIR)$(MANDIR)/man8
453 $(INSTALL_PROGRAM) mandocd $(DESTDIR)$(SBINDIR)
454 $(INSTALL_PROGRAM) catman $(DESTDIR)$(SBINDIR)/$(BINM_CATMAN)
455 $(INSTALL_MAN) mandocd.8 $(DESTDIR)$(MANDIR)/man8
456 $(INSTALL_MAN) catman.8 $(DESTDIR)$(MANDIR)/man8/$(BINM_CATMAN).8
459 rm -f $(DESTDIR)$(BINDIR)/mandoc
460 rm -f $(DESTDIR)$(BINDIR)/demandoc
461 rm -f $(DESTDIR)$(BINDIR)/$(BINM_SOELIM)
462 rm -f $(DESTDIR)$(BINDIR)/$(BINM_MAN)
463 rm -f $(DESTDIR)$(BINDIR)/$(BINM_APROPOS)
464 rm -f $(DESTDIR)$(BINDIR)/$(BINM_WHATIS)
465 rm -f $(DESTDIR)$(SBINDIR)/$(BINM_MAKEWHATIS)
466 rm -f $(DESTDIR)$(MANDIR)/man1/mandoc.1
467 rm -f $(DESTDIR)$(MANDIR)/man1/demandoc.1
468 rm -f $(DESTDIR)$(MANDIR)/man1/$(BINM_SOELIM).1
469 rm -f $(DESTDIR)$(MANDIR)/man1/$(BINM_MAN).1
470 rm -f $(DESTDIR)$(MANDIR)/man1/$(BINM_APROPOS).1
471 rm -f $(DESTDIR)$(MANDIR)/man1/$(BINM_WHATIS).1
472 rm -f $(DESTDIR)$(MANDIR)/man5/$(MANM_MANCONF).5
473 rm -f $(DESTDIR)$(MANDIR)/man5/mandoc.db.5
474 rm -f $(DESTDIR)$(MANDIR)/man7/$(MANM_MAN).7
475 rm -f $(DESTDIR)$(MANDIR)/man7/$(MANM_MDOC).7
476 rm -f $(DESTDIR)$(MANDIR)/man7/$(MANM_ROFF).7
477 rm -f $(DESTDIR)$(MANDIR)/man7/$(MANM_EQN).7
478 rm -f $(DESTDIR)$(MANDIR)/man7/$(MANM_TBL).7
479 rm -f $(DESTDIR)$(MANDIR)/man7/mandoc_char.7
480 rm -f $(DESTDIR)$(MANDIR)/man8/$(BINM_MAKEWHATIS).8
481 rm -f $(DESTDIR)$(CGIBINDIR)/man.cgi
482 rm -f $(DESTDIR)$(HTDOCDIR)/mandoc.css
483 rm -f $(DESTDIR)$(SBINDIR)/mandocd
484 rm -f $(DESTDIR)$(SBINDIR)/$(BINM_CATMAN)
485 rm -f $(DESTDIR)$(MANDIR)/man8/mandocd.8
486 rm -f $(DESTDIR)$(MANDIR)/man8/$(BINM_CATMAN).8
487 rm -f $(DESTDIR)$(LIBDIR)/libmandoc.a
488 rm -f $(DESTDIR)$(MANDIR)/man3/mandoc.3
489 rm -f $(DESTDIR)$(MANDIR)/man3/mandoc_escape.3
490 rm -f $(DESTDIR)$(MANDIR)/man3/mandoc_malloc.3
491 rm -f $(DESTDIR)$(MANDIR)/man3/mansearch.3
492 rm -f $(DESTDIR)$(MANDIR)/man3/mchars_alloc.3
493 rm -f $(DESTDIR)$(MANDIR)/man3/tbl.3
494 rm -f $(DESTDIR)$(INCLUDEDIR)/eqn.h
495 rm -f $(DESTDIR)$(INCLUDEDIR)/man.h
496 rm -f $(DESTDIR)$(INCLUDEDIR)/mandoc.h
497 rm -f $(DESTDIR)$(INCLUDEDIR)/mandoc_aux.h
498 rm -f $(DESTDIR)$(INCLUDEDIR)/mandoc_parse.h
499 rm -f $(DESTDIR)$(INCLUDEDIR)/mdoc.h
500 rm -f $(DESTDIR)$(INCLUDEDIR)/roff.h
501 rm -f $(DESTDIR)$(INCLUDEDIR)/tbl.h
502 [ ! -e $(DESTDIR)$(INCLUDEDIR) ] || rmdir $(DESTDIR)$(INCLUDEDIR)
505 cd regress && ./regress.pl
508 cd regress && ./regress.pl . clean
510 Makefile.local config.h: configure $(TESTSRCS)
511 @echo "$@ is out of date; please run ./configure"
514 libmandoc.a: $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
515 ar rs $@ $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
517 mandoc: $(MAIN_OBJS) libmandoc.a
518 $(CC) -o $@ $(LDFLAGS) $(MAIN_OBJS) libmandoc.a $(LDADD)
520 man.cgi: $(CGI_OBJS) libmandoc.a
521 $(CC) $(STATIC) -o $@ $(LDFLAGS) $(CGI_OBJS) libmandoc.a $(LDADD)
523 mandocd: $(MANDOCD_OBJS) libmandoc.a
524 $(CC) -o $@ $(LDFLAGS) $(MANDOCD_OBJS) libmandoc.a $(LDADD)
526 catman: catman.o libmandoc.a
527 $(CC) -o $@ $(LDFLAGS) catman.o libmandoc.a $(LDADD)
529 demandoc: $(DEMANDOC_OBJS) libmandoc.a
530 $(CC) -o $@ $(LDFLAGS) $(DEMANDOC_OBJS) libmandoc.a $(LDADD)
532 soelim: $(SOELIM_OBJS)
533 $(CC) -o $@ $(LDFLAGS) $(SOELIM_OBJS)
535 # --- maintainer targets ---
538 $(INSTALL_DATA) mandoc.css $(HTDOCDIR)
539 $(INSTALL_DATA) $(WWW_MANS) $(HTDOCDIR)/man
540 $(INSTALL_DATA) $(WWW_INCS) $(HTDOCDIR)/includes
543 mkdep -f Makefile.depend $(CFLAGS) $(SRCS)
544 perl -e 'undef $$/; $$_ = <>; s|/usr/include/\S+||g; \
545 s|\\\n||g; s| +| |g; s| $$||mg; print;' \
546 Makefile.depend > Makefile.tmp
547 mv Makefile.tmp Makefile.depend
558 @find regress ! -type d ! -type f
559 @find regress -type f \
562 ! -name Makefile.inc \
564 ! -name '*.out_ascii' \
565 ! -name '*.out_utf8' \
566 ! -name '*.out_html' \
567 ! -name '*.out_markdown' \
568 ! -name '*.out_lint' \
569 ! -path regress/regress.pl \
570 ! -path regress/regress.pl.1
572 dist: mandoc-$(VERSION).sha256
574 mandoc-$(VERSION).sha256: mandoc-$(VERSION).tar.gz
575 sha256 mandoc-$(VERSION).tar.gz > $@
577 mandoc-$(VERSION).tar.gz: $(DISTFILES)
578 ls regress/*/*/*.mandoc_* && exit 1 || true
579 mkdir -p .dist/mandoc-$(VERSION)/
580 $(INSTALL) -m 0644 $(DISTFILES) .dist/mandoc-$(VERSION)
581 cp -pR regress .dist/mandoc-$(VERSION)
582 find .dist/mandoc-$(VERSION)/regress \
583 -type d -name CVS -print0 | xargs -0 rm -rf
584 chmod 755 .dist/mandoc-$(VERSION)/configure
585 ( cd .dist/ && tar zcf ../$@ mandoc-$(VERSION) )
589 $(INSTALL_DATA) mandoc-$(VERSION).tar.gz mandoc-$(VERSION).sha256 \
590 $(HTDOCDIR)/snapshots
592 # === SUFFIX RULES =====================================================
594 .SUFFIXES: .1 .3 .5 .7 .8 .h
595 .SUFFIXES: .1.html .3.html .5.html .7.html .8.html .h.html
600 .1.1.html .3.3.html .5.5.html .7.7.html .8.8.html: mandoc
601 mandoc -Thtml -Wwarning,stop \
602 -O 'style=/mandoc.css,man=/man/%N.%S.html;https://man.openbsd.org/%N.%S,includes=/includes/%I.html' \