aboutsummaryrefslogtreecommitdiff
path: root/configure
blob: f809420154f37425eeba0c1a0236754788e10355 (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
93
94
95
96
97
98
99
100
101
#!/bin/bash

cc=gcc
ld=ld
objcopy=objcopy
ar=ar

usage() {
    cat <<-EOF
	Usage: $0 [options]

	Options include:
	    --arch=ARCH             Architecture: arm or aarch64
	    --plat=PLATFORM         Platform: virt or vexpress-a15
	    --cpu=PROCESSOR         CPU: cortex-a15 or cortex-a57
	    --cross-prefix=PREFIX   Cross compiler
	    --cc=CC                 C compiler to use (blank is auto)
	    --ld=LD                 Loader to use (blank is auto)
EOF
    exit 1
}

while [[ "$1" = -* ]]; do
    opt="$1"; shift
    arg=
    if [[ "$opt" = *=* ]]; then
	arg="${opt#*=}"
	opt="${opt%%=*}"
    fi
    case "$opt" in
    --arch)
	    arch="$arg"
	    ;;
    --plat)
	    plat="$arg"
	    ;;
    --cpu)
	    cpu="$arg"
	    ;;
	--cross-prefix)
	    cross_prefix="$arg"
	    ;;
	--cc)
	    cc="$arg"
	    ;;
	--ld)
	    ld="$arg"
	    ;;
	--help)
	    usage
	    ;;
	*)
	    usage
	    ;;
    esac
done

if [ -z "$arch" ]; then
    cat <<-EOF
	An architecture must be specified.  Either "--arch=arm" or "--arch=aarch64".
EOF
    exit 1

fi

if [ -z "$cpu" ]; then
    if [ "$arch" = "arm" ]; then
        cpu="cortex-a15"
    elif [ "$arch" = "aarch64" ]; then
        cpu="cortex-a57"
    fi
fi

if [ -z "$plat" ]; then
    plat="virt"
fi

if [ -z "$cross" ]; then
    if [ "$arch" = "arm" ]; then
        cross="arm-linux-gnueabi"
    elif [ "$arch" = "aarch64" ]; then
        cross="aarch64-linux-gnu"
    fi
fi

if [ "$arch" = "arm" ]; then
    cflags="-m$arch -mcpu=$cpu"
fi

# create the config
cat <<EOF > config.mk
export ARCH=$arch
export PLAT=$plat
export PROCESSOR=$cpu
export CROSS=$cross
export CC=$cross-$cc
export LD=$cross-$ld
export OBJCOPY=$cross-$objcopy
export AR=$cross-$ar
export CFLAGS+=$cflags
EOF