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