root/1.8.3/branches/experimental/aclocal.m4

Revision 922, 27.7 KB (checked in by shawnw, 19 months ago)

expr: Sync with devel

Line 
1# DO NOT RUN ACLOCAL TO GENERATE THIS FILE!
2# Some of the macros have been changed from the stock versions.
3# Namely, CHECK_SSL.
4
5# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
6# 2005  Free Software Foundation, Inc.
7# This file is free software; the Free Software Foundation
8# gives unlimited permission to copy and/or distribute it,
9# with or without modifications, as long as this notice is preserved.
10
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
13# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
14# PARTICULAR PURPOSE.
15
16#
17# SYNOPSIS
18#
19#   AX_LIB_MYSQL([MINIMUM-VERSION])
20#
21# DESCRIPTION
22#
23#   This macro provides tests of availability of MySQL client library
24#   of particular version or newer.
25#
26#   AX_LIB_MYSQL macro takes only one argument which is optional. If
27#   there is no required version passed, then macro does not run
28#   version test.
29#
30#   The --with-mysql option takes one of three possible values:
31#
32#   no - do not check for MySQL client library
33#
34#   yes - do check for MySQL library in standard locations
35#   (mysql_config should be in the PATH)
36#
37#   path - complete path to mysql_config utility, use this option if
38#   mysql_config can't be found in the PATH
39#
40#   This macro calls:
41#
42#     AC_SUBST(MYSQL_CFLAGS)
43#     AC_SUBST(MYSQL_LDFLAGS)
44#     AC_SUBST(MYSQL_VERSION)
45#
46#   And sets:
47#
48#     HAVE_MYSQL
49#
50# LAST MODIFICATION
51#
52#   2006-07-16
53#
54# COPYLEFT
55#
56#   Copyright (c) 2006 Mateusz Loskot <mateusz@loskot.net>
57#
58#   Copying and distribution of this file, with or without
59#   modification, are permitted in any medium without royalty provided
60#   the copyright notice and this notice are preserved.
61
62AC_DEFUN([AX_LIB_MYSQL],
63[
64    AC_ARG_WITH([mysql],
65        AC_HELP_STRING([--with-mysql=@<:@ARG@:>@],
66            [use MySQL client library @<:@default=yes@:>@, optionally specify path to mysql_config]
67        ),
68        [
69        if test "$withval" = "no"; then
70            want_mysql="no"
71        elif test "$withval" = "yes"; then
72            want_mysql="yes"
73        else
74            want_mysql="yes"
75            MYSQL_CONFIG="$withval"
76        fi
77        ],
78        [want_mysql="yes"]
79    )
80
81    MYSQL_CFLAGS=""
82    MYSQL_LDFLAGS=""
83    MYSQL_VERSION=""
84
85    dnl
86    dnl Check MySQL libraries (libpq)
87    dnl
88
89    if test "$want_mysql" = "yes"; then
90
91        if test -z "$MYSQL_CONFIG" -o test; then
92            AC_PATH_PROG([MYSQL_CONFIG], [mysql_config], [no])
93        fi
94
95        AC_MSG_CHECKING([for MySQL libraries])
96        if test "$MYSQL_CONFIG" != "no"; then
97
98            MYSQL_CFLAGS="`$MYSQL_CONFIG --cflags`"
99            MYSQL_LDFLAGS="`$MYSQL_CONFIG --libs`"
100
101            MYSQL_VERSION=`$MYSQL_CONFIG --version`
102
103            AC_DEFINE([HAVE_MYSQL], [1],
104                [Define to 1 if MySQL libraries are available])
105
106            found_mysql="yes"
107            AC_MSG_RESULT([yes])
108        else
109            found_mysql="no"
110            AC_MSG_RESULT([no])
111        fi
112    fi
113
114    dnl
115    dnl Check if required version of MySQL is available
116    dnl
117
118
119    mysql_version_req=ifelse([$1], [], [], [$1])
120
121    if test "$found_mysql" = "yes" -a -n "$mysql_version_req"; then
122
123        AC_MSG_CHECKING([if MySQL version is >= $mysql_version_req])
124
125        dnl Decompose required version string of MySQL
126        dnl and calculate its number representation
127        mysql_version_req_major=`expr $mysql_version_req : '\([[0-9]]*\)'`
128        mysql_version_req_minor=`expr $mysql_version_req : '[[0-9]]*\.\([[0-9]]*\)'`
129        mysql_version_req_micro=`expr $mysql_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
130        if test "x$mysql_version_req_micro" = "x"; then
131            mysql_version_req_micro="0"
132        fi
133
134        mysql_version_req_number=`expr $mysql_version_req_major \* 1000000 \
135                                   \+ $mysql_version_req_minor \* 1000 \
136                                   \+ $mysql_version_req_micro`
137
138        dnl Decompose version string of installed MySQL
139        dnl and calculate its number representation
140        mysql_version_major=`expr $MYSQL_VERSION : '\([[0-9]]*\)'`
141        mysql_version_minor=`expr $MYSQL_VERSION : '[[0-9]]*\.\([[0-9]]*\)'`
142        mysql_version_micro=`expr $MYSQL_VERSION : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
143        if test "x$mysql_version_micro" = "x"; then
144            mysql_version_micro="0"
145        fi
146
147        mysql_version_number=`expr $mysql_version_major \* 1000000 \
148                                   \+ $mysql_version_minor \* 1000 \
149                                   \+ $mysql_version_micro`
150
151        mysql_version_check=`expr $mysql_version_number \>\= $mysql_version_req_number`
152        if test "$mysql_version_check" = "1"; then
153            AC_MSG_RESULT([yes])
154        else
155            AC_MSG_RESULT([no])
156        fi
157    fi
158
159    AC_SUBST([MYSQL_VERSION])
160    AC_SUBST([MYSQL_CFLAGS])
161    AC_SUBST([MYSQL_LDFLAGS])
162])
163
164#
165# SYNOPSIS
166#
167#   CHECK_SSL
168#
169# DESCRIPTION
170#
171#   This macro will check various standard spots for OpenSSL including
172#   a user-supplied directory. The user uses '--with-ssl' or
173#   '--with-ssl=/path/to/ssl' as arguments to configure.
174#
175#   If OpenSSL is found the include directory gets added to CFLAGS and
176#   CXXFLAGS as well as '-DHAVE_SSL', '-lssl' & '-lcrypto' get added to
177#   LIBS, and the libraries location gets added to LDFLAGS. Finally
178#   'HAVE_SSL' gets set to 'yes' for use in your Makefile.in I use it
179#   like so (valid for gmake):
180#
181#       HAVE_SSL = @HAVE_SSL@
182#       ifeq ($(HAVE_SSL),yes)
183#           SRCS+= @srcdir@/my_file_that_needs_ssl.c
184#       endif
185#
186#   For bsd 'bmake' use:
187#
188#       .if ${HAVE_SSL} == "yes"
189#           SRCS+= @srcdir@/my_file_that_needs_ssl.c
190#       .endif
191#
192# LAST MODIFICATION
193#
194#   2003-01-28
195#
196# COPYLEFT
197#
198#   Copyright (c) 2003 Mark Ethan Trostler <trostler@juniper.net>
199#
200#   Copying and distribution of this file, with or without
201#   modification, are permitted in any medium without royalty provided
202#   the copyright notice and this notice are preserved.
203
204AC_DEFUN(CHECK_SSL,
205[AC_ARG_WITH(ssl,
206
207[
208AC_HELP_STRING([--with-ssl=@<:@DIR@:>@], [look for OpenSSL in DIR (Use when it's not found with the default search path)])
209],
210
211[ AS_IF([test "x$with_ssl" != xno],
212 [  AC_MSG_CHECKING([for OpenSSL])
213    for dir in $with_ssl /usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr; do
214        ssldir="$dir"
215        if test -f "$dir/include/openssl/ssl.h"; then
216            found_ssl="yes";
217            CFLAGS="$CFLAGS -I$ssldir/include/";
218            break;
219        fi
220        if test -f "$dir/include/ssl.h"; then
221            found_ssl="yes";
222            CFLAGS="$CFLAGS -I$ssldir/include/";
223            break;
224        fi
225    done
226    if test x_$found_ssl != x_yes; then
227        AC_MSG_RESULT(no)
228    else
229        AC_MSG_RESULT(yes)
230        LIBS="$LIBS -lssl -lcrypto";
231        LDFLAGS="$LDFLAGS -L$ssldir/lib";
232        HAVE_SSL="yes";
233        AC_SUBST(HAVE_SSL) 
234    fi
235 ],
236 AC_MSG_NOTICE([ssl support disabled])
237)],
238[
239   AC_MSG_CHECKING([for OpenSSL])
240   for dir in /usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr; do
241        ssldir="$dir"
242        if test -f "$dir/include/openssl/ssl.h"; then
243            found_ssl="yes";
244            CFLAGS="$CFLAGS -I$ssldir/include/";
245            break;
246        fi
247        if test -f "$dir/include/ssl.h"; then
248            found_ssl="yes";
249            CFLAGS="$CFLAGS -I$ssldir/include/";
250            break;
251        fi
252    done
253    if test x_$found_ssl != x_yes; then
254        AC_MSG_RESULT(no)
255    else
256        AC_MSG_RESULT(yes)
257        LIBS="$LIBS -lssl -lcrypto";
258        LDFLAGS="$LDFLAGS -L$ssldir/lib";
259        HAVE_SSL="yes";
260        AC_SUBST(HAVE_SSL)
261    fi
262])
263])
264
265##### http://autoconf-archive.cryp.to/type_socklen_t.html
266#
267# SYNOPSIS
268#
269#   TYPE_SOCKLEN_T
270#
271# DESCRIPTION
272#
273#   Check whether sys/socket.h defines type socklen_t. Please note that
274#   some systems require sys/types.h to be included before sys/socket.h
275#   can be compiled.
276#
277# LAST MODIFICATION
278#
279#   2005-01-11
280#
281# COPYLEFT
282#
283#   Copyright (c) 2005 Lars Brinkhoff <lars@nocrew.org>
284#
285#   This program is free software; you can redistribute it and/or
286#   modify it under the terms of the GNU General Public License as
287#   published by the Free Software Foundation; either version 2 of the
288#   License, or (at your option) any later version.
289#
290#   This program is distributed in the hope that it will be useful, but
291#   WITHOUT ANY WARRANTY; without even the implied warranty of
292#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
293#   General Public License for more details.
294#
295#   You should have received a copy of the GNU General Public License
296#   along with this program; if not, write to the Free Software
297#   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
298#   02111-1307, USA.
299#
300#   As a special exception, the respective Autoconf Macro's copyright
301#   owner gives unlimited permission to copy, distribute and modify the
302#   configure scripts that are the output of Autoconf when processing
303#   the Macro. You need not follow the terms of the GNU General Public
304#   License when using or distributing such scripts, even though
305#   portions of the text of the Macro appear in them. The GNU General
306#   Public License (GPL) does govern all other use of the material that
307#   constitutes the Autoconf Macro.
308#
309#   This special exception to the GPL applies to versions of the
310#   Autoconf Macro released by the Autoconf Macro Archive. When you
311#   make and distribute a modified version of the Autoconf Macro, you
312#   may extend this special exception to the GPL to apply to your
313#   modified version as well.
314
315AC_DEFUN([TYPE_SOCKLEN_T],
316[AC_CACHE_CHECK([for socklen_t], ac_cv_type_socklen_t,
317[
318  AC_TRY_COMPILE(
319  [#include <sys/types.h>
320   #include <sys/socket.h>],
321  [socklen_t len = 42; return 0;],
322  ac_cv_type_socklen_t=yes,
323  ac_cv_type_socklen_t=no)
324])
325  if test $ac_cv_type_socklen_t != yes; then
326    AC_DEFINE(socklen_t, int, [Substitute for socklen_t])
327  fi
328])
329
330
331##### http://autoconf-archive.cryp.to/lib_socket_nsl.html
332#
333# SYNOPSIS
334#
335#   LIB_SOCKET_NSL
336#
337# DESCRIPTION
338#
339#   This macro figures out what libraries are required on this platform
340#   to link sockets programs.
341#
342#   The common cases are not to need any extra libraries, or to need
343#   -lsocket and -lnsl. We need to avoid linking with libnsl unless we
344#   need it, though, since on some OSes where it isn't necessary it
345#   will totally break networking. Unisys also includes gethostbyname()
346#   in libsocket but needs libnsl for socket().
347#
348# LAST MODIFICATION
349#
350#   2005-09-06
351#
352# COPYLEFT
353#
354#   Copyright (c) 2005 Russ Allbery <rra@stanford.edu>
355#   Copyright (c) 2005 Stepan Kasal <kasal@ucw.cz>
356#   Copyright (c) 2005 Warren Young <warren@etr-usa.com>
357#
358#   Copying and distribution of this file, with or without
359#   modification, are permitted in any medium without royalty provided
360#   the copyright notice and this notice are preserved.
361
362AC_DEFUN([LIB_SOCKET_NSL],
363[
364    AC_SEARCH_LIBS([gethostbyname], [nsl])
365    AC_SEARCH_LIBS([socket], [socket], [], [
366        AC_CHECK_LIB([socket], [socket], [LIBS="-lsocket -lnsl $LIBS"],
367        [], [-lnsl])])
368])
369
370##### http://autoconf-archive.cryp.to/ac_func_snprintf.html
371#
372# SYNOPSIS
373#
374#   AC_FUNC_SNPRINTF
375#
376# DESCRIPTION
377#
378#   Checks for a fully C99 compliant snprintf, in particular checks
379#   whether it does bounds checking and returns the correct string
380#   length; does the same check for vsnprintf. If no working snprintf
381#   or vsnprintf is found, request a replacement and warn the user
382#   about it. Note: the mentioned replacement is freely available and
383#   may be used in any project regardless of it's license.
384#
385# LAST MODIFICATION
386#
387#   2006-10-18
388#
389# COPYLEFT
390#
391#   Copyright (c) 2006 Rüdiger Kuhlmann <info@ruediger-kuhlmann.de>
392#
393#   Copying and distribution of this file, with or without
394#   modification, are permitted in any medium without royalty provided
395#   the copyright notice and this notice are preserved.
396
397AC_DEFUN([AC_FUNC_SNPRINTF],
398[AC_CHECK_FUNCS(snprintf vsnprintf)
399AC_MSG_CHECKING(for working snprintf)
400AC_CACHE_VAL(ac_cv_have_working_snprintf,
401[AC_TRY_RUN(
402[#include <stdio.h>
403
404int main(void)
405{
406    char bufs[5] = { 'x', 'x', 'x', '\0', '\0' };
407    char bufd[5] = { 'x', 'x', 'x', '\0', '\0' };
408    int i;
409    i = snprintf (bufs, 2, "%s", "111");
410    if (strcmp (bufs, "1")) exit (1);
411    if (i != 3) exit (1);
412    i = snprintf (bufd, 2, "%d", 111);
413    if (strcmp (bufd, "1")) exit (1);
414    if (i != 3) exit (1);
415    exit(0);
416}], ac_cv_have_working_snprintf=yes, ac_cv_have_working_snprintf=no, ac_cv_have_working_snprintf=cross)])
417AC_MSG_RESULT([$ac_cv_have_working_snprintf])
418AC_MSG_CHECKING(for working vsnprintf)
419AC_CACHE_VAL(ac_cv_have_working_vsnprintf,
420[AC_TRY_RUN(
421[#include <stdio.h>
422#include <stdarg.h>
423
424int my_vsnprintf (char *buf, const char *tmpl, ...)
425{
426    int i;
427    va_list args;
428    va_start (args, tmpl);
429    i = vsnprintf (buf, 2, tmpl, args);
430    va_end (args);
431    return i;
432}
433
434int main(void)
435{
436    char bufs[5] = { 'x', 'x', 'x', '\0', '\0' };
437    char bufd[5] = { 'x', 'x', 'x', '\0', '\0' };
438    int i;
439    i = my_vsnprintf (bufs, "%s", "111");
440    if (strcmp (bufs, "1")) exit (1);
441    if (i != 3) exit (1);
442    i = my_vsnprintf (bufd, "%d", 111);
443    if (strcmp (bufd, "1")) exit (1);
444    if (i != 3) exit (1);
445    exit(0);
446}], ac_cv_have_working_vsnprintf=yes, ac_cv_have_working_vsnprintf=no, ac_cv_have_working_vsnprintf=cross)])
447AC_MSG_RESULT([$ac_cv_have_working_vsnprintf])
448if test x$ac_cv_have_working_snprintf$ac_cv_have_working_vsnprintf != "xyesyes"; then
449  AC_LIBOBJ(snprintf)
450  AC_MSG_WARN([Replacing missing/broken (v)snprintf() with version from http://www.ijs.si/software/snprintf/.])
451  AC_DEFINE(PREFER_PORTABLE_SNPRINTF, 1, "enable replacement (v)snprintf if system (v)snprintf is broken")
452fi])
453##### http://autoconf-archive.cryp.to/ax_lib_postgresql.html
454#
455# SYNOPSIS
456#
457#   AX_LIB_POSTGRESQL([MINIMUM-VERSION])
458#
459# DESCRIPTION
460#
461#   This macro provides tests of availability of PostgreSQL 'libpq'
462#   library of particular version or newer.
463#
464#   AX_LIB_POSTGRESQL macro takes only one argument which is optional.
465#   If there is no required version passed, then macro does not run
466#   version test.
467#
468#   The --with-postgresql option takes one of three possible values:
469#
470#   no - do not check for PostgreSQL client library
471#
472#   yes - do check for PostgreSQL library in standard locations
473#   (pg_config should be in the PATH)
474#
475#   path - complete path to pg_config utility, use this option if
476#   pg_config can't be found in the PATH
477#
478#   This macro calls:
479#
480#     AC_SUBST(POSTGRESQL_CFLAGS)
481#     AC_SUBST(POSTGRESQL_LDFLAGS)
482#     AC_SUBST(POSTGRESQL_VERSION)
483#
484#   And sets:
485#
486#     HAVE_POSTGRESQL
487#
488# LAST MODIFICATION
489#
490#   2006-07-16
491#
492# COPYLEFT
493#
494#   Copyright (c) 2006 Mateusz Loskot <mateusz@loskot.net>
495#
496#   Copying and distribution of this file, with or without
497#   modification, are permitted in any medium without royalty provided
498#   the copyright notice and this notice are preserved.
499
500AC_DEFUN([AX_LIB_POSTGRESQL],
501[
502    AC_ARG_WITH([postgresql],
503        AC_HELP_STRING([--with-postgresql=@<:@ARG@:>@],
504            [use PostgreSQL library @<:@default=yes@:>@, optionally specify path to pg_config]
505        ),
506        [
507        if test "$withval" = "no"; then
508            want_postgresql="no"
509        elif test "$withval" = "yes"; then
510            want_postgresql="yes"
511        else
512            want_postgresql="yes"
513            PG_CONFIG="$withval"
514        fi
515        ],
516        [want_postgresql="yes"]
517    )
518
519    POSTGRESQL_CFLAGS=""
520    POSTGRESQL_LDFLAGS=""
521    POSTGRESQL_POSTGRESQL=""
522
523    dnl
524    dnl Check PostgreSQL libraries (libpq)
525    dnl
526
527    if test "$want_postgresql" = "yes"; then
528
529        if test -z "$PG_CONFIG" -o test; then
530            AC_PATH_PROG([PG_CONFIG], [pg_config], [no])
531        fi
532
533        AC_MSG_CHECKING([for PostgreSQL libraries])
534        if test "$PG_CONFIG" != "no"; then
535
536            POSTGRESQL_CFLAGS="-I`$PG_CONFIG --includedir`"
537            POSTGRESQL_LDFLAGS="-L`$PG_CONFIG --libdir` -lpq"
538
539            POSTGRESQL_VERSION=`$PG_CONFIG --version | sed -e 's#PostgreSQL ##'`
540
541            AC_DEFINE([HAVE_POSTGRESQL], [1],
542                [Define to 1 if PostgreSQL libraries are available])
543
544            found_postgresql="yes"
545            AC_MSG_RESULT([yes])
546        else
547            found_postgresql="no"
548            AC_MSG_RESULT([no])
549        fi
550    fi
551
552    dnl
553    dnl Check if required version of PostgreSQL is available
554    dnl
555
556
557    postgresql_version_req=ifelse([$1], [], [], [$1])
558
559    if test "$found_postgresql" = "yes" -a -n "$postgresql_version_req"; then
560
561        AC_MSG_CHECKING([if PostgreSQL version is >= $postgresql_version_req])
562
563        dnl Decompose required version string of PostgreSQL
564        dnl and calculate its number representation
565        postgresql_version_req_major=`expr $postgresql_version_req : '\([[0-9]]*\)'`
566        postgresql_version_req_minor=`expr $postgresql_version_req : '[[0-9]]*\.\([[0-9]]*\)'`
567        postgresql_version_req_micro=`expr $postgresql_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
568        if test "x$postgresql_version_req_micro" = "x"; then
569            postgresql_version_req_micro="0"
570        fi
571
572        postgresql_version_req_number=`expr $postgresql_version_req_major \* 1000000 \
573                                   \+ $postgresql_version_req_minor \* 1000 \
574                                   \+ $postgresql_version_req_micro`
575
576        dnl Decompose version string of installed PostgreSQL
577        dnl and calculate its number representation
578        postgresql_version_major=`expr $POSTGRESQL_VERSION : '\([[0-9]]*\)'`
579        postgresql_version_minor=`expr $POSTGRESQL_VERSION : '[[0-9]]*\.\([[0-9]]*\)'`
580        postgresql_version_micro=`expr $POSTGRESQL_VERSION : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
581        if test "x$postgresql_version_micro" = "x"; then
582            postgresql_version_micro="0"
583        fi
584
585        postgresql_version_number=`expr $postgresql_version_major \* 1000000 \
586                                   \+ $postgresql_version_minor \* 1000 \
587                                   \+ $postgresql_version_micro`
588
589        postgresql_version_check=`expr $postgresql_version_number \>\= $postgresql_version_req_number`
590        if test "$postgresql_version_check" = "1"; then
591            AC_MSG_RESULT([yes])
592        else
593            AC_MSG_RESULT([no])
594        fi
595    fi
596
597    AC_SUBST([POSTGRESQL_VERSION])
598    AC_SUBST([POSTGRESQL_CFLAGS])
599    AC_SUBST([POSTGRESQL_LDFLAGS])
600])
601##### http://autoconf-archive.cryp.to/ax_lib_sqlite3.html
602#
603# SYNOPSIS
604#
605#   AX_LIB_SQLITE3([MINIMUM-VERSION])
606#
607# DESCRIPTION
608#
609#   Test for the SQLite 3 library of a particular version (or newer)
610#
611#   This macro takes only one optional argument, required version of
612#   SQLite 3 library. If required version is not passed, 3.0.0 is used
613#   in the test of existance of SQLite 3.
614#
615#   If no intallation prefix to the installed SQLite library is given
616#   the macro searches under /usr, /usr/local, and /opt.
617#
618#   This macro calls:
619#
620#     AC_SUBST(SQLITE3_CFLAGS)
621#     AC_SUBST(SQLITE3_LDFLAGS)
622#     AC_SUBST(SQLITE3_VERSION)
623#
624#   And sets:
625#
626#     HAVE_SQLITE3
627#
628# LAST MODIFICATION
629#
630#   2006-07-15
631#
632# COPYLEFT
633#
634#   Copyright (c) 2006 Mateusz Loskot <mateusz@loskot.net>
635#
636#   Copying and distribution of this file, with or without
637#   modification, are permitted in any medium without royalty provided
638#   the copyright notice and this notice are preserved.
639
640AC_DEFUN([AX_LIB_SQLITE3],
641[
642    AC_ARG_WITH([sqlite3],
643        AC_HELP_STRING(
644            [--with-sqlite3=@<:@ARG@:>@],
645            [use SQLite 3 library @<:@default=yes@:>@, optionally specify the prefix for sqlite3 library]
646        ),
647        [
648        if test "$withval" = "no"; then
649            WANT_SQLITE3="no"
650        elif test "$withval" = "yes"; then
651            WANT_SQLITE3="yes"
652            ac_sqlite3_path=""
653        else
654            WANT_SQLITE3="yes"
655            ac_sqlite3_path="$withval"
656        fi
657        ],
658        [WANT_SQLITE3="yes"]
659    )
660
661    SQLITE3_CFLAGS=""
662    SQLITE3_LDFLAGS=""
663    SQLITE3_VERSION=""
664
665    if test "x$WANT_SQLITE3" = "xyes"; then
666
667        ac_sqlite3_header="sqlite3.h"
668
669        sqlite3_version_req=ifelse([$1], [], [3.0.0], [$1])
670        sqlite3_version_req_shorten=`expr $sqlite3_version_req : '\([[0-9]]*\.[[0-9]]*\)'`
671        sqlite3_version_req_major=`expr $sqlite3_version_req : '\([[0-9]]*\)'`
672        sqlite3_version_req_minor=`expr $sqlite3_version_req : '[[0-9]]*\.\([[0-9]]*\)'`
673        sqlite3_version_req_micro=`expr $sqlite3_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
674        if test "x$sqlite3_version_req_micro" = "x" ; then
675            sqlite3_version_req_micro="0"
676        fi
677
678        sqlite3_version_req_number=`expr $sqlite3_version_req_major \* 1000000 \
679                                   \+ $sqlite3_version_req_minor \* 1000 \
680                                   \+ $sqlite3_version_req_micro`
681
682        AC_MSG_CHECKING([for SQLite3 library >= $sqlite3_version_req])
683
684        if test "$ac_sqlite3_path" != ""; then
685            ac_sqlite3_ldflags="-L$ac_sqlite3_path/lib"
686            ac_sqlite3_cppflags="-I$ac_sqlite3_path/include"
687        else
688            for ac_sqlite3_path_tmp in /usr /usr/local /opt ; do
689                if test -f "$ac_sqlite3_path_tmp/include/$ac_sqlite3_header" \
690                    && test -r "$ac_sqlite3_path_tmp/include/$ac_sqlite3_header"; then
691                    ac_sqlite3_path=$ac_sqlite3_path_tmp
692                    ac_sqlite3_cppflags="-I$ac_sqlite3_path_tmp/include"
693                    ac_sqlite3_ldflags="-L$ac_sqlite3_path_tmp/lib"
694                    break;
695                fi
696            done
697        fi
698
699        ac_sqlite3_ldflags="$ac_sqlite3_ldflags -lsqlite3"
700
701        saved_CPPFLAGS="$CPPFLAGS"
702        CPPFLAGS="$CPPFLAGS $ac_sqlite3_cppflags"
703        AC_COMPILE_IFELSE(
704            [
705            AC_LANG_PROGRAM([[@%:@include <sqlite3.h>]],
706                [[
707#if (SQLITE_VERSION_NUMBER >= $sqlite3_version_req_number)
708/* Everything is okay */
709#else
710#  error SQLite version is too old
711#endif
712                ]]
713            )
714            ],
715            [
716            AC_MSG_RESULT([yes])
717            success="yes"
718            ],
719            [
720            AC_MSG_RESULT([not found])
721            succees="no"
722            ]
723        )
724
725        CPPFLAGS="$saved_CPPFLAGS"
726
727        if test "$success" = "yes"; then
728
729            SQLITE3_CFLAGS="$ac_sqlite3_cppflags"
730            SQLITE3_LDFLAGS="$ac_sqlite3_ldflags"
731
732            ac_sqlite3_header_path="$ac_sqlite3_path/include/$ac_sqlite3_header"
733
734            dnl Retrieve SQLite release version
735            if test "x$ac_sqlite3_header_path" != "x"; then
736                ac_sqlite3_version=`cat $ac_sqlite3_header_path \
737                    | grep '#define.*SQLITE_VERSION.*\"' | sed -e 's/.* "//' \
738                        | sed -e 's/"//'`
739                if test $ac_sqlite3_version != ""; then
740                    SQLITE3_VERSION=$ac_sqlite3_version
741                else
742                    AC_MSG_WARN([Can not find SQLITE_VERSION macro in sqlite3.h header to retrieve SQLite version!])
743                fi
744            fi
745
746            AC_SUBST(SQLITE3_CFLAGS)
747            AC_SUBST(SQLITE3_LDFLAGS)
748            AC_SUBST(SQLITE3_VERSION)
749            AC_DEFINE(HAVE_SQLITE3)
750        fi
751    fi
752])
753##### http://autoconf-archive.cryp.to/ax_c___attribute__.html
754#
755# SYNOPSIS
756#
757#   AX_C___ATTRIBUTE__
758#
759# DESCRIPTION
760#
761#   Provides a test for the compiler support of __attribute__
762#   extensions. defines HAVE___ATTRIBUTE__ if it is found.
763#
764#   Originating from the 'pork' package by Ryan McCabe <ryan@numb.org>
765#
766# LAST MODIFICATION
767#
768#   2005-01-21
769#
770# COPYLEFT
771#
772#   Copyright (c) 2005 Christian Haggstrom <chm@c00.info>
773#
774#   This program is free software; you can redistribute it and/or
775#   modify it under the terms of the GNU General Public License as
776#   published by the Free Software Foundation; either version 2 of the
777#   License, or (at your option) any later version.
778#
779#   This program is distributed in the hope that it will be useful, but
780#   WITHOUT ANY WARRANTY; without even the implied warranty of
781#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
782#   General Public License for more details.
783#
784#   You should have received a copy of the GNU General Public License
785#   along with this program; if not, write to the Free Software
786#   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
787#   02111-1307, USA.
788#
789#   As a special exception, the respective Autoconf Macro's copyright
790#   owner gives unlimited permission to copy, distribute and modify the
791#   configure scripts that are the output of Autoconf when processing
792#   the Macro. You need not follow the terms of the GNU General Public
793#   License when using or distributing such scripts, even though
794#   portions of the text of the Macro appear in them. The GNU General
795#   Public License (GPL) does govern all other use of the material that
796#   constitutes the Autoconf Macro.
797#
798#   This special exception to the GPL applies to versions of the
799#   Autoconf Macro released by the Autoconf Macro Archive. When you
800#   make and distribute a modified version of the Autoconf Macro, you
801#   may extend this special exception to the GPL to apply to your
802#   modified version as well.
803
804AC_DEFUN([AX_C___ATTRIBUTE__],
805  [AC_MSG_CHECKING(for __attribute__)
806  AC_CACHE_VAL(ac_cv___attribute__, [
807    AC_TRY_COMPILE(
808      [#include <stdlib.h>
809      static void foo(void) __attribute__ ((unused));
810      static void
811      foo(void) {
812          exit(1);
813      }],,
814      ac_cv___attribute__=yes,
815      ac_cv___attribute__=no
816    )])
817  if test "$ac_cv___attribute__" = "yes"; then
818    AC_DEFINE(HAVE___ATTRIBUTE__, 1, [define if your compiler has __attribute__])
819  fi
820  AC_MSG_RESULT($ac_cv___attribute__)
821])
822##### http://autoconf-archive.cryp.to/ax_gcc_malloc_call.html
823#
824# SYNOPSIS
825#
826#   AX_GCC_MALLOC_CALL
827#
828# DESCRIPTION
829#
830#   The macro will compile a test program to see whether the compiler
831#   does understand the per-function postfix pragma.
832#
833# LAST MODIFICATION
834#
835#   2006-08-10
836#
837# COPYLEFT
838#
839#   Copyright (c) 2006 Guido U. Draheim <guidod@gmx.de>
840#
841#   This program is free software; you can redistribute it and/or
842#   modify it under the terms of the GNU General Public License as
843#   published by the Free Software Foundation; either version 2 of the
844#   License, or (at your option) any later version.
845#
846#   This program is distributed in the hope that it will be useful, but
847#   WITHOUT ANY WARRANTY; without even the implied warranty of
848#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
849#   General Public License for more details.
850#
851#   You should have received a copy of the GNU General Public License
852#   along with this program; if not, write to the Free Software
853#   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
854#   02111-1307, USA.
855#
856#   As a special exception, the respective Autoconf Macro's copyright
857#   owner gives unlimited permission to copy, distribute and modify the
858#   configure scripts that are the output of Autoconf when processing
859#   the Macro. You need not follow the terms of the GNU General Public
860#   License when using or distributing such scripts, even though
861#   portions of the text of the Macro appear in them. The GNU General
862#   Public License (GPL) does govern all other use of the material that
863#   constitutes the Autoconf Macro.
864#
865#   This special exception to the GPL applies to versions of the
866#   Autoconf Macro released by the Autoconf Macro Archive. When you
867#   make and distribute a modified version of the Autoconf Macro, you
868#   may extend this special exception to the GPL to apply to your
869#   modified version as well.
870
871AC_DEFUN([AX_GCC_MALLOC_CALL],[dnl
872AC_CACHE_CHECK(
873 [whether the compiler supports function __attribute__((__malloc__))],
874 ax_cv_gcc_malloc_call,[
875 AC_TRY_COMPILE([__attribute__((__malloc__))
876 int f(int i) { return i; }],
877 [],
878 ax_cv_gcc_malloc_call=yes, ax_cv_gcc_malloc_call=no)])
879 if test "$ax_cv_gcc_malloc_call" = yes; then
880   AC_DEFINE([GCC_MALLOC_CALL],[__attribute__((__malloc__))],
881    [most gcc compilers know a function __attribute__((__malloc__))])
882 fi
883])
Note: See TracBrowser for help on using the browser.