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