From ae24848e4dfdbda5dbfdbab3a82c6c0fa7e28229 Mon Sep 17 00:00:00 2001 From: Marco van Wieringen Date: Sat, 29 Oct 2011 23:55:35 +0200 Subject: [PATCH] Fix detection of batch insert enabler functions. -R is not supported when not run through libtool. For linking the database backend this is no problem as that is done with libtool but for detection of things like PQisthreadsafe, PQputCopyData etc from configure this doesn't work. So we work around that problem using a special LFLAGS variable which is only used in configure and which is not used outside configure. --- bacula/autoconf/bacula-macros/db.m4 | 15 +++++++++++---- bacula/autoconf/configure.in | 18 ++++++++++++++++-- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/bacula/autoconf/bacula-macros/db.m4 b/bacula/autoconf/bacula-macros/db.m4 index debb3c8685..ee24d68d79 100644 --- a/bacula/autoconf/bacula-macros/db.m4 +++ b/bacula/autoconf/bacula-macros/db.m4 @@ -392,6 +392,7 @@ AC_HELP_STRING([--with-mysql@<:@=DIR@:>@], [Include MySQL support. DIR is the My if test -f $MYSQL_LIBDIR/libmysqlclient_r.a \ -o -f $MYSQL_LIBDIR/libmysqlclient_r.so; then MYSQL_LIBS="-R $MYSQL_LIBDIR -L$MYSQL_LIBDIR -lmysqlclient_r -lz" + MYSQL_LFLAGS="-L$MYSQL_LIBDIR -lmysqlclient_r -lz" AC_DEFINE(HAVE_THREAD_SAFE_MYSQL, 1, [Set if Thread Safe MySQL can be checked using mysql_thread_safe]) DB_LIBS="${DB_LIBS} ${MYSQL_LIBS}" fi @@ -413,9 +414,11 @@ AC_HELP_STRING([--with-mysql@<:@=DIR@:>@], [Include MySQL support. DIR is the My else AC_MSG_RESULT(no) fi -] -) +],[ + AC_MSG_RESULT(no) +]) +AC_MSG_CHECKING(for MySQL embedded support) AC_ARG_WITH(embedded-mysql, AC_HELP_STRING([--with-embedded-mysql@<:@=DIR@:>@], [Include MySQL support. DIR is the MySQL base install directory, default is to search through a number of common places for the MySQL files.]), [ @@ -489,6 +492,7 @@ AC_HELP_STRING([--with-embedded-mysql@<:@=DIR@:>@], [Include MySQL support. DIR fi MYSQL_INCLUDE=-I$MYSQL_INCDIR MYSQL_LIBS="-R $MYSQL_LIBDIR -L$MYSQL_LIBDIR -lmysqld -lz -lm -lcrypt" + MYSQL_LFLAGS="-L$MYSQL_LIBDIR -lmysqld -lz -lm -lcrypt" MYSQL_LIB=$MYSQL_LIBDIR/libmysqld.a DB_LIBS="${DB_LIBS} ${MYSQL_LIBS}" @@ -509,8 +513,9 @@ AC_HELP_STRING([--with-embedded-mysql@<:@=DIR@:>@], [Include MySQL support. DIR else AC_MSG_RESULT(no) fi -] -) +],[ + AC_MSG_RESULT(no) +]) AC_SUBST(MYSQL_LIBS) AC_SUBST(MYSQL_INCLUDE) @@ -632,6 +637,7 @@ AC_HELP_STRING([--with-sqlite3@<:@=DIR@:>@], [Include SQLite3 support. DIR is th fi SQLITE_INCLUDE=-I$SQLITE_INCDIR SQLITE_LIBS="-R $SQLITE_LIBDIR -L$SQLITE_LIBDIR -lsqlite3" + SQLITE_LFLAGS="-L$SQLITE_LIBDIR -lsqlite3" SQLITE_LIB=$SQLITE_LIBDIR/libsqlite3.a DB_LIBS="${DB_LIBS} ${SQLITE_LIBS}" @@ -732,6 +738,7 @@ AC_HELP_STRING([--with-postgresql@<:@=DIR@:>@], [Include PostgreSQL support. DIR POSTGRESQL_INCLUDE=-I$POSTGRESQL_INCDIR POSTGRESQL_LIBS="-R $POSTGRESQL_LIBDIR -L$POSTGRESQL_LIBDIR -lpq" AC_CHECK_FUNC(crypt, , AC_CHECK_LIB(crypt, crypt, [POSTGRESQL_LIBS="$POSTGRESQL_LIBS -lcrypt"])) + POSTGRESQL_LFLAGS=`echo ${POSTGRESQL_LIBS} | sed -e "s#-R $POSTGRESQL_LIBDIR##"` POSTGRESQL_LIB=$POSTGRESQL_LIBDIR/libpq.a DB_LIBS="${DB_LIBS} ${POSTGRESQL_LIBS}" diff --git a/bacula/autoconf/configure.in b/bacula/autoconf/configure.in index 8b19d5242b..7c67158c7c 100644 --- a/bacula/autoconf/configure.in +++ b/bacula/autoconf/configure.in @@ -1814,14 +1814,28 @@ dnl ------------------------------------------- dnl Check if mysql supports batch mode dnl ------------------------------------------- if test ! -z "$MYSQL_LIB"; then - AC_CHECK_LIB(mysql_r, mysql_thread_safe, AC_DEFINE(HAVE_MYSQL_THREAD_SAFE, 1, [Set if have mysql_thread_safe])) + dnl For mysql checking + saved_LIBS="${LIBS}" + LIBS="${saved_LIBS} ${MYSQL_LFLAGS}" + + AC_CHECK_LIB(mysqlclient_r, mysql_thread_safe, AC_DEFINE(HAVE_MYSQL_THREAD_SAFE, 1, [Set if have mysql_thread_safe])) + + dnl Revert after mysql checks + LIBS="${saved_LIBS}" fi dnl ------------------------------------------- dnl Check if sqlite supports batch mode dnl ------------------------------------------- if test ! -z "SQLITE_LIB"; then + dnl For sqlite checking + saved_LIBS="${LIBS}" + LIBS="${saved_LIBS} ${SQLITE_LFLAGS}" + AC_CHECK_LIB(sqlite3, sqlite3_threadsafe, AC_DEFINE(HAVE_SQLITE3_THREADSAFE, 1, [Set if have sqlite3_threadsafe])) + + dnl Revert after sqlite checks + LIBS="${saved_LIBS}" fi dnl ------------------------------------------- @@ -1830,7 +1844,7 @@ dnl ------------------------------------------- if test ! -z "$POSTGRESQL_LIB"; then dnl For postgresql checking saved_LIBS="${LIBS}" - LIBS="${saved_LIBS} ${POSTGRESQL_LIB}" + LIBS="${saved_LIBS} ${POSTGRESQL_LFLAGS}" AC_CHECK_LIB(pq, PQisthreadsafe, AC_DEFINE(HAVE_PQISTHREADSAFE, 1, [Set if have PQisthreadsafe])) AC_CHECK_LIB(pq, PQputCopyData, AC_DEFINE(HAVE_PQ_COPY, 1, [Set if have PQputCopyData])) -- 2.39.5