[BACK]Return to bsd.man.mk CVS log [TXT][DIR] Up to [local] / src / share / mk

File: [local] / src / share / mk / bsd.man.mk (download)

Revision 1.35, Tue Jun 28 23:50:46 2011 UTC (12 years, 11 months ago) by schwarze
Branch: MAIN
Changes since 1.34: +10 -10 lines

Less ugly MANSUBDIR handling, not needing '' any longer.
ok espie@

Note: This does not yet fix the issue noted by deraadt@
that two consecutive make install invocations install only once.
Both of my proposed solutions are not nice,
and espie@ is searching for a cleaner way.

#	$OpenBSD: bsd.man.mk,v 1.35 2011/06/28 23:50:46 schwarze Exp $
#	$NetBSD: bsd.man.mk,v 1.23 1996/02/10 07:49:33 jtc Exp $
#	@(#)bsd.man.mk	5.2 (Berkeley) 5/11/90

.if !target(.MAIN)
.  if exists(${.CURDIR}/../Makefile.inc)
.    include "${.CURDIR}/../Makefile.inc"
.  endif

.MAIN: all
.endif

# Add / so that we don't have to specify it.
.if defined(MANSUBDIR) && !empty(MANSUBDIR)
MANSUBDIR:=${MANSUBDIR:S,^,/,:S,$,/,}
.else
MANSUBDIR=/
.endif

CLEANFILES+= .man-linted

.if defined(MAN) && !empty(MAN)
.man-linted: ${MAN}
	mandoc -Tlint -Wfatal ${.ALLSRC}
	@touch ${.TARGET}

all: .man-linted
.endif

.for page in ${MAN}
.  for sub in ${MANSUBDIR}
_MAN_INST=${DESTDIR}${MANDIR}${page:E}${sub}${page:T}
${_MAN_INST}: ${page}
	${INSTALL} ${INSTALL_COPY} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE} \
		${.ALLSRC} ${.TARGET}

maninstall: ${_MAN_INST}
.  endfor
.endfor

maninstall:
.if defined(MLINKS) && !empty(MLINKS)
.  for sub in ${MANSUBDIR}
.     for lnk file in ${MLINKS}
	@l=${DESTDIR}${MANDIR}${lnk:E}${sub}${lnk}; \
	t=${DESTDIR}${MANDIR}${file:E}${sub}${file}; \
	echo $$t -\> $$l; \
	rm -f $$t; ln $$l $$t;
.     endfor
.  endfor
.endif

BEFOREMAN?=
all: ${BEFOREMAN} ${MAN}