1 dnl ** Additional Autoconf tests for BIRD configure script
2 dnl ** (c) 1999 Martin Mares <mj@ucw.cz>
4 AC_DEFUN(BIRD_CHECK_INTEGERS,
5 [AC_CHECK_SIZEOF(char, 0)
6 AC_CHECK_SIZEOF(short int, 0)
7 AC_CHECK_SIZEOF(int, 0)
8 AC_CHECK_SIZEOF(long int, 0)
9 AC_CHECK_SIZEOF(long long int, 0)
10 for size in 1 2 4 8; do
11 bits=`expr $size "*" 8`
12 AC_MSG_CHECKING([for $bits-bit type])
13 if test $ac_cv_sizeof_int = $size ; then
15 elif test $ac_cv_sizeof_char = $size ; then
17 elif test $ac_cv_sizeof_short_int = $size ; then
19 elif test $ac_cv_sizeof_long_int = $size ; then
21 elif test $ac_cv_sizeof_long_long_int = $size ; then
24 AC_MSG_RESULT([not found])
25 AC_MSG_ERROR([Cannot find $bits-bit integer type.])
28 AC_DEFINE_UNQUOTED(INTEGER_$bits, $res)
32 dnl BIRD_CHECK_ENDIAN is unused and obsolete
33 AC_DEFUN(BIRD_CHECK_ENDIAN,
34 [AC_CACHE_CHECK([CPU endianity], bird_cv_c_endian,[
38 unsigned int x = 0x12345678;
39 unsigned char *z = (unsigned char *) &x;
43 FILE *f = fopen("conftestresult", "w");
45 fprintf(f, "%02x %02x %02x %02x", *z, *(z+1), *(z+2), *(z+3));
50 endian=`cat conftestresult`
51 if test "$endian" = "12 34 56 78" ; then
52 bird_cv_c_endian=big-endian
53 elif test "$endian" = "78 56 34 12" ; then
54 bird_cv_c_endian=little-endian
56 ],[endian="test program failed"],[endian="not available, we're cross compiling"])
57 if test -z "$bird_cv_c_endian" ; then
58 AC_MSG_RESULT($endian)
59 AC_MSG_ERROR([Cannot determine CPU endianity.])
62 case $bird_cv_c_endian in
63 big-endian) AC_DEFINE(CPU_BIG_ENDIAN) ;;
64 little-endian) AC_DEFINE(CPU_LITTLE_ENDIAN) ;;
68 AC_DEFUN(BIRD_CHECK_STRUCT_ALIGN,
69 [AC_CACHE_CHECK([usual alignment of structures],bird_cv_c_struct_align,[
73 struct { char x; long int y; } ary[2];
77 FILE *f = fopen("conftestresult", "w");
79 fprintf(f, "%d", sizeof(ary)/2);
84 bird_cv_c_struct_align=`cat conftestresult`
86 AC_MSG_RESULT([test program failed])
87 AC_MSG_ERROR([Cannot determine structure alignment])
88 ],[bird_cv_c_struct_align=16])
90 AC_DEFINE_UNQUOTED(CPU_STRUCT_ALIGN, $bird_cv_c_struct_align)
93 AC_DEFUN(BIRD_CHECK_TIME_T,
94 [AC_CACHE_CHECK([characteristics of time_t], bird_cv_type_time_t, [
102 FILE *f = fopen("conftestresult", "w");
104 fprintf(f, "%d-bit ", sizeof(time_t)*CHAR_BIT);
105 if ((time_t) -1 > 0) fprintf(f, "un");
106 fprintf(f, "signed");
110 ],[bird_cv_type_time_t=`cat conftestresult`
111 ],[ AC_MSG_RESULT([test program failed])
112 AC_MSG_ERROR([Cannot determine time_t size and signedness.])
113 ],[bird_cv_type_time_t="32-bit signed"])
115 case "$bird_cv_type_time_t" in
116 *64-bit*) AC_DEFINE(TIME_T_IS_64BIT) ;;
118 case "$bird_cv_type_time_t" in
120 *) AC_DEFINE(TIME_T_IS_SIGNED) ;;
124 AC_DEFUN(BIRD_CHECK_STRUCT_IP_MREQN,
125 [AC_CACHE_CHECK([for struct ip_mreqn], bird_cv_struct_ip_mreqn,[
126 AC_TRY_COMPILE([#include <netinet/in.h>
127 ],[struct ip_mreqn x;
128 ],[bird_cv_struct_ip_mreqn=yes
129 ],[bird_cv_struct_ip_mreqn=no
131 if test "$bird_cv_struct_ip_mreqn" = yes ; then
132 AC_DEFINE(HAVE_STRUCT_IP_MREQN)
136 AC_DEFUN(BIRD_CHECK_PTHREADS,
138 bird_tmp_cflags="$CFLAGS"
140 CFLAGS="$CFLAGS -pthread"
141 AC_CACHE_CHECK([whether POSIX threads are available], bird_cv_lib_pthreads,
142 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]], [[pthread_t pt; pthread_create(&pt, NULL, NULL, NULL); pthread_spinlock_t lock; pthread_spin_lock(&lock); ]])],
143 [bird_cv_lib_pthreads=yes], [bird_cv_lib_pthreads=no])])
145 CFLAGS="$bird_tmp_cflags"
148 AC_DEFUN(BIRD_CHECK_GCC_OPTION,
150 bird_tmp_cflags="$CFLAGS"
153 AC_CACHE_CHECK([whether CC supports $2], $1,
154 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], [$1=yes], [$1=no])])
156 CFLAGS="$bird_tmp_cflags"
159 AC_DEFUN(BIRD_ADD_GCC_OPTION,
161 if test "$$1" = yes ; then
166 # BIRD_CHECK_PROG_FLAVOR_GNU(PROGRAM-PATH, IF-SUCCESS, [IF-FAILURE])
167 # copied autoconf internal _AC_PATH_PROG_FLAVOR_GNU
168 m4_define([BIRD_CHECK_PROG_FLAVOR_GNU],
170 case `"$1" --version 2>&1` in