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

1.417   ! taca        1: # $NetBSD: phpversion.mk,v 1.416 2023/11/30 16:14:00 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.416     taca       13: #      Possible: 56 74 80 81 82 83
1.413     taca       14: #      Default: 81
1.6       rillig     15: #
1.24      cheusov    16: # === Infrastructure variables ===
                     17: #
1.23      cheusov    18: # PHP_VERSION_REQD
1.24      cheusov    19: #      PHP version to use. This variable should not be set in
                     20: #      packages.  Normally it is used by bulk build tools.
1.23      cheusov    21: #
                     22: #      Possible: ${PHP_VERSIONS_ACCEPTED}
                     23: #      Default:  ${PHP_VERSION_DEFAULT}
                     24: #
1.6       rillig     25: # === Package-settable variables ===
                     26: #
                     27: # PHP_VERSIONS_ACCEPTED
                     28: #      The PHP versions that are accepted by the package.
                     29: #
1.416     taca       30: #      Possible: 56 74 80 81 82 83
                     31: #      Default: 81 82 83 74 56 80
1.6       rillig     32: #
1.152     joerg      33: # PHP_VERSIONS_INCOMPATIBLE
                     34: #      The PHP versions that are not supported by the package.
                     35: #
1.416     taca       36: #      Possible: 56 74 80 81 82 83
1.152     joerg      37: #      Default: (empty)
                     38: #
1.37      taca       39: # PHP_CHECK_INSTALLED
1.416     taca       40: #      Check installed version of PHP.  Should be only used by
                     41: #      lang/php56, lang/php74, lang/php80, lang/php81, lang/php82
                     42: #      and lang/php83.
1.37      taca       43: #
                     44: #      Possible: Yes No
                     45: #      Default: Yes
                     46: #
1.6       rillig     47: # === Variables defined by this file ===
                     48: #
                     49: # PKG_PHP_VERSION
                     50: #      The selected PHP version.
                     51: #
1.416     taca       52: #      Possible: 56 74 80 81 82 83
1.11      taca       53: #      Default: ${PHP_VERSION_DEFAULT}
                     54: #
1.18      taca       55: # PHP_BASE_VERS
                     56: #      The selected PHP's full version depends on PKG_PHP_VERSION
                     57: #
1.11      taca       58: # PKG_PHP_MAJOR_VERS
                     59: #      The selected PHP's major version.
                     60: #
1.322     taca       61: #      Possible: 5 7 8
1.413     taca       62: #      Default: 8
1.6       rillig     63: #
                     64: # PKG_PHP
1.11      taca       65: #      The same as ${PKG_PHP_VERSION}, prefixed with "php-".
1.6       rillig     66: #
                     67: # PHPPKGSRCDIR
                     68: #      The directory of the PHP implementation, relative to the
                     69: #      package directory.
                     70: #
1.413     taca       71: #      Example: ../../lang/php81
1.6       rillig     72: #
                     73: # PHP_PKG_PREFIX
                     74: #      The prefix that is prepended to the package name.
                     75: #
1.416     taca       76: #      Example: php56 php74 php80 php81 php82 php83
1.6       rillig     77: #
1.37      taca       78: # PHP_EXTENSION_DIR
                     79: #      Relative path to ${PREFIX} for PHP's extensions.  It is derived from
                     80: #      initial release of major version.
                     81: #
1.277     taca       82: #      Example: lib/php/20181200
1.37      taca       83: #
1.6       rillig     84: # Keywords: php
                     85: #
1.1       jdolecek   86: 
                     87: .if !defined(PHPVERSION_MK)
                     88: PHPVERSION_MK= defined
                     89: 
1.37      taca       90: # Define each PHP's version.
1.245     taca       91: PHP56_VERSION= 5.6.40
1.380     taca       92: PHP74_VERSION= 7.4.33
1.406     taca       93: PHP80_VERSION= 8.0.30
1.415     taca       94: PHP81_VERSION= 8.1.26
1.414     taca       95: PHP82_VERSION= 8.2.13
1.417   ! taca       96: PHP83_VERSION= 8.3.1
1.37      taca       97: 
1.383     taca       98: # Define API version or initial release of major version.
1.78      taca       99: PHP56_RELDATE= 20140828
1.278     taca      100: PHP74_RELDATE= 20191128
1.322     taca      101: PHP80_RELDATE= 20201124
1.348     taca      102: PHP81_RELDATE= 20211125
1.383     taca      103: PHP82_RELDATE= 20220829
1.416     taca      104: PHP83_RELDATE= 20231123
1.37      taca      105: 
1.8       rillig    106: _VARGROUPS+=   php
                    107: _USER_VARS.php=        PHP_VERSION_DEFAULT
                    108: _PKG_VARS.php= PHP_VERSIONS_ACCEPTED PHP_VERSION_REQD
1.11      taca      109: _SYS_VARS.php= PKG_PHP_VERSION PKG_PHP PHPPKGSRCDIR PHP_PKG_PREFIX \
                    110:                PKG_PHP_MAJOR_VERS
1.8       rillig    111: 
1.1       jdolecek  112: .include "../../mk/bsd.prefs.mk"
                    113: 
1.413     taca      114: PHP_VERSION_DEFAULT?=          81
1.416     taca      115: PHP_VERSIONS_ACCEPTED?=                81 82 83 74 56 80
1.152     joerg     116: .for pv in ${PHP_VERSIONS_ACCEPTED}
                    117: .  if empty(PHP_VERSIONS_INCOMPATIBLE:M${pv})
                    118: _PHP_VERSIONS_ACCEPTED+=       ${pv}
                    119: .  endif
                    120: .endfor
1.1       jdolecek  121: 
                    122: # transform the list into individual variables
1.152     joerg     123: .for pv in ${_PHP_VERSIONS_ACCEPTED}
1.1       jdolecek  124: _PHP_VERSION_${pv}_OK= yes
                    125: .endfor
                    126: 
                    127: # check what is installed
1.416     taca      128: .if exists(${LOCALBASE}/lib/php/${PHP83_RELDATE})
                    129: _PHP_VERSION_83_INSTALLED=     yes
                    130: _PHP_INSTALLED=                        yes
                    131: .elif exists(${LOCALBASE}/lib/php/${PHP82_RELDATE})
1.383     taca      132: _PHP_VERSION_82_INSTALLED=     yes
                    133: _PHP_INSTALLED=                        yes
                    134: .elif exists(${LOCALBASE}/lib/php/${PHP81_RELDATE})
1.348     taca      135: _PHP_VERSION_81_INSTALLED=     yes
                    136: _PHP_INSTALLED=                        yes
                    137: .elif exists(${LOCALBASE}/lib/php/${PHP80_RELDATE})
1.322     taca      138: _PHP_VERSION_80_INSTALLED=     yes
                    139: _PHP_INSTALLED=                        yes
                    140: .elif exists(${LOCALBASE}/lib/php/${PHP74_RELDATE})
1.278     taca      141: _PHP_VERSION_74_INSTALLED=     yes
                    142: _PHP_INSTALLED=                        yes
1.147     jdolecek  143: .elif exists(${LOCALBASE}/lib/php/${PHP56_RELDATE})
1.78      taca      144: _PHP_VERSION_56_INSTALLED=     yes
                    145: _PHP_INSTALLED=                        yes
1.1       jdolecek  146: .endif
                    147: 
1.349     gutterid  148: # if a version is explicitly required, take it
1.1       jdolecek  149: .if defined(PHP_VERSION_REQD)
                    150: _PHP_VERSION=  ${PHP_VERSION_REQD}
                    151: .endif
                    152: # if the default is already installed, it is first choice
                    153: .if !defined(_PHP_VERSION)
                    154: .if defined(_PHP_VERSION_${PHP_VERSION_DEFAULT}_OK)
                    155: .if defined(_PHP_VERSION_${PHP_VERSION_DEFAULT}_INSTALLED)
                    156: _PHP_VERSION=  ${PHP_VERSION_DEFAULT}
                    157: .endif
                    158: .endif
                    159: .endif
                    160: # prefer an already installed version, in order of "accepted"
                    161: .if !defined(_PHP_VERSION)
1.152     joerg     162: .for pv in ${_PHP_VERSIONS_ACCEPTED}
1.1       jdolecek  163: .if defined(_PHP_VERSION_${pv}_INSTALLED)
                    164: _PHP_VERSION?= ${pv}
                    165: .else
                    166: # keep information as last resort - see below
                    167: _PHP_VERSION_FIRSTACCEPTED?=   ${pv}
                    168: .endif
                    169: .endfor
                    170: .endif
1.349     gutterid  171: # if the default is OK for the add-on pkg, take this
1.1       jdolecek  172: .if !defined(_PHP_VERSION)
                    173: .if defined(_PHP_VERSION_${PHP_VERSION_DEFAULT}_OK)
                    174: _PHP_VERSION=  ${PHP_VERSION_DEFAULT}
                    175: .endif
                    176: .endif
                    177: # take the first one accepted by the package
                    178: .if !defined(_PHP_VERSION)
                    179: _PHP_VERSION=  ${_PHP_VERSION_FIRSTACCEPTED}
                    180: .endif
                    181: 
1.14      wiz       182: #
                    183: # Variable assignment for multi-PHP packages
                    184: MULTI+=        PHP_VERSION_REQD=${_PHP_VERSION}
                    185: 
1.349     gutterid  186: # export some of the internal variables
1.12      jdolecek  187: PKG_PHP_VERSION:=      ${_PHP_VERSION:C/\.[0-9]//}
1.38      taca      188: PKG_PHP:=              PHP${_PHP_VERSION:C/([0-9])([0-9])/\1.\2/}
1.11      taca      189: 
1.118     taca      190: # Major version
                    191: PKG_PHP_MAJOR_VERS:=   ${_PHP_VERSION:C/^([0-9]).*/\1/}
1.2       jdolecek  192: 
1.37      taca      193: PHP_CHECK_INSTALLED?=  Yes
                    194: 
1.12      jdolecek  195: # if installed PHP isn't compatible with required PHP, bail out
1.39      taca      196: .if empty(PHP_CHECK_INSTALLED:M[nN][oO])
1.12      jdolecek  197: .if defined(_PHP_INSTALLED) && !defined(_PHP_VERSION_${_PHP_VERSION}_INSTALLED)
1.349     gutterid  198: PKG_FAIL_REASON+=      "Package accepts ${PKG_PHP}, but a different version is installed"
1.12      jdolecek  199: .endif
1.37      taca      200: .endif
1.12      jdolecek  201: 
1.2       jdolecek  202: MESSAGE_SUBST+=                PKG_PHP_VERSION=${PKG_PHP_VERSION} \
                    203:                        PKG_PHP=${PKG_PHP}
1.322     taca      204: PLIST_SUBST+=          PHP_PKG_PREFIX=${PHP_PKG_PREFIX} \
                    205:                        PKG_PHP_VERSION=${PKG_PHP_VERSION} \
1.18      taca      206:                        PKG_PHP_MAJOR_VERS=${PKG_PHP_MAJOR_VERS} \
                    207:                        PHP_EXTENSION_DIR=${PHP_EXTENSION_DIR}
1.2       jdolecek  208: 
1.3       jdolecek  209: # force the selected PHP version for recursive builds
                    210: PHP_VERSION_REQD:=     ${PKG_PHP_VERSION}
                    211: 
1.1       jdolecek  212: #
                    213: # set variables for the version we decided to use:
                    214: #
1.416     taca      215: .if ${_PHP_VERSION} == 56
1.89      taca      216: PHP_VERSION=           ${PHP56_VERSION}
                    217: PHP_INITIAL_TEENY=     3
1.78      taca      218: PHP_EXTENSION_DIR=     lib/php/${PHP56_RELDATE}
1.416     taca      219: .elif ${_PHP_VERSION} == 74
1.278     taca      220: PHP_VERSION=           ${PHP74_VERSION}
                    221: PHP_EXTENSION_DIR=     lib/php/${PHP74_RELDATE}
1.416     taca      222: .elif ${_PHP_VERSION} == 80
1.322     taca      223: PHP_VERSION=           ${PHP80_VERSION}
                    224: PHP_EXTENSION_DIR=     lib/php/${PHP80_RELDATE}
1.416     taca      225: .elif ${_PHP_VERSION} == 81
1.348     taca      226: PHP_VERSION=           ${PHP81_VERSION}
                    227: PHP_EXTENSION_DIR=     lib/php/${PHP81_RELDATE}
1.416     taca      228: .elif ${_PHP_VERSION} == 82
1.383     taca      229: PHP_VERSION=           ${PHP82_VERSION}
                    230: PHP_EXTENSION_DIR=     lib/php/${PHP82_RELDATE}
1.416     taca      231: .elif ${_PHP_VERSION} == 83
                    232: PHP_VERSION=           ${PHP83_VERSION}
                    233: PHP_EXTENSION_DIR=     lib/php/${PHP83_RELDATE}
1.1       jdolecek  234: .else
                    235: # force an error
1.82      dholland  236: PKG_FAIL_REASON+=      "${PKG_PHP} is not a valid package"
1.1       jdolecek  237: .endif
                    238: 
1.279     taca      239: PHP_INITIAL_TEENY?=    0
                    240: PHPPKGSRCDIR=          ../../lang/php${PKG_PHP_VERSION}
                    241: PHP_PKG_PREFIX=                php${PKG_PHP_VERSION}
                    242: 
1.89      taca      243: _PHP_VER_MAJOR=                ${PHP_VERSION:C/([0-9]+)\.([0-9]+)\.([0-9]+)/\1/}
                    244: _PHP_VER_MINOR=                ${PHP_VERSION:C/([0-9]+)\.([0-9]+)\.([0-9]+)/\2/}
                    245: 
                    246: PHP_BASE_VERS= ${_PHP_VER_MAJOR}.${_PHP_VER_MINOR}.${PHP_INITIAL_TEENY}
                    247: 
1.11      taca      248: #
1.349     gutterid  249: # check installed version against required:
1.11      taca      250: #
1.37      taca      251: .if !empty(PHP_CHECK_INSTALLED:M[nN][oO])
                    252: .if defined(_PHP_VERSION_INSTALLED) && ${_PHP_VERSION} != ${_PHP_VERSION_INSTALLED}
1.82      dholland  253: PKG_FAIL_REASON+=      "${PKGBASE} requires ${PKG_PHP}, but php-${_PHP_VERSION_INSTALLED} is already installed."
1.11      taca      254: .endif
                    255: .endif
                    256: 
1.401     taca      257: MAKEFLAGS+=    PHP_VERSION_REQD=${PHP_VERSION_REQD}
                    258: 
1.1       jdolecek  259: .endif # PHPVERSION_MK

CVSweb <webmaster@jp.NetBSD.org>