]> git.cameronkatri.com Git - mandoc.git/blob - Makefile
Render roff escape sequences contained in manual page descriptions
[mandoc.git] / Makefile
1 # $Id: Makefile,v 1.419 2014/04/24 00:29:45 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 # Specify this if you want to hard-code the operating system to appear
23 # in the lower-left hand corner of -mdoc manuals.
24 #
25 # CFLAGS += -DOSNAME="\"OpenBSD 5.5\""
26
27 # IFF your system supports multi-byte functions (setlocale(), wcwidth(),
28 # putwchar()) AND has __STDC_ISO_10646__ (that is, wchar_t is simply a
29 # UCS-4 value) should you define USE_WCHAR. If you define it and your
30 # system DOESN'T support this, -Tlocale will produce garbage.
31 # If you don't define it, -Tlocale is a synonym for -Tacsii.
32 #
33 CFLAGS += -DUSE_WCHAR
34
35 # If your system has manpath(1), uncomment this. This is most any
36 # system that's not OpenBSD or NetBSD. If uncommented, manpage(1) and
37 # makewhatis(8) will use manpath(1) to get the MANPATH variable.
38 #CFLAGS += -DUSE_MANPATH
39
40 # If your system does not support static binaries, comment this,
41 # for example on Mac OS X.
42 STATIC = -static
43 # Linux requires -pthread to statically link with libdb.
44 #STATIC += -pthread
45
46 CFLAGS += -I/usr/local/include -g -DHAVE_CONFIG_H
47 CFLAGS += -W -Wall -Wstrict-prototypes -Wno-unused-parameter -Wwrite-strings
48 PREFIX = /usr/local
49 WWWPREFIX = /var/www
50 HTDOCDIR = $(WWWPREFIX)/htdocs
51 CGIBINDIR = $(WWWPREFIX)/cgi-bin
52 BINDIR = $(PREFIX)/bin
53 INCLUDEDIR = $(PREFIX)/include/mandoc
54 LIBDIR = $(PREFIX)/lib/mandoc
55 MANDIR = $(PREFIX)/man
56 EXAMPLEDIR = $(PREFIX)/share/examples/mandoc
57 INSTALL = install
58 INSTALL_PROGRAM = $(INSTALL) -m 0755
59 INSTALL_DATA = $(INSTALL) -m 0444
60 INSTALL_LIB = $(INSTALL) -m 0644
61 INSTALL_SOURCE = $(INSTALL) -m 0644
62 INSTALL_MAN = $(INSTALL_DATA)
63
64 # If you want to build without database support, for example to avoid
65 # the dependency on SQLite3, comment the following two lines.
66 DBLIB = -L/usr/local/lib -lsqlite3
67 DBBIN = makewhatis manpage apropos
68
69 # === END OF USER SETTINGS =============================================
70
71 ALLBIN = mandoc preconv demandoc $(DBBIN)
72
73 all: $(ALLBIN)
74
75 TESTSRCS = test-fgetln.c \
76 test-getsubopt.c \
77 test-mmap.c \
78 test-ohash.c \
79 test-reallocarray.c \
80 test-strlcat.c \
81 test-strlcpy.c \
82 test-strnlen.c \
83 test-strptime.c
84
85 SRCS = LICENSE \
86 Makefile \
87 NEWS \
88 TODO \
89 apropos.1 \
90 apropos.c \
91 arch.c \
92 arch.in \
93 att.c \
94 att.in \
95 cgi.c \
96 chars.c \
97 chars.in \
98 compat_fgetln.c \
99 compat_getsubopt.c \
100 compat_ohash.c \
101 compat_ohash.h \
102 compat_reallocarray.c \
103 compat_strcasestr.c \
104 compat_strlcat.c \
105 compat_strlcpy.c \
106 compat_strnlen.c \
107 compat_strsep.c \
108 config.h.post \
109 config.h.pre \
110 configure \
111 demandoc.1 \
112 demandoc.c \
113 eqn.7 \
114 eqn.c \
115 eqn_html.c \
116 eqn_term.c \
117 example.style.css \
118 gmdiff \
119 html.c \
120 html.h \
121 lib.c \
122 lib.in \
123 libman.h \
124 libmandoc.h \
125 libmdoc.h \
126 libroff.h \
127 main.c \
128 main.h \
129 makewhatis.8 \
130 man.7 \
131 man.c \
132 man-cgi.css \
133 man.h \
134 man_hash.c \
135 man_html.c \
136 man_macro.c \
137 man_term.c \
138 man_validate.c \
139 mandoc.1 \
140 mandoc.3 \
141 mandoc.c \
142 mandoc.db.5 \
143 mandoc.h \
144 mandoc_aux.c \
145 mandoc_aux.h \
146 mandoc_char.7 \
147 mandocdb.c \
148 manpage.c \
149 manpath.c \
150 manpath.h \
151 mansearch.3 \
152 mansearch.c \
153 mansearch.h \
154 mansearch_const.c \
155 mdoc.7 \
156 mdoc.c \
157 mdoc.h \
158 mdoc_argv.c \
159 mdoc_hash.c \
160 mdoc_html.c \
161 mdoc_macro.c \
162 mdoc_man.c \
163 mdoc_term.c \
164 mdoc_validate.c \
165 msec.c \
166 msec.in \
167 out.c \
168 out.h \
169 preconv.1 \
170 preconv.c \
171 predefs.in \
172 read.c \
173 roff.7 \
174 roff.c \
175 st.c \
176 st.in \
177 style.css \
178 tbl.3 \
179 tbl.7 \
180 tbl.c \
181 tbl_data.c \
182 tbl_html.c \
183 tbl_layout.c \
184 tbl_opts.c \
185 tbl_term.c \
186 term.c \
187 term.h \
188 term_ascii.c \
189 term_ps.c \
190 tree.c \
191 vol.c \
192 vol.in \
193 $(TESTSRCS)
194
195 LIBMAN_OBJS = man.o \
196 man_hash.o \
197 man_macro.o \
198 man_validate.o
199
200 LIBMDOC_OBJS = arch.o \
201 att.o \
202 lib.o \
203 mdoc.o \
204 mdoc_argv.o \
205 mdoc_hash.o \
206 mdoc_macro.o \
207 mdoc_validate.o \
208 st.o \
209 vol.o
210
211 LIBROFF_OBJS = eqn.o \
212 roff.o \
213 tbl.o \
214 tbl_data.o \
215 tbl_layout.o \
216 tbl_opts.o
217
218 LIBMANDOC_OBJS = $(LIBMAN_OBJS) \
219 $(LIBMDOC_OBJS) \
220 $(LIBROFF_OBJS) \
221 chars.o \
222 mandoc.o \
223 mandoc_aux.o \
224 msec.o \
225 read.o
226
227 COMPAT_OBJS = compat_fgetln.o \
228 compat_getsubopt.o \
229 compat_ohash.o \
230 compat_reallocarray.o \
231 compat_strcasestr.o \
232 compat_strlcat.o \
233 compat_strlcpy.o \
234 compat_strnlen.o \
235 compat_strsep.o
236
237 # === DEPENDENCY HANDLING ==============================================
238
239 arch.o: arch.in
240 att.o: att.in
241 chars.o: chars.in
242 lib.o: lib.in
243 msec.o: msec.in
244 roff.o: predefs.in
245 st.o: st.in
246 vol.o: vol.in
247
248 $(LIBMAN_OBJS): libman.h
249 $(LIBMDOC_OBJS): libmdoc.h
250 $(LIBROFF_OBJS): libroff.h
251 $(LIBMANDOC_OBJS): mandoc.h mandoc_aux.h mdoc.h man.h libmandoc.h config.h
252 $(COMPAT_OBJS): config.h compat_ohash.h
253
254 MANDOC_HTML_OBJS = eqn_html.o \
255 html.o \
256 man_html.o \
257 mdoc_html.o \
258 tbl_html.o
259 $(MANDOC_HTML_OBJS): html.h
260
261 MANDOC_MAN_OBJS = mdoc_man.o
262
263 MANDOC_TERM_OBJS = eqn_term.o \
264 man_term.o \
265 mdoc_term.o \
266 term.o \
267 term_ascii.o \
268 term_ps.o \
269 tbl_term.o
270 $(MANDOC_TERM_OBJS): term.h
271
272 MANDOC_OBJS = $(MANDOC_HTML_OBJS) \
273 $(MANDOC_MAN_OBJS) \
274 $(MANDOC_TERM_OBJS) \
275 main.o \
276 out.o \
277 tree.o
278 $(MANDOC_OBJS): main.h mandoc.h mandoc_aux.h mdoc.h man.h config.h out.h
279
280 MAKEWHATIS_OBJS = mandocdb.o mansearch_const.o manpath.o
281 $(MAKEWHATIS_OBJS): mansearch.h mandoc.h mandoc_aux.h \
282 mdoc.h man.h config.h manpath.h
283
284 PRECONV_OBJS = preconv.o
285 $(PRECONV_OBJS): config.h
286
287 APROPOS_OBJS = apropos.o mansearch.o mansearch_const.o manpath.o
288 $(APROPOS_OBJS): config.h mandoc.h mandoc_aux.h manpath.h mansearch.h
289
290 MANPAGE_OBJS = manpage.o mansearch.o mansearch_const.o manpath.o
291 $(MANPAGE_OBJS): config.h mandoc.h mandoc_aux.h manpath.h mansearch.h
292
293 DEMANDOC_OBJS = demandoc.o
294 $(DEMANDOC_OBJS): config.h mandoc.h man.h mdoc.h
295
296 WWW_MANS = apropos.1.html \
297 demandoc.1.html \
298 mandoc.1.html \
299 preconv.1.html \
300 mandoc.3.html \
301 mansearch.3.html \
302 tbl.3.html \
303 mandoc.db.5.html \
304 eqn.7.html \
305 man.7.html \
306 mandoc_char.7.html \
307 mdoc.7.html \
308 roff.7.html \
309 tbl.7.html \
310 makewhatis.8.html \
311 man.h.html \
312 mandoc.h.html \
313 mandoc_aux.h.html \
314 manpath.h.html \
315 mansearch.h.html \
316 mdoc.h.html
317
318 WWW_OBJS = mdocml.tar.gz \
319 mdocml.sha256
320
321 www: $(WWW_OBJS) $(WWW_MANS)
322
323 # === TARGETS CONTAINING SHELL COMMANDS ================================
324
325 clean:
326 rm -f libmandoc.a $(LIBMANDOC_OBJS)
327 rm -f apropos $(APROPOS_OBJS)
328 rm -f makewhatis $(MAKEWHATIS_OBJS)
329 rm -f preconv $(PRECONV_OBJS)
330 rm -f manpage $(MANPAGE_OBJS)
331 rm -f demandoc $(DEMANDOC_OBJS)
332 rm -f mandoc $(MANDOC_OBJS)
333 rm -f config.h config.log $(COMPAT_OBJS)
334 rm -f $(WWW_MANS) $(WWW_OBJS)
335 rm -rf *.dSYM
336
337 install: all
338 mkdir -p $(DESTDIR)$(BINDIR)
339 mkdir -p $(DESTDIR)$(EXAMPLEDIR)
340 mkdir -p $(DESTDIR)$(LIBDIR)
341 mkdir -p $(DESTDIR)$(INCLUDEDIR)
342 mkdir -p $(DESTDIR)$(MANDIR)/man1
343 mkdir -p $(DESTDIR)$(MANDIR)/man3
344 mkdir -p $(DESTDIR)$(MANDIR)/man5
345 mkdir -p $(DESTDIR)$(MANDIR)/man7
346 $(INSTALL_PROGRAM) $(ALLBIN) $(DESTDIR)$(BINDIR)
347 $(INSTALL_LIB) libmandoc.a $(DESTDIR)$(LIBDIR)
348 $(INSTALL_LIB) man.h mdoc.h mandoc.h $(DESTDIR)$(INCLUDEDIR)
349 $(INSTALL_MAN) mandoc.1 preconv.1 demandoc.1 $(DESTDIR)$(MANDIR)/man1
350 $(INSTALL_MAN) mandoc.3 mansearch.3 tbl.3 $(DESTDIR)$(MANDIR)/man3
351 $(INSTALL_MAN) mandoc.db.5 $(DESTDIR)$(MANDIR)/man5
352 $(INSTALL_MAN) man.7 mdoc.7 roff.7 eqn.7 tbl.7 mandoc_char.7 \
353 $(DESTDIR)$(MANDIR)/man7
354 $(INSTALL_DATA) example.style.css $(DESTDIR)$(EXAMPLEDIR)
355
356 installcgi: all
357 mkdir -p $(DESTDIR)$(CGIBINDIR)
358 mkdir -p $(DESTDIR)$(HTDOCDIR)
359 #$(INSTALL_PROGRAM) man.cgi $(DESTDIR)$(CGIBINDIR)
360 $(INSTALL_DATA) example.style.css $(DESTDIR)$(HTDOCDIR)/man.css
361 $(INSTALL_DATA) man-cgi.css $(DESTDIR)$(HTDOCDIR)
362
363 installwww: www
364 mkdir -p $(DESTDIR)$(HTDOCDIR)/snapshots
365 $(INSTALL_DATA) $(WWW_MANS) style.css $(DESTDIR)$(HTDOCDIR)
366 $(INSTALL_DATA) $(WWW_OBJS) $(DESTDIR)$(HTDOCDIR)/snapshots
367 $(INSTALL_DATA) mdocml.tar.gz \
368 $(DESTDIR)$(HTDOCDIR)/snapshots/mdocml-$(VERSION).tar.gz
369 $(INSTALL_DATA) mdocml.sha256 \
370 $(DESTDIR)$(HTDOCDIR)/snapshots/mdocml-$(VERSION).sha256
371
372 libmandoc.a: $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
373 $(AR) rs $@ $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
374
375 mandoc: $(MANDOC_OBJS) libmandoc.a
376 $(CC) $(LDFLAGS) -o $@ $(MANDOC_OBJS) libmandoc.a
377
378 makewhatis: $(MAKEWHATIS_OBJS) libmandoc.a
379 $(CC) $(LDFLAGS) -o $@ $(MAKEWHATIS_OBJS) libmandoc.a $(DBLIB)
380
381 preconv: $(PRECONV_OBJS)
382 $(CC) $(LDFLAGS) -o $@ $(PRECONV_OBJS)
383
384 manpage: $(MANPAGE_OBJS) libmandoc.a
385 $(CC) $(LDFLAGS) -o $@ $(MANPAGE_OBJS) libmandoc.a $(DBLIB)
386
387 apropos: $(APROPOS_OBJS) libmandoc.a
388 $(CC) $(LDFLAGS) -o $@ $(APROPOS_OBJS) libmandoc.a $(DBLIB)
389
390 demandoc: $(DEMANDOC_OBJS) libmandoc.a
391 $(CC) $(LDFLAGS) -o $@ $(DEMANDOC_OBJS) libmandoc.a
392
393 mdocml.sha256: mdocml.tar.gz
394 sha256 mdocml.tar.gz > $@
395
396 mdocml.tar.gz: $(SRCS)
397 mkdir -p .dist/mdocml-$(VERSION)/
398 $(INSTALL_SOURCE) $(SRCS) .dist/mdocml-$(VERSION)
399 chmod 755 .dist/mdocml-$(VERSION)/configure
400 ( cd .dist/ && tar zcf ../$@ mdocml-$(VERSION) )
401 rm -rf .dist/
402
403 config.h: configure config.h.pre config.h.post $(TESTSRCS)
404 rm -f config.log
405 CC="$(CC)" CFLAGS="$(CFLAGS)" VERSION="$(VERSION)" ./configure
406
407 .PHONY: clean install installcgi installwww
408 .SUFFIXES: .1 .3 .5 .7 .8 .h
409 .SUFFIXES: .1.html .3.html .5.html .7.html .8.html .h.html
410
411 .h.h.html:
412 highlight -I $< > $@
413
414 .1.1.html .3.3.html .5.5.html .7.7.html .8.8.html: mandoc
415 ./mandoc -Thtml -Wall,stop \
416 -Ostyle=style.css,man=%N.%S.html,includes=%I.html $< > $@