]> git.ipfire.org Git - thirdparty/bird.git/blob - aclocal.m4
Merge branch 'dev' into ospf3
[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 for size in 1 2 4 ; do
10 bits=`expr $size "*" 8`
11 AC_MSG_CHECKING([for $bits-bit type])
12 if test $ac_cv_sizeof_int = $size ; then
13 res=int
14 elif test $ac_cv_sizeof_char = $size ; then
15 res=char
16 elif test $ac_cv_sizeof_short_int = $size ; then
17 res="short int"
18 elif test $ac_cv_sizeof_long_int = $size ; then
19 res="long int"
20 else
21 AC_MSG_RESULT([not found])
22 AC_MSG_ERROR([Cannot find $bits-bit integer type.])
23 fi
24 AC_MSG_RESULT($res)
25 AC_DEFINE_UNQUOTED(INTEGER_$bits, $res)
26 done
27 ])
28
29 dnl BIRD_CHECK_ENDIAN is unused and obsolete
30 AC_DEFUN(BIRD_CHECK_ENDIAN,
31 [AC_CACHE_CHECK([CPU endianity], bird_cv_c_endian,[
32 AC_TRY_RUN([
33 #include <stdio.h>
34
35 unsigned int x = 0x12345678;
36 unsigned char *z = (unsigned char *) &x;
37
38 int main(void)
39 {
40 FILE *f = fopen("conftestresult", "w");
41 if (!f) return 10;
42 fprintf(f, "%02x %02x %02x %02x", *z, *(z+1), *(z+2), *(z+3));
43 fclose(f);
44 exit(0);
45 }
46 ],[
47 endian=`cat conftestresult`
48 if test "$endian" = "12 34 56 78" ; then
49 bird_cv_c_endian=big-endian
50 elif test "$endian" = "78 56 34 12" ; then
51 bird_cv_c_endian=little-endian
52 fi
53 ],[endian="test program failed"],[endian="not available, we're cross compiling"])
54 if test -z "$bird_cv_c_endian" ; then
55 AC_MSG_RESULT($endian)
56 AC_MSG_ERROR([Cannot determine CPU endianity.])
57 fi
58 ])
59 case $bird_cv_c_endian in
60 big-endian) AC_DEFINE(CPU_BIG_ENDIAN) ;;
61 little-endian) AC_DEFINE(CPU_LITTLE_ENDIAN) ;;
62 esac
63 ])
64
65 AC_DEFUN(BIRD_CHECK_STRUCT_ALIGN,
66 [AC_CACHE_CHECK([usual alignment of structures],bird_cv_c_struct_align,[
67 AC_TRY_RUN([
68 #include <stdio.h>
69
70 struct { char x; long int y; } ary[2];
71
72 int main(void)
73 {
74 FILE *f = fopen("conftestresult", "w");
75 if (!f) return 10;
76 fprintf(f, "%d", sizeof(ary)/2);
77 fclose(f);
78 exit(0);
79 }
80 ],[
81 bird_cv_c_struct_align=`cat conftestresult`
82 ],[
83 AC_MSG_RESULT([test program failed])
84 AC_MSG_ERROR([Cannot determine structure alignment])
85 ],[bird_cv_c_struct_align=16])
86 ])
87 AC_DEFINE_UNQUOTED(CPU_STRUCT_ALIGN, $bird_cv_c_struct_align)
88 ])
89
90 AC_DEFUN(BIRD_CHECK_TIME_T,
91 [AC_CACHE_CHECK([characteristics of time_t], bird_cv_type_time_t, [
92 AC_TRY_RUN([
93 #include <stdio.h>
94 #include <sys/time.h>
95 #include <limits.h>
96
97 int main(void)
98 {
99 FILE *f = fopen("conftestresult", "w");
100 if (!f) return 10;
101 fprintf(f, "%d-bit ", sizeof(time_t)*CHAR_BIT);
102 if ((time_t) -1 > 0) fprintf(f, "un");
103 fprintf(f, "signed");
104 fclose(f);
105 exit(0);
106 }
107 ],[bird_cv_type_time_t=`cat conftestresult`
108 ],[ AC_MSG_RESULT([test program failed])
109 AC_MSG_ERROR([Cannot determine time_t size and signedness.])
110 ],[bird_cv_type_time_t="32-bit signed"])
111 ])
112 case "$bird_cv_type_time_t" in
113 *64-bit*) AC_DEFINE(TIME_T_IS_64BIT) ;;
114 esac
115 case "$bird_cv_type_time_t" in
116 *unsigned*) ;;
117 *) AC_DEFINE(TIME_T_IS_SIGNED) ;;
118 esac
119 ])
120
121 AC_DEFUN(BIRD_CHECK_STRUCT_IP_MREQN,
122 [AC_CACHE_CHECK([for struct ip_mreqn], bird_cv_struct_ip_mreqn,[
123 AC_TRY_COMPILE([#include <netinet/in.h>
124 ],[struct ip_mreqn x;
125 ],[bird_cv_struct_ip_mreqn=yes
126 ],[bird_cv_struct_ip_mreqn=no
127 ])])
128 if test "$bird_cv_struct_ip_mreqn" = yes ; then
129 AC_DEFINE(HAVE_STRUCT_IP_MREQN)
130 fi
131 ])
132
133 AC_DEFUN(BIRD_CHECK_LINUX_VERSION,
134 [AC_CACHE_CHECK([Linux kernel version], bird_cv_sys_linux_version, [
135 AC_REQUIRE_CPP()dnl
136 cat > conftest.$ac_ext <<EOF
137 [#]line __oline__ "configure"
138 #include "confdefs.h"
139 #include <linux/version.h>
140 VERSION: UTS_RELEASE
141 EOF
142 bird_cv_sys_linux_version=`eval "$ac_cpp conftest.$ac_ext" 2>&AC_FD_CC | sed '/^VERSION/!d;s/^VERSION: "//;s/".*//'`
143 rm -rf conftest*
144 if test -z "$bird_cv_sys_linux_version" ; then
145 AC_MSG_RESULT([unknown])
146 AC_MSG_ERROR([Cannot determine kernel version])
147 fi
148 ])])
149
150 # BIRD_CHECK_PROG_FLAVOR_GNU(PROGRAM-PATH, IF-SUCCESS, [IF-FAILURE])
151 # copied autoconf internal _AC_PATH_PROG_FLAVOR_GNU
152 m4_define([BIRD_CHECK_PROG_FLAVOR_GNU],
153 [# Check for GNU $1
154 case `"$1" --version 2>&1` in
155 *GNU*)
156 $2;;
157 m4_ifval([$3],
158 [*)
159 $3;;
160 ])esac
161 ])#