cleanup gd build with system libgd - drop need to use libpng with system libgd - drop need to use libjpeg with system libgd - drop need to use libXpm with system libgd - drop need to use libfreetype with system libgd - improve configure comments

This commit is contained in:
Remi Collet 2019-07-22 11:47:38 +02:00 committed by Remi Collet
parent a2b758dab5
commit 31d85b8417
5 changed files with 30 additions and 91 deletions

View file

@ -17,7 +17,7 @@ if test -z "$PHP_WEBP"; then
PHP_ARG_WITH([webp],
[for libwebp],
[AS_HELP_STRING([--with-webp],
[GD: Enable WEBP support])],
[GD: Enable WEBP support (only for bundled libgd)])],
[no],
[no])
fi
@ -26,7 +26,7 @@ if test -z "$PHP_JPEG"; then
PHP_ARG_WITH([jpeg],
[for libjpeg],
[AS_HELP_STRING([--with-jpeg],
[GD: Enable JPEG support])],
[GD: Enable JPEG support (only for bundled libgd)])],
[no],
[no])
fi
@ -34,21 +34,21 @@ fi
PHP_ARG_WITH([xpm],
[for libXpm],
[AS_HELP_STRING([--with-xpm],
[GD: Enable XPM support])],
[GD: Enable XPM support (only for bundled libgd)])],
[no],
[no])
PHP_ARG_WITH([freetype],
[for FreeType 2],
[AS_HELP_STRING([--with-freetype],
[GD: Enable FreeType 2 support])],
[GD: Enable FreeType 2 support (only for bundled libgd)])],
[no],
[no])
PHP_ARG_ENABLE([gd-jis-conv],
[whether to enable JIS-mapped Japanese font support in GD],
[AS_HELP_STRING([--enable-gd-jis-conv],
[GD: Enable JIS-mapped Japanese font support])],
[GD: Enable JIS-mapped Japanese font support (only for bundled libgd)])],
[no],
[no])
@ -176,15 +176,6 @@ dnl Various checks for GD features
], [ $GD_SHARED_LIBADD ], [char foobar () {}])
else
dnl for png.h in gd_compat (PNG_LIBPNG_VER_STRING)
PHP_GD_PNG
dnl for jpeglib.h in gd_compat (JPEG_LIB_VERSION)
PHP_GD_JPEG
dnl for X11/xpm.h in gd.c (XpmLibraryVersion)
PHP_GD_XPM
dnl for ft2build.h in gd.c (FREETYPE_MAJOR...)
PHP_GD_FREETYPE2
extra_sources="gd_compat.c"
PKG_CHECK_MODULES([GDLIB], [gdlib >= 2.1.0])
PHP_EVAL_LIBLINE($GDLIB_LIBS, GD_SHARED_LIBADD)

View file

@ -37,10 +37,10 @@
#include "php_open_temporary_file.h"
#if HAVE_SYS_WAIT_H
#ifdef HAVE_SYS_WAIT_H
# include <sys/wait.h>
#endif
#if HAVE_UNISTD_H
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#ifdef PHP_WIN32
@ -51,7 +51,7 @@
# include <Wingdi.h>
#endif
#ifdef HAVE_GD_XPM
#if defined(HAVE_GD_XPM) && defined(HAVE_GD_BUNDLED)
# include <X11/xpm.h>
#endif
@ -68,7 +68,7 @@ static int le_gd, le_gd_font;
#include <gdfontl.h> /* 4 Large font */
#include <gdfontg.h> /* 5 Giant font */
#if HAVE_LIBFREETYPE
#if defined(HAVE_GD_FREETYPE) && defined(HAVE_GD_BUNDLED)
# include <ft2build.h>
# include FT_FREETYPE_H
#endif
@ -81,7 +81,7 @@ static int le_gd, le_gd_font;
#define M_PI 3.14159265358979323846
#endif
#if HAVE_LIBFREETYPE
#ifdef HAVE_GD_FREETYPE
static void php_imagettftext_common(INTERNAL_FUNCTION_PARAMETERS, int, int);
#endif
@ -722,7 +722,7 @@ ZEND_BEGIN_ARG_INFO(arginfo_imagegetclip, 0)
ZEND_ARG_INFO(0, im)
ZEND_END_ARG_INFO()
#if HAVE_LIBFREETYPE
#ifdef HAVE_GD_FREETYPE
ZEND_BEGIN_ARG_INFO_EX(arginfo_imageftbbox, 0, 0, 4)
ZEND_ARG_INFO(0, size)
ZEND_ARG_INFO(0, angle)
@ -987,13 +987,11 @@ static const zend_function_entry gd_functions[] = {
PHP_FE(imagegetclip, arginfo_imagegetclip)
PHP_FE(imagedashedline, arginfo_imagedashedline)
#if HAVE_LIBFREETYPE
#ifdef HAVE_GD_FREETYPE
PHP_FE(imagettfbbox, arginfo_imagettfbbox)
PHP_FE(imagettftext, arginfo_imagettftext)
#if HAVE_GD_FREETYPE && HAVE_LIBFREETYPE
PHP_FE(imageftbbox, arginfo_imageftbbox)
PHP_FE(imagefttext, arginfo_imagefttext)
#endif
#endif
PHP_FE(imagetypes, arginfo_imagetypes)
@ -1027,11 +1025,7 @@ zend_module_entry gd_module_entry = {
PHP_MINIT(gd),
PHP_MSHUTDOWN(gd),
NULL,
#if HAVE_GD_FREETYPE && HAVE_LIBFREETYPE
PHP_RSHUTDOWN(gd),
#else
NULL,
#endif
PHP_MINFO(gd),
PHP_GD_VERSION,
STANDARD_MODULE_PROPERTIES
@ -1099,7 +1093,7 @@ PHP_MINIT_FUNCTION(gd)
le_gd = zend_register_list_destructors_ex(php_free_gd_image, NULL, "gd", module_number);
le_gd_font = zend_register_list_destructors_ex(php_free_gd_font, NULL, "gd font", module_number);
#if HAVE_GD_BUNDLED && HAVE_LIBFREETYPE
#if defined(HAVE_GD_FREETYPE) && defined(HAVE_GD_BUNDLED)
gdFontCacheMutexSetup();
#endif
gdSetErrorMethod(php_gd_error_method);
@ -1238,7 +1232,7 @@ PHP_MINIT_FUNCTION(gd)
*/
PHP_MSHUTDOWN_FUNCTION(gd)
{
#if HAVE_GD_BUNDLED && HAVE_LIBFREETYPE
#if defined(HAVE_GD_FREETYPE) && defined(HAVE_GD_BUNDLED)
gdFontCacheMutexShutdown();
#endif
return SUCCESS;
@ -1247,13 +1241,13 @@ PHP_MSHUTDOWN_FUNCTION(gd)
/* {{{ PHP_RSHUTDOWN_FUNCTION
*/
#if HAVE_GD_FREETYPE && HAVE_LIBFREETYPE
PHP_RSHUTDOWN_FUNCTION(gd)
{
#ifdef HAVE_GD_FREETYPE
gdFontCacheShutdown();
#endif
return SUCCESS;
}
#endif
/* }}} */
#if defined(HAVE_GD_BUNDLED)
@ -1280,9 +1274,10 @@ PHP_MINFO_FUNCTION(gd)
#endif
#endif
#if HAVE_LIBFREETYPE
#ifdef HAVE_GD_FREETYPE
php_info_print_table_row(2, "FreeType Support", "enabled");
php_info_print_table_row(2, "FreeType Linkage", "with freetype");
#ifdef HAVE_GD_BUNDLED
{
char tmp[256];
@ -1295,6 +1290,7 @@ PHP_MINFO_FUNCTION(gd)
#endif
php_info_print_table_row(2, "FreeType Version", tmp);
}
#endif
#endif
php_info_print_table_row(2, "GIF Read Support", "enabled");
@ -1303,22 +1299,28 @@ PHP_MINFO_FUNCTION(gd)
#ifdef HAVE_GD_JPG
{
php_info_print_table_row(2, "JPEG Support", "enabled");
#if defined(HAVE_GD_BUNDLED)
php_info_print_table_row(2, "libJPEG Version", gdJpegGetVersionString());
#endif
}
#endif
#ifdef HAVE_GD_PNG
php_info_print_table_row(2, "PNG Support", "enabled");
#if defined(HAVE_GD_BUNDLED)
php_info_print_table_row(2, "libPNG Version", gdPngGetVersionString());
#endif
#endif
php_info_print_table_row(2, "WBMP Support", "enabled");
#if defined(HAVE_GD_XPM)
php_info_print_table_row(2, "XPM Support", "enabled");
#if defined(HAVE_GD_BUNDLED)
{
char tmp[12];
snprintf(tmp, sizeof(tmp), "%d", XpmLibraryVersion());
php_info_print_table_row(2, "libXpm Version", tmp);
}
#endif
#endif
php_info_print_table_row(2, "XBM Support", "enabled");
#if defined(USE_GD_JISX0208)
@ -1350,7 +1352,7 @@ PHP_FUNCTION(gd_info)
add_assoc_string(return_value, "GD Version", PHP_GD_VERSION_STRING);
#if HAVE_LIBFREETYPE
#ifdef HAVE_GD_FREETYPE
add_assoc_bool(return_value, "FreeType Support", 1);
add_assoc_string(return_value, "FreeType Linkage", "with freetype");
#else
@ -3965,14 +3967,10 @@ PHP_FUNCTION(imagegetclip)
}
/* }}} */
#if HAVE_LIBFREETYPE
#define TTFTEXT_DRAW 0
#define TTFTEXT_BBOX 1
#endif
#if HAVE_LIBFREETYPE
#if HAVE_GD_FREETYPE
#ifdef HAVE_GD_FREETYPE
/* {{{ proto array imageftbbox(float size, float angle, string font_file, string text [, array extrainfo])
Give the bounding box of a text using fonts via freetype2 */
PHP_FUNCTION(imageftbbox)
@ -3988,7 +3986,6 @@ PHP_FUNCTION(imagefttext)
php_imagettftext_common(INTERNAL_FUNCTION_PARAM_PASSTHRU, TTFTEXT_DRAW, 1);
}
/* }}} */
#endif /* HAVE_GD_FREETYPE */
/* {{{ proto array imagettfbbox(float size, float angle, string font_file, string text)
Give the bounding box of a text using TrueType fonts */
@ -4069,14 +4066,11 @@ static void php_imagettftext_common(INTERNAL_FUNCTION_PARAMETERS, int mode, int
PHP_GD_CHECK_OPEN_BASEDIR(fontname, "Invalid font filename");
#ifdef HAVE_GD_FREETYPE
if (extended) {
error = gdImageStringFTEx(im, brect, col, fontname, ptsize, angle, x, y, str, &strex);
}
else
} else {
error = gdImageStringFT(im, brect, col, fontname, ptsize, angle, x, y, str);
#endif /* HAVE_GD_FREETYPE */
}
if (error) {
php_error_docref(NULL, E_WARNING, "%s", error);
@ -4091,7 +4085,7 @@ static void php_imagettftext_common(INTERNAL_FUNCTION_PARAMETERS, int mode, int
}
}
/* }}} */
#endif /* HAVE_LIBFREETYPE */
#endif /* HAVE_GD_FREETYPE */
/* {{{ proto bool image2wbmp(resource im [, string filename [, int foreground]])
Output WBMP image to browser or file */

View file

@ -4,47 +4,9 @@
#include "php_config.h"
#endif
#ifdef HAVE_GD_PNG
/* needs to be first */
# include <png.h>
#endif
#ifdef HAVE_GD_JPG
# include <jpeglib.h>
#endif
#include "gd_compat.h"
#include "php.h"
#ifdef HAVE_GD_JPG
const char * gdJpegGetVersionString()
{
switch(JPEG_LIB_VERSION) {
case 62:
return "6b";
break;
case 70:
return "7";
break;
case 80:
return "8";
break;
default:
return "unknown";
}
}
#endif
#ifdef HAVE_GD_PNG
const char * gdPngGetVersionString()
{
return PNG_LIBPNG_VER_STRING;
}
#endif
int overflow2(int a, int b)
{

View file

@ -1,12 +1,6 @@
#ifndef GD_COMPAT_H
#define GD_COMPAT_H 1
#ifndef HAVE_GD_BUNDLED
/* from gd_compat.c */
const char * gdPngGetVersionString();
const char * gdJpegGetVersionString();
#endif
/* from gd_compat.c of libgd/gd_security.c */
int overflow2(int a, int b);

View file

@ -78,9 +78,7 @@ extern zend_module_entry gd_module_entry;
PHP_MINFO_FUNCTION(gd);
PHP_MINIT_FUNCTION(gd);
PHP_MSHUTDOWN_FUNCTION(gd);
#if HAVE_GD_FREETYPE && HAVE_LIBFREETYPE
PHP_RSHUTDOWN_FUNCTION(gd);
#endif
PHP_FUNCTION(gd_info);
PHP_FUNCTION(imagearc);