comparison tools/find-gcc-include-path @ 861:c005a392e27e

fix for Marvaricks
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 31 Mar 2014 18:33:20 +0900
parents c14a1426cfed
children
comparison
equal deleted inserted replaced
860:467be346ae47 861:c005a392e27e
1 #!/usr/bin/perl 1 #!/usr/bin/perl
2 2
3 my $CC = $ARGV[1]; 3 my $CC = $ARGV[1];
4 my $gcc = `echo '#include <stddef.h>' | $CC -E - `; 4 my $gcc = `echo '#include <stdio.h>' | $CC -E - `;
5 5
6 $gcc =~ m=\"(/[^"]+/)stddef\.h"=; 6 $gcc =~ m=\"(/[^"]+/)stdio\.h"=;
7 my $gcc_path = $1; 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;
13
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 }
8 23
9 if ($ARGV[0]=~/-l/) { 24 if ($ARGV[0]=~/-l/) {
10 print <<EOF 25 print <<EOF
11 char *l_include_path[] = { 26 char *l_include_path[] = {
12 "$gcc_path", 27 $path
13 "/usr/include/", 28 "/usr/include/",
14 0 29 0
15 }; 30 };
16 EOF 31 EOF
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 }
17 } else { 43 } else {
18 print "$gcc_path\n"; 44 print "$gcc_path\n";
19 } 45 }