Statistics
| Branch: | Revision:

iof-bird-daemon / aclocal.m4 @ 170c984a

History | View | Annotate | Download (3.16 KB)

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
AC_DEFUN(BIRD_CHECK_ENDIAN,
30
[AC_CACHE_CHECK([CPU endianity], bird_cv_c_endian,[
31
AC_TRY_RUN([
32
#include <stdio.h>
33

    
34
unsigned int x = 0x12345678;
35
unsigned char *z = (unsigned char *) &x;
36

    
37
int main(void)
38
{
39
  FILE *f = fopen("conftestresult", "w");
40
  if (!f) return 10;
41
  fprintf(f, "%02x %02x %02x %02x", *z, *(z+1), *(z+2), *(z+3));
42
  fclose(f);
43
  exit(0);
44
}
45
],[
46
	endian=`cat conftestresult`
47
	if test "$endian" = "12 34 56 78" ; then
48
		bird_cv_c_endian=big-endian
49
	elif test "$endian" = "78 56 34 12" ; then
50
		bird_cv_c_endian=little-endian
51
	fi
52
],[endian="test program failed"],[endian="not available, we're cross compiling"])
53
if test -z "$bird_cv_c_endian" ; then
54
	AC_MSG_RESULT($endian)
55
	AC_MSG_ERROR([Cannot determine CPU endianity.])
56
	fi
57
])
58
case $bird_cv_c_endian in
59
	big-endian)	AC_DEFINE(CPU_BIG_ENDIAN) ;;
60
	little-endian)	AC_DEFINE(CPU_LITTLE_ENDIAN) ;;
61
	esac
62
])
63

    
64
AC_DEFUN(BIRD_CHECK_STRUCT_ALIGN,
65
[AC_CACHE_CHECK([usual alignment of structures],bird_cv_c_struct_align,[
66
AC_TRY_RUN([
67
#include <stdio.h>
68

    
69
struct { char x; long int y; } ary[2];
70

    
71
int main(void)
72
{
73
  FILE *f = fopen("conftestresult", "w");
74
  if (!f) return 10;
75
  fprintf(f, "%d", sizeof(ary)/2);
76
  fclose(f);
77
  exit(0);
78
}
79
],[
80
bird_cv_c_struct_align=`cat conftestresult`
81
],[
82
AC_MSG_RESULT([test program failed])
83
AC_MSG_ERROR([Cannot determine structure alignment])
84
],[bird_cv_c_struct_align=16])
85
])
86
AC_DEFINE_UNQUOTED(CPU_STRUCT_ALIGN, $bird_cv_c_struct_align)
87
])
88

    
89
AC_DEFUN(BIRD_CHECK_TIME_T,
90
[AC_CACHE_CHECK([characteristics of time_t], bird_cv_type_time_t, [
91
AC_TRY_RUN([
92
#include <stdio.h>
93
#include <sys/time.h>
94
#include <limits.h>
95

    
96
int main(void)
97
{
98
  FILE *f = fopen("conftestresult", "w");
99
  if (!f) return 10;
100
  fprintf(f, "%d-bit ", sizeof(time_t)*CHAR_BIT);
101
  if ((time_t) -1 > 0) fprintf(f, "un");
102
  fprintf(f, "signed");
103
  fclose(f);
104
  exit(0);
105
}
106
],[bird_cv_type_time_t=`cat conftestresult`
107
],[	AC_MSG_RESULT([test program failed])
108
	AC_MSG_ERROR([Cannot determine time_t size and signedness.])
109
],[bird_cv_type_time_t="32-bit signed"])
110
])
111
case "$bird_cv_type_time_t" in
112
	*64-bit*)	AC_DEFINE(TIME_T_IS_64BIT) ;;
113
	esac
114
case "$bird_cv_type_time_t" in
115
	*unsigned*)	;;
116
	*)		AC_DEFINE(TIME_T_IS_SIGNED) ;;
117
	esac
118
])
119

    
120
AC_DEFUN(BIRD_CHECK_STRUCT_IP_MREQN,
121
[AC_CACHE_CHECK([for struct ip_mreqn], bird_cv_struct_ip_mreqn,[
122
AC_TRY_COMPILE([#include <netinet/in.h>
123
],[struct ip_mreqn x;
124
],[bird_cv_struct_ip_mreqn=yes
125
],[bird_cv_struct_ip_mreqn=no
126
])])
127
if test "$bird_cv_struct_ip_mreqn" = yes ; then
128
	AC_DEFINE(HAVE_STRUCT_IP_MREQN)
129
fi
130
])