]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - tools/test-build
Merge pull request #677 from Robby-/master-dnsblzline
[user/henk/code/inspircd.git] / tools / test-build
1 #!/usr/bin/env perl
2 #
3 # InspIRCd -- Internet Relay Chat Daemon
4 #
5 #   Copyright (C) 2013-2014 Peter Powell <petpow@saberuk.com>
6 #
7 # This file is part of InspIRCd.  InspIRCd is free software: you can
8 # redistribute it and/or modify it under the terms of the GNU General Public
9 # License as published by the Free Software Foundation, version 2.
10 #
11 # This program is distributed in the hope that it will be useful, but WITHOUT
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 # FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
14 # details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 #
19
20
21 BEGIN {
22         require 5.10.0;
23         unless (-f 'configure') {
24                 print "Error: $0 must be run from the main source directory!\n";
25                 exit 1;
26         }
27 }
28
29 use feature ':5.10';
30 use strict;
31 use warnings FATAL => qw(all);
32
33 use FindBin qw($RealDir);
34
35 use lib $RealDir;
36 use make::common;
37 use make::configure;
38
39 $ENV{INSPIRCD_DEBUG} = $ENV{INSPIRCD_VERBOSE} = 1;
40
41 system 'git', 'clean', '-dfx';
42
43 my @compilers = $#ARGV >= 0 ? @ARGV : qw(g++ clang++ icpc);
44 foreach my $compiler (@compilers) {
45         if (system "$compiler -v > /dev/null 2>&1") {
46                 say "Skipping $compiler as it is not installed on this system!";
47                 next;
48         }
49         $ENV{CXX} = $compiler;
50         my @socketengines = qw(select);
51         push @socketengines, 'epoll' if test_header $compiler, 'sys/epoll.h';
52         push @socketengines, 'kqueue' if test_file $compiler, 'kqueue.cpp';
53         push @socketengines, 'poll' if test_header $compiler, 'poll.h';
54         push @socketengines, 'ports' if test_header $compiler, 'ports.h';
55         foreach my $socketengine (@socketengines) {
56                 say "Attempting to build using the $compiler compiler and the $socketengine socket engine...";
57                 system './configure', '--enable-extras', $ENV{TEST_BUILD_MODULES} if defined $ENV{TEST_BUILD_MODULES};
58                 if (system './configure', '--development', '--socketengine', $socketengine) {
59                         say "Failed to configure using the $compiler compiler and the $socketengine socket engine!";
60                         exit 1;
61                 }
62                 if (!defined $ENV{TEST_BUILD_DYNAMIC}) {
63                         $ENV{INSPIRCD_STATIC} = 1;
64                         if (system 'make', '-j'.get_cpu_count, 'install') {
65                                 say "Failed to compile with static modules using the $compiler compiler and the $socketengine socket engine!";
66                                 exit 1;
67                         }
68                 }
69                 if (!defined $ENV{TEST_BUILD_STATIC}) {
70                         delete $ENV{INSPIRCD_STATIC};
71                         if (system 'make', '-j'.get_cpu_count, 'install') {
72                                 say "Failed to compile with dynamic modules using the $compiler compiler and the $socketengine socket engine!";
73                                 exit 1;
74                         }
75                 }
76                 say "Building using the $compiler compiler and the $socketengine socket engine succeeded!";
77         }
78
79         system 'git', 'clean', '-dfx';
80 }