-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
127 lines (83 loc) · 3.4 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
.PHONY: all build clean rebuild \
logger_build logger_clean logger_rebuild \
gnuplot_build gnuplot_clean gnuplot_rebuild \
clean_all clean_log clean_out clean_obj clean_deps clean_txt clean_bin \
PROJECT_NAME = differ
BUILD_DIR = ./build
SRC_DIR = ./src
COMPILER = gcc
DEBUG_ ?= 1
ifeq ($(origin FLAGS), undefined)
FLAGS = -Wall -Wextra -Waggressive-loop-optimizations \
-Wmissing-declarations -Wcast-align -Wcast-qual -Wchar-subscripts \
-Wconversion -Wempty-body -Wfloat-equal \
-Wformat-nonliteral -Wformat-security -Wformat-signedness -Wformat=2 -Winline -Wlogical-op \
-Wopenmp-simd -Wpacked -Wpointer-arith -Winit-self \
-Wredundant-decls -Wshadow -Wsign-conversion \
-Wstrict-overflow=2 -Wsuggest-attribute=noreturn -Wsuggest-final-methods \
-Wsuggest-final-types -Wswitch-default -Wswitch-enum -Wsync-nand \
-Wundef -Wunreachable-code -Wunused -Wvariadic-macros \
-Wno-missing-field-initializers -Wno-narrowing -Wno-varargs \
-Wstack-protector -fcheck-new -fstack-protector -fstrict-overflow \
-flto-odr-type-merging -fno-omit-frame-pointer -Wlarger-than=81920 -Wstack-usage=81920 -pie \
-fPIE -Werror=vla \
SANITIZER = -fsanitize=address,alignment,bool,bounds,enum,float-cast-overflow,float-divide-by-zero,$\
integer-divide-by-zero,leak,nonnull-attribute,null,object-size,return,returns-nonnull-attribute,$\
shift,signed-integer-overflow,undefined,unreachable,vla-bound,vptr
DEBUG_FLAGS = -D _DEBUG -ggdb -Og -g3 -D_FORTIFY_SOURCES=3 $(SANITIZER)
RELEASE_FLAGS = -DNDEBUG -O2
ifneq ($(DEBUG_),0)
FLAGS += $(DEBUG_FLAGS)
else
FLAGS += $(RELEASE_FLAGS)
endif
endif
FLAGS += $(ADD_FLAGS)
LIBS = -lm -L./libs/logger -llogger -L./libs/gnuplot -lgnuplot
DIRS = utils flags tree tree/verification tree/operation tree/funcs
BUILD_DIRS = $(DIRS:%=$(BUILD_DIR)/%)
SOURCES = main.c utils/utils.c flags/flags.c tree/funcs/funcs_create.c tree/funcs/funcs_diff.c \
tree/verification/verification.c tree/verification/dumb.c tree/operation/op_diff.c \
tree/operation/op_math.c tree/operation/operation.c tree/funcs/funcs_output.c \
tree/funcs/funcs_input.c tree/funcs/funcs_simplify.c mode_funcs.c
SOURCES_REL_PATH = $(SOURCES:%=$(SRC_DIR)/%)
OBJECTS_REL_PATH = $(SOURCES:%.c=$(BUILD_DIR)/%.o)
DEPS_REL_PATH = $(OBJECTS_REL_PATH:%.o=%.d)
all: build start
start:
./$(PROJECT_NAME).out $(OPTS)
build: $(PROJECT_NAME).out
rebuild: clean_all build
$(PROJECT_NAME).out: $(OBJECTS_REL_PATH)
@$(COMPILER) $(FLAGS) -o $@ $^ $(LIBS) -lm
$(BUILD_DIR)/%.o : $(SRC_DIR)/%.c | ./$(BUILD_DIR)/ $(BUILD_DIRS) logger_build gnuplot_build
@$(COMPILER) $(FLAGS) -I$(SRC_DIR) -I./libs -c -MMD -MP $< -o $@
-include $(DEPS_REL_PATH)
$(BUILD_DIRS):
mkdir $@
./$(BUILD_DIR)/:
mkdir $@
logger_rebuild: logger_build logger_clean
logger_build:
@make ADD_FLAGS="$(ADD_FLAGS)" FLAGS="$(FLAGS)" DEBUG_=$(DEBUG_) build -C ./libs/logger
logger_clean:
make ADD_FLAGS="$(ADD_FLAGS)" clean -C ./libs/logger
gnuplot_rebuild: gnuplot_build gnuplot_clean
gnuplot_build:
@make ADD_FLAGS="$(ADD_FLAGS)" FLAGS="$(FLAGS)" DEBUG_=$(DEBUG_) build -C ./libs/gnuplot
gnuplot_clean:
make ADD_FLAGS="$(ADD_FLAGS)" clean -C ./libs/gnuplot
clean_all: clean_obj clean_deps clean_out logger_clean gnuplot_clean
clean: clean_obj clean_deps clean_out
clean_log:
rm -rf ./log/*
clean_out:
rm -rf ./*.out
clean_obj:
rm -rf ./$(OBJECTS_REL_PATH)
clean_deps:
rm -rf ./$(DEPS_REL_PATH)
clean_txt:
rm -rf ./*.txt
clean_bin:
rm -rf ./*.bin