1 # $Id: Makefile,v 1.445 2014/10/25 01:03:52 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 \
46 compat_reallocarray.c \
47 compat_sqlite3_errstr.c \
113 configure.local.example \
158 LIBMAN_OBJS = man.o \
163 LIBMDOC_OBJS = arch.o \
174 LIBROFF_OBJS = eqn.o \
181 LIBMANDOC_OBJS = $(LIBMAN_OBJS) \
191 COMPAT_OBJS = compat_fgetln.o \
195 compat_reallocarray.o \
196 compat_sqlite3_errstr.o \
197 compat_strcasestr.o \
202 MANDOC_HTML_OBJS = eqn_html.o \
208 MANDOC_MAN_OBJS = mdoc_man.o
210 MANDOC_TERM_OBJS = eqn_term.o \
218 MANDOC_OBJS = $(MANDOC_HTML_OBJS) \
220 $(MANDOC_TERM_OBJS) \
225 MAN_OBJS = $(MANDOC_OBJS)
227 MAKEWHATIS_OBJS = mandocdb.o mansearch_const.o manpath.o
229 APROPOS_OBJS = mansearch.o mansearch_const.o manpath.o
231 CGI_OBJS = $(MANDOC_HTML_OBJS) \
237 MANPAGE_OBJS = manpage.o mansearch.o mansearch_const.o manpath.o
239 DEMANDOC_OBJS = demandoc.o
241 WWW_MANS = apropos.1.html \
246 mandoc_escape.3.html \
248 mandoc_malloc.3.html \
250 mchars_alloc.3.html \
268 WWW_OBJS = mdocml.tar.gz \
271 include Makefile.local
273 INSTALL_TARGETS = $(BUILD_TARGETS:-build=-install)
275 # === DEPENDENCY HANDLING ==============================================
277 all: base-build $(BUILD_TARGETS) Makefile.local
279 base-build: $(BASEBIN)
285 install: base-install $(INSTALL_TARGETS)
287 www: $(WWW_OBJS) $(WWW_MANS)
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 $(MANDOC_OBJS) $(APROPOS_OBJS)
301 rm -f makewhatis $(MAKEWHATIS_OBJS)
302 rm -f man.cgi $(CGI_OBJS)
303 rm -f manpage $(MANPAGE_OBJS)
304 rm -f demandoc $(DEMANDOC_OBJS)
305 rm -f $(WWW_MANS) $(WWW_OBJS)
308 base-install: base-build
309 mkdir -p $(DESTDIR)$(BINDIR)
310 mkdir -p $(DESTDIR)$(EXAMPLEDIR)
311 mkdir -p $(DESTDIR)$(LIBDIR)
312 mkdir -p $(DESTDIR)$(INCLUDEDIR)
313 mkdir -p $(DESTDIR)$(MANDIR)/man1
314 mkdir -p $(DESTDIR)$(MANDIR)/man3
315 mkdir -p $(DESTDIR)$(MANDIR)/man7
316 $(INSTALL_PROGRAM) $(BASEBIN) $(DESTDIR)$(BINDIR)
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) man.1 mandoc.1 demandoc.1 \
321 $(DESTDIR)$(MANDIR)/man1
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 mdoc.7 roff.7 eqn.7 tbl.7 mandoc_char.7 \
325 $(DESTDIR)$(MANDIR)/man7
326 $(INSTALL_DATA) example.style.css $(DESTDIR)$(EXAMPLEDIR)
329 mkdir -p $(DESTDIR)$(BINDIR)
330 mkdir -p $(DESTDIR)$(SBINDIR)
331 mkdir -p $(DESTDIR)$(MANDIR)/man1
332 mkdir -p $(DESTDIR)$(MANDIR)/man3
333 mkdir -p $(DESTDIR)$(MANDIR)/man5
334 mkdir -p $(DESTDIR)$(MANDIR)/man8
335 ln -f $(DESTDIR)$(BINDIR)/mandoc $(DESTDIR)$(BINDIR)/apropos
336 ln -f $(DESTDIR)$(BINDIR)/mandoc $(DESTDIR)$(BINDIR)/whatis
337 $(INSTALL_PROGRAM) makewhatis $(DESTDIR)$(SBINDIR)
338 $(INSTALL_MAN) apropos.1 $(DESTDIR)$(MANDIR)/man1
339 ln -f $(DESTDIR)$(MANDIR)/man1/apropos.1 \
340 $(DESTDIR)$(MANDIR)/man1/whatis.1
341 $(INSTALL_MAN) mansearch.3 $(DESTDIR)$(MANDIR)/man3
342 $(INSTALL_MAN) mandoc.db.5 $(DESTDIR)$(MANDIR)/man5
343 $(INSTALL_MAN) makewhatis.8 $(DESTDIR)$(MANDIR)/man8
345 cgi-install: cgi-build
346 mkdir -p $(DESTDIR)$(CGIBINDIR)
347 mkdir -p $(DESTDIR)$(HTDOCDIR)
348 mkdir -p $(DESTDIR)$(WWWPREFIX)/man/mandoc/man1
349 mkdir -p $(DESTDIR)$(WWWPREFIX)/man/mandoc/man8
350 $(INSTALL_PROGRAM) man.cgi $(DESTDIR)$(CGIBINDIR)
351 $(INSTALL_DATA) example.style.css $(DESTDIR)$(HTDOCDIR)/man.css
352 $(INSTALL_DATA) man-cgi.css $(DESTDIR)$(HTDOCDIR)
353 $(INSTALL_MAN) apropos.1 $(DESTDIR)$(WWWPREFIX)/man/mandoc/man1/
354 $(INSTALL_MAN) man.cgi.8 $(DESTDIR)$(WWWPREFIX)/man/mandoc/man8/
357 mkdir -p $(DESTDIR)$(HTDOCDIR)/snapshots
358 $(INSTALL_DATA) $(WWW_MANS) style.css $(DESTDIR)$(HTDOCDIR)
359 $(INSTALL_DATA) $(WWW_OBJS) $(DESTDIR)$(HTDOCDIR)/snapshots
360 $(INSTALL_DATA) mdocml.tar.gz \
361 $(DESTDIR)$(HTDOCDIR)/snapshots/mdocml-$(VERSION).tar.gz
362 $(INSTALL_DATA) mdocml.sha256 \
363 $(DESTDIR)$(HTDOCDIR)/snapshots/mdocml-$(VERSION).sha256
365 Makefile.local config.h: configure ${TESTSRCS}
366 @echo "$@ is out of date; please run ./configure"
370 mkdep -f Makefile.depend $(CFLAGS) $(SRCS)
371 perl -e 'undef $$/; $$_ = <>; s|/usr/include/\S+||g; \
372 s|\\\n||g; s| +| |g; s| $$||mg; print;' \
373 Makefile.depend > Makefile.tmp
374 mv Makefile.tmp Makefile.depend
376 libmandoc.a: $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
377 $(AR) rs $@ $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
379 mandoc: $(MAN_OBJS) libmandoc.a
380 $(CC) $(LDFLAGS) -o $@ $(MAN_OBJS) libmandoc.a $(DBLIB)
382 makewhatis: $(MAKEWHATIS_OBJS) libmandoc.a
383 $(CC) $(LDFLAGS) -o $@ $(MAKEWHATIS_OBJS) libmandoc.a $(DBLIB)
385 manpage: $(MANPAGE_OBJS) libmandoc.a
386 $(CC) $(LDFLAGS) -o $@ $(MANPAGE_OBJS) libmandoc.a $(DBLIB)
388 man.cgi: $(CGI_OBJS) libmandoc.a
389 $(CC) $(LDFLAGS) $(STATIC) -o $@ $(CGI_OBJS) libmandoc.a $(DBLIB)
391 demandoc: $(DEMANDOC_OBJS) libmandoc.a
392 $(CC) $(LDFLAGS) -o $@ $(DEMANDOC_OBJS) libmandoc.a
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 .PHONY: base-install cgi-install db-install install www-install
405 .PHONY: clean distclean depend
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 $< > $@