diff options
Diffstat (limited to 'util/collect2')
-rwxr-xr-x | util/collect2 | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/util/collect2 b/util/collect2 new file mode 100755 index 000000000..30cacb773 --- /dev/null +++ b/util/collect2 @@ -0,0 +1,54 @@ +#!/bin/bash + +unset GCC_EXEC_PREFIX +unset COMPILER_PATH + +unset aspen_version_min +unset macosx_version_min +unset o + +#export | grep 'GCC\|PATH\|PKG' + +function parse() { + while [[ $# -ne 0 ]]; do + if [[ $1 = -maspen-version-min=* ]]; then + maspen_version_min=${1#-maspen-version-min=} + elif [[ $1 = -mmacosx-version-min=* ]]; then + mmacosx_version_min=${1#-mmacosx-version-min=} + elif [[ $1 == -o ]]; then + o=$2 + shift + fi; shift + done +} + +set -e + +eval "parse ${COLLECT_GCC_OPTIONS}" + +if [[ "${maspen_version_min+@}" || "${mmacosx_version_min+@}" ]]; then + darwin= +else + unset darwin +fi + +declare -a flags +if [[ "${darwin+@}" ]]; then + flags[${#flags[@]}]=-no_uuid + + if [[ "${PKG_PATH+@}" ]]; then + flags=("${flags[@]}"$(echo "${PKG_PATH}:" | while read -r -d ':' path; do + find "${path}" -name '*.dylib' -print0 | while read -r -d $'\0' dylib_file; do + dylib_name=${dylib_file#${path}} + echo " -dylib_file ${dylib_name}:${dylib_file}" + done + done)) + fi +fi + +#echo ::: "$("${COLLECT_GCC}" -print-prog-name=collect2)" "$@" "${flags[@]}" +"$("${COLLECT_GCC}" -print-prog-name=collect2)" "$@" "${flags[@]}" + +if [[ "${o+@}" && "${darwin+@}" ]]; then + ldid -T- "$o" +fi |