Annotation of pkgsrc/lang/php/phpversion.mk, revision 1.8
1.8 ! rillig 1: # $NetBSD: phpversion.mk,v 1.7 2007/08/13 14:46:30 ghen Exp $
1.6 rillig 2: #
3: # This file selects a PHP version, based on the user's preferences and
4: # the installed packages.
5: #
6: # === User-settable variables ===
7: #
8: # PHP_VERSION_DEFAULT
9: # The PHP version to choose when more than one is acceptable to
10: # the package.
11: #
12: # Possible: 4 5
1.7 ghen 13: # Default: 5
1.6 rillig 14: #
15: # === Package-settable variables ===
16: #
17: # PHP_VERSIONS_ACCEPTED
18: # The PHP versions that are accepted by the package.
19: #
20: # Possible: 4 5
21: # Default: 4 5
22: #
23: # PHP_VERSION_REQD
24: # If the package works only with a specific PHP version, this
25: # variable can be used to force it.
26: #
27: # Possible: (undefined) 4 5
28: # Default: (undefined)
29: #
30: # === Variables defined by this file ===
31: #
32: # PKG_PHP_VERSION
33: # The selected PHP version.
34: #
35: # Possible: 4 5
36: # Default: ${PHP_VERSION_DEFAULT}
37: #
38: # PKG_PHP
39: # The same as ${PKG_PHP_VERSION}, prefixed with "PHP".
40: # XXX: Why is this necessary?
41: #
42: # PHPPKGSRCDIR
43: # The directory of the PHP implementation, relative to the
44: # package directory.
45: #
46: # Example: ../../lang/php5
47: #
48: # PHP_PKG_PREFIX
49: # The prefix that is prepended to the package name.
50: #
51: # Example: php5
52: #
53: # Keywords: php
54: #
1.1 jdolecek 55:
56: .if !defined(PHPVERSION_MK)
57: PHPVERSION_MK= defined
58:
1.8 ! rillig 59: _VARGROUPS+= php
! 60: _USER_VARS.php= PHP_VERSION_DEFAULT
! 61: _PKG_VARS.php= PHP_VERSIONS_ACCEPTED PHP_VERSION_REQD
! 62: _SYS_VARS.php= PKG_PHP_VERSION PKG_PHP PHPPKGSRCDIR PHP_PKG_PREFIX
! 63:
1.1 jdolecek 64: .include "../../mk/bsd.prefs.mk"
65:
1.4 tron 66: PHP_VERSION_DEFAULT?= 5
1.1 jdolecek 67: PHP_VERSIONS_ACCEPTED?= 4 5
68:
69: # transform the list into individual variables
70: .for pv in ${PHP_VERSIONS_ACCEPTED}
71: _PHP_VERSION_${pv}_OK= yes
72: .endfor
73:
74: # check what is installed
75: .if exists(${LOCALBASE}/lib/php/20020429)
76: _PHP_VERSION_4_INSTALLED= yes
77: .endif
78: .if exists(${LOCALBASE}/lib/php/20040412)
79: _PHP_VERSION_5_INSTALLED= yes
80: .endif
81:
82: # if a version is explicitely required, take it
83: .if defined(PHP_VERSION_REQD)
84: _PHP_VERSION= ${PHP_VERSION_REQD}
85: .endif
86: # if the default is already installed, it is first choice
87: .if !defined(_PHP_VERSION)
88: .if defined(_PHP_VERSION_${PHP_VERSION_DEFAULT}_OK)
89: .if defined(_PHP_VERSION_${PHP_VERSION_DEFAULT}_INSTALLED)
90: _PHP_VERSION= ${PHP_VERSION_DEFAULT}
91: .endif
92: .endif
93: .endif
94: # prefer an already installed version, in order of "accepted"
95: .if !defined(_PHP_VERSION)
96: .for pv in ${PHP_VERSIONS_ACCEPTED}
97: .if defined(_PHP_VERSION_${pv}_INSTALLED)
98: _PHP_VERSION?= ${pv}
99: .else
100: # keep information as last resort - see below
101: _PHP_VERSION_FIRSTACCEPTED?= ${pv}
102: .endif
103: .endfor
104: .endif
105: # if the default is OK for the addon pkg, take this
106: .if !defined(_PHP_VERSION)
107: .if defined(_PHP_VERSION_${PHP_VERSION_DEFAULT}_OK)
108: _PHP_VERSION= ${PHP_VERSION_DEFAULT}
109: .endif
110: .endif
111: # take the first one accepted by the package
112: .if !defined(_PHP_VERSION)
113: _PHP_VERSION= ${_PHP_VERSION_FIRSTACCEPTED}
114: .endif
115:
1.2 jdolecek 116: # export some of internal variables
1.3 jdolecek 117: PKG_PHP_VERSION:= ${_PHP_VERSION}
118: PKG_PHP:= PHP${_PHP_VERSION}
1.2 jdolecek 119:
120: MESSAGE_SUBST+= PKG_PHP_VERSION=${PKG_PHP_VERSION} \
121: PKG_PHP=${PKG_PHP}
122: PLIST_SUBST+= PKG_PHP_VERSION=${PKG_PHP_VERSION}
123:
1.3 jdolecek 124: # force the selected PHP version for recursive builds
125: PHP_VERSION_REQD:= ${PKG_PHP_VERSION}
126:
1.1 jdolecek 127: #
128: # set variables for the version we decided to use:
129: #
130: .if ${_PHP_VERSION} == "4"
1.5 joerg 131: PHPPKGSRCDIR= ../../www/php4
132: PHP_PKG_PREFIX= php4
1.1 jdolecek 133: .elif ${_PHP_VERSION} == "5"
1.5 joerg 134: PHPPKGSRCDIR= ../../lang/php5
135: PHP_PKG_PREFIX= php5
1.1 jdolecek 136: .else
137: # force an error
1.2 jdolecek 138: PKG_SKIP_REASON+= "${PKG_PHP} is not a valid package"
1.1 jdolecek 139: .endif
140:
141: .endif # PHPVERSION_MK
CVSweb <webmaster@jp.NetBSD.org>