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