1 dnl sxe-dbms.m4 -- Database stuff
4 AC_DEFUN([_SXE_CHECK_POSTGRESQL], [dnl
5 ## (re)defines have_postgresql
6 ## defines HAVE_POSTGRESQL
8 ## compute pgsql specific compiler/linker flags
9 PGSQL_CPPFLAGS="-I$pgsql_incdir"
10 PGSQL_LDFLAGS="-L$pgsql_libdir ${pgsql_ldflags}"
11 ## do not add pgsql_libs here, as they concern the server only
14 ## backup values for excursion
16 save_DB_LIBS="$DB_LIBS"
17 save_DB_LDFLAGS="$DB_LDFLAGS"
18 save_DB_CPPFLAGS="$DB_CPPFLAGS"
20 ## prepend temporarily
21 DB_CPPFLAGS="$PGSQL_CPPFLAGS $DB_CPPFLAGS"
22 DB_LDFLAGS="$PGSQL_LDFLAGS $DB_LDFLAGS"
23 DB_LIBS="$PGSQL_LIBS $DB_LIBS"
25 ## add DB_* to corresponding compiler vars temporarily
26 CPPFLAGS="$CPPFLAGS $DB_CPPFLAGS"
27 LDFLAGS="$LDFLAGS $DB_LDFLAGS $DB_LIBS"
29 ## check for necessary header
30 AC_CHECK_HEADERS([libpq-fe.h])
32 ## check for necessary functions
33 AC_CHECK_LIB([pq], [PQconnectdb])
34 AC_CHECK_LIB([pq], [PQconnectStart])
35 AC_CHECK_FUNC(PQserverVersion,
36 [have_PQserverVersion=yes
37 AC_DEFINE([HAVE_PQSERVERVERSION], [1],
38 [Defined when PQserverVersion() is available])],
39 [have_PQserverVersion=no])
42 if test "$ac_cv_header_libpq_fe_h" = "yes"; then
43 libpq_fe_h_file="$pgsql_incdir/libpq-fe.h"
44 AC_DEFINE_UNQUOTED([LIBPQ_FE_H_FILE], ["libpq-fe.h"],
45 [name of the main libpq interface header file])
47 if test "$ac_cv_lib_pq_PQconnectStart" = "yes"; then
48 have_postgresqlv7="yes"
49 AC_DEFINE([HAVE_POSTGRESQLV7], [1], [Description here!])
53 if test "$ac_cv_header_libpq_fe_h" = "yes" -a \
54 "$ac_cv_lib_pq_PQconnectdb" = "yes"; then
56 AC_DEFINE([HAVE_POSTGRESQL], [1], [Description here!])
60 ## restore all values of the DB_* vars
61 DB_LIBS="$save_DB_LIBS"
62 DB_LDFLAGS="$save_DB_LDFLAGS"
63 DB_CPPFLAGS="$save_DB_CPPFLAGS"
65 ## restore our global compiler state
68 ])dnl _SXE_CHECK_POSTGRESQL
70 AC_DEFUN([SXE_CHECK_POSTGRESQL], [dnl
71 AC_MSG_CHECKING([for PostgreSQL])
73 AC_CHECK_PROG([have_pg_config], [pg_config], [yes], [no])
75 if test "$have_pg_config" = "yes"; then
76 AC_PATH_PROG([PG_CONFIG], [pg_config], [:])
77 pgsql_incdir=$(${PG_CONFIG} --includedir)
78 pgsql_libdir=$(${PG_CONFIG} --libdir)
79 pgsql_ldflags=$(${PG_CONFIG} --ldflags)
81 if test -n "${PG_CONFIG}" -a -f "${PG_CONFIG}"; then
82 pgsql_libs="$(${PG_CONFIG} --libs)"
83 elif test -f "${pgsql_libdir}/libpq.so"; then
84 pgsql_libs=$(${LDD} ${pgsql_libdir}/libpq.so | \
85 grep "=> /" | grep -v "=> /lib" | \
86 sed -e "s,.*/lib\(.*\)\.so.*,-l\1," | \
89 ## doesnt matter otherwise
92 if test "$have_openssl" = "no" -a -n "$(echo ${pgsql_libs} | grep ssl)"; then
93 if test "$with_openssl" = "no"; then
94 AC_MSG_WARN([Your PostgreSQL seems to require OpenSSL.])
95 AC_MSG_WARN([Sadly OpenSSL is not available or is misconfigured,])
96 AC_MSG_WARN([and '--with-openssl=no' was passed. Disabling PostgreSQL])
99 AC_MSG_WARN([Your PostgreSQL seems to require OpenSSL.])
100 AC_MSG_WARN([Sadly OpenSSL is not available or is misconfigured.])
101 AC_MSG_WARN([Performing the actual check anyway, cross your fingers!])
102 AC_MSG_WARN([If you still encounter problems disable using '--with-postgresql=no'.])
103 AC_MSG_WARN([NOTE: '--with-openssl=no' will also implictly disable PostgreSQL in this configuration.])
107 AC_MSG_WARN([Unable to find pg_config, if you want PostgreSQL support])
108 AC_MSG_WARN([in SXEmacs, check your PATH environment variable])
109 AC_MSG_WARN([Performing the actual check anyway, cross your fingers!])
111 if test "$have_postgresql" != "no"; then
112 _SXE_CHECK_POSTGRESQL
114 if test "$have_postgresql" = "yes"; then
115 SXE_ADD_DB_OBJS([postgresql.o])
116 AC_SUBST([DB_CPPFLAGS])
117 AC_SUBST([DB_LDFLAGS])
120 AC_MSG_WARN([Your PostgreSQL installation seems broken or is too old.])
122 ])dnl SXE_CHECK_POSTGRESQL
125 AC_DEFUN([SXE_CHECK_LDAP], [dnl
126 AC_MSG_CHECKING([for LDAP])
130 AC_CHECK_HEADER(ldap.h, [], [have_ldap=no])
131 AC_CHECK_HEADER(lber.h, [], [have_ldap=no])
132 AC_CHECK_LIB(ldap, [ldap_search], [have_ldap=yes])
133 dnl Check for other libraries we need to link with to get the main routines.
134 if test "$have_ldap" != "yes"; then
135 AC_CHECK_LIB(ldap, [ldap_open], [
137 have_ldap_lber=yes], [], [-llber])
139 if test "$habe_ldap" != "yes"; then
140 AC_CHECK_LIB(ldap, [ldap_open], [
143 have_ldap_krb=yes], [], [-llber -lkrb])
145 if test "$have_ldap" != "yes"; then
146 AC_CHECK_LIB(ldap, [ldap_open], [
150 have_ldap_des=yes], [], [-llber -lkrb -ldes])
152 dnl Recently, we need -lber even though the main routines are elsewhere,
153 dnl because otherwise be get link errors w.r.t. ber_pvt_opt_on. So just
154 dnl check for that (it's a variable not a fun but that doesn't seem to
155 dnl matter in these checks) and stick in -lber if so. Can't hurt (even to
156 dnl stick it in always shouldn't hurt, I don't think) ... #### Someone who
157 dnl #### understands LDAP needs to fix this properly.
158 if test "$have_ldap_lber" != "yes"; then
159 AC_CHECK_LIB(lber, [ber_pvt_opt_on], [have_ldap_lber=yes])
164 AC_DEFUN([SXE_CHECK_NDBM], [dnl
165 SXE_CHECK_HEADERS([ndbm.h])
166 if test "$ac_cv_header_ndbm_h" = "yes"; then
167 sxe_cv_feat_ndbm="yes"
169 sxe_cv_feat_ndbm="no"
173 AC_DEFUN([SXE_CHECK_GDBM], [dnl
174 AC_REQUIRE([SXE_CHECK_NDBM])
176 if test "$sxe_cv_feat_ndbm" = "yes"; then
177 AC_CHECK_LIB([gdbm], [dbm_open])
178 AC_CHECK_LIB([gdbm_compat], [dbm_open], [:], [:], [-lgdbm])
180 if test "$ac_cv_lib_gdbm_dbm_open" = "yes"; then
181 sxe_cv_feat_gdbm="yes"
183 elif test "$ac_cv_lib_gdbm_compat_dbm_open" = "yes"; then
184 sxe_cv_feat_gdbm="yes"
185 libdbm="-lgdbm_compat -lgdbm"
187 sxe_cv_feat_gdbm="no"
192 AC_DEFUN([SXE_CHECK_DBM], [dnl
193 AC_REQUIRE([SXE_CHECK_NDBM])
195 if test "$sxe_cv_feat_ndbm" = "yes"; then
196 AC_CHECK_LIB([dbm], [dbm_open])
198 if test "$ac_cv_lib_dbm_dbm_open" = "yes"; then
199 sxe_cv_feat_dbm="yes"
207 AC_DEFUN([SXE_CHECK_BERKDB], [dnl
208 SXE_MSG_CHECKING([for BerkeleyDB header file])
210 for header in "db/db.h" "db.h"; do
211 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
213 #if !(defined __GLIBC__ && __GLIBC_MINOR__ >= 1)
214 #ifdef HAVE_INTTYPES_H
215 #define __BIT_TYPES_DEFINED__
216 #include <inttypes.h>
217 typedef uint8_t u_int8_t;
218 typedef uint16_t u_int16_t;
219 typedef uint32_t u_int32_t;
220 #ifdef WE_DONT_NEED_QUADS
221 typedef uint64_t u_int64_t;
226 ]])], [db_h_file="$header"; break])
229 if test -z "$db_h_file"; then
231 sxe_cv_feat_berkdb="no"
233 SXE_MSG_RESULT([$db_h_file])
234 sxe_cv_feat_berkdb="yes"
237 SXE_MSG_CHECKING([for Berkeley DB version])
238 AC_EGREP_CPP([yes], [
239 #include <$db_h_file>
240 #if DB_VERSION_MAJOR > 1
243 ], [AC_EGREP_CPP([yes], [
244 #include <$db_h_file>
245 #if DB_VERSION_MAJOR > 2
248 ], [AC_EGREP_CPP([yes], [
249 #include <$db_h_file>
250 #if DB_VERSION_MAJOR > 3
266 AC_CHECK_FUNC([$dbfunc], [
267 sxe_cv_feat_berkdb="yes"
269 AC_CHECK_LIB([db], [$dbfunc], [
270 sxe_cv_feat_berkdb="yes"
273 dnl Berk db 4.1 decorates public functions with version information
274 if test "$sxe_cv_feat_berkdb" != "yes" -a "$dbver" = "4"; then
276 echo "#include <$db_h_file>" > $tempcname
277 echo "configure___ dbfunc=db_create" >> $tempcname
279 eval $($CPP -Isrc $tempcname \
280 | sed -n -e "s/[[ TAB]]*=[[ TAB\"]]*/='/" \
281 -e "s/[[ TAB\"]]*\$/'/" -e "s/^configure___//p")
283 AC_MSG_WARN([db_create is really $dbfunc])
284 AC_CHECK_LIB([db], [$dbfunc], [
285 sxe_cv_feat_berkdb="yes"
289 if test "$sxe_cv_feat_berkdb" = "yes"; then
290 if test -n "$db_h_file"; then
291 AC_DEFINE_UNQUOTED([DB_H_FILE],
292 ["$db_h_file"], [Description here!])
294 AC_DEFINE([HAVE_BERKELEY_DB], [1], [Description here!])
295 if test "$need_libdb" = "yes"; then
296 SXE_PREPEND([-ldb], [DB_LIBS])
299 sxe_cv_feat_berkdb="no"
301 if test "$sxe_cv_feat_berkdb" = "yes"; then
302 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
305 int type = DB_UNKNOWN;
308 ]])], [have_db_unknown="yes"])
309 if test "$have_db_unknown" = "yes"; then
310 AC_DEFINE_UNQUOTED([HAVE_DB_UNKNOWN], [1],
311 [Berkley DB has DB_UNKNOWN type])
314 ])dnl SXE_CHECK_BERKDB
316 AC_DEFUN([SXE_CHECK_NDBM_BERKDB_CONFLICT], [dnl
317 SXE_MSG_CHECKING([whether ndbm and berkdb can coexist])
319 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
329 [sxe_cv_db_ndbm_berkdb_conflict="no"],
330 [sxe_cv_db_ndbm_berkdb_conflict="yes"])
332 if test "$sxe_cv_db_ndbm_berkdb_conflict" = "no"; then
333 SXE_MSG_RESULT([yes])
336 AC_MSG_WARN([disabling (g)dbm support again])
339 ])dnl SXE_CHECK_NDBM_BERKDB_CONFLICT
341 dnl sxe-dbms.m4 ends here