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