Annotation of pkgsrc/lang/php/phpversion.mk, revision 1.17

1.17    ! taca        1: # $NetBSD: phpversion.mk,v 1.16 2011/10/29 13:47:03 cheusov 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.12      jdolecek   11: #      the package. '5' means any 5.*, 52 only 5.2.*, 53 only 5.3.*
1.6       rillig     12: #
1.12      jdolecek   13: #      Possible: 5 52 53
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.12      jdolecek   21: #      Possible: 5 52 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.12      jdolecek   28: #      Possible: (undefined) 5 52 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.15      taca       73: PHP_VERSION_DEFAULT?=          53
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.12      jdolecek   84: _PHP_VERSION_52_INSTALLED=     yes
                     85: _PHP_INSTALLED=                yes
                     86: .endif
                     87: .if exists(${LOCALBASE}/lib/php/20090626) || exists(${LOCALBASE}/include/php/Zend/zend_gc.h)
1.11      taca       88: _PHP_VERSION_53_INSTALLED=     yes
1.12      jdolecek   89: _PHP_INSTALLED=                yes
1.1       jdolecek   90: .endif
                     91: 
                     92: # if a version is explicitely required, take it
                     93: .if defined(PHP_VERSION_REQD)
                     94: _PHP_VERSION=  ${PHP_VERSION_REQD}
                     95: .endif
                     96: # if the default is already installed, it is first choice
                     97: .if !defined(_PHP_VERSION)
                     98: .if defined(_PHP_VERSION_${PHP_VERSION_DEFAULT}_OK)
                     99: .if defined(_PHP_VERSION_${PHP_VERSION_DEFAULT}_INSTALLED)
                    100: _PHP_VERSION=  ${PHP_VERSION_DEFAULT}
                    101: .endif
                    102: .endif
                    103: .endif
                    104: # prefer an already installed version, in order of "accepted"
                    105: .if !defined(_PHP_VERSION)
                    106: .for pv in ${PHP_VERSIONS_ACCEPTED}
                    107: .if defined(_PHP_VERSION_${pv}_INSTALLED)
                    108: _PHP_VERSION?= ${pv}
                    109: .else
                    110: # keep information as last resort - see below
                    111: _PHP_VERSION_FIRSTACCEPTED?=   ${pv}
                    112: .endif
                    113: .endfor
                    114: .endif
                    115: # if the default is OK for the addon pkg, take this
                    116: .if !defined(_PHP_VERSION)
                    117: .if defined(_PHP_VERSION_${PHP_VERSION_DEFAULT}_OK)
                    118: _PHP_VERSION=  ${PHP_VERSION_DEFAULT}
                    119: .endif
                    120: .endif
                    121: # take the first one accepted by the package
                    122: .if !defined(_PHP_VERSION)
                    123: _PHP_VERSION=  ${_PHP_VERSION_FIRSTACCEPTED}
                    124: .endif
                    125: 
1.14      wiz       126: #
                    127: # Variable assignment for multi-PHP packages
                    128: MULTI+=        PHP_VERSION_REQD=${_PHP_VERSION}
                    129: 
1.2       jdolecek  130: # export some of internal variables
1.12      jdolecek  131: PKG_PHP_VERSION:=      ${_PHP_VERSION:C/\.[0-9]//}
                    132: PKG_PHP:=              PHP${_PHP_VERSION:C/([0-9])([0-9])/\1.\2/}
1.11      taca      133: 
                    134: # currently we have only PHP 5.x packages.
                    135: PKG_PHP_MAJOR_VERS:=   5
1.2       jdolecek  136: 
1.12      jdolecek  137: # if installed PHP isn't compatible with required PHP, bail out
                    138: .if defined(_PHP_INSTALLED) && !defined(_PHP_VERSION_${_PHP_VERSION}_INSTALLED)
                    139: PKG_SKIP_REASON+=      "Package accepts ${PKG_PHP}, but different version is installed"
                    140: .endif
                    141: 
1.2       jdolecek  142: MESSAGE_SUBST+=                PKG_PHP_VERSION=${PKG_PHP_VERSION} \
                    143:                        PKG_PHP=${PKG_PHP}
1.11      taca      144: PLIST_SUBST+=          PKG_PHP_VERSION=${PKG_PHP_VERSION} \
                    145:                        PKG_PHP_MAJOR_VERS=${PKG_PHP_MAJOR_VERS}
1.2       jdolecek  146: 
1.3       jdolecek  147: # force the selected PHP version for recursive builds
                    148: PHP_VERSION_REQD:=     ${PKG_PHP_VERSION}
                    149: 
1.1       jdolecek  150: #
                    151: # set variables for the version we decided to use:
                    152: #
1.12      jdolecek  153: .if ${_PHP_VERSION} == "5" || ${_PHP_VERSION} == "52"
1.5       joerg     154: PHPPKGSRCDIR=          ../../lang/php5
                    155: PHP_PKG_PREFIX=                php5
1.11      taca      156: .elif ${_PHP_VERSION} == "53"
                    157: PHPPKGSRCDIR=          ../../lang/php53
                    158: PHP_PKG_PREFIX=                php53
1.1       jdolecek  159: .else
                    160: # force an error
1.2       jdolecek  161: PKG_SKIP_REASON+=      "${PKG_PHP} is not a valid package"
1.1       jdolecek  162: .endif
                    163: 
1.11      taca      164: #
                    165: # check installed version aginst required:
                    166: #
                    167: .if defined(_PHP_VERSION_INSTALLED)
                    168: .if ${_PHP_VERSION} != ${_PHP_VERSION_INSTALLED}
1.13      taca      169: PKG_SKIP_REASON+=      "${PKGBASE} requires ${PKG_PHP}, but php-${_PHP_VERSION_INSTALLED} is already installed."
1.11      taca      170: .endif
                    171: .endif
                    172: 
1.1       jdolecek  173: .endif # PHPVERSION_MK

CVSweb <webmaster@jp.NetBSD.org>