3 # Generate an h tree that includes the appropriate sys headers
5 # Usage: make_h_tree.pl ${SRC} ...
7 # The specified makefiles will be scanned for variable values. The h
8 # directory will be created under the current directory and populated with
9 # stubs that include the actual header file for every header included by any
10 # source file in the ${SRC} directories. This is an ugly hack to work around
11 # the naming of header files using h instead of their proper names elsewhere
17 die "Usage: $0 SRC ...\n";
20 %remap = ('h' => 'sys');
21 foreach $src (keys %remap) {
22 mkdir($src, 0777) or die "$src: $!\n";
24 @q = map { glob ("$_/*.[Sc]") } @ARGV;
27 $content = new IO::File($src, O_RDONLY) or die "$src: $!\n";
31 if (/^\s*\#\s*include\s*[<\"](?:\.\.\/)?([^\/>\"]*)(.*?)[>\"]/) {
33 if (exists $seen{$inc}) {
35 } elsif (exists $remap{$1} && $2 !~ /.\//) {
36 $H = new IO::File("$inc", O_WRONLY|O_CREAT|O_TRUNC, 0666)
38 print $H "#include <sys$2>\n";
39 $H->close() or die "$inc: $!\n";