Subject: PLIST_SUB
To: None <tech-pkg@netbsd.org>
From: Kazuki Sakamoto <sakamoto@cec.co.jp>
List: tech-pkg
Date: 08/27/1999 20:41:01
I am ported PLIST_SUB from FreeBSD's bsd.port.mk
for substituting PLIST file. is it ok?

sakamoto
--
--- bsd.pkg.mk.orig	Fri Aug 27 18:25:34 1999
+++ bsd.pkg.mk	Fri Aug 27 19:41:52 1999
@@ -331,6 +331,16 @@
 DESCR=			${WRKDIR}/.DESCR
 PLIST=			${WRKDIR}/.PLIST
 
+# Set PLIST_SUB to substitute "${variable}" to "value" in PLIST
+PLIST_SUB+=	OPSYS=${OPSYS}					\
+		OS_VERSION=${OS_VERSION}			\
+		MACHINE_ARCH=${MACHINE_ARCH}			\
+		MACHINE_GNU_ARCH=${MACHINE_GNU_ARCH}		\
+		MACHINE_GNU_PLATFORM=${MACHINE_GNU_PLATFORM}	\
+		LOWER_VENDOR=${LOWER_VENDOR}			\
+		LOWER_OPSYS=${LOWER_OPSYS}			\
+		PKGNAME=${PKGNAME}
+
 # Set INSTALL_FILE to be the name of any INSTALL file
 .if !defined(INSTALL_FILE) && exists(${PKGDIR}/INSTALL)
 INSTALL_FILE=		${PKGDIR}/INSTALL
@@ -2311,7 +2321,7 @@
 # - fixing list of man-pages according to MANCOMPRESSED/MANZ
 #   (we don't take any notice of MANCOMPRESSED as many packages have .gz
 #   pages in PLIST even when they install manpages without compressing them)
-# - substituting ${OPSYS}, ${MACHINE_ARCH} and ${MACHINE_GNU_ARCH}
+# - substituting by ${PLIST_SUB}
 
 .if ${OPSYS} == "NetBSD"
 IMAKE_MAN_CMD=
@@ -2365,14 +2375,7 @@
 			${MANZ_NAWK_CMD} 				\
 			${IMAKE_MAN_CMD} 				\
 			${SED} 	${MANZ_EXPRESSION}			\
-				-e 's|\$${OPSYS}|${OPSYS}|g'		\
-				-e 's|\$${OS_VERSION}|${OS_VERSION}|g'	\
-				-e 's|\$${MACHINE_ARCH}|${MACHINE_ARCH}|g' \
-				-e 's|\$${MACHINE_GNU_ARCH}|${MACHINE_GNU_ARCH}|g' \
-				-e 's|\$${MACHINE_GNU_PLATFORM}|${MACHINE_GNU_PLATFORM}|g' \
-				-e 's|\$${LOWER_VENDOR}|${LOWER_VENDOR}|g'\
-				-e 's|\$${LOWER_OPSYS}|${LOWER_OPSYS}|g'\
-				-e 's|\$${PKGNAME}|${PKGNAME}|g'	\
+				${PLIST_SUB:S/=/}!/:S/$/!g/:S/^/ -e s!\\\${/} \
 			> ${PLIST}; 					\
 	fi