OSDN Git Service

Revert removal of signed, volatile, and signal handler arg type tests.
[pg-rex/syncrep.git] / aclocal.m4
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.)
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.7 2000/08/29 09:36:37 petere Exp $
69
70
71 # PGAC_C_SIGNED
72 # -------------
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,
76 [AC_TRY_COMPILE([],
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])
82 fi])# PGAC_C_SIGNED
83
84
85
86 # PGAC_C_VOLATILE
87 # ---------------
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,
92 [AC_TRY_COMPILE([],
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'])
98 fi])# PGAC_C_VOLATILE
99
100
101
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],
110 [AC_TRY_RUN(
111 [typedef $1 int64;
112
113 /*
114  * These are globals to discourage the compiler from folding all the
115  * arithmetic tests down to compile-time constants.
116  */
117 int64 a = 20000001;
118 int64 b = 40000005;
119
120 int does_int64_work()
121 {
122   int64 c,d;
123
124   if (sizeof(int64) != 8)
125     return 0;                   /* definitely not the right size */
126
127   /* Do perfunctory checks to see if 64-bit arithmetic seems to work */
128   c = a * b;
129   d = (c + b) / b;
130   if (d != a+1)
131     return 0;
132   return 1;
133 }
134 main() {
135   exit(! does_int64_work());
136 }],
137 [Ac_cachevar=yes],
138 [Ac_cachevar=no],
139 [Ac_cachevar=no
140 dnl We will do better here with Autoconf 2.50
141 AC_MSG_WARN([64 bit arithmetic disabled when cross-compiling])])])
142
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])
146 fi
147 undefine([Ac_define])dnl
148 undefine([Ac_cachevar])dnl
149 ])# PGAC_TYPE_64BIT_INT
150
151
152
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.
158 #
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
167 changequote([, ])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;
172 main()
173 {
174   FILE *f=fopen("conftestval", "w");
175   if (!f) exit(1);
176   fprintf(f, "%d\n", ((char*) & mystruct.field) - ((char*) & mystruct));
177   exit(0);
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 $
188
189
190 # PGAC_VAR_INT_TIMEZONE
191 # ---------------------
192 # Check if the global variable `timezone' exists. If so, define
193 # HAVE_INT_TIMEZONE.
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
203
204
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>],
213 [struct timeval *tp;
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
221
222
223 # PGAC_UNION_SEMUN
224 # ----------------
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>
231 #include <sys/ipc.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
239
240
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
245 # to yes or no.
246 #
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
249 # a fancier check.
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>
253 ],
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])
262 fi
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 $
267
268
269 # PGAC_CLASS_STRING
270 # -----------------
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],
276 [AC_LANG_SAVE
277 AC_LANG_CPLUSPLUS
278 AC_CHECK_HEADER(string,
279   [AC_DEFINE(HAVE_CXX_STRING_HEADER)])
280
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>
285 #include <stdlib.h>
286 #include <string.h>
287 ],
288       [string foo = "test"],
289       [pgac_cv_class_string_in_string_h=yes],
290       [pgac_cv_class_string_in_string_h=no])])
291
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\'])
294   fi
295 fi
296 AC_LANG_RESTORE])# PGAC_CLASS_STRING
297
298
299 # PGAC_CXX_NAMESPACE_STD
300 # ----------------------
301 # Check whether the C++ compiler understands `using namespace std'.
302 #
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.
306 #
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,
314 [
315 AC_LANG_SAVE
316 AC_LANG_CPLUSPLUS
317 AC_TRY_COMPILE(
318 [#include <stdio.h>
319 #include <stdlib.h>
320 #ifdef HAVE_CXX_STRING_HEADER
321 #include <string>
322 #endif
323 using namespace std;
324 ], [],
325 [pgac_cv_cxx_namespace_std=yes],
326 [pgac_cv_cxx_namespace_std=no])
327 AC_LANG_RESTORE])
328
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 $
333
334
335 # PGAC_PATH_FLEX
336 # --------------
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.
340
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
346 else
347   pgac_save_IFS=$IFS
348   IFS=:
349   for pgac_dir in $PATH; do
350     if test -z "$pgac_dir" || test x"$pgac_dir" = x"."; then
351       pgac_dir=`pwd`
352     fi
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
357       then
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
362             continue
363           fi
364
365           pgac_cv_path_flex=$pgac_candidate
366           break 2
367         fi
368       fi
369     done
370   done
371   IFS=$pgac_save_IFS
372   rm -f conftest.l
373   : ${pgac_cv_path_flex=no}
374 fi
375 ])[]dnl AC_CACHE_CHECK
376
377 if test x"$pgac_cv_path_flex" = x"no"; then
378   if test -n "$pgac_broken_flex"; then
379     AC_MSG_WARN([
380 ***
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.
383 ###])
384   fi
385
386   AC_MSG_WARN([
387 ***
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.)
392 ***])
393 fi
394
395 if test x"$pgac_cv_path_flex" = x"no"; then
396   FLEX=
397 else
398   FLEX=$pgac_cv_path_flex
399 fi
400
401 AC_SUBST(FLEX)
402 AC_SUBST(FLEXFLAGS)
403 ])# PGAC_PATH_FLEX
404 #
405 # Autoconf macros for configuring the build of Python extension modules
406 #
407 # $Header: /cvsroot/pgsql/aclocal.m4,v 1.7 2000/08/29 09:36:37 petere Exp $
408 #
409
410 # PGAC_PROG_PYTHON
411 # ----------------
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)])
416
417
418 # PGAC_PATH_PYTHONDIR
419 # -------------------
420 # Finds the names of various install dirs and helper files
421 # necessary to build a Python extension module.
422 #
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"]
434
435   AC_MSG_CHECKING(for Python extension makefile)
436   if test -f "${python_extmakefile}" ; then
437     AC_MSG_RESULT(found)
438   else
439     AC_MSG_RESULT(no)
440     AC_MSG_ERROR(
441 [The Python extension makefile was expected at \`${python_extmakefile}\'
442 but does not exist. This means the Python module cannot be built automatically.])
443   fi
444
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)
451 else
452   AC_MSG_ERROR([Python not found])
453 fi])# PGAC_PATH_PYTHONDIR