File gnuplot-gd.patch of Package gnuplot

Index: gnuplot-5.2.2/configure.ac
===================================================================
---
 gnuplot-5.4.0/configure.ac    |   66 ++++++------------------------------------
 gnuplot-5.4.0/src/Makefile.am |    2 -
 2 files changed, 11 insertions(+), 57 deletions(-)

--- gnuplot-5.4.0/configure.ac
+++ gnuplot-5.4.0/configure.ac	2020-07-17 07:31:14.828189953 +0000
@@ -535,63 +535,17 @@ AC_ARG_WITH(gd,dnl
   with_gd=yes)
 
 if test "$with_gd" != no; then
-  AC_PATH_PROG([GDLIB_CONFIG], [gdlib-config])
-  if test -n "$GDLIB_CONFIG"; then
-    libgd_CPPFLAGS=`$GDLIB_CONFIG --cflags`
-    libgd_LDFLAGS=`$GDLIB_CONFIG --ldflags`
-    libgd_LIBS=`$GDLIB_CONFIG --libs`
-  elif test -d "$with_gd"; then
-    libgd_CPPFLAGS="-I$with_gd/include"
-    libgd_LDFLAGS="-L$with_gd/lib"
-    libgd_LIBS="-ljpeg -lpng -lfreetype -lz"
-  fi
-
-  _cppflags="$CPPFLAGS"
-  _ldflags="$LDFLAGS"
-  _libs="$LIBS"
-  CPPFLAGS="$CPPFLAGS $libgd_CPPFLAGS"
-  LDFLAGS="$LDFLAGS $libgd_LDFLAGS"
-  LIBS="$LIBS $libgd_LIBS"
-
-  AC_CHECK_LIB(gd,gdImageCreateTrueColor,
-    [dnl found gd library
+PKG_CHECK_MODULES([GD], [gdlib], [ 
+     ac_cv_lib_gd_gdImageJpeg=yes
+     ac_cv_lib_gd_gdImagePng=yes
+     ac_cv_lib_gd_gdImageGif=yes
+     ac_cv_lib_gd_gdImageGifAnimBegin=yes
      AC_DEFINE(HAVE_LIBGD,1,[ Define if you have gd library. ])
-     AC_CHECK_HEADERS(gd.h,,
-       AC_MSG_WARN([please add path to gd.h to CPPFLAGS in Makefile]))
-
-     dnl gif support in libgd
-     AC_CHECK_LIB(gd,gdImageGif,
-       [AC_DEFINE(HAVE_GD_GIF,1,[ Define if libgd supports gif. ])])
-     AC_CHECK_LIB(gd,gdImageGifAnimBegin,
-       [AC_DEFINE(GIF_ANIMATION,1,[ Define if libgd supports animated gifs. ])])
-
-     dnl jpeg support in libgd
-     AC_CHECK_LIB(gd,gdImageJpeg,
-       [AC_DEFINE(HAVE_GD_JPEG,1,[ Define if libgd supports jpeg. ])])
-
-     dnl freetype support in libgd
-     AC_CHECK_LIB(gd,gdImageStringFT,
-       AC_DEFINE(HAVE_GD_TTF,1,
-           [ Define if libgd supports TrueType fonts through libfreetype. ]))
-
-     dnl png support in libgd
-     AC_CHECK_LIB(gd,gdImagePng,
-       [AC_DEFINE(HAVE_GD_PNG,1,[ Define if libgd supports png. ])])
-
-    ],[dnl gd library not found
-       AC_MSG_WARN([libgd not found or too old, version >= 2.0 is required])
-       with_gd=no
-    ])
-
-  dnl piece it all together
-  if test "$with_gd" = no; then
-    CPPFLAGS="$_cppflags"
-    LDFLAGS="$_ldflags"
-    LIBS="$_libs"
-  else
-    LIBS="$_libs"
-    TERMLIBS="$TERMLIBS -lgd $libgd_LIBS"
-  fi
+     AC_DEFINE(HAVE_GD_GIF,1,[ Define if libgd supports gif. ])
+     AC_DEFINE(GIF_ANIMATION,1,[ Define if libgd supports animated gifs. ])
+     AC_DEFINE(HAVE_GD_JPEG,1,[ Define if libgd supports jpeg. ])
+     AC_DEFINE(HAVE_GD_TTF,1, [ Define if libgd supports TrueType fonts through libfreetype. ])
+     AC_DEFINE(HAVE_GD_PNG,1,[ Define if libgd supports png. ])])
 
 fi
 dnl end gd
--- gnuplot-5.4.0/src/Makefile.am
+++ gnuplot-5.4.0/src/Makefile.am	2020-07-17 07:32:16.391125309 +0000
@@ -60,7 +60,7 @@ term_api.h term.c term.h time.c unset.c
 util3d.c util3d.h variable.c variable.h version.c version.h \
 voxelgrid.c voxelgrid.h vplot.c vplot.h marching_cubes.h
 
-gnuplot_LDADD = $(TERMLIBS) $(TERMXLIBS) $(WX_LIBS) $(QT_LIBS)
+gnuplot_LDADD = $(GD_LIBS) $(TERMLIBS) $(TERMXLIBS) $(WX_LIBS) $(QT_LIBS)
 
 pkglibexec_PROGRAMS =