root/trunk/configure.ac

Revision 1652, 30.6 KB (checked in by jtv, 6 weeks ago)

Peter Geoghegan's error-verbosity patch.

Line 
1#
2# CAUTION: THE configure.ac FILE IS AUTOMATICALLY GENERATED!  DO NOT EDIT IT.
3#
4# If you want to make changes to configure.ac, edit configure.ac.in instead.
5#
6# Process configure.ac.in with autoconf to produce a configure script.
7
8# All text in libpqxx is pure ASCII, so we can afford the "C" locale which is
9# likely to be faster than any other.  This may also work around bugs in some
10# environments, esp. with UTF-8 locales.
11LC_ALL=C
12
13AC_PREREQ(2.59)
14AC_INIT(libpqxx, 3.2, [Jeroen T. Vermeulen <jtv@xs4all.nl>])
15AC_LANG(C++)
16AC_CONFIG_AUX_DIR(config)
17AC_CONFIG_MACRO_DIR([config/m4])
18AM_INIT_AUTOMAKE(libpqxx, 3.2)
19
20PQXXVERSION=3.2
21PQXX_ABI=3.2
22PQXX_MAJOR=3
23PQXX_MINOR=2
24AC_SUBST(PQXXVERSION)
25AC_SUBST(PQXX_ABI)
26AC_SUBST(PQXX_MAJOR)
27AC_SUBST(PQXX_MINOR)
28
29AC_CONFIG_SRCDIR([src/connection.cxx])
30AC_CONFIG_HEADER([include/pqxx/config.h])
31
32# default prefix for installs
33AC_PREFIX_DEFAULT(/usr/local)
34
35# Checks for programs.
36AC_PROG_CXX
37AC_PROG_CC
38AC_PROG_INSTALL
39AC_DISABLE_SHARED
40AC_PROG_LIBTOOL
41AC_PROG_MAKE_SET
42AC_PATH_PROG([MKDIR], [mkdir])
43AC_PATH_PROG([DOXYGEN], [doxygen])
44AM_CONDITIONAL([BUILD_REFERENCE], [test -n "$DOXYGEN"])
45AC_CHECK_PROG(HAVE_DOT, dot, YES, NO)
46AC_PATH_PROG([XMLTO], [xmlto])
47AC_PATH_PROG([PKG_CONFIG], [pkg-config])
48AM_CONDITIONAL([BUILD_TUTORIAL], [test -n "$XMLTO"])
49
50
51AM_MAINTAINER_MODE
52
53# see if we want verbose compiler warnings
54AC_MSG_CHECKING([maintainer mode])
55AC_ARG_ENABLE(maintainer-mode)
56AC_MSG_RESULT(${enable_maintainer_mode})
57
58AC_ARG_ENABLE(shared)
59if test "${shared}" = "yes" ; then
60        CPPFLAGS="$CPPFLAGS -DPQXX_SHARED"
61fi
62
63# Add options to compiler command line, if compiler accepts it
64add_compiler_opts() {
65        for option in $* ; do
66                ACO_SAVE_CXXFLAGS="$CXXFLAGS"
67                CXXFLAGS="$CXXFLAGS $option"
68                AC_MSG_CHECKING([whether $CXX accepts $option])
69                AC_TRY_COMPILE([], [], has_option=yes, has_option=no,)
70                AC_MSG_RESULT($has_option)
71                if test "$has_option" = "no" ; then
72                        CXXFLAGS="$ACO_SAVE_CXXFLAGS"
73                fi
74        done
75}
76
77
78# Let's try to get the compiler to be helpful
79# (Omit options -Weffc++ and -Wabi because they currently yield too many
80# warnings in gcc's standard headers; omit -Wunreachable-code because it isn't
81# always right)
82if test "$GCC" = "yes" ; then
83        # In maintainer mode, enable all the warning options we can
84        if test "$enable_maintainer_mode" = "yes"; then
85                add_compiler_opts \
86                        -Werror \
87                        -Wno-div-by-zero \
88                        -ffor-scope \
89                        -fstrict-aliasing \
90                        -Wstrict-aliasing \
91                        -funit-at-a-time \
92                        -pedantic \
93                        -fno-nonansi-builtins \
94                        -Wall \
95                        -Wmultichar \
96                        -W \
97                        -Wextra \
98                        -Wfloat-equal \
99                        -Wundef \
100                        -Wshadow \
101                        -Wpointer-arith  \
102                        -Wcast-qual  \
103                        -Wcast-align  \
104                        -Wconversion \
105                        -Wctor-dtor-privacy \
106                        -Wc++-compat \
107                        -Wendif-labels \
108                        -Wlogical-op \
109                        -Woverlength-strings \
110                        -Wpointer-sign \
111                        -Wredundant-decls \
112                        -Wsign-compare \
113                        -Wwrite-strings  \
114                        -Wnon-virtual-dtor \
115                        -Wreorder \
116                        -Wold-style-cast \
117                        -Woverloaded-virtual \
118                        -Wsign-promo \
119                        -Wstrict-null-sentinel \
120                        -Wformat-security \
121                        -Wnonnull \
122                        -Winit-self \
123                        -Wswitch \
124                        -Wmissing-field-initializers \
125                        -Wmissing-include-dirs \
126                        -Wunused \
127                        -funit-at-a-time
128        fi
129
130        if test "$enable_long_long" = "yes" ; then
131                add_compiler_opts -Wno-long-long
132        fi
133
134AC_MSG_CHECKING([g++ visibility attribute])
135gcc_visibility=yes
136SAVE_CXXFLAGS="$CXXFLAGS"
137CXXFLAGS="$CXXFLAGS -Werror"
138AC_TRY_COMPILE([
139struct __attribute__ ((visibility("hidden"))) d { d() {} void f() {} };
140        ],
141        [d D;D.f()],
142        AC_DEFINE([PQXX_HAVE_GCC_VISIBILITY],1,
143                [Define if g++ supports visibility attribute, as in g++ 4.0]),
144        gcc_visibility=no)
145AC_MSG_RESULT($gcc_visibility)
146        if test "$gcc_visibility" = "yes" ; then
147                # Setting default symbol visibility to "hidden" vastly reduces
148                # library size with g++ 4.0, but unfortunately this will require
149                # some more work in the libpqxx setup.  Instead, we make only
150                # inline functions hidden.
151                add_compiler_opts -fvisibility-inlines-hidden
152                #add_compiler_opts -fvisibility=hidden
153        fi
154CXXFLAGS="$SAVE_CXXFLAGS"
155
156AC_MSG_CHECKING([g++ deprecation attribute])
157gcc_deprecated=yes
158AC_TRY_COMPILE([void f() __attribute__ ((deprecated));],
159        [],
160        AC_DEFINE([PQXX_HAVE_GCC_DEPRECATED],1,
161                [Define if g++ supports deprecated attribute, as in g++ 4.0]),
162        gcc_deprecated=no)
163AC_MSG_RESULT($gcc_deprecated)
164
165fi
166
167# Determine name of standard namespace.  PGSTD will be set to this name.  The
168# --with-std= option takes precedence if given; otherwise, several alternatives
169# are tried.
170# As a special case, if the argument to the --with-std option is "yes" (as would
171# be the case if the user specified the option but no argument for it), the
172# guessing logic is enabled as if the option had not been used.
173AH_TEMPLATE(PGSTD,[name of standard library namespace (normally "std")])
174AC_MSG_CHECKING([name of standard library namespace (normally "std")])
175guessstd=no
176AC_ARG_WITH(std,
177        AC_HELP_STRING(
178                [--with-std],
179                [name of standard library namespace (normally "std")]),
180        [std=${withval};],
181        [guessstd=yes])
182
183if test "${guessstd}" = "yes" -o "${withval}" = "yes"; then
184        # No explicit std namespace given.  Check for alternative "standard"
185        # namespaces, in order of preference.
186        for ns in std _STL stlp_std "" ; do
187                AC_COMPILE_IFELSE([#include <string>
188                        ${ns}::string justastring;],
189                        [std="${ns}"; break])
190        done
191fi
192AC_DEFINE_UNQUOTED(
193        PGSTD,
194        [$std],
195        [name of standard library namespace (normally "std")])
196if ! test -z "${std}" ; then
197        AC_MSG_RESULT([::${std}])
198        usestd="using namespace ${std};"
199else
200        AC_MSG_RESULT([::])
201fi
202
203
204boost_smart_ptr=yes
205AC_CHECK_HEADER(boost/smart_ptr.hpp, AC_DEFINE(PQXX_HAVE_BOOST_SMART_PTR, 1,
206        [Define if you have the <boost/smart_ptr.hpp> header]),
207        boost_smart_ptr=no)
208
209
210AC_MSG_CHECKING([whether TR1 headers live in tr1 directory])
211tr1headers=yes
212AC_TRY_COMPILE(
213        [#include <tr1/memory>],
214        [],
215        AC_DEFINE(
216                [PQXX_TR1_HEADERS],
217                1,
218                [Define if headers for TR1 extension to standard live in tr1/]),
219        tr1headers=no)
220AC_MSG_RESULT($tr1headers)
221
222if test "${tr1headers}" = "yes" ; then
223        tr1dir="tr1/"
224else
225        tr1dir=""
226fi
227
228AH_TEMPLATE(PQXXTR1, [namespace of TR1 extension to the C++ standard])
229AC_MSG_CHECKING([namespace of TR1 extension to the C++ standard])
230guesstr1=no
231AC_ARG_WITH(
232        tr1,
233        AC_HELP_STRING(
234                [--with-tr1],
235                [namespace of TR1 extension to the C++ standard]),
236        [tr1=${withval};],
237        [guesstr1=yes])
238
239if test "${guesstr1}" = "yes" ; then
240        # No explicit TR1 namespace given.  Try PGSTD::tr1.  If that doesn't
241        # work, assume PGSTD as our best bet.
242        tr1="${std}::tr1"
243        AC_TRY_COMPILE(
244                [#include <${tr1dir}memory>],
245                [using namespace ${tr1}],
246                [],
247                [tr1=${std}])
248fi
249AC_DEFINE_UNQUOTED(
250        PQXXTR1,
251        [$tr1],
252        [namespace of TR1 standard extensions (e.g. "std" or "std::tr1")])
253AC_MSG_RESULT([$tr1])
254
255ioshdr=yes
256AC_CHECK_HEADER(ios,AC_DEFINE(PQXX_HAVE_IOS,1,
257[Define if you have the <ios> header]),
258ioshdr=no)
259
260streambuf=yes
261AC_CHECK_HEADER(streambuf,AC_DEFINE(PQXX_HAVE_STREAMBUF,1,
262[Define if you have the <streambuf> header; if not, <streambuf.h> is used]),
263streambuf=no)
264
265localehdr=yes
266AC_CHECK_HEADER(locale,AC_DEFINE(PQXX_HAVE_LOCALE,1,
267[Define if you have the <locale> header]),
268localehdr=no)
269
270imbue=yes
271AC_MSG_CHECKING([locale function and stringstream::imbue])
272AC_TRY_COMPILE([#include <sstream>
273        #ifdef PQXX_HAVE_LOCALE
274        #include <locale>
275        #endif
276        ${usestd}],
277        [stringstream S; S.imbue(locale("C"))],
278        [AC_DEFINE(PQXX_HAVE_IMBUE, 1, [Define if stringstream::imbue works])],
279        [imbue=no])
280AC_MSG_RESULT($imbue)
281
282AC_MSG_CHECKING([char_traits template])
283char_traits=yes
284AC_TRY_COMPILE([#include <string>
285        ${usestd}],
286        [char_traits<char>::eof()],
287        AC_DEFINE(PQXX_HAVE_CHAR_TRAITS, 1,
288[Define if std provides the char_traits template and <char> specialization]),
289char_traits=no)
290AC_MSG_RESULT($char_traits)
291
292AC_MSG_CHECKING(["warning" preprocessor directive])
293cpp_warning=yes
294AC_TRY_COMPILE([#warning cpp supports warning directive], [], AC_DEFINE(PQXX_HAVE_CPP_WARNING, 1,
295[Define if preprocessor supports nonstandard "warning" directive]),
296cpp_warning=no)
297AC_MSG_RESULT($cpp_warning)
298
299AC_MSG_CHECKING(["message" preprocessor pragma])
300cpp_pragma_message=yes
301AC_TRY_COMPILE([#pragma message("cpp supports message pragma")], [], AC_DEFINE(PQXX_HAVE_CPP_PRAGMA_MESSAGE, 1,
302[Define if preprocessor supports pragma "message"]),
303cpp_pragma_message=no)
304AC_MSG_RESULT($cpp_pragma_message)
305
306# Find PostgreSQL includes and libraries
307AC_PATH_PROGS(PG_CONFIG, pg_config)
308if test -z "$PG_CONFIG" || test ! -r "$PG_CONFIG"; then
309        AC_MSG_ERROR([
310PostgreSQL configuration script pg_config not found.  Make sure this is in your
311command path before configuring.  Without it, the configure script has no way to
312find the right location for the libpq library and its headers.
313])
314fi
315with_postgres_include=`$PG_CONFIG --includedir`
316AC_MSG_NOTICE([using PostgreSQL headers at $with_postgres_include])
317with_postgres_lib=`$PG_CONFIG --libdir`
318AC_MSG_NOTICE([using PostgreSQL libraries at $with_postgres_lib])
319
320AC_SUBST(with_postgres_lib)
321AC_SUBST(with_postgres_include)
322#POSTGRES_LIB="-R${with_postgres_lib}"
323AC_SUBST(POSTGRES_LIB)
324POSTGRES_INCLUDE="-I${with_postgres_include}"
325AC_SUBST(POSTGRES_INCLUDE)
326
327
328AC_HEADER_STDC
329
330AC_MSG_CHECKING([ability to compile programs using the standard C library])
331AC_TRY_COMPILE([#include <string.h>
332        ${usestd}
333        extern void f(size_t);],
334        [f(strlen(""))],[],
335        [AC_MSG_ERROR([
336Could not build even a tiny test program using the standard C library.
337
338Something very basic has gone wrong; try reading config.log to find out what.
339You'll probably want to go straight to the end of that file and read backwards
340until you find an error message.  Then identify the problem, try to fix it, and
341run this script again.
342
343The configure script's --help option may provide useful tips on how to influence
344what compiler and command line options are used, what additional libraries are
345linked in, and so on.
346])])
347AC_MSG_RESULT(yes)
348
349
350# After this check, we should be able to link socket-based programs.
351socklibok=no
352AC_SEARCH_LIBS(select, socket nsl ws2_32 wsock32 winsock, [socklibok=yes])
353
354# Microsoft proprietary libraries do not work with code that is generated with
355# autoconf's SEARCH_LIBS macro, so we need to check manually and just use the
356# first socket library available.
357# We only do this if select() is not available by other means, to avoid picking
358# up an unnecessary Windows compatibility library on a non-Windows system.
359for l in ws2_32 wsock32 winsock ; do
360        if test "${socklibok}" != "yes" ; then
361                AC_CHECK_LIB($l,main,LIBS="$LIBS -l$l";[socklibok=yes])
362        fi
363done
364
365if test "${socklibok}" != "yes" ; then
366        AC_MSG_ERROR([
367Could not figure out how to link a simple sockets-based program.  Please read
368the config.log file for more clues as to why this failed.
369])
370fi
371
372
373AC_CHECK_HEADER([${with_postgres_include}/libpq-fe.h],[],[AC_MSG_ERROR([
374Can't find libpq-fe.h in ${with_postgres_include}.  Are you sure the libpq
375headers are installed correctly?  They should be in the directory returned by
376"pg_config --includedir".
377
378If you do have libpq (the C-language client library for PostgreSQL) installed,
379make sure you have the related development materials--mainly its header files--
380as well as the library binary.  Some system distributions keep the two in
381seperate packages with names like "alibrary" and "alibrary-dev", respectively.
382In that case, make sure you have the latter installed as well.
383])])
384
385
386AC_MSG_CHECKING([for ability to compile source files using libpq])
387AC_TRY_COMPILE([#include<${with_postgres_include}/libpq-fe.h>],[PQexec(0,"")],
388[],
389[AC_MSG_ERROR([
390Could not compile a call to a basic libpq function.  There must be something
391seriously wrong with the headers that "pg_config --includedir" pointed to; the
392contents of config.log may give you a clue about the nature of the failure.
393Source including the libpq header libpq-fe.h can be compiled, but a call to the
394most basic libpq function PQexec() failed to compile successfully.  This is the
395litmus test for a working libpq.
396])])
397AC_MSG_RESULT(yes)
398
399# Perform this check in C; autoconf's AC_HAVE_LIBRARY breaks in C++ because it
400# tries to call main()
401AC_LANG_PUSH(C)
402
403LDFLAGS="$LDFLAGS -L${with_postgres_lib}"
404
405AC_HAVE_LIBRARY(pq, [], [AC_MSG_ERROR([
406Could not link to libpq.  Make sure you have the PostgreSQL client library
407installed, and that the library binary can be found in the location returned by
408"pg_config --libdir".
409])], -L${with_postgres_lib})
410
411AC_CHECK_LIB([pq], [PQexec],[], [AC_MSG_ERROR([
412Did not find the PQexec() function in libpq.  This is the litmus test for a
413working libpq installation.
414
415A source file using the PQexec() function did compile without problems, and the
416libpq library is available for linking, but for some reason a call to PQexec()
417failed to link properly to the libpq library.  This may be because the libpq
418library file is damaged, or in some incorrect format. or if your libpq is much
419more recent than libpqxx version 3.2, perhaps libpq has undergone a
420radical ABI change.
421
422The last parts of config.log may give you a clue as to what really went wrong,
423but be warned that this is no easy reading.  Look for the last error message
424occurring in the file.
425])], -L${with_postgres_lib})
426
427# Remove redundant occurrances of -lpq
428LIBS="`echo "$LIBS" | sed -e 's/-lpq[[:space:]]*[[:space:]]-lpq\>/-lpq/g'`"
429
430AC_LANG_POP(C)
431
432AC_MSG_CHECKING([for correct C++ linkage of basic libpq functions])
433if test "$enable_maintainer_mode" = "yes"; then
434AC_LINK_IFELSE([
435#include <${with_postgres_include}/libpq-fe.h>
436int main(){return !PQexec(0,0);}],
437[],
438[AC_MSG_ERROR([
439Linking a call to libpq failed in C++, even though it succeeded in C.  If your
440C and C++ compilers are very different beasts, this may mean that we do not have
441the right options for linking with it after all.  Alternatively, this may be
442caused by a bug in autoconf or automake.
443
444Since you are configuring libpqxx using the --enable-maintainer-mode option, any
445compiler warnings for autoconf test programs will be treated as errors.  The
446problem may just go away if you run the configure script again but with the
447maintainer mode option omitted.  Please report such cases (including the
448config.log produced by the failed attempt) so future versions can attempt to
449work around the problem.
450
451Should this error occur even while not in maintainer mode, read the config.log
452file for more detailed information.  Look for the last error message, which may
453be several pages up from the end of the file.
454])])
455else
456AC_LINK_IFELSE([
457#include <${with_postgres_include}/libpq-fe.h>
458int main(){return !PQexec(0,0);}],
459[],
460[AC_MSG_ERROR([
461Linking a call to libpq failed in C++, even though it succeeded in C.  If your
462C and C++ compilers are very different beasts, this may mean that we do not have
463the right options for linking with it after all.
464
465Read the config.log file for more detailed information.  Look for the last error
466message, which may be several pages up from the end of the file.
467])])
468fi
469AC_MSG_RESULT(yes)
470
471
472AC_MSG_CHECKING([that type of libpq's Oid is as expected])
473AC_TRY_COMPILE([#include<${with_postgres_include}/libpq-fe.h>
474        #include"${srcdir}/include/pqxx/libpq-forward.hxx"
475        extern void f(pqxx::oid&);],
476        [Oid o;f(o)],
477        [],
478        [AC_MSG_ERROR([
479The Oid typedef in libpq has changed.  Please notify the libpqxx authors of the
480change!
481])])
482AC_MSG_RESULT(yes)
483
484AC_MSG_CHECKING([lo_tell()])
485lotell=yes
486AC_TRY_COMPILE([#include<${with_postgres_include}/libpq-fe.h>
487        void f(PGconn *c) { lo_tell(c,2); }],
488        [],
489        AC_DEFINE(PQXX_HAVE_LO_TELL, 1,
490                [Define if libpq has lo_tell()]),
491        [lotell=no]
492)
493AC_MSG_RESULT($lotell)
494
495
496AC_MSG_CHECKING([for strerror_r])
497strerror_r=yes
498AC_TRY_COMPILE(
499        [#include <cstring>
500        ${usestd}
501        bool f(char x[]) { return strerror_r(0,x,10) != 0; }],
502        [],
503        [AC_DEFINE(PQXX_HAVE_STRERROR_R,1,[Define if strerror_r exists])],
504        [strerror_r=no])
505AC_MSG_RESULT($strerror_r)
506if test "$strerror_r" != "yes" ; then
507        AC_MSG_WARN([
508No definition of strerror_r, the thread-safe version of strerror(), was found in
509your <cstring> header.
510
511This may be because your implementation strerror() is threadsafe, in which case
512there is nothing to worry about.
513])
514fi # strerror_r
515
516
517AC_MSG_CHECKING([for strnlen])
518strnlen=yes
519AC_TRY_COMPILE(
520        [#include <cstring>
521        ${usestd}],
522        [return strnlen("",1)],
523        [AC_DEFINE(PQXX_HAVE_STRNLEN,1,[Define if strnlen exists])],
524        strnlen=no)
525AC_MSG_RESULT($strnlen)
526
527AC_MSG_CHECKING([for strlcpy])
528strlcpy=yes
529AC_TRY_COMPILE(
530        [#include <cstring>
531        ${usestd}],
532        [char buf[2];return strlcpy(buf,"",1)],
533        [AC_DEFINE(PQXX_HAVE_STRLCPY,1,[Define if strlcpy exists])],
534        strlcpy=no)
535AC_MSG_RESULT($strlcpy)
536
537AC_MSG_CHECKING([for long long])
538long_long=yes
539AC_TRY_COMPILE(,[long long l=0LL; return int(l)],
540        AC_DEFINE(PQXX_HAVE_LONG_LONG,1,
541        [Define if the compiler supports "long long" types]),
542        long_long=no)
543AC_MSG_RESULT($long_long)
544
545AC_MSG_CHECKING([for long double])
546long_double=yes
547AC_TRY_COMPILE(,[long double x=0;return int(x)],
548        AC_DEFINE(PQXX_HAVE_LONG_DOUBLE,1,
549        [Define if the compiler supports the standard "long double" type]),
550        long_double=no)
551AC_MSG_RESULT($long_double)
552
553AC_MSG_CHECKING([for working <sys/select.h>])
554select_h=yes
555AC_TRY_COMPILE(
556        [#include <cstring>
557#include <sys/select.h>
558${usestd}]
559        , [select(0,0,0,0,0)]
560        , AC_DEFINE(PQXX_HAVE_SYS_SELECT_H,1,
561[Define if the sys/select.h header defines a working select() and friends, as per POSIX 1003.1-2001])
562        ,select_h=no
563)
564AC_MSG_RESULT($select_h)
565
566
567AC_MSG_CHECKING([for poll()])
568poll=yes
569AC_TRY_COMPILE(
570        [#include <poll.h>
571${usestd}],
572        [pollfd p = { 0,0,0 }; poll(&p,1,0)],
573        AC_DEFINE(PQXX_HAVE_POLL,1,
574[Define if the system has the poll() function (mainly GNU/Linux)]),
575        poll=no
576)
577AC_MSG_RESULT($poll)
578
579
580# Long-standing annoyance in glibc: the definition for FD_SET includes an
581# unnecessary C-style cast that the compiler may warn for.  If the compiler is
582# configured to treat warnings as errors, that may be a problem for us.
583AC_MSG_CHECKING([for working fd_set])
584if test "$enable_maintainer_mode" = "yes"; then
585AC_TRY_COMPILE(
586[#include <cstring>
587#ifdef PQXX_HAVE_SYS_SELECT_H
588#include <sys/select.h>
589#else
590#include <ctime>
591#include <sys/types.h>
592#endif
593#ifdef HAVE_UNISTD_H
594#include <unistd.h>
595#endif
596#ifdef _WIN32
597#include <winsock2.h>
598#endif
599${usestd}
600extern "C" void f() { fd_set s; FD_ZERO(&s); FD_SET(1, &s); }],
601        [],
602        [],
603        [AC_MSG_ERROR([
604Could not compile code using fd_set.  This may be a known problem with GNU libc
605and the extremely strict compiler options used in libpqxx's maintainer mode; try
606configuring again, this time omitting the --enable-maintainer-mode option.
607])])
608else
609AC_TRY_COMPILE(
610[#include <cstring>
611#ifdef PQXX_HAVE_SYS_SELECT_H
612#include <sys/select.h>
613#else
614#include <ctime>
615#include <sys/types.h>
616#endif
617#ifdef HAVE_UNISTD_H
618#include <unistd.h>
619#endif
620#ifdef _WIN32
621#include <winsock2.h>
622#endif
623${usestd}],
624        [fd_set s;FD_ZERO(&s);FD_SET(1,&s)],
625        [],
626        [AC_MSG_ERROR([
627Could not compile code using fd_set.  There is something seriously wrong, or
628maybe your warning options are too strict.  If you are using GNU libc (as will
629be the case on a GNU/Linux system) and are telling the compiler to treat
630warnings as errors, the cause may be an old-style cast in the definition of
631FD_SET that triggers a compiler warning.
632
633See config.log for more details; look for the last error message in the file.
634])])
635fi
636AC_MSG_RESULT(yes)
637
638
639AC_MSG_CHECKING([if select() accepts NULL fdsets])
640select_accepts_null=yes
641AC_RUN_IFELSE(
642[#ifdef PQXX_HAVE_SYS_SELECT_H
643#include <sys/select.h>
644#else
645#include <ctime>
646#include <sys/types.h>
647#endif
648#ifdef HAVE_UNISTD_H
649#include <unistd.h>
650#endif
651#ifdef _WIN32
652#include <winsock2.h>
653#endif
654${usestd}
655extern "C" int foo(){fd_set f; FD_SET(1,&f); return select(2,0,&f,&f,0)<0;}
656int main() { return foo(); }],
657        AC_DEFINE(PQXX_SELECT_ACCEPTS_NULL,1,
658[Define if select() accepts NULL fd_set arguments]),
659        select_accepts_null=no,
660        select_accepts_null=no
661)
662AC_MSG_RESULT($select_accepts_null)
663
664
665AC_MSG_CHECKING([sleep()])
666sleep=yes
667AC_TRY_COMPILE([#ifdef HAVE_UNISTD_H
668#include <unistd.h>
669#endif
670        ${usestd}],[sleep(0x01)],
671        AC_DEFINE(PQXX_HAVE_SLEEP, 1, [Define if POSIX sleep() exists]),
672        [sleep=no]
673)
674AC_MSG_RESULT($sleep)
675
676AC_MSG_CHECKING([PQisthreadsafe()])
677pqisthreadsafe=yes
678AC_TRY_COMPILE(
679        [#include<${with_postgres_include}/libpq-fe.h>],
680        [PQisthreadsafe()],
681        AC_DEFINE(
682                PQXX_HAVE_PQISTHREADSAFE,
683                1,
684                [Define if libpq has PQisthreadsafe()]),
685        [pqisthreadsafe=no])
686AC_MSG_RESULT($pqisthreadsafe)
687
688AC_MSG_CHECKING([PQserverVersion()])
689pqserverversion=yes
690AC_TRY_COMPILE([#include<${with_postgres_include}/libpq-fe.h>],
691        [PQserverVersion(0)],
692        AC_DEFINE(PQXX_HAVE_PQSERVERVERSION, 1,
693                [Define if libpq has PQserverVersion()]),
694        [pqserverversion=no]
695)
696AC_MSG_RESULT($pqserverversion)
697
698AC_MSG_CHECKING([PQprotocolVersion()])
699pqprotocolversion=yes
700AC_TRY_COMPILE([#include<${with_postgres_include}/libpq-fe.h>],
701        [PQprotocolVersion(0)],
702        AC_DEFINE(PQXX_HAVE_PQPROTOCOLVERSION, 1,
703                [Define if libpq has PQprotocolVersion()]),
704        [pqprotocolversion=no]
705)
706AC_MSG_RESULT($pqprotocolversion)
707
708
709AC_MSG_CHECKING([PQescapeString()])
710pqescapestring=yes
711AC_TRY_COMPILE([#include<${with_postgres_include}/libpq-fe.h>],
712        [char c[1];PQescapeString(c,"",0x01)],
713        AC_DEFINE(PQXX_HAVE_PQESCAPESTRING, 1,
714                [Define if libpq has PQescapeString()]),
715        [pqescapestring=no]
716)
717AC_MSG_RESULT($pqescapestring)
718if test "$pqescapestring" != yes ; then
719        AC_MSG_WARN([
720You appear to be building with a very old libpq version that does not have
721PQescapeString().  This can cause serious problems when non-ASCII data is used
722in SQL strings.
723Please consider upgrading to at least the libpq that came with PostgreSQL 7.2
724before going any further!
725])
726fi
727
728AC_MSG_CHECKING([PQescapeStringConn()])
729pqescapestringconn=yes
730AC_TRY_COMPILE([#include<${with_postgres_include}/libpq-fe.h>],
731        [char b[1];PQescapeStringConn(0,b,b,sizeof(b),0)],
732        AC_DEFINE(PQXX_HAVE_PQESCAPESTRINGCONN, 1,
733                [Define if libpq has PQescapeStringConn()]),
734        [pqescapestringconn=no]
735)
736AC_MSG_RESULT($pqescapestringconn)
737
738AC_MSG_CHECKING([PQescapeBytea()])
739pqescapebytea=yes
740AC_TRY_COMPILE([#include<${with_postgres_include}/libpq-fe.h>
741#include<cstddef>
742${usestd}],
743        [size_t l=0;const unsigned char c[]="";PQescapeBytea(c,1,&l)],
744        AC_DEFINE(PQXX_HAVE_PQESCAPEBYTEA,1,[Define if libpq has PQescapeBytea()]),
745        [pqescapebytea=no]
746)
747AC_MSG_RESULT($pqescapebytea)
748
749AC_MSG_CHECKING([PQescapeByteaConn()])
750pqescapebyteaconn=yes
751AC_TRY_COMPILE([#include<${with_postgres_include}/libpq-fe.h>
752#include<cstddef>
753${usestd}],
754        [unsigned char b[1];size_t c;PQescapeByteaConn(0,b,sizeof(b),&c)],
755        AC_DEFINE(PQXX_HAVE_PQESCAPEBYTEACONN,1,[Define if libpq has PQescapeByteaConn()]),
756        [pqescapebyteaconn=no]
757)
758AC_MSG_RESULT($pqescapebyteaconn)
759
760AC_MSG_CHECKING([PQunescapeBytea()])
761pqunescapebytea=yes
762AC_TRY_COMPILE([#include<${with_postgres_include}/libpq-fe.h>
763        ${usestd}],
764        [size_t l=0;const unsigned char c[]="";PQunescapeBytea(c,&l)],
765        AC_DEFINE(PQXX_HAVE_PQUNESCAPEBYTEA,1,[Define if libpq has PQunescapeBytea()]),
766        [pqunescapebytea=no]
767)
768AC_MSG_RESULT($pqunescapebytea)
769
770AC_MSG_CHECKING([PQfreemem()])
771pqfreemem=yes
772AC_TRY_COMPILE([#include<${with_postgres_include}/libpq-fe.h>],
773        [char c='x';PQfreemem(&c)],
774        AC_DEFINE(PQXX_HAVE_PQFREEMEM,1,[Define if libpq has PQfreemem()]),
775        [pqfreemem=no]
776)
777AC_MSG_RESULT($pqfreemem)
778
779AC_MSG_CHECKING([PQfreeNotify()])
780pqfreenotify=yes
781AC_TRY_COMPILE([#include<${with_postgres_include}/libpq-fe.h>],
782        [char c='x';PQfreeNotify(&c)],
783        AC_DEFINE(PQXX_HAVE_PQFREENOTIFY,1,[Define if libpq has PQfreeNotify()]),
784        [pqfreenotify=no]
785)
786AC_MSG_RESULT($pqfreenotify)
787
788AC_MSG_CHECKING([PQftable()])
789pqftable=yes
790AC_TRY_COMPILE([#include<${with_postgres_include}/libpq-fe.h>],
791        [PGresult*r=0;PQftable(r,0)],
792        AC_DEFINE(PQXX_HAVE_PQFTABLE,1,[Define if libpq has PQftable()]),
793        [pqftable=no]
794)
795AC_MSG_RESULT($pqftable)
796
797AC_MSG_CHECKING([PQftablecol()])
798pqftablecol=yes
799AC_TRY_COMPILE([#include<${with_postgres_include}/libpq-fe.h>],
800        [PGresult*r=0;PQftablecol(r,0)],
801        AC_DEFINE(PQXX_HAVE_PQFTABLECOL,1,[Define if libpq has PQftablecol()]),
802        [pqftablecol=no]
803)
804AC_MSG_RESULT($pqftablecol)
805
806AC_MSG_CHECKING([for new COPY functions])
807pqputcopy=yes
808AC_TRY_COMPILE([#include<${with_postgres_include}/libpq-fe.h>],
809        [PGconn*c=0;PQputCopyData(c,"",0)],
810        AC_DEFINE(PQXX_HAVE_PQPUTCOPY,1,[Define if libpq has PQputCopyData() and related functions]),
811        [pqputcopy=no]
812)
813AC_MSG_RESULT($pqputcopy)
814
815AC_MSG_CHECKING([PQprepare()])
816pqprepare=yes
817AC_TRY_COMPILE([#include<${with_postgres_include}/libpq-fe.h>],
818        [extern PGconn*c;Oid o;PQprepare(c,"","",0,&o)],
819        AC_DEFINE(PQXX_HAVE_PQPREPARE,1,[Define if libpq has PQprepare()]),
820        [pqprepare=no]
821)
822AC_MSG_RESULT($pqprepare)
823
824AC_MSG_CHECKING([PQexecPrepared()])
825pqexecprepared=yes
826AC_TRY_COMPILE([#include<${with_postgres_include}/libpq-fe.h>],
827        [PGconn*c=0;const char*p[1]={0};const int i=0;PQexecPrepared(c,"",i,p,&i,&i,i)],
828        AC_DEFINE(PQXX_HAVE_PQEXECPREPARED,1,[Define if libpq has PQexecPrepared()]),
829        [pqexecprepared=no]
830)
831AC_MSG_RESULT($pqexecprepared)
832
833AC_MSG_CHECKING([PQexecParams()])
834pqexecparams=yes
835AC_TRY_COMPILE([#include<${with_postgres_include}/libpq-fe.h>],
836        [PQexecParams(0, "", 0, 0, 0, 0, 0, 0)],
837        AC_DEFINE(PQXX_HAVE_PQEXECPARAMS,1,[Define if libpq has PQexecParams()]),
838        [pqexecparams=no]
839)
840AC_MSG_RESULT($pqexecparams)
841
842AC_MSG_CHECKING([PQresultErrorField()])
843pqresulterrorfield=yes
844AC_TRY_COMPILE([#include<${with_postgres_include}/libpq-fe.h>],
845        [PGresult*r=0;PQresultErrorField(r,PG_DIAG_STATEMENT_POSITION)],
846        AC_DEFINE(PQXX_HAVE_PQRESULTERRORFIELD,1,[Define if libpq has PQresultErrorField() and PG_DIAG_STATEMENT_POSITION]),
847        [pqresulterrorfield=no]
848)
849AC_MSG_RESULT($pqresulterrorfield)
850
851AC_MSG_CHECKING([PQencryptPassword()])
852pqencryptpassword=yes
853AC_TRY_COMPILE([#include<${with_postgres_include}/libpq-fe.h>],
854        [PQencryptPassword("x","y")],
855        AC_DEFINE(PQXX_HAVE_PQENCRYPTPASSWORD,1,[Define if libpq has PQencryptPassword()]),
856        [pqencryptpassword=no]
857)
858AC_MSG_RESULT($pqencryptpassword)
859
860
861AC_MSG_CHECKING([PQclientEncoding()])
862pqclientencoding=yes
863AC_TRY_COMPILE([#include<${with_postgres_include}/libpq-fe.h>],
864        [return PQclientEncoding(NULL)],
865        AC_DEFINE(PQXX_HAVE_PQCLIENTENCODING,1,[Define if libpq has PQclientEncoding()]),
866        [pqclientencoding=no]
867)
868AC_MSG_RESULT($pqclientencoding)
869
870
871AC_MSG_CHECKING([PQmblen()])
872pqmblen=yes
873AC_TRY_COMPILE([#include<${with_postgres_include}/libpq-fe.h>],
874        [return PQmblen(NULL,1)],
875        AC_DEFINE(PQXX_HAVE_PQMBLEN,1,[Define if libpq has PQmblen()]),
876        [pqmblen=no]
877)
878AC_MSG_RESULT($pqmblen)
879
880
881AC_MSG_CHECKING([PQdescribePortal()])
882pqdescribeportal=yes
883AC_TRY_COMPILE([#include<${with_postgres_include}/libpq-fe.h>],
884        [return PQdescribePortal(NULL, "foo")!=0;],
885        AC_DEFINE(PQXX_HAVE_PQDESCRIBEPORTAL,1,[Define if libpq has PQdescribePortal()]),
886        [pqdescribeportal=no]
887)
888AC_MSG_RESULT($pqdescribeportal)
889
890
891AC_MSG_CHECKING([PQcancel()])
892pqcancel=yes
893AC_TRY_COMPILE([#include<${with_postgres_include}/libpq-fe.h>],
894        [PQcancel(NULL, NULL, 0)],
895        AC_DEFINE(PQXX_HAVE_PQCANCEL, 1,
896                [Define if libpq has PQcancel() and friends]),
897        [pqcancel=no]
898)
899AC_MSG_RESULT($pqcancel)
900
901AC_MSG_CHECKING([PQsetErrorVerbosity()])
902pqverbosity=yes
903AC_TRY_COMPILE([#include<${with_postgres_include}/libpq-fe.h>],
904        [PGconn*c=0;PGVerbosity verb=PQERRORS_DEFAULT;PQsetErrorVerbosity(c, verb)],
905        AC_DEFINE(PQXX_HAVE_PQSETERRORVERBOSITY,1,[Define if libpq has PQsetErrorVerbosity()]),
906        [pqverbosity=no]
907)
908AC_MSG_RESULT($pqverbosity)
909
910AC_CHECK_HEADER(limits,
911        [AC_DEFINE(PQXX_HAVE_LIMITS, 1, [Define if <limits> exists])])
912
913AC_MSG_CHECKING([for C99 isnan()])
914c_isnan=yes
915AC_TRY_COMPILE([#include <cmath>
916        extern double f();
917        ${usestd}],
918        [if(isnan(f())f()],
919        AC_DEFINE(PQXX_HAVE_C_ISNAN,1,[Define if math.h defines C99 isnan()]),
920        [c_isnan=no]
921)
922AC_MSG_RESULT($c_isnan)
923
924AC_MSG_CHECKING([for std::numeric_limits<>::quiet_NaN()])
925quiet_nan=yes
926AC_TRY_COMPILE([#include <limits>
927        extern void f(double);
928        ${usestd}],
929        [f(numeric_limits<double>::quiet_NaN())],
930        [AC_DEFINE(PQXX_HAVE_QUIET_NAN,1,
931                [Define if std::numeric_limits has quiet_NaN()])],
932        [quiet_nan=no])
933AC_MSG_RESULT($quiet_nan)
934
935AC_MSG_CHECKING([for C NAN macro])
936c_nan=yes
937AC_TRY_COMPILE([#include <cmath>
938        extern void f(double);
939        ${usestd}],
940        [f(NAN)],
941        [AC_DEFINE(PQXX_HAVE_C_NAN,1,
942                [Define if C math header defines NAN])],
943        [c_nan=no])
944AC_MSG_RESULT($c_nan)
945
946AC_MSG_CHECKING([for C99 nan() family])
947nan=yes
948AC_TRY_COMPILE([#include <cmath>
949        ${usestd}
950        extern void f(double);],
951        [f(nan(""))],
952        [AC_DEFINE(PQXX_HAVE_NAN,1,
953                [Define if C99 fnan()/nan()/lnan() are available])],
954        [nan=no])
955AC_MSG_RESULT($nan)
956
957AC_MSG_CHECKING([for C99 isinf()])
958c_isnan=yes
959AC_TRY_COMPILE([#include <cmath>
960        extern double f();
961        ${usestd}],
962        [if(isinf(f())f()],
963        AC_DEFINE(PQXX_HAVE_C_ISINF,1,[Define if math.h defines C99 isinf()]),
964        [c_isinf=no]
965)
966AC_MSG_RESULT($c_isinf)
967
968AC_MSG_CHECKING([whether std::string has a clear() function])
969string_clear=yes
970AC_TRY_COMPILE([#include <string>
971        ${usestd}],
972        [string i;i.clear()],
973        [AC_DEFINE(PQXX_HAVE_STRING_CLEAR,
974                        1,
975                        [Define if string class has the clear() function])],
976        [string_clear=no])
977AC_MSG_RESULT($string_clear)
978
979AC_MSG_CHECKING([for standard distance()])
980distance=yes
981AC_TRY_COMPILE([#include <iterator>
982        ${usestd}],
983        [int i[1]; return distance(i, i+1)],
984        [AC_DEFINE(PQXX_HAVE_DISTANCE,
985                1,
986                [Define if distance() works according to the standard])],
987        [distance='no'])
988AC_MSG_RESULT($distance)
989
990AC_MSG_CHECKING([if count_if() works as expected])
991count_if='yes'
992AC_TRY_COMPILE([#include <algorithm>
993#include <functional>
994${usestd}
995struct P{P(){}bool operator()(const int&)const{return false;}}p;],
996        [int v;return int(count_if(&v,&v,p))],
997        [AC_DEFINE(PQXX_HAVE_COUNT_IF,
998                        1,
999                        [Define if count_if() works according to the standard])],
1000        [count_if='no'])
1001AC_MSG_RESULT($count_if)
1002
1003AC_MSG_CHECKING([whether <iterator> defines a usable iterator template])
1004AC_TRY_COMPILE([#include <iterator>
1005        ${usestd}],
1006        [struct I:iterator<random_access_iterator_tag,int>{}],
1007        [it='yes'],
1008        [AC_DEFINE(PQXX_BROKEN_ITERATOR,
1009                        1,
1010                        [Define if <iterator> lacks an iterator template definition])
1011         it='no'])
1012AC_MSG_RESULT($it)
1013
1014AC_MSG_CHECKING([for reverse_iterator template])
1015reverseit='yes'
1016AC_TRY_COMPILE([#include <iterator>
1017        ${usestd} struct I:iterator<random_access_iterator_tag,int>{};],
1018        [reverse_iterator<I> rit],
1019        [AC_DEFINE(PQXX_HAVE_REVERSE_ITERATOR,
1020                1,
1021                [Define if reverse_iterator template works as expected])],
1022        [reverseit='no'])
1023AC_MSG_RESULT($reverseit)
1024
1025AC_MSG_CHECKING([for tr1::shared_ptr])
1026sharedptr='yes'
1027AC_TRY_COMPILE([#include <${tr1dir}memory>],
1028        [${tr1}::shared_ptr<int> i(new int(1)); return *i;],
1029        [AC_DEFINE(PQXX_HAVE_SHARED_PTR,
1030                1,
1031                [Define if compiler has shared_ptr])],
1032        [sharedptr='no'])
1033AC_MSG_RESULT($sharedptr)
1034
1035AC_MSG_CHECKING([whether overloaded using-declarations work])
1036AC_TRY_COMPILE([
1037        struct A {A(){} void f(int){}};
1038        struct B:A {B(){} using A::f; void f(int,bool){}};],
1039        [B b;b.f(1,true);],
1040        [usingdecl='yes'],
1041        [AC_DEFINE(PQXX_BROKEN_USING_DECL,
1042                1,
1043                [Define if function overloading using "using" breaks])
1044         usingdecl='no'])
1045AC_MSG_RESULT($usingdecl)
1046
1047
1048AC_PROG_MAKE_SET
1049
1050AC_CONFIG_FILES([Makefile config/Makefile debian/Makefile doc/Makefile
1051doc/Doxyfile src/Makefile test/Makefile test/unit/Makefile tools/Makefile
1052win32/Makefile include/Makefile include/pqxx/Makefile libpqxx.pc pqxx-config
1053libpqxx.spec])
1054
1055
1056AC_CONFIG_COMMANDS([configitems], ["${srcdir}/tools/splitconfig" "${srcdir}"])
1057
1058AC_OUTPUT
1059
Note: See TracBrowser for help on using the browser.