Annotation of pkgsrc/lang/php/phpversion.mk, revision 1.117
1.117 ! taca 1: # $NetBSD: phpversion.mk,v 1.116 2015/11/28 07:09:38 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.117 ! taca 13: # Possible: 55 56
1.112 bouyer 14: # Default: 55
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.117 ! taca 30: # Possible: 55 56
! 31: # Default: 55 56
1.6 rillig 32: #
1.37 taca 33: # PHP_CHECK_INSTALLED
1.117 ! taca 34: # Check installed version of PHP. Should be used by lang/php55,
! 35: # and lang/php56 only.
1.37 taca 36: #
37: # Possible: Yes No
38: # Default: Yes
39: #
1.6 rillig 40: # === Variables defined by this file ===
41: #
42: # PKG_PHP_VERSION
43: # The selected PHP version.
44: #
1.117 ! taca 45: # Possible: 55 56
1.11 taca 46: # Default: ${PHP_VERSION_DEFAULT}
47: #
1.18 taca 48: # PHP_BASE_VERS
49: # The selected PHP's full version depends on PKG_PHP_VERSION
50: #
1.11 taca 51: # PKG_PHP_MAJOR_VERS
52: # The selected PHP's major version.
53: #
1.10 joerg 54: # Possible: 5
1.11 taca 55: # Default: 5
1.6 rillig 56: #
57: # PKG_PHP
1.11 taca 58: # The same as ${PKG_PHP_VERSION}, prefixed with "php-".
1.6 rillig 59: #
60: # PHPPKGSRCDIR
61: # The directory of the PHP implementation, relative to the
62: # package directory.
63: #
1.117 ! taca 64: # Example: ../../lang/php55
1.6 rillig 65: #
66: # PHP_PKG_PREFIX
67: # The prefix that is prepended to the package name.
68: #
1.117 ! taca 69: # Example: php55 php56
1.6 rillig 70: #
1.37 taca 71: # PHP_EXTENSION_DIR
72: # Relative path to ${PREFIX} for PHP's extensions. It is derived from
73: # initial release of major version.
74: #
75: # Example: lib/php/20090630
76: #
1.6 rillig 77: # Keywords: php
78: #
1.1 jdolecek 79:
80: .if !defined(PHPVERSION_MK)
81: PHPVERSION_MK= defined
82:
1.37 taca 83: # Define each PHP's version.
1.113 taca 84: PHP55_VERSION= 5.5.30
1.116 taca 85: PHP56_VERSION= 5.6.16
1.37 taca 86:
87: # Define initial release of major version.
88: PHP55_RELDATE= 20130620
1.78 taca 89: PHP56_RELDATE= 20140828
1.37 taca 90:
1.8 rillig 91: _VARGROUPS+= php
92: _USER_VARS.php= PHP_VERSION_DEFAULT
93: _PKG_VARS.php= PHP_VERSIONS_ACCEPTED PHP_VERSION_REQD
1.11 taca 94: _SYS_VARS.php= PKG_PHP_VERSION PKG_PHP PHPPKGSRCDIR PHP_PKG_PREFIX \
95: PKG_PHP_MAJOR_VERS
1.8 rillig 96:
1.1 jdolecek 97: .include "../../mk/bsd.prefs.mk"
98:
1.112 bouyer 99: PHP_VERSION_DEFAULT?= 55
1.117 ! taca 100: PHP_VERSIONS_ACCEPTED?= 55 56
1.1 jdolecek 101:
102: # transform the list into individual variables
103: .for pv in ${PHP_VERSIONS_ACCEPTED}
104: _PHP_VERSION_${pv}_OK= yes
105: .endfor
106:
107: # check what is installed
1.78 taca 108: .if exists(${LOCALBASE}/lib/php/20140828)
109: _PHP_VERSION_56_INSTALLED= yes
110: _PHP_INSTALLED= yes
111: .elif exists(${LOCALBASE}/lib/php/20130620)
1.38 taca 112: _PHP_VERSION_55_INSTALLED= yes
113: _PHP_INSTALLED= yes
1.1 jdolecek 114: .endif
115:
116: # if a version is explicitely required, take it
117: .if defined(PHP_VERSION_REQD)
118: _PHP_VERSION= ${PHP_VERSION_REQD}
119: .endif
120: # if the default is already installed, it is first choice
121: .if !defined(_PHP_VERSION)
122: .if defined(_PHP_VERSION_${PHP_VERSION_DEFAULT}_OK)
123: .if defined(_PHP_VERSION_${PHP_VERSION_DEFAULT}_INSTALLED)
124: _PHP_VERSION= ${PHP_VERSION_DEFAULT}
125: .endif
126: .endif
127: .endif
128: # prefer an already installed version, in order of "accepted"
129: .if !defined(_PHP_VERSION)
130: .for pv in ${PHP_VERSIONS_ACCEPTED}
131: .if defined(_PHP_VERSION_${pv}_INSTALLED)
132: _PHP_VERSION?= ${pv}
133: .else
134: # keep information as last resort - see below
135: _PHP_VERSION_FIRSTACCEPTED?= ${pv}
136: .endif
137: .endfor
138: .endif
139: # if the default is OK for the addon pkg, take this
140: .if !defined(_PHP_VERSION)
141: .if defined(_PHP_VERSION_${PHP_VERSION_DEFAULT}_OK)
142: _PHP_VERSION= ${PHP_VERSION_DEFAULT}
143: .endif
144: .endif
145: # take the first one accepted by the package
146: .if !defined(_PHP_VERSION)
147: _PHP_VERSION= ${_PHP_VERSION_FIRSTACCEPTED}
148: .endif
149:
1.14 wiz 150: #
151: # Variable assignment for multi-PHP packages
152: MULTI+= PHP_VERSION_REQD=${_PHP_VERSION}
153:
1.2 jdolecek 154: # export some of internal variables
1.12 jdolecek 155: PKG_PHP_VERSION:= ${_PHP_VERSION:C/\.[0-9]//}
1.38 taca 156: PKG_PHP:= PHP${_PHP_VERSION:C/([0-9])([0-9])/\1.\2/}
1.11 taca 157:
158: # currently we have only PHP 5.x packages.
159: PKG_PHP_MAJOR_VERS:= 5
1.2 jdolecek 160:
1.37 taca 161: PHP_CHECK_INSTALLED?= Yes
162:
1.12 jdolecek 163: # if installed PHP isn't compatible with required PHP, bail out
1.39 taca 164: .if empty(PHP_CHECK_INSTALLED:M[nN][oO])
1.12 jdolecek 165: .if defined(_PHP_INSTALLED) && !defined(_PHP_VERSION_${_PHP_VERSION}_INSTALLED)
1.82 dholland 166: PKG_FAIL_REASON+= "Package accepts ${PKG_PHP}, but different version is installed"
1.12 jdolecek 167: .endif
1.37 taca 168: .endif
1.12 jdolecek 169:
1.2 jdolecek 170: MESSAGE_SUBST+= PKG_PHP_VERSION=${PKG_PHP_VERSION} \
171: PKG_PHP=${PKG_PHP}
1.11 taca 172: PLIST_SUBST+= PKG_PHP_VERSION=${PKG_PHP_VERSION} \
1.18 taca 173: PKG_PHP_MAJOR_VERS=${PKG_PHP_MAJOR_VERS} \
174: PHP_EXTENSION_DIR=${PHP_EXTENSION_DIR}
1.2 jdolecek 175:
1.3 jdolecek 176: # force the selected PHP version for recursive builds
177: PHP_VERSION_REQD:= ${PKG_PHP_VERSION}
178:
1.1 jdolecek 179: #
180: # set variables for the version we decided to use:
181: #
1.117 ! taca 182: .if ${_PHP_VERSION} == "55"
1.38 taca 183: PHPPKGSRCDIR= ../../lang/php55
1.89 taca 184: PHP_VERSION= ${PHP55_VERSION}
185: PHP_INITIAL_TEENY= 1
1.38 taca 186: PHP_PKG_PREFIX= php55
187: PHP_EXTENSION_DIR= lib/php/${PHP55_RELDATE}
1.78 taca 188: .elif ${_PHP_VERSION} == "56"
189: PHPPKGSRCDIR= ../../lang/php56
1.89 taca 190: PHP_VERSION= ${PHP56_VERSION}
191: PHP_INITIAL_TEENY= 3
1.78 taca 192: PHP_PKG_PREFIX= php56
193: PHP_EXTENSION_DIR= lib/php/${PHP56_RELDATE}
1.1 jdolecek 194: .else
195: # force an error
1.82 dholland 196: PKG_FAIL_REASON+= "${PKG_PHP} is not a valid package"
1.1 jdolecek 197: .endif
198:
1.89 taca 199: _PHP_VER_MAJOR= ${PHP_VERSION:C/([0-9]+)\.([0-9]+)\.([0-9]+)/\1/}
200: _PHP_VER_MINOR= ${PHP_VERSION:C/([0-9]+)\.([0-9]+)\.([0-9]+)/\2/}
201:
202: PHP_BASE_VERS= ${_PHP_VER_MAJOR}.${_PHP_VER_MINOR}.${PHP_INITIAL_TEENY}
203:
1.11 taca 204: #
205: # check installed version aginst required:
206: #
1.37 taca 207: .if !empty(PHP_CHECK_INSTALLED:M[nN][oO])
208: .if defined(_PHP_VERSION_INSTALLED) && ${_PHP_VERSION} != ${_PHP_VERSION_INSTALLED}
1.82 dholland 209: PKG_FAIL_REASON+= "${PKGBASE} requires ${PKG_PHP}, but php-${_PHP_VERSION_INSTALLED} is already installed."
1.11 taca 210: .endif
211: .endif
212:
1.1 jdolecek 213: .endif # PHPVERSION_MK
CVSweb <webmaster@jp.NetBSD.org>