1 # $Id: Makefile,v 1.526 2018/12/13 11:55:46 schwarze Exp $
3 # Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
4 # Copyright (c) 2011, 2013-2018 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 \
42 test-recallocarray.c \
69 compat_reallocarray.c \
70 compat_recallocarray.c \
137 DISTFILES = INSTALL \
148 compat_stringlist.h \
150 configure.local.example \
213 LIBMAN_OBJS = man.o \
217 LIBMDOC_OBJS = att.o \
226 LIBROFF_OBJS = eqn.o \
234 LIBMANDOC_OBJS = $(LIBMAN_OBJS) \
246 COMPAT_OBJS = compat_err.o \
254 compat_reallocarray.o \
255 compat_recallocarray.o \
256 compat_strcasestr.o \
264 MANDOC_HTML_OBJS = eqn_html.o \
271 MANDOC_TERM_OBJS = eqn_term.o \
291 MAIN_OBJS = $(MANDOC_HTML_OBJS) \
293 $(MANDOC_TERM_OBJS) \
304 CGI_OBJS = $(MANDOC_HTML_OBJS) \
309 MANDOCD_OBJS = $(MANDOC_HTML_OBJS) \
310 $(MANDOC_TERM_OBJS) \
315 DEMANDOC_OBJS = demandoc.o
317 SOELIM_OBJS = soelim.o \
321 compat_reallocarray.o \
324 WWW_MANS = apropos.1.html \
332 mandoc_escape.3.html \
333 mandoc_headers.3.html \
335 mandoc_malloc.3.html \
337 mchars_alloc.3.html \
352 WWW_INCS = eqn.h.html \
357 mandoc_parse.h.html \
363 # === USER CONFIGURATION ===============================================
365 include Makefile.local
367 # === DEPENDENCY HANDLING ==============================================
369 all: mandoc demandoc soelim $(BUILD_TARGETS) Makefile.local
371 install: base-install $(INSTALL_TARGETS)
373 www: $(WWW_MANS) $(WWW_INCS)
375 $(WWW_MANS) $(WWW_INCS): mandoc
377 .PHONY: base-install cgi-install install www-install
378 .PHONY: clean distclean depend
380 include Makefile.depend
382 # === TARGETS CONTAINING SHELL COMMANDS ================================
385 rm -f Makefile.local config.h config.h.old config.log config.log.old
388 rm -f libmandoc.a $(LIBMANDOC_OBJS) $(COMPAT_OBJS)
389 rm -f mandoc $(MAIN_OBJS)
390 rm -f man.cgi $(CGI_OBJS)
391 rm -f mandocd catman catman.o $(MANDOCD_OBJS)
392 rm -f demandoc $(DEMANDOC_OBJS)
393 rm -f soelim $(SOELIM_OBJS)
394 rm -f $(WWW_MANS) $(WWW_INCS) mandoc*.tar.gz mandoc*.sha256
397 base-install: mandoc demandoc soelim
398 mkdir -p $(DESTDIR)$(BINDIR)
399 mkdir -p $(DESTDIR)$(SBINDIR)
400 mkdir -p $(DESTDIR)$(MANDIR)/man1
401 mkdir -p $(DESTDIR)$(MANDIR)/man5
402 mkdir -p $(DESTDIR)$(MANDIR)/man7
403 mkdir -p $(DESTDIR)$(MANDIR)/man8
404 $(INSTALL_PROGRAM) mandoc demandoc $(DESTDIR)$(BINDIR)
405 $(INSTALL_PROGRAM) soelim $(DESTDIR)$(BINDIR)/$(BINM_SOELIM)
406 cd $(DESTDIR)$(BINDIR) && $(LN) mandoc $(BINM_MAN)
407 cd $(DESTDIR)$(BINDIR) && $(LN) mandoc $(BINM_APROPOS)
408 cd $(DESTDIR)$(BINDIR) && $(LN) mandoc $(BINM_WHATIS)
409 cd $(DESTDIR)$(SBINDIR) && \
410 $(LN) ${BIN_FROM_SBIN}/mandoc $(BINM_MAKEWHATIS)
411 $(INSTALL_MAN) mandoc.1 demandoc.1 $(DESTDIR)$(MANDIR)/man1
412 $(INSTALL_MAN) soelim.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_SOELIM).1
413 $(INSTALL_MAN) man.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_MAN).1
414 $(INSTALL_MAN) apropos.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_APROPOS).1
415 cd $(DESTDIR)$(MANDIR)/man1 && $(LN) $(BINM_APROPOS).1 $(BINM_WHATIS).1
416 $(INSTALL_MAN) man.conf.5 $(DESTDIR)$(MANDIR)/man5/$(MANM_MANCONF).5
417 $(INSTALL_MAN) mandoc.db.5 $(DESTDIR)$(MANDIR)/man5
418 $(INSTALL_MAN) man.7 $(DESTDIR)$(MANDIR)/man7/$(MANM_MAN).7
419 $(INSTALL_MAN) mdoc.7 $(DESTDIR)$(MANDIR)/man7/$(MANM_MDOC).7
420 $(INSTALL_MAN) roff.7 $(DESTDIR)$(MANDIR)/man7/$(MANM_ROFF).7
421 $(INSTALL_MAN) eqn.7 $(DESTDIR)$(MANDIR)/man7/$(MANM_EQN).7
422 $(INSTALL_MAN) tbl.7 $(DESTDIR)$(MANDIR)/man7/$(MANM_TBL).7
423 $(INSTALL_MAN) mandoc_char.7 $(DESTDIR)$(MANDIR)/man7
424 $(INSTALL_MAN) makewhatis.8 \
425 $(DESTDIR)$(MANDIR)/man8/$(BINM_MAKEWHATIS).8
427 lib-install: libmandoc.a
428 mkdir -p $(DESTDIR)$(LIBDIR)
429 mkdir -p $(DESTDIR)$(INCLUDEDIR)
430 mkdir -p $(DESTDIR)$(MANDIR)/man3
431 $(INSTALL_LIB) libmandoc.a $(DESTDIR)$(LIBDIR)
432 $(INSTALL_LIB) eqn.h man.h mandoc.h mandoc_aux.h mandoc_parse.h \
433 mdoc.h roff.h tbl.h $(DESTDIR)$(INCLUDEDIR)
434 $(INSTALL_MAN) mandoc.3 mandoc_escape.3 mandoc_malloc.3 \
435 mansearch.3 mchars_alloc.3 tbl.3 $(DESTDIR)$(MANDIR)/man3
438 mkdir -p $(DESTDIR)$(CGIBINDIR)
439 mkdir -p $(DESTDIR)$(HTDOCDIR)
440 $(INSTALL_PROGRAM) man.cgi $(DESTDIR)$(CGIBINDIR)
441 $(INSTALL_DATA) mandoc.css $(DESTDIR)$(HTDOCDIR)
443 catman-install: mandocd catman
444 mkdir -p $(DESTDIR)$(SBINDIR)
445 mkdir -p $(DESTDIR)$(MANDIR)/man8
446 $(INSTALL_PROGRAM) mandocd $(DESTDIR)$(SBINDIR)
447 $(INSTALL_PROGRAM) catman $(DESTDIR)$(SBINDIR)/$(BINM_CATMAN)
448 $(INSTALL_MAN) mandocd.8 $(DESTDIR)$(MANDIR)/man8
449 $(INSTALL_MAN) catman.8 $(DESTDIR)$(MANDIR)/man8/$(BINM_CATMAN).8
452 rm -f $(DESTDIR)$(BINDIR)/mandoc
453 rm -f $(DESTDIR)$(BINDIR)/demandoc
454 rm -f $(DESTDIR)$(BINDIR)/$(BINM_SOELIM)
455 rm -f $(DESTDIR)$(BINDIR)/$(BINM_MAN)
456 rm -f $(DESTDIR)$(BINDIR)/$(BINM_APROPOS)
457 rm -f $(DESTDIR)$(BINDIR)/$(BINM_WHATIS)
458 rm -f $(DESTDIR)$(SBINDIR)/$(BINM_MAKEWHATIS)
459 rm -f $(DESTDIR)$(MANDIR)/man1/mandoc.1
460 rm -f $(DESTDIR)$(MANDIR)/man1/demandoc.1
461 rm -f $(DESTDIR)$(MANDIR)/man1/$(BINM_SOELIM).1
462 rm -f $(DESTDIR)$(MANDIR)/man1/$(BINM_MAN).1
463 rm -f $(DESTDIR)$(MANDIR)/man1/$(BINM_APROPOS).1
464 rm -f $(DESTDIR)$(MANDIR)/man1/$(BINM_WHATIS).1
465 rm -f $(DESTDIR)$(MANDIR)/man5/$(MANM_MANCONF).5
466 rm -f $(DESTDIR)$(MANDIR)/man5/mandoc.db.5
467 rm -f $(DESTDIR)$(MANDIR)/man7/$(MANM_MAN).7
468 rm -f $(DESTDIR)$(MANDIR)/man7/$(MANM_MDOC).7
469 rm -f $(DESTDIR)$(MANDIR)/man7/$(MANM_ROFF).7
470 rm -f $(DESTDIR)$(MANDIR)/man7/$(MANM_EQN).7
471 rm -f $(DESTDIR)$(MANDIR)/man7/$(MANM_TBL).7
472 rm -f $(DESTDIR)$(MANDIR)/man7/mandoc_char.7
473 rm -f $(DESTDIR)$(MANDIR)/man8/$(BINM_MAKEWHATIS).8
474 rm -f $(DESTDIR)$(CGIBINDIR)/man.cgi
475 rm -f $(DESTDIR)$(HTDOCDIR)/mandoc.css
476 rm -f $(DESTDIR)$(SBINDIR)/mandocd
477 rm -f $(DESTDIR)$(SBINDIR)/$(BINM_CATMAN)
478 rm -f $(DESTDIR)$(MANDIR)/man8/mandocd.8
479 rm -f $(DESTDIR)$(MANDIR)/man8/$(BINM_CATMAN).8
480 rm -f $(DESTDIR)$(LIBDIR)/libmandoc.a
481 rm -f $(DESTDIR)$(MANDIR)/man3/mandoc.3
482 rm -f $(DESTDIR)$(MANDIR)/man3/mandoc_escape.3
483 rm -f $(DESTDIR)$(MANDIR)/man3/mandoc_malloc.3
484 rm -f $(DESTDIR)$(MANDIR)/man3/mansearch.3
485 rm -f $(DESTDIR)$(MANDIR)/man3/mchars_alloc.3
486 rm -f $(DESTDIR)$(MANDIR)/man3/tbl.3
487 rm -f $(DESTDIR)$(INCLUDEDIR)/eqn.h
488 rm -f $(DESTDIR)$(INCLUDEDIR)/man.h
489 rm -f $(DESTDIR)$(INCLUDEDIR)/mandoc.h
490 rm -f $(DESTDIR)$(INCLUDEDIR)/mandoc_aux.h
491 rm -f $(DESTDIR)$(INCLUDEDIR)/mandoc_parse.h
492 rm -f $(DESTDIR)$(INCLUDEDIR)/mdoc.h
493 rm -f $(DESTDIR)$(INCLUDEDIR)/roff.h
494 rm -f $(DESTDIR)$(INCLUDEDIR)/tbl.h
495 [ ! -e $(DESTDIR)$(INCLUDEDIR) ] || rmdir $(DESTDIR)$(INCLUDEDIR)
498 cd regress && ./regress.pl
501 cd regress && ./regress.pl . clean
503 Makefile.local config.h: configure $(TESTSRCS)
504 @echo "$@ is out of date; please run ./configure"
507 libmandoc.a: $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
508 ar rs $@ $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
510 mandoc: $(MAIN_OBJS) libmandoc.a
511 $(CC) -o $@ $(LDFLAGS) $(MAIN_OBJS) libmandoc.a $(LDADD)
513 man.cgi: $(CGI_OBJS) libmandoc.a
514 $(CC) $(STATIC) -o $@ $(LDFLAGS) $(CGI_OBJS) libmandoc.a $(LDADD)
516 mandocd: $(MANDOCD_OBJS) libmandoc.a
517 $(CC) -o $@ $(LDFLAGS) $(MANDOCD_OBJS) libmandoc.a $(LDADD)
519 catman: catman.o libmandoc.a
520 $(CC) -o $@ $(LDFLAGS) catman.o libmandoc.a $(LDADD)
522 demandoc: $(DEMANDOC_OBJS) libmandoc.a
523 $(CC) -o $@ $(LDFLAGS) $(DEMANDOC_OBJS) libmandoc.a $(LDADD)
525 soelim: $(SOELIM_OBJS)
526 $(CC) -o $@ $(LDFLAGS) $(SOELIM_OBJS)
528 # --- maintainer targets ---
531 $(INSTALL_DATA) mandoc.css $(HTDOCDIR)
532 $(INSTALL_DATA) $(WWW_MANS) $(HTDOCDIR)/man
533 $(INSTALL_DATA) $(WWW_INCS) $(HTDOCDIR)/includes
536 mkdep -f Makefile.depend $(CFLAGS) $(SRCS)
537 perl -e 'undef $$/; $$_ = <>; s|/usr/include/\S+||g; \
538 s|\\\n||g; s| +| |g; s| $$||mg; print;' \
539 Makefile.depend > Makefile.tmp
540 mv Makefile.tmp Makefile.depend
551 @find regress ! -type d ! -type f
552 @find regress -type f \
555 ! -name Makefile.inc \
557 ! -name '*.out_ascii' \
558 ! -name '*.out_utf8' \
559 ! -name '*.out_html' \
560 ! -name '*.out_markdown' \
561 ! -name '*.out_lint' \
562 ! -path regress/regress.pl \
563 ! -path regress/regress.pl.1
565 dist: mandoc-$(VERSION).sha256
567 mandoc-$(VERSION).sha256: mandoc-$(VERSION).tar.gz
568 sha256 mandoc-$(VERSION).tar.gz > $@
570 mandoc-$(VERSION).tar.gz: $(DISTFILES)
571 ls regress/*/*/*.mandoc_* && exit 1 || true
572 mkdir -p .dist/mandoc-$(VERSION)/
573 $(INSTALL) -m 0644 $(DISTFILES) .dist/mandoc-$(VERSION)
574 cp -pR regress .dist/mandoc-$(VERSION)
575 find .dist/mandoc-$(VERSION)/regress \
576 -type d -name CVS -print0 | xargs -0 rm -rf
577 chmod 755 .dist/mandoc-$(VERSION)/configure
578 ( cd .dist/ && tar zcf ../$@ mandoc-$(VERSION) )
581 # === SUFFIX RULES =====================================================
583 .SUFFIXES: .1 .3 .5 .7 .8 .h
584 .SUFFIXES: .1.html .3.html .5.html .7.html .8.html .h.html
589 .1.1.html .3.3.html .5.5.html .7.7.html .8.8.html: mandoc
591 style=/mandoc.css,man=/man/%N.%S.html,includes=/includes/%I.html \