1 | use 5.006; |
1 | use 5.006; |
2 | |
2 | |
3 | use Config; |
3 | use Config; |
4 | use ExtUtils::MakeMaker; |
4 | use ExtUtils::MakeMaker; |
5 | |
|
|
6 | |
5 | |
7 | unless (-e "libev/ev_epoll.c") { |
6 | unless (-e "libev/ev_epoll.c") { |
8 | print <<EOF; |
7 | print <<EOF; |
9 | |
8 | |
10 | *** |
9 | *** |
… | |
… | |
70 | print <<EOF; |
69 | print <<EOF; |
71 | |
70 | |
72 | |
71 | |
73 | *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** |
72 | *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** |
74 | |
73 | |
75 | EV needs the functions pthread_atfork and clock_gettime. On most systems |
74 | EV can use various backends with various portability issue. The select |
76 | you need some special libraries for this (such as -lrt and -lpthread). You can |
75 | backend is the most portable and makes for a good fallback, but it can be |
77 | specify additional libraries to provide these calls now, or accept the default. |
76 | limited to a low number of file descriptors and/or might not compile. If |
|
|
77 | you have problems with compiling ev_select., you might try to play around |
|
|
78 | with disabling it here, or forcing it to use the fd_set provided by your |
|
|
79 | OS, via the next question. I highly recommend keeping it in. |
78 | |
80 | |
79 | EOF |
81 | EOF |
80 | |
82 | |
81 | $LIBS = prompt "Extra libraries for pthread_atfork and clock_gettime?", "-lpthread -lrt"; |
83 | if (prompt ("Enable select backend (y/n)?", "y") =~ /[yY]/) { |
|
|
84 | $DEFINE .= " -DEV_USE_SELECT"; |
82 | |
85 | |
83 | |
|
|
84 | print <<EOF; |
86 | print <<EOF; |
85 | |
87 | |
86 | |
88 | |
87 | *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** |
89 | *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** |
88 | |
90 | |
89 | EV needs the functions pthread_atfork and clock_gettime. On most systems |
91 | The select backend can operate in two modes. One uses the system-provided |
90 | you need some special libraries for this (such as -lrt and -lpthread). You can |
92 | fd_set and is usually limited to 1024 file descriptors (64 on windows), |
91 | specify additional libraries to provide these calls now, or accept the default. |
93 | the other requires your header files to define NFDBITS and declare a |
|
|
94 | suitable fd_mask type. If you run into problems compiling ev_select.c, you |
|
|
95 | can try forcing the use of the system fd_set here. |
|
|
96 | |
|
|
97 | EOF |
|
|
98 | |
|
|
99 | if (prompt ("Force use of system fd_set for select backend (y/n)?", "n") =~ /[yY]/) { |
|
|
100 | $DEFINE .= " -DEV_SELECT_USE_FD_SET"; |
|
|
101 | } |
|
|
102 | } |
|
|
103 | |
|
|
104 | print <<EOF; |
|
|
105 | |
|
|
106 | |
|
|
107 | *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** |
|
|
108 | |
|
|
109 | The second very portable backend is poll(2). It does not exist on windows |
|
|
110 | and various versions of Mac OS X (and on the other versions it simply |
|
|
111 | doesn't work), but works basically everywhere else. It is recommended to use |
|
|
112 | the default here unless you run into compile problems in ev_poll.c. |
|
|
113 | |
|
|
114 | EOF |
|
|
115 | |
|
|
116 | if (prompt ("Enable poll backend (y/n)?", (-e "/usr/include/poll.h") ? "y" : "n") =~ /[yY]/) { |
|
|
117 | $DEFINE .= " -DEV_USE_POLL"; |
|
|
118 | } |
|
|
119 | |
|
|
120 | print <<EOF; |
|
|
121 | |
|
|
122 | |
|
|
123 | *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** |
|
|
124 | |
|
|
125 | EV by default uses select, which makes it hard to write efficient servers, |
|
|
126 | especially if the number of active conencitons is much lower than the open |
|
|
127 | ones. GNU/Linux systems have a more scalable method called "epoll", which |
|
|
128 | EV can use. For this to work, both your kernel and glibc have to support |
|
|
129 | epoll, but if you can compile it, the detection will be done at runtime, |
|
|
130 | and EV will safely fall back to using select when epoll isn't available. |
|
|
131 | If unsure, accept the default. |
92 | |
132 | |
93 | EOF |
133 | EOF |
94 | |
134 | |
95 | if (prompt ("Enable epoll backend (y/n)?", (-e "/usr/include/sys/epoll.h") ? "y" : "n") =~ /[yY]/) { |
135 | if (prompt ("Enable epoll backend (y/n)?", (-e "/usr/include/sys/epoll.h") ? "y" : "n") =~ /[yY]/) { |
96 | $DEFINE .= " -DEV_USE_EPOLL"; |
136 | $DEFINE .= " -DEV_USE_EPOLL"; |
… | |
… | |
99 | print <<EOF; |
139 | print <<EOF; |
100 | |
140 | |
101 | |
141 | |
102 | *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** |
142 | *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** |
103 | |
143 | |
|
|
144 | Similarly to the epoll backend above, EV can take advantage of kqueue |
|
|
145 | on many BSD systems (it seems to be broken on Mac OS X though, but what |
|
|
146 | isn't broken on that shoddy platform... ah yes, the cash gushing by apple, |
|
|
147 | selling defective software works perfectly there). Support for kqueue will |
|
|
148 | be detected at runtime, with a safe fallback to other methods when it |
|
|
149 | cannot be used. |
|
|
150 | |
104 | EOF |
151 | EOF |
|
|
152 | |
|
|
153 | if (prompt ("Enable kqueue backend (y/n)?", (-e "/usr/include/sys/event.h") ? "y" : "n") =~ /[yY]/) { |
|
|
154 | $DEFINE .= " -DEV_USE_KQUEUE"; |
|
|
155 | } |
|
|
156 | |
|
|
157 | print <<EOF; |
|
|
158 | |
|
|
159 | |
|
|
160 | *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** |
|
|
161 | |
|
|
162 | EV needs the functions pthread_atfork and clock_gettime. On most systems |
|
|
163 | you need some special libraries for this (such as -lrt and -lpthread). You |
|
|
164 | can specify additional libraries to provide these calls now, or accept the |
|
|
165 | default. |
|
|
166 | |
|
|
167 | EOF |
|
|
168 | |
|
|
169 | $LIBS = prompt "Extra libraries for pthread_atfork and clock_gettime?", "-lpthread -lrt"; |
|
|
170 | |
|
|
171 | |
|
|
172 | print <<EOF; |
|
|
173 | |
|
|
174 | |
|
|
175 | *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** |
|
|
176 | |
|
|
177 | EOF |
|
|
178 | |
|
|
179 | my @anyevent = eval { require AnyEvent; $AnyEvent::VERSION < 2.6 } ? (AnyEvent => 2.6) : (); |
105 | |
180 | |
106 | WriteMakefile( |
181 | WriteMakefile( |
107 | dist => { |
182 | dist => { |
108 | PREOP => 'pod2text EV.pm | tee README >$(DISTVNAME)/README; chmod -R u=rwX,go=rX . ;', |
183 | PREOP => 'pod2text EV.pm | tee README >$(DISTVNAME)/README; chmod -R u=rwX,go=rX . ;', |
109 | COMPRESS => 'gzip -9v', |
184 | COMPRESS => 'gzip -9v', |
110 | SUFFIX => '.gz', |
185 | SUFFIX => '.gz', |
111 | }, |
186 | }, |
112 | depend => { |
187 | depend => { |
113 | "EV.c" => "EV/EVAPI.h " |
188 | "EV.c" => "EV/EVAPI.h " |
114 | . "libev/ev.c libev/ev.h libev/ev_epoll.c libev/ev_select.c " |
189 | . "libev/ev.c libev/ev.h libev/ev_epoll.c libev/ev_select.c libev/ev_kqueue.c libev/ev_poll.c " |
115 | . "libev/event.h libev/event.c libev/evdns.h libev/evdns.c", |
190 | . "libev/event.h libev/event.c evdns.h evdns.c libev/ev_vars.h libev/ev_wrap.h", |
116 | }, |
191 | }, |
117 | INC => "-Ilibev", |
192 | INC => "-Ilibev", |
118 | DEFINE => "$DEFINE", |
193 | DEFINE => "$DEFINE", |
119 | NAME => "EV", |
194 | NAME => "EV", |
120 | LIBS => [$LIBS], |
195 | LIBS => [$LIBS], |
|
|
196 | PREREQ_PM => { |
|
|
197 | @anyevent, |
|
|
198 | }, |
121 | VERSION_FROM => "EV.pm", |
199 | VERSION_FROM => "EV.pm", |
122 | PM => { |
200 | PM => { |
123 | 'EV.pm' => '$(INST_LIBDIR)/EV.pm', |
201 | 'EV.pm' => '$(INST_LIBDIR)/EV.pm', |
124 | 'EV/AnyEvent.pm' => '$(INST_LIBDIR)/EV/AnyEvent.pm', |
|
|
125 | 'EV/DNS.pm' => '$(INST_LIBDIR)/EV/DNS.pm', |
202 | 'EV/DNS.pm' => '$(INST_LIBDIR)/EV/DNS.pm', |
126 | 'EV/EVAPI.h' => '$(INST_LIBDIR)/EV/EVAPI.h', |
203 | 'EV/EVAPI.h' => '$(INST_LIBDIR)/EV/EVAPI.h', |
127 | 'EV/MakeMaker.pm' => '$(INST_LIBDIR)/EV/MakeMaker.pm', |
204 | 'EV/MakeMaker.pm' => '$(INST_LIBDIR)/EV/MakeMaker.pm', |
128 | 'libev/ev.h' => '$(INST_LIBDIR)/EV/ev.h', |
205 | 'libev/ev.h' => '$(INST_LIBDIR)/EV/ev.h', |
129 | }, |
206 | }, |