Rewrite the build system directive parser.

This commit is contained in:
Peter Powell 2016-09-11 21:19:28 +01:00
parent 6c98c29874
commit 806e57433a
18 changed files with 344 additions and 478 deletions

7
configure vendored
View File

@ -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.

View 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

264
make/directive.pm Normal file
View File

@ -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;

View File

@ -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';
}

View File

@ -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;

View File

@ -17,6 +17,11 @@
* 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;

View 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

View File

@ -19,6 +19,12 @@
* 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

View File

@ -21,15 +21,18 @@
* 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);
}
}

View File

@ -17,14 +17,17 @@
* 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

View File

@ -17,6 +17,12 @@
* 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;

View File

@ -16,12 +16,13 @@
* 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;

View File

@ -17,15 +17,17 @@
* 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;

View File

@ -19,6 +19,11 @@
* 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;

View File

@ -20,6 +20,15 @@
* 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

View File

@ -16,8 +16,11 @@
* 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"

View File

@ -21,6 +21,12 @@
* 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

View File

@ -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($$) {