1 # $Id: Makefile,v 1.511 2017/05/05 02:06:19 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 \
66 compat_reallocarray.c \
130 DISTFILES = INSTALL \
141 compat_stringlist.h \
143 configure.local.example \
201 LIBMAN_OBJS = man.o \
205 LIBMDOC_OBJS = att.o \
214 LIBROFF_OBJS = eqn.o \
222 LIBMANDOC_OBJS = $(LIBMAN_OBJS) \
233 COMPAT_OBJS = compat_err.o \
241 compat_reallocarray.o \
242 compat_strcasestr.o \
249 MANDOC_HTML_OBJS = eqn_html.o \
256 MANDOC_TERM_OBJS = eqn_term.o \
275 MAIN_OBJS = $(MANDOC_HTML_OBJS) \
277 $(MANDOC_TERM_OBJS) \
288 CGI_OBJS = $(MANDOC_HTML_OBJS) \
293 MANDOCD_OBJS = $(MANDOC_HTML_OBJS) \
294 $(MANDOC_TERM_OBJS) \
299 DEMANDOC_OBJS = demandoc.o
301 SOELIM_OBJS = soelim.o \
305 compat_reallocarray.o \
308 WWW_MANS = apropos.1.html \
315 mandoc_escape.3.html \
316 mandoc_headers.3.html \
318 mandoc_malloc.3.html \
320 mchars_alloc.3.html \
342 WWW_OBJS = mdocml.tar.gz \
345 # === USER CONFIGURATION ===============================================
347 include Makefile.local
349 # === DEPENDENCY HANDLING ==============================================
351 all: mandoc demandoc soelim $(BUILD_TARGETS) Makefile.local
353 install: base-install $(INSTALL_TARGETS)
355 www: $(WWW_OBJS) $(WWW_MANS)
359 .PHONY: base-install cgi-install install www-install
360 .PHONY: clean distclean depend
362 include Makefile.depend
364 # === TARGETS CONTAINING SHELL COMMANDS ================================
367 rm -f Makefile.local config.h config.h.old config.log config.log.old
370 rm -f libmandoc.a $(LIBMANDOC_OBJS) $(COMPAT_OBJS)
371 rm -f mandoc $(MAIN_OBJS)
372 rm -f man.cgi $(CGI_OBJS)
373 rm -f mandocd catman $(MANDOCD_OBJS)
374 rm -f demandoc $(DEMANDOC_OBJS)
375 rm -f soelim $(SOELIM_OBJS)
376 rm -f $(WWW_MANS) $(WWW_OBJS)
379 base-install: mandoc demandoc soelim
380 mkdir -p $(DESTDIR)$(BINDIR)
381 mkdir -p $(DESTDIR)$(SBINDIR)
382 mkdir -p $(DESTDIR)$(MANDIR)/man1
383 mkdir -p $(DESTDIR)$(MANDIR)/man5
384 mkdir -p $(DESTDIR)$(MANDIR)/man7
385 mkdir -p $(DESTDIR)$(MANDIR)/man8
386 $(INSTALL_PROGRAM) mandoc demandoc $(DESTDIR)$(BINDIR)
387 $(INSTALL_PROGRAM) soelim $(DESTDIR)$(BINDIR)/$(BINM_SOELIM)
388 cd $(DESTDIR)$(BINDIR) && $(LN) mandoc $(BINM_MAN)
389 cd $(DESTDIR)$(BINDIR) && $(LN) mandoc $(BINM_APROPOS)
390 cd $(DESTDIR)$(BINDIR) && $(LN) mandoc $(BINM_WHATIS)
391 cd $(DESTDIR)$(SBINDIR) && \
392 $(LN) ${BIN_FROM_SBIN}/mandoc $(BINM_MAKEWHATIS)
393 $(INSTALL_MAN) mandoc.1 demandoc.1 $(DESTDIR)$(MANDIR)/man1
394 $(INSTALL_MAN) soelim.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_SOELIM).1
395 $(INSTALL_MAN) man.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_MAN).1
396 $(INSTALL_MAN) apropos.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_APROPOS).1
397 cd $(DESTDIR)$(MANDIR)/man1 && $(LN) $(BINM_APROPOS).1 $(BINM_WHATIS).1
398 $(INSTALL_MAN) man.conf.5 $(DESTDIR)$(MANDIR)/man5/$(MANM_MANCONF).5
399 $(INSTALL_MAN) mandoc.db.5 $(DESTDIR)$(MANDIR)/man5
400 $(INSTALL_MAN) man.7 $(DESTDIR)$(MANDIR)/man7/$(MANM_MAN).7
401 $(INSTALL_MAN) mdoc.7 $(DESTDIR)$(MANDIR)/man7/$(MANM_MDOC).7
402 $(INSTALL_MAN) roff.7 $(DESTDIR)$(MANDIR)/man7/$(MANM_ROFF).7
403 $(INSTALL_MAN) eqn.7 $(DESTDIR)$(MANDIR)/man7/$(MANM_EQN).7
404 $(INSTALL_MAN) tbl.7 $(DESTDIR)$(MANDIR)/man7/$(MANM_TBL).7
405 $(INSTALL_MAN) mandoc_char.7 $(DESTDIR)$(MANDIR)/man7
406 $(INSTALL_MAN) makewhatis.8 \
407 $(DESTDIR)$(MANDIR)/man8/$(BINM_MAKEWHATIS).8
409 lib-install: libmandoc.a
410 mkdir -p $(DESTDIR)$(LIBDIR)
411 mkdir -p $(DESTDIR)$(INCLUDEDIR)
412 mkdir -p $(DESTDIR)$(MANDIR)/man3
413 $(INSTALL_LIB) libmandoc.a $(DESTDIR)$(LIBDIR)
414 $(INSTALL_LIB) man.h mandoc.h mandoc_aux.h mdoc.h roff.h \
415 $(DESTDIR)$(INCLUDEDIR)
416 $(INSTALL_MAN) mandoc.3 mandoc_escape.3 mandoc_malloc.3 \
417 mansearch.3 mchars_alloc.3 tbl.3 $(DESTDIR)$(MANDIR)/man3
420 mkdir -p $(DESTDIR)$(CGIBINDIR)
421 mkdir -p $(DESTDIR)$(HTDOCDIR)
422 $(INSTALL_PROGRAM) man.cgi $(DESTDIR)$(CGIBINDIR)
423 $(INSTALL_DATA) mandoc.css $(DESTDIR)$(HTDOCDIR)
425 catman-install: mandocd catman
426 mkdir -p $(DESTDIR)$(SBINDIR)
427 mkdir -p $(DESTDIR)$(MANDIR)/man8
428 $(INSTALL_PROGRAM) mandocd $(DESTDIR)$(SBINDIR)
429 $(INSTALL_PROGRAM) catman $(DESTDIR)$(SBINDIR)/$(BINM_CATMAN)
430 $(INSTALL_MAN) mandocd.8 $(DESTDIR)$(MANDIR)/man8
431 $(INSTALL_MAN) catman.8 $(DESTDIR)$(MANDIR)/man8/$(BINM_CATMAN).8
434 rm -f $(DESTDIR)$(BINDIR)/mandoc
435 rm -f $(DESTDIR)$(BINDIR)/demandoc
436 rm -f $(DESTDIR)$(BINDIR)/$(BINM_SOELIM)
437 rm -f $(DESTDIR)$(BINDIR)/$(BINM_MAN)
438 rm -f $(DESTDIR)$(BINDIR)/$(BINM_APROPOS)
439 rm -f $(DESTDIR)$(BINDIR)/$(BINM_WHATIS)
440 rm -f $(DESTDIR)$(SBINDIR)/$(BINM_MAKEWHATIS)
441 rm -f $(DESTDIR)$(MANDIR)/man1/mandoc.1
442 rm -f $(DESTDIR)$(MANDIR)/man1/demandoc.1
443 rm -f $(DESTDIR)$(MANDIR)/man1/$(BINM_SOELIM).1
444 rm -f $(DESTDIR)$(MANDIR)/man1/$(BINM_MAN).1
445 rm -f $(DESTDIR)$(MANDIR)/man1/$(BINM_APROPOS).1
446 rm -f $(DESTDIR)$(MANDIR)/man1/$(BINM_WHATIS).1
447 rm -f $(DESTDIR)$(MANDIR)/man5/$(MANM_MANCONF).5
448 rm -f $(DESTDIR)$(MANDIR)/man5/mandoc.db.5
449 rm -f $(DESTDIR)$(MANDIR)/man7/$(MANM_MAN).7
450 rm -f $(DESTDIR)$(MANDIR)/man7/$(MANM_MDOC).7
451 rm -f $(DESTDIR)$(MANDIR)/man7/$(MANM_ROFF).7
452 rm -f $(DESTDIR)$(MANDIR)/man7/$(MANM_EQN).7
453 rm -f $(DESTDIR)$(MANDIR)/man7/$(MANM_TBL).7
454 rm -f $(DESTDIR)$(MANDIR)/man7/mandoc_char.7
455 rm -f $(DESTDIR)$(MANDIR)/man8/$(BINM_MAKEWHATIS).8
456 rm -f $(DESTDIR)$(CGIBINDIR)/man.cgi
457 rm -f $(DESTDIR)$(HTDOCDIR)/mandoc.css
458 rm -f $(DESTDIR)$(SBINDIR)/mandocd
459 rm -f $(DESTDIR)$(SBINDIR)/$(BINM_CATMAN)
460 rm -f $(DESTDIR)$(MANDIR)/man8/mandocd.8
461 rm -f $(DESTDIR)$(MANDIR)/man8/$(BINM_CATMAN).8
462 rm -f $(DESTDIR)$(LIBDIR)/libmandoc.a
463 rm -f $(DESTDIR)$(MANDIR)/man3/mandoc.3
464 rm -f $(DESTDIR)$(MANDIR)/man3/mandoc_escape.3
465 rm -f $(DESTDIR)$(MANDIR)/man3/mandoc_malloc.3
466 rm -f $(DESTDIR)$(MANDIR)/man3/mansearch.3
467 rm -f $(DESTDIR)$(MANDIR)/man3/mchars_alloc.3
468 rm -f $(DESTDIR)$(MANDIR)/man3/tbl.3
469 rm -f $(DESTDIR)$(INCLUDEDIR)/man.h
470 rm -f $(DESTDIR)$(INCLUDEDIR)/mandoc.h
471 rm -f $(DESTDIR)$(INCLUDEDIR)/mandoc_aux.h
472 rm -f $(DESTDIR)$(INCLUDEDIR)/mdoc.h
473 rm -f $(DESTDIR)$(INCLUDEDIR)/roff.h
474 [ ! -e $(DESTDIR)$(INCLUDEDIR) ] || rmdir $(DESTDIR)$(INCLUDEDIR)
477 cd regress && ./regress.pl
480 cd regress && ./regress.pl . clean
482 Makefile.local config.h: configure $(TESTSRCS)
483 @echo "$@ is out of date; please run ./configure"
486 libmandoc.a: $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
487 ar rs $@ $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
489 mandoc: $(MAIN_OBJS) libmandoc.a
490 $(CC) -o $@ $(LDFLAGS) $(MAIN_OBJS) libmandoc.a $(LDADD)
492 man.cgi: $(CGI_OBJS) libmandoc.a
493 $(CC) $(STATIC) -o $@ $(LDFLAGS) $(CGI_OBJS) libmandoc.a $(LDADD)
495 mandocd: $(MANDOCD_OBJS) libmandoc.a
496 $(CC) -o $@ $(LDFLAGS) $(MANDOCD_OBJS) libmandoc.a $(LDADD)
498 catman: catman.o libmandoc.a
499 $(CC) -o $@ $(LDFLAGS) catman.o libmandoc.a $(LDADD)
501 demandoc: $(DEMANDOC_OBJS) libmandoc.a
502 $(CC) -o $@ $(LDFLAGS) $(DEMANDOC_OBJS) libmandoc.a $(LDADD)
504 soelim: $(SOELIM_OBJS)
505 $(CC) -o $@ $(LDFLAGS) $(SOELIM_OBJS)
507 # --- maintainer targets ---
510 mkdir -p $(HTDOCDIR)/snapshots
511 $(INSTALL_DATA) $(WWW_MANS) mandoc.css $(HTDOCDIR)
512 $(INSTALL_DATA) $(WWW_OBJS) $(HTDOCDIR)/snapshots
513 $(INSTALL_DATA) mdocml.tar.gz \
514 $(HTDOCDIR)/snapshots/mdocml-$(VERSION).tar.gz
515 $(INSTALL_DATA) mdocml.sha256 \
516 $(HTDOCDIR)/snapshots/mdocml-$(VERSION).sha256
519 mkdep -f Makefile.depend $(CFLAGS) $(SRCS)
520 perl -e 'undef $$/; $$_ = <>; s|/usr/include/\S+||g; \
521 s|\\\n||g; s| +| |g; s| $$||mg; print;' \
522 Makefile.depend > Makefile.tmp
523 mv Makefile.tmp Makefile.depend
534 @find regress ! -type d ! -type f
535 @find regress -type f \
538 ! -name Makefile.inc \
540 ! -name '*.out_ascii' \
541 ! -name '*.out_utf8' \
542 ! -name '*.out_html' \
543 ! -name '*.out_lint' \
544 ! -path regress/regress.pl \
545 ! -path regress/regress.pl.1
549 mdocml.sha256: mdocml.tar.gz
550 sha256 mdocml.tar.gz > $@
552 mdocml.tar.gz: $(DISTFILES)
553 ls regress/*/*/*.mandoc_* && exit 1 || true
554 mkdir -p .dist/mdocml-$(VERSION)/
555 $(INSTALL) -m 0644 $(DISTFILES) .dist/mdocml-$(VERSION)
556 cp -pR regress .dist/mdocml-$(VERSION)
557 find .dist/mdocml-$(VERSION)/regress \
558 -type d -name CVS -print0 | xargs -0 rm -rf
559 chmod 755 .dist/mdocml-$(VERSION)/configure
560 ( cd .dist/ && tar zcf ../$@ mdocml-$(VERSION) )
563 # === SUFFIX RULES =====================================================
565 .SUFFIXES: .1 .3 .5 .7 .8 .h
566 .SUFFIXES: .1.html .3.html .5.html .7.html .8.html .h.html
571 .1.1.html .3.3.html .5.5.html .7.7.html .8.8.html: mandoc
572 ./mandoc -Thtml -Wall,stop \
573 -Ostyle=mandoc.css,man=%N.%S.html,includes=%I.html $< > $@