summaryrefslogtreecommitdiff
path: root/mk/buildlink3
diff options
context:
space:
mode:
authorjlam <jlam@pkgsrc.org>2003-09-02 06:59:37 +0000
committerjlam <jlam@pkgsrc.org>2003-09-02 06:59:37 +0000
commit841b57441b803acb6edd290521d4343593e7e175 (patch)
tree84e91cd88c93c01f847527b25d244510cb5b95db /mk/buildlink3
parent97e17132ab11f03e7cfe511b3e6188812a6c47e4 (diff)
downloadpkgsrc-841b57441b803acb6edd290521d4343593e7e175.tar.gz
Merge pkgviews-mk branch into the HEAD by running:
cd pkgsrc/mk cvs update -Pd -A cvs update -Pd -j pkgviews-mk-base -j pkgviews-mk
Diffstat (limited to 'mk/buildlink3')
-rw-r--r--mk/buildlink3/README159
-rw-r--r--mk/buildlink3/TODO43
-rw-r--r--mk/buildlink3/bsd.buildlink3.mk1285
-rw-r--r--mk/buildlink3/gen-transform.sh223
-rw-r--r--mk/buildlink3/ld-post-cache11
-rw-r--r--mk/buildlink3/ld-post-logic14
-rw-r--r--mk/buildlink3/libtool-do-install25
-rw-r--r--mk/buildlink3/libtool-fix-la275
-rw-r--r--mk/buildlink3/libtool-post-cache12
-rw-r--r--mk/buildlink3/libtool-post-logic57
-rw-r--r--mk/buildlink3/libtool.sh98
-rw-r--r--mk/buildlink3/logic75
-rw-r--r--mk/buildlink3/marshall13
-rw-r--r--mk/buildlink3/post-cache4
-rw-r--r--mk/buildlink3/pre-cache3
-rw-r--r--mk/buildlink3/sunpro-cc-post-cache12
-rw-r--r--mk/buildlink3/sunpro-cc-post-logic30
-rw-r--r--mk/buildlink3/wrapper.sh67
18 files changed, 2406 insertions, 0 deletions
diff --git a/mk/buildlink3/README b/mk/buildlink3/README
new file mode 100644
index 00000000000..9e6fe705924
--- /dev/null
+++ b/mk/buildlink3/README
@@ -0,0 +1,159 @@
+$NetBSD: README,v 1.2 2003/09/02 06:59:52 jlam Exp $
+
+ 0 Package Views
+ ===============
+
+Package views is a pkgsrc technology that supports building and
+installing multiple versions of the same software such that they
+co-exist on a single system. Individual packages are installed into
+their own directory tree and their files are symlinked into "views".
+Users can choose amongst different software collections provided by
+different views by appropriately setting shell environment variables,
+e.g., PATH, MANPATH, etc.
+
+Package views is similar in spirit to the Encap Package Management
+System (http://www.encap.org/) and to the Carnegie Mellon University
+Depot software management system.
+
+
+ 0.1 A short history of package views
+ ====================================
+
+Package views was proposed as a solution to the problem of not being
+able to install multiple versions of the same software simultaneously
+via pkgsrc. Alistair Crooks presented a paper on package views at
+EuroBSDCon in November 2002 that described the work he did on the
+"pkgviews" branch of pkgsrc where he implemented his ideas. The paper
+is highly-recommended reading for a more complete understanding of
+package views principles and is available at:
+
+ http://www.NetBSD.org/Documentation/software/pkgviews.pdf
+
+Unfortunately, Alistair ran out of time to devote to integrating his
+work into the main pkgsrc branch. The code he developed languished on
+the "pkgviews" branch for over a year, and in the meantime much code
+was added to pkgsrc that increased the complexity and the capabilities
+of pkgsrc, including buildlink2, which conflicted with Alistair's
+implementation of package views. In July 2003, Johnny Lam attempted
+to integrate the functionality on the pkgviews branch into modern
+pkgsrc. As part of the integration, a new buildlink3 framework was
+created so that the the ability to isolate builds from differences in
+the environment wouldn't be lost.
+
+
+ 0.2 Package views terminology
+ =============================
+
+The terminology for packages in the package views world is as
+follows: a "pkgviews" package is a package that has been converted to
+build and install using package views. An "overwrite" package is one
+that hasn't. A "depoted" package describes a pkgviews package
+installed into /usr/pkg/packages in its "depot" directory. A package
+"instance" in a view describes a depoted package symlinked into a
+view.
+
+
+ 0.3 What's been done
+ ====================
+
+The pkg_install tools have been enhanced to handle both binary depoted
+packages and binary "overwrite" packages. The pkgsrc internals have
+been modified to allow building and installing depoted packages and to
+automatically add a depoted package in the the default view.
+"Overwrite" packages shouldn't be affected by the changes, and can be
+freely mixed with pkgviews packages.
+
+Packages that have been converted to use "pkgviews" should add the
+following line to their Makefiles:
+
+ PKG_INSTALLATION_TYPES= overwrite pkgviews
+
+PKG_INSTALLATION_TYPES can also just be one value or the other to
+explicitly note that the package only supports that one type of
+installation style. Users may add the following line to /etc/mk.conf:
+
+ PKG_INSTALLATION_PREFS= pkgviews overwrite
+
+to note that they prefer building using pkgviews if the package
+supports it, otherwise to build using the "overwrite" installation
+style. However, users should not change PKG_INSTALLATION_PREFS from
+the default value unless they're sure that they want to start
+migrating their package system over to using pkgviews. The default,
+"overwrite pkgviews", will cause all packages to build using the
+"overwrite" installation style.
+
+Some highlight of pkgviews packages include:
+
+ * fully dynamic PLISTs
+ * multiple version of the same package can co-exist
+
+
+ 0.4 buildlink3 pkgsrc build framework
+ =====================================
+
+A new buildlink3 framework that takes advantage of depoted packages
+has been added to pkgsrc as part of the package views changes.
+Buildlink3 uses wrapper scripts much like buildlink2. However, when
+building pkgviews packages, it doesn't symlink files into
+${BUILDLINK_DIR} since it can safely refer to only a specific
+package's files by passing the appropriate -I<dir> and -L<dir> flags
+to the compiler, where <dir> points to a location in the package's
+depot directory. When building "overwrite" packages, buildlink3 will
+act and feel very much like buildlink2 but with more advanced wrapper
+scripts, and there are provisions for allowing an "overwrite" package
+to build against the viewed instance of a depoted package. The
+implementation currently allows "overwrite" to depend on either
+"overwrite" or pkgviews packages, but pkgviews packages are restricted
+to only being able to depend on other pkgviews packages.
+
+Packages that have been converted to use buildlink3 should add the
+following line to their Makefiles:
+
+ USE_BUILDLINK3= YES
+
+A package must be converted to use the buildlink3 framework before it
+can support the pkgviews installation style.
+
+
+ 0.5 Package conversion issues
+ =============================
+
+The conversion process for a package to use buildlink3 and pkgviews
+essentially consists of changing USE_BUILDLINK2 to USE_BUILDLINK3,
+including buildlink3.mk files instead of buildlink2.mk files, and
+adding the PKG_INSTALLATION_TYPES line to the package Makefile. It's
+extremely easy and painless.
+
+Since the idea is that the user can choose to install a package using
+either installation style, the package Makefiles have to explicitly
+support this. This means that "hard" packages just got harder to
+maintain, but easy packages stay about the same. In this case, "hard"
+packages are the ones that have module packages, e.g. PHP4, perl5,
+Apache, Cyrus-SASL, etc. A package of this type must support finding
+shared modules or configuration files in directories shared with all
+of its module packages, thus requiring some hard-coding of paths
+across different packages.
+
+
+ 0.6 Future Work
+ ===============
+
+There may be some way around the problem of pkgviews packages not
+being able to depend on "overwrite" packages. That's the only thing
+standing in the way between allowing an arbitrary package to be built
+using either installation style and working seamlessly with any other
+package. The problem has to do with proper handling of metadata in
+the +REQUIRED_BY and +CONTENTS files that are split in two separate
+places. One possible route to a solution is that for each overwrite
+package, we can symlink /usr/pkg/packages/<pkg> -> /var/db/pkg/<pkg>.
+This allows depoted packages to record themselves directly in the
++REQUIRED_BY files of "overwrite" packages. If a user happens to run
+
+ pkg_delete -K /usr/pkg/packages <overwrite_pkg>
+
+then it still uses the correct +CONTENTS, +INSTALL, and +DEINSTALL
+scripts, so the package will still remove itself properly from
+/usr/pkg. However, there are some remaining issues with properly
+removing both the /var/db/pkg/<pkg> directory and the
+/usr/pkg/packages/<pkg> symlink, so the deletion won't be completely
+clean until this issue can be resolved.
diff --git a/mk/buildlink3/TODO b/mk/buildlink3/TODO
new file mode 100644
index 00000000000..c613311c298
--- /dev/null
+++ b/mk/buildlink3/TODO
@@ -0,0 +1,43 @@
+$NetBSD: TODO,v 1.2 2003/09/02 06:59:53 jlam Exp $
+
+Package views integration plan:
+==============================
+
+(1) Modify pkgsrc internals (bsd.pkg.mk & friends) to build and
+ install depoted packages if PKG_INSTALLATION_TYPE is set to
+ "pkgviews" in the package Makefile, and to add the depoted
+ package to the default view. The depoted package will include
+ all of it's metadata files in the depot directory, and we rely
+ on pkg_view to copy the metadata files into /var/db/pkg as
+ part of adding the package to the default view. We only
+ support the default view. Depoted packages will install into
+ ${LOCALBASE}/packages and the default view will be through
+ ${LOCALBASE} for all packages.
+
+Using this infrastructure, depoted packages that have been added to
+the default view should look and feel like a non-depoted package in
+all respects, down to what you find in /var/db/pkg/${PKGNAME}, so
+non-depoted packages can depend on depoted packages without change.
+
+(2) Migrate non-USE_X11BASE and non-USE_IMAKE packages to set
+ PKG_INSTALLATION_TYPE to "pkgviews". Depoted packages can only
+ depend on other depoted packages. A depoted package will have
+ <deppkg_dir>/lib and ${LOCALBASE}/lib in the run-time library
+ search path (-Wl,-R*) so that wildcard dependencies on library
+ packages will still work (so long as the major number of the shlib
+ hasn't increased).
+
+At this point, all packages in pkgsrc except for those that define
+USE_X11BASE or USE_IMAKE will be depoted.
+
+(3) Make xpkgwedge the default for pkgsrc. It would be nice to
+ enhance xpkgwedge in some way so that a package could be compiled
+ with the correct defaults for finding app-defaults files without
+ having the user fiddle with environment variables.
+
+This is a flag day change and will require bumping the PKGREVISIONs
+for every single USE_X11BASE and USE_IMAKE package and all packages
+that depend on them.
+
+(4) Migrate the USE_X11BASE and USE_IMAKE packages to set
+ PKG_INSTALLATION_TYPE to "pkgviews".
diff --git a/mk/buildlink3/bsd.buildlink3.mk b/mk/buildlink3/bsd.buildlink3.mk
new file mode 100644
index 00000000000..c5f4fea88c0
--- /dev/null
+++ b/mk/buildlink3/bsd.buildlink3.mk
@@ -0,0 +1,1285 @@
+# $NetBSD: bsd.buildlink3.mk,v 1.2 2003/09/02 06:59:53 jlam Exp $
+#
+# An example package buildlink3.mk file:
+#
+# -------------8<-------------8<-------------8<-------------8<-------------
+# .if !defined(FOO_BUILDLINK3_MK)
+# FOO_BUILDLINK3_MK= # defined
+# BUILDLINK_DEPTH:= ${BUILDLINK_DEPTH}+ # push
+#
+# .if !empty(BUILDLINK_DEPTH:M\+)
+# BUILDLINK_DEPENDS+= foo
+# .endif
+#
+# BUILDLINK_PACKAGES+= foo
+# BUILDLINK_DEPENDS.foo?= foo-lib>=1.0
+# BUILDLINK_PKGSRCDIR.foo?= ../../category/foo-lib
+#
+# # We want "-lbar" to eventually resolve to "-lfoo".
+# BUILDLINK_TRANSFORM+= l:bar:foo
+#
+# .include "../../category/baz/buildlink3.mk"
+#
+# BUILDLINK_DEPTH:= ${BUILDLINK_DEPTH:S/\+$//} # pop
+# .endif # FOO_BUILDLINK3_MK
+# -------------8<-------------8<-------------8<-------------8<-------------
+#
+# The different variables that may be set in a buildlink2.mk file are
+# described below.
+#
+# The variable name convention used in this Makefile are:
+#
+# BUILDLINK_* public buildlink-related variables usable in other Makefiles
+# _BLNK_* private buildlink-related variables to this Makefile
+
+ECHO_BUILDLINK_MSG?= ${TRUE}
+BUILDLINK_DIR= ${WRKDIR}/.buildlink
+BUILDLINK_X11_DIR= ${BUILDLINK_DIR:H}/.x11-buildlink
+BUILDLINK_SHELL?= ${SH}
+BUILDLINK_OPSYS?= ${OPSYS}
+
+# Prepend ${BUILDLINK_DIR}/bin to the PATH so that the wrappers are found
+# first when searching for executables.
+#
+.if defined(_OPSYS_DEFAULT_PATH)
+PATH:= ${BUILDLINK_DIR}/bin:${_OPSYS_DEFAULT_PATH}
+.else
+PATH:= ${BUILDLINK_DIR}/bin:${PATH}
+.endif
+
+# BUILDLINK_DEPENDS contains the list of packages for which we add
+# dependencies.
+#
+BUILDLINK_DEPENDS?= ${BUILDLINK_PACKAGES}
+
+X11_LINKS_SUBDIR= share/x11-links
+.if defined(USE_X11)
+USE_X11_LINKS?= YES
+. if empty(USE_X11_LINKS:M[nN][oO])
+BUILDLINK_DEPENDS+= x11-links
+_BLNK_X11_LINKS_PACKAGE= x11-links
+. else
+_BLNK_X11_LINKS_PACKAGE= # empty
+. endif
+BUILDLINK_DEPENDS.x11-links= x11-links>=0.12
+BUILDLINK_DEPMETHOD.x11-links= build
+BUILDLINK_PKGSRCDIR.x11-links= ../../pkgtools/x11-links
+_BLNK_X11_LINKS_DIR= ${BUILDLINK_PREFIX.x11-links}/${X11_LINKS_SUBDIR}
+.else
+_BLNK_X11_LINKS_PACKAGE= # empty
+.endif
+
+.for _pkg_ in ${BUILDLINK_DEPENDS}
+#
+# Add the proper dependency on each package pulled in by buildlink3.mk
+# files. BUILDLINK_DEPMETHOD.<pkg> contains a list of either "full" or
+# "build", and if any of that list if "full" then we use a full dependency
+# on <pkg>, otherwise we use a build dependency on <pkg>. By default,
+# we use a full dependency.
+#
+. if !defined(BUILDLINK_DEPMETHOD.${_pkg_})
+BUILDLINK_DEPMETHOD.${_pkg_}= full
+. endif
+. if !empty(BUILDLINK_DEPMETHOD.${_pkg_}:Mfull)
+_BLNK_DEPMETHOD.${_pkg_}= DEPENDS
+. elif !empty(BUILDLINK_DEPMETHOD.${_pkg_}:Mbuild)
+_BLNK_DEPMETHOD.${_pkg_}= BUILD_DEPENDS
+. endif
+. if defined(BUILDLINK_DEPENDS.${_pkg_}) && \
+ defined(BUILDLINK_PKGSRCDIR.${_pkg_})
+. for _depends_ in ${BUILDLINK_DEPENDS.${_pkg_}}
+${_BLNK_DEPMETHOD.${_pkg_}}+= \
+ ${_depends_}:${BUILDLINK_PKGSRCDIR.${_pkg_}}
+. endfor
+. endif
+.endfor
+
+# Generate default values for:
+#
+# BUILDLINK_PKG_DBDIR.<pkg> contains all of the package metadata
+# files for <pkg>
+#
+# BUILDLINK_PKGNAME.<pkg> the name of the package
+#
+# BUILDLINK_PREFIX.<pkg> contains all of the installed files
+# for <pkg>
+#
+# BUILDLINK_IS_DEPOT.<pkg> "yes" or "no" for whether <pkg> is a
+# depoted package.
+#
+# BUILDLINK_CPPFLAGS.<pkg>,
+# BUILDLINK_LDFLAGS.<pkg> contain extra -D..., -I... and -L.../-Wl,-R
+# options to be passed to the compiler/linker
+# so that building against <pkg> will work.
+#
+# BUILDLINK_INCDIRS.<pkg>,
+# BUILDLINK_LIBDIRS.<pkg> subdirectories of BUILDLINK_PREFIX.<pkg>
+# that should be added to the
+# compiler/linker search paths; these
+# directories are checked to see if they
+# exist before they're added to the search
+# paths.
+#
+.for _pkg_ in ${BUILDLINK_PACKAGES} ${_BLNK_X11_LINKS_PACKAGE}
+. if !defined(BUILDLINK_PKG_DBDIR.${_pkg_})
+BUILDLINK_PKG_DBDIR.${_pkg_}!= \
+ cd ${_PKG_DBDIR}; \
+ dir=`${PKG_ADMIN} -s "" lsbest "${BUILDLINK_DEPENDS.${_pkg_}}" || ${TRUE}`; \
+ case "$$dir" in \
+ "") dir="not_found" ;; \
+ esac; \
+ ${ECHO} $$dir
+. if empty(BUILDLINK_PKG_DBDIR.${_pkg_}:Mnot_found)
+MAKEFLAGS+= BUILDLINK_PKG_DBDIR.${_pkg_}=${BUILDLINK_PKG_DBDIR.${_pkg_}}
+. endif
+. endif
+BUILDLINK_PKGNAME.${_pkg_}?= ${BUILDLINK_PKG_DBDIR.${_pkg_}:T}
+. if !defined(BUILDLINK_PREFIX.${_pkg_})
+. if ${PKG_INSTALLATION_TYPE} == "pkgviews"
+BUILDLINK_PREFIX.${_pkg_}?= ${BUILDLINK_PKG_DBDIR.${_pkg_}}
+. elif ${PKG_INSTALLATION_TYPE} == "overwrite"
+. if empty(BUILDLINK_PKG_DBDIR.${_pkg_}:Mnot_found)
+BUILDLINK_PREFIX.${_pkg_}!= \
+ ${PKG_INFO} -qp ${BUILDLINK_PKGNAME.${_pkg_}} | ${SED} -e "s,^[^/]*,,"
+. else
+BUILDLINK_PREFIX.${_pkg_}?= not_found
+. endif
+. endif
+. if empty(BUILDLINK_PREFIX.${_pkg_}:Mnot_found)
+MAKEFLAGS+= BUILDLINK_PREFIX.${_pkg_}=${BUILDLINK_PREFIX.${_pkg_}}
+. endif
+. endif
+. if exists(${BUILDLINK_PKG_DBDIR.${_pkg_}}/+VIEWS)
+BUILDLINK_IS_DEPOT.${_pkg_}?= yes
+. else
+BUILDLINK_IS_DEPOT.${_pkg_}?= no
+. endif
+BUILDLINK_CPPFLAGS.${_pkg_}?= # empty
+BUILDLINK_LDFLAGS.${_pkg_}?= # empty
+BUILDLINK_INCDIRS.${_pkg_}?= include
+BUILDLINK_LIBDIRS.${_pkg_}?= lib
+.endfor
+
+# BUILDLINK_CPPFLAGS and BUILDLINK_LDFLAGS contain the proper -I...
+# and -L.../-Wl,-R... options to be passed to the compiler and linker
+# to find the headers and libraries for the various packages at
+# configure/build time.
+#
+BUILDLINK_CPPFLAGS= # empty
+BUILDLINK_LDFLAGS= # empty
+
+.for _pkg_ in ${BUILDLINK_PACKAGES}
+. for _flag_ in ${BUILDLINK_CPPFLAGS.${_pkg_}}
+. if empty(BUILDLINK_CPPFLAGS:M${_flag_})
+BUILDLINK_CPPFLAGS+= ${_flag_}
+. endif
+. endfor
+. for _flag_ in ${BUILDLINK_LDFLAGS.${_pkg_}}
+. if empty(BUILDLINK_LDFLAGS:M${_flag_})
+BUILDLINK_LDFLAGS+= ${_flag_}
+. endif
+. endfor
+. if !empty(BUILDLINK_INCDIRS.${_pkg_})
+. for _dir_ in ${BUILDLINK_INCDIRS.${_pkg_}:S/^/${BUILDLINK_PREFIX.${_pkg_}}\//}
+. if exists(${_dir_})
+. if empty(BUILDLINK_CPPFLAGS:M-I${_dir_})
+BUILDLINK_CPPFLAGS+= -I${_dir_}
+. endif
+. endif
+. endfor
+. endif
+. if !empty(BUILDLINK_LIBDIRS.${_pkg_})
+. for _dir_ in ${BUILDLINK_LIBDIRS.${_pkg_}:S/^/${BUILDLINK_PREFIX.${_pkg_}}\//}
+. if exists(${_dir_})
+. if empty(BUILDLINK_LDFLAGS:M-L${_dir_})
+BUILDLINK_LDFLAGS+= -L${_dir_}
+. endif
+. if (${_USE_RPATH} == "yes") && \
+ empty(BUILDLINK_LDFLAGS:M${_COMPILER_LD_FLAG}${RPATH_FLAG}${_dir_})
+BUILDLINK_LDFLAGS+= ${_COMPILER_LD_FLAG}${RPATH_FLAG}${_dir_}
+. endif
+. endif
+. endfor
+. endif
+.endfor
+#
+# Add the default view library directory to the runtime library search
+# path so that wildcard dependencies on library packages can always be
+# fulfilled through the default view.
+#
+.if (${_USE_RPATH} == "yes") && \
+ empty(BUILDLINK_LDFLAGS:M${_COMPILER_LD_FLAG}${RPATH_FLAG}${LOCALBASE}/lib)
+BUILDLINK_LDFLAGS+= ${_COMPILER_LD_FLAG}${RPATH_FLAG}${LOCALBASE}/lib
+.endif
+#
+# Add the X11 library directory to the runtime library search path if
+# the package uses X11.
+#
+.if defined(USE_X11) && \
+ (${_USE_RPATH} == "yes") && \
+ empty(BUILDLINK_LDFLAGS:M${_COMPILER_LD_FLAG}${RPATH_FLAG}${X11BASE}/lib)
+BUILDLINK_LDFLAGS+= ${_COMPILER_LD_FLAG}${RPATH_FLAG}${X11BASE}/lib
+.endif
+
+.for _flag_ in ${BUILDLINK_CPPFLAGS}
+. if empty(CFLAGS:M${_flag_})
+CFLAGS+= ${_flag_}
+. endif
+. if empty(CXXFLAGS:M${_flag_})
+CXXFLAGS+= ${_flag_}
+. endif
+. if empty(CPPFLAGS:M${_flag_})
+CPPFLAGS+= ${_flag_}
+. endif
+.endfor
+.for _flag_ in ${BUILDLINK_LDFLAGS}
+. if empty(LDFLAGS:M${_flag_})
+LDFLAGS+= ${_flag_}
+. endif
+.endfor
+
+# Create the buildlink include and lib directories so that the Darwin
+# compiler/linker won't complain verbosely (on stdout, even!) when
+# those directories are passed as sub-arguments of -I and -L.
+#
+.PHONY: buildlink-directories
+do-buildlink: buildlink-directories
+buildlink-directories:
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${BUILDLINK_DIR}
+.if defined(USE_X11)
+ ${_PKG_SILENT}${_PKG_DEBUG}${RM} -f ${BUILDLINK_X11_DIR}
+ ${_PKG_SILENT}${_PKG_DEBUG}${LN} -sf ${BUILDLINK_DIR} ${BUILDLINK_X11_DIR}
+. if empty(USE_X11_LINKS:M[nN][oO])
+. if exists(${_BLNK_X11_LINKS_DIR})
+ ${_PKG_SILENT}${_PKG_DEBUG}${CP} -R ${_BLNK_X11_LINKS_DIR}/* ${BUILDLINK_X11_DIR}
+. else
+ ${_PKG_SILENT}${_PKG_DEBUG}${ECHO_MSG} "x11-links doesn't seem to be installed."
+ ${_PKG_SILENT}${_PKG_DEBUG}${FALSE}
+. endif
+. endif
+.endif
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${BUILDLINK_DIR}/include
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${BUILDLINK_DIR}/lib
+
+# Create the buildlink wrappers before any of the other buildlink targets
+# are run, as the wrappers may need to be used in some of those targets.
+#
+do-buildlink: buildlink-wrappers buildlink-${_BLNK_OPSYS}-wrappers
+
+# The following variables are all optionally defined and control which
+# package files are symlinked into ${BUILDLINK_DIR} and how their names
+# are transformed during the symlinking:
+#
+# BUILDLINK_FILES.<pkg>
+# shell glob pattern relative to ${BUILDLINK_PREFIX.<pkg>} to be
+# symlinked into ${BUILDLINK_DIR}, e.g. include/*.h
+#
+# BUILDLINK_FILES_CMD.<pkg>
+# shell pipeline that outputs to stdout a list of files relative
+# to ${BUILDLINK_PREFIX.<pkg>}; the shell variable $${pkg_prefix}
+# may be used and is the subdirectory (ending in /) of
+# ${BUILDLINK_PREFIX.<pkg>} to which the +CONTENTS is relative,
+# e.g. if `pkg_info -qp kaffe' returns "/usr/pkg/java/kaffe",
+# then $${pkg_prefix} is "java/kaffe/". The resulting files are
+# to be symlinked into ${BUILDLINK_DIR}. By default for
+# overwrite packages, BUILDLINK_FILES_CMD.<pkg> outputs the
+# contents of the include and lib directories in the package
+# +CONTENTS.
+#
+# BUILDLINK_TRANSFORM.<pkg>
+# sed arguments used to transform the name of the source filename
+# into a destination filename, e.g. -e "s|/curses.h|/ncurses.h|g"
+#
+.for _pkg_ in ${BUILDLINK_PACKAGES}
+_BLNK_COOKIE.${_pkg_}= ${BUILDLINK_DIR}/.buildlink_${_pkg_}_done
+
+BUILDLINK_TARGETS+= buildlink-${_pkg_}
+_BLNK_TARGETS.${_pkg_}= buildlink-${_pkg_}-message
+_BLNK_TARGETS.${_pkg_}+= ${_BLNK_COOKIE.${_pkg_}}
+_BLNK_TARGETS.${_pkg_}+= buildlink-${_pkg_}-cookie
+
+.ORDER: ${_BLNK_TARGETS.${_pkg_}}
+
+.PHONY: buildlink-${_pkg_}
+buildlink-${_pkg_}: ${_BLNK_TARGETS.${_pkg_}}
+
+.PHONY: buildlink-${_pkg_}-message
+buildlink-${_pkg_}-message:
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ${ECHO_BUILDLINK_MSG} "=> Linking ${_pkg_} files into ${BUILDLINK_DIR}."
+
+.PHONY: buildlink-${_pkg_}-cookie
+buildlink-${_pkg_}-cookie:
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ${TOUCH} ${TOUCH_FLAGS} ${_BLNK_COOKIE.${_pkg_}}
+
+.if !empty(BUILDLINK_IS_DEPOT.${_pkg_}:M[yY][eE][sS])
+BUILDLINK_FILES_CMD.${_pkg_}?= ${TRUE}
+.else
+BUILDLINK_FILES_CMD.${_pkg_}?= \
+ ${PKG_INFO} -f ${BUILDLINK_PKGNAME.${_pkg_}} | \
+ ${SED} -n '/File:/s/^[ ]*File:[ ]*//p' | \
+ ${GREP} '\(include.*/\|lib.*/lib[^/]*$$\)' | \
+ ${SED} "s,^,$${pkg_prefix},"
+.endif
+
+${_BLNK_COOKIE.${_pkg_}}:
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ case ${BUILDLINK_PREFIX.${_pkg_}} in \
+ ${X11BASE}) buildlink_dir="${BUILDLINK_X11_DIR}" ;; \
+ *) buildlink_dir="${BUILDLINK_DIR}" ;; \
+ esac; \
+ cd ${BUILDLINK_PREFIX.${_pkg_}}; \
+ pkg_prefix=` \
+ ${PKG_INFO} -qp ${BUILDLINK_PKGNAME.${_pkg_}} | \
+ ${SED} -e "s,^[^/]*,," \
+ -e "s,^${BUILDLINK_PREFIX.${_pkg_}},," \
+ -e "s,^/,," \
+ `; \
+ case "$$pkg_prefix" in \
+ "") ;; \
+ *) pkg_prefix="$${pkg_prefix}/" ;; \
+ esac; \
+ files=`${BUILDLINK_FILES_CMD.${_pkg_}}`; \
+ files="$$files ${BUILDLINK_FILES.${_pkg_}}"; \
+ case "$$files" in \
+ "") ;; \
+ *) for file in $$files; do \
+ src="${BUILDLINK_PREFIX.${_pkg_}}/$$file"; \
+ if [ ! -f $$src ]; then \
+ ${ECHO} "$${file}: not found" >> ${.TARGET}; \
+ continue; \
+ fi; \
+ if [ -z "${BUILDLINK_TRANSFORM.${_pkg_}}" ]; then \
+ dest="$$buildlink_dir/$$file"; \
+ msg="$$src"; \
+ else \
+ dest=`${ECHO} $$dest | ${SED} ${BUILDLINK_TRANSFORM.${_pkg_}}`; \
+ msg="$$src -> $$dest"; \
+ fi; \
+ dir=`${DIRNAME} $$dest`; \
+ if [ ! -d $$dir ]; then \
+ ${MKDIR} $$dir; \
+ fi; \
+ ${RM} -f $$dest; \
+ case $$src in \
+ *.la) \
+ ${CAT} $$src | \
+ ${_BLNK_LT_ARCHIVE_FILTER} \
+ > $$dest; \
+ ;; \
+ *) \
+ ${LN} -sf $$src $$dest; \
+ ;; \
+ esac; \
+ ${ECHO} "$$msg" >> ${.TARGET}; \
+ done; \
+ ;; \
+ esac
+.endfor
+
+# _BLNK_LT_ARCHIVE_FILTER is a command-line filter for transforming
+# libtool archives (*.la) to allow libtool to properly interact with
+# buildlink at link time by linking against the libraries pointed to by
+# symlinks in ${BUILDLINK_DIR}. It achieves this in two ways:
+#
+# - Modifies the dependency_libs line by changing all full paths to
+# other *.la files into the canonical ${BUILDLINK_DIR} path.
+#
+# - Modifies the libdir line to point to within ${BUILDLINK_DIR}.
+# This prevents libtool from looking into the original directory
+# for other *.la files.
+#
+_BLNK_LT_ARCHIVE_FILTER= \
+ ${AWK} ' \
+ /^dependency_libs=/ { \
+ line = $$0; \
+ line = gensub("/usr(/lib/lib[^/ ]*\.la)", "${BUILDLINK_DIR}\\1", "g", line); \
+ line = gensub("${DEPOTBASE}/[^/ ]*(/[^ ]*/lib[^/ ]*\.la)", "${BUILDLINK_DIR}\\1", "g", line); \
+ line = gensub("${X11BASE}(/[^ ]*/lib[^/ ]*\.la)", "${BUILDLINK_X11_DIR}\\1", "g", line); \
+ line = gensub("${LOCALBASE}(/[^ ]*/lib[^/ ]*\.la)", "${BUILDLINK_DIR}\\1", "g", line); \
+ print line; \
+ next; \
+ } \
+ /^libdir=/ { \
+ line = $$0; \
+ line = gensub("/usr(/lib/[^ ]*)", "${BUILDLINK_DIR}\\1", "g", line); \
+ line = gensub("${DEPOTBASE}/[^/ ]*(/[^ ]*)", "${BUILDLINK_DIR}\\1", "g", line); \
+ line = gensub("${X11BASE}(/[^ ]*)", "${BUILDLINK_X11_DIR}\\1", "g", line); \
+ line = gensub("${LOCALBASE}(/[^ ]*)", "${BUILDLINK_DIR}\\1", "g", line); \
+ print line; \
+ next; \
+ } \
+ { print } \
+ '
+
+# Add each of the targets in BUILDLINK_TARGETS as a prerequisite for the
+# do-buildlink target. This ensures that all the buildlink magic happens
+# before any configure or build commands are called.
+#
+.for _target_ in ${BUILDLINK_TARGETS}
+do-buildlink: ${_target_}
+.endfor
+
+# The configure process usually tests for outlandish or missing things
+# that we don't want polluting the argument cache.
+#
+CONFIGURE_ENV+= BUILDLINK_UPDATE_CACHE=no
+
+# The caching code, which greatly speeds up the build process, works only
+# on certain platforms.
+#
+_BLNK_CACHE_ALL= # empty
+_BLNK_CACHE_ALL+= Darwin-6*-*
+_BLNK_CACHE_ALL+= IRIX-*-*
+_BLNK_CACHE_ALL+= NetBSD-1.[5-9]*-*
+_BLNK_CACHE_ALL+= SunOS-[25].[89]-*
+
+# There are three different parts we can add to the common transforming
+# cache to speed things up:
+#
+# passthru automatically accept certain options without
+# further checking
+#
+# transform change -[IL]{${X11BASE},${LOCALBASE},${DEPOTBASE}/*}
+# to the correct ${BUILDLINK_DIR} reference
+#
+# block block certain options without further checking
+#
+# Seeding the cache appropriately lets us handle large classes of options
+# without having to go through the wrapper logic file, which generates
+# a cache hit for every single option and bloats the cache quite bit more.
+#
+_BLNK_SEED_CACHE?= passthru # transform block
+
+.for _pattern_ in ${_BLNK_CACHE_ALL}
+. if !empty(MACHINE_PLATFORM:M${_pattern_})
+CONFIGURE_ENV+= BUILDLINK_CACHE_ALL=yes
+MAKE_ENV+= BUILDLINK_CACHE_ALL=yes
+. endif
+.endfor
+
+# _BLNK_ALLOWED_RPATHDIRS contains the list of directories for which we
+# allow adding to the runtime library search path. Package makefiles may
+# add to its value through ${BUILDLINK_RPATHDIRS}.
+#
+_BLNK_ALLOWED_RPATHDIRS= # empty
+#
+# Add all of the depot directories for packages whose headers and
+# libraries we use.
+#
+.for _pkg_ in ${BUILDLINK_PACKAGES}
+. if !empty(BUILDLINK_IS_DEPOT.${_pkg_}:M[yY][eE][sS])
+_BLNK_ALLOWED_RPATHDIRS+= ${BUILDLINK_PREFIX.${_pkg_}}
+. endif
+.endfor
+#
+# Add the depot directory for the package we're building.
+#
+.if ${PKG_INSTALLATION_TYPE} == "pkgviews"
+_BLNK_ALLOWED_RPATHDIRS+= ${PREFIX}
+.endif
+#
+# Always add ${LOCALBASE}/lib to the runtime library search path so that
+# wildcard dependencies work correctly when installing from binary
+# packages.
+#
+_BLNK_ALLOWED_RPATHDIRS+= ${LOCALBASE}/lib
+#
+# Add ${X11BASE}/lib to the runtime library search path for USE_X11
+# packages so that X11 libraries can be found.
+#
+.if defined(USE_X11)
+_BLNK_ALLOWED_RPATHDIRS+= ${X11BASE}/lib
+.endif
+#
+# Allow manually adding other directories to the runtime library search
+# path, e.g. ${LOCALBASE}/qt3/lib.
+#
+.if defined(BUILDLINK_RPATHDIRS)
+. for _dir_ in ${BUILDLINK_RPATHDIRS}
+_BLNK_ALLOWED_RPATHDIRS+= ${_dir_}
+. endfor
+.endif
+
+_BLNK_MANGLE_DIRS= # empty
+_BLNK_MANGLE_DIRS+= ${BUILDLINK_DIR}
+_BLNK_MANGLE_DIRS+= ${BUILDLINK_X11_DIR}
+_BLNK_MANGLE_DIRS+= ${WRKDIR}
+_BLNK_MANGLE_DIRS+= ${_BLNK_ALLOWED_RPATHDIRS}
+
+# We only want these for the untransform case, so don't add these
+# directories to _BLNK_{,UN}PROTECT_DIRS below.
+#
+_BLNK_MANGLE_DIRS+= ${PREFIX}
+_BLNK_MANGLE_DIRS+= ${X11BASE}
+
+_BLNK_MANGLE_START= _bUiLdLiNk_
+_BLNK_MANGLE_END= \#
+.for _dir_ in ${_BLNK_MANGLE_DIRS}
+_BLNK_MANGLE_DIR.${_dir_}= \
+ ${_BLNK_MANGLE_START}${_dir_:S/\//_/g}${_BLNK_MANGLE_END}
+.endfor
+_BLNK_MANGLE_SED_PATTERN= \
+ ${_BLNK_MANGLE_START}[^/ ${_BLNK_MANGLE_END}]*${_BLNK_MANGLE_END}
+
+_BLNK_PROTECT_DIRS= # empty
+_BLNK_UNPROTECT_DIRS= # empty
+_BLNK_PROTECT= # empty
+_BLNK_UNPROTECT= # empty
+
+_BLNK_PROTECT_DIRS+= ${BUILDLINK_DIR}
+_BLNK_PROTECT_DIRS+= ${BUILDLINK_X11_DIR}
+_BLNK_PROTECT_DIRS+= ${WRKDIR}
+.for _pkg_ in ${BUILDLINK_PACKAGES}
+. if !empty(BUILDLINK_IS_DEPOT.${_pkg_}:M[yY][eE][sS])
+_BLNK_PROTECT_DIRS+= ${BUILDLINK_PREFIX.${_pkg_}}
+_BLNK_UNPROTECT_DIRS+= ${BUILDLINK_PREFIX.${_pkg_}}
+. endif
+.endfor
+_BLNK_UNPROTECT_DIRS+= ${WRKDIR}
+_BLNK_UNPROTECT_DIRS+= ${BUILDLINK_X11_DIR}
+_BLNK_UNPROTECT_DIRS+= ${BUILDLINK_DIR}
+
+# Protect work directories and the dependency directories from all the
+# transformations we're about to do.
+#
+.for _dir_ in ${_BLNK_PROTECT_DIRS}
+_BLNK_TRANSFORM+= mangle:${_dir_}:${_BLNK_MANGLE_DIR.${_dir_}}
+.endfor
+#
+# Protect ${PREFIX} and ${X11BASE} from change when untransforming, e.g.
+# when unbuildlinkifying files.
+#
+.for _dir_ in ${PREFIX} ${X11BASE}
+_BLNK_TRANSFORM+= untransform:mangle:${_dir_}:${_BLNK_MANGLE_DIR.${_dir_}}
+.endfor
+#
+# Change references to ${DEPOTBASE}/<pkg> into ${LOCALBASE} so that
+# "overwrite" packages think headers and libraries for "pkgviews" packages
+# are just found in the default view.
+#
+.if ${PKG_INSTALLATION_TYPE} == "overwrite"
+_BLNK_TRANSFORM+= depot:${DEPOTBASE}:${LOCALBASE}
+.endif
+#
+# Change any buildlink directories in runtime library search paths into
+# the canonical actual installed paths.
+#
+.if ${PKG_INSTALLATION_TYPE} == "overwrite"
+_BLNK_TRANSFORM+= rpath:${_BLNK_MANGLE_DIR.${BUILDLINK_DIR}}:${LOCALBASE}
+.endif
+#
+# Protect some directories that we allow to be specified for the runtime
+# library search path.
+#
+.for _dir_ in ${_BLNK_ALLOWED_RPATHDIRS}
+_BLNK_TRANSFORM+= rpath:${_dir_}:${_BLNK_MANGLE_DIR.${_dir_}}
+.endfor
+#
+# Convert direct paths to shared libraries into "-Ldir -llib" equivalents.
+#
+_BLNK_TRANSFORM+= p:${_BLNK_MANGLE_SED_PATTERN:Q}
+_BLNK_TRANSFORM+= p:
+#
+# Convert direct paths to static libraries and libtool archives in
+# ${LOCALBASE} or ${X11BASE} into references into ${BUILDLINK_DIR}.
+#
+.if ${PKG_INSTALLATION_TYPE} == "overwrite"
+. if defined(USE_X11)
+_BLNK_TRANSFORM+= P:${X11BASE}:${_BLNK_MANGLE_DIR.${BUILDLINK_X11_DIR}}
+. endif
+_BLNK_TRANSFORM+= P:${LOCALBASE}:${_BLNK_MANGLE_DIR.${BUILDLINK_DIR}}
+.endif
+#
+# Transform references into ${X11BASE} into ${BUILDLINK_X11_DIR}.
+#
+.if defined(USE_X11)
+_BLNK_TRANSFORM+= I:${X11BASE}:${_BLNK_MANGLE_DIR.${BUILDLINK_X11_DIR}}
+_BLNK_TRANSFORM+= L:${X11BASE}:${_BLNK_MANGLE_DIR.${BUILDLINK_X11_DIR}}
+.endif
+#
+# Transform references into ${LOCALBASE} into ${BUILDLINK_DIR}.
+#
+.if ${PKG_INSTALLATION_TYPE} == "overwrite"
+_BLNK_TRANSFORM+= I:${LOCALBASE}:${_BLNK_MANGLE_DIR.${BUILDLINK_DIR}}
+_BLNK_TRANSFORM+= L:${LOCALBASE}:${_BLNK_MANGLE_DIR.${BUILDLINK_DIR}}
+.endif
+#
+# Add any package specified transformations (l:, etc.)
+#
+_BLNK_TRANSFORM+= ${BUILDLINK_TRANSFORM}
+#
+# Explicitly remove everything else that's an absolute path, since we've
+# already protected the ones we care about.
+#
+_BLNK_TRANSFORM+= r:
+#
+# Remove -Wl,-R* and *-rpath* if _USE_RPATH != "yes"
+# Transform -Wl,-R* and *-rpath* if Sun compilers are used.
+#
+.if defined(_USE_RPATH) && empty(_USE_RPATH:M[yY][eE][sS])
+_BLNK_TRANSFORM+= no-rpath
+.endif
+#
+# Undo the protection for the directories that we allow to be specified
+# for the runtime library search path.
+#
+.for _dir_ in ${_BLNK_ALLOWED_RPATHDIRS}
+_BLNK_TRANSFORM+= rpath:${_BLNK_MANGLE_DIR.${_dir_}}:${_dir_}
+.endfor
+#
+# Undo the protection for ${PREFIX} and ${X11BASE} so that the directory
+# names are correct, e.g. when unbuildlinkifying files.
+#
+.for _dir_ in ${PREFIX} ${X11BASE}
+_BLNK_TRANSFORM+= untransform:mangle:${_BLNK_MANGLE_DIR.${_dir_}}:${_dir_}
+.endfor
+#
+# Undo the protection so the correct directory names are passed to the
+# the wrappee.
+#
+.for _dir_ in ${_BLNK_UNPROTECT_DIRS}
+_BLNK_TRANSFORM+= mangle:${_BLNK_MANGLE_DIR.${_dir_}}:${_dir_}
+.endfor
+
+_BLNK_TRANSFORM_SED+= -f ${_BLNK_TRANSFORM_SEDFILE}
+_BLNK_UNTRANSFORM_SED+= -f ${_BLNK_UNTRANSFORM_SEDFILE}
+
+# UNBUILDLINK_PATTERNS and UNBUILDLINK_FILES list shell globs and files
+# relative to ${WRKSRC} that need to have reference to ${BUILDLINK_DIR}
+# stripped out of them.
+#
+UNBUILDLINK_PATTERNS?= # empty
+_UNBUILDLINK_PATTERNS= ${UNBUILDLINK_PATTERNS}
+_UNBUILDLINK_PATTERNS+= *-config
+_UNBUILDLINK_PATTERNS+= *Conf.sh
+_UNBUILDLINK_PATTERNS+= *.pc
+_UNBUILDLINK_PATTERNS_FIND= \
+ \( ${_UNBUILDLINK_PATTERNS:S/$/!/:S/^/-o -name !/:S/!/"/g:S/-o//1} \)
+UNBUILDLINK_FILES?= # empty
+_UNBUILDLINK_FILES= \
+ ${UNBUILDLINK_FILES} \
+ `${FIND} . ${_UNBUILDLINK_PATTERNS_FIND} -print | ${SED} -e 's|^\./||' | ${SORT} -u`
+#
+# When "unbuildlinkifying" a file, we must remove references to the
+# buildlink directories and change any -llib to the proper replacement
+# libraries (-lreadline -> -ledit, etc.). Redundant -Idir and -Ldir
+# options are removed to optimize the resulting file. Also, prefer the
+# .la files in ${LOCALBASE}/lib over the ones in ${DEPOTBASE}/*/lib when
+# creating new .la files. This makes "overwrite" packages look and feel
+# more like they would without the pkgviews integration.
+#
+UNBUILDLINK_SED?= # empty
+_UNBUILDLINK_SED= ${UNBUILDLINK_SED}
+_UNBUILDLINK_SED+= ${_BLNK_UNTRANSFORM_SED}
+
+SUBST_CLASSES+= unbuildlink
+SUBST_STAGE.unbuildlink= post-build
+SUBST_MESSAGE.unbuildlink= \
+ "Fixing buildlink references in files-to-be-installed."
+SUBST_FILES.unbuildlink= ${_UNBUILDLINK_FILES}
+SUBST_SED.unbuildlink= ${_UNBUILDLINK_SED}
+
+# Generate wrapper scripts for the compiler tools that sanitize the
+# argument list by converting references to ${LOCALBASE} and ${X11BASE}
+# into references to ${BUILDLINK_DIR} and ${BUILDLINK_X11_DIR}. These
+# wrapper scripts are to be used instead of the actual compiler tools when
+# building software.
+#
+# BUILDLINK_CC, BUILDLINK_LD, etc. are the full paths to the wrapper
+# scripts.
+#
+# ALIASES.CC, ALIASES.LD, etc. are the other names by which each wrapper
+# may be invoked.
+#
+_BLNK_WRAPPEES= AS CC CXX CPP LD
+.if defined(USE_FORTRAN)
+_BLNK_WRAPPEES+= FC
+.endif
+.if defined(USE_LIBTOOL)
+PKGLIBTOOL= ${BUILDLINK_LIBTOOL}
+PKGSHLIBTOOL= ${BUILDLINK_SHLIBTOOL}
+.endif
+_BLNK_WRAPPEES+= LIBTOOL SHLIBTOOL
+.if defined(USE_X11)
+IMAKE?= ${X11BASE}/bin/imake
+_BLNK_WRAPPEES+= IMAKE
+.endif
+_ALIASES.AS= as
+_ALIASES.CC= cc gcc
+_ALIASES.CXX= c++ g++ CC
+_ALIASES.CPP= cpp
+_ALIASES.FC= f77 g77
+_ALIASES.LD= ld
+
+# _BLNK_WRAP_*.<wrappee> variables represent "template methods" of the
+# wrapper script that may be customized per wrapper:
+#
+# _BLNK_WRAP_SETENV.<wrappee> resets the value of CC, CPP, etc. in the
+# configure and make environments (CONFIGURE_ENV, MAKE_ENV) so that
+# they point to the wrappers.
+#
+# _BLNK_WRAP_{*CACHE*,*LOGIC*}.<wrappee> are parts of the wrapper script
+# system as described in pkgsrc/mk/buildlink3/README. The files not
+# ending in "-trans" represent pieces of the wrapper script that may
+# be used to form a wrapper that doesn't translate its arguments,
+# and conversely for the files ending in "-trans". By default, all
+# wrappers use the "-trans" scripts.
+#
+# _BLNK_WRAP_ENV.<wrappee> consists of shell commands to export a shell
+# environment for the wrappee.
+#
+# _BLNK_WRAP_SANITIZE_PATH.<wrappee> sets the PATH for calling executables
+# from within the wrapper. By default, it removes the buildlink
+# directory from the PATH so that sub-invocations of compiler tools
+# will use the wrappees instead of the wrappers.
+#
+_BLNK_SANITIZED_PATH!= ${ECHO} ${PATH} | ${SED} \
+ -e "s|:${BUILDLINK_DIR}[^:]*||" -e "s|${BUILDLINK_DIR}[^:]*:||"
+_BLNK_WRAP_SANITIZE_PATH= PATH="${_BLNK_SANITIZED_PATH}"
+_BLNK_EMPTY_FILE?= ${BUILDLINK_DIR}/bin/.empty
+_BLNK_WRAP_ENV?= ${BUILDLINK_WRAPPER_ENV}
+_BLNK_WRAP_MARSHALL= ${BUILDLINK_DIR}/bin/.marshall
+_BLNK_WRAP_PRE_CACHE= ${BUILDLINK_DIR}/bin/.pre-cache
+_BLNK_WRAP_CACHE_ADD= ${BUILDLINK_DIR}/bin/.cache-add
+_BLNK_WRAP_CACHE= ${BUILDLINK_DIR}/bin/.cache
+_BLNK_WRAP_CACHE_ADD_TRANSFORM= ${BUILDLINK_DIR}/bin/.cache-add-trans
+_BLNK_WRAP_CACHE_TRANSFORM= ${BUILDLINK_DIR}/bin/.cache-trans
+_BLNK_WRAP_POST_CACHE= ${BUILDLINK_DIR}/bin/.post-cache
+_BLNK_WRAP_LOGIC= ${BUILDLINK_DIR}/bin/.logic
+_BLNK_WRAP_LOGIC_TRANSFORM= ${BUILDLINK_DIR}/bin/.logic-trans
+_BLNK_WRAP_LOG= ${WRKLOG}
+_BLNK_LIBTOOL_DO_INSTALL= ${BUILDLINK_DIR}/bin/.libtool-do-install
+_BLNK_LIBTOOL_FIX_LA= ${BUILDLINK_DIR}/bin/.libtool-fix-la
+_BLNK_FAKE_LA= ${BUILDLINK_DIR}/bin/.fake-la
+_BLNK_GEN_TRANSFORM= ${BUILDLINK_DIR}/bin/.gen-transform
+_BLNK_TRANSFORM_SEDFILE= ${BUILDLINK_DIR}/bin/.transform.sed
+_BLNK_UNTRANSFORM_SEDFILE= ${BUILDLINK_DIR}/bin/.untransform.sed
+
+.for _wrappee_ in ${_BLNK_WRAPPEES}
+#
+# _BLNK_WRAPPER_SH.<wrappee> points to the main wrapper script used to
+# generate the wrapper for the wrappee.
+#
+_BLNK_WRAPPER_SH.${_wrappee_}= ${.CURDIR}/../../mk/buildlink3/wrapper.sh
+_BLNK_WRAP_SETENV.${_wrappee_}= ${_wrappee_}="${BUILDLINK_${_wrappee_}:T}"
+_BLNK_WRAP_SANITIZE_PATH.${_wrappee_}= ${_BLNK_WRAP_SANITIZE_PATH}
+_BLNK_WRAP_EXTRA_FLAGS.${_wrappee_}= # empty
+_BLNK_WRAP_ENV.${_wrappee_}= ${_BLNK_WRAP_ENV}
+_BLNK_WRAP_MARSHALL.${_wrappee_}= ${_BLNK_WRAP_MARSHALL}
+_BLNK_WRAP_PRIVATE_PRE_CACHE.${_wrappee_}= ${_BLNK_EMPTY_FILE}
+_BLNK_WRAP_PRIVATE_CACHE_ADD.${_wrappee_}= ${_BLNK_EMPTY_FILE}
+_BLNK_WRAP_PRIVATE_CACHE.${_wrappee_}= ${_BLNK_EMPTY_FILE}
+_BLNK_WRAP_PRIVATE_POST_CACHE.${_wrappee_}= ${_BLNK_EMPTY_FILE}
+_BLNK_WRAP_CACHE_ADD.${_wrappee_}= ${_BLNK_WRAP_CACHE_ADD_TRANSFORM}
+_BLNK_WRAP_CACHE.${_wrappee_}= ${_BLNK_WRAP_CACHE_TRANSFORM}
+_BLNK_WRAP_LOGIC.${_wrappee_}= ${_BLNK_WRAP_LOGIC_TRANSFORM}
+_BLNK_WRAP_POST_LOGIC.${_wrappee_}= ${_BLNK_EMPTY_FILE}
+.endfor
+
+# Don't bother adding AS, CPP to the configure or make environments as
+# adding them seems to break some GNU configure scripts.
+#
+_BLNK_WRAP_SETENV.AS= # empty
+_BLNK_WRAP_SETENV.CPP= # empty
+
+# Also override any F77 value in the environment when compiling Fortran
+# code.
+#
+_BLNK_WRAP_SETENV.FC+= F77="${BUILDLINK_FC:T}"
+
+# Don't override the default LIBTOOL and SHLIBTOOL settings in the
+# environment, as they already correctly point to the correct values, and
+# don't sanitize the PATH because we want libtool to invoke the wrapper
+# scripts, too.
+#
+_BLNK_WRAP_SETENV.LIBTOOL= # empty
+_BLNK_WRAPPER_SH.LIBTOOL= ${.CURDIR}/../../mk/buildlink3/libtool.sh
+_BLNK_WRAP_SANITIZE_PATH.LIBTOOL= # empty
+#
+_BLNK_WRAP_SETENV.SHLIBTOOL= # empty
+_BLNK_WRAPPER_SH.SHLIBTOOL= ${.CURDIR}/../../mk/buildlink3/libtool.sh
+_BLNK_WRAP_SANITIZE_PATH.SHLIBTOOL= # empty
+
+# We need to "unbuildlinkify" any libtool archives.
+_BLNK_WRAP_LT_UNTRANSFORM_SED= ${_UNBUILDLINK_SED}
+
+.if defined(USE_SUNPRO)
+_BLNK_WRAP_PRIVATE_PRE_CACHE.CC= ${_BLNK_WRAP_PRE_CACHE}
+_BLNK_WRAP_PRIVATE_CACHE_ADD.CC= ${BUILDLINK_DIR}/bin/.sunpro-cc-cache-add
+_BLNK_WRAP_PRIVATE_CACHE.CC= ${BUILDLINK_DIR}/bin/.sunpro-cc-cache
+_BLNK_WRAP_PRIVATE_POST_CACHE.CC= ${BUILDLINK_DIR}/bin/.sunpro-cc-post-cache
+_BLNK_WRAP_POST_LOGIC.CC= ${BUILDLINK_DIR}/bin/.sunpro-cc-post-logic
+#
+# The SunPro C++ compiler wrapper shares cache information with the C
+# compiler.
+#
+_BLNK_WRAP_PRIVATE_PRE_CACHE.CXX= ${_BLNK_WRAP_PRE_CACHE}
+_BLNK_WRAP_PRIVATE_CACHE_ADD.CXX= ${BUILDLINK_DIR}/bin/.sunpro-cc-cache-add
+_BLNK_WRAP_PRIVATE_CACHE.CXX= ${BUILDLINK_DIR}/bin/.sunpro-cc-cache
+_BLNK_WRAP_PRIVATE_POST_CACHE.CXX= ${BUILDLINK_DIR}/bin/.sunpro-cc-post-cache
+_BLNK_WRAP_POST_LOGIC.CXX= ${BUILDLINK_DIR}/bin/.sunpro-cc-post-logic
+.endif # USE_SUNPRO
+
+_BLNK_WRAP_PRIVATE_PRE_CACHE.LD= ${_BLNK_WRAP_PRE_CACHE}
+_BLNK_WRAP_PRIVATE_CACHE_ADD.LD= ${BUILDLINK_DIR}/bin/.ld-cache-add
+_BLNK_WRAP_PRIVATE_CACHE.LD= ${BUILDLINK_DIR}/bin/.ld-cache
+_BLNK_WRAP_PRIVATE_POST_CACHE.LD= ${BUILDLINK_DIR}/bin/.ld-post-cache
+_BLNK_WRAP_POST_LOGIC.LD= ${BUILDLINK_DIR}/bin/.ld-post-logic
+
+_BLNK_WRAP_PRIVATE_PRE_CACHE.LIBTOOL= ${_BLNK_WRAP_PRE_CACHE}
+_BLNK_WRAP_PRIVATE_CACHE_ADD.LIBTOOL= ${BUILDLINK_DIR}/bin/.libtool-cache-add
+_BLNK_WRAP_PRIVATE_CACHE.LIBTOOL= ${BUILDLINK_DIR}/bin/.libtool-cache
+_BLNK_WRAP_PRIVATE_POST_CACHE.LIBTOOL= ${BUILDLINK_DIR}/bin/.libtool-post-cache
+_BLNK_WRAP_POST_LOGIC.LIBTOOL= ${BUILDLINK_DIR}/bin/.libtool-post-logic
+
+# shlibtool shares cache information with libtool.
+_BLNK_WRAP_PRIVATE_PRE_CACHE.SHLIBTOOL= ${_BLNK_WRAP_PRIVATE_PRE_CACHE.LIBTOOL}
+_BLNK_WRAP_PRIVATE_CACHE_ADD.SHLIBTOOL= ${_BLNK_WRAP_PRIVATE_CACHE_ADD.LIBTOOL}
+_BLNK_WRAP_PRIVATE_CACHE.SHLIBTOOL= ${_BLNK_WRAP_PRIVATE_CACHE.LIBTOOL}
+_BLNK_WRAP_PRIVATE_POST_CACHE.SHLIBTOOL= ${_BLNK_WRAP_PRIVATE_POST_CACHE.LIBTOOL}
+_BLNK_WRAP_POST_LOGIC.SHLIBTOOL= ${_BLNK_WRAP_POST_LOGIC.LIBTOOL}
+
+# Allow BUILDLINK_SETENV.<wrappee> to override _BLNK_WRAP_SETENV.<wrappee>.
+.for _wrappee_ in ${_BLNK_WRAPPEES}
+. if defined(BUILDLINK_SETENV.${_wrappee_})
+_BLNK_WRAP_SETENV.${_wrappee_}= ${BUILDLINK_SETENV.${_wrappee_}}
+. endif
+.endfor
+
+# Don't transform the arguments for imake, which uses the C preprocessor
+# to generate Makefiles, so that imake will find its config files.
+#
+.if defined(USE_X11)
+_BLNK_WRAP_CACHE_ADD.IMAKE= ${_BLNK_WRAP_CACHE_ADD}
+_BLNK_WRAP_CACHE.IMAKE= ${_BLNK_WRAP_CACHE}
+_BLNK_WRAP_LOGIC.IMAKE= ${_BLNK_WRAP_LOGIC}
+.endif
+
+# Silently pass the appropriate flags to the compiler/linker commands so
+# that headers and libraries in ${BUILDLINK_DIR}/{include,lib} are found
+# before the system headers and libraries.
+#
+_BLNK_CPPFLAGS= -I${BUILDLINK_DIR}/include
+_BLNK_LDFLAGS= -L${BUILDLINK_DIR}/lib
+_BLNK_WRAP_EXTRA_FLAGS.CC= ${_BLNK_CPPFLAGS} ${_BLNK_LDFLAGS}
+_BLNK_WRAP_EXTRA_FLAGS.CXX= ${_BLNK_CPPFLAGS} ${_BLNK_LDFLAGS}}
+_BLNK_WRAP_EXTRA_FLAGS.CPP= ${_BLNK_CPPFLAGS} ${_BLNK_LDFLAGS}
+_BLNK_WRAP_EXTRA_FLAGS.FC= ${_BLNK_CPPFLAGS} ${_BLNK_LDFLAGS}
+_BLNK_WRAP_EXTRA_FLAGS.LD= ${_BLNK_LDFLAGS}
+
+.PHONY: buildlink-wrappers
+
+buildlink-wrappers: ${_BLNK_LIBTOOL_DO_INSTALL}
+buildlink-wrappers: ${_BLNK_LIBTOOL_FIX_LA}
+
+.for _wrappee_ in ${_BLNK_WRAPPEES}
+CONFIGURE_ENV+= ${_BLNK_WRAP_SETENV.${_wrappee_}}
+MAKE_ENV+= ${_BLNK_WRAP_SETENV.${_wrappee_}}
+
+BUILDLINK_${_wrappee_}= \
+ ${BUILDLINK_DIR}/bin/${${_wrappee_}:T:C/^/_asdf_/1:M_asdf_*:S/^_asdf_//}
+
+# Filter to scrunch shell scripts by removing comments and empty lines.
+_BLNK_SH_CRUNCH_FILTER= \
+ ${GREP} -v "^\#[^!]" | ${GREP} -v "^[ ][ ]*\#" | \
+ ${GREP} -v "^\#$$" | ${GREP} -v "^[ ]*$$"
+
+_BLNK_WRAPPER_TRANSFORM_SED.${_wrappee_}= \
+ -e "s|@BUILDLINK_DIR@|${BUILDLINK_DIR}|g" \
+ -e "s|@BUILDLINK_SHELL@|${BUILDLINK_SHELL}|g" \
+ -e "s|@WRKDIR@|${WRKDIR}|g" \
+ -e "s|@WRKSRC@|${WRKSRC}|g" \
+ -e "s|@CAT@|${CAT:Q}|g" \
+ -e "s|@ECHO@|${ECHO:Q}|g" \
+ -e "s|@SED@|${SED:Q}|g" \
+ -e "s|@TEST@|${TEST:Q}|g" \
+ -e "s|@TOUCH@|${TOUCH:Q}|g" \
+ -e "s|@_BLNK_LIBTOOL_DO_INSTALL@|${_BLNK_LIBTOOL_DO_INSTALL:Q}|g" \
+ -e "s|@_BLNK_LIBTOOL_FIX_LA@|${_BLNK_LIBTOOL_FIX_LA:Q}|g" \
+ -e "s|@_BLNK_WRAP_LOG@|${_BLNK_WRAP_LOG:Q}|g" \
+ -e "s|@_BLNK_WRAP_EXTRA_FLAGS@|${_BLNK_WRAP_EXTRA_FLAGS.${_wrappee_}:Q}|g" \
+ -e "s|@_BLNK_WRAP_MARSHALL@|${_BLNK_WRAP_MARSHALL.${_wrappee_}:Q}|g" \
+ -e "s|@_BLNK_WRAP_PRIVATE_PRE_CACHE@|${_BLNK_WRAP_PRIVATE_PRE_CACHE.${_wrappee_}:Q}|g" \
+ -e "s|@_BLNK_WRAP_PRIVATE_CACHE_ADD@|${_BLNK_WRAP_PRIVATE_CACHE_ADD.${_wrappee_}:Q}|g" \
+ -e "s|@_BLNK_WRAP_PRIVATE_CACHE@|${_BLNK_WRAP_PRIVATE_CACHE.${_wrappee_}:Q}|g" \
+ -e "s|@_BLNK_WRAP_PRIVATE_POST_CACHE@|${_BLNK_WRAP_PRIVATE_POST_CACHE.${_wrappee_}:Q}|g" \
+ -e "s|@_BLNK_WRAP_PRE_CACHE@|${_BLNK_WRAP_PRE_CACHE:Q}|g" \
+ -e "s|@_BLNK_WRAP_CACHE_ADD@|${_BLNK_WRAP_CACHE_ADD.${_wrappee_}:Q}|g" \
+ -e "s|@_BLNK_WRAP_CACHE@|${_BLNK_WRAP_CACHE.${_wrappee_}:Q}|g" \
+ -e "s|@_BLNK_WRAP_POST_CACHE@|${_BLNK_WRAP_POST_CACHE:Q}|g" \
+ -e "s|@_BLNK_WRAP_LOGIC@|${_BLNK_WRAP_LOGIC.${_wrappee_}:Q}|g" \
+ -e "s|@_BLNK_WRAP_POST_LOGIC@|${_BLNK_WRAP_POST_LOGIC.${_wrappee_}:Q}|g" \
+ -e "s|@_BLNK_WRAP_ENV@|${_BLNK_WRAP_ENV.${_wrappee_}:Q}|g" \
+ -e "s|@_BLNK_WRAP_SANITIZE_PATH@|${_BLNK_WRAP_SANITIZE_PATH.${_wrappee_}:Q}|g"
+
+buildlink-wrappers: ${BUILDLINK_${_wrappee_}}
+.if !target(${BUILDLINK_${_wrappee_}})
+${BUILDLINK_${_wrappee_}}: \
+ ${_BLNK_WRAPPER_SH.${_wrappee_}} \
+ ${_BLNK_WRAP_MARSHALL.${_wrappee_}} \
+ ${_BLNK_WRAP_PRIVATE_CACHE.${_wrappee_}} \
+ ${_BLNK_WRAP_CACHE.${_wrappee_}} \
+ ${_BLNK_WRAP_LOGIC.${_wrappee_}} \
+ ${_BLNK_WRAP_POST_LOGIC.${_wrappee_}}
+ ${_PKG_SILENT}${_PKG_DEBUG}${ECHO_BUILDLINK_MSG} \
+ "=> Creating wrapper: ${.TARGET}"
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ wrappee="${${_wrappee_}:C/^/_asdf_/1:M_asdf_*:S/^_asdf_//}"; \
+ case $${wrappee} in \
+ /*) absdir=; \
+ ;; \
+ *) OLDIFS="$$IFS"; \
+ IFS=":"; \
+ for dir in $${PATH}; do \
+ case $${dir} in \
+ *${BUILDLINK_DIR}*) \
+ ;; \
+ *) if [ -f $${dir}/$${wrappee} ] || \
+ [ -h $${dir}/$${wrappee} ] && \
+ [ -x $${dir}/$${wrappee} ]; then \
+ absdir=$${dir}/; \
+ wrappee=$${absdir}$${wrappee}; \
+ break; \
+ fi; \
+ ;; \
+ esac; \
+ done; \
+ IFS="$$OLDIFS"; \
+ if [ ! -x "$${wrappee}" ]; then \
+ ${ECHO_MSG} "Unable to create \"$${wrappee}\" wrapper script: no such file"; \
+ exit 1; \
+ fi; \
+ ;; \
+ esac; \
+ ${MKDIR} ${.TARGET:H}; \
+ ${CAT} ${_BLNK_WRAPPER_SH.${_wrappee_}} | \
+ ${SED} ${_BLNK_WRAPPER_TRANSFORM_SED.${_wrappee_}} \
+ -e "s|@WRAPPEE@|$${absdir}${${_wrappee_}:Q}|g" | \
+ ${_BLNK_SH_CRUNCH_FILTER} \
+ > ${.TARGET}; \
+ ${CHMOD} +x ${.TARGET}
+.endif
+
+. for _alias_ in ${_ALIASES.${_wrappee_}:S/^/${BUILDLINK_DIR}\/bin\//}
+. if !target(${_alias_})
+buildlink-wrappers: ${_alias_}
+${_alias_}: ${BUILDLINK_${_wrappee_}}
+ ${_PKG_SILENT}${_PKG_DEBUG}${ECHO_BUILDLINK_MSG} \
+ "=> Linking wrapper: ${.TARGET}"
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG}${LN} -f ${BUILDLINK_${_wrappee_}} ${.TARGET}
+. endif
+. endfor # _alias_
+.endfor # _wrappee_
+
+# Allow BUILDLINK_ENV to override shell environment settings in
+# ${CONFIGURE_ENV} and in ${MAKE_ENV} for the configure and build processes,
+# respectively.
+#
+CONFIGURE_ENV+= ${BUILDLINK_ENV}
+MAKE_ENV+= ${BUILDLINK_ENV}
+
+# OS-specific overrides for buildlink3 wrappers
+#
+.if defined(USE_SUNPRO)
+_BLNK_WRAPPEES.SunOS?= CC CXX
+SUNWSPROBASE?= /opt/SUNWspro
+CC.SunOS?= ${SUNWSPROBASE}/bin/cc
+CXX.SunOS?= ${SUNWSPROBASE}/bin/CC
+.endif
+
+.PHONY: buildlink-${_BLNK_OPSYS}-wrappers
+buildlink-${_BLNK_OPSYS}-wrappers: buildlink-wrappers
+.for _wrappee_ in ${_BLNK_WRAPPEES.${_BLNK_OPSYS}}
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ if [ -x "${${_wrappee_}.${_BLNK_OPSYS}}" ]; then \
+ wrapper="${BUILDLINK_DIR}/bin/${${_wrappee_}.${_BLNK_OPSYS}:T}"; \
+ ${ECHO_BUILDLINK_MSG} \
+ "=> Creating ${_BLNK_OPSYS} wrapper: $${wrapper}"; \
+ ${RM} -f $${wrapper}; \
+ ${CAT} ${_BLNK_WRAPPER_SH.${_wrappee_}} | \
+ ${SED} ${_BLNK_WRAPPER_TRANSFORM_SED.${_wrappee_}} \
+ -e "s|@WRAPPEE@|${${_wrappee_}.${_BLNK_OPSYS}}|g" | \
+ ${_BLNK_SH_CRUNCH_FILTER} \
+ > $${wrapper}; \
+ ${CHMOD} +x $${wrapper}; \
+ for file in ${_ALIASES.${_wrappee_}:S/^/${BUILDLINK_DIR}\/bin\//}; do \
+ if [ "$${file}" != "$${wrappee}" ]; then \
+ ${TOUCH} $${file}; \
+ fi; \
+ done; \
+ fi
+.endfor
+
+${_BLNK_EMPTY_FILE}:
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG}${TOUCH} ${TOUCH_ARGS} ${.TARGET}
+
+${_BLNK_WRAP_MARSHALL}: ${.CURDIR}/../../mk/buildlink3/marshall
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG}${CAT} ${.ALLSRC} \
+ | ${_BLNK_SH_CRUNCH_FILTER} > ${.TARGET}
+
+.for _wrappee_ in ${_BLNK_WRAPPEES}
+. if !target(${_BLNK_WRAP_PRIVATE_CACHE_ADD.${_wrappee_}})
+${_BLNK_WRAP_PRIVATE_CACHE_ADD.${_wrappee_}}:
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG}${TOUCH} ${TOUCH_ARGS} ${.TARGET}
+. endif
+. if !target(${_BLNK_WRAP_PRIVATE_CACHE.${_wrappee_}})
+${_BLNK_WRAP_PRIVATE_CACHE.${_wrappee_}}: \
+ ${_BLNK_WRAP_PRIVATE_PRE_CACHE.${_wrappee_}} \
+ ${_BLNK_WRAP_PRIVATE_CACHE_ADD.${_wrappee_}} \
+ ${_BLNK_WRAP_PRIVATE_POST_CACHE.${_wrappee_}}
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG}${CAT} ${.ALLSRC} \
+ | ${_BLNK_SH_CRUNCH_FILTER} > ${.TARGET}.tmp
+ ${_PKG_SILENT}${_PKG_DEBUG}${MV} -f ${.TARGET}.tmp ${.TARGET}
+. endif
+.endfor
+
+${_BLNK_WRAP_PRIVATE_POST_CACHE.LD}: \
+ ${.CURDIR}/../../mk/buildlink3/ld-post-cache
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG}${CAT} ${.ALLSRC} \
+ | ${_BLNK_SH_CRUNCH_FILTER} > ${.TARGET}
+
+${_BLNK_WRAP_PRIVATE_POST_CACHE.LIBTOOL}: \
+ ${.CURDIR}/../../mk/buildlink3/libtool-post-cache
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG}${CAT} ${.ALLSRC} \
+ | ${_BLNK_SH_CRUNCH_FILTER} > ${.TARGET}
+
+${_BLNK_WRAP_PRE_CACHE}: ${.CURDIR}/../../mk/buildlink3/pre-cache
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG}${CAT} ${.ALLSRC} \
+ | ${_BLNK_SH_CRUNCH_FILTER} > ${.TARGET}
+
+${_BLNK_WRAP_CACHE_ADD}:
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG}${TOUCH} ${TOUCH_ARGS} ${.TARGET}
+
+${_BLNK_WRAP_CACHE}: \
+ ${_BLNK_WRAP_PRE_CACHE} \
+ ${_BLNK_WRAP_CACHE_ADD} \
+ ${_BLNK_WRAP_POST_CACHE}
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG}${CAT} ${.ALLSRC} \
+ | ${_BLNK_SH_CRUNCH_FILTER} > ${.TARGET}.tmp
+ ${_PKG_SILENT}${_PKG_DEBUG}${MV} -f ${.TARGET}.tmp ${.TARGET}
+
+${_BLNK_WRAP_CACHE_TRANSFORM}: \
+ ${_BLNK_WRAP_PRE_CACHE} \
+ ${_BLNK_WRAP_CACHE_ADD_TRANSFORM} \
+ ${_BLNK_WRAP_POST_CACHE}
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG}${CAT} ${.ALLSRC} \
+ | ${_BLNK_SH_CRUNCH_FILTER} > ${.TARGET}.tmp
+ ${_PKG_SILENT}${_PKG_DEBUG}${MV} -f ${.TARGET}.tmp ${.TARGET}
+
+${_BLNK_WRAP_POST_CACHE}: ${.CURDIR}/../../mk/buildlink3/post-cache
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG}${CAT} ${.ALLSRC} \
+ | ${_BLNK_SH_CRUNCH_FILTER} > ${.TARGET}
+
+${_BLNK_WRAP_LOGIC}: ${.CURDIR}/../../mk/buildlink3/logic
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG}${SED} \
+ -e "s|@LOCALBASE@|${LOCALBASE}|g" \
+ -e "s|@X11BASE@|${X11BASE}|g" \
+ -e 's|@_BLNK_TRANSFORM_SED@||g' \
+ ${.ALLSRC} | ${_BLNK_SH_CRUNCH_FILTER} > ${.TARGET}.tmp
+ ${_PKG_SILENT}${_PKG_DEBUG}${MV} -f ${.TARGET}.tmp ${.TARGET}
+
+${_BLNK_WRAP_LOGIC_TRANSFORM}: \
+ ${.CURDIR}/../../mk/buildlink3/logic \
+ ${_BLNK_TRANSFORM_SEDFILE}
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG}${SED} \
+ -e "s|@LOCALBASE@|${LOCALBASE}|g" \
+ -e "s|@X11BASE@|${X11BASE}|g" \
+ -e 's|@_BLNK_TRANSFORM_SED@|${_BLNK_TRANSFORM_SED:Q}|g' \
+ ${.CURDIR}/../../mk/buildlink3/logic \
+ | ${_BLNK_SH_CRUNCH_FILTER} > ${.TARGET}.tmp
+ ${_PKG_SILENT}${_PKG_DEBUG}${MV} -f ${.TARGET}.tmp ${.TARGET}
+
+${_BLNK_WRAP_POST_LOGIC.LD}: ${.CURDIR}/../../mk/buildlink3/ld-post-logic
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG}${CAT} ${.ALLSRC} \
+ | ${_BLNK_SH_CRUNCH_FILTER} > ${.TARGET}
+
+${_BLNK_WRAP_POST_LOGIC.LIBTOOL}: \
+ ${.CURDIR}/../../mk/buildlink3/libtool-post-logic
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG}${CAT} ${.ALLSRC} \
+ | ${_BLNK_SH_CRUNCH_FILTER} > ${.TARGET}
+
+${_BLNK_LIBTOOL_DO_INSTALL}: ${.CURDIR}/../../mk/buildlink3/libtool-do-install
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG}${CAT} ${.ALLSRC} \
+ | ${_BLNK_SH_CRUNCH_FILTER} > ${.TARGET}
+
+${_BLNK_LIBTOOL_FIX_LA}: \
+ ${.CURDIR}/../../mk/buildlink3/libtool-fix-la \
+ ${_BLNK_UNTRANSFORM_SEDFILE}
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG}${SED} \
+ -e "s|@LOCALBASE@|${LOCALBASE}|g" \
+ -e "s|@DEPOTBASE@|${DEPOTBASE}|g" \
+ -e "s|@WRKSRC@|${WRKSRC}|g" \
+ -e "s|@BASENAME@|${BASENAME:Q}|g" \
+ -e "s|@CP@|${CP:Q}|g" \
+ -e "s|@DIRNAME@|${DIRNAME:Q}|g" \
+ -e "s|@EGREP@|${EGREP:Q}|g" \
+ -e "s|@MV@|${MV:Q}|g" \
+ -e "s|@RM@|${RM:Q}|g" \
+ -e "s|@SED@|${SED:Q}|g" \
+ -e "s|@TOUCH@|${TOUCH:Q}|g" \
+ -e 's|@_BLNK_WRAP_LT_UNTRANSFORM_SED@|${_BLNK_WRAP_LT_UNTRANSFORM_SED:Q}|g' \
+ ${.CURDIR}/../../mk/buildlink3/libtool-fix-la \
+ | ${_BLNK_SH_CRUNCH_FILTER} > ${.TARGET}.tmp
+ ${_PKG_SILENT}${_PKG_DEBUG}${MV} -f ${.TARGET}.tmp ${.TARGET}
+
+# Seed the common transforming cache with obvious values that greatly
+# speed up the wrappers.
+#
+_BLNK_RPATH_FLAGS= ${RPATH_FLAG}
+_BLNK_RPATH_FLAGS+= -Wl,${RPATH_FLAG}
+.for _rflag_ in \
+ -Wl,-R -Wl,-rpath, -Wl,--rpath, -Wl,-rpath-link, -Wl,--rpath-link
+. if empty(_BLNK_RPATH_FLAGS:M${_rflag_})
+_BLNK_RPATH_FLAGS+= ${_rflag_}
+. endif
+.endfor
+#
+.if !empty(_BLNK_SEED_CACHE:Mpassthru)
+#
+# Pass through all single letter options, because we don't touch those.
+#
+_BLNK_CACHE_PASSTHRU_GLOB= -?
+#
+# Directories in the ${WRKDIR} should all be allowed in -[IL]<dir>
+_BLNK_CACHE_PASSTHRU_GLOB+= -[IL]${WRKDIR}*|-[IL]${BUILDLINK_DIR}*
+#
+# Directories relative to the srcdir should be allowed in -[IL]<dir>
+_BLNK_CACHE_PASSTHRU_GLOB+= -[IL].|-[IL]./*|-[IL]..*|-[IL][!/]*
+#
+# Allow the depot directories for packages for which we need to find
+# headers and libraries for both -[IL]<dir>.
+#
+. for _pkg_ in ${BUILDLINK_PACKAGES}
+. if !empty(BUILDLINK_IS_DEPOT.${_pkg_}:M[yY][eE][sS])
+_BLNK_CACHE_PASSTHRU_GLOB+= -[IL]${BUILDLINK_PREFIX.${_pkg_}}/*
+. endif
+. endfor
+#
+# Allow all subdirs of ${_BLNK_ALLOWED_RPATHDIRS} to be in the runtime
+# library search path.
+#
+. if ${_USE_RPATH} == "yes"
+. for _dir_ in ${_BLNK_ALLOWED_RPATHDIRS}
+. for _R_ in ${_BLNK_RPATH_FLAGS}
+_BLNK_CACHE_PASSTHRU_GLOB+= ${_R_}${_dir_}|${_R_}${_dir_}/*
+. endfor
+. endfor
+. endif
+.endif # _BLNK_SEED_CACHE has "passthru"
+
+.if !empty(_BLNK_SEED_CACHE:Mblock)
+#
+# Block all other absolute paths (we handle the ${X11BASE} case below).
+#
+_BLNK_CACHE_BLOCK_GLOB= -[IL]/*
+. if ${_USE_RPATH} == "yes"
+. for _R_ in ${_BLNK_RPATH_FLAGS}
+_BLNK_CACHE_BLOCK_GLOB:= ${_BLNK_CACHE_BLOCK_GLOB}|${_R_}/*
+. endfor
+. endif
+.endif # _BLNK_SEED_CACHE has "block"
+
+${_BLNK_WRAP_CACHE_ADD_TRANSFORM}:
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG}${RM} -f ${.TARGET}
+ ${_PKG_SILENT}${_PKG_DEBUG}${TOUCH} ${.TARGET}
+.if !empty(_BLNK_SEED_CACHE)
+. if !empty(_BLNK_SEED_CACHE:Mpassthru)
+. for _glob_ in ${_BLNK_CACHE_PASSTHRU_GLOB}
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ( ${ECHO} "${_glob_})"; \
+ ${ECHO} " cachehit=yes"; \
+ ${ECHO} " ;;"; \
+ ) >> ${.TARGET}
+. endfor
+. endif # _BLNK_SEED_CACHE has "passthru"
+. if !empty(_BLNK_SEED_CACHE:Mtransform)
+. if ${PKG_INSTALLATION_TYPE} == "overwrite"
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ( ${ECHO} "-I${DEPOTBASE}/*)"; \
+ ${ECHO} " arg=\"-I${BUILDLINK_DIR}/\$${arg#-I${DEPOTBASE}/[!/]*/}\""; \
+ ${ECHO} " cachehit=yes"; \
+ ${ECHO} " ;;"; \
+ ) >> ${.TARGET}
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ( ${ECHO} "-L${DEPOTBASE}/*)"; \
+ ${ECHO} " arg=\"-L${BUILDLINK_DIR}/\$${arg#-I${DEPOTBASE}/[!/]*/}\""; \
+ ${ECHO} " cachehit=yes"; \
+ ${ECHO} " ;;"; \
+ ) >> ${.TARGET}
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ( ${ECHO} "-I${LOCALBASE}/*)"; \
+ ${ECHO} " arg=\"-I${BUILDLINK_DIR}/\$${arg#-I${LOCALBASE}/}\""; \
+ ${ECHO} " cachehit=yes"; \
+ ${ECHO} " ;;"; \
+ ) >> ${.TARGET}
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ( ${ECHO} "-L${LOCALBASE}/*)"; \
+ ${ECHO} " arg=\"-L${BUILDLINK_DIR}/\$${arg#-L${LOCALBASE}/}\""; \
+ ${ECHO} " cachehit=yes"; \
+ ${ECHO} " ;;"; \
+ ) >> ${.TARGET}
+. endif
+. if defined(USE_X11)
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ( ${ECHO} "-I${X11BASE}/*)"; \
+ ${ECHO} " arg=\"-I${BUILDLINK_X11_DIR}/\$${arg#-I${X11BASE}/}\""; \
+ ${ECHO} " cachehit=yes"; \
+ ${ECHO} " ;;"; \
+ ) >> ${.TARGET}
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ( ${ECHO} "-L${X11BASE}/*)"; \
+ ${ECHO} " arg=\"-L${BUILDLINK_X11_DIR}/\$${arg#-L${X11BASE}/}\""; \
+ ${ECHO} " cachehit=yes"; \
+ ${ECHO} " ;;"; \
+ ) >> ${.TARGET}
+. endif
+. endif # _BLNK_SEED_CACHE has "transform"
+. if !empty(_BLNK_SEED_CACHE:Mblock)
+. for _glob_ in ${_BLNK_CACHE_BLOCK_GLOB}
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ ( ${ECHO} "${_glob_})"; \
+ ${ECHO} " arg=; cachehit=yes;"; \
+ ${ECHO} " ;;"; \
+ ) >> ${.TARGET}
+. endfor
+. endif # _BLNK_SEED_CACHE has "block"
+.endif # _BLNK_SEED_CACHE
+
+${_BLNK_GEN_TRANSFORM}: ${.CURDIR}/../../mk/buildlink3/gen-transform.sh
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG}${SED} \
+ -e "s|@_BLNK_TRANSFORM_SEDFILE@|${_BLNK_TRANSFORM_SEDFILE:Q}|g" \
+ -e "s|@_BLNK_UNTRANSFORM_SEDFILE@|${_BLNK_UNTRANSFORM_SEDFILE:Q}|g" \
+ -e "s|@_COMPILER_LD_FLAG@|${_COMPILER_LD_FLAG:Q}|g" \
+ -e "s|@_OPSYS_RPATH_NAME@|${_OPSYS_RPATH_NAME:Q}|g" \
+ -e "s|@BUILDLINK_SHELL@|${BUILDLINK_SHELL:Q}|g" \
+ -e "s|@CAT@|${CAT:Q}|g" \
+ ${.ALLSRC} > ${.TARGET}.tmp
+ ${_PKG_SILENT}${_PKG_DEBUG}${CHMOD} +x ${.TARGET}.tmp
+ ${_PKG_SILENT}${_PKG_DEBUG}${MV} -f ${.TARGET}.tmp ${.TARGET}
+
+${_BLNK_TRANSFORM_SEDFILE} ${_BLNK_UNTRANSFORM_SEDFILE}: ${_BLNK_GEN_TRANSFORM}
+ ${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${.TARGET:H}
+ ${_PKG_SILENT}${_PKG_DEBUG}${_BLNK_GEN_TRANSFORM} \
+ ${_BLNK_TRANSFORM}
diff --git a/mk/buildlink3/gen-transform.sh b/mk/buildlink3/gen-transform.sh
new file mode 100644
index 00000000000..61c32222344
--- /dev/null
+++ b/mk/buildlink3/gen-transform.sh
@@ -0,0 +1,223 @@
+#!@BUILDLINK_SHELL@
+#
+# $NetBSD: gen-transform.sh,v 1.2 2003/09/02 06:59:54 jlam Exp $
+
+transform="@_BLNK_TRANSFORM_SEDFILE@"
+untransform="@_BLNK_UNTRANSFORM_SEDFILE@"
+
+# Mini-language for translating wrapper arguments into their buildlink
+# equivalents:
+#
+# mangle:src:dst mangles the directory "src" into "dst"
+# rpath:src:dst translates the directory "src" into "dst"
+# in rpath options
+# no-rpath removes "-R*", "-Wl,-R", and "-Wl,-rpath,*"
+# depot:src:dst translates "src/<dir>/" into "dst/"
+# I:src:dst translates "-Isrc" into "-Idst"
+# L:src:dst translates "-Lsrc" into "-Ldst"
+# l:foo:bar translates "-lfoo" into "-lbar"
+# P:src:dst translates "src/libfoo.{a,la}" into
+# "dst/libfoo.{a,la}"
+# p:path translates "path/*/libfoo.so" into
+# "-Lpath/* -lfoo"
+# r:dir removes "dir" and "dir/*"
+# S:foo:bar translates word "foo" into "bar"
+# s:foo:bar translates "foo" into "bar"
+#
+# Some transformations only make sense in one direction, so if a command
+# is prefixed with either "transform:" or "untransform:", then the
+# resulting sed commands are only appended the the corresponding sedfile.
+
+gen() {
+ action=$1; shift
+ case "$action" in
+ transform) sedfile="$transform" ;;
+ untransform) sedfile="$untransform" ;;
+ esac
+ save_IFS="${IFS}"; IFS=":"
+ set -- $1
+ IFS="${save_IFS}"
+ case "$1" in
+ mangle)
+ case "$action" in
+ transform|untransform)
+ @CAT@ >> $sedfile << EOF
+s|$2\([/ \`"':;]\)|$3\1|g
+s|$2$|$3|g
+EOF
+ ;;
+ esac
+ ;;
+ rpath)
+ gen $action mangle:-Wl,--rpath-link,$2:-Wl,--rpath-link,$3
+ gen $action mangle:-Wl,--rpath,$2:-Wl,--rpath,$3
+ gen $action mangle:-Wl,-rpath-link,$2:-Wl,-rpath-link,$3
+ gen $action mangle:-Wl,-rpath,$2:-Wl,-rpath,$3
+ gen $action mangle:-Wl,-R$2:-Wl,-R$3
+ gen $action mangle:-R$2:-R$3
+ ;;
+ no-rpath)
+ gen $action _r:-Wl,--rpath-link,
+ gen $action _r:-Wl,--rpath,
+ gen $action _r:-Wl,-rpath-link,
+ gen $action _r:-Wl,-rpath,
+ gen $action _r:-Wl,-R
+ gen $action _r:-R
+ ;;
+ depot)
+ case "$action" in
+ transform|untransform)
+ @CAT@ >> $sedfile << EOF
+s|$2/[^/ \`"':;]*\(/[^ \`"':;]\)|$3\1|g
+s|$2/[^/ \`"':;]*$|$3|g
+EOF
+ ;;
+ esac
+ ;;
+ I|L)
+ case "$action" in
+ transform)
+ @CAT@ >> $sedfile << EOF
+s|-$1$2\([ \`"':;]\)$|-$1$3\1|g
+s|-$1$2$|-$1$3|g
+s|-$1$2/|-$1$3/|g
+EOF
+ ;;
+ untransform)
+ @CAT@ >> $sedfile << EOF
+s|-$1$3\([ \`"':;]\)$|-$1$2\1|g
+s|-$1$3$|-$1$2|g
+s|-$1$3/|-$1$2/|g
+EOF
+ ;;
+ esac
+ ;;
+ l)
+ case "$action" in
+ transform|untransform)
+ @CAT@ >> $sedfile << EOF
+s|-$1$2\([ "';;]\)|-$1$3\1|g
+s|-$1$2$|-$1$3|g
+s|-$1$2/|-$1$3/|g
+EOF
+ ;;
+ esac
+ ;;
+ P)
+ case "$action" in
+ transform)
+ @CAT@ >> $sedfile << EOF
+s|$2\(/[^ \`"':;]*/lib[^/ \`"':;]*\.la\)\([ \`"':;]\)|$3\1\2|g
+s|$2\(/[^ \`"':;]*/lib[^/ \`"':;]*\.la\)$|$3\1|g
+s|$2\(/[^ \`"':;]*/lib[^/ \`"':;]*\.a\)\([ \`"':;]\)|$3\1\2|g
+s|$2\(/[^ \`"':;]*/lib[^/ \`"':;]*\.a\)$|$3\1|g
+EOF
+ ;;
+ untransform)
+ @CAT@ >> $sedfile << EOF
+s|$3\(/[^ \`"':;]*/lib[^/ \`"':;]*\.a\)\([ \`"':;]\)|$2\1\2|g
+s|$3\(/[^ \`"':;]*/lib[^/ \`"':;]*\.a\)$|$2\1|g
+s|$3\(/[^ \`"':;]*/lib[^/ \`"':;]*\.la\)\([ \`"':;]\)|$2\1\2|g
+s|$3\(/[^ \`"':;]*/lib[^/ \`"':;]*\.la\)$|$2\1|g
+EOF
+ ;;
+ esac
+ ;;
+ p)
+ case "$action" in
+ transform|untransform)
+ @CAT@ >> $sedfile << EOF
+s|\($2/[^ \`"':;]*\)/lib\([^/ \`"':;]*\)\.so\.[0-9]*\.[0-9]*\.[0-9]*|-L\1 -l\2|g
+s|\($2\)/lib\([^/ \`"':;]*\)\.so\.[0-9]*\.[0-9]*\.[0-9]*|-L\1 -l\2|g
+s|\($2/[^ \`"':;]*\)/lib\([^/ \`"':;]*\)\.so\.[0-9]*\.[0-9]*|-L\1 -l\2|g
+s|\($2\)/lib\([^/ \`"':;]*\)\.so\.[0-9]*\.[0-9]*|-L\1 -l\2|g
+s|\($2/[^ \`"':;]*\)/lib\([^/ \`"':;]*\)\.so\.[0-9]*|-L\1 -l\2|g
+s|\($2\)/lib\([^/ \`"':;]*\)\.so\.[0-9]*|-L\1 -l\2|g
+s|\($2/[^ \`"':;]*\)/lib\([^/ \`"':;]*\)\.so|-L\1 -l\2|g
+s|\($2\)/lib\([^/ \`"':;]*\)\.so|-L\1 -l\2|g
+s|\($2/[^ \`"':;]*\)/lib\([^/ \`"':;]*\)\.[0-9]*\.[0-9]*\.[0-9]*\.dylib|-L\1 -l\2|g
+s|\($2\)/lib\([^/ \`"':;]*\)\.[0-9]*\.[0-9]*\.[0-9]*\.dylib|-L\1 -l\2|g
+s|\($2/[^ \`"':;]*\)/lib\([^/ \`"':;]*\)\.[0-9]*\.[0-9]*\.dylib|-L\1 -l\2|g
+s|\($2\)/lib\([^/ \`"':;]*\)\.[0-9]*\.[0-9]*\.dylib|-L\1 -l\2|g
+s|\($2/[^ \`"':;]*\)/lib\([^/ \`"':;]*\)\.[0-9]*\.dylib|-L\1 -l\2|g
+s|\($2\)/lib\([^/ \`"':;]*\)\.[0-9]*\.dylib|-L\1 -l\2|g
+s|\($2/[^ \`"':;]*\)/lib\([^/ \`"':;]*\)\.dylib|-L\1 -l\2|g
+s|\($2\)/lib\([^/ \`"':;]*\)\.dylib|-L\1 -l\2|g
+EOF
+ ;;
+ esac
+ ;;
+ __r)
+ case "$action" in
+ transform|untransform)
+ @CAT@ >> $sedfile << EOF
+s|$2/[^ \`"':;]*||g
+EOF
+ ;;
+ esac
+ ;;
+ _r)
+ case "$action" in
+ transform|untransform)
+ @CAT@ >> $sedfile << EOF
+s|$2\([ \`"':;]\)|\1|g
+s|$2$||g
+s|$2/[^ \`"':;]*||g
+EOF
+ ;;
+ esac
+ ;;
+ r)
+ case "$2" in
+ "") r=__r ;;
+ *) r=_r ;;
+ esac
+ gen $action $r:-I$2
+ gen $action $r:-L$2
+ gen $action $r:-Wl,--rpath-link,$2
+ gen $action $r:-Wl,--rpath,$2
+ gen $action $r:-Wl,-rpath-link,$2
+ gen $action $r:-Wl,-rpath,$2
+ gen $action $r:-Wl,-R$2
+ gen $action $r:-R$2
+ ;;
+ S)
+ case "$action" in
+ transform|untransform)
+ @CAT@ >> $sedfile << EOF
+s|$2\([ \`"':;]\)|$3\1|g
+s|$2$|$3|g
+EOF
+ ;;
+ esac
+ ;;
+ s)
+ case "$action" in
+ transform|untransform)
+ @CAT@ >> $sedfile << EOF
+s|$2|$3|g
+EOF
+ ;;
+ esac
+ ;;
+ *)
+ echo "Unknown arg: $arg" 1>&2
+ exit 1
+ ;;
+ esac
+}
+
+for arg; do
+ case $arg in
+ transform:*)
+ gen transform "${arg#transform:}"
+ ;;
+ untransform:*)
+ gen untransform "${arg#untransform:}"
+ ;;
+ *)
+ gen transform "$arg"
+ gen untransform "$arg"
+ ;;
+ esac
+done
diff --git a/mk/buildlink3/ld-post-cache b/mk/buildlink3/ld-post-cache
new file mode 100644
index 00000000000..2e7c8eab3f6
--- /dev/null
+++ b/mk/buildlink3/ld-post-cache
@@ -0,0 +1,11 @@
+# $NetBSD: ld-post-cache,v 1.2 2003/09/02 06:59:55 jlam Exp $
+#
+# This file implements the default action of the "ld" private cache,
+# and tells the wrapper to skip the common cache lookup for all
+# arguments that start with "-Wl,"; they will instead be handled
+# directly by ld-post-logic.
+#
+-Wl,*)
+ skipcache=yes
+ ;;
+esac
diff --git a/mk/buildlink3/ld-post-logic b/mk/buildlink3/ld-post-logic
new file mode 100644
index 00000000000..c784a3fb4eb
--- /dev/null
+++ b/mk/buildlink3/ld-post-logic
@@ -0,0 +1,14 @@
+# $NetBSD: ld-post-logic,v 1.2 2003/09/02 06:59:55 jlam Exp $
+#
+# Strip the "-Wl," from arguments that start with that prefix and add
+# the result to the "ld" private cache (which is read before the
+# common cache). This makes "ld" silently accept "-Wl,*" arguments,
+# which are often a part of the LDFLAGS setting in pkgsrc, and allows
+# such LDFLAGS to be shared between the compiler and the linker.
+#
+case $arg in
+-Wl,*)
+ arg=`$echo "X$arg" | $Xsed -e "s|^-Wl,||g" -e "s|,| |g"`
+ addtoprivatecache=yes
+ ;;
+esac
diff --git a/mk/buildlink3/libtool-do-install b/mk/buildlink3/libtool-do-install
new file mode 100644
index 00000000000..dc851a5e339
--- /dev/null
+++ b/mk/buildlink3/libtool-do-install
@@ -0,0 +1,25 @@
+# $NetBSD: libtool-do-install,v 1.2 2003/09/02 06:59:56 jlam Exp $
+#
+# This file is called directly by the libtool wrapper when it has
+# figured out that the libtool invocation is meant to do a file
+# installation. We simply quote the remaining command-line arguments
+# properly to build a correct libtool command line. The libtool
+# wrapper will perform the actual execution. We don't worry about
+# caching or speed, since installation is not a bottleneck for package
+# creation.
+
+cmd="$cmd $arg"
+while $test $# -gt 0; do
+ arg="$1"; shift
+ case $arg in
+ *[\`\"\$\\]*)
+ arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
+ ;;
+ esac
+ case $arg in
+ *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
+ arg="\"$arg\""
+ ;;
+ esac
+ cmd="$cmd $arg"
+done
diff --git a/mk/buildlink3/libtool-fix-la b/mk/buildlink3/libtool-fix-la
new file mode 100644
index 00000000000..c6ab415fb71
--- /dev/null
+++ b/mk/buildlink3/libtool-fix-la
@@ -0,0 +1,275 @@
+# $NetBSD: libtool-fix-la,v 1.2 2003/09/02 06:59:57 jlam Exp $
+#
+# For *.la files, in the "relink_command" line, we make the following
+# replacements:
+#
+# "libfoo.la" -> "-L./.libs libfoo.la"
+# "dirpath/libfoo.la" -> "-Ldirpath/.libs libfoo.la"
+#
+# This allows the libraries to be found within ${WRKSRC} during relinking.
+# We rely on the proper rpath settings to be set by libtool.
+#
+# For the *.lai files, in the "dependency_libs" line, we remove redundant
+# -Ldir and -llib options. We also make sure that we don't ever reference
+# other .la files, only referring to other libraries via the usual
+# "-L/path -llib" and making sure that /path is always somewhere under the
+# default view. This makes wildcard dependencies work for "overwrite"
+# packages by letting libtool find libraries in the default view.
+
+labase=`@BASENAME@ $lafile .la`
+ladir=`@DIRNAME@ $lafile`
+latimestamp=${ladir}/.${labase}.la.timestamp
+laifile=${ladir}/.libs/${labase}.lai
+if $test -f $lafile; then
+ . ${ladir}/${labase}.la
+
+ deps=
+ for i in ${dependency_libs}; do
+ case "$i" in
+ -R*)
+ # Skip all -R* options... rpath info shouldn't go into the
+ # dependency_libs line.
+ ;;
+ # Catch -L<dir> and remove redundant ones.
+ -L*)
+ case "$deps" in
+ *"$i "*) ;;
+ *"$i") ;;
+ *) deps="${deps} $i" ;;
+ esac
+ ;;
+ # Convert "dirpath/libfoo.la" into "-Ldirpath/.libs libfoo.la"
+ # if it's an uninstalled libtool archive. This allows
+ # proper relinking by libtool during the install stage
+ # by allowing it to find the uninstalled shared library
+ # in the .libs directory.
+ #
+ *.la)
+ fixla=0
+ ltlibsdir=`@DIRNAME@ $i`/.libs
+ case "$ltlibsdir" in
+ /*)
+ # fix if an absolute path in ${WRKSRC}
+ case "$ltlibsdir" in
+ @WRKSRC@/*) fixla=1 ;;
+ esac
+ ;;
+ *)
+ # fix all relative paths
+ fixla=1
+ ;;
+ esac
+ if $test $fixla -gt 0; then
+ case "$deps" in
+ *"-L$ltlibsdir "*) ;;
+ *"-L$ltlibsdir") ;;
+ *) deps="$deps -L$ltlibsdir" ;;
+ esac
+ fi
+ deps="${deps} $i"
+ ;;
+ # Everything else Just Belongs in the dependency_libs line.
+ *)
+ deps="${deps} $i"
+ ;;
+ esac
+ done
+
+ relink=
+ for i in ${relink_command}; do
+ case "$i" in
+ # -I* and -D* are useless for linking.
+ -I*|-D*)
+ ;;
+ # Catch -L<dir> and remove redundant ones.
+ -L*)
+ case "$relink" in
+ *"$i "*) ;;
+ *"$i") ;;
+ *) relink="${relink} $i" ;;
+ esac
+ ;;
+ # This is the .la file we're relinking... don't touch it!
+ $lafile)
+ relink="${relink} $i"
+ ;;
+ # Convert "dirpath/libfoo.la" into "-Ldirpath/.libs libfoo.la"
+ # if it's an uninstalled libtool archive. This allows
+ # proper relinking by libtool during the install stage
+ # by allowing it to find the uninstalled shared library
+ # in the .libs directory.
+ #
+ *.la)
+ fixla=0
+ ltlibsdir=`@DIRNAME@ $i`/.libs
+ case "$ltlibsdir" in
+ /*)
+ # fix if an absolute path in ${WRKSRC}
+ case "$ltlibsdir" in
+ @WRKSRC@/*) fixla=1 ;;
+ esac
+ ;;
+ *)
+ # fix all relative paths
+ fixla=1
+ ;;
+ esac
+ if $test $fixla -gt 0; then
+ case "$relink" in
+ *"-L$ltlibsdir "*) ;;
+ *"-L$ltlibsdir") ;;
+ *) relink="$relink -L$ltlibsdir" ;;
+ esac
+ fi
+ relink="${relink} $i"
+ ;;
+ # Everything else Just Belongs in the relink_command line.
+ *)
+ relink="${relink} $i"
+ ;;
+ esac
+ done
+ if $test -z "$deps" && $test -z "$relink" || \
+ @EGREP@ "^#.*modified by buildlink3" $lafile >/dev/null 2>&1; then
+ :
+ else
+ # Save the orignal .la file produced by libtool as
+ # .la.blsav, and create the new one with a signature.
+ #
+ @MV@ -f $lafile ${lafile}.blsav
+ if $test -n "$deps"; then
+ (
+ $cat ${lafile}.blsav | @SED@ -e '/^dependency_libs=/,$d'
+ $echo "dependency_libs='$deps'"
+ $cat ${lafile}.blsav | @SED@ -e '1,/^dependency_libs=/d'
+ ) > ${lafile}.tmp
+ else
+ $cat ${lafile}.blsav > ${lafile}.tmp
+ fi
+ if $test -n "$relink"; then
+ (
+ $cat ${lafile}.tmp | @SED@ -e '/^relink_command=/,$d'
+ $echo "relink_command='$relink'"
+ $cat ${lafile}.tmp | @SED@ -e '1,/^relink_command=/d'
+ ) > $lafile
+ else
+ $cat ${lafile}.tmp > $lafile
+ fi
+ $echo >> $lafile
+ $echo "# This file has been modified by buildlink3." >> $lafile
+ @RM@ ${lafile}.tmp
+ $echo "==> Fixed $lafile" >> $wrapperlog
+ fi
+ #
+ # Fix up any .lai files (libtool archives that will be installed).
+ #
+ if $test -z "$laifile" || $test ! -f "$laifile" || \
+ @EGREP@ "^#.*modified by buildlink3" $laifile >/dev/null 2>&1; then
+ :
+ else
+ @SED@ @_BLNK_WRAP_LT_UNTRANSFORM_SED@ \
+ $laifile > ${laifile}.tmp
+ . ${laifile}.tmp
+ L=; l=; lexist=; prev=
+ for i in ${dependency_libs}; do
+ case "$i" in
+ #
+ # Don't allowed repeated arguments, so "-lm -lm"
+ # becomes just "-lm".
+ #
+ $prev)
+ ;;
+ # Skip all -R* options... rpath info shouldn't go
+ # into the dependency_libs line.
+ #
+ -R*)
+ ;;
+ # Skip directories that should never appear in
+ # the -L<dir> flags. Also modify directories in
+ # ${DEPOTBASE} to point to somewhere in the
+ # default view ${LOCALBASE}, since we want "overwrite"
+ # packages to think the libraries really do just
+ # exist through the default view.
+ #
+ -L*)
+ case "$i" in
+ -L${BUILDLINK_DIR}/*)
+ ;;
+ -L@WRKSRC@|-L@WRKSRC@/*)
+ ;;
+ -L@DEPOTBASE@/*)
+ i=`$echo "X$i" | $Xsed -e "s,-L@DEPOTBASE@/[^/]*/,-L@LOCALBASE@/,"`
+ case "$L" in
+ *"$i "*) ;;
+ *"$i") ;;
+ *) L="$L $i" ;;
+ esac
+ ;;
+ *)
+ case "$L" in
+ *"$i "*) ;;
+ *"$i") ;;
+ *) L="$L $i" ;;
+ esac
+ ;;
+ esac
+ ;;
+ # Libraries really do exist, so we want to keep
+ # any -L<dir> flags we've seen in the generated
+ # dependency_libs line.
+ #
+ -l*)
+ lexist=1
+ l="$l $i"
+ ;;
+ # Libtool archives should be changed from
+ # "/path/libfoo.la" to "-L/path -lfoo", where /path
+ # is appropriately modified so that the depot
+ # directory is changed to the views directory. This
+ # allows the .la files to be used by either "overwrite"
+ # or "pkgviews" packages and works correctly with
+ # wildcard dependencies.
+ #
+ *.la)
+ dirbase=`@DIRNAME@ $i`
+ dir=`$echo "X$dirbase" | $Xsed -e "s,^@DEPOTBASE@/[^/]*/,@LOCALBASE@/,"`
+ case "$L" in
+ *"-L$dir "*) ;;
+ *"-L$dir") ;;
+ *) L="$L -L$dir" ;;
+ esac
+ libbase=`@BASENAME@ $i .la`
+ lib=`$echo "X$libbase" | $Xsed -e "s/^lib//"`
+ lexist=1
+ l="$l -l$lib"
+ ;;
+ # Everything else Just Belongs.
+ *)
+ l="$l $i"
+ ;;
+ esac
+ prev="$i"
+ done
+ if $test -z "$lexist"; then
+ L=
+ fi
+ deps="$L$l"
+ deps=`$echo "X$deps" | $Xsed -e "s/^[ ]*//"`
+ @MV@ -f $laifile ${laifile}.blsav
+ (
+ $cat ${laifile}.tmp | @SED@ -e '/^dependency_libs=/,$d'
+ $echo "dependency_libs='$deps'"
+ $cat ${laifile}.tmp | @SED@ -e '1,/^dependency_libs=/d'
+ $echo
+ $echo "# This file has been modified by buildlink3."
+ ) > ${laifile}
+ @RM@ -f ${laifile}.tmp
+ $echo "==> Fixed $laifile" >> $wrapperlog
+ if $test "$libdir" != "${BUILDLINK_DIR}/.tmp/inst" && \
+ @EGREP@ "${BUILDLINK_DIR}" $laifile >/dev/null 2>&1; then
+ $echo "==> [buildlink3] Error: buildlink3 leakage into $laifile" >> $wrapperlog
+ $echo "==> [buildlink3] Error: buildlink3 leakage into $laifile" 1>&2
+ wrapper_result=1
+ fi
+ fi
+fi
diff --git a/mk/buildlink3/libtool-post-cache b/mk/buildlink3/libtool-post-cache
new file mode 100644
index 00000000000..ebb93ec9f42
--- /dev/null
+++ b/mk/buildlink3/libtool-post-cache
@@ -0,0 +1,12 @@
+# $NetBSD: libtool-post-cache,v 1.2 2003/09/02 06:59:57 jlam Exp $
+#
+# This file implements the default action of the "libtool" private
+# cache, and tells the libtool wrapper to skip the common cache lookup
+# for all directories and library args that may reference a locally
+# linked libtool archive; the appropriate action will be taken instead
+# by libtool-post-logic.
+
+-L.|-L./*|-L..*|-L[!/]*|-L${WRKSRC}*|-l*)
+ skipcache=yes
+ ;;
+esac
diff --git a/mk/buildlink3/libtool-post-logic b/mk/buildlink3/libtool-post-logic
new file mode 100644
index 00000000000..8941f05af3e
--- /dev/null
+++ b/mk/buildlink3/libtool-post-logic
@@ -0,0 +1,57 @@
+# $NetBSD: libtool-post-logic,v 1.2 2003/09/02 06:59:58 jlam Exp $
+#
+# Workaround software authors that don't follow the libtool
+# documentation and link against uninstalled libtool archives with:
+#
+# -L../package/source/dir -lfoo
+#
+# instead of the correct (according to the libtool documentation)
+#
+# ../package/source/dir/libfoo.la
+#
+# We convert the former into the latter by remembering all "local"
+# directories that are mentioned in -L* arguments to to libtool
+# wrapper, and checking to see if <dir>/libfoo.la exists when we see
+# "-lfoo" on the libtool command line.
+
+case $arg in
+-L.|-L./*|-L..*|-L[!/]*|-L${WRKSRC}*)
+ case $fixlibpath in
+ yes)
+ case $arg in
+ */.libs)
+ # ignore -L.../.libs
+ ;;
+ *)
+ $echo "*** [buildlink3] Warning: libtool detected $arg" >> $wrapperlog
+ $echo "*** [buildlink3] Warning: libtool detected $arg" 1>&2
+ lpath=`$echo "X$arg" | $Xsed -e "s/^-L//"`
+ case "$rellpath" in
+ *"$lpath "*) ;;
+ *"$lpath"*) ;;
+ *) rellpath="$rellpath $lpath" ;;
+ esac
+ ;;
+ esac
+ ;;
+ esac
+ ;;
+-l*)
+ case $fixlibpath in
+ yes)
+ lib=`$echo "X$arg" | $Xsed -e "s/^-l//"`
+ for dir in $rellpath; do
+ la="$dir/lib$lib.la"
+ if $test -f "$la"; then
+ $echo "*** [buildlink3] Warning: libtool replaced $arg with $la" >> $wrapperlog
+ $echo "*** [buildlink3] Warning: libtool replaced $arg with $la" 1>&2
+ arg="$la"
+ cachesettings='skipcache=yes'
+ break
+ fi
+ done
+ ;;
+ esac
+ addtoprivatecache=yes
+ ;;
+esac
diff --git a/mk/buildlink3/libtool.sh b/mk/buildlink3/libtool.sh
new file mode 100644
index 00000000000..149833b602e
--- /dev/null
+++ b/mk/buildlink3/libtool.sh
@@ -0,0 +1,98 @@
+#!@BUILDLINK_SHELL@
+#
+# $NetBSD: libtool.sh,v 1.2 2003/09/02 06:59:59 jlam Exp $
+
+Xsed='@SED@ -e 1s/^X//'
+sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
+
+marshall="@_BLNK_WRAP_MARSHALL@"
+private_pre_cache="@_BLNK_WRAP_PRIVATE_PRE_CACHE@"
+private_cache_add="@_BLNK_WRAP_PRIVATE_CACHE_ADD@"
+private_cache="@_BLNK_WRAP_PRIVATE_CACHE@"
+private_post_cache="@_BLNK_WRAP_PRIVATE_POST_CACHE@"
+pre_cache="@_BLNK_WRAP_PRE_CACHE@"
+cache_add="@_BLNK_WRAP_CACHE_ADD@"
+cache="@_BLNK_WRAP_CACHE@"
+post_cache="@_BLNK_WRAP_POST_CACHE@"
+logic="@_BLNK_WRAP_LOGIC@"
+post_logic="@_BLNK_WRAP_POST_LOGIC@"
+
+wrapperlog="${BUILDLINK_WRAPPER_LOG-@_BLNK_WRAP_LOG@}"
+
+libtool_fix_la="@_BLNK_LIBTOOL_FIX_LA@"
+libtool_do_install="@_BLNK_LIBTOOL_DO_INSTALL@"
+fixlibpath=${BUILDLINK_FIX_IMPROPER_LIBTOOL_LIBPATH-yes}
+
+updatecache=${BUILDLINK_UPDATE_CACHE-yes}
+cacheall=${BUILDLINK_CACHE_ALL-no}
+
+cat="@CAT@"
+echo="@ECHO@"
+test="@TEST@"
+
+BUILDLINK_DIR="@BUILDLINK_DIR@"
+WRKDIR="@WRKDIR@"
+WRKSRC="@WRKSRC@"
+
+cmd="@WRAPPEE@"
+lafile=
+case "$1" in
+*install|*cp|*install-sh|*install.sh)
+ arg="$1"; shift
+ . $libtool_do_install
+ ;;
+*)
+ while $test $# -gt 0; do
+ arg="$1"; shift
+ case $arg in
+ --fix-la)
+ case "$1" in
+ *.la)
+ lafile="$1"
+ . $libtool_fix_la
+ exit
+ ;;
+ esac
+ ;;
+ --mode|--mode=install)
+ if $test "$arg" = "--mode=install" || \
+ $test "$arg" = "--mode" -a "$1" = "install"; then
+ . $libtool_do_install
+ break
+ fi
+ ;;
+ -o)
+ case "$1" in
+ *.la) lafile="$1" ;;
+ esac
+ ;;
+ *)
+ cachehit=no
+ skipcache=no
+ . $marshall
+ . $private_cache
+ case $skipcache,$cachehit in
+ no,no) . $cache ;;
+ esac
+ case $cachehit in
+ no) . $logic ;;
+ esac
+ ;;
+ esac
+ cmd="$cmd $arg"
+ done
+ ;;
+esac
+
+@_BLNK_WRAP_ENV@
+@_BLNK_WRAP_SANITIZE_PATH@
+
+$echo $cmd >> $wrapperlog
+eval $cmd
+wrapper_result=$?
+
+if $test -n "$lafile" && $test -f "$lafile"; then
+ . $libtool_fix_la
+fi
+
+exit ${wrapper_result}
diff --git a/mk/buildlink3/logic b/mk/buildlink3/logic
new file mode 100644
index 00000000000..62cbdfd37a0
--- /dev/null
+++ b/mk/buildlink3/logic
@@ -0,0 +1,75 @@
+# $NetBSD: logic,v 1.2 2003/09/02 07:00:00 jlam Exp $
+
+quotedarg=no
+addtocache=no
+addtoprivatecache=no
+cachesettings='arg="$cachearg"; cachehit=yes'
+
+# $qarg contains a correctly-quoted $arg
+case $arg in
+*[\`\"\$\\]*)
+ qarg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
+ quotedarg=yes
+ ;;
+*)
+ qarg="$arg"
+ ;;
+esac
+case $qarg in
+ *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
+ qarg="\"$qarg\""
+ quotedarg=yes
+ ;;
+esac
+searcharg="$qarg"
+
+case $arg in
+-D*)
+ arg="$qarg"
+ addtocache=yes
+ ;;
+-*|/*)
+ arg=`$echo "X$qarg" | $Xsed @_BLNK_TRANSFORM_SED@`
+ addtocache=yes
+ ;;
+*)
+ arg="$qarg"
+ addtocache=no
+ ;;
+esac
+
+. $post_logic
+
+case $updatecache,$addtocache,$cacheall,$quotedarg in
+yes,yes,yes,*|yes,yes,no,no)
+ case $arg in
+ *[\`\"\$\\]*)
+ cachearg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
+ ;;
+ *)
+ cachearg="$arg"
+ ;;
+ esac
+ case $addtoprivatecache in
+ yes)
+ pre_cachefile=$private_pre_cache
+ cachefile_add=$private_cache_add
+ cachefile=$private_cache
+ post_cachefile=$private_post_cache
+ ;;
+ *)
+ pre_cachefile=$pre_cache
+ cachefile_add=$cache_add
+ cachefile=$cache
+ post_cachefile=$post_cache
+ ;;
+ esac
+ $cat >> $cachefile_add << EOF
+$searcharg)
+ cachearg="$cachearg"
+ $cachesettings
+ ;;
+EOF
+ $cat $pre_cachefile $cachefile_add $post_cachefile > $cachefile
+ ;;
+esac
diff --git a/mk/buildlink3/marshall b/mk/buildlink3/marshall
new file mode 100644
index 00000000000..c59f47f1a3e
--- /dev/null
+++ b/mk/buildlink3/marshall
@@ -0,0 +1,13 @@
+# $NetBSD: marshall,v 1.2 2003/09/02 07:00:00 jlam Exp $
+#
+# Merge "-Wl,--rpath -Wl,/path/to/dir" into a single argument
+# "-Wl,--rpath,/path/to/dir" so that we can look it up in the cache.
+#
+case $arg in
+-Wl,-rpath|-Wl,-rpath-link|\
+-Wl,--rpath|-Wl,--rpath-link)
+ nextarg=`$echo "X$1" | $Xsed -e "s|^-Wl,||g"`
+ arg="$arg,$nextarg"
+ shift
+ ;;
+esac
diff --git a/mk/buildlink3/post-cache b/mk/buildlink3/post-cache
new file mode 100644
index 00000000000..b93ade36cc2
--- /dev/null
+++ b/mk/buildlink3/post-cache
@@ -0,0 +1,4 @@
+# $NetBSD: post-cache,v 1.2 2003/09/02 07:00:01 jlam Exp $
+
+*) ;;
+esac
diff --git a/mk/buildlink3/pre-cache b/mk/buildlink3/pre-cache
new file mode 100644
index 00000000000..d6dd1ea05de
--- /dev/null
+++ b/mk/buildlink3/pre-cache
@@ -0,0 +1,3 @@
+# $NetBSD: pre-cache,v 1.2 2003/09/02 07:00:01 jlam Exp $
+
+case $arg in
diff --git a/mk/buildlink3/sunpro-cc-post-cache b/mk/buildlink3/sunpro-cc-post-cache
new file mode 100644
index 00000000000..40ac4ca4fa7
--- /dev/null
+++ b/mk/buildlink3/sunpro-cc-post-cache
@@ -0,0 +1,12 @@
+# $NetBSD: sunpro-cc-post-cache,v 1.2 2003/09/02 07:00:02 jlam Exp $
+#
+# This file implements the default action of the "cc" private cache
+# for the SunPro suite of compilers, and tells the wrapper to skip the
+# common cache lookup for all GCC arguments that the SunPro compiler
+# can't handle; they will instead by handled directly by
+# sunpro-cc-post-logic.
+
+-W*)
+ skipcache=yes
+ ;;
+esac
diff --git a/mk/buildlink3/sunpro-cc-post-logic b/mk/buildlink3/sunpro-cc-post-logic
new file mode 100644
index 00000000000..d78d6bf1ea3
--- /dev/null
+++ b/mk/buildlink3/sunpro-cc-post-logic
@@ -0,0 +1,30 @@
+# $NetBSD: sunpro-cc-post-logic,v 1.2 2003/09/02 07:00:03 jlam Exp $
+#
+# Silently accept some GCC compiler arguments by silently converting
+# them to the SunPro compiler equivalents. This makes the SunPro
+# compiler wrappers work with more software that seems to assume GCC
+# nowadays.
+
+case $arg in
+-Werror)
+ # "-errwarn" is the right way to convince the SunPro compiler
+ # to stop on compilation warnings.
+ #
+ arg="-errwarn"
+ addtoprivatecache=yes
+ ;;
+-Wl,-R*)
+ # Directories for the runtime library search path are passed
+ # via simply "-R<dir>", not "-Wl,-R<dir>".
+ #
+ arg=`$echo "X$arg" | $Xsed -e "s|^-Wl,||g" -e "s|,| |g"`
+ addtoprivatecache=yes
+ ;;
+-W*)
+ # In fact, SunPro compilers don't even understand any -W*
+ # arguments, so just silently ignore them all.
+ #
+ arg=
+ addtoprivatecache=yes
+ ;;
+esac
diff --git a/mk/buildlink3/wrapper.sh b/mk/buildlink3/wrapper.sh
new file mode 100644
index 00000000000..3cd4b4e164b
--- /dev/null
+++ b/mk/buildlink3/wrapper.sh
@@ -0,0 +1,67 @@
+#!@BUILDLINK_SHELL@
+#
+# $NetBSD: wrapper.sh,v 1.2 2003/09/02 07:00:03 jlam Exp $
+
+Xsed='@SED@ -e 1s/^X//'
+sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
+
+marshall="@_BLNK_WRAP_MARSHALL@"
+private_pre_cache="@_BLNK_WRAP_PRIVATE_PRE_CACHE@"
+private_cache_add="@_BLNK_WRAP_PRIVATE_CACHE_ADD@"
+private_cache="@_BLNK_WRAP_PRIVATE_CACHE@"
+private_post_cache="@_BLNK_WRAP_PRIVATE_POST_CACHE@"
+pre_cache="@_BLNK_WRAP_PRE_CACHE@"
+cache_add="@_BLNK_WRAP_CACHE_ADD@"
+cache="@_BLNK_WRAP_CACHE@"
+post_cache="@_BLNK_WRAP_POST_CACHE@"
+logic="@_BLNK_WRAP_LOGIC@"
+post_logic="@_BLNK_WRAP_POST_LOGIC@"
+
+wrapperlog="${BUILDLINK_WRAPPER_LOG-@_BLNK_WRAP_LOG@}"
+
+updatecache="${BUILDLINK_UPDATE_CACHE-yes}"
+cacheall="${BUILDLINK_CACHE_ALL-no}"
+
+cat="@CAT@"
+echo="@ECHO@"
+test="@TEST@"
+
+BUILDLINK_DIR="@BUILDLINK_DIR@"
+WRKDIR="@WRKDIR@"
+WRKSRC="@WRKSRC@"
+
+cmd="@WRAPPEE@ @_BLNK_WRAP_EXTRA_FLAGS@"
+while $test $# -gt 0; do
+ arg="$1"; shift
+ cachehit=no
+ skipcache=no
+ #
+ # Marshall any group of consecutive arguments into a single
+ # $arg to be checked in the cache and logic files.
+ #
+ . $marshall
+ #
+ # Check the private cache, and possibly set skipcache=yes.
+ #
+ . $private_cache
+ #
+ # Check the common cache shared by all of the other wrappers.
+ #
+ case $skipcache,$cachehit in
+ no,no) . $cache ;;
+ esac
+ #
+ # If the cache doesn't cover the arg we're examining, then
+ # run it through the transformations and cache the result.
+ #
+ case $cachehit in
+ no) . $logic ;;
+ esac
+ cmd="$cmd $arg"
+done
+
+@_BLNK_WRAP_ENV@
+@_BLNK_WRAP_SANITIZE_PATH@
+
+$echo $cmd >> $wrapperlog
+eval exec $cmd