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