summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mk/bsd.pkg.mk4
-rw-r--r--mk/internal/pkg_fail_reason.mk41
-rw-r--r--mk/misc/can-be-built-here.mk136
3 files changed, 138 insertions, 43 deletions
diff --git a/mk/bsd.pkg.mk b/mk/bsd.pkg.mk
index 95343f1e36c..7ad9709e2be 100644
--- a/mk/bsd.pkg.mk
+++ b/mk/bsd.pkg.mk
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.pkg.mk,v 1.1898 2006/11/19 09:32:29 wiz Exp $
+# $NetBSD: bsd.pkg.mk,v 1.1899 2006/11/26 08:37:03 rillig Exp $
#
# This file is in the public domain.
#
@@ -914,4 +914,4 @@ changes-entry:
.if make(help)
.include "${PKGSRCDIR}/mk/help/help.mk"
.endif
-.include "${.PARSEDIR}/internal/pkg_fail_reason.mk"
+.include "${.PARSEDIR}/misc/can-be-built-here.mk"
diff --git a/mk/internal/pkg_fail_reason.mk b/mk/internal/pkg_fail_reason.mk
deleted file mode 100644
index a1b9191ff7d..00000000000
--- a/mk/internal/pkg_fail_reason.mk
+++ /dev/null
@@ -1,41 +0,0 @@
-# $NetBSD: pkg_fail_reason.mk,v 1.2 2006/11/16 09:38:53 rillig Exp $
-#
-
-# This file prints the error that are collected when the Makefiles are
-# loaded.
-#
-
-PKG_FAIL_REASON?= # none
-PKG_SKIP_REASON?= # none
-
-.PHONY: _check-pkg-fail-reason
-_check-pkg-fail-reason: .USEBEFORE
-.if defined(SKIP_SILENT)
- @${DO_NADA}
-.else
-. if !empty(PKG_FAIL_REASON:M*)
- @for str in ${PKG_FAIL_REASON}; do \
- ${ERROR_MSG} "$$str"; \
- done
-. endif
-. if !empty(PKG_SKIP_REASON:M*)
- @for str in "Skipping ${PKGNAME}:" ${PKG_SKIP_REASON}; do \
- ${WARNING_MSG} "$$str"; \
- done
-. endif
-.endif
-.if !empty(PKG_FAIL_REASON:M*)
- @${FALSE}
-.endif
-
-# All the "public" targets should be listed here.
-#
-.if !defined(NO_SKIP)
-. if !empty(PKG_FAIL_REASON) || !empty(PKG_SKIP_REASON)
-# FIXME: check-vulnerable is only used here because it is depended
-# upon by each of the "main" pkgsrc targets. Probably its name should be
-# generalized, and both check-vulnerable and _check-pkg-fail-reason should
-# depend on the generalized target.
-check-vulnerable: _check-pkg-fail-reason
-. endif
-.endif # !NO_SKIP
diff --git a/mk/misc/can-be-built-here.mk b/mk/misc/can-be-built-here.mk
new file mode 100644
index 00000000000..e22366c196d
--- /dev/null
+++ b/mk/misc/can-be-built-here.mk
@@ -0,0 +1,136 @@
+# $NetBSD: can-be-built-here.mk,v 1.1 2006/11/26 08:37:03 rillig Exp $
+#
+# This file checks whether a package can be built in the current pkgsrc
+# environment. It checks the following variables:
+#
+# * NOT_FOR_COMPILER, ONLY_FOR_COMPILER
+# * NOT_FOR_PLATFORM, ONLY_FOR_PLATFORM
+# * NOT_FOR_UNPRIVILEGED, ONLY_FOR_UNPRIVILEGED
+# * PKG_FAIL_REASON, PKG_SKIP_REASON
+#
+
+_CBBH_CHECKS= # none, but see below.
+
+# Check NOT_FOR_COMPILER
+_CBBH_CHECKS+= ncomp
+_CBBH_MSGS.ncomp= "This package is not available for these compilers: "${NOT_FOR_COMPILER:Q}"."
+
+_CBBH.ncomp= yes
+.for c in ${NOT_FOR_COMPILER}
+. for pc in ${PKGSRC_COMPILER}
+# The left-hand side of the == operator must be a "real" variable.
+_c:= ${c}
+. if ${_c} == ${pc}
+_CBBH.ncomp= no
+. endif
+. endfor
+.endfor
+
+# Check ONLY_FOR_COMPILER
+_CBBH_CHECKS+= ocomp
+_CBBH_MSGS.ocomp= "This package is only available for these compilers: "${ONLY_FOR_COMPILER:Q}"."
+
+_CBBH.ocomp= yes
+.if defined(ONLY_FOR_COMPILER) && !empty(ONLY_FOR_COMPILER)
+_CBBH.ocomp= yes
+. for pc in ${PKGSRC_COMPILER}
+. if empty(ONLY_FOR_COMPILER:M${pc})
+_CBBH.ocomp= no
+. endif
+. endfor
+.endif
+
+# Check NOT_FOR_PLATFORM
+_CBBH_CHECKS+= nplat
+_CBBH_MSGS.nplat= "This package is not available for these platforms: "${NOT_FOR_PLATFORM:Q}"."
+
+_CBBH.nplat= yes
+.for p in ${NOT_FOR_PLATFORM}
+. if !empty(MACHINE_PLATFORM:M${p})
+_CBBH.nplat= no
+. endif
+.endfor
+
+# Check ONLY_FOR_PLATFORM
+_CBBH_CHECKS+= oplat
+_CBBH_MSGS.oplat= "This package is only available for these platforms: "${ONLY_FOR_PLATFORM:Q}"."
+
+_CBBH.oplat= yes
+.if defined(ONLY_FOR_PLATFORM) && !empty(ONLY_FOR_PLATFORM)
+_CBBH.oplat= no
+. for p in ${ONLY_FOR_PLATFORM}
+. if !empty(MACHINE_PLATFORM:M${p})
+_CBBH.oplat= yes
+. endif
+. endfor
+.endif
+
+# Check NOT_FOR_UNPRIVILEGED
+_CBBH_CHECKS+= nunpriv
+_CBBH_MSGS.nunpriv= "This package is not available in unprivileged mode."
+
+_CBBH.nunpriv= yes
+.if defined(NOT_FOR_UNPRIVILEGED) && !empty(NOT_FOR_UNPRIVILEGED:M[Yy][Ee][Ss])
+. if !empty(UNPRIVILEGED:M[Yy][Ee][Ss])
+_CBBH.nunpriv= no
+. endif
+.endif
+
+# Check ONLY_FOR_UNPRIVILEGED
+_CBBH_CHECKS+= ounpriv
+_CBBH_MSGS.ounpriv= "This package is not available in unprivileged mode."
+
+_CBBH.ounpriv= yes
+.if defined(ONLY_FOR_UNPRIVILEGED) && !empty(ONLY_FOR_UNPRIVILEGED:M[Yy][Ee][Ss])
+. if empty(UNPRIVILEGED:M[Yy][Ee][Ss])
+_CBBH.ounpriv= no
+. endif
+.endif
+
+# Check PKG_FAIL_REASON
+_CBBH_CHECKS+= fail
+_CBBH_MSGS.fail= "This package has set PKG_FAIL_REASON:" ${PKG_FAIL_REASON}
+
+_CBBH.fail= yes
+.if defined(PKG_FAIL_REASON) && !empty(PKG_FAIL_REASON)
+_CBBH.fail= no
+.endif
+
+# Check PKG_SKIP_REASON
+_CBBH_CHECKS+= skip
+_CBBH_MSGS.skip= "This package has set PKG_SKIP_REASON:" ${PKG_SKIP_REASON}
+
+_CBBH.skip= yes
+.if defined(PKG_SKIP_REASON) && !empty(PKG_SKIP_REASON)
+_CBBH.skip= no
+.endif
+
+# Collect and combine the results
+_CBBH= yes
+_CBBH_MSGS= # none
+.for c in ${_CBBH_CHECKS}
+. if ${_CBBH.${c}} != "yes"
+_CBBH= no
+_CBBH_MSGS+= ${_CBBH_MSGS.${c}}
+. endif
+.endfor
+
+# In the first line, this target prints either "yes" or "no", saying
+# whether this package can be built. If the package can not be built,
+# the reasons are given in the following lines.
+#
+can-be-built-here: .PHONY
+ @${ECHO} ${_CBBH}
+ @:; ${_CBBH_MSGS:@m@${ECHO} ${m} ; @}
+
+_cbbh:
+ @:; ${_CBBH_MSGS:@m@${ERROR_MSG} ${m} ; @}
+ @${FALSE}
+
+.if ${_CBBH} == "no"
+# FIXME: check-vulnerable is only used here because it is depended
+# upon by each of the "main" pkgsrc targets. Probably its name should be
+# generalized, and both check-vulnerable and _cbbh should depend
+# on the generalized target.
+check-vulnerable: _cbbh
+.endif