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