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