1// $Id$
2// vim:ft=javascript noet ts=4 sts=4 sw=4
3
4ARG_WITH('ev', 'for ev support', 'no');
5ARG_ENABLE('ev_debug', 'for ev debug support', 'no');
6
7if (PHP_EV != 'no') {
8	if (CHECK_HEADER_ADD_INCLUDE('ev.h', 'CFLAGS_EV', configure_module_dirname + '\\libev;' + PHP_EV)) {
9		var dll = get_define('PHPDLL');
10		var php_ev_sources = 'ev.c util.c watcher.c fe.c pe.c evwrap.c';
11
12		/* XXX override configure_module_dirname, define the basic extension, then set it back*/
13		var old_conf_dir = configure_module_dirname;
14		if (null != dll.match(/^php5/)) {
15			configure_module_dirname = configure_module_dirname + "\\php5";
16		} else if (null != dll.match(/^php7/)) {
17			configure_module_dirname = configure_module_dirname + "\\php7";
18		} else if (null != dll.match(/^php8/)) {
19			configure_module_dirname = configure_module_dirname + "\\php8";
20			php_ev_sources='evwrap.c util.c ev.c watcher.c pe.c';
21		} else {
22			ERROR("Cannot match any known PHP version with '" + dll + "'");
23		}
24		AC_DEFINE('HAVE_EV', 1);
25		ADD_FLAG('CFLAGS_EV', '/D _WIN32');
26
27		ADD_EXTENSION_DEP('ev', 'sockets', true);
28
29		if (PHP_EV_DEBUG != 'no') {
30			ADD_FLAG('CFLAGS_EV', '/D PHP_EV_DEBUG=1');
31		} else {
32			ADD_FLAG('CFLAGS_EV', '/D NDEBUG');
33		}
34
35		EXTENSION('ev', php_ev_sources, true, ' /DZEND_ENABLE_STATIC_TSRMLS_CACHE=1');
36		CHECK_HEADER_ADD_INCLUDE('embed.h', 'CFLAGS_EV', configure_module_dirname);
37		configure_module_dirname = old_conf_dir;
38		//ADD_SOURCES(configure_module_dirname, 'evwrap.c', 'ev');
39	} else {
40		WARNING('ev not enabled; libraries and headers not found');
41	}
42}
43