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

1.9     ! rillig      1: # $NetBSD: phpversion.mk,v 1.8 2007/09/20 09:11:07 rillig 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
                     11: #      the package.
                     12: #
                     13: #      Possible: 4 5
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: #
                     21: #      Possible: 4 5
                     22: #      Default: 4 5
                     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: #
                     28: #      Possible: (undefined) 4 5
                     29: #      Default: (undefined)
                     30: #
                     31: # === Variables defined by this file ===
                     32: #
                     33: # PKG_PHP_VERSION
                     34: #      The selected PHP version.
                     35: #
                     36: #      Possible: 4 5
                     37: #      Default: ${PHP_VERSION_DEFAULT}
                     38: #
                     39: # PKG_PHP
                     40: #      The same as ${PKG_PHP_VERSION}, prefixed with "PHP".
                     41: #      XXX: Why is this necessary?
                     42: #
                     43: # PHPPKGSRCDIR
                     44: #      The directory of the PHP implementation, relative to the
                     45: #      package directory.
                     46: #
                     47: #      Example: ../../lang/php5
                     48: #
                     49: # PHP_PKG_PREFIX
                     50: #      The prefix that is prepended to the package name.
                     51: #
                     52: #      Example: php5
                     53: #
                     54: # Keywords: php
                     55: #
1.1       jdolecek   56: 
                     57: .if !defined(PHPVERSION_MK)
                     58: PHPVERSION_MK= defined
                     59: 
1.8       rillig     60: _VARGROUPS+=   php
                     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
                     64: 
1.1       jdolecek   65: .include "../../mk/bsd.prefs.mk"
                     66: 
1.4       tron       67: PHP_VERSION_DEFAULT?=          5
1.1       jdolecek   68: PHP_VERSIONS_ACCEPTED?=                4 5
                     69: 
                     70: # transform the list into individual variables
                     71: .for pv in ${PHP_VERSIONS_ACCEPTED}
                     72: _PHP_VERSION_${pv}_OK= yes
                     73: .endfor
                     74: 
                     75: # check what is installed
                     76: .if exists(${LOCALBASE}/lib/php/20020429)
                     77: _PHP_VERSION_4_INSTALLED=      yes
                     78: .endif
                     79: .if exists(${LOCALBASE}/lib/php/20040412)
                     80: _PHP_VERSION_5_INSTALLED=      yes
                     81: .endif
                     82: 
                     83: # if a version is explicitely required, take it
                     84: .if defined(PHP_VERSION_REQD)
                     85: _PHP_VERSION=  ${PHP_VERSION_REQD}
                     86: .endif
                     87: # if the default is already installed, it is first choice
                     88: .if !defined(_PHP_VERSION)
                     89: .if defined(_PHP_VERSION_${PHP_VERSION_DEFAULT}_OK)
                     90: .if defined(_PHP_VERSION_${PHP_VERSION_DEFAULT}_INSTALLED)
                     91: _PHP_VERSION=  ${PHP_VERSION_DEFAULT}
                     92: .endif
                     93: .endif
                     94: .endif
                     95: # prefer an already installed version, in order of "accepted"
                     96: .if !defined(_PHP_VERSION)
                     97: .for pv in ${PHP_VERSIONS_ACCEPTED}
                     98: .if defined(_PHP_VERSION_${pv}_INSTALLED)
                     99: _PHP_VERSION?= ${pv}
                    100: .else
                    101: # keep information as last resort - see below
                    102: _PHP_VERSION_FIRSTACCEPTED?=   ${pv}
                    103: .endif
                    104: .endfor
                    105: .endif
                    106: # if the default is OK for the addon pkg, take this
                    107: .if !defined(_PHP_VERSION)
                    108: .if defined(_PHP_VERSION_${PHP_VERSION_DEFAULT}_OK)
                    109: _PHP_VERSION=  ${PHP_VERSION_DEFAULT}
                    110: .endif
                    111: .endif
                    112: # take the first one accepted by the package
                    113: .if !defined(_PHP_VERSION)
                    114: _PHP_VERSION=  ${_PHP_VERSION_FIRSTACCEPTED}
                    115: .endif
                    116: 
1.2       jdolecek  117: # export some of internal variables
1.3       jdolecek  118: PKG_PHP_VERSION:=      ${_PHP_VERSION}
                    119: PKG_PHP:=              PHP${_PHP_VERSION}
1.2       jdolecek  120: 
                    121: MESSAGE_SUBST+=                PKG_PHP_VERSION=${PKG_PHP_VERSION} \
                    122:                        PKG_PHP=${PKG_PHP}
                    123: PLIST_SUBST+=          PKG_PHP_VERSION=${PKG_PHP_VERSION}
                    124: 
1.3       jdolecek  125: # force the selected PHP version for recursive builds
                    126: PHP_VERSION_REQD:=     ${PKG_PHP_VERSION}
                    127: 
1.1       jdolecek  128: #
                    129: # set variables for the version we decided to use:
                    130: #
                    131: .if ${_PHP_VERSION} == "4"
1.5       joerg     132: PHPPKGSRCDIR=          ../../www/php4
                    133: PHP_PKG_PREFIX=                php4
1.1       jdolecek  134: .elif ${_PHP_VERSION} == "5"
1.5       joerg     135: PHPPKGSRCDIR=          ../../lang/php5
                    136: PHP_PKG_PREFIX=                php5
1.1       jdolecek  137: .else
                    138: # force an error
1.2       jdolecek  139: PKG_SKIP_REASON+=      "${PKG_PHP} is not a valid package"
1.1       jdolecek  140: .endif
                    141: 
                    142: .endif # PHPVERSION_MK

CVSweb <webmaster@jp.NetBSD.org>