Skip to content

Commit 6c034ee

Browse files
authored
Wrap gdImageCreateFrom* checks in AC_CACHE_CHECK (#14443)
This enables cross-compiling edge cases to manually override the checks with the php_cv_lib_gd_gdImageCreateFrom* cache variables.
1 parent 07a1921 commit 6c034ee

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

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 'gdImageCreateFrom$1'.])])
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)