php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login

Patch 0001-ext-gd-Use-pkg-config-to-detect-the-availability-of-freetype.patch for Compile Failure Bug #76324

Patch version 2018-05-14 21:54 UTC

Return to Bug #76324 | Download this patch
Patch Revisions:

Developer: eschwartz@archlinux.org

From 6e1f30b75a6f52a822c7d7a36de3c06c8a133499 Mon Sep 17 00:00:00 2001
From: Eli Schwartz <eschwartz93@gmail.com>
Date: Mon, 14 May 2018 17:25:37 -0400
Subject: [PATCH] ext/gd: Use pkg-config to detect the availability of
 freetype2

The latest version of freetype2 does not install freetype-config by
default, but pkg-config support has been there for approximately 15
years. In order to reliably detect freetype2, pkg-config *must* be used.

See:
https://savannah.nongnu.org/bugs/?53093
https://bugs.php.net/bug.php?id=76324
---
 acinclude.m4     | 114 ++++++++++----------
 build/pkg.m4     | 275 +++++++++++++++++++++++++++++++++++++++++++++++
 configure.ac     |  23 ++--
 ext/gd/config.m4 |  27 ++---
 4 files changed, 351 insertions(+), 88 deletions(-)
 create mode 100644 build/pkg.m4

diff --git a/acinclude.m4 b/acinclude.m4
index 9f505a32aa..85d59eb5fe 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -12,7 +12,7 @@ dnl
 dnl PHP_HELP_SEPARATOR(title)
 dnl
 dnl Adds separator title into the configure --help display.
-dnl 
+dnl
 AC_DEFUN([PHP_HELP_SEPARATOR],[
 AC_ARG_ENABLE([],[
 $1
@@ -148,7 +148,7 @@ $EGREP $pattern'.*include/php' $srcdir/configure|$SED 's/.*>//'|xargs touch 2>/d
 
 dnl
 dnl PHP_GEN_GLOBAL_MAKEFILE
-dnl 
+dnl
 dnl Generates the global makefile.
 dnl
 AC_DEFUN([PHP_GEN_GLOBAL_MAKEFILE],[
@@ -183,10 +183,10 @@ AC_DEFUN([PHP_ADD_MAKEFILE_FRAGMENT],[
 dnl
 dnl PHP_ADD_SOURCES(source-path, sources [, special-flags [, type]])
 dnl
-dnl Adds sources which are located relative to source-path to the 
-dnl array of type type.  Sources are processed with optional 
+dnl Adds sources which are located relative to source-path to the
+dnl array of type type.  Sources are processed with optional
 dnl special-flags which are passed to the compiler.  Sources
-dnl can be either written in C or C++ (filenames shall end in .c 
+dnl can be either written in C or C++ (filenames shall end in .c
 dnl or .cpp, respectively).
 dnl
 dnl Note: If source-path begins with a "/", the "/" is removed and
@@ -227,7 +227,7 @@ dnl name of the array target-var directly, as well as whether
 dnl shared objects will be built from the sources.
 dnl
 dnl Should not be used directly.
-dnl 
+dnl
 AC_DEFUN([PHP_ADD_SOURCES_X],[
 dnl relative to source- or build-directory?
 dnl ac_srcdir/ac_bdir include trailing slash
@@ -236,20 +236,20 @@ dnl ac_srcdir/ac_bdir include trailing slash
   /*[)] ac_srcdir=`echo "$1"|cut -c 2-`"/"; ac_bdir=$ac_srcdir; ac_inc="-I$ac_bdir -I$abs_srcdir/$ac_bdir" ;;
   *[)] ac_srcdir="$abs_srcdir/$1/"; ac_bdir="$1/"; ac_inc="-I$ac_bdir -I$ac_srcdir" ;;
   esac
-  
+
 dnl how to build .. shared or static?
   ifelse($5,yes,_PHP_ASSIGN_BUILD_VARS(shared),_PHP_ASSIGN_BUILD_VARS(php))
 
 dnl iterate over the sources
   old_IFS=[$]IFS
   for ac_src in $2; do
-  
+
 dnl remove the suffix
       IFS=.
       set $ac_src
       ac_obj=[$]1
       IFS=$old_IFS
-      
+
 dnl append to the array which has been dynamically chosen at m4 time
       $4="[$]$4 [$]ac_bdir[$]ac_obj.lo"
 
@@ -364,7 +364,7 @@ AC_DEFUN([PHP_LIBGCC_LIBPATH],[
 ])
 
 dnl -------------------------------------------------------------------------
-dnl Macros to modify LIBS, INCLUDES, etc. variables 
+dnl Macros to modify LIBS, INCLUDES, etc. variables
 dnl -------------------------------------------------------------------------
 
 dnl
@@ -486,7 +486,7 @@ dnl cc-specific
 dnl
 dnl PHP_ADD_INCLUDE(path [,before])
 dnl
-dnl add an include path. 
+dnl add an include path.
 dnl if before is 1, add in the beginning of INCLUDES.
 dnl
 AC_DEFUN([PHP_ADD_INCLUDE],[
@@ -774,7 +774,7 @@ AC_DEFUN([PHP_BUILD_SHARED],[
   PHP_BUILD_PROGRAM
   OVERALL_TARGET=libphp[]$PHP_MAJOR_VERSION[.la]
   php_sapi_module=shared
-  
+
   php_c_pre=$shared_c_pre
   php_c_meta=$shared_c_meta
   php_c_post=$shared_c_post
@@ -885,7 +885,7 @@ AC_DEFUN([PHP_SELECT_SAPI],[
 ])
   else
     PHP_SAPI=$1
-  fi  
+  fi
 
   PHP_ADD_BUILD_DIR([sapi/$1])
 
@@ -942,7 +942,7 @@ dnl to build the extension.
 dnl "shared" can be set to "shared" or "yes" to build the extension as
 dnl a dynamically loadable library. Optional parameter "sapi_class" can
 dnl be set to "cli" to mark extension build only with CLI or CGI sapi's.
-dnl "extra-cflags" are passed to the compiler, with 
+dnl "extra-cflags" are passed to the compiler, with
 dnl @ext_srcdir@ and @ext_builddir@ being substituted.
 dnl "cxx" can be used to indicate that a C++ shared module is desired.
 dnl "zend_ext" indicates a zend extension.
@@ -988,7 +988,7 @@ dnl ---------------------------------------------- CLI static module
   PHP_ADD_BUILD_DIR($ext_builddir)
 
 dnl Set for phpize builds only
-dnl --------------------------- 
+dnl ---------------------------
   if test "$ext_builddir" = "."; then
     PHP_PECL_EXTENSION=$1
     PHP_SUBST(PHP_PECL_EXTENSION)
@@ -1018,7 +1018,7 @@ dnl $3 = optional: if true, it's ok for $2 to have not been configured
 dnl default is false and should halt the build.
 dnl To be effective, this macro must be invoked *after* PHP_NEW_EXTENSION.
 dnl The extension on which it depends must also have been configured.
-dnl See ADD_EXTENSION_DEP in win32 build 
+dnl See ADD_EXTENSION_DEP in win32 build
 dnl
 AC_DEFUN([PHP_ADD_EXTENSION_DEP], [
   am_i_shared=$[PHP_]translit($1,a-z_-,A-Z__)[_SHARED]
@@ -1180,7 +1180,7 @@ main() {
   struct tm t, *s;
   time_t old = 0;
   char buf[27], *p;
-  
+
   s = gmtime_r(&old, &t);
   p = asctime_r(&t, buf, 26);
   if (p == buf && s == &t) return (0);
@@ -1245,7 +1245,7 @@ AC_DEFUN([PHP_DOES_PREAD_WORK],[
 #include <errno.h>
 $1
     main() {
-    char buf[3]; 
+    char buf[3];
     int fd = open("conftest_in", O_RDONLY);
     if (fd < 0) exit(1);
     if (pread(fd, buf, 2, 0) != 2) exit(1);
@@ -1282,7 +1282,7 @@ AC_DEFUN([PHP_PWRITE_TEST],[
     if test "$ac_cv_pwrite" = "64"; then
       AC_DEFINE(PHP_PWRITE_64, 1, [whether pwrite64 is default])
     fi
-  fi  
+  fi
 ])
 
 dnl
@@ -1304,7 +1304,7 @@ AC_DEFUN([PHP_PREAD_TEST],[
     if test "$ac_cv_pread" = "64"; then
       AC_DEFINE(PHP_PREAD_64, 1, [whether pread64 is default])
     fi
-  fi  
+  fi
 ])
 
 dnl
@@ -1342,7 +1342,7 @@ AC_DEFUN([PHP_MISSING_TIME_R_DECL],[
 
 dnl
 dnl PHP_READDIR_R_TYPE
-dnl 
+dnl
 AC_DEFUN([PHP_READDIR_R_TYPE],[
   dnl HAVE_READDIR_R is also defined by libmysql
   AC_CHECK_FUNC(readdir_r,ac_cv_func_readdir_r=yes,ac_cv_func_readdir=no)
@@ -1363,7 +1363,7 @@ main() {
   struct dirent *pentry = (struct dirent *) &entry;
 
   dir = opendir("/");
-  if (!dir) 
+  if (!dir)
     exit(1);
   if (readdir_r(dir, (struct dirent *) entry, &pentry) == 0) {
     close(dir);
@@ -1400,7 +1400,7 @@ int readdir_r(DIR *, struct dirent *);
 
 dnl
 dnl PHP_TM_GMTOFF
-dnl 
+dnl
 AC_DEFUN([PHP_TM_GMTOFF],[
 AC_CACHE_CHECK([for tm_gmtoff in struct tm], ac_cv_struct_tm_gmtoff,
 [AC_TRY_COMPILE([#include <sys/types.h>
@@ -1503,7 +1503,7 @@ AC_DEFUN([PHP_AC_BROKEN_SNPRINTF],[
 main() {
   char buf[20];
   int res = 0;
-  res = res || (snprintf(buf, 2, "marcus") != 6); 
+  res = res || (snprintf(buf, 2, "marcus") != 6);
   res = res || (buf[1] != '\0');
   /* Implementations may consider this as an encoding error */
   snprintf(buf, 0, "boerger");
@@ -1511,7 +1511,7 @@ main() {
   res = res || (buf[0] != 'm');
   res = res || (snprintf(NULL, 0, "boerger") != 7);
   res = res || (snprintf(buf, sizeof(buf), "%f", 0.12345678) != 8);
-  exit(res); 
+  exit(res);
 }
     ],[
       ac_cv_broken_snprintf=no
@@ -1618,7 +1618,7 @@ AC_DEFUN([PHP_SOCKADDR_CHECKS], [
   if test "$ac_cv_sockaddr_storage" = "yes"; then
     AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [Whether you have struct sockaddr_storage])
   fi
-  dnl Check if field sa_len exists in struct sockaddr 
+  dnl Check if field sa_len exists in struct sockaddr
   AC_CACHE_CHECK([for field sa_len in struct sockaddr],ac_cv_sockaddr_sa_len,[
     AC_TRY_COMPILE([#include <sys/types.h>
 #include <sys/socket.h>],
@@ -1659,9 +1659,9 @@ dnl
 AC_DEFUN([PHP_EBCDIC], [
   AC_CACHE_CHECK([whether system uses EBCDIC],ac_cv_ebcdic,[
   AC_TRY_RUN( [
-int main(void) { 
-  return (unsigned char)'A' != (unsigned char)0xC1; 
-} 
+int main(void) {
+  return (unsigned char)'A' != (unsigned char)0xC1;
+}
 ],[
   ac_cv_ebcdic=yes
 ],[
@@ -1705,7 +1705,7 @@ int main(int argc, char *argv[])
   FILE *fp;
   long position;
   char *filename = tmpnam(NULL);
-  
+
   fp = fopen(filename, "w");
   if (fp == NULL) {
     perror("fopen");
@@ -1799,7 +1799,7 @@ main() {
 ], [
   cookie_io_functions_use_off64_t=no
 ])
-    
+
     else
 
 dnl older glibc versions (up to 2.1.2 ?)
@@ -1836,7 +1836,7 @@ dnl
 AC_DEFUN([PHP_CHECK_LIBRARY], [
   save_old_LDFLAGS=$LDFLAGS
   ac_stuff="$5"
-  
+
   save_ext_shared=$ext_shared
   ext_shared=yes
   PHP_EVAL_LIBLINE([$]ac_stuff, LDFLAGS)
@@ -1926,11 +1926,11 @@ AC_DEFUN([PHP_CHECK_FUNC],[
   unset ac_cv_func_$1
   unset ac_cv_func___$1
   unset found
-  
+
   AC_CHECK_FUNC($1, [found=yes],[ AC_CHECK_FUNC(__$1,[found=yes],[found=no]) ])
 
   case $found in
-  yes[)] 
+  yes[)]
     PHP_DEF_HAVE($1)
     ac_cv_func_$1=yes
   ;;
@@ -2001,7 +2001,7 @@ dnl
 dnl PHP_CHECK_64BIT([do if 32], [do if 64])
 dnl
 dnl This macro is used to detect if we're at 64-bit platform or not.
-dnl It could be useful for those external libs, that have different precompiled 
+dnl It could be useful for those external libs, that have different precompiled
 dnl versions in different directories.
 dnl
 AC_DEFUN([PHP_CHECK_64BIT],[
@@ -2071,9 +2071,9 @@ AC_DEFUN([PHP_PROG_AWK], [
     *mawk)
       AC_MSG_WARN([mawk is known to have problems on some systems. You should install GNU awk])
       ;;
-    *gawk)  
+    *gawk)
       ;;
-    bork)   
+    bork)
       AC_MSG_ERROR([Could not find awk; Install GNU awk])
       ;;
     *)
@@ -2108,7 +2108,7 @@ dnl
 AC_DEFUN([PHP_PROG_LEX], [
 dnl we only support certain flex versions
   flex_version_list="2.5.4"
-   
+
   AC_PROG_LEX
   if test "$LEX" = "flex"; then
 dnl AC_DECL_YYTEXT is obsolete since autoconf 2.50 and merged into AC_PROG_LEX
@@ -2138,7 +2138,7 @@ dnl it should be removed once we drop support of autoconf 2.13 (if ever)
   else
     flex_version=none
   fi
-  
+
   case $php_cv_flex_version in
     ""|invalid[)]
       if test -f "$abs_srcdir/Zend/zend_language_scanner.c" && test -f "$abs_srcdir/Zend/zend_ini_scanner.c"; then
@@ -2172,7 +2172,7 @@ AC_DEFUN([PHP_PROG_RE2C],[
         php_cv_re2c_version=invalid
       else
         php_cv_re2c_version="`$RE2C --version | cut -d ' ' -f 2  2>/dev/null` (ok)"
-      fi 
+      fi
     ])
   fi
   case $php_cv_re2c_version in
@@ -2307,7 +2307,7 @@ ifelse([$3],[],,[else $3])
   fi
 ])
 
-dnl 
+dnl
 dnl PHP_SETUP_OPENSSL(shared-add [, action-found [, action-not-found]])
 dnl
 dnl Common setup macro for openssl
@@ -2354,7 +2354,7 @@ AC_DEFUN([PHP_SETUP_OPENSSL],[
 
   dnl If pkg-config fails for some reason, revert to the old method
   if test "$found_openssl" = "no"; then
-  
+
     if test "$PHP_OPENSSL_DIR" = "yes"; then
       PHP_OPENSSL_DIR="/usr/local/ssl /usr/local /usr /usr/local/openssl"
     fi
@@ -2393,7 +2393,7 @@ AC_DEFUN([PHP_SETUP_OPENSSL],[
     CPPFLAGS=$old_CPPFLAGS
 
     PHP_ADD_INCLUDE($OPENSSL_INCDIR)
-  
+
     PHP_CHECK_LIBRARY(crypto, CRYPTO_free, [
       PHP_ADD_LIBRARY(crypto,,$1)
     ],[
@@ -2428,7 +2428,7 @@ ifelse([$3],[],,[else $3])
   fi
 ])
 
-dnl 
+dnl
 dnl PHP_SETUP_ICONV(shared-add [, action-found [, action-not-found]])
 dnl
 dnl Common setup macro for iconv
@@ -2492,7 +2492,7 @@ AC_DEFUN([PHP_SETUP_ICONV], [
     if test -z "$ICONV_DIR"; then
       AC_MSG_ERROR([Please specify the install prefix of iconv with --with-iconv=<DIR>])
     fi
-  
+
     if test -f $ICONV_DIR/$PHP_LIBDIR/lib$iconv_lib_name.a ||
        test -f $ICONV_DIR/$PHP_LIBDIR/lib$iconv_lib_name.$SHLIB_SUFFIX_NAME
     then
@@ -2526,7 +2526,7 @@ ifelse([$3],[],,[else $3])
   fi
 ])
 
-dnl 
+dnl
 dnl PHP_SETUP_LIBXML(shared-add [, action-found [, action-not-found]])
 dnl
 dnl Common setup macro for libxml
@@ -2608,7 +2608,7 @@ dnl -------------------------------------------------------------------------
 dnl Misc. macros
 dnl -------------------------------------------------------------------------
 
-dnl 
+dnl
 dnl PHP_INSTALL_HEADERS(path [, file ...])
 dnl
 dnl PHP header files to be installed
@@ -2619,7 +2619,7 @@ AC_DEFUN([PHP_INSTALL_HEADERS],[
       PHP_RUN_ONCE(INSTALLHEADERS, $header_file, [
         INSTALL_HEADERS="$INSTALL_HEADERS $header_file"
       ])
-    done 
+    done
   ], [
     header_path=$1
     for header_file in $2; do
@@ -2627,7 +2627,7 @@ AC_DEFUN([PHP_INSTALL_HEADERS],[
       PHP_RUN_ONCE(INSTALLHEADERS, $hp_hf, [
         INSTALL_HEADERS="$INSTALL_HEADERS $hp_hf"
       ])
-    done 
+    done
   ])
 ])
 
@@ -2650,7 +2650,7 @@ IFS="- /.
 
 dnl
 dnl PHP_DEBUG_MACRO(filename)
-dnl 
+dnl
 AC_DEFUN([PHP_DEBUG_MACRO],[
   DEBUG_LOG=$1
   cat >$1 <<X
@@ -2712,7 +2712,7 @@ EOF
   echo "'[$]0' \\" >> $1
   if test `expr " [$]0" : " '.*"` = 0; then
     CONFIGURE_COMMAND="$CONFIGURE_COMMAND '[$]0'"
-  else 
+  else
     CONFIGURE_COMMAND="$CONFIGURE_COMMAND [$]0"
   fi
   CONFIGURE_ARGS="$clean_configure_args"
@@ -2780,7 +2780,7 @@ AC_DEFUN([PHP_CHECK_CONFIGURE_OPTIONS],[
         if test "$PHP_MAJOR_VERSION" -lt "6"; then
           case $arg_name in
             enable-zend-multibyte[)] continue;;
-          esac 
+          esac
         fi
 
         is_arg_set=php_[]`echo [$]arg_name | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ-' 'abcdefghijklmnopqrstuvwxyz_'`
@@ -2862,7 +2862,7 @@ AC_DEFUN([PHP_CRYPT_R_STYLE],
 ],[
 CRYPTD buffer;
 crypt_r("passwd", "hash", &buffer);
-], 
+],
 php_cv_crypt_r_style=cryptd)
 
     if test "$php_cv_crypt_r_style" = "none"; then
@@ -2872,7 +2872,7 @@ php_cv_crypt_r_style=cryptd)
 ],[
 struct crypt_data buffer;
 crypt_r("passwd", "hash", &buffer);
-], 
+],
 php_cv_crypt_r_style=struct_crypt_data)
     fi
 
@@ -2884,7 +2884,7 @@ php_cv_crypt_r_style=struct_crypt_data)
 ],[
 struct crypt_data buffer;
 crypt_r("passwd", "hash", &buffer);
-], 
+],
 php_cv_crypt_r_style=struct_crypt_data_gnu_source)
     fi
     ])
@@ -3317,5 +3317,7 @@ int main() {
 
 dnl Load the AX_CHECK_COMPILE_FLAG macro from the autoconf archive.
 m4_include([build/ax_check_compile_flag.m4])
-
 m4_include([build/ax_gcc_func_attribute.m4])
+
+dnl Load pkg-config macros
+m4_include([build/pkg.m4])
diff --git a/build/pkg.m4 b/build/pkg.m4
new file mode 100644
index 0000000000..13a8890178
--- /dev/null
+++ b/build/pkg.m4
@@ -0,0 +1,275 @@
+# pkg.m4 - Macros to locate and utilise pkg-config.   -*- Autoconf -*-
+# serial 12 (pkg-config-0.29.2)
+
+dnl Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
+dnl Copyright © 2012-2015 Dan Nicholson <dbn.lists@gmail.com>
+dnl
+dnl This program is free software; you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 2 of the License, or
+dnl (at your option) any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful, but
+dnl WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+dnl General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; if not, write to the Free Software
+dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+dnl 02111-1307, USA.
+dnl
+dnl As a special exception to the GNU General Public License, if you
+dnl distribute this file as part of a program that contains a
+dnl configuration script generated by Autoconf, you may include it under
+dnl the same distribution terms that you use for the rest of that
+dnl program.
+
+dnl PKG_PREREQ(MIN-VERSION)
+dnl -----------------------
+dnl Since: 0.29
+dnl
+dnl Verify that the version of the pkg-config macros are at least
+dnl MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's
+dnl installed version of pkg-config, this checks the developer's version
+dnl of pkg.m4 when generating configure.
+dnl
+dnl To ensure that this macro is defined, also add:
+dnl m4_ifndef([PKG_PREREQ],
+dnl     [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])])
+dnl
+dnl See the "Since" comment for each macro you use to see what version
+dnl of the macros you require.
+m4_defun([PKG_PREREQ],
+[m4_define([PKG_MACROS_VERSION], [0.29.2])
+m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1,
+    [m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])])
+])dnl PKG_PREREQ
+
+dnl PKG_PROG_PKG_CONFIG([MIN-VERSION])
+dnl ----------------------------------
+dnl Since: 0.16
+dnl
+dnl Search for the pkg-config tool and set the PKG_CONFIG variable to
+dnl first found in the path. Checks that the version of pkg-config found
+dnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is
+dnl used since that's the first version where most current features of
+dnl pkg-config existed.
+AC_DEFUN([PKG_PROG_PKG_CONFIG],
+[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
+m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
+m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$])
+AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
+AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
+AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
+
+if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
+	AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
+fi
+if test -n "$PKG_CONFIG"; then
+	_pkg_min_version=m4_default([$1], [0.9.0])
+	AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
+	if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
+		AC_MSG_RESULT([yes])
+	else
+		AC_MSG_RESULT([no])
+		PKG_CONFIG=""
+	fi
+fi[]dnl
+])dnl PKG_PROG_PKG_CONFIG
+
+dnl PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+dnl -------------------------------------------------------------------
+dnl Since: 0.18
+dnl
+dnl Check to see whether a particular set of modules exists. Similar to
+dnl PKG_CHECK_MODULES(), but does not set variables or print errors.
+dnl
+dnl Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
+dnl only at the first occurence in configure.ac, so if the first place
+dnl it's called might be skipped (such as if it is within an "if", you
+dnl have to call PKG_CHECK_EXISTS manually
+AC_DEFUN([PKG_CHECK_EXISTS],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+if test -n "$PKG_CONFIG" && \
+    AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
+  m4_default([$2], [:])
+m4_ifvaln([$3], [else
+  $3])dnl
+fi])
+
+dnl _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
+dnl ---------------------------------------------
+dnl Internal wrapper calling pkg-config via PKG_CONFIG and setting
+dnl pkg_failed based on the result.
+m4_define([_PKG_CONFIG],
+[if test -n "$$1"; then
+    pkg_cv_[]$1="$$1"
+ elif test -n "$PKG_CONFIG"; then
+    PKG_CHECK_EXISTS([$3],
+                     [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`
+		      test "x$?" != "x0" && pkg_failed=yes ],
+		     [pkg_failed=yes])
+ else
+    pkg_failed=untried
+fi[]dnl
+])dnl _PKG_CONFIG
+
+dnl _PKG_SHORT_ERRORS_SUPPORTED
+dnl ---------------------------
+dnl Internal check to see if pkg-config supports short errors.
+AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+        _pkg_short_errors_supported=yes
+else
+        _pkg_short_errors_supported=no
+fi[]dnl
+])dnl _PKG_SHORT_ERRORS_SUPPORTED
+
+
+dnl PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
+dnl   [ACTION-IF-NOT-FOUND])
+dnl --------------------------------------------------------------
+dnl Since: 0.4.0
+dnl
+dnl Note that if there is a possibility the first call to
+dnl PKG_CHECK_MODULES might not happen, you should be sure to include an
+dnl explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
+AC_DEFUN([PKG_CHECK_MODULES],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
+AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
+
+pkg_failed=no
+AC_MSG_CHECKING([for $2])
+
+_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
+_PKG_CONFIG([$1][_LIBS], [libs], [$2])
+
+m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
+and $1[]_LIBS to avoid the need to call pkg-config.
+See the pkg-config man page for more details.])
+
+if test $pkg_failed = yes; then
+        AC_MSG_RESULT([no])
+        _PKG_SHORT_ERRORS_SUPPORTED
+        if test $_pkg_short_errors_supported = yes; then
+	        $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
+        else
+	        $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
+        fi
+	# Put the nasty error message in config.log where it belongs
+	echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
+
+	m4_default([$4], [AC_MSG_ERROR(
+[Package requirements ($2) were not met:
+
+$$1_PKG_ERRORS
+
+Consider adjusting the PKG_CONFIG_PATH environment variable if you
+installed software in a non-standard prefix.
+
+_PKG_TEXT])[]dnl
+        ])
+elif test $pkg_failed = untried; then
+        AC_MSG_RESULT([no])
+	m4_default([$4], [AC_MSG_FAILURE(
+[The pkg-config script could not be found or is too old.  Make sure it
+is in your PATH or set the PKG_CONFIG environment variable to the full
+path to pkg-config.
+
+_PKG_TEXT
+
+To get pkg-config, see <http://pkg-config.freedesktop.org/>.])[]dnl
+        ])
+else
+	$1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
+	$1[]_LIBS=$pkg_cv_[]$1[]_LIBS
+        AC_MSG_RESULT([yes])
+	$3
+fi[]dnl
+])dnl PKG_CHECK_MODULES
+
+
+dnl PKG_CHECK_MODULES_STATIC(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
+dnl   [ACTION-IF-NOT-FOUND])
+dnl ---------------------------------------------------------------------
+dnl Since: 0.29
+dnl
+dnl Checks for existence of MODULES and gathers its build flags with
+dnl static libraries enabled. Sets VARIABLE-PREFIX_CFLAGS from --cflags
+dnl and VARIABLE-PREFIX_LIBS from --libs.
+dnl
+dnl Note that if there is a possibility the first call to
+dnl PKG_CHECK_MODULES_STATIC might not happen, you should be sure to
+dnl include an explicit call to PKG_PROG_PKG_CONFIG in your
+dnl configure.ac.
+AC_DEFUN([PKG_CHECK_MODULES_STATIC],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+_save_PKG_CONFIG=$PKG_CONFIG
+PKG_CONFIG="$PKG_CONFIG --static"
+PKG_CHECK_MODULES($@)
+PKG_CONFIG=$_save_PKG_CONFIG[]dnl
+])dnl PKG_CHECK_MODULES_STATIC
+
+
+dnl PKG_INSTALLDIR([DIRECTORY])
+dnl -------------------------
+dnl Since: 0.27
+dnl
+dnl Substitutes the variable pkgconfigdir as the location where a module
+dnl should install pkg-config .pc files. By default the directory is
+dnl $libdir/pkgconfig, but the default can be changed by passing
+dnl DIRECTORY. The user can override through the --with-pkgconfigdir
+dnl parameter.
+AC_DEFUN([PKG_INSTALLDIR],
+[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])])
+m4_pushdef([pkg_description],
+    [pkg-config installation directory @<:@]pkg_default[@:>@])
+AC_ARG_WITH([pkgconfigdir],
+    [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],,
+    [with_pkgconfigdir=]pkg_default)
+AC_SUBST([pkgconfigdir], [$with_pkgconfigdir])
+m4_popdef([pkg_default])
+m4_popdef([pkg_description])
+])dnl PKG_INSTALLDIR
+
+
+dnl PKG_NOARCH_INSTALLDIR([DIRECTORY])
+dnl --------------------------------
+dnl Since: 0.27
+dnl
+dnl Substitutes the variable noarch_pkgconfigdir as the location where a
+dnl module should install arch-independent pkg-config .pc files. By
+dnl default the directory is $datadir/pkgconfig, but the default can be
+dnl changed by passing DIRECTORY. The user can override through the
+dnl --with-noarch-pkgconfigdir parameter.
+AC_DEFUN([PKG_NOARCH_INSTALLDIR],
+[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])])
+m4_pushdef([pkg_description],
+    [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@])
+AC_ARG_WITH([noarch-pkgconfigdir],
+    [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],,
+    [with_noarch_pkgconfigdir=]pkg_default)
+AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir])
+m4_popdef([pkg_default])
+m4_popdef([pkg_description])
+])dnl PKG_NOARCH_INSTALLDIR
+
+
+dnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
+dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+dnl -------------------------------------------
+dnl Since: 0.28
+dnl
+dnl Retrieves the value of the pkg-config variable for the given module.
+AC_DEFUN([PKG_CHECK_VAR],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl
+
+_PKG_CONFIG([$1], [variable="][$3]["], [$2])
+AS_VAR_COPY([$1], [pkg_cv_][$1])
+
+AS_VAR_IF([$1], [""], [$5], [$4])dnl
+])dnl PKG_CHECK_VAR
diff --git a/configure.ac b/configure.ac
index e18e1de2ef..655e06837b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -159,7 +159,7 @@ if test -n "$with_apxs2filter" && test -n "$with_apxs2"; then
   AC_MSG_ERROR([--with-apxs2filter and --with-apxs2 cannot be used together])
 fi
 
-  
+
 dnl Settings we want to make before the checks.
 dnl -------------------------------------------------------------------------
 
@@ -191,6 +191,7 @@ rm -f libs/*
 dnl Checks for programs.
 dnl -------------------------------------------------------------------------
 
+PKG_PROG_PKG_CONFIG
 AC_PROG_CC([cc gcc])
 PHP_DETECT_ICC
 PHP_DETECT_SUNCC
@@ -705,7 +706,7 @@ dnl Check for getaddrinfo, should be a better way, but...
 dnl Also check for working getaddrinfo
 AC_CACHE_CHECK([for getaddrinfo], ac_cv_func_getaddrinfo,
 [AC_TRY_LINK([#include <netdb.h>],
-                [struct addrinfo *g,h;g=&h;getaddrinfo("","",g,&g);], 
+                [struct addrinfo *g,h;g=&h;getaddrinfo("","",g,&g);],
   AC_TRY_RUN([
 #include <netdb.h>
 #include <sys/types.h>
@@ -727,7 +728,7 @@ int main(void) {
   }
 
   pai = ai;
-  
+
   while (pai) {
     if (pai->ai_family != AF_INET) {
       /* 127.0.0.1/NUMERICHOST should only resolve ONE way */
@@ -828,7 +829,7 @@ if test "$PHP_GCOV" = "yes"; then
   if test "$GCC" != "yes"; then
     AC_MSG_ERROR([GCC is required for --enable-gcov])
   fi
-  
+
   dnl Check if ccache is being used
   case `$php_shtool path $CC` in
     *ccache*[)] gcc_ccache=yes;;
@@ -838,7 +839,7 @@ if test "$PHP_GCOV" = "yes"; then
   if test "$gcc_ccache" = "yes" && (test -z "$CCACHE_DISABLE" || test "$CCACHE_DISABLE" != "1"); then
     AC_MSG_ERROR([ccache must be disabled when --enable-gcov option is used. You can disable ccache by setting environment variable CCACHE_DISABLE=1.])
   fi
-  
+
   dnl min: 1.5 (i.e. 105, major * 100 + minor for easier comparison)
   ltp_version_min="105"
   dnl non-working versions, e.g. "1.8 1.18";
@@ -871,7 +872,7 @@ if test "$PHP_GCOV" = "yes"; then
       fi
     ])
   else
-    ltp_msg="To enable code coverage reporting you must have LTP installed"      
+    ltp_msg="To enable code coverage reporting you must have LTP installed"
     AC_MSG_ERROR([$ltp_msg])
   fi
 
@@ -961,7 +962,7 @@ fi
 AC_MSG_CHECKING([where to scan for configuration files])
 PHP_ARG_WITH(config-file-scan-dir,,
 [  --with-config-file-scan-dir=PATH
-                          Set the path where to scan for configuration files], DEFAULT, no) 
+                          Set the path where to scan for configuration files], DEFAULT, no)
 if test "$PHP_CONFIG_FILE_SCAN_DIR" = "DEFAULT"; then
   PHP_CONFIG_FILE_SCAN_DIR=
 fi
@@ -1059,7 +1060,7 @@ dnl -------------------------------------------------------------------------
 PHP_HELP_SEPARATOR([Extensions:
 
   --with-EXTENSION=[shared[,PATH]]
-  
+
     NOTE: Not all extensions can be build as 'shared'.
 
     Example: --with-foobar=shared,/usr/local/foobar/
@@ -1146,13 +1147,13 @@ if test "$PHP_PEAR" != "no"; then
   dnl PEAR dependancies
   dnl
   if test "$PHP_XML" = "no"; then
-    pear_error_msg="$pear_error_msg 
+    pear_error_msg="$pear_error_msg
                     PEAR requires XML to be enabled.     Add --enable-xml to the configure line. (or --without-pear)"
   fi
 
 dnl
 dnl  if test "$PHP_XMLRPC" = "no"; then
-dnl    pear_error_msg="$pear_error_msg 
+dnl    pear_error_msg="$pear_error_msg
 dnl                    PEAR requires XML-RPC to be enabled. Add --with-xmlrpc to the configure line. (or --without-pear)"
 dnl  fi
 dnl
@@ -1265,7 +1266,7 @@ if test -z "$EXTENSION_DIR"; then
     if test "$enable_maintainer_zts" = "yes"; then
       extbasedir=$extbasedir-zts
     fi
-    
+
     if test "$PHP_DEBUG" = "1"; then
       extbasedir=$extbasedir-debug
     fi
diff --git a/ext/gd/config.m4 b/ext/gd/config.m4
index c3ff5ece24..2a9d8e3570 100644
--- a/ext/gd/config.m4
+++ b/ext/gd/config.m4
@@ -32,8 +32,8 @@ fi
 PHP_ARG_WITH(xpm-dir, for the location of libXpm,
 [  --with-xpm-dir[=DIR]      GD: Set the path to libXpm install prefix], no, no)
 
-PHP_ARG_WITH(freetype-dir, for FreeType 2,
-[  --with-freetype-dir[=DIR] GD: Set the path to FreeType 2 install prefix], no, no)
+PHP_ARG_ENABLE(freetype, for FreeType 2,
+[  --enable-freetype       GD: Enable FreeType 2 support], no, no)
 
 PHP_ARG_ENABLE(gd-jis-conv, whether to enable JIS-mapped Japanese font support in GD,
 [  --enable-gd-jis-conv    GD: Enable JIS-mapped Japanese font support], no, no)
@@ -184,29 +184,14 @@ AC_DEFUN([PHP_GD_XPM],[
 ])
 
 AC_DEFUN([PHP_GD_FREETYPE2],[
-  if test "$PHP_FREETYPE_DIR" != "no"; then
-
-    for i in $PHP_FREETYPE_DIR /usr/local /usr; do
-      if test -f "$i/bin/freetype-config"; then
-        FREETYPE2_DIR=$i
-        FREETYPE2_CONFIG="$i/bin/freetype-config"
-        break
-      fi
-    done
-
-    if test -z "$FREETYPE2_DIR"; then
-      AC_MSG_ERROR([freetype-config not found.])
-    fi
+  if test "$PHP_FREETYPE" != "no"; then
 
-    FREETYPE2_CFLAGS=`$FREETYPE2_CONFIG --cflags`
-    FREETYPE2_LIBS=`$FREETYPE2_CONFIG --libs`
+    PKG_CHECK_MODULES([FREETYPE2], [freetype2], [FREETYPE2_FOUND=true])
 
     PHP_EVAL_INCLINE($FREETYPE2_CFLAGS)
     PHP_EVAL_LIBLINE($FREETYPE2_LIBS, GD_SHARED_LIBADD)
     AC_DEFINE(HAVE_LIBFREETYPE,1,[ ])
     AC_DEFINE(ENABLE_GD_TTF,1,[ ])
-  else
-    AC_MSG_RESULT([If configure fails try --with-freetype-dir=<DIR>])
   fi
 ])
 
@@ -290,7 +275,7 @@ dnl enable the support in bundled GD library
     GDLIB_CFLAGS="$GDLIB_CFLAGS -DHAVE_XPM"
   fi
 
-  if test -n "$FREETYPE2_DIR"; then
+  if test -n "$FREETYPE2_FOUND"; then
     AC_DEFINE(HAVE_GD_FREETYPE,   1, [ ])
     AC_DEFINE(ENABLE_GD_TTF, 1, [ ])
     GDLIB_CFLAGS="$GDLIB_CFLAGS -DHAVE_LIBFREETYPE -DENABLE_GD_TTF"
@@ -347,7 +332,7 @@ dnl
 if test "$PHP_GD" != "no"; then
   PHP_NEW_EXTENSION(gd, gd.c $extra_sources, $ext_shared,, \\$(GDLIB_CFLAGS))
 
-  if test "$GD_MODULE_TYPE" = "builtin"; then 
+  if test "$GD_MODULE_TYPE" = "builtin"; then
     PHP_ADD_BUILD_DIR($ext_builddir/libgd)
     GDLIB_CFLAGS="-I$ext_srcdir/libgd $GDLIB_CFLAGS"
     GD_HEADER_DIRS="ext/gd/ ext/gd/libgd/"
-- 
2.17.0

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 02:01:30 2024 UTC