-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
174 lines (140 loc) · 5.29 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# project name
PROJECT = EpicAnalysis
# check environment
ifndef EPIC_ANALYSIS_HOME
$(error "ERROR: run 'source environ.sh' before building")
endif
# compiler and flags
#################################################################
CXX := g++
FLAGS = -Wno-deprecated -fPIC
FLAGS += -fmax-errors=3
# FLAGS += -fvisibility=hidden # FIXME: required by pybind, but causes unresolved symbols in cling...
ROOTCLING = rootcling
# dependencies
#################################################################
# ROOT
DEP_INCLUDES = -I$(shell root-config --incdir)
DEP_LIBRARIES = $(shell root-config --glibs)
#DEP_LIBRARIES += -lMinuit -lRooFitCore -lRooFit -lRooStats -lProof -lMathMore
# Data Model (PODIO + EDM4hep + EDM4eic)
DEP_LIBRARIES += -L/usr/local/lib -ledm4hep -ledm4eic
ifdef INCLUDE_PODIO
DEP_LIBRARIES += -L/usr/local/lib -lpodio -lpodioRootIO
FLAGS += -DINCLUDE_PODIO
endif
# Miscellaneous
DEP_LIBRARIES += -lfmt
# Delphes
ifdef EXCLUDE_DELPHES
# optionally build without Delphes (for CI speedup)
FLAGS += -DEXCLUDE_DELPHES
else
DEP_INCLUDES += -I${DELPHES_HOME} -I${DELPHES_HOME}/external
DEP_LIBRARIES += -L${DELPHES_HOME} -lDelphes
endif
# Delphes plugin: Fastjet Centauro
ifdef INCLUDE_CENTAURO
DEP_INCLUDES += -I${DELPHES_HOME}/external/fastjet/plugins/Centauro
DEP_LIBRARIES += -L${DELPHES_HOME}/external/fastjet/plugins/Centauro -lCentauro
FLAGS += -DINCLUDE_CENTAURO
endif
# MSTWPDF
DEP_INCLUDES += -I${MSTWPDF_HOME}
DEP_LIBRARIES += -L${MSTWPDF_HOME} -lmstwpdf
DEP_TARGETS = ${MSTWPDF_HOME}/libmstwpdf.so
# ADAGE
DEP_INCLUDES += -I${ADAGE_HOME}/include
DEP_LIBRARIES += -L${ADAGE_HOME}/lib -lAdage
DEP_TARGETS += ${ADAGE_HOME}/lib/libAdage.so
# epic-analysis objects
#################################################################
PREFIX := ${EPIC_ANALYSIS_HOME}/lib
EPIC_ANALYSIS_LIB := $(PREFIX)/lib$(PROJECT).so
EPIC_ANALYSIS_PCM := $(PROJECT)Dict_rdict.pcm
EPIC_ANALYSIS_DICT := src/$(PROJECT)Dict.cxx
EPIC_ANALYSIS_LINKDEF := src/LinkDef.h
EPIC_ANALYSIS_INCLUDES := -I${EPIC_ANALYSIS_HOME}/src
EPIC_ANALYSIS_LIBRARIES := -L$(PREFIX) -l$(PROJECT)
# epic-analysis source code (with $(EPIC_ANALYSIS_DICT) and $(EPIC_ANALYSIS_LINKDEF) moved to end of lists for rootcling)
#################################################################
# move $(EPIC_ANALYSIS_DICT) and $(EPIC_ANALYSIS_LINKDEF) to end of lists for rootcling
SOURCES := $(filter-out $(EPIC_ANALYSIS_DICT), $(wildcard src/*.cxx) $(wildcard src/sfset/*.cxx) $(wildcard src/interp/*.cxx)) $(EPIC_ANALYSIS_DICT)
HEADERS := $(filter-out $(EPIC_ANALYSIS_LINKDEF), $(wildcard src/*.h) $(wildcard src/sfset/*.h) $(wildcard src/interp/*.h) $(wildcard src/interp/*.ipp)) $(EPIC_ANALYSIS_LINKDEF)
# filter out Delphes-dependent code (if needed)
ifdef EXCLUDE_DELPHES
SOURCES := $(filter-out src/AnalysisDelphes.cxx, $(SOURCES))
HEADERS := $(filter-out src/AnalysisDelphes.h, $(HEADERS))
ROOTCLING += -D=EXCLUDE_DELPHES
endif
# epic-analysis builds
#################################################################
all: epic-analysis
all-clean: deps-clean clean
debug: FLAGS += -g
debug: DEP_RECIPE = debug
debug: clean all
release: FLAGS += -O3
release: DEP_RECIPE = release
release: clean all
epic-analysis: deps epic-analysis-header $(EPIC_ANALYSIS_LIB) hpc
@echo "Done.\n"
epic-analysis-header:
@echo "\n===== $(PROJECT) ====="
$(EPIC_ANALYSIS_LIB): $(EPIC_ANALYSIS_DICT) $(HEADERS) $(SOURCES)
@echo "\n----- $(PROJECT) library -----"
@if [ -z "${EXCLUDE_DELPHES}" ]; then \
ln -svf ${DELPHES_HOME}/external ./; \
fi
@echo "target: $@"
$(CXX) $(SOURCES) -shared -o $@ $(FLAGS) $(DEP_LIBRARIES) $(DEP_INCLUDES) -I${EPIC_ANALYSIS_HOME}
$(EPIC_ANALYSIS_DICT): $(HEADERS) $(DEP_TARGETS)
@echo "\n----- $(PROJECT) dictionary -----"
@echo "target: $@"
$(ROOTCLING) -f $@ $(DEP_INCLUDES) $(HEADERS)
@mkdir -p $(PREFIX)
@mv src/$(EPIC_ANALYSIS_PCM) $(PREFIX)/
# dependency builds
#################################################################
deps: delphes mstwpdf adage
deps-clean: delphes-clean mstwpdf-clean adage-clean
delphes:
@if [ -z "${EXCLUDE_DELPHES}" ]; then \
echo "\n===== $@ ====="; \
$(MAKE) -C ${DELPHES_HOME}; \
fi
delphes-clean:
@if [ -z "${EXCLUDE_DELPHES}" ]; then \
echo "\n===== $@ ====="; \
$(MAKE) -C ${DELPHES_HOME} clean; \
fi
mstwpdf:
@echo "\n===== $@ ====="
$(MAKE) -C ${MSTWPDF_HOME} $(DEP_RECIPE)
mstwpdf-clean:
@echo "\n===== $@ ====="
$(MAKE) -C ${MSTWPDF_HOME} clean
adage:
@echo "\n===== $@ ====="
$(MAKE) -C ${ADAGE_HOME} $(DEP_RECIPE)
adage-clean:
@echo "\n===== $@ ====="
$(MAKE) -C ${ADAGE_HOME} clean
# HPC executables
#################################################################
HPC_SOURCES := $(basename $(wildcard hpc/src/*.cpp))
HPC_EXECUTABLES := $(addsuffix .exe, $(HPC_SOURCES))
hpc: hpc-header $(HPC_EXECUTABLES)
hpc-header:
@echo "\n===== HPC executables ====="
hpc/src/%.exe: hpc/src/%.cpp $(EPIC_ANALYSIS_LIB)
@echo "----- build [email protected] -----"
$(CXX) -c $< -o [email protected] $(FLAGS) $(DEP_INCLUDES) $(EPIC_ANALYSIS_INCLUDES)
@echo "--- make executable $@"
$(CXX) -o $@ [email protected] $(DEP_LIBRARIES) $(EPIC_ANALYSIS_LIBRARIES)
$(RM) [email protected]
# clean
#################################################################
clean:
@echo "\n===== CLEAN $(PROJECT) ====="
$(RM) $(EPIC_ANALYSIS_LIB) $(PREFIX)/$(EPIC_ANALYSIS_PCM) $(EPIC_ANALYSIS_DICT) $(HPC_EXECUTABLES)