Update Spanish translation
[gnumeric.git] / plugins / perl-loader / perl-cc-wrapper
blobd27edefb2b4ef3c610bb03b1a34931f60829aca0
1 #!/usr/bin/perl -w
2 # -----------------------------------------------------------------------------
3 # This program changes "... -o foo.lo ..." into "... -o foo.o ...", runs the
4 # compiler proper and then renames foo.o onto foo.lo
6 my @cmd = ();
7 my $target;
8 my $tmptarget;
9 my $sanitize = 0;
11 while (@ARGV) {
12 my $arg = shift @ARGV;
13 if ($arg =~ /^--sanitize=(.*)/) {
14 $sanitize = $1;
15 next;
18 if ($sanitize && $arg =~ /^-/ &&
19 ($arg !~ /^-(threads|-pthread|D|U|I|c|o)/ ||
20 $arg =~ /^-DPIC$/)) {
21 # Options that get here are not in the desiret set.
22 # Notably we drop "-fPIC" (some variant of which should probably
23 # also occur in an unsanitized section).
24 print STDERR "$0: warning dropping $arg\n";
25 next;
28 push @cmd, $arg;
29 if ($arg eq '-o') {
30 $target = shift @ARGV;
31 if ($target =~ /\.lo$/) {
32 $tmptarget = $target;
33 $tmptarget =~ s/\.lo$/-tmp.o/;
34 push @cmd, $tmptarget;
35 } else {
36 push @cmd, $target;
41 # Uncomment to force debug information
42 # push @cmd, '-g';
44 # print STDERR "# ", join (" ", @cmd), "\n";
45 system (@cmd);
47 my $code = $?;
48 if ($code != 0) {
49 unlink $tmptarget if defined $tmptarget;
50 unlink $target;
51 } elsif (defined $tmptarget) {
52 rename $tmptarget, $target;
54 exit $code >> 8;