1 # $NetBSD: phpversion.mk,v 1.10 2010/02/10 17:46:10 joerg 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
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
29 # Default: (undefined)
31 # === Variables defined by this file ===
34 # The selected PHP version.
37 # Default: ${PHP_VERSION_DEFAULT}
40 # The same as ${PKG_PHP_VERSION}, prefixed with "PHP".
41 # XXX: Why is this necessary?
44 # The directory of the PHP implementation, relative to the
47 # Example: ../../lang/php5
50 # The prefix that is prepended to the package name.
57 .if !defined(PHPVERSION_MK)
58 PHPVERSION_MK= defined
61 _USER_VARS.php= PHP_VERSION_DEFAULT
62 _PKG_VARS.php= PHP_VERSIONS_ACCEPTED PHP_VERSION_REQD
63 _SYS_VARS.php= PKG_PHP_VERSION PKG_PHP PHPPKGSRCDIR PHP_PKG_PREFIX
65 .include "../../mk/bsd.prefs.mk"
67 PHP_VERSION_DEFAULT?= 5
68 PHP_VERSIONS_ACCEPTED?= 5
70 # transform the list into individual variables
71 .for pv in ${PHP_VERSIONS_ACCEPTED}
72 _PHP_VERSION_${pv}_OK= yes
75 # check what is installed
76 .if exists(${LOCALBASE}/lib/php/20040412)
77 _PHP_VERSION_5_INSTALLED= yes
80 # if a version is explicitely required, take it
81 .if defined(PHP_VERSION_REQD)
82 _PHP_VERSION= ${PHP_VERSION_REQD}
84 # if the default is already installed, it is first choice
85 .if !defined(_PHP_VERSION)
86 .if defined(_PHP_VERSION_${PHP_VERSION_DEFAULT}_OK)
87 .if defined(_PHP_VERSION_${PHP_VERSION_DEFAULT}_INSTALLED)
88 _PHP_VERSION= ${PHP_VERSION_DEFAULT}
92 # prefer an already installed version, in order of "accepted"
93 .if !defined(_PHP_VERSION)
94 .for pv in ${PHP_VERSIONS_ACCEPTED}
95 .if defined(_PHP_VERSION_${pv}_INSTALLED)
98 # keep information as last resort - see below
99 _PHP_VERSION_FIRSTACCEPTED?= ${pv}
103 # if the default is OK for the addon pkg, take this
104 .if !defined(_PHP_VERSION)
105 .if defined(_PHP_VERSION_${PHP_VERSION_DEFAULT}_OK)
106 _PHP_VERSION= ${PHP_VERSION_DEFAULT}
109 # take the first one accepted by the package
110 .if !defined(_PHP_VERSION)
111 _PHP_VERSION= ${_PHP_VERSION_FIRSTACCEPTED}
114 # export some of internal variables
115 PKG_PHP_VERSION:= ${_PHP_VERSION}
116 PKG_PHP:= PHP${_PHP_VERSION}
118 MESSAGE_SUBST+= PKG_PHP_VERSION=${PKG_PHP_VERSION} \
120 PLIST_SUBST+= PKG_PHP_VERSION=${PKG_PHP_VERSION}
122 # force the selected PHP version for recursive builds
123 PHP_VERSION_REQD:= ${PKG_PHP_VERSION}
126 # set variables for the version we decided to use:
128 .if ${_PHP_VERSION} == "5"
129 PHPPKGSRCDIR= ../../lang/php5
133 PKG_SKIP_REASON+= "${PKG_PHP} is not a valid package"
136 .endif # PHPVERSION_MK