]> git.ipfire.org Git - thirdparty/bird.git/blob - aclocal.m4
Netlink: Allow more than 256 routing tables.
[thirdparty/bird.git] / aclocal.m4
1 dnl ** Additional Autoconf tests for BIRD configure script
2 dnl ** (c) 1999 Martin Mares <mj@ucw.cz>
3
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
14 res=int
15 elif test $ac_cv_sizeof_char = $size ; then
16 res=char
17 elif test $ac_cv_sizeof_short_int = $size ; then
18 res="short int"
19 elif test $ac_cv_sizeof_long_int = $size ; then
20 res="long int"
21 elif test $ac_cv_sizeof_long_long_int = $size ; then
22 res="long long int"
23 else
24 AC_MSG_RESULT([not found])
25 AC_MSG_ERROR([Cannot find $bits-bit integer type.])
26 fi
27 AC_MSG_RESULT($res)
28 AC_DEFINE_UNQUOTED(INTEGER_$bits, $res)
29 done
30 ])
31
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,[
35 AC_TRY_RUN([
36 #include <stdio.h>
37
38 unsigned int x = 0x12345678;
39 unsigned char *z = (unsigned char *) &x;
40
41 int main(void)
42 {
43 FILE *f = fopen("conftestresult", "w");
44 if (!f) return 10;
45 fprintf(f, "%02x %02x %02x %02x", *z, *(z+1), *(z+2), *(z+3));
46 fclose(f);
47 exit(0);
48 }
49 ],[
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
55 fi
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.])
60 fi
61 ])
62 case $bird_cv_c_endian in
63 big-endian) AC_DEFINE(CPU_BIG_ENDIAN) ;;
64 little-endian) AC_DEFINE(CPU_LITTLE_ENDIAN) ;;
65 esac
66 ])
67
68 AC_DEFUN(BIRD_CHECK_STRUCT_ALIGN,
69 [AC_CACHE_CHECK([usual alignment of structures],bird_cv_c_struct_align,[
70 AC_TRY_RUN([
71 #include <stdio.h>
72
73 struct { char x; long int y; } ary[2];
74
75 int main(void)
76 {
77 FILE *f = fopen("conftestresult", "w");
78 if (!f) return 10;
79 fprintf(f, "%d", sizeof(ary)/2);
80 fclose(f);
81 exit(0);
82 }
83 ],[
84 bird_cv_c_struct_align=`cat conftestresult`
85 ],[
86 AC_MSG_RESULT([test program failed])
87 AC_MSG_ERROR([Cannot determine structure alignment])
88 ],[bird_cv_c_struct_align=16])
89 ])
90 AC_DEFINE_UNQUOTED(CPU_STRUCT_ALIGN, $bird_cv_c_struct_align)
91 ])
92
93 AC_DEFUN(BIRD_CHECK_TIME_T,
94 [AC_CACHE_CHECK([characteristics of time_t], bird_cv_type_time_t, [
95 AC_TRY_RUN([
96 #include <stdio.h>
97 #include <sys/time.h>
98 #include <limits.h>
99
100 int main(void)
101 {
102 FILE *f = fopen("conftestresult", "w");
103 if (!f) return 10;
104 fprintf(f, "%d-bit ", sizeof(time_t)*CHAR_BIT);
105 if ((time_t) -1 > 0) fprintf(f, "un");
106 fprintf(f, "signed");
107 fclose(f);
108 exit(0);
109 }
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"])
114 ])
115 case "$bird_cv_type_time_t" in
116 *64-bit*) AC_DEFINE(TIME_T_IS_64BIT) ;;
117 esac
118 case "$bird_cv_type_time_t" in
119 *unsigned*) ;;
120 *) AC_DEFINE(TIME_T_IS_SIGNED) ;;
121 esac
122 ])
123
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
130 ])])
131 if test "$bird_cv_struct_ip_mreqn" = yes ; then
132 AC_DEFINE(HAVE_STRUCT_IP_MREQN)
133 fi
134 ])
135
136 AC_DEFUN(BIRD_CHECK_PTHREADS,
137 [
138 bird_tmp_cflags="$CFLAGS"
139
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])])
144
145 CFLAGS="$bird_tmp_cflags"
146 ])
147
148 AC_DEFUN(BIRD_CHECK_GCC_OPTION,
149 [
150 bird_tmp_cflags="$CFLAGS"
151
152 CFLAGS="$3 $2"
153 AC_CACHE_CHECK([whether CC supports $2], $1,
154 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], [$1=yes], [$1=no])])
155
156 CFLAGS="$bird_tmp_cflags"
157 ])
158
159 AC_DEFUN(BIRD_ADD_GCC_OPTION,
160 [
161 if test "$$1" = yes ; then
162 CFLAGS="$CFLAGS $2"
163 fi
164 ])
165
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],
169 [# Check for GNU $1
170 case `"$1" --version 2>&1` in
171 *GNU*)
172 $2;;
173 m4_ifval([$3],
174 [*)
175 $3;;
176 ])esac
177 ])#