-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
59 lines (56 loc) · 1.84 KB
/
Makefile
File metadata and controls
59 lines (56 loc) · 1.84 KB
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
TARGET = pmem
SRC_DIR = src
INC_DIR = inc
BUILD_DIR = build
SRC = $(SRC_DIR)/main.c
OBJ = $(BUILD_DIR)/main.o
#------------------------------------------------------------------------------
CC = gcc
#------------------------------------------------------------------------------
CFLAGS = \
-O1 \
-Wall \
-Wextra \
# -Werror
-std=c17 \
-Wconversion \
-Wpedantic \
-Wnull-dereference \
-fanalyzer\
-D_FORTIFY_SOURCE=2 \
-fstack-protector-strong \
-fstack-clash-protection \
-fPIE \
-z,relro \
-fcf-protection=full \
#CFLAGS:
# -O1 - optimisation level
# - Wall - output all warnings
# -Wextra - strengthening code auditing during compilation
# -Werror - COMMENTARIED. the option what turnes all warmings to errors
# -std=c17 - choosen clang standard
# -Wconversion - warnings about implicit type conversions with possible data loss
# -Wpedantic - strict adherence to the standard
# -Wnull-dereference - null pointer dereference detection
# -fanalyzer - enabling static analysis
# -D_FORTIFY_SOURCE=2 - replacing system memory functions with safer analogs
# -fstack-protector-strong - stack canaries. protection of callback to the function return address
# -fstack-clash-protection - protecting program execution during stack overflow
# -fPIE - independence from the memory address of the binary file execution
# -z,relro - changing the operating mode of dynamic linkage tables of standard libc functions
# -fcf-protection=full - hardware support for a second program stack with return addresses
CFLAGS += -Iinc/
LDFLAGS = \
-pie \
-Wl,-z,relro \
-Wl,-z,now \
#------------------------------------------------------------------------------
all: $(BUILD_DIR) $(TARGET)
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
$(TARGET): $(OBJ)
$(CC) $(OBJ) -o $(BUILD_DIR)/$(TARGET) $(LDFLAGS)
$(OBJ): $(SRC)
$(CC) $(CFLAGS) -c $(SRC) -o $(OBJ)
clean:
rm -rf $(BUILD_DIR) $(TARGET)