]> git.cameronkatri.com Git - mandoc.git/blob - Makefile
Add support for Mac OS X's sandbox_init(3) sandbox functionality, which
[mandoc.git] / Makefile
1 # $Id: Makefile,v 1.488 2016/07/12 05:18:38 kristaps Exp $
2 #
3 # Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
4 # Copyright (c) 2011, 2013-2016 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.4
19
20 # === LIST OF FILES ====================================================
21
22 TESTSRCS = test-dirent-namlen.c \
23 test-err.c \
24 test-fts.c \
25 test-getline.c \
26 test-getsubopt.c \
27 test-isblank.c \
28 test-mkdtemp.c \
29 test-mmap.c \
30 test-ohash.c \
31 test-pledge.c \
32 test-progname.c \
33 test-reallocarray.c \
34 test-rewb-bsd.c \
35 test-rewb-sysv.c \
36 test-sandbox_init.c \
37 test-sqlite3.c \
38 test-sqlite3_errstr.c \
39 test-strcasestr.c \
40 test-stringlist.c \
41 test-strlcat.c \
42 test-strlcpy.c \
43 test-strptime.c \
44 test-strsep.c \
45 test-strtonum.c \
46 test-vasprintf.c \
47 test-wchar.c
48
49 SRCS = att.c \
50 cgi.c \
51 chars.c \
52 compat_err.c \
53 compat_fts.c \
54 compat_getline.c \
55 compat_getsubopt.c \
56 compat_isblank.c \
57 compat_mkdtemp.c \
58 compat_ohash.c \
59 compat_progname.c \
60 compat_reallocarray.c \
61 compat_sqlite3_errstr.c \
62 compat_strcasestr.c \
63 compat_stringlist.c \
64 compat_strlcat.c \
65 compat_strlcpy.c \
66 compat_strsep.c \
67 compat_strtonum.c \
68 compat_vasprintf.c \
69 demandoc.c \
70 eqn.c \
71 eqn_html.c \
72 eqn_term.c \
73 html.c \
74 lib.c \
75 main.c \
76 man.c \
77 man_hash.c \
78 man_html.c \
79 man_macro.c \
80 man_term.c \
81 man_validate.c \
82 mandoc.c \
83 mandoc_aux.c \
84 mandoc_ohash.c \
85 mandocdb.c \
86 manpage.c \
87 manpath.c \
88 mansearch.c \
89 mansearch_const.c \
90 mdoc.c \
91 mdoc_argv.c \
92 mdoc_hash.c \
93 mdoc_html.c \
94 mdoc_macro.c \
95 mdoc_man.c \
96 mdoc_state.c \
97 mdoc_term.c \
98 mdoc_validate.c \
99 msec.c \
100 out.c \
101 preconv.c \
102 read.c \
103 roff.c \
104 soelim.c \
105 st.c \
106 tag.c \
107 tbl.c \
108 tbl_data.c \
109 tbl_html.c \
110 tbl_layout.c \
111 tbl_opts.c \
112 tbl_term.c \
113 term.c \
114 term_ascii.c \
115 term_ps.c \
116 tree.c
117
118 DISTFILES = INSTALL \
119 LICENSE \
120 Makefile \
121 Makefile.depend \
122 NEWS \
123 TODO \
124 apropos.1 \
125 cgi.h.example \
126 compat_fts.h \
127 compat_ohash.h \
128 compat_stringlist.h \
129 configure \
130 configure.local.example \
131 demandoc.1 \
132 eqn.7 \
133 gmdiff \
134 html.h \
135 lib.in \
136 libman.h \
137 libmandoc.h \
138 libmdoc.h \
139 libroff.h \
140 main.h \
141 makewhatis.8 \
142 man.1 \
143 man.7 \
144 man.cgi.3 \
145 man.cgi.8 \
146 man.conf.5 \
147 man.h \
148 manconf.h \
149 mandoc.1 \
150 mandoc.3 \
151 mandoc.css \
152 mandoc.db.5 \
153 mandoc.h \
154 mandoc_aux.h \
155 mandoc_char.7 \
156 mandoc_escape.3 \
157 mandoc_headers.3 \
158 mandoc_html.3 \
159 mandoc_malloc.3 \
160 mandoc_ohash.h \
161 mansearch.3 \
162 mansearch.h \
163 mchars_alloc.3 \
164 mdoc.7 \
165 mdoc.h \
166 msec.in \
167 out.h \
168 predefs.in \
169 roff.7 \
170 roff.h \
171 roff_int.h \
172 soelim.1 \
173 st.in \
174 tag.h \
175 tbl.3 \
176 tbl.7 \
177 term.h \
178 $(SRCS) \
179 $(TESTSRCS)
180
181 LIBMAN_OBJS = man.o \
182 man_hash.o \
183 man_macro.o \
184 man_validate.o
185
186 LIBMDOC_OBJS = att.o \
187 lib.o \
188 mdoc.o \
189 mdoc_argv.o \
190 mdoc_hash.o \
191 mdoc_macro.o \
192 mdoc_state.o \
193 mdoc_validate.o \
194 st.o
195
196 LIBROFF_OBJS = eqn.o \
197 roff.o \
198 tbl.o \
199 tbl_data.o \
200 tbl_layout.o \
201 tbl_opts.o
202
203 LIBMANDOC_OBJS = $(LIBMAN_OBJS) \
204 $(LIBMDOC_OBJS) \
205 $(LIBROFF_OBJS) \
206 chars.o \
207 mandoc.o \
208 mandoc_aux.o \
209 mandoc_ohash.o \
210 msec.o \
211 preconv.o \
212 read.o
213
214 COMPAT_OBJS = compat_err.o \
215 compat_fts.o \
216 compat_getline.o \
217 compat_getsubopt.o \
218 compat_isblank.o \
219 compat_mkdtemp.o \
220 compat_ohash.o \
221 compat_progname.o \
222 compat_reallocarray.o \
223 compat_sqlite3_errstr.o \
224 compat_strcasestr.o \
225 compat_strlcat.o \
226 compat_strlcpy.o \
227 compat_strsep.o \
228 compat_strtonum.o \
229 compat_vasprintf.o
230
231 MANDOC_HTML_OBJS = eqn_html.o \
232 html.o \
233 man_html.o \
234 mdoc_html.o \
235 tbl_html.o
236
237 MANDOC_MAN_OBJS = mdoc_man.o
238
239 MANDOC_TERM_OBJS = eqn_term.o \
240 man_term.o \
241 mdoc_term.o \
242 term.o \
243 term_ascii.o \
244 term_ps.o \
245 tbl_term.o
246
247 BASE_OBJS = $(MANDOC_HTML_OBJS) \
248 $(MANDOC_MAN_OBJS) \
249 $(MANDOC_TERM_OBJS) \
250 main.o \
251 manpath.o \
252 out.o \
253 tag.o \
254 tree.o
255
256 MAIN_OBJS = $(BASE_OBJS)
257
258 DB_OBJS = mandocdb.o \
259 mansearch.o \
260 mansearch_const.o
261
262 CGI_OBJS = $(MANDOC_HTML_OBJS) \
263 cgi.o \
264 mansearch.o \
265 mansearch_const.o \
266 out.o
267
268 MANPAGE_OBJS = manpage.o mansearch.o mansearch_const.o manpath.o
269
270 DEMANDOC_OBJS = demandoc.o
271
272 SOELIM_OBJS = soelim.o \
273 compat_err.o \
274 compat_getline.o \
275 compat_progname.o \
276 compat_reallocarray.o \
277 compat_stringlist.o
278
279 WWW_MANS = apropos.1.html \
280 demandoc.1.html \
281 man.1.html \
282 mandoc.1.html \
283 soelim.1.html \
284 mandoc.3.html \
285 mandoc_escape.3.html \
286 mandoc_headers.3.html \
287 mandoc_html.3.html \
288 mandoc_malloc.3.html \
289 mansearch.3.html \
290 mchars_alloc.3.html \
291 tbl.3.html \
292 man.conf.5.html \
293 mandoc.db.5.html \
294 eqn.7.html \
295 man.7.html \
296 mandoc_char.7.html \
297 mdoc.7.html \
298 roff.7.html \
299 tbl.7.html \
300 makewhatis.8.html \
301 man.cgi.3.html \
302 man.cgi.8.html \
303 man.h.html \
304 manconf.h.html \
305 mandoc.h.html \
306 mandoc_aux.h.html \
307 mansearch.h.html \
308 mdoc.h.html \
309 roff.h.html
310
311 WWW_OBJS = mdocml.tar.gz \
312 mdocml.sha256
313
314 # === USER CONFIGURATION ===============================================
315
316 include Makefile.local
317
318 # === DEPENDENCY HANDLING ==============================================
319
320 all: base-build $(BUILD_TARGETS) Makefile.local
321
322 base-build: mandoc demandoc soelim
323
324 cgi-build: man.cgi
325
326 install: base-install $(INSTALL_TARGETS)
327
328 www: $(WWW_OBJS) $(WWW_MANS)
329
330 $(WWW_MANS): mandoc
331
332 .PHONY: base-install cgi-install db-install install www-install
333 .PHONY: clean distclean depend
334
335 include Makefile.depend
336
337 # === TARGETS CONTAINING SHELL COMMANDS ================================
338
339 distclean: clean
340 rm -f Makefile.local config.h config.h.old config.log config.log.old
341
342 clean:
343 rm -f libmandoc.a $(LIBMANDOC_OBJS) $(COMPAT_OBJS)
344 rm -f mandoc $(BASE_OBJS) $(DB_OBJS)
345 rm -f man.cgi $(CGI_OBJS)
346 rm -f manpage $(MANPAGE_OBJS)
347 rm -f demandoc $(DEMANDOC_OBJS)
348 rm -f soelim $(SOELIM_OBJS)
349 rm -f $(WWW_MANS) $(WWW_OBJS)
350 rm -rf *.dSYM
351
352 base-install: base-build
353 mkdir -p $(DESTDIR)$(BINDIR)
354 mkdir -p $(DESTDIR)$(LIBDIR)
355 mkdir -p $(DESTDIR)$(INCLUDEDIR)
356 mkdir -p $(DESTDIR)$(MANDIR)/man1
357 mkdir -p $(DESTDIR)$(MANDIR)/man3
358 mkdir -p $(DESTDIR)$(MANDIR)/man5
359 mkdir -p $(DESTDIR)$(MANDIR)/man7
360 $(INSTALL_PROGRAM) mandoc demandoc $(DESTDIR)$(BINDIR)
361 $(INSTALL_PROGRAM) soelim $(DESTDIR)$(BINDIR)/$(BINM_SOELIM)
362 ln -f $(DESTDIR)$(BINDIR)/mandoc $(DESTDIR)$(BINDIR)/$(BINM_MAN)
363 $(INSTALL_LIB) libmandoc.a $(DESTDIR)$(LIBDIR)
364 $(INSTALL_LIB) man.h mandoc.h mandoc_aux.h mdoc.h roff.h \
365 $(DESTDIR)$(INCLUDEDIR)
366 $(INSTALL_MAN) mandoc.1 demandoc.1 $(DESTDIR)$(MANDIR)/man1
367 $(INSTALL_MAN) soelim.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_SOELIM).1
368 $(INSTALL_MAN) man.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_MAN).1
369 $(INSTALL_MAN) mandoc.3 mandoc_escape.3 mandoc_malloc.3 \
370 mchars_alloc.3 tbl.3 $(DESTDIR)$(MANDIR)/man3
371 $(INSTALL_MAN) man.conf.5 $(DESTDIR)$(MANDIR)/man5/${MANM_MANCONF}.5
372 $(INSTALL_MAN) man.7 $(DESTDIR)$(MANDIR)/man7/${MANM_MAN}.7
373 $(INSTALL_MAN) mdoc.7 $(DESTDIR)$(MANDIR)/man7/${MANM_MDOC}.7
374 $(INSTALL_MAN) roff.7 $(DESTDIR)$(MANDIR)/man7/${MANM_ROFF}.7
375 $(INSTALL_MAN) eqn.7 $(DESTDIR)$(MANDIR)/man7/${MANM_EQN}.7
376 $(INSTALL_MAN) tbl.7 $(DESTDIR)$(MANDIR)/man7/${MANM_TBL}.7
377 $(INSTALL_MAN) mandoc_char.7 $(DESTDIR)$(MANDIR)/man7
378
379 db-install: base-build
380 mkdir -p $(DESTDIR)$(BINDIR)
381 mkdir -p $(DESTDIR)$(SBINDIR)
382 mkdir -p $(DESTDIR)$(MANDIR)/man1
383 mkdir -p $(DESTDIR)$(MANDIR)/man3
384 mkdir -p $(DESTDIR)$(MANDIR)/man5
385 mkdir -p $(DESTDIR)$(MANDIR)/man8
386 ln -f $(DESTDIR)$(BINDIR)/mandoc $(DESTDIR)$(BINDIR)/$(BINM_APROPOS)
387 ln -f $(DESTDIR)$(BINDIR)/mandoc $(DESTDIR)$(BINDIR)/$(BINM_WHATIS)
388 ln -f $(DESTDIR)$(BINDIR)/mandoc \
389 $(DESTDIR)$(SBINDIR)/$(BINM_MAKEWHATIS)
390 $(INSTALL_MAN) apropos.1 $(DESTDIR)$(MANDIR)/man1/$(BINM_APROPOS).1
391 ln -f $(DESTDIR)$(MANDIR)/man1/$(BINM_APROPOS).1 \
392 $(DESTDIR)$(MANDIR)/man1/$(BINM_WHATIS).1
393 $(INSTALL_MAN) mansearch.3 $(DESTDIR)$(MANDIR)/man3
394 $(INSTALL_MAN) mandoc.db.5 $(DESTDIR)$(MANDIR)/man5
395 $(INSTALL_MAN) makewhatis.8 \
396 $(DESTDIR)$(MANDIR)/man8/$(BINM_MAKEWHATIS).8
397
398 cgi-install: cgi-build
399 mkdir -p $(DESTDIR)$(CGIBINDIR)
400 mkdir -p $(DESTDIR)$(HTDOCDIR)
401 $(INSTALL_PROGRAM) man.cgi $(DESTDIR)$(CGIBINDIR)
402 $(INSTALL_DATA) mandoc.css $(DESTDIR)$(HTDOCDIR)
403
404 Makefile.local config.h: configure ${TESTSRCS}
405 @echo "$@ is out of date; please run ./configure"
406 @exit 1
407
408 libmandoc.a: $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
409 ar rs $@ $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
410
411 mandoc: $(MAIN_OBJS) libmandoc.a
412 $(CC) -o $@ $(LDFLAGS) $(MAIN_OBJS) libmandoc.a $(LDADD)
413
414 manpage: $(MANPAGE_OBJS) libmandoc.a
415 $(CC) -o $@ $(LDFLAGS) $(MANPAGE_OBJS) libmandoc.a $(LDADD)
416
417 man.cgi: $(CGI_OBJS) libmandoc.a
418 $(CC) $(STATIC) -o $@ $(LDFLAGS) $(CGI_OBJS) libmandoc.a $(LDADD)
419
420 demandoc: $(DEMANDOC_OBJS) libmandoc.a
421 $(CC) -o $@ $(LDFLAGS) $(DEMANDOC_OBJS) libmandoc.a $(LDADD)
422
423 soelim: $(SOELIM_OBJS)
424 $(CC) -o $@ $(LDFLAGS) $(SOELIM_OBJS)
425
426 # --- maintainer targets ---
427
428 www-install: www
429 mkdir -p $(HTDOCDIR)/snapshots
430 $(INSTALL_DATA) $(WWW_MANS) mandoc.css $(HTDOCDIR)
431 $(INSTALL_DATA) $(WWW_OBJS) $(HTDOCDIR)/snapshots
432 $(INSTALL_DATA) mdocml.tar.gz \
433 $(HTDOCDIR)/snapshots/mdocml-$(VERSION).tar.gz
434 $(INSTALL_DATA) mdocml.sha256 \
435 $(HTDOCDIR)/snapshots/mdocml-$(VERSION).sha256
436
437 depend: config.h
438 mkdep -f Makefile.depend $(CFLAGS) $(SRCS)
439 perl -e 'undef $$/; $$_ = <>; s|/usr/include/\S+||g; \
440 s|\\\n||g; s| +| |g; s| $$||mg; print;' \
441 Makefile.depend > Makefile.tmp
442 mv Makefile.tmp Makefile.depend
443
444 dist: mdocml.sha256
445
446 mdocml.sha256: mdocml.tar.gz
447 sha256 mdocml.tar.gz > $@
448
449 mdocml.tar.gz: $(DISTFILES)
450 mkdir -p .dist/mdocml-$(VERSION)/
451 $(INSTALL) -m 0644 $(DISTFILES) .dist/mdocml-$(VERSION)
452 chmod 755 .dist/mdocml-$(VERSION)/configure
453 ( cd .dist/ && tar zcf ../$@ mdocml-$(VERSION) )
454 rm -rf .dist/
455
456 # === SUFFIX RULES =====================================================
457
458 .SUFFIXES: .1 .3 .5 .7 .8 .h
459 .SUFFIXES: .1.html .3.html .5.html .7.html .8.html .h.html
460
461 .h.h.html:
462 highlight -I $< > $@
463
464 .1.1.html .3.3.html .5.5.html .7.7.html .8.8.html: mandoc
465 ./mandoc -Thtml -Wall,stop \
466 -Ostyle=mandoc.css,man=%N.%S.html,includes=%I.html $< > $@