diff options
Diffstat (limited to 'make')
-rw-r--r-- | make/configure.pm | 17 | ||||
-rw-r--r-- | make/console.pm | 18 | ||||
-rw-r--r-- | make/directive.pm | 264 | ||||
-rwxr-xr-x | make/unit-cc.pl | 18 | ||||
-rw-r--r-- | make/utilities.pm | 412 |
5 files changed, 286 insertions, 443 deletions
diff --git a/make/configure.pm b/make/configure.pm index 8619d5be2..e88454658 100644 --- a/make/configure.pm +++ b/make/configure.pm @@ -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/console.pm b/make/console.pm index 621de0274..84fbaae4a 100644 --- a/make/console.pm +++ b/make/console.pm @@ -57,22 +57,26 @@ sub __console_format($$) { sub print_format($;$) { my $message = shift; my $stream = shift // *STDOUT; - while ($message =~ /(<\|(\S+)\s(.+?)\|>)/) { + while ($message =~ /(<\|(\S+)\s(.*?)\|>)/) { my $formatted = __console_format $2, $3; $message =~ s/\Q$1\E/$formatted/; } print { $stream } $message; } -sub print_error($) { - my $message = shift; - print_format "<|RED Error:|> $message\n", *STDERR; +sub print_error { + print_format "<|RED Error:|> ", *STDERR; + for my $line (@_) { + print_format "$line\n", *STDERR; + } exit 1; } -sub print_warning($) { - my $message = shift; - print_format "<|YELLOW Warning:|> $message\n", *STDERR; +sub print_warning { + print_format "<|YELLOW Warning:|> ", *STDERR; + for my $line (@_) { + print_format "$line\n", *STDERR; + } } sub prompt_bool($$$) { diff --git a/make/directive.pm b/make/directive.pm new file mode 100644 index 000000000..c490135fd --- /dev/null +++ b/make/directive.pm @@ -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; diff --git a/make/unit-cc.pl b/make/unit-cc.pl index f04423ce3..1cf6cf866 100755 --- a/make/unit-cc.pl +++ b/make/unit-cc.pl @@ -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 index f2d645f33..000000000 --- a/make/utilities.pm +++ /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; - |