From a9ca786a6a875d38f54f50b7c23ea1ad5d247511 Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Sat, 4 May 2013 16:40:27 +0100 Subject: Improve feature detection in configure. --- make/check_epoll.cpp | 24 ------------------------ make/check_eventfd.cpp | 29 ----------------------------- make/configure.pm | 21 ++++++++++++++++++++- make/test/clock_gettime.cpp | 25 +++++++++++++++++++++++++ make/test/eventfd.cpp | 29 +++++++++++++++++++++++++++++ make/test/kqueue.cpp | 24 ++++++++++++++++++++++++ 6 files changed, 98 insertions(+), 54 deletions(-) delete mode 100644 make/check_epoll.cpp delete mode 100644 make/check_eventfd.cpp create mode 100644 make/test/clock_gettime.cpp create mode 100644 make/test/eventfd.cpp create mode 100644 make/test/kqueue.cpp (limited to 'make') diff --git a/make/check_epoll.cpp b/make/check_epoll.cpp deleted file mode 100644 index 918d3907e..000000000 --- a/make/check_epoll.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* - * InspIRCd -- Internet Relay Chat Daemon - * - * - * This file is part of InspIRCd. InspIRCd is free software: you can - * redistribute it and/or modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation, version 2. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - - -#include - -int main() { - int fd = epoll_create(1); - return (fd < 0); -} diff --git a/make/check_eventfd.cpp b/make/check_eventfd.cpp deleted file mode 100644 index 980d04485..000000000 --- a/make/check_eventfd.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* - * InspIRCd -- Internet Relay Chat Daemon - * - * - * This file is part of InspIRCd. InspIRCd is free software: you can - * redistribute it and/or modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation, version 2. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - - -#include - -int main() { - eventfd_t efd_data; - int fd; - - fd = eventfd(0, EFD_NONBLOCK); - eventfd_read(fd, &efd_data); - - return (fd < 0); -} diff --git a/make/configure.pm b/make/configure.pm index 606483e98..67e91c825 100644 --- a/make/configure.pm +++ b/make/configure.pm @@ -31,10 +31,29 @@ use warnings FATAL => qw(all); use Exporter 'import'; use POSIX; use make::utilities; -our @EXPORT = qw(promptnumeric dumphash is_dir getmodules getrevision getcompilerflags getlinkerflags getdependencies nopedantic resolve_directory yesno showhelp promptstring_s module_installed); +our @EXPORT = qw(test_file test_header promptnumeric dumphash is_dir getmodules getrevision getcompilerflags getlinkerflags getdependencies nopedantic resolve_directory yesno showhelp promptstring_s module_installed); my $no_git = 0; +sub test_file($$;$) { + my ($cc, $file, $args) = @_; + my $status = 0; + $args ||= ''; + $status ||= system "$cc -o __test_$file make/test/$file $args >/dev/null 2>&1"; + $status ||= system "./__test_$file >/dev/null 2>&1"; + unlink "./__test_$file"; + return !$status; +} + +sub test_header($$;$) { + my ($cc, $header, $args) = @_; + $args ||= ''; + open(CC, "| $cc -E - $args >/dev/null 2>&1") or return 0; + print CC "#include <$header>"; + close(CC); + return !$?; +} + sub yesno { my ($flag,$prompt) = @_; print "$prompt [\e[1;32m$main::config{$flag}\e[0m] -> "; diff --git a/make/test/clock_gettime.cpp b/make/test/clock_gettime.cpp new file mode 100644 index 000000000..91d8cd412 --- /dev/null +++ b/make/test/clock_gettime.cpp @@ -0,0 +1,25 @@ +/* + * InspIRCd -- Internet Relay Chat Daemon + * + * + * This file is part of InspIRCd. InspIRCd is free software: you can + * redistribute it and/or modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + + +#include + +int main() { + timespec time_spec; + clock_gettime(CLOCK_REALTIME, &time_spec); + return 0; +} diff --git a/make/test/eventfd.cpp b/make/test/eventfd.cpp new file mode 100644 index 000000000..980d04485 --- /dev/null +++ b/make/test/eventfd.cpp @@ -0,0 +1,29 @@ +/* + * InspIRCd -- Internet Relay Chat Daemon + * + * + * This file is part of InspIRCd. InspIRCd is free software: you can + * redistribute it and/or modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + + +#include + +int main() { + eventfd_t efd_data; + int fd; + + fd = eventfd(0, EFD_NONBLOCK); + eventfd_read(fd, &efd_data); + + return (fd < 0); +} diff --git a/make/test/kqueue.cpp b/make/test/kqueue.cpp new file mode 100644 index 000000000..a20317456 --- /dev/null +++ b/make/test/kqueue.cpp @@ -0,0 +1,24 @@ +/* + * InspIRCd -- Internet Relay Chat Daemon + * + * + * This file is part of InspIRCd. InspIRCd is free software: you can + * redistribute it and/or modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + + +#include + +int main() { + int fd = kqueue(); + return (fd < 0); +} -- cgit v1.2.3