Fixed problem pg_config and use the AC_SEARCH_LIBS.
authorHiroshi Saito <hiroshi@winpg.jp>
Tue, 3 Apr 2007 16:14:05 +0000 (16:14 +0000)
committerHiroshi Saito <hiroshi@winpg.jp>
Tue, 3 Apr 2007 16:14:05 +0000 (16:14 +0000)
configure.ac

index 9dfb326735970fcb4c02bf31f1c22f21bea395e1..0e31cb7d01f0da1dddb15ca7f0a3683b07a46bcb 100644 (file)
@@ -1,57 +1,61 @@
 # Process this file with autoconf to produce a configure script.
-AC_INIT(psqlodbc, 08.02.0204, [pgsql-odbc@postgresql.org])
+AC_INIT(psqlodbc, 08.02.0205, [pgsql-odbc@postgresql.org])
 AC_PREREQ(2.52)
 AM_INIT_AUTOMAKE
 AC_CONFIG_SRCDIR([bind.c])
 AM_CONFIG_HEADER([config.h])
 AM_MAINTAINER_MODE
 
-
 #
 # Decide which ODBC driver manager to use
 #
 PGAC_ARG_BOOL(with, unixodbc, no,
-              [  --with-unixodbc         build ODBC driver for unixODBC (default)],
-              [AC_CHECK_LIB(odbcinst, SQLGetPrivateProfileString, [],
-                            [AC_MSG_ERROR([unixODBC driver manager not found])])])
+   [  --with-unixodbc         build ODBC driver for unixODBC],
+       [AC_CHECK_LIB(odbcinst, SQLGetPrivateProfileString, [],
+       [AC_MSG_ERROR([unixODBC driver manager not found])])])
 
 PGAC_ARG_BOOL(with, iodbc, no,
-              [  --with-iodbc            build ODBC driver for iODBC],
-              [AC_CHECK_LIB(iodbcinst, SQLGetPrivateProfileString, [],
-                            [AC_MSG_ERROR([iODBC driver manager not found])])])
+   [  --with-iodbc            build ODBC driver for iODBC],
+       [AC_CHECK_LIB(iodbcinst, SQLGetPrivateProfileString, [],
+       [AC_MSG_ERROR([iODBC driver manager not found])])])
 
 if test "$with_unixodbc" = yes && test "$with_iodbc" = yes; then
-  AC_MSG_ERROR([ODBC driver cannot be built for both unixODBC and iODBC])
+   AC_MSG_ERROR([ODBC driver cannot be built for both unixODBC and iODBC])
 fi
 
 if test "$with_unixodbc" != yes && test "$with_iodbc" != yes; then
-  AC_CHECK_LIB(odbcinst, SQLGetPrivateProfileString,
-               [with_unixodbc=yes],
-               [AC_CHECK_LIB(iodbcinst, SQLGetPrivateProfileString,
-                             [with_iodbc=yes],
-                             [AC_MSG_ERROR([no suitable ODBC driver manager found])])])
+   AC_CHECK_LIB(odbcinst, SQLGetPrivateProfileString,
+       [with_unixodbc=yes],
+   [AC_CHECK_LIB(iodbcinst, SQLGetPrivateProfileString,
+       [with_iodbc=yes],
+   [AC_MSG_ERROR([no suitable ODBC driver manager found])])])
 fi
 
 if test "$with_unixodbc" = yes; then
-  AC_DEFINE(WITH_UNIXODBC, 1, [Define to 1 to build with unixODBC support])
-  AC_DEFINE(SQL_WCHART_CONVERT, [], [Define to use wchar_t as SQLWCHAR in unixODBC])
-  LIBS="$LIBS -lodbc -lodbcinst"
+   AC_DEFINE(WITH_UNIXODBC, 1, 
+       [Define to 1 to build with unixODBC support])
+   AC_DEFINE(SQL_WCHART_CONVERT, [], 
+       [Define to use wchar_t as SQLWCHAR in unixODBC])
+   AC_SEARCH_LIBS(SQLGetPrivateProfileString, odbcinst, ,
+       AC_MSG_ERROR("no unixODBC Library found"))
 fi
 
 if test "$with_iodbc" = yes; then
-  AC_DEFINE(WITH_IODBC, 1, [Define to 1 to build with iODBC support])
-  LIBS="$LIBS -liodbc -liodbcinst"
+   AC_DEFINE(WITH_IODBC, 1, [Define to 1 to build with iODBC support])
+   AC_SEARCH_LIBS(SQLGetPrivateProfileString, iodbcinst, ,
+       AC_MSG_ERROR("no iODBC Library found"))
 fi
 
 #
 # Default odbc version number (--with-odbcver), default 0x0351
 #
-AC_MSG_CHECKING([for ODBC version number])
-PGAC_ARG_REQ(with, odbcver, [  --with-odbcver=VERSION  change default ODBC version number [[0x0351]]],
-             [],
-             [with_odbcver=0x0351])
+PGAC_ARG_REQ(with, odbcver, 
+   [  --with-odbcver=VERSION  change default ODBC version number [[0x0351]]],
+   [],
+   [with_odbcver=0x0351])
 AC_MSG_RESULT([$with_odbcver])
-AC_DEFINE_UNQUOTED(ODBCVER, [$with_odbcver], [Define to ODBC version (--with-odbcver)])
+AC_DEFINE_UNQUOTED(ODBCVER, [$with_odbcver], 
+   [Define to ODBC version (--with-odbcver)])
 
 # to implement the Unicode driver
 PGAC_ARG_BOOL(enable, unicode, yes,
@@ -63,10 +67,15 @@ PGAC_ARG_BOOL(enable, unicode, yes,
 AM_CONDITIONAL(enable_unicode, [test x"$enable_unicode" = xyes])
 
 AC_CHECK_FUNCS(strtoul strtoll)
-PGAC_STRUCT_ADDRINFO
+
+#
 # If `struct addrinfo' exists, define HAVE_STRUCT_ADDRINFO.
+#
+PGAC_STRUCT_ADDRINFO
 
+#
 # to implement the thread-safe driver
+#
 PGAC_ARG_BOOL(enable, pthreads, no,
     [  --enable-pthreads       build pthread implementation if possible],
     [AC_DEFINE(POSIX_MULTITHREAD_SUPPORT, 1,
@@ -87,38 +96,6 @@ PGAC_ARG_BOOL(enable, pthreads, no,
      PGAC_FUNC_STRERROR_R_INT
     ])
 
-# Need OpenSSL 
-AC_PATH_PROG(PKG_CONFIG, pkg-config)
-PGAC_ARG_BOOL(with, openssl, no,
-   [--with-openssl=PATH       where openssl is installed],
-[if test "x$PKG_CONFIG" = x || test "x$PKG_CONFIG" = "xno" ; then
-   if test x_$with_openssl != x_/usr; then
-       SSLLIBS="-L${with_openssl}/lib"
-       SSLFLAGS="-I${with_openssl}/include"
-   fi
-   SSLLIBS="$SSLLIBS -lssl -lcrypto"
-else
-   SSLLIBS="`$PKG_CONFIG --libs openssl`"
-   SSLFLAGS="`$PKG_CONFIG --cflags openssl`"
-fi
-AC_MSG_RESULT($SSLLIBS)
-LIBS="$LIBS $SSLLIBS"
-AC_MSG_RESULT($SSLFLAGS)
-CPPFLAGS="$SSLFLAGS $CPPFLAGS"
-AC_CHECK_HEADER([openssl/ssl.h],,
-   AC_MSG_ERROR([unable to find openssl header files]))
-AC_MSG_CHECKING(for ERR_load_CRYPTO_string)
-AC_TRY_LINK_FUNC([ERR_load_CRYPTO_strings],,
-   AC_MSG_ERROR([unable to link with openssl libraries]))
-AC_MSG_RESULT(yes)
-AC_MSG_CHECKING(for SSL_library_init)
-AC_TRY_LINK_FUNC([SSL_library_init],, 
-   AC_MSG_ERROR([unable to link with openssl libraries]))
-AC_MSG_RESULT(yes)
-])
-
-#
-
 AC_PROG_CC
 
 AC_LIBTOOL_WIN32_DLL
@@ -140,19 +117,26 @@ AC_C_CONST
 AC_TYPE_SIZE_T
 AC_STRUCT_TM
 
-
 #
 # Find libpq headers and libraries
 #
-AC_PATH_PROGS(PG_CONFIG, pg_config)
+
+PGAC_ARG(with, pgconf,
+   [AC_HELP_STRING([--with-pgconf=pg_config],
+   [specify pg_config with full path when it is not easy to find it.])],
+   [pgconf="pg_config"],[option --without-pgconf does not apply],
+   [pgconf=$withval],[pgconf="pg_config"])
+
+AC_PATH_PROGS(PG_CONFIG, $pgconf)
+
 if test -z "$PG_CONFIG" ; then
-  AC_MSG_ERROR([pg_config not found])
+   AC_MSG_ERROR([pg_config not found])
 fi
+
 pg_includedir=`$PG_CONFIG --includedir`
 pg_libdir=`$PG_CONFIG --libdir`
 CPPFLAGS="$CPPFLAGS -I$pg_includedir"
-LDFLAGS="$LDFLAGS -L$pg_libdir"
-
+LIBS="-L$pg_libdir $LIBS"
 
 AC_CONFIG_FILES([Makefile])
 AC_OUTPUT