-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
86 lines (62 loc) · 1.6 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
####################################################################################
#
# SMLUnit
# SML Unit Testing Framework
#
####################################################################################
SMLSHARP_ENV ?= SMLSHARP_HEAPSIZE=128M:1G
SMLSHARP := smlsharp
SMLDOC := smldoc
## search directories
VROOT := .
VPATH := $(VROOT):$(VROOT)/src/main
INCDIR := $(subst :, ,$(VPATH))
## compile options
SMLFLAGS := $(patsubst %,-I%,$(INCDIR))
## source code
SRCS := $(filter-out src/main/ml_bind.sml,$(wildcard src/main/*.sml))
## object file
OBJS := $(SRCS:.sml=.o)
TARGETS := $(OBJS)
# documents
SMLDOC_ARGFILE := src/smldoc.cfg
DOCDIR := doc/api
all: $(OBJS)
## .o type rules
%.o: %.sml
@echo " SML# [$(notdir $@)]"
@$(SMLSHARP_ENV) $(SMLSHARP) $(SMLFLAGS) -o $@ -c $<
## SML depends
%.d: %.sml
@echo " GEN [$(notdir $@)]"
@$(SHELL) -ec '$(SMLSHARP_ENV) $(SMLSHARP) -MM $(SMLFLAGS) $< \
| sed "s|\($*\)\.o[ :]*|\1.o $@ : |g" > $@; \
[ -s $@ ] || rm -rf $@'
ifeq (,$(findstring $(MAKECMDGOALS),clean))
## include generated dependence
include $(filter %.d,$(SRCS:.sml=.d))
endif
.PHONY: test
test: $(OBJS)
$(MAKE) -C src/test
./src/test/testExec
$(MAKE) -C basis/test
./basis/test/testExec
.PHONY: example
example: $(OBJS)
$(MAKE) -C example
./example/testExec
.PHONY: doc
doc: $(DOCDIR)
@echo " Doc [$(DOCDIR)]"
@$(SMLDOC) -a $(SMLDOC_ARGFILE) -d "$(DOCDIR)" -t "SMLUnit"
$(DOCDIR):
@mkdir -p $(DOCDIR)
.PHONY: clean
clean:
-$(RM) -r $(TARGETS)
-$(RM) -r $(SRCS:.sml=.d)
-$(RM) -r $(DOCDIR)
$(MAKE) -C src/test clean
$(MAKE) -C example clean
$(MAKE) -C basis/test clean