forked from miking-lang/miking
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
120 lines (88 loc) · 3.36 KB
/
Makefile
File metadata and controls
120 lines (88 loc) · 3.36 KB
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
114
115
116
117
118
119
120
BOOT_NAME=mi-boot
MI_LITE_NAME=mi-lite
MI_MID_NAME=mi-mid
MI_NAME=mi
MI_CHEAT_NAME=mi-cheat
prefix ?= $(HOME)/.local
bindir ?= $(prefix)/bin
libdir ?= $(prefix)/lib
mcoredir = $(libdir)/mcore
ifdef OPAM_SWITCH_PREFIX
opamlibdir = $(OPAM_SWITCH_PREFIX)/lib
endif
ocamllibdir ?= $(or $(opamlibdir), $(libdir)/ocaml/site-lib)
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
current_dir := $(dir $(mkfile_path))
SET_STDLIB=MCORE_LIBS=stdlib=$(current_dir)/src/stdlib
ifdef OCAMLPATH
SET_OCAMLPATH=OCAMLPATH=$(current_dir)/build/lib:$(OCAMLPATH)
else
SET_OCAMLPATH=OCAMLPATH=$(current_dir)/build/lib
endif
j_flag := $(filter -j%, $(MAKEFLAGS))
.PHONY: default
default: bootstrap
# NOTE(vipa, 2023-03-29): This removes all ignored files in the build
# directory, which should coincide with generated files
.PHONY: clean
clean:
misc/scripts/repo-ignored-files build | tr "\n" "\0" | xargs -r0 rm -f
find build -depth -type d -empty -delete
# The OCaml library and executables (`boot`)
.PHONY: boot
boot:
misc/scripts/with-tmp-dir dune build --root=src/boot/ --build-dir="{}" \
"&&" dune install --root=src/boot/ --build-dir="{}" --prefix=$(current_dir)/build ">/dev/null" "2>&1"
mv $(current_dir)"/build/bin/boot" build/$(BOOT_NAME)
rm -f $(current_dir)"/build/lib/boot/dune-package"
.PHONY: install-boot
install-boot:
misc/scripts/with-tmp-dir dune build --root=src/boot/ --build-dir="{}" \
"&&" dune install --root=src/boot/ --build-dir="{}" --prefix=$(prefix) --libdir=$(ocamllibdir) ">/dev/null 2>&1"
.PHONY: uninstall-boot
uninstall-boot:
misc/scripts/with-tmp-dir dune uninstall --root=src/boot --build-dir="{}" --prefix=$(prefix) --libdir=$(ocamllibdir) ">/dev/null 2>&1"
## Formatting, checking and autoformatting respectively
.PHONY: lint
lint:
misc/scripts/with-tmp-dir dune build @fmt --root=src/boot/ --build-dir="{}"
.PHONY: fix
fix:
misc/scripts/with-tmp-dir dune fmt --root=src/boot/ --build-dir="{}"
# Bootstrapping the `mi` executable
.PHONY: bootstrap
bootstrap: $(if $(wildcard build/$(BOOT_NAME)),,boot)
$(SET_STDLIB) $(SET_OCAMLPATH) build/$(BOOT_NAME) eval src/main/mi-lite.mc -- 0 src/main/mi-lite.mc build/$(MI_LITE_NAME)
$(SET_STDLIB) $(SET_OCAMLPATH) build/$(MI_LITE_NAME) 1 src/main/mi.mc build/$(MI_MID_NAME)
$(SET_STDLIB) $(SET_OCAMLPATH) build/$(MI_MID_NAME) compile src/main/mi.mc --output build/$(MI_NAME)
.PHONY: cheat
cheat:
$(SET_STDLIB) $(SET_OCAMLPATH) mi compile src/main/mi.mc --output build/$(MI_CHEAT_NAME)
# Installing and uninstalling `mi` and the standard library
.PHONY: install
install: $(if $(wildcard build/$(MI_NAME)),,bootstrap) install-boot
mkdir -p $(bindir) $(mcoredir)
cp -f build/$(MI_NAME) $(bindir)
rm -rf $(mcoredir)/stdlib || true
cp -rf src/stdlib $(mcoredir)
.PHONY: uninstall
uninstall:
rm -f $(bindir)/$(MI_NAME)
rm -rf $(mcoredir)/stdlib
# Basic testing (for more granular control, use `misc/test` directly,
# or `misc/watch` to autorun tests when files change)
.PHONY: test test-all test-quick
test test-all test-quick: lint
test:
+ exec misc/test $(j_flag) --bootstrapped smart
test-all:
+ exec misc/test $(j_flag) --bootstrapped --non-interactive all
test-quick:
+ exec misc/test $(j_flag) --bootstrapped
test-info:
@echo "Tasks run:" `find build/src/ -name '*.out' | wc -l`
@misc/test-spec --bootstrapped smart 2>&1 >/dev/null
# Building and testing via tup
.PHONY: setup-tup
setup-tup:
misc/scripts/setup-tup