[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] Make OpenSSL configure.in logic match libevent configure.in...



Update of /home/or/cvsroot/tor
In directory moria:/tmp/cvs-serv29019

Modified Files:
	configure.in 
Log Message:
Make OpenSSL configure.in logic match libevent configure.in logic.

Index: configure.in
===================================================================
RCS file: /home/or/cvsroot/tor/configure.in,v
retrieving revision 1.257
retrieving revision 1.258
diff -u -p -d -r1.257 -r1.258
--- configure.in	27 Jan 2006 18:39:40 -0000	1.257
+++ configure.in	27 Jan 2006 19:38:16 -0000	1.258
@@ -106,7 +106,7 @@ fi
 dnl ------------------------------------------------------
 dnl Where do you live, libevent?  And how do we call you?
 
-AC_CACHE_CHECK([for libevent location], ac_cv_libevent_dir, [
+AC_CACHE_CHECK([for libevent directory], ac_cv_libevent_dir, [
   saved_LIBS="$LIBS"
   saved_LDFLAGS="$LDFLAGS"
   le_found=no
@@ -140,7 +140,7 @@ AC_CACHE_CHECK([for libevent location], 
   done
   LIBS="$saved_LIBS"
   LDFLAGS="$saved_LIBS"
-  if test le_found = no ; then
+  if test $le_found = no ; then
     AC_MSG_ERROR([Could not find a linkable libevent. You can specify an explicit path using --with-libevent-dir])
   fi
 ])
@@ -166,7 +166,7 @@ AC_CACHE_CHECK([whether we need extra op
     saved_LDFLAGS="$LDFLAGS"
     le_runs=no
     for le_extra in "" "-Wl,-R$le_libdir" "-R$le_libdir" ; do
-      LDFLAGS="$saved_LDFLAGS $le_extra"
+      LDFLAGS="$le_extra $saved_LDFLAGS"
       AC_TRY_RUN([void *event_init(void);
                 int main(int c, char **v) {
                    event_init(); return 0;
@@ -193,51 +193,70 @@ if test $ac_cv_libevent_linker_option !=
 fi
 
 dnl ------------------------------------------------------
-dnl Where do you live, OpenSSL?
+dnl Where do you live, openssl?  And how do we call you?
 
-saved_LIBS="$LIBS"
-saved_LDFLAGS="$LDFLAGS"
-saved_CPPFLAGS="$CPPFLAGS"
-if test "x$prefix" != "xNONE" ; then
-        tryssldir="$tryssldir $prefix"
-fi
-AC_CACHE_CHECK([for OpenSSL directory], ac_cv_openssldir, [
-        for ssldir in $tryssldir "" /usr/local/openssl /usr/lib/openssl /usr/local/ssl /usr/lib/ssl /usr/local /usr/athena /usr/pkg /opt /opt/openssl ; do
-                CPPFLAGS="$saved_CPPFLAGS"
-                LDFLAGS="$saved_LDFLAGS"
-                LIBS="$saved_LIBS -lssl -lcrypto"
+AC_CACHE_CHECK([for OpenSSL directory], ac_cv_openssl_dir, [
+  saved_LIBS="$LIBS"
+  saved_LDFLAGS="$LDFLAGS"
+  ssl_found=no
+  for ssldir in $tryssldir "" $prefix /usr/local/openssl /usr/lib/openssl /usr/local/ssl /usr/lib/ssl /usr/local /usr/athena /usr/pkg /opt /opt/openssl ; do
+    LDFLAGS="$saved_LDFLAGS"
+    LIBS="$saved_LIBS -lssl -lcrypto"
 
-                # Skip directories if they don't exist
-                if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
-                        continue;
-                fi
-                if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
-                        # Try to use $ssldir/lib if it exists, otherwise
-                        # $ssldir
-                        if test -d "$ssldir/lib" ; then
-                                LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
-                                if test ! -z "$need_dash_r" ; then
-                                        LDFLAGS="-R$ssldir/lib $LDFLAGS"
-                                fi
-                        else
-                                LDFLAGS="-L$ssldir $saved_LDFLAGS"
-                                if test ! -z "$need_dash_r" ; then
-                                        LDFLAGS="-R$ssldir $LDFLAGS"
-                                fi
-                        fi
-                        # Try to use $ssldir/include if it exists, otherwise
-                        # $ssldir
-                        if test -d "$ssldir/include" ; then
-                                CPPFLAGS="-I$ssldir/include $saved_CPPFLAGS"
-                        else
-                                CPPFLAGS="-I$ssldir $saved_CPPFLAGS"
-                        fi
-                fi
+    # Skip the directory if it isn't there.
+    if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
+       continue;
+    fi
+    if test ! -z "$ssldir" ; then
+      if test -d "$ssldir/lib" ; then
+        LDFLAGS="-L$ssldir/lib $LDFLAGS"
+      else
+        LDFLAGS="-L$ssldir $LDFLAGS"
+      fi
+    fi
+    # Can I link it?
+    AC_TRY_LINK([],
+       [ void RAND_add(const void *, int, double); RAND_add((void*)0,0,0); ],
+       [ openssl_linked=yes ], [ openssl_linked=no ])
+    if test $openssl_linked = yes; then
+       if test ! -z "$ssldir" ; then
+         ac_cv_openssl_dir=$ssldir
+       else
+         ac_cv_openssl_dir="(system)"
+       fi
+       ssl_found=yes
+       break
+    fi
+  done
+  LIBS="$saved_LIBS"
+  LDFLAGS="$saved_LIBS"
+  if test $ssl_found = no ; then
+    AC_MSG_ERROR([Could not find a linkable OpenSSL. You can specify an explicit path using --with-ssl-dir])
+  fi
+])
+LIBS="$LIBS -lssl -lcrypto"
+if test "$ac_cv_openssl_dir" != "(system)"; then
+  if test -d "$ac_cv_openssl_dir/lib" ; then
+    LDFLAGS="-L$ac_cv_openssl_dir/lib $LDFLAGS"
+    ssl_libdir="$ac_cv_openssl_dir/lib"
+  else
+    LDFLAGS="-L$ac_cv_openssl_dir $LDFLAGS"
+    ssl_libdir="$ac_cv_openssl_dir"
+  fi
+  if test -d "$ac_cv_openssl_dir/include" ; then
+    CPPFLAGS="-I$ac_cv_openssl_dir/include $CPPFLAGS"
+  else
+    CPPFLAGS="-I$ac_cv_openssl_dir $CPPFLAGS"
+  fi
+fi
 
-                # Basic test to check for compatible version and correct linking
-                # *does not* test for RSA - that comes later.
-                AC_TRY_RUN(
-                        [
+AC_CACHE_CHECK([whether we need extra options to link OpenSSL],
+               ac_cv_openssl_linker_option, [
+    saved_LDFLAGS="$LDFLAGS"
+    ssl_runs=no
+    for ssl_extra in "" "-Wl,-R$ssl_libdir" "-R$ssl_libdir" ; do
+      LDFLAGS="$ssl_extra $saved_LDFLAGS"
+      AC_TRY_RUN([
 #include <string.h>
 #include <openssl/rand.h>
 int main(void)
@@ -248,54 +267,28 @@ int main(void)
         return(RAND_status() <= 0);
 }
                         ],
-                        [
-                                found_crypto=1
-                                break;
-                        ], []
-                )
-
-                if test ! -z "$found_crypto" ; then
-                        break;
-                fi
-        done
-
-        if test -z "$found_crypto" ; then
-                AC_MSG_ERROR([Could not find working OpenSSL library, please install or check config.log])
-        fi
-        if test -z "$ssldir" ; then
-                ssldir="(system)"
+                openssl_runs=yes, openssl_runs=no)
+      if test $openssl_runs = yes ; then
+        if test -z "$ssl_extra" ; then
+	  ac_cv_openssl_linker_option='(none)'
+        else
+          ac_cv_openssl_linker_option=$ssl_extra
         fi
-
-        ac_cv_openssldir=$ssldir
+        ssl_runs=yes
+        break
+      fi
+    done
+    if test ssl_runs = no ; then
+      AC_MSG_ERROR([Found linkable OpenSSL in $ac_cv_openssl_dir, but it doesn't run, even with -R.  Maybe specify another using --with-ssl-dir?])
+    fi
+    LDFLAGS="$saved_LDFLAGS"
 ])
-if (test ! -z "$ac_cv_openssldir" && test "x$ac_cv_openssldir" != "x(system)") ;
- then
-        dnl Need to recover ssldir - test above runs in subshell
-        ssldir=$ac_cv_openssldir
-        if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
-                # Try to use $ssldir/lib if it exists, otherwise
-                # $ssldir
-                if test -d "$ssldir/lib" ; then
-                        LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
-                        if test ! -z "$need_dash_r" ; then
-                                LDFLAGS="-R$ssldir/lib $LDFLAGS"
-                        fi
-                else
-                        LDFLAGS="-L$ssldir $saved_LDFLAGS"
-                        if test ! -z "$need_dash_r" ; then
-                                LDFLAGS="-R$ssldir $LDFLAGS"
-                        fi
-                fi
-                # Try to use $ssldir/include if it exists, otherwise
-                # $ssldir
-                if test -d "$ssldir/include" ; then
-                        CPPFLAGS="-I$ssldir/include $saved_CPPFLAGS"
-                else
-                        CPPFLAGS="-I$ssldir $saved_CPPFLAGS"
-                fi
-        fi
+
+if test $ac_cv_openssl_linker_option != '(none)' ; then
+   LDFLAGS="$ac_cv_openssl_linker_option $LDFLAGS"
 fi
-LIBS="$saved_LIBS"
+
+dnl Make sure to enable support for large off_t if avalable.
 
 AC_SYS_LARGEFILE