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