-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
46 lines (34 loc) · 1 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
36
37
38
39
40
41
42
43
44
45
46
MKDIR = mkdir -p
CC ?= gcc
CFLAGS ?= -Wall -std=gnu11 -Og -pedantic -MMD \
-Werror=implicit-function-declaration #-fsanitize=address -fno-omit-frame-pointer
LDFLAGS := -lcoconut #-fsanitize=address
LFLAGS := -L./bin/
INCLUDE_DIRS = -Iinclude/
SOURCE_DIR = source
BIN_DIR = bin
BUILD_DIR = build
SILENCED:=
AR := ar
AR_FLAGS := rcs
SRC := $(wildcard $(SOURCE_DIR)/*.c)
OBJ := $(SRC:.c=.o)
OBJ := $(patsubst $(SOURCE_DIR)/%, $(BUILD_DIR)/%, $(OBJ))
coconut-lib: $(BIN_DIR)/libcoconut.a
tests: $(BIN_DIR)/libcoconut.a test/main.o
$(CC) -o $(BIN_DIR)/tests test/main.o $(LFLAGS) $(LDFLAGS)
test/%.o: test/%.c
$(CC) $(CFLAGS) $(INCLUDE_DIRS) -o $@ -c $<
$(BIN_DIR)/libcoconut.a: $(OBJ)
$(SILENCED)$(AR) $(AR_FLAGS) $@ $^
$(OBJ): | $(BUILD_DIR) $(BIN_DIR)
$(BUILD_DIR):
$(SILENCED)$(MKDIR) $@
$(BIN_DIR):
$(SILENCED)$(MKDIR) $@
$(BUILD_DIR)/%.o: $(SOURCE_DIR)/%.c
$(SILENCED)$(CC) $(CFLAGS) $(INCLUDE_DIRS) -o $@ -c $<
.PHONY = clean
clean:
rm -rf $(BUILD_DIR)
rm -rf $(BIN_DIR)