Annotation of pkgsrc/lang/php/phpversion.mk, revision 1.320
1.320 ! taca 1: # $NetBSD: phpversion.mk,v 1.319 2021/02/05 14:45:19 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.316 taca 13: # Possible: 56 73 74
1.276 taca 14: # Default: 73
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.316 taca 30: # Possible: 56 73 74
31: # Default: 73 56 74
1.6 rillig 32: #
1.152 joerg 33: # PHP_VERSIONS_INCOMPATIBLE
34: # The PHP versions that are not supported by the package.
35: #
1.316 taca 36: # Possible: 56 73 74
1.152 joerg 37: # Default: (empty)
38: #
1.37 taca 39: # PHP_CHECK_INSTALLED
1.153 taca 40: # Check installed version of PHP. Should be used by lang/php56,
1.316 taca 41: # lang/php73 or lang/php74 only.
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.316 taca 51: # Possible: 56 73 74
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.118 taca 60: # Possible: 5 7
1.210 taca 61: # Default: 7
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.277 taca 70: # Example: ../../lang/php73
1.6 rillig 71: #
72: # PHP_PKG_PREFIX
73: # The prefix that is prepended to the package name.
74: #
1.316 taca 75: # Example: php56 php73 php74
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.320 ! taca 91: PHP73_VERSION= 7.3.27
1.319 taca 92: PHP74_VERSION= 7.4.15
1.37 taca 93:
94: # Define initial release of major version.
1.78 taca 95: PHP56_RELDATE= 20140828
1.241 taca 96: PHP73_RELDATE= 20181200
1.278 taca 97: PHP74_RELDATE= 20191128
1.37 taca 98:
1.8 rillig 99: _VARGROUPS+= php
100: _USER_VARS.php= PHP_VERSION_DEFAULT
101: _PKG_VARS.php= PHP_VERSIONS_ACCEPTED PHP_VERSION_REQD
1.11 taca 102: _SYS_VARS.php= PKG_PHP_VERSION PKG_PHP PHPPKGSRCDIR PHP_PKG_PREFIX \
103: PKG_PHP_MAJOR_VERS
1.8 rillig 104:
1.1 jdolecek 105: .include "../../mk/bsd.prefs.mk"
106:
1.276 taca 107: PHP_VERSION_DEFAULT?= 73
1.316 taca 108: PHP_VERSIONS_ACCEPTED?= 73 74 56
1.152 joerg 109: .for pv in ${PHP_VERSIONS_ACCEPTED}
110: . if empty(PHP_VERSIONS_INCOMPATIBLE:M${pv})
111: _PHP_VERSIONS_ACCEPTED+= ${pv}
112: . endif
113: .endfor
1.1 jdolecek 114:
115: # transform the list into individual variables
1.152 joerg 116: .for pv in ${_PHP_VERSIONS_ACCEPTED}
1.1 jdolecek 117: _PHP_VERSION_${pv}_OK= yes
118: .endfor
119:
120: # check what is installed
1.278 taca 121: .if exists(${LOCALBASE}/lib/php/${PHP74_RELDATE})
122: _PHP_VERSION_74_INSTALLED= yes
123: _PHP_INSTALLED= yes
124: .elif exists(${LOCALBASE}/lib/php/${PHP73_RELDATE})
1.241 taca 125: _PHP_VERSION_73_INSTALLED= yes
126: _PHP_INSTALLED= yes
1.147 jdolecek 127: .elif exists(${LOCALBASE}/lib/php/${PHP56_RELDATE})
1.78 taca 128: _PHP_VERSION_56_INSTALLED= yes
129: _PHP_INSTALLED= yes
1.1 jdolecek 130: .endif
131:
132: # if a version is explicitely required, take it
133: .if defined(PHP_VERSION_REQD)
134: _PHP_VERSION= ${PHP_VERSION_REQD}
135: .endif
136: # if the default is already installed, it is first choice
137: .if !defined(_PHP_VERSION)
138: .if defined(_PHP_VERSION_${PHP_VERSION_DEFAULT}_OK)
139: .if defined(_PHP_VERSION_${PHP_VERSION_DEFAULT}_INSTALLED)
140: _PHP_VERSION= ${PHP_VERSION_DEFAULT}
141: .endif
142: .endif
143: .endif
144: # prefer an already installed version, in order of "accepted"
145: .if !defined(_PHP_VERSION)
1.152 joerg 146: .for pv in ${_PHP_VERSIONS_ACCEPTED}
1.1 jdolecek 147: .if defined(_PHP_VERSION_${pv}_INSTALLED)
148: _PHP_VERSION?= ${pv}
149: .else
150: # keep information as last resort - see below
151: _PHP_VERSION_FIRSTACCEPTED?= ${pv}
152: .endif
153: .endfor
154: .endif
155: # if the default is OK for the addon pkg, take this
156: .if !defined(_PHP_VERSION)
157: .if defined(_PHP_VERSION_${PHP_VERSION_DEFAULT}_OK)
158: _PHP_VERSION= ${PHP_VERSION_DEFAULT}
159: .endif
160: .endif
161: # take the first one accepted by the package
162: .if !defined(_PHP_VERSION)
163: _PHP_VERSION= ${_PHP_VERSION_FIRSTACCEPTED}
164: .endif
165:
1.14 wiz 166: #
167: # Variable assignment for multi-PHP packages
168: MULTI+= PHP_VERSION_REQD=${_PHP_VERSION}
169:
1.2 jdolecek 170: # export some of internal variables
1.12 jdolecek 171: PKG_PHP_VERSION:= ${_PHP_VERSION:C/\.[0-9]//}
1.38 taca 172: PKG_PHP:= PHP${_PHP_VERSION:C/([0-9])([0-9])/\1.\2/}
1.11 taca 173:
1.118 taca 174: # Major version
175: PKG_PHP_MAJOR_VERS:= ${_PHP_VERSION:C/^([0-9]).*/\1/}
1.2 jdolecek 176:
1.37 taca 177: PHP_CHECK_INSTALLED?= Yes
178:
1.12 jdolecek 179: # if installed PHP isn't compatible with required PHP, bail out
1.39 taca 180: .if empty(PHP_CHECK_INSTALLED:M[nN][oO])
1.12 jdolecek 181: .if defined(_PHP_INSTALLED) && !defined(_PHP_VERSION_${_PHP_VERSION}_INSTALLED)
1.82 dholland 182: PKG_FAIL_REASON+= "Package accepts ${PKG_PHP}, but different version is installed"
1.12 jdolecek 183: .endif
1.37 taca 184: .endif
1.12 jdolecek 185:
1.2 jdolecek 186: MESSAGE_SUBST+= PKG_PHP_VERSION=${PKG_PHP_VERSION} \
187: PKG_PHP=${PKG_PHP}
1.11 taca 188: PLIST_SUBST+= PKG_PHP_VERSION=${PKG_PHP_VERSION} \
1.18 taca 189: PKG_PHP_MAJOR_VERS=${PKG_PHP_MAJOR_VERS} \
190: PHP_EXTENSION_DIR=${PHP_EXTENSION_DIR}
1.2 jdolecek 191:
1.3 jdolecek 192: # force the selected PHP version for recursive builds
193: PHP_VERSION_REQD:= ${PKG_PHP_VERSION}
194:
1.1 jdolecek 195: #
196: # set variables for the version we decided to use:
197: #
1.153 taca 198: .if ${_PHP_VERSION} == "56"
1.89 taca 199: PHP_VERSION= ${PHP56_VERSION}
200: PHP_INITIAL_TEENY= 3
1.78 taca 201: PHP_EXTENSION_DIR= lib/php/${PHP56_RELDATE}
1.241 taca 202: .elif ${_PHP_VERSION} == "73"
203: PHP_VERSION= ${PHP73_VERSION}
204: PHP_EXTENSION_DIR= lib/php/${PHP73_RELDATE}
1.278 taca 205: .elif ${_PHP_VERSION} == "74"
206: PHP_VERSION= ${PHP74_VERSION}
207: PHP_EXTENSION_DIR= lib/php/${PHP74_RELDATE}
1.1 jdolecek 208: .else
209: # force an error
1.82 dholland 210: PKG_FAIL_REASON+= "${PKG_PHP} is not a valid package"
1.1 jdolecek 211: .endif
212:
1.279 taca 213: PHP_INITIAL_TEENY?= 0
214: PHPPKGSRCDIR= ../../lang/php${PKG_PHP_VERSION}
215: PHP_PKG_PREFIX= php${PKG_PHP_VERSION}
216:
1.89 taca 217: _PHP_VER_MAJOR= ${PHP_VERSION:C/([0-9]+)\.([0-9]+)\.([0-9]+)/\1/}
218: _PHP_VER_MINOR= ${PHP_VERSION:C/([0-9]+)\.([0-9]+)\.([0-9]+)/\2/}
219:
220: PHP_BASE_VERS= ${_PHP_VER_MAJOR}.${_PHP_VER_MINOR}.${PHP_INITIAL_TEENY}
221:
1.11 taca 222: #
223: # check installed version aginst required:
224: #
1.37 taca 225: .if !empty(PHP_CHECK_INSTALLED:M[nN][oO])
226: .if defined(_PHP_VERSION_INSTALLED) && ${_PHP_VERSION} != ${_PHP_VERSION_INSTALLED}
1.82 dholland 227: PKG_FAIL_REASON+= "${PKGBASE} requires ${PKG_PHP}, but php-${_PHP_VERSION_INSTALLED} is already installed."
1.11 taca 228: .endif
229: .endif
230:
1.1 jdolecek 231: .endif # PHPVERSION_MK
CVSweb <webmaster@jp.NetBSD.org>