-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
124 lines (91 loc) · 2.95 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
HDR = ./interface/
OBJ = ./obj/
LIB = ./lib/
BIN = ./bin/
PRG = ./test/
SRC = ./src/
DIC = $(SRC)
HdrSuf = .h
SrcSuf = .cc
ObjSuf = .o
PrgSuf = .cpp
BinSuf = .exe
LibSuf = .so
LIBNAME=libh2gglobeVertexAnalysis
HDRS = $(wildcard $(HDR)*$(HdrSuf))
SRCS = $(wildcard $(SRC)*$(SrcSuf))
## _OBJS = $(patsubst %$(SrcSuf), %$(ObjSuf), $(SRCS))
_OBJS = $(patsubst $(SRC)%$(SrcSuf), %$(ObjSuf), $(SRCS))
OBJS = $(addprefix $(OBJ),$(_OBJS))
PRGS = $(wildcard $(PRG)*$(PrgSuf))
_BINS = $(wildcard $(PRG)*$(PrgSuf))
__BINS = $(_BINS:$(PrgSuf)=$(BinSuf))
___BINS = $(notdir $(__BINS))
BINS = $(addprefix $(BIN),${___BINS})
LINKDEF =$(wildcard ${DIC}*LinkDef.h)
DICTHDRS =$(LINKDEF)
ROOTCFLAGS = $(shell root-config --cflags)
ROOTGLIBS = $(shell root-config --glibs)
CLHEPCFLAGS = $(shell clhep-config --include)
CLHEPLIBS = $(shell clhep-config --libs)
## to use a different TMVA wrt the one shipped with ROOT
TMVA_ROOT=$(HOME)/Analysis/tools/tmva/V04-01-00_root-5.22.00d-cms28
ifneq ($(TMVA_ROOT),)
TMVAFLAGS=-I$(TMVA_ROOT)
TMVALDD=-L$(TMVA_ROOT)/lib
endif
ifneq ($(DICTHDRS),)
OBJS+=$(OBJ)mydict.o
endif
ARCHL = -m32
ARCH = $(shell root-config --arch)
ifeq ($(ARCH),linuxx8664gcc)
ARCHL = -m64
endif
CXX = c++
CXXFLAGS = -Wall -O -fPIC -I$(HDR) $(TMVAFLAGS) $(ROOTCFLAGS)
CPP = c++
CPPFLAGS = -Wall $(ARCHL) -I$(HDR) $(TMVAFLAGS) $(ROOTCFLAGS)
LD = c++
LDFLAGS = -rdynamic -shared $(ARCHL)
SONAME = $(LIBNAME).so
SOFLAGS = -Wl,-soname,$(SONAME)
GLIBS = -lm -ldl -rdynamic $(TMVALDD) $(ROOTGLIBS) -lGenVector -lFoam -lMinuit -lTMVA -lMLP -lXMLIO -lTreePlayer
#################################################
#if mac
ARCH = $(shell root-config --arch)
ifeq ($(ARCH),macosx64)
LibSuf = .dylib
CPPFLAGS = -Wall -W -Woverloaded-virtual -O2 $(ARCHL) -pipe -I$(HDR) $(ROOTCFLAGS)
CXXFLAGS = -Wall -W -Woverloaded-virtual -O2 $(ARCHL) -pipe -I$(HDR) $(ROOTCFLAGS)
LDFLAGS = -dynamiclib -shared -single_module -undefined dynamic_lookup $(ARCHL)
SONAME = $(LIBNAME).dylib
SOFLAGS =
endif
#################################################
.PHONY: all exe test clean
all: paths $(LIB)$(SONAME)
exe: paths $(BINS)
test:
@echo "HDRS = \"$(HDRS)\""
@echo "DICTHDRS = \"$(DICTHDRS)\""
@echo "SRCS = $(SRCS)"
@echo "OBJS = $(OBJS)"
@echo "PRGS = $(PRGS)"
@echo "BINS = $(BINS)"
paths:
mkdir -p $(LIB) $(OBJ)
$(OBJ)%$(ObjSuf): $(SRC)%$(SrcSuf) $(HDRS)
$(CXX) -c $(CXXFLAGS) -o $@ $<
$(OBJ)mydict.o: $(OBJ)mydict.cc
$(CXX) -c $(CXXFLAGS) -I. -o $@ $<
$(OBJ)mydict.cc: $(DICTHDRS) $(HDRS)
@echo "Generating dictionary for ..."
rootcint -f $(OBJ)mydict.cc -c -p ${CXXFLAGS} -I. $(HDRS) $(DICTHDRS)
$(LIB)$(SONAME): $(OBJS)
@echo "Linking $(SONAME):"
$(LD) $(LDFLAGS) $(OBJS) $(SOFLAGS) $(GLIBS) -o $(LIB)$(SONAME)
$(BIN)%$(BinSuf): $(PRG)%$(PrgSuf) $(HDRS) $(LIB)$(SONAME)
$(CPP) $(CPPFLAGS) -L$(LIB) $(GLIBS) -lMyTest -o $@ $<
clean:
rm -f $(OBJ)*$(ObjSuf) $(LIB)*$(LibSuf) $(OBJ)mydict*