toys/tools: . gcc.wrapper

sparky cvs at pld-linux.org
Sun Jul 30 22:08:37 CEST 2006


Author: sparky
Date: Sun Jul 30 22:08:35 2006
New Revision: 7563

Added:
   toys/tools/
   toys/tools/gcc.wrapper   (contents, props changed)
Log:
- wrapper for gcc, maybe will be usefull for someone


Added: toys/tools/gcc.wrapper
==============================================================================
--- (empty file)
+++ toys/tools/gcc.wrapper	Sun Jul 30 22:08:35 2006
@@ -0,0 +1,61 @@
+#!/usr/bin/perl
+#
+# Wrapper for gcc for detecting whether %{rpmcflags} and %{rpmldflags} are
+# passed.
+#
+# (c) 2006 PLD Linux Distribution
+# Licensed under GPL v2
+
+my $ldflags = "-Wl,--as-needed -Wl,-s";
+my $cflags = "-fno-align-loops -fno-align-jumps -fno-align-functions";
+
+my $link = 1;
+my $compile = 1;
+my $source = 0;
+
+FORARGS:
+foreach my $arg (@ARGV) {
+	foreach my $nocomp (qw(-E -MM --version -v -V -print-prog-name=ld conftest -print-search-dirs conftest conftest.o gcctest.c try.c --help --target-help)) {
+		if ($arg eq $nocomp) {
+			$link = 0;
+			$compile = 0;
+			last FORARGS;
+		}
+	}
+	if ($arg eq "-c" or $arg eq "-S") {
+		$link = 0;
+		next;
+	}
+	$source = 1 if $arg =~ /\.(c|cpp|cxx)$/;
+}
+$compile = 0 unless $source;
+
+(my $prog = $0) =~ s#.*/##;
+
+if ($link or $compile) {
+	(my $pwd = $ENV{PWD}) =~ s#.*BUILD/##;
+	my $args = join ' ', @ARGV;
+	if (length $ldflags and $link) {
+		unless ($args =~ /$ldflags/o) {
+			open PROBLEMS, ">> $ENV{HOME}/ldflags-problems"
+								or die "$!\n"; 
+			print PROBLEMS "LDFLAGS! $pwd: $args\n";
+			close PROBLEMS;
+		}
+	}
+	if (length $cflags and $compile) {
+		unless ($args =~ /$cflags/o) {
+			open PROBLEMS, ">> $ENV{HOME}/ldflags-problems"
+								or die "$!\n"; 
+			print PROBLEMS "CFLAGS! $pwd: $args\n";
+			close PROBLEMS;
+		}
+	}
+	unless ($prog eq "ppc-pld-linux-gcc" or $prog eq "ppc-pld-linux-g++") {
+		open PROBLEMS, ">> $ENV{HOME}/ldflags-problems" or die "$!\n"; 
+		print PROBLEMS "PROGRAM! $pwd: $0\n";
+		close PROBLEMS;
+	}
+}
+
+exec("/usr/bin/$prog.real", @ARGV);


More information about the pld-cvs-commit mailing list