]> jfr.im git - solanum.git/blob - librb/acinclude.m4
rename libratbox to librb, since its pretty modified anyway
[solanum.git] / librb / acinclude.m4
1 # $Id: acinclude.m4 23020 2006-09-01 18:20:19Z androsyn $ - aclocal.m4 - Autoconf fun...
2 AC_DEFUN([AC_DEFINE_DIR], [
3 test "x$prefix" = xNONE && prefix="$ac_default_prefix"
4 test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
5 last_ac_define_dir=`eval echo [$]$2`
6 ac_define_dir=`eval echo [$]last_ac_define_dir`
7 ac_define_dir_counter=0
8 while test "x[$]last_ac_define_dir" != "x[$]ac_define_dir"; do
9 last_ac_define_dir="[$]ac_define_dir"
10 ac_define_dir=`eval echo [$]last_ac_define_dir`
11 AS_VAR_ARITH([ac_define_dir_counter], [$ac_define_dir_counter + 1])
12 AS_VAR_IF([ac_define_dir_counter], [128],
13 [AC_MSG_ERROR([detected recusive directory expansion when expanding $1=[$]$2: [$]ac_define_dir])
14 break])
15 done
16 $1="$ac_define_dir"
17 AC_SUBST($1)
18 ifelse($3, ,
19 AC_DEFINE_UNQUOTED($1, "$ac_define_dir"),
20 AC_DEFINE_UNQUOTED($1, "$ac_define_dir", $3))
21 ])
22
23 AC_DEFUN([AC_SUBST_DIR], [
24 ifelse($2,,,$1="[$]$2")
25 $1=`(
26 test "x$prefix" = xNONE && prefix="$ac_default_prefix"
27 test "x$exec_prefix" = xNONE && exec_prefix="${prefix}"
28 eval echo \""[$]$1"\"
29 )`
30 AC_SUBST($1)
31 ])
32
33
34 dnl IPv6 support macros..pretty much swiped from wget
35
36 dnl RB_PROTO_INET6
37
38 AC_DEFUN([RB_PROTO_INET6],[
39 AC_CACHE_CHECK([for INET6 protocol support], [rb_cv_proto_inet6],[
40 AC_TRY_CPP([
41 #include <sys/types.h>
42 #include <sys/socket.h>
43
44 #ifndef PF_INET6
45 #error Missing PF_INET6
46 #endif
47 #ifndef AF_INET6
48 #error Mlssing AF_INET6
49 #endif
50 ],[
51 rb_cv_proto_inet6=yes
52 ],[
53 rb_cv_proto_inet6=no
54 ])
55 ])
56
57 if test "X$rb_cv_proto_inet6" = "Xyes"; then :
58 $1
59 else :
60 $2
61 fi
62 ])
63
64
65 AC_DEFUN([RB_TYPE_STRUCT_SOCKADDR_IN6],[
66 rb_have_sockaddr_in6=
67 AC_CHECK_TYPES([struct sockaddr_in6],[
68 rb_have_sockaddr_in6=yes
69 ],[
70 rb_have_sockaddr_in6=no
71 ],[
72 #include <sys/types.h>
73 #include <sys/socket.h>
74 #include <netinet/in.h>
75 ])
76
77 if test "X$rb_have_sockaddr_in6" = "Xyes"; then :
78 $1
79 else :
80 $2
81 fi
82 ])
83
84
85 AC_DEFUN([RB_CHECK_TIMER_CREATE],
86 [AC_CACHE_CHECK([for a working timer_create(CLOCK_REALTIME)],
87 [rb__cv_timer_create_works],
88 [AC_TRY_RUN([
89 #ifdef HAVE_TIME_H
90 #include <time.h>
91 #endif
92 #ifdef HAVE_SIGNAL_H
93 #include <signal.h>
94 #endif
95 #ifdef HAVE_UNISTD_H
96 #include <unistd.h>
97 #endif
98 int main(int argc, char *argv[])
99 {
100 #if HAVE_TIMER_CREATE
101 struct sigevent ev;
102 timer_t timer;
103 ev.sigev_notify = SIGEV_SIGNAL;
104 ev.sigev_signo = SIGVTALRM;
105 if (timer_create(CLOCK_REALTIME, &ev, &timer) != 0) {
106 return 1;
107 }
108 #else
109 return 1;
110 #endif
111 return 0;
112 }
113 ],
114 [rb__cv_timer_create_works=yes],
115 [rb__cv_timer_create_works=no])
116 ])
117 case $rb__cv_timer_create_works in
118 yes) AC_DEFINE([USE_TIMER_CREATE], 1,
119 [Define to 1 if we can use timer_create(CLOCK_REALTIME,...)]);;
120 esac
121 ])
122
123
124
125 AC_DEFUN([RB_CHECK_TIMERFD_CREATE],
126 [AC_CACHE_CHECK([for a working timerfd_create(CLOCK_REALTIME)],
127 [rb__cv_timerfd_create_works],
128 [AC_TRY_RUN([
129 #ifdef HAVE_TIME_H
130 #include <time.h>
131 #endif
132 #ifdef HAVE_SIGNAL_H
133 #include <signal.h>
134 #endif
135 #ifdef HAVE_UNISTD_H
136 #include <unistd.h>
137 #endif
138 #ifdef HAVE_SYS_TIMERFD_H
139 #include <sys/timerfd.h>
140 #endif
141 int main(int argc, char *argv[])
142 {
143 #if defined(HAVE_TIMERFD_CREATE) && defined(HAVE_SYS_TIMERFD_H)
144 if (timerfd_create(CLOCK_REALTIME, 0) < 0) {
145 return 1;
146 }
147 #else
148 return 1;
149 #endif
150 return 0;
151 }
152 ],
153 [rb__cv_timerfd_create_works=yes],
154 [rb__cv_timerfd_create_works=no])
155 ])
156 case $rb__cv_timerfd_create_works in
157 yes) AC_DEFINE([USE_TIMERFD_CREATE], 1,
158 [Define to 1 if we can use timerfd_create(CLOCK_REALTIME,...)]);;
159 esac
160 ])
161