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