]> git.ipfire.org Git - thirdparty/bird.git/blame - aclocal.m4
Babel: Rework handling of retractions
[thirdparty/bird.git] / aclocal.m4
CommitLineData
2f9bcf97
MM
1dnl ** Additional Autoconf tests for BIRD configure script
2dnl ** (c) 1999 Martin Mares <mj@ucw.cz>
3
4AC_DEFUN(BIRD_CHECK_INTEGERS,
5[AC_CHECK_SIZEOF(char, 0)
6AC_CHECK_SIZEOF(short int, 0)
7AC_CHECK_SIZEOF(int, 0)
8AC_CHECK_SIZEOF(long int, 0)
42a0c054
OZ
9AC_CHECK_SIZEOF(long long int, 0)
10for size in 1 2 4 8; do
2f9bcf97
MM
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"
42a0c054
OZ
21 elif test $ac_cv_sizeof_long_long_int = $size ; then
22 res="long long int"
2f9bcf97
MM
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
e6ff7a08 32dnl BIRD_CHECK_ENDIAN is unused and obsolete
2f9bcf97
MM
33AC_DEFUN(BIRD_CHECK_ENDIAN,
34[AC_CACHE_CHECK([CPU endianity], bird_cv_c_endian,[
35AC_TRY_RUN([
36#include <stdio.h>
37
38unsigned int x = 0x12345678;
39unsigned char *z = (unsigned char *) &x;
40
41int 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"])
57if test -z "$bird_cv_c_endian" ; then
58 AC_MSG_RESULT($endian)
59 AC_MSG_ERROR([Cannot determine CPU endianity.])
60 fi
61])
62case $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
68AC_DEFUN(BIRD_CHECK_STRUCT_ALIGN,
69[AC_CACHE_CHECK([usual alignment of structures],bird_cv_c_struct_align,[
70AC_TRY_RUN([
71#include <stdio.h>
72
73struct { char x; long int y; } ary[2];
74
75int 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],[
84bird_cv_c_struct_align=`cat conftestresult`
85],[
86AC_MSG_RESULT([test program failed])
87AC_MSG_ERROR([Cannot determine structure alignment])
88],[bird_cv_c_struct_align=16])
89])
90AC_DEFINE_UNQUOTED(CPU_STRUCT_ALIGN, $bird_cv_c_struct_align)
91])
92
93AC_DEFUN(BIRD_CHECK_TIME_T,
94[AC_CACHE_CHECK([characteristics of time_t], bird_cv_type_time_t, [
95AC_TRY_RUN([
96#include <stdio.h>
97#include <sys/time.h>
98#include <limits.h>
99
100int 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])
115case "$bird_cv_type_time_t" in
116 *64-bit*) AC_DEFINE(TIME_T_IS_64BIT) ;;
117 esac
118case "$bird_cv_type_time_t" in
119 *unsigned*) ;;
120 *) AC_DEFINE(TIME_T_IS_SIGNED) ;;
121 esac
122])
61fb537c
MM
123
124AC_DEFUN(BIRD_CHECK_STRUCT_IP_MREQN,
170c984a 125[AC_CACHE_CHECK([for struct ip_mreqn], bird_cv_struct_ip_mreqn,[
61fb537c
MM
126AC_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])])
131if test "$bird_cv_struct_ip_mreqn" = yes ; then
132 AC_DEFINE(HAVE_STRUCT_IP_MREQN)
133fi
134])
416e3ee4 135
1ec52253
OZ
136AC_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
efd6d12b
OZ
148AC_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
159AC_DEFUN(BIRD_ADD_GCC_OPTION,
160[
161 if test "$$1" = yes ; then
162 CFLAGS="$CFLAGS $2"
163 fi
164])
b1c030b0 165
8de11deb
OZ
166# BIRD_CHECK_PROG_FLAVOR_GNU(PROGRAM-PATH, IF-SUCCESS, [IF-FAILURE])
167# copied autoconf internal _AC_PATH_PROG_FLAVOR_GNU
168m4_define([BIRD_CHECK_PROG_FLAVOR_GNU],
169[# Check for GNU $1
170case `"$1" --version 2>&1` in
171*GNU*)
172 $2;;
173m4_ifval([$3],
174[*)
175 $3;;
176])esac
177])#