-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
74 lines (60 loc) · 2.3 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
## Map Guard Makefile
CC = clang
SHELL := /bin/bash
## Support for multithreaded programs
THREADS = -DTHREAD_SUPPORT=1
## Support for Intel MPK
MPK = -DMPK_SUPPORT=0
CFLAGS = -Wall -std=c11
EXE_CFLAGS = -fPIE -pie
DEBUG_FLAGS = -DDEBUG -ggdb
LIBRARY = -fPIC -shared -ldl
ASAN = -fsanitize=address
TEST_FLAGS = -DVECTOR_UNIT_TEST=1
VECTOR_SRC = vector_t/vector.c
SRC = src
INCLUDE = include
TEST_SRC = tests
SRC_FILES = *.c
BUILD_DIR = build
STRIP = strip -s $(BUILD_DIR)/libmapguard.so
ifeq ($(THREADS), -DTHREAD_SUPPORT=1)
CFLAGS += -lpthread $(THREADS)
endif
ifeq ($(MPK), -MPK_SUPPORT=1)
CFLAGS += $(MPK)
endif
all: library library_mpk tests
## Build the library
library: clean
@echo "make clean"
mkdir -p $(BUILD_DIR)/
$(CC) $(CFLAGS) $(LIBRARY) $(SRC)/$(SRC_FILES) -I $(INCLUDE) $(VECTOR_SRC) -o $(BUILD_DIR)/libmapguard.so
$(STRIP)
## Build a debug version of the library
library_debug: clean
@echo "make library_debug"
mkdir -p $(BUILD_DIR)/
$(CC) $(CFLAGS) $(LIBRARY) $(DEBUG_FLAGS) $(SRC)/$(SRC_FILES) -I $(INCLUDE) $(VECTOR_SRC) -o $(BUILD_DIR)/libmapguard.so
## Build the library with MPK support
library_mpk: clean
@echo "make library_mpk"
mkdir -p $(BUILD_DIR)/
$(CC) $(CFLAGS) $(LIBRARY) $(MPK) $(SRC)/$(SRC_FILES) -I $(INCLUDE) $(VECTOR_SRC) -o $(BUILD_DIR)/libmapguard_mpk.so
## Build a debug version of the library with MPK support
library_mpk_debug: clean
@echo "make library_mpk_debug"
mkdir -p $(BUILD_DIR)/
$(CC) $(CFLAGS) $(LIBRARY) $(MPK) $(DEBUG_FLAGS) $(SRC)/$(SRC_FILES) -I $(INCLUDE) $(VECTOR_SRC) -o $(BUILD_DIR)/libmapguard_mpk.so
## Build the unit tests
tests: clean library_debug library_mpk_debug
@echo "make tests"
mkdir -p $(BUILD_DIR)/
$(CC) $(CFLAGS) $(EXE_CFLAGS) $(DEBUG_FLAGS) $(TEST_SRC)/mapguard_test.c -I $(INCLUDE) $(VECTOR_SRC) -o $(BUILD_DIR)/mapguard_test -L build/ -lmapguard -ldl
$(CC) $(CFLAGS) $(EXE_CFLAGS) $(DEBUG_FLAGS) $(MPK) $(TEST_SRC)/mapguard_test.c -I $(INCLUDE) $(VECTOR_SRC) -o $(BUILD_DIR)/mapguard_test_with_mpk -L build/ -lmapguard_mpk -ldl
$(CC) $(CFLAGS) $(EXE_CFLAGS) $(DEBUG_FLAGS) $(MPK) $(TEST_SRC)/mapguard_thread_test.c -I $(INCLUDE) $(VECTOR_SRC) -o $(BUILD_DIR)/mapguard_thread_test -L build/ -lmapguard_mpk -lpthread -ldl
./run_tests.sh
format:
clang-format $(INCLUDE)/*.* $(SRC)/*.* $(TEST_SRC)/*.* -i
clean:
rm -rf build/* test_output.txt core