1 # Process this file with autoconf to produce a configure script.
2 AC_INIT(psqlodbc, 08.02.0400, [pgsql-odbc@postgresql.org])
5 AC_CONFIG_SRCDIR([bind.cc])
6 AM_CONFIG_HEADER([config.h])
12 # Decide which unixODBC driver manager to use
14 AC_ARG_WITH(unixodbc, [ --with-unixodbc=DIR odbc-config installation of unixODBC(default)],
16 if test "$withval" != no
18 if test "$withval" = yes;then
23 if test ! -f "${ODBC_HOME}/bin/odbc_config"
25 if test ! -f "${ODBC_HOME}/local/bin/odbc_config"
27 if test ! -f "${ODBC_HOME}"
29 AC_MSG_ERROR([odbc_config not find unixODBC installation in ${withval}])
31 ODBC_CONFIG=${ODBC_HOME}
34 ODBC_CONFIG=${ODBC_HOME}/local/bin/odbc_config
37 ODBC_CONFIG=${ODBC_HOME}/bin/odbc_config
41 if test ! -f "${ODBC_HOME}/bin/odbc_config"
43 if test ! -f "${ODBC_HOME}/local/bin/odbc_config"
45 if test ! -f "${ODBC_HOME}/odbc_config"
47 AC_MSG_ERROR([you must specify a valid unixODBC installation with --with-unixodbc=DIR])
49 ODBC_CONFIG=${ODBC_HOME}/odbc_config
52 ODBC_CONFIG=${ODBC_HOME}/local/bin/odbc_config
55 ODBC_CONFIG=${ODBC_HOME}/bin/odbc_config
58 AC_DEFINE(WITH_UNIXODBC, 1,
59 [Define to 1 to build with unixODBC support])
61 ],[with_unixodbc=yes])
64 # Decide which iODBC driver manager to use
66 AC_ARG_WITH(iodbc, [ --with-iodbc=DIR iodbc-config installation of iODBC],
68 if test "$withval" != no
70 if test "$withval" = yes;then
75 if test ! -f "${ODBC_HOME}/bin/iodbc-config"
77 if test ! -f "${ODBC_HOME}/local/bin/iodbc-config"
79 if test ! -f "${ODBC_HOME}"
81 AC_MSG_ERROR([iodbc-config not find iODBC installation in ${withval}])
83 ODBC_CONFIG=${ODBC_HOME}
86 ODBC_CONFIG=${ODBC_HOME}/local/bin/iodbc-config
89 ODBC_CONFIG=${ODBC_HOME}/bin/iodbc-config
93 if test ! -f "${ODBC_HOME}/bin/iodbc-config"
95 if test ! -f "${ODBC_HOME}/local/bin/iodbc-config"
97 if test ! -f "${ODBC_HOME}/iodbc-config"
99 AC_MSG_ERROR([you must specify a valid iODBC installation with --with-iodbc=DIR])
101 ODBC_CONFIG=${ODBC_HOME}/iodbc-config
104 ODBC_CONFIG=${ODBC_HOME}/local/bin/iodbc-config
107 ODBC_CONFIG=${ODBC_HOME}/bin/iodbc-config
110 AC_DEFINE(WITH_IODBC, 1,
111 [Define to 1 to build with iODBC support])
116 # Default odbc version number (--with-odbcver), default 0x0351
119 [ --with-odbcver=VERSION change default ODBC version number [[0x0351]]],
120 [if test "$withval" != no;then
127 AC_DEFINE_UNQUOTED(ODBCVER, $ODBC_VER,
128 [Define to ODBC version (--with-odbcver)])
130 # odbc include and library
132 if test "$ODBC_CONFIG" != "";then
133 if test "$with_iodbc" = yes;then
134 ODBC_INCLUDE=`${ODBC_CONFIG} --cflags`
135 CPPFLAGS="$CPPFLAGS ${ODBC_INCLUDE}"
136 ODBC_LIBS=`${ODBC_CONFIG} --libs`
137 LIBS="$LIBS ${ODBC_LIBS}"
139 ODBC_INCLUDE=`${ODBC_CONFIG} --include-prefix`
140 CPPFLAGS="$CPPFLAGS -I${ODBC_INCLUDE}"
141 ODBC_LIBS=`${ODBC_CONFIG} --libs`
142 LIBS="$LIBS ${ODBC_LIBS}"
144 AC_MSG_CHECKING($ODBC_CONFIG $CPPFLAGS $LIBS)
149 if test "$with_iodbc" = yes; then
151 AC_DEFINE(WITH_IODBC, 1, [Define to 1 to build with iODBC support])
152 AC_SEARCH_LIBS(SQLGetPrivateProfileString, iodbcinst, ,
153 AC_MSG_ERROR("no iODBC Library found"))
156 if test "$with_unixodbc" = yes; then
157 AC_DEFINE(WITH_UNIXODBC, 1,
158 [Define to 1 to build with unixODBC support])
159 AC_DEFINE(SQL_WCHART_CONVERT, [],
160 [Define to use wchar_t as SQLWCHAR in unixODBC])
161 AC_SEARCH_LIBS(SQLGetPrivateProfileString, odbcinst, ,
162 AC_MSG_ERROR("no unixODBC Library found"))
168 AC_ARG_ENABLE(unicode,
169 [ --disable-unicode unicode support (default enable).],
170 [enable_unicode="$enableval"],
171 [enable_unicode="yes"])
173 if test $enable_unicode = yes; then
174 AM_CONDITIONAL(enable_unicode, [test x$enable_unicode = xyes])
175 AC_DEFINE(UNICODE_SUPPORT, 1,
176 [build with Unicode support])
177 AC_CHECK_FUNCS(iswascii)
180 AC_CHECK_FUNCS(strtoul strtoll)
183 # compile check the struct addrinfo, if exist define HAVE_STRUCT_ADDRINFO.
185 AC_MSG_CHECKING(for addrinfo)
186 AC_CACHE_VAL(ac_cv_struct_addrinfo,
188 #include <sys/types.h>
191 ac_cv_struct_addrinfo=yes,
192 ac_cv_struct_addrinfo=no))
193 AC_MSG_RESULT($ac_cv_struct_addrinfo)
195 if test $ac_cv_struct_addrinfo = yes; then
196 AC_DEFINE(HAVE_STRUCT_ADDRINFO, [1],
197 [Define to 1 if you have struct addrinfo])
201 # to implement the thread-safe driver
203 AC_ARG_ENABLE(pthread,
204 [ --disable-pthread pthread support (default enable).],
205 [PTHREAD="$enableval"],
208 if test "$PTHREAD" = "yes"; then
209 AC_DEFINE(POSIX_MULTITHREAD_SUPPORT, 1,
210 [Define to 1 to build with pthreads support (--enable-pthreads)])
211 AC_DEFINE(_REENTRANT, 1,
212 [Define _REENTRANT for several plaforms])
213 AC_CHECK_LIB(pthreads, pthread_create, [],
214 [AC_CHECK_LIB(pthread, pthread_create)])
215 AC_CHECK_FUNCS(gmtime_r strtok_r strerror_r pthread_mutexattr_settype)
216 if test x"$ac_cv_func_pthread_mutexattr_settype" = xyes; then
217 AC_TRY_COMPILE([#include <pthread.h>],
218 [ int i = PTHREAD_MUTEX_RECURSIVE;],
219 [AC_DEFINE(PG_RECURSIVE_MUTEXATTR, PTHREAD_MUTEX_RECURSIVE,
220 [Define if you have PTHREAD_MUTEX_RECURSIVE])], [
221 AC_TRY_COMPILE([#include <pthread.h>],
222 [ int i = PTHREAD_MUTEX_RECURSIVE_NP;],
223 [AC_DEFINE(PG_RECURSIVE_MUTEXATTR, PTHREAD_MUTEX_RECURSIVE_NP,
224 [Define if you have PTHREAD_MUTEX_RECURSIVE_NP])])])
228 AC_CHECK_FUNCS(strerror_r)
237 AC_CHECK_HEADERS(locale.h sys/un.h sys/time.h)
239 AC_CHECK_TYPES(ssize_t)
241 # unixODBC wants the following to get sane behavior for ODBCINT64
242 AC_CHECK_SIZEOF(long)
243 AC_CHECK_SIZEOF(void *)
244 AC_CHECK_TYPES(long long)
255 [AC_HELP_STRING([--with-pgconf=pg_config],
256 [specify pg_config with full path when it is not easy to find it.])],
257 [if test "$withval" = yes;then
258 PG_CONFIG="pg_config"
261 fi],[PG_CONFIG="pg_config"])
264 AC_PATH_PROGS(PG_CONFIG_PATH, ${PG_CONFIG},${PG_CONFIG})
266 #xAC_CONFIG_FILES([Makefile])