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