bump product version to 7.2.5.1
[LibreOffice.git] / solenv / bin / macosx-change-install-names.pl
blob3d393a01235fecbc201edc793e736427e34600de
2 # This file is part of the LibreOffice project.
4 # This Source Code Form is subject to the terms of the Mozilla Public
5 # License, v. 2.0. If a copy of the MPL was not distributed with this
6 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 # This file incorporates work covered by the following license notice:
10 # Licensed to the Apache Software Foundation (ASF) under one or more
11 # contributor license agreements. See the NOTICE file distributed
12 # with this work for additional information regarding copyright
13 # ownership. The ASF licenses this file to you under the Apache
14 # License, Version 2.0 (the "License"); you may not use this file
15 # except in compliance with the License. You may obtain a copy of
16 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 # The install names of our dynamic libraries contain a special segment token
20 # that denotes where the dynamic library is located in the installation set.
21 # The segment token consists of "@", optionally followed by ".", followed by 50
22 # "_", followed by a location token (one of "URELIB", "OOO", "OXT", or "NONE").
24 # Typically, the segment token is the first segment of a relative install name.
25 # But the segment token may also appear within an absolute install name. That
26 # is useful when tunnelling the segment token into the external build process
27 # via a --prefix configure switch, for example.
29 # When another dynamic library or an executable links against such a dynamic
30 # library, the path recorded in the former to locate the latter is rewritten
31 # according to the below %action table. The result path consists of the prefix
32 # from the action table followed by the suffix of the dynamic library's install
33 # name. If the special segment token does not contain the optional "." after
34 # the "@", the suffix consists of all segments after the special token segment.
35 # If the special token segment does contain the optional ".", then the suffix
36 # consists of just the last segment of the original install name.
38 # That latter case is useful for libraries from external modules, where the
39 # external build process locates them in some sub-directory.
41 sub action($$$)
43 # The @__VIA_LIBRARY_PATH__ thing has no magic meaning anywhere
44 # (here in LO or to the dynamic linker), it is effectively a
45 # comment telling that this library is supposed to have been found
46 # by the dynamic linker already in DYLD_LIBRARY_PATH.
48 my %action =
49 ('app/UREBIN/URELIB' => '@executable_path/../Frameworks',
50 'app/OOO/URELIB' => '@executable_path/../Frameworks',
51 'app/OOO/OOO' => '@executable_path/../Frameworks',
52 'app/SDKBIN/URELIB' => '@__VIA_LIBRARY_PATH__',
53 'app/NONE/URELIB' => '@__VIA_LIBRARY_PATH__',
54 'app/NONE/OOO' => '@__VIA_LIBRARY_PATH__',
55 'app/NONE/NONE' => '@__VIA_LIBRARY_PATH__',
56 'shl/URELIB/URELIB' => '@loader_path',
57 'shl/OOO/URELIB' => '@loader_path',
58 'shl/OOO/OOO' => '@loader_path',
59 'shl/URELIB/OOO' => '@loader_path',
60 'shl/OXT/URELIB' => '@executable_path/urelibs',
61 'shl/NONE/URELIB' => '@__VIA_LIBRARY_PATH__',
62 'shl/NONE/OOO' => '@__VIA_LIBRARY_PATH__',
63 'shl/NONE/NONE' => '@loader_path');
64 my ($type, $loc1, $loc2) = @_;
65 my $act = $action{"$type/$loc1/$loc2"};
66 die "illegal combination $type/$loc1/$loc2" unless defined $act;
67 return $act;
70 @ARGV >= 2 or die 'Usage: app|shl UREBIN|URELIB|OOO|SDKBIN|OXT|NONE <filepath>*';
71 $type = shift @ARGV;
72 $loc = shift @ARGV;
73 foreach $file (@ARGV)
75 my $call = "otool -L $file";
76 open(IN, "-|", $call) or die "cannot $call";
77 my $change = "";
78 while (<IN>)
80 if (m'^\s*(((/.*)?/)?@_{50}([^/]+)(/.+)) \(compatibility version \d+\.\d+\.\d+, current version \d+\.\d+\.\d+\)\n$')
82 $change .= " -change $1 " . action($type, $loc, $4) . $5;
84 elsif (m'^\s*(((/.*)?/)?@\._{50}([^/]+)(/.+)?(/[^/]+)) \(compatibility version \d+\.\d+\.\d+, current version \d+\.\d+\.\d+\)\n$')
86 $change .= " -change $1 " . action($type, $loc, $4) . $6;
89 close(IN) or die "got $? from $call";
90 if ($change ne "")
92 $call = "$ENV{'INSTALL_NAME_TOOL'} $change $file";
93 system($call) == 0 or die "cannot $call";