]> jfr.im git - solanum.git/blob - librb/acinclude.m4
Merge branch 'master' into authd-framework-2
[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 #ifndef _WIN32
42 #include <sys/types.h>
43 #include <sys/socket.h>
44 #else
45 #include <winsock2.h>
46 #include <ws2tcpip.h>
47 #endif
48
49 #ifndef PF_INET6
50 #error Missing PF_INET6
51 #endif
52 #ifndef AF_INET6
53 #error Mlssing AF_INET6
54 #endif
55 ],[
56 rb_cv_proto_inet6=yes
57 ],[
58 rb_cv_proto_inet6=no
59 ])
60 ])
61
62 if test "X$rb_cv_proto_inet6" = "Xyes"; then :
63 $1
64 else :
65 $2
66 fi
67 ])
68
69
70 AC_DEFUN([RB_TYPE_STRUCT_SOCKADDR_IN6],[
71 rb_have_sockaddr_in6=
72 AC_CHECK_TYPES([struct sockaddr_in6],[
73 rb_have_sockaddr_in6=yes
74 ],[
75 rb_have_sockaddr_in6=no
76 ],[
77 #ifndef _WIN32
78 #include <sys/types.h>
79 #include <sys/socket.h>
80 #include <netinet/in.h>
81 #else
82 #include <winsock2.h>
83 #include <ws2tcpip.h>
84 #endif
85 ])
86
87 if test "X$rb_have_sockaddr_in6" = "Xyes"; then :
88 $1
89 else :
90 $2
91 fi
92 ])
93
94
95 AC_DEFUN([RB_CHECK_TIMER_CREATE],
96 [AC_CACHE_CHECK([for a working timer_create(CLOCK_REALTIME)],
97 [rb__cv_timer_create_works],
98 [AC_TRY_RUN([
99 #ifdef HAVE_TIME_H
100 #include <time.h>
101 #endif
102 #ifdef HAVE_SIGNAL_H
103 #include <signal.h>
104 #endif
105 #ifdef HAVE_UNISTD_H
106 #include <unistd.h>
107 #endif
108 int main(int argc, char *argv[])
109 {
110 #if HAVE_TIMER_CREATE
111 struct sigevent ev;
112 timer_t timer;
113 ev.sigev_notify = SIGEV_SIGNAL;
114 ev.sigev_signo = SIGVTALRM;
115 if (timer_create(CLOCK_REALTIME, &ev, &timer) != 0) {
116 return 1;
117 }
118 #else
119 return 1;
120 #endif
121 return 0;
122 }
123 ],
124 [rb__cv_timer_create_works=yes],
125 [rb__cv_timer_create_works=no],
126 [rb__cv_timer_create_works=no])
127 ])
128 case $rb__cv_timer_create_works in
129 yes) AC_DEFINE([USE_TIMER_CREATE], 1,
130 [Define to 1 if we can use timer_create(CLOCK_REALTIME,...)]);;
131 esac
132 ])
133
134
135
136 AC_DEFUN([RB_CHECK_TIMERFD_CREATE],
137 [AC_CACHE_CHECK([for a working timerfd_create(CLOCK_REALTIME)],
138 [rb__cv_timerfd_create_works],
139 [AC_TRY_RUN([
140 #ifdef HAVE_TIME_H
141 #include <time.h>
142 #endif
143 #ifdef HAVE_SIGNAL_H
144 #include <signal.h>
145 #endif
146 #ifdef HAVE_UNISTD_H
147 #include <unistd.h>
148 #endif
149 #ifdef HAVE_SYS_TIMERFD_H
150 #include <sys/timerfd.h>
151 #endif
152 int main(int argc, char *argv[])
153 {
154 #if defined(HAVE_TIMERFD_CREATE) && defined(HAVE_SYS_TIMERFD_H)
155 if (timerfd_create(CLOCK_REALTIME, 0) < 0) {
156 return 1;
157 }
158 #else
159 return 1;
160 #endif
161 return 0;
162 }
163 ],
164 [rb__cv_timerfd_create_works=yes],
165 [rb__cv_timerfd_create_works=no],
166 [rb__cv_timerfd_create_works=no])
167 ])
168 case $rb__cv_timerfd_create_works in
169 yes) AC_DEFINE([USE_TIMERFD_CREATE], 1,
170 [Define to 1 if we can use timerfd_create(CLOCK_REALTIME,...)]);;
171 esac
172 ])
173