forked from fabio-mon/HHGGBBAnalysis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
125 lines (90 loc) · 3.13 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
DIR := ${CURDIR}
HDR = ./interface/
SRC = ./src/
PLG = ./plugins/
PRG = ./main/
OBJ = ./obj/
LIB = ./lib/
BIN = ./bin/
HDRSuf = .h
SRCSuf = .cc
PRGSuf = .cpp
OBJSuf = .o
LIBSuf = .so
BINSuf = .exe
HDRS = $(wildcard $(HDR)*$(HDRSuf))
SRCS = $(wildcard $(SRC)*$(SRCSuf))
PLGS = $(wildcard $(PLG)*$(SRCSuf))
_OBJS = $(patsubst %$(SRCSuf), %$(OBJSuf), $(SRCS))
OBJS = $(patsubst $(SRC)%, $(OBJ)%, $(_OBJS))
_PLGOBJS = $(patsubst %$(SRCSuf), %$(OBJSuf), $(PLGS))
PLGOBJS = $(patsubst $(PLG)%, $(OBJ)%, $(_PLGOBJS))
_LIBS = $(patsubst %$(SRCSuf), %$(LIBSuf), $(PLGS))
LIBS = $(patsubst $(PLG)%, $(LIB)lib%, $(_LIBS))
PRGS = $(wildcard $(PRG)*$(PRGSuf))
_BINS = $(wildcard $(PRG)*$(PRGSuf))
__BINS = $(_BINS:$(PRGSuf)=$(BINSuf))
___BINS = $(notdir $(__BINS))
BINS = $(addprefix $(BIN),${___BINS})
LINKDEF = $(wildcard ${HDR}*LinkDef.h)
DICTHDRS = $(patsubst $(LINKDEF),,$(HDRS)) $(LINKDEF)
ARCH = $(shell root-config --arch)
ROOTCFLAGS = $(shell root-config --cflags)
ROOTGLIBS = $(shell root-config --glibs) -lGenVector -lFoam -lMinuit -lTMVA -lMLP -lXMLIO -lTreePlayer -lRooFit -lRooFitCore -lRooStats
CXX = g++
CXXFLAGS = -Wall -O2 -fPIC -I$(DIR) $(ROOTCFLAGS)
CPP = g++
CPPFLAGS = -Wall -I$(DIR) $(ROOTCFLAGS)
LD = g++
LDFLAGS = -rdynamic -shared -O2
SONAME = libDelphesAnalysis.so
SOFLAGS = -Wl,-soname,
GLIBS = -lm -ldl -rdynamic -L./DynamicTTree/lib -L./CfgManager/lib -lDynamicTTree -lCfgManager $(ROOTGLIBS)
#################################################
#if mac 64
ifeq ($(ARCH),macosx64)
LIBSuf = .dylib
CPPFLAGS = -Wall -W -O2 -pipe -I$(DIR) $(ROOTCFLAGS)
CXXFLAGS = -Wall -W -O2 -pipe -I$(DIR) $(ROOTCFLAGS)
LDFLAGS = -dynamiclib -shared -single_module -undefined dynamic_lookup
SONAME = libDelphesAnalysis.dylib
SOFLAGS = -Wl,-install_name,
endif
#################################################
.PHONY: all clean test
all: dynTTree cfgMan $(LIB)$(SONAME) $(LIBS)
exe: $(BINS)
test:
@echo "HDRS = $(HDRS)"
@echo "DICTHDRS = $(DICTHDRS)"
@echo "SRCS = $(SRCS)"
@echo "PLGS = $(PLGS)"
@echo "PRGS = $(PRGS)"
@echo "OBJS = $(OBJS)"
@echo "PLGOBJS = $(PLGOBJS)"
@echo "LIBS = $(LIBS)"
@echo "BINS = $(BINS)"
$(BIN)%$(BINSuf): $(PRG)%$(PRGSuf) $(HDRS) $(LIB)$(SONAME)
$(CPP) $(CPPFLAGS) $(GLIBS) -L$(LIB) -lDelphesAnalysis -o $@ $<
$(OBJ)%$(OBJSuf): $(SRC)%$(SRCSuf)
$(CXX) -c $(CXXFLAGS) -o $@ $<
$(LIB)mydict.cc: $(DICTHDRS)
@echo "Generating dictionary..."
rootcling -f $(LIB)mydict.cc -c -p ${CXXFLAGS} $(DICTHDRS)
$(LIB)mydict.o: $(LIB)mydict.cc
$(CXX) -c $(CXXFLAGS) -o $@ $<
$(LIB)$(SONAME): $(OBJS) $(LIB)mydict.o
@echo "Linking $(SONAME):"
$(LD) $(LDFLAGS) $(OBJS) $(LIB)mydict.o -o $(LIB)$(SONAME) $(SOFLAGS)$(SONAME)
$(LIB)lib%$(LIBSuf): $(PLG)%$(SRCSuf) $(PLG)%$(HDRSuf) $(OBJS)
@echo "Creating plugin library " $@ " and " $<
$(LD) $(CXXFLAGS) $(LDFLAGS) -o $@ $< $(SOFLAGS)lib$*.so $(GLIBS)
dynTTree:
cd DynamicTTree && $(MAKE)
cfgMan:
cd CfgManager && $(MAKE)
clean:
@echo "cleaning..."
rm -f $(OBJ)*$(OBJSuf) $(LIB)*$(LIBSuf) $(LIB)mydict* $(BIN)*$(BINSuf)
cd DynamicTTree && $(MAKE) clean
cd CfgManager && $(MAKE) clean