Annotation of pkgsrc/lang/php/phpversion.mk, revision 1.441
1.441 ! taca 1: # $NetBSD: phpversion.mk,v 1.440 2024/08/31 04:35:00 taca Exp $
1.6 rillig 2: #
3: # This file selects a PHP version, based on the user's preferences and
1.9 rillig 4: # the installed packages. It does not add a dependency on the PHP
5: # package.
1.6 rillig 6: #
7: # === User-settable variables ===
8: #
9: # PHP_VERSION_DEFAULT
10: # The PHP version to choose when more than one is acceptable to
1.18 taca 11: # the package.
1.6 rillig 12: #
1.432 taca 13: # Possible: 56 74 81 82 83
1.424 taca 14: # Default: 82
1.6 rillig 15: #
1.24 cheusov 16: # === Infrastructure variables ===
17: #
1.23 cheusov 18: # PHP_VERSION_REQD
1.24 cheusov 19: # PHP version to use. This variable should not be set in
20: # packages. Normally it is used by bulk build tools.
1.23 cheusov 21: #
22: # Possible: ${PHP_VERSIONS_ACCEPTED}
23: # Default: ${PHP_VERSION_DEFAULT}
24: #
1.6 rillig 25: # === Package-settable variables ===
26: #
27: # PHP_VERSIONS_ACCEPTED
28: # The PHP versions that are accepted by the package.
29: #
1.432 taca 30: # Possible: 56 74 81 82 83
31: # Default: 82 81 83 74 56
1.6 rillig 32: #
1.152 joerg 33: # PHP_VERSIONS_INCOMPATIBLE
34: # The PHP versions that are not supported by the package.
35: #
1.432 taca 36: # Possible: 56 74 81 82 83
1.152 joerg 37: # Default: (empty)
38: #
1.37 taca 39: # PHP_CHECK_INSTALLED
1.416 taca 40: # Check installed version of PHP. Should be only used by
1.432 taca 41: # lang/php56, lang/php74, lang/php81, lang/php82 and lang/php83.
1.37 taca 42: #
43: # Possible: Yes No
44: # Default: Yes
45: #
1.6 rillig 46: # === Variables defined by this file ===
47: #
48: # PKG_PHP_VERSION
49: # The selected PHP version.
50: #
1.432 taca 51: # Possible: 56 74 81 82 83
1.11 taca 52: # Default: ${PHP_VERSION_DEFAULT}
53: #
1.18 taca 54: # PHP_BASE_VERS
55: # The selected PHP's full version depends on PKG_PHP_VERSION
56: #
1.11 taca 57: # PKG_PHP_MAJOR_VERS
58: # The selected PHP's major version.
59: #
1.322 taca 60: # Possible: 5 7 8
1.413 taca 61: # Default: 8
1.6 rillig 62: #
63: # PKG_PHP
1.11 taca 64: # The same as ${PKG_PHP_VERSION}, prefixed with "php-".
1.6 rillig 65: #
66: # PHPPKGSRCDIR
67: # The directory of the PHP implementation, relative to the
68: # package directory.
69: #
1.413 taca 70: # Example: ../../lang/php81
1.6 rillig 71: #
72: # PHP_PKG_PREFIX
73: # The prefix that is prepended to the package name.
74: #
1.432 taca 75: # Example: php56 php74 php81 php82 php83
1.6 rillig 76: #
1.37 taca 77: # PHP_EXTENSION_DIR
78: # Relative path to ${PREFIX} for PHP's extensions. It is derived from
79: # initial release of major version.
80: #
1.277 taca 81: # Example: lib/php/20181200
1.37 taca 82: #
1.6 rillig 83: # Keywords: php
84: #
1.1 jdolecek 85:
86: .if !defined(PHPVERSION_MK)
87: PHPVERSION_MK= defined
88:
1.37 taca 89: # Define each PHP's version.
1.245 taca 90: PHP56_VERSION= 5.6.40
1.380 taca 91: PHP74_VERSION= 7.4.33
1.433 taca 92: PHP81_VERSION= 8.1.29
1.440 taca 93: PHP82_VERSION= 8.2.23
1.441 ! taca 94: PHP83_VERSION= 8.3.11
1.37 taca 95:
1.383 taca 96: # Define API version or initial release of major version.
1.78 taca 97: PHP56_RELDATE= 20140828
1.278 taca 98: PHP74_RELDATE= 20191128
1.348 taca 99: PHP81_RELDATE= 20211125
1.383 taca 100: PHP82_RELDATE= 20220829
1.416 taca 101: PHP83_RELDATE= 20231123
1.37 taca 102:
1.8 rillig 103: _VARGROUPS+= php
104: _USER_VARS.php= PHP_VERSION_DEFAULT
105: _PKG_VARS.php= PHP_VERSIONS_ACCEPTED PHP_VERSION_REQD
1.11 taca 106: _SYS_VARS.php= PKG_PHP_VERSION PKG_PHP PHPPKGSRCDIR PHP_PKG_PREFIX \
107: PKG_PHP_MAJOR_VERS
1.8 rillig 108:
1.1 jdolecek 109: .include "../../mk/bsd.prefs.mk"
110:
1.424 taca 111: PHP_VERSION_DEFAULT?= 82
1.432 taca 112: PHP_VERSIONS_ACCEPTED?= 82 81 83 74 56
1.152 joerg 113: .for pv in ${PHP_VERSIONS_ACCEPTED}
114: . if empty(PHP_VERSIONS_INCOMPATIBLE:M${pv})
115: _PHP_VERSIONS_ACCEPTED+= ${pv}
116: . endif
117: .endfor
1.1 jdolecek 118:
119: # transform the list into individual variables
1.152 joerg 120: .for pv in ${_PHP_VERSIONS_ACCEPTED}
1.1 jdolecek 121: _PHP_VERSION_${pv}_OK= yes
122: .endfor
123:
124: # check what is installed
1.416 taca 125: .if exists(${LOCALBASE}/lib/php/${PHP83_RELDATE})
126: _PHP_VERSION_83_INSTALLED= yes
127: _PHP_INSTALLED= yes
128: .elif exists(${LOCALBASE}/lib/php/${PHP82_RELDATE})
1.383 taca 129: _PHP_VERSION_82_INSTALLED= yes
130: _PHP_INSTALLED= yes
131: .elif exists(${LOCALBASE}/lib/php/${PHP81_RELDATE})
1.348 taca 132: _PHP_VERSION_81_INSTALLED= yes
133: _PHP_INSTALLED= yes
1.322 taca 134: .elif exists(${LOCALBASE}/lib/php/${PHP74_RELDATE})
1.278 taca 135: _PHP_VERSION_74_INSTALLED= yes
136: _PHP_INSTALLED= yes
1.147 jdolecek 137: .elif exists(${LOCALBASE}/lib/php/${PHP56_RELDATE})
1.78 taca 138: _PHP_VERSION_56_INSTALLED= yes
139: _PHP_INSTALLED= yes
1.1 jdolecek 140: .endif
141:
1.349 gutterid 142: # if a version is explicitly required, take it
1.1 jdolecek 143: .if defined(PHP_VERSION_REQD)
144: _PHP_VERSION= ${PHP_VERSION_REQD}
145: .endif
146: # if the default is already installed, it is first choice
147: .if !defined(_PHP_VERSION)
148: .if defined(_PHP_VERSION_${PHP_VERSION_DEFAULT}_OK)
149: .if defined(_PHP_VERSION_${PHP_VERSION_DEFAULT}_INSTALLED)
150: _PHP_VERSION= ${PHP_VERSION_DEFAULT}
151: .endif
152: .endif
153: .endif
154: # prefer an already installed version, in order of "accepted"
155: .if !defined(_PHP_VERSION)
1.152 joerg 156: .for pv in ${_PHP_VERSIONS_ACCEPTED}
1.1 jdolecek 157: .if defined(_PHP_VERSION_${pv}_INSTALLED)
158: _PHP_VERSION?= ${pv}
159: .else
160: # keep information as last resort - see below
161: _PHP_VERSION_FIRSTACCEPTED?= ${pv}
162: .endif
163: .endfor
164: .endif
1.349 gutterid 165: # if the default is OK for the add-on pkg, take this
1.1 jdolecek 166: .if !defined(_PHP_VERSION)
167: .if defined(_PHP_VERSION_${PHP_VERSION_DEFAULT}_OK)
168: _PHP_VERSION= ${PHP_VERSION_DEFAULT}
169: .endif
170: .endif
171: # take the first one accepted by the package
172: .if !defined(_PHP_VERSION)
173: _PHP_VERSION= ${_PHP_VERSION_FIRSTACCEPTED}
174: .endif
175:
1.14 wiz 176: #
177: # Variable assignment for multi-PHP packages
178: MULTI+= PHP_VERSION_REQD=${_PHP_VERSION}
179:
1.349 gutterid 180: # export some of the internal variables
1.12 jdolecek 181: PKG_PHP_VERSION:= ${_PHP_VERSION:C/\.[0-9]//}
1.38 taca 182: PKG_PHP:= PHP${_PHP_VERSION:C/([0-9])([0-9])/\1.\2/}
1.11 taca 183:
1.118 taca 184: # Major version
185: PKG_PHP_MAJOR_VERS:= ${_PHP_VERSION:C/^([0-9]).*/\1/}
1.2 jdolecek 186:
1.37 taca 187: PHP_CHECK_INSTALLED?= Yes
188:
1.12 jdolecek 189: # if installed PHP isn't compatible with required PHP, bail out
1.39 taca 190: .if empty(PHP_CHECK_INSTALLED:M[nN][oO])
1.12 jdolecek 191: .if defined(_PHP_INSTALLED) && !defined(_PHP_VERSION_${_PHP_VERSION}_INSTALLED)
1.349 gutterid 192: PKG_FAIL_REASON+= "Package accepts ${PKG_PHP}, but a different version is installed"
1.12 jdolecek 193: .endif
1.37 taca 194: .endif
1.12 jdolecek 195:
1.2 jdolecek 196: MESSAGE_SUBST+= PKG_PHP_VERSION=${PKG_PHP_VERSION} \
197: PKG_PHP=${PKG_PHP}
1.322 taca 198: PLIST_SUBST+= PHP_PKG_PREFIX=${PHP_PKG_PREFIX} \
199: PKG_PHP_VERSION=${PKG_PHP_VERSION} \
1.18 taca 200: PKG_PHP_MAJOR_VERS=${PKG_PHP_MAJOR_VERS} \
201: PHP_EXTENSION_DIR=${PHP_EXTENSION_DIR}
1.2 jdolecek 202:
1.3 jdolecek 203: # force the selected PHP version for recursive builds
204: PHP_VERSION_REQD:= ${PKG_PHP_VERSION}
205:
1.1 jdolecek 206: #
207: # set variables for the version we decided to use:
208: #
1.416 taca 209: .if ${_PHP_VERSION} == 56
1.89 taca 210: PHP_VERSION= ${PHP56_VERSION}
211: PHP_INITIAL_TEENY= 3
1.78 taca 212: PHP_EXTENSION_DIR= lib/php/${PHP56_RELDATE}
1.416 taca 213: .elif ${_PHP_VERSION} == 74
1.278 taca 214: PHP_VERSION= ${PHP74_VERSION}
215: PHP_EXTENSION_DIR= lib/php/${PHP74_RELDATE}
1.416 taca 216: .elif ${_PHP_VERSION} == 81
1.348 taca 217: PHP_VERSION= ${PHP81_VERSION}
218: PHP_EXTENSION_DIR= lib/php/${PHP81_RELDATE}
1.416 taca 219: .elif ${_PHP_VERSION} == 82
1.383 taca 220: PHP_VERSION= ${PHP82_VERSION}
221: PHP_EXTENSION_DIR= lib/php/${PHP82_RELDATE}
1.416 taca 222: .elif ${_PHP_VERSION} == 83
223: PHP_VERSION= ${PHP83_VERSION}
224: PHP_EXTENSION_DIR= lib/php/${PHP83_RELDATE}
1.1 jdolecek 225: .else
226: # force an error
1.82 dholland 227: PKG_FAIL_REASON+= "${PKG_PHP} is not a valid package"
1.1 jdolecek 228: .endif
229:
1.279 taca 230: PHP_INITIAL_TEENY?= 0
231: PHPPKGSRCDIR= ../../lang/php${PKG_PHP_VERSION}
232: PHP_PKG_PREFIX= php${PKG_PHP_VERSION}
233:
1.89 taca 234: _PHP_VER_MAJOR= ${PHP_VERSION:C/([0-9]+)\.([0-9]+)\.([0-9]+)/\1/}
235: _PHP_VER_MINOR= ${PHP_VERSION:C/([0-9]+)\.([0-9]+)\.([0-9]+)/\2/}
236:
237: PHP_BASE_VERS= ${_PHP_VER_MAJOR}.${_PHP_VER_MINOR}.${PHP_INITIAL_TEENY}
238:
1.11 taca 239: #
1.349 gutterid 240: # check installed version against required:
1.11 taca 241: #
1.37 taca 242: .if !empty(PHP_CHECK_INSTALLED:M[nN][oO])
243: .if defined(_PHP_VERSION_INSTALLED) && ${_PHP_VERSION} != ${_PHP_VERSION_INSTALLED}
1.82 dholland 244: PKG_FAIL_REASON+= "${PKGBASE} requires ${PKG_PHP}, but php-${_PHP_VERSION_INSTALLED} is already installed."
1.11 taca 245: .endif
246: .endif
247:
1.401 taca 248: MAKEFLAGS+= PHP_VERSION_REQD=${PHP_VERSION_REQD}
249:
1.1 jdolecek 250: .endif # PHPVERSION_MK
CVSweb <webmaster@jp.NetBSD.org>