forked from aerospike/asmalloc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
102 lines (66 loc) · 1.8 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#
# Makefile
#
# This is the makefile for the ASMalloc memory allocation tracking tools.
#
# Define variables.
INCDIR = include
SRCDIR = src
OBJDIR = obj
LIBDIR = lib
BINDIR = bin
LIB_HEADERS = \
$(INCDIR)/asmalloc.h \
$(INCDIR)/vm_stats.h
LIB_SOURCES = \
$(SRCDIR)/asmalloc.c \
$(SRCDIR)/vm_stats.c
LIB_OBJECTS = $(LIB_SOURCES:$(SRCDIR)/%.c=$(OBJDIR)/%.o)
LIBRARY = $(LIBDIR)/asmalloc$(EXT).so
PRELOADS = $(LIBRARY)
JEM_LIBRARY = /usr/lib64/libjemalloc.so
PROGRAM_NAMES = test-asmalloc
PROGRAMS = $(PROGRAM_NAMES:%=$(BINDIR)/%$(EXT))
PGM_HEADERS = $(INCDIR)/test-mallocations.h
PGM_SOURCES = $(PROGRAM_NAMES:%=$(SRCDIR)/%.c)
PGM_OBJECTS = $(PGM_SOURCES:$(SRCDIR)/%.c=$(OBJDIR)/%.o)
HEADERS = $(LIB_HEADERS) $(PGM_HEADERS)
SOURCES = $(LIB_SOURCES) $(PGM_SOURCES)
OBJECTS = $(LIB_OBJECTS) $(PGM_OBJECTS)
# If GCC v4.4.7 or later, use DWARF version 4, othewise use version 2:
ifeq ($(shell bin/VersionCheck.py 'gcc -dumpversion' 4.4.7), 1)
DWARF_VERSION=4
else
DWARF_VERSION=2
endif
CFLAGS = -gdwarf-$(DWARF_VERSION) -g3 -Wall -std=gnu99 -fPIC -I$(INCDIR)
ifneq ($(FOR_JEMALLOC),)
CFLAGS += -DFOR_JEMALLOC
EXT = .jem
PRELOADS = $(LIBRARY):$(JEM_LIBRARY)
endif
LIB_LDFLAGS = -shared
PGM_LDFLAGS = -rdynamic
LIBRARIES = -ldl -lpthread -lrt
TARGETS = all clean cleaner cleanest test
TARGETS.JEM = $(TARGETS:%=%.jem)
# Define targets.
all: clean $(LIBRARY) $(PROGRAMS)
jem: all.jem
clean:
$(RM) $(OBJECTS)
cleaner: clean
$(RM) $(PROGRAMS)
cleanest: cleaner
$(RM) $(LIBRARY)
test: all
LD_PRELOAD=$(PRELOADS) $(PROGRAMS)
$(TARGETS.JEM):
$(MAKE) $(@:%.jem=%) FOR_JEMALLOC=1
$(SOURCES): $(HEADERS)
$(LIBRARY): $(LIB_OBJECTS)
$(LINK.c) $(LIB_LDFLAGS) -o $@ $^ $(LIBRARIES)
$(PROGRAMS): $(PGM_OBJECTS)
$(LINK.c) $(PGM_LDFLAGS) -o $@ $^ $(LIBRARIES)
$(OBJDIR)/%.o: $(SRCDIR)/%.c
$(COMPILE.c) $< -o $@