1 # $Id: Makefile,v 1.449 2014/12/01 08:09:26 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 BASEBIN = mandoc demandoc
22 TESTSRCS = test-dirent-namlen.c \
30 test-sqlite3_errstr.c \
45 compat_reallocarray.c \
46 compat_sqlite3_errstr.c \
109 configure.local.example \
154 LIBMAN_OBJS = man.o \
159 LIBMDOC_OBJS = att.o \
168 LIBROFF_OBJS = eqn.o \
175 LIBMANDOC_OBJS = $(LIBMAN_OBJS) \
185 COMPAT_OBJS = compat_fgetln.o \
189 compat_reallocarray.o \
190 compat_sqlite3_errstr.o \
191 compat_strcasestr.o \
196 MANDOC_HTML_OBJS = eqn_html.o \
202 MANDOC_MAN_OBJS = mdoc_man.o
204 MANDOC_TERM_OBJS = eqn_term.o \
212 MANDOC_OBJS = $(MANDOC_HTML_OBJS) \
214 $(MANDOC_TERM_OBJS) \
219 MAN_OBJS = $(MANDOC_OBJS)
221 MAKEWHATIS_OBJS = mandocdb.o mansearch_const.o manpath.o
223 APROPOS_OBJS = mansearch.o mansearch_const.o manpath.o
225 CGI_OBJS = $(MANDOC_HTML_OBJS) \
231 MANPAGE_OBJS = manpage.o mansearch.o mansearch_const.o manpath.o
233 DEMANDOC_OBJS = demandoc.o
235 WWW_MANS = apropos.1.html \
240 mandoc_escape.3.html \
241 mandoc_headers.3.html \
243 mandoc_malloc.3.html \
245 mchars_alloc.3.html \
263 WWW_OBJS = mdocml.tar.gz \
266 include Makefile.local
268 INSTALL_TARGETS = $(BUILD_TARGETS:-build=-install)
270 # === DEPENDENCY HANDLING ==============================================
272 all: base-build $(BUILD_TARGETS) Makefile.local
274 base-build: $(BASEBIN)
280 install: base-install $(INSTALL_TARGETS)
282 www: $(WWW_OBJS) $(WWW_MANS)
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 $(MANDOC_OBJS) $(APROPOS_OBJS)
296 rm -f makewhatis $(MAKEWHATIS_OBJS)
297 rm -f man.cgi $(CGI_OBJS)
298 rm -f manpage $(MANPAGE_OBJS)
299 rm -f demandoc $(DEMANDOC_OBJS)
300 rm -f $(WWW_MANS) $(WWW_OBJS)
303 base-install: base-build
304 mkdir -p $(DESTDIR)$(BINDIR)
305 mkdir -p $(DESTDIR)$(EXAMPLEDIR)
306 mkdir -p $(DESTDIR)$(LIBDIR)
307 mkdir -p $(DESTDIR)$(INCLUDEDIR)
308 mkdir -p $(DESTDIR)$(MANDIR)/man1
309 mkdir -p $(DESTDIR)$(MANDIR)/man3
310 mkdir -p $(DESTDIR)$(MANDIR)/man7
311 $(INSTALL_PROGRAM) $(BASEBIN) $(DESTDIR)$(BINDIR)
312 $(INSTALL_LIB) libmandoc.a $(DESTDIR)$(LIBDIR)
313 $(INSTALL_LIB) man.h mandoc.h mandoc_aux.h mdoc.h \
314 $(DESTDIR)$(INCLUDEDIR)
315 $(INSTALL_MAN) man.1 mandoc.1 demandoc.1 \
316 $(DESTDIR)$(MANDIR)/man1
317 $(INSTALL_MAN) mandoc.3 mandoc_escape.3 mandoc_malloc.3 \
318 mchars_alloc.3 tbl.3 $(DESTDIR)$(MANDIR)/man3
319 $(INSTALL_MAN) man.7 mdoc.7 roff.7 eqn.7 tbl.7 mandoc_char.7 \
320 $(DESTDIR)$(MANDIR)/man7
321 $(INSTALL_DATA) example.style.css $(DESTDIR)$(EXAMPLEDIR)
324 mkdir -p $(DESTDIR)$(BINDIR)
325 mkdir -p $(DESTDIR)$(SBINDIR)
326 mkdir -p $(DESTDIR)$(MANDIR)/man1
327 mkdir -p $(DESTDIR)$(MANDIR)/man3
328 mkdir -p $(DESTDIR)$(MANDIR)/man5
329 mkdir -p $(DESTDIR)$(MANDIR)/man8
330 ln -f $(DESTDIR)$(BINDIR)/mandoc $(DESTDIR)$(BINDIR)/apropos
331 ln -f $(DESTDIR)$(BINDIR)/mandoc $(DESTDIR)$(BINDIR)/whatis
332 $(INSTALL_PROGRAM) makewhatis $(DESTDIR)$(SBINDIR)
333 $(INSTALL_MAN) apropos.1 $(DESTDIR)$(MANDIR)/man1
334 ln -f $(DESTDIR)$(MANDIR)/man1/apropos.1 \
335 $(DESTDIR)$(MANDIR)/man1/whatis.1
336 $(INSTALL_MAN) mansearch.3 $(DESTDIR)$(MANDIR)/man3
337 $(INSTALL_MAN) mandoc.db.5 $(DESTDIR)$(MANDIR)/man5
338 $(INSTALL_MAN) makewhatis.8 $(DESTDIR)$(MANDIR)/man8
340 cgi-install: cgi-build
341 mkdir -p $(DESTDIR)$(CGIBINDIR)
342 mkdir -p $(DESTDIR)$(HTDOCDIR)
343 mkdir -p $(DESTDIR)$(WWWPREFIX)/man/mandoc/man1
344 mkdir -p $(DESTDIR)$(WWWPREFIX)/man/mandoc/man8
345 $(INSTALL_PROGRAM) man.cgi $(DESTDIR)$(CGIBINDIR)
346 $(INSTALL_DATA) example.style.css $(DESTDIR)$(HTDOCDIR)/man.css
347 $(INSTALL_DATA) man-cgi.css $(DESTDIR)$(HTDOCDIR)
348 $(INSTALL_MAN) apropos.1 $(DESTDIR)$(WWWPREFIX)/man/mandoc/man1/
349 $(INSTALL_MAN) man.cgi.8 $(DESTDIR)$(WWWPREFIX)/man/mandoc/man8/
352 mkdir -p $(DESTDIR)$(HTDOCDIR)/snapshots
353 $(INSTALL_DATA) $(WWW_MANS) style.css $(DESTDIR)$(HTDOCDIR)
354 $(INSTALL_DATA) $(WWW_OBJS) $(DESTDIR)$(HTDOCDIR)/snapshots
355 $(INSTALL_DATA) mdocml.tar.gz \
356 $(DESTDIR)$(HTDOCDIR)/snapshots/mdocml-$(VERSION).tar.gz
357 $(INSTALL_DATA) mdocml.sha256 \
358 $(DESTDIR)$(HTDOCDIR)/snapshots/mdocml-$(VERSION).sha256
360 Makefile.local config.h: configure ${TESTSRCS}
361 @echo "$@ is out of date; please run ./configure"
365 mkdep -f Makefile.depend $(CFLAGS) $(SRCS)
366 perl -e 'undef $$/; $$_ = <>; s|/usr/include/\S+||g; \
367 s|\\\n||g; s| +| |g; s| $$||mg; print;' \
368 Makefile.depend > Makefile.tmp
369 mv Makefile.tmp Makefile.depend
371 libmandoc.a: $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
372 $(AR) rs $@ $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
374 mandoc: $(MAN_OBJS) libmandoc.a
375 $(CC) $(LDFLAGS) -o $@ $(MAN_OBJS) libmandoc.a $(DBLIB)
377 makewhatis: $(MAKEWHATIS_OBJS) libmandoc.a
378 $(CC) $(LDFLAGS) -o $@ $(MAKEWHATIS_OBJS) libmandoc.a $(DBLIB)
380 manpage: $(MANPAGE_OBJS) libmandoc.a
381 $(CC) $(LDFLAGS) -o $@ $(MANPAGE_OBJS) libmandoc.a $(DBLIB)
383 man.cgi: $(CGI_OBJS) libmandoc.a
384 $(CC) $(LDFLAGS) $(STATIC) -o $@ $(CGI_OBJS) libmandoc.a $(DBLIB)
386 demandoc: $(DEMANDOC_OBJS) libmandoc.a
387 $(CC) $(LDFLAGS) -o $@ $(DEMANDOC_OBJS) libmandoc.a
389 mdocml.sha256: mdocml.tar.gz
390 sha256 mdocml.tar.gz > $@
392 mdocml.tar.gz: $(DISTFILES)
393 mkdir -p .dist/mdocml-$(VERSION)/
394 $(INSTALL) -m 0644 $(DISTFILES) .dist/mdocml-$(VERSION)
395 chmod 755 .dist/mdocml-$(VERSION)/configure
396 ( cd .dist/ && tar zcf ../$@ mdocml-$(VERSION) )
399 .PHONY: base-install cgi-install db-install install www-install
400 .PHONY: clean distclean depend
401 .SUFFIXES: .1 .3 .5 .7 .8 .h
402 .SUFFIXES: .1.html .3.html .5.html .7.html .8.html .h.html
407 .1.1.html .3.3.html .5.5.html .7.7.html .8.8.html: mandoc
408 ./mandoc -Thtml -Wall,stop \
409 -Ostyle=style.css,man=%N.%S.html,includes=%I.html $< > $@