summaryrefslogtreecommitdiffstats
path: root/make/xcodemake
blob: 2c6c1a80b2feff9cdc56643a3dbd47f232f1cea8 (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
86
87
88
89
90
91
92
#!/bin/sh
#

set -e

## This script is invoked by Xcode external targets.
##
## We must guarantee no jobserver is passed through since the file-descriptors
## have been clobbered by Xcode. If this is not done then make behaves as if
## it is allowed to run an infinite number of jobs.
##
MAKEFLAGS=
MFLAGS=

## re/configure if not configured by Xcode or if missing top-makefile
if [ $EXTERNAL_METHOD != 'xcode' -o ! -f $EXTERNAL_BUILD/GNUmakefile ]; then
    ## compute --arch value based on Xcode configuration naming convention
    case "$CONFIGURATION" in
    *.i386)
        arch="--arch=i386"
        ;;
    *.x86_64)
        arch="--arch=x86_64"
        ;;
    *.ppc)
        arch="--arch=ppc"
        ;;
    *.ppc64)
        arch="--arch=ppc64"
        ;;
    *)
        arch=
        ;;
    esac

    case "$CONFIGURATION" in
    debug*)
        debug="--debug=max"
        ;;
    *)
        debug=
        ;;
    esac

    ## invoke configure with (hidden) option which indicates conf performed by xcode
    $EXTERNAL_SRC/configure --force --build=$EXTERNAL_BUILD $arch $debug \
        --conf-method=xcode PATH=$PATH $EXTERNAL_CONFARGS
fi

## safeguard against passing blank value which would result in unlimited jobs
if [ -z "$EXTERNAL_JOBS" ]; then
    jobs=
else
    jobs=--jobs=$EXTERNAL_JOBS
fi

spec="$TARGET_NAME:$ACTION"
echo "env specification: $spec"

## compute goals
case "$spec" in
    contrib:clean)
        goals=contrib.xclean
        ;;
    contrib:*)
        goals=contrib.install
        ;;
    external:clean)
        goals=clean
        ;;
    external:*)
        if [ -z "$EXTERNAL_GOALS" ]; then
            goals=build
        else
            goals="$EXTERNAL_GOALS"
        fi
        ;;
    libhb:clean)
        goals=libhb.clean
        ;;
    libhb:*)
        goals=libhb.build
        ;;
    *)
        echo "ERROR: invalid env specification: $spec"
        exit 1
        ;;
esac

## handoff
set -x
make -C $EXTERNAL_BUILD BUILD.method=xcode $jobs $goals $EXTERNAL_VARS