X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=configure;h=d86229afbb7752ba20d1ccac81da2c7c9b0ccb15;hb=f2dcf19923c4b60b268899c93b8deb3e6f30c6fe;hp=2db2b98d0da730fe7ede17aabfb1e9794c6adfe1;hpb=73977e660f8bcb53c3f7363835d94d3bb7ad021a;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/configure b/configure index 2db2b98d0..d86229afb 100755 --- a/configure +++ b/configure @@ -47,8 +47,6 @@ use Getopt::Long; # Utility functions for our buildsystem use make::utilities; use make::configure; -use make::gnutlscert; -use make::opensslcert; ############################################################################################### # @@ -102,8 +100,8 @@ GetOptions ( 'list-extras' => sub { list_extras; exit 0; }, # This, --enable-extras, and --disable-extras are for non-interactive managing. 'enable-extras=s@' => \@opt_enableextras, # ^ 'disable-extras=s@' => \@opt_disableextras, # ^ - 'generate-openssl-cert' => sub { make_openssl_cert(); exit(0); }, - 'generate-gnutls-cert' => sub { make_gnutls_cert(); exit(0); } + 'generate-openssl-cert' => sub { exec './tools/genssl openssl'; }, + 'generate-gnutls-cert' => sub { exec './tools/genssl gnutls'; } ); if (scalar(@opt_enableextras) + scalar(@opt_disableextras) > 0) { @@ -145,17 +143,18 @@ chomp(our $topdir = getcwd()); our $this = resolve_directory($topdir); # PWD, Regardless. our @modlist = (); # Declare for Module List.. our %config = (); # Initiate Configuration Hash.. +our $cache_loaded = getcache(); $config{ME} = resolve_directory($topdir); # Present Working Directory $config{BASE_DIR} = $config{ME}."/run"; if (defined $opt_base_dir) { $config{BASE_DIR} = $opt_base_dir; -} elsif (defined $opt_system || defined $opt_uid) { +} elsif (defined $opt_system) { $config{BASE_DIR} = '/var/lib/inspircd'; } -if (defined $opt_system || defined $opt_uid) { +if (defined $opt_system) { $config{UID} = $opt_uid || 'ircd'; $config{CONFIG_DIR} = '/etc/inspircd'; $config{MODULE_DIR} = '/usr/lib/inspircd'; @@ -164,7 +163,7 @@ if (defined $opt_system || defined $opt_uid) { $config{DATA_DIR} = '/var/inspircd'; $config{LOG_DIR} = '/var/log/inspircd'; } else { - $config{UID} = $<; + $config{UID} = $opt_uid || $<; $config{CONFIG_DIR} = resolve_directory($config{BASE_DIR}."/conf"); # Configuration Directory $config{MODULE_DIR} = resolve_directory($config{BASE_DIR}."/modules"); # Modules Directory $config{BINARY_DIR} = resolve_directory($config{BASE_DIR}."/bin"); # Binary Directory @@ -230,7 +229,6 @@ if (!defined $opt_disable_debug) { $config{OPTIMISATI} = "-O2"; } -$config{HAS_STRLCPY} = "false"; # strlcpy Check. $config{HAS_STDINT} = "false"; # stdint.h check $config{USE_KQUEUE} = "y"; # kqueue enabled if (defined $opt_nokqueue) { @@ -272,7 +270,7 @@ $exec = $config{CC} . " -dumpversion | cut -c 3"; chomp($config{GCCMINOR} = `$exec`); $config{MAXBUF} = "512"; # Max buffer size -if ($config{HAS_OPENSSL} =~ /^([-[:digit:].]+)([a-z])?(\-[a-z][0-9])?$/) { +if ($config{HAS_OPENSSL} =~ /^([-[:digit:].]+)(?:[a-z])?(?:\-[a-z][0-9])?/) { $config{HAS_OPENSSL} = $1; } else { $config{HAS_OPENSSL} = ""; @@ -332,19 +330,9 @@ sub update exit; } - -sub test_compile { - my $feature = shift; - my $fail = 0; - $fail ||= system "$config{CC} -o test_$feature make/check_$feature.cpp >/dev/null 2>&1"; - $fail ||= system "./test_$feature"; - unlink "test_$feature"; - return !$fail; -} - print "Running non-interactive configure...\n" unless $interactive; print "Checking for cache from previous configure... "; -print ((!getcache()) ? "not found\n" : "found\n"); +print ($cache_loaded ? "found\n" : "not found\n"); $config{SYSTEM} = lc $^O; print "Checking operating system version... $config{SYSTEM}\n"; @@ -353,76 +341,45 @@ chomp($config{GCCVER} = `$exec`); # Major GCC Version $exec = $config{CC} . " -dumpversion | cut -c 3"; chomp($config{GCCMINOR} = `$exec`); -printf "Checking if stdint.h exists... "; -$config{HAS_STDINT} = "true"; -our $fail = 0; -open(STDINT, " exists... "; +if (test_header($config{CC}, "stdint.h")) { + $config{HAS_STDINT} = "true"; + print "yes\n"; +} else { + $config{HAS_STDINT} = "false"; + print "no\n"; } -print "yes\n" if $config{HAS_STDINT} eq "true"; -print "no\n" if $config{HAS_STDINT} eq "false"; - -printf "Checking if strlcpy exists... "; -# Perform the strlcpy() test.. -$config{HAS_STRLCPY} = "false"; -$fail = 0; -open(STRLCPY, ")) { - chomp($line); - # try and find the delcaration of: - # size_t strlcpy(...) - if ($line =~ /size_t(\0x9|\s)+strlcpy/) { - $config{HAS_STRLCPY} = "true"; - } - } - close(STRLCPY); + +printf "Checking whether clock_gettime() exists... "; +if (test_file($config{CC}, "clock_gettime.cpp", "-lrt")) { + $config{HAS_CLOCK_GETTIME} = "true"; + print "yes\n"; +} else { + $config{HAS_CLOCK_GETTIME} = "false"; + print "no\n"; } -print "yes\n" if $config{HAS_STRLCPY} eq "true"; -print "no\n" if $config{HAS_STRLCPY} eq "false"; - -printf "Checking if kqueue exists... "; -$has_kqueue = 0; -$fail = 0; -open(KQUEUE, ")) { - chomp($line); - # try and find the delcaration of: - # int kqueue(void); - if ($line =~ /int(\0x9|\s)+kqueue/) { - $has_kqueue = 1; - } - } - close(KQUEUE); + +printf "Checking whether eventfd() exists... "; +if (test_file($config{CC}, "eventfd.cpp")) { + $config{HAS_EVENTFD} = "true"; + print "yes\n"; +} else { + $config{HAS_EVENTFD} = "false"; + print "no\n"; } -print "yes\n" if $has_kqueue == 1; -print "no\n" if $has_kqueue == 0; -printf "Checking for epoll support... "; -$has_epoll = test_compile('epoll'); +print "Checking whether epoll is available... "; +$has_epoll = test_header($config{CC}, "sys/epoll.h"); print $has_epoll ? "yes\n" : "no\n"; -printf "Checking for eventfd support... "; -$config{HAS_EVENTFD} = test_compile('eventfd') ? 'true' : 'false'; -print $config{HAS_EVENTFD} eq 'true' ? "yes\n" : "no\n"; - -printf "Checking if Solaris I/O completion ports are available... "; -$has_ports = 0; -our $system = `uname -s`; -chomp ($system); -$has_ports = 1 if ($system eq "SunOS"); - -if ($has_ports) { - my $kernel = `uname -r`; - chomp($kernel); - if (($kernel !~ /^5\.1./)) { - $has_ports = 0; - } -} -print "yes\n" if $has_ports == 1; -print "no\n" if $has_ports == 0; +print "Checking whether Kqueue is available... "; +$has_kqueue = test_file($config{CC}, "kqueue.cpp"); +print $has_kqueue ? "yes\n" : "no\n"; + +print 'Checking whether Solaris IOCP is available... '; +$has_ports = test_header($config{CC}, 'port.h'); +print $has_ports ? "yes\n" : "no\n"; $config{HAS_EPOLL} = $has_epoll; $config{HAS_KQUEUE} = $has_kqueue; @@ -691,7 +648,7 @@ if ($config{USE_GNUTLS} eq "y") { * few times and get that HD going :) Then answer the * * Questions which follow. If you are unsure, just hit enter * *************************************************************\n\n"; - $failed = make_gnutls_cert(); + $failed = system "./tools/genssl gnutls"; if ($failed) { print "\n\e[1;32mCertificate generation failed!\e[0m\n\n"; } else { @@ -725,7 +682,7 @@ if ($config{USE_OPENSSL} eq "y") { * Generating the certificates may take some time, go grab a * * coffee, or something. * *************************************************************\n\n"; - make_openssl_cert(); + system "./tools/genssl openssl"; print "\nCertificate generation complete, copying to config directory... "; File::Copy::move("key.pem", "$config{CONFIG_DIR}/key.pem") or print STDERR "Could not copy key.pem!\n"; File::Copy::move("cert.pem", "$config{CONFIG_DIR}/cert.pem") or print STDERR "Could not copy cert.pem!\n"; @@ -862,7 +819,7 @@ my ($mliflags, $mfrules, $mobjs, $mfcount) = ("", "", "", 0); sub writefiles { my($writeheader) = @_; - # First File.. inspircd_config.h + # First File.. config.h chomp(my $incos = `uname -n -s -r`); chomp(my $version = `sh src/version.sh`); chomp(my $revision2 = getrevision()); @@ -873,16 +830,16 @@ sub writefiles { } if ($writeheader == 1) { - print "Writing \e[1;32minspircd_config.h\e[0m\n"; - open(FILEHANDLE, ">include/inspircd_config.h.tmp"); + print "Writing \e[1;32mconfig.h\e[0m\n"; + open(FILEHANDLE, ">include/config.h.tmp"); print FILEHANDLE <= 3) { print FILEHANDLE "#define GCC3\n"; } - if ( - (($config{GCCVER} == 4) && ($config{GCCMINOR} >= 3)) - || - ($config{GCCVER} > 4) - ) { - print FILEHANDLE "#define HASHMAP_DEPRECATED\n"; - } - if ($config{HAS_STRLCPY} eq "true") { - print FILEHANDLE "#define HAS_STRLCPY\n"; - } if ($config{HAS_STDINT} eq "true") { print FILEHANDLE "#define HAS_STDINT\n"; } if ($config{HAS_EVENTFD} eq 'true') { print FILEHANDLE "#define HAS_EVENTFD\n"; } - if ($config{OSNAME} !~ /DARWIN/i) { + if ($config{HAS_CLOCK_GETTIME} eq 'true') { print FILEHANDLE "#define HAS_CLOCK_GETTIME\n"; } my $use_hiperf = 0; @@ -953,40 +900,30 @@ print FILEHANDLE "#define MAXBUF " . ($config{MAXBUF}+2) . "\n"; $config{SOCKETENGINE} = "socketengine_select"; } } - print FILEHANDLE "\n#include \"threadengines/threadengine_pthread.h\"\n\n#endif\n"; + print FILEHANDLE "\n#include \"threadengines/threadengine_pthread.h\"\n"; close(FILEHANDLE); - - open(FILEHANDLE, ">include/inspircd_version.h.tmp"); - print FILEHANDLE <; - my $line2 = <$fh2>; - if (defined($line1) != defined($line2)) { - $diff = 1; - } elsif (!defined $line1) { - last; - } else { - $diff = ($line1 ne $line2); - } - } - if ($diff) { - unlink $file; - rename "$file.tmp", $file; + + my $file = 'include/config.h'; + my $diff = 0; + open my $fh1, $file or $diff = 1; + open my $fh2, $file.'.tmp' or die "Can't read $file.tmp that we just wrote: $!"; + while (!$diff) { + my $line1 = <$fh1>; + my $line2 = <$fh2>; + if (defined($line1) != defined($line2)) { + $diff = 1; + } elsif (!defined $line1) { + last; } else { - unlink "$file.tmp"; + $diff = ($line1 ne $line2); } } + if ($diff) { + unlink $file; + rename "$file.tmp", $file; + } else { + unlink "$file.tmp"; + } } # Write all .in files.