summaryrefslogtreecommitdiff
path: root/util/collect2
blob: 864805335cd675dbba1e438a151a89439facf538 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/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}" | tr ':' $'\n'

            for DEP_NAME in libgcc sqlite3; do
                echo "$(PKG_DEST_ "${DEP_NAME}")"
            done
        } | while read -r path; do
            find "${path}" -name '*.dylib' -print0 | while read -r -d $'\0' dylib_file; do
                dylib_name=${dylib_file#${path}}
                echo -n " -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