-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
65 lines (52 loc) · 1.38 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
# Project structure
RECIPE ?=
BUILD_DIR ?= bin
SOURCE_DIR ?= src
# Project parameters
PROJECT = main
SOURCES = $(wildcard $(SOURCE_DIR)/main.ml)
OBJECTS = $(patsubst $(SOURCE_DIR)/%.ml, $(BUILD_DIR)/%.c, $(SOURCES))
ASM_OBJECTS = $(patsubst $(SOURCE_DIR)/%.ml, $(BUILD_DIR)/%.S, $(SOURCES))
# C compiler parameters
CC = gcc
CFLAGS ?=
CFLAGS += -g
# Compiler parameters
ML = python ../../src/Main.py
MLLIB ?= "../../include"
MLFLAGS ?=
MLFLAGS += -C
# Recipes
default: clean def
c: clean _c
ml: clean _ml
debug: clean _mldebug
cdebug: clean _cdebug
assemble: $(ASM_OBJECTS)
compile: $(PROJECT)
# Shortcuts
def: c
dbg: debug
cdbg: cdebug
asm: assemble
_c: $(SOURCES)
@mkdir -p $(BUILD_DIR)
$(ML) $(MLFLAGS) -I $(MLLIB) -I src $(SOURCES) > $(BUILD_DIR)/$(PROJECT).c
$(CC) $(CFLAGS) -I include include/*.c $(BUILD_DIR)/$(PROJECT).c -o $(BUILD_DIR)/$(PROJECT)
_cdebug: $(SOURCES)
$(ML) $(MLFLAGS) -I $(MLLIB) -I src $(SOURCES)
_ml:
@mkdir -p $(BUILD_DIR)
$(ML) $(MLFLAGS) -d -I $(MLLIB) -I src $(SOURCES) -o $(BUILD_DIR)/$(PROJECT).ml
_mldebug: $(SOURCES)
$(ML) $(MLFLAGS) -d -I $(MLLIB) -I src $(SOURCES)
$(PROJECT) : $(OBJECTS)
$(CC) $(CFLAGS) $(CXX) $^ -o $(BUILD_DIR)/$@
$(BUILD_DIR)/%.o: $(BUILD_DIR)/%.S
@mkdir -p $(BUILD_DIR)
$(CC) $(CFLAGS) $^ -o $@
$(BUILD_DIR)/%.S: $(SOURCE_DIR)/%.ml
@mkdir -p $(BUILD_DIR)
$(ML) $(MLFLAGS) -I $(MLLIB) -I src $< -o $@
clean:
@rm -vrf $(BUILD_DIR)