1cdf0e10cSrcweir: 2cdf0e10cSrcweireval 'exec perl -wS $0 ${1+"$@"}' 3cdf0e10cSrcweir if 0; 4*7e90fac2SAndrew Rist#************************************************************** 5*7e90fac2SAndrew Rist# 6*7e90fac2SAndrew Rist# Licensed to the Apache Software Foundation (ASF) under one 7*7e90fac2SAndrew Rist# or more contributor license agreements. See the NOTICE file 8*7e90fac2SAndrew Rist# distributed with this work for additional information 9*7e90fac2SAndrew Rist# regarding copyright ownership. The ASF licenses this file 10*7e90fac2SAndrew Rist# to you under the Apache License, Version 2.0 (the 11*7e90fac2SAndrew Rist# "License"); you may not use this file except in compliance 12*7e90fac2SAndrew Rist# with the License. You may obtain a copy of the License at 13*7e90fac2SAndrew Rist# 14*7e90fac2SAndrew Rist# http://www.apache.org/licenses/LICENSE-2.0 15*7e90fac2SAndrew Rist# 16*7e90fac2SAndrew Rist# Unless required by applicable law or agreed to in writing, 17*7e90fac2SAndrew Rist# software distributed under the License is distributed on an 18*7e90fac2SAndrew Rist# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 19*7e90fac2SAndrew Rist# KIND, either express or implied. See the License for the 20*7e90fac2SAndrew Rist# specific language governing permissions and limitations 21*7e90fac2SAndrew Rist# under the License. 22*7e90fac2SAndrew Rist# 23*7e90fac2SAndrew Rist#************************************************************** 24*7e90fac2SAndrew Rist 25*7e90fac2SAndrew Rist 26cdf0e10cSrcweir 27cdf0e10cSrcweir$ENV{'LC_MESSAGES'} = 'C'; 28cdf0e10cSrcweir 29cdf0e10cSrcweir$Dest = pop(@ARGV) || die "No destination to copy to"; 30cdf0e10cSrcweir 31cdf0e10cSrcweir$cc = $ENV{'CC'} || die "No CC environment set"; 32cdf0e10cSrcweir 33cdf0e10cSrcweirif ($Dest =~ /--help/ || @ARGV < 1) { 34cdf0e10cSrcweir print "Syntax:\n gcc-instlib <library-in-libpath ...> <destination-dir>\n"; 35cdf0e10cSrcweir exit (0); 36cdf0e10cSrcweir} 37a6bbe7eeSEike Rathke 38a6bbe7eeSEike Rathke%SrcAndDest = (); 39a6bbe7eeSEike Rathke 40cdf0e10cSrcweirforeach $File (@ARGV) { 41cdf0e10cSrcweir my $string; 42a6bbe7eeSEike Rathke my $normalized_file = $File; 43a6bbe7eeSEike Rathke $normalized_file =~ s/\.so\.\d+/.so/; 44a6bbe7eeSEike Rathke open (GCCOut, "LANGUAGE=C LC_ALL=C $cc -print-file-name=$normalized_file|") || die "Failed to exec $cc -print-file-name=$normalized_file $!"; 45cdf0e10cSrcweir $string=<GCCOut>; 46cdf0e10cSrcweir chomp ($string); 47a6bbe7eeSEike Rathke $SrcAndDest{$string} = "$Dest/$File"; 48cdf0e10cSrcweir close (GCCOut); 49cdf0e10cSrcweir} 50cdf0e10cSrcweir 51a6bbe7eeSEike Rathkewhile (($Src, $FullDest) = each %SrcAndDest) { 52a6bbe7eeSEike Rathke printf "copy $Src to $FullDest\n"; 53a6bbe7eeSEike Rathke system ("/bin/cp $Src $FullDest") && die "copy failed: $!"; 54cdf0e10cSrcweir} 55cdf0e10cSrcweir 56cdf0e10cSrcweir 57cdf0e10cSrcweirforeach $File (@ARGV) { 58cdf0e10cSrcweir #https://bugzilla.redhat.com/show_bug.cgi?id=149465 59cdf0e10cSrcweir printf "unprelinking $Dest/$File\n"; 60cdf0e10cSrcweir #If it's already unprelinked .i.e. no .gnu.prelink_undo section, that's fine 61cdf0e10cSrcweir #If prelink is not installed, it's massively unlikely that it's prelinked 62cdf0e10cSrcweir system ("prelink -u $Dest/$File > /dev/null 2>&1"); 63cdf0e10cSrcweir} 64cdf0e10cSrcweir 65cdf0e10cSrcweirexit (0); 66