File: perl-cc-wrapper

package info (click to toggle)
gnumeric 1.6.3-5.1%2Betch2
  • links: PTS
  • area: main
  • in suites: etch
  • size: 70,644 kB
  • ctags: 18,973
  • sloc: ansic: 204,271; xml: 47,128; sh: 8,917; makefile: 2,540; yacc: 1,137; perl: 179; python: 86
file content (39 lines) | stat: -rw-r--r-- 975 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
#!/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' && $ARGV[0] =~ /\.lo$/) {
	$target = $tmptarget = shift @ARGV;
	$tmptarget =~ s/\.lo$/-tmp.o/;
	push @cmd, $tmptarget;
    }
}

system (@cmd);
my $code = $?;
if (defined $tmptarget) {
    rename $tmptarget, $target;
}
exit $code;