-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
50 lines (37 loc) · 928 Bytes
/
Makefile
File metadata and controls
50 lines (37 loc) · 928 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
41
42
43
44
45
46
47
48
49
50
CC?=clang
SRCS=parse_printf.c example.c test.c
OBJS=$(SRCS:.c=.o)
DEBUG_OBJS=$(SRCS:.c=.d.o)
CFLAGS=-Iinclude/ -Wall -Wextra
DEBUG_CFLAGS=$(CFLAGS) -g3 -fsanitize=undefined -fsanitize=address
RELEASE_CFLAGS=$(CFLAGS) -Ofast
TARGET=test
DEBUG_TARGET=test_debug
.PHONY: all clean debug compile_commands
all: $(TARGET)
$(TARGET): $(OBJS)
@mkdir -p $(dir $(TARGET))
@$(CC) $^ -o $@
@strip $(TARGET)
clean:
@find . -name '*.o' -type f -delete
@$(RM) $(TARGET)
@$(RM) $(DEBUG_TARGET)
debug_clean:
@find . -name '*.d.o' -type f -delete
@$(RM) $(DEBUG_TARGET)
debug: $(DEBUG_TARGET)
$(DEBUG_TARGET): $(DEBUG_OBJS)
@mkdir -p $(dir $(DEBUG_TARGET))
@$(CC) $(LDFLAGS) $^ -o $@
%.o: %.c
@mkdir -p $(shell dirname $@)
@$(CC) $(RELEASE_CFLAGS) -c $< -o $@
%.d.o: %.c
@mkdir -p $(shell dirname $@)
@$(CC) $(DEBUG_CFLAGS) -c $< -o $@
compile_commands: clean
@compiledb make
print_info:
@echo $(OBJS)
@echo $(SRCS)