Fork me on GitHub

source: git/doc/genMakefile.tcl@ 54b6dfc

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

add CHANGELOG to tar file

  • 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
[0d60c9d]73 puts -nonewline "${dictVar} += $suffix"
[d7d2da3]74 puts [join $dictSrcFiles $suffix]
[af9008e]75 puts {}
[d7d2da3]76
[0d60c9d]77 puts -nonewline "${dictVar}_OBJ += $suffix"
[d7d2da3]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
[0d60c9d]135 puts -nonewline "TCL_OBJ += $suffix"
[d7d2da3]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 {
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
[ded7435]155
[d7d2da3]156 puts "$exeName$exeSuf:$suffix$exeObjName$objSuf"
[af9008e]157 puts {}
[ded7435]158
[d7d2da3]159 dependencies $fileName "$exeObjName$objSuf:$suffix$fileName"
160 }
[ded7435]161
[d7d2da3]162 if [info exists exeFiles] {
[af9008e]163 puts -nonewline "EXECUTABLE += $suffix"
[d7d2da3]164 puts [join $exeFiles $suffix]
[af9008e]165 puts {}
[d7d2da3]166 }
167 if [info exists exeObjFiles] {
[af9008e]168 puts -nonewline "EXECUTABLE_OBJ += $suffix"
[d7d2da3]169 puts [join $exeObjFiles $suffix]
[af9008e]170 puts {}
[d7d2da3]171 }
172}
173
174proc headerDeps {} {
175 global suffix headerFiles
[ded7435]176
[d7d2da3]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
[00bcbe6]200DELPHES_LIBS = $(shell $(RC) --libs) -lEG $(SYSLIBS)
201DISPLAY_LIBS = $(shell $(RC) --evelibs) $(SYSLIBS)
[d7d2da3]202
[af9008e]203ifneq ($(CMSSW_FWLITE_INCLUDE_PATH),)
204HAS_CMSSW = true
[41fec5e]205CXXFLAGS += -std=c++0x -I$(subst :, -I,$(CMSSW_FWLITE_INCLUDE_PATH))
206DELPHES_LIBS += -L$(subst include,lib,$(subst :, -L,$(CMSSW_FWLITE_INCLUDE_PATH)))
[af9008e]207ifneq ($(CMSSW_RELEASE_BASE),)
208CXXFLAGS += -I$(CMSSW_RELEASE_BASE)/src
209endif
210ifneq ($(LD_LIBRARY_PATH),)
[41fec5e]211DELPHES_LIBS += -L$(subst include,lib,$(subst :, -L,$(LD_LIBRARY_PATH)))
[af9008e]212endif
213DELPHES_LIBS += -lFWCoreFWLite -lDataFormatsFWLite -lDataFormatsPatCandidates -lDataFormatsLuminosity -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
[c41c262]222ifneq ($(PYTHIA8),)
[c466459]223HAS_PYTHIA8 = true
[0d60c9d]224CXXFLAGS += -I$(PYTHIA8)/include
[c82c0d1]225DELPHES_LIBS += -L$(PYTHIA8)/lib -lpythia8 -lLHAPDF -lgfortran -lz
[c466459]226else
227ifneq ($(PYTHIA8DATA),)
228HAS_PYTHIA8 = true
[0d60c9d]229CXXFLAGS += -I$(PYTHIA8DATA)/../include
[c82c0d1]230DELPHES_LIBS += -L$(PYTHIA8DATA)/../lib -lpythia8 -lLHAPDF -lgfortran -lz
[c466459]231endif
[c41c262]232endif
233
[d7d2da3]234###
235
[00bcbe6]236DELPHES = libDelphes.$(DllSuf)
237DELPHESLIB = libDelphes.lib
238
239DISPLAY = libDelphesDisplay.$(DllSuf)
240DISPLAYLIB = libDelphesDisplay.lib
[d7d2da3]241
242VERSION = $(shell cat VERSION)
243DISTDIR = Delphes-$(VERSION)
244DISTTAR = $(DISTDIR).tar.gz
245
246all:
247
248}
249
[af9008e]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}
[0d60c9d]267dictDeps {DELPHES_DICT} {modules/Pythia8LinkDef.h}
[af9008e]268puts {endif}
269puts {}
[d7d2da3]270
[0d60c9d]271dictDeps {DELPHES_DICT} {classes/ClassesLinkDef.h} {modules/ModulesLinkDef.h} {external/ExRootAnalysis/ExRootAnalysisLinkDef.h}
[00bcbe6]272
[0d60c9d]273dictDeps {DISPLAY_DICT} {display/DisplayLinkDef.h}
[00bcbe6]274
275sourceDeps {DELPHES} {classes/*.cc} {modules/*.cc} {external/ExRootAnalysis/*.cc} {external/fastjet/*.cc} {external/fastjet/tools/*.cc} {external/fastjet/plugins/*/*.cc}
[d7d2da3]276
[00bcbe6]277sourceDeps {DISPLAY} {display/*.cc}
[d7d2da3]278
279tclDeps
280
281headerDeps
282
283puts {
284
285###
286
[00bcbe6]287all: $(DELPHES) $(EXECUTABLE)
[d7d2da3]288
[00bcbe6]289display: $(DISPLAY)
290
291$(DELPHES): $(DELPHES_DICT_OBJ) $(DELPHES_OBJ) $(TCL_OBJ)
[d7d2da3]292 @mkdir -p $(@D)
293 @echo ">> Building $@"
294ifeq ($(ARCH),aix5)
[00bcbe6]295 @$(MAKESHARED) $(OutPutOpt) $@ $(DELPHES_LIBS) -p 0 $^
[d7d2da3]296else
297ifeq ($(PLATFORM),macosx)
298# We need to make both the .dylib and the .so
[00bcbe6]299 @$(LD) $(SOFLAGS)$@ $(LDFLAGS) $^ $(OutPutOpt) $@ $(DELPHES_LIBS)
[d7d2da3]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
[00bcbe6]308 @lib -nologo -MACHINE:IX86 $^ -def:$*.def $(OutPutOpt)$(DELPHESLIB)
309 @$(LD) $(SOFLAGS) $(LDFLAGS) $^ $*.exp $(DELPHES_LIBS) $(OutPutOpt)$@
[d7d2da3]310 @$(MT_DLL)
311else
[00bcbe6]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)
[d7d2da3]340 @$(MT_DLL)
341endif
342endif
343endif
344
345clean:
[00bcbe6]346 @rm -f $(DELPHES_DICT_OBJ) $(DISPLAY_DICT_OBJ) $(DELPHES_OBJ) $(DISPLAY_OBJ) $(TCL_OBJ) core
347 @rm -rf tmp
[d7d2da3]348
349distclean: clean
[00bcbe6]350 @rm -f $(DELPHES) $(DELPHESLIB) $(DISPLAY) $(DISPLAYLIB) $(EXECUTABLE)
[d7d2da3]351
352dist:
353 @echo ">> Building $(DISTTAR)"
354 @mkdir -p $(DISTDIR)
[8560904]355 @cp -a CHANGELOG CREDITS README VERSION Makefile configure classes converters display doc examples external modules python readers $(DISTDIR)
[d7d2da3]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 $@"
[0d60c9d]367 @rootcint -f $@ -c -Iexternal $<
[d7d2da3]368 @echo "#define private public" > $@.arch
369 @echo "#define protected public" >> $@.arch
370 @mv $@ $@.base
371 @cat $@.arch $< $@.base > $@
372 @rm $@.arch $@.base
373
[00bcbe6]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)
[d7d2da3]385 @mkdir -p $(@D)
386 @echo ">> Compiling $<"
387 @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@
388
[00bcbe6]389$(DISPLAY_DICT_OBJ): %.$(ObjSuf): %.$(SrcSuf)
[d7d2da3]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
[00bcbe6]404$(EXECUTABLE): %$(ExeSuf): $(DELPHES_DICT_OBJ) $(DELPHES_OBJ) $(TCL_OBJ)
[d7d2da3]405 @echo ">> Building $@"
[00bcbe6]406 @$(LD) $(LDFLAGS) $^ $(DELPHES_LIBS) $(OutPutOpt)$@
[d7d2da3]407
408###
409
410}
Note: See TracBrowser for help on using the repository browser.