1 # $Header: /cvsroot/pgsql/aclocal.m4,v 1.3 2000/06/14 18:17:24 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 AC_DEFUN(AC_FUNC_ACCEPT_ARGTYPES,
34 [AC_MSG_CHECKING([types of arguments for accept()])
35 AC_CACHE_VAL(ac_cv_func_accept_arg1,dnl
36 [AC_CACHE_VAL(ac_cv_func_accept_arg2,dnl
37 [AC_CACHE_VAL(ac_cv_func_accept_arg3,dnl
38 [for ac_cv_func_accept_arg1 in 'int' 'unsigned int'; do
39 for ac_cv_func_accept_arg2 in 'struct sockaddr *' 'void *'; do
40 for ac_cv_func_accept_arg3 in 'socklen_t' 'size_t' 'unsigned int' 'int'; do
42 [#ifdef HAVE_SYS_TYPES_H
43 #include <sys/types.h>
45 #ifdef HAVE_SYS_SOCKET_H
46 #include <sys/socket.h>
48 extern accept ($ac_cv_func_accept_arg1, $ac_cv_func_accept_arg2, $ac_cv_func_accept_arg3 *);],,dnl
49 [ac_not_found=no ; break 3], ac_not_found=yes)
56 if test "$ac_not_found" = yes; then
57 ac_cv_func_accept_arg1=int
58 ac_cv_func_accept_arg2='struct sockaddr *'
59 ac_cv_func_accept_arg3='socklen_t'
61 AC_MSG_RESULT([$ac_cv_func_accept_arg1, $ac_cv_func_accept_arg2, $ac_cv_func_accept_arg3 *])
62 AC_DEFINE_UNQUOTED(ACCEPT_TYPE_ARG1,$ac_cv_func_accept_arg1)
63 AC_DEFINE_UNQUOTED(ACCEPT_TYPE_ARG2,$ac_cv_func_accept_arg2)
64 AC_DEFINE_UNQUOTED(ACCEPT_TYPE_ARG3,$ac_cv_func_accept_arg3)
66 # Macros to detect C compiler features
67 # $Header: /cvsroot/pgsql/aclocal.m4,v 1.3 2000/06/14 18:17:24 petere Exp $
72 # Check if the C compiler understands signed types.
73 # (Of course any ISO C compiler should, what is this still doing here?)
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.3 2000/06/14 18:17:24 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.3 2000/06/14 18:17:24 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
333 # Autoconf macros for configuring the build of Python extension modules
335 # $Header: /cvsroot/pgsql/aclocal.m4,v 1.3 2000/06/14 18:17:24 petere Exp $
340 # Look for Python and set the output variable `PYTHON'
341 # to `python' if found, empty otherwise.
342 AC_DEFUN([PGAC_PROG_PYTHON],
343 [AC_CHECK_PROG(PYTHON, python, python)])
346 # PGAC_PATH_PYTHONDIR
347 # -------------------
348 # Finds the names of various install dirs and helper files
349 # necessary to build a Python extension module.
351 # It would be nice if we could check whether the current setup allows
352 # the build of the shared module. Future project.
353 AC_DEFUN([PGAC_PATH_PYTHONDIR],
354 [AC_REQUIRE([PGAC_PROG_PYTHON])
355 [if test "${PYTHON+set}" = set ; then
356 python_version=`${PYTHON} -c "import sys; print sys.version[:3]"`
357 python_prefix=`${PYTHON} -c "import sys; print sys.prefix"`
358 python_execprefix=`${PYTHON} -c "import sys; print sys.exec_prefix"`
359 python_configdir="${python_execprefix}/lib/python${python_version}/config"
360 python_moduledir="${python_prefix}/lib/python${python_version}"
361 python_extmakefile="${python_configdir}/Makefile.pre.in"]
363 AC_MSG_CHECKING(for Python extension makefile)
364 if test -f "${python_extmakefile}" ; then
369 [The Python extension makefile was expected at \`${python_extmakefile}\'
370 but does not exist. This means the Python module cannot be built automatically.])
373 AC_SUBST(python_version)
374 AC_SUBST(python_prefix)
375 AC_SUBST(python_execprefix)
376 AC_SUBST(python_configdir)
377 AC_SUBST(python_moduledir)
378 AC_SUBST(python_extmakefile)
380 AC_MSG_ERROR([Python not found])
381 fi])# PGAC_PATH_PYTHONDIR