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)
10 bits=`expr $size "*" 8`
11 AC_MSG_CHECKING([for $bits-bit type])
12 if test $ac_cv_sizeof_int = $size ; then
14 elif test $ac_cv_sizeof_char = $size ; then
16 elif test $ac_cv_sizeof_short_int = $size ; then
18 elif test $ac_cv_sizeof_long_int = $size ; then
21 AC_MSG_RESULT([not found])
22 AC_MSG_ERROR([Cannot find $bits-bit integer type.])
25 AC_DEFINE_UNQUOTED(INTEGER_$bits, $res)
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,[
35 unsigned int x = 0x12345678;
36 unsigned char *z = (unsigned char *) &x;
40 FILE *f = fopen("conftestresult", "w");
42 fprintf(f, "%02x %02x %02x %02x", *z, *(z+1), *(z+2), *(z+3));
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
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.])
59 case $bird_cv_c_endian in
60 big-endian) AC_DEFINE(CPU_BIG_ENDIAN) ;;
61 little-endian) AC_DEFINE(CPU_LITTLE_ENDIAN) ;;
65 AC_DEFUN(BIRD_CHECK_STRUCT_ALIGN,
66 [AC_CACHE_CHECK([usual alignment of structures],bird_cv_c_struct_align,[
70 struct { char x; long int y; } ary[2];
74 FILE *f = fopen("conftestresult", "w");
76 fprintf(f, "%d", sizeof(ary)/2);
81 bird_cv_c_struct_align=`cat conftestresult`
83 AC_MSG_RESULT([test program failed])
84 AC_MSG_ERROR([Cannot determine structure alignment])
85 ],[bird_cv_c_struct_align=16])
87 AC_DEFINE_UNQUOTED(CPU_STRUCT_ALIGN, $bird_cv_c_struct_align)
90 AC_DEFUN(BIRD_CHECK_TIME_T,
91 [AC_CACHE_CHECK([characteristics of time_t], bird_cv_type_time_t, [
99 FILE *f = fopen("conftestresult", "w");
101 fprintf(f, "%d-bit ", sizeof(time_t)*CHAR_BIT);
102 if ((time_t) -1 > 0) fprintf(f, "un");
103 fprintf(f, "signed");
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"])
112 case "$bird_cv_type_time_t" in
113 *64-bit*) AC_DEFINE(TIME_T_IS_64BIT) ;;
115 case "$bird_cv_type_time_t" in
117 *) AC_DEFINE(TIME_T_IS_SIGNED) ;;
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
128 if test "$bird_cv_struct_ip_mreqn" = yes ; then
129 AC_DEFINE(HAVE_STRUCT_IP_MREQN)
133 AC_DEFUN(BIRD_CHECK_LINUX_VERSION,
134 [AC_CACHE_CHECK([Linux kernel version], bird_cv_sys_linux_version, [
136 cat > conftest.$ac_ext <<EOF
137 [#]line __oline__ "configure"
138 #include "confdefs.h"
139 #include <linux/version.h>
142 bird_cv_sys_linux_version=`eval "$ac_cpp conftest.$ac_ext" 2>&AC_FD_CC | sed '/^VERSION/!d;s/^VERSION: "//;s/".*//'`
144 if test -z "$bird_cv_sys_linux_version" ; then
145 AC_MSG_RESULT([unknown])
146 AC_MSG_ERROR([Cannot determine kernel version])
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],
154 case `"$1" --version 2>&1` in