Fork me on GitHub

source: git/doc/genMakefile.tcl@ 529fe78

ImprovedOutputFile Timing dual_readout llp
Last change on this file since 529fe78 was 529fe78, checked in by Pavel Demin <pavel.demin@…>, 10 years ago

replace weights()[0] with weight() in DelphesCMSFWLite.cpp

  • Property mode set to 100644
File size: 9.8 KB
Line 
1#!/usr/bin/env tclsh
2
3set prefix "tmp/"
4set suffix " \\\n\t"
5
6set srcSuf {.$(SrcSuf)}
7set objSuf {.$(ObjSuf)}
8set exeSuf {$(ExeSuf)}
9
10proc 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
54proc 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
83proc 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
116proc 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
140proc 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
174proc headerDeps {} {
175 global suffix headerFiles
176
177 foreach fileName [array names headerFiles] {
178 dependencies $fileName "$fileName:" 0 "\t@touch \$@"
179 }
180}
181
182puts {
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
191include doc/Makefile.arch
192
193ifeq ($(ARCH),macosx64)
194UNDEFOPT = dynamic_lookup
195endif
196
197SrcSuf = cc
198
199CXXFLAGS += $(ROOTCFLAGS) -Wno-write-strings -D_FILE_OFFSET_BITS=64 -DDROP_CGAL -I. -Iexternal -Iexternal/tcl
200DELPHES_LIBS = $(shell $(RC) --libs) -lEG $(SYSLIBS)
201DISPLAY_LIBS = $(shell $(RC) --evelibs) $(SYSLIBS)
202
203ifneq ($(CMSSW_FWLITE_INCLUDE_PATH),)
204HAS_CMSSW = true
205CXXFLAGS += -std=c++0x -I$(subst :, -I,$(CMSSW_FWLITE_INCLUDE_PATH))
206DELPHES_LIBS += -L$(subst include,lib,$(subst :, -L,$(CMSSW_FWLITE_INCLUDE_PATH)))
207ifneq ($(CMSSW_RELEASE_BASE),)
208CXXFLAGS += -I$(CMSSW_RELEASE_BASE)/src
209endif
210ifneq ($(LD_LIBRARY_PATH),)
211DELPHES_LIBS += -L$(subst include,lib,$(subst :, -L,$(LD_LIBRARY_PATH)))
212endif
213DELPHES_LIBS += -lGenVector -lFWCoreFWLite -lDataFormatsFWLite -lDataFormatsPatCandidates -lDataFormatsLuminosity -lSimDataFormatsGeneratorProducts -lCommonToolsUtils
214endif
215
216ifneq ($(PROMC),)
217HAS_PROMC = true
218CXXFLAGS += -I$(PROMC)/include
219DELPHES_LIBS += -L$(PROMC)/lib -lprotoc -lprotobuf -lprotobuf-lite -lcbook -lz
220endif
221
222ifneq ($(PYTHIA8),)
223HAS_PYTHIA8 = true
224CXXFLAGS += -I$(PYTHIA8)/include
225DELPHES_LIBS += -L$(PYTHIA8)/lib -lpythia8 -lLHAPDF -lgfortran -lz
226else
227ifneq ($(PYTHIA8DATA),)
228HAS_PYTHIA8 = true
229CXXFLAGS += -I$(PYTHIA8DATA)/../include
230DELPHES_LIBS += -L$(PYTHIA8DATA)/../lib -lpythia8 -lLHAPDF -lgfortran -lz
231endif
232endif
233
234###
235
236DELPHES = libDelphes.$(DllSuf)
237DELPHESLIB = libDelphes.lib
238
239DISPLAY = libDelphesDisplay.$(DllSuf)
240DISPLAYLIB = libDelphesDisplay.lib
241
242VERSION = $(shell cat VERSION)
243DISTDIR = Delphes-$(VERSION)
244DISTTAR = $(DISTDIR).tar.gz
245
246all:
247
248}
249
250executableDeps {converters/*.cpp} {examples/*.cpp}
251
252executableDeps {readers/DelphesHepMC.cpp} {readers/DelphesLHEF.cpp} {readers/DelphesSTDHEP.cpp}
253
254puts {ifeq ($(HAS_CMSSW),true)}
255executableDeps {readers/DelphesCMSFWLite.cpp}
256puts {endif}
257puts {}
258
259puts {ifeq ($(HAS_PROMC),true)}
260executableDeps {readers/DelphesProMC.cpp}
261sourceDeps {DELPHES} {external/ProMC/*.cc}
262puts {endif}
263puts {}
264
265puts {ifeq ($(HAS_PYTHIA8),true)}
266executableDeps {readers/DelphesPythia8.cpp}
267dictDeps {DELPHES_DICT} {modules/Pythia8LinkDef.h}
268puts {endif}
269puts {}
270
271dictDeps {DELPHES_DICT} {classes/ClassesLinkDef.h} {modules/ModulesLinkDef.h} {external/ExRootAnalysis/ExRootAnalysisLinkDef.h}
272
273dictDeps {DISPLAY_DICT} {display/DisplayLinkDef.h}
274
275sourceDeps {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}
276
277sourceDeps {DISPLAY} {display/*.cc}
278
279tclDeps
280
281headerDeps
282
283puts {
284
285###
286
287all: $(DELPHES) $(EXECUTABLE)
288
289display: $(DISPLAY)
290
291$(DELPHES): $(DELPHES_DICT_OBJ) $(DELPHES_OBJ) $(TCL_OBJ)
292 @mkdir -p $(@D)
293 @echo ">> Building $@"
294ifeq ($(ARCH),aix5)
295 @$(MAKESHARED) $(OutPutOpt) $@ $(DELPHES_LIBS) -p 0 $^
296else
297ifeq ($(PLATFORM),macosx)
298# We need to make both the .dylib and the .so
299 @$(LD) $(SOFLAGS)$@ $(LDFLAGS) $^ $(OutPutOpt) $@ $(DELPHES_LIBS)
300ifneq ($(subst $(MACOSX_MINOR),,1234),1234)
301ifeq ($(MACOSX_MINOR),4)
302 @ln -sf $@ $(subst .$(DllSuf),.so,$@)
303endif
304endif
305else
306ifeq ($(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)
311else
312 @$(LD) $(SOFLAGS) $(LDFLAGS) $^ $(OutPutOpt) $@ $(DELPHES_LIBS)
313 @$(MT_DLL)
314endif
315endif
316endif
317
318$(DISPLAY): $(DELPHES_DICT_OBJ) $(DISPLAY_DICT_OBJ) $(DELPHES_OBJ) $(DISPLAY_OBJ) $(TCL_OBJ)
319 @mkdir -p $(@D)
320 @echo ">> Building $@"
321ifeq ($(ARCH),aix5)
322 @$(MAKESHARED) $(OutPutOpt) $@ $(DISPLAY_LIBS) -p 0 $^
323else
324ifeq ($(PLATFORM),macosx)
325# We need to make both the .dylib and the .so
326 @$(LD) $(SOFLAGS)$@ $(LDFLAGS) $^ $(OutPutOpt) $@ $(DISPLAY_LIBS)
327ifneq ($(subst $(MACOSX_MINOR),,1234),1234)
328ifeq ($(MACOSX_MINOR),4)
329 @ln -sf $@ $(subst .$(DllSuf),.so,$@)
330endif
331endif
332else
333ifeq ($(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)
338else
339 @$(LD) $(SOFLAGS) $(LDFLAGS) $^ $(OutPutOpt) $@ $(DISPLAY_LIBS)
340 @$(MT_DLL)
341endif
342endif
343endif
344
345clean:
346 @rm -f $(DELPHES_DICT_OBJ) $(DISPLAY_DICT_OBJ) $(DELPHES_OBJ) $(DISPLAY_OBJ) $(TCL_OBJ) core
347 @rm -rf tmp
348
349distclean: clean
350 @rm -f $(DELPHES) $(DELPHESLIB) $(DISPLAY) $(DISPLAYLIB) $(EXECUTABLE)
351
352dist:
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}
Note: See TracBrowser for help on using the repository browser.