1# $OpenBSD: bsd.man.mk,v 1.38 2011/07/06 20:40:32 schwarze Exp $ 2# $NetBSD: bsd.man.mk,v 1.23 1996/02/10 07:49:33 jtc Exp $ 3# @(#)bsd.man.mk 5.2 (Berkeley) 5/11/90 4 5.if !target(.MAIN) 6. if exists(${.CURDIR}/../Makefile.inc) 7. include "${.CURDIR}/../Makefile.inc" 8. endif 9 10.MAIN: all 11.endif 12 13BEFOREMAN?= 14MANLINT=${MAN:S/$/.manlint/} 15CLEANFILES+=.man-linted ${MANLINT} 16 17# Add / so that we don't have to specify it. 18.if defined(MANSUBDIR) && !empty(MANSUBDIR) 19MANSUBDIR:=${MANSUBDIR:S,^,/,:S,$,/,} 20.else 21MANSUBDIR=/ 22.endif 23 24# Files contained in ${BEFOREMAN} must be built before generating any 25# manual page source code. However, static manual page files contained 26# in the source tree must not appear as targets, or the ${.IMPSRC} in 27# the .man.manlint suffix rule below will not find them in the .PATH. 28.for page in ${MAN} 29. if target(${page}) 30${page}: ${BEFOREMAN} 31. endif 32.endfor 33 34# In any case, ${BEFOREMAN} must be finished before linting any manuals. 35.if !empty(MANLINT) 36${MANLINT}: ${BEFOREMAN} 37.endif 38 39# Set up the suffix rules for checking manuals. 40_MAN_SUFFIXES=1 2 3 3p 4 5 6 7 8 9 41.for s in ${_MAN_SUFFIXES} 42.SUFFIXES: .${s} .${s}.manlint 43.${s}.${s}.manlint: 44 mandoc -Tlint -Wfatal ${.IMPSRC} 45 @touch ${.TARGET} 46.endfor 47 48# Install the real manuals. 49.for page in ${MAN} 50. for sub in ${MANSUBDIR} 51_MAN_INST=${DESTDIR}${MANDIR}${page:E}${sub}${page:T} 52${_MAN_INST}: ${page} 53 ${INSTALL} ${INSTALL_COPY} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE} \ 54 ${.ALLSRC} ${.TARGET} 55 56maninstall: ${_MAN_INST} 57 58.PHONY: ${_MAN_INST} 59. endfor 60.endfor 61 62# Install the manual hardlinks, if any. 63maninstall: 64.if defined(MLINKS) && !empty(MLINKS) 65. for sub in ${MANSUBDIR} 66. for lnk file in ${MLINKS} 67 @l=${DESTDIR}${MANDIR}${lnk:E}${sub}${lnk}; \ 68 t=${DESTDIR}${MANDIR}${file:E}${sub}${file}; \ 69 echo $$t -\> $$l; \ 70 rm -f $$t; ln $$l $$t; 71. endfor 72. endfor 73.endif 74 75# Explicitly list ${BEFOREMAN} to get it done even if ${MAN} is empty. 76all: ${BEFOREMAN} ${MAN} ${MANLINT} 77