-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
243 lines (200 loc) · 8.74 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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
# ProofAna makefile
# B. Butler
# --- External configuration ----------------------------------
ARCH_LOC_1 := $(wildcard $(shell root-config --prefix)/etc/Makefile.arch)
ARCH_LOC_2 := $(wildcard $(shell root-config --prefix)/test/Makefile.arch)
ARCH_LOC_3 := $(wildcard $(shell root-config --prefix)/share/root/test/Makefile.arch)
ARCH_LOC_4 := $(wildcard $(shell root-config --prefix)/share/doc/root/test/Makefile.arch)
ifneq ($(strip $(ARCH_LOC_1)),)
$(info Using $(ARCH_LOC_1))
include $(ARCH_LOC_1)
else
ifneq ($(strip $(ARCH_LOC_2)),)
$(info Using $(ARCH_LOC_2))
include $(ARCH_LOC_2)
else
ifneq ($(strip $(ARCH_LOC_3)),)
$(info Using $(ARCH_LOC_3))
include $(ARCH_LOC_3)
else
ifneq ($(strip $(ARCH_LOC_4)),)
$(info Using $(ARCH_LOC_4))
include $(ARCH_LOC_4)
else
$(error Could not find Makefile.arch! Is ROOT not set up?)
endif
endif
endif
endif
# -------------------------------------------------------------
# Hack for Mac OSX 10.6+
# -------------------------------------------------------------
ifeq ($(PLATFORM),macosx)
SOFLAGS += -undefined dynamic_lookup
endif
# -------------------------------------------------------------
# General flags
# -------------------------------------------------------------
PACKAGE := ProofAna
OUTPUTDIR := lib
# glibc memcmp much faster (factor of 3) than gcc builtin for gcc 4.0-4.7, we use it heavily for comparing strings
ifneq ($(CXX),clang++)
CXXFLAGS += -fno-builtin-memcmp
else
CXXFLAGS += -Qunused-arguments
endif
# SLC5 Athena release in SL6
CXXFLAGS += $(CPPEXPFLAGS)
INCLUDES += -I. -Icore -Ihelpers -Ianalyses -Ieventbuilders -Iutils -I${ROOTSYS}/include
# Need these to avoid loading dependent libraries when ROOT starts
LINKLIBS := -L${ROOTSYS}/lib -lHist -lMatrix -lTree -lNet -lProofPlayer -lProof -lRIO -lThread -lMathCore -lPhysics
default: parlib
# -------------------------------------------------------------
# ProofAna packages
# -------------------------------------------------------------
# These have the form NAME/eventbuilders, NAME/utils NAME/analyses, etc. They are detected via scripts which
# use symbolic links in order to integrate them with ProofAna
PACKAGEOUT := $(shell sh scripts/package_links.sh)
PACKAGEFLAG := $(findstring SUCCESS,$(PACKAGEOUT))
PACKAGEMSG := $(filter-out SUCCESS,$(PACKAGEOUT))
ifneq (SUCCESS,$(PACKAGEFLAG))
$(error ProofAna package symbolic link processing failed: $(PACKAGEMSG))
endif
# -------------------------------------------------------------
# External utilities
# -------------------------------------------------------------
# DEPS is a list of rules to make util dependencies for ProofAna, can be shared libraries or other files
# LOADS is a list of CINT commands to execute to load utils libraries
# CLEANS are rules to make clean for utils packages
# EXCLUDES are files (in the form "--exclude FILE1 --exclude FILE2") which should NOT be put in the PAR tarball
# GRIDEXECS are CINT commands that must be executed only on the grid
-include $(shell sh scripts/order_utils.sh)
# -------------------------------------------------------------
# ROOT Cint
# -------------------------------------------------------------
CINT := ProofAnaCint
LDEFFILE := $(OUTPUTDIR)/LinkDef.h
CINTFILE := $(OUTPUTDIR)/$(CINT).cxx
CINTOBJ := $(patsubst %.cxx,%.o,$(CINTFILE))
EBCXXLIST := $(filter-out %Cint.cxx,$(wildcard eventbuilders/EventBuilder_*.cxx))
ANACXXLIST := $(filter-out %Cint.cxx,$(wildcard analyses/Analysis_*.cxx))
EBHLIST := $(patsubst %.cxx,%.h,$(EBCXXLIST))
ANAHLIST := $(patsubst %.cxx,%.h,$(ANACXXLIST))
PAHLIST := $(wildcard core/*.h)
FECINTOBJLIST := $(patsubst %.h,%_Cint.o,$(EBHLIST))
ANACINTOBJLIST := $(patsubst %.h,%_Cint.o,$(ANAHLIST))
# -------------------------------------------------------------
# ProofAna source
# -------------------------------------------------------------
# add util subdirectories if needed
CXXLIST := $(wildcard core/*.cxx) $(EBCXXLIST) $(ANACXXLIST)
HLIST := $(PAHLIST) $(EBHLIST) $(ANAHLIST)
OLIST := $(patsubst %.cxx,%.o,$(CXXLIST)) $(FECINTOBJLIST) $(ANACINTOBJLIST) $(CINTOBJ)
DLIST := $(patsubst %.h,%.d,$(HLIST))
# -------------------------------------------------------------
# Libraries
# -------------------------------------------------------------
LIBFILE := $(OUTPUTDIR)/libProofAna.so
PARFILE := $(OUTPUTDIR)/libProofAna.par
ifeq ($(PLATFORM),macosx)
EXTRALDFLAGS := -install_name @rpath/libProofAna.so
endif
# get libraries of ROOT
define ldlinksuffixROOT
$(addsuffix $(LDLINKSUFFIX),$(Lib)) $(shell if [ "$(findstring -Ldlink2,$(OPTIONS))" ]; then echo $(addsuffix _pkgid_$(ROOTVER),$(Lib)); fi)
endef
# -------------------------------------------------------------
# PAR file extras
# -------------------------------------------------------------
# use "make root" to include ROOT files in the PAR file (can increase the size of the PAR file enormously)
ifeq (,$(findstring root,$(MAKECMDGOALS)))
EXCLUDES += --exclude \*.root\*
else
$(shell if [ -e $(PARFILE) ]; then rm $(PARFILE); fi)
endif
# use "make binparlib" to include binary libraries in par file to avoid compilation on workers
# do not use this option on the Grid!
ifeq (,$(findstring binparlib,$(MAKECMDGOALS)))
EXCLUDES += --exclude \*.so --exclude \*.dylib --exclude \*Cint\* --exclude \*.d --exclude \*.o --exclude packages.lock
else
EXCLUDESBKP := $(EXCLUDES)
EXCLUDES := binparlib $(EXCLUDESBKP)
$(shell if [ -e $(PARFILE) ]; then rm $(PARFILE); fi)
endif
# -------------------------------------------------------------
# Compilation
# -------------------------------------------------------------
# Implicit rule to compile Analysis classes
Analysis_%.o : Analysis_%.cxx $(DEPS)
@echo "Compiling $<"
@$(CXX) -MD $(CXXFLAGS) $(INCLUDES) -c $< -o $@
# Implicit rule to compile EventBuilder classes
EventBuilder_%.o : EventBuilder_%.cxx $(DEPS)
@echo "Compiling $<"
@$(CXX) -MD $(CXXFLAGS) $(INCLUDES) -c $< -o $@
# Implicit rule to compile core and generic classes
%.o : %.cxx
@echo "Compiling $<"
@$(CXX) -MD $(CXXFLAGS) $(INCLUDES) -c $< -o $@
# Implicit rule to write ROOTCINT dictionary classes for Analyses, EventBuilders
%_Cint.cxx : %.h $(PAHLIST) %_LinkDef.h
@echo "Running rootcint for $*"
@$(ROOTSYS)/bin/rootcint -f $@ -c -p $(CXXFLAGS) $(INCLUDES) $^
# Implicit rule to write LinkDef.h files for Analyses, EventBuilders
%_LinkDef.h : $(DEPS)
@echo "Creating LinkDef file for class $(patsubst analyses/%,%,$(patsubst eventbuilders/%,%,$*))"
@echo "#ifndef __$(patsubst analyses/%,%,$(patsubst eventbuilders/%,%,$*))__" >> $@
@echo "#define __$(patsubst analyses/%,%,$(patsubst eventbuilders/%,%,$*))__" >> $@
@echo "" >> $@
@echo "#ifdef __CINT__" >> $@
@echo "" >> $@
@echo "#pragma link off all globals;" >> $@
@echo "#pragma link off all defined_ines;" >> $@
@echo "#pragma link off all functions;" >> $@
@echo "#pragma link C++ nestedclasses;" >> $@
@echo "" >> $@
@echo "#pragma link C++ class $(patsubst analyses/%,%,$(patsubst eventbuilders/%,%,$*))+;" >> $@
@echo "" >> $@
@echo "#endif" >> $@
@echo "#endif" >> $@
# Rules to make ROOTCINT output file
$(CINTOBJ) : $(PAHLIST) $(LDEFFILE)
@echo "Running rootcint for $(CINT)"
@$(ROOTSYS)/bin/rootcint -f $(CINTFILE) -c -p $(CXXFLAGS) $(INCLUDES) $(PAHLIST) $(LDEFFILE)
@echo "Compiling $(CINTFILE)"
@$(CXX) $(CXXFLAGS) $(INCLUDES) -c $(CINTFILE) -o $@
# Rule to combine objects into a shared library
$(LIBFILE): $(OLIST) $(OUTPUTDIR)/packages.lock
@echo "Linking $(LIBFILE)"
@mkdir -p $(OUTPUTDIR)
@rm -f $(LIBFILE)
@$(LD) $(CXXFLAGS) $(SOFLAGS) $(LINKLIBS) $(EXTRALDFLAGS) $(OLIST) -o $(LIBFILE)
# Rule to create PAR file
$(PARFILE): $(DEPS) $(CXXLIST) $(HLIST) $(LDEFFILE) $(LIBFILE)
@echo "Making lib/libProofAna.par"
@sh scripts/make_ProofAna_par.sh $(EXCLUDES) --exclude \*.log --exclude \*.status --exclude \*~ --exclude .svn --exclude \*.par
# Rule to write library-loading script
scripts/loadLibraries.C:
@if [ -e scripts/loadLibraries.C ]; then rm scripts/loadLibraries.C; fi
@echo "Writing loadLibraries function..."
@echo "// Generated by ProofAna makefile, do not edit manually" >> $@
@echo "int loadLibraries() {" >> $@
@echo " if(!gSystem->Getenv(\"PROOFANADIR\")) gSystem->Setenv(\"PROOFANADIR\",\"..\");" >> $@
@echo " gSystem->AddDynamicPath(gSystem->Getenv(\"PROOFANADIR\"));" >> $@
@echo " $(LOADS)" >> $@
@echo " if (gSystem->Load(\"$(LIBFILE)\") == -1) return -1;" >> $@
@echo " return 0;" >> $@
@echo "}" >> $@
-include $(DLIST)
.PHONY: ProofAnaCint parlib binparlib root solib clean $(CLEANS) scripts/loadLibraries.C
# Prevents deletion of intermediate files
.SECONDARY:
ProofAnaCint: $(CINTOBJ) $(ANACINTOBJLIST) $(FECINTOBJLIST)
parlib: solib $(PARFILE)
binparlib: parlib
@:
root: parlib
@:
solib: $(DEPS) $(LIBFILE) scripts/loadLibraries.C
clean: $(CLEANS)
@rm -f */*.o */*.d */*Cint* */*.so */*.lock */*.par