1SUMMARY = "A server-side, HTML-embedded scripting language" 2HOMEPAGE = "http://www.php.net" 3SECTION = "console/network" 4 5LICENSE = "PHP-3.0" 6LIC_FILES_CHKSUM = "file://LICENSE;md5=fd469cce1a919f0cc95bab7afb28d19d" 7 8BBCLASSEXTEND = "native" 9DEPENDS = "zlib bzip2 libxml2 virtual/libiconv php-native" 10DEPENDS:append:libc-musl = " libucontext" 11DEPENDS:class-native = "zlib-native libxml2-native" 12 13PHP_MAJOR_VERSION = "${@d.getVar('PV').split('.')[0]}" 14 15SRC_URI = "http://php.net/distributions/php-${PV}.tar.bz2 \ 16 file://0002-build-php.m4-don-t-unset-cache-variables.patch \ 17 file://0003-php-remove-host-specific-info-from-header-file.patch \ 18 file://0004-configure.ac-don-t-include-build-libtool.m4.patch \ 19 file://0006-ext-phar-Makefile.frag-Fix-phar-packaging.patch \ 20 file://0009-php-don-t-use-broken-wrapper-for-mkdir.patch \ 21 file://0010-iconv-fix-detection.patch \ 22 file://0001-Change-whether-to-inline-XXH3_hashLong_withSecret-to.patch \ 23 " 24 25SRC_URI:append:class-target = " \ 26 file://0001-ext-opcache-config.m4-enable-opcache.patch \ 27 file://0005-pear-fix-Makefile.frag-for-Yocto.patch \ 28 file://0007-sapi-cli-config.m4-fix-build-directory.patch \ 29 file://0008-ext-imap-config.m4-fix-include-paths.patch \ 30 file://php-fpm.conf \ 31 file://php-fpm-apache.conf \ 32 file://70_mod_php${PHP_MAJOR_VERSION}.conf \ 33 file://php-fpm.service \ 34 " 35 36S = "${WORKDIR}/php-${PV}" 37SRC_URI[sha256sum] = "5dec6fa61c7b9c47aa1d76666be651f2642ed2bcf6cd8638c57e3571ce2aac61" 38 39CVE_STATUS_GROUPS += "CVE_STATUS_PHP" 40CVE_STATUS_PHP[status] = "fixed-version: The name of this product is exactly the same as github.com/emlog/emlog. CVE can be safely ignored." 41CVE_STATUS_PHP = " \ 42 CVE-2007-2728 \ 43 CVE-2007-3205 \ 44 CVE-2007-4596 \ 45" 46CVE_STATUS[CVE-2022-4900] = "cpe-incorrect: The current version (8.2.20) is not affected." 47 48inherit autotools pkgconfig python3native gettext multilib_header multilib_script systemd 49 50# phpize is not scanned for absolute paths by default (but php-config is). 51# 52SSTATE_SCAN_FILES += "phpize" 53SSTATE_SCAN_FILES += "build-defs.h" 54 55PHP_LIBDIR = "${libdir}/php${PHP_MAJOR_VERSION}" 56 57# Common EXTRA_OECONF 58COMMON_EXTRA_OECONF = "--enable-sockets \ 59 --enable-pcntl \ 60 --enable-shared \ 61 --disable-rpath \ 62 --with-pic \ 63 --libdir=${PHP_LIBDIR} \ 64" 65EXTRA_OECONF = "--enable-mbstring \ 66 --enable-fpm \ 67 --with-libdir=${baselib} \ 68 --with-gettext=${STAGING_LIBDIR}/.. \ 69 --with-zlib=${STAGING_LIBDIR}/.. \ 70 --with-iconv=${STAGING_LIBDIR}/.. \ 71 --with-bz2=${STAGING_DIR_TARGET}${exec_prefix} \ 72 --with-config-file-path=${sysconfdir}/php/apache2-php${PHP_MAJOR_VERSION} \ 73 ${@oe.utils.conditional('SITEINFO_ENDIANNESS', 'le', 'ac_cv_c_bigendian_php=no', 'ac_cv_c_bigendian_php=yes', d)} \ 74 ${@bb.utils.contains('PACKAGECONFIG', 'pam', '', 'ac_cv_lib_pam_pam_start=no', d)} \ 75 ${COMMON_EXTRA_OECONF} \ 76" 77 78EXTRA_OECONF:append:riscv64 = " --with-pcre-jit=no" 79EXTRA_OECONF:append:riscv32 = " --with-pcre-jit=no" 80# Needs fibers assembly implemented for rv32 81# for example rv64 implementation is below 82# see https://github.com/php/php-src/commit/70b02d75f2abe3a292d49c4a4e9e4f850c2fee68 83EXTRA_OECONF:append:riscv32:libc-musl = " --disable-fiber-asm" 84 85CACHED_CONFIGUREVARS += "ac_cv_func_dlopen=no ac_cv_lib_dl_dlopen=yes" 86 87EXTRA_OECONF:class-native = " \ 88 --with-zlib=${STAGING_LIBDIR_NATIVE}/.. \ 89 --without-iconv \ 90 ${COMMON_EXTRA_OECONF} \ 91" 92 93PACKAGECONFIG ??= "mysql sqlite3 imap opcache openssl \ 94 ${@bb.utils.filter('DISTRO_FEATURES', 'ipv6 pam', d)} \ 95" 96PACKAGECONFIG:class-native = "" 97 98PACKAGECONFIG[zip] = "--with-zip --with-zlib-dir=${STAGING_EXECPREFIXDIR},,libzip" 99 100PACKAGECONFIG[mysql] = "--with-mysqli=mysqlnd \ 101 --with-pdo-mysql=mysqlnd \ 102 ,--without-mysqli --without-pdo-mysql \ 103 ,mysql5" 104 105PACKAGECONFIG[sqlite3] = "--with-sqlite3=${STAGING_LIBDIR}/.. \ 106 --with-pdo-sqlite=${STAGING_LIBDIR}/.. \ 107 ,--without-sqlite3 --without-pdo-sqlite \ 108 ,sqlite3" 109PACKAGECONFIG[pgsql] = "--with-pgsql=${STAGING_DIR_TARGET}${exec_prefix},--without-pgsql,postgresql" 110PACKAGECONFIG[soap] = "--enable-soap, --disable-soap, libxml2" 111PACKAGECONFIG[apache2] = "--with-apxs2=${STAGING_BINDIR_CROSS}/apxs,,apache2-native apache2" 112PACKAGECONFIG[pam] = ",,libpam" 113PACKAGECONFIG[imap] = "--with-imap=${STAGING_DIR_HOST} \ 114 --with-imap-ssl=${STAGING_DIR_HOST} \ 115 ,--without-imap --without-imap-ssl \ 116 ,uw-imap" 117PACKAGECONFIG[ipv6] = "--enable-ipv6,--disable-ipv6," 118PACKAGECONFIG[opcache] = "--enable-opcache,--disable-opcache" 119PACKAGECONFIG[openssl] = "--with-openssl,--without-openssl,openssl" 120PACKAGECONFIG[valgrind] = "--with-valgrind=${STAGING_DIR_TARGET}/usr,--with-valgrind=no,valgrind" 121PACKAGECONFIG[mbregex] = "--enable-mbregex, --disable-mbregex, oniguruma" 122PACKAGECONFIG[mbstring] = "--enable-mbstring,," 123 124export HOSTCC = "${BUILD_CC}" 125export PHP_NATIVE_DIR = "${STAGING_BINDIR_NATIVE}" 126export PHP_PEAR_PHP_BIN = "${STAGING_BINDIR_NATIVE}/php" 127CFLAGS += " -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -g -DPTYS_ARE_GETPT -DPTYS_ARE_SEARCHED -I${STAGING_INCDIR}/apache2" 128 129# Adding these flags enables dynamic library support, which is disabled by 130# default when cross compiling 131# See https://bugs.php.net/bug.php?id=60109 132CFLAGS += " -DHAVE_LIBDL " 133LDFLAGS += " -ldl " 134LDFLAGS:append:libc-musl = " -lucontext " 135LDFLAGS:append:riscv64 = " -latomic" 136 137EXTRA_OEMAKE = "INSTALL_ROOT=${D}" 138 139acpaths = "" 140 141do_configure:prepend () { 142 rm -f ${S}/build/libtool.m4 ${S}/ltmain.sh ${S}/aclocal.m4 143 find ${S} -name config.m4 | xargs -n1 sed -i 's!APXS_HTTPD=.*!APXS_HTTPD=${STAGING_SBINDIR_NATIVE}/httpd!' 144} 145 146do_configure:append() { 147 # No, libtool, we really don't want rpath set... 148 sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool 149 sed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool 150 sed -i -e's@${RECIPE_SYSROOT}@@g' \ 151 -e's@-ffile-prefix-map=[^ ]*[ ]*@@g' \ 152 -e's@-fdebug-prefix-map=[^ ]*[ ]*@@g' \ 153 -e's@-ffile-prefix-map=[^ ]*[ ]*@@g' \ 154 -e's@-fmacro-prefix-map=[^ ]*[ ]*@@g' \ 155 ${B}/main/build-defs.h \ 156 ${B}/scripts/php-config 157} 158 159do_install:append:class-native() { 160 rm -rf ${D}/${PHP_LIBDIR}/php/.registry 161 rm -rf ${D}/${PHP_LIBDIR}/php/.channels 162 rm -rf ${D}/${PHP_LIBDIR}/php/.[a-z]* 163} 164 165do_install:prepend() { 166 cat ${ACLOCALDIR}/libtool.m4 ${ACLOCALDIR}/lt~obsolete.m4 ${ACLOCALDIR}/ltoptions.m4 \ 167 ${ACLOCALDIR}/ltsugar.m4 ${ACLOCALDIR}/ltversion.m4 > ${S}/build/libtool.m4 168} 169 170do_install:prepend:class-target() { 171 if ${@bb.utils.contains('PACKAGECONFIG', 'apache2', 'true', 'false', d)}; then 172 # Install dummy config file so apxs doesn't fail 173 install -d ${D}${sysconfdir}/apache2 174 printf "\nLoadModule dummy_module modules/mod_dummy.so\n" > ${D}${sysconfdir}/apache2/httpd.conf 175 fi 176} 177 178# fixme 179do_install:append:class-target() { 180 install -d ${D}${sysconfdir}/ 181 rm -rf ${D}/.registry 182 rm -rf ${D}/.channels 183 rm -rf ${D}/.[a-z]* 184 rm -rf ${D}/var 185 rm -f ${D}/${sysconfdir}/php-fpm.conf.default 186 install -m 0644 ${UNPACKDIR}/php-fpm.conf ${D}/${sysconfdir}/php-fpm.conf 187 install -d ${D}/${sysconfdir}/apache2/conf.d 188 install -m 0644 ${UNPACKDIR}/php-fpm-apache.conf ${D}/${sysconfdir}/apache2/conf.d/php-fpm.conf 189 install -d ${D}${sysconfdir}/init.d 190 sed -i 's:=/usr/sbin:=${sbindir}:g' ${B}/sapi/fpm/init.d.php-fpm 191 sed -i 's:=/etc:=${sysconfdir}:g' ${B}/sapi/fpm/init.d.php-fpm 192 sed -i 's:=/var:=${localstatedir}:g' ${B}/sapi/fpm/init.d.php-fpm 193 install -m 0755 ${B}/sapi/fpm/init.d.php-fpm ${D}${sysconfdir}/init.d/php-fpm 194 install -m 0644 ${UNPACKDIR}/php-fpm-apache.conf ${D}/${sysconfdir}/apache2/conf.d/php-fpm.conf 195 196 if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)};then 197 install -d ${D}${systemd_system_unitdir} 198 install -m 0644 ${UNPACKDIR}/php-fpm.service ${D}${systemd_system_unitdir}/php-fpm.service 199 sed -i -e 's,@LOCALSTATEDIR@,${localstatedir},g' ${D}${systemd_system_unitdir}/php-fpm.service 200 sed -i -e 's,@SBINDIR@,${sbindir},g' ${D}${systemd_system_unitdir}/php-fpm.service 201 sed -i -e 's,@BINDIR@,${bindir},g' ${D}${systemd_system_unitdir}/php-fpm.service 202 fi 203 204 if ${@bb.utils.contains('PACKAGECONFIG', 'apache2', 'true', 'false', d)}; then 205 install -d ${D}${sysconfdir}/apache2/modules.d 206 install -d ${D}${sysconfdir}/php/apache2-php${PHP_MAJOR_VERSION} 207 install -m 644 ${UNPACKDIR}/70_mod_php${PHP_MAJOR_VERSION}.conf ${D}${sysconfdir}/apache2/modules.d 208 sed -i s,lib/,${libexecdir}/, ${D}${sysconfdir}/apache2/modules.d/70_mod_php${PHP_MAJOR_VERSION}.conf 209 cat ${S}/php.ini-production | \ 210 sed -e 's,extension_dir = \"\./\",extension_dir = \"/usr/lib/extensions\",' \ 211 > ${D}${sysconfdir}/php/apache2-php${PHP_MAJOR_VERSION}/php.ini 212 rm -f ${D}${sysconfdir}/apache2/httpd.conf* 213 fi 214} 215 216MULTILIB_SCRIPTS += "${PN}:${bindir}/php-config \ 217 ${PN}:${bindir}/phpize \ 218" 219 220do_install:append () { 221 oe_multilib_header php/main/build-defs.h php/main/php_config.h 222} 223 224SYSROOT_PREPROCESS_FUNCS += "php_sysroot_preprocess" 225 226php_sysroot_preprocess () { 227 install -d ${SYSROOT_DESTDIR}${bindir_crossscripts}/ 228 install -m 755 ${D}${bindir}/phpize ${SYSROOT_DESTDIR}${bindir_crossscripts}/ 229 install -m 755 ${D}${bindir}/php-config ${SYSROOT_DESTDIR}${bindir_crossscripts}/ 230 231 sed -i 's!eval echo /!eval echo ${STAGING_DIR_HOST}/!' ${SYSROOT_DESTDIR}${bindir_crossscripts}/phpize 232 sed -i 's!^include_dir=.*!include_dir=${STAGING_INCDIR}/php!' ${SYSROOT_DESTDIR}${bindir_crossscripts}/php-config 233} 234 235MODPHP_PACKAGE = "${@bb.utils.contains('PACKAGECONFIG', 'apache2', '${PN}-modphp', '', d)}" 236 237PACKAGES = "${PN}-dbg ${PN}-cli ${PN}-phpdbg ${PN}-cgi ${PN}-fpm ${PN}-fpm-apache2 ${PN}-pear ${PN}-phar ${MODPHP_PACKAGE} ${PN}-dev ${PN}-staticdev ${PN}-doc ${PN}-opcache ${PN}" 238 239RDEPENDS:${PN} += "libgcc" 240RDEPENDS:${PN}-pear = "${PN}" 241RDEPENDS:${PN}-phar = "${PN}-cli" 242RDEPENDS:${PN}-cli = "${PN}" 243RDEPENDS:${PN}-modphp = "${PN} apache2" 244RDEPENDS:${PN}-opcache = "${PN}" 245 246ALLOW_EMPTY:${PN} = "1" 247 248INITSCRIPT_PACKAGES = "${PN}-fpm" 249inherit update-rc.d 250 251# WARNING: lib32-php-8.0.12-r0 do_package_qa: QA Issue: lib32-php: ELF binary /usr/libexec/apache2/modules/libphp.so has relocations in .text [textrel] 252#WARNING: lib32-php-8.0.12-r0 do_package_qa: QA Issue: lib32-php-opcache: ELF binary /usr/lib/php8/extensions/no-debug-zts-20200930/opcache.so has relocations in .text [textrel] 253INSANE_SKIP:${PN}:append:x86 = " textrel" 254INSANE_SKIP:${PN}-opcache:append:x86 = " textrel" 255 256FILES:${PN}-dbg =+ "${bindir}/.debug \ 257 ${libexecdir}/apache2/modules/.debug" 258FILES:${PN}-doc += "${PHP_LIBDIR}/php/doc" 259FILES:${PN}-cli = "${bindir}/php" 260FILES:${PN}-phpdbg = "${bindir}/phpdbg" 261FILES:${PN}-phar = "${bindir}/phar*" 262FILES:${PN}-cgi = "${bindir}/php-cgi" 263FILES:${PN}-fpm = "${sbindir}/php-fpm ${sysconfdir}/php-fpm.conf ${datadir}/fpm ${sysconfdir}/init.d/php-fpm ${sysconfdir}/php-fpm.d/www.conf.default" 264FILES:${PN}-fpm-apache2 = "${sysconfdir}/apache2/conf.d/php-fpm.conf" 265CONFFILES:${PN}-fpm = "${sysconfdir}/php-fpm.conf" 266CONFFILES:${PN}-fpm-apache2 = "${sysconfdir}/apache2/conf.d/php-fpm.conf" 267INITSCRIPT_NAME:${PN}-fpm = "php-fpm" 268INITSCRIPT_PARAMS:${PN}-fpm = "defaults 60" 269FILES:${PN}-pear = "${bindir}/pear* ${bindir}/pecl ${PHP_LIBDIR}/php/PEAR \ 270 ${PHP_LIBDIR}/php/PEAR*.php ${PHP_LIBDIR}/php/System.php \ 271 ${PHP_LIBDIR}/php/peclcmd.php ${PHP_LIBDIR}/php/pearcmd.php \ 272 ${PHP_LIBDIR}/php/.channels ${PHP_LIBDIR}/php/.channels/.alias \ 273 ${PHP_LIBDIR}/php/.registry ${PHP_LIBDIR}/php/Archive/Tar.php \ 274 ${PHP_LIBDIR}/php/Console/Getopt.php ${PHP_LIBDIR}/php/OS/Guess.php \ 275 ${PHP_LIBDIR}/php/data/PEAR \ 276 ${sysconfdir}/pear.conf" 277FILES:${PN}-dev = "${includedir}/php ${PHP_LIBDIR}/build ${bindir}/phpize \ 278 ${bindir}/php-config ${PHP_LIBDIR}/php/.depdb \ 279 ${PHP_LIBDIR}/php/.depdblock ${PHP_LIBDIR}/php/.filemap \ 280 ${PHP_LIBDIR}/php/.lock ${PHP_LIBDIR}/php/test" 281FILES:${PN}-staticdev += "${PHP_LIBDIR}/extensions/*/*.a" 282FILES:${PN}-opcache = "${PHP_LIBDIR}/extensions/*/opcache${SOLIBSDEV}" 283FILES:${PN} = "${PHP_LIBDIR}/php" 284FILES:${PN} += "${bindir} ${libexecdir}/apache2" 285 286SUMMARY:${PN}-modphp = "PHP module for the Apache HTTP server" 287FILES:${PN}-modphp = "${libdir}/apache2 ${sysconfdir}" 288 289MODPHP_OLDPACKAGE = "${@bb.utils.contains('PACKAGECONFIG', 'apache2', 'modphp', '', d)}" 290RPROVIDES:${PN}-modphp = "${MODPHP_OLDPACKAGE}" 291RREPLACES:${PN}-modphp = "${MODPHP_OLDPACKAGE}" 292RCONFLICTS:${PN}-modphp = "${MODPHP_OLDPACKAGE}" 293 294SYSTEMD_SERVICE:${PN}-fpm = "php-fpm.service" 295SYSTEMD_PACKAGES += "${PN}-fpm" 296 297do_install:append:class-native() { 298 create_wrapper ${D}${bindir}/php \ 299 PHP_PEAR_SYSCONF_DIR=${sysconfdir}/ 300} 301