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