1 | use 5.006; |
1 | use 5.008002; |
2 | |
2 | |
|
|
3 | use strict qw(vars subs); |
3 | use Config; |
4 | use Config; |
4 | use ExtUtils::MakeMaker; |
5 | use ExtUtils::MakeMaker; |
5 | |
6 | |
6 | unless (-e "libev/ev_epoll.c") { |
7 | unless (-e "libev/ev_epoll.c") { |
7 | print <<EOF; |
8 | print <<EOF; |
… | |
… | |
43 | will otherwise be autodetected at both compile- and runtime. (this setting |
44 | will otherwise be autodetected at both compile- and runtime. (this setting |
44 | currently affects the use of nanosleep over select as well). |
45 | currently affects the use of nanosleep over select as well). |
45 | |
46 | |
46 | EOF |
47 | EOF |
47 | |
48 | |
48 | $DEFINE .= " -DEV_USE_MONOTONIC=" . (0 + (prompt ("Enable optional support for CLOCK_MONOTONIC (y/n)?", "y") =~ /[yY]/)); |
49 | my $DEFINE .= " -DEV_USE_MONOTONIC=" . (0 + (prompt ("Enable optional support for CLOCK_MONOTONIC (y/n)?", "y") =~ /[yY]/)); |
49 | |
50 | |
50 | print <<EOF; |
51 | print <<EOF; |
51 | |
52 | |
52 | *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** |
53 | *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** |
53 | |
54 | |
54 | |
55 | |
55 | POSIX optionally offers support for a (potentially) high-resolution |
56 | POSIX optionally offers support for a (potentially) high-resolution |
56 | realtime clock interface. In a good implementation, using it is faster |
57 | realtime clock interface. In a good implementation, using it is faster |
57 | than the normal method of using gettimeofday. Unfortunately, this option |
58 | than the normal method of using gettimeofday. Unfortunately, this option |
58 | is also bound to be broken on some systems, so you can disable use and |
59 | is also bound to be broken on some systems, and current EV versions do not |
59 | probing of this feature altogether here. Otherwise support for this clock |
60 | actually call C<gettimeofday> very often, so ti defaults to no. |
60 | type will be autodetected at compiletime. |
|
|
61 | |
61 | |
62 | EOF |
62 | EOF |
63 | |
63 | |
64 | $DEFINE .= " -DEV_USE_REALTIME=" . (0 + (prompt ("Prefer clock_gettime (CLOCK_REALTIME) over gettimeofday (y/n)?", "y") =~ /[yY]/)); |
64 | $DEFINE .= " -DEV_USE_REALTIME=" . (0 + (prompt ("Prefer clock_gettime (CLOCK_REALTIME) over gettimeofday (y/n)?", "n") =~ /[yY]/)); |
65 | |
|
|
66 | print <<EOF; |
|
|
67 | |
|
|
68 | *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** |
|
|
69 | |
|
|
70 | |
|
|
71 | Another useful bit of functionality is the Linux eventfd, which is useful |
|
|
72 | for faster signal handling (don't care) and intra-thread communications |
|
|
73 | (mostly useful for embedding). Kernel support for this will be probed at |
|
|
74 | runtime, but your libc must contain the necessary wrapper. Glibc 2.7 and |
|
|
75 | later should have this wrapper. |
|
|
76 | |
|
|
77 | EOF |
|
|
78 | |
|
|
79 | $DEFINE .= " -DEV_USE_EVENTFD=" . (0 + (prompt ("Enable linux eventfd support (y/n)?", (-e "/usr/include/sys/eventfd.h") || $ENV{EV_EVENTFD} ? "y" : "n") =~ /[yY]/)); |
|
|
80 | |
65 | |
81 | print <<EOF; |
66 | print <<EOF; |
82 | |
67 | |
83 | *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** |
68 | *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** |
84 | |
69 | |
… | |
… | |
142 | fall back to using select when epoll isn't available. If unsure, accept |
127 | fall back to using select when epoll isn't available. If unsure, accept |
143 | the default. |
128 | the default. |
144 | |
129 | |
145 | EOF |
130 | EOF |
146 | |
131 | |
|
|
132 | my $can_epoll = -e "/usr/include/sys/epoll.h"; |
|
|
133 | $can_epoll = $ENV{EV_EPOLL} if exists $ENV{EV_EPOLL}; |
147 | $DEFINE .= " -DEV_USE_EPOLL=" . (0 + (prompt ("Enable epoll backend (y/n)?", (-e "/usr/include/sys/epoll.h") ? "y" : "n") =~ /[yY]/)); |
134 | $DEFINE .= " -DEV_USE_EPOLL=" . (0 + (prompt ("Enable epoll backend (y/n)?", $can_epoll ? "y" : "n") =~ /[yY]/)); |
148 | |
135 | |
149 | print <<EOF; |
136 | print <<EOF; |
150 | |
137 | |
151 | *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** |
138 | *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** |
152 | |
139 | |
… | |
… | |
155 | many BSD systems. Support for kqueue will be detected at runtime, with a |
142 | many BSD systems. Support for kqueue will be detected at runtime, with a |
156 | safe fallback to other methods when it cannot be used. |
143 | safe fallback to other methods when it cannot be used. |
157 | |
144 | |
158 | Note that kqueue is broken on most operating systems, so by default it |
145 | Note that kqueue is broken on most operating systems, so by default it |
159 | won't be used on many platforms, but you can still create your own event |
146 | won't be used on many platforms, but you can still create your own event |
160 | loop with qkueue backend. |
147 | loop with kqueue backend if you ask specifically for it. |
161 | |
148 | |
162 | Here is what we know: |
149 | Here is what we know: |
163 | |
150 | |
164 | NetBSD: partially working in at least 3.1. Yeah! :) |
151 | NetBSD: partially working in at least 3.1. Yeah! :) |
165 | FreeBSD: broken on at least 6.2-STABLE, |
152 | FreeBSD: broken on at least 6.2-STABLE, |
… | |
… | |
169 | OS X: completely, utterly broken on at least < 10.5. |
156 | OS X: completely, utterly broken on at least < 10.5. |
170 | |
157 | |
171 | EOF |
158 | EOF |
172 | |
159 | |
173 | my $can_kqueue = -e "/usr/include/sys/event.h"; |
160 | my $can_kqueue = -e "/usr/include/sys/event.h"; |
174 | |
161 | $can_kqueue = $ENV{EV_KQUEUE} if exists $ENV{EV_KQUEUE}; |
175 | $DEFINE .= " -DEV_USE_KQUEUE=" . (0 + (prompt ("Enable kqueue backend (y/n)?", $can_kqueue ? "y" : "n") =~ /[yY]/)); |
162 | $DEFINE .= " -DEV_USE_KQUEUE=" . (0 + (prompt ("Enable kqueue backend (y/n)?", $can_kqueue ? "y" : "n") =~ /[yY]/)); |
176 | |
163 | |
177 | print <<EOF; |
164 | print <<EOF; |
178 | |
165 | |
179 | *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** |
166 | *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** |
… | |
… | |
197 | can specify additional libraries to provide these calls (and any other |
184 | can specify additional libraries to provide these calls (and any other |
198 | required by EV) now, or accept the default. |
185 | required by EV) now, or accept the default. |
199 | |
186 | |
200 | EOF |
187 | EOF |
201 | |
188 | |
202 | $SOLARIS_LIBS = $^O =~ /solaris/ ? " -lsocket -lnsl" : ""; |
189 | my $solaris_libs = $^O =~ /solaris/i ? "-lsocket -lnsl" : ""; |
203 | |
190 | my $librt = $^O =~ /linux/i ? "-lpthread" : "-lpthread -lrt"; |
204 | $LIBS = prompt "Extra libraries for pthread_atfork and clock_gettime?", "-lpthread -lrt$SOLARIS_LIBS"; |
191 | my $LIBS = prompt "Extra libraries for pthread_atfork and clock_gettime?", "$librt $solaris_libs"; |
205 | |
192 | |
206 | |
193 | |
207 | print <<EOF; |
194 | print <<EOF; |
208 | |
195 | |
209 | *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** |
196 | *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** |
210 | |
197 | |
211 | |
198 | |
212 | A backend of a different kind is the Linux inotify(7) interface, which can |
199 | A backend of a different kind is the Linux inotify(7) interface, which can |
213 | be used to speed up (and reduce resource consumption) of stat watchers. If |
200 | be used to speed up (and reduce resource consumption) of stat watchers. If |
214 | you have it, it is usually a good idea to enable it. |
201 | you have the include file and libc support for it, it is usually a good |
|
|
202 | idea to enable it, as kernel availability is detected at runtime. |
215 | |
203 | |
216 | EOF |
204 | EOF |
217 | |
205 | |
218 | my $can_inotify = -e "/usr/include/sys/inotify.h"; |
206 | my $can_inotify = -e "/usr/include/sys/inotify.h"; |
219 | |
207 | $can_inotify = $ENV{EV_INOTIFY} if exists $ENV{EV_INOTIFY}; |
220 | $DEFINE .= " -DEV_USE_INOTIFY=" . (0 + (prompt ("Enable inotify support (y/n)?", $can_inotify ? "y" : "n") =~ /[yY]/)); |
208 | $DEFINE .= " -DEV_USE_INOTIFY=" . (0 + (prompt ("Enable inotify support (y/n)?", $can_inotify ? "y" : "n") =~ /[yY]/)); |
|
|
209 | |
|
|
210 | print <<EOF; |
|
|
211 | |
|
|
212 | *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** |
|
|
213 | |
|
|
214 | |
|
|
215 | Another useful bit of functionality is the Linux eventfd, which is useful |
|
|
216 | for faster signal handling (don't care) and intra-thread communications |
|
|
217 | (more relevant). Kernel support for this will be probed at runtime, but |
|
|
218 | your libc must contain the necessary wrapper. Glibc 2.7 and later should |
|
|
219 | have this wrapper. |
|
|
220 | |
|
|
221 | EOF |
|
|
222 | |
|
|
223 | my $can_eventfd = -e "/usr/include/sys/eventfd.h"; |
|
|
224 | $can_eventfd = $ENV{EV_EVENTFD} if exists $ENV{EV_EVENTFD}; |
|
|
225 | $DEFINE .= " -DEV_USE_EVENTFD=" . (0 + (prompt ("Enable linux eventfd support (y/n)?", $can_eventfd ? "y" : "n") =~ /[yY]/)); |
|
|
226 | |
|
|
227 | print <<EOF; |
|
|
228 | |
|
|
229 | *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** |
|
|
230 | |
|
|
231 | |
|
|
232 | Another sometimes useful bit of functionality is the Linux signalfd, which |
|
|
233 | is useful for faster signal handling (don't care). Kernel support for |
|
|
234 | this will be probed at runtime, but your libc must contain the necessary |
|
|
235 | wrapper and include files. Glibc 2.9 and later should have this wrapper. |
|
|
236 | |
|
|
237 | EOF |
|
|
238 | |
|
|
239 | my $can_signalfd = -e "/usr/include/sys/signalfd.h"; |
|
|
240 | $can_signalfd = $ENV{EV_SIGNALFD} if exists $ENV{EV_SIGNALFD}; |
|
|
241 | $DEFINE .= " -DEV_USE_SIGNALFD=" . (0 + (prompt ("Enable linux signalfd support (y/n)?", $can_signalfd ? "y" : "n") =~ /[yY]/)); |
221 | |
242 | |
222 | print <<EOF; |
243 | print <<EOF; |
223 | |
244 | |
224 | *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** |
245 | *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** |
225 | |
246 | |
… | |
… | |
243 | DEFINE => "$DEFINE", |
264 | DEFINE => "$DEFINE", |
244 | NAME => "EV", |
265 | NAME => "EV", |
245 | LIBS => [$LIBS], |
266 | LIBS => [$LIBS], |
246 | PREREQ_PM => { |
267 | PREREQ_PM => { |
247 | @anyevent, |
268 | @anyevent, |
|
|
269 | "common::sense" => 0, |
248 | }, |
270 | }, |
249 | VERSION_FROM => "EV.pm", |
271 | VERSION_FROM => "EV.pm", |
250 | PM => { |
272 | PM => { |
251 | 'EV.pm' => '$(INST_LIBDIR)/EV.pm', |
273 | 'EV.pm' => '$(INST_LIBDIR)/EV.pm', |
252 | 'EV/EVAPI.h' => '$(INST_LIBDIR)/EV/EVAPI.h', |
274 | 'EV/EVAPI.h' => '$(INST_LIBDIR)/EV/EVAPI.h', |
253 | 'EV/MakeMaker.pm' => '$(INST_LIBDIR)/EV/MakeMaker.pm', |
275 | 'EV/MakeMaker.pm' => '$(INST_LIBDIR)/EV/MakeMaker.pm', |
254 | 'libev/ev.h' => '$(INST_LIBDIR)/EV/ev.h', |
276 | 'libev/ev.h' => '$(INST_LIBDIR)/EV/ev.h', |
255 | 'libev/ev.pod' => '$(INST_LIBDIR)/EV/c_doc.pod', |
277 | 'libev/ev.pod' => '$(INST_LIBDIR)/EV/libev.pod', |
256 | }, |
278 | }, |
257 | MAN3PODS => { |
279 | MAN3PODS => { |
258 | 'EV.pm' => '$(INST_MAN3DIR)/EV.$(MAN3EXT)', |
280 | 'EV.pm' => '$(INST_MAN3DIR)/EV.$(MAN3EXT)', |
259 | 'EV/MakeMaker.pm' => '$(INST_MAN3DIR)/EV::MakeMaker.$(MAN3EXT)', |
281 | 'EV/MakeMaker.pm' => '$(INST_MAN3DIR)/EV::MakeMaker.$(MAN3EXT)', |
260 | 'libev/ev.pod' => '$(INST_MAN3DIR)/EV::c_doc.$(MAN3EXT)', |
282 | 'libev/ev.pod' => '$(INST_MAN3DIR)/EV::libev.$(MAN3EXT)', |
261 | }, |
283 | }, |
262 | ); |
284 | ); |
263 | |
285 | |
264 | |
286 | |