diff --git a/.travis.yml b/.travis.yml index d26a3db2..5aadb252 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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" diff --git a/Makefile b/Makefile index 65be308e..64c02bed 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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 diff --git a/configure.sh b/configure.sh index d06454f6..dd9a62c5 100755 --- a/configure.sh +++ b/configure.sh @@ -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 @@ -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 <Makeconf FREESTANDING_CFLAGS=${FREESTANDING_CFLAGS} BUILD_ARCH=${BUILD_ARCH} @@ -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 diff --git a/install.sh b/install.sh index 5829afd5..a27f9bd4 100755 --- a/install.sh +++ b/install.sh @@ -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 diff --git a/nolibc/include/sys/ioctl.h b/nolibc/include/sys/ioctl.h new file mode 100644 index 00000000..541e4d5e --- /dev/null +++ b/nolibc/include/sys/ioctl.h @@ -0,0 +1,4 @@ +#ifndef _SYS_IOCTL_H +#define _SYS_IOCTL_H + +#endif diff --git a/ocaml-freestanding.pc.in b/ocaml-freestanding.pc.in index a6e167ad..aef95ce5 100644 --- a/ocaml-freestanding.pc.in +++ b/ocaml-freestanding.pc.in @@ -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@@ diff --git a/opam b/opam index 56bcb914..93736803 100644 --- a/opam +++ b/opam @@ -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" ))) ]