diff options
Diffstat (limited to 'make')
-rwxr-xr-x | make/calcdep.pl | 6 | ||||
-rw-r--r-- | make/configure.pm | 437 | ||||
-rw-r--r-- | make/gnutlscert.pm | 147 | ||||
-rw-r--r-- | make/opensslcert.pm | 61 | ||||
-rw-r--r-- | make/template/inspircd | 4 | ||||
-rw-r--r-- | make/template/main.mk | 67 | ||||
-rw-r--r-- | make/test/clock_gettime.cpp | 25 | ||||
-rw-r--r-- | make/test/eventfd.cpp (renamed from make/check_eventfd.cpp) | 0 | ||||
-rw-r--r-- | make/test/kqueue.cpp (renamed from make/check_epoll.cpp) | 5 | ||||
-rwxr-xr-x | make/unit-cc.pl | 10 | ||||
-rw-r--r-- | make/utilities.pm | 83 |
11 files changed, 313 insertions, 532 deletions
diff --git a/make/calcdep.pl b/make/calcdep.pl index 4a759a24a..26be367f5 100755 --- a/make/calcdep.pl +++ b/make/calcdep.pl @@ -78,7 +78,7 @@ END for my $file (<*.cpp>, <modes/*.cpp>, <socketengines/*.cpp>, "threadengines/threadengine_pthread.cpp") { my $out = find_output $file; dep_cpp $file, $out, 'gen-o'; - next if $file =~ m#^socketengines/# && $file ne "socketengines/$ENV{SOCKETENGINE}.cpp"; + next if $file =~ m#^socketengines/# && $file ne "socketengines/socketengine_$ENV{SOCKETENGINE}.cpp"; push @core_deps, $out; } @@ -148,7 +148,7 @@ END mkdir "$ENV{BUILDPATH}/obj/$1"; } dep_cpp $file, $out, 'gen-o'; - next if $file =~ m#^socketengines/# && $file ne "socketengines/$ENV{SOCKETENGINE}.cpp"; + next if $file =~ m#^socketengines/# && $file ne "socketengines/socketengine_$ENV{SOCKETENGINE}.cpp"; push @deps, $out; push @srcs, $file; } @@ -199,7 +199,7 @@ sub gendep($) { while (<$in>) { if (/^\s*#\s*include\s*"([^"]+)"/) { my $inc = $1; - next if $inc eq 'inspircd_version.h' && $f eq '../include/inspircd.h'; + next if $inc eq 'config.h' && $f eq '../include/inspircd.h'; my $found = 0; for my $loc ("$basedir/$inc", "../include/$inc") { next unless -e $loc; diff --git a/make/configure.pm b/make/configure.pm index 606483e98..286424080 100644 --- a/make/configure.pm +++ b/make/configure.pm @@ -21,291 +21,246 @@ # -package make::configure; +BEGIN { + require 5.8.0; +} -require 5.8.0; +package make::configure; use strict; use warnings FATAL => qw(all); +use Cwd; 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); - -my $no_git = 0; - -sub yesno { - my ($flag,$prompt) = @_; - print "$prompt [\e[1;32m$main::config{$flag}\e[0m] -> "; - chomp(my $tmp = <STDIN>); - if ($tmp eq "") { $tmp = $main::config{$flag} } - if (($tmp eq "") || ($tmp =~ /^y/i)) - { - $main::config{$flag} = "y"; - } - else - { - $main::config{$flag} = "n"; + +our @EXPORT = qw(cmd_clean cmd_help cmd_update + read_configure_cache write_configure_cache + get_compiler_info find_compiler + run_test test_file test_header + get_property get_revision + dump_hash); + +my $revision; + +sub __get_socketengines() { + my @socketengines; + foreach (<src/socketengines/socketengine_*.cpp>) { + s/src\/socketengines\/socketengine_(\w+)\.cpp/$1/; + push @socketengines, $1; } - return; + return @socketengines; } -sub resolve_directory -{ - my $ret = $_[0]; - eval - { - use File::Spec; - $ret = File::Spec->rel2abs($_[0]); - }; - return $ret; +sub cmd_clean { + unlink '.config.cache'; } -sub getrevision { - if ($no_git) - { - return "0"; - } - my $data = `git describe --tags 2>/dev/null`; - if ($data eq "") - { - $no_git = 1; - return '0'; +sub cmd_help { + my $PWD = getcwd(); + my $SELIST = join ', ', __get_socketengines(); + print <<EOH; +Usage: $0 [options] + +When no options are specified, configure runs in interactive mode and you must +specify any required values manually. If one or more options are specified, +non-interactive configuration is started and any omitted values are defaulted. + +PATH OPTIONS + + --system Automatically set up the installation paths + for system-wide installation. + --prefix=[dir] The root install directory. If this is set then + all subdirectories will be adjusted accordingly. + [$PWD/run] + --binary-dir=[dir] The location where the main server binary is + stored. + [$PWD/run/bin] + --config-dir=[dir] The location where the configuration files and + SSL certificates are stored. + [$PWD/run/conf] + --data-dir=[dir] The location where the data files, such as the + pid file, are stored. + [$PWD/run/data] + --log-dir=[dir] The location where the log files are stored. + [$PWD/run/logs] + --module-dir=[dir] The location where the loadable modules are + stored. + [$PWD/run/modules] + --build-dir=[dir] The location to store files in while building. + + +EXTRA MODULE OPTIONS + + --enable-extras=[extras] Enables a comma separated list of extra modules. + --disable-extras=[extras] Disables a comma separated list of extra modules. + --list-extras Shows the availability status of all extra + modules. + +MISC OPTIONS + + --clean Remove the configuration cache file and start + the interactive configuration wizard. + --disable-interactive Disables the interactive configuration wizard. + --help Show this message and exit. + --uid=[name] Sets the user to run InspIRCd as. + --socketengine=[name] Sets the socket engine to be used. Possible + values are $SELIST. + --update Updates the build environment. + + +FLAGS + + CXX=[name] Sets the C++ compiler to use when building the + server. If not specified then the build system + will search for c++, g++, clang++ or icpc. + +If you have any problems with configuring InspIRCd then visit our IRC channel +at irc.ChatSpike.net #InspIRCd. + +EOH + exit 0; +} + +sub cmd_update { + unless (-f '.config.cache') { + print "You have not run $0 before. Please do this before trying to update the build files.\n"; + exit 1; } - chomp $data; # remove \n - return $data; + print "Updating...\n"; + %main::config = read_configure_cache(); + %main::cxx = get_compiler_info($main::config{CXX}); + $main::topdir = getcwd(); + main::writefiles(); + print "Update complete!\n"; + exit 0; } -sub getcompilerflags { - my ($file) = @_; - open(FLAGS, $file) or return ""; - while (<FLAGS>) { - if ($_ =~ /^\/\* \$CompileFlags: (.+) \*\/$/) { - my $x = translate_functions($1, $file); - next if ($x eq ""); - close(FLAGS); - return $x; - } +sub read_configure_cache { + my %cfg = (); + open(CACHE, '.config.cache') or return %cfg; + while (my $line = <CACHE>) { + next if $line =~ /^\s*($|\#)/; + my ($key, $value) = ($line =~ /^(\S+)="(.*)"$/); + $cfg{$key} = $value; } - close(FLAGS); - return ""; + close(CACHE); + return %cfg; } -sub getlinkerflags { - my ($file) = @_; - open(FLAGS, $file) or return ""; - while (<FLAGS>) { - if ($_ =~ /^\/\* \$LinkerFlags: (.+) \*\/$/) { - my $x = translate_functions($1, $file); - next if ($x eq ""); - close(FLAGS); - return $x; - } +sub write_configure_cache(%) { + my %cfg = @_; + open(CACHE, ">.config.cache") or return 0; + while (my ($key, $value) = each %cfg) { + $value = "" unless defined $value; + print CACHE "$key=\"$value\"\n"; } - close(FLAGS); - return ""; + close(CACHE); + return 1; } -sub getdependencies { - my ($file) = @_; - open(FLAGS, $file) or return ""; - while (<FLAGS>) { - if ($_ =~ /^\/\* \$ModDep: (.+) \*\/$/) { - my $x = translate_functions($1, $file); - next if ($x eq ""); - close(FLAGS); - return $x; - } +sub get_compiler_info($) { + my $binary = shift; + my $version = `$binary -v 2>&1`; + if ($version =~ /(?:clang|llvm)\sversion\s(\d+\.\d+)/i) { + return ( + NAME => 'Clang', + VERSION => $1, + UNSUPPORTED => $1 lt '3.0', + REASON => 'Clang 2.9 and older do not have adequate C++ support.' + ); + } elsif ($version =~ /gcc\sversion\s(\d+\.\d+)/i) { + return ( + NAME => 'GCC', + VERSION => $1, + UNSUPPORTED => $1 lt '4.1', + 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) { + return ( + NAME => 'ICC', + VERSION => $1, + UNSUPPORTED => $2 lt '4.1', + REASON => "ICC $1 (GCC $2 compatibility mode) does not have adequate C++ support." + ); } - close(FLAGS); - return ""; + return ( + NAME => $binary, + VERSION => '0.0' + ); } -sub nopedantic { - my ($file) = @_; - open(FLAGS, $file) or return ""; - while (<FLAGS>) { - if ($_ =~ /^\/\* \$NoPedantic \*\/$/) { - my $x = translate_functions($_, $file); - next if ($x eq ""); - close(FLAGS); - return 1; +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"; } } - close(FLAGS); - return 0; + return ""; } -sub getmodules -{ - my ($silent) = @_; - - my $i = 0; - - if (!$silent) - { - print "Detecting modules "; - } +sub run_test($$) { + my ($what, $result) = @_; + print "Checking whether $what is available... "; + print $result ? "yes\n" : "no\n"; + return $result; +} - opendir(DIRHANDLE, "src/modules") or die("WTF, missing src/modules!"); - foreach my $name (sort readdir(DIRHANDLE)) - { - if ($name =~ /^m_(.+)\.cpp$/) - { - my $mod = $1; - $main::modlist[$i++] = $mod; - if (!$silent) - { - print "."; - } - } - } - closedir(DIRHANDLE); +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; +} - if (!$silent) - { - print "\nOk, $i modules.\n"; - } +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 promptnumeric($$) +sub get_property($$;$) { - my $continue = 0; - my ($prompt, $configitem) = @_; - while (!$continue) - { - print "Please enter the maximum $prompt?\n"; - print "[\e[1;32m$main::config{$configitem}\e[0m] -> "; - chomp(my $var = <STDIN>); - if ($var eq "") - { - $var = $main::config{$configitem}; - } - if ($var =~ /^\d+$/) { - # We don't care what the number is, set it and be on our way. - $main::config{$configitem} = $var; - $continue = 1; - print "\n"; - } else { - print "You must enter a number in this field. Please try again.\n\n"; + my ($file, $property, $default) = @_; + open(MODULE, $file) or return $default; + while (<MODULE>) { + if ($_ =~ /^\/\* \$(\S+): (.+) \*\/$/) { + next unless $1 eq $property; + close(MODULE); + return translate_functions($2, $file); } } + close(MODULE); + return defined $default ? $default : ''; } -sub module_installed($) -{ - my $module = shift; - eval("use $module;"); - return !$@; -} - -sub promptstring_s($$) -{ - my ($prompt,$default) = @_; - my $var; - print "$prompt\n"; - print "[\e[1;32m$default\e[0m] -> "; - chomp($var = <STDIN>); - $var = $default if $var eq ""; - print "\n"; - return $var; +sub get_revision { + return $revision if defined $revision; + chomp(my $tags = `git describe --tags 2>/dev/null`); + $revision = $tags || 'release'; + return $revision; } -sub dumphash() +sub dump_hash() { print "\n\e[1;32mPre-build configuration is complete!\e[0m\n\n"; 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[0mData path:\e[1;32m\t\t\t$main::config{DATA_DIR}\e[0m\n"; + print "\e[0mLog path:\e[1;32m\t\t\t$main::config{LOG_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[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"; - print "\e[1;32m configuration file, not in ./configure! See the <limits>\e[0m\n"; - print "\e[1;32m tag in the configuration file for more information.\e[0m\n\n"; -} - -sub is_dir -{ - my ($path) = @_; - if (chdir($path)) - { - chdir($main::this); - return 1; - } - else - { - # Just in case.. - chdir($main::this); - return 0; - } -} - -sub showhelp -{ - chomp(my $PWD = `pwd`); - print <<EOH; -Usage: configure [options] - -*** NOTE: NON-INTERACTIVE CONFIGURE IS *NOT* SUPPORTED BY THE *** -*** INSPIRCD DEVELOPMENT TEAM. DO NOT ASK FOR HELP REGARDING *** -*** NON-INTERACTIVE CONFIGURE ON THE FORUMS OR ON IRC! *** - -Options: [defaults in brackets after descriptions] - -When no options are specified, interactive -configuration is started and you must specify -any required values manually. If one or more -options are specified, non-interactive configuration -is started, and any omitted values are defaulted. - -Arguments with a single \"-\" symbol, as in -InspIRCd 1.0.x, are also allowed. - - --disable-interactive Sets no options itself, but - will disable any interactive prompting. - --update Update makefiles and dependencies - --clean Remove .config.cache file and go interactive - --enable-gnutls Enable GnuTLS module [no] - --enable-openssl Enable OpenSSL module [no] - --enable-epoll Enable epoll() where supported [set] - --enable-kqueue Enable kqueue() where supported [set] - --disable-epoll Do not enable epoll(), fall back - to select() [not set] - --disable-kqueue Do not enable kqueue(), fall back - to select() [not set] - --disable-ipv6 Do not build IPv6 native InspIRCd [not set] - --with-cc=[filename] Use an alternative compiler to - build InspIRCd [g++] - --with-maxbuf=[n] Change the per message buffer size [512] - DO NOT ALTER THIS OPTION WITHOUT GOOD REASON - AS IT *WILL* BREAK CLIENTS!!! - --prefix=[directory] Base directory to install into (if defined, - can automatically define config, module, bin - and library dirs as subdirectories of prefix) - [$PWD] - --config-dir=[directory] Config file directory for config and SSL certs - [$PWD/conf] - --log-dir=[directory] Log file directory for logs - [$PWD/logs] - --data-dir=[directory] Data directory for variable data, such as the permchannel configuration and the XLine database - [$PWD/data] - --module-dir=[directory] Modules directory for loadable modules - [$PWD/modules] - --binary-dir=[directory] Binaries directory for core binary - [$PWD/bin] - --library-dir=[directory] Library directory for core libraries - [$PWD/lib] - --list-extras Show current status of extra modules - --enable-extras=[extras] Enable the specified list of extras - --disable-extras=[extras] Disable the specified list of extras - --help Show this help text and exit - -EOH - exit(0); + print "\e[0mCompiler:\e[1;32m\t\t\t$main::cxx{NAME} $main::cxx{VERSION}\e[0m\n"; + print "\e[0mSocket engine:\e[1;32m\t\t\t$main::config{SOCKETENGINE}\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"; } 1; - diff --git a/make/gnutlscert.pm b/make/gnutlscert.pm deleted file mode 100644 index a67be0cfd..000000000 --- a/make/gnutlscert.pm +++ /dev/null @@ -1,147 +0,0 @@ -# -# InspIRCd -- Internet Relay Chat Daemon -# -# Copyright (C) 2007 Dennis Friis <peavey@inspircd.org> -# Copyright (C) 2007 Craig Edwards <craigedwards@brainbox.cc> -# -# 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 <http://www.gnu.org/licenses/>. -# - - -package make::gnutlscert; - -require 5.8.0; - -use strict; -use warnings FATAL => qw(all); - -use Exporter 'import'; -use make::configure; -our @EXPORT = qw(make_gnutls_cert); - - -sub make_gnutls_cert() -{ - open (FH, ">certtool.template"); - my $timestr = time(); - my $org = promptstring_s("Please enter the organization name", "My IRC Network"); - my $unit = promptstring_s("Please enter the unit Name", "Server Admins"); - my $state = promptstring_s("Please enter your state (two letter code)", "CA"); - my $country = promptstring_s("Please enter your country", "Oompa Loompa Land"); - my $commonname = promptstring_s("Please enter the certificate common name (hostname)", "irc.mynetwork.com"); - my $email = promptstring_s("Please enter a contact email address", "oompa\@loompa.com"); - print FH <<__END__; -# X.509 Certificate options -# -# DN options - -# The organization of the subject. -organization = "$org" - -# The organizational unit of the subject. -unit = "$unit" - -# The locality of the subject. -# locality = - -# The state of the certificate owner. -state = "$state" - -# The country of the subject. Two letter code. -country = $country - -# The common name of the certificate owner. -cn = "$commonname" - -# A user id of the certificate owner. -#uid = "clauper" - -# If the supported DN OIDs are not adequate you can set -# any OID here. -# For example set the X.520 Title and the X.520 Pseudonym -# by using OID and string pairs. -#dn_oid = "2.5.4.12" "Dr." "2.5.4.65" "jackal" - -# This is deprecated and should not be used in new -# certificates. -# pkcs9_email = "none\@none.org" - -# The serial number of the certificate -serial = $timestr - -# In how many days, counting from today, this certificate will expire. -expiration_days = 700 - -# X.509 v3 extensions - -# A dnsname in case of a WWW server. -#dns_name = "www.none.org" - -# An IP address in case of a server. -#ip_address = "192.168.1.1" - -# An email in case of a person -email = "$email" - -# An URL that has CRLs (certificate revocation lists) -# available. Needed in CA certificates. -#crl_dist_points = "http://www.getcrl.crl/getcrl/" - -# Whether this is a CA certificate or not -#ca - -# Whether this certificate will be used for a TLS client -tls_www_client - -# Whether this certificate will be used for a TLS server -tls_www_server - -# Whether this certificate will be used to sign data (needed -# in TLS DHE ciphersuites). -signing_key - -# Whether this certificate will be used to encrypt data (needed -# in TLS RSA ciphersuites). Note that it is prefered to use different -# keys for encryption and signing. -encryption_key - -# Whether this key will be used to sign other certificates. -cert_signing_key - -# Whether this key will be used to sign CRLs. -crl_signing_key - -# Whether this key will be used to sign code. -code_signing_key - -# Whether this key will be used to sign OCSP data. -ocsp_signing_key - -# Whether this key will be used for time stamping. -time_stamping_key -__END__ -close(FH); -my $certtool = "certtool"; -if (`uname -s` eq "Darwin\n") { - # On OS X the certtool binary name is different to prevent - # collisions with the system certtool from NSS. - $certtool = "gnutls-certtool"; -} -if ( (my $status = system("$certtool --generate-privkey --outfile key.pem")) ne 0) { return 1; } -if ( (my $status = system("$certtool --generate-self-signed --load-privkey key.pem --outfile cert.pem --template certtool.template")) ne 0) { return 1; } -unlink("certtool.template"); -return 0; -} - -1; - diff --git a/make/opensslcert.pm b/make/opensslcert.pm deleted file mode 100644 index fd7bd6998..000000000 --- a/make/opensslcert.pm +++ /dev/null @@ -1,61 +0,0 @@ -# -# InspIRCd -- Internet Relay Chat Daemon -# -# Copyright (C) 2007 Dennis Friis <peavey@inspircd.org> -# Copyright (C) 2007 Craig Edwards <craigedwards@brainbox.cc> -# -# 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 <http://www.gnu.org/licenses/>. -# - - -package make::opensslcert; - -require 5.8.0; - -use strict; -use warnings FATAL => qw(all); - -use Exporter 'import'; -use make::configure; -our @EXPORT = qw(make_openssl_cert); - - -sub make_openssl_cert() -{ - open (FH, ">openssl.template"); - my $org = promptstring_s("Please enter the organization name", "My IRC Network"); - my $unit = promptstring_s("Please enter the unit Name", "Server Admins"); - my $country = promptstring_s("Please enter your country (two letter code)", "US"); - my $state = promptstring_s("Please enter your state or locality name", "Alaska"); - my $city = promptstring_s("Please enter your city", "Factory Town"); - my $email = promptstring_s("Please enter a contact email address", "oompa\@loompa.com"); - my $commonname = promptstring_s("Please enter the common name (domain name) of the irc server", "example.inspircd.org"); - print FH <<__END__; -$country -$state -$city -$org -$unit -$commonname -$email -__END__ -close(FH); - -my $time = promptstring_s("Please enter the number of days that this certificate is valid for","365"); - -system("cat openssl.template | openssl req -x509 -nodes -newkey rsa:1024 -keyout key.pem -out cert.pem -days $time 2>/dev/null"); -system("openssl dhparam -out dhparams.pem 1024"); -unlink("openssl.template"); -} - -1; diff --git a/make/template/inspircd b/make/template/inspircd index 322ee2cd6..c14099323 100644 --- a/make/template/inspircd +++ b/make/template/inspircd @@ -29,11 +29,11 @@ my $binpath = "@BINARY_DIR@"; my $runpath = "@BASE_DIR@"; my $datadir = "@DATA_DIR@"; my $valgrindlogpath = "$basepath/valgrindlogs"; -my $executable = "@EXECUTABLE@"; +my $executable = "inspircd"; my $version = "@VERSION@"; my $uid = "@UID@"; -if ($< == 0 || $> == 0) { +if (!("--runasroot" ~~ @ARGV) && ($< == 0 || $> == 0)) { if ($uid !~ /^\d+$/) { # Named UID, look it up $uid = getpwnam $uid; diff --git a/make/template/main.mk b/make/template/main.mk index e55e36c0a..bdb4d9762 100644 --- a/make/template/main.mk +++ b/make/template/main.mk @@ -30,13 +30,13 @@ # -CC = @CC@ +CXX = @CXX@ +COMPILER = @COMPILER@ SYSTEM = @SYSTEM@ BUILDPATH = @BUILD_DIR@ SOCKETENGINE = @SOCKETENGINE@ -CXXFLAGS = -pipe -fPIC -DPIC -LDLIBS = -pthread -lstdc++ -LDFLAGS = +CORECXXFLAGS = -fPIC -pipe -Iinclude -Wall -Wextra -Wfatal-errors -Wno-unused-parameter -Wshadow +LDLIBS = -lstdc++ CORELDFLAGS = -rdynamic -L. $(LDFLAGS) PICLDFLAGS = -fPIC -shared -rdynamic $(LDFLAGS) BASE = "$(DESTDIR)@BASE_DIR@" @@ -46,16 +46,17 @@ DATPATH = "$(DESTDIR)@DATA_DIR@" BINPATH = "$(DESTDIR)@BINARY_DIR@" INSTALL = install INSTUID = @UID@ -INSTMODE_DIR = 0755 -INSTMODE_BIN = 0755 -INSTMODE_LIB = 0644 +INSTMODE_DIR = 0750 +INSTMODE_BIN = 0750 +INSTMODE_LIB = 0640 -@IFEQ $(CC) icc - CXXFLAGS += -Wshadow -@ELSE - CXXFLAGS += -pedantic -Woverloaded-virtual -Wshadow -Wformat=2 -Wmissing-format-attribute -Wall +@IFNEQ $(COMPILER) icc + CORECXXFLAGS += -pedantic -Woverloaded-virtual -Wshadow -Wformat=2 -Wmissing-format-attribute @ENDIF +@IFNEQ $(SYSTEM) darwin + LDLIBS += -pthread +@ENDIF @IFEQ $(SYSTEM) linux LDLIBS += -ldl -lrt @@ -70,19 +71,11 @@ INSTMODE_LIB = 0644 LDLIBS += -lsocket -lnsl -lrt -lresolv INSTALL = ginstall @ENDIF -@IFEQ $(SYSTEM) sunos - LDLIBS += -lsocket -lnsl -lrt -lresolv - INSTALL = ginstall -@ENDIF @IFEQ $(SYSTEM) darwin - CXXFLAGS += -DDARWIN -frtti LDLIBS += -ldl CORELDFLAGS = -dynamic -bind_at_load -L. $(LDFLAGS) PICLDFLAGS = -fPIC -shared -twolevel_namespace -undefined dynamic_lookup $(LDFLAGS) @ENDIF -@IFEQ $(SYSTEM) interix - CXXFLAGS += -D_ALL_SOURCE -I/usr/local/include -@ENDIF @IFNDEF D D=0 @@ -90,48 +83,50 @@ INSTMODE_LIB = 0644 DBGOK=0 @IFEQ $(D) 0 - CXXFLAGS += -O2 -@IFEQ $(CC) gcc - CXXFLAGS += -g1 + CORECXXFLAGS += -O2 +@IFEQ $(CXX) g++ + CORECXXFLAGS += -g1 @ENDIF HEADER = std-header DBGOK=1 @ENDIF @IFEQ $(D) 1 - CXXFLAGS += -O0 -g3 -Werror + CORECXXFLAGS += -O0 -g3 -Werror HEADER = debug-header DBGOK=1 @ENDIF @IFEQ $(D) 2 - CXXFLAGS += -O2 -g3 + CORECXXFLAGS += -O2 -g3 HEADER = debug-header DBGOK=1 @ENDIF FOOTER = finishmessage -CXXFLAGS += -Iinclude - @GNU_ONLY MAKEFLAGS += --no-print-directory @GNU_ONLY SOURCEPATH = $(shell /bin/pwd) @BSD_ONLY SOURCEPATH != /bin/pwd @IFDEF V - RUNCC = $(CC) - RUNLD = $(CC) + RUNCC = $(CXX) + RUNLD = $(CXX) VERBOSE = -v @ELSE @GNU_ONLY MAKEFLAGS += --silent @BSD_ONLY MAKE += -s - RUNCC = perl $(SOURCEPATH)/make/run-cc.pl $(CC) - RUNLD = perl $(SOURCEPATH)/make/run-cc.pl $(CC) + RUNCC = perl $(SOURCEPATH)/make/run-cc.pl $(CXX) + RUNLD = perl $(SOURCEPATH)/make/run-cc.pl $(CXX) @ENDIF @IFDEF PURE_STATIC - CXXFLAGS += -DPURE_STATIC + CORECXXFLAGS += -DPURE_STATIC @ENDIF -@DO_EXPORT RUNCC RUNLD CXXFLAGS LDLIBS PICLDFLAGS VERBOSE SOCKETENGINE CORELDFLAGS +# Add the users CXXFLAGS to the base ones to allow them to override +# things like -Wfatal-errors if they wish to. +CORECXXFLAGS += $(CXXFLAGS) + +@DO_EXPORT RUNCC RUNLD CORECXXFLAGS LDLIBS PICLDFLAGS VERBOSE SOCKETENGINE CORELDFLAGS @DO_EXPORT SOURCEPATH BUILDPATH PURE_STATIC SPLIT_CC # Default target @@ -230,6 +225,7 @@ install: target [ $(BUILDPATH)/modules/ -ef $(MODPATH) ] || $(INSTALL) -m $(INSTMODE_LIB) $(BUILDPATH)/modules/*.so $(MODPATH) @ENDIF -$(INSTALL) -m $(INSTMODE_BIN) @STARTSCRIPT@ $(BASE) 2>/dev/null + -$(INSTALL) -m $(INSTMODE_BIN) tools/genssl $(BINPATH)/inspircd-genssl 2>/dev/null -$(INSTALL) -m $(INSTMODE_LIB) tools/gdbargs $(BASE)/.gdbargs 2>/dev/null -$(INSTALL) -m $(INSTMODE_LIB) docs/conf/*.example $(CONPATH)/examples -$(INSTALL) -m $(INSTMODE_LIB) docs/conf/aliases/*.example $(CONPATH)/examples/aliases @@ -269,14 +265,11 @@ deinstall: -rm -f $(BASE)/.gdbargs -rm -f $(BASE)/org.inspircd.plist -squeakyclean: distclean - configureclean: rm -f .config.cache rm -f BSDmakefile rm -f GNUmakefile - rm -f include/inspircd_config.h - rm -f include/inspircd_version.h + rm -f include/config.h rm -f inspircd -rm -f org.inspircd.plist @@ -312,4 +305,4 @@ help: @echo ' deinstall Removes the files created by "make install"' @echo -.PHONY: all target debug debug-header mod-header mod-footer std-header finishmessage install clean deinstall squeakyclean configureclean help +.PHONY: all target debug debug-header mod-header mod-footer std-header finishmessage install clean deinstall configureclean help 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 <http://www.gnu.org/licenses/>. + */ + + +#include <time.h> + +int main() { + timespec time_spec; + clock_gettime(CLOCK_REALTIME, &time_spec); + return 0; +} diff --git a/make/check_eventfd.cpp b/make/test/eventfd.cpp index 980d04485..980d04485 100644 --- a/make/check_eventfd.cpp +++ b/make/test/eventfd.cpp diff --git a/make/check_epoll.cpp b/make/test/kqueue.cpp index 918d3907e..a8b9882cf 100644 --- a/make/check_epoll.cpp +++ b/make/test/kqueue.cpp @@ -16,9 +16,10 @@ */ -#include <sys/epoll.h> +#include <sys/types.h> +#include <sys/event.h> int main() { - int fd = epoll_create(1); + int fd = kqueue(); return (fd < 0); } diff --git a/make/unit-cc.pl b/make/unit-cc.pl index 7474365aa..5b0c50021 100755 --- a/make/unit-cc.pl +++ b/make/unit-cc.pl @@ -52,7 +52,7 @@ exit 1; sub do_static_find { my @flags; for my $file (@ARGV) { - push @flags, getlinkerflags($file); + push @flags, get_property($file, 'LinkerFlags'); } open F, '>', $out; print F join ' ', @flags; @@ -97,12 +97,10 @@ sub do_compile { my $libs = ''; my $binary = $ENV{RUNCC}; if ($do_compile) { - $flags = $ENV{CXXFLAGS}; - $flags =~ s/ -pedantic// if nopedantic($file); - $flags .= ' ' . getcompilerflags($file); + $flags = $ENV{CORECXXFLAGS} . ' ' . get_property($file, 'CompileFlags'); if ($file =~ m#(?:^|/)((?:m|cmd)_[^/. ]+)(?:\.cpp|/.*\.cpp)$#) { - $flags .= ' -DMODNAME='.$1.'.so'; + $flags .= ' -DMODNAME=\\"'.$1.'\\"'; } } else { $binary = $ENV{RUNLD}; @@ -110,7 +108,7 @@ sub do_compile { if ($do_link) { $flags = join ' ', $flags, $ENV{PICLDFLAGS}; - $libs = join ' ', getlinkerflags($file); + $libs = get_property($file, 'LinkerFlags'); } else { $flags .= ' -c'; } diff --git a/make/utilities.pm b/make/utilities.pm index 9281246fb..87aa46d6e 100644 --- a/make/utilities.pm +++ b/make/utilities.pm @@ -20,18 +20,22 @@ # -package make::utilities; +BEGIN { + require 5.8.0; +} -require 5.8.0; +package make::utilities; use strict; use warnings FATAL => qw(all); use Exporter 'import'; -use POSIX; -use Getopt::Long; use Fcntl; -our @EXPORT = qw(make_rpath pkgconfig_get_include_dirs pkgconfig_get_lib_dirs pkgconfig_check_version translate_functions promptstring); +use File::Path; +use File::Spec::Functions qw(rel2abs); +use Getopt::Long; + +our @EXPORT = qw(module_installed prompt_bool prompt_dir prompt_string make_rpath pkgconfig_get_include_dirs pkgconfig_get_lib_dirs pkgconfig_check_version translate_functions promptstring); # Parse the output of a *_config program, # such as pcre_config, take out the -L @@ -42,6 +46,47 @@ our @EXPORT = qw(make_rpath pkgconfig_get_include_dirs pkgconfig_get_lib_dirs pk my %already_added = (); my $if_skip_lines = 0; +sub module_installed($) +{ + my $module = shift; + eval("use $module;"); + return !$@; +} + +sub prompt_bool($$$) { + my ($interactive, $question, $default) = @_; + my $answer = prompt_string($interactive, $question, $default ? 'y' : 'n'); + return $answer =~ /y/i; +} + +sub prompt_dir($$$) { + my ($interactive, $question, $default) = @_; + my ($answer, $create) = (undef, 'y'); + do { + $answer = rel2abs(prompt_string($interactive, $question, $default)); + $create = prompt_bool($interactive && !-d $answer, "$answer does not exist. Create it?", 'y'); + my $mkpath = eval { + mkpath($answer, 0, 0750); + return 1; + }; + unless (defined $mkpath) { + print "Error: unable to create $answer!\n\n"; + $create = 0; + } + } while (!$create); + return $answer; +} + +sub prompt_string($$$) { + my ($interactive, $question, $default) = @_; + return $default unless $interactive; + print $question, "\n"; + print "[\e[1;32m$default\e[0m] => "; + chomp(my $answer = <STDIN>); + print "\n"; + return $answer ? $answer : $default; +} + sub promptstring($$$$$) { my ($prompt, $configitem, $default, $package, $commandlineswitch) = @_; @@ -108,15 +153,6 @@ sub pkgconfig_get_include_dirs($$$;$) { my ($packagename, $headername, $defaults, $module) = @_; - my $key = "default_includedir_$packagename"; - if (exists $main::config{$key}) - { - print "Locating include directory for package \e[1;32m$packagename\e[0m for module \e[1;32m$module\e[0m... "; - my $ret = $main::config{$key}; - print "\e[1;32m$ret\e[0m (cached)\n"; - return $ret; - } - extend_pkg_path(); print "Locating include directory for package \e[1;32m$packagename\e[0m for module \e[1;32m$module\e[0m... "; @@ -223,15 +259,6 @@ sub pkgconfig_get_lib_dirs($$$;$) { my ($packagename, $libname, $defaults, $module) = @_; - my $key = "default_libdir_$packagename"; - if (exists $main::config{$key}) - { - print "Locating library directory for package \e[1;32m$packagename\e[0m for module \e[1;32m$module\e[0m... "; - my $ret = $main::config{$key}; - print "\e[1;32m$ret\e[0m (cached)\n"; - return $ret; - } - extend_pkg_path(); print "Locating library directory for package \e[1;32m$packagename\e[0m for module \e[1;32m$module\e[0m... "; @@ -305,16 +332,6 @@ sub translate_functions($$) $module =~ /modules*\/(.+?)$/; $module = $1; - # This is only a cursory check, just designed to catch casual accidental use of backticks. - # There are pleanty of ways around it, but its not supposed to be for security, just checking - # that people are using the new configuration api as theyre supposed to and not just using - # backticks instead of eval(), being as eval has accountability. People wanting to get around - # the accountability will do so anyway. - if (($line =~ /`/) && ($line !~ /eval\(.+?`.+?\)/)) - { - die "Developers should no longer use backticks in configuration macros. Please use exec() and eval() macros instead. Offending line: $line (In module: $module)"; - } - if ($line =~ /ifuname\(\!"(\w+)"\)/) { my $uname = $1; |