1 # $Id: Makefile,v 1.493 2016/11/19 15:24:51 schwarze Exp $
3 # Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
4 # Copyright (c) 2011, 2013-2016 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 \
23 test-dirent-namlen.c \
62 compat_reallocarray.c \
124 DISTFILES = INSTALL \
134 compat_stringlist.h \
136 configure.local.example \
192 LIBMAN_OBJS = man.o \
197 LIBMDOC_OBJS = att.o \
207 LIBROFF_OBJS = eqn.o \
214 LIBMANDOC_OBJS = $(LIBMAN_OBJS) \
225 COMPAT_OBJS = compat_err.o \
233 compat_reallocarray.o \
234 compat_strcasestr.o \
241 MANDOC_HTML_OBJS = eqn_html.o \
247 MANDOC_MAN_OBJS = mdoc_man.o
249 MANDOC_TERM_OBJS = eqn_term.o \
267 MAIN_OBJS = $(MANDOC_HTML_OBJS) \
269 $(MANDOC_TERM_OBJS) \
278 CGI_OBJS = $(MANDOC_HTML_OBJS) \
283 MANPAGE_OBJS = $(DBM_OBJS) \
287 DEMANDOC_OBJS = demandoc.o
289 SOELIM_OBJS = soelim.o \
293 compat_reallocarray.o \
296 WWW_MANS = apropos.1.html \
302 mandoc_escape.3.html \
303 mandoc_headers.3.html \
305 mandoc_malloc.3.html \
307 mchars_alloc.3.html \
328 WWW_OBJS = mdocml.tar.gz \
331 # === USER CONFIGURATION ===============================================
333 include Makefile.local
335 # === DEPENDENCY HANDLING ==============================================
337 all: base-build $(BUILD_TARGETS) Makefile.local
339 base-build: mandoc demandoc soelim
343 install: base-install $(INSTALL_TARGETS)
345 www: $(WWW_OBJS) $(WWW_MANS)
349 .PHONY: base-install cgi-install install www-install
350 .PHONY: clean distclean depend
352 include Makefile.depend
354 # === TARGETS CONTAINING SHELL COMMANDS ================================
357 rm -f Makefile.local config.h config.h.old config.log config.log.old
360 rm -f libmandoc.a $(LIBMANDOC_OBJS) $(COMPAT_OBJS)
361 rm -f mandoc $(MAIN_OBJS)
362 rm -f man.cgi $(CGI_OBJS)
363 rm -f manpage $(MANPAGE_OBJS)
364 rm -f demandoc $(DEMANDOC_OBJS)
365 rm -f soelim $(SOELIM_OBJS)
366 rm -f $(WWW_MANS) $(WWW_OBJS)
369 base-install: base-build
370 mkdir -p $(DESTDIR)$(BINDIR)
371 mkdir -p $(DESTDIR)$(SBINDIR)
372 mkdir -p $(DESTDIR)$(MANDIR)/man1
373 mkdir -p $(DESTDIR)$(MANDIR)/man5
374 mkdir -p $(DESTDIR)$(MANDIR)/man7
375 mkdir -p $(DESTDIR)$(MANDIR)/man8
376 $(INSTALL_PROGRAM) mandoc demandoc $(DESTDIR)$(BINDIR)
377 $(INSTALL_PROGRAM) soelim $(DESTDIR)$(BINDIR)/$(BINM_SOELIM)
378 ln -f $(DESTDIR)$(BINDIR)/mandoc $(DESTDIR)$(BINDIR)/$(BINM_MAN)
379 ln -f $(DESTDIR)$(BINDIR)/mandoc $(DESTDIR)$(BINDIR)/$(BINM_APROPOS)
380 ln -f $(DESTDIR)$(BINDIR)/mandoc $(DESTDIR)$(BINDIR)/$(BINM_WHATIS)
381 ln -f $(DESTDIR)$(BINDIR)/mandoc \
382 $(DESTDIR)$(SBINDIR)/$(BINM_MAKEWHATIS)
383 $(INSTALL_MAN) mandoc.1 demandoc.1 $(DESTDIR)$(MANDIR)/man1
384 $(INSTALL_MAN) soelim.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_SOELIM).1
385 $(INSTALL_MAN) man.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_MAN).1
386 $(INSTALL_MAN) apropos.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_APROPOS).1
387 ln -f $(DESTDIR)$(MANDIR)/man1/$(BINM_APROPOS).1 \
388 $(DESTDIR)$(MANDIR)/man1/$(BINM_WHATIS).1
389 $(INSTALL_MAN) man.conf.5 $(DESTDIR)$(MANDIR)/man5/${MANM_MANCONF}.5
390 $(INSTALL_MAN) mandoc.db.5 $(DESTDIR)$(MANDIR)/man5
391 $(INSTALL_MAN) man.7 $(DESTDIR)$(MANDIR)/man7/${MANM_MAN}.7
392 $(INSTALL_MAN) mdoc.7 $(DESTDIR)$(MANDIR)/man7/${MANM_MDOC}.7
393 $(INSTALL_MAN) roff.7 $(DESTDIR)$(MANDIR)/man7/${MANM_ROFF}.7
394 $(INSTALL_MAN) eqn.7 $(DESTDIR)$(MANDIR)/man7/${MANM_EQN}.7
395 $(INSTALL_MAN) tbl.7 $(DESTDIR)$(MANDIR)/man7/${MANM_TBL}.7
396 $(INSTALL_MAN) mandoc_char.7 $(DESTDIR)$(MANDIR)/man7
397 $(INSTALL_MAN) makewhatis.8 \
398 $(DESTDIR)$(MANDIR)/man8/$(BINM_MAKEWHATIS).8
400 lib-install: base-build
401 mkdir -p $(DESTDIR)$(LIBDIR)
402 mkdir -p $(DESTDIR)$(INCLUDEDIR)
403 mkdir -p $(DESTDIR)$(MANDIR)/man3
404 $(INSTALL_LIB) libmandoc.a $(DESTDIR)$(LIBDIR)
405 $(INSTALL_LIB) man.h mandoc.h mandoc_aux.h mdoc.h roff.h \
406 $(DESTDIR)$(INCLUDEDIR)
407 $(INSTALL_MAN) mandoc.3 mandoc_escape.3 mandoc_malloc.3 \
408 mansearch.3 mchars_alloc.3 tbl.3 $(DESTDIR)$(MANDIR)/man3
410 cgi-install: cgi-build
411 mkdir -p $(DESTDIR)$(CGIBINDIR)
412 mkdir -p $(DESTDIR)$(HTDOCDIR)
413 $(INSTALL_PROGRAM) man.cgi $(DESTDIR)$(CGIBINDIR)
414 $(INSTALL_DATA) mandoc.css $(DESTDIR)$(HTDOCDIR)
416 Makefile.local config.h: configure ${TESTSRCS}
417 @echo "$@ is out of date; please run ./configure"
420 libmandoc.a: $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
421 ar rs $@ $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
423 mandoc: $(MAIN_OBJS) libmandoc.a
424 $(CC) -o $@ $(LDFLAGS) $(MAIN_OBJS) libmandoc.a $(LDADD)
426 manpage: $(MANPAGE_OBJS) libmandoc.a
427 $(CC) -o $@ $(LDFLAGS) $(MANPAGE_OBJS) libmandoc.a $(LDADD)
429 man.cgi: $(CGI_OBJS) libmandoc.a
430 $(CC) $(STATIC) -o $@ $(LDFLAGS) $(CGI_OBJS) libmandoc.a $(LDADD)
432 demandoc: $(DEMANDOC_OBJS) libmandoc.a
433 $(CC) -o $@ $(LDFLAGS) $(DEMANDOC_OBJS) libmandoc.a $(LDADD)
435 soelim: $(SOELIM_OBJS)
436 $(CC) -o $@ $(LDFLAGS) $(SOELIM_OBJS)
438 # --- maintainer targets ---
441 mkdir -p $(HTDOCDIR)/snapshots
442 $(INSTALL_DATA) $(WWW_MANS) mandoc.css $(HTDOCDIR)
443 $(INSTALL_DATA) $(WWW_OBJS) $(HTDOCDIR)/snapshots
444 $(INSTALL_DATA) mdocml.tar.gz \
445 $(HTDOCDIR)/snapshots/mdocml-$(VERSION).tar.gz
446 $(INSTALL_DATA) mdocml.sha256 \
447 $(HTDOCDIR)/snapshots/mdocml-$(VERSION).sha256
450 mkdep -f Makefile.depend $(CFLAGS) $(SRCS)
451 perl -e 'undef $$/; $$_ = <>; s|/usr/include/\S+||g; \
452 s|\\\n||g; s| +| |g; s| $$||mg; print;' \
453 Makefile.depend > Makefile.tmp
454 mv Makefile.tmp Makefile.depend
458 mdocml.sha256: mdocml.tar.gz
459 sha256 mdocml.tar.gz > $@
461 mdocml.tar.gz: $(DISTFILES)
462 mkdir -p .dist/mdocml-$(VERSION)/
463 $(INSTALL) -m 0644 $(DISTFILES) .dist/mdocml-$(VERSION)
464 chmod 755 .dist/mdocml-$(VERSION)/configure
465 ( cd .dist/ && tar zcf ../$@ mdocml-$(VERSION) )
468 # === SUFFIX RULES =====================================================
470 .SUFFIXES: .1 .3 .5 .7 .8 .h
471 .SUFFIXES: .1.html .3.html .5.html .7.html .8.html .h.html
476 .1.1.html .3.3.html .5.5.html .7.7.html .8.8.html: mandoc
477 ./mandoc -Thtml -Wall,stop \
478 -Ostyle=mandoc.css,man=%N.%S.html,includes=%I.html $< > $@