ignore some files
[tridge/bind9.git] / contrib / dlz / config.dlz.in
1 # Copyright (C) 2005  Internet Systems Consortium, Inc. ("ISC")
2 #
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.
6 #
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.
14
15 #
16 # Shorthand.  Note quoting: DLZ_DRIVER_DIR expanded in Makefile, not here.
17 #
18 dlzdir='${DLZ_DRIVER_DIR}'
19
20 #
21 # Private autoconf macro to simplify configuring drivers:
22 #
23 #   DLZ_ADD_DRIVER(DEFINE, DRIVER, INCLUDES, LIBS)
24 #
25 # where:
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
30 #
31 AC_DEFUN(DLZ_ADD_DRIVER, [
32         USE_DLZ="$USE_DLZ -DDLZ_$1"
33         for i in $2
34         do
35                 DLZ_DRIVER_SRCS="$DLZ_DRIVER_SRCS $dlzdir/$i.c"
36                 DLZ_DRIVER_OBJS="$DLZ_DRIVER_OBJS $i.$O"
37         done
38         if test -n "$3"
39         then
40                 DLZ_DRIVER_INCLUDES="$DLZ_DRIVER_INCLUDES $3"
41         fi
42         if test -n "$4"
43         then
44                 DLZ_DRIVER_LIBS="$DLZ_DRIVER_LIBS $4"
45         fi
46 ])
47
48 #
49 # Check for the various DLZ drivers
50 #
51
52 #
53 # Was --with-dlz-postgres specified?
54 #
55
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")
61
62 if test "$use_dlz_postgres" = "yes"
63 then
64         # User did not specify a path - guess it
65         # Ask Postgres to tell us where it is
66
67         AC_PATH_PROGS(PG_CONFIG, pg_config, [not found])
68
69         if test "$PG_CONFIG" != "not found"
70         then
71                 use_dlz_postgres=`$PG_CONFIG --includedir`
72                 use_dlz_postgres_lib=`$PG_CONFIG --libdir`
73         fi
74 fi
75
76 if test "$use_dlz_postgres" = "yes"
77 then
78         # User did not specify path and Postgres didn't say - guess it
79
80         pgdirs="/usr /usr/local /usr/local/pgsql /usr/pkg"
81         for d in $pgdirs
82         do
83                 if test -f $d/include/libpq-fe.h
84                 then
85                         use_dlz_postgres=$d/include
86                         use_dlz_postgres_lib=$d/lib
87                         break
88                 fi
89         done
90 fi
91
92 if test "$use_dlz_postgres" = "yes"
93 then
94         # Still no joy, give up
95
96         AC_MSG_RESULT(not found)
97         AC_MSG_ERROR(
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])
99 fi
100
101 case "$use_dlz_postgres" in
102         no)
103                 AC_MSG_RESULT(no)
104                 ;;
105         *)
106                 DLZ_ADD_DRIVER(POSTGRES, dlz_postgres_driver,
107                                 [-I$use_dlz_postgres],
108                                 [-L$use_dlz_postgres_lib -lpq])
109
110                 AC_MSG_RESULT(
111 [using PostgreSQL from $use_dlz_postgres_lib and $use_dlz_postgres])
112                 ;;
113 esac
114
115
116 #
117 # Was --with-dlz-mysql specified?
118 #
119
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")
125
126 mysql_include=""
127 mysql_lib=""
128 if test "$use_dlz_mysql" = "yes"
129 then
130         # User did not specify a path - guess it
131         mysqldirs="/usr /usr/local /usr/local/mysql /usr/pkg"
132         for d in $mysqldirs
133         do
134                 if test -f $d/include/mysql/mysql.h
135                 then
136                         use_dlz_mysql=$d
137                         mysql_include=$d/include/mysql
138                         if test -d $d/lib/mysql
139                         then
140                                 mysql_lib=$d/lib/mysql
141                         else
142                                 mysql_lib=$d/lib
143                         fi
144                         break
145                 elif test -f $d/include/mysql.h
146                 then
147                         use_dlz_mysql=$d
148                         mysql_include=$d/include
149                         if test -d $d/lib/mysql
150                         then
151                                 mysql_lib=$d/lib/mysql
152                         else
153                                 mysql_lib=$d/lib
154                         fi
155                         break
156                 fi
157         done
158 elif test "$use_dlz_mysql" != "no"
159 then
160         d=$use_dlz_mysql
161         if test -f $d/include/mysql/mysql.h
162         then
163                 mysql_include=$d/include/mysql
164                 if test -d $d/lib/mysql
165                 then
166                         mysql_lib=$d/lib/mysql
167                 else
168                         mysql_lib=$d/lib
169                 fi
170         elif test -f $d/include/mysql.h
171         then
172                 mysql_include=$d/include
173                 if test -d $d/lib/mysql
174                 then
175                         mysql_lib=$d/lib/mysql
176                 else
177                         mysql_lib=$d/lib
178                 fi
179         fi
180 fi
181
182 if test "$use_dlz_mysql" = "yes"
183 then
184         AC_MSG_RESULT(not found)
185         AC_MSG_ERROR(
186 [MySQL was not found in any of $mysqldirs; use --with-dlz-mysql=/path])
187 fi
188
189 case "$use_dlz_mysql" in
190         no)
191                 AC_MSG_RESULT(no)
192                 ;;
193         *)
194                 DLZ_ADD_DRIVER(MYSQL, dlz_mysql_driver,
195                                 [-I${mysql_include}],
196                                 [-L${mysql_lib} -lmysqlclient -lz -lcrypt -lm])
197
198                 AC_MSG_RESULT(
199 [using mysql from ${mysql_lib} and ${mysql_include}])
200                 ;;
201 esac
202
203
204 #
205 # Was --with-dlz-bdb specified?
206 #
207
208 AC_MSG_CHECKING(for Berkeley DB DLZ driver)
209 AC_ARG_WITH(dlz_bdb,
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")
213
214 case "$use_dlz_bdb" in
215         no)
216                 AC_MSG_RESULT(no)
217                 ;;
218         *)
219                 if test "$use_dlz_bdb" = "yes"
220                 then
221                         # User did not specify a path - guess directories
222                         bdbdirs="/usr/local /usr/pkg /usr"
223                 elif test -d "$use_dlz_bdb"
224                 then
225                         # User specified directory and it exists
226                         bdbdirs="$use_dlz_bdb"
227                 else
228                         AC_MSG_RESULT(not found)
229                         AC_MSG_ERROR([path $use_dlz_bdb does not exist])
230                         bdbdirs=""
231                 fi
232
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.
237
238                 # Set both to yes, so we can check them later
239                 dlz_bdb_inc="yes"
240                 dlz_bdb_libs="yes"
241
242                 for dd in $bdbdirs
243                 do
244                         # Skip nonexistant directories
245                         if test ! -d "$dd"
246                         then
247                                 continue
248                         fi
249
250                         # Check other locations for includes.
251                         # Order is important (sigh).
252
253                         bdb_incdirs="/ /db42/ /db41/ /db4/ /db/"
254                         for d in $bdb_incdirs
255                         do
256                                 if test -f "$dd/include${d}db.h"
257                                 then
258                                         dlz_bdb_inc="-I$dd/include${d}"
259                                         break
260                                 fi
261                         done
262
263                         # Give up on this directory if we couldn't
264                         # find the include subdir
265
266                         if test "$dlz_bdb_inc" = "yes"
267                         then
268                                 continue
269                         fi
270
271                         # Look for libname other than libdb.so.
272                         # Order is important (sigh).
273
274                         bdb_libnames="db42 db-4.2 db41 db-4.1 db"
275                         for d in $bdb_libnames
276                         do
277                                 if test -f "$dd/lib/lib${d}.so"
278                                 then
279                                         if test "$dd" != "/usr"
280                                         then
281                                                 dlz_bdb_libs="-L${dd}/lib "
282                                         else
283                                                 dlz_bdb_libs=""
284                                         fi
285                                         dlz_bdb_libs="${dlz_bdb_libs}-l${d}"
286                                         break
287                                 fi
288                         done
289
290                         # If we found both incdir and lib, we're done
291                         if test "$dlz_bdb_libs" != "yes"
292                         then
293                                 break
294                         fi
295
296                         # Otherwise, we're starting over
297
298                         dlz_bdb_inc="yes"
299                         dlz_bdb_libs="yes"
300                 done
301                 
302                 # Done searching, now make sure we got everything.
303
304                 if test "$dlz_bdb_inc" = "yes"
305                 then
306                         AC_MSG_RESULT(not found)
307                         AC_MSG_ERROR([could not find Berkeley DB include directory])
308                 fi
309
310                 if test "$dlz_bdb_libs" = "yes"
311                 then
312                         AC_MSG_RESULT(not found)
313                         AC_MSG_ERROR([could not find Berkeley DB library])
314                 fi
315
316                 DLZ_ADD_DRIVER(BDB, dlz_bdb_driver dlz_bdbhpt_driver,
317                                [$dlz_bdb_inc], [$dlz_bdb_libs])
318
319                 AC_MSG_RESULT([using Berkeley DB: $dlz_bdb_inc $dlz_bdb_libs])
320
321                 AC_CONFIG_FILES([contrib/dlz/bin/dlzbdb/Makefile])
322                 ;;
323 esac
324
325
326 #
327 # Was --with-dlz-filesystem specified?
328 #
329
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")
335
336 case "$use_dlz_filesystem" in
337         no)
338                 AC_MSG_RESULT(no)
339                 ;;
340         *)
341                 DLZ_ADD_DRIVER(FILESYSTEM, dlz_filesystem_driver)
342
343                 AC_MSG_RESULT(yes)
344                 ;;
345 esac
346
347
348 #
349 # Was --with-dlz-ldap specified?
350 #
351
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")
357
358 if test "$use_dlz_ldap" = "yes"
359 then
360         # User did not specify a path - guess it
361         ldapdirs="/usr /usr/local /usr/pkg"
362         for d in $ldapdirs
363         do
364                 if test -f $d/include/ldap.h
365                 then
366                         use_dlz_ldap=$d
367                         break
368                 fi
369         done
370 fi
371
372 if test "$use_dlz_ldap" = "yes"
373 then
374         AC_MSG_RESULT(not found)
375         AC_MSG_ERROR(
376 [LDAP headers were not found in any of $ldapdirs; use --with-dlz-ldap=/path])
377 fi
378
379 case "$use_dlz_ldap" in
380         no)
381                 AC_MSG_RESULT(no)
382                 ;;
383         *)
384                 DLZ_ADD_DRIVER(LDAP, dlz_ldap_driver,
385                                 [-I$use_dlz_ldap/include],
386                                 [-L$use_dlz_ldap/lib -lldap -llber])
387
388                 AC_MSG_RESULT(
389 [using LDAP from $use_dlz_ldap/lib and $use_dlz_ldap/include])
390                 ;;
391 esac
392
393
394 #
395 # Was --with-dlz-odbc specified?
396 #
397
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")
403
404 if test "$use_dlz_odbc" = "yes"
405 then
406         # User did not specify a path - guess it
407         odbcdirs="/usr /usr/local /usr/pkg"
408         for d in $odbcdirs
409         do
410                 if test -f $d/include/sql.h -a -f $d/lib/libodbc.a
411                 then
412                         use_dlz_odbc=$d
413                         break
414                 fi
415         done
416 fi
417
418 case "$use_dlz_odbc" in
419         no)
420                 AC_MSG_RESULT(no)
421                 ;;
422         yes)
423                 AC_MSG_RESULT(not found)
424                 AC_MSG_ERROR(
425 [ODBC headers were not found in any of $odbcdirs; use --with-dlz-odbc=/path])
426                 ;;
427         *)
428                 DLZ_ADD_DRIVER(ODBC, dlz_odbc_driver,
429                                 [-I$use_dlz_odbc/include],
430                                 [-L$use_dlz_odbc/lib -lodbc])
431
432                 AC_MSG_RESULT([using ODBC from $use_dlz_odbc])
433                 ;;
434 esac
435
436
437 #
438 # Was --with-dlz-stub specified?
439 #
440
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")
446
447 case "$use_dlz_stub" in
448         no)
449                 AC_MSG_RESULT(no)
450                 ;;
451         *)
452
453                 DLZ_ADD_DRIVER(STUB, dlz_stub_driver)
454
455                 AC_MSG_RESULT(yes)
456                 ;;
457 esac
458
459
460 # Add any additional DLZ drivers here.
461
462 #
463 # Finally, some generic stuff that applies to all drivers, assuming
464 # we're compiling DLZ at all.
465 #
466 if test -n "$USE_DLZ"
467 then
468         #
469         # Where to find DLZ driver header files.
470         #
471         DLZ_DRIVER_INCLUDES="-I$dlzdir/include $DLZ_DRIVER_INCLUDES"
472
473         #
474         # Initialization and shutdown wrappers, helper functions.
475         #
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"
478 fi