]> git.cameronkatri.com Git - mandoc.git/blob - Makefile
Sync library documentation with reality.
[mandoc.git] / Makefile
1 # $Id: Makefile,v 1.430 2014/08/05 05:48:56 schwarze Exp $
2 #
3 # Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
4 # Copyright (c) 2011, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
5 #
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.
9 #
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.
17
18 VERSION = 1.13.0
19
20 # === USER SETTINGS ====================================================
21
22 # --- user settings relevant for all builds ----------------------------
23
24 # Specify this if you want to hard-code the operating system to appear
25 # in the lower-left hand corner of -mdoc manuals.
26 #
27 # CFLAGS += -DOSNAME="\"OpenBSD 5.5\""
28
29 # IFF your system supports multi-byte functions (setlocale(), wcwidth(),
30 # putwchar()) AND has __STDC_ISO_10646__ (that is, wchar_t is simply a
31 # UCS-4 value) should you define USE_WCHAR. If you define it and your
32 # system DOESN'T support this, -Tlocale will produce garbage.
33 # If you don't define it, -Tlocale is a synonym for -Tacsii.
34 #
35 CFLAGS += -DUSE_WCHAR
36
37 CFLAGS += -g -DHAVE_CONFIG_H
38 CFLAGS += -W -Wall -Wstrict-prototypes -Wno-unused-parameter -Wwrite-strings
39 PREFIX = /usr/local
40 BINDIR = $(PREFIX)/bin
41 INCLUDEDIR = $(PREFIX)/include/mandoc
42 LIBDIR = $(PREFIX)/lib/mandoc
43 MANDIR = $(PREFIX)/man
44 EXAMPLEDIR = $(PREFIX)/share/examples/mandoc
45
46 INSTALL = install
47 INSTALL_PROGRAM = $(INSTALL) -m 0555
48 INSTALL_DATA = $(INSTALL) -m 0444
49 INSTALL_LIB = $(INSTALL) -m 0444
50 INSTALL_SOURCE = $(INSTALL) -m 0644
51 INSTALL_MAN = $(INSTALL_DATA)
52
53 # --- user settings related to database support ------------------------
54
55 # If you want to build without database support, for example to avoid
56 # the dependency on SQLite3, comment the following line.
57 # However, you won't get apropos(1) and makewhatis(8) in that case.
58 #
59 BUILD_TARGETS += db-build
60
61 # The remaining settings in this section
62 # are only relevant if db-build is enabled.
63 # Otherwise, they have no effect either way.
64
65 # If your system has manpath(1), uncomment this. This is most any
66 # system that's not OpenBSD or NetBSD. If uncommented, apropos(1)
67 # and makewhatis(8) will use manpath(1) to get the MANPATH variable.
68 #
69 #CFLAGS += -DUSE_MANPATH
70
71 # On some systems, SQLite3 may be installed below /usr/local.
72 # In that case, uncomment the following two lines.
73 #
74 #CFLAGS += -I/usr/local/include
75 #DBLIB += -L/usr/local/lib
76
77 # OpenBSD has the ohash functions in libutil.
78 # Comment the following line if your system doesn't.
79 #
80 DBLIB += -lutil
81
82 SBINDIR = $(PREFIX)/sbin
83
84 # --- user settings related to man.cgi ---------------------------------
85
86 # To build man.cgi, copy cgi.h.example to cgi.h, edit it,
87 # and enable the following line.
88 # Obviously, this requires that db-build is enabled, too.
89 #
90 #BUILD_TARGETS += cgi-build
91
92 # The remaining settings in this section
93 # are only relevant if cgi-build is enabled.
94 # Otherwise, they have no effect either way.
95
96 # If your system does not support static binaries, comment this,
97 # for example on Mac OS X.
98 #
99 STATIC = -static
100
101 # Linux requires -pthread for statical linking.
102 #
103 #STATIC += -pthread
104
105 WWWPREFIX = /var/www
106 HTDOCDIR = $(WWWPREFIX)/htdocs
107 CGIBINDIR = $(WWWPREFIX)/cgi-bin
108
109 # === END OF USER SETTINGS =============================================
110
111 INSTALL_TARGETS = $(BUILD_TARGETS:-build=-install)
112
113 BASEBIN = mandoc preconv demandoc
114 DBBIN = apropos makewhatis
115 CGIBIN = man.cgi
116
117 DBLIB += -lsqlite3
118
119 TESTSRCS = test-fgetln.c \
120 test-getsubopt.c \
121 test-mmap.c \
122 test-ohash.c \
123 test-reallocarray.c \
124 test-strcasestr.c \
125 test-strlcat.c \
126 test-strlcpy.c \
127 test-strptime.c \
128 test-strsep.c
129
130 SRCS = apropos.c \
131 arch.c \
132 att.c \
133 cgi.c \
134 chars.c \
135 compat_fgetln.c \
136 compat_getsubopt.c \
137 compat_ohash.c \
138 compat_reallocarray.c \
139 compat_strcasestr.c \
140 compat_strlcat.c \
141 compat_strlcpy.c \
142 compat_strsep.c \
143 demandoc.c \
144 eqn.c \
145 eqn_html.c \
146 eqn_term.c \
147 html.c \
148 lib.c \
149 main.c \
150 man.c \
151 man_hash.c \
152 man_html.c \
153 man_macro.c \
154 man_term.c \
155 man_validate.c \
156 mandoc.c \
157 mandoc_aux.c \
158 mandocdb.c \
159 manpage.c \
160 manpath.c \
161 mansearch.c \
162 mansearch_const.c \
163 mdoc.c \
164 mdoc_argv.c \
165 mdoc_hash.c \
166 mdoc_html.c \
167 mdoc_macro.c \
168 mdoc_man.c \
169 mdoc_term.c \
170 mdoc_validate.c \
171 msec.c \
172 out.c \
173 preconv.c \
174 read.c \
175 roff.c \
176 st.c \
177 tbl.c \
178 tbl_data.c \
179 tbl_html.c \
180 tbl_layout.c \
181 tbl_opts.c \
182 tbl_term.c \
183 term.c \
184 term_ascii.c \
185 term_ps.c \
186 tree.c \
187 vol.c \
188 $(TESTSRCS)
189
190 DISTFILES = LICENSE \
191 Makefile \
192 Makefile.depend \
193 NEWS \
194 TODO \
195 apropos.1 \
196 arch.in \
197 att.in \
198 cgi.h.example \
199 chars.in \
200 compat_ohash.h \
201 config.h.post \
202 config.h.pre \
203 configure \
204 demandoc.1 \
205 eqn.7 \
206 example.style.css \
207 gmdiff \
208 html.h \
209 lib.in \
210 libman.h \
211 libmandoc.h \
212 libmdoc.h \
213 libroff.h \
214 main.h \
215 makewhatis.8 \
216 man-cgi.css \
217 man.7 \
218 man.cgi.8 \
219 man.h \
220 mandoc.1 \
221 mandoc.3 \
222 mandoc.db.5 \
223 mandoc.h \
224 mandoc_aux.h \
225 mandoc_char.7 \
226 mandoc_escape.3 \
227 mandoc_html.3 \
228 mandoc_malloc.3 \
229 manpath.h \
230 mansearch.3 \
231 mansearch.h \
232 mchars_alloc.3 \
233 mdoc.7 \
234 mdoc.h \
235 msec.in \
236 out.h \
237 preconv.1 \
238 predefs.in \
239 roff.7 \
240 st.in \
241 style.css \
242 tbl.3 \
243 tbl.7 \
244 term.h \
245 vol.in \
246 $(SRCS)
247
248 LIBMAN_OBJS = man.o \
249 man_hash.o \
250 man_macro.o \
251 man_validate.o
252
253 LIBMDOC_OBJS = arch.o \
254 att.o \
255 lib.o \
256 mdoc.o \
257 mdoc_argv.o \
258 mdoc_hash.o \
259 mdoc_macro.o \
260 mdoc_validate.o \
261 st.o \
262 vol.o
263
264 LIBROFF_OBJS = eqn.o \
265 roff.o \
266 tbl.o \
267 tbl_data.o \
268 tbl_layout.o \
269 tbl_opts.o
270
271 LIBMANDOC_OBJS = $(LIBMAN_OBJS) \
272 $(LIBMDOC_OBJS) \
273 $(LIBROFF_OBJS) \
274 chars.o \
275 mandoc.o \
276 mandoc_aux.o \
277 msec.o \
278 read.o
279
280 COMPAT_OBJS = compat_fgetln.o \
281 compat_getsubopt.o \
282 compat_ohash.o \
283 compat_reallocarray.o \
284 compat_strcasestr.o \
285 compat_strlcat.o \
286 compat_strlcpy.o \
287 compat_strsep.o
288
289 MANDOC_HTML_OBJS = eqn_html.o \
290 html.o \
291 man_html.o \
292 mdoc_html.o \
293 tbl_html.o
294
295 MANDOC_MAN_OBJS = mdoc_man.o
296
297 MANDOC_TERM_OBJS = eqn_term.o \
298 man_term.o \
299 mdoc_term.o \
300 term.o \
301 term_ascii.o \
302 term_ps.o \
303 tbl_term.o
304
305 MANDOC_OBJS = $(MANDOC_HTML_OBJS) \
306 $(MANDOC_MAN_OBJS) \
307 $(MANDOC_TERM_OBJS) \
308 main.o \
309 out.o \
310 tree.o
311
312 MAKEWHATIS_OBJS = mandocdb.o mansearch_const.o manpath.o
313
314 PRECONV_OBJS = preconv.o
315
316 APROPOS_OBJS = apropos.o mansearch.o mansearch_const.o manpath.o
317
318 CGI_OBJS = $(MANDOC_HTML_OBJS) \
319 cgi.o \
320 mansearch.o \
321 mansearch_const.o \
322 out.o
323
324 MANPAGE_OBJS = manpage.o mansearch.o mansearch_const.o manpath.o
325
326 DEMANDOC_OBJS = demandoc.o
327
328 WWW_MANS = apropos.1.html \
329 demandoc.1.html \
330 mandoc.1.html \
331 preconv.1.html \
332 mandoc.3.html \
333 mandoc_escape.3.html \
334 mandoc_html.3.html \
335 mandoc_malloc.3.html \
336 mansearch.3.html \
337 mchars_alloc.3.html \
338 tbl.3.html \
339 mandoc.db.5.html \
340 eqn.7.html \
341 man.7.html \
342 mandoc_char.7.html \
343 mdoc.7.html \
344 roff.7.html \
345 tbl.7.html \
346 makewhatis.8.html \
347 man.cgi.8.html \
348 man.h.html \
349 mandoc.h.html \
350 mandoc_aux.h.html \
351 manpath.h.html \
352 mansearch.h.html \
353 mdoc.h.html
354
355 WWW_OBJS = mdocml.tar.gz \
356 mdocml.sha256
357
358 # === DEPENDENCY HANDLING ==============================================
359
360 all: base-build $(BUILD_TARGETS)
361
362 base-build: $(BASEBIN)
363
364 db-build: $(DBBIN)
365
366 cgi-build: $(CGIBIN)
367
368 install: base-install $(INSTALL_TARGETS)
369
370 www: $(WWW_OBJS) $(WWW_MANS)
371
372 .include "Makefile.depend"
373
374 # === TARGETS CONTAINING SHELL COMMANDS ================================
375
376 clean:
377 rm -f libmandoc.a $(LIBMANDOC_OBJS)
378 rm -f apropos $(APROPOS_OBJS)
379 rm -f makewhatis $(MAKEWHATIS_OBJS)
380 rm -f preconv $(PRECONV_OBJS)
381 rm -f man.cgi $(CGI_OBJS)
382 rm -f manpage $(MANPAGE_OBJS)
383 rm -f demandoc $(DEMANDOC_OBJS)
384 rm -f mandoc $(MANDOC_OBJS)
385 rm -f config.h config.log $(COMPAT_OBJS)
386 rm -f $(WWW_MANS) $(WWW_OBJS)
387 rm -rf *.dSYM
388
389 base-install: base-build
390 mkdir -p $(DESTDIR)$(BINDIR)
391 mkdir -p $(DESTDIR)$(EXAMPLEDIR)
392 mkdir -p $(DESTDIR)$(LIBDIR)
393 mkdir -p $(DESTDIR)$(INCLUDEDIR)
394 mkdir -p $(DESTDIR)$(MANDIR)/man1
395 mkdir -p $(DESTDIR)$(MANDIR)/man3
396 mkdir -p $(DESTDIR)$(MANDIR)/man7
397 $(INSTALL_PROGRAM) $(BASEBIN) $(DESTDIR)$(BINDIR)
398 $(INSTALL_LIB) libmandoc.a $(DESTDIR)$(LIBDIR)
399 $(INSTALL_LIB) man.h mandoc.h mandoc_aux.h mdoc.h \
400 $(DESTDIR)$(INCLUDEDIR)
401 $(INSTALL_MAN) mandoc.1 preconv.1 demandoc.1 $(DESTDIR)$(MANDIR)/man1
402 $(INSTALL_MAN) mandoc.3 mandoc_escape.3 mandoc_malloc.3 \
403 mchars_alloc.3 tbl.3 $(DESTDIR)$(MANDIR)/man3
404 $(INSTALL_MAN) man.7 mdoc.7 roff.7 eqn.7 tbl.7 mandoc_char.7 \
405 $(DESTDIR)$(MANDIR)/man7
406 $(INSTALL_DATA) example.style.css $(DESTDIR)$(EXAMPLEDIR)
407
408 db-install: db-build
409 mkdir -p $(DESTDIR)$(BINDIR)
410 mkdir -p $(DESTDIR)$(SBINDIR)
411 mkdir -p $(DESTDIR)$(MANDIR)/man1
412 mkdir -p $(DESTDIR)$(MANDIR)/man3
413 mkdir -p $(DESTDIR)$(MANDIR)/man5
414 mkdir -p $(DESTDIR)$(MANDIR)/man8
415 $(INSTALL_PROGRAM) apropos $(DESTDIR)$(BINDIR)
416 ln -f $(DESTDIR)$(BINDIR)/apropos $(DESTDIR)$(BINDIR)/whatis
417 $(INSTALL_PROGRAM) makewhatis $(DESTDIR)$(SBINDIR)
418 $(INSTALL_MAN) apropos.1 $(DESTDIR)$(MANDIR)/man1
419 ln -f $(DESTDIR)$(MANDIR)/man1/apropos.1 \
420 $(DESTDIR)$(MANDIR)/man1/whatis.1
421 $(INSTALL_MAN) mansearch.3 $(DESTDIR)$(MANDIR)/man3
422 $(INSTALL_MAN) mandoc.db.5 $(DESTDIR)$(MANDIR)/man5
423 $(INSTALL_MAN) makewhatis.8 $(DESTDIR)$(MANDIR)/man8
424
425 cgi-install: cgi-build
426 mkdir -p $(DESTDIR)$(CGIBINDIR)
427 mkdir -p $(DESTDIR)$(HTDOCDIR)
428 mkdir -p $(DESTDIR)$(WWWPREFIX)/man/mandoc/man1
429 mkdir -p $(DESTDIR)$(WWWPREFIX)/man/mandoc/man8
430 $(INSTALL_PROGRAM) man.cgi $(DESTDIR)$(CGIBINDIR)
431 $(INSTALL_DATA) example.style.css $(DESTDIR)$(HTDOCDIR)/man.css
432 $(INSTALL_DATA) man-cgi.css $(DESTDIR)$(HTDOCDIR)
433 $(INSTALL_MAN) apropos.1 $(DESTDIR)$(WWWPREFIX)/man/mandoc/man1/
434 $(INSTALL_MAN) man.cgi.8 $(DESTDIR)$(WWWPREFIX)/man/mandoc/man8/
435
436 www-install: www
437 mkdir -p $(DESTDIR)$(HTDOCDIR)/snapshots
438 $(INSTALL_DATA) $(WWW_MANS) style.css $(DESTDIR)$(HTDOCDIR)
439 $(INSTALL_DATA) $(WWW_OBJS) $(DESTDIR)$(HTDOCDIR)/snapshots
440 $(INSTALL_DATA) mdocml.tar.gz \
441 $(DESTDIR)$(HTDOCDIR)/snapshots/mdocml-$(VERSION).tar.gz
442 $(INSTALL_DATA) mdocml.sha256 \
443 $(DESTDIR)$(HTDOCDIR)/snapshots/mdocml-$(VERSION).sha256
444
445 Makefile.depend: $(SRCS) config.h Makefile
446 mkdep -f Makefile.depend $(CFLAGS) $(SRCS)
447 perl -e 'undef $$/; $$_ = <>; s|/usr/include/\S+||g; \
448 s|\\\n||g; s| +| |g; print;' Makefile.depend > Makefile.tmp
449 mv Makefile.tmp Makefile.depend
450
451 libmandoc.a: $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
452 $(AR) rs $@ $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
453
454 mandoc: $(MANDOC_OBJS) libmandoc.a
455 $(CC) $(LDFLAGS) -o $@ $(MANDOC_OBJS) libmandoc.a
456
457 makewhatis: $(MAKEWHATIS_OBJS) libmandoc.a
458 $(CC) $(LDFLAGS) -o $@ $(MAKEWHATIS_OBJS) libmandoc.a $(DBLIB)
459
460 preconv: $(PRECONV_OBJS)
461 $(CC) $(LDFLAGS) -o $@ $(PRECONV_OBJS)
462
463 manpage: $(MANPAGE_OBJS) libmandoc.a
464 $(CC) $(LDFLAGS) -o $@ $(MANPAGE_OBJS) libmandoc.a $(DBLIB)
465
466 apropos: $(APROPOS_OBJS) libmandoc.a
467 $(CC) $(LDFLAGS) -o $@ $(APROPOS_OBJS) libmandoc.a $(DBLIB)
468
469 man.cgi: $(CGI_OBJS) libmandoc.a
470 $(CC) $(LDFLAGS) $(STATIC) -o $@ $(CGI_OBJS) libmandoc.a $(DBLIB)
471
472 demandoc: $(DEMANDOC_OBJS) libmandoc.a
473 $(CC) $(LDFLAGS) -o $@ $(DEMANDOC_OBJS) libmandoc.a
474
475 mdocml.sha256: mdocml.tar.gz
476 sha256 mdocml.tar.gz > $@
477
478 mdocml.tar.gz: $(DISTFILES)
479 mkdir -p .dist/mdocml-$(VERSION)/
480 $(INSTALL_SOURCE) $(DISTFILES) .dist/mdocml-$(VERSION)
481 chmod 755 .dist/mdocml-$(VERSION)/configure
482 ( cd .dist/ && tar zcf ../$@ mdocml-$(VERSION) )
483 rm -rf .dist/
484
485 config.h: configure config.h.pre config.h.post $(TESTSRCS)
486 rm -f config.log
487 CC="$(CC)" CFLAGS="$(CFLAGS)" VERSION="$(VERSION)" ./configure
488
489 .PHONY: base-install clean cgi-install db-install install www-install
490 .SUFFIXES: .1 .3 .5 .7 .8 .h
491 .SUFFIXES: .1.html .3.html .5.html .7.html .8.html .h.html
492
493 .h.h.html:
494 highlight -I $< > $@
495
496 .1.1.html .3.3.html .5.5.html .7.7.html .8.8.html: mandoc
497 ./mandoc -Thtml -Wall,stop \
498 -Ostyle=style.css,man=%N.%S.html,includes=%I.html $< > $@