-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·112 lines (97 loc) · 2.15 KB
/
configure
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
102
103
104
105
106
107
108
109
110
111
112
#!/usr/bin/env bash
rootdir=$(cd "$(dirname "$0")"; pwd)
libdir=$(cd "${rootdir}/src/lib"; pwd)
exampledir=$(cd "${rootdir}/examples"; pwd)
checkdir=$(cd "${rootdir}/src/casemate-check-c"; pwd)
cc='clang'
ld='ld'
objdump='objdump'
objcopy='objcopy'
casemate_o="${libdir}/casemate.o"
casemate_h="${libdir}/casemate.h"
lib_includes="${libdir}/include"
arch=`uname -m`
cross_prefix=
clangd=1
usage() {
echo "Usage $0 [OPTIONS]";
echo
echo "Options:";
echo " -h --help print this help";
echo " --cross-prefix=PREFIX compilation tool prefix";
echo " --cc=CC compiler";
echo " --ld=LD linker";
echo " --arch=ARCH machine architecture (aarch64 or x86)";
echo " --[no-]clangd force enable/disable clangd targets";
}
# collect all the -arg and --args
while [[ "$1" = -* ]]; do
opt="$1"; shift
arg=
if [[ "$opt" = *=* ]]; then
arg="${opt#*=}";
opt="${opt%%=*}";
fi
case "$opt" in
--cross-prefix)
cross_prefix="$arg"
;;
--arch)
arch="$arg"
;;
--cc)
cc="$arg"
;;
--ld)
ld="$arg"
;;
--clangd)
clangd=1
;;
--no-clangd)
clangd=
;;
-h|--help)
usage
exit 0
;;
*)
usage
exit 1
;;
esac
done
tool_prefix=${cross_prefix}
cc=${tool_prefix}${cc}
ld=${tool_prefix}${ld}
objcopy=${tool_prefix}${objcopy}
objdump=${tool_prefix}${objdump}
# normalise arch name
[ "$arch" = "arm64" ] && arch="aarch64"
[ "$arch" = "i386" ] && arch="x86"
[ "$arch" = "i686" ] && arch="x86"
[ "$arch" = "x86_64" ] && arch="x86"
arch_name=
if [ "$arch" = "aarch64" ]; then
arch_name="AARCH64";
elif [ "$arch" = "x86" ]; then
arch_name="X86";
else
echo "unknown architecture '${arch}'"
exit 1
fi
cat <<EOF > config.mk
# Auto-generated, see ./configure script.
root = ${rootdir}
CC = ${cc}
LD = ${ld}
OBJDUMP = ${objdump}
OBJCOPY = ${objcopy}
ARCH = ${arch_name}
CFLAGS = -Wall -MD -g -gdwarf-4 -D__${arch_name}__
LDFLAGS =
CLANGD = ${clangd}
casemate_o = ${casemate_o}
casemate_h = ${casemate_h}
lib_includes = ${lib_includes}
EOF