views:

23

answers:

0

Hi,

I've autoconfiscated a project that link against libresolv and libtpthread, and optionally against ssl, mysqlclient and pq. I am working on Fedora 13 (i686).

I've found a macro AX_EXT_HAVE_LIB (http://www.gnu.org/software/autoconf-archive/ax_ext_have_lib.html) that "is identical to AC_SEARCH_LIBS with the exception that will add -L when looking, and use a different variable for each directory. " It seems great for me!

The problem is that at the end only take the last library found, in my case "pq".

It seems that macro override the earlier value of "LIBS" variable.

I've read autoconf documentation and examined the configure script but it's a bit tricky.

I've tried modifying macro, replacing the final LIBS="$new_libs" por LIBS="$new_libs $LIBS"

But now LIBS ends as: '-lpq -lmysqlclient -lssl -lpthread -lresolv -lssl -lpthread -lresolv '

It seems harmless but it's too ugly, isn't it? Please could you help me to get the correct value of LIBS variable. I know that I can get it with AC_SEARCH_LIBS but this macro lacks the hability to search on given libdirs

The autoconf is as follows:

AC_PREREQ([2.59])
AC_INIT([UpTools],[8.5.3],[[email protected]],[UpTools])
AM_INIT_AUTOMAKE([foreign -Wall -Werror])
LT_PREREQ([2.2])
LT_INIT([dlopen])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_SRCDIR([UpConf.cc])
AC_CONFIG_HEADERS([config.h])
AC_PREFIX_DEFAULT(/usr)
AC_PROG_CXX
AX_EXT_HAVE_LIB([/lib64 /lib /usr/lib64 /usr/lib64 /usr/lib
/usr/local/lib64 /usr/local/lib],resolv,inet_net_pton)
AS_ECHO($LIBS)
AX_EXT_HAVE_LIB([/lib64 /lib /usr/lib64 /usr/lib64 /usr/lib
/usr/local/lib64 /usr/local/lib],pthread,pthread_create)
AC_ARG_WITH([ssl],
           [AS_HELP_STRING([--with-ssl],
             [enable support for ssl @<:@default=check@:>@])],
           [],
           [with_ssl=check])
AS_IF([test "x$with_ssl" != xno],[AX_EXT_HAVE_LIB(/lib64 /lib
/usr/lib64 /usr/lib /usr/local/lib64 /usr/local/lib
/usr/local/lib64/ssl /usr/lib/ssl , ssl, SSL_library_init)],
[if test "x$with_ssl" != xcheck -a "x$ext_lib_found" = xno
then AC_MSG_FAILURE([ssl test failed (--without-ssl to disable)])
fi
])
if test x"$ext_lib_found" = xyes
       then found_ssl=yes
fi
AC_ARG_WITH([mysql],
           [AS_HELP_STRING([--with-mysql],
             [enable support for mysql @<:@default=check@:>@])],
           [],
           [with_mysql=check])
AS_IF([test "x$with_mysql" != xno],[AX_EXT_HAVE_LIB(/lib64 /lib
/usr/lib64 /usr/lib /usr/local/lib64 /usr/local/lib
/usr/local/lib64/mysql /usr/lib/mysql , mysqlclient, mysql_close)],
[if test "x$with_mysql" != xcheck -a "x$ext_lib_found" = xno
then AC_MSG_FAILURE([mysql test failed (--without-mysql to disable)])
fi
])
if test x"$ext_lib_found" = xyes
       then found_mysql=yes
fi
AC_ARG_WITH([postgresql],
           [AS_HELP_STRING([--with-postgresql],
             [enable support for mysql @<:@default=check@:>@])],
           [],
           [with_postgresql=check])
AS_IF([test "x$with_postgresql" != xno],[AX_EXT_HAVE_LIB(/lib64 /lib
/usr/lib64 /usr/lib /usr/local/lib64 /usr/local/lib
/usr/local/lib64/postgresql /usr/lib/postgresql , pq, PQfinish)],
[if test "x$with_postgresql" != xcheck -a "x$ext_lib_found" = xno
then AC_MSG_FAILURE([postgresql test failed (--without-postgresql to disable)])
fi
])
if test x"$ext_lib_found" = xyes
       then found_postgresql=yes
fi
AC_HEADER_RESOLV
if test "x${found_ssl}" = xyes
       then AC_CHECK_HEADERS([openssl/ssl.h yassl/ssl.h], [break])
       if test x"$ac_cv_header_openssl_ssl_h" != xyes -a
x"$ac_cv_header_yassl_ssl_h" != xyes
               then AC_MSG_FAILURE([ssl headers not found or not usable])
               else ssl=true
       fi
       else ssl=false
fi
if test "x$want_mysql" != xno -a "x$found_mysql" != xno
       then AC_CHECK_HEADERS([mysql/mysql.h mysql.h], [break])
       if test x"$ac_cv_header_mysql_mysql_h" != xyes -a
x"$ac_cv_header_mysql_h" != xyes
               then AC_MSG_FAILURE([MySQL headers not found or not usable])
               else mysql=true
       fi
       else mysql=false
fi
if test x"${found_pq}" = xyes
       then AC_CHECK_HEADERS([postgresql/libpq-fe.h libpq-fe.h], [break])
       if test x"$ac_cv_header_postgresql_libpq_fe_h" != xyes -a
x"$ac_cv_header_libpq_fe_h" != xyes
               then AC_MSG_FAILURE([PostgreSQL headers not found or
not usable])
               else postgresql=true
       fi
       else postgresql=false
fi
AM_CONDITIONAL([ssl], [test x$ssl = xtrue])
AM_CONDITIONAL([mysql], [test x$mysql = xtrue])
AM_CONDITIONAL([postgresql], [test x$postgresql = xtrue])
if test x"$ssl" = xfalse
then
       ss="No. You may enable with --enable-ssl"
else
       ss="Yes"
fi
if test x"$mysql" != xtrue
then
       ms="No. You may enable with --with-mysql"
else
       ms="Yes"
fi
if test x"$postgresql" = xfalse
then
       pq="No. You may enable with --with-postgresql"
else
       pq="Yes"
fi
AC_CHECK_HEADERS([arpa/inet.h fcntl.h netdb.h netinet/in.h stdlib.h
string.h strings.h sys/ioctl.h sys/socket.h sys/time.h syslog.h
unistd.h])
AC_HEADER_STDBOOL
AC_C_INLINE
AC_TYPE_SIZE_T
AC_FUNC_MKTIME
AC_CHECK_FUNCS([gethostbyname localtime_r memmove memset regcomp
select socket strcasecmp strerror strncasecmp])
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
echo \
"-------------------------------------------------
Congratulations! You have created a Makefile for: ${PACKAGE_NAME}
${PACKAGE_VERSION}
Prefix is '${prefix}'.
Compiler is '${CXX}
LIBS are '${LIBS}'
ssl support: '${ss}'
Wanted MySQL: ${want_mysql}
mysql support: ${found_mysql}
postgresql support: '${pq}'
UpTools will be Built on: '${build}'
UpTools will Built for: '${host}'
Now type 'make'  in order to compile
If you want to test your compiling type 'make check'
After compiling, you can install with 'make install'
At the end, you can check your installation with 'make installcheck'
--------------------------------------------------"

EOF