Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support OCaml 5.2 #134

Open
wants to merge 87 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
a894db6
Add -Wl,--start-group & -Wl,--end-group
dinosaure Jan 9, 2023
d580220
Delete the usage of `sed -i` (and replace it by `sed && mv`)
dinosaure Jan 9, 2023
f3a91fa
Specify the architecture into the OCaml's `./configure` script
dinosaure Jan 9, 2023
31bd923
Add $$PTHREAD_LIB into our pattern to modify nativecclibs
dinosaure Jan 9, 2023
aeb1b7d
Add runtime/primitives as a dependency for the coldstart rule
dinosaure Jan 9, 2023
5d551fc
ocamlrun{,d,i} are located into the runtime directory
dinosaure Jan 9, 2023
26c9f4d
Delete fake libcamlrun{,d,i}.a from the Makefile
dinosaure Jan 9, 2023
40f0c2f
/runtime/Makefile was deleted (OCaml 5.0) and everything is into /Mak…
dinosaure Jan 11, 2023
3886e3c
Replace ocamlyacc by $$(ocamlyacc_PROGRAM)
dinosaure Jan 9, 2023
ee17f73
Replace the number of domains into our OCaml runtime
dinosaure Jan 9, 2023
da1b4f0
Disable debug runtime
dinosaure Jan 9, 2023
9c12de1
Delete unecessary tweak Makefile rule about objinfo_helper
dinosaure Jan 11, 2023
d74bf80
Add a missing / into our nolibc's test-include/%.c rule
dinosaure Jan 9, 2023
a0b346a
Add the -p option when we use mkdir (nolibc's Makefile)
dinosaure Jan 9, 2023
217d7fb
Set NATIVE_COMPILER to true into the OCaml's Makefile.config
dinosaure Jan 9, 2023
5f6bfca
Add test-include/sys/ as a dependency for test-headers (nolibc's Make…
dinosaure Jan 9, 2023
b5db5ce
Define EBUSY
dinosaure Jan 9, 2023
be0aad0
Define O_RDWR
dinosaure Jan 9, 2023
f4f52a2
Define SIG_BLOCK/SIG_SETMASK
dinosaure Jan 9, 2023
34bc918
Define S_{IR,IW}USR
dinosaure Jan 11, 2023
269d9c0
Stub pthread
dinosaure Jan 9, 2023
d6c2e0f
Stub sigfillset
dinosaure Jan 9, 2023
f052909
Stub fputs, fopen and fclose and implement puts and putchar
dinosaure Jan 13, 2023
23b4ec5
Stub strerror_r
dinosaure Jan 11, 2023
7af0209
Stub ftruncate
dinosaure Jan 11, 2023
1726bba
Stub usleep
dinosaure Jan 11, 2023
cd593ac
Export stdrup & strcpy
dinosaure Jan 11, 2023
2863bd9
Export qsort and mktemp
dinosaure Jan 9, 2023
2c63b4b
Export fstat
dinosaure Jan 11, 2023
11e978c
Export islanum and tolower
dinosaure Jan 9, 2023
d6c7ed4
Add longjmp & setjmp
dinosaure Jan 9, 2023
3f40660
Add the sched.h interface (and the CPU_ZERO value)
dinosaure Jan 9, 2023
88f58da
Add the stdatomic.h
dinosaure Jan 11, 2023
9d56d63
Add sysconf.c (to let OCaml to know the _SC_PAGE{,_}SIZE)
dinosaure Jan 13, 2023
66f5aea
Add the mmap() function
dinosaure Jan 13, 2023
a11227c
Initialise the Thread Local Store
dinosaure Jan 11, 2023
b50d638
Upgrade ocaml-solo5 with OCaml 5.0
dinosaure Jan 11, 2023
06ce260
Upgrade GitHub workflow and Cirrus CI with OCaml 5.0
dinosaure Jan 11, 2023
22ec349
Use __c11 atomic macros when they are available (and fix the LLVM sup…
dinosaure Jan 19, 2023
f154390
Update to the new Solo5 API.
palainp Feb 7, 2023
8fa4ee3
minor change to trigger CI
hannesm May 19, 2023
3c84241
use linux defines constants
palainp Oct 18, 2023
17113f5
bump solo5 version
palainp Oct 18, 2023
cdb7aa1
explicit conversion from size_t to int
palainp Oct 18, 2023
c0cf23e
add munmap
palainp Oct 18, 2023
7eb825b
bump ocaml version
palainp Oct 18, 2023
a8a84a0
fix mmap and munmap
palainp Oct 18, 2023
c3394df
add CHAR_BIT
palainp Oct 18, 2023
4a96b72
relax alignment with mmap when addr is not NULL
palainp Nov 20, 2023
47b0f7f
Stub `sigwait`
shym Feb 26, 2024
348772b
Stub `execv`
shym Feb 28, 2024
7d9de55
Define `static_assert`
shym Feb 27, 2024
a29b575
Define `strnlen`
shym Feb 27, 2024
48e8ee5
Define some extra `errno` values
shym Feb 27, 2024
cf55596
Use the compiler-provided `stdatomic.h`
shym Feb 27, 2024
3c03282
Do not rebuild `nolibc.a` when nothing changed
shym Mar 28, 2024
48f9351
Trim down `configure.sh` and adapt Makefiles
shym Mar 26, 2024
2888a51
Clean up typos in `configure.sh`
shym Apr 4, 2024
6f590c2
Add a `sysroot` configuration option
shym Apr 5, 2024
5d6a5aa
WIP Create a OCaml/Solo5-specific cross toolchain
shym Apr 4, 2024
6d32ebf
Define __BSD_VISIBLE and __XSI_VISIBLE when compiling C files
shym Apr 4, 2024
00de7bd
Disable a Clang warning
shym Apr 16, 2024
452ac54
Clean up options to build libraries
shym Apr 4, 2024
e84b036
Use OCaml's cross-compiler-aware configure and make
shym Apr 4, 2024
c09bc95
Remove workaround for #101
shym Apr 4, 2024
45f55ab
Generate `solo5.conf` with available .opt programs
shym Mar 28, 2024
9342962
Update {,dist}clean targets
shym Apr 4, 2024
c016052
Update the dependencies of the `all` target
shym Apr 4, 2024
712b5dc
Add a `test` rule
shym Apr 4, 2024
e7fda01
Split up the declaration of phoniness of targets
shym Apr 5, 2024
6894d7f
Add a rule to build an empty file to use as `META`
shym Apr 4, 2024
09926fa
Generate an OPAM .install file
shym Apr 4, 2024
83f6429
WIP Use opam-installer for the install and uninstall targets
shym Mar 29, 2024
820fb6b
Drop ocaml-option-nnp, not available in OCaml 5+, from .opam
shym Mar 26, 2024
726c968
Update the rules and dependencies of the OPAM packages
shym Apr 5, 2024
542f109
WIP OPAM package: Depend on the 5.2.0 OCaml compiler
shym Apr 5, 2024
75c4174
OPAM: Add the URL for the sources of the compiler
shym Mar 29, 2024
23a43dd
Update the compiler version in CI
shym Apr 5, 2024
80168f6
Use an order-only dependency for nolibc test directory
shym Apr 9, 2024
0df415e
Update comments in nolibc' `signal.h`
shym Apr 9, 2024
b9575c2
Ignore `sigfillset`
shym Apr 12, 2024
34f02b9
Change pthread_create stub to report a failure to create
shym Apr 16, 2024
6c9fd42
Ensure that library dependencies work across Makefiles
shym Apr 16, 2024
89be472
WIP Add patches for 5.2.0
shym Apr 17, 2024
c3cebec
TMP CI: Pin a branch for Solo5 on FreeBSD
shym Apr 22, 2024
5ad3cc3
Handle `mmap(addr..., MAP_FIXED, ...)` uses
shym May 6, 2024
0b3b7ff
Reformulate two comments in `mmap`
shym May 6, 2024
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: 2 additions & 3 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ freebsd_task:
OPAMYES: 1
env:
matrix:
- OCAML_VERSION: 4.12.1
- OCAML_VERSION: 4.13.1
- OCAML_VERSION: 4.14.1
- OCAML_VERSION: 5.2.0
pkg_install_script: pkg install -y ocaml-opam gmp gmake pkgconf bash
opam_ocaml_cache:
folder: $HOME/.opam
Expand All @@ -21,6 +19,7 @@ freebsd_task:
setup_script:
- opam update
- opam install dune
- opam pin add -n solo5 'https://github.com/shym/solo5.git#freebsd-stdatomic'
- opam pin add -n -t .
- opam depext -yt ocaml-solo5
- opam install -t ocaml-solo5 --deps-only
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
strategy:
matrix:
operating-system: [ubuntu-latest]
ocaml-version: [4.12.1,4.13.1,4.14.1]
ocaml-version: [5.2.0]
name: OCaml ${{ matrix.ocaml-version }}
runs-on: ${{ matrix.operating-system }}
steps:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ nolibc/*.a
nolibc/test-include/
ocaml/
_build/
/ocaml-src.tar.gz
/*.install
284 changes: 170 additions & 114 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,138 +1,194 @@
.PHONY: all clean install uninstall distclean ocaml

include Makeconf

all: openlibm/libopenlibm.a nolibc/libnolibc.a ocaml solo5.conf
# The `all` target is moved to the end to use variables in its dependencies
.PHONY: default
default: all

TOP=$(abspath .)

# CFLAGS used to build nolibc / openlibm / ocaml runtime
LOCAL_CFLAGS=$(MAKECONF_CFLAGS) -I$(TOP)/nolibc/include -include _solo5/overrides.h
# CFLAGS used by the OCaml compiler to build C stubs
GLOBAL_CFLAGS=$(MAKECONF_CFLAGS) -I$(MAKECONF_PREFIX)/solo5-sysroot/include/nolibc/ -include _solo5/overrides.h
# LIBS used by the OCaml compiler to link executables
GLOBAL_LIBS=-L$(MAKECONF_PREFIX)/solo5-sysroot/lib/nolibc/ -lnolibc -lopenlibm $(MAKECONF_EXTRA_LIBS)
# Most parts (OCaml, nolibc, openlibm) currently build their result in-tree but
# we reuse dune's `_build` dir, as familiar and already usable for `example`,
# etc., for some generated files
_build:
mkdir -p $@

LIBS := openlibm/libopenlibm.a nolibc/libnolibc.a

# CFLAGS used to build the nolibc and openlibm libraries
LIB_CFLAGS=-I$(TOP)/nolibc/include -include _solo5/overrides.h

# NOLIBC
NOLIBC_CFLAGS=$(LOCAL_CFLAGS) -I$(TOP)/openlibm/src -I$(TOP)/openlibm/include
nolibc/libnolibc.a:
$(MAKE) -C nolibc \
"CC=$(MAKECONF_CC)" \
"FREESTANDING_CFLAGS=$(NOLIBC_CFLAGS)" \
"SYSDEP_OBJS=$(MAKECONF_NOLIBC_SYSDEP_OBJS)"
# Use a phony target indirection, so that nolibc/Makefile is always checked to
# see whether the library should be rebuilt while avoiding useless rebuild if
# nolibc/libnolibc.a was up-to-date
NOLIBC_CFLAGS=$(LIB_CFLAGS) -I$(TOP)/openlibm/src -I$(TOP)/openlibm/include
nolibc/libnolibc.a: phony-nolibc

.PHONY: phony-nolibc
phony-nolibc:
$(MAKE) -C nolibc libnolibc.a \
"CC=$(MAKECONF_TOOLCHAIN)-cc" \
"FREESTANDING_CFLAGS=$(NOLIBC_CFLAGS)"

# OPENLIBM
openlibm/libopenlibm.a:
$(MAKE) -C openlibm "CC=$(MAKECONF_CC)" "CPPFLAGS=$(LOCAL_CFLAGS)" libopenlibm.a
# See NOLIBC for explanations of the phony target
openlibm/libopenlibm.a: phony-openlibm

.PHONY: phony-openlibm
phony-openlibm:
$(MAKE) -C openlibm libopenlibm.a \
"CC=$(MAKECONF_TOOLCHAIN)-cc" \
"CPPFLAGS=$(LIB_CFLAGS)"

# TOOLCHAIN
# We create prefix-gcc even when the actual compiler will be Clang because
# autoconf toolchain detection will pick the first compiler that exists in the
# list: prefix-gcc, gcc, prefix-cc, cc...
# Anyway, configure scripts always explicitly test whether the compiler defines
# Clang-specific macros when they want to distinguish GCC and Clang
ALLTOOLS := gcc cc ar as ld nm objcopy objdump ranlib readelf strip
ALLTOOLS := $(foreach tool,$(ALLTOOLS), \
$(MAKECONF_TARGET_ARCH)-solo5-ocaml-$(tool))

TOOLDIR_FOR_BUILD := _build/build-toolchain
TOOLCHAIN_FOR_BUILD := $(addprefix $(TOOLDIR_FOR_BUILD)/,$(ALLTOOLS))
TOOLDIR_FINAL := _build/toolchain
TOOLCHAIN_FINAL := $(addprefix $(TOOLDIR_FINAL)/,$(ALLTOOLS))

# Options for the build version of the tools
TOOLCHAIN_BUILD_CFLAGS := -I$(TOP)/nolibc/include \
-I$(TOP)/openlibm/include -I$(TOP)/openlibm/src
TOOLCHAIN_BUILD_LDFLAGS := -L$(TOP)/nolibc -L$(TOP)/openlibm

# Options for the installed version of the tools
TOOLCHAIN_FINAL_CFLAGS := -I$(MAKECONF_SYSROOT)/include
TOOLCHAIN_FINAL_LDFLAGS := -L$(MAKECONF_SYSROOT)/lib

$(TOOLDIR_FOR_BUILD) $(TOOLDIR_FINAL):
mkdir -p $@

$(TOOLDIR_FOR_BUILD)/$(MAKECONF_TARGET_ARCH)-solo5-ocaml-%: \
gen_toolchain_tool.sh | $(TOOLDIR_FOR_BUILD)
ARCH="$(MAKECONF_TARGET_ARCH)" \
SOLO5_TOOLCHAIN="$(MAKECONF_TOOLCHAIN)" \
OTHERTOOLPREFIX="$(MAKECONF_TOOLPREFIX)" \
TOOL_CFLAGS="$(TOOLCHAIN_BUILD_CFLAGS)" \
TOOL_LDFLAGS="$(TOOLCHAIN_BUILD_LDFLAGS)" \
sh $< $* > $@
chmod +x $@

$(TOOLDIR_FINAL)/$(MAKECONF_TARGET_ARCH)-solo5-ocaml-%: \
gen_toolchain_tool.sh | $(TOOLDIR_FINAL)
ARCH="$(MAKECONF_TARGET_ARCH)" \
SOLO5_TOOLCHAIN="$(MAKECONF_TOOLCHAIN)" \
OTHERTOOLPREFIX="$(MAKECONF_TOOLPREFIX)" \
TOOL_CFLAGS="$(TOOLCHAIN_FINAL_CFLAGS)" \
TOOL_LDFLAGS="$(TOOLCHAIN_FINAL_LDFLAGS)" \
sh $< $* > $@
chmod +x $@

.PHONY: toolchains
toolchains: $(TOOLCHAIN_FOR_BUILD) $(TOOLCHAIN_FINAL)

# OCAML
ocaml/Makefile:
cp -r `opam var prefix`/lib/ocaml-src ./ocaml

# OCaml >= 4.08.0 uses an autotools-based build system. In this case we
# convince it to think it's using the Solo5 compiler as a cross compiler, and
# let the build system do its work with as little additional changes on our
# side as possible.
#
# Notes:
#
# - CPPFLAGS must be set for configure as well as CC, otherwise it complains
# about headers due to differences of opinion between the preprocessor and
# compiler.
# - ARCH must be overridden manually in Makefile.config due to the use of
# hardcoded combinations in the OCaml configure.
# - We use LIBS with a stubbed out solo5 implementation to override the OCaml
# configure link test
# - We override OCAML_OS_TYPE since configure just hardcodes it to "Unix".
OC_CFLAGS=$(LOCAL_CFLAGS) -I$(TOP)/openlibm/include -I$(TOP)/openlibm/src -nostdlib
OC_LIBS=-L$(TOP)/nolibc -lnolibc -L$(TOP)/openlibm -lopenlibm -nostdlib $(MAKECONF_EXTRA_LIBS)
ocaml/Makefile.config: ocaml/Makefile openlibm/libopenlibm.a nolibc/libnolibc.a
# configure: Do not build dynlink
sed -i -e 's/otherlibraries="dynlink"/otherlibraries=""/g' ocaml/configure
# configure: Allow precise input of flags and libs
sed -i -e 's/oc_cflags="/oc_cflags="$$OC_CFLAGS /g' ocaml/configure
sed -i -e 's/ocamlc_cflags="/ocamlc_cflags="$$OCAMLC_CFLAGS /g' ocaml/configure
sed -i -e 's/nativecclibs="$$cclibs $$DLLIBS"/nativecclibs="$$GLOBAL_LIBS"/g' ocaml/configure
# runtime/Makefile: Runtime rules: don't build libcamlrun.a and import ocamlrun from the system
sed -i -e 's/^all: $$(BYTECODE_STATIC_LIBRARIES) $$(BYTECODE_SHARED_LIBRARIES)/all: primitives ld.conf/' ocaml/runtime/Makefile
sed -i -e 's/^ocamlrun$$(EXE):.*/dummy:/g' ocaml/runtime/Makefile
sed -i -e 's/^ocamlruni$$(EXE):.*/dummyi:/g' ocaml/runtime/Makefile
sed -i -e 's/^ocamlrund$$(EXE):.*/dummyd:/g' ocaml/runtime/Makefile
echo -e "ocamlrun:\n\tcp $(shell which ocamlrun) .\n" >> ocaml/runtime/Makefile
echo -e "ocamlrund:\n\tcp $(shell which ocamlrund) .\n" >> ocaml/runtime/Makefile
echo -e "ocamlruni:\n\tcp $(shell which ocamlruni) .\n" >> ocaml/runtime/Makefile
touch ocaml/runtime/libcamlrun.a ocaml/runtime/libcamlrund.a ocaml/runtime/libcamlruni.a
# yacc/Makefile: import ocamlyacc from the system
sed -i -e 's/^ocamlyacc$$(EXE):.*/dummy:/g' ocaml/yacc/Makefile
echo -e "ocamlyacc:\n\tcp $(shell which ocamlyacc) .\n" >> ocaml/yacc/Makefile
# tools/Makefile: stub out objinfo_helper
echo -e "objinfo_helper:\n\ttouch objinfo_helper\n" >> ocaml/tools/Makefile
# av_cv_libm_cos=no is passed to configure to prevent -lm being used (which
# would use the host system libm instead of the freestanding openlibm, see
# https://github.com/mirage/ocaml-solo5/issues/101
# Extract sources from ocaml-src.tar.gz (if available, supporting the
# differences of options between various tar implementations to strip the first
# directory in the archive) or from the ocaml-src OPAM package and apply patches
# if there any in `patches/<OCaml version>/`
ocaml:
mkdir -p $@
if test -f ocaml-src.tar.gz; then \
if tar --version >/dev/null 2>&1; then \
tar -x -f ocaml-src.tar.gz -z -C $@ --strip-components=1; \
else tar -x -f ocaml-src.tar.gz -z -C $@ -s '/^[^\/]*\///'; \
fi ; \
elif opam var ocaml-src:lib; then cp -R `opam var ocaml-src:lib` $@; \
else echo Cannot find OCaml sources; false; \
fi
if test -d "patches/`head -n1 ocaml/VERSION`" ; then \
git apply --directory=$@ "patches/`head -n1 ocaml/VERSION`"/*; \
fi

ocaml/Makefile.config: $(LIBS) $(TOOLCHAIN_FOR_BUILD) | ocaml
cd ocaml && \
CC="$(MAKECONF_CC)" \
OC_CFLAGS="$(OC_CFLAGS)" \
OCAMLC_CFLAGS="$(GLOBAL_CFLAGS)" \
AS="$(MAKECONF_AS)" \
ASPP="$(MAKECONF_CC) $(OC_CFLAGS) -c" \
CPPFLAGS="$(OC_CFLAGS)" \
LIBS="$(OC_LIBS)"\
GLOBAL_LIBS="$(GLOBAL_LIBS)"\
LD="$(MAKECONF_LD)" \
ac_cv_prog_DIRECT_LD="$(MAKECONF_LD)" \
ac_cv_lib_m_cos="no" \
PATH="$(abspath $(TOOLDIR_FOR_BUILD)):$$PATH" \
./configure \
-host=$(MAKECONF_ARCH)-unknown-none \
-target=$(MAKECONF_BUILD_ARCH)-solo5-none \
-prefix $(MAKECONF_PREFIX)/solo5-sysroot \
-disable-shared\
-disable-systhreads\
-disable-unix-lib\
-disable-instrumented-runtime\
-disable-ocamltest\
-disable-ocamldoc\
--target=$(MAKECONF_TARGET_ARCH)-solo5-ocaml \
--prefix=$(MAKECONF_SYSROOT) \
--disable-shared \
--disable-systhreads \
--disable-unix-lib \
--disable-instrumented-runtime \
--disable-debug-runtime \
--disable-ocamltest \
--disable-ocamldoc \
--without-zstd \
$(MAKECONF_OCAML_CONFIGURE_OPTIONS)
echo "ARCH=$(MAKECONF_OCAML_BUILD_ARCH)" >> ocaml/Makefile.config
echo 'SAK_CC=cc' >> ocaml/Makefile.config
echo 'SAK_CFLAGS=' >> ocaml/Makefile.config
echo 'SAK_LINK=cc $(SAK_CFLAGS) $$(OUTPUTEXE)$$(1) $$(2)' >> ocaml/Makefile.config
echo '#undef OCAML_OS_TYPE' >> ocaml/runtime/caml/s.h
echo '#define OCAML_OS_TYPE "None"' >> ocaml/runtime/caml/s.h

# NOTE: ocaml/tools/make-version-header.sh is integrated into OCaml's ./configure script starting from OCaml 4.14
ifneq (,$(wildcard ocaml/tools/make-version-header.sh))
ocaml/runtime/caml/version.h: ocaml/Makefile.config
ocaml/tools/make-version-header.sh > $@
else
ocaml/runtime/caml/version.h: ocaml/Makefile.config
@
endif

ocaml: ocaml/Makefile.config ocaml/runtime/caml/version.h
$(MAKE) -C ocaml world
$(MAKE) -C ocaml opt

OCAML_IS_BUILT := _build/ocaml_is_built
$(OCAML_IS_BUILT): ocaml/Makefile.config | _build
PATH="$(abspath $(TOOLDIR_FOR_BUILD)):$$PATH" $(MAKE) -C ocaml cross.opt
cd ocaml && ocamlrun tools/stripdebug ocamlc ocamlc.tmp
cd ocaml && ocamlrun tools/stripdebug ocamlopt ocamlopt.tmp
touch $@

# TODO: Decide whether these files should be provided in the repository (if so,
# we should make sure they cover all the use cases and move the files to the
# root) or rebuilt every time
DOT_INSTALL_PREFIX_FOR_OCAML := _build/ocaml.install
DOT_INSTALL_CHUNKS_FOR_OCAML := $(addprefix $(DOT_INSTALL_PREFIX_FOR_OCAML),\
.lib .libexec)
$(DOT_INSTALL_CHUNKS_FOR_OCAML): | ocaml/Makefile.config
MAKE="$(MAKE)" ./gen_ocaml_install.sh \
$(DOT_INSTALL_PREFIX_FOR_OCAML) ocaml $(MAKECONF_SYSROOT)

# CONFIGURATION FILES
solo5.conf: solo5.conf.in
sed -e 's!@@PREFIX@@!$(MAKECONF_PREFIX)!' \
solo5.conf.in > $@
_build/solo5.conf: gen_solo5_conf.sh $(OCAML_IS_BUILT)
SYSROOT="$(MAKECONF_SYSROOT)" ./gen_solo5_conf.sh > $@

_build/empty-META: | _build
touch $@

# INSTALL
PACKAGES := $(basename $(wildcard *.opam))
INSTALL_FILES := $(foreach pkg,$(PACKAGES),$(pkg).install)

$(INSTALL_FILES): $(TOOLCHAIN_FINAL) $(DOT_INSTALL_CHUNKS_FOR_OCAML)
./gen_dot_install.sh $(DOT_INSTALL_PREFIX_FOR_OCAML) $(TOOLCHAIN_FINAL)\
> $@

# COMMANDS
install: all
MAKE=$(MAKE) PREFIX=$(MAKECONF_PREFIX) ./install.sh
PACKAGE := ocaml-solo5
.PHONY: install
install: $(PACKAGE).install
opam-installer --prefix=$(MAKECONF_PREFIX) $<

uninstall:
./uninstall.sh
.PHONY: uninstall
uninstall: $(PACKAGE).install
opam-installer --prefix=$(MAKECONF_PREFIX) --uninstall $<

.PHONY: clean
clean:
$(RM) -r ocaml/
$(RM) solo5.conf
$(RM) -rf _build
$(MAKE) -C openlibm clean
$(MAKE) -C nolibc \
"FREESTANDING_CFLAGS=$(NOLIBC_CFLAGS)" \
"SYSDEP_OBJS=$(MAKECONF_NOLIBC_SYSDEP_OBJS)" \
clean
$(MAKE) -C nolibc clean FREESTANDING_CFLAGS=_
if [ -d ocaml ] ; then $(MAKE) -C ocaml clean ; fi
$(RM) -f $(INSTALL_FILES)

.PHONY: distclean
distclean: clean
rm Makeconf
$(RM) -f Makeconf
# Don't remove the ocaml directory itself, to play nicer with
# development in there
if [ -d ocaml ] ; then $(MAKE) -C ocaml distclean ; fi

.PHONY: all
all: $(LIBS) $(OCAML_IS_BUILT) \
_build/solo5.conf _build/empty-META \
$(TOOLCHAIN_FINAL)

.PHONY: test
test:
$(MAKE) -C nolibc test-headers \
"CC=$(MAKECONF_TOOLCHAIN)-cc" \
"FREESTANDING_CFLAGS=$(NOLIBC_CFLAGS)"
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ Run: `solo5-hvt _build/solo5/main.exe`

## Supported compiler versions

Tested against OCaml 4.12.1 through 4.14.1. Other versions may require
changing `configure.sh`.
Tested against OCaml 5.0. Other versions may require changing `configure.sh`.

## Porting to a different (uni)kernel base layer

Expand Down
Loading
Loading