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