Annotation of pkgsrc/lang/php/phpversion.mk, revision 1.11
1.11 ! taca 1: # $NetBSD: phpversion.mk,v 1.10 2010/02/10 17:46:10 joerg 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
11: # the package.
12: #
1.11 ! taca 13: # Possible: 5 53
1.7 ghen 14: # Default: 5
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.11 ! taca 21: # Possible: 5 53
1.10 joerg 22: # Default: 5
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.11 ! taca 28: # Possible: (undefined) 5 53
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.11 ! taca 36: # Possible: 5 53
! 37: # Default: ${PHP_VERSION_DEFAULT}
! 38: #
! 39: # PKG_PHP_MAJOR_VERS
! 40: # The selected PHP's major version.
! 41: #
1.10 joerg 42: # Possible: 5
1.11 ! taca 43: # Default: 5
1.6 rillig 44: #
45: # PKG_PHP
1.11 ! taca 46: # The same as ${PKG_PHP_VERSION}, prefixed with "php-".
1.6 rillig 47: #
48: # PHPPKGSRCDIR
49: # The directory of the PHP implementation, relative to the
50: # package directory.
51: #
52: # Example: ../../lang/php5
53: #
54: # PHP_PKG_PREFIX
55: # The prefix that is prepended to the package name.
56: #
1.11 ! taca 57: # Example: php5, php53
1.6 rillig 58: #
59: # Keywords: php
60: #
1.1 jdolecek 61:
62: .if !defined(PHPVERSION_MK)
63: PHPVERSION_MK= defined
64:
1.8 rillig 65: _VARGROUPS+= php
66: _USER_VARS.php= PHP_VERSION_DEFAULT
67: _PKG_VARS.php= PHP_VERSIONS_ACCEPTED PHP_VERSION_REQD
1.11 ! taca 68: _SYS_VARS.php= PKG_PHP_VERSION PKG_PHP PHPPKGSRCDIR PHP_PKG_PREFIX \
! 69: PKG_PHP_MAJOR_VERS
1.8 rillig 70:
1.1 jdolecek 71: .include "../../mk/bsd.prefs.mk"
72:
1.4 tron 73: PHP_VERSION_DEFAULT?= 5
1.11 ! taca 74: PHP_VERSIONS_ACCEPTED?= 5 53
1.1 jdolecek 75:
76: # transform the list into individual variables
77: .for pv in ${PHP_VERSIONS_ACCEPTED}
78: _PHP_VERSION_${pv}_OK= yes
79: .endfor
80:
81: # check what is installed
82: .if exists(${LOCALBASE}/lib/php/20040412)
83: _PHP_VERSION_5_INSTALLED= yes
1.11 ! taca 84: _PHP_VERSION_INSTALLED= 5
! 85: .elif exists(${LOCALBASE}/lib/php/20090630)
! 86: _PHP_VERSION_53_INSTALLED= yes
! 87: _PHP_VERSION_INSTALLED= 53
1.1 jdolecek 88: .endif
89:
90: # if a version is explicitely required, take it
91: .if defined(PHP_VERSION_REQD)
92: _PHP_VERSION= ${PHP_VERSION_REQD}
93: .endif
94: # if the default is already installed, it is first choice
95: .if !defined(_PHP_VERSION)
96: .if defined(_PHP_VERSION_${PHP_VERSION_DEFAULT}_OK)
97: .if defined(_PHP_VERSION_${PHP_VERSION_DEFAULT}_INSTALLED)
98: _PHP_VERSION= ${PHP_VERSION_DEFAULT}
99: .endif
100: .endif
101: .endif
102: # prefer an already installed version, in order of "accepted"
103: .if !defined(_PHP_VERSION)
104: .for pv in ${PHP_VERSIONS_ACCEPTED}
105: .if defined(_PHP_VERSION_${pv}_INSTALLED)
106: _PHP_VERSION?= ${pv}
107: .else
108: # keep information as last resort - see below
109: _PHP_VERSION_FIRSTACCEPTED?= ${pv}
110: .endif
111: .endfor
112: .endif
113: # if the default is OK for the addon pkg, take this
114: .if !defined(_PHP_VERSION)
115: .if defined(_PHP_VERSION_${PHP_VERSION_DEFAULT}_OK)
116: _PHP_VERSION= ${PHP_VERSION_DEFAULT}
117: .endif
118: .endif
119: # take the first one accepted by the package
120: .if !defined(_PHP_VERSION)
121: _PHP_VERSION= ${_PHP_VERSION_FIRSTACCEPTED}
122: .endif
123:
1.2 jdolecek 124: # export some of internal variables
1.3 jdolecek 125: PKG_PHP_VERSION:= ${_PHP_VERSION}
1.11 ! taca 126: PKG_PHP:= php-${_PHP_VERSION}
! 127:
! 128: # currently we have only PHP 5.x packages.
! 129: PKG_PHP_MAJOR_VERS:= 5
1.2 jdolecek 130:
131: MESSAGE_SUBST+= PKG_PHP_VERSION=${PKG_PHP_VERSION} \
132: PKG_PHP=${PKG_PHP}
1.11 ! taca 133: PLIST_SUBST+= PKG_PHP_VERSION=${PKG_PHP_VERSION} \
! 134: PKG_PHP_MAJOR_VERS=${PKG_PHP_MAJOR_VERS}
1.2 jdolecek 135:
1.3 jdolecek 136: # force the selected PHP version for recursive builds
137: PHP_VERSION_REQD:= ${PKG_PHP_VERSION}
138:
1.1 jdolecek 139: #
140: # set variables for the version we decided to use:
141: #
1.10 joerg 142: .if ${_PHP_VERSION} == "5"
1.5 joerg 143: PHPPKGSRCDIR= ../../lang/php5
144: PHP_PKG_PREFIX= php5
1.11 ! taca 145: .elif ${_PHP_VERSION} == "53"
! 146: PHPPKGSRCDIR= ../../lang/php53
! 147: PHP_PKG_PREFIX= php53
1.1 jdolecek 148: .else
149: # force an error
1.2 jdolecek 150: PKG_SKIP_REASON+= "${PKG_PHP} is not a valid package"
1.1 jdolecek 151: .endif
152:
1.11 ! taca 153: #
! 154: # check installed version aginst required:
! 155: #
! 156: .if defined(_PHP_VERSION_INSTALLED)
! 157: .if ${_PHP_VERSION} != ${_PHP_VERSION_INSTALLED}
! 158: PKG_SKIP_REASON+= "${PKGBASE} requires ${PKG_PHP}, but php-${_PHP_VERSION_INSTALLED} is installed."
! 159: .endif
! 160: .endif
! 161:
1.1 jdolecek 162: .endif # PHPVERSION_MK
CVSweb <webmaster@jp.NetBSD.org>