pkgsrc/mk/misc/can-be-built-here.mk
dholland de73f20ecb Add support for BROKEN_ON_PLATFORM and BROKEN_EXCEPT_ON_PLATFORM, as per
discussion on tech-pkg.

BROKEN_ON_PLATFORM and NOT_FOR_PLATFORM are the same, except that
(now) BROKEN_ON_PLATFORM sets PKG_FAIL_REASON and NOT_FOR_PLATFORM
sets PKG_SKIP_REASON. BROKEN_EXCEPT_FOR_PLATFORM and ONLY_FOR_PLATFORM
correspond in the same way.

The idea is that going forward we will distinguish unbuildable
packages that theoretically ought to be fixed (these are BROKEN) from
packages where it doesn't make sense to build (these are NOT_FOR)...
examples of the former include most non-64-bit-clean packges; examples
of the latter include OS-specific language bindings.

A general review of the uses of NOT_FOR_PLATFORM and ONLY_FOR_PLATFORM
(converting many of them to BROKEN...) is coming up.

Similarly, a general review of the uses of PKG_FAIL_REASON and
PKG_SKIP_REASON is coming up.

For this to become useful, pbulk needs to be taught to report failing
and skipped packages differently - the idea is that failing packages
should be reported up front and skipped packages don't need to be. This
has not been done yet, but one set of things at a time...
2015-01-01 06:06:06 +00:00

184 lines
4.9 KiB
Makefile

# $NetBSD: can-be-built-here.mk,v 1.8 2015/01/01 06:06:06 dholland 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
# * BROKEN_ON_PLATFORM, BROKEN_EXCEPT_ON_PLATFORM
# * NOT_FOR_BULK_PLATFORM
# * NOT_FOR_UNPRIVILEGED, ONLY_FOR_UNPRIVILEGED
# * PKG_FAIL_REASON, PKG_SKIP_REASON
#
# It also depends on the following internal variables:
#
# NO_SKIP
# When defined, the checks in this file are skipped. It is called
# NO_SKIP because the code that skips building the package should
# _not_ be run.
#
# XXX: It's weird to have three negations in such a short variable
# name.
#
_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
# Ignore compilers that only cache or distribute the real work that has
# to be done (see PR 35173).
. for pc in ${PKGSRC_COMPILER:Nccache:Ndistcc}
. 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 NOT_FOR_BULK_PLATFORM
_CBBH_CHECKS+= nbplat
_CBBH_MSGS.nbplat= "This package is known to stall the bulk build on these platforms: "${NOT_FOR_BULK_PLATFORM:Q}"."
_CBBH.nbplat= yes
.for p in ${NOT_FOR_BULK_PLATFORM}
. if defined(BATCH) && !empty(MACHINE_PLATFORM:M${p})
_CBBH.nbplat= 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 BROKEN_ON_PLATFORM
_CBBH_CHECKS+= bplat
_CBBH_MSGS.bplat= "This package is broken on these platforms: "${BROKEN_ON_PLATFORM:Q}"."
_CBBH.bplat= yes
.for p in ${BROKEN_ON_PLATFORM}
. if !empty(MACHINE_PLATFORM:M${p})
_CBBH.bplat= no
. endif
.endfor
# Check BROKEN_EXCEPT_ON_PLATFORM
_CBBH_CHECKS+= beplat
_CBBH_MSGS.beplat= "This package is broken except on these platforms: "${BROKEN_EXCEPT_ON_PLATFORM:Q}"."
_CBBH.beplat= yes
.if defined(BROKEN_EXCEPT_ON_PLATFORM) && !empty(BROKEN_EXCEPT_ON_PLATFORM)
_CBBH.beplat= no
. for p in ${BROKEN_EXCEPT_ON_PLATFORM}
. if !empty(MACHINE_PLATFORM:M${p})
_CBBH.beplat= 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 !defined(NO_SKIP) && ${_CBBH} == "no"
# XXX: bootstrap-depends is only used here because it is depended
# upon by each of the "main" pkgsrc targets.
bootstrap-depends: _cbbh
.endif