changeset 1335:2e05b030e814

- Check for giflib in PACKAGE_PATH if not found in standard locations and setup GIFLIB_CFLAGS and GIFLIB_LDFLAGS so the build can find it. This fixes --with-giflib=system for bsd's.
author kurt
date Fri, 22 May 2015 12:41:10 -0400
parents efcdaab49c6c
children 448afd6aeb47
files common/autoconf/libraries.m4 common/autoconf/spec.gmk.in
diffstat 2 files changed, 50 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/common/autoconf/libraries.m4	Thu May 21 08:31:55 2015 -0400
+++ b/common/autoconf/libraries.m4	Fri May 22 12:41:10 2015 -0400
@@ -654,17 +654,61 @@
 
   if test "x${with_giflib}" = "xbundled"; then
     USE_EXTERNAL_LIBGIF=false
+    GIFLIB_CFLAGS=
+    GIFLIB_LDFLAGS=
   elif test "x${with_giflib}" = "xsystem"; then
-    AC_CHECK_HEADER(gif_lib.h, [],
-        [ AC_MSG_ERROR([--with-giflib=system specified, but gif_lib.h not found!])])
-    AC_CHECK_LIB(gif, DGifGetCode, [],
-        [ AC_MSG_ERROR([--with-giflib=system specified, but no giflib found!])])
+    GIFLIB_H_FOUND=no
+    AC_CHECK_HEADER(gif_lib.h,
+        [
+           GIFLIB_H_FOUND=yes
+           GIFLIB_CFLAGS=
+        ]
+    )
+    if test "x$GIFLIB_H_FOUND" = xno; then
+      AC_MSG_CHECKING([for giflib headers])
+      if test -s ${PACKAGE_PATH}/include/gif_lib.h; then
+        # Standard package location for BSD
+        GIFLIB_H_FOUND=yes
+        GIFLIB_CFLAGS="-I${PACKAGE_PATH}/include"
+      fi
+      AC_MSG_RESULT([$GIFLIB_H_FOUND])
+    fi
+    if test "x$GIFLIB_H_FOUND" = xno; then
+      HELP_MSG_MISSING_DEPENDENCY([giflib])
+      AC_MSG_ERROR([Could not find giflib headers! $HELP_MSG ])
+    fi
+
+    GIFLIB_LIB_FOUND=no
+    AC_CHECK_LIB(gif, DGifGetCode,
+        [
+           GIFLIB_LIB_FOUND=yes
+           GIFLIB_LDFLAGS=
+        ]
+    )
+    if test "x$GIFLIB_LIB_FOUND" = xno; then
+      save_LDFLAGS="$LDFLAGS"
+      LDFLAGS="$LDFLAGS -L${PACKAGE_PATH}/lib"
+      AC_CHECK_LIB(gif, DGifOpen,
+          [
+             GIFLIB_LIB_FOUND=yes
+             GIFLIB_LDFLAGS="-L${PACKAGE_PATH}/lib"
+          ]
+      )
+      LDFLAGS="$save_LDFLAGS"
+    fi
+
+    if test "x$GIFLIB_LIB_FOUND" = xno; then
+      HELP_MSG_MISSING_DEPENDENCY([giflib])
+      AC_MSG_ERROR([Could not find giflib library! $HELP_MSG ])
+    fi
 
     USE_EXTERNAL_LIBGIF=true
   else
     AC_MSG_ERROR([Invalid value of --with-giflib: ${with_giflib}, use 'system' or 'bundled'])
   fi
   AC_SUBST(USE_EXTERNAL_LIBGIF)
+  AC_SUBST(GIFLIB_CFLAGS)
+  AC_SUBST(GIFLIB_LDFLAGS)
 
   ###############################################################################
   #
--- a/common/autoconf/spec.gmk.in	Thu May 21 08:31:55 2015 -0400
+++ b/common/autoconf/spec.gmk.in	Fri May 22 12:41:10 2015 -0400
@@ -562,6 +562,8 @@
 ENABLE_INTREE_EC=@ENABLE_INTREE_EC@
 USE_EXTERNAL_LIBJPEG:=@USE_EXTERNAL_LIBJPEG@
 USE_EXTERNAL_LIBGIF:=@USE_EXTERNAL_LIBGIF@
+GIFLIB_CFLAGS:=@GIFLIB_CFLAGS@
+GIFLIB_LDFLAGS:=@GIFLIB_LDFLAGS@
 USE_EXTERNAL_LIBZ:=@USE_EXTERNAL_LIBZ@
 LIBZIP_CAN_USE_MMAP:=@LIBZIP_CAN_USE_MMAP@
 MSVCR_DLL:=@MSVCR_DLL@