-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile.mlton
115 lines (79 loc) · 2.42 KB
/
Makefile.mlton
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
MLTON := mlton
MLTON_FLAGS := -default-ann "nonexhaustiveMatch ignore"
# path to the file `mlb-path-map`
ifneq ($(MLB_PATH_MAP),)
MLTON_FLAGS += -mlb-path-map $(MLB_PATH_MAP)
endif
MLLEX := mllex
MLYACC := mlyacc
PREFIX := /usr/local/mlton
BINDIR := bin
LIBDIR := lib/smldoc
DOCDIR := doc/smldoc
SMLDOC_ARGFILE := src/smldoc.cfg
BASIS_DOCDIR := doc/SMLBasis
SMLDOC_MLB := src/mlton/smldoc.mlb
SMLDOC_TEST_MLB := src/test/sources.mlb
SMLDOC_MLBS := $(SMLDOC_MLB) \
$(SMLDOC_TEST_MLB)
DEPENDS := $(SMLDOC_MLBS:.mlb=.mlb.d)
SMLDOC := bin/smldoc
all: smldoc
.PHONY: smldoc
smldoc: $(SMLDOC)
$(SMLDOC): $(SMLDOC_MLB:.mlb=)
@cp $< $@
$(SMLDOC_MLB:.mlb=) $(SMLDOC_TEST_MLB:.mlb=): %: %.mlb
@echo " [MLTON] $@"
@$(MLTON) $(MLTON_FLAGS) -output $@ $<
%.mlb.d: %.mlb
@echo " [GEN] $@"
@$(SHELL) -ec '$(MLTON) $(MLTON_FLAGS) -stop f $< \
| sed -e "1i$(<:.mlb=) $@:\\\\" -e "s|.*| & \\\\|" -e "\$$s| \\\\||" > $@; \
[ -s $@ ] || rm -rf $@'
%.lex.sml: %.lex
@echo " [MLLEX] $<"
@$(MLLEX) $<
%.grm.sml %.grm.sig %.grm.desc: %.grm
@echo " [MLYACC] $<"
@$(MLYACC) $<
ifeq ($(findstring clean,$(MAKECMDGOALS)),)
include $(DEPENDS)
endif
.PHONY: install
install: $(SMLDOC)
install -m 0755 -t $(PREFIX)/$(BINDIR) $(SMLDOC)
.PHONY: smldoc-doc
smldoc-doc: $(SMLDOC) basis-doc
@echo " [SMLDoc] $(DOCDIR)"
@$(RM) -r $(DOCDIR)
@install -d $(DOCDIR)
@$(SMLDOC) -c UTF-8 -a $(SMLDOC_ARGFILE) -d "$(DOCDIR)"
# Generate the 'Basis' documentation
.PHONY: basis-doc
basis-doc: $(SMLDOC)
@echo " [SMLDoc] $(BASIS_DOCDIR)"
@$(RM) -r $(BASIS_DOCDIR)
@install -d $(BASIS_DOCDIR)
@install -d example/SMLBasis/doc/api
@cd example/SMLBasis/src && ../../../$(SMLDOC) -c UTF-8 -d "$$(realpath --relative-to=. ../../../$(BASIS_DOCDIR))" -a SMLDocOptions.txt
.PHONY: example
example: basis-doc
.PHONY: test
test: $(SMLDOC_TEST_MLB:.mlb=)
$(SMLDOC_TEST_MLB:.mlb=)
.PHONY: clean
clean:
-$(RM) $(SMLDOC_MLBS:.mlb=)
-$(RM) $(DEPENDS)
-$(RM) $(SMLDOC)
-$(RM) -r $(DOCDIR)
-$(RM) -r $(BASIS_DOCDIR)
-$(RM) src/main/ML.grm.*
-$(RM) src/main/ML.lex.sml
-$(RM) src/main/ParamPattern.grm.*
-$(RM) src/main/ParamPattern.lex.sml
-$(RM) src/main/LinkFile.grm.*
-$(RM) src/main/LinkFile.lex.sml
-$(RM) src/main/smlnjcm/CM.grm.*
-$(RM) src/main/smlnjcm/CM.lex.sml