pkgsrc-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

pkg/32471: Modulization of PLIST handling in bsd.pkg.mk



>Number:         32471
>Category:       pkg
>Synopsis:       Modulization of PLIST handling in bsd.pkg.mk
>Confidential:   no
>Severity:       non-critical
>Priority:       high
>Responsible:    pkg-manager
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Fri Jan 06 22:15:00 +0000 2006
>Originator:     Johnny C. Lam
>Release:        NetBSD 3.0_BETA
>Organization:
        The NetBSD Project
>Environment:
        NetBSD.3.0_BETA/i386 with pkgsrc HEAD
Architecture: i386
Machine: i386
>Description:
        This patch splits out the PLIST handling from bsd.pkg.mk into
        a separate module "plist" and separates out some giant in-line
        awk scripts from make variables into standalone awk scripts.

        This also fixes bugs in the Darwin dylib code that generated
        incorrect absolute path entries in the +CONTENTS file.

        I've tested this on ELF and exercised the code for both the
        a.out and dylib cases.

        I don't have time to deal with this patch.  If this works,
        someone please commit this.

>How-To-Repeat:
        n/a
>Fix:

Index: bsd.pkg.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/bsd.pkg.mk,v
retrieving revision 1.1785
diff -u -r1.1785 bsd.pkg.mk
--- bsd.pkg.mk  5 Jan 2006 23:18:26 -0000       1.1785
+++ bsd.pkg.mk  6 Jan 2006 22:06:32 -0000
@@ -93,34 +93,6 @@
 PKGNAME_NOREV=         ${PKGNAME}
 .endif
 
-##### PLIST
-
-.if ${PKG_INSTALLATION_TYPE} == "pkgviews"
-PLIST_TYPE?=           dynamic
-.endif
-PLIST_TYPE?=           static
-
-.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
-
 ##### Others
 
 _DISTDIR?=             ${DISTDIR}/${DIST_SUBDIR}
@@ -173,7 +145,6 @@
 DDIR=                  ${WRKDIR}/.DDIR
 DESCR=                 ${PKG_DB_TMPDIR}/+DESC
 DLIST=                 ${WRKDIR}/.DLIST
-PLIST=                 ${WRKDIR}/.PLIST
 
 # Files to create for versioning and build information
 BUILD_VERSION_FILE=    ${PKG_DB_TMPDIR}/+BUILD_VERSION
@@ -210,14 +181,6 @@
 PKG_FAIL_REASON+=      "This package doesn't support 
PKG_INSTALLATION_TYPE=${PKG_INSTALLATION_TYPE}."
 .endif
 
-.if (${PLIST_TYPE} != "dynamic") && (${PLIST_TYPE} != "static")
-PKG_FAIL_REASON+=      "PLIST_TYPE must be \`\`dynamic'' or \`\`static''."
-.endif
-
-.if (${PKG_INSTALLATION_TYPE} == "overwrite") && (${PLIST_TYPE} != "static")
-PKG_FAIL_REASON+=      "PLIST_TYPE must be \`\`static'' for \`\`overwrite'' 
packages."
-.endif
-
 # Check that we are using up-to-date pkg_* tools with this file.
 .if !defined(NO_PKGTOOLS_REQD_CHECK)
 .  if ${PKGTOOLS_VERSION} < ${PKGTOOLS_REQD}
@@ -351,22 +314,6 @@
 PKG_FAIL_REASON+=      "DEPOT_SUBDIR may not be empty."
 .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
-_PLIST_IGNORE_FILES+=  ${PLIST_IGNORE_FILES}
-.endif
-BUILD_DEFS+=           _PLIST_IGNORE_FILES
-
 # Automatically increase process limit where necessary for building.
 _ULIMIT_CMD=           ${UNLIMIT_RESOURCES:@_lim_@${ULIMIT_CMD_${_lim_}};@}
 
@@ -472,35 +419,6 @@
 .  undef NO_PACKAGE
 .endif
 
-# Set PLIST_SUBST to substitute "${variable}" to "value" in PLIST
-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}                                          \
-               QMAILDIR=${QMAILDIR:Q}                                  \
-               PKGMANDIR=${PKGMANDIR:Q}
-
 # Handle alternatives
 #
 .include "../../mk/alternatives.mk"
@@ -710,9 +628,6 @@
       !empty(PKG_SYSCONFBASE:M${PREFIX}/*)
 PKG_SYSCONFDEPOTBASE=  # empty
 PKG_SYSCONFBASEDIR=    ${PKG_SYSCONFBASE}
-.    if !empty(CONF_DEPENDS)
-_PLIST_IGNORE_FILES+=  ${PKG_SYSCONFDIR:S,^${PREFIX}/,,}
-.    endif
 .  else
 PKG_SYSCONFDEPOTBASE=  ${PKG_SYSCONFBASE}/${DEPOT_SUBDIR}
 PKG_SYSCONFBASEDIR=    ${PKG_SYSCONFDEPOTBASE}/${PKGNAME}
@@ -2183,249 +2098,6 @@
 .endif
 
 
-
-# Do handling of shared libs for two cases:
-#
-# SHLIB_PLIST_MODE=1: when first called via the ${PLIST} target,
-#                     update the PLIST to contain ELF symlink, run
-#                     ldconfig on a.out,  etc. (used when called via
-#                     the ${PLIST} target). Will update ${PLIST}.
-# SHLIB_PLIST_MODE=0: when called via the real-su-install target,
-#                     actually generate symlinks for ELF, run ldconfig
-#                     for a.out, etc. Will not modify ${PLIST}.
-#
-# XXX This target could need some cleanup after it was ripped out of
-#     real-su-install
-#
-_AOUT_AWK = \
-       BEGIN { linkc = 1 }                     \
-       /^@/ { lines[NR] = $$0; next }          \
-       function libtool_release(lib) {         \
-               if (gsub("-[^-]+\\.so\\.", ".so.", lib)) { \
-                       if (system("${TEST} -h ${PREFIX}/" lib) == 0) { \
-                               rels[NR] = lib; \
-                       }                       \
-               }                               \
-       }                                       \
-       /.*\/lib[^\/]+\.so\.[0-9]+\.[0-9]+\.[0-9]+$$/ { \
-               libtool_release($$0);           \
-               lines[NR] = $$0;                \
-               sub("\\.[0-9]+$$", "");         \
-               links[linkc++] = $$0;           \
-               sub("\\.[0-9]+$$", "");         \
-               links[linkc++] = $$0;           \
-               sub("\\.[0-9]+$$", "");         \
-               links[linkc++] = $$0;           \
-               if (sub("-[^-]+\\.so$$", ".so")) { \
-                       links[linkc++] = $$0;   \
-               }                               \
-               next                            \
-       }                                       \
-       /.*\/lib[^\/]+\.so\.[0-9]+\.[0-9]+$$/ { \
-               libtool_release($$0);           \
-               lines[NR] = $$0;                \
-               sub("\\.[0-9]+$$", "");         \
-               links[linkc++] = $$0;           \
-               sub("\\.[0-9]+$$", "");         \
-               links[linkc++] = $$0;           \
-               if (sub("-[^-]+\\.so$$", ".so")) { \
-                       links[linkc++] = $$0;   \
-               }                               \
-               next                            \
-       }                                       \
-       { lines[NR] = $$0 }                     \
-       END {                                   \
-               for (i = 0 ; i <= linkc ; i++)  \
-                       for (j = 1 ; j < NR ; j++) \
-                               if (lines[j] == links[i]) \
-                                       lines[j] = "@comment " lines[j]; \
-               if (${SHLIB_PLIST_MODE})        \
-                       for (i = 1 ; i <= NR ; i++) { \
-                               print lines[i]; \
-                               if (rels[i] != "") \
-                                       print rels[i]; \
-                       }                       \
-       }
-
-_DYLIB_AWK= \
-       /^@/ { lines[NR] = $$0; next }          \
-               function libtool_release(lib) {         \
-               if (gsub("\\.so\\.", ".", lib) || gsub("\\.so$$", "", lib)) { \
-                       lib = lib ".dylib"; \
-                       if (system("${TEST} -h ${PREFIX}/" lib) == 0) { \
-                               rels[NR] = lib; \
-                       }                       \
-               }                               \
-       }                                       \
-       /.*\/lib[^\/]+\.so\.[0-9]+\.[0-9]+\.[0-9]+$$/ { \
-               libtool_release($$0);           \
-               lines[NR] = $$0;                \
-               links[linkc++] = $$0;           \
-               sub("\\.[0-9]+$$", "");         \
-               links[linkc++] = $$0;           \
-               sub("\\.[0-9]+$$", "");         \
-               links[linkc++] = $$0;           \
-               sub("\\.[0-9]+$$", "");         \
-               links[linkc++] = $$0;           \
-               if (sub("-[^-]+\\.so$$", ".so")) { \
-                       links[linkc++] = $$0;   \
-               }                               \
-               next                            \
-       }                                       \
-       /.*\/lib[^\/]+\.so\.[0-9]+\.[0-9]+$$/ { \
-               libtool_release($$0);           \
-               lines[NR] = $$0;                \
-               links[linkc++] = $$0;           \
-               sub("\\.[0-9]+$$", "");         \
-               links[linkc++] = $$0;           \
-               sub("\\.[0-9]+$$", "");         \
-               links[linkc++] = $$0;           \
-               if (sub("-[^-]+\\.so$$", ".so")) { \
-                       links[linkc++] = $$0;   \
-               }                               \
-               next                            \
-       }                                       \
-       /.*\/lib[^\/]+\.so\.[0-9]+$$/ {         \
-               libtool_release($$0);           \
-               lines[NR] = $$0;                \
-               links[linkc++] = $$0;           \
-               sub("\\.[0-9]+$$", "");         \
-               links[linkc++] = $$0;           \
-               if (sub("-[^-]+\\.so$$", ".so")) { \
-                       links[linkc++] = $$0;   \
-               }                               \
-               next                            \
-       }                                       \
-       /.*\/lib[^\/]+\.so$$/ {                 \
-               lines[NR] = $$0;                \
-               if (system("${TEST} -f ${PREFIX}/" $$0) == 0) { \
-                       next;                   \
-               }                               \
-               libtool_release($$0);           \
-               links[linkc++] = $$0;           \
-               if (sub("-[^-]+\\.so$$", ".so")) { \
-                       links[linkc++] = $$0;   \
-               }                               \
-               next                            \
-       }                                       \
-       { lines[NR] = $$0 }                     \
-       END {                                   \
-               for (i = 0 ; i <= linkc ; i++)  \
-                       for (j = 1 ; j <= NR ; j++) \
-                               if (lines[j] == links[i]) \
-                                       lines[j] = "@comment " lines[j]; \
-               if (${SHLIB_PLIST_MODE})        \
-                       for (i = 1 ; i <= NR ; i++) { \
-                               print lines[i]; \
-                               if (rels[i] != "") { \
-                                       print rels[i]; \
-                                       cmd = "${LS} -l ${PREFIX}/" rels[i]; \
-                                       cmd | getline tgt; \
-                                       close(cmd); \
-                                       gsub(".* ", "", tgt); \
-                                       if (tgts[tgt] == "") { \
-                                               tgts[tgt] = tgt; \
-                                               if (index(tgt, "/") == 1) \
-                                                       print tgt; \
-                                               else { \
-                                                       prefix=""; \
-                                                       if (match(rels[i], 
".*/") != 0) \
-                                                               
prefix=substr(rels[i],1,RLENGTH); \
-                                                       print prefix tgt; \
-                                               } \
-                                       }       \
-                               }               \
-                       }                       \
-       }
-
-# Turn lib*.so.*, lib*.so into lib*.so.  Drop duplicates.
-_AIXLIB_AWK= \
-       /^@/ { lines[NR] = $$0; next }          \
-       /.*\/lib[^\/]+\.so(\.[0-9]+)*$$/ {      \
-               sub("(\\.[0-9]+)*$$", "");      \
-               sub("\\.so$$", ".so");          \
-               lines[NR] = $$0;                \
-               next                            \
-       }                                       \
-       { lines[NR] = $$0 }                     \
-       END {                                   \
-               nlibs = 0;                      \
-               for (i = 1; i <= NR; i++) {     \
-                       for (j = 0; j < nlibs; j++) { \
-                               if (libs[j] == lines[i]) \
-                                       break;  \
-                       }                       \
-                       if (j >= nlibs)         \
-                               print lines[i]; \
-                       if (match(lines[i], ".*/lib[^/]+\\.a$$")) { \
-                               libs[nlibs] = lines[i]; \
-                               nlibs++;        \
-                       }                       \
-               }                               \
-       }
-
-.PHONY: do-shlib-handling
-do-shlib-handling:
-.if ${SHLIB_HANDLING} == "YES"
-       ${_PKG_SILENT}${_PKG_DEBUG}                                     \
-       sos=`${EGREP} -h '^.*/lib[^/]+\.so$$' ${PLIST} || ${TRUE}`;     \
-       if [ "$$sos" != "" ]; then                                      \
-               shlib_type=`${MAKE} ${MAKEFLAGS} show-shlib-type`;      \
-               if [ "${SHLIB_PLIST_MODE}" = "0" ]; then                \
-                       ${ECHO_MSG} "${_PKGSRC_IN}> [Automatic $$shlib_type 
shared object handling]"; \
-               fi;                                                     \
-               case "$$shlib_type" in                                  \
-               ELF)    ;;                                              \
-               aixlib) ;;                                              \
-               "a.out")                                                \
-                       ${AWK} '${_AOUT_AWK}' <${PLIST} >${PLIST}.tmp ; \
-                       if [ "${SHLIB_PLIST_MODE}" = "1" ]; then        \
-                               ${MV} ${PLIST}.tmp ${PLIST};            \
-                       else                                            \
-                               ${RM} ${PLIST}.tmp ;                    \
-                       fi ;                                            \
-                       cnt=`${EGREP} -c '^@exec[       ]*${LDCONFIG}$$' 
${PLIST} || ${TRUE}`; \
-                       if [ "${SHLIB_PLIST_MODE}" = "1" ]; then        \
-                               if [ $$cnt -eq 0 ]; then                \
-                                       ${ECHO} "@exec ${LDCONFIG}" >> 
${PLIST}; \
-                                       ${ECHO} "@unexec ${LDCONFIG}" >> 
${PLIST}; \
-                               fi                                      \
-                       fi;                                             \
-                       if [ "${SHLIB_PLIST_MODE}" = "0" ]; then        \
-                               if [ "${PKG_VERBOSE}" != "" ]; then     \
-                                       ${ECHO_MSG} "$$sos";            \
-                                       ${ECHO_MSG} "Running ${LDCONFIG}"; \
-                               fi;                                     \
-                               ${LDCONFIG} || ${TRUE};                 \
-                       fi                                              \
-                       ;;                                              \
-               "dylib")                                                \
-                       ${AWK} '${_DYLIB_AWK}' <${PLIST} >${PLIST}.tmp && \
-                       if [ "${SHLIB_PLIST_MODE}" = "1" ]; then        \
-                               ${MV} ${PLIST}.tmp ${PLIST};            \
-                       else                                            \
-                               ${RM} ${PLIST}.tmp ;                    \
-                       fi ;                                            \
-                       ;;                                              \
-               "*")                                                    \
-                       if [ "${SHLIB_PLIST_MODE}" = "0" ]; then        \
-                               ${ECHO_MSG} "No shared libraries for 
${MACHINE_ARCH}"; \
-                       fi ;                                            \
-                       if [ "${SHLIB_PLIST_MODE}" = "1" ]; then        \
-                               for so in $$sos; do                     \
-                                       if [ X"${PKG_VERBOSE}" != X"" ]; then \
-                                               ${ECHO_MSG} >&2 "Ignoring 
$$so"; \
-                                       fi;                             \
-                                       ${SED} -e "s;^$$so$$;@comment No shared 
objects - &;" \
-                                               ${PLIST} >${PLIST}.tmp && ${MV} 
${PLIST}.tmp ${PLIST};  \
-                               done;                                   \
-                       fi ;                                            \
-                       ;;                                              \
-               esac;                                                   \
-       fi
-.endif # SHLIB_HANDLING == "YES"
-
-
 # Check if all binaries and shlibs find their needed libs
 # Must be run after "make install", so that files are installed, and
 # ${PLIST} exists.
@@ -2468,36 +2140,6 @@
 .endif # NO_PKG_REGISTER
 
 
-.if !target(show-shlib-type)
-# Show the shared lib type being built: one of ELF, a.out, dylib, or none
-.PHONY: show-shlib-type
-show-shlib-type:
-.  if empty(USE_LANGUAGES)
-       @${ECHO} "none"
-.  elif ${_OPSYS_SHLIB_TYPE} == "ELF/a.out"
-       @cd ${WRKDIR} &&                                                \
-       sotype=none;                                                    \
-       if [ "X${MKPIC}" != "Xno" -a "X${NOPIC}" = "X" ]; then          \
-               ${ECHO} "int main() { return(0); }" > a.$$$$.c;         \
-               ${SETENV} PATH=${PATH:Q}                                \
-               ${CC} ${CFLAGS} a.$$$$.c -o a.$$$$.out;                 \
-               case `${FILE_CMD} a.$$$$.out` in                        \
-               *ELF*dynamically*)                                      \
-                       sotype=ELF ;;                                   \
-               *shared*library*)                                       \
-                       sotype="a.out" ;;                               \
-               *dynamically*)                                          \
-                       sotype="a.out" ;;                               \
-               esac;                                                   \
-       fi;                                                             \
-       ${ECHO} "$$sotype";                                             \
-       ${RM} -f a.$$$$.c a.$$$$.out
-.  else
-       @${ECHO} ${_OPSYS_SHLIB_TYPE}
-.  endif   # USE_LANGUAGES
-.endif
-
-
 .PHONY: acquire-extract-lock acquire-patch-lock acquire-tools-lock
 .PHONY: acquire-wrapper-lock acquire-configure-lock acquire-build-lock
 .PHONY: acquire-install-lock acquire-package-lock
@@ -3996,181 +3638,6 @@
                ${ECHO} "0";                                            \
        fi
 
-
-###
-### 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
-_PRINT_LA_LIBNAMES=    ${SETENV} ECHO=${ECHO:Q} GREP=${GREP:Q} SORT=${SORT:Q} \
-                       ${SH} ${.CURDIR}/../../mk/scripts/print-la-libnames
-
-.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)                                                   \
-                       ${_PRINT_LA_LIBNAMES} $$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)
-
 # By default, all packages attempt to link into the views.
 .if ${PKG_INSTALLATION_TYPE} == "pkgviews"
 BUILD_VIEWS?=  yes
@@ -4483,184 +3950,6 @@
 tags:
 .endif
 
-# generate ${PLIST} from ${PLIST_SRC} by:
-# - substituting for PLIST_SUBST entries
-# - fixing list of man-pages according to PKGMANDIR, MANZ, MANINSTALL.
-# - adding symlinks for shared libs (ELF) or ldconfig calls (a.out).
-
-# plist awk pattern-action statement to convert man/ to ${PKGMANDIR}/
-_PLIST_AWK_PKGMANDIR=                                                  \
-/^([^\/]*\/)*man\/([^\/]*\/)?(man[1-9ln]\/.*[1-9ln]|cat[1-9ln]\/.*[0-9])$$/ { \
-       sub("^man/", "${PKGMANDIR}/");                                  \
-}                                                                      \
-/^@dirrm man\// {                                                      \
-       sub(" man/", " ${PKGMANDIR}/");                                 \
-}
-
-# plist awk pattern-action statement to handle MANINSTALL
-_PLIST_AWK_MANINSTALL=                                                 \
-{                                                                      \
-       if (!"${MANINSTALL:Mmaninstall}" &&                             \
-               match($$0, "^([^/]*/)*man/([^/]*/)?man[1-9ln]") ) {     \
-                       next;                                           \
-       }                                                               \
-       if (!"${MANINSTALL:Mcatinstall}" &&                             \
-               match($$0, "^([^/]*/)*man/([^/]*/)?cat[1-9ln]") ) {     \
-                       next;                                           \
-       }                                                               \
-}
-
-# plist awk pattern-action statement to strip '.gz' from man
-# entries
-_PLIST_AWK_STRIP_MANZ=                                                 \
-/^([^\/]*\/)*man\/([^\/]*\/)?(man[1-9ln]\/.*[1-9ln]|cat[1-9ln]\/.*[0-9])\.gz$$/
 { \
-       $$0 = substr($$0, 1, length($$0) - 3);                          \
-}
-
-# plist awk pattern-action statement to add '.gz' to man entries
-_PLIST_AWK_ADD_MANZ=                                                   \
-/^([^\/]*\/)*man\/([^\/]*\/)?(man[1-9ln]\/.*[1-9ln]|cat[1-9ln]\/.*[0-9])$$/ { \
-       $$0 = $$0 ".gz";                                                \
-}
-
-# plist awk pattern-action statement to handle PLIST_SUBST substitutions
-# BEWARE: the awk script quote is closed and reopened around the
-# string argument of gsub() calls so historic quoting semantic of
-# PLIST_SUBST is preserved.
-# XXX `_str_quote_{start,end}_' is a gross hack to work around weird word
-# splitting.
-_PLIST_AWK_SUBST= { 
${PLIST_SUBST:S|=|\\}/,_str_quote_start_|:S|$|_str_quote_end_);|:S|^|gsub(/\\\$\\{|:S|_str_quote_start_|"'|g:S|_str_quote_end_|'"|g}
 }
-
-# plist awk pattern-action statement to rewrite "imake installed" catman pages
-# as plain manpages.
-_PLIST_AWK_IMAKE_MAN=                                                  \
-/^([^\/]*\/)*man\/([^\/]*\/)?cat[1-9ln]\/.*0$$/ {                      \
-       n = match($$0, "/cat[1-9ln]");                                  \
-       sect = sprintf(".%s", substr($$0, n + 4, 1));                   \
-       sub("/cat", "/man");                                            \
-       sub("\\.0$$", sect);                                            \
-}
-
-# plist awk pattern-action statement to handle info files:
-# generate list of files matching
-# ${PREFIX}/${INFO_DIR}/filename(-[0-9]+)?(.gz)?
-# for `filename' being each word of INFO_FILES in turn.
-# Notes:
-# - first the filenames matching ${PREFIX}/${INFO_DIR}/filename*
-# are generated with ls then they are filtered by the exact pattern.
-# - ${PREFIX}/${INFO_DIR}/filename is single quoted and single quote
-# escaped
-# XXX When all info file entries will be removed from PLIST files
-# the non-BEGIN pattern-action statements generated below will be retired.
-_PLIST_AWK_INFO=
-.if ${PLIST_TYPE} == "static"
-.  if !empty(INFO_FILES)
-.    for _f_ in ${INFO_FILES}
-_PLIST_AWK_INFO+=                                                      \
-BEGIN {                                                                        
\
-       cmd="${_f_}"; gsub("'\''", "\\'\''", cmd);                      \
-       sub("^", "${LS} '\''${PREFIX}/${INFO_DIR}/", cmd);              \
-       sub("$$", "'\''*", cmd);                                        \
-       while ((cmd | getline l) > 0) {                                 \
-               if (match(l, ".*/${_f_:S|+|\\\+|g}(-[0-9]+)?(\\.gz)?$$")) { \
-                       sub("^${PREFIX}/", "", l);                      \
-                       print l;                                        \
-               }                                                       \
-       }                                                               \
-       close(cmd);                                                     \
-}                                                                      \
-/^${INFO_DIR:S|/|\\/|g}\/${_f_}(-[0-9]+)?$$/ { next; }
-.    endfor
-.  endif
-.endif
-
-# plist awk pattern-action statement to expand libtool archives into
-# shared and/or static libraries.
-#
-.if ${PLIST_TYPE} == "dynamic"
-_PLIST_AWK_LIBTOOL?=   # empty
-.elif empty(LIBTOOLIZE_PLIST:M[yY][eE][sS])
-BROKEN+=               "USE_LIBTOOL requires LIBTOOLIZE_PLIST=yes for proper 
PLIST generation"
-.else
-_PLIST_AWK_LIBTOOL?=                                                   \
-/^[^@].*\.la$$/ {                                                      \
-       system("cd ${PREFIX} && ${_PRINT_LA_LIBNAMES} " $$0)            \
-}
-.endif
-
-# _PLIST_AWK_SCRIPT hold the complete awk script for plist target.
-#
-_PLIST_AWK_SCRIPT=     '
-# Do the substitutions
-# See comments above about _PLIST_AWK_SUBST: it contains single quotes!
-# So _PLIST_AWK_SCRIPT is intended to be single quoted.
-_PLIST_AWK_SCRIPT+=    ${_PLIST_AWK_SUBST}
-# Generated entries for info files
-.if !empty(INFO_FILES)
-_PLIST_AWK_SCRIPT+=    ${_PLIST_AWK_INFO}
-.endif
-# Change path to man directory if using custom PKGMANDIR
-_PLIST_AWK_SCRIPT+=    ${_PLIST_AWK_PKGMANDIR}
-# Expand libtool archives
-_PLIST_AWK_SCRIPT+=    ${_PLIST_AWK_LIBTOOL}
-# Strip the '.gz' suffixes on man entries
-_PLIST_AWK_SCRIPT+=    ${_PLIST_AWK_STRIP_MANZ}
-# Deal with MANINSTALL and man entries
-_PLIST_AWK_SCRIPT+=    ${_PLIST_AWK_MANINSTALL}
-# Deal with "imake installed" catman pages
-.if (defined(USE_IMAKE) || !empty(USE_TOOLS:Mimake)) && 
${_PREFORMATTED_MAN_DIR} == "man"
-_PLIST_AWK_SCRIPT+=    ${_PLIST_AWK_IMAKE_MAN}
-.endif
-# Add '.gz' suffixes on man entries if needed
-.if !empty(_MANZ:M[yY][eE][sS])
-_PLIST_AWK_SCRIPT+=    ${_PLIST_AWK_ADD_MANZ}
-.endif
-# Print the entry
-_PLIST_AWK_SCRIPT+=    { print $$0; }
-#
-_PLIST_AWK_SCRIPT+=    '
-
-# 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};
-.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=       ${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} } | ${AWK} ${_PLIST_AWK_SCRIPT}            \
-               > ${PLIST};                                             \
-         ${MAKE} ${MAKEFLAGS} do-shlib-handling                        \
-               SHLIB_PLIST_MODE=1
-
 # generate ${MESSAGE} from ${MESSAGE_SRC} by substituting
 # for MESSAGE_SUBST entries
 
@@ -4693,6 +3982,8 @@
        ${ECHO} '${HOMEPAGE}'   >>${DESCR}
 .endif
 
+.include "../../mk/plist/bsd.plist.mk"
+
 .include "../../mk/subst.mk"
 
 #
Index: plist/bsd.plist.mk
===================================================================
RCS file: plist/bsd.plist.mk
diff -N plist/bsd.plist.mk
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ plist/bsd.plist.mk  6 Jan 2006 22:06:32 -0000
@@ -0,0 +1,544 @@
+##### PLIST
+
+.if ${PKG_INSTALLATION_TYPE} == "pkgviews"
+PLIST_TYPE?=   dynamic
+.endif
+PLIST_TYPE?=   static
+
+.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
+
+PLIST=         ${WRKDIR}/.PLIST
+
+.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
+
+# Set PLIST_SUBST to substitute "${variable}" to "value" in PLIST
+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}                                          \
+               QMAILDIR=${QMAILDIR:Q}                                  \
+               PKGMANDIR=${PKGMANDIR:Q}
+
+#
+# Show the shared library type: ELF, a.out, dylib, or none.
+#
+.if !target(show-shlib-type)
+.PHONY: show-shlib-type
+show-shlib-type:
+.  if empty(USE_LANGUAGES)
+       @${ECHO} "none"
+.  elif ${_OPSYS_SHLIB_TYPE} == "ELF/a.out"
+       @cd ${WRKDIR} &&                                                \
+       sotype=none;                                                    \
+       if [ "X${MKPIC}" != "Xno" -a "X${NOPIC}" = "X" ]; then          \
+               ${ECHO} "int main() { return(0); }" > a.$$$$.c;         \
+               ${SETENV} PATH=${PATH:Q}                                \
+               ${CC} ${CFLAGS} a.$$$$.c -o a.$$$$.out;                 \
+               case `${FILE_CMD} a.$$$$.out` in                        \
+               *ELF*dynamically*)                                      \
+                       sotype=ELF ;;                                   \
+               *shared*library*)                                       \
+                       sotype="a.out" ;;                               \
+               *dynamically*)                                          \
+                       sotype="a.out" ;;                               \
+               esac;                                                   \
+       fi;                                                             \
+       ${ECHO} "$$sotype";                                             \
+       ${RM} -f a.$$$$.c a.$$$$.out
+.  else
+       @${ECHO} ${_OPSYS_SHLIB_TYPE}
+.  endif
+.endif
+
+# Do handling of shared libs for two cases:
+#
+# SHLIB_PLIST_MODE=1: when first called via the ${PLIST} target,
+#                     update the PLIST to contain ELF symlink, run
+#                     ldconfig on a.out,  etc. (used when called via
+#                     the ${PLIST} target). Will update ${PLIST}.
+# SHLIB_PLIST_MODE=0: when called via the real-su-install target,
+#                     actually generate symlinks for ELF, run ldconfig
+#                     for a.out, etc. Will not modify ${PLIST}.
+#
+# XXX This target could need some cleanup after it was ripped out of
+#     real-su-install
+#
+_SHLIB_AWKFILE.a.out=  ${.CURDIR}/../../mk/plist/shlib-aout.awk
+_SHLIB_AWKFILE.dylib=  ${.CURDIR}/../../mk/plist/shlib-dylib.awk
+_SHLIB_AWK_ENV=                PREFIX=${PREFIX:Q}                              
\
+                       PRINT_LA_LIBNAMES=${_PRINT_LA_LIBNAMES:Q}       \
+                       TEST=${TEST:Q}
+
+.PHONY: do-shlib-handling
+do-shlib-handling:
+.if ${SHLIB_HANDLING} == "YES"
+       ${_PKG_SILENT}${_PKG_DEBUG}                                     \
+       sos=`${EGREP} -h '^.*/lib[^/]+\.so$$' ${PLIST} || ${TRUE}`;     \
+       if [ "$$sos" != "" ]; then                                      \
+               shlib_type=`${MAKE} ${MAKEFLAGS} show-shlib-type`;      \
+               if [ "${SHLIB_PLIST_MODE}" = "0" ]; then                \
+                       ${ECHO_MSG} "${_PKGSRC_IN}> [Automatic $$shlib_type 
shared object handling]"; \
+               fi;                                                     \
+               case "$$shlib_type" in                                  \
+               ELF)    ;;                                              \
+               aixlib) ;;                                              \
+               "a.out")                                                \
+                       ${SETENV} ${_SHLIB_AWK_ENV} ${AWK}              \
+                               -f ${_SHLIB_AWKFILE.a.out}              \
+                               < ${PLIST} > ${PLIST}.tmp ;             \
+                       if [ "${SHLIB_PLIST_MODE}" = "1" ]; then        \
+                               ${MV} ${PLIST}.tmp ${PLIST};            \
+                       else                                            \
+                               ${RM} ${PLIST}.tmp ;                    \
+                       fi ;                                            \
+                       cnt=`${EGREP} -c '^@exec[       ]*${LDCONFIG}$$' 
${PLIST} || ${TRUE}`; \
+                       if [ "${SHLIB_PLIST_MODE}" = "1" ]; then        \
+                               if [ $$cnt -eq 0 ]; then                \
+                                       ${ECHO} "@exec ${LDCONFIG}" >> 
${PLIST}; \
+                                       ${ECHO} "@unexec ${LDCONFIG}" >> 
${PLIST}; \
+                               fi                                      \
+                       fi;                                             \
+                       if [ "${SHLIB_PLIST_MODE}" = "0" ]; then        \
+                               if [ "${PKG_VERBOSE}" != "" ]; then     \
+                                       ${ECHO_MSG} "$$sos";            \
+                                       ${ECHO_MSG} "Running ${LDCONFIG}"; \
+                               fi;                                     \
+                               ${LDCONFIG} || ${TRUE};                 \
+                       fi                                              \
+                       ;;                                              \
+               "dylib")                                                \
+                       ${SETENV} ${_SHLIB_AWK_ENV} ${AWK}              \
+                               -f ${_SHLIB_AWKFILE.dylib}              \
+                               < ${PLIST} > ${PLIST}.tmp &&            \
+                       if [ "${SHLIB_PLIST_MODE}" = "1" ]; then        \
+                               ${MV} ${PLIST}.tmp ${PLIST};            \
+                       else                                            \
+                               ${RM} ${PLIST}.tmp ;                    \
+                       fi ;                                            \
+                       ;;                                              \
+               "*")                                                    \
+                       if [ "${SHLIB_PLIST_MODE}" = "0" ]; then        \
+                               ${ECHO_MSG} "No shared libraries for 
${MACHINE_ARCH}"; \
+                       fi ;                                            \
+                       if [ "${SHLIB_PLIST_MODE}" = "1" ]; then        \
+                               for so in $$sos; do                     \
+                                       if [ X"${PKG_VERBOSE}" != X"" ]; then \
+                                               ${ECHO_MSG} >&2 "Ignoring 
$$so"; \
+                                       fi;                             \
+                                       ${SED} -e "s;^$$so$$;@comment No shared 
objects - &;" \
+                                               ${PLIST} >${PLIST}.tmp && ${MV} 
${PLIST}.tmp ${PLIST};  \
+                               done;                                   \
+                       fi ;                                            \
+                       ;;                                              \
+               esac;                                                   \
+       fi
+.endif # SHLIB_HANDLING == "YES"
+
+###
+### 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
+_PRINT_LA_LIBNAMES=    ${SETENV} ECHO=${ECHO:Q} GREP=${GREP:Q} SORT=${SORT:Q} \
+                       ${SH} ${.CURDIR}/../../mk/plist/print-la-libnames
+
+.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)                                                   \
+                       ${_PRINT_LA_LIBNAMES} $$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)
+
+# generate ${PLIST} from ${PLIST_SRC} by:
+# - substituting for PLIST_SUBST entries
+# - fixing list of man-pages according to PKGMANDIR, MANZ, MANINSTALL.
+# - adding symlinks for shared libs (ELF) or ldconfig calls (a.out).
+
+# plist awk pattern-action statement to convert man/ to ${PKGMANDIR}/
+_PLIST_AWK_PKGMANDIR=                                                  \
+/^([^\/]*\/)*man\/([^\/]*\/)?(man[1-9ln]\/.*[1-9ln]|cat[1-9ln]\/.*[0-9])$$/ { \
+       sub("^man/", "${PKGMANDIR}/");                                  \
+}                                                                      \
+/^@dirrm man\// {                                                      \
+       sub(" man/", " ${PKGMANDIR}/");                                 \
+}
+
+# plist awk pattern-action statement to handle MANINSTALL
+_PLIST_AWK_MANINSTALL=                                                 \
+{                                                                      \
+       if (!"${MANINSTALL:Mmaninstall}" &&                             \
+               match($$0, "^([^/]*/)*man/([^/]*/)?man[1-9ln]") ) {     \
+                       next;                                           \
+       }                                                               \
+       if (!"${MANINSTALL:Mcatinstall}" &&                             \
+               match($$0, "^([^/]*/)*man/([^/]*/)?cat[1-9ln]") ) {     \
+                       next;                                           \
+       }                                                               \
+}
+
+# plist awk pattern-action statement to strip '.gz' from man
+# entries
+_PLIST_AWK_STRIP_MANZ=                                                 \
+/^([^\/]*\/)*man\/([^\/]*\/)?(man[1-9ln]\/.*[1-9ln]|cat[1-9ln]\/.*[0-9])\.gz$$/
 { \
+       $$0 = substr($$0, 1, length($$0) - 3);                          \
+}
+
+# plist awk pattern-action statement to add '.gz' to man entries
+_PLIST_AWK_ADD_MANZ=                                                   \
+/^([^\/]*\/)*man\/([^\/]*\/)?(man[1-9ln]\/.*[1-9ln]|cat[1-9ln]\/.*[0-9])$$/ { \
+       $$0 = $$0 ".gz";                                                \
+}
+
+# plist awk pattern-action statement to handle PLIST_SUBST substitutions
+# BEWARE: the awk script quote is closed and reopened around the
+# string argument of gsub() calls so historic quoting semantic of
+# PLIST_SUBST is preserved.
+# XXX `_str_quote_{start,end}_' is a gross hack to work around weird word
+# splitting.
+_PLIST_AWK_SUBST= { 
${PLIST_SUBST:S|=|\\}/,_str_quote_start_|:S|$|_str_quote_end_);|:S|^|gsub(/\\\$\\{|:S|_str_quote_start_|"'|g:S|_str_quote_end_|'"|g}
 }
+
+# plist awk pattern-action statement to rewrite "imake installed" catman pages
+# as plain manpages.
+_PLIST_AWK_IMAKE_MAN=                                                  \
+/^([^\/]*\/)*man\/([^\/]*\/)?cat[1-9ln]\/.*0$$/ {                      \
+       n = match($$0, "/cat[1-9ln]");                                  \
+       sect = sprintf(".%s", substr($$0, n + 4, 1));                   \
+       sub("/cat", "/man");                                            \
+       sub("\\.0$$", sect);                                            \
+}
+
+# plist awk pattern-action statement to handle info files:
+# generate list of files matching
+# ${PREFIX}/${INFO_DIR}/filename(-[0-9]+)?(.gz)?
+# for `filename' being each word of INFO_FILES in turn.
+# Notes:
+# - first the filenames matching ${PREFIX}/${INFO_DIR}/filename*
+# are generated with ls then they are filtered by the exact pattern.
+# - ${PREFIX}/${INFO_DIR}/filename is single quoted and single quote
+# escaped
+# XXX When all info file entries will be removed from PLIST files
+# the non-BEGIN pattern-action statements generated below will be retired.
+_PLIST_AWK_INFO=
+.if ${PLIST_TYPE} == "static"
+.  if !empty(INFO_FILES)
+.    for _f_ in ${INFO_FILES}
+_PLIST_AWK_INFO+=                                                      \
+BEGIN {                                                                        
\
+       cmd="${_f_}"; gsub("'\''", "\\'\''", cmd);                      \
+       sub("^", "${LS} '\''${PREFIX}/${INFO_DIR}/", cmd);              \
+       sub("$$", "'\''*", cmd);                                        \
+       while ((cmd | getline l) > 0) {                                 \
+               if (match(l, ".*/${_f_:S|+|\\\+|g}(-[0-9]+)?(\\.gz)?$$")) { \
+                       sub("^${PREFIX}/", "", l);                      \
+                       print l;                                        \
+               }                                                       \
+       }                                                               \
+       close(cmd);                                                     \
+}                                                                      \
+/^${INFO_DIR:S|/|\\/|g}\/${_f_}(-[0-9]+)?$$/ { next; }
+.    endfor
+.  endif
+.endif
+
+# plist awk pattern-action statement to expand libtool archives into
+# shared and/or static libraries.
+#
+.if ${PLIST_TYPE} == "dynamic"
+_PLIST_AWK_LIBTOOL?=   # empty
+.elif empty(LIBTOOLIZE_PLIST:M[yY][eE][sS])
+BROKEN+=               "USE_LIBTOOL requires LIBTOOLIZE_PLIST=yes for proper 
PLIST generation"
+.else
+_PLIST_AWK_LIBTOOL?=                                                   \
+/^[^@].*\.la$$/ {                                                      \
+       system("cd ${PREFIX} && ${_PRINT_LA_LIBNAMES} " $$0)            \
+}
+.endif
+
+# _PLIST_AWK_SCRIPT hold the complete awk script for plist target.
+#
+_PLIST_AWK_SCRIPT=     '
+# Do the substitutions
+# See comments above about _PLIST_AWK_SUBST: it contains single quotes!
+# So _PLIST_AWK_SCRIPT is intended to be single quoted.
+_PLIST_AWK_SCRIPT+=    ${_PLIST_AWK_SUBST}
+# Generated entries for info files
+.if !empty(INFO_FILES)
+_PLIST_AWK_SCRIPT+=    ${_PLIST_AWK_INFO}
+.endif
+# Change path to man directory if using custom PKGMANDIR
+_PLIST_AWK_SCRIPT+=    ${_PLIST_AWK_PKGMANDIR}
+# Expand libtool archives
+_PLIST_AWK_SCRIPT+=    ${_PLIST_AWK_LIBTOOL}
+# Strip the '.gz' suffixes on man entries
+_PLIST_AWK_SCRIPT+=    ${_PLIST_AWK_STRIP_MANZ}
+# Deal with MANINSTALL and man entries
+_PLIST_AWK_SCRIPT+=    ${_PLIST_AWK_MANINSTALL}
+# Deal with "imake installed" catman pages
+.if (defined(USE_IMAKE) || !empty(USE_TOOLS:Mimake)) && 
${_PREFORMATTED_MAN_DIR} == "man"
+_PLIST_AWK_SCRIPT+=    ${_PLIST_AWK_IMAKE_MAN}
+.endif
+# Add '.gz' suffixes on man entries if needed
+.if !empty(_MANZ:M[yY][eE][sS])
+_PLIST_AWK_SCRIPT+=    ${_PLIST_AWK_ADD_MANZ}
+.endif
+# Print the entry
+_PLIST_AWK_SCRIPT+=    { print $$0; }
+#
+_PLIST_AWK_SCRIPT+=    '
+
+# 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};
+.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=       ${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} } | ${AWK} ${_PLIST_AWK_SCRIPT}            \
+               > ${PLIST};                                             \
+         ${MAKE} ${MAKEFLAGS} do-shlib-handling                        \
+               SHLIB_PLIST_MODE=1
Index: plist/print-la-libnames
===================================================================
RCS file: plist/print-la-libnames
diff -N plist/print-la-libnames
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ plist/print-la-libnames     6 Jan 2006 22:06:33 -0000
@@ -0,0 +1,77 @@
+# /bin/sh
+#
+# $NetBSD: print-la-libnames,v 1.4 2004/11/12 21:21:08 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}
+
+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 [ -r "$lapath" -a ! -h "$lapath" ]; then
+               if ${GREP} -q "libtool library file" "$lapath"; then
+                       . "$lapath"
+                       if [ "$installed" = "no" ]; then
+                               ${ECHO} 1>&2 "$0: \`$lapath' was not properly 
installed"
+                               exit 1
+                       fi
+                       for lib in $library_names $old_library; do
+                               libpath="$dir$lib"
+                               if [ ! -f "$libpath" ]; then
+                                       ${ECHO} 1>&2 "$0: \`$libpath' was not 
found"
+                               fi
+                               ${ECHO} "$libpath"
+                       done
+               fi
+       else
+               ${ECHO} 1>&2 "$0: cannot read libtool archive \`$lapath'"
+       fi
+done | ${SORT} -u
Index: plist/shlib-aout.awk
===================================================================
RCS file: plist/shlib-aout.awk
diff -N plist/shlib-aout.awk
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ plist/shlib-aout.awk        6 Jan 2006 22:06:33 -0000
@@ -0,0 +1,132 @@
+# $NetBSD$
+#
+# 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 {
+       PREFIX = ENVIRON["PREFIX"]
+       PRINT_LA_LIBNAMES = ENVIRON["PRINT_LA_LIBNAMES"]
+       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.
+###
+/.*\/[^\/]+\.la$/ {
+       entries[++nentries] = $0
+       cmd = TEST " -f " PREFIX "/" $0
+       if (system(cmd) == 0) {
+               cmd = "cd " PREFIX " && " PRINT_LA_LIBNAMES " " $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]
+               }
+       }
+}
Index: plist/shlib-dylib.awk
===================================================================
RCS file: plist/shlib-dylib.awk
diff -N plist/shlib-dylib.awk
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ plist/shlib-dylib.awk       6 Jan 2006 22:06:33 -0000
@@ -0,0 +1,181 @@
+# $NetBSD$
+#
+# 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 {
+       PREFIX = ENVIRON["PREFIX"]
+       PRINT_LA_LIBNAMES = ENVIRON["PRINT_LA_LIBNAMES"]
+       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.
+###
+/.*\/[^\/]+\.la$/ {
+       entries[++nentries] = $0
+       cmd = TEST " -f " PREFIX "/" $0
+       if (system(cmd) == 0) {
+               cmd = "cd " PREFIX " && " PRINT_LA_LIBNAMES " " $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]
+               }
+       }
+}




Home | Main Index | Thread Index | Old Index