-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSetup.mk
36 lines (30 loc) · 886 Bytes
/
Setup.mk
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
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (C) 2022 Tomas Paukrt
# ccache command
CCACHE := $(shell command -v ccache 2> /dev/null)
# subdirectory for object files
OBJDIR := OBJ
# basic compiler flags
CFLAGS += -Wall -Wextra -Wshadow -Wmissing-declarations -Wformat-security
# extra compiler flags for debug and release build
ifeq ($(DEBUG),1)
OBJDIR := $(OBJDIR).debug
CFLAGS += -O0 -ggdb
CPPFLAGS += -DDEBUG
else
OBJDIR := $(OBJDIR).release
CFLAGS += -O2
LDFLAGS += -s
endif
# extra compiler flags for address sanitizer
ifeq ($(ASAN),1)
OBJDIR := $(OBJDIR).asan
CFLAGS += -fsanitize=address -fno-omit-frame-pointer
LDFLAGS += -fsanitize=address
endif
# extra compiler flags for undefined behavior sanitizer
ifeq ($(UBSAN),1)
OBJDIR := $(OBJDIR).ubsan
CFLAGS += -fsanitize=undefined -fno-omit-frame-pointer
LDFLAGS += -fsanitize=undefined
endif