There is apparently a bug in autoconf: when calling AC_CHECK_LIB, it uses -l and -L in 
the wrong order. It does not disturb gcc or Tru64's cc, but it fails with Sun's cc.

With the configure.in attached, this fails:

./configure --with-ssl=$HOME

with the following config.log:

configure:795: cc -o conftest -g  -I/home/bortz/include  conftest.c -lssl -lcrypto
  -L/home/bortz/lib 1>&5
ld: fatal: library -lssl: not found
ld: fatal: library -lcrypto: not found

Because -L was put too late. If I run cc by hand with the right order, SSL is detected.

Indeed, the fault seems to be in acgeneral.m4, when defining AC_CHECK_LIB:

LIBS="-l$1 $5 $LIBS"

IMHO, it should be:

LIBS="$LIBS -l$1 $5"


%  autoconf --version
Autoconf version 2.13
(Debian 2.2 package)


AC_INIT(foo.c)

AC_ARG_WITH(ssl,
 [--with-ssl[=DIR]   SSL crypt support (needs OpenSSL)],dnl
 [if test "$withval" != "no"; then
   AC_DEFINE(OPENSSL)
   OPENSSL=1
   if test "$withval" != "yes"; then
        SSLROOT=$withval
        LIBS="${LIBS} -L$SSLROOT/lib"
        CPPFLAGS="${CPPFLAGS} -I$SSLROOT/include"  
   fi
 fi],
 dnl Default: disable it
)

AC_PROG_CC

# Check OpenSSL
AC_DEFUN([CF_LIB_OPENSSL],
[
AC_CHECK_LIB(ssl,SSL_CTX_new,
[LIBS="${LIBS} -lssl -lcrypto"],
[AC_ERROR([Get the OpenSSL library (http://www.openssl.org/)])], dnl
-lcrypto
)])

if test "$OPENSSL" = "1"; then
CF_LIB_OPENSSL
fi

AC_OUTPUT(Makefile)


Reply via email to