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

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

CVSweb <webmaster@jp.NetBSD.org>