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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
|
# $NetBSD: phpversion.mk,v 1.157 2016/09/16 16:10:28 taca Exp $
#
# This file selects a PHP version, based on the user's preferences and
# the installed packages. It does not add a dependency on the PHP
# package.
#
# === User-settable variables ===
#
# PHP_VERSION_DEFAULT
# The PHP version to choose when more than one is acceptable to
# the package.
#
# Possible: 56 70 71
# Default: 56
#
# === Infrastructure variables ===
#
# PHP_VERSION_REQD
# PHP version to use. This variable should not be set in
# packages. Normally it is used by bulk build tools.
#
# Possible: ${PHP_VERSIONS_ACCEPTED}
# Default: ${PHP_VERSION_DEFAULT}
#
# === Package-settable variables ===
#
# PHP_VERSIONS_ACCEPTED
# The PHP versions that are accepted by the package.
#
# Possible: 56 70 71
# Default: 56
#
# PHP_VERSIONS_INCOMPATIBLE
# The PHP versions that are not supported by the package.
#
# Possible: 56 70 71
# Default: (empty)
#
# PHP_CHECK_INSTALLED
# Check installed version of PHP. Should be used by lang/php56,
# lang/php70, or lang/php71 only.
#
# Possible: Yes No
# Default: Yes
#
# === Variables defined by this file ===
#
# PKG_PHP_VERSION
# The selected PHP version.
#
# Possible: 56 70 71
# Default: ${PHP_VERSION_DEFAULT}
#
# PHP_BASE_VERS
# The selected PHP's full version depends on PKG_PHP_VERSION
#
# PKG_PHP_MAJOR_VERS
# The selected PHP's major version.
#
# Possible: 5 7
# Default: 5
#
# PKG_PHP
# The same as ${PKG_PHP_VERSION}, prefixed with "php-".
#
# PHPPKGSRCDIR
# The directory of the PHP implementation, relative to the
# package directory.
#
# Example: ../../lang/php56
#
# PHP_PKG_PREFIX
# The prefix that is prepended to the package name.
#
# Example: php56 php70 php71
#
# PHP_EXTENSION_DIR
# Relative path to ${PREFIX} for PHP's extensions. It is derived from
# initial release of major version.
#
# Example: lib/php/20140828
#
# Keywords: php
#
.if !defined(PHPVERSION_MK)
PHPVERSION_MK= defined
# Define each PHP's version.
PHP56_VERSION= 5.6.26
PHP70_VERSION= 7.0.11
PHP71_VERSION= 7.1.0RC1
# Define initial release of major version.
PHP56_RELDATE= 20140828
PHP70_RELDATE= 20151203
PHP71_RELDATE= 20160303
_VARGROUPS+= php
_USER_VARS.php= PHP_VERSION_DEFAULT
_PKG_VARS.php= PHP_VERSIONS_ACCEPTED PHP_VERSION_REQD
_SYS_VARS.php= PKG_PHP_VERSION PKG_PHP PHPPKGSRCDIR PHP_PKG_PREFIX \
PKG_PHP_MAJOR_VERS
.include "../../mk/bsd.prefs.mk"
PHP_VERSION_DEFAULT?= 56
PHP_VERSIONS_ACCEPTED?= 56 70 71
.for pv in ${PHP_VERSIONS_ACCEPTED}
. if empty(PHP_VERSIONS_INCOMPATIBLE:M${pv})
_PHP_VERSIONS_ACCEPTED+= ${pv}
. endif
.endfor
# transform the list into individual variables
.for pv in ${_PHP_VERSIONS_ACCEPTED}
_PHP_VERSION_${pv}_OK= yes
.endfor
# check what is installed
.if exists(${LOCALBASE}/lib/php/${PHP71_RELDATE})
_PHP_VERSION_71_INSTALLED= yes
_PHP_INSTALLED= yes
.elif exists(${LOCALBASE}/lib/php/${PHP70_RELDATE})
_PHP_VERSION_70_INSTALLED= yes
_PHP_INSTALLED= yes
.elif exists(${LOCALBASE}/lib/php/${PHP56_RELDATE})
_PHP_VERSION_56_INSTALLED= yes
_PHP_INSTALLED= yes
.endif
# if a version is explicitely required, take it
.if defined(PHP_VERSION_REQD)
_PHP_VERSION= ${PHP_VERSION_REQD}
.endif
# if the default is already installed, it is first choice
.if !defined(_PHP_VERSION)
.if defined(_PHP_VERSION_${PHP_VERSION_DEFAULT}_OK)
.if defined(_PHP_VERSION_${PHP_VERSION_DEFAULT}_INSTALLED)
_PHP_VERSION= ${PHP_VERSION_DEFAULT}
.endif
.endif
.endif
# prefer an already installed version, in order of "accepted"
.if !defined(_PHP_VERSION)
.for pv in ${_PHP_VERSIONS_ACCEPTED}
.if defined(_PHP_VERSION_${pv}_INSTALLED)
_PHP_VERSION?= ${pv}
.else
# keep information as last resort - see below
_PHP_VERSION_FIRSTACCEPTED?= ${pv}
.endif
.endfor
.endif
# if the default is OK for the addon pkg, take this
.if !defined(_PHP_VERSION)
.if defined(_PHP_VERSION_${PHP_VERSION_DEFAULT}_OK)
_PHP_VERSION= ${PHP_VERSION_DEFAULT}
.endif
.endif
# take the first one accepted by the package
.if !defined(_PHP_VERSION)
_PHP_VERSION= ${_PHP_VERSION_FIRSTACCEPTED}
.endif
#
# Variable assignment for multi-PHP packages
MULTI+= PHP_VERSION_REQD=${_PHP_VERSION}
# export some of internal variables
PKG_PHP_VERSION:= ${_PHP_VERSION:C/\.[0-9]//}
PKG_PHP:= PHP${_PHP_VERSION:C/([0-9])([0-9])/\1.\2/}
# Major version
PKG_PHP_MAJOR_VERS:= ${_PHP_VERSION:C/^([0-9]).*/\1/}
PHP_CHECK_INSTALLED?= Yes
# if installed PHP isn't compatible with required PHP, bail out
.if empty(PHP_CHECK_INSTALLED:M[nN][oO])
.if defined(_PHP_INSTALLED) && !defined(_PHP_VERSION_${_PHP_VERSION}_INSTALLED)
PKG_FAIL_REASON+= "Package accepts ${PKG_PHP}, but different version is installed"
.endif
.endif
MESSAGE_SUBST+= PKG_PHP_VERSION=${PKG_PHP_VERSION} \
PKG_PHP=${PKG_PHP}
PLIST_SUBST+= PKG_PHP_VERSION=${PKG_PHP_VERSION} \
PKG_PHP_MAJOR_VERS=${PKG_PHP_MAJOR_VERS} \
PHP_EXTENSION_DIR=${PHP_EXTENSION_DIR}
# force the selected PHP version for recursive builds
PHP_VERSION_REQD:= ${PKG_PHP_VERSION}
#
# set variables for the version we decided to use:
#
.if ${_PHP_VERSION} == "56"
PHPPKGSRCDIR= ../../lang/php56
PHP_VERSION= ${PHP56_VERSION}
PHP_INITIAL_TEENY= 3
PHP_PKG_PREFIX= php56
PHP_EXTENSION_DIR= lib/php/${PHP56_RELDATE}
.elif ${_PHP_VERSION} == "70"
PHPPKGSRCDIR= ../../lang/php70
PHP_VERSION= ${PHP70_VERSION}
PHP_INITIAL_TEENY= 0
PHP_PKG_PREFIX= php70
PHP_EXTENSION_DIR= lib/php/${PHP70_RELDATE}
.elif ${_PHP_VERSION} == "71"
PHPPKGSRCDIR= ../../lang/php71
PHP_VERSION= ${PHP71_VERSION}
PHP_INITIAL_TEENY= 0
PHP_PKG_PREFIX= php71
PHP_EXTENSION_DIR= lib/php/${PHP71_RELDATE}
.else
# force an error
PKG_FAIL_REASON+= "${PKG_PHP} is not a valid package"
.endif
_PHP_VER_MAJOR= ${PHP_VERSION:C/([0-9]+)\.([0-9]+)\.([0-9]+)/\1/}
_PHP_VER_MINOR= ${PHP_VERSION:C/([0-9]+)\.([0-9]+)\.([0-9]+)/\2/}
PHP_BASE_VERS= ${_PHP_VER_MAJOR}.${_PHP_VER_MINOR}.${PHP_INITIAL_TEENY}
#
# check installed version aginst required:
#
.if !empty(PHP_CHECK_INSTALLED:M[nN][oO])
.if defined(_PHP_VERSION_INSTALLED) && ${_PHP_VERSION} != ${_PHP_VERSION_INSTALLED}
PKG_FAIL_REASON+= "${PKGBASE} requires ${PKG_PHP}, but php-${_PHP_VERSION_INSTALLED} is already installed."
.endif
.endif
.endif # PHPVERSION_MK
|