blob: 7e2ea78a152b64d84e26aa4f602be322d3f411f2 [file] [log] [blame]
Patrick Williams92b42cb2022-09-03 06:53:57 -05001SUMMARY = "A server-side, HTML-embedded scripting language"
2HOMEPAGE = "http://www.php.net"
3SECTION = "console/network"
4
5LICENSE = "PHP-3.0"
Andrew Geisslerfc113ea2023-03-31 09:59:46 -05006LIC_FILES_CHKSUM = "file://LICENSE;md5=5ebd5be8e2a89f634486445bd164bef0"
Patrick Williams92b42cb2022-09-03 06:53:57 -05007
8BBCLASSEXTEND = "native"
9DEPENDS = "zlib bzip2 libxml2 virtual/libiconv php-native lemon-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 \
Patrick Williams8e7b46e2023-05-01 14:19:06 -050022 file://0001-Change-whether-to-inline-XXH3_hashLong_withSecret-to.patch \
Patrick Williams92b42cb2022-09-03 06:53:57 -050023 "
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}"
Andrew Geissler3eeda902023-05-19 10:14:02 -050037SRC_URI[sha256sum] = "44a70c52f537662c10d91eedbf51fd765c9961be6ba2508ed63bf7a26cdd3100"
Patrick Williams92b42cb2022-09-03 06:53:57 -050038
39CVE_CHECK_IGNORE += "\
40 CVE-2007-2728 \
41 CVE-2007-3205 \
42 CVE-2007-4596 \
43"
44
45inherit autotools pkgconfig python3native gettext
46
47# phpize is not scanned for absolute paths by default (but php-config is).
48#
49SSTATE_SCAN_FILES += "phpize"
50SSTATE_SCAN_FILES += "build-defs.h"
51
52PHP_LIBDIR = "${libdir}/php${PHP_MAJOR_VERSION}"
53
54# Common EXTRA_OECONF
55COMMON_EXTRA_OECONF = "--enable-sockets \
56 --enable-pcntl \
57 --enable-shared \
58 --disable-rpath \
59 --with-pic \
60 --libdir=${PHP_LIBDIR} \
61"
62EXTRA_OECONF = "--enable-mbstring \
63 --enable-fpm \
64 --with-libdir=${baselib} \
65 --with-gettext=${STAGING_LIBDIR}/.. \
66 --with-zlib=${STAGING_LIBDIR}/.. \
67 --with-iconv=${STAGING_LIBDIR}/.. \
68 --with-bz2=${STAGING_DIR_TARGET}${exec_prefix} \
69 --with-config-file-path=${sysconfdir}/php/apache2-php${PHP_MAJOR_VERSION} \
70 ${@oe.utils.conditional('SITEINFO_ENDIANNESS', 'le', 'ac_cv_c_bigendian_php=no', 'ac_cv_c_bigendian_php=yes', d)} \
71 ${@bb.utils.contains('PACKAGECONFIG', 'pam', '', 'ac_cv_lib_pam_pam_start=no', d)} \
72 ${COMMON_EXTRA_OECONF} \
73"
74
75EXTRA_OECONF:append:riscv64 = " --with-pcre-jit=no"
76EXTRA_OECONF:append:riscv32 = " --with-pcre-jit=no"
77# Needs fibers assembly implemented for rv32
78# for example rv64 implementation is below
79# see https://github.com/php/php-src/commit/70b02d75f2abe3a292d49c4a4e9e4f850c2fee68
80EXTRA_OECONF:append:riscv32:libc-musl = " --disable-fiber-asm"
81
82CACHED_CONFIGUREVARS += "ac_cv_func_dlopen=no ac_cv_lib_dl_dlopen=yes"
83
84EXTRA_OECONF:class-native = " \
85 --with-zlib=${STAGING_LIBDIR_NATIVE}/.. \
86 --without-iconv \
87 ${COMMON_EXTRA_OECONF} \
88"
89
90PACKAGECONFIG ??= "mysql sqlite3 imap opcache openssl \
91 ${@bb.utils.filter('DISTRO_FEATURES', 'ipv6 pam', d)} \
92"
93PACKAGECONFIG:class-native = ""
94
95PACKAGECONFIG[zip] = "--with-zip --with-zlib-dir=${STAGING_EXECPREFIXDIR},,libzip"
96
97PACKAGECONFIG[mysql] = "--with-mysqli=mysqlnd \
98 --with-pdo-mysql=mysqlnd \
99 ,--without-mysqli --without-pdo-mysql \
100 ,mysql5"
101
102PACKAGECONFIG[sqlite3] = "--with-sqlite3=${STAGING_LIBDIR}/.. \
103 --with-pdo-sqlite=${STAGING_LIBDIR}/.. \
104 ,--without-sqlite3 --without-pdo-sqlite \
105 ,sqlite3"
106PACKAGECONFIG[pgsql] = "--with-pgsql=${STAGING_DIR_TARGET}${exec_prefix},--without-pgsql,postgresql"
107PACKAGECONFIG[soap] = "--enable-soap, --disable-soap, libxml2"
108PACKAGECONFIG[apache2] = "--with-apxs2=${STAGING_BINDIR_CROSS}/apxs,,apache2-native apache2"
109PACKAGECONFIG[pam] = ",,libpam"
110PACKAGECONFIG[imap] = "--with-imap=${STAGING_DIR_HOST} \
111 --with-imap-ssl=${STAGING_DIR_HOST} \
112 ,--without-imap --without-imap-ssl \
113 ,uw-imap"
114PACKAGECONFIG[ipv6] = "--enable-ipv6,--disable-ipv6,"
115PACKAGECONFIG[opcache] = "--enable-opcache,--disable-opcache"
116PACKAGECONFIG[openssl] = "--with-openssl,--without-openssl,openssl"
117PACKAGECONFIG[valgrind] = "--with-valgrind=${STAGING_DIR_TARGET}/usr,--with-valgrind=no,valgrind"
118PACKAGECONFIG[mbregex] = "--enable-mbregex, --disable-mbregex, oniguruma"
119PACKAGECONFIG[mbstring] = "--enable-mbstring,,"
120
121export HOSTCC = "${BUILD_CC}"
122export PHP_NATIVE_DIR = "${STAGING_BINDIR_NATIVE}"
123export PHP_PEAR_PHP_BIN = "${STAGING_BINDIR_NATIVE}/php"
Andrew Geissler517393d2023-01-13 08:55:19 -0600124CFLAGS += " -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -g -DPTYS_ARE_GETPT -DPTYS_ARE_SEARCHED -I${STAGING_INCDIR}/apache2"
Patrick Williams92b42cb2022-09-03 06:53:57 -0500125
126# Adding these flags enables dynamic library support, which is disabled by
127# default when cross compiling
128# See https://bugs.php.net/bug.php?id=60109
129CFLAGS += " -DHAVE_LIBDL "
130LDFLAGS += " -ldl "
131LDFLAGS:append:libc-musl = " -lucontext "
132
133EXTRA_OEMAKE = "INSTALL_ROOT=${D}"
134
135acpaths = ""
136
137do_configure:prepend () {
138 rm -f ${S}/build/libtool.m4 ${S}/ltmain.sh ${S}/aclocal.m4
139 find ${S} -name config.m4 | xargs -n1 sed -i 's!APXS_HTTPD=.*!APXS_HTTPD=${STAGING_SBINDIR_NATIVE}/httpd!'
140}
141
142do_configure:append() {
143 # No, libtool, we really don't want rpath set...
144 sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool
145 sed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool
Andrew Geissler3eeda902023-05-19 10:14:02 -0500146 sed -i -e's@${RECIPE_SYSROOT}@@g' \
147 -e's@-ffile-prefix-map=[^ ]*[ ]*@@g' \
148 -e's@-fdebug-prefix-map=[^ ]*[ ]*@@g' \
149 -e's@-ffile-prefix-map=[^ ]*[ ]*@@g' \
150 -e's@-fmacro-prefix-map=[^ ]*[ ]*@@g' \
151 ${B}/main/build-defs.h \
152 ${B}/scripts/php-config
Patrick Williams92b42cb2022-09-03 06:53:57 -0500153}
154
155do_install:append:class-native() {
156 rm -rf ${D}/${PHP_LIBDIR}/php/.registry
157 rm -rf ${D}/${PHP_LIBDIR}/php/.channels
158 rm -rf ${D}/${PHP_LIBDIR}/php/.[a-z]*
159}
160
161do_install:prepend() {
162 cat ${ACLOCALDIR}/libtool.m4 ${ACLOCALDIR}/lt~obsolete.m4 ${ACLOCALDIR}/ltoptions.m4 \
163 ${ACLOCALDIR}/ltsugar.m4 ${ACLOCALDIR}/ltversion.m4 > ${S}/build/libtool.m4
164}
165
166do_install:prepend:class-target() {
167 if ${@bb.utils.contains('PACKAGECONFIG', 'apache2', 'true', 'false', d)}; then
168 # Install dummy config file so apxs doesn't fail
169 install -d ${D}${sysconfdir}/apache2
170 printf "\nLoadModule dummy_module modules/mod_dummy.so\n" > ${D}${sysconfdir}/apache2/httpd.conf
171 fi
172}
173
174# fixme
175do_install:append:class-target() {
176 install -d ${D}${sysconfdir}/
177 rm -rf ${D}/.registry
178 rm -rf ${D}/.channels
179 rm -rf ${D}/.[a-z]*
180 rm -rf ${D}/var
181 rm -f ${D}/${sysconfdir}/php-fpm.conf.default
182 install -m 0644 ${WORKDIR}/php-fpm.conf ${D}/${sysconfdir}/php-fpm.conf
183 install -d ${D}/${sysconfdir}/apache2/conf.d
184 install -m 0644 ${WORKDIR}/php-fpm-apache.conf ${D}/${sysconfdir}/apache2/conf.d/php-fpm.conf
185 install -d ${D}${sysconfdir}/init.d
186 sed -i 's:=/usr/sbin:=${sbindir}:g' ${B}/sapi/fpm/init.d.php-fpm
187 sed -i 's:=/etc:=${sysconfdir}:g' ${B}/sapi/fpm/init.d.php-fpm
188 sed -i 's:=/var:=${localstatedir}:g' ${B}/sapi/fpm/init.d.php-fpm
189 install -m 0755 ${B}/sapi/fpm/init.d.php-fpm ${D}${sysconfdir}/init.d/php-fpm
190 install -m 0644 ${WORKDIR}/php-fpm-apache.conf ${D}/${sysconfdir}/apache2/conf.d/php-fpm.conf
191
192 if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)};then
193 install -d ${D}${systemd_unitdir}/system
194 install -m 0644 ${WORKDIR}/php-fpm.service ${D}${systemd_unitdir}/system/
195 sed -i -e 's,@SYSCONFDIR@,${sysconfdir},g' \
196 -e 's,@LOCALSTATEDIR@,${localstatedir},g' \
197 ${D}${systemd_unitdir}/system/php-fpm.service
198 fi
199
200 if ${@bb.utils.contains('PACKAGECONFIG', 'apache2', 'true', 'false', d)}; then
201 install -d ${D}${sysconfdir}/apache2/modules.d
202 install -d ${D}${sysconfdir}/php/apache2-php${PHP_MAJOR_VERSION}
203 install -m 644 ${WORKDIR}/70_mod_php${PHP_MAJOR_VERSION}.conf ${D}${sysconfdir}/apache2/modules.d
204 sed -i s,lib/,${libexecdir}/, ${D}${sysconfdir}/apache2/modules.d/70_mod_php${PHP_MAJOR_VERSION}.conf
205 cat ${S}/php.ini-production | \
206 sed -e 's,extension_dir = \"\./\",extension_dir = \"/usr/lib/extensions\",' \
207 > ${D}${sysconfdir}/php/apache2-php${PHP_MAJOR_VERSION}/php.ini
208 rm -f ${D}${sysconfdir}/apache2/httpd.conf*
209 fi
210}
211
212SYSROOT_PREPROCESS_FUNCS += "php_sysroot_preprocess"
213
214php_sysroot_preprocess () {
215 install -d ${SYSROOT_DESTDIR}${bindir_crossscripts}/
216 install -m 755 ${D}${bindir}/phpize ${SYSROOT_DESTDIR}${bindir_crossscripts}/
217 install -m 755 ${D}${bindir}/php-config ${SYSROOT_DESTDIR}${bindir_crossscripts}/
218
219 sed -i 's!eval echo /!eval echo ${STAGING_DIR_HOST}/!' ${SYSROOT_DESTDIR}${bindir_crossscripts}/phpize
220 sed -i 's!^include_dir=.*!include_dir=${STAGING_INCDIR}/php!' ${SYSROOT_DESTDIR}${bindir_crossscripts}/php-config
221}
222
223MODPHP_PACKAGE = "${@bb.utils.contains('PACKAGECONFIG', 'apache2', '${PN}-modphp', '', d)}"
224
225PACKAGES = "${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}"
226
227RDEPENDS:${PN} += "libgcc"
228RDEPENDS:${PN}-pear = "${PN}"
229RDEPENDS:${PN}-phar = "${PN}-cli"
230RDEPENDS:${PN}-cli = "${PN}"
231RDEPENDS:${PN}-modphp = "${PN} apache2"
232RDEPENDS:${PN}-opcache = "${PN}"
233
234ALLOW_EMPTY:${PN} = "1"
235
236INITSCRIPT_PACKAGES = "${PN}-fpm"
237inherit update-rc.d
238
239# 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]
240#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]
241INSANE_SKIP:${PN}:append:x86 = " textrel"
242INSANE_SKIP:${PN}-opcache:append:x86 = " textrel"
243
244FILES:${PN}-dbg =+ "${bindir}/.debug \
245 ${libexecdir}/apache2/modules/.debug"
246FILES:${PN}-doc += "${PHP_LIBDIR}/php/doc"
247FILES:${PN}-cli = "${bindir}/php"
248FILES:${PN}-phpdbg = "${bindir}/phpdbg"
249FILES:${PN}-phar = "${bindir}/phar*"
250FILES:${PN}-cgi = "${bindir}/php-cgi"
251FILES:${PN}-fpm = "${sbindir}/php-fpm ${sysconfdir}/php-fpm.conf ${datadir}/fpm ${sysconfdir}/init.d/php-fpm ${systemd_unitdir}/system/php-fpm.service ${sysconfdir}/php-fpm.d/www.conf.default"
252FILES:${PN}-fpm-apache2 = "${sysconfdir}/apache2/conf.d/php-fpm.conf"
253CONFFILES:${PN}-fpm = "${sysconfdir}/php-fpm.conf"
254CONFFILES:${PN}-fpm-apache2 = "${sysconfdir}/apache2/conf.d/php-fpm.conf"
255INITSCRIPT_NAME:${PN}-fpm = "php-fpm"
256INITSCRIPT_PARAMS:${PN}-fpm = "defaults 60"
257FILES:${PN}-pear = "${bindir}/pear* ${bindir}/pecl ${PHP_LIBDIR}/php/PEAR \
258 ${PHP_LIBDIR}/php/PEAR*.php ${PHP_LIBDIR}/php/System.php \
259 ${PHP_LIBDIR}/php/peclcmd.php ${PHP_LIBDIR}/php/pearcmd.php \
260 ${PHP_LIBDIR}/php/.channels ${PHP_LIBDIR}/php/.channels/.alias \
261 ${PHP_LIBDIR}/php/.registry ${PHP_LIBDIR}/php/Archive/Tar.php \
262 ${PHP_LIBDIR}/php/Console/Getopt.php ${PHP_LIBDIR}/php/OS/Guess.php \
263 ${PHP_LIBDIR}/php/data/PEAR \
264 ${sysconfdir}/pear.conf"
265FILES:${PN}-dev = "${includedir}/php ${PHP_LIBDIR}/build ${bindir}/phpize \
266 ${bindir}/php-config ${PHP_LIBDIR}/php/.depdb \
267 ${PHP_LIBDIR}/php/.depdblock ${PHP_LIBDIR}/php/.filemap \
268 ${PHP_LIBDIR}/php/.lock ${PHP_LIBDIR}/php/test"
269FILES:${PN}-staticdev += "${PHP_LIBDIR}/extensions/*/*.a"
270FILES:${PN}-opcache = "${PHP_LIBDIR}/extensions/*/opcache${SOLIBSDEV}"
271FILES:${PN} = "${PHP_LIBDIR}/php"
272FILES:${PN} += "${bindir} ${libexecdir}/apache2"
273
274SUMMARY:${PN}-modphp = "PHP module for the Apache HTTP server"
275FILES:${PN}-modphp = "${libdir}/apache2 ${sysconfdir}"
276
277MODPHP_OLDPACKAGE = "${@bb.utils.contains('PACKAGECONFIG', 'apache2', 'modphp', '', d)}"
278RPROVIDES:${PN}-modphp = "${MODPHP_OLDPACKAGE}"
279RREPLACES:${PN}-modphp = "${MODPHP_OLDPACKAGE}"
280RCONFLICTS:${PN}-modphp = "${MODPHP_OLDPACKAGE}"
281
282do_install:append:class-native() {
283 create_wrapper ${D}${bindir}/php \
284 PHP_PEAR_SYSCONF_DIR=${sysconfdir}/
285}
286
287# Fails to build with thumb-1 (qemuarm)
288# | {standard input}: Assembler messages:
289# | {standard input}:3719: Error: selected processor does not support Thumb mode `smull r0,r2,r9,r3'
290# | {standard input}:3720: Error: unshifted register required -- `sub r2,r2,r0,asr#31'
291# | {standard input}:3796: Error: selected processor does not support Thumb mode `smull r0,r2,r3,r3'
292# | {standard input}:3797: Error: unshifted register required -- `sub r2,r2,r0,asr#31'
293# | make: *** [ext/standard/math.lo] Error 1
294ARM_INSTRUCTION_SET = "arm"