1 # $Id: Makefile,v 1.457 2015/03/13 12:35:32 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 \
30 test-sqlite3_errstr.c \
46 compat_reallocarray.c \
47 compat_sqlite3_errstr.c \
111 configure.local.example \
156 LIBMAN_OBJS = man.o \
161 LIBMDOC_OBJS = att.o \
170 LIBROFF_OBJS = eqn.o \
177 LIBMANDOC_OBJS = $(LIBMAN_OBJS) \
187 COMPAT_OBJS = compat_fgetln.o \
191 compat_reallocarray.o \
192 compat_sqlite3_errstr.o \
193 compat_strcasestr.o \
199 MANDOC_HTML_OBJS = eqn_html.o \
205 MANDOC_MAN_OBJS = mdoc_man.o
207 MANDOC_TERM_OBJS = eqn_term.o \
215 BASE_OBJS = $(MANDOC_HTML_OBJS) \
217 $(MANDOC_TERM_OBJS) \
223 MAIN_OBJS = $(BASE_OBJS)
225 DB_OBJS = mandocdb.o \
229 CGI_OBJS = $(MANDOC_HTML_OBJS) \
235 MANPAGE_OBJS = manpage.o mansearch.o mansearch_const.o manpath.o
237 DEMANDOC_OBJS = demandoc.o
239 WWW_MANS = apropos.1.html \
244 mandoc_escape.3.html \
245 mandoc_headers.3.html \
247 mandoc_malloc.3.html \
249 mchars_alloc.3.html \
267 WWW_OBJS = mdocml.tar.gz \
270 # === USER CONFIGURATION ===============================================
272 include Makefile.local
274 # === DEPENDENCY HANDLING ==============================================
276 all: base-build $(BUILD_TARGETS) Makefile.local
278 base-build: mandoc demandoc
282 install: base-install $(INSTALL_TARGETS)
284 www: $(WWW_OBJS) $(WWW_MANS)
288 .PHONY: base-install cgi-install db-install install www-install
289 .PHONY: clean distclean depend
291 include Makefile.depend
293 # === TARGETS CONTAINING SHELL COMMANDS ================================
296 rm -f Makefile.local config.h config.h.old config.log config.log.old
299 rm -f libmandoc.a $(LIBMANDOC_OBJS) $(COMPAT_OBJS)
300 rm -f mandoc $(BASE_OBJS) $(DB_OBJS)
301 rm -f man.cgi $(CGI_OBJS)
302 rm -f manpage $(MANPAGE_OBJS)
303 rm -f demandoc $(DEMANDOC_OBJS)
304 rm -f $(WWW_MANS) $(WWW_OBJS)
307 base-install: base-build
308 mkdir -p $(DESTDIR)$(BINDIR)
309 mkdir -p $(DESTDIR)$(EXAMPLEDIR)
310 mkdir -p $(DESTDIR)$(LIBDIR)
311 mkdir -p $(DESTDIR)$(INCLUDEDIR)
312 mkdir -p $(DESTDIR)$(MANDIR)/man1
313 mkdir -p $(DESTDIR)$(MANDIR)/man3
314 mkdir -p $(DESTDIR)$(MANDIR)/man7
315 $(INSTALL_PROGRAM) mandoc demandoc $(DESTDIR)$(BINDIR)
316 ln -f $(DESTDIR)$(BINDIR)/mandoc $(DESTDIR)$(BINDIR)/$(BINM_MAN)
317 $(INSTALL_LIB) libmandoc.a $(DESTDIR)$(LIBDIR)
318 $(INSTALL_LIB) man.h mandoc.h mandoc_aux.h mdoc.h \
319 $(DESTDIR)$(INCLUDEDIR)
320 $(INSTALL_MAN) mandoc.1 demandoc.1 $(DESTDIR)$(MANDIR)/man1
321 $(INSTALL_MAN) man.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_MAN).1
322 $(INSTALL_MAN) mandoc.3 mandoc_escape.3 mandoc_malloc.3 \
323 mchars_alloc.3 tbl.3 $(DESTDIR)$(MANDIR)/man3
324 $(INSTALL_MAN) man.7 $(DESTDIR)$(MANDIR)/man7/${MANM_MAN}.7
325 $(INSTALL_MAN) mdoc.7 $(DESTDIR)$(MANDIR)/man7/${MANM_MDOC}.7
326 $(INSTALL_MAN) roff.7 $(DESTDIR)$(MANDIR)/man7/${MANM_ROFF}.7
327 $(INSTALL_MAN) eqn.7 $(DESTDIR)$(MANDIR)/man7/${MANM_EQN}.7
328 $(INSTALL_MAN) tbl.7 $(DESTDIR)$(MANDIR)/man7/${MANM_TBL}.7
329 $(INSTALL_MAN) mandoc_char.7 $(DESTDIR)$(MANDIR)/man7
330 $(INSTALL_DATA) example.style.css $(DESTDIR)$(EXAMPLEDIR)
332 db-install: base-build
333 mkdir -p $(DESTDIR)$(BINDIR)
334 mkdir -p $(DESTDIR)$(SBINDIR)
335 mkdir -p $(DESTDIR)$(MANDIR)/man1
336 mkdir -p $(DESTDIR)$(MANDIR)/man3
337 mkdir -p $(DESTDIR)$(MANDIR)/man5
338 mkdir -p $(DESTDIR)$(MANDIR)/man8
339 ln -f $(DESTDIR)$(BINDIR)/mandoc $(DESTDIR)$(BINDIR)/$(BINM_APROPOS)
340 ln -f $(DESTDIR)$(BINDIR)/mandoc $(DESTDIR)$(BINDIR)/$(BINM_WHATIS)
341 ln -f $(DESTDIR)$(BINDIR)/mandoc \
342 $(DESTDIR)$(SBINDIR)/$(BINM_MAKEWHATIS)
343 $(INSTALL_MAN) apropos.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_APROPOS).1
344 ln -f $(DESTDIR)$(MANDIR)/man1/$(BINM_APROPOS).1 \
345 $(DESTDIR)$(MANDIR)/man1/$(BINM_WHATIS).1
346 $(INSTALL_MAN) mansearch.3 $(DESTDIR)$(MANDIR)/man3
347 $(INSTALL_MAN) mandoc.db.5 $(DESTDIR)$(MANDIR)/man5
348 $(INSTALL_MAN) makewhatis.8 \
349 $(DESTDIR)$(MANDIR)/man8/$(BINM_MAKEWHATIS).8
351 cgi-install: cgi-build
352 mkdir -p $(DESTDIR)$(CGIBINDIR)
353 mkdir -p $(DESTDIR)$(HTDOCDIR)
354 mkdir -p $(DESTDIR)$(WWWPREFIX)/man/mandoc/man1
355 mkdir -p $(DESTDIR)$(WWWPREFIX)/man/mandoc/man8
356 $(INSTALL_PROGRAM) man.cgi $(DESTDIR)$(CGIBINDIR)
357 $(INSTALL_DATA) example.style.css $(DESTDIR)$(HTDOCDIR)/man.css
358 $(INSTALL_DATA) man-cgi.css $(DESTDIR)$(HTDOCDIR)
359 $(INSTALL_MAN) apropos.1 $(DESTDIR)$(WWWPREFIX)/man/mandoc/man1/
360 $(INSTALL_MAN) man.cgi.8 $(DESTDIR)$(WWWPREFIX)/man/mandoc/man8/
362 Makefile.local config.h: configure ${TESTSRCS}
363 @echo "$@ is out of date; please run ./configure"
366 libmandoc.a: $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
367 $(AR) rs $@ $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
369 mandoc: $(MAIN_OBJS) libmandoc.a
370 $(CC) $(LDFLAGS) -o $@ $(MAIN_OBJS) libmandoc.a $(DBLIB)
372 manpage: $(MANPAGE_OBJS) libmandoc.a
373 $(CC) $(LDFLAGS) -o $@ $(MANPAGE_OBJS) libmandoc.a $(DBLIB)
375 man.cgi: $(CGI_OBJS) libmandoc.a
376 $(CC) $(LDFLAGS) $(STATIC) -o $@ $(CGI_OBJS) libmandoc.a $(DBLIB)
378 demandoc: $(DEMANDOC_OBJS) libmandoc.a
379 $(CC) $(LDFLAGS) -o $@ $(DEMANDOC_OBJS) libmandoc.a
381 # --- maintainer targets ---
384 mkdir -p $(HTDOCDIR)/snapshots
385 $(INSTALL_DATA) $(WWW_MANS) style.css $(HTDOCDIR)
386 $(INSTALL_DATA) $(WWW_OBJS) $(HTDOCDIR)/snapshots
387 $(INSTALL_DATA) mdocml.tar.gz \
388 $(HTDOCDIR)/snapshots/mdocml-$(VERSION).tar.gz
389 $(INSTALL_DATA) mdocml.sha256 \
390 $(HTDOCDIR)/snapshots/mdocml-$(VERSION).sha256
393 mkdep -f Makefile.depend $(CFLAGS) $(SRCS)
394 perl -e 'undef $$/; $$_ = <>; s|/usr/include/\S+||g; \
395 s|\\\n||g; s| +| |g; s| $$||mg; print;' \
396 Makefile.depend > Makefile.tmp
397 mv Makefile.tmp Makefile.depend
399 mdocml.sha256: mdocml.tar.gz
400 sha256 mdocml.tar.gz > $@
402 mdocml.tar.gz: $(DISTFILES)
403 mkdir -p .dist/mdocml-$(VERSION)/
404 $(INSTALL) -m 0644 $(DISTFILES) .dist/mdocml-$(VERSION)
405 chmod 755 .dist/mdocml-$(VERSION)/configure
406 ( cd .dist/ && tar zcf ../$@ mdocml-$(VERSION) )
409 # === SUFFIX RULES =====================================================
411 .SUFFIXES: .1 .3 .5 .7 .8 .h
412 .SUFFIXES: .1.html .3.html .5.html .7.html .8.html .h.html
417 .1.1.html .3.3.html .5.5.html .7.7.html .8.8.html: mandoc
418 ./mandoc -Thtml -Wall,stop \
419 -Ostyle=style.css,man=%N.%S.html,includes=%I.html $< > $@