Convert system library version tests from AC_TRY_RUN to AC_TRY_COMPILE so that they work when cross-compiling. b=372878 r=bsmedberg
authordbaron@dbaron.org
Thu, 22 Mar 2007 23:26:53 -0700
changeset 25 e18bce582158609740085471529b677c4175c57f
parent 24 8473a4abe3eacc527e8e4973e650fcc19065cf36
child 26 6b8dccd5afac01049cbd8f28f5a8cf7d3cb99732
push idunknown
push userunknown
push dateunknown
reviewersbsmedberg
bugs372878
milestone1.9a3pre
Convert system library version tests from AC_TRY_RUN to AC_TRY_COMPILE so that they work when cross-compiling. b=372878 r=bsmedberg
configure.in
--- a/configure.in
+++ b/configure.in
@@ -98,17 +98,17 @@ dnl ====================================
 _SUBDIR_HOST_CXXFLAGS="$HOST_CXXFLAGS"
 _SUBDIR_HOST_LDFLAGS="$HOST_LDFLAGS"
 _SUBDIR_CONFIG_ARGS="$ac_configure_args"
 
 dnl Set the version number of the libs included with mozilla
 dnl ========================================================
 MOZJPEG=62
 MOZPNG=10207
-MOZZLIB=1.2.3
+MOZZLIB=0x1230
 NSPR_VERSION=4
 NSS_VERSION=3
 
 dnl Set the minimum version of toolkit libs used by mozilla
 dnl ========================================================
 GLIB_VERSION=1.2.0
 GTK_VERSION=1.2.0
 LIBIDL_VERSION=0.6.3
@@ -3906,29 +3906,24 @@ fi
 if test -z "$JPEG_DIR" -o "$JPEG_DIR" = no; then
     SYSTEM_JPEG=
 else
     AC_CHECK_LIB(jpeg, jpeg_destroy_compress, [SYSTEM_JPEG=1 JPEG_LIBS="-ljpeg $JPEG_LIBS"], SYSTEM_JPEG=, $JPEG_LIBS)
 fi
 
 if test "$SYSTEM_JPEG" = 1; then
     LIBS="$JPEG_LIBS $LIBS"
-    AC_TRY_RUN( 
-	#include <stdio.h>
-	#include <sys/types.h>
-	#include <jpeglib.h>
-	int main () {
-	    #if JPEG_LIB_VERSION >= $MOZJPEG
-		exit(0);
-	    #else
-		exit(1);
-	    #endif
-	}
-	, SYSTEM_JPEG=1, [SYSTEM_JPEG= JPEG_CFLAGS= JPEG_LIBS=], SYSTEM_JPEG= ) 
-    rm -f core
+    AC_TRY_COMPILE([ #include <stdio.h>
+                     #include <sys/types.h>
+                     #include <jpeglib.h> ],
+                   [ #if JPEG_LIB_VERSION < $MOZJPEG
+                     #error "Insufficient JPEG library version ($MOZJPEG required)."
+                     #endif ],
+                   SYSTEM_JPEG=1,
+                   [SYSTEM_JPEG= JPEG_CFLAGS= JPEG_LIBS=]) 
 fi 
 CFLAGS=$_SAVE_CFLAGS
 LDFLAGS=$_SAVE_LDFLAGS
 LIBS=$_SAVE_LIBS
 
 if test -n "${JPEG_DIR}" -a -d "${JPEG_DIR}" -a "$SYSTEM_JPEG" = 1; then
     JPEG_CFLAGS="-I${JPEG_DIR}/include"
     JPEG_LIBS="-L${JPEG_DIR}/lib ${JPEG_LIBS}"
@@ -3951,35 +3946,24 @@ fi
 if test -z "$ZLIB_DIR" -o "$ZLIB_DIR" = no; then
     SYSTEM_ZLIB=
 else
     AC_CHECK_LIB(z, gzread, [SYSTEM_ZLIB=1 ZLIB_LIBS="-lz $ZLIB_LIBS"], 
 	[SYSTEM_ZLIB= ZLIB_CFLAGS= ZLIB_LIBS=], $ZLIB_LIBS)
 fi
 if test "$SYSTEM_ZLIB" = 1; then
     LIBS="$ZLIB_LIBS $LIBS"
-    AC_TRY_RUN([
-    #include <stdio.h>
-    #include <string.h>
-    #include <zlib.h>
-    int parse_version(const char *str, int *ver) {
-      return (sscanf(str, "%d.%d.%d", ver, ver+1, ver+2)==3?0:1);
-    }
-    int main() {
-      int sys[3], req[3];
-      if (parse_version(zlib_version, sys) || parse_version("$MOZZLIB", req))
-        exit(1);
-      if ((sys[0] == req[0]) &&
-          ((sys[1] > req[1]) || ((sys[1] == req[1]) && (sys[2] >= req[2]))))
-        exit(0);
-      else
-        exit(1);
-    }
-    ], SYSTEM_ZLIB=1, [SYSTEM_ZLIB= ZLIB_CFLAGS= ZLIB_LIBS=], SYSTEM_ZLIB= ) 
-    rm -f core
+    AC_TRY_COMPILE([ #include <stdio.h>
+                     #include <string.h>
+                     #include <zlib.h> ],
+                   [ #if ZLIB_VERNUM < $MOZZLIB 
+                     #error "Insufficient zlib version ($MOZZLIB required)."
+                     #endif ],
+                   SYSTEM_ZLIB=1,
+                   [SYSTEM_ZLIB= ZLIB_CFLAGS= ZLIB_LIBS=]) 
 fi
 CFLAGS=$_SAVE_CFLAGS
 LDFLAGS=$_SAVE_LDFLAGS
 LIBS=$_SAVE_LIBS
 
 if test "${ZLIB_DIR}" -a -d "${ZLIB_DIR}" -a "$SYSTEM_ZLIB" = 1; then
     ZLIB_CFLAGS="-I${ZLIB_DIR}/include"
     ZLIB_LIBS="-L${ZLIB_DIR}/lib ${ZLIB_LIBS}"
@@ -4007,33 +3991,27 @@ else
     _SAVE_PNG_LIBS=$PNG_LIBS
     AC_CHECK_LIB(png, png_get_valid, [SYSTEM_PNG=1 PNG_LIBS="-lpng $PNG_LIBS"],
                  SYSTEM_PNG=, $PNG_LIBS)
     AC_CHECK_LIB(png, png_get_acTl, ,
                  [SYSTEM_PNG= PNG_LIBS=$_SAVE_PNG_LIBS], $_SAVE_PNG_LIBS)
 fi
 if test "$SYSTEM_PNG" = 1; then
     LIBS="$PNG_LIBS $LIBS"
-    AC_TRY_RUN(
-	#include <stdio.h>
-	#include <sys/types.h>
-	#include <png.h>
-	int main () {
-            #if PNG_LIBPNG_VER >= $MOZPNG
-                #ifdef PNG_UINT_31_MAX
-		    exit(0);
-	        #else
-	            exit(1);
-                #endif
-	    #else
-		exit(1);
-	    #endif
-	}
-	, SYSTEM_PNG=1, [SYSTEM_PNG= PNG_CFLAGS= PNG_LIBS=], SYSTEM_PNG= ) 
-    rm -f core
+    AC_TRY_COMPILE([ #include <stdio.h>
+                     #include <sys/types.h>
+                     #include <png.h> ],
+                   [ #if PNG_LIBPNG_VER < $MOZPNG
+                     #error "Insufficient libpng version ($MOZPNG required)."
+                     #endif
+                     #ifndef PNG_UINT_31_MAX
+                     #error "Insufficient libpng version."
+                     #endif ],
+                   SYSTEM_PNG=1,
+                   [SYSTEM_PNG= PNG_CFLAGS= PNG_LIBS=]) 
 fi
 CFLAGS=$_SAVE_CFLAGS
 LDFLAGS=$_SAVE_LDFLAGS
 LIBS=$_SAVE_LIBS
 
 if test "${PNG_DIR}" -a -d "${PNG_DIR}" -a "$SYSTEM_PNG" = 1; then
     PNG_CFLAGS="-I${PNG_DIR}/include"
     PNG_LIBS="-L${PNG_DIR}/lib ${PNG_LIBS}"