[project @ 1997-03-14 07:52:06 by simonpj]
[ghc-hetmet.git] / ghc / driver / ghc-consist.lprl
1 %************************************************************************
2 %*                                                                      *
3 \section[Driver-consistency-chk]{@chk_consistency_info@: Check an executable for consistency}
4 %*                                                                      *
5 %************************************************************************
6
7 \begin{code}
8 sub chk_consistency_info {
9     local($executable) = @_;
10
11     local($major_version, $minor_version);
12     local($phase, $infile, $opts);
13
14     print STDERR "Checking consistency of: $executable\n" if $Verbose;
15
16     &tidy_up_and_die(1, "Panic: no such executable: $executable\n")
17         if ! -x $executable;
18
19     # by this point, consistency strings (with commas) have become
20     # local symbols (with .'s)
21     $HsC_consist_options =~ s/,/./g;
22     $Cc_consist_options  =~ s/,/./g;
23
24     # now run `nm' and check all the version info
25     open(CONSIST, "$Nm -p $executable |") || &tidy_up_and_die(1,"$Pgm: can't run: $Nm\n");
26     while (<CONSIST>) {
27         chop;
28         next if ! /^[\da-fA-F]+\s+[tn]\s+(hsc|cc)\./;
29
30         if (/^[\da-fA-F]+\s+[tn]\s+(hsc|cc)\.(\S+)\.(\d+)\.(\d+)\.(.*)/) {
31             $phase = $1; $infile = $2;
32             $major_version = $3; $minor_version = $4;
33             $opts = $5;
34             if ($phase eq 'hsc') {
35                 $Status++,
36                 print STDERR "$Pgm: consistency error: major version not $HsC_major_version:\n$_\n"
37                     if $major_version != $HsC_major_version;
38                 print STDERR "$Pgm: consistency warning: minor version not $HsC_minor_version:\n$_\n"
39                     if $minor_version != $HsC_minor_version;
40                 $Status++,
41                 print STDERR "$Pgm: consistency error: not options $opts -- $HsC_consist_options:\n$_\n"
42                     if $opts ne $HsC_consist_options;
43
44             } else { # phase is cc ...
45                 $Status++,
46                 print STDERR "$Pgm: consistency error: major version not $Cc_major_version:\n$_\n"
47                     if $major_version != $Cc_major_version;
48                 print STDERR "$Pgm: consistency warning: minor version not $Cc_minor_version:\n$_\n"
49                     if $minor_version != $Cc_minor_version;
50
51                 $Status++,
52                 print STDERR "$Pgm: consistency error: not options $Cc_consist_options:\n$_\n"
53                     if $opts ne $Cc_consist_options;
54             }
55         } else {
56             print STDERR "$Pgm: consistency-checking: unrecognised `what' line:\n$_\n";
57         }
58     }
59     close(CONSIST) || &tidy_up_and_die(1,"Failed in running $Nm (consistency checking)\n");
60 }
61
62 # make "require"r happy...
63 1;
64 \end{code}