delibtoolize.pl revision 851
4249c36b4ab4024464db91e2606f651f3b20c1e5nd# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
4249c36b4ab4024464db91e2606f651f3b20c1e5nd# Use is subject to license terms.
4249c36b4ab4024464db91e2606f651f3b20c1e5nd# Permission is hereby granted, free of charge, to any person obtaining a
4249c36b4ab4024464db91e2606f651f3b20c1e5nd# copy of this software and associated documentation files (the
4249c36b4ab4024464db91e2606f651f3b20c1e5nd# "Software"), to deal in the Software without restriction, including
4249c36b4ab4024464db91e2606f651f3b20c1e5nd# without limitation the rights to use, copy, modify, merge, publish,
4249c36b4ab4024464db91e2606f651f3b20c1e5nd# distribute, and/or sell copies of the Software, and to permit persons
4249c36b4ab4024464db91e2606f651f3b20c1e5nd# to whom the Software is furnished to do so, provided that the above
4249c36b4ab4024464db91e2606f651f3b20c1e5nd# copyright notice(s) and this permission notice appear in all copies of
4249c36b4ab4024464db91e2606f651f3b20c1e5nd# the Software and that both the above copyright notice(s) and this
4249c36b4ab4024464db91e2606f651f3b20c1e5nd# permission notice appear in supporting documentation.
4249c36b4ab4024464db91e2606f651f3b20c1e5nd# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
4249c36b4ab4024464db91e2606f651f3b20c1e5nd# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
4249c36b4ab4024464db91e2606f651f3b20c1e5nd# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
4249c36b4ab4024464db91e2606f651f3b20c1e5nd# OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
4249c36b4ab4024464db91e2606f651f3b20c1e5nd# HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
4249c36b4ab4024464db91e2606f651f3b20c1e5nd# INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
4249c36b4ab4024464db91e2606f651f3b20c1e5nd# FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
4249c36b4ab4024464db91e2606f651f3b20c1e5nd# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
4249c36b4ab4024464db91e2606f651f3b20c1e5nd# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
4249c36b4ab4024464db91e2606f651f3b20c1e5nd# Except as contained in this notice, the name of a copyright holder
4249c36b4ab4024464db91e2606f651f3b20c1e5nd# shall not be used in advertising or otherwise to promote the sale, use
4249c36b4ab4024464db91e2606f651f3b20c1e5nd# or other dealings in this Software without prior written authorization
4249c36b4ab4024464db91e2606f651f3b20c1e5nd# of the copyright holder.
4249c36b4ab4024464db91e2606f651f3b20c1e5nd# ident "@(#)delibtoolize.pl 1.15 09/12/05 SMI"
4249c36b4ab4024464db91e2606f651f3b20c1e5nd# Undo libtool damage to makefiles to allow us to control the linker
4249c36b4ab4024464db91e2606f651f3b20c1e5nd# settings that libtool tries to force on us.
4249c36b4ab4024464db91e2606f651f3b20c1e5nd# Usage: delibtoolize.pl [-P] <path>
4249c36b4ab4024464db91e2606f651f3b20c1e5nd# -P - Use large pic flags (-KPIC/-fPIC) instead of default/small (-Kpic/-fpic)
4249c36b4ab4024464db91e2606f651f3b20c1e5nd# -s - Only track libraries from a single file at a time, instead of across all
4249c36b4ab4024464db91e2606f651f3b20c1e5nd# files in a project
4249c36b4ab4024464db91e2606f651f3b20c1e5nduse strict;
4249c36b4ab4024464db91e2606f651f3b20c1e5nduse warnings;
4249c36b4ab4024464db91e2606f651f3b20c1e5nduse integer;
4249c36b4ab4024464db91e2606f651f3b20c1e5ndmy %compiler_sharedobj_flags = ( 'cc' => '-G -z allextract',
4249c36b4ab4024464db91e2606f651f3b20c1e5nd if ($_ eq 'Makefile' && -f $_) {
4249c36b4ab4024464db91e2606f651f3b20c1e5nd or die "Can't open $old_file for reading: $!\n";
4249c36b4ab4024464db91e2606f651f3b20c1e5nd # Read in original file and preprocess for data we'll need later
4249c36b4ab4024464db91e2606f651f3b20c1e5nd my $l = "";
4249c36b4ab4024464db91e2606f651f3b20c1e5nd while (my $n = <$OLD>) {
4249c36b4ab4024464db91e2606f651f3b20c1e5nd # handle line continuation
4249c36b4ab4024464db91e2606f651f3b20c1e5nd next if ($n =~ m/\\$/);
4249c36b4ab4024464db91e2606f651f3b20c1e5nd # Save macros for later expansion if needed
4249c36b4ab4024464db91e2606f651f3b20c1e5nd if ($l =~ m/^([^\#\s]*)\s*=\s*(.*)\s*/ms) {
4249c36b4ab4024464db91e2606f651f3b20c1e5nd if ($l =~ m/^([^\#\s]*)_la_LDFLAGS\s*=(.*)/ms) {
4249c36b4ab4024464db91e2606f651f3b20c1e5nd elsif ($l =~ m/^[^\#\s]*_LTLIBRARIES\s*=(.*)$/ms) {
4249c36b4ab4024464db91e2606f651f3b20c1e5nd close($OLD) or die;
4249c36b4ab4024464db91e2606f651f3b20c1e5nd if ($flags =~ m/[\b\s]-version-(number|info)\s+(\S+)/ms) {
4249c36b4ab4024464db91e2606f651f3b20c1e5nd my $v = $2;
4249c36b4ab4024464db91e2606f651f3b20c1e5nd if (($vtype eq "info") && ($v =~ m/^(\d+):\d+:(\d+)$/ms)) {
4249c36b4ab4024464db91e2606f651f3b20c1e5nd } elsif ($v =~ m/^(\d+)[:\d]*$/ms) {
4249c36b4ab4024464db91e2606f651f3b20c1e5nd# print "Set version to $so_versions{$ln} for $ln.\n";
4249c36b4ab4024464db91e2606f651f3b20c1e5nd my ($filename) = @_;
4249c36b4ab4024464db91e2606f651f3b20c1e5nd print "delibtoolizing $filename...\n";
4249c36b4ab4024464db91e2606f651f3b20c1e5nd die "Can't rename $new_file to $old_file: $!\n";
4249c36b4ab4024464db91e2606f651f3b20c1e5nd or die "Can't open $old_file for reading: $!\n";
4249c36b4ab4024464db91e2606f651f3b20c1e5nd or die "Can't open $new_file for writing: $!\n";
4249c36b4ab4024464db91e2606f651f3b20c1e5nd # Read in original file and preprocess for data we'll need later
4249c36b4ab4024464db91e2606f651f3b20c1e5nd my $l = "";
4249c36b4ab4024464db91e2606f651f3b20c1e5nd while (my $n = <$OLD>) {
4249c36b4ab4024464db91e2606f651f3b20c1e5nd # handle line continuation
4249c36b4ab4024464db91e2606f651f3b20c1e5nd next if ($n =~ m/\\$/);
4249c36b4ab4024464db91e2606f651f3b20c1e5nd if ($l =~ m/^\s*CC\s*=(?:.*\s+)?(\S+)/) {
4249c36b4ab4024464db91e2606f651f3b20c1e5nd close($OLD) or die;
foreach $l (@inlines) {
$l =~ s{\$\(LIBTOOL\)
(?:[\\\s]+ \$\(LT_QUIET\))?
(?:[\\\s]+ \$\(AM_V_lt\))?
$l =~ s{\$\(LIBTOOL\)
(?:[\\\s]+ \$\(LT_QUIET\))?
(?:[\\\s]+ \$\(AM_V_lt\))?
[\\\s]+ --mode=link
}{}xs;
if ($l =~ m/_la_LDFLAGS\s*=/) {
if ($single_file) {
so=$${p%+(.+(\d))} ; \
fi; \
$l .= $installrule;
if ($curtarget =~ m/^.*\.a$/) {
close($NEW) or die;