forked from MLanguage/mlang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
113 lines (82 loc) · 2.6 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# Check Makefile.config.template if you want to override some of the flags
# in this Makefile.
include Makefile.include
ifeq ($(OPTIMIZE), 1)
OPTIMIZE_FLAG=-O --fast-math
else
OPTIMIZE_FLAG=
endif
ifeq ($(CODE_COVERAGE), 1)
CODE_COVERAGE_FLAG=--code_coverage
else
CODE_COVERAGE_FLAG=
endif
MLANG_BIN=dune exec --no-print-director src/main.exe --
MPP_FUNCTION?=compute_double_liquidation_pvro
PRECISION?=double
TEST_ERROR_MARGIN?=0.
MLANG_DEFAULT_OPTS=\
--display_time --debug \
--precision $(PRECISION) \
--mpp_file=$(MPP_FILE) \
--test_error_margin=$(TEST_ERROR_MARGIN) \
--mpp_function=$(MPP_FUNCTION)
MLANG=$(MLANG_BIN) $(MLANG_DEFAULT_OPTS) $(OPTIMIZE_FLAG) $(CODE_COVERAGE_FLAG)
default: build
##################################################
# Building the compiler
##################################################
deps-without-ocaml:
opam install . --deps-only
git submodule update --init --recursive
deps:
opam switch create . --deps-only
git submodule update --init --recursive
format:
dune build @fmt --auto-promote | true
build: format dune
dune:
dune build $(DUNE_OPTIONS)
# Run only in an opam switch with musl and static options activated
build-static: DUNE_OPTIONS+=--profile=static
build-static: build
##################################################
# Testing the compiler
##################################################
# use: TEST_FILE=bla make test
test: build
$(MLANG) --run_test=$(TEST_FILE) $(SOURCE_FILES)
# use: TESTS_DIR=bla make test
tests: build
$(MLANG) --run_all_tests=$(TESTS_DIR) $(SOURCE_FILES)
test_python_backend:
OPTIMIZE=1 $(MAKE) -C examples/python/backend_tests all_tests
test_c_backend_perf:
$(MAKE) -C examples/c/backend_tests run_perf
test_c_backend:
$(MAKE) -C examples/c/backend_tests run_tests
test_java_backend:
ifeq ($(OPTIMIZE), 0)
@echo "\033[0;31mWarning, non-optimized Java files cannot be executed for now (too many constants for the JVM)\033[0m"
else
endif
$(MAKE) -C examples/java/ run_tests
test_dgfip_c_backend:
$(MAKE) -C examples/dgfip_c/ backend_tests
quick_test:
$(MLANG) --backend interpreter --function_spec $(M_SPEC_FILE) $(SOURCE_FILES)
all: tests test_python_backend test_c_backend_perf \
test_c_backend test_java_backend test_dgfip_c_backend quick_test
##################################################
# Doc
##################################################
doc: FORCE
dune build @doc
ln -fs $(shell pwd)/_build/default/_doc/_html/index.html doc/doc.html
clean:
$(MAKE) -C examples/c clean
$(MAKE) -C examples/dgfip_c clean
$(MAKE) -C examples/python clean
$(MAKE) -C examples/java clean
dune clean
FORCE: