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