summaryrefslogtreecommitdiff
path: root/mk/plist
diff options
context:
space:
mode:
authorjlam <jlam>2006-01-12 23:43:56 +0000
committerjlam <jlam>2006-01-12 23:43:56 +0000
commit42eed5db640d465dfb4729e28df349c2a8a24e96 (patch)
tree549e889f813ac3835ae3b1d7708def459c235461 /mk/plist
parent3f64cb9fec87a661d388d3ae68a53af2322a1f69 (diff)
downloadpkgsrc-42eed5db640d465dfb4729e28df349c2a8a24e96.tar.gz
Initial commit of a new module that encapsulates all of the code
for manipulating PLISTs. This module is not used by default pending more widespread testing -- currently the variable _USE_PLIST_MODULE must be defined in /etc/mk.conf to enable its use. The main features of the new PLIST module are: (1) Splits out the PLIST-handling code from bsd.pkg.mk into a separate "plist" module. (2) Splits out giant, multi-line awk scripts stored in make variables into separate awk scripts that may be joined together to post-process PLISTs. Each of these awk scripts consolidates the processing for one set of files, e.g., man pages, info pages, etc., and is more easily commented than a make variable. (3) Splits out the print-PLIST code from the regular PLIST code since they have no common pieces (print-plist.mk vs. plist.mk). (4) Completely re-implements the shared-library handling to be more efficient. Along the way, this also fixes a problem for Mac OS X users where the PLISTs incorrectly contained absolute paths. (5) Completely re-implements the info-file handling so that we can migrate from INFO_FILES definitions to just adding info/foo.info entries in the static PLISTs. (6) Adds commented-out support for automatically compressed or decompressed info page entries based on the value of MANZ. These changes will be activated after texinfo.mk has been replaced by something that is built using the more modern primitives now available in pkgsrc. (7) Move the file compression logic into a separate script "doc-compress" that compresses or decompresses files while minding symlinks. This script is now called by bsd.pkg.mk to do the "autmoatic man page handling". In the future, it will also handle the "automatic info page handling" and possible others. In general, the idea is to move stuff out of the Makefiles and into separate files where we don't need to worry about quoting rules and where each file can have a separate history of commits. This simplifies the makefile logic (especially in terms of readability) and also simplifies maintenance of the code.
Diffstat (limited to 'mk/plist')
-rw-r--r--mk/plist/bsd.plist.mk7
-rwxr-xr-xmk/plist/doc-compress104
-rwxr-xr-xmk/plist/libtool-expand86
-rw-r--r--mk/plist/plist-default.awk43
-rw-r--r--mk/plist/plist-functions.awk59
-rw-r--r--mk/plist/plist-info.awk93
-rw-r--r--mk/plist/plist-libtool.awk78
-rw-r--r--mk/plist/plist-man.awk149
-rw-r--r--mk/plist/plist-subst.awk66
-rw-r--r--mk/plist/plist.mk235
-rw-r--r--mk/plist/print-plist.mk172
-rw-r--r--mk/plist/shlib-aout.awk133
-rw-r--r--mk/plist/shlib-dylib.awk182
-rw-r--r--mk/plist/shlib-elf.awk48
-rw-r--r--mk/plist/shlib-none.awk54
-rwxr-xr-xmk/plist/shlib-type54
16 files changed, 1563 insertions, 0 deletions
diff --git a/mk/plist/bsd.plist.mk b/mk/plist/bsd.plist.mk
new file mode 100644
index 00000000000..376069c959b
--- /dev/null
+++ b/mk/plist/bsd.plist.mk
@@ -0,0 +1,7 @@
+# $NetBSD: bsd.plist.mk,v 1.1 2006/01/12 23:43:57 jlam Exp $
+#
+# This Makefile fragment is included by bsd.pkg.mk and provides all
+# PLIST-related variables and targets.
+
+.include "../../mk/plist/plist.mk"
+.include "../../mk/plist/print-plist.mk"
diff --git a/mk/plist/doc-compress b/mk/plist/doc-compress
new file mode 100755
index 00000000000..5f40a460fc4
--- /dev/null
+++ b/mk/plist/doc-compress
@@ -0,0 +1,104 @@
+#!/bin/sh
+#
+# $NetBSD: doc-compress,v 1.1 2006/01/12 23:43:57 jlam Exp $
+#
+# This script is derived from software contributed to The NetBSD Foundation
+# by Alistair Crooks.
+#
+# This script compresses or decompresses files listed in standard input.
+# It handles symlinks by recreating the symlinks to point to the
+# compressed or uncompressed targets.
+#
+
+: ${ECHO=echo}
+: ${EXPR=expr}
+: ${GZIP_CMD=gzip}
+: ${GUNZIP_CMD=gunzip}
+: ${LN=ln}
+: ${LS=ls}
+: ${RM=rm}
+: ${TEST=test}
+
+self="${0##*/}"
+
+usage() {
+ ${ECHO} 1>&2 "usage: $self [-v] [-z] prefix"
+}
+
+case "$MANZ" in
+[yY][eE][sS]) compress=yes ;;
+*) compress=no ;;
+esac
+case "$PKG_VERBOSE" in
+"") verbose=no ;;
+*) verbose=yes ;;
+esac
+prefix=/nonexistent
+
+# Process optional arguments
+while ${TEST} $# -gt 0; do
+ case "$1" in
+ -v) verbose=yes; shift ;;
+ -z) compress=yes; shift ;;
+ --) shift; break ;;
+ -*) ${ECHO} 1>&2 "$self: unknown option -- ${1#-}"
+ usage
+ exit 1
+ ;;
+ *) break ;;
+ esac
+done
+
+${TEST} $# -gt 0 || { usage; exit 1; }
+
+# Process required arguments
+prefix="$1"
+
+while read file; do
+ file="${file%.gz}"
+ path="$prefix/$file"
+ pathgz="$path.gz"
+ case "$compress" in
+ yes)
+ # If compressed pages were requested and we find an
+ # uncompressed page, then compress it, but if it was
+ # a symlink, then remove it and create a "compressed"
+ # symlink by symlinking to the compressed target.
+ #
+ if ${TEST} -h "$path"; then
+ target=`${LS} -l $path`
+ target="${target##*-> }"
+ ${RM} -f $pathgz
+ ${LN} -s $target.gz $pathgz
+ ${RM} -f $path
+ ${TEST} "$verbose" = no ||
+ ${ECHO} "Symlinking: $file"
+ elif ${TEST} -f "$path"; then
+ ${GZIP_CMD} $path
+ ${TEST} "$verbose" = no ||
+ ${ECHO} "Compressing: $file"
+ fi
+ ;;
+ no)
+ # If uncompressed pages were requested and we find a
+ # compressed page, then decompress it, but if it was
+ # a symlink, then remove it and create an "uncompressed"
+ # symlink by symlinking to the uncompressed target.
+ #
+ if ${TEST} -h "$pathgz"; then
+ target=`${LS} -l $pathgz`
+ target="${target##*-> }"
+ target="${target%.gz}"
+ ${RM} -f $path
+ ${LN} -s $target $path
+ ${RM} -f $pathgz
+ ${TEST} "$verbose" = no ||
+ ${ECHO} "Symlinking: $file.gz"
+ elif ${TEST} -f "$pathgz"; then
+ ${GUNZIP_CMD} $pathgz
+ ${TEST} "$verbose" = no ||
+ ${ECHO} "Decompressing: $file.gz"
+ fi
+ ;;
+ esac
+done
diff --git a/mk/plist/libtool-expand b/mk/plist/libtool-expand
new file mode 100755
index 00000000000..b1a353afe85
--- /dev/null
+++ b/mk/plist/libtool-expand
@@ -0,0 +1,86 @@
+# /bin/sh
+#
+# $NetBSD: libtool-expand,v 1.1 2006/01/12 23:43:57 jlam Exp $
+#
+# Copyright (c) 2004 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Todd Vierling.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. All advertising materials mentioning features or use of this software
+# must display the following acknowledgement:
+# This product includes software developed by the NetBSD
+# Foundation, Inc. and its contributors.
+# 4. Neither the name of The NetBSD Foundation nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+
+: ${ECHO=echo}
+: ${GREP=grep}
+: ${SORT=sort}
+: ${TEST=test}
+
+self="${0##*/}"
+
+usage() {
+ ${ECHO} 1>&2 "usage: $self archive ..."
+}
+
+${TEST} $# -gt 0 || { usage; exit 1; }
+
+for la
+do
+ dir="${la%/*.la}"
+ library_names=
+ old_library=
+
+ case $dir in
+ $la) dir= ;;
+ *) dir="$dir/" ;;
+ esac
+ case $la in
+ /*|./*) lapath="$la" ;;
+ *) lapath="./$la" ;;
+ esac
+
+ if ${TEST} -r "$lapath" -a ! -h "$lapath"; then
+ if ${GREP} -q "libtool library file" "$lapath"; then
+ . "$lapath"
+ if ${TEST} "$installed" = "no"; then
+ ${ECHO} 1>&2 "$self: \`$lapath' was not properly installed"
+ exit 1
+ fi
+ for lib in $library_names $old_library; do
+ libpath="$dir$lib"
+ if ${TEST} ! -f "$libpath"; then
+ ${ECHO} 1>&2 "$self: \`$libpath' was not found"
+ fi
+ ${ECHO} "$libpath"
+ done
+ fi
+ else
+ ${ECHO} 1>&2 "$self: cannot read libtool archive \`$lapath'"
+ fi
+done | ${SORT} -u
diff --git a/mk/plist/plist-default.awk b/mk/plist/plist-default.awk
new file mode 100644
index 00000000000..5b80ab9a858
--- /dev/null
+++ b/mk/plist/plist-default.awk
@@ -0,0 +1,43 @@
+# $NetBSD: plist-default.awk,v 1.1 2006/01/12 23:43:57 jlam Exp $
+#
+# Copyright (c) 2006 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Johnny C. Lam.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. All advertising materials mentioning features or use of this software
+# must display the following acknowledgement:
+# This product includes software developed by the NetBSD
+# Foundation, Inc. and its contributors.
+# 4. Neither the name of The NetBSD Foundation nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+###
+### By default, print the PLIST entry.
+###
+{
+ print_entry($0)
+ next
+}
diff --git a/mk/plist/plist-functions.awk b/mk/plist/plist-functions.awk
new file mode 100644
index 00000000000..9c422b08561
--- /dev/null
+++ b/mk/plist/plist-functions.awk
@@ -0,0 +1,59 @@
+# $NetBSD: plist-functions.awk,v 1.1 2006/01/12 23:43:57 jlam Exp $
+#
+# Copyright (c) 2006 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Johnny C. Lam.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. All advertising materials mentioning features or use of this software
+# must display the following acknowledgement:
+# This product includes software developed by the NetBSD
+# Foundation, Inc. and its contributors.
+# 4. Neither the name of The NetBSD Foundation nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+###
+### join(array, start, end, separator) concatenates an array of strings
+### with a separator and returns the concatenated string. It is the
+### inverse of the built-in split() function.
+###
+function join(array, start, end, separator, result, i) {
+ result = array[start]
+ for (i = start + 1; i <= end; i++)
+ result = result separator array[i]
+ return result
+}
+
+###
+### print_entry(entry) prints the entry to standard output. If avoids
+### printing out duplicate entries by caching ones that have previously
+### been printed.
+###
+function print_entry(entry) {
+ if (entries[entry] == "") {
+ entries[entry] = entry
+ print entry
+ }
+}
diff --git a/mk/plist/plist-info.awk b/mk/plist/plist-info.awk
new file mode 100644
index 00000000000..b36575bf201
--- /dev/null
+++ b/mk/plist/plist-info.awk
@@ -0,0 +1,93 @@
+# $NetBSD: plist-info.awk,v 1.1 2006/01/12 23:43:57 jlam Exp $
+#
+# Copyright (c) 2006 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Johnny C. Lam.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. All advertising materials mentioning features or use of this software
+# must display the following acknowledgement:
+# This product includes software developed by the NetBSD
+# Foundation, Inc. and its contributors.
+# 4. Neither the name of The NetBSD Foundation nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+### This awk script handles *.info file entries in PLISTs. This script
+### requires the following scripts to be included:
+###
+### plist-functions.awk (print_entry)
+###
+### Certain environment variables must be set prior to running this script:
+###
+### INFO_DIR is the ${PREFIX}-relative path to the installed info pages.
+###
+### LS is the path to the "ls" binary.
+###
+### MANZ is a yes/no variable that determines whether the info pages
+### should be recorded as compressed or not.
+###
+### PREFIX is the installation prefix of the the package.
+###
+### TEST is the command used for shell tests, e.g. shell test built-in or
+### the path to a "test" binary.
+###
+BEGIN {
+ INFO_DIR = ENVIRON["INFO_DIR"]
+ LS = ENVIRON["LS"]
+ MANZ = ENVIRON["MANZ"]
+ PREFIX = ENVIRON["PREFIX"]
+ TEST = ENVIRON["TEST"]
+}
+
+###
+### Ignore *.info-1, *.info-2, etc. files in the PLIST as we get the
+### list of installed *.info-[0-9]* files below.
+###
+/^[^@]/ && /^info\/[^\/]*\.info-[0-9]+(\.gz)?$/ {
+ next
+}
+
+###
+### For each info page entry, print all of the installed info sub-pages
+### associated with that entry.
+###
+/^[^@]/ && /^info\/[^\/]*\.info(\.gz)?$/ {
+ sub("^info/", INFO_DIR "/")
+ cmd = TEST " -f " PREFIX "/" $0
+ if (system(cmd) == 0) {
+ sub("\.gz$", "")
+ cmd = "cd " PREFIX " && " LS " -1 " $0 "*"
+ while (cmd | getline) {
+ #if ((MANZ ~ /[yY][eE][sS]/) && ($0 !~ /\.gz$/)) {
+ # $0 = $0 ".gz"
+ #} else if ((MANZ !~ /[yY][eE][sS]/) && ($0 ~ /\.gz$/)) {
+ # sub("\.gz$", "")
+ #}
+ print_entry($0)
+ }
+ close(cmd)
+ }
+ next
+}
diff --git a/mk/plist/plist-libtool.awk b/mk/plist/plist-libtool.awk
new file mode 100644
index 00000000000..8120f9e54f2
--- /dev/null
+++ b/mk/plist/plist-libtool.awk
@@ -0,0 +1,78 @@
+# $NetBSD: plist-libtool.awk,v 1.1 2006/01/12 23:43:57 jlam Exp $
+#
+# Copyright (c) 2006 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Johnny C. Lam.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. All advertising materials mentioning features or use of this software
+# must display the following acknowledgement:
+# This product includes software developed by the NetBSD
+# Foundation, Inc. and its contributors.
+# 4. Neither the name of The NetBSD Foundation nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+### This awk script handles libtool archive entries in PLISTs. This script
+### requires the following scripts to be included:
+###
+### plist-functions.awk (print_entry)
+###
+### Certain environment variables must be set prior to running this script:
+###
+### LIBTOOL_EXPAND is the path to the script that prints out the
+### actual library files associated with a libtool archive file.
+###
+### LIBTOOLIZE_PLIST is a yes/no variable indicating whether to expand
+### *.la files in the PLIST into the corresponding real libraries.
+###
+### PREFIX is the installation prefix of the the package.
+###
+### TEST is the command used for shell tests, e.g. shell test built-in or
+### the path to a "test" binary.
+###
+
+BEGIN {
+ LIBTOOL_EXPAND = ENVIRON["LIBTOOL_EXPAND"]
+ LIBTOOLIZE_PLIST = ENVIRON["LIBTOOLIZE_PLIST"]
+ PREFIX = ENVIRON["PREFIX"]
+ TEST = ENVIRON["TEST"]
+}
+
+###
+### Expand libtool archives into the list of corresponding shared and/or
+### static libraries.
+###
+(LIBTOOLIZE_PLIST ~ /[yY][eE][sS]/) && /^[^@].*\.la$/ {
+ print_entry($0)
+ cmd = TEST " -f " PREFIX "/" $0
+ if (system(cmd) == 0) {
+ cmd = "cd " PREFIX " && " LIBTOOL_EXPAND " " $0
+ while (cmd | getline) {
+ print_entry($0)
+ }
+ close(cmd)
+ }
+ next
+}
diff --git a/mk/plist/plist-man.awk b/mk/plist/plist-man.awk
new file mode 100644
index 00000000000..1676b416d2c
--- /dev/null
+++ b/mk/plist/plist-man.awk
@@ -0,0 +1,149 @@
+# $NetBSD: plist-man.awk,v 1.1 2006/01/12 23:43:57 jlam Exp $
+#
+# Copyright (c) 2006 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Johnny C. Lam.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. All advertising materials mentioning features or use of this software
+# must display the following acknowledgement:
+# This product includes software developed by the NetBSD
+# Foundation, Inc. and its contributors.
+# 4. Neither the name of The NetBSD Foundation nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+### This awk script handles man page entries in PLISTs. This script
+### requires the following scripts to be included:
+###
+### plist-functions.awk (print_entry)
+###
+### Certain environment variables must be set prior to running this script:
+###
+### IMAKE_INSTALL specifies how imake-using packages install man pages.
+### Valid values are:
+###
+### no value the package doesn't use imake
+### maninstall the package installed man pages
+### catinstall the package installed catman pages
+###
+### Both "maninstall" and "catinstall" may be specified.
+###
+### MANINSTALL specifies if man pages are installed by the package.
+### Valid values are:
+###
+### maninstall the package installed man pages
+### catinstall the package installed catman pages
+###
+### Both "maninstall" and "catinstall" may be specified.
+###
+### MANZ is a yes/no variable that determines whether the man pages
+### should be recorded as compressed or not.
+###
+### PKGMANDIR is the ${PREFIX}-relative path to the installed man pages.
+###
+BEGIN {
+ IMAKE_MANINSTALL = ENVIRON["IMAKE_MANINSTALL"]
+ MANINSTALL = ENVIRON["MANINSTALL"]
+ MANZ = ENVIRON["MANZ"]
+ PKGMANDIR = ENVIRON["PKGMANDIR"]
+}
+
+###
+### Canonicalize man page entries by stripping any ".gz" suffixes.
+###
+/^[^@]/ && \
+/^([^\/]*\/)+(man[1-9ln]\/[^\/]*\.[1-9ln]|cat[1-9ln]\/[^\/]*\.[0-9])\.gz$/ {
+ sub("\.gz$", "")
+}
+
+###
+### Rewrite "imake-installed" catman pages as man pages if imake only
+### supports man pages.
+###
+(IMAKE_MANINSTALL == "maninstall") && /^[^@]/ && \
+/^([^\/]*\/)+cat[1-9ln]\/[^\/]*\.[0-9ln]$/ {
+ n = split($0, components, "/")
+ sub("cat", "man", components[n-1])
+ section = substr(components[n-1], 4, 1)
+ sub("[0-9ln]$", section, components[n])
+ $0 = join(components, 1, n, "/")
+ delete components
+}
+(IMAKE_MANINSTALL == "maninstall") && \
+/^@dirrm ([^\/]*\/)+cat[1-9ln]/ {
+ next
+}
+
+###
+### Rewrite "imake-installed" man pages as catman pages if imake only
+### supports catman pages.
+###
+(IMAKE_MANINSTALL == "catinstall") && /^[^@]/ && \
+/^([^\/]*\/)+man[1-9ln]\/[^\/]*\.[0-9ln]$/ {
+ n = split($0, components, "/")
+ sub("man", "cat", components[n-1])
+ section = "0"
+ sub("[0-9ln]$", section, components[n])
+ $0 = join(components, 1, n, "/")
+ delete components
+}
+(IMAKE_MANINSTALL == "catinstall") && \
+/^@dirrm ([^\/]*\/)+man[1-9ln]/ {
+ next
+}
+
+###
+### If MANINSTALL doesn't contain "maninstall", then strip out man page
+### entries from the PLIST, and similarly for "catinstall" and catman page
+### entries.
+###
+(MANINSTALL !~ /catinstall/) && /^[^@]/ && \
+/^([^\/]*\/)+cat[1-9ln]\/[^\/]*\.[0-9ln]$/ {
+ next
+}
+(MANINSTALL !~ /maninstall/) && /^[^@]/ && \
+/^([^\/]*\/)+man[1-9ln]\/[^\/]*\.[0-9ln]$/ {
+ next
+}
+
+###
+### Append ".gz" to the end of man page entries if compressed pages are
+### requested.
+###
+(MANZ ~ /[yY][eE][sS]/) && /^[^@]/ && \
+/^([^\/]*\/)+(man[1-9ln]\/[^\/]*\.[1-9ln]|cat[1-9ln]\/[^\/]*\.[0-9])$/ {
+ $0 = $0 ".gz"
+}
+
+###
+### Convert man/ to ${PKGMANDIR}/ for all man and catman page entries.
+###
+/^[^@]/ && \
+/^man\/([^\/]*\/)?(man[1-9ln]\/[^\/]*\.[1-9ln]|cat[1-9ln]\/[^\/]*\.[0-9])/ {
+ sub("^man/", PKGMANDIR "/")
+}
+/^@dirrm man\/([^\/]*\/)?(man[1-9ln]|cat[1-9ln])/ {
+ sub("^@dirrm man/", "@dirrm " PKGMANDIR "/")
+}
diff --git a/mk/plist/plist-subst.awk b/mk/plist/plist-subst.awk
new file mode 100644
index 00000000000..66b84aa7cd8
--- /dev/null
+++ b/mk/plist/plist-subst.awk
@@ -0,0 +1,66 @@
+# $NetBSD: plist-subst.awk,v 1.1 2006/01/12 23:43:57 jlam Exp $
+#
+# Copyright (c) 2006 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Johnny C. Lam.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. All advertising materials mentioning features or use of this software
+# must display the following acknowledgement:
+# This product includes software developed by the NetBSD
+# Foundation, Inc. and its contributors.
+# 4. Neither the name of The NetBSD Foundation nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+###
+### Build an array "substitute" of <regexp, value> pairs, that may be used
+### to do variable substitutions in PLIST entries. The variables which
+### will be substituted are passed in the environment variable
+### PLIST_SUBST_VARS, and the named variables should be found in the
+### shell environment.
+###
+BEGIN {
+ PLIST_SUBST_VARS = ENVIRON["PLIST_SUBST_VARS"]
+
+ split(PLIST_SUBST_VARS, vars, " ")
+ for (i in vars) {
+ value = ENVIRON[vars[i]]
+ var = vars[i]
+ sub("^PLIST_", "", var)
+ regexp = "\\${" var "}"
+ substitute[regexp] = value
+ }
+ delete vars
+}
+
+###
+### For each entry, replace all ${...} variables with their respective
+### values taken from the environment.
+###
+{
+ for (regexp in substitute) {
+ gsub(regexp, substitute[regexp])
+ }
+}
diff --git a/mk/plist/plist.mk b/mk/plist/plist.mk
new file mode 100644
index 00000000000..4575bb309cb
--- /dev/null
+++ b/mk/plist/plist.mk
@@ -0,0 +1,235 @@
+# $NetBSD: plist.mk,v 1.1 2006/01/12 23:43:57 jlam Exp $
+#
+# This Makefile fragment handles the creation of PLISTs for use by
+# pkg_create(8).
+#
+# The following variables affect
+#
+# PLIST_TYPE specifies whether the generated PLIST is derived
+# automatically from the installed files, or if the PLIST entries
+# are listed in files. Valid values are "dynamic" and "static",
+# and the default value is "static".
+#
+# PLIST_SRC is the source file(s) for the generated PLIST file. By
+# default, its value is constructed from the PLIST.* files within
+# the package directory.
+#
+# GENERATE_PLIST is a sequence of commands, terminating in a semicolon,
+# that outputs contents for a PLIST to stdout and is appended to
+# the contents of ${PLIST_SRC}.
+#
+
+.if ${PKG_INSTALLATION_TYPE} == "pkgviews"
+PLIST_TYPE?= dynamic
+.endif
+PLIST_TYPE?= static
+
+######################################################################
+
+# PLIST_SRC is the source file for the generated PLIST file. If PLIST_SRC
+# is not explicitly defined, then build one up from various PLIST.* files
+# that are present in the package directory. The order goes (if the files
+# are present):
+#
+# PLIST.common
+# PLIST.${OPSYS} (e.g., PLIST.NetBSD)
+# PLIST.${MACHINE_ARCH} (e.g,, PLIST.macppc)
+# PLIST.${OPSYS}-${MACHINE_ARCH} (e.g., PLIST.NetBSD-macppc)
+# PLIST
+# PLIST.common_end
+#
+.if !defined(PLIST_SRC)
+. if exists(${PKGDIR}/PLIST.common)
+PLIST_SRC+= ${PKGDIR}/PLIST.common
+. endif
+. if exists(${PKGDIR}/PLIST.${OPSYS})
+PLIST_SRC+= ${PKGDIR}/PLIST.${OPSYS}
+. endif
+. if exists(${PKGDIR}/PLIST.${MACHINE_ARCH:C/i[3-6]86/i386/g})
+PLIST_SRC+= ${PKGDIR}/PLIST.${MACHINE_ARCH:C/i[3-6]86/i386/g}
+. endif
+. if exists(${PKGDIR}/PLIST.${OPSYS}-${MACHINE_ARCH:C/i[3-6]86/i386/g})
+PLIST_SRC+= ${PKGDIR}/PLIST.${OPSYS}-${MACHINE_ARCH:C/i[3-6]86/i386/
+g}
+. endif
+. if exists(${PKGDIR}/PLIST)
+PLIST_SRC+= ${PKGDIR}/PLIST
+. endif
+. if exists(${PKGDIR}/PLIST.common_end)
+PLIST_SRC+= ${PKGDIR}/PLIST.common_end
+. endif
+.endif # !PLIST_SRC
+
+# This is the path to the generated PLIST file.
+PLIST= ${WRKDIR}/.PLIST
+
+######################################################################
+
+.if (defined(USE_IMAKE) || !empty(USE_TOOLS:Mimake))
+_IMAKE_MANINSTALL= # empty
+.else
+_IMAKE_MANINSTALL= ${IMAKE_MANINSTALL}
+.endif
+
+_LIBTOOL_EXPAND= \
+ ${SETENV} ECHO=${TOOLS_ECHO:Q} GREP=${TOOLS_GREP:Q} \
+ SORT=${TOOLS_SORT:Q} TEST=${TOOLS_TEST:Q} \
+ ${SH} ${.CURDIR}/../../mk/plist/libtool-expand
+
+# _PLIST_AWK_ENV holds the shell environment passed to the awk script
+# that does post-processing of the PLIST. See the individual *.awk
+# scripts for information on each of the variable set in the environment.
+#
+_PLIST_AWK_ENV+= IMAKE_MANINSTALL=${_IMAKE_MANINSTALL:Q}
+_PLIST_AWK_ENV+= INFO_DIR=${INFO_DIR:Q}
+_PLIST_AWK_ENV+= LIBTOOLIZE_PLIST=${LIBTOOLIZE_PLIST:Q}
+_PLIST_AWK_ENV+= LS=${TOOLS_LS:Q}
+_PLIST_AWK_ENV+= MANINSTALL=${MANINSTALL:Q}
+_PLIST_AWK_ENV+= MANZ=${_MANZ:Q}
+_PLIST_AWK_ENV+= PKGMANDIR=${PKGMANDIR:Q}
+_PLIST_AWK_ENV+= PREFIX=${PREFIX:Q}
+_PLIST_AWK_ENV+= LIBTOOL_EXPAND=${_LIBTOOL_EXPAND:Q}
+_PLIST_AWK_ENV+= TEST=${TOOLS_TEST:Q}
+
+# PLIST_SUBST contains package-settable "${variable}" to "value"
+# substitutions for PLISTs
+#
+PLIST_SUBST+= OPSYS=${OPSYS:Q} \
+ OS_VERSION=${OS_VERSION:Q} \
+ MACHINE_ARCH=${MACHINE_ARCH:Q} \
+ MACHINE_GNU_ARCH=${MACHINE_GNU_ARCH:Q} \
+ MACHINE_GNU_PLATFORM=${MACHINE_GNU_PLATFORM:Q} \
+ LN=${LN:Q} \
+ LOWER_VENDOR=${LOWER_VENDOR:Q} \
+ LOWER_OPSYS=${LOWER_OPSYS:Q} \
+ LOWER_OS_VERSION=${LOWER_OS_VERSION:Q} \
+ PKGBASE=${PKGBASE:Q} \
+ PKGNAME=${PKGNAME_NOREV:Q} \
+ PKGLOCALEDIR=${PKGLOCALEDIR:Q} \
+ PKGVERSION=${PKGVERSION:C/nb[0-9]*$//} \
+ LOCALBASE=${LOCALBASE:Q} \
+ VIEWBASE=${VIEWBASE:Q} \
+ X11BASE=${X11BASE:Q} \
+ X11PREFIX=${X11PREFIX:Q} \
+ SVR4_PKGNAME=${SVR4_PKGNAME:Q} \
+ CHGRP=${CHGRP:Q} \
+ CHMOD=${CHMOD:Q} \
+ CHOWN=${CHOWN:Q} \
+ MKDIR=${MKDIR:Q} \
+ RMDIR=${RMDIR:Q} \
+ RM=${RM:Q} \
+ TRUE=${TRUE:Q} \
+ PKGMANDIR=${PKGMANDIR:Q}
+
+# Pass the PLIST_SUBST substitutions to the subst.awk script by prepending
+# PLIST_" to all of the variable names and adding them into the environment.
+#
+_PLIST_AWK_ENV+= ${PLIST_SUBST:S/^/PLIST_/}
+_PLIST_AWK_ENV+= PLIST_SUBST_VARS=${PLIST_SUBST:S/^/PLIST_/:C/=.*//:M*:Q}
+
+_PLIST_AWK+= -f ${.CURDIR}/../../mk/plist/plist-functions.awk
+_PLIST_AWK+= -f ${.CURDIR}/../../mk/plist/plist-subst.awk
+_PLIST_AWK+= -f ${.CURDIR}/../../mk/plist/plist-info.awk
+_PLIST_AWK+= -f ${.CURDIR}/../../mk/plist/plist-man.awk
+_PLIST_AWK+= -f ${.CURDIR}/../../mk/plist/plist-libtool.awk
+_PLIST_AWK+= -f ${.CURDIR}/../../mk/plist/plist-default.awk
+
+_PLIST_SHLIB_AWK= -f ${_SHLIB_AWKFILE.${SHLIB_TYPE}}
+_SHLIB_AWKFILE.COFF= ${.CURDIR}/../../mk/plist/shlib-none.awk
+_SHLIB_AWKFILE.ELF= ${.CURDIR}/../../mk/plist/shlib-elf.awk
+_SHLIB_AWKFILE.aixlib= ${.CURDIR}/../../mk/plist/shlib-none.awk
+_SHLIB_AWKFILE.a.out= ${.CURDIR}/../../mk/plist/shlib-aout.awk
+_SHLIB_AWKFILE.dylib= ${.CURDIR}/../../mk/plist/shlib-dylib.awk
+_SHLIB_AWKFILE.none= ${.CURDIR}/../../mk/plist/shlib-none.awk
+
+# SHLIB_TYPE is the type of shared library supported by the platform.
+SHLIB_TYPE= ${_SHLIB_TYPE_cmd:sh}
+_SHLIB_TYPE_cmd= \
+ ${SETENV} CC=${CC:Q} ECHO=${TOOLS_ECHO:Q} \
+ FILE_CMD=${TOOLS_FILE_CMD:Q} MKDIR=${TOOLS_MKDIR:Q} \
+ RM=${TOOLS_RM:Q} TEST=${TOOLS_TEST:Q} \
+ ${SH} ${.CURDIR}/../../mk/plist/shlib-type ${_OPSYS_SHLIB_TYPE:Q}
+
+.if !target(show-shlib-type)
+.PHONY: show-shlib-type
+show-shlib-type:
+ @${ECHO} ${SHLIB_TYPE:Q}
+.endif
+
+######################################################################
+
+# GENERATE_PLIST is a sequence of commands, terminating in a semicolon,
+# that outputs contents for a PLIST to stdout and is appended to
+# the contents of ${PLIST_SRC}.
+#
+GENERATE_PLIST?= ${TRUE};
+
+# XXX Generate info page entries for each of the listed INFO_FILES.
+# XXX This section should go away after info file listings have been
+# XXX pushed into the PLISTs.
+# XXX
+.if defined(INFO_FILES) && !empty(INFO_FILES)
+. for _file_ in ${INFO_FILES}
+_INFO_GENERATE_PLIST+= ${ECHO} "info/"${_file_:Q};
+. endfor
+.else
+_INFO_GENERATE_PLIST= ${TRUE};
+.endif
+
+.if ${PKG_INSTALLATION_TYPE} == "pkgviews"
+#
+# _PLIST_IGNORE_FILES basically mirrors the list of ignored files found
+# in pkg_views(1). It's used by the dynamic PLIST generator to skip
+# adding the named files to the PLIST.
+#
+_PLIST_IGNORE_FILES+= +* # package metadata files
+_PLIST_IGNORE_FILES+= info/dir
+. if defined(INFO_DIR) && empty(INFO_DIR:Minfo)
+_PLIST_IGNORE_FILES+= ${INFO_DIR}/dir
+. endif
+_PLIST_IGNORE_FILES+= *[~\#] *.OLD *.orig *,v # scratch config files
+. if !empty(CONF_DEPENDS)
+_PLIST_IGNORE_FILES+= ${PKG_SYSCONFDIR:S,^${PREFIX}/,,}
+. endif
+_PLIST_IGNORE_FILES+= ${PLIST_IGNORE_FILES}
+.endif
+BUILD_DEFS+= _PLIST_IGNORE_FILES
+
+.if ${PLIST_TYPE} == "dynamic"
+_PLIST_IGNORE_CMD= \
+ ( while read i; do \
+ ignore=no; \
+ for p in ${_PLIST_IGNORE_FILES}; do \
+ case "$$i" in \
+ $$p) ignore=yes; break ;; \
+ esac; \
+ done; \
+ [ "$$ignore" = "yes" ] || ${ECHO} "$$i"; \
+ done )
+_GENERATE_PLIST= \
+ ${FIND} ${PREFIX} \! -type d -print | ${SORT} | \
+ ${SED} -e "s|^${PREFIX}/||" | \
+ ${_PLIST_IGNORE_CMD}; \
+ ${FIND} ${PREFIX} -type d -print | ${SORT} -r | \
+ ${GREP} -v "^${PREFIX}$$" | \
+ ${_PLIST_IGNORE_CMD} | \
+ ${SED} -e "s|^${PREFIX}/|@unexec ${RMDIR} -p %D/|" \
+ -e "s,$$, 2>/dev/null || ${TRUE},";
+.else
+_GENERATE_PLIST= { ${_INFO_GENERATE_PLIST} }; \
+ ${CAT} ${PLIST_SRC}; \
+ ${GENERATE_PLIST}
+.endif
+
+.PHONY: plist
+plist: ${PLIST}
+
+.if ${PLIST_TYPE} == "static"
+${PLIST}: ${PLIST_SRC}
+.endif
+${PLIST}:
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ { ${_GENERATE_PLIST} } | \
+ ${SETENV} ${_PLIST_AWK_ENV} ${AWK} ${_PLIST_AWK} | \
+ ${SETENV} ${_PLIST_AWK_ENV} ${AWK} ${_PLIST_SHLIB_AWK} \
+ > ${PLIST}
diff --git a/mk/plist/print-plist.mk b/mk/plist/print-plist.mk
new file mode 100644
index 00000000000..f3c6dcf5ab8
--- /dev/null
+++ b/mk/plist/print-plist.mk
@@ -0,0 +1,172 @@
+# $$etBSD$
+
+###
+### Automatic PLIST generation
+### - files & symlinks first
+### - @dirrm statements last
+### - empty directories are handled properly
+### - dirs from mtree files are excluded
+### - substitute for platform or package specifics substrings
+###
+### Usage:
+### - make install
+### - make print-PLIST | brain >PLIST
+###
+
+_PRINT_PLIST_AWK_SUBST={ \
+ gsub(/${OPSYS}/, "$${OPSYS}"); \
+ gsub(/${OS_VERSION:S/./\./g}/, "$${OS_VERSION}"); \
+ gsub(/${MACHINE_GNU_PLATFORM}/, "$${MACHINE_GNU_PLATFORM}"); \
+ gsub(/${MACHINE_ARCH}/, "$${MACHINE_ARCH}"); \
+ gsub(/${MACHINE_GNU_ARCH}/, "$${MACHINE_GNU_ARCH}");
+.if !empty(LOWER_VENDOR)
+_PRINT_PLIST_AWK_SUBST+= gsub(/${LOWER_VENDOR}/, "$${LOWER_VENDOR}");
+.endif
+_PRINT_PLIST_AWK_SUBST+= \
+ gsub(/${LOWER_OS_VERSION:S/./\./g}/, "$${LOWER_OS_VERSION}"); \
+ gsub(/${LOWER_OPSYS}/, "$${LOWER_OPSYS}"); \
+ gsub(/${PKGNAME_NOREV}/, "$${PKGNAME}"); \
+ gsub(/${PKGVERSION:S/./\./g:C/nb[0-9]*$$//}/, "$${PKGVERSION}");\
+ gsub(/${PKGLOCALEDIR}\/locale/, "$${PKGLOCALEDIR}/locale"); \
+ gsub("^${PKGMANDIR}\/", "man/"); \
+}
+
+_PRINT_PLIST_AWK_IGNORE= ($$0 ~ /emul\/linux\/proc/)
+_PRINT_PLIST_AWK_IGNORE+= || ($$0 ~ /^info\/dir$$/)
+.if defined(INFO_DIR) && empty(INFO_DIR:Minfo)
+_PRINT_PLIST_AWK_IGNORE+= || ($$0 ~ /^${INFO_DIR:S|/|\\/|g}\/dir$$/)
+.endif
+.if !empty(INFO_FILES)
+. for _f_ in ${INFO_FILES}
+_PRINT_PLIST_AWK_IGNORE+= || ($$0 ~ /^${INFO_DIR:S|/|\\/|g}\/${_f_:S|+|\+|g}(-[0-9]+)?(\.gz)?$$/)
+. endfor
+.endif
+
+# Common (system) directories not to generate @dirrm statements for
+# Reads MTREE_FILE and generate awk statements that will
+# sort out which directories NOT to include into the PLIST @dirrm list
+.if make(print-PLIST)
+_PRINT_PLIST_COMMON_DIRS!= ${AWK} 'BEGIN { \
+ i=0; \
+ stack[i]="${PREFIX}" ; \
+ cwd=""; \
+ } \
+ ! ( /^\// || /^\#/ || /^$$/ ) { \
+ if ( $$1 == ".." ){ \
+ i=i-1; \
+ cwd = stack[i]; \
+ } else if ( $$1 == "." ){ \
+ } else { \
+ stack[i] = cwd ; \
+ if ( i == 0 ){ \
+ cwd = $$1 ; \
+ } else { \
+ cwd = cwd "\\/" $$1 ; \
+ } \
+ print "/^" cwd "$$$$/ { next; }"; \
+ i=i+1 ; \
+ } \
+ } \
+ END { print "{ print $$$$0; }"; } \
+ ' <${MTREE_FILE}
+.endif
+
+# scan $PREFIX for any files/dirs modified since the package was extracted
+# will emit "@exec mkdir"-statements for empty directories
+# XXX will fail for data files that were copied using tar (e.g. emacs)!
+# XXX should check $LOCALBASE and $X11BASE, and add @cwd statements
+
+_PRINT_PLIST_FILES_CMD= \
+ ${FIND} ${PREFIX}/. -xdev -newer ${_EXTRACT_COOKIE} \! -type d -print
+_PRINT_PLIST_DIRS_CMD= \
+ ${FIND} ${PREFIX}/. -xdev -newer ${_EXTRACT_COOKIE} -type d -print
+
+.if !empty(LIBTOOLIZE_PLIST:M[yY][eE][sS])
+_PRINT_PLIST_LIBTOOLIZE_FILTER?= \
+ ( \
+ if ${TEST} -d ${WRKDIR}; then \
+ tmpdir="${WRKDIR}"; \
+ else \
+ tmpdir="$${TMPDIR-/tmp}"; \
+ fi; \
+ fileslist="$$tmpdir/print.plist.files.$$$$"; \
+ libslist="$$tmpdir/print.plist.libs.$$$$"; \
+ while read file; do \
+ case $$file in \
+ *.la) \
+ ${_LIBTOOL_EXPAND} $$file >> $$libslist; \
+ ;; \
+ esac; \
+ ${ECHO} "$$file"; \
+ done > $$fileslist; \
+ if ${TEST} -f "$$libslist"; then \
+ ${GREP} -hvxF "`${SORT} -u $$libslist`" "$$fileslist"; \
+ else \
+ ${CAT} "$$fileslist"; \
+ fi; \
+ ${RM} -f "$$fileslist" "$$libslist"; \
+ )
+.else
+_PRINT_PLIST_LIBTOOLIZE_FILTER?= ${CAT}
+.endif
+
+.PHONY: print-PLIST
+.if !target(print-PLIST)
+print-PLIST:
+ ${_PKG_SILENT}${_PKG_DEBUG}\
+ ${ECHO} '@comment $$'NetBSD'$$'
+ ${_PKG_SILENT}${_PKG_DEBUG}\
+ shlib_type=`${MAKE} ${MAKEFLAGS} show-shlib-type`; \
+ case $$shlib_type in \
+ "a.out") genlinks=1 ;; \
+ *) genlinks=0 ;; \
+ esac; \
+ ${_PRINT_PLIST_FILES_CMD} \
+ | ${_PRINT_PLIST_LIBTOOLIZE_FILTER} \
+ | ${SORT} \
+ | ${AWK} ' \
+ { sub("${PREFIX}/\\./", ""); } \
+ ${_PRINT_PLIST_AWK_IGNORE} { next; } \
+ ${_PRINT_PLIST_AWK_SUBST} \
+ /^@/ { print $$0; next } \
+ /.*\/lib[^\/]+\.so\.[0-9]+\.[0-9]+\.[0-9]+$$/ { \
+ print $$0; \
+ sub("\\.[0-9]+$$", ""); \
+ if ('$$genlinks') print $$0; \
+ sub("\\.[0-9]+$$", ""); \
+ if ('$$genlinks') print $$0; \
+ sub("\\.[0-9]+$$", ""); \
+ if ('$$genlinks') print $$0; \
+ next; \
+ } \
+ /.*\/lib[^\/]+\.so\.[0-9]+\.[0-9]+$$/ { \
+ print $$0; \
+ sub("\\.[0-9]+$$", ""); \
+ if ('$$genlinks') print $$0; \
+ sub("\\.[0-9]+$$", ""); \
+ if ('$$genlinks') print $$0; \
+ next; \
+ } \
+ ${PRINT_PLIST_AWK} \
+ { print $$0; }'
+ ${_PKG_SILENT}${_PKG_DEBUG}\
+ for i in `${_PRINT_PLIST_DIRS_CMD} \
+ | ${SORT} -r \
+ | ${AWK} ' \
+ /emul\/linux\/proc/ { next; } \
+ /${PREFIX:S|/|\\/|g}\/\.$$/ { next; } \
+ { sub("${PREFIX}/\\\\./", ""); } \
+ { sub("^${PKGMANDIR}/", "man/"); } \
+ ${_PRINT_PLIST_COMMON_DIRS}'` ; \
+ do \
+ if [ `${LS} -la ${PREFIX}/$$i | ${WC} -l` = 3 ]; then \
+ ${ECHO} @exec \$${MKDIR} %D/$$i | ${AWK} ' \
+ ${PRINT_PLIST_AWK} \
+ { print $$0; }' ; \
+ fi ; \
+ ${ECHO} @dirrm $$i | ${AWK} ' \
+ ${PRINT_PLIST_AWK} \
+ { print $$0; }' ; \
+ done \
+ | ${AWK} '${_PRINT_PLIST_AWK_SUBST} { print $$0; }'
+.endif # target(print-PLIST)
diff --git a/mk/plist/shlib-aout.awk b/mk/plist/shlib-aout.awk
new file mode 100644
index 00000000000..e98379cc0cc
--- /dev/null
+++ b/mk/plist/shlib-aout.awk
@@ -0,0 +1,133 @@
+# $NetBSD: shlib-aout.awk,v 1.1 2006/01/12 23:43:57 jlam Exp $
+#
+# Copyright (c) 2006 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Johnny C. Lam.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. All advertising materials mentioning features or use of this software
+# must display the following acknowledgement:
+# This product includes software developed by the NetBSD
+# Foundation, Inc. and its contributors.
+# 4. Neither the name of The NetBSD Foundation nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+#
+# This awk script is a filter that reads PLIST entries and strips out
+# entries that match ELF library symlinks that aren't installed on a.out
+# platforms.
+#
+
+BEGIN {
+ LIBTOOL_EXPAND = ENVIRON["LIBTOOL_EXPAND"]
+ LIBTOOLIZE_PLIST = ENVIRON["LIBTOOLIZE_PLIST"]
+ PREFIX = ENVIRON["PREFIX"]
+ TEST = ENVIRON["TEST"]
+ nentries = 0
+}
+
+###
+### Stored special PLIST commands, e.g. @comment, @exec, etc., verbatim
+### in the entries array.
+###
+/^@/ {
+ entries[++nentries] = $0
+ next
+}
+
+###
+### Record all of the library names associated with a libtool archive
+### in the "ltnames" array. Also, record the libtool archive in the
+### "entries" array.
+###
+(LIBTOOLIZE_PLIST ~ /[yY][eE][sS]/) && /.*\/[^\/]+\.la$/ {
+ entries[++nentries] = $0
+ cmd = TEST " -f " PREFIX "/" $0
+ if (system(cmd) == 0) {
+ cmd = "cd " PREFIX " && " LIBTOOL_EXPAND " " $0
+ while (cmd | getline) {
+ ltnames[$0] = $0
+ }
+ close(cmd)
+ }
+ next
+}
+
+###
+### Record all library symlinks derived from a shared library name in the
+### "symlinks" array. Also, record the full shared library name in the
+### "entries" array.
+###
+/.*\/lib[^\/]+\.so(\.[0-9]+)*$/ {
+ entries[++nentries] = $0
+ while (sub("\.[0-9]+$", "")) {
+ symlinks[$0] = $0
+ }
+ if (sub("-[^-]+\.so$", ".so")) {
+ symlinks[$0] = $0
+ }
+ next
+}
+
+###
+### All other entries are stored verbatim in the entries array.
+###
+{
+ entries[++nentries] = $0
+}
+
+###
+### Print out the PLIST entries to standard output.
+###
+END {
+ # Drop valid library names associated with a libtool archive from
+ # the list of library symlinks that will be removed from the PLIST.
+ #
+ for (j in symlinks) {
+ for (k in ltnames) {
+ if (symlinks[j] == ltnames[k]) {
+ delete symlinks[j]
+ break
+ }
+ }
+ }
+
+ # Remove PLIST entries which match a library symlink.
+ for (i in entries) {
+ for (j in symlinks) {
+ if (entries[i] == symlinks[j]) {
+ delete entries[i]
+ break
+ }
+ }
+ }
+
+ # Output the PLIST entries in order.
+ for (i = 1; i <= nentries; i++) {
+ if (entries[i]) {
+ print entries[i]
+ }
+ }
+}
diff --git a/mk/plist/shlib-dylib.awk b/mk/plist/shlib-dylib.awk
new file mode 100644
index 00000000000..1c99c37a026
--- /dev/null
+++ b/mk/plist/shlib-dylib.awk
@@ -0,0 +1,182 @@
+# $NetBSD: shlib-dylib.awk,v 1.1 2006/01/12 23:43:57 jlam Exp $
+#
+# Copyright (c) 2006 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Johnny C. Lam.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. All advertising materials mentioning features or use of this software
+# must display the following acknowledgement:
+# This product includes software developed by the NetBSD
+# Foundation, Inc. and its contributors.
+# 4. Neither the name of The NetBSD Foundation nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+#
+# This awk script is a filter that reads PLIST entries and transforms
+# and expands entries that match ELF library into the appropriate Mach-O
+# dylib names.
+#
+
+BEGIN {
+ LIBTOOL_EXPAND = ENVIRON["LIBTOOL_EXPAND"]
+ LIBTOOLIZE_PLIST = ENVIRON["LIBTOOLIZE_PLIST"]
+ PREFIX = ENVIRON["PREFIX"]
+ TEST = ENVIRON["TEST"]
+ nentries = 0
+}
+
+###
+### add_dylib(lib) adds the named "lib" to the PLIST entries list and
+### to the dylibs list if we haven't already seen it.
+###
+function add_dylib(lib) {
+ if (dylibs[lib] == "") {
+ dylibs[lib] = lib
+ entries[++nentries] = lib
+ }
+}
+
+###
+### Stored special PLIST commands, e.g. @comment, @exec, etc., verbatim
+### in the entries array.
+###
+/^@/ {
+ entries[++nentries] = $0
+ next
+}
+
+###
+### Record all of the library names associated with a libtool archive
+### in the "ltnames" array. Also, record the libtool archive in the
+### "entries" array.
+###
+(LIBTOOLIZE_PLIST ~ /[yY][eE][sS]/) && /.*\/[^\/]+\.la$/ {
+ entries[++nentries] = $0
+ cmd = TEST " -f " PREFIX "/" $0
+ if (system(cmd) == 0) {
+ cmd = "cd " PREFIX " && " LIBTOOL_EXPAND " " $0
+ while (cmd | getline) {
+ ltnames[$0] = $0
+ }
+ close(cmd)
+ }
+ next
+}
+
+###
+### Convert each ELF shlib entry into a dylib entry. Also, record all
+### dylib names that can be derived from this entry as dylibs.
+###
+/.*\/lib[^\/]+\.so(\.[0-9]+)+$/ {
+ lib = $0; sub("\.so\.", ".", lib); sub("\.so$", "", lib)
+ lib = lib ".dylib"
+ add_dylib(lib)
+ while (sub("\.[0-9]+$", "")) {
+ lib = $0; sub("\.so\.", ".", lib); sub("\.so$", "", lib)
+ lib = lib ".dylib"
+ add_dylib(lib)
+ }
+ if (sub("\.so$", "")) {
+ lib = $0 ".dylib"
+ add_dylib(lib)
+ }
+ if (sub("-([0-9.]+)$", "")) {
+ lib = $0 ".dylib"
+ add_dylib(lib)
+ }
+ next
+}
+
+###
+### If the ".so" file actually exists, then it's a dynamically loadable
+### module, so the entry should stay. Convert it into a dylib name as
+### well and record it as a dylib.
+###
+/.*\/lib[^\/]+\.so$/ {
+ cmd = TEST " -f " PREFIX "/" $0
+ if (system(cmd) == 0) {
+ entries[++nentries] = $0
+ }
+ lib = $0; sub("\.so$", "", lib)
+ lib = lib ".dylib"
+ add_dylib(lib)
+ if (sub("-([0-9.]+)$", "")) {
+ lib = $0 ".dylib"
+ add_dylib(lib)
+ }
+ next
+}
+
+###
+### All other entries are stored verbatim in the entries array.
+###
+{
+ entries[++nentries] = $0
+}
+
+###
+### Print out the PLIST entries to standard output.
+###
+END {
+ # Drop valid library names associated with a libtool archive from
+ # the list of dylibs that will be removed from the PLIST.
+ #
+ for (j in dylibs) {
+ for (k in ltnames) {
+ if (dylibs[j] == ltnames[k]) {
+ delete dylibs[j]
+ break
+ }
+ }
+ }
+
+ # Remove dylib entries that *do* exist on the filesystem from the
+ # list of dylibs that will be removed from the PLIST.
+ #
+ for (j in dylibs) {
+ cmd = TEST " -f " PREFIX "/" dylibs[j]
+ if (system(cmd) == 0) {
+ delete dylibs[j]
+ }
+ }
+
+ # Remove PLIST entries that match a non-existent dylib.
+ for (i in entries) {
+ for (j in dylibs) {
+ if (entries[i] == dylibs[j]) {
+ delete entries[i]
+ break
+ }
+ }
+ }
+
+ # Output the PLIST entries in order.
+ for (i = 1; i <= nentries; i++) {
+ if (entries[i]) {
+ print entries[i]
+ }
+ }
+}
diff --git a/mk/plist/shlib-elf.awk b/mk/plist/shlib-elf.awk
new file mode 100644
index 00000000000..e29b766e48b
--- /dev/null
+++ b/mk/plist/shlib-elf.awk
@@ -0,0 +1,48 @@
+# $NetBSD: shlib-elf.awk,v 1.1 2006/01/12 23:43:57 jlam Exp $
+#
+# Copyright (c) 2006 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Johnny C. Lam.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. All advertising materials mentioning features or use of this software
+# must display the following acknowledgement:
+# This product includes software developed by the NetBSD
+# Foundation, Inc. and its contributors.
+# 4. Neither the name of The NetBSD Foundation nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+#
+# This awk script is a null filter that reads PLIST entries from standard
+# input and writes them to standard output. No action is necessary because
+# PLISTs are always ELF-centric.
+#
+
+###
+### All entries are output verbatim.
+###
+{
+ print
+}
diff --git a/mk/plist/shlib-none.awk b/mk/plist/shlib-none.awk
new file mode 100644
index 00000000000..5d2c2b1d2e9
--- /dev/null
+++ b/mk/plist/shlib-none.awk
@@ -0,0 +1,54 @@
+# $NetBSD: shlib-none.awk,v 1.1 2006/01/12 23:43:57 jlam Exp $
+#
+# Copyright (c) 2006 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Johnny C. Lam.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. All advertising materials mentioning features or use of this software
+# must display the following acknowledgement:
+# This product includes software developed by the NetBSD
+# Foundation, Inc. and its contributors.
+# 4. Neither the name of The NetBSD Foundation nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+#
+# This awk script is a filter that reads PLIST entries and comments out
+# entries that match ELF library symlinks.
+#
+
+###
+### Comment out shared library entries.
+###
+/^[^@]/ && /.*\/lib[^\/]+\.so(\.[0-9]+)*$/ {
+ $0 = "@comment No shared objects - " $0
+}
+
+###
+### All other entries are output verbatim.
+###
+{
+ print
+}
diff --git a/mk/plist/shlib-type b/mk/plist/shlib-type
new file mode 100755
index 00000000000..62b68974fbb
--- /dev/null
+++ b/mk/plist/shlib-type
@@ -0,0 +1,54 @@
+# /bin/sh
+#
+# $NetBSD: shlib-type,v 1.1 2006/01/12 23:43:57 jlam Exp $
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Alistair Crooks.
+#
+# This script returns the the library format for the platform. If the
+# library format is "ELF/a.out", then a small program is cmopiled to
+# determine the correct object format (either ELF or a.out).
+#
+
+: ${CC=cc}
+: ${ECHO=echo}
+: ${FILE_CMD=file}
+: ${RM=rm}
+: ${MKDIR=mkdir}
+: ${TEST=test}
+: ${TMPDIR=/tmp}
+
+self="${0##*/}"
+
+usage() {
+ ${ECHO} 1>&2 "usage: $self libformat"
+}
+
+${TEST} $# -gt 0 || { usage; exit 1; }
+
+sotype=none
+case "$1" in
+ELF/a.out)
+ tmpdir="${TMPDIR}/shlib-type.$$"
+ umask 077 && ${MKDIR} "$tmpdir"
+ if ${TEST} -d "$tmpdir"; then
+ cd $tmpdir
+ ${ECHO} "int main() { return(0); }" > a.c
+ ${CC} ${CFLAGS} a.c -o a.out >/dev/null 2>&1
+ if ${TEST} -f "a.out"; then
+ case `${FILE_CMD} a.out` in
+ *ELF*dynamically*) sotype="ELF" ;;
+ *shared*library*) sotype="a.out" ;;
+ *dynamically*) sotype="a.out" ;;
+ esac
+ fi
+ ${RM} -fr "$tmpdir"
+ fi
+ ;;
+*)
+ sotype="$1"
+ ;;
+esac
+${ECHO} $sotype
+
+exit 0