1 # $Id: Makefile,v 1.479 2015/11/07 21:38:28 schwarze Exp $
3 # Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
4 # Copyright (c) 2011, 2013, 2014, 2015 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-dirent-namlen.c \
35 test-sqlite3_errstr.c \
57 compat_reallocarray.c \
58 compat_sqlite3_errstr.c \
115 DISTFILES = INSTALL \
125 compat_stringlist.h \
127 configure.local.example \
176 LIBMAN_OBJS = man.o \
181 LIBMDOC_OBJS = att.o \
191 LIBROFF_OBJS = eqn.o \
198 LIBMANDOC_OBJS = $(LIBMAN_OBJS) \
209 COMPAT_OBJS = compat_err.o \
217 compat_reallocarray.o \
218 compat_sqlite3_errstr.o \
219 compat_strcasestr.o \
226 MANDOC_HTML_OBJS = eqn_html.o \
232 MANDOC_MAN_OBJS = mdoc_man.o
234 MANDOC_TERM_OBJS = eqn_term.o \
242 BASE_OBJS = $(MANDOC_HTML_OBJS) \
244 $(MANDOC_TERM_OBJS) \
251 MAIN_OBJS = $(BASE_OBJS)
253 DB_OBJS = mandocdb.o \
257 CGI_OBJS = $(MANDOC_HTML_OBJS) \
263 MANPAGE_OBJS = manpage.o mansearch.o mansearch_const.o manpath.o
265 DEMANDOC_OBJS = demandoc.o
267 SOELIM_OBJS = soelim.o \
273 WWW_MANS = apropos.1.html \
279 mandoc_escape.3.html \
280 mandoc_headers.3.html \
282 mandoc_malloc.3.html \
284 mchars_alloc.3.html \
304 WWW_OBJS = mdocml.tar.gz \
307 # === USER CONFIGURATION ===============================================
309 include Makefile.local
311 # === DEPENDENCY HANDLING ==============================================
313 all: base-build $(BUILD_TARGETS) Makefile.local
315 base-build: mandoc demandoc soelim
319 install: base-install $(INSTALL_TARGETS)
321 www: $(WWW_OBJS) $(WWW_MANS)
325 .PHONY: base-install cgi-install db-install install www-install
326 .PHONY: clean distclean depend
328 include Makefile.depend
330 # === TARGETS CONTAINING SHELL COMMANDS ================================
333 rm -f Makefile.local config.h config.h.old config.log config.log.old
336 rm -f libmandoc.a $(LIBMANDOC_OBJS) $(COMPAT_OBJS)
337 rm -f mandoc $(BASE_OBJS) $(DB_OBJS)
338 rm -f man.cgi $(CGI_OBJS)
339 rm -f manpage $(MANPAGE_OBJS)
340 rm -f demandoc $(DEMANDOC_OBJS)
341 rm -f soelim $(SOELIM_OBJS)
342 rm -f $(WWW_MANS) $(WWW_OBJS)
345 base-install: base-build
346 mkdir -p $(DESTDIR)$(BINDIR)
347 mkdir -p $(DESTDIR)$(LIBDIR)
348 mkdir -p $(DESTDIR)$(INCLUDEDIR)
349 mkdir -p $(DESTDIR)$(MANDIR)/man1
350 mkdir -p $(DESTDIR)$(MANDIR)/man3
351 mkdir -p $(DESTDIR)$(MANDIR)/man5
352 mkdir -p $(DESTDIR)$(MANDIR)/man7
353 $(INSTALL_PROGRAM) mandoc demandoc $(DESTDIR)$(BINDIR)
354 $(INSTALL_PROGRAM) soelim $(DESTDIR)$(BINDIR)/$(BINM_SOELIM)
355 ln -f $(DESTDIR)$(BINDIR)/mandoc $(DESTDIR)$(BINDIR)/$(BINM_MAN)
356 $(INSTALL_LIB) libmandoc.a $(DESTDIR)$(LIBDIR)
357 $(INSTALL_LIB) man.h mandoc.h mandoc_aux.h mdoc.h roff.h \
358 $(DESTDIR)$(INCLUDEDIR)
359 $(INSTALL_MAN) mandoc.1 demandoc.1 $(DESTDIR)$(MANDIR)/man1
360 $(INSTALL_MAN) soelim.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_SOELIM).1
361 $(INSTALL_MAN) man.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_MAN).1
362 $(INSTALL_MAN) mandoc.3 mandoc_escape.3 mandoc_malloc.3 \
363 mchars_alloc.3 tbl.3 $(DESTDIR)$(MANDIR)/man3
364 $(INSTALL_MAN) man.conf.5 $(DESTDIR)$(MANDIR)/man5/${MANM_MANCONF}.5
365 $(INSTALL_MAN) man.7 $(DESTDIR)$(MANDIR)/man7/${MANM_MAN}.7
366 $(INSTALL_MAN) mdoc.7 $(DESTDIR)$(MANDIR)/man7/${MANM_MDOC}.7
367 $(INSTALL_MAN) roff.7 $(DESTDIR)$(MANDIR)/man7/${MANM_ROFF}.7
368 $(INSTALL_MAN) eqn.7 $(DESTDIR)$(MANDIR)/man7/${MANM_EQN}.7
369 $(INSTALL_MAN) tbl.7 $(DESTDIR)$(MANDIR)/man7/${MANM_TBL}.7
370 $(INSTALL_MAN) mandoc_char.7 $(DESTDIR)$(MANDIR)/man7
372 db-install: base-build
373 mkdir -p $(DESTDIR)$(BINDIR)
374 mkdir -p $(DESTDIR)$(SBINDIR)
375 mkdir -p $(DESTDIR)$(MANDIR)/man1
376 mkdir -p $(DESTDIR)$(MANDIR)/man3
377 mkdir -p $(DESTDIR)$(MANDIR)/man5
378 mkdir -p $(DESTDIR)$(MANDIR)/man8
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) apropos.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_APROPOS).1
384 ln -f $(DESTDIR)$(MANDIR)/man1/$(BINM_APROPOS).1 \
385 $(DESTDIR)$(MANDIR)/man1/$(BINM_WHATIS).1
386 $(INSTALL_MAN) mansearch.3 $(DESTDIR)$(MANDIR)/man3
387 $(INSTALL_MAN) mandoc.db.5 $(DESTDIR)$(MANDIR)/man5
388 $(INSTALL_MAN) makewhatis.8 \
389 $(DESTDIR)$(MANDIR)/man8/$(BINM_MAKEWHATIS).8
391 cgi-install: cgi-build
392 mkdir -p $(DESTDIR)$(CGIBINDIR)
393 mkdir -p $(DESTDIR)$(HTDOCDIR)
394 mkdir -p $(DESTDIR)$(WWWPREFIX)/man/mandoc/man1
395 mkdir -p $(DESTDIR)$(WWWPREFIX)/man/mandoc/man8
396 $(INSTALL_PROGRAM) man.cgi $(DESTDIR)$(CGIBINDIR)
397 $(INSTALL_DATA) mandoc.css $(DESTDIR)$(HTDOCDIR)
398 $(INSTALL_MAN) apropos.1 $(DESTDIR)$(WWWPREFIX)/man/mandoc/man1/
399 $(INSTALL_MAN) man.cgi.8 $(DESTDIR)$(WWWPREFIX)/man/mandoc/man8/
401 Makefile.local config.h: configure ${TESTSRCS}
402 @echo "$@ is out of date; please run ./configure"
405 libmandoc.a: $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
406 $(AR) rs $@ $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
408 mandoc: $(MAIN_OBJS) libmandoc.a
409 $(CC) $(LDFLAGS) -o $@ $(MAIN_OBJS) libmandoc.a $(DBLIB)
411 manpage: $(MANPAGE_OBJS) libmandoc.a
412 $(CC) $(LDFLAGS) -o $@ $(MANPAGE_OBJS) libmandoc.a $(DBLIB)
414 man.cgi: $(CGI_OBJS) libmandoc.a
415 $(CC) $(LDFLAGS) $(STATIC) -o $@ $(CGI_OBJS) libmandoc.a $(DBLIB)
417 demandoc: $(DEMANDOC_OBJS) libmandoc.a
418 $(CC) $(LDFLAGS) -o $@ $(DEMANDOC_OBJS) libmandoc.a $(DBLIB)
420 soelim: $(SOELIM_OBJS) compat_reallocarray.o
421 $(CC) $(LDFLAGS) -o $@ $(SOELIM_OBJS) compat_reallocarray.o
423 # --- maintainer targets ---
426 mkdir -p $(HTDOCDIR)/snapshots
427 $(INSTALL_DATA) $(WWW_MANS) mandoc.css $(HTDOCDIR)
428 $(INSTALL_DATA) $(WWW_OBJS) $(HTDOCDIR)/snapshots
429 $(INSTALL_DATA) mdocml.tar.gz \
430 $(HTDOCDIR)/snapshots/mdocml-$(VERSION).tar.gz
431 $(INSTALL_DATA) mdocml.sha256 \
432 $(HTDOCDIR)/snapshots/mdocml-$(VERSION).sha256
435 mkdep -f Makefile.depend $(CFLAGS) $(SRCS)
436 perl -e 'undef $$/; $$_ = <>; s|/usr/include/\S+||g; \
437 s|\\\n||g; s| +| |g; s| $$||mg; print;' \
438 Makefile.depend > Makefile.tmp
439 mv Makefile.tmp Makefile.depend
441 mdocml.sha256: mdocml.tar.gz
442 sha256 mdocml.tar.gz > $@
444 mdocml.tar.gz: $(DISTFILES)
445 mkdir -p .dist/mdocml-$(VERSION)/
446 $(INSTALL) -m 0644 $(DISTFILES) .dist/mdocml-$(VERSION)
447 chmod 755 .dist/mdocml-$(VERSION)/configure
448 ( cd .dist/ && tar zcf ../$@ mdocml-$(VERSION) )
451 # === SUFFIX RULES =====================================================
453 .SUFFIXES: .1 .3 .5 .7 .8 .h
454 .SUFFIXES: .1.html .3.html .5.html .7.html .8.html .h.html
459 .1.1.html .3.3.html .5.5.html .7.7.html .8.8.html: mandoc
460 ./mandoc -Thtml -Wall,stop \
461 -Ostyle=mandoc.css,man=%N.%S.html,includes=%I.html $< > $@