-
Notifications
You must be signed in to change notification settings - Fork 22
/
Makefile
40 lines (29 loc) · 795 Bytes
/
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
36
37
38
39
40
CC=clang
OBJ=obj
SRC=src
SRCS=$(wildcard $(SRC)/*.c)
OBJS=$(foreach obj,$(SRCS:src/%=%),$(OBJ)/$(basename $(obj)).o)
CFLAGS=-Iinclude/ -Wshadow -Wwrite-strings -Wunused-parameter -Wall -std=gnu11
CFLAGS+=-funroll-loops -Ofast
DEBUGCFLAGS=$(CFLAGS) -g3
RELEASECFLAGS=$(CFLAGS) -Ofast
TARGET=bin/tbd
DEBUGTARGET=bin/tbd_debug
DEBUGOBJS=$(foreach obj,$(SRCS:src/%=%),$(OBJ)/$(basename $(obj)).d.o)
.PHONY: all clean debug
$(TARGET): $(OBJS)
@mkdir -p $(dir $(TARGET))
@$(CC) $^ -o $@
clean:
@$(RM) -rf $(OBJ)
@$(RM) $(TARGET)
debug: $(DEBUGTARGET)
$(DEBUGTARGET): $(DEBUGOBJS)
@mkdir -p $(dir $(DEBUGTARGET))
@$(CC) $^ -o $@
$(OBJ)/%.o: $(SRC)/%.c
@mkdir -p $(OBJ)
@$(CC) $(RELEASECFLAGS) -c $< -o $@
$(OBJ)/%.d.o: $(SRC)/%.c
@mkdir -p $(OBJ)
@$(CC) $(DEBUGCFLAGS) -c $< -o $@