Fixup fromcvs/togit conversion
[pkgsrcv2.git] / lang / php / phpversion.mk
1 # $NetBSD: phpversion.mk,v 1.18 2012/06/16 02:47:51 taca Exp $
2 #
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
5 # package.
6 #
7 # === User-settable variables ===
8 #
9 # PHP_VERSION_DEFAULT
10 #       The PHP version to choose when more than one is acceptable to
11 #       the package.
12 #
13 #       Possible: 53 54
14 #       Default: 53
15 #
16 # === Package-settable variables ===
17 #
18 # PHP_VERSIONS_ACCEPTED
19 #       The PHP versions that are accepted by the package.
20 #
21 #       Possible: 53 54
22 #       Default: 53 54
23 #
24 # PHP_VERSION_REQD
25 #       If the package works only with a specific PHP version, this
26 #       variable can be used to force it.
27 #
28 #       Possible: (undefined) 53 54
29 #       Default: (undefined)
30 #
31 # === Variables defined by this file ===
32 #
33 # PKG_PHP_VERSION
34 #       The selected PHP version.
35 #
36 #       Possible: 53 54
37 #       Default: ${PHP_VERSION_DEFAULT}
38 #
39 # PHP_BASE_VERS
40 #       The selected PHP's full version depends on PKG_PHP_VERSION
41 #
42 # PKG_PHP_MAJOR_VERS
43 #       The selected PHP's major version.
44 #
45 #       Possible: 5
46 #       Default: 5
47 #
48 # PKG_PHP
49 #       The same as ${PKG_PHP_VERSION}, prefixed with "php-".
50 #
51 # PHPPKGSRCDIR
52 #       The directory of the PHP implementation, relative to the
53 #       package directory.
54 #
55 #       Example: ../../lang/php5
56 #
57 # PHP_PKG_PREFIX
58 #       The prefix that is prepended to the package name.
59 #
60 #       Example: php53, php54
61 #
62 # Keywords: php
63 #
64
65 .if !defined(PHPVERSION_MK)
66 PHPVERSION_MK=  defined
67
68 _VARGROUPS+=    php
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 \
72                 PKG_PHP_MAJOR_VERS
73
74 .include "../../mk/bsd.prefs.mk"
75
76 PHP53_VERSION=                  5.3.14
77 PHP54_VERSION=                  5.4.4
78
79 PHP_VERSION_DEFAULT?=           53
80 PHP_VERSIONS_ACCEPTED?=         53 54
81
82 # transform the list into individual variables
83 .for pv in ${PHP_VERSIONS_ACCEPTED}
84 _PHP_VERSION_${pv}_OK=  yes
85 .endfor
86
87 # check what is installed
88 .if exists(${LOCALBASE}/lib/php/20120301)
89 _PHP_VERSION_54_INSTALLED=      yes
90 _PHP_INSTALLED=                 yes
91 .elif exists(${LOCALBASE}/lib/php/20090626) || exists(${LOCALBASE}/include/php/Zend/zend_gc.h)
92 _PHP_VERSION_53_INSTALLED=      yes
93 _PHP_INSTALLED=                 yes
94 .endif
95
96 # if a version is explicitely required, take it
97 .if defined(PHP_VERSION_REQD)
98 _PHP_VERSION=   ${PHP_VERSION_REQD}
99 .endif
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}
105 .endif
106 .endif
107 .endif
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)
112 _PHP_VERSION?=  ${pv}
113 .else
114 # keep information as last resort - see below
115 _PHP_VERSION_FIRSTACCEPTED?=    ${pv}
116 .endif
117 .endfor
118 .endif
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}
123 .endif
124 .endif
125 # take the first one accepted by the package
126 .if !defined(_PHP_VERSION)
127 _PHP_VERSION=   ${_PHP_VERSION_FIRSTACCEPTED}
128 .endif
129
130 #
131 # Variable assignment for multi-PHP packages
132 MULTI+= PHP_VERSION_REQD=${_PHP_VERSION}
133
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/}
137
138 # currently we have only PHP 5.x packages.
139 PKG_PHP_MAJOR_VERS:=    5
140
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"
144 .endif
145
146 MESSAGE_SUBST+=         PKG_PHP_VERSION=${PKG_PHP_VERSION} \
147                         PKG_PHP=${PKG_PHP}
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}
151
152 # force the selected PHP version for recursive builds
153 PHP_VERSION_REQD:=      ${PKG_PHP_VERSION}
154
155 #
156 # set variables for the version we decided to use:
157 #
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
166 .else
167 # force an error
168 PKG_SKIP_REASON+=       "${PKG_PHP} is not a valid package"
169 .endif
170
171 #
172 # check installed version aginst required:
173 #
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."
177 .endif
178 .endif
179
180 .endif  # PHPVERSION_MK