615
|
1 #!/usr/bin/perl
|
|
2
|
|
3 my $CC = $ARGV[1];
|
861
|
4 my $gcc = `echo '#include <stdio.h>' | $CC -E - `;
|
|
5
|
|
6 $gcc =~ m=\"(/[^"]+/)stdio\.h"=;
|
|
7 my $gcc_path = $1;
|
|
8
|
|
9 my $gcc1 = `echo '#include <stddef.h>' | $CC -E - `;
|
|
10
|
|
11 $gcc1 =~ m=\"(/[^"]+/)stddef\.h"=;
|
|
12 my $gcc_path1 = $1;
|
615
|
13
|
861
|
14 my $path = <<EOF;
|
|
15 "$gcc_path",
|
|
16 EOF
|
|
17 if ($gcc_path1 ne $gcc_path) {
|
|
18 $path = <<EOF;
|
|
19 "$gcc_path",
|
|
20 "$gcc_path1",
|
|
21 EOF
|
|
22 }
|
615
|
23
|
|
24 if ($ARGV[0]=~/-l/) {
|
|
25 print <<EOF
|
|
26 char *l_include_path[] = {
|
861
|
27 $path
|
615
|
28 "/usr/include/",
|
|
29 0
|
|
30 };
|
|
31 EOF
|
861
|
32 } elsif ($ARGV[0]=~/-s/) {
|
|
33 open my $fd, "<", "stdio.template" or die("can't open stdio.template");
|
|
34 my $repl = 1;
|
|
35 while(<$fd>) {
|
|
36 if ($repl && /\#include \"\/usr\/include\/stdio.h\"/) {
|
|
37 print "#include \"${gcc_path}stdio.h\"\n";
|
|
38 $repl = 0;
|
|
39 next;
|
|
40 }
|
|
41 print;
|
|
42 }
|
615
|
43 } else {
|
|
44 print "$gcc_path\n";
|
|
45 }
|