summaryrefslogtreecommitdiff
path: root/mk/pkgformat/pkg
diff options
context:
space:
mode:
authorriastradh <riastradh>2013-05-09 23:37:25 +0000
committerriastradh <riastradh>2013-05-09 23:37:25 +0000
commitcec703cf29d80e63a369189af54c1ccdc7995248 (patch)
treeeef7f13a77e111e43481a085f3d5cf0aabb03aa6 /mk/pkgformat/pkg
parentb4ea6815358e106ab97e451afb9445aefa5c0f6b (diff)
downloadpkgsrc-cec703cf29d80e63a369189af54c1ccdc7995248.tar.gz
Split BUILD_DEPENDS into TOOL_DEPENDS and BUILD_DEPENDS in mk/.
Build depends are target packages that are needed at build-time for, e.g., static libraries to link against, header files to include, &c. Tool depends are native packages that are needed at build-time for, e.g., compilers/linkers/&c. to run. ok agc
Diffstat (limited to 'mk/pkgformat/pkg')
-rw-r--r--mk/pkgformat/pkg/deinstall.mk3
-rw-r--r--mk/pkgformat/pkg/depends.mk63
-rwxr-xr-xmk/pkgformat/pkg/list-dependencies9
-rw-r--r--mk/pkgformat/pkg/pkgformat-vars.mk17
-rw-r--r--mk/pkgformat/pkg/reduce-resolved-depends.awk46
-rwxr-xr-xmk/pkgformat/pkg/resolve-dependencies9
6 files changed, 119 insertions, 28 deletions
diff --git a/mk/pkgformat/pkg/deinstall.mk b/mk/pkgformat/pkg/deinstall.mk
index 5928a41ac5b..e34a8b3a330 100644
--- a/mk/pkgformat/pkg/deinstall.mk
+++ b/mk/pkgformat/pkg/deinstall.mk
@@ -1,4 +1,4 @@
-# $NetBSD: deinstall.mk,v 1.1 2011/10/15 00:23:09 reed Exp $
+# $NetBSD: deinstall.mk,v 1.2 2013/05/09 23:37:26 riastradh Exp $
# Set the appropriate flags to pass to pkg_delete(1) based on the value
# of DEINSTALLDEPENDS (see pkgsrc/mk/install/deinstall.mk).
@@ -46,6 +46,7 @@ _pkgformat-deinstall: .PHONY
${PKG_DELETE} ${_PKG_ARGS_DEINSTALL} "$$found" || ${TRUE} ; \
fi
.if defined(DEINSTALLDEPENDS) && !empty(DEINSTALLDEPENDS:M[yY][eE][sS])
+# XXX Need to handle BUILD_DEPENDS/TOOL_DEPENDS split.
. for _pkg_ in ${BUILD_DEPENDS:C/:.*$//}
${RUN} \
found=`${_PKG_BEST_EXISTS} ${_pkg_:Q} || ${TRUE}`; \
diff --git a/mk/pkgformat/pkg/depends.mk b/mk/pkgformat/pkg/depends.mk
index d5ebf1174ed..c85ef5054e8 100644
--- a/mk/pkgformat/pkg/depends.mk
+++ b/mk/pkgformat/pkg/depends.mk
@@ -1,4 +1,4 @@
-# $NetBSD: depends.mk,v 1.2 2012/07/02 14:53:13 joerg Exp $
+# $NetBSD: depends.mk,v 1.3 2013/05/09 23:37:26 riastradh Exp $
# This command prints out the dependency patterns for all full (run-time)
# dependencies of the package.
@@ -33,18 +33,26 @@ _FULL_DEPENDS_CMD= \
${AWK} '$$1 == "full" { print $$3; }' < ${_RDEPENDS_FILE}
_REDUCE_DEPENDS_CMD= ${PKGSRC_SETENV} CAT=${CAT:Q} \
- PKG_ADMIN=${PKG_ADMIN_CMD:Q} \
+ PKG_ADMIN=${PKG_ADMIN:Q} \
+ PWD_CMD=${PWD_CMD:Q} TEST=${TEST:Q} \
+ ${AWK} -f ${PKGSRCDIR}/mk/pkgformat/pkg/reduce-depends.awk
+
+_HOST_REDUCE_DEPENDS_CMD= \
+ ${PKGSRC_SETENV} CAT=${CAT:Q} \
+ PKG_ADMIN=${HOST_PKG_ADMIN:Q} \
PWD_CMD=${PWD_CMD:Q} TEST=${TEST:Q} \
${AWK} -f ${PKGSRCDIR}/mk/pkgformat/pkg/reduce-depends.awk
_REDUCE_RESOLVED_DEPENDS_CMD=${PKGSRC_SETENV} CAT=${CAT:Q} \
- PKG_INFO=${PKG_INFO_CMD:Q} \
+ PKG_INFO=${PKG_INFO:Q} \
+ HOST_PKG_INFO=${HOST_PKG_INFO:Q} \
${AWK} -f ${PKGSRCDIR}/mk/pkgformat/pkg/reduce-resolved-depends.awk \
< ${_RDEPENDS_FILE}
_pkgformat-show-depends: .PHONY
@case ${VARNAME:Q}"" in \
BUILD_DEPENDS) ${_REDUCE_DEPENDS_CMD} ${BUILD_DEPENDS:Q} ;; \
+ TOOL_DEPENDS) ${_HOST_REDUCE_DEPENDS_CMD} ${TOOL_DEPENDS:Q} ;;\
DEPENDS|*) ${_REDUCE_DEPENDS_CMD} ${DEPENDS:Q} ;; \
esac
@@ -53,6 +61,7 @@ _LIST_DEPENDS_CMD= \
PKGSRCDIR=${PKGSRCDIR:Q} PWD_CMD=${PWD_CMD:Q} SED=${SED:Q} \
${SH} ${PKGSRCDIR}/mk/pkgformat/pkg/list-dependencies \
" "${BOOTSTRAP_DEPENDS:Q} \
+ " "${TOOL_DEPENDS:Q} \
" "${BUILD_DEPENDS:Q} \
" "${DEPENDS:Q}
@@ -60,13 +69,15 @@ _LIST_DEPENDS_CMD.bootstrap= \
${PKGSRC_SETENV} AWK=${AWK:Q} PKG_ADMIN=${PKG_ADMIN:Q} \
PKGSRCDIR=${PKGSRCDIR:Q} PWD_CMD=${PWD_CMD:Q} SED=${SED:Q} \
${SH} ${PKGSRCDIR}/mk/pkgformat/pkg/list-dependencies \
- " "${BOOTSTRAP_DEPENDS:Q} " " " "
+ " "${BOOTSTRAP_DEPENDS:Q} " " " " " "
_RESOLVE_DEPENDS_CMD= \
${PKGSRC_SETENV} _PKG_DBDIR=${_PKG_DBDIR:Q} PKG_INFO=${PKG_INFO:Q} \
+ HOST_PKG_INFO=${HOST_PKG_INFO:Q} \
_DEPENDS_FILE=${_DEPENDS_FILE:Q} \
${SH} ${PKGSRCDIR}/mk/pkgformat/pkg/resolve-dependencies \
" "${BOOTSTRAP_DEPENDS:Q} \
+ " "${TOOL_DEPENDS:Q} \
" "${BUILD_DEPENDS:Q} \
" "${DEPENDS:Q}
@@ -76,12 +87,29 @@ _RESOLVE_DEPENDS_CMD= \
# @param $pattern The pattern of the package to be installed.
# @param $dir The pkgsrc directory from which the package can be
# built.
-# @param $type The dependency type. Can be one of bootstrap,
+# @param $type The dependency type. Can be one of bootstrap, tool,
# build, full.
#
_DEPENDS_INSTALL_CMD= \
- pkg=`${_PKG_BEST_EXISTS} "$$pattern" || ${TRUE}`; \
- case $$type in bootstrap) Type=Bootstrap;; build) Type=Build;; full) Type=Full;; esac; \
+ case $$type in bootstrap) Type=Bootstrap;; tool) Type=Tool;; build) Type=Build;; full) Type=Full;; esac; \
+ case $$type in \
+ bootstrap|tool) \
+ if expr "${USE_CROSS_COMPILE:Uno}" : '[yY][eE][sS]' >/dev/null; then \
+ extradep=""; \
+ else \
+ extradep=" ${PKGNAME}"; \
+ fi; \
+ cross=no; \
+ archopt=TARGET_ARCH=${MACHINE_ARCH}; \
+ pkg=`${_HOST_PKG_BEST_EXISTS} "$$pattern" || ${TRUE}`; \
+ ;; \
+ build|full) \
+ extradep=" ${PKGNAME}"; \
+ cross=${USE_CROSS_COMPILE:Uno}; \
+ archopt=; \
+ pkg=`${_PKG_BEST_EXISTS} "$$pattern" || ${TRUE}`; \
+ ;; \
+ esac; \
case "$$pkg" in \
"") \
${STEP_MSG} "$$Type dependency $$pattern: NOT found"; \
@@ -89,8 +117,18 @@ _DEPENDS_INSTALL_CMD= \
${STEP_MSG} "Verifying $$target for $$dir"; \
[ -d "$$dir" ] || ${FAIL_MSG} "[depends.mk] The directory \`\`$$dir'' does not exist."; \
cd $$dir; \
- ${PKGSRC_SETENV} ${PKGSRC_MAKE_ENV} _PKGSRC_DEPS=" ${PKGNAME}${_PKGSRC_DEPS}" PKGNAME_REQD="$$pattern" ${MAKE} ${MAKEFLAGS} _AUTOMATIC=yes $$target; \
- pkg=`${_PKG_BEST_EXISTS} "$$pattern" || ${TRUE}`; \
+ ${PKGSRC_SETENV} ${PKGSRC_MAKE_ENV} \
+ _PKGSRC_DEPS="$$extradep${_PKGSRC_DEPS}" \
+ PKGNAME_REQD="$$pattern" \
+ USE_CROSS_COMPILE=$$cross \
+ $$archopt \
+ ${MAKE} ${MAKEFLAGS} _AUTOMATIC=yes $$target; \
+ case $$type in \
+ bootstrap|tool) \
+ pkg=`${_HOST_PKG_BEST_EXISTS} "$$pattern" || ${TRUE}`;; \
+ build|full) \
+ pkg=`${_PKG_BEST_EXISTS} "$$pattern" || ${TRUE}`;; \
+ esac; \
case "$$pkg" in \
"") ${ERROR_MSG} "[depends.mk] A package matching \`\`$$pattern'' should"; \
${ERROR_MSG} " be installed, but one cannot be found. Perhaps there is a"; \
@@ -100,7 +138,12 @@ _DEPENDS_INSTALL_CMD= \
${STEP_MSG} "Returning to build of ${PKGNAME}"; \
;; \
*) \
- objfmt=`${PKG_INFO} -Q OBJECT_FMT "$$pkg"`; \
+ case $$type in \
+ bootstrap|tool) \
+ objfmt=`${HOST_PKG_INFO} -Q OBJECT_FMT "$$pkg"`;; \
+ build|full) \
+ objfmt=`${PKG_INFO} -Q OBJECT_FMT "$$pkg"`;; \
+ esac; \
case "$$objfmt" in \
"") ${WARNING_MSG} "[depends.mk] Unknown object format for installed package $$pkg" ;; \
${OBJECT_FMT}) ;; \
diff --git a/mk/pkgformat/pkg/list-dependencies b/mk/pkgformat/pkg/list-dependencies
index a7c6d9c37ae..81b926670f4 100755
--- a/mk/pkgformat/pkg/list-dependencies
+++ b/mk/pkgformat/pkg/list-dependencies
@@ -57,11 +57,12 @@ print_entries() {
done
}
-if [ $# != 3 ]; then
- echo "usage: list-dependencies bootstrap_depends build_depends depends" 1>&2
+if [ $# != 4 ]; then
+ echo "usage: list-dependencies bootstrap_depends tool_depends build_depends depends" 1>&2
exit 1
fi
print_entries bootstrap "$1"
-print_entries build "$2"
-print_entries full "$3"
+print_entries tool "$2"
+print_entries build "$3"
+print_entries full "$4"
diff --git a/mk/pkgformat/pkg/pkgformat-vars.mk b/mk/pkgformat/pkg/pkgformat-vars.mk
index 246dcc33d8d..8aa81ea6167 100644
--- a/mk/pkgformat/pkg/pkgformat-vars.mk
+++ b/mk/pkgformat/pkg/pkgformat-vars.mk
@@ -1,4 +1,4 @@
-# $NetBSD: pkgformat-vars.mk,v 1.2 2011/12/13 16:35:48 joerg Exp $
+# $NetBSD: pkgformat-vars.mk,v 1.3 2013/05/09 23:37:26 riastradh Exp $
#
# This Makefile fragment is included indirectly by bsd.prefs.mk and
# defines some variables which must be defined earlier than where
@@ -23,8 +23,10 @@ PKG_DBDIR?= /var/db/pkg
#
.if ${PKG_INSTALLATION_TYPE} == "overwrite"
_PKG_DBDIR= ${_CROSS_DESTDIR}${PKG_DBDIR}
+_HOST_PKG_DBDIR= ${HOST_PKG_DBDIR:U${PKG_DBDIR}}
.elif ${PKG_INSTALLATION_TYPE} == "pkgviews"
_PKG_DBDIR= ${_CROSS_DESTDIR}${DEPOTBASE}
+_HOST_PKG_DBDIR= ${HOST_DEPOTBASE:U${DEPOTBASE}}
.endif
PKG_ADD_CMD?= ${PKG_TOOLS_BIN}/pkg_add
@@ -67,12 +69,14 @@ _AUDIT_CONFIG_OPTION= IGNORE_URL
# correct package database directory.
#
PKGTOOLS_ARGS?= -K ${_PKG_DBDIR}
+HOST_PKGTOOLS_ARGS?= -K ${_HOST_PKG_DBDIR}
# Views are rooted in ${LOCALBASE}, all packages are depoted in
# ${DEPOTBASE}, and the package database directory for the default view
# is in ${PKG_DBDIR}.
#
-PKG_VIEW_ARGS?= -W ${LOCALBASE} -d ${DEPOTBASE} -k ${PKG_DBDIR}
+PKG_VIEW_ARGS?= -W ${LOCALBASE} -d ${DEPOTBASE} -k ${_CROSS_DESTDIR}${PKG_DBDIR}
+HOST_PKG_VIEW_ARGS?= -W ${LOCALBASE} -d ${DEPOTBASE} -k ${PKG_DBDIR}
PKG_ADD?= ${PKG_ADD_CMD} ${PKGTOOLS_ARGS}
PKG_ADMIN?= ${PKG_ADMIN_CMD} ${PKGTOOLS_ARGS}
@@ -82,12 +86,21 @@ PKG_INFO?= ${PKG_INFO_CMD} ${PKGTOOLS_ARGS}
PKG_VIEW?= ${PKG_VIEW_CMD} ${PKG_VIEW_ARGS}
LINKFARM?= ${LINKFARM_CMD}
+HOST_PKG_ADD?= ${PKG_ADD_CMD} ${HOST-PKGTOOLS_ARGS}
+HOST_PKG_ADMIN?= ${PKG_ADMIN_CMD} ${HOST_PKGTOOLS_ARGS}
+HOST_PKG_CREATE?= ${PKG_CREATE_CMD} ${HOST_PKGTOOLS_ARGS}
+HOST_PKG_DELETE?= ${PKG_DELETE_CMD} ${HOST_PKGTOOLS_ARGS}
+HOST_PKG_INFO?= ${PKG_INFO_CMD} ${HOST_PKGTOOLS_ARGS}
+HOST_PKG_VIEW?= ${PKG_VIEW_CMD} ${HOST_PKG_VIEW_ARGS}
+HOST_LINKFARM?= ${LINKFARM_CMD}
+
# "${_PKG_BEST_EXISTS} pkgpattern" prints out the name of the installed
# package that best matches pkgpattern. Use this instead of
# "${PKG_INFO} -e pkgpattern" if the latter would return more than one
# package name.
#
_PKG_BEST_EXISTS?= ${PKG_INFO} -E
+_HOST_PKG_BEST_EXISTS?= ${HOST_PKG_INFO} -E
# XXX Leave this here until all uses of this have been purged from the
# XXX public parts of pkgsrc.
diff --git a/mk/pkgformat/pkg/reduce-resolved-depends.awk b/mk/pkgformat/pkg/reduce-resolved-depends.awk
index 0e60a09344f..32ca12c41e6 100644
--- a/mk/pkgformat/pkg/reduce-resolved-depends.awk
+++ b/mk/pkgformat/pkg/reduce-resolved-depends.awk
@@ -1,6 +1,6 @@
#!/usr/bin/awk -f
#
-# $NetBSD: reduce-resolved-depends.awk,v 1.1 2012/07/02 14:53:13 joerg Exp $
+# $NetBSD: reduce-resolved-depends.awk,v 1.2 2013/05/09 23:37:26 riastradh Exp $
#
# Copyright (c) 2012 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -46,12 +46,14 @@
# ENVIRONMENT
# CAT
# PKG_INFO
+# HOST_PKG_INFO (for cross-compilation)
#
######################################################################
BEGIN {
CAT = ENVIRON["CAT"] ? ENVIRON["CAT"] : "cat"
PKG_INFO = ENVIRON["PKG_INFO"] ? ENVIRON["PKG_INFO"] : "pkg_info"
+ HOST_PKG_INFO = ENVIRON["HOST_PKG_INFO"] ? ENVIRON["HOST_PKG_INFO"] : "pkg_info"
PROGNAME = "reduce-resolved-depends.awk"
ERRCAT = CAT " 1>&2"
@@ -61,7 +63,10 @@ BEGIN {
print "ERROR: [" PROGNAME "] invalid dependency line " $0 | ERRCAT
exit 1
}
- if ($1 != "full" && $1 != "build" && $1 != "bootstrap") {
+ if ($1 != "full" &&
+ $1 != "build" &&
+ $1 != "tool" &&
+ $1 != "bootstrap") {
print "ERROR: [" PROGNAME "] invalid dependency line " $0 | ERRCAT
exit 1
}
@@ -77,6 +82,7 @@ BEGIN {
if (type[i] == "full" && checked_full[pkg[i]] != 1) {
checked_full[pkg[i]] = 1
checked_build[pkg[i]] = 1
+ checked_tool[pkg[i]] = 1
checked_bootstrap[pkg[i]] = 1
print_line[i] = 1
}
@@ -86,23 +92,45 @@ BEGIN {
if (type[i] == "bootstrap" && checked_bootstrap[pkg[i]] != 1) {
checked_bootstrap[pkg[i]] = 1
found = 0
- cmd = PKG_INFO " -qr " pkg[i]
- while (cmd | getline dpkg) {
- if (checked_full[dpkg] == 1)
- found = 1
+ if (PKG_INFO == HOST_PKG_INFO) {
+ cmd = PKG_INFO " -qr " pkg[i]
+ while (cmd | getline dpkg) {
+ if (checked_full[dpkg] == 1)
+ found = 1
+ }
+ close(cmd)
}
- close(cmd)
if (found == 0)
print_line[i] = 1
}
}
for (i = 0; i < lines; ++i) {
- if (type[i] == "build" && checked_build[pkg[i]] != 1) {
- checked_build[pkg[i]] = 1
+ if (type[i] == "tool" && checked_tool[pkg[i]] != 1) {
+ checked_tool[pkg[i]] = 1
if (checked_bootstrap[pkg[i]] == 1)
continue
found = 0
+ if (PKG_INFO == HOST_PKG_INFO) {
+ cmd = PKG_INFO " -qr " pkg[i]
+ while (cmd | getline dpkg) {
+ if (checked_full[dpkg] == 1)
+ found = 1
+ }
+ close(cmd)
+ }
+ if (found == 0)
+ print_line[i] = 1
+ }
+ }
+
+ for (i = 0; i < lines; ++i) {
+ if (type[i] == "build" && checked_build[pkg[i]] != 1) {
+ checked_build[pkg[i]] = 1
+ if (PKG_INFO == HOST_PKG_INFO)
+ if (checked_bootstrap[pkg[i]] == 1)
+ continue
+ found = 0
cmd = PKG_INFO " -qr " pkg[i]
while (cmd | getline dpkg) {
if (checked_full[dpkg] == 1)
diff --git a/mk/pkgformat/pkg/resolve-dependencies b/mk/pkgformat/pkg/resolve-dependencies
index 3ee0bba4a89..89296f1e5fa 100755
--- a/mk/pkgformat/pkg/resolve-dependencies
+++ b/mk/pkgformat/pkg/resolve-dependencies
@@ -30,11 +30,16 @@ error_msg() {
}
find_best() {
- ${PKG_INFO} -E "$1" || ${TRUE}
+ case $1 in
+ bootstrap|tool)
+ ${HOST_PKG_INFO} -E "$2" || ${TRUE};;
+ build|full)
+ ${PKG_INFO} -E "$2" || ${TRUE};;
+ esac
}
${CAT} ${DEPENDS_FILE} | while read type pattern dir; do
- pkg=`find_best "$pattern"`
+ pkg=`find_best "$type" "$pattern"`
case "$pkg" in
"")
error_msg "[resolve-dependencies] A package matching \`\`$pattern'' should"