-
-
Notifications
You must be signed in to change notification settings - Fork 90
/
Makefile
84 lines (62 loc) · 2.22 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
TARGET = duplicut
SHELL = /bin/sh
# debug level
level = 1
CFLAGS = -Iinclude -Wall -Wextra \
-Wdisabled-optimization -Winline \
-Wdouble-promotion -Wunknown-pragmas \
-Wno-implicit-fallthrough \
-Wno-error=implicit-function-declaration \
-mtune=native -ffast-math
LDFLAGS = -lm -pthread
RELEASEFLAGS = -O2 -D NDEBUG
DEBUGFLAGS = -O0 -D DEBUG=$(level) -std=gnu99 -g3
COVERAGEFLAGS = -O0 -D NDEBUG -std=gnu99 -g3 --coverage
SOURCES = main.c thpool.c file.c chunk.c line.c dedupe.c \
optparse.c config.c error.c memstate.c meminfo.c bytesize.c \
hmap.c status.c uinput.c \
COMMON = include/const.h include/debug.h
OBJECTS = $(patsubst %.c, objects/%.o, $(SOURCES))
PREFIX = $(DESTDIR)/usr/local
BINDIR = $(PREFIX)/bin
all: $(TARGET)
release: $(TARGET)
re: $(TARGET)
debug: CFLAGS += $(DEBUGFLAGS)
debug: distclean $(OBJECTS) $(COMMON)
-ctags src/* include/*
$(CC) $(FLAGS) $(CFLAGS) -o $(TARGET) $(OBJECTS) $(LDFLAGS)
coverage: CFLAGS += $(COVERAGEFLAGS)
coverage: distclean $(OBJECTS) $(COMMON)
$(CC) $(FLAGS) $(CFLAGS) -o $(TARGET) $(OBJECTS) $(LDFLAGS)
$(TARGET): CFLAGS += $(RELEASEFLAGS)
$(TARGET): distclean $(OBJECTS) $(COMMON)
$(CC) $(FLAGS) $(CFLAGS) -o $(TARGET) $(OBJECTS) $(LDFLAGS)
strip --strip-all $(TARGET) || strip -Sx $(TARGET) # osx fallback
profile: CFLAGS += -pg
profile: distclean $(TARGET)
profile-generate: CFLAGS += $(RELEASEFLAGS) -fprofile-generate -fprofile-arcs
profile-generate: distclean $(OBJECTS) $(COMMON)
$(CC) $(FLAGS) $(CFLAGS) -o $(TARGET) $(OBJECTS) $(LDFLAGS)
rm-objects:
rm objects/*.o
profile-use: CFLAGS += $(RELEASEFLAGS) -fprofile-use -fprofile-arcs
profile-use: rm-objects $(OBJECTS) $(COMMON)
$(CC) $(FLAGS) $(CFLAGS) -o $(TARGET) $(OBJECTS) $(LDFLAGS)
objects/%.o: src/%.c
mkdir -p `dirname $@`
$(CC) $(FLAGS) $(CFLAGS) -c $< -o $@
install: release
install -D $(TARGET) $(BINDIR)/$(TARGET)
uninstall:
rm $(BINDIR)/$(TARGET)
test:
./test/run.sh
clean:
-rm -rf objects/
-rm -f gmon.out
-rm -f tags
distclean: clean
-rm -f $(TARGET)
.PHONY: all release profile clean distclean \
install uninstall test