@@ -13,7 +13,7 @@ dnl PARTICULAR PURPOSE.
1313#
1414# Autoconf macros for configuring the build of Python extension modules
1515#
16- # $Header: /cvsroot/pgsql/aclocal.m4,v 1.1 2000/06/10 18:01:34 petere Exp $
16+ # $Header: /cvsroot/pgsql/aclocal.m4,v 1.2 2000/06/11 11:39:45 petere Exp $
1717#
1818
1919# PGAC_PROG_PYTHON
6161AC_MSG_ERROR ( [ Python not found] )
6262fi] ) # PGAC_PATH_PYTHONDIR
6363
64+ # Macros to detect certain C++ features
65+ # $Header: /cvsroot/pgsql/aclocal.m4,v 1.2 2000/06/11 11:39:45 petere Exp $
66+
67+
68+ # PGAC_CLASS_STRING
69+ # -----------------
70+ # Look for class `string'. First look for the <string> header. If this
71+ # is found a <string> header then it's probably safe to assume that
72+ # class string exists. If not, check to make sure that <string.h>
73+ # defines class `string'.
74+ AC_DEFUN ( [ PGAC_CLASS_STRING] ,
75+ [ AC_LANG_SAVE
76+ AC_LANG_CPLUSPLUS
77+ AC_CHECK_HEADER ( string ,
78+ [ AC_DEFINE ( HAVE_CXX_STRING_HEADER ) ] )
79+
80+ if test x"$ac_cv_header_string" != xyes ; then
81+ AC_CACHE_CHECK ( [ for class string in <string.h>] ,
82+ [ pgac_cv_class_string_in_string_h] ,
83+ [ AC_TRY_COMPILE ( [ #include <stdio.h>
84+ #include <stdlib.h>
85+ #include <string.h>
86+ ] ,
87+ [ string foo = "test"] ,
88+ [ pgac_cv_class_string_in_string_h=yes] ,
89+ [ pgac_cv_class_string_in_string_h=no] ) ] )
90+
91+ if test x"$pgac_cv_class_string_in_string_h" != xyes ; then
92+ AC_MSG_ERROR ( [ neither <string> nor <string.h> seem to define the C++ class \`string\'] )
93+ fi
94+ fi
95+ AC_LANG_RESTORE ] ) # PGAC_CLASS_STRING
96+
97+
98+ # PGAC_CXX_NAMESPACE_STD
99+ # ----------------------
100+ # Check whether the C++ compiler understands `using namespace std'.
101+ #
102+ # Note 1: On at least some compilers, it will not work until you've
103+ # included a header that mentions namespace std. Thus, include the
104+ # usual suspects before trying it.
105+ #
106+ # Note 2: This test does not actually reveal whether the C++ compiler
107+ # properly understands namespaces in all generality. (GNU C++ 2.8.1
108+ # is one that doesn't.) However, we don't care.
109+ AC_DEFUN ( [ PGAC_CXX_NAMESPACE_STD] ,
110+ [ AC_REQUIRE ( [ PGAC_CLASS_STRING] )
111+ AC_CACHE_CHECK ( [ for namespace std in C++] ,
112+ pgac_cv_cxx_namespace_std ,
113+ [
114+ AC_LANG_SAVE
115+ AC_LANG_CPLUSPLUS
116+ AC_TRY_COMPILE (
117+ [ #include <stdio.h>
118+ #include <stdlib.h>
119+ #ifdef HAVE_CXX_STRING_HEADER
120+ #include <string>
121+ #endif
122+ using namespace std;
123+ ] ,[ ] ,
124+ [ pgac_cv_cxx_namespace_std=yes] ,
125+ [ pgac_cv_cxx_namespace_std=no] )
126+ AC_LANG_RESTORE ] )
127+
128+ if test $pgac_cv_cxx_namespace_std = yes ; then
129+ AC_DEFINE ( HAVE_NAMESPACE_STD ,1 ,[ Define to 1 if the C++ compiler understands `using namespace std'] )
130+ fi] ) # PGAC_CXX_NAMESPACE_STD
131+
64132dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY)
65133dnl The program must properly implement --version.
66134AC_DEFUN ( AM_MISSING_PROG ,
@@ -77,3 +145,270 @@ else
77145fi
78146AC_SUBST ( $1 ) ] )
79147
148+ # Macros to detect C compiler features
149+ # $Header: /cvsroot/pgsql/aclocal.m4,v 1.2 2000/06/11 11:39:45 petere Exp $
150+
151+
152+ # PGAC_C_SIGNED
153+ # -------------
154+ # Check if the C compiler understands signed types.
155+ # (Of course any ISO C compiler should, what is this still doing here?)
156+ AC_DEFUN ( [ PGAC_C_SIGNED] ,
157+ [ AC_CACHE_CHECK ( for signed types ,pgac_cv_c_signed ,
158+ [ AC_TRY_COMPILE ( [ ] ,
159+ [ signed char c; signed short s; signed int i;] ,
160+ [ pgac_cv_c_signed=yes] ,
161+ [ pgac_cv_c_signed=no] ) ] )
162+ if test x"$pgac_cv_c_signed" = xno ; then
163+ AC_DEFINE ( signed ,,[ Define empty if the C compiler does not understand signed types] )
164+ fi] ) # PGAC_C_SIGNED
165+
166+
167+
168+ # PGAC_C_VOLATILE
169+ # ---------------
170+ # Check if the C compiler understands `volatile'. Note that if it doesn't
171+ # then this will potentially break the program semantics.
172+ AC_DEFUN ( [ PGAC_C_VOLATILE] ,
173+ [ AC_CACHE_CHECK ( for volatile ,pgac_cv_c_volatile ,
174+ [ AC_TRY_COMPILE ( [ ] ,
175+ [ extern volatile int i;] ,
176+ [ pgac_cv_c_volatile=yes] ,
177+ [ pgac_cv_c_volatile=no] ) ] )
178+ if test x"$pgac_cv_c_volatile" = xno ; then
179+ AC_DEFINE ( volatile ,,[ Define empty if the C compiler does not understand `volatile'] )
180+ fi] ) # PGAC_C_VOLATILE
181+
182+
183+
184+ # PGAC_TYPE_64BIT_INT(TYPE)
185+ # -------------------------
186+ # Check if TYPE is a working 64 bit integer type. Set HAVE_TYPE_64 to
187+ # yes or no respectively, and define HAVE_TYPE_64 if yes.
188+ AC_DEFUN ( [ PGAC_TYPE_64BIT_INT] ,
189+ [ define ( [ Ac_define] ,[ translit ( [ have_$1 _64] ,[ a-z *] ,[ A-Z_P] ) ] ) dnl
190+ define ( [ Ac_cachevar] ,[ translit ( [ pgac_cv_type_$1 _64] ,[ *] ,[ _p] ) ] ) dnl
191+ AC_CACHE_CHECK ( [ whether$1 is 64 bits] ,[ Ac_cachevar] ,
192+ [ AC_TRY_RUN (
193+ [ typedef$1 int64;
194+
195+ /*
196+ * These are globals to discourage the compiler from folding all the
197+ * arithmetic tests down to compile-time constants.
198+ */
199+ int64 a = 20000001;
200+ int64 b = 40000005;
201+
202+ int does_int64_work()
203+ {
204+ int64 c,d;
205+
206+ if (sizeof(int64) != 8)
207+ return 0;/* definitely not the right size */
208+
209+ /* Do perfunctory checks to see if 64-bit arithmetic seems to work */
210+ c = a * b;
211+ d = (c + b) / b;
212+ if (d != a+1)
213+ return 0;
214+ return 1;
215+ }
216+ main() {
217+ exit(! does_int64_work());
218+ }] ,
219+ [ Ac_cachevar=yes] ,
220+ [ Ac_cachevar=no] ,
221+ [ Ac_cachevar=no
222+ dnl We will do better here with Autoconf 2.50
223+ AC_MSG_WARN ( [ 64 bit arithmetic disabled when cross-compiling] ) ] ) ] )
224+
225+ Ac_define=$Ac_cachevar
226+ if test x"$Ac_cachevar" = xyes ; then
227+ AC_DEFINE ( Ac_define ,,[ Set to 1 if `] $1 [ ' is 64 bits] )
228+ fi
229+ undefine ( [ Ac_define] ) dnl
230+ undefine ( [ Ac_cachevar] ) dnl
231+ ] ) # PGAC_TYPE_64BIT_INT
232+
233+
234+
235+ # PGAC_CHECK_ALIGNOF(TYPE)
236+ # ------------------------
237+ # Find the alignment requirement of the given type. Define the result
238+ # as ALIGNOF_TYPE. If cross-compiling, sizeof(type) is used as a
239+ # default assumption.
240+ #
241+ # This is modeled on the standard autoconf macro AC_CHECK_SIZEOF.
242+ # That macro never got any points for style.
243+ AC_DEFUN ( [ PGAC_CHECK_ALIGNOF] ,
244+ [ changequote ( << ,>> ) dnl
245+ dnl The name to #define.
246+ define ( <<AC_TYPE_NAME>> ,translit ( alignof_$1 ,[ a-z *] ,[ A-Z_P] ) ) dnl
247+ dnl The cache variable name.
248+ define ( <<AC_CV_NAME>> ,translit ( pgac_cv_alignof_$1 ,[ *] ,[ _p] ) ) dnl
249+ changequote ( [ ,] ) dnl
250+ AC_MSG_CHECKING ( alignment of $1 )
251+ AC_CACHE_VAL ( AC_CV_NAME ,
252+ [ AC_TRY_RUN ( [ #include <stdio.h>
253+ struct { char filler;$1 field; } mystruct;
254+ main()
255+ {
256+ FILE *f=fopen("conftestval", "w");
257+ if (!f) exit(1);
258+ fprintf(f, "%d\n", ((char*) & mystruct.field) - ((char*) & mystruct));
259+ exit(0);
260+ }] ,AC_CV_NAME=`cat conftestval` ,
261+ AC_CV_NAME='sizeof ( $1 ) ' ,
262+ AC_CV_NAME='sizeof ( $1 ) ' ) ] ) dnl
263+ AC_MSG_RESULT ( $AC_CV_NAME )
264+ AC_DEFINE_UNQUOTED ( AC_TYPE_NAME ,$AC_CV_NAME ,[ The alignment requirement of a `] $1 [ '] )
265+ undefine ( [ AC_TYPE_NAME] ) dnl
266+ undefine ( [ AC_CV_NAME] ) dnl
267+ ] ) # PGAC_CHECK_ALIGNOF
268+
269+ # $Header: /cvsroot/pgsql/aclocal.m4,v 1.2 2000/06/11 11:39:45 petere Exp $
270+ # This comes from the official Autoconf macro archive at
271+ # <http://research.cys.de/autoconf-archive/>
272+ # (I removed the $ before the Id CVS keyword below.)
273+
274+
275+ dnl @synopsis AC_FUNC_ACCEPT_ARGTYPES
276+ dnl
277+ dnl Checks the data types of the three arguments to accept(). Results are
278+ dnl placed into the symbols ACCEPT_TYPE_ARG[123], consistent with the
279+ dnl following example:
280+ dnl
281+ dnl #define ACCEPT_TYPE_ARG1 int
282+ dnl #define ACCEPT_TYPE_ARG2 struct sockaddr *
283+ dnl #define ACCEPT_TYPE_ARG3 socklen_t
284+ dnl
285+ dnl This macro requires AC_CHECK_HEADERS to have already verified the
286+ dnl presence or absence of sys/types.h and sys/socket.h.
287+ dnl
288+ dnl NOTE: This is just a modified version of the AC_FUNC_SELECT_ARGTYPES
289+ dnl macro. Credit for that one goes to David MacKenzie et. al.
290+ dnl
291+ dnl @version Id: ac_func_accept_argtypes.m4,v 1.1 1999/12/03 11:29:29 simons Exp $
292+ dnl @author Daniel Richard G. <skunk@mit.edu>
293+ dnl
294+
295+ # PostgreSQL local changes: In the original version ACCEPT_TYPE_ARG3
296+ # is a pointer type. That's kind of useless because then you can't
297+ # use the macro to define a corresponding variable. We also make the
298+ # reasonable(?) assumption that you can use arg3 for getsocktype etc.
299+ # as well (i.e., anywhere POSIX.2 has socklen_t).
300+
301+ AC_DEFUN ( AC_FUNC_ACCEPT_ARGTYPES ,
302+ [ AC_MSG_CHECKING ( [ types of arguments for accept()] )
303+ AC_CACHE_VAL ( ac_cv_func_accept_arg1 ,dnl
304+ [ AC_CACHE_VAL ( ac_cv_func_accept_arg2 ,dnl
305+ [ AC_CACHE_VAL ( ac_cv_func_accept_arg3 ,dnl
306+ [ for ac_cv_func_accept_arg1 in 'int' 'unsigned int'; do
307+ for ac_cv_func_accept_arg2 in 'struct sockaddr *' 'void *'; do
308+ for ac_cv_func_accept_arg3 in 'socklen_t' 'size_t' 'unsigned int' 'int'; do
309+ AC_TRY_COMPILE ( dnl
310+ [ #ifdef HAVE_SYS_TYPES_H
311+ #include <sys/types.h>
312+ #endif
313+ #ifdef HAVE_SYS_SOCKET_H
314+ #include <sys/socket.h>
315+ #endif
316+ extern accept ($ac_cv_func_accept_arg1, $ac_cv_func_accept_arg2, $ac_cv_func_accept_arg3 *);] ,,dnl
317+ [ ac_not_found=no ; break 3] ,ac_not_found=yes )
318+ done
319+ done
320+ done
321+ ] ) dnl AC_CACHE_VAL
322+ ] ) dnl AC_CACHE_VAL
323+ ] ) dnl AC_CACHE_VAL
324+ if test "$ac_not_found" = yes; then
325+ ac_cv_func_accept_arg1=int
326+ ac_cv_func_accept_arg2='struct sockaddr *'
327+ ac_cv_func_accept_arg3='socklen_t'
328+ fi
329+ AC_MSG_RESULT ( [ $ac_cv_func_accept_arg1, $ac_cv_func_accept_arg2, $ac_cv_func_accept_arg3 *] )
330+ AC_DEFINE_UNQUOTED ( ACCEPT_TYPE_ARG1 ,$ac_cv_func_accept_arg1 )
331+ AC_DEFINE_UNQUOTED ( ACCEPT_TYPE_ARG2 ,$ac_cv_func_accept_arg2 )
332+ AC_DEFINE_UNQUOTED ( ACCEPT_TYPE_ARG3 ,$ac_cv_func_accept_arg3 )
333+ ] )
334+
335+ # Macros that test various C library quirks
336+ # $Header: /cvsroot/pgsql/aclocal.m4,v 1.2 2000/06/11 11:39:45 petere Exp $
337+
338+
339+ # PGAC_VAR_INT_TIMEZONE
340+ # ---------------------
341+ # Check if the global variable `timezone' exists. If so, define
342+ # HAVE_INT_TIMEZONE.
343+ AC_DEFUN ( [ PGAC_VAR_INT_TIMEZONE] ,
344+ [ AC_CACHE_CHECK ( for int timezone ,pgac_cv_var_int_timezone ,
345+ [ AC_TRY_LINK ( [ #include <time.h>] ,
346+ [ int res = timezone / 60;] ,
347+ [ pgac_cv_var_int_timezone=yes] ,
348+ [ pgac_cv_var_int_timezone=no] ) ] )
349+ if test x"$pgac_cv_var_int_timezone" = xyes ; then
350+ AC_DEFINE ( HAVE_INT_TIMEZONE ,,[ Set to 1 if you have the global variable timezone] )
351+ fi] ) # PGAC_VAR_INT_TIMEZONE
352+
353+
354+ # PGAC_FUNC_GETTIMEOFDAY_1ARG
355+ # ---------------------------
356+ # Check if gettimeofday() has only one arguments. (Normal is two.)
357+ # If so, define GETTIMEOFDAY_1ARG.
358+ AC_DEFUN ( [ PGAC_FUNC_GETTIMEOFDAY_1ARG] ,
359+ [ AC_CACHE_CHECK ( whether gettimeofday takes only one argument ,
360+ pgac_cv_func_gettimeofday_1arg ,
361+ [ AC_TRY_COMPILE ( [ #include <sys/time.h>] ,
362+ [ struct timeval *tp;
363+ struct timezone *tzp;
364+ gettimeofday(tp,tzp);] ,
365+ [ pgac_cv_func_gettimeofday_1arg=no] ,
366+ [ pgac_cv_func_gettimeofday_1arg=yes] ) ] )
367+ if test x"$pgac_cv_func_gettimeofday_1arg" = xyes ; then
368+ AC_DEFINE ( GETTIMEOFDAY_1ARG ,,[ Set to 1 if gettimeofday() takes only 1 argument] )
369+ fi] ) # PGAC_FUNC_GETTIMEOFDAY_1ARG
370+
371+
372+ # PGAC_UNION_SEMUN
373+ # ----------------
374+ # Check if `union semun' exists. Define HAVE_UNION_SEMUN if so.
375+ # If it doesn't then one could define it as
376+ # union semun { int val; struct semid_ds *buf; unsigned short *array; }
377+ AC_DEFUN ( [ PGAC_UNION_SEMUN] ,
378+ [ AC_CACHE_CHECK ( for union semun ,pgac_cv_union_semun ,
379+ [ AC_TRY_COMPILE ( [ #include <sys/types.h>
380+ #include <sys/ipc.h>
381+ #include <sys/sem.h>] ,
382+ [ union semun semun;] ,
383+ [ pgac_cv_union_semun=yes] ,
384+ [ pgac_cv_union_semun=no] ) ] )
385+ if test x"$pgac_cv_union_semun" = xyes ; then
386+ AC_DEFINE ( HAVE_UNION_SEMUN ,,[ Set to 1 if you have `union semun'] )
387+ fi] ) # PGAC_UNION_SEMUN
388+
389+
390+ # PGAC_FUNC_POSIX_SIGNALS
391+ # -----------------------
392+ # Check to see if the machine has the POSIX signal interface. Define
393+ # HAVE_POSIX_SIGNALS if so. Also set the output variable HAVE_POSIX_SIGNALS
394+ # to yes or no.
395+ #
396+ # Note that this test only compiles a test program, it doesn't check
397+ # whether the routines actually work. If that becomes a problem, make
398+ # a fancier check.
399+ AC_DEFUN ( [ PGAC_FUNC_POSIX_SIGNALS] ,
400+ [ AC_CACHE_CHECK ( for POSIX signal interface ,pgac_cv_func_posix_signals ,
401+ [ AC_TRY_LINK ( [ #include <signal.h>
402+ ] ,
403+ [ struct sigaction act, oact;
404+ sigemptyset(&act.sa_mask);
405+ act.sa_flags = SA_RESTART;
406+ sigaction(0, &act, &oact);] ,
407+ [ pgac_cv_func_posix_signals=yes] ,
408+ [ pgac_cv_func_posix_signals=no] ) ] )
409+ if test x"$pgac_cv_func_posix_signals" = xyes ; then
410+ AC_DEFINE ( HAVE_POSIX_SIGNALS ,,[ Set to 1 if you have the POSIX signal interface] )
411+ fi
412+ HAVE_POSIX_SIGNALS=$pgac_cv_func_posix_signals
413+ AC_SUBST ( HAVE_POSIX_SIGNALS ) ] ) # PGAC_FUNC_POSIX_SIGNALS
414+