1 # $Id: Makefile,v 1.513 2017/06/12 19:05:47 schwarze Exp $
3 # Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
4 # Copyright (c) 2011, 2013-2017 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 \
67 compat_reallocarray.c \
68 compat_recallocarray.c \
133 DISTFILES = INSTALL \
144 compat_stringlist.h \
146 configure.local.example \
204 LIBMAN_OBJS = man.o \
208 LIBMDOC_OBJS = att.o \
217 LIBROFF_OBJS = eqn.o \
225 LIBMANDOC_OBJS = $(LIBMAN_OBJS) \
236 COMPAT_OBJS = compat_err.o \
244 compat_reallocarray.o \
245 compat_recallocarray.o \
246 compat_strcasestr.o \
253 MANDOC_HTML_OBJS = eqn_html.o \
260 MANDOC_TERM_OBJS = eqn_term.o \
280 MAIN_OBJS = $(MANDOC_HTML_OBJS) \
282 $(MANDOC_TERM_OBJS) \
293 CGI_OBJS = $(MANDOC_HTML_OBJS) \
298 MANDOCD_OBJS = $(MANDOC_HTML_OBJS) \
299 $(MANDOC_TERM_OBJS) \
304 DEMANDOC_OBJS = demandoc.o
306 SOELIM_OBJS = soelim.o \
310 compat_reallocarray.o \
313 WWW_MANS = apropos.1.html \
320 mandoc_escape.3.html \
321 mandoc_headers.3.html \
323 mandoc_malloc.3.html \
325 mchars_alloc.3.html \
347 WWW_OBJS = mdocml.tar.gz \
350 # === USER CONFIGURATION ===============================================
352 include Makefile.local
354 # === DEPENDENCY HANDLING ==============================================
356 all: mandoc demandoc soelim $(BUILD_TARGETS) Makefile.local
358 install: base-install $(INSTALL_TARGETS)
360 www: $(WWW_OBJS) $(WWW_MANS)
364 .PHONY: base-install cgi-install install www-install
365 .PHONY: clean distclean depend
367 include Makefile.depend
369 # === TARGETS CONTAINING SHELL COMMANDS ================================
372 rm -f Makefile.local config.h config.h.old config.log config.log.old
375 rm -f libmandoc.a $(LIBMANDOC_OBJS) $(COMPAT_OBJS)
376 rm -f mandoc $(MAIN_OBJS)
377 rm -f man.cgi $(CGI_OBJS)
378 rm -f mandocd catman $(MANDOCD_OBJS)
379 rm -f demandoc $(DEMANDOC_OBJS)
380 rm -f soelim $(SOELIM_OBJS)
381 rm -f $(WWW_MANS) $(WWW_OBJS)
384 base-install: mandoc demandoc soelim
385 mkdir -p $(DESTDIR)$(BINDIR)
386 mkdir -p $(DESTDIR)$(SBINDIR)
387 mkdir -p $(DESTDIR)$(MANDIR)/man1
388 mkdir -p $(DESTDIR)$(MANDIR)/man5
389 mkdir -p $(DESTDIR)$(MANDIR)/man7
390 mkdir -p $(DESTDIR)$(MANDIR)/man8
391 $(INSTALL_PROGRAM) mandoc demandoc $(DESTDIR)$(BINDIR)
392 $(INSTALL_PROGRAM) soelim $(DESTDIR)$(BINDIR)/$(BINM_SOELIM)
393 cd $(DESTDIR)$(BINDIR) && $(LN) mandoc $(BINM_MAN)
394 cd $(DESTDIR)$(BINDIR) && $(LN) mandoc $(BINM_APROPOS)
395 cd $(DESTDIR)$(BINDIR) && $(LN) mandoc $(BINM_WHATIS)
396 cd $(DESTDIR)$(SBINDIR) && \
397 $(LN) ${BIN_FROM_SBIN}/mandoc $(BINM_MAKEWHATIS)
398 $(INSTALL_MAN) mandoc.1 demandoc.1 $(DESTDIR)$(MANDIR)/man1
399 $(INSTALL_MAN) soelim.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_SOELIM).1
400 $(INSTALL_MAN) man.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_MAN).1
401 $(INSTALL_MAN) apropos.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_APROPOS).1
402 cd $(DESTDIR)$(MANDIR)/man1 && $(LN) $(BINM_APROPOS).1 $(BINM_WHATIS).1
403 $(INSTALL_MAN) man.conf.5 $(DESTDIR)$(MANDIR)/man5/$(MANM_MANCONF).5
404 $(INSTALL_MAN) mandoc.db.5 $(DESTDIR)$(MANDIR)/man5
405 $(INSTALL_MAN) man.7 $(DESTDIR)$(MANDIR)/man7/$(MANM_MAN).7
406 $(INSTALL_MAN) mdoc.7 $(DESTDIR)$(MANDIR)/man7/$(MANM_MDOC).7
407 $(INSTALL_MAN) roff.7 $(DESTDIR)$(MANDIR)/man7/$(MANM_ROFF).7
408 $(INSTALL_MAN) eqn.7 $(DESTDIR)$(MANDIR)/man7/$(MANM_EQN).7
409 $(INSTALL_MAN) tbl.7 $(DESTDIR)$(MANDIR)/man7/$(MANM_TBL).7
410 $(INSTALL_MAN) mandoc_char.7 $(DESTDIR)$(MANDIR)/man7
411 $(INSTALL_MAN) makewhatis.8 \
412 $(DESTDIR)$(MANDIR)/man8/$(BINM_MAKEWHATIS).8
414 lib-install: libmandoc.a
415 mkdir -p $(DESTDIR)$(LIBDIR)
416 mkdir -p $(DESTDIR)$(INCLUDEDIR)
417 mkdir -p $(DESTDIR)$(MANDIR)/man3
418 $(INSTALL_LIB) libmandoc.a $(DESTDIR)$(LIBDIR)
419 $(INSTALL_LIB) man.h mandoc.h mandoc_aux.h mdoc.h roff.h \
420 $(DESTDIR)$(INCLUDEDIR)
421 $(INSTALL_MAN) mandoc.3 mandoc_escape.3 mandoc_malloc.3 \
422 mansearch.3 mchars_alloc.3 tbl.3 $(DESTDIR)$(MANDIR)/man3
425 mkdir -p $(DESTDIR)$(CGIBINDIR)
426 mkdir -p $(DESTDIR)$(HTDOCDIR)
427 $(INSTALL_PROGRAM) man.cgi $(DESTDIR)$(CGIBINDIR)
428 $(INSTALL_DATA) mandoc.css $(DESTDIR)$(HTDOCDIR)
430 catman-install: mandocd catman
431 mkdir -p $(DESTDIR)$(SBINDIR)
432 mkdir -p $(DESTDIR)$(MANDIR)/man8
433 $(INSTALL_PROGRAM) mandocd $(DESTDIR)$(SBINDIR)
434 $(INSTALL_PROGRAM) catman $(DESTDIR)$(SBINDIR)/$(BINM_CATMAN)
435 $(INSTALL_MAN) mandocd.8 $(DESTDIR)$(MANDIR)/man8
436 $(INSTALL_MAN) catman.8 $(DESTDIR)$(MANDIR)/man8/$(BINM_CATMAN).8
439 rm -f $(DESTDIR)$(BINDIR)/mandoc
440 rm -f $(DESTDIR)$(BINDIR)/demandoc
441 rm -f $(DESTDIR)$(BINDIR)/$(BINM_SOELIM)
442 rm -f $(DESTDIR)$(BINDIR)/$(BINM_MAN)
443 rm -f $(DESTDIR)$(BINDIR)/$(BINM_APROPOS)
444 rm -f $(DESTDIR)$(BINDIR)/$(BINM_WHATIS)
445 rm -f $(DESTDIR)$(SBINDIR)/$(BINM_MAKEWHATIS)
446 rm -f $(DESTDIR)$(MANDIR)/man1/mandoc.1
447 rm -f $(DESTDIR)$(MANDIR)/man1/demandoc.1
448 rm -f $(DESTDIR)$(MANDIR)/man1/$(BINM_SOELIM).1
449 rm -f $(DESTDIR)$(MANDIR)/man1/$(BINM_MAN).1
450 rm -f $(DESTDIR)$(MANDIR)/man1/$(BINM_APROPOS).1
451 rm -f $(DESTDIR)$(MANDIR)/man1/$(BINM_WHATIS).1
452 rm -f $(DESTDIR)$(MANDIR)/man5/$(MANM_MANCONF).5
453 rm -f $(DESTDIR)$(MANDIR)/man5/mandoc.db.5
454 rm -f $(DESTDIR)$(MANDIR)/man7/$(MANM_MAN).7
455 rm -f $(DESTDIR)$(MANDIR)/man7/$(MANM_MDOC).7
456 rm -f $(DESTDIR)$(MANDIR)/man7/$(MANM_ROFF).7
457 rm -f $(DESTDIR)$(MANDIR)/man7/$(MANM_EQN).7
458 rm -f $(DESTDIR)$(MANDIR)/man7/$(MANM_TBL).7
459 rm -f $(DESTDIR)$(MANDIR)/man7/mandoc_char.7
460 rm -f $(DESTDIR)$(MANDIR)/man8/$(BINM_MAKEWHATIS).8
461 rm -f $(DESTDIR)$(CGIBINDIR)/man.cgi
462 rm -f $(DESTDIR)$(HTDOCDIR)/mandoc.css
463 rm -f $(DESTDIR)$(SBINDIR)/mandocd
464 rm -f $(DESTDIR)$(SBINDIR)/$(BINM_CATMAN)
465 rm -f $(DESTDIR)$(MANDIR)/man8/mandocd.8
466 rm -f $(DESTDIR)$(MANDIR)/man8/$(BINM_CATMAN).8
467 rm -f $(DESTDIR)$(LIBDIR)/libmandoc.a
468 rm -f $(DESTDIR)$(MANDIR)/man3/mandoc.3
469 rm -f $(DESTDIR)$(MANDIR)/man3/mandoc_escape.3
470 rm -f $(DESTDIR)$(MANDIR)/man3/mandoc_malloc.3
471 rm -f $(DESTDIR)$(MANDIR)/man3/mansearch.3
472 rm -f $(DESTDIR)$(MANDIR)/man3/mchars_alloc.3
473 rm -f $(DESTDIR)$(MANDIR)/man3/tbl.3
474 rm -f $(DESTDIR)$(INCLUDEDIR)/man.h
475 rm -f $(DESTDIR)$(INCLUDEDIR)/mandoc.h
476 rm -f $(DESTDIR)$(INCLUDEDIR)/mandoc_aux.h
477 rm -f $(DESTDIR)$(INCLUDEDIR)/mdoc.h
478 rm -f $(DESTDIR)$(INCLUDEDIR)/roff.h
479 [ ! -e $(DESTDIR)$(INCLUDEDIR) ] || rmdir $(DESTDIR)$(INCLUDEDIR)
482 cd regress && ./regress.pl
485 cd regress && ./regress.pl . clean
487 Makefile.local config.h: configure $(TESTSRCS)
488 @echo "$@ is out of date; please run ./configure"
491 libmandoc.a: $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
492 ar rs $@ $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
494 mandoc: $(MAIN_OBJS) libmandoc.a
495 $(CC) -o $@ $(LDFLAGS) $(MAIN_OBJS) libmandoc.a $(LDADD)
497 man.cgi: $(CGI_OBJS) libmandoc.a
498 $(CC) $(STATIC) -o $@ $(LDFLAGS) $(CGI_OBJS) libmandoc.a $(LDADD)
500 mandocd: $(MANDOCD_OBJS) libmandoc.a
501 $(CC) -o $@ $(LDFLAGS) $(MANDOCD_OBJS) libmandoc.a $(LDADD)
503 catman: catman.o libmandoc.a
504 $(CC) -o $@ $(LDFLAGS) catman.o libmandoc.a $(LDADD)
506 demandoc: $(DEMANDOC_OBJS) libmandoc.a
507 $(CC) -o $@ $(LDFLAGS) $(DEMANDOC_OBJS) libmandoc.a $(LDADD)
509 soelim: $(SOELIM_OBJS)
510 $(CC) -o $@ $(LDFLAGS) $(SOELIM_OBJS)
512 # --- maintainer targets ---
515 mkdir -p $(HTDOCDIR)/snapshots
516 $(INSTALL_DATA) $(WWW_MANS) mandoc.css $(HTDOCDIR)
517 $(INSTALL_DATA) $(WWW_OBJS) $(HTDOCDIR)/snapshots
518 $(INSTALL_DATA) mdocml.tar.gz \
519 $(HTDOCDIR)/snapshots/mdocml-$(VERSION).tar.gz
520 $(INSTALL_DATA) mdocml.sha256 \
521 $(HTDOCDIR)/snapshots/mdocml-$(VERSION).sha256
524 mkdep -f Makefile.depend $(CFLAGS) $(SRCS)
525 perl -e 'undef $$/; $$_ = <>; s|/usr/include/\S+||g; \
526 s|\\\n||g; s| +| |g; s| $$||mg; print;' \
527 Makefile.depend > Makefile.tmp
528 mv Makefile.tmp Makefile.depend
539 @find regress ! -type d ! -type f
540 @find regress -type f \
543 ! -name Makefile.inc \
545 ! -name '*.out_ascii' \
546 ! -name '*.out_utf8' \
547 ! -name '*.out_html' \
548 ! -name '*.out_lint' \
549 ! -path regress/regress.pl \
550 ! -path regress/regress.pl.1
554 mdocml.sha256: mdocml.tar.gz
555 sha256 mdocml.tar.gz > $@
557 mdocml.tar.gz: $(DISTFILES)
558 ls regress/*/*/*.mandoc_* && exit 1 || true
559 mkdir -p .dist/mdocml-$(VERSION)/
560 $(INSTALL) -m 0644 $(DISTFILES) .dist/mdocml-$(VERSION)
561 cp -pR regress .dist/mdocml-$(VERSION)
562 find .dist/mdocml-$(VERSION)/regress \
563 -type d -name CVS -print0 | xargs -0 rm -rf
564 chmod 755 .dist/mdocml-$(VERSION)/configure
565 ( cd .dist/ && tar zcf ../$@ mdocml-$(VERSION) )
568 # === SUFFIX RULES =====================================================
570 .SUFFIXES: .1 .3 .5 .7 .8 .h
571 .SUFFIXES: .1.html .3.html .5.html .7.html .8.html .h.html
576 .1.1.html .3.3.html .5.5.html .7.7.html .8.8.html: mandoc
577 ./mandoc -Thtml -Wall,stop \
578 -Ostyle=mandoc.css,man=%N.%S.html,includes=%I.html $< > $@