-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
48 lines (35 loc) · 1.11 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
47
48
CC ?= gcc
AR ?= ar
LINTER ?= clang-format
PROG := chronic
UNIT_TARGET := unit_test
SRCDIR := src
DEPSDIR := deps
TESTDIR := t
SRC := $(wildcard $(SRCDIR)/*.c)
TEST_DEPS := $(wildcard $(DEPSDIR)/tap.c/*.c)
DEPS := $(filter-out $(wildcard $(DEPSDIR)/tap.c/*), $(wildcard $(DEPSDIR)/*/*.c))
CFLAGS := -I$(DEPSDIR) -Wall -Wextra -pedantic
UNIT_TEST_CFLAGS := -DUNIT_TEST
LIBS := -lm -lpthread -lpcre -luuid
TESTS := $(wildcard $(TESTDIR)/*.c)
$(PROG):
$(CC) $(CFLAGS) $(SRC) $(DEPS) $(LIBS) -Ideps -Isrc -o $(PROG)
test:
$(MAKE) unit_test
unit_test:
$(CC) $(UNIT_TEST_CFLAGS) $(wildcard $(TESTDIR)/unit/*.c) $(TEST_DEPS) $(DEPS) $(filter-out $(SRCDIR)/main.c, $(SRC)) -I$(SRCDIR) -I$(DEPSDIR) $(LIBS) -o $(UNIT_TARGET)
./$(UNIT_TARGET)
$(MAKE) clean
integ_test: $(PROG)
./$(TESTDIR)/integ/utils/run.bash
$(MAKE) clean
valgrind: CFLAGS += -g -O0 -DVALGRIND
valgrind: $(PROG)
valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes -s ./$(PROG)
$(MAKE) clean
clean:
rm -f $(UNIT_TARGET) $(PROG) .log*
lint:
$(LINTER) -i $(SRC) $(wildcard $(TESTDIR)/*/*.c)
.PHONY: test unit_test integ_test valgrind clean lint