-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
67 lines (52 loc) · 1.75 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
FILES = prelude prepare solution template test meta
META = meta.json
BDIR = bin
SDIR = src
TDIR = tests
INPUT = input.ml
SUFFIX = .native
SOLPREFIX = sol_
MAPPREFIX = mapper_
ASTPREFIX = ptree_
MAPPERS = $(addprefix $(MAPPREFIX), $(FILES))
TARGETS = $(addsuffix $(SUFFIX), $(MAPPERS))
MAIN = autogen
EXE = $(MAIN)$(SUFFIX)
NAME = learn-ocaml-autogen
BEXE = $(BDIR)/$(NAME)
OCB_LIBS = -package compiler-libs.common -package cmdliner -package ezjsonm
OCB_DIR_FLAGS = -I $(SDIR)
OCB = ocamlbuild $(OCB_LIBS) $(OCB_DIR_FLAGS)
TESTS = $(wildcard $(TDIR)/*/)
OCF = ocamlfind ppx_tools/rewriter
.PHONY : all clean clear test tests_clean learn-ocaml-autogen.install install remove
all : $(TARGETS)
$(OCB) $(EXE)
mkdir -p $(BDIR) && mv $(EXE) $(BEXE); mv *$(SUFFIX) $(BDIR)
%.native : $(SDIR)/%.ml
$(OCB) $@
test : all
$(TDIR)/run-tests
learn-ocaml-autogen.install :
@echo 'bin: [' > $@
@$(foreach X, $(TARGETS), echo ' "$(BDIR)/$X" {"$X"}' >> $@;)
@echo ' "$(BEXE)" {"$(NAME)"}' >> $@
@echo ']' >> $@
@echo 'lib: [' >> $@
@$(foreach M, $(MAPPERS), $(foreach EXT, .cmi .cmo .cmx, \
echo ' "_build/src/$M$(EXT)" {"$M$(EXT)"}' >> $@;))
@echo ']' >> $@
install : all learn-ocaml-autogen.install
opam-installer --prefix `opam var prefix` learn-ocaml-autogen.install
remove : learn-ocaml-autogen.install
opam-installer --prefix `opam var prefix` -u learn-ocaml-autogen.install
clean : remove
$(OCB) -clean
@rm -rf rmdir $(BDIR)
@rm -f learn-ocaml-autogen.install
tests_clean :
@rm -f $(foreach X, $(TESTS), $(foreach Y, $(FILES), $X$Y.ml))
@rm -f $(foreach X, $(TESTS), $(foreach Y, $(FILES), $X$(ASTPREFIX)$Y.ml))
@rm -f $(foreach X, $(TESTS), $(foreach Y, $(FILES), $X$(ASTPREFIX)$(SOLPREFIX)$Y.ml))
@rm -f $(foreach X, $(TESTS), $X$(META))
clear : clean tests_clean