Fork me on GitHub

source: git/doc/genMakefile.tcl@ f6b6ee7

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

add optional libraries to event display

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