]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Rewrite the build system directive parser.
authorPeter Powell <petpow@saberuk.com>
Sun, 11 Sep 2016 20:19:28 +0000 (21:19 +0100)
committerPeter Powell <petpow@saberuk.com>
Fri, 16 Sep 2016 03:23:56 +0000 (04:23 +0100)
18 files changed:
configure
make/configure.pm
make/directive.pm [new file with mode: 0644]
make/unit-cc.pl
make/utilities.pm [deleted file]
src/modules/extra/m_geoip.cpp
src/modules/extra/m_ldap.cpp
src/modules/extra/m_mysql.cpp
src/modules/extra/m_pgsql.cpp
src/modules/extra/m_regex_pcre.cpp
src/modules/extra/m_regex_re2.cpp
src/modules/extra/m_regex_stdlib.cpp
src/modules/extra/m_regex_tre.cpp
src/modules/extra/m_sqlite3.cpp
src/modules/extra/m_ssl_gnutls.cpp
src/modules/extra/m_ssl_mbedtls.cpp
src/modules/extra/m_ssl_openssl.cpp
tools/genssl

index 025492e01487e723b3d0b49a1d2ac4fd6046f055..a384be0813984e296abc8a07f344262d0de8e224 100755 (executable)
--- a/configure
+++ b/configure
@@ -43,6 +43,7 @@ use POSIX                 qw(getgid getuid);
 use make::common;
 use make::configure;
 use make::console;
+use make::directive;
 
 my ($opt_binary_dir,
     $opt_config_dir,
@@ -409,7 +410,7 @@ EXTRA:      for my $extra (@extras) {
        for my $extra (keys(%extras)) {
                next unless $extras{$extra} =~ m/enabled/; # only process enabled extras.
                my $abs_extra = File::Spec->catfile($abs_srcdir, "extra", $extra);
-               my @deps = split /\s+/, get_property($abs_extra, 'ModDep');
+               my @deps = split /\s+/, get_directive($abs_extra, 'ModDep', '');
                for my $dep (@deps) {
                        if (exists($extras{$dep})) {
                                my $ref = \$extras{$dep}; # Take reference.
@@ -456,7 +457,7 @@ sub enable_extras (@) {
                        next;
                }
                # Get dependencies, and add them to be processed.
-               my @deps = split /\s+/, get_property($extrapath, 'ModDep');
+               my @deps = split /\s+/, get_directive($extrapath, 'ModDep', '');
                for my $dep (@deps) {
                        next if scalar(grep { $_ eq $dep } (@extras)) > 0; # Skip if we're going to be enabling it anyway.
                        if (!-e "src/modules/$dep" && !-e "include/$dep") {
@@ -492,7 +493,7 @@ EXTRA:      for my $extra (@extras) {
                }
                # Check if anything needs this.
                for my $file (@files) {
-                       my @deps = split /\s+/, get_property("src/modules/extra/$file", 'ModDep');
+                       my @deps = split /\s+/, get_directive("src/modules/extra/$file", 'ModDep', '');
                        # File depends on this extra...
                        if (scalar(grep { $_ eq $extra } @deps) > 0) {
                                # And is both enabled and not about to be disabled.
index 8619d5be265f6b76dcade5f14afbfab7f471cc13..e88454658811c34821f9bb5511c94cde438fdd58 100644 (file)
@@ -38,7 +38,6 @@ use File::Spec::Functions qw(catfile);
 
 use make::common;
 use make::console;
-use make::utilities;
 
 use constant CONFIGURE_DIRECTORY     => '.configure';
 use constant CONFIGURE_CACHE_FILE    => catfile(CONFIGURE_DIRECTORY, 'cache.cfg');
@@ -56,7 +55,6 @@ our @EXPORT = qw(CONFIGURE_CACHE_FILE
                  write_configure_cache
                  get_compiler_info
                  find_compiler
-                 get_property
                  parse_templates);
 
 sub __get_socketengines {
@@ -268,21 +266,6 @@ sub find_compiler {
        }
 }
 
-sub get_property($$;$)
-{
-       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 $default // '';
-}
-
 sub parse_templates($$$) {
 
        # These are actually hash references
diff --git a/make/directive.pm b/make/directive.pm
new file mode 100644 (file)
index 0000000..c490135
--- /dev/null
@@ -0,0 +1,264 @@
+#
+# InspIRCd -- Internet Relay Chat Daemon
+#
+#   Copyright (C) 2016 Peter Powell <petpow@saberuk.com>
+#
+# 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::directive;
+
+BEGIN {
+       require 5.10.0;
+}
+
+use feature ':5.10';
+use strict;
+use warnings FATAL => qw(all);
+
+use File::Basename qw(basename);
+use Exporter       qw(import);
+
+use make::configure;
+use make::console;
+
+use constant DIRECTIVE_ERROR_PIPE => $ENV{INSPIRCD_VERBOSE} ? '' : '2>/dev/null';
+
+our @EXPORT = qw(get_directive
+                 execute_functions);
+
+sub get_directive($$;$)
+{
+       my ($file, $property, $default) = @_;
+       open(MODULE, $file) or return $default;
+
+       my $value = '';
+       while (<MODULE>) {
+               if ($_ =~ /^\/\* \$(\S+): (.+) \*\/$/ || $_ =~ /^\/\/\/ \$(\S+): (.+)/) {
+                       next unless $1 eq $property;
+                       $value .= ' ' . execute_functions($file, $1, $2);
+               }
+       }
+       close(MODULE);
+
+       # Strip all extraneous whitespace.
+       $value =~ s/^\s+|\s+$//g;
+       return $value || $default;
+}
+
+sub execute_functions($$$) {
+       my ($file, $name, $line) = @_;
+
+       # NOTE: we have to use 'our' instead of 'my' here because of a Perl bug.
+       for (our @parameters = (); $line =~ /([a-z_]+)\((?:\s*"([^"]*)(?{push @parameters, $2})"\s*)*\)/; undef @parameters) {
+               my $sub = make::directive->can("__function_$1");
+               print_error "unknown $name directive '$1' in $file!" unless $sub;
+
+               # Call the subroutine and replace the function.
+               my $result = $sub->($file, @parameters);
+               if (defined $result) {
+                       $line = $` . $result . $';
+                       next;
+               }
+
+               # If the subroutine returns undef then it is a sign that we should
+               # disregard the rest of the line and stop processing it.
+               $line = $`;
+       }
+
+       return $line;
+}
+
+sub __error {
+       my ($file, @message) = @_;
+       push @message, '';
+
+       # If we have package details then suggest to the user that they check
+       # that they have the packages installed.=
+       my $dependencies = get_directive($file, 'PackageInfo');
+       if (defined $dependencies) {
+               my @packages = sort grep { /^\S+$/ } split /\s/, $dependencies;
+               push @message, 'You should make sure you have the following packages installed:';
+               for (@packages) {
+                       push @message, " * $_";
+               }
+       } else {
+               push @message, 'You should make sure that you have all of the required dependencies';
+               push @message, 'for this module installed.';
+       }
+       push @message, '';
+
+       # If we have author information then tell the user to report the bug
+       # to them. Otherwise, assume it is a bundled module and tell the user
+       # to report it to the InspIRCd issue tracker.
+       my $author = get_directive($file, 'ModAuthor');
+       if (defined $author) {
+               push @message, 'If you believe this error to be a bug then you can try to contact the';
+               push @message, 'author of this module:';
+               my $author_mail = get_directive($file, 'ModAuthorMail');
+               if (defined $author_mail) {
+                       push @message, " * $author <$author_mail>";
+               } else {
+                       push @message, " * $author";
+               }
+       } else {
+               push @message, 'If you believe this error to be a bug then you can file a bug report';
+               push @message, 'at https://github.com/inspircd/inspircd/issues';
+       }
+       push @message, '';
+
+       push @message, 'If you would like help with fixing this problem then visit our IRC';
+       push @message, 'channel at irc.inspircd.org #InspIRCd for support.';
+       push @message, '';
+
+       print_error @message;
+}
+
+sub __function_error {
+       my ($file, @messages) = @_;
+       __error $file, @messages;
+}
+
+sub __function_execute {
+       my ($file, $command, $environment, $defaults) = @_;
+
+       # Try to execute the command...
+       chomp(my $result = `$command ${\DIRECTIVE_ERROR_PIPE}`);
+       unless ($?) {
+               print_format "Execution of `<|GREEN $command|>` succeeded: <|BOLD $result|>\n";
+               return $result;
+       }
+
+       # If looking up with pkg-config fails then check the environment...
+       if (defined $environment && $environment ne '') {
+               $environment = sprintf('INSPIRCD_%s', uc $environment);
+               if (defined $ENV{$environment}) {
+                       print_format "Execution of `<|GREEN $command|>` failed; using the environment: <|BOLD $ENV{$environment}|>\n";
+                       return $ENV{$environment};
+               }
+       }
+
+       # If all else fails then look for the defaults..
+       if (defined $defaults) {
+               print_format "Execution of `<|GREEN $command|>` failed; using the defaults: <|BOLD $defaults|>\n";
+               return $defaults;
+       }
+
+       # Executing the command failed and we don't have any defaults so give up. 
+       __error $file, "`<|GREEN $command|>` exited with a non-zero exit code!";
+}
+
+sub __function_find_compiler_flags {
+       my ($file, $name, $defaults) = @_;
+
+       # Try to look up the compiler flags with pkg-config...
+       chomp(my $flags = `pkg-config --cflags $name ${\DIRECTIVE_ERROR_PIPE}`);
+       unless ($?) {
+               print_format "Found the compiler flags for <|GREEN ${\basename $file, '.cpp'}|> using pkg-config: <|BOLD $flags|>\n";
+               return $flags;
+       }
+
+       # If looking up with pkg-config fails then check the environment...
+       my $key = sprintf('INSPIRCD_CXXFLAGS_%s', uc $name);
+       if (defined $ENV{$key}) {
+               print_format "Found the compiler flags for <|GREEN ${\basename $file, '.cpp'}|> using the environment: <|BOLD $ENV{$key}|>\n";
+               return $ENV{$key};
+       }
+
+       # If all else fails then look for the defaults..
+       if (defined $defaults) {
+               print_format "Found the compiler flags for <|GREEN ${\basename $file, '.cpp'}|> using the defaults: <|BOLD $defaults|>\n";
+               return $defaults;
+       }
+
+       # We can't find it via pkg-config, via the environment, or via the defaults so give up.
+       __error $file, "unable to find the compiler flags for <|GREEN ${\basename $file, '.cpp'}|>!";
+}
+
+sub __function_find_linker_flags {
+       my ($file, $name, $defaults) = @_;
+
+       # Try to look up the linker flags with pkg-config...
+       chomp(my $flags = `pkg-config --libs $name ${\DIRECTIVE_ERROR_PIPE}`);
+       unless ($?) {
+               print_format "Found the linker flags for <|GREEN ${\basename $file, '.cpp'}|> using pkg-config: <|BOLD $flags|>\n";
+               return $flags;
+       }
+
+       # If looking up with pkg-config fails then check the environment...
+       my $key = sprintf('INSPIRCD_LDFLAGS_%s', uc $name);
+       if (defined $ENV{$key}) {
+               print_format "Found the linker flags for <|GREEN ${\basename $file, '.cpp'}|> using the environment: <|BOLD $ENV{$key}|>\n";
+               return $ENV{$key};
+       }
+
+       # If all else fails then look for the defaults..
+       if (defined $defaults) {
+               print_format "Found the linker flags for <|GREEN ${\basename $file, '.cpp'}|> using the defaults: <|BOLD $defaults|>\n";
+               return $defaults;
+       }
+
+       # We can't find it via pkg-config, via the environment, or via the defaults so give up.
+       __error $file, "unable to find the linker flags for <|GREEN ${\basename $file, '.cpp'}|>!";
+}
+
+sub __function_require_system {
+       my ($file, $name, $minimum, $maximum) = @_;
+       my ($system, $version);
+
+       # Linux is special and can be compared by distribution names.
+       if ($^O eq 'linux' && $name ne 'linux') {
+               chomp($system = lc `lsb_release --id --short 2>/dev/null`);
+               chomp($version = lc `lsb_release --release --short 2>/dev/null`);
+       }
+
+       # Gather information on the system if we don't have it already.
+       chomp($system ||= lc `uname -s 2>/dev/null`);
+       chomp($version ||= lc `uname -r 2>/dev/null`);
+
+       # We only care about the important bit of the version number so trim the rest.
+       $version =~ s/^(\d+\.\d+).+/$1/;
+
+       # Check whether the current system is suitable.
+       return undef if $name ne $system;
+       return undef if defined $minimum && $version < $minimum;
+       return undef if defined $maximum && $version > $maximum;
+
+       # Requirement directives don't change anything directly.
+       return "";
+}
+
+sub __function_require_version {
+       my ($file, $name, $minimum, $maximum) = @_;
+
+       # If pkg-config isn't installed then we can't do anything here.
+       if (system "pkg-config --exists $name ${\DIRECTIVE_ERROR_PIPE}") {
+               print_warning "unable to look up the version of $name using pkg-config!";
+               return undef;
+       }
+
+       # Check with pkg-config whether we have the required version.
+       return undef if defined $minimum && system "pkg-config --atleast-version $minimum $name";
+       return undef if defined $maximum && system "pkg-config --max-version $maximum $name";
+
+       # Requirement directives don't change anything directly.
+       return "";
+}
+
+sub __function_warning {
+       my ($file, @messages) = @_;
+       print_warning @messages;
+}
+
+1;
index f04423ce3cf20920223bc14d5fc5634dc2c8c846..1cf6cf86601f2cd0d1b34001d4f7f07148c7d94a 100755 (executable)
@@ -29,16 +29,14 @@ use warnings FATAL => qw(all);
 
 use File::Spec::Functions qw(abs2rel);
 
-use make::configure;
 use make::console;
+use make::directive;
 
 chdir $ENV{BUILDPATH};
 
 my $type = shift;
 my $out = shift;
 
-our %config = read_configure_cache();
-
 if ($type eq 'gen-ld') {
        do_static_find(@ARGV);
 } elsif ($type eq 'static-ld') {
@@ -67,10 +65,16 @@ sub message($$$) {
        }
 }
 
+sub rpath($) {
+       my $message = shift;
+       $message =~ s/-L(\S+)/-Wl,-rpath,$1 -L$1/g unless defined $ENV{INSPIRCD_DISABLE_RPATH};
+       return $message;
+}
+
 sub do_static_find {
        my @flags;
        for my $file (@ARGV) {
-               push @flags, get_property($file, 'LinkerFlags');
+               push @flags, rpath(get_directive($file, 'LinkerFlags', ''));
        }
        open F, '>', $out;
        print F join ' ', @flags;
@@ -106,7 +110,7 @@ sub do_core_link {
 sub do_link_dir {
        my ($dir, $link_flags) = (shift, '');
        for my $file (<$dir/*.cpp>) {
-               $link_flags .= get_property($file, 'LinkerFlags') . ' ';
+               $link_flags .= rpath(get_directive($file, 'LinkerFlags', '')) . ' ';
        }
        my $execstr = "$ENV{CXX} -o $out $ENV{PICLDFLAGS} $link_flags @_";
        message 'LINK', $out, $execstr;
@@ -119,7 +123,7 @@ sub do_compile {
        my $flags = '';
        my $libs = '';
        if ($do_compile) {
-               $flags = $ENV{CORECXXFLAGS} . ' ' . get_property($file, 'CompileFlags');
+               $flags = $ENV{CORECXXFLAGS} . ' ' . get_directive($file, 'CompilerFlags', '');
 
                if ($file =~ m#(?:^|/)((?:m|core)_[^/. ]+)(?:\.cpp|/.*\.cpp)$#) {
                        $flags .= ' -DMODNAME=\\"'.$1.'\\"';
@@ -128,7 +132,7 @@ sub do_compile {
 
        if ($do_link) {
                $flags = join ' ', $flags, $ENV{PICLDFLAGS};
-               $libs = get_property($file, 'LinkerFlags');
+               $libs = rpath(get_directive($file, 'LinkerFlags', ''));
        } else {
                $flags .= ' -c';
        }
diff --git a/make/utilities.pm b/make/utilities.pm
deleted file mode 100644 (file)
index f2d645f..0000000
+++ /dev/null
@@ -1,412 +0,0 @@
-#
-# InspIRCd -- Internet Relay Chat Daemon
-#
-#   Copyright (C) 2010 Daniel De Graaf <danieldg@inspircd.org>
-#   Copyright (C) 2007-2008 Craig Edwards <craigedwards@brainbox.cc>
-#   Copyright (C) 2008 Thomas Stagner <aquanight@inspircd.org>
-#   Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
-#
-# 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/>.
-#
-
-
-BEGIN {
-       require 5.8.0;
-}
-
-package make::utilities;
-
-use strict;
-use warnings FATAL => qw(all);
-
-use Exporter 'import';
-use Fcntl;
-use File::Path;
-use File::Temp;
-use Getopt::Long;
-use POSIX;
-
-our @EXPORT = qw(make_rpath pkgconfig_get_include_dirs pkgconfig_get_lib_dirs pkgconfig_check_version translate_functions promptstring);
-
-my %already_added = ();
-
-sub promptstring($$$$$)
-{
-       my ($prompt, $configitem, $default, $package, $commandlineswitch) = @_;
-       my $var;
-       if (!$main::interactive)
-       {
-               my $opt_commandlineswitch;
-               GetOptions ("$commandlineswitch=s" => \$opt_commandlineswitch);
-               if (defined $opt_commandlineswitch)
-               {
-                       print "\e[1;32m$opt_commandlineswitch\e[0m\n";
-                       $var = $opt_commandlineswitch;
-               }
-               else
-               {
-                       die "Could not detect $package! Please specify the $prompt via the command line option \e[1;32m--$commandlineswitch=\"/path/to/file\"\e[0m";
-               }
-       }
-       else
-       {
-               print "\nPlease enter the $prompt?\n";
-               print "[\e[1;32m$default\e[0m] -> ";
-               chomp($var = <STDIN>);
-       }
-       if ($var eq "")
-       {
-               $var = $default;
-       }
-       $main::config{$configitem} = $var;
-}
-
-sub make_rpath($;$)
-{
-       my ($executable, $module) = @_;
-       return "" if defined $ENV{DISABLE_RPATH};
-       chomp(my $data = `$executable`);
-       my $output = "";
-       while ($data =~ /-L(\S+)/)
-       {
-               my $libpath = $1;
-               if (!exists $already_added{$libpath})
-               {
-                       print "Adding runtime library path to \e[1;32m$module\e[0m ... \e[1;32m$libpath\e[0m\n";
-                       $already_added{$libpath} = 1;
-               }
-               $output .= "-Wl,-rpath -Wl,$libpath -L$libpath ";
-               $data =~ s/-L(\S+)//;
-       }
-       return $output;
-}
-
-sub pkgconfig_get_include_dirs($$$;$)
-{
-       my ($packagename, $headername, $defaults, $module) = @_;
-
-       print "Locating include directory for package \e[1;32m$packagename\e[0m for module \e[1;32m$module\e[0m... ";
-
-       my $v = `pkg-config --modversion $packagename 2>/dev/null`;
-       my $ret = `pkg-config --cflags $packagename 2>/dev/null`;
-       my $foo = "";
-       if ((!defined $v) || ($v eq ""))
-       {
-               print "\e[31mCould not find $packagename via pkg-config\e[m (\e[1;32mplease install pkg-config\e[m)\n";
-               my $locbin = $^O eq 'solaris' ? 'slocate' : 'locate';
-               $foo = `$locbin "$headername" 2>/dev/null | head -n 1`;
-               my $find = $foo =~ /(.+)\Q$headername\E/ ? $1 : '';
-               chomp($find);
-               if ((defined $find) && ($find ne "") && ($find ne $packagename))
-               {
-                       print "(\e[1;32mFound via search\e[0m) ";
-                       $foo = "-I$1";
-               }
-               else
-               {
-                       $foo = " ";
-                       undef $v;
-               }
-               $ret = "$foo";
-       }
-       if (($defaults ne "") && (($ret eq "") || (!defined $ret)))
-       {
-               $ret = "$foo " . $defaults;
-       }
-       chomp($ret);
-       if ((($ret eq " ") || (!defined $ret)) && ((!defined $v) || ($v eq "")))
-       {
-               my $key = "default_includedir_$packagename";
-               if (exists $main::config{$key})
-               {
-                       $ret = $main::config{$key};
-               }
-               else
-               {
-                       $headername =~ s/^\///;
-                       promptstring("path to the directory containing $headername", $key, "/usr/include",$packagename,"$packagename-includes");
-                       $packagename =~ tr/a-z/A-Z/;
-                       if (defined $v)
-                       {
-                               $main::config{$key} = "-I$main::config{$key}" . " $defaults -DVERSION_$packagename=\"$v\"";
-                       }
-                       else
-                       {
-                               $main::config{$key} = "-I$main::config{$key}" . " $defaults -DVERSION_$packagename=\"0.0\"";
-                       }
-                       $main::config{$key} =~ s/^\s+//g;
-                       $ret = $main::config{$key};
-                       return $ret;
-               }
-       }
-       else
-       {
-               chomp($v);
-               my $key = "default_includedir_$packagename";
-               $packagename =~ tr/a-z/A-Z/;
-               $main::config{$key} = "$ret -DVERSION_$packagename=\"$v\"";
-               $main::config{$key} =~ s/^\s+//g;
-               $ret = $main::config{$key};
-               print "\e[1;32m$ret\e[0m (version $v)\n";
-       }
-       $ret =~ s/^\s+//g;
-       return $ret;
-}
-
-sub pkgconfig_check_version($$;$)
-{
-       my ($packagename, $version, $module) = @_;
-
-       print "Checking version of package \e[1;32m$packagename\e[0m is >= \e[1;32m$version\e[0m... ";
-
-       my $v = `pkg-config --modversion $packagename 2>/dev/null`;
-       if (defined $v)
-       {
-               chomp($v);
-       }
-       if ((defined $v) && ($v ne ""))
-       {
-               if (!system "pkg-config --atleast-version $version $packagename")
-               {
-                       print "\e[1;32mYes (version $v)\e[0m\n";
-                       return 1;
-               }
-               else
-               {
-                       print "\e[1;32mNo (version $v)\e[0m\n";
-                       return 0;
-               }
-       }
-       # If we didnt find it, we  cant definitively say its too old.
-       # Return ok, and let pkgconflibs() or pkgconfincludes() pick up
-       # the missing library later on.
-       print "\e[1;32mNo (not found)\e[0m\n";
-       return 1;
-}
-
-sub pkgconfig_get_lib_dirs($$$;$)
-{
-       my ($packagename, $libname, $defaults, $module) = @_;
-
-       print "Locating library directory for package \e[1;32m$packagename\e[0m for module \e[1;32m$module\e[0m... ";
-
-       my $v = `pkg-config --modversion $packagename 2>/dev/null`;
-       my $ret = `pkg-config --libs $packagename 2>/dev/null`;
-
-       my $foo = "";
-       if ((!defined $v) || ($v eq ""))
-       {
-               my $locbin = $^O eq 'solaris' ? 'slocate' : 'locate';
-               $foo = `$locbin "$libname" | head -n 1`;
-               $foo =~ /(.+)\Q$libname\E/;
-               my $find = $1;
-               chomp($find);
-               if ((defined $find) && ($find ne "") && ($find ne $packagename))
-               {
-                       print "(\e[1;32mFound via search\e[0m) ";
-                       $foo = "-L$1";
-               }
-               else
-               {
-                       $foo = " ";
-                       undef $v;
-               }
-               $ret = "$foo";
-       }
-
-       if (($defaults ne "") && (($ret eq "") || (!defined $ret)))
-       {
-               $ret = "$foo " . $defaults;
-       }
-       chomp($ret);
-       if ((($ret eq " ") || (!defined $ret)) && ((!defined $v) || ($v eq "")))
-       {
-               my $key = "default_libdir_$packagename";
-               if (exists $main::config{$key})
-               {
-                       $ret = $main::config{$key};
-               }
-               else
-               {
-                       $libname =~ s/^\///;
-                       promptstring("path to the directory containing $libname", $key, "/usr/lib",$packagename,"$packagename-libs");
-                       $main::config{$key} = "-L$main::config{$key}" . " $defaults";
-                       $main::config{$key} =~ s/^\s+//g;
-                       $ret = $main::config{$key};
-                       return $ret;
-               }
-       }
-       else
-       {
-               chomp($v);
-               print "\e[1;32m$ret\e[0m (version $v)\n";
-               my $key = "default_libdir_$packagename";
-               $main::config{$key} = $ret;
-               $main::config{$key} =~ s/^\s+//g;
-               $ret =~ s/^\s+//g;
-       }
-       $ret =~ s/^\s+//g;
-       return $ret;
-}
-
-# Translate a $CompileFlags etc line and parse out function calls
-# to functions within these modules at configure time.
-sub translate_functions($$)
-{
-       my ($line,$module) = @_;
-
-       eval
-       {
-               $module =~ /modules*\/(.+?)$/;
-               $module = $1;
-
-               if ($line =~ /ifuname\(\!"(\w+)"\)/)
-               {
-                       my $uname = $1;
-                       if ($uname eq $^O)
-                       {
-                               $line = "";
-                               return "";
-                       }
-
-                       $line =~ s/ifuname\(\!"(.+?)"\)//;
-               }
-
-               if ($line =~ /ifuname\("(\w+)"\)/)
-               {
-                       my $uname = $1;
-                       if ($uname ne $^O)
-                       {
-                               $line = "";
-                               return "";
-                       }
-
-                       $line =~ s/ifuname\("(.+?)"\)//;
-               }
-
-               if ($line =~ /if\("(\w+)"\)/)
-               {
-                       if (defined $main::config{$1})
-                       {
-                               if (($main::config{$1} !~ /y/i) and ($main::config{$1} ne "1"))
-                               {
-                                       $line = "";
-                                       return "";
-                               }
-                       }
-
-                       $line =~ s/if\("(.+?)"\)//;
-               }
-               if ($line =~ /if\(\!"(\w+)"\)/)
-               {
-                       if (!exists $main::config{$1})
-                       {
-                               $line = "";
-                               return "";
-                       }
-                       else
-                       {
-                               if (defined $1)
-                               {
-                                       if (exists ($main::config{$1}) and (($main::config{$1} =~ /y/i) or ($main::config{$1} eq "1")))
-                                       {
-                                               $line = "";
-                                               return "";
-                                       }
-                               }
-                       }
-
-                       $line =~ s/if\(\!"(.+?)"\)//;
-               }
-               while ($line =~ /exec\("(.+?)"\)/)
-               {
-                       print "Executing program for module \e[1;32m$module\e[0m ... \e[1;32m$1\e[0m\n";
-                       my $replace = `$1`;
-                       die $replace if ($replace =~ /Configuration failed/);
-                       chomp($replace);
-                       $line =~ s/exec\("(.+?)"\)/$replace/;
-               }
-               while ($line =~ /execruntime\("(.+?)"\)/)
-               {
-                       $line =~ s/execruntime\("(.+?)"\)/`$1`/;
-               }
-               while ($line =~ /eval\("(.+?)"\)/)
-               {
-                       print "Evaluating perl code for module \e[1;32m$module\e[0m ... ";
-                       my $tmpfile;
-                       do
-                       {
-                               $tmpfile = File::Temp::tmpnam();
-                       } until sysopen(TF, $tmpfile, O_RDWR|O_CREAT|O_EXCL|O_NOFOLLOW, 0700);
-                       print "(Created and executed \e[1;32m$tmpfile\e[0m)\n";
-                       print TF $1;
-                       close TF;
-                       my $replace = `perl $tmpfile`;
-                       chomp($replace);
-                       unlink($tmpfile);
-                       $line =~ s/eval\("(.+?)"\)/$replace/;
-               }
-               while ($line =~ /pkgconflibs\("(.+?)","(.+?)","(.+?)"\)/)
-               {
-                       my $replace = pkgconfig_get_lib_dirs($1, $2, $3, $module);
-                       $line =~ s/pkgconflibs\("(.+?)","(.+?)","(.+?)"\)/$replace/;
-               }
-               while ($line =~ /pkgconfversion\("(.+?)","(.+?)"\)/)
-               {
-                       if (pkgconfig_check_version($1, $2, $module) != 1)
-                       {
-                               die "Version of package $1 is too old. Please upgrade it to version \e[1;32m$2\e[0m or greater and try again.";
-                       }
-                       # This doesnt actually get replaced with anything
-                       $line =~ s/pkgconfversion\("(.+?)","(.+?)"\)//;
-               }
-               while ($line =~ /pkgconflibs\("(.+?)","(.+?)",""\)/)
-               {
-                       my $replace = pkgconfig_get_lib_dirs($1, $2, "", $module);
-                       $line =~ s/pkgconflibs\("(.+?)","(.+?)",""\)/$replace/;
-               }
-               while ($line =~ /pkgconfincludes\("(.+?)","(.+?)",""\)/)
-               {
-                       my $replace = pkgconfig_get_include_dirs($1, $2, "", $module);
-                       $line =~ s/pkgconfincludes\("(.+?)","(.+?)",""\)/$replace/;
-               }
-               while ($line =~ /pkgconfincludes\("(.+?)","(.+?)","(.+?)"\)/)
-               {
-                       my $replace = pkgconfig_get_include_dirs($1, $2, $3, $module);
-                       $line =~ s/pkgconfincludes\("(.+?)","(.+?)","(.+?)"\)/$replace/;
-               }
-               while ($line =~ /rpath\("(.+?)"\)/)
-               {
-                       my $replace = make_rpath($1,$module);
-                       $line =~ s/rpath\("(.+?)"\)/$replace/;
-               }
-       };
-       if ($@)
-       {
-               my $err = $@;
-               #$err =~ s/at .+? line \d+.*//g;
-               print "\n\nConfiguration failed. The following error occured:\n\n$err\n";
-               print "\nMake sure you have pkg-config installed\n";
-               print "\nIn the case of gnutls configuration errors on debian,\n";
-               print "Ubuntu, etc, you should ensure that you have installed\n";
-               print "gnutls-bin as well as libgnutls-dev and libgnutls.\n";
-               exit;
-       }
-       else
-       {
-               return $line;
-       }
-}
-
-1;
-
index 967c6a761f2c80a94058ca71381ad616a16768ca..564599bf8c3c34423d3f098cdb4568514b5e3978 100644 (file)
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+/// $CompilerFlags: find_compiler_flags("geoip" "")
+/// $LinkerFlags: find_linker_flags("geoip" "-lGeoIP")
+
+/// $PackageInfo: require_system("darwin") geoip pkg-config
+/// $PackageInfo: require_system("ubuntu") libgeoip-dev pkg-config
 
 #include "inspircd.h"
 #include "xline.h"
@@ -27,8 +32,6 @@
 # pragma comment(lib, "GeoIP.lib")
 #endif
 
-/* $LinkerFlags: -lGeoIP */
-
 class ModuleGeoIP : public Module
 {
        LocalStringExt ext;
index 6987381451f3b0690158219a1d786cb733bd063c..67a4e6745ba4d3166fed87defcdfef4001165527 100644 (file)
@@ -17,6 +17,9 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+/// $LinkerFlags: -llber -lldap_r
+/// $PackageInfo: require_system("ubuntu") libldap2-dev
+
 #include "inspircd.h"
 #include "modules/ldap.h"
 
@@ -27,8 +30,6 @@
 # pragma comment(lib, "liblber.lib")
 #endif
 
-/* $LinkerFlags: -lldap_r -llber */
-
 class LDAPService;
 
 class LDAPRequest
index e65a8de922c6364b0550686317a2217fb479c369..d965c88fb84cef1d0dc52e6113156cfc20ff8814 100644 (file)
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+/// $CompilerFlags: execute("mysql_config --include" "MYSQL_CXXFLAGS")
+/// $LinkerFlags: execute("mysql_config --libs_r" "MYSQL_LDFLAGS" "-lmysqlclient")
+
+/// $PackageInfo: require_system("darwin") mysql-connector-c
+/// $PackageInfo: require_system("ubuntu") libmysqlclient-dev
+
 
 // Fix warnings about the use of `long long` on C++03.
 #if defined __clang__
@@ -37,9 +43,6 @@
 
 /* VERSION 3 API: With nonblocking (threaded) requests */
 
-/* $CompileFlags: exec("mysql_config --include") */
-/* $LinkerFlags: exec("mysql_config --libs_r") rpath("mysql_config --libs_r") */
-
 /* THE NONBLOCKING MYSQL API!
  *
  * MySQL provides no nonblocking (asyncronous) API of its own, and its developers recommend
index ff8c1174c8e72937a93c6f800d5b4c7d6beabee3..56455a718b28ff38830c70c009a3b73f31417464 100644 (file)
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+/// $CompilerFlags: -Iexecute("pg_config --includedir" "POSTGRESQL_INCLUDE_DIR")
+/// $LinkerFlags: -Lexecute("pg_config --libdir" "POSTGRESQL_LIBRARY_DIR") -lpq
+
+/// $PackageInfo: require_system("darwin") postgresql
+/// $PackageInfo: require_system("ubuntu") libpq-dev
+
 
 #include "inspircd.h"
 #include <cstdlib>
 #include <libpq-fe.h>
 #include "modules/sql.h"
 
-/* $CompileFlags: -Iexec("pg_config --includedir") eval("my $s = `pg_config --version`;$s =~ /^.*?(\d+)\.(\d+)\.(\d+).*?$/;my $v = hex(sprintf("0x%02x%02x%02x", $1, $2, $3));print "-DPGSQL_HAS_ESCAPECONN" if(($v >= 0x080104) || ($v >= 0x07030F && $v < 0x070400) || ($v >= 0x07040D && $v < 0x080000) || ($v >= 0x080008 && $v < 0x080100));") */
-/* $LinkerFlags: -Lexec("pg_config --libdir") -lpq */
-
 /* SQLConn rewritten by peavey to
  * use EventHandler instead of
  * BufferedSocket. This is much neater
@@ -412,14 +415,10 @@ restart:
                                {
                                        std::string parm = p[param++];
                                        std::vector<char> buffer(parm.length() * 2 + 1);
-#ifdef PGSQL_HAS_ESCAPECONN
                                        int error;
                                        size_t escapedsize = PQescapeStringConn(sql, &buffer[0], parm.data(), parm.length(), &error);
                                        if (error)
                                                ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "BUG: Apparently PQescapeStringConn() failed");
-#else
-                                       size_t escapedsize = PQescapeString(&buffer[0], parm.data(), parm.length());
-#endif
                                        res.append(&buffer[0], escapedsize);
                                }
                        }
@@ -447,14 +446,10 @@ restart:
                                {
                                        std::string parm = it->second;
                                        std::vector<char> buffer(parm.length() * 2 + 1);
-#ifdef PGSQL_HAS_ESCAPECONN
                                        int error;
                                        size_t escapedsize = PQescapeStringConn(sql, &buffer[0], parm.data(), parm.length(), &error);
                                        if (error)
                                                ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "BUG: Apparently PQescapeStringConn() failed");
-#else
-                                       size_t escapedsize = PQescapeString(&buffer[0], parm.data(), parm.length());
-#endif
                                        res.append(&buffer[0], escapedsize);
                                }
                        }
index 9ae6719ba96a89d35adc9d67ca7d5c5f7bd6932f..5ad27858fa68d9c1d9076063380cf42920727f5e 100644 (file)
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+/// $CompilerFlags: execute("pcre-config --cflags" "PCRE_CXXFLAGS")
+/// $LinkerFlags: execute("pcre-config --libs" "PCRE_LDFLAGS" "-lpcre")
+
+/// $PackageInfo: require_system("darwin") pcre pkg-config
+/// $PackageInfo: require_system("ubuntu") libpcre3-dev pkg-config
+
 
 #include "inspircd.h"
 #include <pcre.h>
 #include "modules/regex.h"
 
-/* $CompileFlags: exec("pcre-config --cflags") */
-/* $LinkerFlags: exec("pcre-config --libs") rpath("pcre-config --libs") -lpcre */
-
 #ifdef _WIN32
 # pragma comment(lib, "libpcre.lib")
 #endif
index c4657bf8b10c06e28df3c5321d9ad393daa651b7..2f0ee2998b12522227a5060980ef0c8b670d2711 100644 (file)
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+/// $CompilerFlags: find_compiler_flags("re2" "")
+/// $LinkerFlags: find_linker_flags("re2" "-lre2")
+
+/// $PackageInfo: require_system("darwin") pkg-config re2
+/// $PackageInfo: require_system("ubuntu" "15.10") libre2-dev pkg-config
+
 
 #include "inspircd.h"
 #include "modules/regex.h"
@@ -32,8 +38,6 @@
 
 #include <re2/re2.h>
 
-/* $LinkerFlags: -lre2 */
-
 class RE2Regex : public Regex
 {
        RE2 regexcl;
index 8e7bd0da25f99375ca7ab2b5304dc44c89805aa2..7a888ed722b77b0523ec321a44372b71d76d03b8 100644 (file)
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+/// $CompilerFlags: -std=c++11
+
+
 #include "inspircd.h"
 #include "modules/regex.h"
 #include <regex>
 
-/* $CompileFlags: -std=c++11 */
-
 class StdRegex : public Regex
 {
        std::regex regexcl;
index 8a1d5424880d6d479ea9286494a2a0ec921f5433..e2eafcd01a300d3c8190846f1d378c1cb4daf130 100644 (file)
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+/// $CompilerFlags: find_compiler_flags("tre")
+/// $LinkerFlags: find_linker_flags("tre" "-ltre")
+
+/// $PackageInfo: require_system("darwin") pkg-config tre
+/// $PackageInfo: require_system("ubuntu") libtre-dev pkg-config
 
 #include "inspircd.h"
 #include "modules/regex.h"
 #include <sys/types.h>
 #include <tre/regex.h>
 
-/* $CompileFlags: pkgconfincludes("tre","tre/regex.h","") */
-/* $LinkerFlags: pkgconflibs("tre","/libtre.so","-ltre") rpath("pkg-config --libs tre") */
-
 class TRERegex : public Regex
 {
        regex_t regbuf;
index 8c07bfc6aa60e601bb001b6cdff6dec4731a90b2..fa88cacc389301466da0414e3a3fbb61b1552915 100644 (file)
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+/// $CompilerFlags: find_compiler_flags("sqlite3")
+/// $LinkerFlags: find_linker_flags("sqlite3" "-lsqlite3")
+
+/// $PackageInfo: require_system("darwin") pkg-config sqlite3
+/// $PackageInfo: require_system("ubuntu") libsqlite3-dev pkg-config
 
 #include "inspircd.h"
 #include "modules/sql.h"
@@ -36,9 +41,6 @@
 # pragma comment(lib, "sqlite3.lib")
 #endif
 
-/* $CompileFlags: pkgconfversion("sqlite3","3.3") pkgconfincludes("sqlite3","/sqlite3.h","") */
-/* $LinkerFlags: pkgconflibs("sqlite3","/libsqlite3.so","-lsqlite3") */
-
 class SQLConn;
 typedef insp::flat_map<std::string, SQLConn*> ConnMap;
 
index e5cb8ee9000ab3c1040db3d0a670ebce9f0c0035..a42efa1ab121359f6f1587873a4484e280ec7019 100644 (file)
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+/// $CompilerFlags: find_compiler_flags("gnutls")
+/// $CompilerFlags: require_version("gnutls" "1.0" "2.12") execute("libgcrypt-config --cflags" "LIBGCRYPT_CXXFLAGS")
+
+/// $LinkerFlags: find_linker_flags("gnutls" "-lgnutls")
+/// $LinkerFlags: require_version("gnutls" "1.0" "2.12") execute("libgcrypt-config --libs" "LIBGCRYPT_LDFLAGS")
+
+/// $PackageInfo: require_system("darwin") gnutls pkg-config
+/// $PackageInfo: require_system("ubuntu" "1.0" "13.10") libgcrypt11-dev
+/// $PackageInfo: require_system("ubuntu" "14.04") gnutls-bin libgnutls-dev pkg-config
 
 #include "inspircd.h"
 #include "modules/ssl.h"
@@ -62,9 +71,6 @@
 # pragma comment(lib, "libgnutls-30.lib")
 #endif
 
-/* $CompileFlags: pkgconfincludes("gnutls","/gnutls/gnutls.h","") eval("print `libgcrypt-config --cflags | tr -d \r` if `pkg-config --modversion gnutls 2>/dev/null | tr -d \r` lt '2.12'") */
-/* $LinkerFlags: rpath("pkg-config --libs gnutls") pkgconflibs("gnutls","/libgnutls.so","-lgnutls") eval("print `libgcrypt-config --libs | tr -d \r` if `pkg-config --modversion gnutls 2>/dev/null | tr -d \r` lt '2.12'") */
-
 // These don't exist in older GnuTLS versions
 #if INSPIRCD_GNUTLS_HAS_VERSION(2, 1, 7)
 #define GNUTLS_NEW_PRIO_API
index 50bf382666f5a66109ba3a468d059bf03ce0003c..f3b5adfd5e1d8713cbf85dbfab9a8b92c05f0308 100644 (file)
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+/// $LinkerFlags: -lmbedtls
+
+/// $PackageInfo: require_system("darwin") mbedtls
+/// $PackageInfo: require_system("ubuntu" "16.04") libmbedtls-dev
 
-/* $LinkerFlags: -lmbedtls */
 
 #include "inspircd.h"
 #include "modules/ssl.h"
index 8467cc6d416b5931efb721009aeca33611e7ea60..8843c34f6a9a118b668749fa6979a97619416c50 100644 (file)
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+/// $CompilerFlags: find_compiler_flags("openssl")
+/// $LinkerFlags: find_linker_flags("openssl" "-lssl -lcrypto")
+
+/// $PackageInfo: require_system("darwin") openssl pkg-config
+/// $PackageInfo: require_system("ubuntu" "16.04") libssl-dev openssl pkg-config
+
 
 #include "inspircd.h"
 #include "iohook.h"
@@ -46,9 +52,6 @@
 # pragma comment(lib, "libeay32.lib")
 #endif
 
-/* $CompileFlags: pkgconfversion("openssl","0.9.7") pkgconfincludes("openssl","/openssl/ssl.h","") */
-/* $LinkerFlags: rpath("pkg-config --libs openssl") pkgconflibs("openssl","/libssl.so","-lssl -lcrypto") */
-
 #if ((OPENSSL_VERSION_NUMBER >= 0x10000000L) && (!(defined(OPENSSL_NO_ECDH))))
 // OpenSSL 0.9.8 includes some ECC support, but it's unfinished. Enable only for 1.0.0 and later.
 #define INSPIRCD_OPENSSL_ENABLE_ECDH
index 739f7fc7d82adc3ffd200fa3d85397d1f816ff9f..c88f9534f46ea79d13a09e1cf265b0c76de39f2f 100755 (executable)
@@ -31,7 +31,7 @@ use warnings FATAL => qw(all);
 use File::Temp();
 
 # IMPORTANT: This script has to be able to run by itself so that it can be used
-#            by binary distributions where the make/utilities.pm module will not
+#            by binary distributions where the make/console.pm module will not
 #            be available!
 
 sub prompt($$) {