summaryrefslogtreecommitdiff
path: root/mk
diff options
context:
space:
mode:
authorjlam <jlam@pkgsrc.org>2005-06-01 18:02:37 +0000
committerjlam <jlam@pkgsrc.org>2005-06-01 18:02:37 +0000
commit95fd1f6ec9ce583a46e4351179d93b744a17d1ad (patch)
tree614ebca62dbe176d9c75cab1cfeef7c554a336c9 /mk
parent6469e231c2dabc4fdb3edae536776b2c90cf5616 (diff)
downloadpkgsrc-95fd1f6ec9ce583a46e4351179d93b744a17d1ad.tar.gz
Massive cleanup of buildlink3.mk and builtin.mk files in pkgsrc.
Several changes are involved since they are all interrelated. These changes affect about 1000 files. The first major change is rewriting bsd.builtin.mk as well as all of the builtin.mk files to follow the new example in bsd.builtin.mk. The loop to include all of the builtin.mk files needed by the package is moved from bsd.builtin.mk and into bsd.buildlink3.mk. bsd.builtin.mk is now included by each of the individual builtin.mk files and provides some common logic for all of the builtin.mk files. Currently, this includes the computation for whether the native or pkgsrc version of the package is preferred. This causes USE_BUILTIN.* to be correctly set when one builtin.mk file includes another. The second major change is teach the builtin.mk files to consider files under ${LOCALBASE} to be from pkgsrc-controlled packages. Most of the builtin.mk files test for the presence of built-in software by checking for the existence of certain files, e.g. <pthread.h>, and we now assume that if that file is under ${LOCALBASE}, then it must be from pkgsrc. This modification is a nod toward LOCALBASE=/usr. The exceptions to this new check are the X11 distribution packages, which are handled specially as noted below. The third major change is providing builtin.mk and version.mk files for each of the X11 distribution packages in pkgsrc. The builtin.mk file can detect whether the native X11 distribution is the same as the one provided by pkgsrc, and the version.mk file computes the version of the X11 distribution package, whether it's built-in or not. The fourth major change is that the buildlink3.mk files for X11 packages that install parts which are part of X11 distribution packages, e.g. Xpm, Xcursor, etc., now use imake to query the X11 distribution for whether the software is already provided by the X11 distribution. This is more accurate than grepping for a symbol name in the imake config files. Using imake required sprinkling various builtin-imake.mk helper files into pkgsrc directories. These files are used as input to imake since imake can't use stdin for that purpose. The fifth major change is in how packages note that they use X11. Instead of setting USE_X11, package Makefiles should now include x11.buildlink3.mk instead. This causes the X11 package buildlink3 and builtin logic to be executed at the correct place for buildlink3.mk and builtin.mk files that previously set USE_X11, and fixes packages that relied on buildlink3.mk files to implicitly note that X11 is needed. Package buildlink3.mk should also include x11.buildlink3.mk when linking against the package libraries requires also linking against the X11 libraries. Where it was obvious, redundant inclusions of x11.buildlink3.mk have been removed.
Diffstat (limited to 'mk')
-rw-r--r--mk/bsd.pkg.mk6
-rw-r--r--mk/bsd.pkg.use.mk11
-rw-r--r--mk/buildlink3/bsd.buildlink3.mk27
-rw-r--r--mk/buildlink3/bsd.builtin.mk132
-rw-r--r--mk/buildlink3/find-files.mk101
-rw-r--r--mk/buildlink3/find-libs.mk21
-rw-r--r--mk/db1.builtin.mk119
-rw-r--r--mk/defaults/mk.conf4
-rw-r--r--mk/dlopen.builtin.mk102
-rw-r--r--mk/motif.buildlink3.mk5
-rw-r--r--mk/pthread.builtin.mk70
-rw-r--r--mk/solaris-pam.builtin.mk68
-rw-r--r--mk/x11.buildlink3.mk22
-rw-r--r--mk/x11.builtin.mk8
-rw-r--r--mk/x11.version.mk31
-rw-r--r--mk/xaw.buildlink3.mk3
16 files changed, 456 insertions, 274 deletions
diff --git a/mk/bsd.pkg.mk b/mk/bsd.pkg.mk
index a9bea62fdd5..6f7a2bd883f 100644
--- a/mk/bsd.pkg.mk
+++ b/mk/bsd.pkg.mk
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.pkg.mk,v 1.1684 2005/06/01 17:27:22 jlam Exp $
+# $NetBSD: bsd.pkg.mk,v 1.1685 2005/06/01 18:03:05 jlam Exp $
#
# This file is in the public domain.
#
@@ -717,10 +717,6 @@ CONFIGURE_ARGS+= --host=${MACHINE_GNU_PLATFORM}
. endif
CONFIGURE_ARGS+= --prefix=${GNU_CONFIGURE_PREFIX}
HAS_CONFIGURE= yes
-. if defined(USE_X11)
-CONFIGURE_ARGS+= --x-includes=${X11BASE}/include
-CONFIGURE_ARGS+= --x-libraries=${X11BASE}/lib${LIBABISUFFIX}
-. endif
CONFIGURE_HAS_INFODIR?= yes
. if !empty(INFO_FILES) && !empty(CONFIGURE_HAS_INFODIR:M[yY][eE][sS])
CONFIGURE_ARGS+= --infodir=${PREFIX}/${INFO_DIR}
diff --git a/mk/bsd.pkg.use.mk b/mk/bsd.pkg.use.mk
index 65d466b7c33..837ab426dbf 100644
--- a/mk/bsd.pkg.use.mk
+++ b/mk/bsd.pkg.use.mk
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.pkg.use.mk,v 1.15 2005/05/22 19:11:12 jlam Exp $
+# $NetBSD: bsd.pkg.use.mk,v 1.16 2005/06/01 18:03:05 jlam Exp $
#
# Turn USE_* macros into proper depedency logic. Included near the top of
# bsd.pkg.mk, after bsd.prefs.mk.
@@ -27,7 +27,7 @@ MAKE_FLAGS+= CC=${CC:Q} CXX=${CXX:Q}
.if defined(USE_X11BASE)
MTREE_FILE?= ${PKGSRCDIR}/mk/${OPSYS}.x11.dist
-USE_X11?= implied
+. include "../../mk/x11.buildlink3.mk"
.endif
.if ${PKG_INSTALLATION_TYPE} == "pkgviews"
@@ -119,13 +119,6 @@ RMAN?= ${X11BASE}/bin/rman
. endif
.endif
-### USE_X11
-
-.if defined(USE_X11)
-X11_LDFLAGS+= ${COMPILER_RPATH_FLAG}${X11BASE}/lib${LIBABISUFFIX}
-X11_LDFLAGS+= -L${X11BASE}/lib${LIBABISUFFIX}
-.endif
-
### USE_XPKGWEDGE
.if defined(USE_X11BASE) && !empty(USE_XPKGWEDGE:M[yY][eE][sS])
diff --git a/mk/buildlink3/bsd.buildlink3.mk b/mk/buildlink3/bsd.buildlink3.mk
index f5ea9fce213..3483df9212a 100644
--- a/mk/buildlink3/bsd.buildlink3.mk
+++ b/mk/buildlink3/bsd.buildlink3.mk
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.buildlink3.mk,v 1.170 2005/05/11 22:08:18 jlam Exp $
+# $NetBSD: bsd.buildlink3.mk,v 1.171 2005/06/01 18:03:06 jlam Exp $
#
# Copyright (c) 2004 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -104,27 +104,10 @@ BUILDLINK_DEPENDS?= # empty
# For each package we use, check whether we are using the built-in
# version of the package or if we are using the pkgsrc version.
#
-.include "../../mk/buildlink3/bsd.builtin.mk"
-
-# Check whether we should include the X11 buildlink3.mk file here since
-# USE_X11 may have been set indirectly by bsd.builtin.mk.
-#
-.if defined(USE_X11)
-X11_TYPE?= native
-X11_PKGSRCDIR.native= ../../pkgtools/x11-links
-X11_PKGSRCDIR.XFree86= ../../x11/XFree86-libs
-X11_PKGSRCDIR.xlibs= ../../x11/xlibs
-X11_PKGSRCDIR.xorg= ../../x11/xorg-libs
-. if exists(${X11_PKGSRCDIR.${X11_TYPE}}/buildlink3.mk)
-. include "${X11_PKGSRCDIR.${X11_TYPE}}/buildlink3.mk"
-. if exists(${X11_PKGSRCDIR.${X11_TYPE}}/builtin.mk)
-. include "${X11_PKGSRCDIR.${X11_TYPE}}/builtin.mk"
-. endif
-. else
-PKG_FAIL_REASON+= \
- "${PKGNAME} uses X11, but \"${X11_TYPE}\" isn't a valid X11 type."
-. endif
-.endif
+.for _pkg_ in ${BUILDLINK_PACKAGES}
+BUILDLINK_BUILTIN_MK.${_pkg_}?= ${BUILDLINK_PKGSRCDIR.${_pkg_}}/builtin.mk
+. sinclude "${BUILDLINK_BUILTIN_MK.${_pkg_}}"
+.endfor
# Set IGNORE_PKG.<pkg> if <pkg> is the current package we're building.
# We can then check for this value to avoid build loops.
diff --git a/mk/buildlink3/bsd.builtin.mk b/mk/buildlink3/bsd.builtin.mk
index f0144b1f81e..97893e248b3 100644
--- a/mk/buildlink3/bsd.builtin.mk
+++ b/mk/buildlink3/bsd.builtin.mk
@@ -1,6 +1,6 @@
-# $NetBSD: bsd.builtin.mk,v 1.4 2005/05/24 15:41:05 xtraeme Exp $
+# $NetBSD: bsd.builtin.mk,v 1.5 2005/06/01 18:03:06 jlam Exp $
#
-# Copyright (c) 2004 The NetBSD Foundation, Inc.
+# Copyright (c) 2004-2005 The NetBSD Foundation, Inc.
# All rights reserved.
#
# This code is derived from software contributed to The NetBSD Foundation
@@ -51,44 +51,66 @@
# An example package builtin.mk file is:
#
# -------------8<-------------8<-------------8<-------------8<-------------
-# .if !defined(IS_BUILTIN.foo)
-# #
-# # IS_BUILTIN.foo is set to "yes" or "no" depending on whether "foo"
-# # genuinely exists in the system or not.
-# #
-# IS_BUILTIN.foo?= no
-#
-# # BUILTIN_PKG.foo should be set here if "foo" is built-in and its package
-# # version can be determined.
-# #
-# . if !empty(IS_BUILTIN.foo:M[yY][eE][sS])
-# BUILTIN_PKG.foo?= foo-1.0
-# . endif
-# .endif # IS_BUILTIN.foo
-#
-# .if !defined(USE_BUILTIN.foo)
-# USE_BUILTIN.foo?= ${IS_BUILTIN.foo}
-# . if defined(BUILTIN_PKG.foo)
-# . for _depend_ in ${BUILDLINK_DEPENDS.foo}
-# . if !empty(USE_BUILTIN.foo:M[yY][eE][sS])
-# USE_BUILTIN.foo!= \
-# if ${PKG_ADMIN} pmatch '${_depend_}' ${BUILTIN_PKG.foo}; then \
+# BUILTIN_PKG:= wibble
+# .include "../../mk/buildlink3/bsd.builtin.mk"
+#
+# ###
+# ### Determine if there is a built-in implementation of the package and
+# ### set IS_BUILTIN.<pkg> appropriately ("yes" or "no").
+# ###
+# .if !defined(IS_BUILTIN.wibble)
+# IS_BUILTIN.wibble= no
+# .endif
+# MAKEVARS+= IS_BUILTIN.wibble
+#
+# ###
+# ### If there is a built-in implementation, then set BUILTIN_PKG.<pkg> to
+# ### a package name to represent the built-in package.
+# ###
+# .if !defined(BUILTIN_PKG.iconv) && \
+# !empty(IS_BUILTIN.wibble:M[yY][eE][sS])
+# BUILTIN_PKG.wibble= wibble-1.0
+# .endif
+# MAKEVARS+= BUILTIN_PKG.wibble
+#
+# ###
+# ### Determine whether we should use the built-in implementation if it
+# ### exists, and set USE_BUILTIN.<pkg> appropriate ("yes" or "no").
+# ###
+# .if !defined(USE_BUILTIN.wibble)
+# . if ${PREFER.wibble} == "pkgsrc"
+# USE_BUILTIN.wibble= no
+# . else
+# USE_BUILTIN.wibble= ${IS_BUILTIN.wibble}
+# . if defined(BUILTIN_PKG.wibble) && \
+# !empty(IS_BUILTIN.wibble:M[yY][eE][sS])
+# USE_BUILTIN.wibble= yes
+# . for _dep_ in ${BUILDLINK_DEPENDS.wibble}
+# . if !empty(USE_BUILTIN.wibble:M[yY][eE][sS])
+# USE_BUILTIN.wibble!= \
+# if ${PKG_ADMIN} pmatch ${_dep_:Q} ${BUILTIN_PKG.wibble:Q}; then \
# ${ECHO} "yes"; \
# else \
# ${ECHO} "no"; \
# fi
-# . endif
-# . endfor
+# . endif
+# . endfor
+# . endif
# . endif
-# .endif # USE_BUILTIN.foo
-#
-# CHECK_BUILTIN.foo?= no
-# .if !empty(CHECK_BUILTIN.foo:M[nN][oO])
+# .endif
+# MAKEVARS+= USE_BUILTIN.wibble
+#
+# ###
+# ### The section below only applies if we are not including this file
+# ### solely to determine whether a built-in implementation exists.
+# ###
+# CHECK_BUILTIN.wibble?= no
+# .if !empty(CHECK_BUILTIN.wibble:M[nN][oO])
# #
-# # Here we place code that depends on whether USE_BUILTIN.foo is set to
-# # "yes" or "no".
+# # Here we place code that depends on whether USE_BUILTIN.wibble is
+# # set to "yes" or "no".
# #
-# .endif # CHECK_BUILTIN.foo
+# .endif # CHECK_BUILTIN.wibble
# -------------8<-------------8<-------------8<-------------8<-------------
#
# Note the structure of the builtin.mk file: first we set IS_BUILTIN.<pkg>,
@@ -96,17 +118,21 @@
# USE_BUILTIN.<pkg> is "yes" or "no" in a region that is guarded by
# CHECK_BUILTIN.<pkg>. Package builtin.mk files aren't protected against
# multiple inclusion.
+#
+
+.include "../../mk/bsd.prefs.mk"
+.for _pkg_ in ${BUILTIN_PKG}
+#
# Define PREFER.<pkg> to be either "pkgsrc" or "native" depending on
# whether to prefer the pkgsrc or native versions of software that's
-# also part of the base system. It's value is determined from the
+# also part of the base system. Its value is determined from the
# user-settable values PREFER_PKGSRC and PREFER_NATIVE. Preferences are
# determined by the most specific instance of the package in either
# PREFER_PKGSRC or PREFER_NATIVE. If a package is specified in neither
# or in both variables, then PREFER_PKGSRC has precedence over
# PREFER_NATIVE.
#
-.for _pkg_ in ${BUILDLINK_PACKAGES}
PREFER.${_pkg_}?= pkgsrc
. if !empty(PREFER_NATIVE:M[yY][eE][sS])
PREFER.${_pkg_}= native
@@ -122,37 +148,5 @@ PREFER.${_pkg_}= pkgsrc
. endif
.endfor
-.for _pkg_ in ${BUILDLINK_PACKAGES}
-#
-# builtin.mk files default to using the built-in software if it's
-# available (${PREFER.<pkg>} == "native") unless USE_BUILTIN.<pkg> has
-# been previously set.
-#
-. if ${PREFER.${_pkg_}} == "pkgsrc"
-USE_BUILTIN.${_pkg_}?= no
-. endif
-#
-# Set the default path to the package builtin.mk file.
-#
-BUILDLINK_BUILTIN_MK.${_pkg_}?= ${BUILDLINK_PKGSRCDIR.${_pkg_}}/builtin.mk
-. if exists(${BUILDLINK_BUILTIN_MK.${_pkg_}})
-. include "${BUILDLINK_BUILTIN_MK.${_pkg_}}"
-. endif
-.endfor
-
-# Default fall-through for packages that don't provide a builtin.mk. This
-# is here to set the default for any package added to BUILDLINK_PACKAGES
-# by any of the above code.
-#
-# BUILTIN_PACKAGES will contain the list of all builtin
-# dependencies used in packages.
-#
-
-.for _pkg_ in ${BUILDLINK_PACKAGES}
-USE_BUILTIN.${_pkg_}?= no
-BUILTIN_PACKAGES?= # empty
-. if !empty(USE_BUILTIN.${_pkg_}:M[Yy][Ee][Ss])
-BUILTIN_PACKAGES+= ${_pkg_}
-. endif
-.endfor
-
+.include "../../mk/buildlink3/find-libs.mk"
+.include "../../mk/buildlink3/find-files.mk"
diff --git a/mk/buildlink3/find-files.mk b/mk/buildlink3/find-files.mk
new file mode 100644
index 00000000000..cd1ff634eca
--- /dev/null
+++ b/mk/buildlink3/find-files.mk
@@ -0,0 +1,101 @@
+# $NetBSD: find-files.mk,v 1.1 2005/06/01 18:03:06 jlam Exp $
+#
+# Copyright (c) 2005 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 is a "subroutine" that can be included to detect the presence of
+# files in the base system.
+#
+# The following variables must be defined before including this file:
+#
+# BUILTIN_FIND_FILES_VAR is a list of variables to define. These
+# variables take the value of the path to the file that is
+# "found".
+#
+# BUILTIN_FIND_FILES.<var> is the list of paths to files to find, in
+# order, on the filesystem. The variable <var> is set to the
+# first path "found" on the filesystem.
+#
+# Optionally, the following variables may also be defined:
+#
+# BUILTIN_FIND_GREP.<var> is a regular expression that must be
+# matched within a file in order for the file to be considered
+# "found". If it isn't defined, then we simply check for the
+# existence of the file.
+#
+# After including this file, the following variables are defined:
+#
+# <var> is the first of the files listed in ${BUILTIN_FIND_FILES.<var>}
+# that is "found", or else it is "__nonexistent__".
+#
+# An example use is:
+#
+# BUILTIN_FIND_FILES_VAR:= FOO BAR
+#
+# BUILTIN_FIND_FILES.FOO= /path1 /path2
+# BUILTIN_FIND_GREP.FOO= \#define.*FOO
+#
+# BUILTIN_FIND_FILES.BAR= /path3 /path4
+# .include "../../mk/buildlink3/builtin-files.mk"
+#
+
+.if empty(PKGSRC_USE_TOOLS:Mecho)
+PKGSRC_USE_TOOLS+= echo
+.endif
+.if empty(PKGSRC_USE_TOOLS:Mgrep)
+PKGSRC_USE_TOOLS+= grep
+.endif
+
+.for _var_ in ${BUILTIN_FIND_FILES_VAR}
+. if !defined(${_var_})
+${_var_}= __nonexistent__
+. for _file_ in ${BUILTIN_FIND_FILES.${_var_}}
+. if !empty(${_var_}:M__nonexistent__) && exists(${_file_})
+. if !defined(BUILTIN_FIND_GREP.${_var_})
+${_var_}= ${_file_}
+. else
+${_var_}!= \
+ if ${GREP} -q ${BUILTIN_FIND_GREP.${_var_}:Q} ${_file_:Q}; then \
+ ${ECHO} ${_file_:Q}; \
+ else \
+ ${ECHO} __nonexistent__; \
+ fi
+. endif
+. endif
+. endfor
+. endif
+MAKEVARS+= ${_var_}
+.endfor
diff --git a/mk/buildlink3/find-libs.mk b/mk/buildlink3/find-libs.mk
index 538e852c7f5..9cd0ce0475f 100644
--- a/mk/buildlink3/find-libs.mk
+++ b/mk/buildlink3/find-libs.mk
@@ -1,4 +1,4 @@
-# $NetBSD: find-libs.mk,v 1.1 2005/05/24 03:44:04 jlam Exp $
+# $NetBSD: find-libs.mk,v 1.2 2005/06/01 18:03:06 jlam Exp $
#
# Copyright (c) 2005 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -41,14 +41,14 @@
#
# The input variable is BUILDLINK_FIND_LIBS, which is a list of library
# names, e.g. ncurses, iconv, etc., that will be sought in the base
-# system. BUILDLINK_LIB_FOUND.<lib> is set to "yes" or "no" depending
+# system. BUILTIN_LIB_FOUND.<lib> is set to "yes" or "no" depending
# on the result of the search.
-#
+#
# An example use is:
#
# BUILDLINK_FIND_LIBS:= intl iconv
# .include "../../mk/buildlink3/find-libs.mk"
-# # ${BUILDLINK_LIB_FOUND.intl} and ${BUILDLINK_LIB_FOUND.iconv} are now
+# # ${BUILTIN_LIB_FOUND.intl} and ${BUILTIN_LIB_FOUND.iconv} are now
# # either "yes" or "no".
#
@@ -59,17 +59,16 @@ PKGSRC_USE_TOOLS+= echo
PKGSRC_USE_TOOLS+= test
.endif
-.for _lib_ in ${BUILDLINK_FIND_LIBS}
-. if !defined(BUILDLINK_LIB_FOUND.${_lib_})
-BUILDLINK_LIB_FOUND.${_lib_}!= \
- if ${TEST} "`${ECHO} /usr/lib/lib${_lib_}.*`" != "/usr/lib/lib${_lib_}.*"; then \
+.for _lib_ in ${BUILTIN_FIND_LIBS}
+. if !defined(BUILTIN_LIB_FOUND.${_lib_})
+BUILTIN_LIB_FOUND.${_lib_}!= \
+ if ${TEST} "`${ECHO} /usr/lib${ABI}/lib${_lib_}.*`" != "/usr/lib${ABI}/lib${_lib_}.*"; then \
${ECHO} yes; \
- elif ${TEST} "`${ECHO} /lib/lib${_lib_}.*`" != "/lib/lib${_lib_}.*"; then \
+ elif ${TEST} "`${ECHO} /lib${ABI}/lib${_lib_}.*`" != "/lib${ABI}/lib${_lib_}.*"; then \
${ECHO} yes; \
else \
${ECHO} no; \
fi
. endif
-MAKEVARS+= BUILDLINK_LIB_FOUND.${_lib_}
+MAKEVARS+= BUILTIN_LIB_FOUND.${_lib_}
.endfor
-.undef _lib_
diff --git a/mk/db1.builtin.mk b/mk/db1.builtin.mk
index c92e9984895..4aef418388c 100644
--- a/mk/db1.builtin.mk
+++ b/mk/db1.builtin.mk
@@ -1,90 +1,91 @@
-# $NetBSD: db1.builtin.mk,v 1.10 2004/12/23 14:27:04 jlam Exp $
+# $NetBSD: db1.builtin.mk,v 1.11 2005/06/01 18:03:06 jlam Exp $
-.for _lib_ in db db1
-. if !defined(_BLNK_LIB_FOUND.${_lib_})
-_BLNK_LIB_FOUND.${_lib_}!= \
- if ${TEST} "`${ECHO} /usr/lib/lib${_lib_}.*`" != "/usr/lib/lib${_lib_}.*"; then \
- ${ECHO} "yes"; \
- elif ${TEST} "`${ECHO} /lib/lib${_lib_}.*`" != "/lib/lib${_lib_}.*"; then \
- ${ECHO} "yes"; \
- else \
- ${ECHO} "no"; \
- fi
-BUILDLINK_VARS+= _BLNK_LIB_FOUND.${_lib_}
-. endif
-.endfor
-.undef _lib_
+BUILTIN_PKG:= db1
-_DB_H_HEADERS= /usr/include/db.h /usr/include/db1/db.h
-
-.if !defined(IS_BUILTIN.db1)
-IS_BUILTIN.db1= no
+BUILTIN_FIND_LIBS:= db db1
+BUILTIN_FIND_FILES_VAR:= H_DB
+BUILTIN_FIND_FILES.H_DB= /usr/include/db.h /usr/include/db1/db.h
#
# The builtin Berkeley database library must support hash version 2 or
# else it doesn't support db-1.85 databases.
#
-_BLNK_NATIVE_DB1_OK= no
-. for _inc_ in ${_DB_H_HEADERS}
-. if exists(${_inc_})
-_BLNK_NATIVE_DB1_OK.${_inc_}!= \
- if ${GREP} -q "^\#define.*HASHVERSION.*2$$" ${_inc_}; then \
- ${ECHO} "yes"; \
- else \
- ${ECHO} "no"; \
- fi
-. endif
-_BLNK_NATIVE_DB1_OK+= ${_BLNK_NATIVE_DB1_OK.${_inc_}}
-. endfor
-. undef _inc_
-. if !empty(_BLNK_NATIVE_DB1_OK:M[yY][eE][sS])
-IS_BUILTIN.db1= yes
+BUILTIN_FIND_GREP.H_DB= ^\#define.*HASHVERSION.*2$$
+
+.include "../../mk/buildlink3/bsd.builtin.mk"
+
+###
+### Determine if there is a built-in implementation of the package and
+### set IS_BUILTIN.<pkg> appropriately ("yes" or "no").
+###
+.if !defined(IS_BUILTIN.db1)
+IS_BUILTIN.db1= no
+. if empty(H_DB:M${LOCALBASE}/*) && exists(${H_DB})
+IS_BUILTIN.db1= yes
. endif
-BUILDLINK_VARS+= IS_BUILTIN.db1
-.endif # IS_BUILTIN.db1
+.endif
+MAKEVARS+= IS_BUILTIN.db1
+###
+### Determine whether we should use the built-in implementation if it
+### exists, and set USE_BUILTIN.<pkg> appropriate ("yes" or "no").
+###
.if !defined(USE_BUILTIN.db1)
-USE_BUILTIN.db1?= ${IS_BUILTIN.db1}
-_INCOMPAT_DB1?= # empty
-. for _pattern_ in ${_INCOMPAT_DB1} ${INCOMPAT_DB1}
-. if !empty(MACHINE_PLATFORM:M${_pattern_})
+. if ${PREFER.db1} == "pkgsrc"
USE_BUILTIN.db1= no
+. else
+USE_BUILTIN.db1= ${IS_BUILTIN.db1}
+. if defined(BUILTIN_PKG.db1) && \
+ !empty(IS_BUILTIN.db1:M[yY][eE][sS])
+USE_BUILTIN.db1= yes
+. for _dep_ in ${BUILDLINK_DEPENDS.db1}
+. if !empty(USE_BUILTIN.db1:M[yY][eE][sS])
+USE_BUILTIN.db1!= \
+ if ${PKG_ADMIN} pmatch ${_dep_:Q} ${BUILTIN_PKG.db1:Q}; then \
+ ${ECHO} yes; \
+ else \
+ ${ECHO} no; \
+ fi
+. endif
+. endfor
. endif
-. endfor
-. undef _pattern_
-BUILDLINK_VARS+= USE_BUILTIN.db1
-.endif # USE_BUILTIN.db1
+. endif # PREFER.db1
+.endif
+MAKEVARS+= USE_BUILTIN.db1
+###
+### The section below only applies if we are not including this file
+### solely to determine whether a built-in implementation exists.
+###
CHECK_BUILTIN.db1?= no
.if !empty(CHECK_BUILTIN.db1:M[nN][oO])
+
. if !empty(USE_BUILTIN.db1:M[yY][eE][sS])
BUILDLINK_PREFIX.db1= /usr
-. for _inc_ in ${_DB_H_HEADERS}
-. if exists(${_inc_})
-BUILDLINK_INCDIRS.db1?= ${_inc_:H:S/^${BUILDLINK_PREFIX.db1}\///}
-. endif
-. endfor
-. if !empty(_BLNK_LIB_FOUND.db:M[yY][eE][sS])
+. if exists(${H_DB})
+BUILDLINK_INCDIRS.db1?= ${H_DB:H:S/^${BUILDLINK_PREFIX.db1}\///}
+. endif
+. if !empty(BUILTIN_LIB_FOUND.db:M[yY][eE][sS])
BUILDLINK_LDADD.db1= -ldb
-. elif !empty(_BLNK_LIB_FOUND.db1:M[yY][eE][sS])
+. elif !empty(BUILTIN_LIB_FOUND.db1:M[yY][eE][sS])
BUILDLINK_LDADD.db1= -ldb1
BUILDLINK_TRANSFORM+= l:db:db1
. else
BUILDLINK_LDADD.db1= # empty
. endif
BUILDLINK_LIBS.db1= ${BUILDLINK_LDADD.db1}
+. endif
BUILDLINK_TARGETS+= buildlink-db1-db185-h
-. for _inc_ in ${_DB_H_HEADERS}
-. if !target(buildlink-db1-db185-h)
+. if !target(buildlink-db1-db185-h)
.PHONY: buildlink-db1-db185-h
buildlink-db1-db185-h:
${_PKG_SILENT}${_PKG_DEBUG} \
- if ${TEST} ! -f ${BUILDLINK_DIR}/include/db_185.h; then \
- ${MKDIR} -p ${BUILDLINK_DIR}/include; \
- ${LN} -fs ${_inc_} ${BUILDLINK_DIR}/include/db_185.h; \
+ src=${H_DB:Q}; \
+ dest=${BUILDLINK_DIR:Q}"/include/db_185.h"; \
+ if ${TEST} -f "$$src" -a ! -f "$$dest"; then \
+ ${MKDIR} `${DIRNAME} "$$dest"`; \
+ ${LN} -fs "$$src" "$$dest"; \
fi
-. endif
-. endfor
+. endif
-. endif # USE_BUILTIN.db1 == yes
.endif # CHECK_BUILTIN.db1
diff --git a/mk/defaults/mk.conf b/mk/defaults/mk.conf
index 218110b978b..40e1ec3b30d 100644
--- a/mk/defaults/mk.conf
+++ b/mk/defaults/mk.conf
@@ -1,4 +1,4 @@
-# $NetBSD: mk.conf,v 1.50 2005/06/01 14:45:35 wiz Exp $
+# $NetBSD: mk.conf,v 1.51 2005/06/01 18:03:06 jlam Exp $
#
# A file providing defaults for pkgsrc and the packages collection.
@@ -195,8 +195,6 @@ VARBASE?= /var
X11ROOT_PREFIX?= XFree86
.elif defined(X11_TYPE) && !empty(X11_TYPE:Mxorg)
X11ROOT_PREFIX?= xorg
-USE_BUILTIN.Xfixes= yes
-USE_BUILTIN.Xcomposite= yes
.else
X11ROOT_PREFIX?= # empty
.endif
diff --git a/mk/dlopen.builtin.mk b/mk/dlopen.builtin.mk
index be0c1e54a81..29e6660c4c4 100644
--- a/mk/dlopen.builtin.mk
+++ b/mk/dlopen.builtin.mk
@@ -1,54 +1,78 @@
-# $NetBSD: dlopen.builtin.mk,v 1.10 2005/01/20 15:22:39 jlam Exp $
+# $NetBSD: dlopen.builtin.mk,v 1.11 2005/06/01 18:03:06 jlam Exp $
-.for _lib_ in dl
-. if !defined(_BLNK_LIB_FOUND.${_lib_})
-_BLNK_LIB_FOUND.${_lib_}!= \
- if ${TEST} "`${ECHO} /usr/lib/lib${_lib_}.*`" != "/usr/lib/lib${_lib_}.*"; then \
- ${ECHO} "yes"; \
- elif ${TEST} "`${ECHO} /lib/lib${_lib_}.*`" != "/lib/lib${_lib_}.*"; then \
- ${ECHO} "yes"; \
- else \
- ${ECHO} "no"; \
- fi
-BUILDLINK_VARS+= _BLNK_LIB_FOUND.${_lib_}
-. endif
-.endfor
-.undef _lib_
+BUILTIN_PKG:= dl
+
+BUILTIN_FIND_LIBS:= dl
+BUILTIN_FIND_FILES_VAR:= H_DL
+BUILTIN_FIND_FILES.H_DL= /usr/include/dlfcn.h \
+ /opt/gcc.3.3/include/dlfcn.h
+.include "../../mk/buildlink3/bsd.builtin.mk"
+
+###
+### Determine if there is a built-in implementation of the package and
+### set IS_BUILTIN.<pkg> appropriately ("yes" or "no").
+###
.if !defined(IS_BUILTIN.dl)
-IS_BUILTIN.dl= no
-. if exists(/usr/include/dlfcn.h) || exists(/opt/gcc.3.3/include/dlfcn.h)
-IS_BUILTIN.dl= yes
+IS_BUILTIN.dl= no
+. if empty(H_DL:M${LOCALBASE}/*) && exists(${H_DL})
+IS_BUILTIN.dl= yes
. endif
-BUILDLINK_VARS+= IS_BUILTIN.dl
-.endif # IS_BUILTIN.pthread
+.endif
+MAKEVARS+= IS_BUILTIN.dl
+###
+### Determine whether we should use the built-in implementation if it
+### exists, and set USE_BUILTIN.<pkg> appropriate ("yes" or "no").
+###
.if !defined(USE_BUILTIN.dl)
-USE_BUILTIN.dl= ${IS_BUILTIN.dl}
-. if ${OPSYS} == "Darwin"
+. if ${PREFER.dl} == "pkgsrc"
+USE_BUILTIN.dl= no
+. else
+USE_BUILTIN.dl= ${IS_BUILTIN.dl}
+. if defined(BUILTIN_PKG.dl) && \
+ !empty(IS_BUILTIN.dl:M[yY][eE][sS])
+USE_BUILTIN.dl= yes
+. for _dep_ in ${BUILDLINK_DEPENDS.dl}
+. if !empty(USE_BUILTIN.dl:M[yY][eE][sS])
+USE_BUILTIN.dl!= \
+ if ${PKG_ADMIN} pmatch ${_dep_:Q} ${BUILTIN_PKG.dl:Q}; then \
+ ${ECHO} yes; \
+ else \
+ ${ECHO} no; \
+ fi
+. endif
+. endfor
+. endif
+. if ${OPSYS} == "Darwin"
USE_BUILTIN.dl= no # Darwin uses devel/dlcompat
-. endif
+. endif
+. endif # PREFER.dl
.endif
-#
+MAKEVARS+= USE_BUILTIN.dl
+
# The following platforms require pthreads to be linked into the
# application if it uses dlopen() or else the applications will core
# dump when they dlopen a shared module that _is_ linked with pthread
# support.
#
-_DLOPEN_REQUIRE_PTHREAD_PLATFORMS= \
+_BLNK_DLOPEN_REQUIRE_PTHREAD_PLATFORMS= \
NetBSD-2.[0-9]_*-* \
NetBSD-2.[0-9]-* NetBSD-2.[0-9].[0-9]*-* \
NetBSD-2.[0-8][0-9]*-* NetBSD-2.9[0-8]*-* \
NetBSD-2.99.[0-9]-* NetBSD-2.99.10-*
-_DLOPEN_REQUIRE_PTHREADS?= no
-.for _pattern_ in ${_DLOPEN_REQUIRE_PTHREAD_PLATFORMS}
-. if !empty(MACHINE_PLATFORM:M${_pattern_})
-. if !empty(PREFER_NATIVE_PTHREADS:M[yY][eE][sS])
-_DLOPEN_REQUIRE_PTHREADS= yes
+.if !defined(_BLNK_DLOPEN_REQUIRE_PTHREADS)
+_BLNK_DLOPEN_REQUIRE_PTHREADS?= no
+. for _pattern_ in ${_BLNK_DLOPEN_REQUIRE_PTHREAD_PLATFORMS}
+. if !empty(MACHINE_PLATFORM:M${_pattern_})
+. if !empty(PREFER_NATIVE_PTHREADS:M[yY][eE][sS])
+_BLNK_DLOPEN_REQUIRE_PTHREADS= yes
+. endif
. endif
-. endif
-.endfor
+. endfor
+.endif
+MAKEVARS+= _BLNK_DLOPEN_REQUIRE_PTHREADS
#
# DLOPEN_REQUIRE_PTHREADS is a user- and package-settable yes/no variable
# whose value decides whether pthread.buildlink3.mk is automatically
@@ -56,24 +80,28 @@ _DLOPEN_REQUIRE_PTHREADS= yes
# pthreads exist.
#
.if defined(DLOPEN_REQUIRE_PTHREADS)
-_DLOPEN_REQUIRE_PTHREADS:= ${DLOPEN_REQUIRE_PTHREADS}
+_BLNK_DLOPEN_REQUIRE_PTHREADS:= ${DLOPEN_REQUIRE_PTHREADS}
.else
-DLOPEN_REQUIRE_PTHREADS= ${_DLOPEN_REQUIRE_PTHREADS}
+DLOPEN_REQUIRE_PTHREADS= ${_BLNK_DLOPEN_REQUIRE_PTHREADS}
.endif
+###
+### The section below only applies if we are not including this file
+### solely to determine whether a built-in implementation exists.
+###
CHECK_BUILTIN.dl?= no
.if !empty(CHECK_BUILTIN.dl:M[nN][oO])
. if !empty(USE_BUILTIN.dl:M[yY][eE][sS])
BUILDLINK_PREFIX.dl= /usr
-. if !empty(_BLNK_LIB_FOUND.dl:M[yY][eE][sS])
+. if !empty(BUILTIN_LIB_FOUND.dl:M[yY][eE][sS])
#
# No need to add this to BUILDLINK_LIBS.dl since most GNU configure
# scripts already check for -ldl themselves.
#
BUILDLINK_LDADD.dl= -ldl
. endif
-. if !empty(_DLOPEN_REQUIRE_PTHREADS:M[yY][eE][sS])
+. if !empty(_BLNK_DLOPEN_REQUIRE_PTHREADS:M[yY][eE][sS])
BUILDLINK_DEPTH:= ${BUILDLINK_DEPTH}+
. include "../../mk/pthread.buildlink3.mk"
BUILDLINK_DEPTH:= ${BUILDLINK_DEPTH:S/+$//}
@@ -82,6 +110,6 @@ BUILDLINK_CFLAGS.dl+= ${PTHREAD_CFLAGS}
BUILDLINK_LDFLAGS.dl+= ${PTHREAD_LDFLAGS}
BUILDLINK_LIBS.dl+= ${PTHREAD_LIBS}
. endif
-. endif # USE_BUILTIN.dl == yes
+. endif
.endif # CHECK_BUILTIN.dl
diff --git a/mk/motif.buildlink3.mk b/mk/motif.buildlink3.mk
index 674eed4c3c4..54d3802cff3 100644
--- a/mk/motif.buildlink3.mk
+++ b/mk/motif.buildlink3.mk
@@ -1,4 +1,4 @@
-# $NetBSD: motif.buildlink3.mk,v 1.7 2005/05/22 21:44:07 rillig Exp $
+# $NetBSD: motif.buildlink3.mk,v 1.8 2005/06/01 18:03:06 jlam Exp $
#
# MOTIFBASE
# choose the Motif-2.0 installation at the named location.
@@ -79,7 +79,8 @@ MOTIF_TYPE:= ${_MOTIF_TYPE}
MOTIFBASE= ${_MOTIFBASE}
.endif
-USE_X11?= yes
+.include "../../mk/x11.buildlink3.mk"
+
MAKE_ENV+= MOTIFLIB="${MOTIFLIB}"
MAKE_ENV+= MOTIFBASE="${_MOTIFBASE}"
CPPFLAGS+= -I${_MOTIFBASE}/include
diff --git a/mk/pthread.builtin.mk b/mk/pthread.builtin.mk
index 87a93995fed..8d99d147fe1 100644
--- a/mk/pthread.builtin.mk
+++ b/mk/pthread.builtin.mk
@@ -1,28 +1,30 @@
-# $NetBSD: pthread.builtin.mk,v 1.7 2005/01/17 08:29:30 jlam Exp $
+# $NetBSD: pthread.builtin.mk,v 1.8 2005/06/01 18:03:06 jlam Exp $
-.for _lib_ in pthread c_r rt
-. if !defined(_BLNK_LIB_FOUND.${_lib_})
-_BLNK_LIB_FOUND.${_lib_}!= \
- if ${TEST} "`${ECHO} /usr/lib/lib${_lib_}.*`" != "/usr/lib/lib${_lib_}.*"; then \
- ${ECHO} "yes"; \
- elif ${TEST} "`${ECHO} /lib/lib${_lib_}.*`" != "/lib/lib${_lib_}.*"; then \
- ${ECHO} "yes"; \
- else \
- ${ECHO} "no"; \
- fi
-BUILDLINK_VARS+= _BLNK_LIB_FOUND.${_lib_}
-. endif
-.endfor
-.undef _lib_
+BUILTIN_PKG:= pthread
+
+BUILTIN_FIND_LIBS:= pthread c_r rt
+BUILTIN_FIND_FILES_VAR= H_PTHREAD
+BUILTIN_FIND_FILES.H_PTHREAD= /usr/include/pthread.h
+
+.include "../../mk/buildlink3/bsd.builtin.mk"
+###
+### Determine if there is a built-in implementation of the package and
+### set IS_BUILTIN.<pkg> appropriately ("yes" or "no").
+###
.if !defined(IS_BUILTIN.pthread)
IS_BUILTIN.pthread= no
-. if exists(/usr/include/pthread.h)
+. if empty(H_PTHREAD:M${LOCALBASE}/*) && exists(${H_PTHREAD})
IS_BUILTIN.pthread= yes
. endif
-BUILDLINK_VARS+= IS_BUILTIN.pthread
-.endif # IS_BUILTIN.pthread
+.endif
+MAKEVARS+= IS_BUILTIN.pthread
+###
+### Determine whether we should use the built-in implementation if it
+### exists, and set USE_BUILTIN.<pkg> appropriate ("yes" or "no").
+###
+#
# We ignore the value of PREFER_PKGSRC and PREFER_NATIVE. Whether we
# prefer one or the other is dependent on the value of
# PREFER_NATIVE_PTHREADS, which is yes/no.
@@ -33,10 +35,14 @@ USE_BUILTIN.pthread= ${IS_BUILTIN.pthread}
USE_BUILTIN.pthread= no
.endif
+###
+### The section below only applies if we are not including this file
+### solely to determine whether a built-in implementation exists.
+###
CHECK_BUILTIN.pthread?= no
.if !empty(CHECK_BUILTIN.pthread:M[nN][oO])
-.if !empty(USE_BUILTIN.pthread:M[yY][eE][sS])
+. if !empty(USE_BUILTIN.pthread:M[yY][eE][sS])
BUILDLINK_PREFIX.pthread= /usr
BUILDLINK_CFLAGS.pthread= # empty
BUILDLINK_LDFLAGS.pthread= # empty
@@ -46,33 +52,33 @@ BUILDLINK_LDFLAGS.pthread= # empty
# XXX This should really be a check for GCC!
# XXX
BUILDLINK_OPSYS_SUPPORT_PTHREAD= DragonFly FreeBSD Linux NetBSD
-. if !empty(BUILDLINK_OPSYS_SUPPORT_PTHREAD:M${OPSYS})
+. if !empty(BUILDLINK_OPSYS_SUPPORT_PTHREAD:M${OPSYS})
BUILDLINK_CFLAGS.pthread+= -pthread
BUILDLINK_LDFLAGS.pthread+= -pthread
-. elif ${OPSYS} == "OSF1"
+. elif ${OPSYS} == "OSF1"
BUILDLINK_CFLAGS.pthread+= -pthread
-. else
+. else
BUILDLINK_CPPFLAGS.pthread+= -D_REENTRANT
-. endif
-. if ${OPSYS} == "FreeBSD"
+. endif
+. if ${OPSYS} == "FreeBSD"
BUILDLINK_CPPFLAGS.pthread+= -D_THREAD_SAFE
-. endif
+. endif
# Handle systems which have pthreads functions in libc_r such as
# FreeBSD 5.x, or fall back to libc if we don't find libc_r.
#
-. if ${OPSYS} == "NetBSD"
+. if ${OPSYS} == "NetBSD"
BUILDLINK_LIBS.pthread= # empty
-. elif !empty(_BLNK_LIB_FOUND.pthread:M[yY][eE][sS])
+. elif !empty(BUILTIN_LIB_FOUND.pthread:M[yY][eE][sS])
BUILDLINK_LIBS.pthread= -lpthread
-. if !empty(_BLNK_LIB_FOUND.rt:M[yY][eE][sS])
+. if !empty(BUILTIN_LIB_FOUND.rt:M[yY][eE][sS])
BUILDLINK_LIBS.pthread+= -lrt
-. endif
-. elif !empty(_BLNK_LIB_FOUND.c_r:M[yY][eE][sS])
+. endif
+. elif !empty(BUILTIN_LIB_FOUND.c_r:M[yY][eE][sS])
BUILDLINK_LIBS.pthread= -lc_r
-. else
+. else
BUILDLINK_LIBS.pthread= # empty
+. endif
. endif
-.endif # USE_BUILTIN.pthread
.endif # CHECK_BUILTIN.pthread
diff --git a/mk/solaris-pam.builtin.mk b/mk/solaris-pam.builtin.mk
index 7245ee78f88..277e9243eaa 100644
--- a/mk/solaris-pam.builtin.mk
+++ b/mk/solaris-pam.builtin.mk
@@ -1,28 +1,48 @@
-# $NetBSD: solaris-pam.builtin.mk,v 1.2 2005/01/14 07:54:20 jlam Exp $
+# $NetBSD: solaris-pam.builtin.mk,v 1.3 2005/06/01 18:03:06 jlam Exp $
-_SOLARIS_PAM_APPL_HEADERS= /usr/include/security/pam_appl.h
-_SOLARIS_PAM_IDENT= Copyright.*Sun Microsystems
+BUILTIN_PKG:= solaris-pam
+BUILTIN_FIND_FILES_VAR:= H_SOLARIS_PAM
+BUILTIN_FIND_FILES.H_SOLARIS_PAM= /usr/include/security/pam_appl.h
+BUILTIN_FIND_GREP.H_SOLARIS_PAM= Copyright.*Sun Microsystems
+
+.include "../../mk/buildlink3/bsd.builtin.mk"
+
+###
+### Determine if there is a built-in implementation of the package and
+### set IS_BUILTIN.<pkg> appropriately ("yes" or "no").
+###
.if !defined(IS_BUILTIN.solaris-pam)
-IS_BUILTIN.solaris-pam= no
-. for _inc_ in ${_SOLARIS_PAM_APPL_HEADERS}
-. if !empty(IS_BUILTIN.solaris-pam:M[nN][oO]) && exists(${_inc_})
-IS_BUILTIN.solaris-pam!= \
- case ${_inc_} in \
- ${LOCALBASE}/*) \
- ${ECHO} "no"; \
- ;; \
- *) \
- if ${GREP} -q "${_SOLARIS_PAM_IDENT}" ${_inc_}; then \
- ${ECHO} "yes"; \
- else \
- ${ECHO} "no"; \
- fi; \
- ;; \
- esac
-. endif
-. endfor
-BUILDLINK_VARS+= IS_BUILTIN.solaris-pam
-.endif # IS_BUILTIN.solaris-pam
+IS_BUILTIN.solaris-pam= no
+. if empty(H_SOLARIS_PAM:M${LOCALBASE}/*) && exists(${H_SOLARIS_PAM})
+IS_BUILTIN.solaris-pam= yes
+. endif
+.endif
+MAKEVARS+= IS_BUILTIN.solaris-pam
-USE_BUILTIN.solaris-pam?= ${IS_BUILTIN.solaris-pam}
+###
+### Determine whether we should use the built-in implementation if it
+### exists, and set USE_BUILTIN.<pkg> appropriate ("yes" or "no").
+###
+.if !defined(USE_BUILTIN.solaris-pam)
+. if ${PREFER.solaris-pam} == "pkgsrc"
+USE_BUILTIN.solaris-pam= no
+. else
+USE_BUILTIN.solaris-pam= ${IS_BUILTIN.solaris-pam}
+. if defined(BUILTIN_PKG.solaris-pam) && \
+ !empty(IS_BUILTIN.solaris-pam:M[yY][eE][sS])
+USE_BUILTIN.solaris-pam= yes
+. for _dep_ in ${BUILDLINK_DEPENDS.solaris-pam}
+. if !empty(USE_BUILTIN.solaris-pam:M[yY][eE][sS])
+USE_BUILTIN.solaris-pam!= \
+ if ${PKG_ADMIN} pmatch ${_dep_:Q} ${BUILTIN_PKG.solaris-pam:Q}; then \
+ ${ECHO} yes; \
+ else \
+ ${ECHO} no; \
+ fi
+. endif
+. endfor
+. endif
+. endif # PREFER.solaris-pam
+.endif
+MAKEVARS+= USE_BUILTIN.solaris-pam
diff --git a/mk/x11.buildlink3.mk b/mk/x11.buildlink3.mk
new file mode 100644
index 00000000000..4ab3c82e865
--- /dev/null
+++ b/mk/x11.buildlink3.mk
@@ -0,0 +1,22 @@
+# $NetBSD: x11.buildlink3.mk,v 1.1 2005/06/01 18:03:06 jlam Exp $
+#
+# This Makefile fragment is meant to be included by packages that
+# require an X11 distribution. x11.buildlink3.mk will include the
+# buildlink3.mk file from the appropriate X11 distribution.
+#
+
+.include "../../mk/bsd.prefs.mk"
+
+USE_X11= yes
+
+.include "../../mk/x11.version.mk"
+
+.if defined(GNU_CONFIGURE)
+CONFIGURE_ARGS+= --x-includes=${X11BASE:Q}/include
+CONFIGURE_ARGS+= --x-libraries=${X11BASE:Q}/lib${LIBABISUFFIX:Q}
+.endif
+
+X11_LDFLAGS+= ${COMPILER_RPATH_FLAG}${X11BASE}/lib${LIBABISUFFIX}
+X11_LDFLAGS+= -L${X11BASE}/lib${LIBABISUFFIX}
+
+.sinclude "${X11_PKGSRCDIR.${X11_TYPE}}/buildlink3.mk"
diff --git a/mk/x11.builtin.mk b/mk/x11.builtin.mk
new file mode 100644
index 00000000000..732dab80503
--- /dev/null
+++ b/mk/x11.builtin.mk
@@ -0,0 +1,8 @@
+# $NetBSD: x11.builtin.mk,v 1.1 2005/06/01 18:03:06 jlam Exp $
+#
+# x11.builtin.mk will include the builtin.mk file from the appropriate
+# X11 distribution.
+#
+
+.include "../../mk/x11.version.mk"
+.sinclude "${X11_PKGSRCDIR.${X11_TYPE}}/builtin.mk"
diff --git a/mk/x11.version.mk b/mk/x11.version.mk
new file mode 100644
index 00000000000..883823bbb20
--- /dev/null
+++ b/mk/x11.version.mk
@@ -0,0 +1,31 @@
+# $NetBSD: x11.version.mk,v 1.1 2005/06/01 18:03:06 jlam Exp $
+#
+# The following variables may be set in /etc/mk.conf:
+#
+# X11_TYPE sets the X11 distribution used when building X11 packages.
+# Possible values are "xorg" (use x11/xorg-libs), "XFree86" (use
+# x11/XFree86-libs), or "native" (use the native X11 distribution).
+# The default X11_TYPE is "native".
+#
+# The following variables are provided by this file:
+#
+# X11_PKGSRCDIR.${X11_TYPE} sets the pkgsrc directory location for
+# the package which manages/represents ${X11_TYPE}. It can be
+# used to find the relevant buildlink3.mk or builtin.mk files.
+#
+# BUILTIN_X11_TYPE.${X11_TYPE} is the X11_TYPE of the native X11
+# distribution detected on the system.
+#
+# BUILTIN_X11_VERSION.${X11_TYPE} is the version number of the native
+# X11 distribution detected on the system.
+#
+
+X11_TYPE?= native
+X11_PKGSRCDIR.native= ../../pkgtools/x11-links
+X11_PKGSRCDIR.XFree86= ../../x11/XFree86-libs
+X11_PKGSRCDIR.xorg= ../../x11/xorg-libs
+
+# Makefiles that include this file can access the version of the X11
+# distribution as ${BUILTIN_X11_VERSION.${X11_TYPE}}.
+#
+.sinclude "${X11_PKGSRCDIR.${X11_TYPE}}/version.mk"
diff --git a/mk/xaw.buildlink3.mk b/mk/xaw.buildlink3.mk
index 471cd55e855..1a049fcbf93 100644
--- a/mk/xaw.buildlink3.mk
+++ b/mk/xaw.buildlink3.mk
@@ -1,4 +1,4 @@
-# $NetBSD: xaw.buildlink3.mk,v 1.1 2004/04/11 23:35:16 xtraeme Exp $
+# $NetBSD: xaw.buildlink3.mk,v 1.2 2005/06/01 18:03:06 jlam Exp $
.if !defined(XAW_BUILDLINK3_MK)
XAW_BUILDLINK3_MK= # defined
@@ -18,6 +18,7 @@ BUILDLINK_PREFIX.Xaw?= ${BUILDLINK_PREFIX.Xaw3d}
. include "../../x11/neXtaw/buildlink3.mk"
BUILDLINK_PREFIX.Xaw?= ${BUILDLINK_PREFIX.neXtaw}
.else
+. include "../../mk/x11.buildlink3.mk"
BUILDLINK_PREFIX.Xaw?= ${X11BASE}
.endif