blob: dad95545234a9a9859d056bb0f860f3653c9db37 [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 "
Patrick Williamse760df82023-05-26 11:10:49 -0500132LDFLAGS:append:riscv64 = " -latomic"
Patrick Williams92b42cb2022-09-03 06:53:57 -0500133
134EXTRA_OEMAKE = "INSTALL_ROOT=${D}"
135
136acpaths = ""
137
138do_configure:prepend () {
139 rm -f ${S}/build/libtool.m4 ${S}/ltmain.sh ${S}/aclocal.m4
140 find ${S} -name config.m4 | xargs -n1 sed -i 's!APXS_HTTPD=.*!APXS_HTTPD=${STAGING_SBINDIR_NATIVE}/httpd!'
141}
142
143do_configure:append() {
144 # No, libtool, we really don't want rpath set...
145 sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool
146 sed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool
Andrew Geissler3eeda902023-05-19 10:14:02 -0500147 sed -i -e's@${RECIPE_SYSROOT}@@g' \
148 -e's@-ffile-prefix-map=[^ ]*[ ]*@@g' \
149 -e's@-fdebug-prefix-map=[^ ]*[ ]*@@g' \
150 -e's@-ffile-prefix-map=[^ ]*[ ]*@@g' \
151 -e's@-fmacro-prefix-map=[^ ]*[ ]*@@g' \
152 ${B}/main/build-defs.h \
153 ${B}/scripts/php-config
Patrick Williams92b42cb2022-09-03 06:53:57 -0500154}
155
156do_install:append:class-native() {
157 rm -rf ${D}/${PHP_LIBDIR}/php/.registry
158 rm -rf ${D}/${PHP_LIBDIR}/php/.channels
159 rm -rf ${D}/${PHP_LIBDIR}/php/.[a-z]*
160}
161
162do_install:prepend() {
163 cat ${ACLOCALDIR}/libtool.m4 ${ACLOCALDIR}/lt~obsolete.m4 ${ACLOCALDIR}/ltoptions.m4 \
164 ${ACLOCALDIR}/ltsugar.m4 ${ACLOCALDIR}/ltversion.m4 > ${S}/build/libtool.m4
165}
166
167do_install:prepend:class-target() {
168 if ${@bb.utils.contains('PACKAGECONFIG', 'apache2', 'true', 'false', d)}; then
169 # Install dummy config file so apxs doesn't fail
170 install -d ${D}${sysconfdir}/apache2
171 printf "\nLoadModule dummy_module modules/mod_dummy.so\n" > ${D}${sysconfdir}/apache2/httpd.conf
172 fi
173}
174
175# fixme
176do_install:append:class-target() {
177 install -d ${D}${sysconfdir}/
178 rm -rf ${D}/.registry
179 rm -rf ${D}/.channels
180 rm -rf ${D}/.[a-z]*
181 rm -rf ${D}/var
182 rm -f ${D}/${sysconfdir}/php-fpm.conf.default
183 install -m 0644 ${WORKDIR}/php-fpm.conf ${D}/${sysconfdir}/php-fpm.conf
184 install -d ${D}/${sysconfdir}/apache2/conf.d
185 install -m 0644 ${WORKDIR}/php-fpm-apache.conf ${D}/${sysconfdir}/apache2/conf.d/php-fpm.conf
186 install -d ${D}${sysconfdir}/init.d
187 sed -i 's:=/usr/sbin:=${sbindir}:g' ${B}/sapi/fpm/init.d.php-fpm
188 sed -i 's:=/etc:=${sysconfdir}:g' ${B}/sapi/fpm/init.d.php-fpm
189 sed -i 's:=/var:=${localstatedir}:g' ${B}/sapi/fpm/init.d.php-fpm
190 install -m 0755 ${B}/sapi/fpm/init.d.php-fpm ${D}${sysconfdir}/init.d/php-fpm
191 install -m 0644 ${WORKDIR}/php-fpm-apache.conf ${D}/${sysconfdir}/apache2/conf.d/php-fpm.conf
192
193 if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)};then
194 install -d ${D}${systemd_unitdir}/system
195 install -m 0644 ${WORKDIR}/php-fpm.service ${D}${systemd_unitdir}/system/
196 sed -i -e 's,@SYSCONFDIR@,${sysconfdir},g' \
197 -e 's,@LOCALSTATEDIR@,${localstatedir},g' \
198 ${D}${systemd_unitdir}/system/php-fpm.service
199 fi
200
201 if ${@bb.utils.contains('PACKAGECONFIG', 'apache2', 'true', 'false', d)}; then
202 install -d ${D}${sysconfdir}/apache2/modules.d
203 install -d ${D}${sysconfdir}/php/apache2-php${PHP_MAJOR_VERSION}
204 install -m 644 ${WORKDIR}/70_mod_php${PHP_MAJOR_VERSION}.conf ${D}${sysconfdir}/apache2/modules.d
205 sed -i s,lib/,${libexecdir}/, ${D}${sysconfdir}/apache2/modules.d/70_mod_php${PHP_MAJOR_VERSION}.conf
206 cat ${S}/php.ini-production | \
207 sed -e 's,extension_dir = \"\./\",extension_dir = \"/usr/lib/extensions\",' \
208 > ${D}${sysconfdir}/php/apache2-php${PHP_MAJOR_VERSION}/php.ini
209 rm -f ${D}${sysconfdir}/apache2/httpd.conf*
210 fi
211}
212
213SYSROOT_PREPROCESS_FUNCS += "php_sysroot_preprocess"
214
215php_sysroot_preprocess () {
216 install -d ${SYSROOT_DESTDIR}${bindir_crossscripts}/
217 install -m 755 ${D}${bindir}/phpize ${SYSROOT_DESTDIR}${bindir_crossscripts}/
218 install -m 755 ${D}${bindir}/php-config ${SYSROOT_DESTDIR}${bindir_crossscripts}/
219
220 sed -i 's!eval echo /!eval echo ${STAGING_DIR_HOST}/!' ${SYSROOT_DESTDIR}${bindir_crossscripts}/phpize
221 sed -i 's!^include_dir=.*!include_dir=${STAGING_INCDIR}/php!' ${SYSROOT_DESTDIR}${bindir_crossscripts}/php-config
222}
223
224MODPHP_PACKAGE = "${@bb.utils.contains('PACKAGECONFIG', 'apache2', '${PN}-modphp', '', d)}"
225
226PACKAGES = "${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}"
227
228RDEPENDS:${PN} += "libgcc"
229RDEPENDS:${PN}-pear = "${PN}"
230RDEPENDS:${PN}-phar = "${PN}-cli"
231RDEPENDS:${PN}-cli = "${PN}"
232RDEPENDS:${PN}-modphp = "${PN} apache2"
233RDEPENDS:${PN}-opcache = "${PN}"
234
235ALLOW_EMPTY:${PN} = "1"
236
237INITSCRIPT_PACKAGES = "${PN}-fpm"
238inherit update-rc.d
239
240# 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]
241#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]
242INSANE_SKIP:${PN}:append:x86 = " textrel"
243INSANE_SKIP:${PN}-opcache:append:x86 = " textrel"
244
245FILES:${PN}-dbg =+ "${bindir}/.debug \
246 ${libexecdir}/apache2/modules/.debug"
247FILES:${PN}-doc += "${PHP_LIBDIR}/php/doc"
248FILES:${PN}-cli = "${bindir}/php"
249FILES:${PN}-phpdbg = "${bindir}/phpdbg"
250FILES:${PN}-phar = "${bindir}/phar*"
251FILES:${PN}-cgi = "${bindir}/php-cgi"
252FILES:${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"
253FILES:${PN}-fpm-apache2 = "${sysconfdir}/apache2/conf.d/php-fpm.conf"
254CONFFILES:${PN}-fpm = "${sysconfdir}/php-fpm.conf"
255CONFFILES:${PN}-fpm-apache2 = "${sysconfdir}/apache2/conf.d/php-fpm.conf"
256INITSCRIPT_NAME:${PN}-fpm = "php-fpm"
257INITSCRIPT_PARAMS:${PN}-fpm = "defaults 60"
258FILES:${PN}-pear = "${bindir}/pear* ${bindir}/pecl ${PHP_LIBDIR}/php/PEAR \
259 ${PHP_LIBDIR}/php/PEAR*.php ${PHP_LIBDIR}/php/System.php \
260 ${PHP_LIBDIR}/php/peclcmd.php ${PHP_LIBDIR}/php/pearcmd.php \
261 ${PHP_LIBDIR}/php/.channels ${PHP_LIBDIR}/php/.channels/.alias \
262 ${PHP_LIBDIR}/php/.registry ${PHP_LIBDIR}/php/Archive/Tar.php \
263 ${PHP_LIBDIR}/php/Console/Getopt.php ${PHP_LIBDIR}/php/OS/Guess.php \
264 ${PHP_LIBDIR}/php/data/PEAR \
265 ${sysconfdir}/pear.conf"
266FILES:${PN}-dev = "${includedir}/php ${PHP_LIBDIR}/build ${bindir}/phpize \
267 ${bindir}/php-config ${PHP_LIBDIR}/php/.depdb \
268 ${PHP_LIBDIR}/php/.depdblock ${PHP_LIBDIR}/php/.filemap \
269 ${PHP_LIBDIR}/php/.lock ${PHP_LIBDIR}/php/test"
270FILES:${PN}-staticdev += "${PHP_LIBDIR}/extensions/*/*.a"
271FILES:${PN}-opcache = "${PHP_LIBDIR}/extensions/*/opcache${SOLIBSDEV}"
272FILES:${PN} = "${PHP_LIBDIR}/php"
273FILES:${PN} += "${bindir} ${libexecdir}/apache2"
274
275SUMMARY:${PN}-modphp = "PHP module for the Apache HTTP server"
276FILES:${PN}-modphp = "${libdir}/apache2 ${sysconfdir}"
277
278MODPHP_OLDPACKAGE = "${@bb.utils.contains('PACKAGECONFIG', 'apache2', 'modphp', '', d)}"
279RPROVIDES:${PN}-modphp = "${MODPHP_OLDPACKAGE}"
280RREPLACES:${PN}-modphp = "${MODPHP_OLDPACKAGE}"
281RCONFLICTS:${PN}-modphp = "${MODPHP_OLDPACKAGE}"
282
283do_install:append:class-native() {
284 create_wrapper ${D}${bindir}/php \
285 PHP_PEAR_SYSCONF_DIR=${sysconfdir}/
286}
287
288# Fails to build with thumb-1 (qemuarm)
289# | {standard input}: Assembler messages:
290# | {standard input}:3719: Error: selected processor does not support Thumb mode `smull r0,r2,r9,r3'
291# | {standard input}:3720: Error: unshifted register required -- `sub r2,r2,r0,asr#31'
292# | {standard input}:3796: Error: selected processor does not support Thumb mode `smull r0,r2,r3,r3'
293# | {standard input}:3797: Error: unshifted register required -- `sub r2,r2,r0,asr#31'
294# | make: *** [ext/standard/math.lo] Error 1
295ARM_INSTRUCTION_SET = "arm"