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

1.6     ! rillig      1: # $NetBSD: phpversion.mk,v 1.5 2006/06/02 18:27:56 joerg Exp $
        !             2: #
        !             3: # This file selects a PHP version, based on the user's preferences and
        !             4: # the installed packages.
        !             5: #
        !             6: # === User-settable variables ===
        !             7: #
        !             8: # PHP_VERSION_DEFAULT
        !             9: #      The PHP version to choose when more than one is acceptable to
        !            10: #      the package.
        !            11: #
        !            12: #      Possible: 4 5
        !            13: #      Default: 4
        !            14: #
        !            15: # === Package-settable variables ===
        !            16: #
        !            17: # PHP_VERSIONS_ACCEPTED
        !            18: #      The PHP versions that are accepted by the package.
        !            19: #
        !            20: #      Possible: 4 5
        !            21: #      Default: 4 5
        !            22: #
        !            23: # PHP_VERSION_REQD
        !            24: #      If the package works only with a specific PHP version, this
        !            25: #      variable can be used to force it.
        !            26: #
        !            27: #      Possible: (undefined) 4 5
        !            28: #      Default: (undefined)
        !            29: #
        !            30: # === Variables defined by this file ===
        !            31: #
        !            32: # PKG_PHP_VERSION
        !            33: #      The selected PHP version.
        !            34: #
        !            35: #      Possible: 4 5
        !            36: #      Default: ${PHP_VERSION_DEFAULT}
        !            37: #
        !            38: # PKG_PHP
        !            39: #      The same as ${PKG_PHP_VERSION}, prefixed with "PHP".
        !            40: #      XXX: Why is this necessary?
        !            41: #
        !            42: # PHPPKGSRCDIR
        !            43: #      The directory of the PHP implementation, relative to the
        !            44: #      package directory.
        !            45: #
        !            46: #      Example: ../../lang/php5
        !            47: #
        !            48: # PHP_PKG_PREFIX
        !            49: #      The prefix that is prepended to the package name.
        !            50: #
        !            51: #      Example: php5
        !            52: #
        !            53: # Keywords: php
        !            54: #
1.1       jdolecek   55: 
                     56: .if !defined(PHPVERSION_MK)
                     57: PHPVERSION_MK= defined
                     58: 
                     59: .include "../../mk/bsd.prefs.mk"
                     60: 
1.4       tron       61: PHP_VERSION_DEFAULT?=          5
1.1       jdolecek   62: PHP_VERSIONS_ACCEPTED?=                4 5
                     63: 
                     64: # transform the list into individual variables
                     65: .for pv in ${PHP_VERSIONS_ACCEPTED}
                     66: _PHP_VERSION_${pv}_OK= yes
                     67: .endfor
                     68: 
                     69: # check what is installed
                     70: .if exists(${LOCALBASE}/lib/php/20020429)
                     71: _PHP_VERSION_4_INSTALLED=      yes
                     72: .endif
                     73: .if exists(${LOCALBASE}/lib/php/20040412)
                     74: _PHP_VERSION_5_INSTALLED=      yes
                     75: .endif
                     76: 
                     77: # if a version is explicitely required, take it
                     78: .if defined(PHP_VERSION_REQD)
                     79: _PHP_VERSION=  ${PHP_VERSION_REQD}
                     80: .endif
                     81: # if the default is already installed, it is first choice
                     82: .if !defined(_PHP_VERSION)
                     83: .if defined(_PHP_VERSION_${PHP_VERSION_DEFAULT}_OK)
                     84: .if defined(_PHP_VERSION_${PHP_VERSION_DEFAULT}_INSTALLED)
                     85: _PHP_VERSION=  ${PHP_VERSION_DEFAULT}
                     86: .endif
                     87: .endif
                     88: .endif
                     89: # prefer an already installed version, in order of "accepted"
                     90: .if !defined(_PHP_VERSION)
                     91: .for pv in ${PHP_VERSIONS_ACCEPTED}
                     92: .if defined(_PHP_VERSION_${pv}_INSTALLED)
                     93: _PHP_VERSION?= ${pv}
                     94: .else
                     95: # keep information as last resort - see below
                     96: _PHP_VERSION_FIRSTACCEPTED?=   ${pv}
                     97: .endif
                     98: .endfor
                     99: .endif
                    100: # if the default is OK for the addon pkg, take this
                    101: .if !defined(_PHP_VERSION)
                    102: .if defined(_PHP_VERSION_${PHP_VERSION_DEFAULT}_OK)
                    103: _PHP_VERSION=  ${PHP_VERSION_DEFAULT}
                    104: .endif
                    105: .endif
                    106: # take the first one accepted by the package
                    107: .if !defined(_PHP_VERSION)
                    108: _PHP_VERSION=  ${_PHP_VERSION_FIRSTACCEPTED}
                    109: .endif
                    110: 
1.2       jdolecek  111: # export some of internal variables
1.3       jdolecek  112: PKG_PHP_VERSION:=      ${_PHP_VERSION}
                    113: PKG_PHP:=              PHP${_PHP_VERSION}
1.2       jdolecek  114: 
                    115: MESSAGE_SUBST+=                PKG_PHP_VERSION=${PKG_PHP_VERSION} \
                    116:                        PKG_PHP=${PKG_PHP}
                    117: PLIST_SUBST+=          PKG_PHP_VERSION=${PKG_PHP_VERSION}
                    118: 
1.3       jdolecek  119: # force the selected PHP version for recursive builds
                    120: PHP_VERSION_REQD:=     ${PKG_PHP_VERSION}
                    121: 
1.1       jdolecek  122: #
                    123: # set variables for the version we decided to use:
                    124: #
                    125: .if ${_PHP_VERSION} == "4"
1.5       joerg     126: PHPPKGSRCDIR=          ../../www/php4
                    127: PHP_PKG_PREFIX=                php4
1.1       jdolecek  128: .elif ${_PHP_VERSION} == "5"
1.5       joerg     129: PHPPKGSRCDIR=          ../../lang/php5
                    130: PHP_PKG_PREFIX=                php5
1.1       jdolecek  131: .else
                    132: # force an error
1.2       jdolecek  133: PKG_SKIP_REASON+=      "${PKG_PHP} is not a valid package"
1.1       jdolecek  134: .endif
                    135: 
                    136: .endif # PHPVERSION_MK

CVSweb <webmaster@jp.NetBSD.org>