-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
80 lines (64 loc) · 2.45 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
# ------------------------------------------------------------
# configure for lib/
# ------------------------------------------------------------
# SML files
MODULES = $(wildcard lib/*/*.sml)
C_MODULES = $(wildcard lib/*/*.c)
# ------------------------------------------------------------
# configure for test
# ------------------------------------------------------------
TEST_MODULES = $(wildcard test/*/*.sml) test/Main.sml
TEST_TARGET = testRunner
# ------------------------------------------------------------
# configure for test
# ------------------------------------------------------------
EXAMPLE_MODULES = $(wildcard example/*.sml)
EXAMPLE_MAIN = hello
TARGET = example/hello
# ------------------------------------------------------------
# Flags
# ------------------------------------------------------------
SMLSHARP = smlsharp
SMLSHARP_FLAGS = -I lib
SMLSHARP_CFLAGS = -O2
SMLSHARP_LDFLAGS =
CFLAGS += -m32 -Iinclude
# ------------------------------------------------------------
# prepare variables
# ------------------------------------------------------------
sources := $(MODULES)
objects := $(sources:.sml=.o)
c_sources = $(C_MODULES)
c_objects := $(c_sources:.c=.o)
test_sources := $(TEST_MODULES)
test_objects := $(test_sources:.sml=.o)
example_sources := $(EXAMPLE_MODULES)
example_objects := $(example_sources:.sml=.o)
# ------------------------------------------------------------
# Build target
# ------------------------------------------------------------
.PHONY: all clean check
all: $(TARGET)
$(TARGET): $(example_objects) $(objects) $(c_objects)
$(SMLSHARP) $(SMLSHARP_LDFLAGS) $(SMLSHARP_FLAGS) -o $@ example/$(EXAMPLE_MAIN).smi $(c_objects)
$(TEST_TARGET): $(objects) $(c_objects) $(lib_objects) $(test_objects)
$(SMLSHARP) $(SMLSHARP_LDFLAGS) $(SMLSHARP_FLAGS) -o $@ test/Main.smi $(c_objects)
check: $(TEST_TARGET)
./$(TEST_TARGET)
clean:
find . -name '*.o' | xargs rm -rf
rm -rf $(TARGET) $(TEST_TARGET)
# ------------------------------------------------------------
# Build rules
# ------------------------------------------------------------
%.o: %.sml
$(SMLSHARP) $(SMLSHARP_CFLAGS) $(SMLSHARP_FLAGS) -c -o $@ $<
%.o: %.c
$(CC) $(CFLAGS) $(DEFS) $(CPPFLAGS) -c -o $@ $<
# ------------------------------------------------------------
# Dependencies
# ------------------------------------------------------------
.PHONY: depend
depend:
$(SMLSHARP) $(SMLSHARP_FLAGS) -MM $(sources) $(test_sources) $(lib_sources) > .depend
-include .depend