1 # $NetBSD: phpversion.mk,v 1.18 2012/06/16 02:47:51 taca Exp $
3 # This file selects a PHP version, based on the user's preferences and
4 # the installed packages. It does not add a dependency on the PHP
7 # === User-settable variables ===
10 # The PHP version to choose when more than one is acceptable to
16 # === Package-settable variables ===
18 # PHP_VERSIONS_ACCEPTED
19 # The PHP versions that are accepted by the package.
25 # If the package works only with a specific PHP version, this
26 # variable can be used to force it.
28 # Possible: (undefined) 53 54
29 # Default: (undefined)
31 # === Variables defined by this file ===
34 # The selected PHP version.
37 # Default: ${PHP_VERSION_DEFAULT}
40 # The selected PHP's full version depends on PKG_PHP_VERSION
43 # The selected PHP's major version.
49 # The same as ${PKG_PHP_VERSION}, prefixed with "php-".
52 # The directory of the PHP implementation, relative to the
55 # Example: ../../lang/php5
58 # The prefix that is prepended to the package name.
60 # Example: php53, php54
65 .if !defined(PHPVERSION_MK)
66 PHPVERSION_MK= defined
69 _USER_VARS.php= PHP_VERSION_DEFAULT
70 _PKG_VARS.php= PHP_VERSIONS_ACCEPTED PHP_VERSION_REQD
71 _SYS_VARS.php= PKG_PHP_VERSION PKG_PHP PHPPKGSRCDIR PHP_PKG_PREFIX \
74 .include "../../mk/bsd.prefs.mk"
79 PHP_VERSION_DEFAULT?= 53
80 PHP_VERSIONS_ACCEPTED?= 53 54
82 # transform the list into individual variables
83 .for pv in ${PHP_VERSIONS_ACCEPTED}
84 _PHP_VERSION_${pv}_OK= yes
87 # check what is installed
88 .if exists(${LOCALBASE}/lib/php/20120301)
89 _PHP_VERSION_54_INSTALLED= yes
91 .elif exists(${LOCALBASE}/lib/php/20090626) || exists(${LOCALBASE}/include/php/Zend/zend_gc.h)
92 _PHP_VERSION_53_INSTALLED= yes
96 # if a version is explicitely required, take it
97 .if defined(PHP_VERSION_REQD)
98 _PHP_VERSION= ${PHP_VERSION_REQD}
100 # if the default is already installed, it is first choice
101 .if !defined(_PHP_VERSION)
102 .if defined(_PHP_VERSION_${PHP_VERSION_DEFAULT}_OK)
103 .if defined(_PHP_VERSION_${PHP_VERSION_DEFAULT}_INSTALLED)
104 _PHP_VERSION= ${PHP_VERSION_DEFAULT}
108 # prefer an already installed version, in order of "accepted"
109 .if !defined(_PHP_VERSION)
110 .for pv in ${PHP_VERSIONS_ACCEPTED}
111 .if defined(_PHP_VERSION_${pv}_INSTALLED)
114 # keep information as last resort - see below
115 _PHP_VERSION_FIRSTACCEPTED?= ${pv}
119 # if the default is OK for the addon pkg, take this
120 .if !defined(_PHP_VERSION)
121 .if defined(_PHP_VERSION_${PHP_VERSION_DEFAULT}_OK)
122 _PHP_VERSION= ${PHP_VERSION_DEFAULT}
125 # take the first one accepted by the package
126 .if !defined(_PHP_VERSION)
127 _PHP_VERSION= ${_PHP_VERSION_FIRSTACCEPTED}
131 # Variable assignment for multi-PHP packages
132 MULTI+= PHP_VERSION_REQD=${_PHP_VERSION}
134 # export some of internal variables
135 PKG_PHP_VERSION:= ${_PHP_VERSION:C/\.[0-9]//}
136 PKG_PHP:= PHP${_PHP_VERSION:C/([0-9])([0-9])/\1.\2/}
138 # currently we have only PHP 5.x packages.
139 PKG_PHP_MAJOR_VERS:= 5
141 # if installed PHP isn't compatible with required PHP, bail out
142 .if defined(_PHP_INSTALLED) && !defined(_PHP_VERSION_${_PHP_VERSION}_INSTALLED)
143 PKG_SKIP_REASON+= "Package accepts ${PKG_PHP}, but different version is installed"
146 MESSAGE_SUBST+= PKG_PHP_VERSION=${PKG_PHP_VERSION} \
148 PLIST_SUBST+= PKG_PHP_VERSION=${PKG_PHP_VERSION} \
149 PKG_PHP_MAJOR_VERS=${PKG_PHP_MAJOR_VERS} \
150 PHP_EXTENSION_DIR=${PHP_EXTENSION_DIR}
152 # force the selected PHP version for recursive builds
153 PHP_VERSION_REQD:= ${PKG_PHP_VERSION}
156 # set variables for the version we decided to use:
158 .if ${_PHP_VERSION} == "53"
159 PHPPKGSRCDIR= ../../lang/php53
160 PHP_BASE_VERS= ${PHP53_VERSION}
161 PHP_PKG_PREFIX= php53
162 .elif ${_PHP_VERSION} == "54"
163 PHPPKGSRCDIR= ../../lang/php54
164 PHP_BASE_VERS= ${PHP54_VERSION}
165 PHP_PKG_PREFIX= php54
168 PKG_SKIP_REASON+= "${PKG_PHP} is not a valid package"
172 # check installed version aginst required:
174 .if defined(_PHP_VERSION_INSTALLED)
175 .if ${_PHP_VERSION} != ${_PHP_VERSION_INSTALLED}
176 PKG_SKIP_REASON+= "${PKGBASE} requires ${PKG_PHP}, but php-${_PHP_VERSION_INSTALLED} is already installed."
180 .endif # PHPVERSION_MK