Annotation of pkgsrc/lang/php/phpversion.mk, revision 1.19
1.19 ! taca 1: # $NetBSD: phpversion.mk,v 1.18 2012/06/16 02:47:51 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.19 ! taca 13: # Possible: 53 54
1.17 taca 14: # Default: 53
1.6 rillig 15: #
16: # === Package-settable variables ===
17: #
18: # PHP_VERSIONS_ACCEPTED
19: # The PHP versions that are accepted by the package.
20: #
1.19 ! taca 21: # Possible: 53 54
! 22: # Default: 53 54
1.6 rillig 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: #
1.19 ! taca 28: # Possible: (undefined) 53 54
1.6 rillig 29: # Default: (undefined)
30: #
31: # === Variables defined by this file ===
32: #
33: # PKG_PHP_VERSION
34: # The selected PHP version.
35: #
1.19 ! taca 36: # Possible: 53 54
1.11 taca 37: # Default: ${PHP_VERSION_DEFAULT}
38: #
1.18 taca 39: # PHP_BASE_VERS
40: # The selected PHP's full version depends on PKG_PHP_VERSION
41: #
1.11 taca 42: # PKG_PHP_MAJOR_VERS
43: # The selected PHP's major version.
44: #
1.10 joerg 45: # Possible: 5
1.11 taca 46: # Default: 5
1.6 rillig 47: #
48: # PKG_PHP
1.11 taca 49: # The same as ${PKG_PHP_VERSION}, prefixed with "php-".
1.6 rillig 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: #
1.19 ! taca 60: # Example: php53, php54
1.6 rillig 61: #
62: # Keywords: php
63: #
1.1 jdolecek 64:
65: .if !defined(PHPVERSION_MK)
66: PHPVERSION_MK= defined
67:
1.8 rillig 68: _VARGROUPS+= php
69: _USER_VARS.php= PHP_VERSION_DEFAULT
70: _PKG_VARS.php= PHP_VERSIONS_ACCEPTED PHP_VERSION_REQD
1.11 taca 71: _SYS_VARS.php= PKG_PHP_VERSION PKG_PHP PHPPKGSRCDIR PHP_PKG_PREFIX \
72: PKG_PHP_MAJOR_VERS
1.8 rillig 73:
1.1 jdolecek 74: .include "../../mk/bsd.prefs.mk"
75:
1.18 taca 76: PHP53_VERSION= 5.3.14
77: PHP54_VERSION= 5.4.4
78:
1.15 taca 79: PHP_VERSION_DEFAULT?= 53
1.19 ! taca 80: PHP_VERSIONS_ACCEPTED?= 53 54
1.1 jdolecek 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
1.18 taca 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
1.1 jdolecek 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:
1.14 wiz 130: #
131: # Variable assignment for multi-PHP packages
132: MULTI+= PHP_VERSION_REQD=${_PHP_VERSION}
133:
1.2 jdolecek 134: # export some of internal variables
1.12 jdolecek 135: PKG_PHP_VERSION:= ${_PHP_VERSION:C/\.[0-9]//}
136: PKG_PHP:= PHP${_PHP_VERSION:C/([0-9])([0-9])/\1.\2/}
1.11 taca 137:
138: # currently we have only PHP 5.x packages.
139: PKG_PHP_MAJOR_VERS:= 5
1.2 jdolecek 140:
1.12 jdolecek 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:
1.2 jdolecek 146: MESSAGE_SUBST+= PKG_PHP_VERSION=${PKG_PHP_VERSION} \
147: PKG_PHP=${PKG_PHP}
1.11 taca 148: PLIST_SUBST+= PKG_PHP_VERSION=${PKG_PHP_VERSION} \
1.18 taca 149: PKG_PHP_MAJOR_VERS=${PKG_PHP_MAJOR_VERS} \
150: PHP_EXTENSION_DIR=${PHP_EXTENSION_DIR}
1.2 jdolecek 151:
1.3 jdolecek 152: # force the selected PHP version for recursive builds
153: PHP_VERSION_REQD:= ${PKG_PHP_VERSION}
154:
1.1 jdolecek 155: #
156: # set variables for the version we decided to use:
157: #
1.19 ! taca 158: .if ${_PHP_VERSION} == "53"
1.11 taca 159: PHPPKGSRCDIR= ../../lang/php53
1.18 taca 160: PHP_BASE_VERS= ${PHP53_VERSION}
1.11 taca 161: PHP_PKG_PREFIX= php53
1.18 taca 162: .elif ${_PHP_VERSION} == "54"
163: PHPPKGSRCDIR= ../../lang/php54
164: PHP_BASE_VERS= ${PHP54_VERSION}
165: PHP_PKG_PREFIX= php54
1.1 jdolecek 166: .else
167: # force an error
1.2 jdolecek 168: PKG_SKIP_REASON+= "${PKG_PHP} is not a valid package"
1.1 jdolecek 169: .endif
170:
1.11 taca 171: #
172: # check installed version aginst required:
173: #
174: .if defined(_PHP_VERSION_INSTALLED)
175: .if ${_PHP_VERSION} != ${_PHP_VERSION_INSTALLED}
1.13 taca 176: PKG_SKIP_REASON+= "${PKGBASE} requires ${PKG_PHP}, but php-${_PHP_VERSION_INSTALLED} is already installed."
1.11 taca 177: .endif
178: .endif
179:
1.1 jdolecek 180: .endif # PHPVERSION_MK
CVSweb <webmaster@jp.NetBSD.org>