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

1.23    ! cheusov     1: # $NetBSD: phpversion.mk,v 1.22 2012/09/14 15:54:22 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.18      taca       11: #      the package.
1.6       rillig     12: #
1.19      taca       13: #      Possible: 53 54
1.17      taca       14: #      Default: 53
1.6       rillig     15: #
1.23    ! cheusov    16: # PHP_VERSION_REQD
        !            17: #      PHP version to use. This is a user variable and
        !            18: #      should not be set in packages.
        !            19: #      Normally it is used by bulk build tools.
        !            20: #
        !            21: #      Possible: ${PHP_VERSIONS_ACCEPTED}
        !            22: #      Default:  ${PHP_VERSION_DEFAULT}
        !            23: #
1.6       rillig     24: # === Package-settable variables ===
                     25: #
                     26: # PHP_VERSIONS_ACCEPTED
                     27: #      The PHP versions that are accepted by the package.
                     28: #
1.19      taca       29: #      Possible: 53 54
                     30: #      Default: 53 54
1.6       rillig     31: #
                     32: # === Variables defined by this file ===
                     33: #
                     34: # PKG_PHP_VERSION
                     35: #      The selected PHP version.
                     36: #
1.19      taca       37: #      Possible: 53 54
1.11      taca       38: #      Default: ${PHP_VERSION_DEFAULT}
                     39: #
1.18      taca       40: # PHP_BASE_VERS
                     41: #      The selected PHP's full version depends on PKG_PHP_VERSION
                     42: #
1.11      taca       43: # PKG_PHP_MAJOR_VERS
                     44: #      The selected PHP's major version.
                     45: #
1.10      joerg      46: #      Possible: 5
1.11      taca       47: #      Default: 5
1.6       rillig     48: #
                     49: # PKG_PHP
1.11      taca       50: #      The same as ${PKG_PHP_VERSION}, prefixed with "php-".
1.6       rillig     51: #
                     52: # PHPPKGSRCDIR
                     53: #      The directory of the PHP implementation, relative to the
                     54: #      package directory.
                     55: #
                     56: #      Example: ../../lang/php5
                     57: #
                     58: # PHP_PKG_PREFIX
                     59: #      The prefix that is prepended to the package name.
                     60: #
1.19      taca       61: #      Example: php53, php54
1.6       rillig     62: #
                     63: # Keywords: php
                     64: #
1.1       jdolecek   65: 
                     66: .if !defined(PHPVERSION_MK)
                     67: PHPVERSION_MK= defined
                     68: 
1.8       rillig     69: _VARGROUPS+=   php
                     70: _USER_VARS.php=        PHP_VERSION_DEFAULT
                     71: _PKG_VARS.php= PHP_VERSIONS_ACCEPTED PHP_VERSION_REQD
1.11      taca       72: _SYS_VARS.php= PKG_PHP_VERSION PKG_PHP PHPPKGSRCDIR PHP_PKG_PREFIX \
                     73:                PKG_PHP_MAJOR_VERS
1.8       rillig     74: 
1.1       jdolecek   75: .include "../../mk/bsd.prefs.mk"
                     76: 
1.22      taca       77: PHP53_VERSION=                 5.3.17
                     78: PHP54_VERSION=                 5.4.7
1.18      taca       79: 
1.15      taca       80: PHP_VERSION_DEFAULT?=          53
1.19      taca       81: PHP_VERSIONS_ACCEPTED?=                53 54
1.1       jdolecek   82: 
                     83: # transform the list into individual variables
                     84: .for pv in ${PHP_VERSIONS_ACCEPTED}
                     85: _PHP_VERSION_${pv}_OK= yes
                     86: .endfor
                     87: 
                     88: # check what is installed
1.18      taca       89: .if exists(${LOCALBASE}/lib/php/20120301)
                     90: _PHP_VERSION_54_INSTALLED=     yes
                     91: _PHP_INSTALLED=                        yes
                     92: .elif exists(${LOCALBASE}/lib/php/20090626) || exists(${LOCALBASE}/include/php/Zend/zend_gc.h)
                     93: _PHP_VERSION_53_INSTALLED=     yes
                     94: _PHP_INSTALLED=                        yes
1.1       jdolecek   95: .endif
                     96: 
                     97: # if a version is explicitely required, take it
                     98: .if defined(PHP_VERSION_REQD)
                     99: _PHP_VERSION=  ${PHP_VERSION_REQD}
                    100: .endif
                    101: # if the default is already installed, it is first choice
                    102: .if !defined(_PHP_VERSION)
                    103: .if defined(_PHP_VERSION_${PHP_VERSION_DEFAULT}_OK)
                    104: .if defined(_PHP_VERSION_${PHP_VERSION_DEFAULT}_INSTALLED)
                    105: _PHP_VERSION=  ${PHP_VERSION_DEFAULT}
                    106: .endif
                    107: .endif
                    108: .endif
                    109: # prefer an already installed version, in order of "accepted"
                    110: .if !defined(_PHP_VERSION)
                    111: .for pv in ${PHP_VERSIONS_ACCEPTED}
                    112: .if defined(_PHP_VERSION_${pv}_INSTALLED)
                    113: _PHP_VERSION?= ${pv}
                    114: .else
                    115: # keep information as last resort - see below
                    116: _PHP_VERSION_FIRSTACCEPTED?=   ${pv}
                    117: .endif
                    118: .endfor
                    119: .endif
                    120: # if the default is OK for the addon pkg, take this
                    121: .if !defined(_PHP_VERSION)
                    122: .if defined(_PHP_VERSION_${PHP_VERSION_DEFAULT}_OK)
                    123: _PHP_VERSION=  ${PHP_VERSION_DEFAULT}
                    124: .endif
                    125: .endif
                    126: # take the first one accepted by the package
                    127: .if !defined(_PHP_VERSION)
                    128: _PHP_VERSION=  ${_PHP_VERSION_FIRSTACCEPTED}
                    129: .endif
                    130: 
1.14      wiz       131: #
                    132: # Variable assignment for multi-PHP packages
                    133: MULTI+=        PHP_VERSION_REQD=${_PHP_VERSION}
                    134: 
1.2       jdolecek  135: # export some of internal variables
1.12      jdolecek  136: PKG_PHP_VERSION:=      ${_PHP_VERSION:C/\.[0-9]//}
                    137: PKG_PHP:=              PHP${_PHP_VERSION:C/([0-9])([0-9])/\1.\2/}
1.11      taca      138: 
                    139: # currently we have only PHP 5.x packages.
                    140: PKG_PHP_MAJOR_VERS:=   5
1.2       jdolecek  141: 
1.12      jdolecek  142: # if installed PHP isn't compatible with required PHP, bail out
                    143: .if defined(_PHP_INSTALLED) && !defined(_PHP_VERSION_${_PHP_VERSION}_INSTALLED)
                    144: PKG_SKIP_REASON+=      "Package accepts ${PKG_PHP}, but different version is installed"
                    145: .endif
                    146: 
1.2       jdolecek  147: MESSAGE_SUBST+=                PKG_PHP_VERSION=${PKG_PHP_VERSION} \
                    148:                        PKG_PHP=${PKG_PHP}
1.11      taca      149: PLIST_SUBST+=          PKG_PHP_VERSION=${PKG_PHP_VERSION} \
1.18      taca      150:                        PKG_PHP_MAJOR_VERS=${PKG_PHP_MAJOR_VERS} \
                    151:                        PHP_EXTENSION_DIR=${PHP_EXTENSION_DIR}
1.2       jdolecek  152: 
1.3       jdolecek  153: # force the selected PHP version for recursive builds
                    154: PHP_VERSION_REQD:=     ${PKG_PHP_VERSION}
                    155: 
1.1       jdolecek  156: #
                    157: # set variables for the version we decided to use:
                    158: #
1.19      taca      159: .if ${_PHP_VERSION} == "53"
1.11      taca      160: PHPPKGSRCDIR=          ../../lang/php53
1.18      taca      161: PHP_BASE_VERS=         ${PHP53_VERSION}
1.11      taca      162: PHP_PKG_PREFIX=                php53
1.18      taca      163: .elif ${_PHP_VERSION} == "54"
                    164: PHPPKGSRCDIR=          ../../lang/php54
                    165: PHP_BASE_VERS=         ${PHP54_VERSION}
                    166: PHP_PKG_PREFIX=                php54
1.1       jdolecek  167: .else
                    168: # force an error
1.2       jdolecek  169: PKG_SKIP_REASON+=      "${PKG_PHP} is not a valid package"
1.1       jdolecek  170: .endif
                    171: 
1.11      taca      172: #
                    173: # check installed version aginst required:
                    174: #
                    175: .if defined(_PHP_VERSION_INSTALLED)
                    176: .if ${_PHP_VERSION} != ${_PHP_VERSION_INSTALLED}
1.13      taca      177: PKG_SKIP_REASON+=      "${PKGBASE} requires ${PKG_PHP}, but php-${_PHP_VERSION_INSTALLED} is already installed."
1.11      taca      178: .endif
                    179: .endif
                    180: 
1.1       jdolecek  181: .endif # PHPVERSION_MK

CVSweb <webmaster@jp.NetBSD.org>