1 # Copyright (C) 2005 Internet Systems Consortium, Inc. ("ISC")
3 # Permission to use, copy, modify, and distribute this software for any
4 # purpose with or without fee is hereby granted, provided that the above
5 # copyright notice and this permission notice appear in all copies.
7 # THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
8 # REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
9 # AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
10 # INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
11 # LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
12 # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13 # PERFORMANCE OF THIS SOFTWARE.
16 # Shorthand. Note quoting: DLZ_DRIVER_DIR expanded in Makefile, not here.
18 dlzdir='${DLZ_DRIVER_DIR}'
21 # Private autoconf macro to simplify configuring drivers:
23 # DLZ_ADD_DRIVER(DEFINE, DRIVER, INCLUDES, LIBS)
26 # DEFINE is FOO (to define -DDLZ_FOO)
27 # DRIVER is dlz_foo_driver (sources without the .c)
28 # INCLUDES is any necessary include definitions
29 # LIBS is any necessary library definitions
31 AC_DEFUN(DLZ_ADD_DRIVER, [
32 CONTRIB_DLZ="$CONTRIB_DLZ -DDLZ_$1"
35 DLZ_DRIVER_SRCS="$DLZ_DRIVER_SRCS $dlzdir/$i.c"
36 DLZ_DRIVER_OBJS="$DLZ_DRIVER_OBJS $i.$O"
40 DLZ_DRIVER_INCLUDES="$DLZ_DRIVER_INCLUDES $3"
44 DLZ_DRIVER_LIBS="$DLZ_DRIVER_LIBS $4"
49 # Check for the various DLZ drivers
53 # Was --with-dlz-postgres specified?
56 AC_MSG_CHECKING(for Postgres DLZ driver)
57 AC_ARG_WITH(dlz_postgres,
58 [ --with-dlz-postgres[=PATH] Build with Postgres DLZ driver [yes|no|path].
59 (Required to use Postgres with DLZ)],
60 use_dlz_postgres="$withval", use_dlz_postgres="no")
62 if test "$use_dlz_postgres" != "no"
64 if test "$use_dlz_postgres" != "yes"
66 AC_PATH_PROGS(PG_CONFIG, pg_config, [not found], $use_dlz_postgres/bin)
68 AC_PATH_PROGS(PG_CONFIG, pg_config, [not found])
71 if test "$PG_CONFIG" != "not found"
73 use_dlz_postgres=`$PG_CONFIG --includedir`
74 use_dlz_postgres_lib=`$PG_CONFIG --libdir`
76 pgprefix="$use_dlz_postgres"
77 use_dlz_postgres="$pgprefix/include"
78 use_dlz_postgres_lib="$pgprefix/lib"
82 if test "$use_dlz_postgres" = "yes/include"
84 # User did not specify path and Postgres didn't say - guess it
85 pgdirs="/usr /usr/local /usr/local/pgsql /usr/pkg"
88 if test -f $d/include/libpq-fe.h
90 use_dlz_postgres=$d/include
91 use_dlz_postgres_lib=$d/lib
97 if test "$use_dlz_postgres" = "yes/include"
99 # Still no joy, give up
101 AC_MSG_RESULT(not found)
103 [No pg_config and PostgreSQL was not found in any of $pgdirs; use --with-dlz-postgres=/path or put pg_config in your path])
106 case "$use_dlz_postgres" in
111 DLZ_ADD_DRIVER(POSTGRES, dlz_postgres_driver,
112 [-I$use_dlz_postgres],
113 [-L$use_dlz_postgres_lib -lpq])
116 [using PostgreSQL from $use_dlz_postgres_lib and $use_dlz_postgres])
122 # Was --with-dlz-mysql specified?
125 AC_MSG_CHECKING(for MySQL DLZ driver)
126 AC_ARG_WITH(dlz_mysql,
127 [ --with-dlz-mysql[=PATH] Build with MySQL DLZ driver [yes|no|path].
128 (Required to use MySQL with DLZ)],
129 use_dlz_mysql="$withval", use_dlz_mysql="no")
133 if test "$use_dlz_mysql" = "yes"
135 # User did not specify a path - guess it
136 mysqldirs="/usr /usr/local /usr/local/mysql /usr/pkg"
139 if test -f $d/include/mysql/mysql.h
142 mysql_include=$d/include/mysql
143 if test -d $d/lib/mysql
145 mysql_lib=$d/lib/mysql
150 elif test -f $d/include/mysql.h
153 mysql_include=$d/include
154 if test -d $d/lib/mysql
156 mysql_lib=$d/lib/mysql
163 elif test "$use_dlz_mysql" != "no"
166 if test -f $d/include/mysql/mysql.h
168 mysql_include=$d/include/mysql
169 if test -d $d/lib/mysql
171 mysql_lib=$d/lib/mysql
175 elif test -f $d/include/mysql.h
177 mysql_include=$d/include
178 if test -d $d/lib/mysql
180 mysql_lib=$d/lib/mysql
187 if test "$use_dlz_mysql" = "yes"
189 AC_MSG_RESULT(not found)
191 [MySQL was not found in any of $mysqldirs; use --with-dlz-mysql=/path])
194 case "$use_dlz_mysql" in
199 DLZ_ADD_DRIVER(MYSQL, dlz_mysql_driver,
200 [-I${mysql_include}],
201 [-L${mysql_lib} -lmysqlclient -lz -lcrypt -lm])
204 [using mysql from ${mysql_lib} and ${mysql_include}])
210 # Was --with-dlz-bdb specified?
213 AC_MSG_CHECKING(for Berkeley DB DLZ driver...)
215 [ --with-dlz-bdb[=PATH] Build with Berkeley DB DLZ driver [yes|no|path].
216 (Required to use Berkeley DB with DLZ)],
217 use_dlz_bdb="$withval", use_dlz_bdb="no")
219 case "$use_dlz_bdb" in
224 if test "$use_dlz_bdb" = "yes"
226 # User did not specify a path - guess directories
227 bdbdirs="/usr/local /usr/pkg /usr"
228 elif test -d "$use_dlz_bdb"
230 # User specified directory and it exists
231 bdbdirs="$use_dlz_bdb"
233 AC_MSG_RESULT(not found)
234 AC_MSG_ERROR([path $use_dlz_bdb does not exist])
238 # Use path we were given or guessed. This is insanely
239 # complicated because we have to search for a bunch of
240 # platform-specific variations and have to check
241 # separately for include and library directories.
243 # Set both to yes, so we can check them later
250 # Skip nonexistant directories
256 # Check other locations for includes.
257 # Order is important (sigh).
259 bdb_incdirs="/db53 /db51 /db48 /db47 /db46 /db45 /db44 /db43 /db42 /db41 /db4 /db"
260 # include a blank element first
261 for d in "" $bdb_incdirs
263 if test -f "$dd/include${d}/db.h"
265 dlz_bdb_inc="-I$dd/include${d}"
270 # Give up on this directory if we couldn't
271 # find the include subdir
273 if test "$dlz_bdb_inc" = "yes"
278 # Look for libname other than libdb.so.
279 # Order is important (sigh).
281 bdb_libnames="db53 db-5.3 db51 db-5.1 db48 db-4.8 db47 db-4.7 db46 db-4.6 db45 db-4.5 db44 db-4.4 db43 db-4.3 db42 db-4.2 db41 db-4.1 db"
282 for d in $bdb_libnames
284 if test "$dd" = "/usr"
286 AC_CHECK_LIB($d, db_create, dlz_bdb_libs="-l${d}")
287 if test $dlz_bdb_libs != "yes"
291 elif test -f "$dd/lib/lib${d}.so"
293 dlz_bdb_libs="-L${dd}/lib -l${d}"
298 # If we found both incdir and lib, we're done
299 if test "$dlz_bdb_libs" != "yes"
304 # Otherwise, we're starting over
310 # Done searching, now make sure we got everything.
312 if test "$dlz_bdb_inc" = "yes"
314 AC_MSG_ERROR([could not find Berkeley DB include directory])
317 if test "$dlz_bdb_libs" = "yes"
319 AC_MSG_RESULT(not found)
320 AC_MSG_ERROR([could not find Berkeley DB library])
323 DLZ_ADD_DRIVER(BDB, dlz_bdb_driver dlz_bdbhpt_driver,
324 [$dlz_bdb_inc], [$dlz_bdb_libs])
326 AC_MSG_RESULT([using Berkeley DB: $dlz_bdb_inc $dlz_bdb_libs])
328 AC_CONFIG_FILES([contrib/dlz/bin/dlzbdb/Makefile])
334 # Was --with-dlz-filesystem specified?
337 AC_MSG_CHECKING(for file system DLZ driver)
338 AC_ARG_WITH(dlz_filesystem,
339 [ --with-dlz-filesystem[=PATH] Build with filesystem DLZ driver [yes|no].
340 (Required to use file system driver with DLZ)],
341 use_dlz_filesystem="$withval", use_dlz_filesystem="no")
343 case "$use_dlz_filesystem" in
348 DLZ_ADD_DRIVER(FILESYSTEM, dlz_filesystem_driver)
349 DLZ_SYSTEM_TEST=filesystem
356 # Was --with-dlz-ldap specified?
359 AC_MSG_CHECKING(for LDAP DLZ driver)
360 AC_ARG_WITH(dlz_ldap,
361 [ --with-dlz-ldap[=PATH] Build with LDAP DLZ driver [yes|no|path].
362 (Required to use LDAP with DLZ)],
363 use_dlz_ldap="$withval", use_dlz_ldap="no")
365 if test "$use_dlz_ldap" = "yes"
367 # User did not specify a path - guess it
368 ldapdirs="/usr /usr/local /usr/pkg"
371 if test -f $d/include/ldap.h
379 if test "$use_dlz_ldap" = "yes"
381 AC_MSG_RESULT(not found)
383 [LDAP headers were not found in any of $ldapdirs; use --with-dlz-ldap=/path])
386 case "$use_dlz_ldap" in
391 DLZ_ADD_DRIVER(LDAP, dlz_ldap_driver,
392 [-I$use_dlz_ldap/include],
393 [-L$use_dlz_ldap/lib -lldap -llber])
396 [using LDAP from $use_dlz_ldap/lib and $use_dlz_ldap/include])
402 # Was --with-dlz-odbc specified?
405 AC_MSG_CHECKING(for ODBC DLZ driver)
406 AC_ARG_WITH(dlz_odbc,
407 [ --with-dlz-odbc[=PATH] Build with ODBC DLZ driver [yes|no|path].
408 (Required to use ODBC with DLZ)],
409 use_dlz_odbc="$withval", use_dlz_odbc="no")
411 if test "$use_dlz_odbc" = "yes"
413 # User did not specify a path - guess it
416 AC_CHECK_HEADER(sql.h, sql_h_found=yes)
417 AC_CHECK_LIB(odbc, SQLConnect, libodbc_found=yes)
419 if test $libodbc_found = "yes" -o $sql_h_found = "yes"
423 dlz_odbc_libs="-lodbc"
425 odbcdirs="/usr /usr/local /usr/pkg"
428 if test -f $d/include/sql.h -a -f $d/lib/libodbc.a
431 dlz_odbc_include="-I$use_dlz_odbc/include"
432 dlz_odbc_libs="-L$use_dlz_odbc/lib -lodbc"
439 case "$use_dlz_odbc" in
444 AC_MSG_RESULT(not found)
446 [ODBC headers were not found in any of $odbcdirs; use --with-dlz-odbc=/path])
449 DLZ_ADD_DRIVER(ODBC, dlz_odbc_driver,
453 AC_MSG_RESULT([using ODBC from $use_dlz_odbc])
459 # Was --with-dlz-stub specified?
462 AC_MSG_CHECKING(for stub DLZ driver)
463 AC_ARG_WITH(dlz_stub,
464 [ --with-dlz-stub[=PATH] Build with stub DLZ driver [yes|no].
465 (Required to use stub driver with DLZ)],
466 use_dlz_stub="$withval", use_dlz_stub="no")
468 case "$use_dlz_stub" in
474 DLZ_ADD_DRIVER(STUB, dlz_stub_driver)
480 # Add any additional DLZ drivers here.
483 # Finally, some generic stuff that applies to all drivers, assuming
484 # we're compiling contrib DLZ drivers at all.
486 if test -n "$CONTRIB_DLZ"
488 CONTRIB_DLZ="-DCONTRIB_DLZ $CONTRIB_DLZ"
491 # Where to find DLZ driver header files.
493 DLZ_DRIVER_INCLUDES="-I$dlzdir/include $DLZ_DRIVER_INCLUDES"
496 # Initialization and shutdown wrappers, helper functions.
498 DLZ_DRIVER_SRCS="$dlzdir/dlz_drivers.c $dlzdir/sdlz_helper.c $DLZ_DRIVER_SRCS"
499 DLZ_DRIVER_OBJS="dlz_drivers.$O sdlz_helper.$O $DLZ_DRIVER_OBJS"