1 | #!/usr/bin/env tclsh
|
---|
2 |
|
---|
3 | set prefix "tmp/"
|
---|
4 | set suffix " \\\n\t"
|
---|
5 |
|
---|
6 | set srcSuf {.$(SrcSuf)}
|
---|
7 | set objSuf {.$(ObjSuf)}
|
---|
8 | set exeSuf {$(ExeSuf)}
|
---|
9 |
|
---|
10 | proc dependencies {fileName firstLine {force 1} {command {}}} {
|
---|
11 | global suffix headerFiles sourceFiles
|
---|
12 |
|
---|
13 | if {[info exists sourceFiles($fileName)]} return
|
---|
14 |
|
---|
15 | set sourceFiles($fileName) 1
|
---|
16 |
|
---|
17 | set list {}
|
---|
18 | set fid [open $fileName]
|
---|
19 | while {! [eof $fid]} {
|
---|
20 | set line [gets $fid]
|
---|
21 | if [regexp -- {^\s*#include\s*"((\w+/)+\w+\.(h|hh))"} $line] {
|
---|
22 | set elements [split $line {"}]
|
---|
23 | set file [lindex $elements 1]
|
---|
24 | if [file exists $file] {
|
---|
25 | lappend list $file
|
---|
26 | set headerFiles($file) 1
|
---|
27 | } elseif [file exists external/$file] {
|
---|
28 | lappend list external/$file
|
---|
29 | set headerFiles(external/$file) 1
|
---|
30 | }
|
---|
31 | }
|
---|
32 | }
|
---|
33 |
|
---|
34 | if {[llength $list] > 0} {
|
---|
35 | puts -nonewline $firstLine
|
---|
36 | foreach file $list {puts -nonewline $suffix$file}
|
---|
37 | if {$command != {}} {
|
---|
38 | puts {}
|
---|
39 | puts $command
|
---|
40 | }
|
---|
41 | puts {}
|
---|
42 | } elseif {$force} {
|
---|
43 | puts -nonewline $firstLine
|
---|
44 | if {$command != {}} {
|
---|
45 | puts {}
|
---|
46 | puts $command
|
---|
47 | }
|
---|
48 | puts {}
|
---|
49 | }
|
---|
50 |
|
---|
51 | close $fid
|
---|
52 | }
|
---|
53 |
|
---|
54 | proc dictDeps {dictVar args} {
|
---|
55 |
|
---|
56 | global prefix suffix srcSuf objSuf
|
---|
57 |
|
---|
58 | set dict [eval glob -nocomplain $args]
|
---|
59 |
|
---|
60 | set dictSrcFiles {}
|
---|
61 | set dictObjFiles {}
|
---|
62 |
|
---|
63 | foreach fileName $dict {
|
---|
64 | regsub {LinkDef\.h} $fileName {Dict} dictName
|
---|
65 | set dictName $prefix$dictName
|
---|
66 |
|
---|
67 | lappend dictSrcFiles $dictName$srcSuf
|
---|
68 | lappend dictObjFiles $dictName$objSuf
|
---|
69 |
|
---|
70 | dependencies $fileName "$dictName$srcSuf:$suffix$fileName"
|
---|
71 | }
|
---|
72 |
|
---|
73 | puts -nonewline "${dictVar} += $suffix"
|
---|
74 | puts [join $dictSrcFiles $suffix]
|
---|
75 | puts {}
|
---|
76 |
|
---|
77 | puts -nonewline "${dictVar}_OBJ += $suffix"
|
---|
78 | puts [join $dictObjFiles $suffix]
|
---|
79 | puts {}
|
---|
80 |
|
---|
81 | }
|
---|
82 |
|
---|
83 | proc sourceDeps {srcPrefix args} {
|
---|
84 |
|
---|
85 | global prefix suffix srcSuf objSuf
|
---|
86 |
|
---|
87 | set source [eval glob -nocomplain $args]
|
---|
88 |
|
---|
89 | set srcObjFiles {}
|
---|
90 | set srcObjFilesPythia8 {}
|
---|
91 |
|
---|
92 | foreach fileName $source {
|
---|
93 | regsub {\.cc} $fileName {} srcName
|
---|
94 | set srcObjName $prefix$srcName
|
---|
95 |
|
---|
96 | if {$fileName == "modules/PileUpMergerPythia8.cc"} {
|
---|
97 | lappend srcObjFilesPythia8 $srcObjName$objSuf
|
---|
98 | } else {
|
---|
99 | lappend srcObjFiles $srcObjName$objSuf
|
---|
100 | }
|
---|
101 |
|
---|
102 | dependencies $fileName "$srcObjName$objSuf:$suffix$srcName$srcSuf"
|
---|
103 | }
|
---|
104 |
|
---|
105 | puts -nonewline "${srcPrefix}_OBJ += $suffix"
|
---|
106 | puts [join $srcObjFiles $suffix]
|
---|
107 | puts {}
|
---|
108 |
|
---|
109 | puts {ifeq ($(HAS_PYTHIA8),true)}
|
---|
110 | puts -nonewline "${srcPrefix}_OBJ += $suffix"
|
---|
111 | puts [join $srcObjFilesPythia8 $suffix]
|
---|
112 | puts {endif}
|
---|
113 | puts {}
|
---|
114 | }
|
---|
115 |
|
---|
116 | proc tclDeps {} {
|
---|
117 |
|
---|
118 | global prefix suffix srcSuf objSuf
|
---|
119 |
|
---|
120 | set source [glob -nocomplain {external/tcl/*.c}]
|
---|
121 |
|
---|
122 | set srcObjFiles {}
|
---|
123 |
|
---|
124 | foreach fileName $source {
|
---|
125 | if {$fileName == "tcl/tclc.c" || $fileName == "tcl/tcl.c"} continue
|
---|
126 |
|
---|
127 | regsub {\.c} $fileName {} srcName
|
---|
128 | set srcObjName $prefix$srcName
|
---|
129 |
|
---|
130 | lappend srcObjFiles $srcObjName$objSuf
|
---|
131 |
|
---|
132 | dependencies $fileName "$srcObjName$objSuf:$suffix$fileName"
|
---|
133 | }
|
---|
134 |
|
---|
135 | puts -nonewline "TCL_OBJ += $suffix"
|
---|
136 | puts [join $srcObjFiles $suffix]
|
---|
137 | puts {}
|
---|
138 | }
|
---|
139 |
|
---|
140 | proc executableDeps {args} {
|
---|
141 |
|
---|
142 | global prefix suffix objSuf exeSuf
|
---|
143 |
|
---|
144 | set executable [eval glob -nocomplain $args]
|
---|
145 |
|
---|
146 | set exeFiles {}
|
---|
147 |
|
---|
148 | foreach fileName $executable {
|
---|
149 | regsub {\.cpp} $fileName {} exeObjName
|
---|
150 | set exeObjName $prefix$exeObjName
|
---|
151 | set exeName [file tail $exeObjName]
|
---|
152 |
|
---|
153 | lappend exeFiles $exeName$exeSuf
|
---|
154 | lappend exeObjFiles $exeObjName$objSuf
|
---|
155 |
|
---|
156 | puts "$exeName$exeSuf:$suffix$exeObjName$objSuf"
|
---|
157 | puts {}
|
---|
158 |
|
---|
159 | dependencies $fileName "$exeObjName$objSuf:$suffix$fileName"
|
---|
160 | }
|
---|
161 |
|
---|
162 | if [info exists exeFiles] {
|
---|
163 | puts -nonewline "EXECUTABLE += $suffix"
|
---|
164 | puts [join $exeFiles $suffix]
|
---|
165 | puts {}
|
---|
166 | }
|
---|
167 | if [info exists exeObjFiles] {
|
---|
168 | puts -nonewline "EXECUTABLE_OBJ += $suffix"
|
---|
169 | puts [join $exeObjFiles $suffix]
|
---|
170 | puts {}
|
---|
171 | }
|
---|
172 | }
|
---|
173 |
|
---|
174 | proc headerDeps {} {
|
---|
175 | global suffix headerFiles
|
---|
176 |
|
---|
177 | foreach fileName [array names headerFiles] {
|
---|
178 | dependencies $fileName "$fileName:" 0 "\t@touch \$@"
|
---|
179 | }
|
---|
180 | }
|
---|
181 |
|
---|
182 | puts {
|
---|
183 | #
|
---|
184 | # Makefile for ExRootAnalysis
|
---|
185 | #
|
---|
186 | # Author: P. Demin - UCL, Louvain-la-Neuve
|
---|
187 | #
|
---|
188 | # multi-platform configuration is taken from ROOT (root/test/Makefile.arch)
|
---|
189 | #
|
---|
190 |
|
---|
191 | include doc/Makefile.arch
|
---|
192 |
|
---|
193 | ifeq ($(ARCH),macosx64)
|
---|
194 | UNDEFOPT = dynamic_lookup
|
---|
195 | endif
|
---|
196 |
|
---|
197 | SrcSuf = cc
|
---|
198 |
|
---|
199 | CXXFLAGS += $(ROOTCFLAGS) -Wno-write-strings -D_FILE_OFFSET_BITS=64 -DDROP_CGAL -I. -Iexternal -Iexternal/tcl
|
---|
200 | DELPHES_LIBS = $(shell $(RC) --libs) -lEG $(SYSLIBS)
|
---|
201 | DISPLAY_LIBS = $(shell $(RC) --evelibs) $(SYSLIBS)
|
---|
202 |
|
---|
203 | ifneq ($(CMSSW_FWLITE_INCLUDE_PATH),)
|
---|
204 | HAS_CMSSW = true
|
---|
205 | CXXFLAGS += -std=c++0x -I$(subst :, -I,$(CMSSW_FWLITE_INCLUDE_PATH))
|
---|
206 | DELPHES_LIBS += -L$(subst include,lib,$(subst :, -L,$(CMSSW_FWLITE_INCLUDE_PATH)))
|
---|
207 | ifneq ($(CMSSW_RELEASE_BASE),)
|
---|
208 | CXXFLAGS += -I$(CMSSW_RELEASE_BASE)/src
|
---|
209 | endif
|
---|
210 | ifneq ($(LD_LIBRARY_PATH),)
|
---|
211 | DELPHES_LIBS += -L$(subst include,lib,$(subst :, -L,$(LD_LIBRARY_PATH)))
|
---|
212 | endif
|
---|
213 | DELPHES_LIBS += -lGenVector -lFWCoreFWLite -lDataFormatsFWLite -lDataFormatsPatCandidates -lDataFormatsLuminosity -lCommonToolsUtils
|
---|
214 | endif
|
---|
215 |
|
---|
216 | ifneq ($(PROMC),)
|
---|
217 | HAS_PROMC = true
|
---|
218 | CXXFLAGS += -I$(PROMC)/include
|
---|
219 | DELPHES_LIBS += -L$(PROMC)/lib -lprotoc -lprotobuf -lprotobuf-lite -lcbook -lz
|
---|
220 | endif
|
---|
221 |
|
---|
222 | ifneq ($(PYTHIA8),)
|
---|
223 | HAS_PYTHIA8 = true
|
---|
224 | CXXFLAGS += -I$(PYTHIA8)/include
|
---|
225 | DELPHES_LIBS += -L$(PYTHIA8)/lib -lpythia8 -lLHAPDF -lgfortran -lz
|
---|
226 | else
|
---|
227 | ifneq ($(PYTHIA8DATA),)
|
---|
228 | HAS_PYTHIA8 = true
|
---|
229 | CXXFLAGS += -I$(PYTHIA8DATA)/../include
|
---|
230 | DELPHES_LIBS += -L$(PYTHIA8DATA)/../lib -lpythia8 -lLHAPDF -lgfortran -lz
|
---|
231 | endif
|
---|
232 | endif
|
---|
233 |
|
---|
234 | ###
|
---|
235 |
|
---|
236 | DELPHES = libDelphes.$(DllSuf)
|
---|
237 | DELPHESLIB = libDelphes.lib
|
---|
238 |
|
---|
239 | DISPLAY = libDelphesDisplay.$(DllSuf)
|
---|
240 | DISPLAYLIB = libDelphesDisplay.lib
|
---|
241 |
|
---|
242 | VERSION = $(shell cat VERSION)
|
---|
243 | DISTDIR = Delphes-$(VERSION)
|
---|
244 | DISTTAR = $(DISTDIR).tar.gz
|
---|
245 |
|
---|
246 | all:
|
---|
247 |
|
---|
248 | }
|
---|
249 |
|
---|
250 | executableDeps {converters/*.cpp} {examples/*.cpp}
|
---|
251 |
|
---|
252 | executableDeps {readers/DelphesHepMC.cpp} {readers/DelphesLHEF.cpp} {readers/DelphesSTDHEP.cpp}
|
---|
253 |
|
---|
254 | puts {ifeq ($(HAS_CMSSW),true)}
|
---|
255 | executableDeps {readers/DelphesCMSFWLite.cpp}
|
---|
256 | puts {endif}
|
---|
257 | puts {}
|
---|
258 |
|
---|
259 | puts {ifeq ($(HAS_PROMC),true)}
|
---|
260 | executableDeps {readers/DelphesProMC.cpp}
|
---|
261 | sourceDeps {DELPHES} {external/ProMC/*.cc}
|
---|
262 | puts {endif}
|
---|
263 | puts {}
|
---|
264 |
|
---|
265 | puts {ifeq ($(HAS_PYTHIA8),true)}
|
---|
266 | executableDeps {readers/DelphesPythia8.cpp}
|
---|
267 | dictDeps {DELPHES_DICT} {modules/Pythia8LinkDef.h}
|
---|
268 | puts {endif}
|
---|
269 | puts {}
|
---|
270 |
|
---|
271 | dictDeps {DELPHES_DICT} {classes/ClassesLinkDef.h} {modules/ModulesLinkDef.h} {external/ExRootAnalysis/ExRootAnalysisLinkDef.h}
|
---|
272 |
|
---|
273 | dictDeps {DISPLAY_DICT} {display/DisplayLinkDef.h}
|
---|
274 |
|
---|
275 | sourceDeps {DELPHES} {classes/*.cc} {modules/*.cc} {external/ExRootAnalysis/*.cc} {external/fastjet/*.cc} {external/fastjet/tools/*.cc} {external/fastjet/plugins/*/*.cc} {external/Hector/*.cc} {external/fastjet/contribs/Nsubjettiness/*.cc}
|
---|
276 |
|
---|
277 | sourceDeps {DISPLAY} {display/*.cc}
|
---|
278 |
|
---|
279 | tclDeps
|
---|
280 |
|
---|
281 | headerDeps
|
---|
282 |
|
---|
283 | puts {
|
---|
284 |
|
---|
285 | ###
|
---|
286 |
|
---|
287 | all: $(DELPHES) $(EXECUTABLE)
|
---|
288 |
|
---|
289 | display: $(DISPLAY)
|
---|
290 |
|
---|
291 | $(DELPHES): $(DELPHES_DICT_OBJ) $(DELPHES_OBJ) $(TCL_OBJ)
|
---|
292 | @mkdir -p $(@D)
|
---|
293 | @echo ">> Building $@"
|
---|
294 | ifeq ($(ARCH),aix5)
|
---|
295 | @$(MAKESHARED) $(OutPutOpt) $@ $(DELPHES_LIBS) -p 0 $^
|
---|
296 | else
|
---|
297 | ifeq ($(PLATFORM),macosx)
|
---|
298 | # We need to make both the .dylib and the .so
|
---|
299 | @$(LD) $(SOFLAGS)$@ $(LDFLAGS) $^ $(OutPutOpt) $@ $(DELPHES_LIBS)
|
---|
300 | ifneq ($(subst $(MACOSX_MINOR),,1234),1234)
|
---|
301 | ifeq ($(MACOSX_MINOR),4)
|
---|
302 | @ln -sf $@ $(subst .$(DllSuf),.so,$@)
|
---|
303 | endif
|
---|
304 | endif
|
---|
305 | else
|
---|
306 | ifeq ($(PLATFORM),win32)
|
---|
307 | @bindexplib $* $^ > $*.def
|
---|
308 | @lib -nologo -MACHINE:IX86 $^ -def:$*.def $(OutPutOpt)$(DELPHESLIB)
|
---|
309 | @$(LD) $(SOFLAGS) $(LDFLAGS) $^ $*.exp $(DELPHES_LIBS) $(OutPutOpt)$@
|
---|
310 | @$(MT_DLL)
|
---|
311 | else
|
---|
312 | @$(LD) $(SOFLAGS) $(LDFLAGS) $^ $(OutPutOpt) $@ $(DELPHES_LIBS)
|
---|
313 | @$(MT_DLL)
|
---|
314 | endif
|
---|
315 | endif
|
---|
316 | endif
|
---|
317 |
|
---|
318 | $(DISPLAY): $(DELPHES_DICT_OBJ) $(DISPLAY_DICT_OBJ) $(DELPHES_OBJ) $(DISPLAY_OBJ) $(TCL_OBJ)
|
---|
319 | @mkdir -p $(@D)
|
---|
320 | @echo ">> Building $@"
|
---|
321 | ifeq ($(ARCH),aix5)
|
---|
322 | @$(MAKESHARED) $(OutPutOpt) $@ $(DISPLAY_LIBS) -p 0 $^
|
---|
323 | else
|
---|
324 | ifeq ($(PLATFORM),macosx)
|
---|
325 | # We need to make both the .dylib and the .so
|
---|
326 | @$(LD) $(SOFLAGS)$@ $(LDFLAGS) $^ $(OutPutOpt) $@ $(DISPLAY_LIBS)
|
---|
327 | ifneq ($(subst $(MACOSX_MINOR),,1234),1234)
|
---|
328 | ifeq ($(MACOSX_MINOR),4)
|
---|
329 | @ln -sf $@ $(subst .$(DllSuf),.so,$@)
|
---|
330 | endif
|
---|
331 | endif
|
---|
332 | else
|
---|
333 | ifeq ($(PLATFORM),win32)
|
---|
334 | @bindexplib $* $^ > $*.def
|
---|
335 | @lib -nologo -MACHINE:IX86 $^ -def:$*.def $(OutPutOpt)$(DISPLAYLIB)
|
---|
336 | @$(LD) $(SOFLAGS) $(LDFLAGS) $^ $*.exp $(DISPLAY_LIBS) $(OutPutOpt)$@
|
---|
337 | @$(MT_DLL)
|
---|
338 | else
|
---|
339 | @$(LD) $(SOFLAGS) $(LDFLAGS) $^ $(OutPutOpt) $@ $(DISPLAY_LIBS)
|
---|
340 | @$(MT_DLL)
|
---|
341 | endif
|
---|
342 | endif
|
---|
343 | endif
|
---|
344 |
|
---|
345 | clean:
|
---|
346 | @rm -f $(DELPHES_DICT_OBJ) $(DISPLAY_DICT_OBJ) $(DELPHES_OBJ) $(DISPLAY_OBJ) $(TCL_OBJ) core
|
---|
347 | @rm -rf tmp
|
---|
348 |
|
---|
349 | distclean: clean
|
---|
350 | @rm -f $(DELPHES) $(DELPHESLIB) $(DISPLAY) $(DISPLAYLIB) $(EXECUTABLE)
|
---|
351 |
|
---|
352 | dist:
|
---|
353 | @echo ">> Building $(DISTTAR)"
|
---|
354 | @mkdir -p $(DISTDIR)
|
---|
355 | @cp -a CHANGELOG CREDITS README VERSION Makefile configure classes converters display doc examples external modules python readers $(DISTDIR)
|
---|
356 | @find $(DISTDIR) -depth -name .\* -exec rm -rf {} \;
|
---|
357 | @tar -czf $(DISTTAR) $(DISTDIR)
|
---|
358 | @rm -rf $(DISTDIR)
|
---|
359 |
|
---|
360 | ###
|
---|
361 |
|
---|
362 | .SUFFIXES: .$(SrcSuf) .$(ObjSuf) .$(DllSuf)
|
---|
363 |
|
---|
364 | %Dict.$(SrcSuf):
|
---|
365 | @mkdir -p $(@D)
|
---|
366 | @echo ">> Generating $@"
|
---|
367 | @rootcint -f $@ -c -Iexternal $<
|
---|
368 | @echo "#define private public" > $@.arch
|
---|
369 | @echo "#define protected public" >> $@.arch
|
---|
370 | @mv $@ $@.base
|
---|
371 | @cat $@.arch $< $@.base > $@
|
---|
372 | @rm $@.arch $@.base
|
---|
373 |
|
---|
374 | $(DELPHES_OBJ): tmp/%.$(ObjSuf): %.$(SrcSuf)
|
---|
375 | @mkdir -p $(@D)
|
---|
376 | @echo ">> Compiling $<"
|
---|
377 | @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@
|
---|
378 |
|
---|
379 | $(DISPLAY_OBJ): tmp/%.$(ObjSuf): %.$(SrcSuf)
|
---|
380 | @mkdir -p $(@D)
|
---|
381 | @echo ">> Compiling $<"
|
---|
382 | @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@
|
---|
383 |
|
---|
384 | $(DELPHES_DICT_OBJ): %.$(ObjSuf): %.$(SrcSuf)
|
---|
385 | @mkdir -p $(@D)
|
---|
386 | @echo ">> Compiling $<"
|
---|
387 | @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@
|
---|
388 |
|
---|
389 | $(DISPLAY_DICT_OBJ): %.$(ObjSuf): %.$(SrcSuf)
|
---|
390 | @mkdir -p $(@D)
|
---|
391 | @echo ">> Compiling $<"
|
---|
392 | @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@
|
---|
393 |
|
---|
394 | $(TCL_OBJ): tmp/%.$(ObjSuf): %.c
|
---|
395 | @mkdir -p $(@D)
|
---|
396 | @echo ">> Compiling $<"
|
---|
397 | @gcc $(CXXFLAGS) -c $< $(OutPutOpt)$@
|
---|
398 |
|
---|
399 | $(EXECUTABLE_OBJ): tmp/%.$(ObjSuf): %.cpp
|
---|
400 | @mkdir -p $(@D)
|
---|
401 | @echo ">> Compiling $<"
|
---|
402 | @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@
|
---|
403 |
|
---|
404 | $(EXECUTABLE): %$(ExeSuf): $(DELPHES_DICT_OBJ) $(DELPHES_OBJ) $(TCL_OBJ)
|
---|
405 | @echo ">> Building $@"
|
---|
406 | @$(LD) $(LDFLAGS) $^ $(DELPHES_LIBS) $(OutPutOpt)$@
|
---|
407 |
|
---|
408 | ###
|
---|
409 |
|
---|
410 | }
|
---|