-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathMakefile-simple
65 lines (50 loc) · 1.5 KB
/
Makefile-simple
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
# Makefile template for small simple projects
EXEC = execname
DEPS = # static files like assets
SOURCES = $(wildcard *.c)
OBJECTS = $(SOURCES:.c=.o)
HEADERS = $(wildcard *.h)
INCLUDES = # additional headers, maybe in includes/
CC = gcc
CFLAGS = -fno-omit-frame-pointer -std=c11 -Wall -Wextra -Wpedantic
CFLAGS += -Wmissing-prototypes -Wshadow -Werror=vla
CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3
CFLAGS += $(shell pkg-config --cflags LIBNAME)
LDFLAGS =
LDLIBS =
LDLIBS += $(shell pkg-config --libs LIBNAME)
SANFLAGS = -fsanitize=address,leak,undefined
ifndef BEAR
CFLAGS += -fanalyzer
endif
ifdef RELEASE
CFLAGS += -O2
else
CFLAGS += -g3 -Og $(SANFLAGS)
LDFLAGS += $(SANFLAGS)
endif
# if you have a file named as the execname, that is a sufficient target to
# compile the entire project. eg: execname and execname.c
all: $(EXEC) $(HEADERS) $(INCLUDES)
# $(LINK.c) $^ $(LDLIBS) $(OUTPUT_OPTION)
$(EXEC): $(OBJECTS)
$(CC) $(LDFLAGS) $^ $(LOADLIBES) $(LDLIBS) -o $(EXEC)
#%.o: %.c %.h $(DEPS)
# $(COMPILE.c) $(OUTPUT_OPTION) $<
# $@: $< $^
# $@ is the left side of the :
# $^ is the right side of the :
# the $< is the first item in the dependencies list
.PHONY: check clean oclean release check debug
clean: oclean
rm -f $(EXEC)
oclean:
rm -f *.o
release: all oclean
check: $(SRCS)
cppcheck --enable=all --std=c11 --inline-suppr \
--suppress=missingIncludeSystem $^
codespell $^
debug:
sudo sysctl -w kernel.yama.ptrace_scope=0
#vim: set noexpandtab sw=8 ts=8 tw=80: