-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile
64 lines (51 loc) · 1.3 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
54
55
56
57
58
59
60
61
62
63
64
#
# This file is a part of Polyfuse
#
# Copyright (c) 2018 Luke Gallagher <luke.gallagher@rmit.edu.au>
#
# For the full copyright and license information, please view the LICENSE file
# that was distributed with this source code.
#
TARGET = polyfuse
GIT = $(shell which git)
GITDIR = $(shell stat .git > /dev/null; echo $$?)
VERSION_NUM = 0.2.0
VERSION_EXTRA = -dev
ifneq ($(GIT),)
ifeq ($(GITDIR), 0)
VERSION_EXTRA += ($(shell $(GIT) rev-parse --short=8 HEAD))
endif
endif
VERSION = $(VERSION_NUM)$(VERSION_EXTRA)
CC = gcc
CFLAGS += -std=c11 -Wall -Wextra -pedantic -O2 -D_XOPEN_SOURCE=700 \
-DPOLYFUSE_VERSION='"$(VERSION)"' -Isrc
LDFLAGS += -lm
DEBUG_CFLAGS = -g -O0 -DDEBUG
SRC = src/main.c src/util.c src/trec.c src/pf_accum.c \
src/polyfuse.c src/pf_topic.c src/pq.c
OBJ := $(SRC:.c=.o)
DEP := $(patsubst %.c,%.d,$(SRC))
TESTDIR = test
.PHONY: all
all: $(TARGET)
.PHONY: debug
debug: CFLAGS := $(CFLAGS:-O%=)
debug: CC := $(CC) $(DEBUG_CFLAGS)
debug: all
.PHONY: release
release: VERSION_EXTRA :=
release: all
$(TARGET): $(OBJ)
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
%.o: %.c Makefile
$(CC) $(CFLAGS) -MMD -MP -c $< -o $@ $(LDFLAGS)
.PHONY: clean
clean:
$(MAKE) -C $(TESTDIR) $@
$(RM) $(TARGET) $(OBJ) $(DEP)
.PHONY: check
check: $(TARGET)
$(MAKE) -C $(TESTDIR)
./test/all -c
-include $(DEP)