summaryrefslogtreecommitdiff
path: root/mk/buildlink3
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/buildlink3
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/buildlink3')
-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
4 files changed, 179 insertions, 102 deletions
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_