-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
49 lines (36 loc) · 1.15 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
49
include Makefile.config
.PHONY: all test unit_test unit_test_dev integ_test clean fmt
.DELETE_ON_ERROR:
UNIT_TARGET := unit_test
TARGET := $(PROGNAME).$(PROGVERS)
SRCDIR := src
INCDIR := include
DEPSDIR := deps
TESTDIR := t
SRC := $(wildcard $(SRCDIR)/*.c)
SRC_NOMAIN := $(filter-out $(SRCDIR)/main.c, $(SRC))
TESTS := $(wildcard $(TESTDIR)/*.c)
UNIT_TESTS := $(wildcard $(TESTDIR)/unit/*.c)
TEST_DEPS := $(wildcard $(DEPSDIR)/tap.c/*.c)
DEPS := $(filter-out $(wildcard $(DEPSDIR)/tap.c/*), $(wildcard $(DEPSDIR)/*/*.c))
LIBS := -lm
INCLUDES := -I$(INCDIR) -isystem$(DEPSDIR) -I$(SRCDIR)
CFLAGS := -Wall -Wextra -pedantic $(INCLUDES) -O0 -g
all: $(TARGET)
$(TARGET): $(SRC) $(DEPS)
$(CC) $(CFLAGS) $^ $(LIBS) -o $@
test:
@$(MAKE) unit_test
@$(MAKE) integ_test
unit_test: $(UNIT_TESTS) $(TEST_DEPS) $(DEPS) $(SRC_NOMAIN)
$(CC) $(CFLAGS) $^ $(LIBS) -o $(UNIT_TARGET)
@./$(UNIT_TARGET)
@$(MAKE) clean
unit_test_dev:
ls $(SRCDIR)/*.{h,c} $(TESTDIR)/**/*.{h,c} | entr -s 'make -s unit_test'
integ_test: $(TARGET)
@$(MAKE) clean
clean:
@rm -f $(UNIT_TARGET) $(TARGET)
fmt:
@$(FMT) -i $(SRC) $(TESTS)