flag-dedup stable port information

Package: flag-dedup
Version: 0.2
Revision: 1
Description: Remove duplicate compiler flags
License: GPL
Maintainer: Benjamin Reed

BuildDepends: fink (>= 0.30.0-1)

Source: none
PatchFile: %n.patch
PatchFile-MD5: 1622940414256c3afb47b5cd49e0805a

UseMaxBuildJobs: true
CompileScript: #

InstallScript: <<
mkdir -p %i/bin
install -m755 flag-dedup %i/bin
<<

DescUsage: <<
flag-dedup [-v] CMD ARG1 ARG2 ...

The command CMD is launched with ARG1 ARG2 ... as arguments. The
arguments are de-duplicated so multiple compiler flags are reduced
to a single flag.

The -v flag causes flag-dedup to print the command that will be
launched and all the flags in order on STDOUT.
<<

flag-dedup stable port .patch

--- /dev/null 2011-05-14 23:17:03.000000000 -0400
+++ tmp/flag-dedup 2011-05-14 23:45:43.000000000 -0400
@@ -0,0 +1,57 @@
+#!/usr/bin/perl
+# -*- mode: Perl; tab-width: 4; -*-
+
+# A dirty hack by Benjamin Reed
+# Based on a dirty hack by Daniel Macks
+
+use warnings;
+use strict;
+
+my $verbose = 0;
+if (@ARGV && $ARGV[0] eq '-v') {
+ $verbose = 1;
+ shift;
+}
+
+if (!@ARGV) {
+ warn "Usage: $0 [-v] cmd [flags for cmd]\n";
+ warn " resort [flags for cmd] and call cmd with them\n";
+ warn " -v causes display of some diagnostics on STDOUT\n";
+ exit 1;
+}
+
+my @flag_prefixes = qw( -I -L -F -Wl -l -framework );
+
+# keep a list of seen flags
+my %existing_args = ();
+
+# what we will launch after organizing the flags
+my @subcmd = ();
+
+# separate the args according to flag
+my $skip_next = 0;
+while (@ARGV) {
+ if ($skip_next) {
+ $skip_next = 0;
+ next;
+ }
+ my $arg = shift @ARGV;
+ my($match) = grep { $arg =~ /^$_/ } @flag_prefixes;
+ if (defined $match) {
+ if ($match eq "-framework") {
+ $skip_next = 1;
+ $arg = "-Wl,-framework," . shift @ARGV;
+ }
+ # parsed off a known flag
+ if (not exists $existing_args{$arg}) {
+ push(@subcmd, $arg);
+ }
+ $existing_args{$arg}++;
+ } else {
+ # unhandled flag, add it
+ push(@subcmd, $arg);
+ }
+}
+
+print "$0: @subcmd\n" if $verbose;
+exec {$subcmd[0]} @subcmd or die "Could not exec $subcmd[0]: $!\n";

flag-dedup _unstable_ port .patch