-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
101 lines (76 loc) · 2.04 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#
#
# The Quickfall makefile. Allows to build the Quickfall toolchain.
#
#
ifeq ($(OS),Windows_NT)
DETECTED_OS := Windows
TARGET_EXTENSION := .exe
RM := del /Q
MKDIR := mkdir
CP := copy
PATHSEP := \\
else
DETECTED_OS := $(shell uname -s)
TARGET_EXTENSION :=
RM := rm -rf
MKDIR := mkdir -p
CP := cp
PATHSEP := /
endif
#
# Compiling configuration.
#
# Which compiler to use (must be equal to the command used to compile)
COMPILER = gcc
# Flags that are passed to the compiler
FLAGS = -Wall -Wextra -Wimplicit-function-declaration
#
# Path configuration.
#
# The directory containing the code of Quickfall.
SRC_DIR = src
# The directory containing the benchmarks of Quickfall.
BENCH_SRC_DIR = benchmarks
# The directory containg the tests
TESTS_SRC_DIR = tests
#
# Output definition
#
# The target of a normal mode compiling.
TARGET = quickfall$(TARGET_EXTENSION)
# The target of a bench mode compiling.
BENCH_TARGET = bench$(TARGET_EXTENSION)
# The target of a testing mode compiling.
TEST_TARGET = test$(TARGET_EXTENSION)
#
# Building variables
#
# The sources that are going to be compiled in normal mode.
SRCS = $(wildcard ${SRC_DIR}/**/*.c) $(wildcard ${SRC_DIR}/**/**/*.c)
SOURCES = $(subst src/cli/main.c,,${SRCS})
BENCH_SOURCES = ${SOURCES} $(wildcard ${BENCH_SRC_DIR}/**/*.c)
TSRCS = ${SOURCES} $(wildcard ${TESTS_SRC_DIR}/*.c)
TEST_SOURCES = $(subst tests/main.c,,${TSRCS})
#
# Building logic
#
all: prepare_build $(TARGET)
bench: prepare_build $(BENCH_TARGET)
test: prepare_build $(TEST_TARGET)
prepare_build:
@echo [INFO] Using "${COMPILER}" as a compiler!
@echo [INFO] Detected current operating system as ${DETECTED_OS}
$(CHECK_COMMANDS)
@echo [INFO] Starting building logic
clean:
$(RM) build
$(RM) $(TARGET)
$(RM) $(TEST_TARGET)
$(RM) $(BENCH_TARGET)
$(TARGET):
$(COMPILER) $(FLAGS) $(SOURCES) src/cli/main.c -o $(TARGET)
$(BENCH_TARGET):
$(COMPILER) $(FLAGS) $(SOURCES) benchmarks/main.c -o $(BENCH_TARGET)
$(TEST_TARGET):
$(COMPILER) $(FLAGS) $(TEST_SOURCES) tests/main.c -o $(TEST_TARGET)