chiark / gitweb /
Make run_directory.c stat the place it is going to try to run.
[elogind.git] / klibc / klibc / makeerrlist.pl
index 121ed1f46b97ebdaf8e16e8eb64679086c5bfbfe..14498d880a9e29603bf8ef39394fc5a0b88558a8 100644 (file)
@@ -10,20 +10,27 @@ use FileHandle;
 %errors  = ();
 %errmsg  = ();
 $maxerr  = -1;
-$rootdir = 'linux/include/';   # Must have trailing /
+@includelist = ();             # Include directories
 
 sub parse_file($) {
     my($file) = @_;
     my($fh) = new FileHandle;
     my($line, $error, $msg);
     my($kernelonly) = 0;
+    my($root);
 
-    $file = $rootdir.$file;
+    print STDERR "opening $file\n" unless ( $quiet );
 
-    print STDERR "opening $file\n";
+    $ok = 0;
+    foreach $root ( @includelist ) {
+       if ( $fh->open($root.'//'.$file, '<') ) {
+           $ok = 1;
+           last;
+       }
+    }
 
-    if ( !($fh->open("< ".$file)) ) {
-       die "$0: cannot open $file\n";
+    if ( ! $ok ) {
+       die "$0: Cannot find file $file\n";
     }
 
     while ( defined($line = <$fh>) ) {
@@ -38,7 +45,7 @@ sub parse_file($) {
                $error = $1;
                $errno = $2+0;
                $msg   = $3;
-               print STDERR "$error ($errno) => \"$msg\"\n";
+               print STDERR "$error ($errno) => \"$msg\"\n" unless ( $quiet );
                $errors{$errno} = $error;
                $errmsg{$errno} = $msg;
                $maxerr = $errno if ( $errno > $maxerr );
@@ -50,12 +57,25 @@ sub parse_file($) {
        }
     }
     close($fh);
-    print STDERR "closing $file\n";
+    print STDERR "closing $file\n" unless ( $quiet );
 }
         
-parse_file('linux/errno.h');
+$v = $ENV{'KBUILD_VERBOSE'};
+$quiet = defined($v) ? !$v : 0;
 
-($type) = @ARGV;
+foreach $arg ( @ARGV ) {
+    if ( $arg eq '-q' ) {
+       $quiet = 1;
+    } elsif ( $arg =~ /^-(errlist|errnos|maxerr)$/ ) {
+       $type = $arg;
+    } elsif ( $arg =~ '^\-I' ) {
+       push(@includelist, "$'");
+    } else {
+       die "$0: Unknown option: $arg\n";
+    }
+}
+
+parse_file('linux/errno.h');
 
 if ( $type eq '-errlist' ) {
     print  "#include <errno.h>\n";