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