void-packages/srcpkgs/php8.2/patches/cross-gdImageCreateFrom.patch
Joel Beckmeyer 4a97542c26 php8.2: update to 8.2.26.
- enable fpm ACLs
- clean up patches
- generate configure locally instead of using vendored for ease of
  patching
- add user for php-fpm instead of using uncreated `http` user
2024-11-23 12:28:58 +01:00

67 lines
2.4 KiB
Diff

Copied and modified library macros from /usr/share/autoconf/autoconf/general.m4
with support for using qemu-user-static to execute when cross compiling.
diff --git a/ext/gd/config.m4 b/ext/gd/config.m4
index b31c9b2..e5e2d9f 100644
--- a/ext/gd/config.m4
+++ b/ext/gd/config.m4
@@ -147,6 +147,40 @@ dnl that gd defines "junk" versions of each gdImageCreateFromFoo function
dnl even when it does not support the Foo format. Those junk functions
dnl display a warning but eventually return normally, making a simple link
dnl or run test insufficient.
+
+AC_DEFUN([_AC_DO_TOKENS_QEMU],
+[{
+ if test "$cross_compiling" = "yes"; then
+ ac_try='QEMU_LD_PREFIX=${XBPS_CROSS_BASE} qemu-${XBPS_TARGET_QEMU_MACHINE}-static $1'
+ else
+ ac_try='$1'
+ fi
+ _AC_DO([$ac_try]); }])
+
+m4_define([_AC_RUN_IFELSE_QEMU_BODY],
+[ AS_LINENO_PUSH([$[]1])
+ AS_IF([_AC_DO_VAR(ac_link) && _AC_DO_TOKENS_QEMU(./conftest$ac_exeext)],
+ [ac_retval=0],
+ [AS_ECHO(["$as_me: program exited with status $ac_status"]) >&AS_MESSAGE_LOG_FD
+ _AC_MSG_LOG_CONFTEST
+ ac_retval=$ac_status])
+ rm -rf conftest.dSYM conftest_ipa8_conftest.oo
+ AS_LINENO_POP
+ AS_SET_STATUS([$ac_retval])
+])
+
+AC_DEFUN([_AC_RUN_IFELSE_QEMU],
+[AC_REQUIRE_SHELL_FN([ac_fn_]_AC_LANG_ABBREV[_try_run_qemu],
+ [AS_FUNCTION_DESCRIBE([ac_fn_]_AC_LANG_ABBREV[_try_run_qemu], [LINENO],
+ [Try to run conftest.$ac_ext, and return whether this succeeded.
+ Assumes that executables *can* be run.])],
+ [$0_BODY])]dnl
+[m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])]dnl
+[AS_IF([ac_fn_[]_AC_LANG_ABBREV[]_try_run_qemu "$LINENO"], [$2], [$3])
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+ conftest.$ac_objext conftest.beam[]m4_ifval([$1], [ conftest.$ac_ext])[]dnl
+])
+
AC_DEFUN([PHP_GD_CHECK_FORMAT],[
old_LIBS="${LIBS}"
LIBS="${LIBS} ${GD_SHARED_LIBADD}"
@@ -154,7 +188,7 @@ AC_DEFUN([PHP_GD_CHECK_FORMAT],[
CFLAGS="${CFLAGS} ${GDLIB_CFLAGS}"
AC_MSG_CHECKING([for working gdImageCreateFrom$1 in libgd])
AC_LANG_PUSH([C])
- AC_RUN_IFELSE([AC_LANG_SOURCE([
+ _AC_RUN_IFELSE_QEMU([AC_LANG_SOURCE([
#include <stdio.h>
#include <unistd.h>
#include <gd.h>
@@ -178,8 +212,6 @@ int main(int argc, char** argv) {
AC_DEFINE($2, 1, [Does gdImageCreateFrom$1 work?])
],[
AC_MSG_RESULT([no])
- ],[
- AC_MSG_RESULT([no])
])
AC_LANG_POP([C])
CFLAGS="${old_CFLAGS}"