Fork me on GitHub

source: git/doc/genMakefile.tcl@ af9008e

ImprovedOutputFile Timing dual_readout llp
Last change on this file since af9008e was af9008e, checked in by pavel <pavel@…>, 11 years ago

add DelphesCMSFWLite, DelphesProMC and DelphesPythia8 to Makefile

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