1 # $Id: Makefile,v 1.494 2017/02/04 12:03:07 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 \
63 compat_reallocarray.c \
126 DISTFILES = INSTALL \
136 compat_stringlist.h \
138 configure.local.example \
194 LIBMAN_OBJS = man.o \
199 LIBMDOC_OBJS = att.o \
209 LIBROFF_OBJS = eqn.o \
216 LIBMANDOC_OBJS = $(LIBMAN_OBJS) \
227 COMPAT_OBJS = compat_err.o \
235 compat_reallocarray.o \
236 compat_strcasestr.o \
243 MANDOC_HTML_OBJS = eqn_html.o \
249 MANDOC_MAN_OBJS = mdoc_man.o
251 MANDOC_TERM_OBJS = eqn_term.o \
269 MAIN_OBJS = $(MANDOC_HTML_OBJS) \
271 $(MANDOC_TERM_OBJS) \
280 CGI_OBJS = $(MANDOC_HTML_OBJS) \
285 MANDOCD_OBJS = $(MANDOC_HTML_OBJS) \
286 $(MANDOC_TERM_OBJS) \
291 MANPAGE_OBJS = $(DBM_OBJS) \
295 DEMANDOC_OBJS = demandoc.o
297 SOELIM_OBJS = soelim.o \
301 compat_reallocarray.o \
304 WWW_MANS = apropos.1.html \
310 mandoc_escape.3.html \
311 mandoc_headers.3.html \
313 mandoc_malloc.3.html \
315 mchars_alloc.3.html \
336 WWW_OBJS = mdocml.tar.gz \
339 # === USER CONFIGURATION ===============================================
341 include Makefile.local
343 # === DEPENDENCY HANDLING ==============================================
345 all: mandoc demandoc soelim $(BUILD_TARGETS) Makefile.local
347 install: base-install $(INSTALL_TARGETS)
349 www: $(WWW_OBJS) $(WWW_MANS)
353 .PHONY: base-install cgi-install install www-install
354 .PHONY: clean distclean depend
356 include Makefile.depend
358 # === TARGETS CONTAINING SHELL COMMANDS ================================
361 rm -f Makefile.local config.h config.h.old config.log config.log.old
364 rm -f libmandoc.a $(LIBMANDOC_OBJS) $(COMPAT_OBJS)
365 rm -f mandoc $(MAIN_OBJS)
366 rm -f man.cgi $(CGI_OBJS)
367 rm -f mandocd catman $(MANDOCD_OBJS)
368 rm -f manpage $(MANPAGE_OBJS)
369 rm -f demandoc $(DEMANDOC_OBJS)
370 rm -f soelim $(SOELIM_OBJS)
371 rm -f $(WWW_MANS) $(WWW_OBJS)
374 base-install: mandoc demandoc soelim
375 mkdir -p $(DESTDIR)$(BINDIR)
376 mkdir -p $(DESTDIR)$(SBINDIR)
377 mkdir -p $(DESTDIR)$(MANDIR)/man1
378 mkdir -p $(DESTDIR)$(MANDIR)/man5
379 mkdir -p $(DESTDIR)$(MANDIR)/man7
380 mkdir -p $(DESTDIR)$(MANDIR)/man8
381 $(INSTALL_PROGRAM) mandoc demandoc $(DESTDIR)$(BINDIR)
382 $(INSTALL_PROGRAM) soelim $(DESTDIR)$(BINDIR)/$(BINM_SOELIM)
383 ln -f $(DESTDIR)$(BINDIR)/mandoc $(DESTDIR)$(BINDIR)/$(BINM_MAN)
384 ln -f $(DESTDIR)$(BINDIR)/mandoc $(DESTDIR)$(BINDIR)/$(BINM_APROPOS)
385 ln -f $(DESTDIR)$(BINDIR)/mandoc $(DESTDIR)$(BINDIR)/$(BINM_WHATIS)
386 ln -f $(DESTDIR)$(BINDIR)/mandoc \
387 $(DESTDIR)$(SBINDIR)/$(BINM_MAKEWHATIS)
388 $(INSTALL_MAN) mandoc.1 demandoc.1 $(DESTDIR)$(MANDIR)/man1
389 $(INSTALL_MAN) soelim.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_SOELIM).1
390 $(INSTALL_MAN) man.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_MAN).1
391 $(INSTALL_MAN) apropos.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_APROPOS).1
392 ln -f $(DESTDIR)$(MANDIR)/man1/$(BINM_APROPOS).1 \
393 $(DESTDIR)$(MANDIR)/man1/$(BINM_WHATIS).1
394 $(INSTALL_MAN) man.conf.5 $(DESTDIR)$(MANDIR)/man5/${MANM_MANCONF}.5
395 $(INSTALL_MAN) mandoc.db.5 $(DESTDIR)$(MANDIR)/man5
396 $(INSTALL_MAN) man.7 $(DESTDIR)$(MANDIR)/man7/${MANM_MAN}.7
397 $(INSTALL_MAN) mdoc.7 $(DESTDIR)$(MANDIR)/man7/${MANM_MDOC}.7
398 $(INSTALL_MAN) roff.7 $(DESTDIR)$(MANDIR)/man7/${MANM_ROFF}.7
399 $(INSTALL_MAN) eqn.7 $(DESTDIR)$(MANDIR)/man7/${MANM_EQN}.7
400 $(INSTALL_MAN) tbl.7 $(DESTDIR)$(MANDIR)/man7/${MANM_TBL}.7
401 $(INSTALL_MAN) mandoc_char.7 $(DESTDIR)$(MANDIR)/man7
402 $(INSTALL_MAN) makewhatis.8 \
403 $(DESTDIR)$(MANDIR)/man8/$(BINM_MAKEWHATIS).8
405 lib-install: libmandoc.a
406 mkdir -p $(DESTDIR)$(LIBDIR)
407 mkdir -p $(DESTDIR)$(INCLUDEDIR)
408 mkdir -p $(DESTDIR)$(MANDIR)/man3
409 $(INSTALL_LIB) libmandoc.a $(DESTDIR)$(LIBDIR)
410 $(INSTALL_LIB) man.h mandoc.h mandoc_aux.h mdoc.h roff.h \
411 $(DESTDIR)$(INCLUDEDIR)
412 $(INSTALL_MAN) mandoc.3 mandoc_escape.3 mandoc_malloc.3 \
413 mansearch.3 mchars_alloc.3 tbl.3 $(DESTDIR)$(MANDIR)/man3
416 mkdir -p $(DESTDIR)$(CGIBINDIR)
417 mkdir -p $(DESTDIR)$(HTDOCDIR)
418 $(INSTALL_PROGRAM) man.cgi $(DESTDIR)$(CGIBINDIR)
419 $(INSTALL_DATA) mandoc.css $(DESTDIR)$(HTDOCDIR)
421 catman-install: mandocd catman
422 mkdir -p $(DESTDIR)$(SBINDIR)
423 $(INSTALL_PROGRAM) mandocd catman $(DESTDIR)$(SBINDIR)
425 Makefile.local config.h: configure ${TESTSRCS}
426 @echo "$@ is out of date; please run ./configure"
429 libmandoc.a: $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
430 ar rs $@ $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
432 mandoc: $(MAIN_OBJS) libmandoc.a
433 $(CC) -o $@ $(LDFLAGS) $(MAIN_OBJS) libmandoc.a $(LDADD)
435 manpage: $(MANPAGE_OBJS) libmandoc.a
436 $(CC) -o $@ $(LDFLAGS) $(MANPAGE_OBJS) libmandoc.a $(LDADD)
438 man.cgi: $(CGI_OBJS) libmandoc.a
439 $(CC) $(STATIC) -o $@ $(LDFLAGS) $(CGI_OBJS) libmandoc.a $(LDADD)
441 mandocd: $(MANDOCD_OBJS) libmandoc.a
442 $(CC) -o $@ $(LDFLAGS) $(MANDOCD_OBJS) libmandoc.a $(LDADD)
445 $(CC) -o $@ $(LDFLAGS) catman.o
447 demandoc: $(DEMANDOC_OBJS) libmandoc.a
448 $(CC) -o $@ $(LDFLAGS) $(DEMANDOC_OBJS) libmandoc.a $(LDADD)
450 soelim: $(SOELIM_OBJS)
451 $(CC) -o $@ $(LDFLAGS) $(SOELIM_OBJS)
453 # --- maintainer targets ---
456 mkdir -p $(HTDOCDIR)/snapshots
457 $(INSTALL_DATA) $(WWW_MANS) mandoc.css $(HTDOCDIR)
458 $(INSTALL_DATA) $(WWW_OBJS) $(HTDOCDIR)/snapshots
459 $(INSTALL_DATA) mdocml.tar.gz \
460 $(HTDOCDIR)/snapshots/mdocml-$(VERSION).tar.gz
461 $(INSTALL_DATA) mdocml.sha256 \
462 $(HTDOCDIR)/snapshots/mdocml-$(VERSION).sha256
465 mkdep -f Makefile.depend $(CFLAGS) $(SRCS)
466 perl -e 'undef $$/; $$_ = <>; s|/usr/include/\S+||g; \
467 s|\\\n||g; s| +| |g; s| $$||mg; print;' \
468 Makefile.depend > Makefile.tmp
469 mv Makefile.tmp Makefile.depend
473 mdocml.sha256: mdocml.tar.gz
474 sha256 mdocml.tar.gz > $@
476 mdocml.tar.gz: $(DISTFILES)
477 mkdir -p .dist/mdocml-$(VERSION)/
478 $(INSTALL) -m 0644 $(DISTFILES) .dist/mdocml-$(VERSION)
479 chmod 755 .dist/mdocml-$(VERSION)/configure
480 ( cd .dist/ && tar zcf ../$@ mdocml-$(VERSION) )
483 # === SUFFIX RULES =====================================================
485 .SUFFIXES: .1 .3 .5 .7 .8 .h
486 .SUFFIXES: .1.html .3.html .5.html .7.html .8.html .h.html
491 .1.1.html .3.3.html .5.5.html .7.7.html .8.8.html: mandoc
492 ./mandoc -Thtml -Wall,stop \
493 -Ostyle=mandoc.css,man=%N.%S.html,includes=%I.html $< > $@