1 # $Header: /cvsroot/pgsql/aclocal.m4,v 1.7 2000/08/29 09:36:37 petere Exp $
2 # This comes from the official Autoconf macro archive at
3 # <http://research.cys.de/autoconf-archive/>
4 # (I removed the $ before the Id CVS keyword below.)
7 dnl @synopsis AC_FUNC_ACCEPT_ARGTYPES
9 dnl Checks the data types of the three arguments to accept(). Results are
10 dnl placed into the symbols ACCEPT_TYPE_ARG[123], consistent with the
11 dnl following example:
13 dnl #define ACCEPT_TYPE_ARG1 int
14 dnl #define ACCEPT_TYPE_ARG2 struct sockaddr *
15 dnl #define ACCEPT_TYPE_ARG3 socklen_t
17 dnl This macro requires AC_CHECK_HEADERS to have already verified the
18 dnl presence or absence of sys/types.h and sys/socket.h.
20 dnl NOTE: This is just a modified version of the AC_FUNC_SELECT_ARGTYPES
21 dnl macro. Credit for that one goes to David MacKenzie et. al.
23 dnl @version Id: ac_func_accept_argtypes.m4,v 1.1 1999/12/03 11:29:29 simons Exp $
24 dnl @author Daniel Richard G. <skunk@mit.edu>
27 # PostgreSQL local changes: In the original version ACCEPT_TYPE_ARG3
28 # is a pointer type. That's kind of useless because then you can't
29 # use the macro to define a corresponding variable. We also make the
30 # reasonable(?) assumption that you can use arg3 for getsocktype etc.
31 # as well (i.e., anywhere POSIX.2 has socklen_t).
33 # arg2 can also be `const' (e.g., RH 4.2). Change the order of tests
34 # for arg3 so that `int' is first, in case there is no prototype at all.
36 AC_DEFUN(AC_FUNC_ACCEPT_ARGTYPES,
37 [AC_MSG_CHECKING([types of arguments for accept()])
38 AC_CACHE_VAL(ac_cv_func_accept_arg1,dnl
39 [AC_CACHE_VAL(ac_cv_func_accept_arg2,dnl
40 [AC_CACHE_VAL(ac_cv_func_accept_arg3,dnl
41 [for ac_cv_func_accept_arg1 in 'int' 'unsigned int'; do
42 for ac_cv_func_accept_arg2 in 'struct sockaddr *' 'const struct sockaddr *' 'void *'; do
43 for ac_cv_func_accept_arg3 in 'int' 'size_t' 'socklen_t' 'unsigned int'; do
45 [#ifdef HAVE_SYS_TYPES_H
46 #include <sys/types.h>
48 #ifdef HAVE_SYS_SOCKET_H
49 #include <sys/socket.h>
51 extern accept ($ac_cv_func_accept_arg1, $ac_cv_func_accept_arg2, $ac_cv_func_accept_arg3 *);],
52 [], [ac_not_found=no; break 3], [ac_not_found=yes])
56 if test "$ac_not_found" = yes; then
57 AC_MSG_ERROR([could not determine argument types])
62 AC_MSG_RESULT([$ac_cv_func_accept_arg1, $ac_cv_func_accept_arg2, $ac_cv_func_accept_arg3 *])
63 AC_DEFINE_UNQUOTED(ACCEPT_TYPE_ARG1,$ac_cv_func_accept_arg1)
64 AC_DEFINE_UNQUOTED(ACCEPT_TYPE_ARG2,$ac_cv_func_accept_arg2)
65 AC_DEFINE_UNQUOTED(ACCEPT_TYPE_ARG3,$ac_cv_func_accept_arg3)
67 # Macros to detect C compiler features
68 # $Header: /cvsroot/pgsql/aclocal.m4,v 1.7 2000/08/29 09:36:37 petere Exp $
73 # Check if the C compiler understands signed types.
74 AC_DEFUN([PGAC_C_SIGNED],
75 [AC_CACHE_CHECK(for signed types, pgac_cv_c_signed,
77 [signed char c; signed short s; signed int i;],
78 [pgac_cv_c_signed=yes],
79 [pgac_cv_c_signed=no])])
80 if test x"$pgac_cv_c_signed" = xno ; then
81 AC_DEFINE(signed,, [Define empty if the C compiler does not understand signed types])
88 # Check if the C compiler understands `volatile'. Note that if it doesn't
89 # then this will potentially break the program semantics.
90 AC_DEFUN([PGAC_C_VOLATILE],
91 [AC_CACHE_CHECK(for volatile, pgac_cv_c_volatile,
93 [extern volatile int i;],
94 [pgac_cv_c_volatile=yes],
95 [pgac_cv_c_volatile=no])])
96 if test x"$pgac_cv_c_volatile" = xno ; then
97 AC_DEFINE(volatile,, [Define empty if the C compiler does not understand `volatile'])
102 # PGAC_TYPE_64BIT_INT(TYPE)
103 # -------------------------
104 # Check if TYPE is a working 64 bit integer type. Set HAVE_TYPE_64 to
105 # yes or no respectively, and define HAVE_TYPE_64 if yes.
106 AC_DEFUN([PGAC_TYPE_64BIT_INT],
107 [define([Ac_define], [translit([have_$1_64], [a-z *], [A-Z_P])])dnl
108 define([Ac_cachevar], [translit([pgac_cv_type_$1_64], [ *], [_p])])dnl
109 AC_CACHE_CHECK([whether $1 is 64 bits], [Ac_cachevar],
114 * These are globals to discourage the compiler from folding all the
115 * arithmetic tests down to compile-time constants.
120 int does_int64_work()
124 if (sizeof(int64) != 8)
125 return 0; /* definitely not the right size */
127 /* Do perfunctory checks to see if 64-bit arithmetic seems to work */
135 exit(! does_int64_work());
140 dnl We will do better here with Autoconf 2.50
141 AC_MSG_WARN([64 bit arithmetic disabled when cross-compiling])])])
143 Ac_define=$Ac_cachevar
144 if test x"$Ac_cachevar" = xyes ; then
145 AC_DEFINE(Ac_define,, [Set to 1 if `]$1[' is 64 bits])
147 undefine([Ac_define])dnl
148 undefine([Ac_cachevar])dnl
149 ])# PGAC_TYPE_64BIT_INT
153 # PGAC_CHECK_ALIGNOF(TYPE)
154 # ------------------------
155 # Find the alignment requirement of the given type. Define the result
156 # as ALIGNOF_TYPE. If cross-compiling, sizeof(type) is used as a
157 # default assumption.
159 # This is modeled on the standard autoconf macro AC_CHECK_SIZEOF.
160 # That macro never got any points for style.
161 AC_DEFUN([PGAC_CHECK_ALIGNOF],
162 [changequote(<<, >>)dnl
163 dnl The name to #define.
164 define(<<AC_TYPE_NAME>>, translit(alignof_$1, [a-z *], [A-Z_P]))dnl
165 dnl The cache variable name.
166 define(<<AC_CV_NAME>>, translit(pgac_cv_alignof_$1, [ *], [_p]))dnl
168 AC_MSG_CHECKING(alignment of $1)
169 AC_CACHE_VAL(AC_CV_NAME,
170 [AC_TRY_RUN([#include <stdio.h>
171 struct { char filler; $1 field; } mystruct;
174 FILE *f=fopen("conftestval", "w");
176 fprintf(f, "%d\n", ((char*) & mystruct.field) - ((char*) & mystruct));
178 }], AC_CV_NAME=`cat conftestval`,
179 AC_CV_NAME='sizeof($1)',
180 AC_CV_NAME='sizeof($1)')])dnl
181 AC_MSG_RESULT($AC_CV_NAME)
182 AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME, [The alignment requirement of a `]$1['])
183 undefine([AC_TYPE_NAME])dnl
184 undefine([AC_CV_NAME])dnl
185 ])# PGAC_CHECK_ALIGNOF
186 # Macros that test various C library quirks
187 # $Header: /cvsroot/pgsql/aclocal.m4,v 1.7 2000/08/29 09:36:37 petere Exp $
190 # PGAC_VAR_INT_TIMEZONE
191 # ---------------------
192 # Check if the global variable `timezone' exists. If so, define
194 AC_DEFUN([PGAC_VAR_INT_TIMEZONE],
195 [AC_CACHE_CHECK(for int timezone, pgac_cv_var_int_timezone,
196 [AC_TRY_LINK([#include <time.h>],
197 [int res = timezone / 60;],
198 [pgac_cv_var_int_timezone=yes],
199 [pgac_cv_var_int_timezone=no])])
200 if test x"$pgac_cv_var_int_timezone" = xyes ; then
201 AC_DEFINE(HAVE_INT_TIMEZONE,, [Set to 1 if you have the global variable timezone])
202 fi])# PGAC_VAR_INT_TIMEZONE
205 # PGAC_FUNC_GETTIMEOFDAY_1ARG
206 # ---------------------------
207 # Check if gettimeofday() has only one arguments. (Normal is two.)
208 # If so, define GETTIMEOFDAY_1ARG.
209 AC_DEFUN([PGAC_FUNC_GETTIMEOFDAY_1ARG],
210 [AC_CACHE_CHECK(whether gettimeofday takes only one argument,
211 pgac_cv_func_gettimeofday_1arg,
212 [AC_TRY_COMPILE([#include <sys/time.h>],
214 struct timezone *tzp;
215 gettimeofday(tp,tzp);],
216 [pgac_cv_func_gettimeofday_1arg=no],
217 [pgac_cv_func_gettimeofday_1arg=yes])])
218 if test x"$pgac_cv_func_gettimeofday_1arg" = xyes ; then
219 AC_DEFINE(GETTIMEOFDAY_1ARG,, [Set to 1 if gettimeofday() takes only 1 argument])
220 fi])# PGAC_FUNC_GETTIMEOFDAY_1ARG
225 # Check if `union semun' exists. Define HAVE_UNION_SEMUN if so.
226 # If it doesn't then one could define it as
227 # union semun { int val; struct semid_ds *buf; unsigned short *array; }
228 AC_DEFUN([PGAC_UNION_SEMUN],
229 [AC_CACHE_CHECK(for union semun, pgac_cv_union_semun,
230 [AC_TRY_COMPILE([#include <sys/types.h>
232 #include <sys/sem.h>],
233 [union semun semun;],
234 [pgac_cv_union_semun=yes],
235 [pgac_cv_union_semun=no])])
236 if test x"$pgac_cv_union_semun" = xyes ; then
237 AC_DEFINE(HAVE_UNION_SEMUN,, [Set to 1 if you have `union semun'])
238 fi])# PGAC_UNION_SEMUN
241 # PGAC_FUNC_POSIX_SIGNALS
242 # -----------------------
243 # Check to see if the machine has the POSIX signal interface. Define
244 # HAVE_POSIX_SIGNALS if so. Also set the output variable HAVE_POSIX_SIGNALS
247 # Note that this test only compiles a test program, it doesn't check
248 # whether the routines actually work. If that becomes a problem, make
250 AC_DEFUN([PGAC_FUNC_POSIX_SIGNALS],
251 [AC_CACHE_CHECK(for POSIX signal interface, pgac_cv_func_posix_signals,
252 [AC_TRY_LINK([#include <signal.h>
254 [struct sigaction act, oact;
255 sigemptyset(&act.sa_mask);
256 act.sa_flags = SA_RESTART;
257 sigaction(0, &act, &oact);],
258 [pgac_cv_func_posix_signals=yes],
259 [pgac_cv_func_posix_signals=no])])
260 if test x"$pgac_cv_func_posix_signals" = xyes ; then
261 AC_DEFINE(HAVE_POSIX_SIGNALS,, [Set to 1 if you have the POSIX signal interface])
263 HAVE_POSIX_SIGNALS=$pgac_cv_func_posix_signals
264 AC_SUBST(HAVE_POSIX_SIGNALS)])# PGAC_FUNC_POSIX_SIGNALS
265 # Macros to detect certain C++ features
266 # $Header: /cvsroot/pgsql/aclocal.m4,v 1.7 2000/08/29 09:36:37 petere Exp $
271 # Look for class `string'. First look for the <string> header. If this
272 # is found a <string> header then it's probably safe to assume that
273 # class string exists. If not, check to make sure that <string.h>
274 # defines class `string'.
275 AC_DEFUN([PGAC_CLASS_STRING],
278 AC_CHECK_HEADER(string,
279 [AC_DEFINE(HAVE_CXX_STRING_HEADER)])
281 if test x"$ac_cv_header_string" != xyes ; then
282 AC_CACHE_CHECK([for class string in <string.h>],
283 [pgac_cv_class_string_in_string_h],
284 [AC_TRY_COMPILE([#include <stdio.h>
288 [string foo = "test"],
289 [pgac_cv_class_string_in_string_h=yes],
290 [pgac_cv_class_string_in_string_h=no])])
292 if test x"$pgac_cv_class_string_in_string_h" != xyes ; then
293 AC_MSG_ERROR([neither <string> nor <string.h> seem to define the C++ class \`string\'])
296 AC_LANG_RESTORE])# PGAC_CLASS_STRING
299 # PGAC_CXX_NAMESPACE_STD
300 # ----------------------
301 # Check whether the C++ compiler understands `using namespace std'.
303 # Note 1: On at least some compilers, it will not work until you've
304 # included a header that mentions namespace std. Thus, include the
305 # usual suspects before trying it.
307 # Note 2: This test does not actually reveal whether the C++ compiler
308 # properly understands namespaces in all generality. (GNU C++ 2.8.1
309 # is one that doesn't.) However, we don't care.
310 AC_DEFUN([PGAC_CXX_NAMESPACE_STD],
311 [AC_REQUIRE([PGAC_CLASS_STRING])
312 AC_CACHE_CHECK([for namespace std in C++],
313 pgac_cv_cxx_namespace_std,
320 #ifdef HAVE_CXX_STRING_HEADER
325 [pgac_cv_cxx_namespace_std=yes],
326 [pgac_cv_cxx_namespace_std=no])
329 if test $pgac_cv_cxx_namespace_std = yes ; then
330 AC_DEFINE(HAVE_NAMESPACE_STD, 1, [Define to 1 if the C++ compiler understands `using namespace std'])
331 fi])# PGAC_CXX_NAMESPACE_STD
332 # $Header: /cvsroot/pgsql/aclocal.m4,v 1.7 2000/08/29 09:36:37 petere Exp $
337 # Look for Flex, set the output variable FLEX to its path if found.
338 # Avoid the buggy version 2.5.3. Also find Flex if its installed
339 # under `lex', but do not accept other Lex programs.
341 AC_DEFUN([PGAC_PATH_FLEX],
342 [AC_CACHE_CHECK([for flex], pgac_cv_path_flex,
343 [# Let the user override the test
344 if test -n "$FLEX"; then
345 pgac_cv_path_flex=$FLEX
349 for pgac_dir in $PATH; do
350 if test -z "$pgac_dir" || test x"$pgac_dir" = x"."; then
353 for pgac_prog in flex lex; do
354 pgac_candidate="$pgac_dir/$pgac_prog"
355 if test -f "$pgac_candidate" \
356 && $pgac_candidate --version >/dev/null 2>&1
358 echo '%%' > conftest.l
359 if $pgac_candidate -t conftest.l 2>/dev/null | grep FLEX_SCANNER >/dev/null 2>&1; then
360 if $pgac_candidate --version | grep '2\.5\.3' >/dev/null 2>&1; then
361 pgac_broken_flex=$pgac_candidate
365 pgac_cv_path_flex=$pgac_candidate
373 : ${pgac_cv_path_flex=no}
375 ])[]dnl AC_CACHE_CHECK
377 if test x"$pgac_cv_path_flex" = x"no"; then
378 if test -n "$pgac_broken_flex"; then
381 The Flex version 2.5.3 you have at $pgac_broken_flex contains a bug. You
382 should get version 2.5.4 or later.
388 Without Flex you won't be able to build PostgreSQL from scratch, or change
389 any of the scanner definition files. You can obtain Flex from a GNU mirror
390 site. (If you are using the official distribution of PostgreSQL then you
391 do not need to worry about this because the lexer files are pre-generated.)
395 if test x"$pgac_cv_path_flex" = x"no"; then
398 FLEX=$pgac_cv_path_flex
405 # Autoconf macros for configuring the build of Python extension modules
407 # $Header: /cvsroot/pgsql/aclocal.m4,v 1.7 2000/08/29 09:36:37 petere Exp $
412 # Look for Python and set the output variable `PYTHON'
413 # to `python' if found, empty otherwise.
414 AC_DEFUN([PGAC_PROG_PYTHON],
415 [AC_CHECK_PROG(PYTHON, python, python)])
418 # PGAC_PATH_PYTHONDIR
419 # -------------------
420 # Finds the names of various install dirs and helper files
421 # necessary to build a Python extension module.
423 # It would be nice if we could check whether the current setup allows
424 # the build of the shared module. Future project.
425 AC_DEFUN([PGAC_PATH_PYTHONDIR],
426 [AC_REQUIRE([PGAC_PROG_PYTHON])
427 [if test "${PYTHON+set}" = set ; then
428 python_version=`${PYTHON} -c "import sys; print sys.version[:3]"`
429 python_prefix=`${PYTHON} -c "import sys; print sys.prefix"`
430 python_execprefix=`${PYTHON} -c "import sys; print sys.exec_prefix"`
431 python_configdir="${python_execprefix}/lib/python${python_version}/config"
432 python_moduledir="${python_prefix}/lib/python${python_version}"
433 python_extmakefile="${python_configdir}/Makefile.pre.in"]
435 AC_MSG_CHECKING(for Python extension makefile)
436 if test -f "${python_extmakefile}" ; then
441 [The Python extension makefile was expected at \`${python_extmakefile}\'
442 but does not exist. This means the Python module cannot be built automatically.])
445 AC_SUBST(python_version)
446 AC_SUBST(python_prefix)
447 AC_SUBST(python_execprefix)
448 AC_SUBST(python_configdir)
449 AC_SUBST(python_moduledir)
450 AC_SUBST(python_extmakefile)
452 AC_MSG_ERROR([Python not found])
453 fi])# PGAC_PATH_PYTHONDIR