summaryrefslogtreecommitdiff
path: root/mk/misc/can-be-built-here.mk
blob: ba23f0be8bb969c3b0ecafcf34e5eb71daafe1d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# $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