Fork me on GitHub

source: git/doc/genMakefile.tcl@ 83eb7e1

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

adapt Delphes to ProMC 1.5

  • Property mode set to 100644
File size: 10.4 KB
Line 
1#!/usr/bin/env tclsh
2
3set prefix "tmp/"
4set suffix " \\\n\t"
5
6set srcSuf {.$(SrcSuf)}
7set objSuf {.$(ObjSuf)}
8set pcmSuf {$(PcmSuf)}
9set exeSuf {$(ExeSuf)}
10
11proc 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
55proc 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
93proc 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
126proc 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
150proc 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
184proc headerDeps {} {
185 global suffix headerFiles
186
187 foreach fileName [array names headerFiles] {
188 dependencies $fileName "$fileName:" 0 "\t@touch \$@"
189 }
190}
191
192puts {
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
201include doc/Makefile.arch
202
203ROOT_MAJOR := $(shell $(RC) --version | cut -d'.' -f1)
204
205SrcSuf = cc
206PcmSuf = _rdict.pcm
207
208CXXFLAGS += $(ROOTCFLAGS) -Wno-write-strings -D_FILE_OFFSET_BITS=64 -DDROP_CGAL -I. -Iexternal -Iexternal/tcl
209DELPHES_LIBS = $(shell $(RC) --libs) -lEG $(SYSLIBS)
210DISPLAY_LIBS = $(shell $(RC) --evelibs) $(SYSLIBS)
211
212ifneq ($(CMSSW_FWLITE_INCLUDE_PATH),)
213HAS_CMSSW = true
214CXXFLAGS += -std=c++0x -I$(subst :, -I,$(CMSSW_FWLITE_INCLUDE_PATH))
215DELPHES_LIBS += -L$(subst include,lib,$(subst :, -L,$(CMSSW_FWLITE_INCLUDE_PATH)))
216ifneq ($(CMSSW_RELEASE_BASE),)
217CXXFLAGS += -I$(CMSSW_RELEASE_BASE)/src
218endif
219ifneq ($(LD_LIBRARY_PATH),)
220DELPHES_LIBS += -L$(subst include,lib,$(subst :, -L,$(LD_LIBRARY_PATH)))
221endif
222DELPHES_LIBS += -lGenVector -lFWCoreFWLite -lDataFormatsFWLite -lDataFormatsPatCandidates -lDataFormatsLuminosity -lSimDataFormatsGeneratorProducts -lCommonToolsUtils
223endif
224
225ifneq ($(PROMC),)
226HAS_PROMC = true
227CXXFLAGS += -I$(PROMC)/include -I$(PROMC)/src
228DELPHES_LIBS += -L$(PROMC)/lib -lpromc -lprotoc -lprotobuf -lprotobuf-lite -lcbook -lz
229endif
230
231ifneq ($(PYTHIA8),)
232HAS_PYTHIA8 = true
233CXXFLAGS += -I$(PYTHIA8)/include
234DELPHES_LIBS += -L$(PYTHIA8)/lib -lpythia8 -lLHAPDF -lgfortran -lz
235else
236ifneq ($(PYTHIA8DATA),)
237HAS_PYTHIA8 = true
238CXXFLAGS += -I$(PYTHIA8DATA)/../include
239DELPHES_LIBS += -L$(PYTHIA8DATA)/../lib -lpythia8 -lLHAPDF -lgfortran -lz
240endif
241endif
242
243###
244
245DELPHES = libDelphes.$(DllSuf)
246DELPHESLIB = libDelphes.lib
247
248DISPLAY = libDelphesDisplay.$(DllSuf)
249DISPLAYLIB = libDelphesDisplay.lib
250
251VERSION = $(shell cat VERSION)
252DISTDIR = Delphes-$(VERSION)
253DISTTAR = $(DISTDIR).tar.gz
254
255all:
256
257}
258
259executableDeps {converters/*.cpp} {examples/*.cpp}
260
261executableDeps {readers/DelphesHepMC.cpp} {readers/DelphesLHEF.cpp} {readers/DelphesSTDHEP.cpp}
262
263puts {ifeq ($(HAS_CMSSW),true)}
264executableDeps {readers/DelphesCMSFWLite.cpp}
265puts {endif}
266puts {}
267
268puts {ifeq ($(HAS_PROMC),true)}
269executableDeps {readers/DelphesProMC.cpp}
270puts {endif}
271puts {}
272
273puts {ifeq ($(HAS_PYTHIA8),true)}
274executableDeps {readers/DelphesPythia8.cpp}
275dictDeps {DELPHES_DICT} {modules/Pythia8LinkDef.h}
276puts {endif}
277puts {}
278
279dictDeps {DELPHES_DICT} {classes/ClassesLinkDef.h} {modules/ModulesLinkDef.h} {external/ExRootAnalysis/ExRootAnalysisLinkDef.h}
280
281dictDeps {DISPLAY_DICT} {display/DisplayLinkDef.h}
282
283sourceDeps {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}
284
285sourceDeps {DISPLAY} {display/*.cc}
286
287tclDeps
288
289headerDeps
290
291puts {
292
293###
294
295ifeq ($(ROOT_MAJOR),6)
296all: $(DELPHES) $(DELPHES_DICT_PCM) $(EXECUTABLE)
297display: $(DISPLAY) $(DISPLAY_DICT_PCM)
298else
299all: $(DELPHES) $(EXECUTABLE)
300display: $(DISPLAY)
301endif
302
303$(DELPHES): $(DELPHES_DICT_OBJ) $(DELPHES_OBJ) $(TCL_OBJ)
304 @mkdir -p $(@D)
305 @echo ">> Building $@"
306ifeq ($(ARCH),aix5)
307 @$(MAKESHARED) $(OutPutOpt) $@ $(DELPHES_LIBS) -p 0 $^
308else
309ifeq ($(PLATFORM),macosx)
310# We need to make both the .dylib and the .so
311 @$(LD) $(SOFLAGS)$@ $(LDFLAGS) $^ $(OutPutOpt) $@ $(DELPHES_LIBS)
312ifneq ($(subst $(MACOSX_MINOR),,1234),1234)
313ifeq ($(MACOSX_MINOR),4)
314 @ln -sf $@ $(subst .$(DllSuf),.so,$@)
315endif
316endif
317else
318ifeq ($(PLATFORM),win32)
319 @bindexplib $* $^ > $*.def
320 @lib -nologo -MACHINE:IX86 $^ -def:$*.def $(OutPutOpt)$(DELPHESLIB)
321 @$(LD) $(SOFLAGS) $(LDFLAGS) $^ $*.exp $(DELPHES_LIBS) $(OutPutOpt)$@
322 @$(MT_DLL)
323else
324 @$(LD) $(SOFLAGS) $(LDFLAGS) $^ $(OutPutOpt) $@ $(DELPHES_LIBS)
325 @$(MT_DLL)
326endif
327endif
328endif
329
330$(DISPLAY): $(DELPHES_DICT_OBJ) $(DISPLAY_DICT_OBJ) $(DELPHES_OBJ) $(DISPLAY_OBJ) $(TCL_OBJ)
331 @mkdir -p $(@D)
332 @echo ">> Building $@"
333ifeq ($(ARCH),aix5)
334 @$(MAKESHARED) $(OutPutOpt) $@ $(DISPLAY_LIBS) -p 0 $^
335else
336ifeq ($(PLATFORM),macosx)
337# We need to make both the .dylib and the .so
338 @$(LD) $(SOFLAGS)$@ $(LDFLAGS) $^ $(OutPutOpt) $@ $(DISPLAY_LIBS)
339ifneq ($(subst $(MACOSX_MINOR),,1234),1234)
340ifeq ($(MACOSX_MINOR),4)
341 @ln -sf $@ $(subst .$(DllSuf),.so,$@)
342endif
343endif
344else
345ifeq ($(PLATFORM),win32)
346 @bindexplib $* $^ > $*.def
347 @lib -nologo -MACHINE:IX86 $^ -def:$*.def $(OutPutOpt)$(DISPLAYLIB)
348 @$(LD) $(SOFLAGS) $(LDFLAGS) $^ $*.exp $(DISPLAY_LIBS) $(OutPutOpt)$@
349 @$(MT_DLL)
350else
351 @$(LD) $(SOFLAGS) $(LDFLAGS) $^ $(OutPutOpt) $@ $(DISPLAY_LIBS)
352 @$(MT_DLL)
353endif
354endif
355endif
356
357clean:
358 @rm -f $(DELPHES_DICT_OBJ) $(DISPLAY_DICT_OBJ) $(DELPHES_OBJ) $(DISPLAY_OBJ) $(TCL_OBJ) core
359 @rm -rf tmp
360
361distclean: clean
362 @rm -f $(DELPHES) $(DELPHESLIB) $(DELPHES_DICT_PCM) $(DISPLAY) $(DISPLAYLIB) $(DISPLAY_DICT_PCM) $(EXECUTABLE)
363
364dist:
365 @echo ">> Building $(DISTTAR)"
366 @mkdir -p $(DISTDIR)
367 @cp -a CHANGELOG CREDITS README VERSION Makefile configure classes converters display doc examples external modules python readers $(DISTDIR)
368 @find $(DISTDIR) -depth -name .\* -exec rm -rf {} \;
369 @tar -czf $(DISTTAR) $(DISTDIR)
370 @rm -rf $(DISTDIR)
371
372###
373
374.SUFFIXES: .$(SrcSuf) .$(ObjSuf) .$(DllSuf) $(PcmSuf)
375
376%Dict.$(SrcSuf):
377 @mkdir -p $(@D)
378 @echo ">> Generating $@"
379 @rootcint -f $@ -c -Iexternal $<
380 @echo "#define private public" > $@.arch
381 @echo "#define protected public" >> $@.arch
382 @mv $@ $@.base
383 @cat $@.arch $< $@.base > $@
384 @rm $@.arch $@.base
385
386%Dict$(PcmSuf):
387 @echo ">> Copying $@"
388 @cp $< $@
389
390$(DELPHES_OBJ): tmp/%.$(ObjSuf): %.$(SrcSuf)
391 @mkdir -p $(@D)
392 @echo ">> Compiling $<"
393 @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@
394
395$(DISPLAY_OBJ): tmp/%.$(ObjSuf): %.$(SrcSuf)
396 @mkdir -p $(@D)
397 @echo ">> Compiling $<"
398 @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@
399
400$(DELPHES_DICT_OBJ): %.$(ObjSuf): %.$(SrcSuf)
401 @mkdir -p $(@D)
402 @echo ">> Compiling $<"
403 @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@
404
405$(DISPLAY_DICT_OBJ): %.$(ObjSuf): %.$(SrcSuf)
406 @mkdir -p $(@D)
407 @echo ">> Compiling $<"
408 @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@
409
410$(TCL_OBJ): tmp/%.$(ObjSuf): %.c
411 @mkdir -p $(@D)
412 @echo ">> Compiling $<"
413 @$(CC) $(patsubst -std=%,,$(CXXFLAGS)) -c $< $(OutPutOpt)$@
414
415$(EXECUTABLE_OBJ): tmp/%.$(ObjSuf): %.cpp
416 @mkdir -p $(@D)
417 @echo ">> Compiling $<"
418 @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@
419
420$(EXECUTABLE): %$(ExeSuf): $(DELPHES_DICT_OBJ) $(DELPHES_OBJ) $(TCL_OBJ)
421 @echo ">> Building $@"
422 @$(LD) $(LDFLAGS) $^ $(DELPHES_LIBS) $(OutPutOpt)$@
423
424###
425
426}
Note: See TracBrowser for help on using the repository browser.