summaryrefslogtreecommitdiff
path: root/exec.sh
blob: 8cfab11d75261e0993c323925c27e3577ac47f01 (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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/bin/bash
set -e
shopt -s extglob nullglob

export PKG_NAME=${1%_}
export PKG_BASE=$(realpath "$(dirname "$0")")
export PATH=${PKG_BASE}/util:$PATH
shift

source "${PKG_BASE}/helper.sh"
export PKG_TAPF=$(cat "${PKG_BASE}/arch/${PKG_ARCH}/${PKG_CFTARG}/prefix")

PKG_PATH=

PKG_INCL=
PKG_LIBS=
PKG_PKGS=

if [[ -n ${FAKEROOTKEY} ]]; then
    for i in "$(dirname $(which fakeroot))"/../lib{64,32,}/libfakeroot; do
        PKG_LIBS=$i:${PKG_LIBS}
    done
fi

case "${PKG_NAME}" in
    (-) deps=() ;;
    (:*) deps=(${PKG_NAME//:/ }) ;;
    (*) deps=($(find -L "${PKG_DATA}"/_metadata -name '*.dep' | sed -e 's/^.*\///' -e 's/\.dep$//' | sort -u)) ;;
esac

for dep in ${deps[@]}; do
    # XXX: bother dealing with weird arguments?
    #DEP_NAME=$(basename "${dep}" .dep)
    DEP_NAME=${dep}
    DEP_MORE=$(PKG_MORE_ "${DEP_NAME}")
    DEP_DEST=$(PKG_DEST_ "${DEP_NAME}")
    PKG_PATH=${PKG_PATH}:${DEP_DEST}

    if [[ -f "$(PKG_DATA_ ${DEP_NAME})/_metadata/exclude.${PKG_CFTARG}" ]]; then
		    continue
		fi

    if [[ -d ${DEP_DEST}${PKG_TAPF}/include ]]; then
        PKG_INCL=${DEP_DEST}${PKG_TAPF}/include:${PKG_INCL}
    fi

    if [[ -d ${DEP_DEST}${PKG_TAPF}/lib ]]; then
        PKG_LIBS=${DEP_DEST}${PKG_TAPF}/lib:${PKG_LIBS}
    fi

    if [[ -d ${DEP_DEST}${PKG_TAPF}/local/lib ]]; then
        PKG_LIBS=${DEP_DEST}${PKG_TAPF}/local/lib:${PKG_LIBS}
    fi

    if [[ -d ${DEP_MORE}${PKG_TAPF}/lib ]]; then
        PKG_LIBS=${DEP_MORE}${PKG_TAPF}/lib:${PKG_LIBS}
    fi

    if [[ -d ${DEP_DEST}${PKG_TAPF}/lib/pkgconfig ]]; then
        PKG_PKGS=${DEP_DEST}${PKG_TAPF}/lib/pkgconfig:${PKG_PKGS}
    fi

    if [[ -d ${DEP_DEST}${PKG_TAPF}/local/lib/pkgconfig ]]; then
        PKG_PKGS=${DEP_DEST}${PKG_TAPF}/local/lib/pkgconfig:${PKG_PKGS}
    fi
done

PKG_PATH=${PKG_PATH}:${PKG_ROOT}
export PKG_PATH=${PKG_PATH#:}

PKG_INCL=${PKG_INCL%:}
PKG_LIBS=${PKG_LIBS%:}
PKG_PKGS=${PKG_PKGS%:}

CODESIGN_ALLOCATE=$(which "${PKG_TARG}"-codesign_allocate) \
C_INCLUDE_PATH= \
COMPILER_PATH=${PKG_BASE}/util \
CPATH=/dat/git/iphone-api:${PKG_INCL} \
CPLUS_INCLUDE_PATH= \
LD_LIBRARY_PATH=${PKG_LIBS} \
LIBRARY_PATH=${PKG_LIBS} \
MIGCC=${PKG_TARG}-gcc \
PKG_CONFIG_PATH=${PKG_PKGS} \
LD_TWOLEVEL_NAMESPACE= \
    "$@"