-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
51 lines (40 loc) · 1022 Bytes
/
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
CC=cc
OPT=-O2
STD=-std=gnu18
LDFLAGS=-lseccomp
WARNING=-Werror -Wall -Wextra -Wpedantic -Wfloat-equal -Wundef -Wshadow \
-Wpointer-arith -Wcast-align -Wstrict-prototypes -Wmissing-prototypes \
-Wstrict-overflow=5 -Wwrite-strings -Waggregate-return -Wcast-qual \
-Wswitch-enum -Wunreachable-code -Wformat -Wformat-security -Wvla \
FLAGS=-fstack-protector-all -fPIE -pipe -fcf-protection
CFLAGS=$(WARNING) $(STD) $(OPT) $(FLAGS)
SRC = $(wildcard *.c)
HEADERS = $(wildcard *.h)
OBJS = $(patsubst %.c,%.o,$(SRC))
.PHONY: release
release: OPT=-O2 -D_FORTIFY_SOURCE=2
release: all
.PHONY: debug
debug: OPT=-O0 -ggdb3
debug: all
.PHONY: sanitize
sanitize: OPT=-O0 -ggdb3 -fsanitize=address,undefined,leak
sanitize: all
.PHONY: all
all: capejail
capejail: $(OBJS)
$(CC) -o capejail $(OBJS) $(CFLAGS) $(LDFLAGS)
%.o: %.c $(HEADERS)
$(CC) -c $< -o $@ $(CFLAGS)
.PHONY: lint
lint:
clang-tidy *.c *.h
.PHONY: fmt
fmt:
clang-format -i *.c *.h
.PHONY: clean
clean:
rm -f *.a
rm -f *.so
rm -f *.o
rm -f capejail