1 # $NetBSD: phpversion.mk,v 1.15 2011/09/14 16:44:26 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
11 # the package. '5' means any 5.*, 52 only 5.2.*, 53 only 5.3.*
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) 5 52 53
29 # Default: (undefined)
31 # === Variables defined by this file ===
34 # The selected PHP version.
37 # Default: ${PHP_VERSION_DEFAULT}
40 # The selected PHP's major version.
46 # The same as ${PKG_PHP_VERSION}, prefixed with "php-".
49 # The directory of the PHP implementation, relative to the
52 # Example: ../../lang/php5
55 # The prefix that is prepended to the package name.
57 # Example: php5, php53
62 .if !defined(PHPVERSION_MK)
63 PHPVERSION_MK= defined
66 _USER_VARS.php= PHP_VERSION_DEFAULT
67 _PKG_VARS.php= PHP_VERSIONS_ACCEPTED PHP_VERSION_REQD
68 _SYS_VARS.php= PKG_PHP_VERSION PKG_PHP PHPPKGSRCDIR PHP_PKG_PREFIX \
71 .include "../../mk/bsd.prefs.mk"
73 PHP_VERSION_DEFAULT?= 53
74 PHP_VERSIONS_ACCEPTED?= 5 53
76 # transform the list into individual variables
77 .for pv in ${PHP_VERSIONS_ACCEPTED}
78 _PHP_VERSION_${pv}_OK= yes
81 # check what is installed
82 .if exists(${LOCALBASE}/lib/php/20040412)
83 _PHP_VERSION_5_INSTALLED= yes
84 _PHP_VERSION_52_INSTALLED= yes
87 .if exists(${LOCALBASE}/lib/php/20090626) || exists(${LOCALBASE}/include/php/Zend/zend_gc.h)
88 _PHP_VERSION_53_INSTALLED= yes
92 # if a version is explicitely required, take it
93 .if defined(PHP_VERSION_REQD)
94 _PHP_VERSION= ${PHP_VERSION_REQD}
96 # if the default is already installed, it is first choice
97 .if !defined(_PHP_VERSION)
98 .if defined(_PHP_VERSION_${PHP_VERSION_DEFAULT}_OK)
99 .if defined(_PHP_VERSION_${PHP_VERSION_DEFAULT}_INSTALLED)
100 _PHP_VERSION= ${PHP_VERSION_DEFAULT}
104 # prefer an already installed version, in order of "accepted"
105 .if !defined(_PHP_VERSION)
106 .for pv in ${PHP_VERSIONS_ACCEPTED}
107 .if defined(_PHP_VERSION_${pv}_INSTALLED)
110 # keep information as last resort - see below
111 _PHP_VERSION_FIRSTACCEPTED?= ${pv}
115 # if the default is OK for the addon pkg, take this
116 .if !defined(_PHP_VERSION)
117 .if defined(_PHP_VERSION_${PHP_VERSION_DEFAULT}_OK)
118 _PHP_VERSION= ${PHP_VERSION_DEFAULT}
121 # take the first one accepted by the package
122 .if !defined(_PHP_VERSION)
123 _PHP_VERSION= ${_PHP_VERSION_FIRSTACCEPTED}
127 # Variable assignment for multi-PHP packages
128 MULTI+= PHP_VERSION_REQD=${_PHP_VERSION}
130 # export some of internal variables
131 PKG_PHP_VERSION:= ${_PHP_VERSION:C/\.[0-9]//}
132 PKG_PHP:= PHP${_PHP_VERSION:C/([0-9])([0-9])/\1.\2/}
134 # currently we have only PHP 5.x packages.
135 PKG_PHP_MAJOR_VERS:= 5
137 # if installed PHP isn't compatible with required PHP, bail out
138 .if defined(_PHP_INSTALLED) && !defined(_PHP_VERSION_${_PHP_VERSION}_INSTALLED)
139 PKG_SKIP_REASON+= "Package accepts ${PKG_PHP}, but different version is installed"
142 MESSAGE_SUBST+= PKG_PHP_VERSION=${PKG_PHP_VERSION} \
144 PLIST_SUBST+= PKG_PHP_VERSION=${PKG_PHP_VERSION} \
145 PKG_PHP_MAJOR_VERS=${PKG_PHP_MAJOR_VERS}
147 # force the selected PHP version for recursive builds
148 PHP_VERSION_REQD:= ${PKG_PHP_VERSION}
151 # set variables for the version we decided to use:
153 .if ${_PHP_VERSION} == "5" || ${_PHP_VERSION} == "52"
154 PHPPKGSRCDIR= ../../lang/php5
156 .elif ${_PHP_VERSION} == "53"
157 PHPPKGSRCDIR= ../../lang/php53
158 PHP_PKG_PREFIX= php53
161 PKG_SKIP_REASON+= "${PKG_PHP} is not a valid package"
165 # check installed version aginst required:
167 .if defined(_PHP_VERSION_INSTALLED)
168 .if ${_PHP_VERSION} != ${_PHP_VERSION_INSTALLED}
169 PKG_SKIP_REASON+= "${PKGBASE} requires ${PKG_PHP}, but php-${_PHP_VERSION_INSTALLED} is already installed."
173 .endif # PHPVERSION_MK