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