OSDN Git Service

Remove configure tests for `signed', `volatile', and signal handler args;
[pg-rex/syncrep.git] / aclocal.m4
1 # $Header: /cvsroot/pgsql/aclocal.m4,v 1.5 2000/08/27 19:00:00 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.)
5
6
7 dnl @synopsis AC_FUNC_ACCEPT_ARGTYPES
8 dnl
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:
12 dnl
13 dnl       #define ACCEPT_TYPE_ARG1 int
14 dnl       #define ACCEPT_TYPE_ARG2 struct sockaddr *
15 dnl       #define ACCEPT_TYPE_ARG3 socklen_t
16 dnl
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.
19 dnl
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.
22 dnl
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>
25 dnl
26
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).
32 #
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.
35
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
44        AC_TRY_COMPILE(
45 [#ifdef HAVE_SYS_TYPES_H
46 #include <sys/types.h>
47 #endif
48 #ifdef HAVE_SYS_SOCKET_H
49 #include <sys/socket.h>
50 #endif
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])
53       done
54      done
55     done
56     if test "$ac_not_found" = yes; then
57       AC_MSG_ERROR([could not determine argument types])
58     fi
59    ])dnl AC_CACHE_VAL
60   ])dnl AC_CACHE_VAL
61  ])dnl AC_CACHE_VAL
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)
66 ])
67 # Macros to detect C compiler features
68 # $Header: /cvsroot/pgsql/aclocal.m4,v 1.5 2000/08/27 19:00:00 petere Exp $
69
70
71
72 # PGAC_TYPE_64BIT_INT(TYPE)
73 # -------------------------
74 # Check if TYPE is a working 64 bit integer type. Set HAVE_TYPE_64 to
75 # yes or no respectively, and define HAVE_TYPE_64 if yes.
76 AC_DEFUN([PGAC_TYPE_64BIT_INT],
77 [define([Ac_define], [translit([have_$1_64], [a-z *], [A-Z_P])])dnl
78 define([Ac_cachevar], [translit([pgac_cv_type_$1_64], [ *], [_p])])dnl
79 AC_CACHE_CHECK([whether $1 is 64 bits], [Ac_cachevar],
80 [AC_TRY_RUN(
81 [typedef $1 int64;
82
83 /*
84  * These are globals to discourage the compiler from folding all the
85  * arithmetic tests down to compile-time constants.
86  */
87 int64 a = 20000001;
88 int64 b = 40000005;
89
90 int does_int64_work()
91 {
92   int64 c,d;
93
94   if (sizeof(int64) != 8)
95     return 0;                   /* definitely not the right size */
96
97   /* Do perfunctory checks to see if 64-bit arithmetic seems to work */
98   c = a * b;
99   d = (c + b) / b;
100   if (d != a+1)
101     return 0;
102   return 1;
103 }
104 main() {
105   exit(! does_int64_work());
106 }],
107 [Ac_cachevar=yes],
108 [Ac_cachevar=no],
109 [Ac_cachevar=no
110 dnl We will do better here with Autoconf 2.50
111 AC_MSG_WARN([64 bit arithmetic disabled when cross-compiling])])])
112
113 Ac_define=$Ac_cachevar
114 if test x"$Ac_cachevar" = xyes ; then
115   AC_DEFINE(Ac_define,, [Set to 1 if `]$1[' is 64 bits])
116 fi
117 undefine([Ac_define])dnl
118 undefine([Ac_cachevar])dnl
119 ])# PGAC_TYPE_64BIT_INT
120
121
122
123 # PGAC_CHECK_ALIGNOF(TYPE)
124 # ------------------------
125 # Find the alignment requirement of the given type. Define the result
126 # as ALIGNOF_TYPE. If cross-compiling, sizeof(type) is used as a
127 # default assumption.
128 #
129 # This is modeled on the standard autoconf macro AC_CHECK_SIZEOF.
130 # That macro never got any points for style.
131 AC_DEFUN([PGAC_CHECK_ALIGNOF],
132 [changequote(<<, >>)dnl
133 dnl The name to #define.
134 define(<<AC_TYPE_NAME>>, translit(alignof_$1, [a-z *], [A-Z_P]))dnl
135 dnl The cache variable name.
136 define(<<AC_CV_NAME>>, translit(pgac_cv_alignof_$1, [ *], [_p]))dnl
137 changequote([, ])dnl
138 AC_MSG_CHECKING(alignment of $1)
139 AC_CACHE_VAL(AC_CV_NAME,
140 [AC_TRY_RUN([#include <stdio.h>
141 struct { char filler; $1 field; } mystruct;
142 main()
143 {
144   FILE *f=fopen("conftestval", "w");
145   if (!f) exit(1);
146   fprintf(f, "%d\n", ((char*) & mystruct.field) - ((char*) & mystruct));
147   exit(0);
148 }], AC_CV_NAME=`cat conftestval`,
149 AC_CV_NAME='sizeof($1)',
150 AC_CV_NAME='sizeof($1)')])dnl
151 AC_MSG_RESULT($AC_CV_NAME)
152 AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME, [The alignment requirement of a `]$1['])
153 undefine([AC_TYPE_NAME])dnl
154 undefine([AC_CV_NAME])dnl
155 ])# PGAC_CHECK_ALIGNOF
156 # Macros that test various C library quirks
157 # $Header: /cvsroot/pgsql/aclocal.m4,v 1.5 2000/08/27 19:00:00 petere Exp $
158
159
160 # PGAC_VAR_INT_TIMEZONE
161 # ---------------------
162 # Check if the global variable `timezone' exists. If so, define
163 # HAVE_INT_TIMEZONE.
164 AC_DEFUN([PGAC_VAR_INT_TIMEZONE],
165 [AC_CACHE_CHECK(for int timezone, pgac_cv_var_int_timezone,
166 [AC_TRY_LINK([#include <time.h>],
167   [int res = timezone / 60;],
168   [pgac_cv_var_int_timezone=yes],
169   [pgac_cv_var_int_timezone=no])])
170 if test x"$pgac_cv_var_int_timezone" = xyes ; then
171   AC_DEFINE(HAVE_INT_TIMEZONE,, [Set to 1 if you have the global variable timezone])
172 fi])# PGAC_VAR_INT_TIMEZONE
173
174
175 # PGAC_FUNC_GETTIMEOFDAY_1ARG
176 # ---------------------------
177 # Check if gettimeofday() has only one arguments. (Normal is two.)
178 # If so, define GETTIMEOFDAY_1ARG.
179 AC_DEFUN([PGAC_FUNC_GETTIMEOFDAY_1ARG],
180 [AC_CACHE_CHECK(whether gettimeofday takes only one argument,
181 pgac_cv_func_gettimeofday_1arg,
182 [AC_TRY_COMPILE([#include <sys/time.h>],
183 [struct timeval *tp;
184 struct timezone *tzp;
185 gettimeofday(tp,tzp);],
186 [pgac_cv_func_gettimeofday_1arg=no],
187 [pgac_cv_func_gettimeofday_1arg=yes])])
188 if test x"$pgac_cv_func_gettimeofday_1arg" = xyes ; then
189   AC_DEFINE(GETTIMEOFDAY_1ARG,, [Set to 1 if gettimeofday() takes only 1 argument])
190 fi])# PGAC_FUNC_GETTIMEOFDAY_1ARG
191
192
193 # PGAC_UNION_SEMUN
194 # ----------------
195 # Check if `union semun' exists. Define HAVE_UNION_SEMUN if so.
196 # If it doesn't then one could define it as
197 # union semun { int val; struct semid_ds *buf; unsigned short *array; }
198 AC_DEFUN([PGAC_UNION_SEMUN],
199 [AC_CACHE_CHECK(for union semun, pgac_cv_union_semun,
200 [AC_TRY_COMPILE([#include <sys/types.h>
201 #include <sys/ipc.h>
202 #include <sys/sem.h>],
203   [union semun semun;],
204   [pgac_cv_union_semun=yes],
205   [pgac_cv_union_semun=no])])
206 if test x"$pgac_cv_union_semun" = xyes ; then
207   AC_DEFINE(HAVE_UNION_SEMUN,, [Set to 1 if you have `union semun'])
208 fi])# PGAC_UNION_SEMUN
209
210
211 # PGAC_FUNC_POSIX_SIGNALS
212 # -----------------------
213 # Check to see if the machine has the POSIX signal interface. Define
214 # HAVE_POSIX_SIGNALS if so. Also set the output variable HAVE_POSIX_SIGNALS
215 # to yes or no.
216 #
217 # Note that this test only compiles a test program, it doesn't check
218 # whether the routines actually work. If that becomes a problem, make
219 # a fancier check.
220 AC_DEFUN([PGAC_FUNC_POSIX_SIGNALS],
221 [AC_CACHE_CHECK(for POSIX signal interface, pgac_cv_func_posix_signals,
222 [AC_TRY_LINK([#include <signal.h>
223 ],
224 [struct sigaction act, oact;
225 sigemptyset(&act.sa_mask);
226 act.sa_flags = SA_RESTART;
227 sigaction(0, &act, &oact);],
228 [pgac_cv_func_posix_signals=yes],
229 [pgac_cv_func_posix_signals=no])])
230 if test x"$pgac_cv_func_posix_signals" = xyes ; then
231   AC_DEFINE(HAVE_POSIX_SIGNALS,, [Set to 1 if you have the POSIX signal interface])
232 fi
233 HAVE_POSIX_SIGNALS=$pgac_cv_func_posix_signals
234 AC_SUBST(HAVE_POSIX_SIGNALS)])# PGAC_FUNC_POSIX_SIGNALS
235 # Macros to detect certain C++ features
236 # $Header: /cvsroot/pgsql/aclocal.m4,v 1.5 2000/08/27 19:00:00 petere Exp $
237
238
239 # PGAC_CLASS_STRING
240 # -----------------
241 # Look for class `string'. First look for the <string> header. If this
242 # is found a <string> header then it's probably safe to assume that
243 # class string exists.  If not, check to make sure that <string.h>
244 # defines class `string'.
245 AC_DEFUN([PGAC_CLASS_STRING],
246 [AC_LANG_SAVE
247 AC_LANG_CPLUSPLUS
248 AC_CHECK_HEADER(string,
249   [AC_DEFINE(HAVE_CXX_STRING_HEADER)])
250
251 if test x"$ac_cv_header_string" != xyes ; then
252   AC_CACHE_CHECK([for class string in <string.h>],
253     [pgac_cv_class_string_in_string_h],
254     [AC_TRY_COMPILE([#include <stdio.h>
255 #include <stdlib.h>
256 #include <string.h>
257 ],
258       [string foo = "test"],
259       [pgac_cv_class_string_in_string_h=yes],
260       [pgac_cv_class_string_in_string_h=no])])
261
262   if test x"$pgac_cv_class_string_in_string_h" != xyes ; then
263     AC_MSG_ERROR([neither <string> nor <string.h> seem to define the C++ class \`string\'])
264   fi
265 fi
266 AC_LANG_RESTORE])# PGAC_CLASS_STRING
267
268
269 # PGAC_CXX_NAMESPACE_STD
270 # ----------------------
271 # Check whether the C++ compiler understands `using namespace std'.
272 #
273 # Note 1: On at least some compilers, it will not work until you've
274 # included a header that mentions namespace std. Thus, include the
275 # usual suspects before trying it.
276 #
277 # Note 2: This test does not actually reveal whether the C++ compiler
278 # properly understands namespaces in all generality. (GNU C++ 2.8.1
279 # is one that doesn't.) However, we don't care.
280 AC_DEFUN([PGAC_CXX_NAMESPACE_STD],
281 [AC_REQUIRE([PGAC_CLASS_STRING])
282 AC_CACHE_CHECK([for namespace std in C++],
283 pgac_cv_cxx_namespace_std,
284 [
285 AC_LANG_SAVE
286 AC_LANG_CPLUSPLUS
287 AC_TRY_COMPILE(
288 [#include <stdio.h>
289 #include <stdlib.h>
290 #ifdef HAVE_CXX_STRING_HEADER
291 #include <string>
292 #endif
293 using namespace std;
294 ], [],
295 [pgac_cv_cxx_namespace_std=yes],
296 [pgac_cv_cxx_namespace_std=no])
297 AC_LANG_RESTORE])
298
299 if test $pgac_cv_cxx_namespace_std = yes ; then
300     AC_DEFINE(HAVE_NAMESPACE_STD, 1, [Define to 1 if the C++ compiler understands `using namespace std'])
301 fi])# PGAC_CXX_NAMESPACE_STD
302 #
303 # Autoconf macros for configuring the build of Python extension modules
304 #
305 # $Header: /cvsroot/pgsql/aclocal.m4,v 1.5 2000/08/27 19:00:00 petere Exp $
306 #
307
308 # PGAC_PROG_PYTHON
309 # ----------------
310 # Look for Python and set the output variable `PYTHON'
311 # to `python' if found, empty otherwise.
312 AC_DEFUN([PGAC_PROG_PYTHON],
313 [AC_CHECK_PROG(PYTHON, python, python)])
314
315
316 # PGAC_PATH_PYTHONDIR
317 # -------------------
318 # Finds the names of various install dirs and helper files
319 # necessary to build a Python extension module.
320 #
321 # It would be nice if we could check whether the current setup allows
322 # the build of the shared module. Future project.
323 AC_DEFUN([PGAC_PATH_PYTHONDIR],
324 [AC_REQUIRE([PGAC_PROG_PYTHON])
325 [if test "${PYTHON+set}" = set ; then
326   python_version=`${PYTHON} -c "import sys; print sys.version[:3]"`
327   python_prefix=`${PYTHON} -c "import sys; print sys.prefix"`
328   python_execprefix=`${PYTHON} -c "import sys; print sys.exec_prefix"`
329   python_configdir="${python_execprefix}/lib/python${python_version}/config"
330   python_moduledir="${python_prefix}/lib/python${python_version}"
331   python_extmakefile="${python_configdir}/Makefile.pre.in"]
332
333   AC_MSG_CHECKING(for Python extension makefile)
334   if test -f "${python_extmakefile}" ; then
335     AC_MSG_RESULT(found)
336   else
337     AC_MSG_RESULT(no)
338     AC_MSG_ERROR(
339 [The Python extension makefile was expected at \`${python_extmakefile}\'
340 but does not exist. This means the Python module cannot be built automatically.])
341   fi
342
343   AC_SUBST(python_version)
344   AC_SUBST(python_prefix)
345   AC_SUBST(python_execprefix)
346   AC_SUBST(python_configdir)
347   AC_SUBST(python_moduledir)
348   AC_SUBST(python_extmakefile)
349 else
350   AC_MSG_ERROR([Python not found])
351 fi])# PGAC_PATH_PYTHONDIR