-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.smlnj
127 lines (90 loc) · 2.93 KB
/
Makefile.smlnj
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
SML := sml
# -32 or -64
# empty is default
SML_BITMODE :=
SML_FLAGS :=
HEAP_SUFFIX := $(shell $(SML) $(SML_BITMODE) @SMLsuffix)
# directory of CM product
CM_SUFFIX := $(shell $(SML) $(SML_BITMODE) < script/suffix.sml 2>&1 >/dev/null)
SMLDOC := smldoc
MLBUILD := ml-build
MLBUILD_FLAGS :=
MLDEPENDS := ml-makedepend
MLDEPENDS_FLAGS := -n
# for profiling, set '-DMEASURE'
SML_DULIST :=
PREFIX := /usr/local/sml
LIBDIR := lib/libsha3sml.cm
DOCDIR := doc/libsha3sml
DEPENDS := libsha3sml.d test/sources.d
TEST_TARGET := bin/Sha3Test.$(HEAP_SUFFIX)
all: libsha3sml
.PHONY: libsha3sml-nodoc
libsha3sml-nodoc: .cm/$(CM_SUFFIX)/libsha3sml.cm
.PHONY: libsha3sml
libsha3sml: libsha3sml-nodoc doc
.cm/$(CM_SUFFIX)/%.cm: %.cm
@echo " [SMLNJ] $@"
@echo 'CM.stabilize true "libsha3sml.cm";' | $(SML) $(SML_BITMODE) $(SML_DULIST)
$(DEPENDS): %.d: %.cm
@echo " [GEN] $@"
@touch $@
@$(MLDEPENDS) $(MLDEPENDS_FLAGS) $(SML_BITMODE) $(SML_DULIST) -f $@ $< $(dir $<).cm/$(CM_SUFFIX)
@sed -i -e "s|^\([^#][^:]\+\):|\1 $@:|" $@
ifeq (,$(findstring clean,$(MAKECMDGOALS)))
include $(DEPENDS)
endif
.PHONY: install-nodoc
install-nodoc: libsha3sml-nodoc
@install -d $(PREFIX)/$(LIBDIR)
@cp -R .cm $(PREFIX)/$(LIBDIR)/
@echo "================================================================"
@echo "libsha3sml has been installed to:"
@echo "\t$(PREFIX)/$(LIBDIR)"
@echo "Add an entry to your pathconfig (e.g. ~/.smlnj-pathconfig) such like:"
@echo "\tlibsha3sml.cm $(PREFIX)/$(LIBDIR)"
@echo "Then you can load the library like"
@echo "\t- CM.make \"$$/libsha3sml.cm\";"
@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 Sha3SML"
@echo "\t$(PREFIX)/$(DOCDIR)"
@echo "================================================================"
$(TEST_TARGET): test/.cm/$(CM_SUFFIX)
@mkdir -p bin
@$(MLBUILD) $(SML_BITMODE) $(SML_DULIST) $(MLBUILD_FLAGS) $(patsubst %/.cm/$(CM_SUFFIX),%/sources.cm,$<) Sha3Test.main $@
.PHONY: test
test: $(TEST_TARGET)
$(SML) $(SML_BITMODE) $(SML_DULIST) $(SML_FLAGS) @SMLload=$<
.PHONY: test-ignored
test-ignored: $(TEST_TARGET)
$(SML) $(SML_BITMODE) $(SML_DULIST) $(SML_FLAGS) @SMLload=$< --ignored
.PHONY: clean
clean:
-$(RM) $(DEPENDS)
-$(RM) -r $(DOCDIR)
-$(RM) $(TEST_TARGET)
-$(RM) -r .cm
-$(RM) -r src/.cm
-$(RM) -r test/.cm