Statistics
| Branch: | Revision:

iof-bird-daemon / aclocal.m4 @ 42a0c054

History | View | Annotate | Download (4.39 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
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_LINUX_VERSION,
137
[AC_CACHE_CHECK([Linux kernel version], bird_cv_sys_linux_version, [
138
AC_REQUIRE_CPP()dnl
139
cat > conftest.$ac_ext <<EOF
140
[#]line __oline__ "configure"
141
#include "confdefs.h"
142
#include <linux/version.h>
143
VERSION: UTS_RELEASE
144
EOF
145
bird_cv_sys_linux_version=`eval "$ac_cpp conftest.$ac_ext" 2>&AC_FD_CC | sed '/^VERSION/!d;s/^VERSION: "//;s/".*//'`
146
rm -rf conftest*
147
if test -z "$bird_cv_sys_linux_version" ; then
148
	AC_MSG_RESULT([unknown])
149
	AC_MSG_ERROR([Cannot determine kernel version])
150
fi
151
])])
152

    
153
AC_DEFUN(BIRD_CHECK_GCC_OPTIONS,
154
[AC_CACHE_VAL(bird_cv_c_option_no_pointer_sign, [
155
cat >conftest.c <<EOF
156
int main(void)
157
{ return 0; }
158
EOF
159
if $CC -Wall -Wno-pointer-sign conftest.c >&AS_MESSAGE_LOG_FD 2>&1 ; then
160
	bird_cv_c_option_no_pointer_sign=yes
161
else
162
	bird_cv_c_option_no_pointer_sign=no
163
fi
164
rm -rf conftest* a.out
165
])])
166

    
167
# BIRD_CHECK_PROG_FLAVOR_GNU(PROGRAM-PATH, IF-SUCCESS, [IF-FAILURE])
168
# copied autoconf internal _AC_PATH_PROG_FLAVOR_GNU
169
m4_define([BIRD_CHECK_PROG_FLAVOR_GNU],
170
[# Check for GNU $1
171
case `"$1" --version 2>&1` in
172
*GNU*)
173
  $2;;
174
m4_ifval([$3],
175
[*)
176
  $3;;
177
])esac
178
])#