Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ script: bash -ex .travis-opam.sh
env:
global:
- TESTS=false
- PACKAGE="ocaml-freestanding"
- OPAM_VERSION=1.2.2
matrix:
- OCAML_VERSION=4.07 EXTRA_DEPS="solo5-kernel-ukvm"
- OCAML_VERSION=4.07 EXTRA_DEPS="solo5-kernel-virtio"
- OCAML_VERSION=4.07 EXTRA_DEPS="solo5-kernel-muen"
- OCAML_VERSION=4.06 EXTRA_DEPS="solo5-kernel-ukvm"
- OCAML_VERSION=4.06 EXTRA_DEPS="solo5-kernel-virtio"
- OCAML_VERSION=4.06 EXTRA_DEPS="solo5-kernel-muen"
Expand Down
15 changes: 13 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
.PHONY: all clean install

include Makeconf

ifeq ($(OCAML_GTE_4_07_0),yes)
FREESTANDING_LIBS=build/openlibm/libopenlibm.a \
build/ocaml/asmrun/libasmrun.a \
build/nolibc/libnolibc.a
else
FREESTANDING_LIBS=build/openlibm/libopenlibm.a \
build/ocaml/asmrun/libasmrun.a \
build/ocaml/otherlibs/libotherlibs.a \
build/nolibc/libnolibc.a
endif

all: $(FREESTANDING_LIBS) ocaml-freestanding.pc

include Makeconf

Makeconf:
./configure.sh

Expand Down Expand Up @@ -77,6 +84,10 @@ endif
build/nolibc/Makefile:
mkdir -p build
cp -r nolibc build
ifeq ($(OCAML_GTE_4_07_0),yes)
echo '/* automatically added by configure.sh */' >> build/nolibc/stubs.c
echo 'STUB_ABORT(caml_ba_map_file);' >> build/nolibc/stubs.c
endif

NOLIBC_CFLAGS=$(FREESTANDING_CFLAGS) -isystem $(TOP)/build/openlibm/src -isystem $(TOP)/build/openlibm/include
build/nolibc/libnolibc.a: build/nolibc/Makefile build/openlibm/Makefile
Expand Down
25 changes: 20 additions & 5 deletions configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,9 @@ if [ ! -f config.in/Makefile.${BUILD_OS}.${BUILD_ARCH} ]; then
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
OCAML_GTE_4_07_0=no
case $(ocamlopt -version) in
4.04.[1-9]|4.04.[1-9]+*)
OCAML_EXTRA_DEPS=build/ocaml/byterun/caml/version.h
Expand All @@ -62,12 +58,30 @@ case $(ocamlopt -version) in
echo '#define INT64_LITERAL(s) s ## LL' >> config/m.${BUILD_ARCH}.h
echo 'SYSTEM=freestanding' >> config/Makefile.${BUILD_OS}.${BUILD_ARCH}
;;
4.07.[0-9]|4.07.[0-9]+*)
OCAML_GTE_4_06_0=yes
OCAML_GTE_4_07_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

PKG_CONFIG_EXTRA_LIBS=
if [ $OCAML_GTE_4_07_0 = "no" ] ; then
PKG_CONFIG_EXTRA_LIBS="-lotherlibs"
fi

if [ "${BUILD_ARCH}" = "aarch64" ]; then
PKG_CONFIG_EXTRA_LIBS="$PKG_CONFIG_EXTRA_LIBS $(gcc -print-libgcc-file-name)" || exit 1
fi


cat <<EOM >Makeconf
FREESTANDING_CFLAGS=${FREESTANDING_CFLAGS}
BUILD_ARCH=${BUILD_ARCH}
Expand All @@ -77,4 +91,5 @@ 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}
OCAML_GTE_4_07_0=${OCAML_GTE_4_07_0}
EOM
8 changes: 6 additions & 2 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,12 @@ else
done
fi
cp build/ocaml/asmrun/libasmrun.a ${DESTLIB}/libasmrun.a
# OCaml "otherlibs"
cp build/ocaml/otherlibs/libotherlibs.a ${DESTLIB}/libotherlibs.a

# Prior to OCaml 4.07.0, "otherlibs" contained the bigarray implementation.
# OCaml >= 4.07.0 includes bigarray as part of stdlib/libasmrun.a
if [ -f build/ocaml/otherlibs/libotherlibs.a ]; then
cp build/ocaml/otherlibs/libotherlibs.a ${DESTLIB}/libotherlibs.a
fi

# pkg-config
mkdir -p ${prefix}/lib/pkgconfig
Expand Down
4 changes: 4 additions & 0 deletions nolibc/include/sys/ioctl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#ifndef _SYS_IOCTL_H
#define _SYS_IOCTL_H

#endif
4 changes: 2 additions & 2 deletions ocaml-freestanding.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ libdir=${exec_prefix}/lib/ocaml-freestanding

Name: ocaml-freestanding
Version: 1.0.0
URL: https://github.com/mirage/mirage-platform/
URL: https://github.com/mirage/ocaml-freestanding/
Description: Freestanding OCaml runtime
Cflags: -I${includedir}
Libs: ${libdir}/libasmrun.a ${libdir}/libotherlibs.a ${libdir}/libnolibc.a ${libdir}/libopenlibm.a @@PKG_CONFIG_EXTRA_LIBS@@
Libs: -L${libdir} -lasmrun -lnolibc -lopenlibm @@PKG_CONFIG_EXTRA_LIBS@@
Requires: @@PKG_CONFIG_DEPS@@
2 changes: 1 addition & 1 deletion opam
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ conflicts: [
"sexplib" {= "v0.9.0"}
]
available: [
ocaml-version >= "4.04.2" & ocaml-version < "4.07.0" &
ocaml-version >= "4.04.2" & ocaml-version < "4.08.0" &
((os = "linux" & (arch = "x86_64" | arch = "aarch64") |
(os = "freebsd" & arch = "amd64") | (os = "openbsd" & arch = "amd64" )))
]