make clean does not work in OpenSource, fails in WebKitLibraries
https://bugs.webkit.org/show_bug.cgi?id=135734

Patch by Joseph Pecoraro <pecoraro@apple.com> on 2014-08-08
Reviewed by David Kilzer.

Tools:

* Scripts/copy-webkitlibraries-to-product-directory:
Add a --clean switch that removes possible WebKitSystemInterface
and LLVM libraries and headers that may have been copied to the
product directory.

WebKitLibraries:

* Makefile:
Add a "clean" target that runs copy-webkitlibraries-to-product-dir
with the new --clean switch.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@172349 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Tools/Scripts/copy-webkitlibraries-to-product-directory b/Tools/Scripts/copy-webkitlibraries-to-product-directory
index 7fbd81e..c860192 100755
--- a/Tools/Scripts/copy-webkitlibraries-to-product-directory
+++ b/Tools/Scripts/copy-webkitlibraries-to-product-directory
@@ -33,6 +33,7 @@
 my $showHelp = 0;
 my $llvm = 0;
 my $wksi = 0;
+my $clean = 0;
 my $llvmIncludePackage = "";
 my $llvmLibraryPackage = "";
 my $useFullLibPaths = 0;
@@ -49,6 +50,7 @@
   --help                        Show this help message
   --[no-]llvm                   Toggle copying LLVM drops (default: $llvm)
   --[no-]wksi                   Toggle copying WebKitSystemInterface drops (default: $wksi)
+  --clean                       Clean the libraries (default: $clean)
   --use-llvm-includes=<path>    Get the LLVM inludes package from <path>
   --use-llvm-libraries=<path>   Get the LLVM libraries package from <path>
   --[no-]use-full-lib-paths     Toggle using full library paths
@@ -64,6 +66,7 @@
     'help' => \$showHelp,
     'llvm!' => \$llvm,
     'wksi!' => \$wksi,
+    'clean' => \$clean,
     'use-llvm-includes=s' => \$llvmIncludePackage,
     'use-llvm-libraries=s' => \$llvmLibraryPackage,
     'use-full-lib-paths!' => \$useFullLibPaths,
@@ -302,3 +305,12 @@
     }
 }
 
+if ($clean) {
+    print "Cleaning.\n";    
+    (system("rm", "-rf", "$productDir/usr/local/include/WebKitSystemInterface.h") == 0) or die;
+    (system("rm", "-rf", "$productDir$llvmPrefix") == 0) or die;
+    unlink glob "$productDir/libWebKitSystemInterface*" or die if glob "$productDir/libWebKitSystemInterface*";
+    unlink glob "$productDir/usr/local/lib/libWebKitSystemInterface*" or die if glob "$productDir/usr/local/lib/libWebKitSystemInterface*";
+    unlink glob "$productDir/libLLVM*" or die if glob "$productDir/libLLVM*";
+    unlink glob "$productDir/libLTO*" or die if glob "$productDir/libLTO*";
+}