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 my $OLD = $ENV{ENABLE_MACOSX_MACLIKE_APP_STRUCTURE
} ne 'TRUE';
45 # The @__VIA_LIBRARY_PATH__ thing has no magic meaning anywhere
46 # (here in LO or to the dynamic linker), it is effectively a
47 # comment telling that this library is supposed to have been found
48 # by the dynamic linker already in DYLD_LIBRARY_PATH.
51 ('app/UREBIN/URELIB' => ($OLD ?
'@executable_path/../lib' : '@executable_path/../Frameworks'),
52 'app/OOO/URELIB' => ($OLD ?
'@executable_path/../ure-link/lib' : '@executable_path/../Frameworks'),
53 'app/OOO/OOO' => ($OLD ?
'@executable_path' : '@executable_path/../Frameworks'),
54 'app/SDKBIN/URELIB' => ($OLD ?
'@executable_path/../../ure-link/lib' : '@executable_path/../Frameworks'),
55 'app/NONE/URELIB' => '@__VIA_LIBRARY_PATH__',
56 'app/NONE/OOO' => '@__VIA_LIBRARY_PATH__',
57 'app/NONE/NONE' => '@__VIA_LIBRARY_PATH__',
58 'shl/URELIB/URELIB' => '@loader_path',
59 'shl/OOO/URELIB' => ($OLD ?
'@loader_path/../ure-link/lib' : '@loader_path'),
60 'shl/OOO/OOO' => '@loader_path',
61 'shl/OXT/URELIB' => ($OLD ?
'@executable_path/urelibs' : '@executable_path/../Frameworks'),
62 'shl/NONE/URELIB' => '@__VIA_LIBRARY_PATH__',
63 'shl/NONE/OOO' => '@__VIA_LIBRARY_PATH__',
64 'shl/NONE/NONE' => '@loader_path');
65 my ($type, $loc1, $loc2) = @_;
66 my $act = $action{"$type/$loc1/$loc2"};
67 die "illegal combination $type/$loc1/$loc2" unless defined $act;
71 @ARGV >= 2 or die 'Usage: app|shl UREBIN|URELIB|OOO|SDKBIN|OXT|NONE <filepath>*';
76 my $call = "otool -L $file";
77 open(IN
, "-|", $call) or die "cannot $call";
81 if (m
'^\s*(((/.*)?/)?@_{50}([^/]+)(/.+)) \(compatibility version \d+\.\d+\.\d+, current version \d+\.\d+\.\d+\)\n$')
83 $change .= " -change $1 " . action
($type, $loc, $4) . $5;
85 elsif (m
'^\s*(((/.*)?/)?@\._{50}([^/]+)(/.+)?(/[^/]+)) \(compatibility version \d+\.\d+\.\d+, current version \d+\.\d+\.\d+\)\n$')
87 $change .= " -change $1 " . action
($type, $loc, $4) . $6;
90 close(IN
) or die "got $? from $call";
93 $call = "$ENV{'INSTALL_NAME_TOOL'} $change $file";
94 system($call) == 0 or die "cannot $call";