source: tags/arb_5.3/util/arb_check_build_env.pl

Last change on this file was 6772, checked in by westram, 14 years ago
  • 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                'perl',
22                'rm',
23                'xmllint',
24                'xsltproc',
25                'sed',
26                'sort',
27                'tar',
28                'test',
29                'touch',
30                'uniq',
31               );
32
33sub findPath($\@) {
34  my ($command,$path_dirs_r) = @_;
35  my ($found,$executable) = (undef,undef);
36
37  if (-e $command) {
38    $found = $command;
39    if (-X $command) { $executable = $command; }
40  }
41
42  if (not defined $executable) {
43    foreach (@$path_dirs_r) {
44      my $full = $_.'/'.$command;
45      if (-e $full) {
46        $found = $full;
47        if (-X $full) { $executable = $full; }
48      }
49    }
50  }
51  return ($found,$executable);
52}
53
54sub main() {
55  foreach (@ARGV) {
56    s/ .*$//og; # skip anything from first space to EOL
57    push @commands, $_;
58  }
59  {
60    my %commands = map { $_ => 1; } @commands;
61    @commands = sort keys %commands;
62  }
63
64  my $path = $ENV{PATH};
65  if (not defined $path) { die "Environmentvariable 'PATH' is undefined"; }
66  my @path_dirs = split(':',$path);
67
68  my @missing       = ();
69  my @notExecutable = ();
70
71  foreach (@commands) {
72    my ($found,$executable) = findPath($_,@path_dirs);
73    if (not defined $executable) { # not ok
74      if (defined $found) { push @notExecutable, $_; }
75      else { push @missing, $_; }
76    }
77  }
78
79  my $missing = scalar(@missing);
80  my $notExecutable = scalar(@notExecutable);
81
82  if (($missing+$notExecutable)==0) {
83    print "All tools needed for ARB compilation have been located.\n";
84  }
85  else {
86    my $missingList       = join(', ', @missing);
87    my $notExecutableList = join(', ', @notExecutable);
88
89    my $msg = "The following tools are missing:\n";
90    if ($missing>0)       { $msg .= "    $missingList\n"; }
91    if ($notExecutable>0) { $msg .= "    $notExecutableList (found but not executable)\n"; }
92    $msg .= "These tools are vital to compile ARB, so\n";
93    $msg .= "please ensure that these tools are installed and that either\n";
94    $msg .= "- their installation directory is in PATH or\n";
95    $msg .= "- they are linked into the PATH\n\n";
96
97    die $msg;
98  }
99}
100
101main();
102
Note: See TracBrowser for help on using the repository browser.