-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.polyml
126 lines (91 loc) · 2.86 KB
/
Makefile.polyml
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
POLYML := poly
POLYMLC := polyc
POLYMLFLAGS := -q --error-exit \
--eval 'PolyML.suffixes := ".sig"::(!PolyML.suffixes)' \
--use script/loadModule.sml
PREFIX := /usr/local/polyml
LIBDIR := lib/libsha3sml
DOCDIR := doc/libsha3sml
SMLDOC := smldoc
SRC := $(wildcard src/*.sml src/*.sig)
TEST_SRC := $(wildcard test/*.sml)
LIBSHA3SML := libsha3sml.poly
TEST := bin/libsha3sml-test-poly
# Path to the directory which contains the binary module of [SMLUnit] like:
# > make -f Makefile.polyml POLYML_LIBDIR=~/.sml/polyml/5.8.1/lib
POLYML_LIBDIR := SPECIFY_THE_POLYML_LIBDIR
# For profiling, define 'MEASURE=Timer' like:
# > make -f Makefile.polyml MEASURE=Timer test
ifeq "$(MEASURE)" "Timer"
MEASURE_MODULE = MeasureTimer.sml
else
MEASURE_MODULE = MeasureDummy.sml
endif
define export-module
@echo " [POLYML] $@"
@echo "" | $(POLYML) $(POLYMLFLAGS) \
$(foreach dep,$(3),--eval 'loadModule "$(dep)"') \
--eval 'PolyML.make "$(2)"' \
--eval 'PolyML.export("$@", $(1))'
endef
all: libsha3sml
.PHONY: libsha3sml-nodoc
libsha3sml-nodoc: $(LIBSHA3SML)
.PHONY: libsha3sml
libsha3sml: libsha3sml-nodoc doc
$(LIBSHA3SML): export.sml $(SRC)
@echo " [POLYML] $@"
@echo "" | $(POLYML) $(POLYMLFLAGS) \
--use src/$(MEASURE_MODULE) \
--eval 'PolyML.make "src"' \
--use export.sml \
--eval 'PolyML.SaveState.saveModule ("$(LIBSHA3SML)", Sha3)'
$(TEST).o: $(LIBSHA3SML) $(TEST_SRC)
$(call export-module,Sha3Test.main'\'',test,'./$<' '$(POLYML_LIBDIR)/smlunit-lib/smlunit-lib.poly')
$(TEST): %: %.o
@echo " [POLYC] $@"
@$(POLYMLC) -o $@ $^
.PHONY: install-nodoc
install-nodoc: libsha3sml-nodoc
@install -D -m 644 -t $(PREFIX)/$(LIBDIR) $(LIBSHA3SML)
@echo "================================================================"
@echo "libsha3sml has been installed to:"
@echo "\t$(PREFIX)/$(LIBDIR)/$(LIBSHA3SML)"
@echo "================================================================"
.PHONY: install
install: install-doc install-nodoc
.PHONY: doc
doc:
@echo " [SMLDoc]"
@$(RM) -r $(DOCDIR)
@install -d $(DOCDIR)
@$(SMLDOC) -c UTF-8 \
--builtinstructure=Word8 \
--builtinstructure=TextIO \
--builtinstructure=VectorSlice \
--builtinstructure=Timer \
--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 SMLUnit"
@echo "\t$(PREFIX)/$(DOCDIR)"
@echo "================================================================"
.PHONY: test
test: $(TEST)
./$(TEST)
.PHONY: test-ignored
test-ignored: $(TEST)
./$(TEST) --ignored
.PHONY: clean
clean:
-$(RM) $(LIBSHA3SML)
-$(RM) -r $(DOCDIR)
-$(RM) $(TEST)
-$(RM) $(TEST:=.o)