1
1
mirror of https://github.com/kanaka/mal.git synced 2024-08-17 09:40:21 +03:00

add sml_MODE selection for Make

This commit is contained in:
Fabian 2021-03-29 14:43:51 +02:00 committed by Joel Martin
parent 3672361157
commit 8424de4274
3 changed files with 50 additions and 11 deletions

View File

@ -24,6 +24,8 @@ matlab_MODE = octave
python_MODE = python
# scheme (chibi, kawa, gauche, chicken, sagittarius, cyclone, foment)
scheme_MODE = chibi
# sml (polyml, mlton, mosml)
sml_MODE = polyml
# wasmtime wasmer lucet wax node warpy wace_libc
wasm_MODE = wasmtime

4
impls/sml/.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
.smlmode
.step*
*.ui
*.uo

View File

@ -1,23 +1,56 @@
STEP_BINS = step0_repl step1_read_print step2_eval step3_env step4_if_fn_do
sml_MODE_DEFAULT = polyml
sml_MODE_CONFIG = .smlmode
ifeq ($(sml_MODE),)
sml_MODE = $(sml_MODE_DEFAULT)
endif
# some hackery to let Make know if it needs to rebuild when sml_MODE changes
ifneq ($(sml_MODE),$(shell cat $(sml_MODE_CONFIG) 2> /dev/null))
$(shell rm $(sml_MODE_CONFIG) 2> /dev/null)
endif
ifeq ($(sml_MODE),mlton)
SMLC = mlton
SMLCOUTFLAG = -output
BUILD_FILE = %.mlb
build_args = $1
endif
ifeq ($(sml_MODE),mosml)
SMLC = mosmlc
SMLCOUTFLAG = -o
BUILD_FILE = %.mlb
build_args = -toplevel $(shell grep "\\.sml" $1)
endif
ifeq ($(sml_MODE),polyml)
SMLC = polyc
SMLCOUTFLAG = -o
BUILD_FILE = .%.poly.sml
build_args = $1
endif
all: $(STEP_BINS)
step0_repl: step0_repl.mlb step0_repl.sml main.sml
mlton -output $@ $<
.%.dep: %.mlb
@echo sml-deps -o $@ $<
$(eval DEPS := $(shell grep "\\.sml" $<))
@echo "$(@:.%.dep=%) $@: $(DEPS)" > $@
step1_read_print: step1_read_print.mlb step1_read_print.sml reader.sml printer.sml types.sml util.sml main.sml
mlton -output $@ $<
include $(STEP_BINS:%=.%.dep)
step2_eval: step2_eval.mlb step2_eval.sml env.sml reader.sml printer.sml types.sml util.sml main.sml
mlton -output $@ $<
.%.poly.sml: %.mlb
@echo generate-sml -o $@ $<
@grep "\\.sml" $< | grep -v main | xargs printf "use \"%s\";\n" > $@
step3_env: step3_env.mlb step3_env.sml env.sml reader.sml printer.sml types.sml util.sml main.sml
mlton -output $@ $<
# some hackery to let Make track changes in sml_MODE
$(sml_MODE_CONFIG):
@echo $(sml_MODE) > $@
step4_if_fn_do: step4_if_fn_do.mlb step4_if_fn_do.sml core.sml env.sml reader.sml printer.sml types.sml util.sml main.sml
mlton -output $@ $<
$(STEP_BINS): %: $(BUILD_FILE) $(sml_MODE_CONFIG)
$(SMLC) $(SMLCOUTFLAG) $@ $(call build_args,$<)
clean:
rm -f $(STEP_BINS)
rm -f $(STEP_BINS) .*.dep *.ui *.uo .*.poly.sml $(sml_MODE_CONFIG)
.PHONY: all clean