Fork me on GitHub

source: git/doc/genMakefile.tcl@ df04eb1

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

add COPYING to tar file

  • Property mode set to 100644
File size: 11.9 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 {dictPrefix args} {
56
57 global prefix suffix srcSuf objSuf pcmSuf
58
59 set dict [lsort [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 "${dictPrefix}_OBJ += $suffix"
81 puts [join $dictObjFiles $suffix]
82 puts {}
83
84 puts -nonewline "${dictPrefix}_PCM += $suffix"
85 puts [join $dictPcmFiles $suffix]
86 puts {}
87}
88
89proc sourceDeps {srcPrefix args} {
90
91 global prefix suffix srcSuf objSuf
92
93 set source [lsort [eval glob -nocomplain $args]]
94
95 set srcObjFiles {}
96 set srcObjFilesFastJet {}
97 set srcObjFilesPythia8 {}
98
99 foreach fileName $source {
100 regsub {\.cc} $fileName {} srcName
101 set srcObjName $prefix$srcName
102
103 if {$fileName == "modules/PileUpMergerPythia8.cc"} {
104 lappend srcObjFilesPythia8 $srcObjName$objSuf
105 } elseif {[string match {modules/FastJet*.cc} $fileName] && $srcPrefix != {FASTJET}} {
106 continue
107 } else {
108 lappend srcObjFiles $srcObjName$objSuf
109 }
110
111 dependencies $fileName "$srcObjName$objSuf:$suffix$srcName$srcSuf"
112 }
113
114 puts -nonewline "${srcPrefix}_OBJ += $suffix"
115 puts [join $srcObjFiles $suffix]
116 puts {}
117
118 puts {ifeq ($(HAS_PYTHIA8),true)}
119 puts -nonewline "${srcPrefix}_OBJ += $suffix"
120 puts [join $srcObjFilesPythia8 $suffix]
121 puts {endif}
122 puts {}
123}
124
125proc tclDeps {} {
126
127 global prefix suffix srcSuf objSuf
128
129 set source [lsort [glob -nocomplain {external/tcl/*.c}]]
130
131 set srcObjFiles {}
132
133 foreach fileName $source {
134 if {$fileName == "tcl/tclc.c" || $fileName == "tcl/tcl.c"} continue
135
136 regsub {\.c} $fileName {} srcName
137 set srcObjName $prefix$srcName
138
139 lappend srcObjFiles $srcObjName$objSuf
140
141 dependencies $fileName "$srcObjName$objSuf:$suffix$fileName"
142 }
143
144 puts -nonewline "TCL_OBJ += $suffix"
145 puts [join $srcObjFiles $suffix]
146 puts {}
147}
148
149proc executableDeps {args} {
150
151 global prefix suffix objSuf exeSuf
152
153 set executable [lsort [eval glob -nocomplain $args]]
154
155 set exeFiles {}
156
157 foreach fileName $executable {
158 regsub {\.cpp} $fileName {} exeObjName
159 set exeObjName $prefix$exeObjName
160 set exeName [file tail $exeObjName]
161
162 lappend exeFiles $exeName$exeSuf
163 lappend exeObjFiles $exeObjName$objSuf
164
165 puts "$exeName$exeSuf:$suffix$exeObjName$objSuf"
166 puts {}
167
168 dependencies $fileName "$exeObjName$objSuf:$suffix$fileName"
169 }
170
171 if [info exists exeFiles] {
172 puts -nonewline "EXECUTABLE += $suffix"
173 puts [join $exeFiles $suffix]
174 puts {}
175 }
176 if [info exists exeObjFiles] {
177 puts -nonewline "EXECUTABLE_OBJ += $suffix"
178 puts [join $exeObjFiles $suffix]
179 puts {}
180 }
181}
182
183proc headerDeps {} {
184 global suffix headerFiles
185
186 foreach fileName [array names headerFiles] {
187 dependencies $fileName "$fileName:" 0 "\t@touch \$@"
188 }
189}
190
191puts {
192#
193# Makefile for ExRootAnalysis
194#
195# Author: P. Demin - UCL, Louvain-la-Neuve
196#
197# multi-platform configuration is taken from ROOT (root/test/Makefile.arch)
198#
199
200include doc/Makefile.arch
201
202ROOT_MAJOR := $(shell $(RC) --version | cut -d'.' -f1)
203
204SrcSuf = cc
205PcmSuf = _rdict.pcm
206
207CXXFLAGS += $(ROOTCFLAGS) -Wno-write-strings -D_FILE_OFFSET_BITS=64 -DDROP_CGAL -I. -Iexternal -Iexternal/tcl
208DELPHES_LIBS = $(shell $(RC) --libs) -lEG $(SYSLIBS)
209DISPLAY_LIBS = $(shell $(RC) --evelibs) -lGuiHtml $(SYSLIBS)
210
211ifneq ($(CMSSW_FWLITE_INCLUDE_PATH),)
212HAS_CMSSW = true
213CXXFLAGS += -std=c++0x -I$(subst :, -I,$(CMSSW_FWLITE_INCLUDE_PATH))
214OPT_LIBS += -L$(subst include,lib,$(subst :, -L,$(CMSSW_FWLITE_INCLUDE_PATH)))
215ifneq ($(CMSSW_RELEASE_BASE),)
216CXXFLAGS += -I$(CMSSW_RELEASE_BASE)/src
217endif
218ifneq ($(LD_LIBRARY_PATH),)
219OPT_LIBS += -L$(subst include,lib,$(subst :, -L,$(LD_LIBRARY_PATH)))
220endif
221OPT_LIBS += -lGenVector -lFWCoreFWLite -lDataFormatsFWLite -lDataFormatsPatCandidates -lDataFormatsLuminosity -lSimDataFormatsGeneratorProducts -lCommonToolsUtils
222endif
223
224ifneq ($(PROMC),)
225HAS_PROMC = true
226CXXFLAGS += -I$(PROMC)/include -I$(PROMC)/src
227OPT_LIBS += -L$(PROMC)/lib -lpromc -lprotoc -lprotobuf -lprotobuf-lite -lcbook -lz
228endif
229
230ifneq ($(PYTHIA8),)
231HAS_PYTHIA8 = true
232CXXFLAGS += -I$(PYTHIA8)/include
233CXXFLAGS += -I$(PYTHIA8)/include/Pythia8
234OPT_LIBS += -L$(PYTHIA8)/lib -lpythia8 -ldl
235else
236ifneq ($(PYTHIA8DATA),)
237HAS_PYTHIA8 = true
238CXXFLAGS += -I$(PYTHIA8DATA)/../include
239CXXFLAGS += -I$(PYTHIA8DATA)/../include/Pythia8
240OPT_LIBS += -L$(PYTHIA8DATA)/../lib -lpythia8 -ldl
241endif
242endif
243
244DELPHES_LIBS += $(OPT_LIBS)
245DISPLAY_LIBS += $(OPT_LIBS)
246
247###
248
249NOFASTJET = libDelphesNoFastJet.$(DllSuf)
250NOFASTJETLIB = libDelphesNoFastJet.lib
251
252DELPHES = libDelphes.$(DllSuf)
253DELPHESLIB = libDelphes.lib
254
255DISPLAY = libDelphesDisplay.$(DllSuf)
256DISPLAYLIB = libDelphesDisplay.lib
257
258VERSION = $(shell cat VERSION)
259DISTDIR = Delphes-$(VERSION)
260DISTTAR = $(DISTDIR).tar.gz
261
262all:
263
264}
265
266executableDeps {converters/*.cpp} {examples/*.cpp}
267
268executableDeps {readers/DelphesHepMC.cpp} {readers/DelphesLHEF.cpp} {readers/DelphesSTDHEP.cpp}
269
270puts {ifeq ($(HAS_CMSSW),true)}
271executableDeps {readers/DelphesCMSFWLite.cpp}
272puts {endif}
273puts {}
274
275puts {ifeq ($(HAS_PROMC),true)}
276executableDeps {readers/DelphesProMC.cpp}
277puts {endif}
278puts {}
279
280puts {ifeq ($(HAS_PYTHIA8),true)}
281executableDeps {readers/DelphesPythia8.cpp}
282dictDeps {DELPHES_DICT} {modules/Pythia8LinkDef.h}
283puts {endif}
284puts {}
285
286dictDeps {DELPHES_DICT} {classes/ClassesLinkDef.h} {modules/ModulesLinkDef.h} {external/ExRootAnalysis/ExRootAnalysisLinkDef.h}
287
288dictDeps {FASTJET_DICT} {modules/FastJetLinkDef.h}
289
290dictDeps {DISPLAY_DICT} {display/DisplayLinkDef.h}
291
292sourceDeps {DELPHES} {classes/*.cc} {modules/*.cc} {external/ExRootAnalysis/*.cc} {external/Hector/*.cc}
293
294sourceDeps {FASTJET} {modules/FastJet*.cc} {external/fastjet/*.cc} {external/fastjet/tools/*.cc} {external/fastjet/plugins/*/*.cc} {external/fastjet/contribs/*/*.cc}
295
296sourceDeps {DISPLAY} {display/*.cc}
297
298tclDeps
299
300headerDeps
301
302puts {
303
304###
305
306ifeq ($(ROOT_MAJOR),6)
307all: $(NOFASTJET) $(DELPHES) $(DELPHES_DICT_PCM) $(FASTJET_DICT_PCM) $(EXECUTABLE)
308display: $(DISPLAY) $(DISPLAY_DICT_PCM)
309else
310all: $(NOFASTJET) $(DELPHES) $(EXECUTABLE)
311display: $(DISPLAY)
312endif
313
314$(NOFASTJET): $(DELPHES_DICT_OBJ) $(DELPHES_OBJ) $(TCL_OBJ)
315 @mkdir -p $(@D)
316 @echo ">> Building $@"
317ifeq ($(ARCH),aix5)
318 @$(MAKESHARED) $(OutPutOpt) $@ $(DELPHES_LIBS) -p 0 $^
319else
320ifeq ($(PLATFORM),macosx)
321# We need to make both the .dylib and the .so
322 @$(LD) $(SOFLAGS)$@ $(LDFLAGS) $^ $(OutPutOpt) $@ $(DELPHES_LIBS)
323ifneq ($(subst $(MACOSX_MINOR),,1234),1234)
324ifeq ($(MACOSX_MINOR),4)
325 @ln -sf $@ $(subst .$(DllSuf),.so,$@)
326endif
327endif
328else
329ifeq ($(PLATFORM),win32)
330 @bindexplib $* $^ > $*.def
331 @lib -nologo -MACHINE:IX86 $^ -def:$*.def $(OutPutOpt)$(NOFASTJETLIB)
332 @$(LD) $(SOFLAGS) $(LDFLAGS) $^ $*.exp $(DELPHES_LIBS) $(OutPutOpt)$@
333 @$(MT_DLL)
334else
335 @$(LD) $(SOFLAGS) $(LDFLAGS) $^ $(OutPutOpt) $@ $(DELPHES_LIBS)
336 @$(MT_DLL)
337endif
338endif
339endif
340
341$(DELPHES): $(DELPHES_DICT_OBJ) $(FASTJET_DICT_OBJ) $(DELPHES_OBJ) $(FASTJET_OBJ) $(TCL_OBJ)
342 @mkdir -p $(@D)
343 @echo ">> Building $@"
344ifeq ($(ARCH),aix5)
345 @$(MAKESHARED) $(OutPutOpt) $@ $(DELPHES_LIBS) -p 0 $^
346else
347ifeq ($(PLATFORM),macosx)
348# We need to make both the .dylib and the .so
349 @$(LD) $(SOFLAGS)$@ $(LDFLAGS) $^ $(OutPutOpt) $@ $(DELPHES_LIBS)
350ifneq ($(subst $(MACOSX_MINOR),,1234),1234)
351ifeq ($(MACOSX_MINOR),4)
352 @ln -sf $@ $(subst .$(DllSuf),.so,$@)
353endif
354endif
355else
356ifeq ($(PLATFORM),win32)
357 @bindexplib $* $^ > $*.def
358 @lib -nologo -MACHINE:IX86 $^ -def:$*.def $(OutPutOpt)$(DELPHESLIB)
359 @$(LD) $(SOFLAGS) $(LDFLAGS) $^ $*.exp $(DELPHES_LIBS) $(OutPutOpt)$@
360 @$(MT_DLL)
361else
362 @$(LD) $(SOFLAGS) $(LDFLAGS) $^ $(OutPutOpt) $@ $(DELPHES_LIBS)
363 @$(MT_DLL)
364endif
365endif
366endif
367
368$(DISPLAY): $(DELPHES_DICT_OBJ) $(FASTJET_DICT_OBJ) $(DISPLAY_DICT_OBJ) $(DELPHES_OBJ) $(FASTJET_OBJ) $(DISPLAY_OBJ) $(TCL_OBJ)
369 @mkdir -p $(@D)
370 @echo ">> Building $@"
371ifeq ($(ARCH),aix5)
372 @$(MAKESHARED) $(OutPutOpt) $@ $(DISPLAY_LIBS) -p 0 $^
373else
374ifeq ($(PLATFORM),macosx)
375# We need to make both the .dylib and the .so
376 @$(LD) $(SOFLAGS)$@ $(LDFLAGS) $^ $(OutPutOpt) $@ $(DISPLAY_LIBS)
377ifneq ($(subst $(MACOSX_MINOR),,1234),1234)
378ifeq ($(MACOSX_MINOR),4)
379 @ln -sf $@ $(subst .$(DllSuf),.so,$@)
380endif
381endif
382else
383ifeq ($(PLATFORM),win32)
384 @bindexplib $* $^ > $*.def
385 @lib -nologo -MACHINE:IX86 $^ -def:$*.def $(OutPutOpt)$(DISPLAYLIB)
386 @$(LD) $(SOFLAGS) $(LDFLAGS) $^ $*.exp $(DISPLAY_LIBS) $(OutPutOpt)$@
387 @$(MT_DLL)
388else
389 @$(LD) $(SOFLAGS) $(LDFLAGS) $^ $(OutPutOpt) $@ $(DISPLAY_LIBS)
390 @$(MT_DLL)
391endif
392endif
393endif
394
395clean:
396 @rm -f $(DELPHES_DICT_OBJ) $(DISPLAY_DICT_OBJ) $(DELPHES_OBJ) $(FASTJET_OBJ) $(DISPLAY_OBJ) $(TCL_OBJ) core
397 @rm -rf tmp
398
399distclean: clean
400 @rm -f $(NOFASTJET) $(NOFASTJETLIB) $(DELPHES) $(DELPHESLIB) $(DELPHES_DICT_PCM) $(FASTJET_DICT_PCM) $(DISPLAY) $(DISPLAYLIB) $(DISPLAY_DICT_PCM) $(EXECUTABLE)
401
402dist:
403 @echo ">> Building $(DISTTAR)"
404 @mkdir -p $(DISTDIR)
405 @cp -a CHANGELOG COPYING CREDITS README VERSION Makefile configure cards classes converters display doc examples external modules python readers $(DISTDIR)
406 @find $(DISTDIR) -depth -name .\* -exec rm -rf {} \;
407 @tar -czf $(DISTTAR) $(DISTDIR)
408 @rm -rf $(DISTDIR)
409
410###
411
412.SUFFIXES: .$(SrcSuf) .$(ObjSuf) .$(DllSuf) $(PcmSuf)
413
414%Dict.$(SrcSuf):
415 @mkdir -p $(@D)
416 @echo ">> Generating $@"
417 @rootcint -f $@ -c -Iexternal $<
418 @echo "#define private public" > $@.arch
419 @echo "#define protected public" >> $@.arch
420 @mv $@ $@.base
421 @cat $@.arch $< $@.base > $@
422 @rm $@.arch $@.base
423
424%Dict$(PcmSuf):
425 @echo ">> Copying $@"
426 @cp $< $@
427
428$(DELPHES_OBJ): tmp/%.$(ObjSuf): %.$(SrcSuf)
429 @mkdir -p $(@D)
430 @echo ">> Compiling $<"
431 @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@
432
433$(FASTJET_OBJ): tmp/%.$(ObjSuf): %.$(SrcSuf)
434 @mkdir -p $(@D)
435 @echo ">> Compiling $<"
436 @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@
437
438$(DISPLAY_OBJ): tmp/%.$(ObjSuf): %.$(SrcSuf)
439 @mkdir -p $(@D)
440 @echo ">> Compiling $<"
441 @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@
442
443$(DELPHES_DICT_OBJ): %.$(ObjSuf): %.$(SrcSuf)
444 @mkdir -p $(@D)
445 @echo ">> Compiling $<"
446 @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@
447
448$(FASTJET_DICT_OBJ): %.$(ObjSuf): %.$(SrcSuf)
449 @mkdir -p $(@D)
450 @echo ">> Compiling $<"
451 @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@
452
453$(DISPLAY_DICT_OBJ): %.$(ObjSuf): %.$(SrcSuf)
454 @mkdir -p $(@D)
455 @echo ">> Compiling $<"
456 @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@
457
458$(TCL_OBJ): tmp/%.$(ObjSuf): %.c
459 @mkdir -p $(@D)
460 @echo ">> Compiling $<"
461 @$(CC) $(patsubst -std=%,,$(CXXFLAGS)) -c $< $(OutPutOpt)$@
462
463$(EXECUTABLE_OBJ): tmp/%.$(ObjSuf): %.cpp
464 @mkdir -p $(@D)
465 @echo ">> Compiling $<"
466 @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@
467
468$(EXECUTABLE): %$(ExeSuf): $(DELPHES_DICT_OBJ) $(FASTJET_DICT_OBJ) $(DELPHES_OBJ) $(FASTJET_OBJ) $(TCL_OBJ)
469 @echo ">> Building $@"
470 @$(LD) $(LDFLAGS) $^ $(DELPHES_LIBS) $(OutPutOpt)$@
471
472###
473
474}
Note: See TracBrowser for help on using the repository browser.