diff options
author | Klaus Aehlig <klaus.aehlig@huawei.com> | 2023-09-27 17:04:45 +0200 |
---|---|---|
committer | Klaus Aehlig <klaus.aehlig@huawei.com> | 2023-09-28 12:58:09 +0200 |
commit | e19b55e9101b77146a9b71d3299097f6b23b0ea6 (patch) | |
tree | 99882b8e849a589882c76f0d7300934a72170e3b /CC/pkgconfig/add_rpath | |
parent | 7a7bdef2344c4982d35493a6ce8c5be7b9dfa812 (diff) | |
download | rules-cc-e19b55e9101b77146a9b71d3299097f6b23b0ea6.tar.gz |
["CC/pkgconfig", "system_library"] Add -rpath
When a shared library is picked up from the host system via pkg-config
that is located at a non-standard location, binaries linked against
this library by a standard linker either need LD_LIBRARY_PATH set
appropriately, or -rpath set at link time. However, not all custom
installations set -rpath in the link flags in their pkg-config file.
Therefore, in order to get working binaries (and not have to set
custom paths in tests), add a -rpath for every -L option found in
the ldflags provided by pkg-config.
Diffstat (limited to 'CC/pkgconfig/add_rpath')
-rwxr-xr-x | CC/pkgconfig/add_rpath | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/CC/pkgconfig/add_rpath b/CC/pkgconfig/add_rpath new file mode 100755 index 0000000..d020f2b --- /dev/null +++ b/CC/pkgconfig/add_rpath @@ -0,0 +1,24 @@ +#!/bin/sh +# Copyright 2023 Huawei Cloud Computing Technology Co., Ltd. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +for x in "$@" +do + echo -n '' "$x" + case $x in + -L*) echo -n '' -Xlinker -rpath -Xlinker "$(expr "$x" : "..\(.*\)")" + ;; + esac +done +echo |