Statistics
| Branch: | Revision:

iof-bird-daemon / aclocal.m4 @ 5d6dc930

History | View | Annotate | Download (2.51 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_STRUCT_ALIGN],
5
[AC_CACHE_CHECK([usual alignment of structures],bird_cv_c_struct_align,[
6
AC_TRY_RUN([
7
#include <stdio.h>
8

    
9
struct { char x; long int y; } ary[2];
10

    
11
int main(void)
12
{
13
  FILE *f = fopen("conftestresult", "w");
14
  if (!f) return 10;
15
  fprintf(f, "%d", sizeof(ary)/2);
16
  fclose(f);
17
  exit(0);
18
}
19
],[
20
bird_cv_c_struct_align=`cat conftestresult`
21
],[
22
AC_MSG_RESULT([test program failed])
23
AC_MSG_ERROR([Cannot determine structure alignment])
24
],[bird_cv_c_struct_align=16])
25
])
26
AC_DEFINE_UNQUOTED([CPU_STRUCT_ALIGN], [$bird_cv_c_struct_align], [Usual alignment of structures])
27
])
28

    
29
AC_DEFUN([BIRD_CHECK_TIME_T],
30
[AC_CACHE_CHECK([characteristics of time_t], bird_cv_type_time_t, [
31
AC_TRY_RUN([
32
#include <stdio.h>
33
#include <sys/time.h>
34
#include <limits.h>
35

    
36
int main(void)
37
{
38
  FILE *f = fopen("conftestresult", "w");
39
  if (!f) return 10;
40
  fprintf(f, "%d-bit ", sizeof(time_t)*CHAR_BIT);
41
  if ((time_t) -1 > 0) fprintf(f, "un");
42
  fprintf(f, "signed");
43
  fclose(f);
44
  exit(0);
45
}
46
],[bird_cv_type_time_t=`cat conftestresult`
47
],[	AC_MSG_RESULT([test program failed])
48
	AC_MSG_ERROR([Cannot determine time_t size and signedness.])
49
],[bird_cv_type_time_t="32-bit signed"])
50
])
51
case "$bird_cv_type_time_t" in
52
	*64-bit*)	AC_DEFINE([TIME_T_IS_64BIT], [1], [Define to 1 if time_t is 64 bit]) ;;
53
	esac
54
case "$bird_cv_type_time_t" in
55
	*unsigned*)	;;
56
	*)		AC_DEFINE([TIME_T_IS_SIGNED], [1], [Define to 1 if time_t is signed]) ;;
57
	esac
58
])
59

    
60
AC_DEFUN([BIRD_CHECK_PTHREADS],
61
[
62
  bird_tmp_cflags="$CFLAGS"
63

    
64
  CFLAGS="$CFLAGS -pthread"
65
  AC_CACHE_CHECK([whether POSIX threads are available], bird_cv_lib_pthreads,
66
    [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); ]])],
67
		    [bird_cv_lib_pthreads=yes], [bird_cv_lib_pthreads=no])])
68

    
69
  CFLAGS="$bird_tmp_cflags"
70
])
71

    
72
AC_DEFUN([BIRD_CHECK_GCC_OPTION],
73
[
74
  bird_tmp_cflags="$CFLAGS"
75

    
76
  CFLAGS="$3 $2"
77
  AC_CACHE_CHECK([whether CC supports $2], $1,
78
    [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], [$1=yes], [$1=no])])
79

    
80
  CFLAGS="$bird_tmp_cflags"
81
])
82

    
83
AC_DEFUN([BIRD_ADD_GCC_OPTION],
84
[
85
  if test "$$1" = yes ; then
86
    CFLAGS="$CFLAGS $2"
87
  fi
88
])
89

    
90
# BIRD_CHECK_PROG_FLAVOR_GNU(PROGRAM-PATH, IF-SUCCESS, [IF-FAILURE])
91
# copied autoconf internal _AC_PATH_PROG_FLAVOR_GNU
92
AC_DEFUN([BIRD_CHECK_PROG_FLAVOR_GNU],
93
[# Check for GNU $1
94
case `"$1" --version 2>&1` in
95
*GNU*)
96
  $2;;
97
m4_ifval([$3],
98
[*)
99
  $3;;
100
])esac
101
])