update dev300-m58
[ooovba.git] / solenv / bin / macosx-change-install-names.pl
blobd10ff2e325aa9135d4711d3631a67d4c43d48f2b
1 #*************************************************************************
3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 #
5 # Copyright 2008 by Sun Microsystems, Inc.
7 # OpenOffice.org - a multi-platform office productivity suite
9 # $RCSfile: macosx-change-install-names.pl,v $
11 # $Revision: 1.6 $
13 # This file is part of OpenOffice.org.
15 # OpenOffice.org is free software: you can redistribute it and/or modify
16 # it under the terms of the GNU Lesser General Public License version 3
17 # only, as published by the Free Software Foundation.
19 # OpenOffice.org is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU Lesser General Public License version 3 for more details
23 # (a copy is included in the LICENSE file that accompanied this code).
25 # You should have received a copy of the GNU Lesser General Public License
26 # version 3 along with OpenOffice.org. If not, see
27 # <http://www.openoffice.org/license.html>
28 # for a copy of the LGPLv3 License.
30 #*************************************************************************
32 use lib ("$ENV{SOLARENV}/bin/modules");
33 use macosxotoolhelper;
35 sub action($$$)
37 my %action =
38 ('app/UREBIN/URELIB' => '@executable_path/../lib',
39 'app/OOO/URELIB' => '@executable_path/../ure-link/lib',
40 'app/OOO/OOO' => '@executable_path',
41 'app/SDK/URELIB' => '@executable_path/../../ure-link/lib',
42 'app/BRAND/URELIB' => '@executable_path/../basis-link/ure-link/lib',
43 'app/BRAND/OOO' => '@executable_path/../basis-link/program',
44 'app/NONE/URELIB' => '@__VIA_LIBRARY_PATH__',
45 'app/NONE/OOO' => '@__VIA_LIBRARY_PATH__',
46 'shl/URELIB/URELIB' => '@loader_path',
47 'shl/OOO/URELIB' => '@loader_path/../ure-link/lib',
48 'shl/OOO/OOO' => '@loader_path',
49 'shl/OXT/URELIB' => '@executable_path/urelibs');
50 my ($type, $loc1, $loc2) = @_;
51 my $act = $action{"$type/$loc1/$loc2"};
52 die "illegal combination $type/$loc/$2" unless defined $act;
53 return $act;
56 @ARGV == 3 || @ARGV >= 2 && $ARGV[0] eq "extshl" or die
57 'Usage: app|shl|extshl UREBIN|URELIB|OOO|SDK|BRAND|OXT|NONE <filepath>*';
58 $type = shift @ARGV;
59 $loc = shift @ARGV;
60 if ($type eq "extshl")
62 $type = "shl";
63 my $change = "";
64 my %inames;
65 foreach $file (@ARGV)
67 my $iname = otoolD($file);
68 (defined $iname ? $iname : $file . "\n") =~ m'^(.*?([^/]+))\n$' or
69 die "unexpected otool -D output";
70 $change .= " -change $1 " . action($type, $loc, $loc) . "/$2";
71 $inames{$file} = $2;
73 foreach $file (@ARGV)
75 my $call = "install_name_tool$change -id \@__________________________________________________$loc/$inames{$file} $file";
76 system($call) == 0 or die "cannot $call";
79 foreach $file (@ARGV)
81 my $call = "otool -L $file";
82 open(IN, "-|", $call) or die "cannot $call";
83 my $change = "";
84 while (<IN>)
86 $change .= " -change $1 " . action($type, $loc, $2) . "$3"
87 if m'^\s*(@_{50}([^/]+)(/.+)) \(compatibility version \d+\.\d+\.\d+, current version \d+\.\d+\.\d+\)\n$';
89 close(IN);
90 if ($change ne "")
92 $call = "install_name_tool$change $file";
93 system($call) == 0 or die "cannot $call";