-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
53 lines (41 loc) · 1.2 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
50
51
52
53
MKDIR := mkdir -p --
RMDIR := rm -Rf --
RM := rm --
PRINTF := printf --
CP := cp --
EXTRA_CFLAGS :=
WARNINGS := -Wall -Wextra -Wfloat-equal -Wundef
ERRORS := -Werror=implicit-int -Werror=implicit-function-declaration
CFLAGS := $(WARNINGS) $(ERRORS) -std=gnu2x $(EXTRA_CFLAGS)
CURRENT_CFLAGS :=
BIN := ./bin
INCLUDE := ./include
SRC := ./src
SRCS := $(wildcard $(SRC)/*.c)
OUT := $(BIN)/clhasher
INCLUDEFLAGS := -I$(INCLUDE)
TESTSRC := ./tests
TESTSRCS := $(wildcard $(TESTSRC)/*.c)
TESTBIN := ./testbin
TESTOUT := $(TESTBIN)/test
CHECK_TEST_FLAGS:= -pthread -lcheck -lrt -lm
DESTDIR := /usr/local/bin
.PHONY: release debug tests install clean
release: CURRENT_CFLAGS += -O3 -DNDEBUG
release: $(OUT)
debug: CURRENT_CFLAGS += -g3 -O0 -DDEBUG
debug: $(OUT) tests
$(OUT): $(SRCS)
$(MKDIR) $(BIN)
$(CC) $(CFLAGS) $(CURRENT_CFLAGS) $(INCLUDEFLAGS) $^ -o $(OUT)
tests: $(TESTOUT)
$(RM) $^
$(TESTOUT): $(TESTSRC)/main.c $(SRC)/fnv.c $(SRC)/escape.c
$(PRINTF) 'NEEDED: check\n'
$(MKDIR) $(TESTBIN)
$(CC) $(CFLAGS) $(INCLUDEFLAGS) $(CHECK_TEST_FLAGS) -o $@ $^
./$@
install:
$(CP) ./bin/clhasher $(DESTDIR)/clhasher
clean:
$(RMDIR) $(TESTBIN) $(BIN)