1 # $Id: Makefile,v 1.453 2014/12/09 09:14:33 schwarze Exp $
3 # Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
4 # Copyright (c) 2011, 2013, 2014 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.
18 # === LIST OF FILES ====================================================
20 TESTSRCS = test-dirent-namlen.c \
28 test-sqlite3_errstr.c \
43 compat_reallocarray.c \
44 compat_sqlite3_errstr.c \
107 configure.local.example \
152 LIBMAN_OBJS = man.o \
157 LIBMDOC_OBJS = att.o \
166 LIBROFF_OBJS = eqn.o \
173 LIBMANDOC_OBJS = $(LIBMAN_OBJS) \
183 COMPAT_OBJS = compat_fgetln.o \
187 compat_reallocarray.o \
188 compat_sqlite3_errstr.o \
189 compat_strcasestr.o \
194 MANDOC_HTML_OBJS = eqn_html.o \
200 MANDOC_MAN_OBJS = mdoc_man.o
202 MANDOC_TERM_OBJS = eqn_term.o \
210 BASE_OBJS = $(MANDOC_HTML_OBJS) \
212 $(MANDOC_TERM_OBJS) \
217 MAIN_OBJS = $(BASE_OBJS)
219 DB_OBJS = mandocdb.o \
224 CGI_OBJS = $(MANDOC_HTML_OBJS) \
230 MANPAGE_OBJS = manpage.o mansearch.o mansearch_const.o manpath.o
232 DEMANDOC_OBJS = demandoc.o
234 WWW_MANS = apropos.1.html \
239 mandoc_escape.3.html \
240 mandoc_headers.3.html \
242 mandoc_malloc.3.html \
244 mchars_alloc.3.html \
262 WWW_OBJS = mdocml.tar.gz \
265 # === USER CONFIGURATION ===============================================
267 include Makefile.local
269 # === DEPENDENCY HANDLING ==============================================
271 all: base-build $(BUILD_TARGETS) Makefile.local
273 base-build: mandoc demandoc
277 install: base-install $(INSTALL_TARGETS)
279 www: $(WWW_OBJS) $(WWW_MANS)
283 .PHONY: base-install cgi-install db-install install www-install
284 .PHONY: clean distclean depend
286 include Makefile.depend
288 # === TARGETS CONTAINING SHELL COMMANDS ================================
291 rm -f Makefile.local config.h config.h.old config.log config.log.old
294 rm -f libmandoc.a $(LIBMANDOC_OBJS) $(COMPAT_OBJS)
295 rm -f mandoc $(BASE_OBJS) $(DB_OBJS)
296 rm -f man.cgi $(CGI_OBJS)
297 rm -f manpage $(MANPAGE_OBJS)
298 rm -f demandoc $(DEMANDOC_OBJS)
299 rm -f $(WWW_MANS) $(WWW_OBJS)
302 base-install: base-build
303 mkdir -p $(DESTDIR)$(BINDIR)
304 mkdir -p $(DESTDIR)$(EXAMPLEDIR)
305 mkdir -p $(DESTDIR)$(LIBDIR)
306 mkdir -p $(DESTDIR)$(INCLUDEDIR)
307 mkdir -p $(DESTDIR)$(MANDIR)/man1
308 mkdir -p $(DESTDIR)$(MANDIR)/man3
309 mkdir -p $(DESTDIR)$(MANDIR)/man7
310 $(INSTALL_PROGRAM) mandoc demandoc $(DESTDIR)$(BINDIR)
311 $(INSTALL_LIB) libmandoc.a $(DESTDIR)$(LIBDIR)
312 $(INSTALL_LIB) man.h mandoc.h mandoc_aux.h mdoc.h \
313 $(DESTDIR)$(INCLUDEDIR)
314 $(INSTALL_MAN) mandoc.1 demandoc.1 $(DESTDIR)$(MANDIR)/man1
315 $(INSTALL_MAN) mandoc.3 mandoc_escape.3 mandoc_malloc.3 \
316 mchars_alloc.3 tbl.3 $(DESTDIR)$(MANDIR)/man3
317 $(INSTALL_MAN) man.7 $(DESTDIR)$(MANDIR)/man7/${MANM_MAN}.7
318 $(INSTALL_MAN) mdoc.7 $(DESTDIR)$(MANDIR)/man7/${MANM_MDOC}.7
319 $(INSTALL_MAN) roff.7 $(DESTDIR)$(MANDIR)/man7/${MANM_ROFF}.7
320 $(INSTALL_MAN) eqn.7 $(DESTDIR)$(MANDIR)/man7/${MANM_EQN}.7
321 $(INSTALL_MAN) tbl.7 $(DESTDIR)$(MANDIR)/man7/${MANM_TBL}.7
322 $(INSTALL_MAN) mandoc_char.7 $(DESTDIR)$(MANDIR)/man7
323 $(INSTALL_DATA) example.style.css $(DESTDIR)$(EXAMPLEDIR)
325 db-install: base-build
326 mkdir -p $(DESTDIR)$(BINDIR)
327 mkdir -p $(DESTDIR)$(SBINDIR)
328 mkdir -p $(DESTDIR)$(MANDIR)/man1
329 mkdir -p $(DESTDIR)$(MANDIR)/man3
330 mkdir -p $(DESTDIR)$(MANDIR)/man5
331 mkdir -p $(DESTDIR)$(MANDIR)/man8
332 ln -f $(DESTDIR)$(BINDIR)/mandoc $(DESTDIR)$(BINDIR)/$(BINM_APROPOS)
333 ln -f $(DESTDIR)$(BINDIR)/mandoc $(DESTDIR)$(BINDIR)/$(BINM_MAN)
334 ln -f $(DESTDIR)$(BINDIR)/mandoc $(DESTDIR)$(BINDIR)/$(BINM_WHATIS)
335 ln -f $(DESTDIR)$(BINDIR)/mandoc \
336 $(DESTDIR)$(SBINDIR)/$(BINM_MAKEWHATIS)
337 $(INSTALL_MAN) apropos.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_APROPOS).1
338 $(INSTALL_MAN) man.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_MAN).1
339 ln -f $(DESTDIR)$(MANDIR)/man1/$(BINM_APROPOS).1 \
340 $(DESTDIR)$(MANDIR)/man1/$(BINM_WHATIS).1
341 $(INSTALL_MAN) mansearch.3 $(DESTDIR)$(MANDIR)/man3
342 $(INSTALL_MAN) mandoc.db.5 $(DESTDIR)$(MANDIR)/man5
343 $(INSTALL_MAN) makewhatis.8 \
344 $(DESTDIR)$(MANDIR)/man8/$(BINM_MAKEWHATIS).8
346 cgi-install: cgi-build
347 mkdir -p $(DESTDIR)$(CGIBINDIR)
348 mkdir -p $(DESTDIR)$(HTDOCDIR)
349 mkdir -p $(DESTDIR)$(WWWPREFIX)/man/mandoc/man1
350 mkdir -p $(DESTDIR)$(WWWPREFIX)/man/mandoc/man8
351 $(INSTALL_PROGRAM) man.cgi $(DESTDIR)$(CGIBINDIR)
352 $(INSTALL_DATA) example.style.css $(DESTDIR)$(HTDOCDIR)/man.css
353 $(INSTALL_DATA) man-cgi.css $(DESTDIR)$(HTDOCDIR)
354 $(INSTALL_MAN) apropos.1 $(DESTDIR)$(WWWPREFIX)/man/mandoc/man1/
355 $(INSTALL_MAN) man.cgi.8 $(DESTDIR)$(WWWPREFIX)/man/mandoc/man8/
357 Makefile.local config.h: configure ${TESTSRCS}
358 @echo "$@ is out of date; please run ./configure"
361 libmandoc.a: $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
362 $(AR) rs $@ $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
364 mandoc: $(MAIN_OBJS) libmandoc.a
365 $(CC) $(LDFLAGS) -o $@ $(MAIN_OBJS) libmandoc.a $(DBLIB)
367 manpage: $(MANPAGE_OBJS) libmandoc.a
368 $(CC) $(LDFLAGS) -o $@ $(MANPAGE_OBJS) libmandoc.a $(DBLIB)
370 man.cgi: $(CGI_OBJS) libmandoc.a
371 $(CC) $(LDFLAGS) $(STATIC) -o $@ $(CGI_OBJS) libmandoc.a $(DBLIB)
373 demandoc: $(DEMANDOC_OBJS) libmandoc.a
374 $(CC) $(LDFLAGS) -o $@ $(DEMANDOC_OBJS) libmandoc.a
376 # --- maintainer targets ---
379 mkdir -p $(HTDOCDIR)/snapshots
380 $(INSTALL_DATA) $(WWW_MANS) style.css $(HTDOCDIR)
381 $(INSTALL_DATA) $(WWW_OBJS) $(HTDOCDIR)/snapshots
382 $(INSTALL_DATA) mdocml.tar.gz \
383 $(HTDOCDIR)/snapshots/mdocml-$(VERSION).tar.gz
384 $(INSTALL_DATA) mdocml.sha256 \
385 $(HTDOCDIR)/snapshots/mdocml-$(VERSION).sha256
388 mkdep -f Makefile.depend $(CFLAGS) $(SRCS)
389 perl -e 'undef $$/; $$_ = <>; s|/usr/include/\S+||g; \
390 s|\\\n||g; s| +| |g; s| $$||mg; print;' \
391 Makefile.depend > Makefile.tmp
392 mv Makefile.tmp Makefile.depend
394 mdocml.sha256: mdocml.tar.gz
395 sha256 mdocml.tar.gz > $@
397 mdocml.tar.gz: $(DISTFILES)
398 mkdir -p .dist/mdocml-$(VERSION)/
399 $(INSTALL) -m 0644 $(DISTFILES) .dist/mdocml-$(VERSION)
400 chmod 755 .dist/mdocml-$(VERSION)/configure
401 ( cd .dist/ && tar zcf ../$@ mdocml-$(VERSION) )
404 # === SUFFIX RULES =====================================================
406 .SUFFIXES: .1 .3 .5 .7 .8 .h
407 .SUFFIXES: .1.html .3.html .5.html .7.html .8.html .h.html
412 .1.1.html .3.3.html .5.5.html .7.7.html .8.8.html: mandoc
413 ./mandoc -Thtml -Wall,stop \
414 -Ostyle=style.css,man=%N.%S.html,includes=%I.html $< > $@