-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
42 lines (26 loc) · 729 Bytes
/
Makefile
File metadata and controls
42 lines (26 loc) · 729 Bytes
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
CC = cc
CFLAGS = -std=c99 -Wall -Wextra -Werror -MMD -D_DEFAULT_SOURCE
# -D_POSIX_C_SOURCE=200112L
INCLUDE = -I include
LFLAGS =
SOURCE_FILES = $(wildcard src/*.c)
OBJECT_FILES = $(patsubst src/%.c,build/%.o,$(SOURCE_FILES))
DEPS_FILES = $(OBJECT_FILES:.o=.d)
TARGET_BIN = build/target.out
.PHONY: all run clean
all: debug
run:
@$(TARGET_BIN)
clean:
$(RM) $(wildcard build/*)
release: CFLAGS += -DNODEBUG
release: LFLAGS += -O3 -s
release: $(TARGET_BIN)
debug: CFLAGS += -g -fsanitize=address,undefined #-fsanitize=leak
debug: LFLAGS += -O0
debug: $(TARGET_BIN)
-include $(DEPS_FILES)
build/%.o: src/%.c
$(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@
$(TARGET_BIN): $(OBJECT_FILES)
$(CC) $(CFLAGS) $^ $(LFLAGS) -o $@