diff options
author | Michael Haubenwallner <haubi@gentoo.org> | 2019-03-20 10:35:34 +0100 |
---|---|---|
committer | Sam James <sam@gentoo.org> | 2023-05-26 06:59:06 +0100 |
commit | a5921f9abc0ff4353907b5c4f879eeff2d0a696f (patch) | |
tree | 805883e57891911aa86c444233e3ef9bc1c11857 /prefix-stack-ccwrap | |
download | prefix-toolkit-a5921f9abc0ff4353907b5c4f879eeff2d0a696f.tar.gz prefix-toolkit-a5921f9abc0ff4353907b5c4f879eeff2d0a696f.tar.bz2 prefix-toolkit-a5921f9abc0ff4353907b5c4f879eeff2d0a696f.zip |
app-portage/prefix-toolkit: new packageprefix-toolkit-0
* For any Gentoo Prefix, provides the 'startprefix' script, and should
provide some 'runprefix' script later on, as inspired in
Bug: https://bugs.gentoo.org/673816
* For base Gentoo Prefix (as in "not stacked"), provides the
'prefix-stack-setup' script, superseding app-portage/prefix-chain-setup,
does force the prefix-stack implit USE flag in the stacked Prefix.
* For stacked Gentoo Prefix (set up using 'prefix-stack-setup'),
provides the toolchain wrapper, superseding sys-apps/prefix-chain-utils.
Bug: https://bugs.gentoo.org/658572
Closes: https://bugs.gentoo.org/509142
Package-Manager: Portage-2.3.51, Repoman-2.3.11
Signed-off-by: Michael Haubenwallner <haubi@gentoo.org>
(cherry picked from commit 84b9f582e8c8db69a3b3677de702c7cc00ac3dab)
Diffstat (limited to 'prefix-stack-ccwrap')
-rw-r--r-- | prefix-stack-ccwrap | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/prefix-stack-ccwrap b/prefix-stack-ccwrap new file mode 100644 index 0000000..93f7a82 --- /dev/null +++ b/prefix-stack-ccwrap @@ -0,0 +1,94 @@ +#!@GENTOO_PORTAGE_BPREFIX@/bin/bash + +if [ -r /cygdrive/. ]; then + winpath2unix() { cygpath -u "$1"; } + unixpath2win() { cygpath -w "$1"; } +fi + +myself=${0##*/} # basename $0 +link_dirs=() +opts=() +chost="@GENTOO_PORTAGE_CHOST@" +prefix="@GENTOO_PORTAGE_EPREFIX@" +absprefix=${prefix} +if [[ ${chost} == *"-winnt"* ]]; then + # we may get called from windows binary, like pkgdata in dev-libs/icu + # in this case, PATH elements get the "/dev/fs/C/WINDOWS/SUA" prefix + absprefix=$(winpath2unix "$(unixpath2win "${absprefix}")") +fi +[[ ${myself} == *windres* ]] && mode=compile || mode=link +orig_args=("$@") + +for opt in "$@" +do + case "$opt" in + -L) + link_dirs=("${link_dirs[@]}" "-L$1") + shift + ;; + -L*) + link_dirs=("${link_dirs[@]}" "${opt}") + ;; + *) + case "${opt}" in + -v) + # -v done right: only use mode version if -v is the _only_ + # argument on the command line. + [[ ${#orig_args[@]} -gt 1 ]] || mode=version + ;; + --version) mode=version ;; + -c|-E|-S) mode=compile ;; + -print-search-dirs) mode=dirs ;; + esac + opts=("${opts[@]}" "${opt}") + ;; + esac +done + +# remove any path to current prefix, need base prefix only +new_path= +save_ifs=$IFS +IFS=':' +for p in $PATH +do + IFS=$save_ifs + [[ ${p#${absprefix}} != "${p}" ]] && continue + if [[ -z "${new_path}" ]]; then + new_path="${p}" + else + new_path="${new_path}:${p}" + fi +done +IFS=$save_ifs + +PATH=${new_path} + +# binutils-config's ldwrapper understands '-R' for aix and hpux too. +# parity (winnt) understands -rpath only ... +case "${chost}" in +*-winnt*) rpath_opt="-Wl,-rpath," ;; +*) rpath_opt="-Wl,-R," ;; +esac + +pfx_link=("-L${prefix}/usr/lib" "-L${prefix}/lib") +pfx_link_r=("${rpath_opt}${prefix}/lib" "${rpath_opt}${prefix}/usr/lib") +pfx_comp=("-I${prefix}/include" "-I${prefix}/usr/include") + +# ensure we run the right chost program in base prefix +[[ ${myself} == *-*-*-* ]] || myself=${chost}-${myself#${chost}-} + +case "$mode" in +link) exec "${myself}" "${link_dirs[@]}" "${pfx_link[@]}" "${opts[@]}" "${pfx_comp[@]}" "${pfx_link_r[@]}" ;; +compile) exec "${myself}" "${link_dirs[@]}" "${opts[@]}" "${pfx_comp[@]}" ;; +version) exec "${myself}" "${orig_args[@]}" ;; +dirs) + "${myself}" "${orig_args[@]}" | while read line; do + if [[ "${line}" == "libraries: ="* ]]; then + echo "libraries: =${prefix}/usr/lib:${prefix}/lib:${line#"libraries: ="}" + else + echo "${line}" + fi + done + ;; +*) echo "cannot infer ${myself}'s mode from comamnd line arguments"; exit 1 ;; +esac |