aboutsummaryrefslogtreecommitdiff
path: root/cgcc
diff options
context:
space:
mode:
authorAlexey Zaytsev <alexey.zaytsev@gmail.com>2008-12-18 20:22:27 +0300
committerAlexey Zaytsev <alexey.zaytsev@gmail.com>2008-12-18 21:11:00 +0300
commit9e6965b5031ad49b2ce4b6c8db6e1343b3364292 (patch)
treea9d6d4273581701eb1b6b04d6d1f305abb77ea2e /cgcc
parentSet gcc include path at runtime. (diff)
downloadsparse-9e6965b5031ad49b2ce4b6c8db6e1343b3364292.tar.gz
sparse-9e6965b5031ad49b2ce4b6c8db6e1343b3364292.tar.bz2
sparse-9e6965b5031ad49b2ce4b6c8db6e1343b3364292.zip
Let cgcc pass -gcc-base-dir to sparse.
Signed-off-by: Alexey Zaytsev <alexey.zaytsev@gmail.com>
Diffstat (limited to 'cgcc')
-rwxr-xr-xcgcc14
1 files changed, 13 insertions, 1 deletions
diff --git a/cgcc b/cgcc
index cda8dab..fdda6d1 100755
--- a/cgcc
+++ b/cgcc
@@ -10,9 +10,11 @@ my $has_specs = 0;
my $gendeps = 0;
my $do_check = 0;
my $do_compile = 1;
+my $gcc_base_dir;
my $verbose = 0;
-foreach (@ARGV) {
+while (@ARGV) {
+ $_ = shift(@ARGV);
# Look for a .c file. We don't want to run the checker on .o or .so files
# in the link run. (This simplistic check knows nothing about options
# with arguments, but it seems to do the job.)
@@ -36,6 +38,12 @@ foreach (@ARGV) {
next;
}
+ if (/^-gcc-base-dir$/) {
+ $gcc_base_dir = shift @ARGV;
+ die ("$0: missing argument for -gcc-base-dir option") if !$gcc_base_dir;
+ next;
+ }
+
# If someone adds "-E", don't pre-process twice.
$do_compile = 0 if $_ eq '-E';
@@ -56,6 +64,10 @@ if ($do_check) {
$check .= &add_specs ('host_arch_specs');
$check .= &add_specs ('host_os_specs');
}
+
+ $gcc_base_dir = qx($cc -print-file-name=) if !$gcc_base_dir;
+ $check .= " -gcc-base-dir " . $gcc_base_dir if $gcc_base_dir;
+
print "$check\n" if $verbose;
if ($do_compile) {
system ($check);