-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathMakefile.smlsharp
110 lines (88 loc) · 2.68 KB
/
Makefile.smlsharp
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
# -*- Makefile -*-
####################################################################################
#
# QCheck
# automatic unit testing of Standard ML modules.
#
####################################################################################
SMLSHARP = smlsharp
PERL = perl
## search directories
VROOT = .
VPATH = $(VROOT):$(VROOT)/src
INCDIR = $(patsubst %,-I%,$(subst :, ,$(VPATH)))
## compile options
SMLSHARPFLAGS = $(INCDIR)
## test patterns
TESTS = compose reverse from-to-str from-to-smlsharp
## source code
SRC=src
SRCS= $(SRC)/BagFromMap.sml \
$(SRC)/BaseGeneratorFn.sml \
$(SRC)/CMStyle.sml \
$(SRC)/Files.sml \
$(SRC)/GenDateTime.sml \
$(SRC)/GenInt.sml \
$(SRC)/GenReal.sml \
$(SRC)/GenText.sml \
$(SRC)/GenWord.sml \
$(SRC)/PerlStyle.sml \
$(SRC)/Property.sml \
$(SRC)/QCheck.sml \
$(SRC)/QCheckVersion.sml \
$(SRC)/Rand.sml \
$(SRC)/RandGen-smlsharp.sml \
$(SRC)/Settings.sml \
$(SRC)/StringBag.sml \
$(SRC)/TextStreamIO.sml
SHARP_SRC = $(SRC)/GENERATOR_SIG-smlsharp.sml \
$(SRC)/RandGen-smlsharp.sml \
tests/from-to-smlsharp.sml
## categorise object file
OBJS = $(filter %.o,$(SRCS:.sml=.o))
## default targets
all: $(OBJS)
include Makefile.version
## compiler dependent modules
$(SHARP_SRC): scripts/basis-gen.pl scripts/smlsharp-basis.pl
$(PERL) scripts/basis-gen.pl $(SHARP_SRC) \
`$(PERL) scripts/smlsharp-basis.pl $(SMLSHARP)`
## .o type rules
%.o: %.sml
@echo " SML# [$@]"
@SMLSHARP_HEAPSIZE=32M:2G $(SMLSHARP) $(SMLSHARPFLAGS) -c $<
## generate for SML dependence
%.d: %.sml
@echo " GEN [$@]"
@$(SHELL) -ec '$(SMLSHARP) -MM $(SMLSHARPFLAGS) $< \
| sed "s!\($*\)\.o[ :]*!\1.o $@ : !g" > $@; \
[ -s $@ ] || rm -rf $@'
ifeq (,$(findstring clean,$(MAKECMDGOALS)))
## include generated dependence
include $(filter %.d,$(SRCS:.sml=.d))
endif
## test rules
TEST_EXES = $(addprefix tests/,$(TESTS))
TEST_SRCS = $(addsuffix .sml,$(addprefix tests/,$(TESTS)))
TEST_OBJS = $(TEST_SRCS:.sml=.o)
$(TEST_EXES): $(TEST_OBJS)
@echo " [LINK] $@"
@$(SMLSHARP) $(SMLSHARPFLAGS) -o $@ $(addsuffix .smi,$@)
test: $(OBJS) $(TEST_EXES)
@for test in $(TEST_EXES); do \
echo " [TEST] $$(basename $$test)"; \
$$test ; \
done
ifeq (test,$(findstring test,$(MAKECMDGOALS)))
include $(TEST_SRCS:.sml=.d)
endif
.PHONY: clean
clean:
$(RM) $(OBJS)
$(RM) $(filter %.d,$(SRCS:.sml=.d))
$(RM) $(SHARP_SRC)
$(RM) $(TEST_SRCS:.sml=.d)
$(RM) $(TEST_OBJS)
$(RM) $(TEST_EXES)
realclean: clean
mostlyclean: clean