-
Notifications
You must be signed in to change notification settings - Fork 30
/
configure.sh
executable file
·99 lines (85 loc) · 2.23 KB
/
configure.sh
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
#!/bin/sh
prog_NAME="$(basename "$0")"
err()
{
echo "${prog_NAME}: ERROR: $*" 1>&2
}
die()
{
echo "${prog_NAME}: ERROR: $*" 1>&2
exit 1
}
usage()
{
cat <<EOM 1>&2
usage: ${prog_NAME} [ OPTIONS ]
Configures the ocaml-solo5 build system.
Options:
--prefix=DIR
Installation prefix (default: /usr/local).
--sysroot=DIR
Installation prefix for the OCaml cross-compiler and its supporting
libraries (default: <installation prefix>/lib/ocaml-solo5).
--target=TARGET
Solo5 compiler toolchain to use.
--othertoolprefix=PREFIX
Prefix for tools besides the Solo5 toolchain
(default: \`TARGET-cc -dumpmachine\`-).
--ocaml-configure-option=OPTION
Add an option to the OCaml compiler configuration.
EOM
exit 1
}
OCAML_CONFIGURE_OPTIONS=
MAKECONF_PREFIX=/usr/local
while [ $# -gt 0 ]; do
OPT="$1"
case "${OPT}" in
--target=*)
CONFIG_TARGET="${OPT#*=}"
;;
--othertoolprefix=*)
MAKECONF_TOOLPREFIX="${OPT#*=}"
;;
--prefix=*)
MAKECONF_PREFIX="${OPT#*=}"
;;
--sysroot=*)
MAKECONF_SYSROOT="${OPT#*=}"
;;
--ocaml-configure-option=*)
OCAML_CONFIGURE_OPTIONS="${OCAML_CONFIGURE_OPTIONS} ${OPT#*=}"
;;
--help)
usage
;;
*)
err "Unknown option: '${OPT}'"
usage
;;
esac
shift
done
MAKECONF_SYSROOT="${MAKECONF_SYSROOT:-$MAKECONF_PREFIX/lib/ocaml-solo5}"
[ -z "${CONFIG_TARGET}" ] && die "The --target option needs to be specified."
TARGET_TRIPLET="$("$CONFIG_TARGET-cc" -dumpmachine)"
MAKECONF_TOOLPREFIX="${MAKECONF_TOOLPREFIX:-$TARGET_TRIPLET-}"
case "${TARGET_TRIPLET}" in
amd64-*|x86_64-*)
TARGET_ARCH="x86_64"
;;
aarch64-*)
TARGET_ARCH="aarch64"
;;
*)
die "Unsupported build architecture: ${TARGET_TRIPLET}"
;;
esac
cat <<EOM >Makeconf
MAKECONF_PREFIX=${MAKECONF_PREFIX}
MAKECONF_SYSROOT=${MAKECONF_SYSROOT}
MAKECONF_TOOLCHAIN=${CONFIG_TARGET}
MAKECONF_TOOLPREFIX=${MAKECONF_TOOLPREFIX}
MAKECONF_TARGET_ARCH=${TARGET_ARCH}
MAKECONF_OCAML_CONFIGURE_OPTIONS=${OCAML_CONFIGURE_OPTIONS}
EOM