Bug #554 support for --with-openssl[=DIR]
Submitted: 31 May 2003 6:45 Modified: 22 Jul 2003 7:57
Reporter: Jens Elkner Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Compiling Severity:S4 (Feature request)
Version:4.0.13 OS:Linux (Linux 2.4.20)
Assigned to: Sergei Glukhov CPU Architecture:Any

[31 May 2003 6:45] Jens Elkner
Description:
Unfortenately the current Build system does not allow to specify a directory,
where [a recent] openssl is installed, and thus mysql either does not find 
the required files or looks them up in wrong (i.e. unwanted) directories.
So the user does not really have the opportunity, which openssl version
should be used during the build process. 
Furthermore the corresponding macro checks only for libssl.a, which will never
used ...

I made a quick and dirty patch against acinclude.m4, but the best thing (I guess) is, to use similar checks like OpenSSH does (see configure.ac)...

How to repeat:
E.g. Remove all openssl packages and install one in /local/openssl ...

Suggested fix:
--- mysql-4.0.13/acinclude.m4.orig	Wed May 14 22:24:34 2003
+++ mysql-4.0.13/acinclude.m4	Sun May 25 20:06:32 2003
@@ -702,33 +702,37 @@
 ])
 
 AC_DEFUN(MYSQL_FIND_OPENSSL, [
-  for d in /usr/ssl/include /usr/local/ssl/include /usr/include \
-/usr/include/ssl /opt/ssl/include /opt/openssl/include \
-/usr/local/ssl/include /usr/local/include ; do
-   if test -f $d/openssl/ssl.h  ; then
-     OPENSSL_INCLUDE=$d
-   fi
-  done
 
- for d in /usr/ssl/lib /usr/local/ssl/lib /usr/lib/openssl \
-/usr/lib /opt/ssl/lib /opt/openssl/lib /usr/local/lib/ ; do
-  if test -f $d/libssl.a ; then
-    OPENSSL_LIB=$d
+	# the following stuff is wishy-washy, i.e. more a guess than a test,
+	# since for dyn. linking one does not need static libs and vs. versa.
+	# However, static linking is not supported, so we check for libssl.so ...
+	if test -z "$openssl" -o "$openssl" = "yes"
+	then
+		# --with-openssl
+		for d in /usr/openssl /opt/openssl /usr/local/openssl \
+  			/usr/ssl /opt/ssl /usr/local/ssl \
+			/usr /usr/local
+		do
+			# -f is not suitable, since required files might be links ...
+   			if test -r $d/include/openssl/ssl.h -a -r $d/lib/libssl.so
+			then
+     			OPENSSL_DIR=$d
+				break
   fi
  done
-
- if test -z "$OPENSSL_LIB" -o -z "$OPENSSL_INCLUDE" ; then
-   echo "Could not find an installation of OpenSSL"
-   if test -n "$OPENSSL_LIB" ; then
-    if test "$IS_LINUX" = "true"; then
-      echo "Looks like you've forgotted to install OpenSSL development RPM"
-    fi
+	else
+		# --with-openssl=dir
+		if test -r "$openssl"/include/openssl/ssl.h \
+			-a -r "$openssl"/lib/libssl.so
+		then
+				OPENSSL_DIR="$openssl"
    fi
-  exit 1
  fi
 
 ])
 
+# this check is still bogus and should be replaced by a better version
+# e.g. have a look at openssh's configure.ac
 AC_DEFUN(MYSQL_CHECK_OPENSSL, [
 AC_MSG_CHECKING(for OpenSSL)
   AC_ARG_WITH([openssl],
@@ -738,20 +742,22 @@
 
   openssl_libs=""
   openssl_includes=""
-  if test "$openssl" = "yes"
+  if test "$openssl" = "no"
   then
+	AC_MSG_RESULT(skipped.)
+  else
     MYSQL_FIND_OPENSSL
+	if test -n "$OPENSSL_DIR" ; then
     #force VIO use
     vio_dir="vio"
     vio_libs="../vio/libvio.la"
     AC_DEFINE(HAVE_VIO)
-    AC_MSG_RESULT(yes)
-    openssl_libs="-L$OPENSSL_LIB -lssl -lcrypto"
+    	openssl_libs="-L$OPENSSL_DIR/lib -lssl -lcrypto"
     # Don't set openssl_includes to /usr/include as this gives us a lot of
     # compiler warnings when using gcc 3.x
-    if test "$OPENSSL_INCLUDE" != "/usr/include"
+    	if test "$OPENSSL_DIR" != "/usr"
     then
-	openssl_includes="-I$OPENSSL_INCLUDE"
+			openssl_includes="-I$OPENSSL_DIR/include"
     fi
     AC_DEFINE(HAVE_OPENSSL)
 
@@ -762,12 +768,15 @@
     case "$CLIENT_EXTRA_LDFLAGS $MYSQLD_EXTRA_LDFLAGS" in
 	*-all-static*) using_static="yes" ;;
     esac
-    if test $using_static = "yes"
+    	if test "$using_static" = "yes"
     then
-      echo "You can't use the --all-static link option when using openssl."
+      		AC_MSG_ERROR([You can't use the --all-static link option when using openssl.])
       exit 1
     fi
+		AC_MSG_RESULT(yes)
+	else
     AC_MSG_RESULT(no)
+	fi
   fi
   NON_THREADED_CLIENT_LIBS="$NON_THREADED_CLIENT_LIBS $openssl_libs"
   AC_SUBST(openssl_libs)
[11 Jun 2003 6:56] Lenz Grimmer
Thanks for the patch! 
 
Gluh, could you please take a look at this? Thank you.
[22 Jul 2003 3:10] Sergei Glukhov
ChangeSet
  1.1540 03/07/22 15:04:37