backport fix for linking with libpng installed in a non-standard location SDL-1.2
authorOzkan Sezer <sezeroz@gmail.com>
Sat, 13 Oct 2018 15:55:55 +0300
branchSDL-1.2
changeset 59812758bec1240
parent 597 85d1fcc58846
child 599 f5f1e8452f74
backport fix for linking with libpng installed in a non-standard location

(default 2.0 branch commit: 4088a517f9a5)
configure
configure.in
     1.1 --- a/configure	Sat Oct 13 11:11:02 2018 +0300
     1.2 +++ b/configure	Sat Oct 13 15:55:55 2018 +0300
     1.3 @@ -14084,7 +14084,10 @@
     1.4  
     1.5  fi
     1.6  if test "x$ac_cv_header_png_h" = x""yes; then
     1.7 -  have_png_hdr=yes
     1.8 +
     1.9 +            have_png_hdr=yes
    1.10 +            LIBPNG_CFLAGS=""
    1.11 +
    1.12  fi
    1.13  
    1.14  
    1.15 @@ -14154,7 +14157,10 @@
    1.16  { $as_echo "$as_me:$LINENO: result: $ac_cv_lib_png_png_create_read_struct" >&5
    1.17  $as_echo "$ac_cv_lib_png_png_create_read_struct" >&6; }
    1.18  if test "x$ac_cv_lib_png_png_create_read_struct" = x""yes; then
    1.19 -  have_png_lib=yes
    1.20 +
    1.21 +            have_png_lib=yes
    1.22 +            LIBPNG_LIBS="-lpng -lz"
    1.23 +
    1.24  fi
    1.25  
    1.26  
    1.27 @@ -14287,7 +14293,10 @@
    1.28  
    1.29  fi
    1.30  if test "x$ac_cv_header_png_h" = x""yes; then
    1.31 -  have_png_hdr=yes
    1.32 +
    1.33 +            have_png_hdr=yes
    1.34 +            LIBPNG_CFLAGS=""
    1.35 +
    1.36  fi
    1.37  
    1.38  
    1.39 @@ -14357,7 +14366,10 @@
    1.40  { $as_echo "$as_me:$LINENO: result: $ac_cv_lib_png_png_create_read_struct" >&5
    1.41  $as_echo "$ac_cv_lib_png_png_create_read_struct" >&6; }
    1.42  if test "x$ac_cv_lib_png_png_create_read_struct" = x""yes; then
    1.43 -  have_png_lib=yes
    1.44 +
    1.45 +            have_png_lib=yes
    1.46 +            LIBPNG_LIBS="-lpng -lz"
    1.47 +
    1.48  fi
    1.49  
    1.50  
    1.51 @@ -14367,7 +14379,6 @@
    1.52          { $as_echo "$as_me:$LINENO: result: yes" >&5
    1.53  $as_echo "yes" >&6; }
    1.54  	        have_png_hdr=yes
    1.55 -        CFLAGS="$LIBPNG_CFLAGS $CFLAGS"
    1.56          have_png_lib=yes
    1.57  
    1.58  fi
    1.59 @@ -14825,7 +14836,10 @@
    1.60  
    1.61  fi
    1.62  if test "x$ac_cv_header_webp_decode_h" = x""yes; then
    1.63 -  have_webp_hdr=yes
    1.64 +
    1.65 +            have_webp_hdr=yes
    1.66 +            LIBWEBP_CFLAGS=""
    1.67 +
    1.68  fi
    1.69  
    1.70  
    1.71 @@ -14895,7 +14909,10 @@
    1.72  { $as_echo "$as_me:$LINENO: result: $ac_cv_lib_webp_WebPGetDecoderVersion" >&5
    1.73  $as_echo "$ac_cv_lib_webp_WebPGetDecoderVersion" >&6; }
    1.74  if test "x$ac_cv_lib_webp_WebPGetDecoderVersion" = x""yes; then
    1.75 -  have_webp_lib=yes
    1.76 +
    1.77 +            have_webp_lib=yes
    1.78 +            LIBWEBP_LIBS="-lwebp"
    1.79 +
    1.80  fi
    1.81  
    1.82  
    1.83 @@ -15028,7 +15045,10 @@
    1.84  
    1.85  fi
    1.86  if test "x$ac_cv_header_webp_decode_h" = x""yes; then
    1.87 -  have_webp_hdr=yes
    1.88 +
    1.89 +            have_webp_hdr=yes
    1.90 +            LIBWEBP_CFLAGS=""
    1.91 +
    1.92  fi
    1.93  
    1.94  
    1.95 @@ -15098,7 +15118,10 @@
    1.96  { $as_echo "$as_me:$LINENO: result: $ac_cv_lib_webp_WebPGetDecoderVersion" >&5
    1.97  $as_echo "$ac_cv_lib_webp_WebPGetDecoderVersion" >&6; }
    1.98  if test "x$ac_cv_lib_webp_WebPGetDecoderVersion" = x""yes; then
    1.99 -  have_webp_lib=yes
   1.100 +
   1.101 +            have_webp_lib=yes
   1.102 +            LIBWEBP_LIBS="-lwebp"
   1.103 +
   1.104  fi
   1.105  
   1.106  
   1.107 @@ -15108,7 +15131,6 @@
   1.108          { $as_echo "$as_me:$LINENO: result: yes" >&5
   1.109  $as_echo "yes" >&6; }
   1.110  	        have_webp_hdr=yes
   1.111 -        CFLAGS="$LIBWEBP_CFLAGS $CFLAGS"
   1.112          have_webp_lib=yes
   1.113  
   1.114  fi
   1.115 @@ -15210,6 +15232,7 @@
   1.116  fi
   1.117  
   1.118  if test x$enable_webp = xyes -a x$have_webp_hdr = xyes -a x$have_webp_lib = xyes; then
   1.119 +    CFLAGS="$LIBWEBP_CFLAGS $CFLAGS"
   1.120      if test x$enable_webp_shared = xyes && test x$webp_lib != x; then
   1.121          echo "-- dynamic libwebp -> $webp_lib"
   1.122          cat >>confdefs.h <<_ACEOF
   1.123 @@ -15217,7 +15240,7 @@
   1.124  _ACEOF
   1.125  
   1.126      else
   1.127 -        IMG_LIBS="-lwebp $IMG_LIBS"
   1.128 +        IMG_LIBS="$LIBWEBP_LIBS $IMG_LIBS"
   1.129      fi
   1.130  fi
   1.131  
   1.132 @@ -15248,6 +15271,7 @@
   1.133      fi
   1.134  fi
   1.135  if test x$enable_png = xyes -a x$have_png_hdr = xyes -a x$have_png_lib = xyes; then
   1.136 +    CFLAGS="$LIBPNG_CFLAGS $CFLAGS"
   1.137      if test x$enable_png_shared = xyes && test x$png_lib != x; then
   1.138          echo "-- dynamic libpng -> $png_lib"
   1.139          cat >>confdefs.h <<_ACEOF
   1.140 @@ -15255,7 +15279,7 @@
   1.141  _ACEOF
   1.142  
   1.143      else
   1.144 -        IMG_LIBS="-lpng -lz $IMG_LIBS"
   1.145 +        IMG_LIBS="$LIBPNG_LIBS $IMG_LIBS"
   1.146      fi
   1.147  fi
   1.148  
     2.1 --- a/configure.in	Sat Oct 13 11:11:02 2018 +0300
     2.2 +++ b/configure.in	Sat Oct 13 15:55:55 2018 +0300
     2.3 @@ -194,11 +194,16 @@
     2.4  if test "x$enable_png" = xyes; then
     2.5      PKG_CHECK_MODULES([LIBPNG], [libpng], [dnl
     2.6          have_png_hdr=yes
     2.7 -        CFLAGS="$LIBPNG_CFLAGS $CFLAGS"
     2.8          have_png_lib=yes
     2.9        ], [dnl
    2.10 -        AC_CHECK_HEADER([png.h], [have_png_hdr=yes])
    2.11 -        AC_CHECK_LIB([png], [png_create_read_struct], [have_png_lib=yes], [], [-lz])
    2.12 +        AC_CHECK_HEADER([png.h], [
    2.13 +            have_png_hdr=yes
    2.14 +            LIBPNG_CFLAGS=""
    2.15 +        ])
    2.16 +        AC_CHECK_LIB([png], [png_create_read_struct], [
    2.17 +            have_png_lib=yes
    2.18 +            LIBPNG_LIBS="-lpng -lz"
    2.19 +        ], [], [-lz])
    2.20        ])
    2.21      if test x$have_png_hdr = xyes -a x$have_png_lib = xyes; then
    2.22          AC_DEFINE([LOAD_PNG])
    2.23 @@ -258,11 +263,16 @@
    2.24  if test x$enable_webp = xyes; then
    2.25      PKG_CHECK_MODULES([LIBWEBP], [libwebp], [dnl
    2.26          have_webp_hdr=yes
    2.27 -        CFLAGS="$LIBWEBP_CFLAGS $CFLAGS"
    2.28          have_webp_lib=yes
    2.29        ], [dnl
    2.30 -        AC_CHECK_HEADER([webp/decode.h], [have_webp_hdr=yes])
    2.31 -        AC_CHECK_LIB([webp], [WebPGetDecoderVersion], [have_webp_lib=yes], [], [-lm])
    2.32 +        AC_CHECK_HEADER([webp/decode.h], [
    2.33 +            have_webp_hdr=yes
    2.34 +            LIBWEBP_CFLAGS=""
    2.35 +        ])
    2.36 +        AC_CHECK_LIB([webp], [WebPGetDecoderVersion], [
    2.37 +            have_webp_lib=yes
    2.38 +            LIBWEBP_LIBS="-lwebp"
    2.39 +        ], [], [-lm])
    2.40        ])
    2.41      if test x$have_webp_hdr = xyes -a x$have_webp_lib = xyes; then
    2.42          AC_DEFINE([LOAD_WEBP])
    2.43 @@ -330,11 +340,12 @@
    2.44  fi
    2.45  
    2.46  if test x$enable_webp = xyes -a x$have_webp_hdr = xyes -a x$have_webp_lib = xyes; then
    2.47 +    CFLAGS="$LIBWEBP_CFLAGS $CFLAGS"
    2.48      if test x$enable_webp_shared = xyes && test x$webp_lib != x; then
    2.49          echo "-- dynamic libwebp -> $webp_lib"
    2.50          AC_DEFINE_UNQUOTED(LOAD_WEBP_DYNAMIC, "$webp_lib")
    2.51      else
    2.52 -        IMG_LIBS="-lwebp $IMG_LIBS"
    2.53 +        IMG_LIBS="$LIBWEBP_LIBS $IMG_LIBS"
    2.54      fi
    2.55  fi
    2.56  
    2.57 @@ -359,11 +370,12 @@
    2.58      fi
    2.59  fi
    2.60  if test x$enable_png = xyes -a x$have_png_hdr = xyes -a x$have_png_lib = xyes; then
    2.61 +    CFLAGS="$LIBPNG_CFLAGS $CFLAGS"
    2.62      if test x$enable_png_shared = xyes && test x$png_lib != x; then
    2.63          echo "-- dynamic libpng -> $png_lib"
    2.64          AC_DEFINE_UNQUOTED(LOAD_PNG_DYNAMIC, "$png_lib")
    2.65      else
    2.66 -        IMG_LIBS="-lpng -lz $IMG_LIBS"
    2.67 +        IMG_LIBS="$LIBPNG_LIBS $IMG_LIBS"
    2.68      fi
    2.69  fi
    2.70