1#
2# Copyright (c) 2001-2015 Hypertriton, Inc. <http://hypertriton.com/>
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions
7# are met:
8# 1. Redistributions of source code must retain the above copyright
9#    notice, this list of conditions and the following disclaimer.
10# 2. Redistributions in binary form must reproduce the above copyright
11#    notice, this list of conditions and the following disclaimer in the
12#    documentation and/or other materials provided with the distribution.
13#
14# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
18# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19# DAMAGES (INCLUDING BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
21# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
22# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
23# USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
25#
26# Preformat and install manual pages from mandoc sources.
27#
28
29MANDOC?=
30PAGER?=more
31MAN1?=
32MAN2?=
33MAN3?=
34MAN4?=
35MAN5?=
36MAN6?=
37MAN7?=
38MAN8?=
39MAN9?=
40CATMAN1?=
41CATMAN2?=
42CATMAN3?=
43CATMAN4?=
44CATMAN5?=
45CATMAN6?=
46CATMAN7?=
47CATMAN8?=
48CATMAN9?=
49MANS=${MAN1} ${MAN2} ${MAN3} ${MAN4} ${MAN5} ${MAN6} ${MAN7} ${MAN8} ${MAN9}
50MANLINKS?=
51NOMAN?=
52NOCATMAN?=
53NOMANLINKS?=
54CLEANFILES?=
55
56all: all-subdir all-catman
57install: install-man-dirs install-man install-subdir
58deinstall: deinstall-subdir
59clean: clean-man clean-subdir
60cleandir: clean-man clean-subdir cleandir-subdir
61regress: regress-subdir
62depend: depend-subdir
63
64.SUFFIXES: .1 .2 .3 .4 .5 .6 .7 .8 .9 .cat1 .cat2 .cat3 .cat4 .cat5 .cat6 .cat7 .cat8 .cat9 .ps .pdf .html
65
66.1.cat1 .2.cat2 .3.cat3 .4.cat4 .5.cat5 .6.cat6 .7.cat7 .8.cat8 .9.cat9:
67	@echo "${MANDOC} -Tascii $< > $@"
68	@(cat $< | \
69	  sed 's,\$$SYSCONFDIR,${SYSCONFDIR},' | \
70	  sed 's,\$$PREFIX,${PREFIX},' | \
71	  sed 's,\$$DATADIR,${DATADIR},' | \
72	  ${MANDOC} -Tascii > $@) || (rm -f $@; true)
73
74.1.ps .2.ps .3.ps .4.ps .5.ps .6.ps .7.ps .8.ps .9.ps:
75	@if [ "${HAVE_MANDOC}" != "yes" ]; then echo "Requires mandoc"; exit 1; fi
76	@echo "${MANDOC} -Tps $< > $@"
77	@(cat $< | \
78	  sed 's,\$$SYSCONFDIR,${SYSCONFDIR},' | \
79	  sed 's,\$$PREFIX,${PREFIX},' | \
80	  sed 's,\$$DATADIR,${DATADIR},' | \
81	  ${MANDOC} -Tps > $@) || (rm -f $@; true)
82
83.1.pdf .2.pdf .3.pdf .4.pdf .5.pdf .6.pdf .7.pdf .8.pdf .9.pdf:
84	@if [ "${HAVE_MANDOC}" != "yes" ]; then echo "Requires mandoc"; exit 1; fi
85	@echo "${MANDOC} -Tpdf $< > $@"
86	@(cat $< | \
87	  sed 's,\$$SYSCONFDIR,${SYSCONFDIR},' | \
88	  sed 's,\$$PREFIX,${PREFIX},' | \
89	  sed 's,\$$DATADIR,${DATADIR},' | \
90	  ${MANDOC} -Tpdf > $@) || (rm -f $@; true)
91
92.1.html .2.html .3.html .4.html .5.html .6.html .7.html .8.html .9.html:
93	@if [ "${HAVE_MANDOC}" != "yes" ]; then echo "Requires mandoc"; exit 1; fi
94	@echo "${MANDOC} -Thtml $< > $@"
95	@(cat $< | \
96	  sed 's,\$$SYSCONFDIR,${SYSCONFDIR},' | \
97	  sed 's,\$$PREFIX,${PREFIX},' | \
98	  sed 's,\$$DATADIR,${DATADIR},' | \
99	  ${MANDOC} -Thtml > $@) || (rm -f $@; true)
100
101all-catman:
102	@if [ "${HAVE_MANDOC}" != "yes" ]; then exit 0; fi
103	@if [ "${MAN1}" != "" -a "${NOMAN}" != "yes" ]; then \
104	    if [ "${CATMAN1}" = "" ]; then \
105	        CATLIST=""; \
106	        for F in ${MAN1}; do \
107	            CAT=`echo $$F | sed 's/.1$$/.cat1/'`; \
108		    CATLIST="$$CATLIST $$CAT"; \
109	        done; \
110	        ${MAKE} $$CATLIST; \
111	    else \
112	        ${MAKE} ${CATMAN1}; \
113	    fi; \
114	fi
115	@if [ "${MAN2}" != "" -a "${NOMAN}" != "yes" ]; then \
116	    if [ "${CATMAN2}" = "" ]; then \
117	        CATLIST=""; \
118	        for F in ${MAN2}; do \
119	            CAT=`echo $$F | sed 's/.2$$/.cat2/'`; \
120		    CATLIST="$$CATLIST $$CAT"; \
121	        done; \
122	        ${MAKE} $$CATLIST; \
123	    else \
124	        ${MAKE} ${CATMAN2}; \
125	    fi; \
126	fi
127	@if [ "${MAN3}" != "" -a "${NOMAN}" != "yes" ]; then \
128	    if [ "${CATMAN3}" = "" ]; then \
129	        CATLIST=""; \
130	        for F in ${MAN3}; do \
131	            CAT=`echo $$F | sed 's/.3$$/.cat3/'`; \
132		    CATLIST="$$CATLIST $$CAT"; \
133	        done; \
134	        ${MAKE} $$CATLIST; \
135	    else \
136	        ${MAKE} ${CATMAN3}; \
137	    fi; \
138	fi
139	@if [ "${MAN4}" != "" -a "${NOMAN}" != "yes" ]; then \
140	    if [ "${CATMAN4}" = "" ]; then \
141	        CATLIST=""; \
142	        for F in ${MAN4}; do \
143	            CAT=`echo $$F | sed 's/.4$$/.cat4/'`; \
144		    CATLIST="$$CATLIST $$CAT"; \
145	        done; \
146	        ${MAKE} $$CATLIST; \
147	    else \
148	        ${MAKE} ${CATMAN4}; \
149	    fi; \
150	fi
151	@if [ "${MAN5}" != "" -a "${NOMAN}" != "yes" ]; then \
152	    if [ "${CATMAN5}" = "" ]; then \
153	        CATLIST=""; \
154	        for F in ${MAN5}; do \
155	            CAT=`echo $$F | sed 's/.5$$/.cat5/'`; \
156		    CATLIST="$$CATLIST $$CAT"; \
157	        done; \
158	        ${MAKE} $$CATLIST; \
159	    else \
160	        ${MAKE} ${CATMAN5}; \
161	    fi; \
162	fi
163	@if [ "${MAN6}" != "" -a "${NOMAN}" != "yes" ]; then \
164	    if [ "${CATMAN6}" = "" ]; then \
165	        CATLIST=""; \
166	        for F in ${MAN6}; do \
167	            CAT=`echo $$F | sed 's/.6$$/.cat6/'`; \
168		    CATLIST="$$CATLIST $$CAT"; \
169	        done; \
170	        ${MAKE} $$CATLIST; \
171	    else \
172	        ${MAKE} ${CATMAN6}; \
173	    fi; \
174	fi
175	@if [ "${MAN7}" != "" -a "${NOMAN}" != "yes" ]; then \
176	    if [ "${CATMAN7}" = "" ]; then \
177	        CATLIST=""; \
178	        for F in ${MAN7}; do \
179	            CAT=`echo $$F | sed 's/.7$$/.cat7/'`; \
180		    CATLIST="$$CATLIST $$CAT"; \
181	        done; \
182	        ${MAKE} $$CATLIST; \
183	    else \
184	        ${MAKE} ${CATMAN7}; \
185	    fi; \
186	fi
187	@if [ "${MAN8}" != "" -a "${NOMAN}" != "yes" ]; then \
188	    if [ "${CATMAN8}" = "" ]; then \
189	        CATLIST=""; \
190	        for F in ${MAN8}; do \
191	            CAT=`echo $$F | sed 's/.8$$/.cat8/'`; \
192		    CATLIST="$$CATLIST $$CAT"; \
193	        done; \
194	        ${MAKE} $$CATLIST; \
195	    else \
196	        ${MAKE} ${CATMAN8}; \
197	    fi; \
198	fi
199	@if [ "${MAN9}" != "" -a "${NOMAN}" != "yes" ]; then \
200	    if [ "${CATMAN9}" = "" ]; then \
201	        CATLIST=""; \
202	        for F in ${MAN9}; do \
203	            CAT=`echo $$F | sed 's/.9$$/.cat9/'`; \
204		    CATLIST="$$CATLIST $$CAT"; \
205	        done; \
206	        ${MAKE} $$CATLIST; \
207	    else \
208	        ${MAKE} ${CATMAN9}; \
209	    fi; \
210	fi
211
212clean-man:
213	@if [ "${MAN1}" != "" ]; then \
214	    if [ "${CATMAN1}" = "" ]; then \
215	        for F in ${MAN1}; do \
216	            CAT=`echo $$F | sed 's/.1$$/.cat1/'`; \
217	            rm -f $$CAT; \
218	        done; \
219	     else \
220	         rm -f ${CATMAN1}; \
221	     fi; \
222	fi
223	@if [ "${MAN2}" != "" ]; then \
224	    if [ "${CATMAN2}" = "" ]; then \
225	        for F in ${MAN2}; do \
226	            CAT=`echo $$F | sed 's/.2$$/.cat2/'`; \
227	            rm -f $$CAT; \
228	        done; \
229	     else \
230	         rm -f ${CATMAN2}; \
231	     fi; \
232	fi
233	@if [ "${MAN3}" != "" ]; then \
234	    if [ "${CATMAN3}" = "" ]; then \
235	        for F in ${MAN3}; do \
236	            CAT=`echo $$F | sed 's/.3$$/.cat3/'`; \
237	            rm -f $$CAT; \
238	        done; \
239	     else \
240	         rm -f ${CATMAN3}; \
241	     fi; \
242	fi
243	@if [ "${MAN4}" != "" ]; then \
244	    if [ "${CATMAN4}" = "" ]; then \
245	        for F in ${MAN4}; do \
246	            CAT=`echo $$F | sed 's/.4$$/.cat4/'`; \
247	            rm -f $$CAT; \
248	        done; \
249	     else \
250	         rm -f ${CATMAN4}; \
251	     fi; \
252	fi
253	@if [ "${MAN5}" != "" ]; then \
254	    if [ "${CATMAN5}" = "" ]; then \
255	        for F in ${MAN5}; do \
256	            CAT=`echo $$F | sed 's/.5$$/.cat5/'`; \
257	            rm -f $$CAT; \
258	        done; \
259	     else \
260	         rm -f ${CATMAN5}; \
261	     fi; \
262	fi
263	@if [ "${MAN6}" != "" ]; then \
264	    if [ "${CATMAN6}" = "" ]; then \
265	        for F in ${MAN6}; do \
266	            CAT=`echo $$F | sed 's/.6$$/.cat6/'`; \
267	            rm -f $$CAT; \
268	        done; \
269	     else \
270	         rm -f ${CATMAN6}; \
271	     fi; \
272	fi
273	@if [ "${MAN7}" != "" ]; then \
274	    if [ "${CATMAN7}" = "" ]; then \
275	        for F in ${MAN7}; do \
276	            CAT=`echo $$F | sed 's/.7$$/.cat7/'`; \
277	            rm -f $$CAT; \
278	        done; \
279	     else \
280	         rm -f ${CATMAN7}; \
281	     fi; \
282	fi
283	@if [ "${MAN8}" != "" ]; then \
284	    if [ "${CATMAN8}" = "" ]; then \
285	        for F in ${MAN8}; do \
286	            CAT=`echo $$F | sed 's/.8$$/.cat8/'`; \
287	            rm -f $$CAT; \
288	        done; \
289	     else \
290	         rm -f ${CATMAN8}; \
291	     fi; \
292	fi
293	@if [ "${MAN9}" != "" ]; then \
294	    if [ "${CATMAN9}" = "" ]; then \
295	        for F in ${MAN9}; do \
296	            CAT=`echo $$F | sed 's/.9$$/.cat9/'`; \
297	            rm -f $$CAT; \
298	        done; \
299	     else \
300	         rm -f ${CATMAN9}; \
301	     fi; \
302	fi
303	@if [ "${CLEANFILES}" != "" ]; then \
304	    echo "rm -f ${CLEANFILES}"; \
305	    rm -f ${CLEANFILES}; \
306	fi
307
308install-man-dirs:
309	@if [ "${MANS}" != "       " ]; then \
310	    if [ ! -d "${DESTDIR}${MANDIR}" ]; then \
311	        echo "${INSTALL_MAN_DIR} ${MANDIR}"; \
312	        ${SUDO} ${INSTALL_MAN_DIR} ${DESTDIR}${MANDIR}; \
313	    fi; \
314	    if [ ! -d "${DESTDIR}${MANDIR}/man1" ]; then \
315	        echo "${INSTALL_MAN_DIR} ${MANDIR}/man1"; \
316	        ${SUDO} ${INSTALL_MAN_DIR} ${DESTDIR}${MANDIR}/man1; \
317	    fi; \
318	    if [ ! -d "${DESTDIR}${MANDIR}/man2" ]; then \
319	        echo "${INSTALL_MAN_DIR} ${MANDIR}/man2"; \
320	        ${SUDO} ${INSTALL_MAN_DIR} ${DESTDIR}${MANDIR}/man2; \
321	    fi; \
322	    if [ ! -d "${DESTDIR}${MANDIR}/man3" ]; then \
323	        echo "${INSTALL_MAN_DIR} ${MANDIR}/man3"; \
324	        ${SUDO} ${INSTALL_MAN_DIR} ${DESTDIR}${MANDIR}/man3; \
325	    fi; \
326	    if [ ! -d "${DESTDIR}${MANDIR}/man4" ]; then \
327	        echo "${INSTALL_MAN_DIR} ${MANDIR}/man4"; \
328	        ${SUDO} ${INSTALL_MAN_DIR} ${DESTDIR}${MANDIR}/man4; \
329	    fi; \
330	    if [ ! -d "${DESTDIR}${MANDIR}/man5" ]; then \
331	        echo "${INSTALL_MAN_DIR} ${MANDIR}/man5"; \
332	        ${SUDO} ${INSTALL_MAN_DIR} ${DESTDIR}${MANDIR}/man5; \
333	    fi; \
334	    if [ ! -d "${DESTDIR}${MANDIR}/man6" ]; then \
335	        echo "${INSTALL_MAN_DIR} ${MANDIR}/man6"; \
336	        ${SUDO} ${INSTALL_MAN_DIR} ${DESTDIR}${MANDIR}/man6; \
337	    fi; \
338	    if [ ! -d "${DESTDIR}${MANDIR}/man7" ]; then \
339	        echo "${INSTALL_MAN_DIR} ${MANDIR}/man7"; \
340	        ${SUDO} ${INSTALL_MAN_DIR} ${DESTDIR}${MANDIR}/man7; \
341	    fi; \
342	    if [ ! -d "${DESTDIR}${MANDIR}/man8" ]; then \
343	        echo "${INSTALL_MAN_DIR} ${MANDIR}/man8"; \
344	        ${SUDO} ${INSTALL_MAN_DIR} ${DESTDIR}${MANDIR}/man8; \
345	    fi; \
346	    if [ ! -d "${DESTDIR}${MANDIR}/man9" ]; then \
347	        echo "${INSTALL_MAN_DIR} ${MANDIR}/man9"; \
348	        ${SUDO} ${INSTALL_MAN_DIR} ${DESTDIR}${MANDIR}/man9; \
349	    fi; \
350	    if [ ! -d "${DESTDIR}${MANDIR}/cat1" ]; then \
351	        echo "${INSTALL_MAN_DIR} ${MANDIR}/cat1"; \
352	        ${SUDO} ${INSTALL_MAN_DIR} ${DESTDIR}${MANDIR}/cat1; \
353	    fi; \
354	    if [ ! -d "${DESTDIR}${MANDIR}/cat2" ]; then \
355	        echo "${INSTALL_MAN_DIR} ${MANDIR}/cat2"; \
356	        ${SUDO} ${INSTALL_MAN_DIR} ${DESTDIR}${MANDIR}/cat2; \
357	    fi; \
358	    if [ ! -d "${DESTDIR}${MANDIR}/cat3" ]; then \
359	        echo "${INSTALL_MAN_DIR} ${MANDIR}/cat3"; \
360	        ${SUDO} ${INSTALL_MAN_DIR} ${DESTDIR}${MANDIR}/cat3; \
361	    fi; \
362	    if [ ! -d "${DESTDIR}${MANDIR}/cat4" ]; then \
363	        echo "${INSTALL_MAN_DIR} ${MANDIR}/cat4"; \
364	        ${SUDO} ${INSTALL_MAN_DIR} ${DESTDIR}${MANDIR}/cat4; \
365	    fi; \
366	    if [ ! -d "${DESTDIR}${MANDIR}/cat5" ]; then \
367	        echo "${INSTALL_MAN_DIR} ${MANDIR}/cat5"; \
368	        ${SUDO} ${INSTALL_MAN_DIR} ${DESTDIR}${MANDIR}/cat5; \
369	    fi; \
370	    if [ ! -d "${DESTDIR}${MANDIR}/cat6" ]; then \
371	        echo "${INSTALL_MAN_DIR} ${MANDIR}/cat6"; \
372	        ${SUDO} ${INSTALL_MAN_DIR} ${DESTDIR}${MANDIR}/cat6; \
373	    fi; \
374	    if [ ! -d "${DESTDIR}${MANDIR}/cat7" ]; then \
375	        echo "${INSTALL_MAN_DIR} ${MANDIR}/cat7"; \
376	        ${SUDO} ${INSTALL_MAN_DIR} ${DESTDIR}${MANDIR}/cat7; \
377	    fi; \
378	    if [ ! -d "${DESTDIR}${MANDIR}/cat8" ]; then \
379	        echo "${INSTALL_MAN_DIR} ${MANDIR}/cat8"; \
380	        ${SUDO} ${INSTALL_MAN_DIR} ${DESTDIR}${MANDIR}/cat8; \
381	    fi; \
382	    if [ ! -d "${DESTDIR}${MANDIR}/cat9" ]; then \
383	        echo "${INSTALL_MAN_DIR} ${MANDIR}/cat9"; \
384	        ${SUDO} ${INSTALL_MAN_DIR} ${DESTDIR}${MANDIR}/cat9; \
385	    fi; \
386	fi
387
388install-man:
389	@if [ "${MAN1}" != "" -a "${NOMAN}" != "yes" ]; then \
390	    ${SUDO} env MAN="${MAN1}" CATMAN="${CATMAN1}" NOCATMAN="${NOCATMAN}" \
391	        INSTALL_DATA="${INSTALL_DATA}" \
392		MANDIR="${DESTDIR}${MANDIR}/man1" \
393	        CATMANDIR="${DESTDIR}${MANDIR}/cat1" \
394	        ${SH} ${TOP}/mk/install-manpages.sh; \
395	    if [ $$? != 0 ]; then \
396	    	echo "install-manpages.sh failed"; \
397		exit 1; \
398	    fi; \
399	fi
400	@if [ "${MAN2}" != "" -a "${NOMAN}" != "yes" ]; then \
401	    ${SUDO} env MAN="${MAN2}" CATMAN="${CATMAN2}" NOCATMAN="${NOCATMAN}" \
402	        INSTALL_DATA="${INSTALL_DATA}" \
403		MANDIR="${DESTDIR}${MANDIR}/man2" \
404	        CATMANDIR="${DESTDIR}${MANDIR}/cat2" \
405	        ${SH} ${TOP}/mk/install-manpages.sh; \
406	    if [ $$? != 0 ]; then \
407	    	echo "install-manpages.sh failed"; \
408		exit 1; \
409	    fi; \
410	fi
411	@if [ "${MAN3}" != "" -a "${NOMAN}" != "yes" ]; then \
412	    ${SUDO} env MAN="${MAN3}" CATMAN="${CATMAN3}" NOCATMAN="${NOCATMAN}" \
413	        INSTALL_DATA="${INSTALL_DATA}" \
414		MANDIR="${DESTDIR}${MANDIR}/man3" \
415	        CATMANDIR="${DESTDIR}${MANDIR}/cat3" \
416	        ${SH} ${TOP}/mk/install-manpages.sh; \
417	    if [ $$? != 0 ]; then \
418	    	echo "install-manpages.sh failed"; \
419		exit 1; \
420	    fi; \
421	fi
422	@if [ "${MAN4}" != "" -a "${NOMAN}" != "yes" ]; then \
423	    ${SUDO} env MAN="${MAN4}" CATMAN="${CATMAN4}" NOCATMAN="${NOCATMAN}" \
424	        INSTALL_DATA="${INSTALL_DATA}" \
425		MANDIR="${DESTDIR}${MANDIR}/man4" \
426	        CATMANDIR="${DESTDIR}${MANDIR}/cat4" \
427	        ${SH} ${TOP}/mk/install-manpages.sh; \
428	    if [ $$? != 0 ]; then \
429	    	echo "install-manpages.sh failed"; \
430		exit 1; \
431	    fi; \
432	fi
433	@if [ "${MAN5}" != "" -a "${NOMAN}" != "yes" ]; then \
434	    ${SUDO} env MAN="${MAN5}" CATMAN="${CATMAN5}" NOCATMAN="${NOCATMAN}" \
435	        INSTALL_DATA="${INSTALL_DATA}" \
436		MANDIR="${DESTDIR}${MANDIR}/man5" \
437	        CATMANDIR="${DESTDIR}${MANDIR}/cat5" \
438	        ${SH} ${TOP}/mk/install-manpages.sh; \
439	    if [ $$? != 0 ]; then \
440	    	echo "install-manpages.sh failed"; \
441		exit 1; \
442	    fi; \
443	fi
444	@if [ "${MAN6}" != "" -a "${NOMAN}" != "yes" ]; then \
445	    ${SUDO} env MAN="${MAN6}" CATMAN="${CATMAN6}" NOCATMAN="${NOCATMAN}" \
446	        INSTALL_DATA="${INSTALL_DATA}" \
447		MANDIR="${DESTDIR}${MANDIR}/man6" \
448	        CATMANDIR="${DESTDIR}${MANDIR}/cat6" \
449	        ${SH} ${TOP}/mk/install-manpages.sh; \
450	    if [ $$? != 0 ]; then \
451	    	echo "install-manpages.sh failed"; \
452		exit 1; \
453	    fi; \
454	fi
455	@if [ "${MAN7}" != "" -a "${NOMAN}" != "yes" ]; then \
456	    ${SUDO} env MAN="${MAN7}" CATMAN="${CATMAN7}" NOCATMAN="${NOCATMAN}" \
457	        INSTALL_DATA="${INSTALL_DATA}" \
458		MANDIR="${DESTDIR}${MANDIR}/man7" \
459	        CATMANDIR="${DESTDIR}${MANDIR}/cat7" \
460	        ${SH} ${TOP}/mk/install-manpages.sh; \
461	    if [ $$? != 0 ]; then \
462	    	echo "install-manpages.sh failed"; \
463		exit 1; \
464	    fi; \
465	fi
466	@if [ "${MAN8}" != "" -a "${NOMAN}" != "yes" ]; then \
467	    ${SUDO} env MAN="${MAN8}" CATMAN="${CATMAN8}" NOCATMAN="${NOCATMAN}" \
468	        INSTALL_DATA="${INSTALL_DATA}" \
469		MANDIR="${DESTDIR}${MANDIR}/man8" \
470	        CATMANDIR="${DESTDIR}${MANDIR}/cat8" \
471	        ${SH} ${TOP}/mk/install-manpages.sh; \
472	    if [ $$? != 0 ]; then \
473	    	echo "install-manpages.sh failed"; \
474		exit 1; \
475	    fi; \
476	fi
477	@if [ "${MAN9}" != "" -a "${NOMAN}" != "yes" ]; then \
478	    ${SUDO} env MAN="${MAN9}" CATMAN="${CATMAN9}" NOCATMAN="${NOCATMAN}" \
479	        INSTALL_DATA="${INSTALL_DATA}" \
480		MANDIR="${DESTDIR}${MANDIR}/man9" \
481	        CATMANDIR="${DESTDIR}${MANDIR}/cat9" \
482	        ${SH} ${TOP}/mk/install-manpages.sh; \
483	    if [ $$? != 0 ]; then \
484	    	echo "install-manpages.sh failed"; \
485		exit 1; \
486	    fi; \
487	fi
488	@if [ "${NOMANLINKS}" != "yes" -a "${MANLINKS}" != "" ]; then \
489		echo "${MAKE} install-manlinks"; \
490		${MAKE} install-manlinks; \
491	fi
492
493install-manlinks:
494	@(cd ${DESTDIR}${MANDIR} && \
495	     for L in ${MANLINKS}; do \
496	        MPG=`echo $$L | sed 's/:.*//'`; \
497	        MLNK=`echo $$L | sed 's/.*://'`; \
498		MS=`echo $$L | sed 's/.*\.//'`; \
499		echo "ln -fs $$MPG man$$MS/$$MLNK"; \
500		${SUDO} ln -fs $$MPG man$$MS/$$MLNK; \
501	    done)
502	@if [ "${NOCATMAN}" != "yes" ]; then \
503	    (cd ${DESTDIR}${MANDIR} && \
504	     for L in ${CATLINKS}; do \
505	        MPG=`echo $$L | sed 's/:.*//'`; \
506	        MLNK=`echo $$L | sed 's/.*://'`; \
507		MS=`echo $$L | sed 's/.*\.//'`; \
508		echo "ln -fs $$MPG $$MS/$$MLNK"; \
509		${SUDO} ln -fs $$MPG $$MS/$$MLNK; \
510	    done); \
511	fi
512
513man:
514	@if [ "${MAN}" != "" ]; then \
515		echo "${MANDOC} -Tascii ${MAN} | ${PAGER}"; \
516		${MANDOC} -Tascii ${MAN} | ${PAGER}; \
517	else \
518		echo "Usage: ${MAKE} man MAN=(manpage)"; \
519		exit 1; \
520	fi
521
522manlinks: Makefile
523	echo > .manlinks.mk
524	@if [ "${MAN2}" != "" ]; then \
525		for F in ${MAN2}; do \
526			echo "cat $$F |perl ${TOP}/mk/manlinks.pl $$F >>.manlinks.mk"; \
527			cat $$F |perl ${TOP}/mk/manlinks.pl $$F >>.manlinks.mk; \
528		done; \
529	fi
530	@if [ "${MAN3}" != "" ]; then \
531		for F in ${MAN3}; do \
532			echo "cat $$F |perl ${TOP}/mk/manlinks.pl $$F >>.manlinks.mk"; \
533			cat $$F |perl ${TOP}/mk/manlinks.pl $$F >>.manlinks.mk; \
534		done; \
535	fi
536	@if [ "${MAN9}" != "" ]; then \
537		for F in ${MAN9}; do \
538			echo "cat $$F |perl ${TOP}/mk/manlinks.pl $$F >>.manlinks.mk"; \
539			cat $$F |perl ${TOP}/mk/manlinks.pl $$F >>.manlinks.mk; \
540		done; \
541	fi
542
543all-manlinks:
544	@if [ "${SRC}" != "" ]; then \
545		(cd ${SRC} && \
546		 for DIR in `find . -name .manlinks.mk |sed 's/\/\.manlinks\.mk//'`; do \
547			echo "(cd $$DIR && ${MAKE} manlinks)"; \
548			(cd $$DIR && ${MAKE} manlinks); \
549		done); \
550	else \
551		for DIR in `find . -name .manlinks.mk |sed 's/\/\.manlinks\.mk//'`; do \
552			echo "(cd $$DIR && ${MAKE} manlinks)"; \
553			(cd $$DIR && ${MAKE} manlinks); \
554		done; \
555	fi
556
557man2wiki: Makefile
558	@if [ "${MAN1}" != "" ]; then \
559		for F in ${MAN1}; do \
560			echo "cat $$F |perl ${TOP}/mk/man2wiki.pl $$F"; \
561			cat $$F |perl ${TOP}/mk/man2wiki.pl $$F; \
562		done; \
563	fi
564	@if [ "${MAN2}" != "" ]; then \
565		for F in ${MAN2}; do \
566			echo "cat $$F |perl ${TOP}/mk/man2wiki.pl $$F"; \
567			cat $$F |perl ${TOP}/mk/man2wiki.pl $$F; \
568		done; \
569	fi
570	@if [ "${MAN3}" != "" ]; then \
571		for F in ${MAN3}; do \
572			echo "cat $$F |perl ${TOP}/mk/man2wiki.pl $$F"; \
573			cat $$F |perl ${TOP}/mk/man2wiki.pl $$F; \
574		done; \
575	fi
576	@if [ "${MAN4}" != "" ]; then \
577		for F in ${MAN4}; do \
578			echo "cat $$F |perl ${TOP}/mk/man2wiki.pl $$F"; \
579			cat $$F |perl ${TOP}/mk/man2wiki.pl $$F; \
580		done; \
581	fi
582	@if [ "${MAN5}" != "" ]; then \
583		for F in ${MAN5}; do \
584			echo "cat $$F |perl ${TOP}/mk/man2wiki.pl $$F"; \
585			cat $$F |perl ${TOP}/mk/man2wiki.pl $$F; \
586		done; \
587	fi
588	@if [ "${MAN6}" != "" ]; then \
589		for F in ${MAN6}; do \
590			echo "cat $$F |perl ${TOP}/mk/man2wiki.pl $$F"; \
591			cat $$F |perl ${TOP}/mk/man2wiki.pl $$F; \
592		done; \
593	fi
594	@if [ "${MAN7}" != "" ]; then \
595		for F in ${MAN7}; do \
596			echo "cat $$F |perl ${TOP}/mk/man2wiki.pl $$F"; \
597			cat $$F |perl ${TOP}/mk/man2wiki.pl $$F; \
598		done; \
599	fi
600	@if [ "${MAN8}" != "" ]; then \
601		for F in ${MAN8}; do \
602			echo "cat $$F |perl ${TOP}/mk/man2wiki.pl $$F"; \
603			cat $$F |perl ${TOP}/mk/man2wiki.pl $$F; \
604		done; \
605	fi
606	@if [ "${MAN9}" != "" ]; then \
607		for F in ${MAN9}; do \
608			echo "cat $$F |perl ${TOP}/mk/man2wiki.pl $$F"; \
609			cat $$F |perl ${TOP}/mk/man2wiki.pl $$F; \
610		done; \
611	fi
612
613lint:
614	@if [ "${HAVE_MANDOC}" != "yes" ]; then \
615		echo "Cannot find mandoc (re-run ./configure?)"; \
616		exit 1; \
617	fi
618	@if [ "${MAN1}" != "" ]; then for F in ${MAN1}; do ${MANDOC} -Tlint $$F; done; fi
619	@if [ "${MAN2}" != "" ]; then for F in ${MAN2}; do ${MANDOC} -Tlint $$F; done; fi
620	@if [ "${MAN3}" != "" ]; then for F in ${MAN3}; do ${MANDOC} -Tlint $$F; done; fi
621	@if [ "${MAN4}" != "" ]; then for F in ${MAN4}; do ${MANDOC} -Tlint $$F; done; fi
622	@if [ "${MAN5}" != "" ]; then for F in ${MAN5}; do ${MANDOC} -Tlint $$F; done; fi
623	@if [ "${MAN6}" != "" ]; then for F in ${MAN6}; do ${MANDOC} -Tlint $$F; done; fi
624	@if [ "${MAN7}" != "" ]; then for F in ${MAN7}; do ${MANDOC} -Tlint $$F; done; fi
625	@if [ "${MAN8}" != "" ]; then for F in ${MAN8}; do ${MANDOC} -Tlint $$F; done; fi
626	@if [ "${MAN9}" != "" ]; then for F in ${MAN9}; do ${MANDOC} -Tlint $$F; done; fi
627
628.PHONY: install deinstall clean cleandir regress depend
629.PHONY: install-man install-manlinks clean-man
630.PHONY: man all-catman install-man-dirs manlinks all-manlinks man2wiki
631
632include ${TOP}/mk/build.common.mk
633