-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
35 lines (26 loc) · 1.01 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
# See gcc/clang manual to understand all flags
CFLAGS += -std=c99 # Define which version of the C standard to use
CFLAGS += -Wall # Enable the 'all' set of warnings
CFLAGS += -Werror # Treat all warnings as error
CFLAGS += -Wshadow # Warn when shadowing variables
CFLAGS += -Wextra # Enable additional warnings
CFLAGS += -O2 -D_FORTIFY_SOURCE=2 # Add canary code, i.e. detect buffer overflows
CFLAGS += -fstack-protector-all # Add canary code to detect stack smashing
CFLAGS += -D_XOPEN_SOURCE -D_POSIX_C_SOURCE=201112L # getopt, clock_getttime
SOURCES=$(wildcard *.c)
OBJECTS=$(SOURCES:.c=.o)
LDFLAGS= -rdynamic
ifneq ($(shell uname -s),Darwin) # Apple does not have clock_gettime
LDFLAGS += -lrt # hence does not need librealtime
endif
all: link_sim
debug: CFLAGS += -g -DDEBUG -Wno-unused-parameter -fno-omit-frame-pointer
debug: LDFLAGS += -lSegFault
debug: link_sim
link_sim: $(OBJECTS)
.PHONY: clean mrproper rebuild
clean:
@rm -f $(OBJECTS)
mrproper:
@rm -f link_sim
rebuild: clean mrproper link_sim