1 # $Id: Makefile,v 1.519 2018/07/31 15:34:00 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 \
209 LIBMAN_OBJS = man.o \
213 LIBMDOC_OBJS = att.o \
222 LIBROFF_OBJS = eqn.o \
230 LIBMANDOC_OBJS = $(LIBMAN_OBJS) \
242 COMPAT_OBJS = compat_err.o \
250 compat_reallocarray.o \
251 compat_recallocarray.o \
252 compat_strcasestr.o \
260 MANDOC_HTML_OBJS = eqn_html.o \
267 MANDOC_TERM_OBJS = eqn_term.o \
287 MAIN_OBJS = $(MANDOC_HTML_OBJS) \
289 $(MANDOC_TERM_OBJS) \
300 CGI_OBJS = $(MANDOC_HTML_OBJS) \
305 MANDOCD_OBJS = $(MANDOC_HTML_OBJS) \
306 $(MANDOC_TERM_OBJS) \
311 DEMANDOC_OBJS = demandoc.o
313 SOELIM_OBJS = soelim.o \
317 compat_reallocarray.o \
320 WWW_MANS = apropos.1.html \
327 mandoc_escape.3.html \
328 mandoc_headers.3.html \
330 mandoc_malloc.3.html \
332 mchars_alloc.3.html \
354 # === USER CONFIGURATION ===============================================
356 include Makefile.local
358 # === DEPENDENCY HANDLING ==============================================
360 all: mandoc demandoc soelim $(BUILD_TARGETS) Makefile.local
362 install: base-install $(INSTALL_TARGETS)
368 .PHONY: base-install cgi-install install www-install
369 .PHONY: clean distclean depend
371 include Makefile.depend
373 # === TARGETS CONTAINING SHELL COMMANDS ================================
376 rm -f Makefile.local config.h config.h.old config.log config.log.old
379 rm -f libmandoc.a $(LIBMANDOC_OBJS) $(COMPAT_OBJS)
380 rm -f mandoc $(MAIN_OBJS)
381 rm -f man.cgi $(CGI_OBJS)
382 rm -f mandocd catman catman.o $(MANDOCD_OBJS)
383 rm -f demandoc $(DEMANDOC_OBJS)
384 rm -f soelim $(SOELIM_OBJS)
385 rm -f $(WWW_MANS) mandoc.tar.gz mandoc.sha256
388 base-install: mandoc demandoc soelim
389 mkdir -p $(DESTDIR)$(BINDIR)
390 mkdir -p $(DESTDIR)$(SBINDIR)
391 mkdir -p $(DESTDIR)$(MANDIR)/man1
392 mkdir -p $(DESTDIR)$(MANDIR)/man5
393 mkdir -p $(DESTDIR)$(MANDIR)/man7
394 mkdir -p $(DESTDIR)$(MANDIR)/man8
395 $(INSTALL_PROGRAM) mandoc demandoc $(DESTDIR)$(BINDIR)
396 $(INSTALL_PROGRAM) soelim $(DESTDIR)$(BINDIR)/$(BINM_SOELIM)
397 cd $(DESTDIR)$(BINDIR) && $(LN) mandoc $(BINM_MAN)
398 cd $(DESTDIR)$(BINDIR) && $(LN) mandoc $(BINM_APROPOS)
399 cd $(DESTDIR)$(BINDIR) && $(LN) mandoc $(BINM_WHATIS)
400 cd $(DESTDIR)$(SBINDIR) && \
401 $(LN) ${BIN_FROM_SBIN}/mandoc $(BINM_MAKEWHATIS)
402 $(INSTALL_MAN) mandoc.1 demandoc.1 $(DESTDIR)$(MANDIR)/man1
403 $(INSTALL_MAN) soelim.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_SOELIM).1
404 $(INSTALL_MAN) man.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_MAN).1
405 $(INSTALL_MAN) apropos.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_APROPOS).1
406 cd $(DESTDIR)$(MANDIR)/man1 && $(LN) $(BINM_APROPOS).1 $(BINM_WHATIS).1
407 $(INSTALL_MAN) man.conf.5 $(DESTDIR)$(MANDIR)/man5/$(MANM_MANCONF).5
408 $(INSTALL_MAN) mandoc.db.5 $(DESTDIR)$(MANDIR)/man5
409 $(INSTALL_MAN) man.7 $(DESTDIR)$(MANDIR)/man7/$(MANM_MAN).7
410 $(INSTALL_MAN) mdoc.7 $(DESTDIR)$(MANDIR)/man7/$(MANM_MDOC).7
411 $(INSTALL_MAN) roff.7 $(DESTDIR)$(MANDIR)/man7/$(MANM_ROFF).7
412 $(INSTALL_MAN) eqn.7 $(DESTDIR)$(MANDIR)/man7/$(MANM_EQN).7
413 $(INSTALL_MAN) tbl.7 $(DESTDIR)$(MANDIR)/man7/$(MANM_TBL).7
414 $(INSTALL_MAN) mandoc_char.7 $(DESTDIR)$(MANDIR)/man7
415 $(INSTALL_MAN) makewhatis.8 \
416 $(DESTDIR)$(MANDIR)/man8/$(BINM_MAKEWHATIS).8
418 lib-install: libmandoc.a
419 mkdir -p $(DESTDIR)$(LIBDIR)
420 mkdir -p $(DESTDIR)$(INCLUDEDIR)
421 mkdir -p $(DESTDIR)$(MANDIR)/man3
422 $(INSTALL_LIB) libmandoc.a $(DESTDIR)$(LIBDIR)
423 $(INSTALL_LIB) man.h mandoc.h mandoc_aux.h mdoc.h roff.h \
424 $(DESTDIR)$(INCLUDEDIR)
425 $(INSTALL_MAN) mandoc.3 mandoc_escape.3 mandoc_malloc.3 \
426 mansearch.3 mchars_alloc.3 tbl.3 $(DESTDIR)$(MANDIR)/man3
429 mkdir -p $(DESTDIR)$(CGIBINDIR)
430 mkdir -p $(DESTDIR)$(HTDOCDIR)
431 $(INSTALL_PROGRAM) man.cgi $(DESTDIR)$(CGIBINDIR)
432 $(INSTALL_DATA) mandoc.css $(DESTDIR)$(HTDOCDIR)
434 catman-install: mandocd catman
435 mkdir -p $(DESTDIR)$(SBINDIR)
436 mkdir -p $(DESTDIR)$(MANDIR)/man8
437 $(INSTALL_PROGRAM) mandocd $(DESTDIR)$(SBINDIR)
438 $(INSTALL_PROGRAM) catman $(DESTDIR)$(SBINDIR)/$(BINM_CATMAN)
439 $(INSTALL_MAN) mandocd.8 $(DESTDIR)$(MANDIR)/man8
440 $(INSTALL_MAN) catman.8 $(DESTDIR)$(MANDIR)/man8/$(BINM_CATMAN).8
443 rm -f $(DESTDIR)$(BINDIR)/mandoc
444 rm -f $(DESTDIR)$(BINDIR)/demandoc
445 rm -f $(DESTDIR)$(BINDIR)/$(BINM_SOELIM)
446 rm -f $(DESTDIR)$(BINDIR)/$(BINM_MAN)
447 rm -f $(DESTDIR)$(BINDIR)/$(BINM_APROPOS)
448 rm -f $(DESTDIR)$(BINDIR)/$(BINM_WHATIS)
449 rm -f $(DESTDIR)$(SBINDIR)/$(BINM_MAKEWHATIS)
450 rm -f $(DESTDIR)$(MANDIR)/man1/mandoc.1
451 rm -f $(DESTDIR)$(MANDIR)/man1/demandoc.1
452 rm -f $(DESTDIR)$(MANDIR)/man1/$(BINM_SOELIM).1
453 rm -f $(DESTDIR)$(MANDIR)/man1/$(BINM_MAN).1
454 rm -f $(DESTDIR)$(MANDIR)/man1/$(BINM_APROPOS).1
455 rm -f $(DESTDIR)$(MANDIR)/man1/$(BINM_WHATIS).1
456 rm -f $(DESTDIR)$(MANDIR)/man5/$(MANM_MANCONF).5
457 rm -f $(DESTDIR)$(MANDIR)/man5/mandoc.db.5
458 rm -f $(DESTDIR)$(MANDIR)/man7/$(MANM_MAN).7
459 rm -f $(DESTDIR)$(MANDIR)/man7/$(MANM_MDOC).7
460 rm -f $(DESTDIR)$(MANDIR)/man7/$(MANM_ROFF).7
461 rm -f $(DESTDIR)$(MANDIR)/man7/$(MANM_EQN).7
462 rm -f $(DESTDIR)$(MANDIR)/man7/$(MANM_TBL).7
463 rm -f $(DESTDIR)$(MANDIR)/man7/mandoc_char.7
464 rm -f $(DESTDIR)$(MANDIR)/man8/$(BINM_MAKEWHATIS).8
465 rm -f $(DESTDIR)$(CGIBINDIR)/man.cgi
466 rm -f $(DESTDIR)$(HTDOCDIR)/mandoc.css
467 rm -f $(DESTDIR)$(SBINDIR)/mandocd
468 rm -f $(DESTDIR)$(SBINDIR)/$(BINM_CATMAN)
469 rm -f $(DESTDIR)$(MANDIR)/man8/mandocd.8
470 rm -f $(DESTDIR)$(MANDIR)/man8/$(BINM_CATMAN).8
471 rm -f $(DESTDIR)$(LIBDIR)/libmandoc.a
472 rm -f $(DESTDIR)$(MANDIR)/man3/mandoc.3
473 rm -f $(DESTDIR)$(MANDIR)/man3/mandoc_escape.3
474 rm -f $(DESTDIR)$(MANDIR)/man3/mandoc_malloc.3
475 rm -f $(DESTDIR)$(MANDIR)/man3/mansearch.3
476 rm -f $(DESTDIR)$(MANDIR)/man3/mchars_alloc.3
477 rm -f $(DESTDIR)$(MANDIR)/man3/tbl.3
478 rm -f $(DESTDIR)$(INCLUDEDIR)/man.h
479 rm -f $(DESTDIR)$(INCLUDEDIR)/mandoc.h
480 rm -f $(DESTDIR)$(INCLUDEDIR)/mandoc_aux.h
481 rm -f $(DESTDIR)$(INCLUDEDIR)/mdoc.h
482 rm -f $(DESTDIR)$(INCLUDEDIR)/roff.h
483 [ ! -e $(DESTDIR)$(INCLUDEDIR) ] || rmdir $(DESTDIR)$(INCLUDEDIR)
486 cd regress && ./regress.pl
489 cd regress && ./regress.pl . clean
491 Makefile.local config.h: configure $(TESTSRCS)
492 @echo "$@ is out of date; please run ./configure"
495 libmandoc.a: $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
496 ar rs $@ $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
498 mandoc: $(MAIN_OBJS) libmandoc.a
499 $(CC) -o $@ $(LDFLAGS) $(MAIN_OBJS) libmandoc.a $(LDADD)
501 man.cgi: $(CGI_OBJS) libmandoc.a
502 $(CC) $(STATIC) -o $@ $(LDFLAGS) $(CGI_OBJS) libmandoc.a $(LDADD)
504 mandocd: $(MANDOCD_OBJS) libmandoc.a
505 $(CC) -o $@ $(LDFLAGS) $(MANDOCD_OBJS) libmandoc.a $(LDADD)
507 catman: catman.o libmandoc.a
508 $(CC) -o $@ $(LDFLAGS) catman.o libmandoc.a $(LDADD)
510 demandoc: $(DEMANDOC_OBJS) libmandoc.a
511 $(CC) -o $@ $(LDFLAGS) $(DEMANDOC_OBJS) libmandoc.a $(LDADD)
513 soelim: $(SOELIM_OBJS)
514 $(CC) -o $@ $(LDFLAGS) $(SOELIM_OBJS)
516 # --- maintainer targets ---
519 $(INSTALL_DATA) $(WWW_MANS) mandoc.css $(HTDOCDIR)
522 mkdep -f Makefile.depend $(CFLAGS) $(SRCS)
523 perl -e 'undef $$/; $$_ = <>; s|/usr/include/\S+||g; \
524 s|\\\n||g; s| +| |g; s| $$||mg; print;' \
525 Makefile.depend > Makefile.tmp
526 mv Makefile.tmp Makefile.depend
537 @find regress ! -type d ! -type f
538 @find regress -type f \
541 ! -name Makefile.inc \
543 ! -name '*.out_ascii' \
544 ! -name '*.out_utf8' \
545 ! -name '*.out_html' \
546 ! -name '*.out_markdown' \
547 ! -name '*.out_lint' \
548 ! -path regress/regress.pl \
549 ! -path regress/regress.pl.1
551 dist: mandoc-$(VERSION).sha256
553 mandoc-$(VERSION).sha256: mandoc-$(VERSION).tar.gz
554 sha256 mandoc-$(VERSION).tar.gz > $@
556 mandoc-$(VERSION).tar.gz: $(DISTFILES)
557 ls regress/*/*/*.mandoc_* && exit 1 || true
558 mkdir -p .dist/mandoc-$(VERSION)/
559 $(INSTALL) -m 0644 $(DISTFILES) .dist/mandoc-$(VERSION)
560 cp -pR regress .dist/mandoc-$(VERSION)
561 find .dist/mandoc-$(VERSION)/regress \
562 -type d -name CVS -print0 | xargs -0 rm -rf
563 chmod 755 .dist/mandoc-$(VERSION)/configure
564 ( cd .dist/ && tar zcf ../$@ mandoc-$(VERSION) )
567 # === SUFFIX RULES =====================================================
569 .SUFFIXES: .1 .3 .5 .7 .8 .h
570 .SUFFIXES: .1.html .3.html .5.html .7.html .8.html .h.html
575 .1.1.html .3.3.html .5.5.html .7.7.html .8.8.html: mandoc
576 ./mandoc -Thtml -Wall,stop \
577 -Ostyle=mandoc.css,man=%N.%S.html,includes=%I.html $< > $@