1 # $Id: Makefile,v 1.500 2017/02/16 15:12:32 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 \
65 compat_reallocarray.c \
128 DISTFILES = INSTALL \
139 compat_stringlist.h \
141 configure.local.example \
199 LIBMAN_OBJS = man.o \
204 LIBMDOC_OBJS = att.o \
214 LIBROFF_OBJS = eqn.o \
221 LIBMANDOC_OBJS = $(LIBMAN_OBJS) \
232 COMPAT_OBJS = compat_err.o \
240 compat_reallocarray.o \
241 compat_strcasestr.o \
248 MANDOC_HTML_OBJS = eqn_html.o \
254 MANDOC_MAN_OBJS = mdoc_man.o
256 MANDOC_TERM_OBJS = eqn_term.o \
274 MAIN_OBJS = $(MANDOC_HTML_OBJS) \
276 $(MANDOC_TERM_OBJS) \
285 CGI_OBJS = $(MANDOC_HTML_OBJS) \
290 MANDOCD_OBJS = $(MANDOC_HTML_OBJS) \
291 $(MANDOC_TERM_OBJS) \
296 MANPAGE_OBJS = $(DBM_OBJS) \
300 DEMANDOC_OBJS = demandoc.o
302 SOELIM_OBJS = soelim.o \
306 compat_reallocarray.o \
309 WWW_MANS = apropos.1.html \
316 mandoc_escape.3.html \
317 mandoc_headers.3.html \
319 mandoc_malloc.3.html \
321 mchars_alloc.3.html \
343 WWW_OBJS = mdocml.tar.gz \
346 # === USER CONFIGURATION ===============================================
348 include Makefile.local
350 # === DEPENDENCY HANDLING ==============================================
352 all: mandoc demandoc soelim $(BUILD_TARGETS) Makefile.local
354 install: base-install $(INSTALL_TARGETS)
356 www: $(WWW_OBJS) $(WWW_MANS)
360 .PHONY: base-install cgi-install install www-install
361 .PHONY: clean distclean depend
363 include Makefile.depend
365 # === TARGETS CONTAINING SHELL COMMANDS ================================
368 rm -f Makefile.local config.h config.h.old config.log config.log.old
371 rm -f libmandoc.a $(LIBMANDOC_OBJS) $(COMPAT_OBJS)
372 rm -f mandoc $(MAIN_OBJS)
373 rm -f man.cgi $(CGI_OBJS)
374 rm -f mandocd catman $(MANDOCD_OBJS)
375 rm -f manpage $(MANPAGE_OBJS)
376 rm -f demandoc $(DEMANDOC_OBJS)
377 rm -f soelim $(SOELIM_OBJS)
378 rm -f $(WWW_MANS) $(WWW_OBJS)
381 base-install: mandoc demandoc soelim
382 mkdir -p $(DESTDIR)$(BINDIR)
383 mkdir -p $(DESTDIR)$(SBINDIR)
384 mkdir -p $(DESTDIR)$(MANDIR)/man1
385 mkdir -p $(DESTDIR)$(MANDIR)/man5
386 mkdir -p $(DESTDIR)$(MANDIR)/man7
387 mkdir -p $(DESTDIR)$(MANDIR)/man8
388 $(INSTALL_PROGRAM) mandoc demandoc $(DESTDIR)$(BINDIR)
389 $(INSTALL_PROGRAM) soelim $(DESTDIR)$(BINDIR)/$(BINM_SOELIM)
390 ln -f $(DESTDIR)$(BINDIR)/mandoc $(DESTDIR)$(BINDIR)/$(BINM_MAN)
391 ln -f $(DESTDIR)$(BINDIR)/mandoc $(DESTDIR)$(BINDIR)/$(BINM_APROPOS)
392 ln -f $(DESTDIR)$(BINDIR)/mandoc $(DESTDIR)$(BINDIR)/$(BINM_WHATIS)
393 ln -f $(DESTDIR)$(BINDIR)/mandoc \
394 $(DESTDIR)$(SBINDIR)/$(BINM_MAKEWHATIS)
395 $(INSTALL_MAN) mandoc.1 demandoc.1 $(DESTDIR)$(MANDIR)/man1
396 $(INSTALL_MAN) soelim.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_SOELIM).1
397 $(INSTALL_MAN) man.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_MAN).1
398 $(INSTALL_MAN) apropos.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_APROPOS).1
399 ln -f $(DESTDIR)$(MANDIR)/man1/$(BINM_APROPOS).1 \
400 $(DESTDIR)$(MANDIR)/man1/$(BINM_WHATIS).1
401 $(INSTALL_MAN) man.conf.5 $(DESTDIR)$(MANDIR)/man5/${MANM_MANCONF}.5
402 $(INSTALL_MAN) mandoc.db.5 $(DESTDIR)$(MANDIR)/man5
403 $(INSTALL_MAN) man.7 $(DESTDIR)$(MANDIR)/man7/${MANM_MAN}.7
404 $(INSTALL_MAN) mdoc.7 $(DESTDIR)$(MANDIR)/man7/${MANM_MDOC}.7
405 $(INSTALL_MAN) roff.7 $(DESTDIR)$(MANDIR)/man7/${MANM_ROFF}.7
406 $(INSTALL_MAN) eqn.7 $(DESTDIR)$(MANDIR)/man7/${MANM_EQN}.7
407 $(INSTALL_MAN) tbl.7 $(DESTDIR)$(MANDIR)/man7/${MANM_TBL}.7
408 $(INSTALL_MAN) mandoc_char.7 $(DESTDIR)$(MANDIR)/man7
409 $(INSTALL_MAN) makewhatis.8 \
410 $(DESTDIR)$(MANDIR)/man8/$(BINM_MAKEWHATIS).8
412 lib-install: libmandoc.a
413 mkdir -p $(DESTDIR)$(LIBDIR)
414 mkdir -p $(DESTDIR)$(INCLUDEDIR)
415 mkdir -p $(DESTDIR)$(MANDIR)/man3
416 $(INSTALL_LIB) libmandoc.a $(DESTDIR)$(LIBDIR)
417 $(INSTALL_LIB) man.h mandoc.h mandoc_aux.h mdoc.h roff.h \
418 $(DESTDIR)$(INCLUDEDIR)
419 $(INSTALL_MAN) mandoc.3 mandoc_escape.3 mandoc_malloc.3 \
420 mansearch.3 mchars_alloc.3 tbl.3 $(DESTDIR)$(MANDIR)/man3
423 mkdir -p $(DESTDIR)$(CGIBINDIR)
424 mkdir -p $(DESTDIR)$(HTDOCDIR)
425 $(INSTALL_PROGRAM) man.cgi $(DESTDIR)$(CGIBINDIR)
426 $(INSTALL_DATA) mandoc.css $(DESTDIR)$(HTDOCDIR)
428 catman-install: mandocd catman
429 mkdir -p $(DESTDIR)$(SBINDIR)
430 mkdir -p $(DESTDIR)$(MANDIR)/man8
431 $(INSTALL_PROGRAM) mandocd $(DESTDIR)$(SBINDIR)
432 $(INSTALL_PROGRAM) catman $(DESTDIR)$(SBINDIR)/$(BINM_CATMAN)
433 $(INSTALL_MAN) mandocd.8 $(DESTDIR)$(MANDIR)/man8
434 $(INSTALL_MAN) catman.8 $(DESTDIR)$(MANDIR)/man8/$(BINM_CATMAN).8
436 Makefile.local config.h: configure ${TESTSRCS}
437 @echo "$@ is out of date; please run ./configure"
440 libmandoc.a: $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
441 ar rs $@ $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
443 mandoc: $(MAIN_OBJS) libmandoc.a
444 $(CC) -o $@ $(LDFLAGS) $(MAIN_OBJS) libmandoc.a $(LDADD)
446 manpage: $(MANPAGE_OBJS) libmandoc.a
447 $(CC) -o $@ $(LDFLAGS) $(MANPAGE_OBJS) libmandoc.a $(LDADD)
449 man.cgi: $(CGI_OBJS) libmandoc.a
450 $(CC) $(STATIC) -o $@ $(LDFLAGS) $(CGI_OBJS) libmandoc.a $(LDADD)
452 mandocd: $(MANDOCD_OBJS) libmandoc.a
453 $(CC) -o $@ $(LDFLAGS) $(MANDOCD_OBJS) libmandoc.a $(LDADD)
455 catman: catman.o libmandoc.a
456 $(CC) -o $@ $(LDFLAGS) catman.o libmandoc.a $(LDADD)
458 demandoc: $(DEMANDOC_OBJS) libmandoc.a
459 $(CC) -o $@ $(LDFLAGS) $(DEMANDOC_OBJS) libmandoc.a $(LDADD)
461 soelim: $(SOELIM_OBJS)
462 $(CC) -o $@ $(LDFLAGS) $(SOELIM_OBJS)
464 # --- maintainer targets ---
467 mkdir -p $(HTDOCDIR)/snapshots
468 $(INSTALL_DATA) $(WWW_MANS) mandoc.css $(HTDOCDIR)
469 $(INSTALL_DATA) $(WWW_OBJS) $(HTDOCDIR)/snapshots
470 $(INSTALL_DATA) mdocml.tar.gz \
471 $(HTDOCDIR)/snapshots/mdocml-$(VERSION).tar.gz
472 $(INSTALL_DATA) mdocml.sha256 \
473 $(HTDOCDIR)/snapshots/mdocml-$(VERSION).sha256
476 mkdep -f Makefile.depend $(CFLAGS) $(SRCS)
477 perl -e 'undef $$/; $$_ = <>; s|/usr/include/\S+||g; \
478 s|\\\n||g; s| +| |g; s| $$||mg; print;' \
479 Makefile.depend > Makefile.tmp
480 mv Makefile.tmp Makefile.depend
484 mdocml.sha256: mdocml.tar.gz
485 sha256 mdocml.tar.gz > $@
487 mdocml.tar.gz: $(DISTFILES)
488 ls regress/*/*/*.mandoc_* && exit 1 || true
489 mkdir -p .dist/mdocml-$(VERSION)/
490 $(INSTALL) -m 0644 $(DISTFILES) .dist/mdocml-$(VERSION)
491 cp -pR regress .dist/mdocml-$(VERSION)
492 find .dist/mdocml-$(VERSION)/regress \
493 -type d -name CVS -print0 | xargs -0 rm -rf
494 chmod 755 .dist/mdocml-$(VERSION)/configure
495 ( cd .dist/ && tar zcf ../$@ mdocml-$(VERSION) )
498 # === SUFFIX RULES =====================================================
500 .SUFFIXES: .1 .3 .5 .7 .8 .h
501 .SUFFIXES: .1.html .3.html .5.html .7.html .8.html .h.html
506 .1.1.html .3.3.html .5.5.html .7.7.html .8.8.html: mandoc
507 ./mandoc -Thtml -Wall,stop \
508 -Ostyle=mandoc.css,man=%N.%S.html,includes=%I.html $< > $@