1 # $Id: Makefile,v 1.469 2015/10/13 22:59:54 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 \
34 test-sqlite3_errstr.c \
55 compat_reallocarray.c \
56 compat_sqlite3_errstr.c \
112 DISTFILES = INSTALL \
122 compat_stringlist.h \
124 configure.local.example \
175 LIBMAN_OBJS = man.o \
180 LIBMDOC_OBJS = att.o \
189 LIBROFF_OBJS = eqn.o \
196 LIBMANDOC_OBJS = $(LIBMAN_OBJS) \
207 COMPAT_OBJS = compat_err.o \
214 compat_reallocarray.o \
215 compat_sqlite3_errstr.o \
216 compat_strcasestr.o \
223 MANDOC_HTML_OBJS = eqn_html.o \
229 MANDOC_MAN_OBJS = mdoc_man.o
231 MANDOC_TERM_OBJS = eqn_term.o \
239 BASE_OBJS = $(MANDOC_HTML_OBJS) \
241 $(MANDOC_TERM_OBJS) \
248 MAIN_OBJS = $(BASE_OBJS)
250 DB_OBJS = mandocdb.o \
254 CGI_OBJS = $(MANDOC_HTML_OBJS) \
260 MANPAGE_OBJS = manpage.o mansearch.o mansearch_const.o manpath.o
262 DEMANDOC_OBJS = demandoc.o
264 SOELIM_OBJS = soelim.o compat_stringlist.o
266 WWW_MANS = apropos.1.html \
272 mandoc_escape.3.html \
273 mandoc_headers.3.html \
275 mandoc_malloc.3.html \
277 mchars_alloc.3.html \
297 WWW_OBJS = mdocml.tar.gz \
300 # === USER CONFIGURATION ===============================================
302 include Makefile.local
304 # === DEPENDENCY HANDLING ==============================================
306 all: base-build $(BUILD_TARGETS) Makefile.local
308 base-build: mandoc demandoc soelim
312 install: base-install $(INSTALL_TARGETS)
314 www: $(WWW_OBJS) $(WWW_MANS)
318 .PHONY: base-install cgi-install db-install install www-install
319 .PHONY: clean distclean depend
321 include Makefile.depend
323 # === TARGETS CONTAINING SHELL COMMANDS ================================
326 rm -f Makefile.local config.h config.h.old config.log config.log.old
329 rm -f libmandoc.a $(LIBMANDOC_OBJS) $(COMPAT_OBJS)
330 rm -f mandoc $(BASE_OBJS) $(DB_OBJS)
331 rm -f man.cgi $(CGI_OBJS)
332 rm -f manpage $(MANPAGE_OBJS)
333 rm -f demandoc $(DEMANDOC_OBJS)
334 rm -f soelim $(SOELIM_OBJS)
335 rm -f $(WWW_MANS) $(WWW_OBJS)
338 base-install: base-build
339 mkdir -p $(DESTDIR)$(BINDIR)
340 mkdir -p $(DESTDIR)$(EXAMPLEDIR)
341 mkdir -p $(DESTDIR)$(LIBDIR)
342 mkdir -p $(DESTDIR)$(INCLUDEDIR)
343 mkdir -p $(DESTDIR)$(MANDIR)/man1
344 mkdir -p $(DESTDIR)$(MANDIR)/man3
345 mkdir -p $(DESTDIR)$(MANDIR)/man5
346 mkdir -p $(DESTDIR)$(MANDIR)/man7
347 $(INSTALL_PROGRAM) mandoc demandoc soelim $(DESTDIR)$(BINDIR)
348 ln -f $(DESTDIR)$(BINDIR)/mandoc $(DESTDIR)$(BINDIR)/$(BINM_MAN)
349 $(INSTALL_LIB) libmandoc.a $(DESTDIR)$(LIBDIR)
350 $(INSTALL_LIB) man.h mandoc.h mandoc_aux.h mdoc.h roff.h \
351 $(DESTDIR)$(INCLUDEDIR)
352 $(INSTALL_MAN) mandoc.1 demandoc.1 soelim.1 $(DESTDIR)$(MANDIR)/man1
353 $(INSTALL_MAN) man.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_MAN).1
354 $(INSTALL_MAN) mandoc.3 mandoc_escape.3 mandoc_malloc.3 \
355 mchars_alloc.3 tbl.3 $(DESTDIR)$(MANDIR)/man3
356 $(INSTALL_MAN) man.conf.5 $(DESTDIR)$(MANDIR)/man5/${MANM_MANCONF}.5
357 $(INSTALL_MAN) man.7 $(DESTDIR)$(MANDIR)/man7/${MANM_MAN}.7
358 $(INSTALL_MAN) mdoc.7 $(DESTDIR)$(MANDIR)/man7/${MANM_MDOC}.7
359 $(INSTALL_MAN) roff.7 $(DESTDIR)$(MANDIR)/man7/${MANM_ROFF}.7
360 $(INSTALL_MAN) eqn.7 $(DESTDIR)$(MANDIR)/man7/${MANM_EQN}.7
361 $(INSTALL_MAN) tbl.7 $(DESTDIR)$(MANDIR)/man7/${MANM_TBL}.7
362 $(INSTALL_MAN) mandoc_char.7 $(DESTDIR)$(MANDIR)/man7
363 $(INSTALL_DATA) example.style.css $(DESTDIR)$(EXAMPLEDIR)
365 db-install: base-build
366 mkdir -p $(DESTDIR)$(BINDIR)
367 mkdir -p $(DESTDIR)$(SBINDIR)
368 mkdir -p $(DESTDIR)$(MANDIR)/man1
369 mkdir -p $(DESTDIR)$(MANDIR)/man3
370 mkdir -p $(DESTDIR)$(MANDIR)/man5
371 mkdir -p $(DESTDIR)$(MANDIR)/man8
372 ln -f $(DESTDIR)$(BINDIR)/mandoc $(DESTDIR)$(BINDIR)/$(BINM_APROPOS)
373 ln -f $(DESTDIR)$(BINDIR)/mandoc $(DESTDIR)$(BINDIR)/$(BINM_WHATIS)
374 ln -f $(DESTDIR)$(BINDIR)/mandoc \
375 $(DESTDIR)$(SBINDIR)/$(BINM_MAKEWHATIS)
376 $(INSTALL_MAN) apropos.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_APROPOS).1
377 ln -f $(DESTDIR)$(MANDIR)/man1/$(BINM_APROPOS).1 \
378 $(DESTDIR)$(MANDIR)/man1/$(BINM_WHATIS).1
379 $(INSTALL_MAN) mansearch.3 $(DESTDIR)$(MANDIR)/man3
380 $(INSTALL_MAN) mandoc.db.5 $(DESTDIR)$(MANDIR)/man5
381 $(INSTALL_MAN) makewhatis.8 \
382 $(DESTDIR)$(MANDIR)/man8/$(BINM_MAKEWHATIS).8
384 cgi-install: cgi-build
385 mkdir -p $(DESTDIR)$(CGIBINDIR)
386 mkdir -p $(DESTDIR)$(HTDOCDIR)
387 mkdir -p $(DESTDIR)$(WWWPREFIX)/man/mandoc/man1
388 mkdir -p $(DESTDIR)$(WWWPREFIX)/man/mandoc/man8
389 $(INSTALL_PROGRAM) man.cgi $(DESTDIR)$(CGIBINDIR)
390 $(INSTALL_DATA) example.style.css $(DESTDIR)$(HTDOCDIR)/man.css
391 $(INSTALL_DATA) man-cgi.css $(DESTDIR)$(HTDOCDIR)
392 $(INSTALL_MAN) apropos.1 $(DESTDIR)$(WWWPREFIX)/man/mandoc/man1/
393 $(INSTALL_MAN) man.cgi.8 $(DESTDIR)$(WWWPREFIX)/man/mandoc/man8/
395 Makefile.local config.h: configure ${TESTSRCS}
396 @echo "$@ is out of date; please run ./configure"
399 libmandoc.a: $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
400 $(AR) rs $@ $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
402 mandoc: $(MAIN_OBJS) libmandoc.a
403 $(CC) $(LDFLAGS) -o $@ $(MAIN_OBJS) libmandoc.a $(DBLIB)
405 manpage: $(MANPAGE_OBJS) libmandoc.a
406 $(CC) $(LDFLAGS) -o $@ $(MANPAGE_OBJS) libmandoc.a $(DBLIB)
408 man.cgi: $(CGI_OBJS) libmandoc.a
409 $(CC) $(LDFLAGS) $(STATIC) -o $@ $(CGI_OBJS) libmandoc.a $(DBLIB)
411 demandoc: $(DEMANDOC_OBJS) libmandoc.a
412 $(CC) $(LDFLAGS) -o $@ $(DEMANDOC_OBJS) libmandoc.a -lz
414 soelim: $(SOELIM_OBJS) compat_reallocarray.o
415 $(CC) $(LDFLAGS) -o $@ $(SOELIM_OBJS) compat_reallocarray.o
417 # --- maintainer targets ---
420 mkdir -p $(HTDOCDIR)/snapshots
421 $(INSTALL_DATA) $(WWW_MANS) style.css $(HTDOCDIR)
422 $(INSTALL_DATA) $(WWW_OBJS) $(HTDOCDIR)/snapshots
423 $(INSTALL_DATA) mdocml.tar.gz \
424 $(HTDOCDIR)/snapshots/mdocml-$(VERSION).tar.gz
425 $(INSTALL_DATA) mdocml.sha256 \
426 $(HTDOCDIR)/snapshots/mdocml-$(VERSION).sha256
429 mkdep -f Makefile.depend $(CFLAGS) $(SRCS)
430 perl -e 'undef $$/; $$_ = <>; s|/usr/include/\S+||g; \
431 s|\\\n||g; s| +| |g; s| $$||mg; print;' \
432 Makefile.depend > Makefile.tmp
433 mv Makefile.tmp Makefile.depend
435 mdocml.sha256: mdocml.tar.gz
436 sha256 mdocml.tar.gz > $@
438 mdocml.tar.gz: $(DISTFILES)
439 mkdir -p .dist/mdocml-$(VERSION)/
440 $(INSTALL) -m 0644 $(DISTFILES) .dist/mdocml-$(VERSION)
441 chmod 755 .dist/mdocml-$(VERSION)/configure
442 ( cd .dist/ && tar zcf ../$@ mdocml-$(VERSION) )
445 # === SUFFIX RULES =====================================================
447 .SUFFIXES: .1 .3 .5 .7 .8 .h
448 .SUFFIXES: .1.html .3.html .5.html .7.html .8.html .h.html
453 .1.1.html .3.3.html .5.5.html .7.7.html .8.8.html: mandoc
454 ./mandoc -Thtml -Wall,stop \
455 -Ostyle=style.css,man=%N.%S.html,includes=%I.html $< > $@