-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
39 lines (28 loc) · 867 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
SRC_PATH ?= ./src
BUILD_PATH ?= ./build
OBJ_PATH = $(BUILD_PATH)/objs
SRC = $(wildcard $(SRC_PATH)/*.c)
HEADER = $(wildcard $(SRC_PATH)/*.h)
DEPS = $(HEADER)
OBJS = $(patsubst %.c,$(OBJ_PATH)/%.o,$(SRC))
BINS = $(BUILD_PATH)/mkhd
DEBUG_FLAGS ?= -g -O0 -fsanitize=address
CFLAGS = -std=c99 -Wall $(DEBUG_FLAGS)
LDFLAGS = -framework Cocoa -framework Carbon -framework CoreServices
.PHONY: all clean release format check-format
all: $(BINS)
release: DEBUG_FLAGS=-O2
release: clean $(BINS)
clean:
rm -f $(BINS) $(OBJS)
$(BINS): $(OBJS)
mkdir -p $(BUILD_PATH)
clang $(OBJS) $(CFLAGS) $(LDFLAGS) -o $@
$(OBJ_PATH)/%.o: %.c $(DEPS)
@mkdir -p $(@D)
clang -c $< $(CFLAGS) -o $@
%.o: %.c
format:
clang-format -i $(SRC) $(HEADER)
check-format:
clang-format --dry-run --Werror -i $(SRC) $(HEADER)