From 7c4f2ec8a795534164ee1923093b7d5be0126c55 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Wed, 29 Feb 2012 18:34:42 +0100 Subject: Simplify install name handling for external libraries on Mac OS X ...by allowing our special @___... tokens anywhere within an install name, so that external modules can configure --prefix=/@___... etc. This removes the need for the special extshl and EXTRPATH=LOADER. Also, a new OUT2BIN_NONE can be used for external modules where the generated libraries need the default EXTRPATH=OOO, but generated executables are only used during the build and such need RPATH=NONE. --- solenv/bin/macosx-change-install-names.pl | 76 +++++++++++++------------------ 1 file changed, 31 insertions(+), 45 deletions(-) (limited to 'solenv/bin/macosx-change-install-names.pl') diff --git a/solenv/bin/macosx-change-install-names.pl b/solenv/bin/macosx-change-install-names.pl index 290a488342b1..91bea7e165c1 100644 --- a/solenv/bin/macosx-change-install-names.pl +++ b/solenv/bin/macosx-change-install-names.pl @@ -25,8 +25,27 @@ # #************************************************************************* -use lib ("$ENV{SOLARENV}/bin/modules"); -use macosxotoolhelper; +# The install names of our dynamic libraries contain a special segment token +# that denotes where the dynamic library is located in the installation set. +# The segment token consists of "@", optionally followed by ".", followed by 50 +# "_", followed by a location token (one of "URELIB", "OOO", "OXT", or "NONE"). +# +# Typically, the segment token is the first segment of a relative install name. +# But the segment token may also appear within an absolute install name. That +# is useful when tunnelling the segment token into the external build process +# via a --prefix configure switch, for example. +# +# When another dynamic library or an executable links against such a dynamic +# library, the path recorded in the former to locate the latter is rewritten +# according to the below %action table. The result path consists of the prefix +# from the action table followed by the suffix of the dynamic library's install +# name. If the special segment token does not contain the optional "." after +# the "@", the suffix consists of all segments after the special token segment. +# If the special token segment does contain the optional ".", then the suffix +# consists of just the last segment of the original install name. +# +# That latter case is useful for libraries from external modules, where the +# external build process locates them in some sub-directory. sub action($$$) { @@ -41,8 +60,6 @@ sub action($$$) 'shl/URELIB/URELIB' => '@loader_path', 'shl/OOO/URELIB' => '@loader_path/../ure-link/lib', 'shl/OOO/OOO' => '@loader_path', - 'shl/LOADER/LOADER' => '@loader_path', - 'shl/LOADER/URELIB' => '@loader_path/../ure-link/lib', 'shl/OXT/URELIB' => '@executable_path/urelibs', 'shl/NONE/URELIB' => '@__VIA_LIBRARY_PATH__', 'shl/OOO/NONE' => '@__VIA_LIBRARY_PATH__', @@ -54,52 +71,17 @@ sub action($$$) return $act; } -@ARGV == 3 || @ARGV >= 2 && $ARGV[0] eq "extshl" or die - 'Usage: app|shl|extshl UREBIN|URELIB|OOO|SDK|OXT|NONE|LOADER *'; +@ARGV >= 2 or die 'Usage: app|shl UREBIN|URELIB|OOO|SDK|OXT|NONE *'; $type = shift @ARGV; $loc = shift @ARGV; -if ($type eq "SharedLibrary") -{ - $type = "shl"; -} if ($type eq "Executable") { $type = "app" } -if ($type eq "Library") +elsif ($type eq "Library" || $type eq "SharedLibrary") { $type = "shl" } -if ($type eq "extshl") -{ - $type = "shl"; - my $change = ""; - my %inames; - foreach $file (@ARGV) - { - my $iname = otoolD($file); - (defined $iname ? $iname : $file . "\n") =~ m'^(.*?([^/]+))\n$' or - die "unexpected otool -D output"; - $change .= " -change $1 " . action($type, $loc, $loc) . "/$2"; - $inames{$file} = $2; - } - if( $loc eq "LOADER" ) - { - foreach $file (@ARGV) - { - my $call = "install_name_tool$change -id \@loader_path/$inames{$file} $file"; - system($call) == 0 or die "cannot $call"; - } - } - else - { - foreach $file (@ARGV) - { - my $call = "install_name_tool$change -id \@__________________________________________________$loc/$inames{$file} $file"; - system($call) == 0 or die "cannot $call"; - } - } -} foreach $file (@ARGV) { my $call = "otool -L $file"; @@ -107,10 +89,14 @@ foreach $file (@ARGV) my $change = ""; while () { - $change .= " -change $1 " . action($type, $loc, $2) . "$3" - if m'^\s*(@_{50}([^/]+)(/.+)) \(compatibility version \d+\.\d+\.\d+, current version \d+\.\d+\.\d+\)\n$'; - $change .= ' -change '.$1.' @loader_path/'.$2 - if m'^\s*(/python-inst/(OOoPython.framework/Versions/[^/]+/OOoPython))'; + if (m'^\s*(((/.*)?/)?@_{50}([^/]+)(/.+)) \(compatibility version \d+\.\d+\.\d+, current version \d+\.\d+\.\d+\)\n$') + { + $change .= " -change $1 " . action($type, $loc, $4) . $5; + } + elsif (m'^\s*(((/.*)?/)?@\._{50}([^/]+)(/.+)?(/[^/]+)) \(compatibility version \d+\.\d+\.\d+, current version \d+\.\d+\.\d+\)\n$') + { + $change .= " -change $1 " . action($type, $loc, $4) . $6; + } } close(IN); if ($change ne "") -- cgit