-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
65 lines (48 loc) · 1.6 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
CC = gcc
CXX = g++
COMFLAGS = -Wall -Wextra -Werror -O3 -MMD -pthread -IplrCommon
CFLAGS = -std=gnu99
CXXFLAGS = -std=c++11
LDFLAGS = -pthread -Wl,-rpath='$$ORIGIN/lib' -Llib
LDLIBS = -lrt -lplrCommon
OBJDIR = obj
LIBDIR = lib
CFILES = $(wildcard *.c)
CXXFILES = $(wildcard *.cpp)
OBJ = $(CFILES:%.c=$(OBJDIR)/%.o) $(CXXFILES:%.cpp=$(OBJDIR)/%.o)
DEP = $(OBJ:%.o=%.d)
LIBNAMES = plrCommon plrPintool plrPreload
LIBS = $(LIBNAMES:%=$(LIBDIR)/lib%.so)
###############################################################################
all: $(LIBNAMES) pinFaultInject plr
clean:
$(RM) -R $(OBJDIR) $(LIBDIR) plr
$(MAKE) -C plrPintool clean extraclean
$(MAKE) -C plrPreload clean
$(MAKE) -C plrCommon clean
$(MAKE) -C pinFaultInject clean extraclean
.PHONY : all clean $(LIBNAMES) pinFaultInject
###############################################################################
plr: $(OBJ) | $(LIBS)
$(CXX) $(LDFLAGS) -o $@ $^ $(LDLIBS)
# Include .d dependency files created by -MMD flag
-include $(DEP)
# Rules so that OBJDIR is created if it doesn't exist
$(OBJ): | $(OBJDIR)
$(OBJDIR):
mkdir -p $@
# Rule to build any C source files
$(OBJDIR)/%.o: %.c
$(CC) $(COMFLAGS) $(CFLAGS) -c $< -o $@
# Rule to build any C++ source files
$(OBJDIR)/%.o: %.cpp
$(CXX) $(COMFLAGS) $(CXXFLAGS) -c $< -o $@
###############################################################################
$(LIBNAMES): %: | $(LIBDIR)
$(MAKE) -C $@ [email protected]
ln -sf ../$@/[email protected] $(LIBDIR)
pinFaultInject: | $(LIBDIR)
$(MAKE) -C $@ [email protected]
ln -sf ../$@/[email protected] $(LIBDIR)
$(LIBDIR):
mkdir -p $@