-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
83 lines (63 loc) · 1.98 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
VERSION = 0.3.1
CFLAGS = -O2 -Wall -fPIC -g -std=gnu99
LIBS = -lelf -lunwind-ptrace -lunwind-generic
BIN = xrprof
BINOBJ = src/xrprof.o
OBJ = src/cursor.o \
src/locate.o \
src/memory.o \
src/process.o
SHLIB = libxrprof.so
all: $(BIN)
clean:
$(RM) $(BIN) $(BINOBJ) $(OBJ) $(SHLIB)
cd tests && $(MAKE) clean
$(BIN): $(OBJ) $(BINOBJ)
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
shlib: $(SHLIB)
$(SHLIB): $(OBJ)
$(CC) $(LDFLAGS) -shared -o $@ $^
src/cursor.o: src/cursor.c src/cursor.h src/rdefs.h src/locate.h src/memory.h
$(CC) $(CFLAGS) -c -o $@ $<
src/locate.o: src/locate.c src/locate.h src/memory.h
$(CC) $(CFLAGS) -c -o $@ $<
src/memory.o: src/memory.c src/memory.h src/rdefs.h
$(CC) $(CFLAGS) -c -o $@ $<
src/process.o: src/process.c
$(CC) $(CFLAGS) -c -o $@ $<
src/xrprof.o: src/xrprof.c src/cursor.h
$(CC) $(CFLAGS) -c -o $@ $<
test: $(BIN)
cd tests && $(MAKE) "BIN=../$(BIN)"
# Mostly compatible with https://www.gnu.org/prep/standards/html_node/Makefile-Conventions.html
INSTALL = install
prefix ?= /usr/local
bindir = $(prefix)/bin
datadir = $(prefix)/share
includedir = $(prefix)/include
libdir = $(prefix)/lib
install:
$(INSTALL) -d $(DESTDIR)$(bindir)
$(INSTALL) -T -m 0755 $(BIN) $(DESTDIR)$(bindir)/$(BIN)
$(INSTALL) -d $(DESTDIR)$(datadir)/man/man1
$(INSTALL) -T -m 0755 docs/$(BIN).1 $(DESTDIR)$(datadir)/man/man1/$(BIN).1
setcap cap_sys_ptrace=eip $(DESTDIR)$(bindir)/$(BIN) || exit 0
install-shlib:
$(INSTALL) -d $(DESTDIR)$(libdir)
$(INSTALL) -T -m 0644 $(SHLIB) $(DESTDIR)$(libdir)/$(SHLIB)
PACKAGE = $(BIN)
DISTDIR = $(PACKAGE)-$(VERSION)
dist:
$(INSTALL) -d $(DISTDIR)
$(RM) -r $(DISTDIR)/*
$(INSTALL) -d $(DISTDIR)/src
cp src/*.c src/*.h $(DISTDIR)/src
$(INSTALL) -d $(DISTDIR)/docs
cp docs/* $(DISTDIR)/docs
cp Makefile README.md NEWS.md $(DISTDIR)/
tar -czf $(DISTDIR).tar.gz $(DISTDIR)
$(RM) -r $(DISTDIR)
sha256sum $(DISTDIR).tar.gz > $(DISTDIR).tar.gz.sha256
distclean:
$(RM) $(BIN) $(BINOBJ) $(OBJ) $(SHLIB)
.PHONY: all clean test install dist distclean