Skip to content

Commit 278cc22

Browse files
committed
Fix phpGH-14443: Cross-compiling with external GD library
This enables cross-compiling simplifications when using external GD library as requested in phpGH-14443 using cache variables: * php_cv_lib_gd_gdImageCreateFromPng * php_cv_lib_gd_gdImageCreateFromAvif * php_cv_lib_gd_gdImageCreateFromWebp * php_cv_lib_gd_gdImageCreateFromJpeg * php_cv_lib_gd_gdImageCreateFromXpm * php_cv_lib_gd_gdImageCreateFromBmp * php_cv_lib_gd_gdImageCreateFromTga For example: ./configure --host=... --build=... --enable-gd --with-external-gd \ php_cv_lib_gd_gdImageCreateFromPng=yes
1 parent eb8c3cb commit 278cc22

File tree

2 files changed

+21
-19
lines changed

2 files changed

+21
-19
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ PHP NEWS
1010
(nielsdos)
1111
. Fixed OSS-Fuzz #69765. (nielsdos)
1212
. Fixed bug GH-14741 (Segmentation fault in Zend/zend_types.h). (nielsdos)
13+
. Fixed bug GH-14443 (Cross-compiling with external GD library). (Peter Kokot)
1314

1415
- Dom:
1516
. Fixed bug GH-14702 (DOMDocument::xinclude() crash). (nielsdos)

ext/gd/config.m4

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,15 @@ dnl that gd defines "junk" versions of each gdImageCreateFromFoo function
147147
dnl even when it does not support the Foo format. Those junk functions
148148
dnl display a warning but eventually return normally, making a simple link
149149
dnl or run test insufficient.
150-
AC_DEFUN([PHP_GD_CHECK_FORMAT],[
151-
old_LIBS="${LIBS}"
152-
LIBS="${LIBS} ${GD_SHARED_LIBADD}"
153-
old_CFLAGS="${CFLAGS}"
154-
CFLAGS="${CFLAGS} ${GDLIB_CFLAGS}"
155-
AC_MSG_CHECKING([for working gdImageCreateFrom$1 in libgd])
156-
AC_LANG_PUSH([C])
157-
AC_RUN_IFELSE([AC_LANG_SOURCE([
150+
AC_DEFUN([PHP_GD_CHECK_FORMAT],
151+
[AS_VAR_PUSHDEF([php_var], [php_cv_lib_gd_gdImageCreateFrom$1])
152+
old_LIBS=$LIBS
153+
LIBS="$LIBS $GD_SHARED_LIBADD"
154+
old_CFLAGS=$CFLAGS
155+
CFLAGS="$CFLAGS $GDLIB_CFLAGS"
156+
AC_LANG_PUSH([C])
157+
AC_CACHE_CHECK([for working gdImageCreateFrom$1 in libgd], [php_var],
158+
[AC_RUN_IFELSE([AC_LANG_SOURCE([
158159
#include <stdio.h>
159160
#include <unistd.h>
160161
#include <gd.h>
@@ -173,17 +174,17 @@ int main(int argc, char** argv) {
173174
gdSetErrorMethod(exit1);
174175
gdImagePtr p = gdImageCreateFrom$1(f);
175176
return 0;
176-
}])],[
177-
AC_MSG_RESULT([yes])
178-
AC_DEFINE($2, 1, [Does gdImageCreateFrom$1 work?])
179-
],[
180-
AC_MSG_RESULT([no])
181-
],[
182-
AC_MSG_RESULT([no])
183-
])
184-
AC_LANG_POP([C])
185-
CFLAGS="${old_CFLAGS}"
186-
LIBS="${old_LIBS}"
177+
}])],
178+
[AS_VAR_SET([php_var], [yes])],
179+
[AS_VAR_SET([php_var], [no])],
180+
[AS_VAR_SET([php_var], [no])])])
181+
AS_VAR_IF([php_var], [yes],
182+
[AC_DEFINE_UNQUOTED([$2], [1],
183+
[Define to 1 if GD library has the 'gdImageCreateFrom$1' function.])])
184+
AC_LANG_POP([C])
185+
CFLAGS=$old_CFLAGS
186+
LIBS=$old_LIBS
187+
AS_VAR_POPDEF([php_var])
187188
])
188189

189190
AC_DEFUN([PHP_GD_CHECK_VERSION],[

0 commit comments

Comments
 (0)