-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
62 lines (48 loc) · 1.32 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
# Copyright 2017-2022 Yury Gribov
#
# Use of this source code is governed by MIT license that can be
# found in the LICENSE.txt file.
CC ?= gcc
DESTDIR ?= /usr/local
CPPFLAGS = -D_GNU_SOURCE
CFLAGS = -g -fPIC -fvisibility=hidden -Wall -Wextra -Werror
LDFLAGS = -shared -fPIC -Wl,--warn-common
LIBS = -ldl
ifneq (,$(COVERAGE))
DEBUG = 1
CFLAGS += --coverage -DNDEBUG
CFLAGS += -fprofile-dir=coverage.%p
LDFLAGS += --coverage
endif
ifeq (,$(DEBUG))
CFLAGS += -O2
LDFLAGS += -Wl,-O2
else
CFLAGS += -O0
endif
$(shell mkdir -p bin)
all: bin/libpregrind.so bin/pregrind
bin/%: scripts/% Makefile
cp $< $@
bin/libpregrind.so: bin/pregrind.o bin/async_safe.o Makefile bin/FLAGS
$(CC) $(LDFLAGS) -o $@ $(filter %.o, $^) $(LIBS)
bin/%.o: src/async_safe.h src/common.h
bin/%.o: src/%.c Makefile bin/FLAGS
$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
bin/FLAGS: FORCE
if test x"$(CFLAGS) $(CXXFLAGS) $(LDFLAGS)" != x"$$(cat $@)"; then \
echo "$(CFLAGS) $(CXXFLAGS) $(LDFLAGS)" > $@; \
fi
clean:
rm -f bin/*
find -name \*.gcov -o -name \*.gcno -o -name \*.gcda -o -name coverage.\* | xargs rm -rf
install:
mkdir -p $(DESTDIR)
install bin/libpregrind.so $(DESTDIR)/lib
install scripts/pregrind $(DESTDIR)/bin
check:
tests/exec/run.sh
tests/system/run.sh
tests/spawn/run.sh
@echo SUCCESS
.PHONY: clean all check install FORCE