-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
60 lines (39 loc) · 1.6 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
########################
### MAKEFILE ###
########################
PROJECT_DIR ?= $(shell pwd)
include $(PROJECT_DIR)/global.mk
FSANITIZE = -fsanitize=address -fsanitize=undefined -fsanitize=leak -fsanitize=null -fsanitize=signed-integer-overflow
CC = gcc
CFLAGS = -Wall -Wextra -Werror -Iinclude -g -std=gnu99 -D_ISOC11_SOURCE
LDFLAGS = -lm -lcrypto $(FSANITIZE)
SRC = $(shell find $(FS_CORE_DIR) -name '*.c')
OBJ = $(subst $(PROJECT_DIR),$(BUILD_DIR),$(SRC:.c=.o))
TESTS_SRC = $(shell find $(TESTS_DIR) -name '*.c')
TESTS_OBJ = $(subst $(PROJECT_DIR),$(BUILD_DIR),$(TESTS_SRC:.c=.o))
FORMAT_SRC = $(SRC_DIR)/formater.c
FORMAT_OBJ = $(subst $(PROJECT_DIR),$(BUILD_DIR),$(FORMAT_SRC:.c=.o))
MOUNT_SRC = $(SRC_DIR)/mount_fuse.c
MOUNT_OBJ = $(subst $(PROJECT_DIR),$(BUILD_DIR),$(MOUNT_SRC:.c=.o))
all : formater mount
formater: $(BUILD_DIR)/formater $(OBJ)
mount: $(BUILD_DIR)/mount $(OBJ)
$(BUILD_DIR)/formater: $(FORMAT_OBJ) $(OBJ)
$(CC) $(CFLAGS) $^ -o $(BUILD_DIR)/formater $(LDFLAGS)
$(BUILD_DIR)/mount: $(MOUNT_OBJ) $(OBJ)
$(CC) $(CFLAGS) $^ -o $(BUILD_DIR)/mount $(LDFLAGS)
$(BUILD_DIR)/%.o: $(PROJECT_DIR)/%.c
mkdir -p $(dir $@)
$(CC) $(CFLAGS) -c $< -o $@ $(LDFLAGS)
tests_suite: $(BUILD_DIR)/tests_suite
$(BUILD_DIR)/tests_suite: LDFLAGS += -lcriterion
$(BUILD_DIR)/tests_suite: $(TESTS_OBJ) $(OBJ)
$(CC) $(CFLAGS) $^ -o $(BUILD_DIR)/tests_suite $(LDFLAGS)
test_main: $(BUILD_DIR)/test_main
$(BUILD_DIR)/test_main: $(OBJ) $(BUILD_DIR)/tests/test_main.o
$(CC) $(CFLAGS) -o $(BUILD_DIR)/test_main $^ $(LDFLAGS)
check: tests_suite
$(BUILD_DIR)/tests_suite
clean:
rm -rf $(BUILD_DIR)
.PHONY: clean