forked from mirage/ocaml-solo5
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfigure.sh
More file actions
executable file
·91 lines (84 loc) · 3.22 KB
/
configure.sh
File metadata and controls
executable file
·91 lines (84 loc) · 3.22 KB
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
#!/bin/sh
export PKG_CONFIG_PATH=$(opam config var prefix)/lib/pkgconfig
pkg_exists() {
pkg-config --exists "$@"
}
if pkg_exists solo5-kernel-ukvm solo5-kernel-virtio solo5-kernel-muen; then
echo "ERROR: Conflicting packages." 1>&2
echo "ERROR: Only one of solo5-kernel-ukvm, solo5-kernel-virtio, solo5-kernel-muen can be installed." 1>&2
exit 1
fi
PKG_CONFIG_DEPS=
pkg_exists solo5-kernel-ukvm && PKG_CONFIG_DEPS=solo5-kernel-ukvm
pkg_exists solo5-kernel-muen && PKG_CONFIG_DEPS=solo5-kernel-muen
pkg_exists solo5-kernel-virtio && PKG_CONFIG_DEPS=solo5-kernel-virtio
if [ -z "${PKG_CONFIG_DEPS}" ]; then
echo "ERROR: No supported kernel package found." 1>&2
echo "ERROR: solo5-kernel-ukvm, solo5-kernel-virtio or solo5-kernel-muen must be installed." 1>&2
exit 1
fi
ocamlfind query ocaml-src >/dev/null || exit 1
FREESTANDING_CFLAGS="$(pkg-config --cflags ${PKG_CONFIG_DEPS})"
BUILD_ARCH=$(uname -m)
BUILD_OS=$(uname -s)
# FreeBSD uses amd64, unify to x86_64 here.
if [ "${BUILD_ARCH}" = "amd64" ]; then
BUILD_ARCH="x86_64"
fi
if [ ! -f config.in/Makefile.${BUILD_OS}.${BUILD_ARCH} ]; then
echo "ERROR: Unsupported build OS/architecture combination: ${BUILD_OS}/${BUILD_ARCH}" 1>&2
exit 1
fi
PKG_CONFIG_EXTRA_LIBS=
if [ "${BUILD_ARCH}" = "aarch64" ]; then
PKG_CONFIG_EXTRA_LIBS="$(gcc -print-libgcc-file-name)" || exit 1
fi
cp -r config.in config
OCAML_GTE_4_06_0=no
case $(ocamlopt -version) in
4.02.3)
echo '#define OCAML_OS_TYPE "Unix"' >> config/s.h
;;
4.03.0)
OCAML_EXTRA_DEPS=build/ocaml/byterun/caml/version.h
echo '#define OCAML_OS_TYPE "Unix"' >> config/s.h
;;
4.04.0|4.04.0+*)
OCAML_EXTRA_DEPS=build/ocaml/byterun/caml/version.h
echo '#define OCAML_OS_TYPE "freestanding"' >> config/s.h
;;
4.04.[1-9]|4.04.[1-9]+*)
OCAML_EXTRA_DEPS=build/ocaml/byterun/caml/version.h
echo '#define OCAML_OS_TYPE "freestanding"' >> config/s.h
echo '#define INT64_LITERAL(s) s ## LL' >> config/m.${BUILD_ARCH}.h
;;
4.05.[0-9]|4.05.[0-9]+*)
OCAML_EXTRA_DEPS=build/ocaml/byterun/caml/version.h
echo '#define OCAML_OS_TYPE "freestanding"' >> config/s.h
echo '#define INT64_LITERAL(s) s ## LL' >> config/m.${BUILD_ARCH}.h
# Use __ANDROID__ here to disable the AFL code, otherwise we'd have to
# add many more stubs to ocaml-freestanding.
echo 'afl.o: CFLAGS+=-D__ANDROID__' >> config/Makefile.${BUILD_OS}.${BUILD_ARCH}
;;
4.06.[0-9]|4.06.[0-9]+*)
OCAML_GTE_4_06_0=yes
OCAML_EXTRA_DEPS=build/ocaml/byterun/caml/version.h
echo '#define OCAML_OS_TYPE "freestanding"' >> config/s.h
echo '#define INT64_LITERAL(s) s ## LL' >> config/m.${BUILD_ARCH}.h
echo 'SYSTEM=freestanding' >> config/Makefile.${BUILD_OS}.${BUILD_ARCH}
;;
*)
echo "ERROR: Unsupported OCaml version: $(ocamlopt -version)." 1>&2
exit 1
;;
esac
cat <<EOM >Makeconf
FREESTANDING_CFLAGS=${FREESTANDING_CFLAGS}
BUILD_ARCH=${BUILD_ARCH}
BUILD_OS=${BUILD_OS}
NOLIBC_SYSDEP_OBJS=sysdeps_solo5.o
PKG_CONFIG_DEPS=${PKG_CONFIG_DEPS}
PKG_CONFIG_EXTRA_LIBS=${PKG_CONFIG_EXTRA_LIBS}
OCAML_EXTRA_DEPS=${OCAML_EXTRA_DEPS}
OCAML_GTE_4_06_0=${OCAML_GTE_4_06_0}
EOM