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 USE_DLZ="$USE_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" = "yes"
64 # User did not specify a path - guess it
65 # Ask Postgres to tell us where it is
67 AC_PATH_PROGS(PG_CONFIG, pg_config, [not found])
69 if test "$PG_CONFIG" != "not found"
71 use_dlz_postgres=`$PG_CONFIG --includedir`
72 use_dlz_postgres_lib=`$PG_CONFIG --libdir`
76 if test "$use_dlz_postgres" = "yes"
78 # User did not specify path and Postgres didn't say - guess it
80 pgdirs="/usr /usr/local /usr/local/pgsql /usr/pkg"
83 if test -f $d/include/libpq-fe.h
85 use_dlz_postgres=$d/include
86 use_dlz_postgres_lib=$d/lib
92 if test "$use_dlz_postgres" = "yes"
94 # Still no joy, give up
96 AC_MSG_RESULT(not found)
98 [No pg_config and PostgreSQL was not found in any of $pgdirs; use --with-dlz-postgres=/path or put pg_config in your path])
101 case "$use_dlz_postgres" in
106 DLZ_ADD_DRIVER(POSTGRES, dlz_postgres_driver,
107 [-I$use_dlz_postgres],
108 [-L$use_dlz_postgres_lib -lpq])
111 [using PostgreSQL from $use_dlz_postgres_lib and $use_dlz_postgres])
117 # Was --with-dlz-mysql specified?
120 AC_MSG_CHECKING(for MySQL DLZ driver)
121 AC_ARG_WITH(dlz_mysql,
122 [ --with-dlz-mysql[=PATH] Build with MySQL DLZ driver [yes|no|path].
123 (Required to use MySQL with DLZ)],
124 use_dlz_mysql="$withval", use_dlz_mysql="no")
128 if test "$use_dlz_mysql" = "yes"
130 # User did not specify a path - guess it
131 mysqldirs="/usr /usr/local /usr/local/mysql /usr/pkg"
134 if test -f $d/include/mysql/mysql.h
137 mysql_include=$d/include/mysql
138 if test -d $d/lib/mysql
140 mysql_lib=$d/lib/mysql
145 elif test -f $d/include/mysql.h
148 mysql_include=$d/include
149 if test -d $d/lib/mysql
151 mysql_lib=$d/lib/mysql
158 elif test "$use_dlz_mysql" != "no"
161 if test -f $d/include/mysql/mysql.h
163 mysql_include=$d/include/mysql
164 if test -d $d/lib/mysql
166 mysql_lib=$d/lib/mysql
170 elif test -f $d/include/mysql.h
172 mysql_include=$d/include
173 if test -d $d/lib/mysql
175 mysql_lib=$d/lib/mysql
182 if test "$use_dlz_mysql" = "yes"
184 AC_MSG_RESULT(not found)
186 [MySQL was not found in any of $mysqldirs; use --with-dlz-mysql=/path])
189 case "$use_dlz_mysql" in
194 DLZ_ADD_DRIVER(MYSQL, dlz_mysql_driver,
195 [-I${mysql_include}],
196 [-L${mysql_lib} -lmysqlclient -lz -lcrypt -lm])
199 [using mysql from ${mysql_lib} and ${mysql_include}])
205 # Was --with-dlz-bdb specified?
208 AC_MSG_CHECKING(for Berkeley DB DLZ driver)
210 [ --with-dlz-bdb[=PATH] Build with Berkeley DB DLZ driver [yes|no|path].
211 (Required to use Berkeley DB with DLZ)],
212 use_dlz_bdb="$withval", use_dlz_bdb="no")
214 case "$use_dlz_bdb" in
219 if test "$use_dlz_bdb" = "yes"
221 # User did not specify a path - guess directories
222 bdbdirs="/usr/local /usr/pkg /usr"
223 elif test -d "$use_dlz_bdb"
225 # User specified directory and it exists
226 bdbdirs="$use_dlz_bdb"
228 AC_MSG_RESULT(not found)
229 AC_MSG_ERROR([path $use_dlz_bdb does not exist])
233 # Use path we were given or guessed. This is insanely
234 # complicated because we have to search for a bunch of
235 # platform-specific variations and have to check
236 # separately for include and library directories.
238 # Set both to yes, so we can check them later
244 # Skip nonexistant directories
250 # Check other locations for includes.
251 # Order is important (sigh).
253 bdb_incdirs="/ /db42/ /db41/ /db4/ /db/"
254 for d in $bdb_incdirs
256 if test -f "$dd/include${d}db.h"
258 dlz_bdb_inc="-I$dd/include${d}"
263 # Give up on this directory if we couldn't
264 # find the include subdir
266 if test "$dlz_bdb_inc" = "yes"
271 # Look for libname other than libdb.so.
272 # Order is important (sigh).
274 bdb_libnames="db42 db-4.2 db41 db-4.1 db"
275 for d in $bdb_libnames
277 if test -f "$dd/lib/lib${d}.so"
279 if test "$dd" != "/usr"
281 dlz_bdb_libs="-L${dd}/lib "
285 dlz_bdb_libs="${dlz_bdb_libs}-l${d}"
290 # If we found both incdir and lib, we're done
291 if test "$dlz_bdb_libs" != "yes"
296 # Otherwise, we're starting over
302 # Done searching, now make sure we got everything.
304 if test "$dlz_bdb_inc" = "yes"
306 AC_MSG_RESULT(not found)
307 AC_MSG_ERROR([could not find Berkeley DB include directory])
310 if test "$dlz_bdb_libs" = "yes"
312 AC_MSG_RESULT(not found)
313 AC_MSG_ERROR([could not find Berkeley DB library])
316 DLZ_ADD_DRIVER(BDB, dlz_bdb_driver dlz_bdbhpt_driver,
317 [$dlz_bdb_inc], [$dlz_bdb_libs])
319 AC_MSG_RESULT([using Berkeley DB: $dlz_bdb_inc $dlz_bdb_libs])
321 AC_CONFIG_FILES([contrib/dlz/bin/dlzbdb/Makefile])
327 # Was --with-dlz-filesystem specified?
330 AC_MSG_CHECKING(for file system DLZ driver)
331 AC_ARG_WITH(dlz_filesystem,
332 [ --with-dlz-filesystem[=PATH] Build with filesystem DLZ driver [yes|no].
333 (Required to use file system driver with DLZ)],
334 use_dlz_filesystem="$withval", use_dlz_filesystem="no")
336 case "$use_dlz_filesystem" in
341 DLZ_ADD_DRIVER(FILESYSTEM, dlz_filesystem_driver)
349 # Was --with-dlz-ldap specified?
352 AC_MSG_CHECKING(for LDAP DLZ driver)
353 AC_ARG_WITH(dlz_ldap,
354 [ --with-dlz-ldap[=PATH] Build with LDAP DLZ driver [yes|no|path].
355 (Required to use LDAP with DLZ)],
356 use_dlz_ldap="$withval", use_dlz_ldap="no")
358 if test "$use_dlz_ldap" = "yes"
360 # User did not specify a path - guess it
361 ldapdirs="/usr /usr/local /usr/pkg"
364 if test -f $d/include/ldap.h
372 if test "$use_dlz_ldap" = "yes"
374 AC_MSG_RESULT(not found)
376 [LDAP headers were not found in any of $ldapdirs; use --with-dlz-ldap=/path])
379 case "$use_dlz_ldap" in
384 DLZ_ADD_DRIVER(LDAP, dlz_ldap_driver,
385 [-I$use_dlz_ldap/include],
386 [-L$use_dlz_ldap/lib -lldap -llber])
389 [using LDAP from $use_dlz_ldap/lib and $use_dlz_ldap/include])
395 # Was --with-dlz-odbc specified?
398 AC_MSG_CHECKING(for ODBC DLZ driver)
399 AC_ARG_WITH(dlz_odbc,
400 [ --with-dlz-odbc[=PATH] Build with ODBC DLZ driver [yes|no|path].
401 (Required to use ODBC with DLZ)],
402 use_dlz_odbc="$withval", use_dlz_odbc="no")
404 if test "$use_dlz_odbc" = "yes"
406 # User did not specify a path - guess it
407 odbcdirs="/usr /usr/local /usr/pkg"
410 if test -f $d/include/sql.h -a -f $d/lib/libodbc.a
418 case "$use_dlz_odbc" in
423 AC_MSG_RESULT(not found)
425 [ODBC headers were not found in any of $odbcdirs; use --with-dlz-odbc=/path])
428 DLZ_ADD_DRIVER(ODBC, dlz_odbc_driver,
429 [-I$use_dlz_odbc/include],
430 [-L$use_dlz_odbc/lib -lodbc])
432 AC_MSG_RESULT([using ODBC from $use_dlz_odbc])
438 # Was --with-dlz-stub specified?
441 AC_MSG_CHECKING(for stub DLZ driver)
442 AC_ARG_WITH(dlz_stub,
443 [ --with-dlz-stub[=PATH] Build with stub DLZ driver [yes|no].
444 (Required to use stub driver with DLZ)],
445 use_dlz_stub="$withval", use_dlz_stub="no")
447 case "$use_dlz_stub" in
453 DLZ_ADD_DRIVER(STUB, dlz_stub_driver)
460 # Add any additional DLZ drivers here.
463 # Finally, some generic stuff that applies to all drivers, assuming
464 # we're compiling DLZ at all.
466 if test -n "$USE_DLZ"
469 # Where to find DLZ driver header files.
471 DLZ_DRIVER_INCLUDES="-I$dlzdir/include $DLZ_DRIVER_INCLUDES"
474 # Initialization and shutdown wrappers, helper functions.
476 DLZ_DRIVER_SRCS="$dlzdir/dlz_drivers.c $dlzdir/sdlz_helper.c $DLZ_DRIVER_SRCS"
477 DLZ_DRIVER_OBJS="dlz_drivers.$O sdlz_helper.$O $DLZ_DRIVER_OBJS"