summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjlam <jlam>2003-08-27 11:44:27 +0000
committerjlam <jlam>2003-08-27 11:44:27 +0000
commitab56bacb66dc996ea991ed3f6c69be3be4e2dc6d (patch)
tree2a01be718e992daac9fb7bde13be3bc111f0b2e9
parentacde3151339acacea74191cfd00c0b6ab85ef043 (diff)
downloadpkgsrc-ab56bacb66dc996ea991ed3f6c69be3be4e2dc6d.tar.gz
Sync to HEAD for subst.mk
-rw-r--r--mk/Darwin.pkg.dist6
-rw-r--r--mk/Darwin.x11.dist6
-rw-r--r--mk/FreeBSD.pkg.dist6
-rw-r--r--mk/IRIX.pkg.dist6
-rw-r--r--mk/IRIX.x11.dist6
-rw-r--r--mk/Linux.pkg.dist6
-rw-r--r--mk/Linux.x11.dist6
-rw-r--r--mk/NetBSD.pkg.dist6
-rw-r--r--mk/NetBSD.x11.dist6
-rw-r--r--mk/OpenBSD.pkg.dist6
-rw-r--r--mk/OpenBSD.x11.dist6
-rw-r--r--mk/SunOS.pkg.dist6
-rw-r--r--mk/SunOS.x11.dist6
-rw-r--r--mk/bsd.pkg.mk56
-rw-r--r--mk/buildlink2/bsd.buildlink2.mk96
-rw-r--r--mk/subst.mk80
-rw-r--r--mk/tools.mk2
17 files changed, 193 insertions, 119 deletions
diff --git a/mk/Darwin.pkg.dist b/mk/Darwin.pkg.dist
index 27da3a6e8df..d18c66b53c2 100644
--- a/mk/Darwin.pkg.dist
+++ b/mk/Darwin.pkg.dist
@@ -1,5 +1,5 @@
# Id: BSD.local.dist,v 1.30 1997/08/01 13:16:39 phk Exp
-# $NetBSD: Darwin.pkg.dist,v 1.32.2.2 2003/08/01 19:00:19 jlam Exp $
+# $NetBSD: Darwin.pkg.dist,v 1.32.2.3 2003/08/27 11:44:27 jlam Exp $
#
/set type=dir uname=root gname=wheel mode=0755
@@ -640,6 +640,10 @@
LC_MESSAGES
..
..
+ ne
+ LC_MESSAGES
+ ..
+ ..
nl
LC_MESSAGES
..
diff --git a/mk/Darwin.x11.dist b/mk/Darwin.x11.dist
index 878f23306e6..c33a0c43609 100644
--- a/mk/Darwin.x11.dist
+++ b/mk/Darwin.x11.dist
@@ -1,4 +1,4 @@
-# $NetBSD: Darwin.x11.dist,v 1.21.2.2 2003/08/01 19:00:20 jlam Exp $
+# $NetBSD: Darwin.x11.dist,v 1.21.2.3 2003/08/27 11:44:28 jlam Exp $
# FreeBSD Id: BSD.x11.dist,v 1.2 1997/06/10 07:55:10 asami Exp
#
@@ -478,6 +478,10 @@
LC_MESSAGES
..
..
+ ne
+ LC_MESSAGES
+ ..
+ ..
nl
LC_MESSAGES
..
diff --git a/mk/FreeBSD.pkg.dist b/mk/FreeBSD.pkg.dist
index 506ec2f7e67..ccc34e41c75 100644
--- a/mk/FreeBSD.pkg.dist
+++ b/mk/FreeBSD.pkg.dist
@@ -1,4 +1,4 @@
-# $NetBSD: FreeBSD.pkg.dist,v 1.23.4.2 2003/08/01 19:00:20 jlam Exp $
+# $NetBSD: FreeBSD.pkg.dist,v 1.23.4.3 2003/08/27 11:44:28 jlam Exp $
#
/set type=dir uname=root gname=wheel mode=0755
@@ -639,6 +639,10 @@
LC_MESSAGES
..
..
+ ne
+ LC_MESSAGES
+ ..
+ ..
nl
LC_MESSAGES
..
diff --git a/mk/IRIX.pkg.dist b/mk/IRIX.pkg.dist
index 49aa4ddf547..826840d5cc4 100644
--- a/mk/IRIX.pkg.dist
+++ b/mk/IRIX.pkg.dist
@@ -1,4 +1,4 @@
-# $NetBSD: IRIX.pkg.dist,v 1.22.4.2 2003/08/01 19:00:20 jlam Exp $
+# $NetBSD: IRIX.pkg.dist,v 1.22.4.3 2003/08/27 11:44:28 jlam Exp $
#
/set type=dir uname=root gname=sys mode=0755
@@ -639,6 +639,10 @@
LC_MESSAGES
..
..
+ ne
+ LC_MESSAGES
+ ..
+ ..
nl
LC_MESSAGES
..
diff --git a/mk/IRIX.x11.dist b/mk/IRIX.x11.dist
index 24400475ffd..d15bdb172ad 100644
--- a/mk/IRIX.x11.dist
+++ b/mk/IRIX.x11.dist
@@ -1,4 +1,4 @@
-# $NetBSD: IRIX.x11.dist,v 1.1.4.2 2003/08/01 19:00:21 jlam Exp $
+# $NetBSD: IRIX.x11.dist,v 1.1.4.3 2003/08/27 11:44:28 jlam Exp $
# FreeBSD Id: BSD.x11.dist,v 1.2 1997/06/10 07:55:10 asami Exp
#
@@ -450,6 +450,10 @@
LC_MESSAGES
..
..
+ ne
+ LC_MESSAGES
+ ..
+ ..
nl
LC_MESSAGES
..
diff --git a/mk/Linux.pkg.dist b/mk/Linux.pkg.dist
index 2262f0ab710..bf453093157 100644
--- a/mk/Linux.pkg.dist
+++ b/mk/Linux.pkg.dist
@@ -1,5 +1,5 @@
# Id: BSD.local.dist,v 1.30 1997/08/01 13:16:39 phk Exp
-# $NetBSD: Linux.pkg.dist,v 1.39.2.2 2003/08/01 19:00:21 jlam Exp $
+# $NetBSD: Linux.pkg.dist,v 1.39.2.3 2003/08/27 11:44:28 jlam Exp $
#
/set type=dir uname=root gname=sys mode=0755
@@ -640,6 +640,10 @@
LC_MESSAGES
..
..
+ ne
+ LC_MESSAGES
+ ..
+ ..
nl
LC_MESSAGES
..
diff --git a/mk/Linux.x11.dist b/mk/Linux.x11.dist
index 85798dac08b..922042bc805 100644
--- a/mk/Linux.x11.dist
+++ b/mk/Linux.x11.dist
@@ -1,4 +1,4 @@
-# $NetBSD: Linux.x11.dist,v 1.27.2.2 2003/08/01 19:00:22 jlam Exp $
+# $NetBSD: Linux.x11.dist,v 1.27.2.3 2003/08/27 11:44:28 jlam Exp $
# FreeBSD Id: BSD.x11.dist,v 1.2 1997/06/10 07:55:10 asami Exp
#
@@ -478,6 +478,10 @@
LC_MESSAGES
..
..
+ ne
+ LC_MESSAGES
+ ..
+ ..
nl
LC_MESSAGES
..
diff --git a/mk/NetBSD.pkg.dist b/mk/NetBSD.pkg.dist
index fdf96957c3e..f7c371c1df6 100644
--- a/mk/NetBSD.pkg.dist
+++ b/mk/NetBSD.pkg.dist
@@ -1,5 +1,5 @@
# Id: BSD.local.dist,v 1.30 1997/08/01 13:16:39 phk Exp
-# $NetBSD: NetBSD.pkg.dist,v 1.49.2.2 2003/08/01 19:00:22 jlam Exp $
+# $NetBSD: NetBSD.pkg.dist,v 1.49.2.3 2003/08/27 11:44:29 jlam Exp $
#
/set type=dir uname=root gname=wheel mode=0755
@@ -640,6 +640,10 @@
LC_MESSAGES
..
..
+ ne
+ LC_MESSAGES
+ ..
+ ..
nl
LC_MESSAGES
..
diff --git a/mk/NetBSD.x11.dist b/mk/NetBSD.x11.dist
index 33867e93bcc..39126afbc17 100644
--- a/mk/NetBSD.x11.dist
+++ b/mk/NetBSD.x11.dist
@@ -1,4 +1,4 @@
-# $NetBSD: NetBSD.x11.dist,v 1.28.2.2 2003/08/01 19:00:23 jlam Exp $
+# $NetBSD: NetBSD.x11.dist,v 1.28.2.3 2003/08/27 11:44:29 jlam Exp $
# FreeBSD Id: BSD.x11.dist,v 1.2 1997/06/10 07:55:10 asami Exp
#
@@ -478,6 +478,10 @@
LC_MESSAGES
..
..
+ ne
+ LC_MESSAGES
+ ..
+ ..
nl
LC_MESSAGES
..
diff --git a/mk/OpenBSD.pkg.dist b/mk/OpenBSD.pkg.dist
index 8d72bf8804f..b6360057e55 100644
--- a/mk/OpenBSD.pkg.dist
+++ b/mk/OpenBSD.pkg.dist
@@ -1,4 +1,4 @@
-# $NetBSD: OpenBSD.pkg.dist,v 1.22.4.2 2003/08/01 19:00:23 jlam Exp $
+# $NetBSD: OpenBSD.pkg.dist,v 1.22.4.3 2003/08/27 11:44:29 jlam Exp $
#
/set type=dir uname=root gname=wheel mode=0755
@@ -639,6 +639,10 @@
LC_MESSAGES
..
..
+ ne
+ LC_MESSAGES
+ ..
+ ..
nl
LC_MESSAGES
..
diff --git a/mk/OpenBSD.x11.dist b/mk/OpenBSD.x11.dist
index bca2165f7b3..50cd0b6834d 100644
--- a/mk/OpenBSD.x11.dist
+++ b/mk/OpenBSD.x11.dist
@@ -1,4 +1,4 @@
-# $NetBSD: OpenBSD.x11.dist,v 1.15.4.2 2003/08/01 19:00:23 jlam Exp $
+# $NetBSD: OpenBSD.x11.dist,v 1.15.4.3 2003/08/27 11:44:29 jlam Exp $
# OpenBSD: BSD.x11.dist,v 1.4 2002/06/09 06:15:15 todd Exp
# FreeBSD: BSD.x11.dist,v 1.2 1997/06/10 07:55:10 asami Exp
@@ -478,6 +478,10 @@
LC_MESSAGES
..
..
+ ne
+ LC_MESSAGES
+ ..
+ ..
nl
LC_MESSAGES
..
diff --git a/mk/SunOS.pkg.dist b/mk/SunOS.pkg.dist
index 85b536c31ca..deb4c9393c3 100644
--- a/mk/SunOS.pkg.dist
+++ b/mk/SunOS.pkg.dist
@@ -1,5 +1,5 @@
# Id: BSD.local.dist,v 1.30 1997/08/01 13:16:39 phk Exp
-# $NetBSD: SunOS.pkg.dist,v 1.44.2.2 2003/08/01 19:00:25 jlam Exp $
+# $NetBSD: SunOS.pkg.dist,v 1.44.2.3 2003/08/27 11:44:29 jlam Exp $
#
/set type=dir uname=root gname=sys mode=0755
@@ -246,6 +246,10 @@
LC_MESSAGES
..
..
+ ne
+ LC_MESSAGES
+ ..
+ ..
nl
LC_MESSAGES
..
diff --git a/mk/SunOS.x11.dist b/mk/SunOS.x11.dist
index 632f3a932c2..568be69ef78 100644
--- a/mk/SunOS.x11.dist
+++ b/mk/SunOS.x11.dist
@@ -1,4 +1,4 @@
-# $NetBSD: SunOS.x11.dist,v 1.28.2.2 2003/08/01 19:00:25 jlam Exp $
+# $NetBSD: SunOS.x11.dist,v 1.28.2.3 2003/08/27 11:44:30 jlam Exp $
# FreeBSD Id: BSD.x11.dist,v 1.2 1997/06/10 07:55:10 asami Exp
#
@@ -372,6 +372,10 @@
LC_MESSAGES
..
..
+ ne
+ LC_MESSAGES
+ ..
+ ..
nl
LC_MESSAGES
..
diff --git a/mk/bsd.pkg.mk b/mk/bsd.pkg.mk
index 7605d70f573..ced53cf527b 100644
--- a/mk/bsd.pkg.mk
+++ b/mk/bsd.pkg.mk
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.pkg.mk,v 1.1216.2.40 2003/08/27 03:56:50 jlam Exp $
+# $NetBSD: bsd.pkg.mk,v 1.1216.2.41 2003/08/27 11:44:30 jlam Exp $
#
# This file is in the public domain.
#
@@ -692,9 +692,6 @@ MESSAGE_SUBST+= PKGNAME=${PKGNAME} \
MESSAGE_SUBST_SED= ${MESSAGE_SUBST:S/=/}!/:S/$/!g/:S/^/ -e s!\\\${/}
.endif
-PKGCONFIG_OVERRIDE_SED= \
- '-e s|^\(Libs:.*[ ]\)-L\([ ]*[^ ]*\)\(.*\)$$|\1-Wl,${RPATH_FLAG}\2 -L\2\3|'
-
# Latest version of digest(1) required for pkgsrc
DIGEST_REQD= 20010302
@@ -2176,6 +2173,34 @@ do-patch: uptodate-digest
# post-configure. These targets typically edit the files generated by
# the do-configure target that are used during the build phase.
+.if defined(USE_PKGLOCALEDIR)
+_PKGLOCALEDIR= ${PREFIX}/${PKGLOCALEDIR}/locale
+REPLACE_LOCALEDIR_PATTERNS?= # empty
+_REPLACE_LOCALEDIR_PATTERNS= ${REPLACE_LOCALEDIR_PATTERNS}
+. if defined(HAS_CONFIGURE) || defined(GNU_CONFIGURE)
+_REPLACE_LOCALEDIR_PATTERNS+= Makefile.in*
+. else
+_REPLACE_LOCALEDIR_PATTERNS+= Makefile*
+. endif
+_REPLACE_LOCALEDIR_PATTERNS_FIND= \
+ \( ${_REPLACE_LOCALEDIR_PATTERNS:S/$/!/:S/^/-o -name !/:S/!/"/g:S/-o//1} \)
+REPLACE_LOCALEDIR?= # empty
+_REPLACE_LOCALEDIR= \
+ ${REPLACE_LOCALEDIR} \
+ `${FIND} . ${_REPLACE_LOCALEDIR_PATTERNS_FIND} -print | ${SED} -e 's|^\./||' | ${GREP} -v '\.orig' | ${SORT} -u`
+
+_CONFIGURE_PREREQ+= subst-pkglocaledir
+. if empty(USE_PKGLOCALEDIR:M[nN][oO])
+SUBST_CLASSES+= pkglocaledir
+. endif
+SUBST_MESSAGE.pkglocaledir= "Fixing locale directory references."
+SUBST_FILES.pkglocaledir= ${_REPLACE_LOCALEDIR}
+SUBST_SED.pkglocaledir= \
+ -e 's|^\(localedir[ :]*=\).*|\1 ${_PKGLOCALEDIR}|' \
+ -e 's|^\(gnulocaledir[ :]*=\).*|\1 ${_PKGLOCALEDIR}|' \
+ -e 's|\(-DLOCALEDIR[ ]*=\)[^ ]*\(.*\)|\1"\\"${_PKGLOCALEDIR}\\""\2|'
+.endif
+
.if defined(REPLACE_PERL)
REPLACE_INTERPRETER+= perl
_REPLACE.perl.old= .*/bin/perl
@@ -2242,18 +2267,15 @@ do-config-star-override:
. endif
.endif
-.if defined(PKGCONFIG_OVERRIDE)
-_CONFIGURE_PREREQ+= do-pkgconfig-override
-.PHONY: do-pkgconfig-override
-do-pkgconfig-override:
-. for pkgconfig in ${PKGCONFIG_OVERRIDE}
- ${_PKG_SILENT}${_PKG_DEBUG} \
- if [ -f ${pkgconfig} ]; then \
- ${MV} ${pkgconfig} ${pkgconfig}.norpath ; \
- ${SED} ${PKGCONFIG_OVERRIDE_SED} \
- < ${pkgconfig}.norpath > ${pkgconfig} ; \
- fi
-. endfor
+PKGCONFIG_OVERRIDE_SED= \
+ -e 's|^\(Libs:.*[ ]\)-L\([ ]*[^ ]*\)\(.*\)$$|\1${_COMPILER_LD_FLAG}${RPATH_FLAG}\2 -L\2\3|'
+
+.if defined(PKGCONFIG_OVERRIDE) && !empty(PKGCONFIG_OVERRIDE)
+_CONFIGURE_PREREQ+= subst-pkgconfig
+SUBST_CLASSES+= pkgconfig
+SUBST_MESSAGE.pkgconfig= "Adding rpaths to pkgconfig files."
+SUBST_FILES.pkgconfig= ${PKGCONFIG_OVERRIDE:S/^${WRKSRC}\///}
+SUBST_SED.pkgconfig= ${PKGCONFIG_OVERRIDE_SED}
.endif
# By adding this target, it makes sure the the above PREREQ's work.
@@ -4853,6 +4875,8 @@ ${DESCR}: ${DESCR_SRC}
${ECHO} '${HOMEPAGE}' >>${DESCR}
.endif
+.include "../../mk/subst.mk"
+
#
# For bulk build targets (bulk-install, bulk-package), the
# BATCH variable must be set in /etc/mk.conf:
diff --git a/mk/buildlink2/bsd.buildlink2.mk b/mk/buildlink2/bsd.buildlink2.mk
index 7da9ae41ecd..d67c226097a 100644
--- a/mk/buildlink2/bsd.buildlink2.mk
+++ b/mk/buildlink2/bsd.buildlink2.mk
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.buildlink2.mk,v 1.90.4.11 2003/08/18 15:37:36 jlam Exp $
+# $NetBSD: bsd.buildlink2.mk,v 1.90.4.12 2003/08/27 11:44:33 jlam Exp $
#
# An example package buildlink2.mk file:
#
@@ -382,54 +382,6 @@ _BLNK_TRANSFORM+= ${_BLNK_UNPROTECT}
_BLNK_TRANSFORM_SED+= -f ${_BLNK_TRANSFORM_SEDFILE}
_BLNK_UNTRANSFORM_SED+= -f ${_BLNK_UNTRANSFORM_SEDFILE}
-_BLNK_CHECK_IS_TEXT_FILE?= \
- ${FILE_CMD} $${file} | ${EGREP} "(shell script|text)" >/dev/null 2>&1
-
-# _BUILDLINK_SUBST_USE is a make macro that executes code to do general text
-# replacement in files in ${WRKSRC}. The following variables are used:
-#
-# BUILDLINK_SUBST_MESSAGE.<package> message to display, noting what is
-# being substituted
-#
-# BUILDLINK_SUBST_FILES.<package> files on which to run the substitution;
-# these are relative to ${WRKSRC}
-#
-# BUILDLINK_SUBST_SED.<package> sed(1) substitution expression to run
-# on the specified files.
-#
-# The _BUILDLINK_SUBST_USE macro code will try to verify that a file is a text
-# file before attempting any substitutions.
-#
-_BUILDLINK_SUBST_USE: .USE
- ${_PKG_SILENT}${_PKG_DEBUG} \
- cookie=${BUILDLINK_DIR}/.${.TARGET:S/-buildlink-subst//:S/-/_/g}_buildlink_subst_done; \
- if [ ! -f $${cookie} ]; then \
- ${MKDIR} ${BUILDLINK_DIR}; \
- if [ -n "${BUILDLINK_SUBST_SED.${.TARGET:S/-buildlink-subst//}:C/[ ]//g:Q}" ]; then \
- cd ${WRKSRC}; \
- files="${BUILDLINK_SUBST_FILES.${.TARGET:S/-buildlink-subst//}}"; \
- if [ -n "$${files}" ]; then \
- ${ECHO_BUILDLINK_MSG} ${BUILDLINK_SUBST_MESSAGE.${.TARGET:S/-buildlink-subst//}}; \
- cd ${WRKSRC}; \
- for file in $${files}; do \
- if ${_BLNK_CHECK_IS_TEXT_FILE}; then \
- ${MV} -f $${file} $${file}.blsav; \
- ${SED} ${BUILDLINK_SUBST_SED.${.TARGET:S/-buildlink-subst//}} \
- $${file}.blsav > $${file}; \
- if [ -x $${file}.blsav ]; then \
- ${CHMOD} +x $${file}; \
- fi; \
- if ${CMP} -s $${file}.blsav $${file}; then \
- ${MV} -f $${file}.blsav $${file}; \
- else \
- ${ECHO} $${file} >> $${cookie}; \
- fi; \
- fi; \
- done; \
- fi; \
- fi; \
- fi
-
REPLACE_BUILDLINK_PATTERNS?= # empty
_REPLACE_BUILDLINK_PATTERNS= ${REPLACE_BUILDLINK_PATTERNS}
_REPLACE_BUILDLINK_PATTERNS+= *-config
@@ -459,47 +411,13 @@ REPLACE_BUILDLINK_SED?= # empty
_REPLACE_BUILDLINK_SED= ${REPLACE_BUILDLINK_SED}
_REPLACE_BUILDLINK_SED+= ${_LIBTOOL_ARCHIVE_UNTRANSFORM_SED}
-BUILDLINK_SUBST_MESSAGE.unbuildlink= \
+SUBST_CLASSES+= unbuildlink
+SUBST_STAGE.unbuildlink= post-build
+SUBST_MESSAGE.unbuildlink= \
"Fixing buildlink references in files-to-be-installed."
-BUILDLINK_SUBST_FILES.unbuildlink= ${_REPLACE_BUILDLINK}
-BUILDLINK_SUBST_SED.unbuildlink= ${_REPLACE_BUILDLINK_SED}
-BUILDLINK_SUBST_SED.unbuildlink+= ${_BLNK_UNTRANSFORM_SED}
-
-post-build: unbuildlink-buildlink-subst
-unbuildlink-buildlink-subst: _BUILDLINK_SUBST_USE
-
-# Fix locale directory references.
-#
-USE_PKGLOCALEDIR?= no
-_PKGLOCALEDIR= ${PREFIX}/${PKGLOCALEDIR}/locale
-REPLACE_LOCALEDIR_PATTERNS?= # empty
-_REPLACE_LOCALEDIR_PATTERNS= ${REPLACE_LOCALEDIR_PATTERNS}
-.if defined(HAS_CONFIGURE) || defined(GNU_CONFIGURE)
-_REPLACE_LOCALEDIR_PATTERNS+= Makefile.in*
-.else
-_REPLACE_LOCALEDIR_PATTERNS+= Makefile*
-.endif
-_REPLACE_LOCALEDIR_PATTERNS_FIND= \
- \( ${_REPLACE_LOCALEDIR_PATTERNS:S/$/!/:S/^/-o -name !/:S/!/"/g:S/-o//1} \)
-
-REPLACE_LOCALEDIR?= # empty
-_REPLACE_LOCALEDIR= \
- ${REPLACE_LOCALEDIR} \
- `${FIND} . ${_REPLACE_LOCALEDIR_PATTERNS_FIND} -print | ${SED} -e 's|^\./||' | ${GREP} -v '\.orig' | ${SORT} -u`
-
-BUILDLINK_SUBST_MESSAGE.pkglocaledir= \
- "Fixing locale directory references."
-BUILDLINK_SUBST_FILES.pkglocaledir= \
- ${_REPLACE_LOCALEDIR}
-BUILDLINK_SUBST_SED.pkglocaledir= \
- -e 's|^\(localedir[ :]*=\).*|\1 ${_PKGLOCALEDIR}|' \
- -e 's|^\(gnulocaledir[ :]*=\).*|\1 ${_PKGLOCALEDIR}|' \
- -e 's|\(-DLOCALEDIR[ ]*=\)[^ ]*\(.*\)|\1"\\"${_PKGLOCALEDIR}\\""\2|'
-
-.if empty(USE_PKGLOCALEDIR:M[nN][oO])
-pre-configure: pkglocaledir-buildlink-subst
-.endif
-pkglocaledir-buildlink-subst: _BUILDLINK_SUBST_USE
+SUBST_FILES.unbuildlink= ${_REPLACE_BUILDLINK}
+SUBST_SED.unbuildlink= ${_REPLACE_BUILDLINK_SED}
+SUBST_SED.unbuildlink+= ${_BLNK_UNTRANSFORM_SED}
.if !defined(USE_LIBTOOL)
BUILDLINK_FAKE_LA= ${TRUE}
diff --git a/mk/subst.mk b/mk/subst.mk
new file mode 100644
index 00000000000..f9afbca8c1b
--- /dev/null
+++ b/mk/subst.mk
@@ -0,0 +1,80 @@
+# $NetBSD: subst.mk,v 1.1.2.2 2003/08/27 11:44:32 jlam Exp $
+#
+# This Makefile fragment implements a general text replacement facility
+# for different classes of files in ${WRKSRC}. For each class of files,
+# a target <class>-subst is created to perform the text replacement.
+#
+# The following variables are used:
+#
+# SUBST_STAGE.<class>
+# "stage" at which we do the text replacement, e.g. pre-configure,
+# post-build, etc.
+#
+# SUBST_MESSAGE.<class>
+# message to display, noting what is being substituted
+#
+# SUBST_FILES.<class>
+# files on which to run the substitution; these are relative to
+# ${WRKSRC}
+#
+# SUBST_SED.<class>
+# sed(1) substitution expression to run on the specified files
+
+ECHO_SUBST_MSG?= ${ECHO}
+
+# _SUBST_IS_TEXT_FILE returns 0 if $${file} is a text file.
+_SUBST_IS_TEXT_FILE?= \
+ ${FILE_CMD} $${file} | ${EGREP} "(shell script|text)" >/dev/null 2>&1
+
+.for _class_ in ${SUBST_CLASSES}
+_SUBST_COOKIE.${_class_}= ${WRKDIR}/.subst_${_class_}_done
+
+SUBST_TARGETS+= subst-${_class_}
+_SUBST_TARGETS.${_class_}= subst-${_class_}-message
+_SUBST_TARGETS.${_class_}+= ${_SUBST_COOKIE.${_class_}}
+_SUBST_TARGETS.${_class_}+= subst-${_class_}-cookie
+
+.ORDER: ${_SUBST_TARGETS.${_class_}}
+
+.if defined(SUBST_STAGE.${_class_})
+${SUBST_STAGE.${_class_}}: subst-${_class_}
+.endif
+
+.PHONY: subst-${_class_}
+subst-${_class_}: ${_SUBST_TARGETS.${_class_}}
+
+.PHONY: subst-${_class_}-message
+ subst-${_class_}-message:
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ${ECHO_SUBST_MSG} "=> ${SUBST_MESSAGE.${_class_}}"
+
+.PHONY: subst-${_class_}-cookie
+ subst-${_class_}-cookie:
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ${TOUCH} ${TOUCH_FLAGS} ${_SUBST_COOKIE.${_class_}}
+
+${_SUBST_COOKIE.${_class_}}:
+. if !empty(SUBST_SED.${_class_})
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ cd ${WRKSRC}; \
+ files="${SUBST_FILES.${_class_}}"; \
+ case "$$files" in \
+ "") ;; \
+ *) for file in $${files}; do \
+ if ${_SUBST_IS_TEXT_FILE}; then \
+ ${MV} -f $$file $$file.subst.sav; \
+ ${SED} ${SUBST_SED.${_class_}} \
+ $$file.subst.sav > $$file; \
+ if [ -x $$file.subst.sav ]; then \
+ ${CHMOD} +x $$file; \
+ fi; \
+ if ${CMP} -s $$file.subst.sav $$file; then \
+ ${MV} -f $$file.subst.sav $$file; \
+ else \
+ ${ECHO} $$file >> ${.TARGET}; \
+ fi; \
+ fi; \
+ done ;; \
+ esac
+. endif
+.endfor
diff --git a/mk/tools.mk b/mk/tools.mk
index 61a3ebb7965..bfb828e55bf 100644
--- a/mk/tools.mk
+++ b/mk/tools.mk
@@ -1,4 +1,4 @@
-# $NetBSD: tools.mk,v 1.4.2.6 2003/08/27 01:57:19 jlam Exp $
+# $NetBSD: tools.mk,v 1.4.2.7 2003/08/27 11:44:32 jlam Exp $
#
# This Makefile creates a ${TOOLS_DIR} directory and populates the bin
# subdir with tools that hide the ones outside of ${TOOLS_DIR}.