From f52123b1ed0b1bd96db2282f04f0e5852a50d782 Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Thu, 4 Jul 2013 08:28:26 +0100 Subject: Purge --with-cc in favour of the CXX environment variable. --- configure | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'configure') diff --git a/configure b/configure index c3d8c4110..0b3f293c0 100755 --- a/configure +++ b/configure @@ -56,7 +56,7 @@ use make::configure; our ($opt_use_gnutls, $opt_use_openssl, $opt_nointeractive, $opt_ports, $opt_epoll, $opt_kqueue, $opt_noports, $opt_noepoll, $opt_nokqueue, $opt_freebsd_port, $opt_system, $opt_uid); -our ($opt_cc, $opt_base_dir, $opt_config_dir, $opt_module_dir, $opt_binary_dir, $opt_data_dir, $opt_log_dir); +our ($opt_base_dir, $opt_config_dir, $opt_module_dir, $opt_binary_dir, $opt_data_dir, $opt_log_dir); sub list_extras (); @@ -79,7 +79,6 @@ GetOptions ( 'disable-ports' => \$opt_noports, 'disable-epoll' => \$opt_noepoll, 'disable-kqueue' => \$opt_nokqueue, - 'with-cc=s' => \$opt_cc, 'enable-freebsd-ports-openssl' => \$opt_freebsd_port, 'prefix=s' => \$opt_base_dir, 'config-dir=s' => \$opt_config_dir, @@ -114,7 +113,6 @@ our $interactive = !( (defined $opt_data_dir) || (defined $opt_log_dir) || (defined $opt_nointeractive) || - (defined $opt_cc) || (defined $opt_kqueue) || (defined $opt_epoll) || (defined $opt_ports) || @@ -240,9 +238,9 @@ else { $config{CC} = "g++"; # C++ compiler } -if (defined $opt_cc) +if (defined $ENV{CXX}) { - $config{CC} = $opt_cc; + $config{CC} = $ENV{CXX}; } our $exec = $config{CC} . " -dumpversion | cut -c 1"; chomp($config{GCCVER} = `$exec`); # Major GCC Version -- cgit v1.2.3 From 2677d12f20f2921b9724dc198f5e232fa9217d6a Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Thu, 4 Jul 2013 08:41:33 +0100 Subject: Automatically detect the compiler which the user has installed. --- configure | 24 +++++++----------------- make/configure.pm | 12 +++++++++++- 2 files changed, 18 insertions(+), 18 deletions(-) (limited to 'configure') diff --git a/configure b/configure index 0b3f293c0..777c6c323 100755 --- a/configure +++ b/configure @@ -232,16 +232,15 @@ $config{DESTINATION} = "BASE"; # Is target path. if ($config{OSNAME} =~ /darwin/i) { $config{STARTSCRIPT} = "org.inspircd.plist"; # start script for OSX. - $config{CC} = "xcrun clang++"; # C++ compiler for OSX. } -else -{ - $config{CC} = "g++"; # C++ compiler -} -if (defined $ENV{CXX}) -{ - $config{CC} = $ENV{CXX}; + +$config{CC} = defined $ENV{CXX} && !system("$ENV{CXX} -v > /dev/null 2>&1") ? $ENV{CXX} : find_compiler(); +if ($config{CC} eq "") { + print "A C++ compiler could not be detected on your system!\n"; + print "Set the CXX environment variable to the full path if this is incorrect.\n"; + exit 1; } + our $exec = $config{CC} . " -dumpversion | cut -c 1"; chomp($config{GCCVER} = `$exec`); # Major GCC Version $exec = $config{CC} . " -dumpversion | cut -c 3"; @@ -253,15 +252,6 @@ if ($config{HAS_OPENSSL} =~ /^([-[:digit:].]+)(?:[a-z])?(?:\-[a-z][0-9])?/) { $config{HAS_OPENSSL} = ""; } -if (($config{GCCVER} eq "") || ($config{GCCMINOR} eq "")) { - if ($config{OSNAME} eq 'darwin') { - print $config{CC} . " was not found! You require clang++ (the LLVM C++ compiler, part of the OSX developer tools) to build InspIRCd!\n"; - } else { - print $config{CC} . " was not found! You require g++ (the GNU C++ compiler, part of GCC) to build InspIRCd!\n"; - } - exit; -} - # Get and Set some important vars.. getmodules(); diff --git a/make/configure.pm b/make/configure.pm index 194d439e3..c022a7493 100644 --- a/make/configure.pm +++ b/make/configure.pm @@ -31,10 +31,20 @@ use warnings FATAL => qw(all); use Exporter 'import'; use POSIX; use make::utilities; -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); +our @EXPORT = qw(find_compiler 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 find_compiler { + foreach my $compiler ('c++', 'g++', 'clang++', 'icpc') { + return $compiler unless system "$compiler -v > /dev/null 2>&1"; + if ($^O eq 'Darwin') { + return $compiler unless system "xcrun $compiler -v > /dev/null 2>&1"; + } + } + return ""; +} + sub test_file($$;$) { my ($cc, $file, $args) = @_; my $status = 0; -- cgit v1.2.3 From 77a08e490c340ffeca089fb15043490f1ce4b7de Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Thu, 4 Jul 2013 09:27:12 +0100 Subject: Correctly detect the compiler version and whether it is acceptable. --- configure | 63 +++++++------------------------------------------------ make/configure.pm | 28 ++++++++++++++++++++++--- 2 files changed, 32 insertions(+), 59 deletions(-) (limited to 'configure') diff --git a/configure b/configure index 777c6c323..c8fbdce09 100755 --- a/configure +++ b/configure @@ -241,10 +241,12 @@ if ($config{CC} eq "") { exit 1; } -our $exec = $config{CC} . " -dumpversion | cut -c 1"; -chomp($config{GCCVER} = `$exec`); # Major GCC Version -$exec = $config{CC} . " -dumpversion | cut -c 3"; -chomp($config{GCCMINOR} = `$exec`); +our %cxx = get_compiler_info($config{CC}); +if ($cxx{UNSUPPORTED}) { + print "Your C++ compiler is too old to build InspIRCd!\n"; + print "Reason: $cxx{REASON}\n"; + exit 1; +} if ($config{HAS_OPENSSL} =~ /^([-[:digit:].]+)(?:[a-z])?(?:\-[a-z][0-9])?/) { $config{HAS_OPENSSL} = $1; @@ -298,12 +300,6 @@ print ($cache_loaded ? "found\n" : "not found\n"); $config{SYSTEM} = lc $^O; print "Checking operating system version... $config{SYSTEM}\n"; -$exec = $config{CC} . " -dumpversion | cut -c 1"; -chomp($config{GCCVER} = `$exec`); # Major GCC Version -$exec = $config{CC} . " -dumpversion | cut -c 3"; -chomp($config{GCCMINOR} = `$exec`); - - print "Checking whether exists... "; if (test_header($config{CC}, "stdint.h")) { $config{HAS_STDINT} = "true"; @@ -439,36 +435,7 @@ STOP } print ".\n\n"; - $config{CHANGE_COMPILER} = "n"; - print "I have detected the following compiler: \e[1;32m$config{CC}\e[0m (version \e[1;32m$config{GCCVER}.$config{GCCMINOR}\e[0m)\n"; - - while (($config{GCCVER} < 3) || ($config{GCCVER} eq "")) { - print "\e[1;32mIMPORTANT!\e[0m A GCC 2.x compiler has been detected, and -should NOT be used. You should probably specify a newer compiler.\n\n"; - yesno('CHANGE_COMPILER',"Do you want to change the compiler?"); - if ($config{CHANGE_COMPILER} =~ /y/i) { - print "What command do you want to use to invoke your compiler?\n"; - print "[\e[1;32m$config{CC}\e[0m] -> "; - chomp($config{CC} = ); - if ($config{CC} eq "") { - $config{CC} = "g++"; - } - chomp(my $foo = `$config{CC} -dumpversion | cut -c 1`); - if ($foo ne "") { - chomp($config{GCCVER} = `$config{CC} -dumpversion | cut -c 1`); # we must redo these if we change compilers - chomp($config{GCCMINOR} = `$config{CC} -dumpversion | cut -c 3`); - print "Queried compiler: \e[1;32m$config{CC}\e[0m (version \e[1;32m$config{GCCVER}.$config{GCCMINOR}\e[0m)\n"; - if ($config{GCCVER} < 4 || $config{GCCVER} == 4 && $config{GCCMINOR} < 1) { - print "\e[1;32mGCC 4.1 and earlier WILL NOT WORK!\e[0m. Let's try that again, shall we?\n"; - } - } - else { - print "\e[1;32mWARNING!\e[0m Could not execute the compiler you specified. You may want to try again.\n"; - } - } - } - - print "\n"; + print "I have detected the following compiler: \e[1;32m$cxx{NAME}\e[0m (version \e[1;32m$cxx{VERSION}\e[0m)\n\n"; # Directory Settings.. my $tmpbase = $config{BASE_DIR}; @@ -688,19 +655,6 @@ if (($config{USE_GNUTLS} eq "y") || ($config{USE_OPENSSL} eq "y")) { print "\e[1;32mhttp://wiki.inspircd.org/Installation_From_Tarball\e[0m\n"; } print "*** \e[1;32mRemember to edit your configuration files!!!\e[0m ***\n\n\n"; -if (($config{OSNAME} eq "OpenBSD") && ($config{CC} ne "eg++")) { - print "\e[1;32mWARNING!\e[0m You are running OpenBSD but you are using the base gcc package\nrather than eg++. This compile will most likely fail, but i'm letting you\ngo ahead with it anyway, just in case i'm wrong :-)\n"; -} - -if ($config{GCCVER} < "3") { - print <= 3) { - print FILEHANDLE "#define GCC3\n"; - } if ($config{HAS_STDINT} eq "true") { print FILEHANDLE "#define HAS_STDINT\n"; } diff --git a/make/configure.pm b/make/configure.pm index c022a7493..95499720f 100644 --- a/make/configure.pm +++ b/make/configure.pm @@ -31,10 +31,33 @@ use warnings FATAL => qw(all); use Exporter 'import'; use POSIX; use make::utilities; -our @EXPORT = qw(find_compiler test_file test_header promptnumeric dumphash is_dir getmodules getrevision getcompilerflags getlinkerflags getdependencies nopedantic resolve_directory yesno showhelp promptstring_s module_installed); +our @EXPORT = qw(get_compiler_info find_compiler 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 get_compiler_info($) { + my %info = (NAME => shift, VERSION => '0.0'); + my $version = `$info{NAME} -v 2>&1`; + return (ERROR => 1) if $?; + if ($version =~ /(?:clang|llvm)\sversion\s(\d+\.\d+)/i) { + $info{NAME} = 'Clang'; + $info{VERSION} = $1; + $info{UNSUPPORTED} = $1 lt '3.0'; + $info{REASON} = 'Clang 2.9 and older do not have adequate C++ support.'; + } elsif ($version =~ /gcc\sversion\s(\d+\.\d+)/i) { + $info{NAME} = 'GCC'; + $info{VERSION} = $1; + $info{UNSUPPORTED} = $1 lt '4.1'; + $info{REASON} = 'GCC 4.0 and older do not have adequate C++ support.'; + } elsif ($version =~ /(?:icc|icpc)\sversion\s(\d+\.\d+).\d+\s\(gcc\sversion\s(\d+\.\d+).\d+/i) { + $info{NAME} = 'ICC'; + $info{VERSION} = $1; + $info{UNSUPPORTED} = $2 lt '4.1'; + $info{REASON} = "ICC $1 (GCC $2 compatibility mode) does not have adequate C++ support." + } + return %info; +} + sub find_compiler { foreach my $compiler ('c++', 'g++', 'clang++', 'icpc') { return $compiler unless system "$compiler -v > /dev/null 2>&1"; @@ -247,8 +270,7 @@ sub dumphash() print "\e[0mBase install path:\e[1;32m\t\t$main::config{BASE_DIR}\e[0m\n"; print "\e[0mConfig path:\e[1;32m\t\t\t$main::config{CONFIG_DIR}\e[0m\n"; print "\e[0mModule path:\e[1;32m\t\t\t$main::config{MODULE_DIR}\e[0m\n"; - print "\e[0mGCC Version Found:\e[1;32m\t\t$main::config{GCCVER}.$main::config{GCCMINOR}\e[0m\n"; - print "\e[0mCompiler program:\e[1;32m\t\t$main::config{CC}\e[0m\n"; + print "\e[0mCompiler:\e[1;32m\t\t\t$main::cxx{NAME} $main::cxx{VERSION}\e[0m\n"; print "\e[0mGnuTLS Support:\e[1;32m\t\t\t$main::config{USE_GNUTLS}\e[0m\n"; print "\e[0mOpenSSL Support:\e[1;32m\t\t$main::config{USE_OPENSSL}\e[0m\n\n"; print "\e[1;32mImportant note: The maximum length values are now configured in the\e[0m\n"; -- cgit v1.2.3 From 90a068af714dac058fba97e1b413dc8c0dbd5bcf Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Thu, 4 Jul 2013 18:46:46 +0100 Subject: Rename configuration variable to CXX to match everything else. --- configure | 24 ++++++++++++------------ make/template/main.mk | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) (limited to 'configure') diff --git a/configure b/configure index c8fbdce09..d8d356bfb 100755 --- a/configure +++ b/configure @@ -234,14 +234,14 @@ if ($config{OSNAME} =~ /darwin/i) $config{STARTSCRIPT} = "org.inspircd.plist"; # start script for OSX. } -$config{CC} = defined $ENV{CXX} && !system("$ENV{CXX} -v > /dev/null 2>&1") ? $ENV{CXX} : find_compiler(); -if ($config{CC} eq "") { +$config{CXX} = defined $ENV{CXX} && !system("$ENV{CXX} -v > /dev/null 2>&1") ? $ENV{CXX} : find_compiler(); +if ($config{CXX} eq "") { print "A C++ compiler could not be detected on your system!\n"; print "Set the CXX environment variable to the full path if this is incorrect.\n"; exit 1; } -our %cxx = get_compiler_info($config{CC}); +our %cxx = get_compiler_info($config{CXX}); if ($cxx{UNSUPPORTED}) { print "Your C++ compiler is too old to build InspIRCd!\n"; print "Reason: $cxx{REASON}\n"; @@ -301,7 +301,7 @@ $config{SYSTEM} = lc $^O; print "Checking operating system version... $config{SYSTEM}\n"; print "Checking whether exists... "; -if (test_header($config{CC}, "stdint.h")) { +if (test_header($config{CXX}, "stdint.h")) { $config{HAS_STDINT} = "true"; print "yes\n"; } else { @@ -310,7 +310,7 @@ if (test_header($config{CC}, "stdint.h")) { } printf "Checking whether clock_gettime() exists... "; -if (test_file($config{CC}, "clock_gettime.cpp", "-lrt")) { +if (test_file($config{CXX}, "clock_gettime.cpp", "-lrt")) { $config{HAS_CLOCK_GETTIME} = "true"; print "yes\n"; } else { @@ -319,7 +319,7 @@ if (test_file($config{CC}, "clock_gettime.cpp", "-lrt")) { } printf "Checking whether eventfd() exists... "; -if (test_file($config{CC}, "eventfd.cpp")) { +if (test_file($config{CXX}, "eventfd.cpp")) { $config{HAS_EVENTFD} = "true"; print "yes\n"; } else { @@ -328,10 +328,10 @@ if (test_file($config{CC}, "eventfd.cpp")) { } printf "Checking if a TCP deferring mechanism is available... "; -if (test_file($config{CC}, "tcp_defer_accept.cpp")) { +if (test_file($config{CXX}, "tcp_defer_accept.cpp")) { $config{HAS_DEFER} = "TCP_DEFER_ACCEPT"; print "yes (TCP_DEFER_ACCEPT)\n"; -} elsif (test_file($config{CC}, "so_acceptfilter.cpp")) { +} elsif (test_file($config{CXX}, "so_acceptfilter.cpp")) { $config{HAS_DEFER} = "SO_ACCEPTFILTER"; print "yes (SO_ACCEPTFILTER)\n"; } else { @@ -340,15 +340,15 @@ if (test_file($config{CC}, "tcp_defer_accept.cpp")) { } print "Checking whether epoll is available... "; -$has_epoll = test_header($config{CC}, "sys/epoll.h"); +$has_epoll = test_header($config{CXX}, "sys/epoll.h"); print $has_epoll ? "yes\n" : "no\n"; print "Checking whether Kqueue is available... "; -$has_kqueue = test_file($config{CC}, "kqueue.cpp"); +$has_kqueue = test_file($config{CXX}, "kqueue.cpp"); print $has_kqueue ? "yes\n" : "no\n"; print 'Checking whether Solaris IOCP is available... '; -$has_ports = test_header($config{CC}, 'port.h'); +$has_ports = test_header($config{CXX}, 'port.h'); print $has_ports ? "yes\n" : "no\n"; $config{HAS_EPOLL} = $has_epoll; @@ -884,7 +884,7 @@ EOF $config{BUILD_DIR} ||= resolve_directory($config{ME}."/build"); for my $var (qw( - CC SYSTEM BASE_DIR CONFIG_DIR MODULE_DIR BINARY_DIR BUILD_DIR DATA_DIR UID + CXX SYSTEM BASE_DIR CONFIG_DIR MODULE_DIR BINARY_DIR BUILD_DIR DATA_DIR UID STARTSCRIPT DESTINATION SOCKETENGINE )) { s/\@$var\@/$config{$var}/g; diff --git a/make/template/main.mk b/make/template/main.mk index fd094b578..5350e113e 100644 --- a/make/template/main.mk +++ b/make/template/main.mk @@ -30,7 +30,7 @@ # -CXX = @CC@ +CXX = @CXX@ SYSTEM = @SYSTEM@ BUILDPATH = @BUILD_DIR@ SOCKETENGINE = @SOCKETENGINE@ -- cgit v1.2.3 From 1b475afbe5e033a55795271cdf98108dac3e97a7 Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Thu, 4 Jul 2013 19:42:15 +0100 Subject: Expose compiler name to make. - Convert ICC detection to use new variable. --- configure | 3 ++- make/template/main.mk | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'configure') diff --git a/configure b/configure index d8d356bfb..32e8fc12d 100755 --- a/configure +++ b/configure @@ -882,9 +882,10 @@ EOF close(FILEHANDLE); $config{BUILD_DIR} ||= resolve_directory($config{ME}."/build"); + $config{COMPILER} = lc $cxx{NAME}; for my $var (qw( - CXX SYSTEM BASE_DIR CONFIG_DIR MODULE_DIR BINARY_DIR BUILD_DIR DATA_DIR UID + CXX COMPILER SYSTEM BASE_DIR CONFIG_DIR MODULE_DIR BINARY_DIR BUILD_DIR DATA_DIR UID STARTSCRIPT DESTINATION SOCKETENGINE )) { s/\@$var\@/$config{$var}/g; diff --git a/make/template/main.mk b/make/template/main.mk index 5350e113e..b93c15094 100644 --- a/make/template/main.mk +++ b/make/template/main.mk @@ -31,11 +31,12 @@ CXX = @CXX@ +COMPILER = @COMPILER@ SYSTEM = @SYSTEM@ BUILDPATH = @BUILD_DIR@ SOCKETENGINE = @SOCKETENGINE@ CORECXXFLAGS = -fPIC -pipe -Iinclude -Wall -Wextra -Wfatal-errors -Wno-unused-parameter -Wshadow -LDLIBS = -pthread -lstdc++ +LDLIBS = -lstdc++ CORELDFLAGS = -rdynamic -L. $(LDFLAGS) PICLDFLAGS = -fPIC -shared -rdynamic $(LDFLAGS) BASE = "$(DESTDIR)@BASE_DIR@" @@ -49,7 +50,7 @@ INSTMODE_DIR = 0755 INSTMODE_BIN = 0755 INSTMODE_LIB = 0644 -@IFNEQ $(CXX) icc +@IFNEQ $(COMPILER) icc CORECXXFLAGS += -pedantic -Woverloaded-virtual -Wshadow -Wformat=2 -Wmissing-format-attribute @ENDIF -- cgit v1.2.3