File: perl-cc-wrapper

package info (click to toggle)
gnumeric 1.10.8-1squeeze5
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 90,968 kB
  • ctags: 23,303
  • sloc: ansic: 248,235; xml: 51,894; sh: 10,491; makefile: 2,822; perl: 2,466; yacc: 1,272; python: 205
file content (48 lines) | stat: -rw-r--r-- 1,134 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/perl -w
# -----------------------------------------------------------------------------
# This program changes "... -o foo.lo ..." into "... -o foo.o ...", runs the
# compiler proper and then renames foo.o onto foo.lo

my @cmd = ();
my $target;
my $tmptarget;
my $sanitize = 0;

while (@ARGV) {
    my $arg = shift @ARGV;
    if ($arg =~ /^--sanitize=(.*)/) {
	$sanitize = $1;
	next;
    }

    if ($sanitize && $arg =~ /^-/ && $arg !~ /^-(threads|-pthread|D|U|I|c|o)/) {
	# Options that get here are not in the desiret set.
	# Notably we drop "-fPIC" (some variant of which should probably
	# also occur in an unsanitized section).
	print STDERR "$0: warning dropping $arg\n";
	next;
    }

    push @cmd, $arg;
    if ($arg eq '-o') {
	$target = shift @ARGV;;
	if ($target =~ /\.lo$/) {
	    $tmptarget = $target;
	    $tmptarget =~ s/\.lo$/-tmp.o/;
	    push @cmd, $tmptarget;
	} else {
	    push @cmd, $target;
	}
    }
}

system (@cmd);

my $code = $?;
if ($code != 0) {
    unlink $tmptarget if defined $tmptarget;
    unlink $target;
} elsif (defined $tmptarget) {
    rename $tmptarget, $target;
}
exit $code >> 8;