]> jfr.im git - solanum.git/blame - librb/acinclude.m4
librb: further cleanups
[solanum.git] / librb / acinclude.m4
CommitLineData
db137867
AC
1# $Id: acinclude.m4 23020 2006-09-01 18:20:19Z androsyn $ - aclocal.m4 - Autoconf fun...
2AC_DEFUN([AC_DEFINE_DIR], [
3 test "x$prefix" = xNONE && prefix="$ac_default_prefix"
4 test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
c74836dc
NPB
5 last_ac_define_dir=`eval echo [$]$2`
6 ac_define_dir=`eval echo [$]last_ac_define_dir`
422cf3bb 7 ac_define_dir_counter=0
c74836dc
NPB
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`
422cf3bb
NPB
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])
c74836dc 15 done
db137867
AC
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
23AC_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
db137867
AC
34dnl IPv6 support macros..pretty much swiped from wget
35
36dnl RB_PROTO_INET6
37
38AC_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
65AC_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
85AC_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
98int 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],
498b1893 115 [rb__cv_timer_create_works=no],
db137867
AC
116 [rb__cv_timer_create_works=no])
117 ])
118case $rb__cv_timer_create_works in
119 yes) AC_DEFINE([USE_TIMER_CREATE], 1,
120 [Define to 1 if we can use timer_create(CLOCK_REALTIME,...)]);;
121esac
122])
123
3202e249
VY
124
125
126AC_DEFUN([RB_CHECK_TIMERFD_CREATE],
127 [AC_CACHE_CHECK([for a working timerfd_create(CLOCK_REALTIME)],
128 [rb__cv_timerfd_create_works],
129 [AC_TRY_RUN([
130#ifdef HAVE_TIME_H
131#include <time.h>
132#endif
133#ifdef HAVE_SIGNAL_H
134#include <signal.h>
135#endif
136#ifdef HAVE_UNISTD_H
137#include <unistd.h>
138#endif
139#ifdef HAVE_SYS_TIMERFD_H
140#include <sys/timerfd.h>
141#endif
142int main(int argc, char *argv[])
143{
144#if defined(HAVE_TIMERFD_CREATE) && defined(HAVE_SYS_TIMERFD_H)
145 if (timerfd_create(CLOCK_REALTIME, 0) < 0) {
146 return 1;
147 }
148#else
149 return 1;
150#endif
151 return 0;
152}
153 ],
154 [rb__cv_timerfd_create_works=yes],
498b1893 155 [rb__cv_timerfd_create_works=no],
3202e249
VY
156 [rb__cv_timerfd_create_works=no])
157 ])
158case $rb__cv_timerfd_create_works in
159 yes) AC_DEFINE([USE_TIMERFD_CREATE], 1,
160 [Define to 1 if we can use timerfd_create(CLOCK_REALTIME,...)]);;
161esac
162])
163