X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;ds=sidebyside;f=make%2Fdirective.pm;h=c0c2aee85039bb297ba9f016d8fb233ab032276f;hb=bd6e75ffa1a9827aa135e313eca4e5b396ebda2f;hp=6650825bc817fd63cd47f2d374441be58a9b0f55;hpb=124c17e14134a4999afc1a5e981ab7c75b3694b9;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/make/directive.pm b/make/directive.pm index 6650825bc..c0c2aee85 100644 --- a/make/directive.pm +++ b/make/directive.pm @@ -27,13 +27,15 @@ use feature ':5.10'; use strict; use warnings FATAL => qw(all); -use File::Basename qw(basename); -use Exporter qw(import); +use File::Basename qw(basename dirname); +use File::Spec::Functions qw(catdir); +use Exporter qw(import); use make::configure; use make::console; use constant DIRECTIVE_ERROR_PIPE => $ENV{INSPIRCD_VERBOSE} ? '' : '2>/dev/null'; +use constant VENDOR_DIRECTORY => catdir(dirname(dirname(__FILE__)), 'vendor'); our @EXPORT = qw(get_directive execute_functions); @@ -162,7 +164,7 @@ sub __function_execute { return $defaults; } - # Executing the command failed and we don't have any defaults so give up. + # 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!"; } @@ -185,7 +187,7 @@ sub __function_find_compiler_flags { # If all else fails then look for the defaults.. if (defined $defaults) { - print_format "Found the <|GREEN $name|> compiler flags for <|GREEN ${\basename $file, '.cpp'}|> using the defaults: <|BOLD $defaults|>\n"; + print_format "Using the default <|GREEN $name|> compiler flags for <|GREEN ${\basename $file, '.cpp'}|>: <|BOLD $defaults|>\n"; return $defaults; } @@ -212,7 +214,7 @@ sub __function_find_linker_flags { # If all else fails then look for the defaults.. if (defined $defaults) { - print_format "Found the <|GREEN $name|> linker flags for <|GREEN ${\basename $file, '.cpp'}|> using the defaults: <|BOLD $defaults|>\n"; + print_format "Using the default <|GREEN $name|> linker flags for <|GREEN ${\basename $file, '.cpp'}|>: <|BOLD $defaults|>\n"; return $defaults; } @@ -220,6 +222,22 @@ sub __function_find_linker_flags { __error $file, "unable to find the <|GREEN $name|> linker flags for <|GREEN ${\basename $file, '.cpp'}|>!"; } +sub __function_require_compiler { + my ($file, $name, $minimum, $maximum) = @_; + + # Look up information about the compiler. + return undef unless $ENV{CXX}; + my %compiler = get_compiler_info($ENV{CXX}); + + # Check whether the current compiler is suitable. + return undef unless $compiler{NAME} eq $name; + return undef if defined $minimum && $compiler{VERSION} < $minimum; + return undef if defined $maximum && $compiler{VERSION} > $maximum; + + # Requirement directives don't change anything directly. + return ""; +} + sub __function_require_system { my ($file, $name, $minimum, $maximum) = @_; my ($system, $version); @@ -263,6 +281,26 @@ sub __function_require_version { return ""; } +sub __function_vendor_directory { + my ($file, $name) = @_; + + # Try to look the directory up in the environment... + my $key = __environment 'INSPIRCD_VENDOR_', $name; + if (defined $ENV{$key}) { + print_format "Found the <|GREEN $name|> vendor directory for <|GREEN ${\basename $file, '.cpp'}|> using the environment: <|BOLD $ENV{$key}|>\n"; + return $ENV{$key}; + } + + my $directory = catdir(VENDOR_DIRECTORY, $name); + if (-d $directory) { + print_format "Using the default <|GREEN $name|> vendor directory for <|GREEN ${\basename $file, '.cpp'}|>: <|BOLD $directory|>\n"; + return $directory; + } + + # We can't find it via the environment or via the filesystem so give up. + __error $file, "unable to find the <|GREEN $name|> vendor directory for <|GREEN ${\basename $file, '.cpp'}|>!"; +} + sub __function_warning { my ($file, @messages) = @_; print_warning @messages;