-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.mlton
155 lines (116 loc) · 3.43 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
MLTON := mlton
MLTON_FLAGS :=
# path to the file `mlb-path-map`
ifneq ($(MLB_PATH_MAP),)
MLTON_FLAGS += -mlb-path-map $(MLB_PATH_MAP)
endif
SMLDOC := smldoc
PREFIX := /usr/local/mlton
LIBDIR := lib/libsha3sml
DOCDIR := doc/libsha3sml
TEST_MLB := test/sources.mlb
LIBSHA3SML_MLBS := libsha3sml.mlb \
$(TEST_MLB)
DEPENDS := $(LIBSHA3SML_MLBS:.mlb=.mlb.d)
TYPECHECK_DUMMY := bin/.libsha3sml
all: libsha3sml
.PHONY: libsha3sml-nodoc
libsha3sml-nodoc: $(TYPECHECK_DUMMY)
.PHONY: libsha3sml
libsha3sml: libsha3sml-nodoc doc
$(TYPECHECK_DUMMY): libsha3sml.mlb
@echo " [MLTON] typecheck: $<"
@$(MLTON) $(MLTON_FLAGS) -stop tc $<
@mkdir -p $(dir $@)
@touch $@
# for profiling, define 'MEASURE=Timer' like:
# > make MEASURE=Timer test
src/sources.mlb: src/sources.mlb.m4
@echo " [M4] $@"
ifeq "$(MEASURE)" "Timer"
@m4 -DMEASURE $< > $@
else
@m4 $< > $@
endif
libsha3sml.mlb.d: libsha3sml.mlb
@echo " [GEN] $@"
@$(SHELL) -ec '$(MLTON) '"$(MLTON_FLAGS)"' -stop f $< \
| while read file; do \
if expr $$(readlink -f $$file) : ^$$(pwd) >/dev/null; then \
echo "$$(realpath --relative-to=$$(pwd) $$file)" ; \
else \
echo $$file; \
fi; \
done \
| sed -e "1i$(TYPECHECK_DUMMY) $@:\\\\" -e "s|.*| & \\\\|" -e "\$$s| \\\\||" > $@; \
[ -s $@ ] || rm -rf $@'
%.mlb.d: %.mlb
@echo " [GEN] $@"
@$(SHELL) -ec '$(MLTON) '"$(MLTON_FLAGS)"' -stop f $< \
| while read file; do \
if expr $$(readlink -f $$file) : ^$$(pwd) >/dev/null; then \
echo "$$(realpath --relative-to=$$(pwd) $$file)" ; \
else \
echo $$file; \
fi; \
done \
| sed -e "1i$(<:.mlb=) $@:\\\\" -e "s|.*| & \\\\|" -e "\$$s| \\\\||" > $@; \
[ -s $@ ] || rm -rf $@'
ifeq ($(findstring clean,$(MAKECMDGOALS)),)
include $(DEPENDS)
endif
.PHONY: install-nodoc
install-nodoc: libsha3sml-nodoc
@install -d $(PREFIX)/$(LIBDIR)
@$(MLTON) $(MLTON_FLAGS) -stop f libsha3sml.mlb | \
while read file; do \
if expr $$(readlink -f $$file) : ^$$(pwd) >/dev/null; then \
cp --parents $$(realpath --relative-to=$$(pwd) $$file) $(PREFIX)/$(LIBDIR); \
echo -n . ; \
fi; \
done
@echo "Installation has been completed."
@echo "Add the entry to your mlb path map file:"
@echo ""
@echo " SHA3SML $(PREFIX)/$(LIBDIR)"
@echo ""
.PHONY: install
install: install-doc install-nodoc
.PHONY: doc
doc:
@echo " [SMLDoc] $(DOCDIR)"
@$(RM) -r $(DOCDIR)
@install -d $(DOCDIR)
@$(SMLDOC) -c UTF-8 \
--builtinstructure=Word8 \
--builtinstructure=TextIO \
--builtinstructure=VectorSlice \
--hidebysig \
--recursive \
--linksource \
-d $(DOCDIR) \
libsha3sml.cm
.PHONY: install-doc
install-doc: doc
@install -d $(PREFIX)/$(DOCDIR)
@cp -prT $(DOCDIR) $(PREFIX)/$(DOCDIR)
@echo "================================================================"
@echo "Generated API Documents of Sha3SML"
@echo "\t$(PREFIX)/$(DOCDIR)"
@echo "================================================================"
$(TEST_MLB:.mlb=): %: %.mlb
@echo " [MLTON] $@"
@$(MLTON) $(MLTON_FLAGS) -output $@ $<
.PHONY: test
test: $(TEST_MLB:.mlb=)
$(TEST_MLB:.mlb=)
.PHONY: test-ignored
test-ignored: $(TEST_MLB:.mlb=)
$(TEST_MLB:.mlb=) --ignored
.PHONY: clean
clean:
-$(RM) src/sources.mlb
-$(RM) $(TYPECHECK_DUMMY)
-$(RM) $(DEPENDS)
-$(RM) -r $(DOCDIR)
-$(RM) $(filter-out libsha3sml,$(LIBSHA3SML_MLBS:.mlb=))