File: perl-cc-wrapper

package info (click to toggle)
gnumeric 1.12.18-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 103,816 kB
  • ctags: 25,022
  • sloc: ansic: 278,696; xml: 54,477; sh: 11,677; perl: 4,216; makefile: 2,751; yacc: 1,324; python: 203
file content (48 lines) | stat: -rw-r--r-- 1,133 bytes parent folder | download | duplicates (2)
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;