source: branches/stable/util/arb_check_build_env.pl

Last change on this file was 18342, checked in by westram, 4 years ago
  • improve errors shown when trying to build while no gcc is installed.
  • add 'patch' to required build tools.
  • updated list of compile requirements according to SUSE leap 15.1
  • Property svn:executable set to *
File size: 2.5 KB
Line 
1#!/usr/bin/perl
2#
3# This script checks whether all tools needed for ARB compilation are found in path.
4
5use strict;
6use warnings;
7
8my @commands = (
9                'bash',
10                'cat',
11                'chmod',
12                'cp',
13                'find',
14                'grep',
15                'gzip',
16                'ln',
17                'ls',
18                'lynx',
19                'mkdir',
20                'mv',
21                'patch',
22                'perl',
23                'rm',
24                'sed',
25                'sort',
26                'tar',
27                'test',
28                'time',
29                'touch',
30                'uniq',
31                'xmllint',
32                'xsltproc',
33               );
34
35sub findPath($\@) {
36  my ($command,$path_dirs_r) = @_;
37  my ($found,$executable) = (undef,undef);
38
39  if (-e $command) {
40    $found = $command;
41    if (-X $command) { $executable = $command; }
42  }
43
44  if (not defined $executable) {
45    foreach (@$path_dirs_r) {
46      my $full = $_.'/'.$command;
47      if (-e $full) {
48        $found = $full;
49        if (-X $full) { $executable = $full; }
50      }
51    }
52  }
53  return ($found,$executable);
54}
55
56sub main() {
57  foreach (@ARGV) {
58    s/ .*$//og; # skip anything from first space to EOL
59    push @commands, $_;
60  }
61  {
62    my %commands = map { $_ => 1; } @commands;
63    @commands = sort keys %commands;
64  }
65
66  my $path = $ENV{PATH};
67  if (not defined $path) { die "Environmentvariable 'PATH' is undefined"; }
68  my @path_dirs = split(':',$path);
69
70  my @missing       = ();
71  my @notExecutable = ();
72
73  foreach (@commands) {
74    my ($found,$executable) = findPath($_,@path_dirs);
75    if (not defined $executable) { # not ok
76      if (defined $found) { push @notExecutable, $_; }
77      else { push @missing, $_; }
78    }
79  }
80
81  my $missing = scalar(@missing);
82  my $notExecutable = scalar(@notExecutable);
83
84  if (($missing+$notExecutable)==0) {
85    print "All tools needed for ARB compilation have been located.\n";
86  }
87  else {
88    my $missingList       = join(', ', @missing);
89    my $notExecutableList = join(', ', @notExecutable);
90
91    my $msg = "The following tools are missing:\n";
92    if ($missing>0)       { $msg .= "    $missingList\n"; }
93    if ($notExecutable>0) { $msg .= "    $notExecutableList (found but not executable)\n"; }
94    $msg .= "These tools are vital to compile ARB, so\n";
95    $msg .= "please ensure that these tools are installed and that either\n";
96    $msg .= "- their installation directory is in PATH or\n";
97    $msg .= "- they are linked into the PATH\n\n";
98
99    die $msg;
100  }
101}
102
103main();
104
Note: See TracBrowser for help on using the repository browser.