forked from clacaputo/ClassicSVfit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
67 lines (51 loc) · 2.07 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
CXX = g++
WFLAGS = -Wall -Wextra -Wpedantic -Werror -Wno-unused-parameter -Wno-vla
CXXFLAGS = $(WFLAGS) -fvisibility-inlines-hidden -fno-math-errno --param vect-max-version-for-alias-checks=50 \
-Xassembler --compress-debug-sections -fno-crossjumping -msse3 -felide-constructors -fmessage-length=0 \
-fdiagnostics-show-option -pipe -fPIC $(shell root-config --cflags)
LDFLAGS = -flto
ifdef DEBUG
CXXFLAGS += -Og -ggdb3
else
CXXFLAGS += -O3 -ggdb0
LDFLAGS += -s
endif
BASEDIR = TauAnalysis/ClassicSVfit
SOURCE_PATH = $(BASEDIR)/src
BIN_PATH = $(BASEDIR)/bin
OBJ_PATH = $(BASEDIR)/obj
DEP_PATH = $(BASEDIR)/dep
LIB_PATH = $(BASEDIR)/lib
EXEC_PATH = $(BASEDIR)/exec
SRC_EXT = cc
OBJ_EXT = o
DEP_EXT = d
LIB_EXT = so
INCLUDES = -I.
LIBS = $(shell root-config --libs) -lGenVector
SRCS = $(shell find $(SOURCE_PATH) -name '*.$(SRC_EXT)' -exec basename {} \;)
OBJS = $(SRCS:%.$(SRC_EXT)=$(OBJ_PATH)/%.$(OBJ_EXT))
DEPS = $(SRCS:%.$(SRC_EXT)=$(DEP_PATH)/%.$(DEP_EXT))
TRGT_SRCS = $(shell find $(BIN_PATH) -name '*.$(SRC_EXT)' -exec basename {} \;)
TRGT_OBJS = $(TRGT_SRCS:%.$(SRC_EXT)=$(OBJ_PATH)/%.$(OBJ_EXT))
TRGT = $(TRGT_SRCS:%.$(SRC_EXT)=$(EXEC_PATH)/%)
TRGT_LIB_BASE = $(subst /,_,$(BASEDIR))
TRGT_LIB_PATH = $(LIB_PATH)/lib$(TRGT_LIB_BASE).$(LIB_EXT)
all: $(TRGT)
$(TRGT): $(EXEC_PATH)/%: $(OBJ_PATH)/%.$(OBJ_EXT) $(TRGT_LIB_PATH)
@mkdir -p $(EXEC_PATH)
@$(CXX) $(CXXFLAGS) $^ -o $@ $(LDFLAGS) $(LIBS) -l$(TRGT_LIB_BASE)
$(TRGT_LIB_PATH): $(OBJS)
@mkdir -p $(LIB_PATH)
@$(CXX) $(CXXFLAGS) -shared $^ -o $@ $(LDFLAGS) $(LIBS)
$(OBJ_PATH)/%.$(OBJ_EXT): $(SOURCE_PATH)/%.$(SRC_EXT)
@mkdir -p $(@D)
@mkdir -p $(DEP_PATH)
@$(CXX) $(CXXFLAGS) $(INCLUDES) -MMD -MF $(patsubst $(OBJ_PATH)/%.$(OBJ_EXT),$(DEP_PATH)/%.$(DEP_EXT),$@) -c $< -o $@
$(OBJ_PATH)/%.$(OBJ_EXT): $(BIN_PATH)/%.$(SRC_EXT)
@mkdir -p $(@D)
@mkdir -p $(DEP_PATH)
@$(CXX) $(CXXFLAGS) $(INCLUDES) -MMD -MF $(patsubst $(OBJ_PATH)/%.$(OBJ_EXT),$(DEP_PATH)/%.$(DEP_EXT),$@) -c $< -o $@
.PHONY: clean
clean:
@rm -rf $(OBJ_PATH) $(DEP_PATH) $(EXEC_PATH)