1
1
mirror of https://github.com/kanaka/mal.git synced 2024-09-11 13:55:55 +03:00
mal/impls/sml/Makefile

62 lines
1.4 KiB
Makefile
Raw Normal View History

2021-04-05 22:22:32 +03:00
STEP_BINS = step0_repl step1_read_print step2_eval step3_env step4_if_fn_do step6_file step7_quote step8_macros step9_try stepA_mal
2021-03-24 19:24:35 +03:00
2021-03-29 15:43:51 +03:00
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 = LargeInt.sml -toplevel $(shell grep "\\.sml" $1)
2021-03-29 15:43:51 +03:00
endif
ifeq ($(sml_MODE),polyml)
SMLC = polyc
SMLCOUTFLAG = -o
BUILD_FILE = .%.poly.sml
build_args = $1
endif
2021-03-24 19:24:35 +03:00
all: $(STEP_BINS)
2021-04-07 15:29:39 +03:00
dist: mal
mal: stepA_mal
cp $< $@
2021-03-29 15:43:51 +03:00
.%.dep: %.mlb
@echo sml-deps -o $@ $<
$(eval DEPS := $(shell grep "\\.sml" $<))
@echo "$(@:.%.dep=%) $@: $(DEPS)" > $@
2021-03-24 19:24:35 +03:00
2021-03-29 15:43:51 +03:00
include $(STEP_BINS:%=.%.dep)
2021-03-25 20:59:11 +03:00
2021-03-29 15:43:51 +03:00
.%.poly.sml: %.mlb
@echo generate-sml -o $@ $<
@grep "\\.sml" $< | grep -v main | xargs printf "use \"%s\";\n" > $@
2021-03-26 14:05:05 +03:00
2021-03-29 15:43:51 +03:00
# some hackery to let Make track changes in sml_MODE
$(sml_MODE_CONFIG):
@echo $(sml_MODE) > $@
2021-03-26 19:27:49 +03:00
2021-03-29 15:43:51 +03:00
$(STEP_BINS): %: $(BUILD_FILE) $(sml_MODE_CONFIG)
$(SMLC) $(SMLCOUTFLAG) $@ $(call build_args,$<)
2021-03-27 13:18:42 +03:00
2021-03-24 19:24:35 +03:00
clean:
2021-03-29 15:43:51 +03:00
rm -f $(STEP_BINS) .*.dep *.ui *.uo .*.poly.sml $(sml_MODE_CONFIG)
2021-03-24 19:24:35 +03:00
.PHONY: all clean