diff -Nurd -x'*~' pkgconfig-common-2.orig/pc-resort pkgconfig-common-2/pc-resort
--- pkgconfig-common-2.orig/pc-resort	1969-12-31 19:00:00.000000000 -0500
+++ pkgconfig-common-2/pc-resort	2014-06-04 14:30:43.000000000 -0400
@@ -0,0 +1,51 @@
+#!/usr/bin/perl
+
+use warnings;
+use strict;
+
+use constant FINK_PREFIX => '@PREFIX@';  # for flag-sorting precedence
+my $real_prog = "$0.real"; # the wrapped program
+
+open my $pc_program, '-|', $real_prog, @ARGV
+    or die "$0: failed to open actual pkg-config process ($real_prog): $!\n";
+while (defined ($_=<$pc_program>) ) {
+    print &resort($_);
+}
+close $pc_program;
+my $rc = $? >> 8;
+exit $rc;
+
+sub resort {
+    my $line = shift;
+
+    # skip obvious pkg-config diagnostics (iff --errors-to-stdout)
+    return $line if /^\s/;
+
+    # if no flags, then nothing to resort
+    return $line unless /(\a|\s)-/;
+
+    chomp $line;
+
+    # for teasing apart the -I nd -L flag lists
+    my @flags_special;		# unusual places that mask fink
+    my @flags_fink;		# %p (masks apple and x11)
+    my @flags_system;		# apple and x11
+    my @flags_other;		# flags other than -I or -L
+
+    #for now, don't try to handle quotes/embedded-whitespace paths
+    foreach (split /\s+/, $line) {
+	# figure out the priority of each -I or -L flag
+	if (/^-[IL]FINK_PREFIX/) {
+	    push @flags_fink, $_;
+	} elsif (/^-[IL]\/(usr\/lib|usr\/include|usr\/X11|opt\/X11)/) {
+	    push @flags_system, $_;
+	} elsif (/^-[IL]/) {
+	    push @flags_special, $_;
+	} else {
+	    push @flags_other, $_;
+	}
+    }
+ 
+    my $sane_line = join ' ', @flags_special, @flags_fink, @flags_system, @flags_other;
+    return $sane_line . "\n";
+}