Fork me on GitHub

source: svn/trunk/doc/genMakefile.tcl@ 1190

Last change on this file since 1190 was 1186, checked in by Pavel Demin, 11 years ago

link Pythia 8 with LHAPDF

File size: 9.7 KB
RevLine 
[593]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
[610]27 } elseif [file exists external/$file] {
28 lappend list external/$file
29 set headerFiles(external/$file) 1
30 }
[593]31 }
32 }
[1128]33
[593]34 if {[llength $list] > 0} {
35 puts -nonewline $firstLine
36 foreach file $list {puts -nonewline $suffix$file}
37 if {$command != {}} {
[1176]38 puts {}
[593]39 puts $command
40 }
[1176]41 puts {}
[593]42 } elseif {$force} {
43 puts -nonewline $firstLine
44 if {$command != {}} {
[1176]45 puts {}
[593]46 puts $command
47 }
[1176]48 puts {}
[593]49 }
50
[1128]51 close $fid
[593]52}
53
54proc dictDeps {dictVar args} {
55
56 global prefix suffix srcSuf objSuf
57
58 set dict [eval glob -nocomplain $args]
[1128]59
[593]60 set dictSrcFiles {}
61 set dictObjFiles {}
62
63 foreach fileName $dict {
64 regsub {LinkDef\.h} $fileName {Dict} dictName
65 set dictName $prefix$dictName
[1128]66
[593]67 lappend dictSrcFiles $dictName$srcSuf
68 lappend dictObjFiles $dictName$objSuf
[1128]69
[593]70 dependencies $fileName "$dictName$srcSuf:$suffix$fileName"
71 }
[1128]72
[1177]73 puts -nonewline "${dictVar} += $suffix"
[593]74 puts [join $dictSrcFiles $suffix]
[1176]75 puts {}
[593]76
[1177]77 puts -nonewline "${dictVar}_OBJ += $suffix"
[593]78 puts [join $dictObjFiles $suffix]
[1176]79 puts {}
[593]80
81}
82
83proc sourceDeps {srcPrefix args} {
84
85 global prefix suffix srcSuf objSuf
[1128]86
[593]87 set source [eval glob -nocomplain $args]
[1128]88
[593]89 set srcObjFiles {}
[1167]90 set srcObjFilesPythia8 {}
[1128]91
[593]92 foreach fileName $source {
93 regsub {\.cc} $fileName {} srcName
94 set srcObjName $prefix$srcName
[1171]95
[1167]96 if {$fileName == "modules/PileUpMergerPythia8.cc"} {
97 lappend srcObjFilesPythia8 $srcObjName$objSuf
98 } else {
99 lappend srcObjFiles $srcObjName$objSuf
100 }
[1128]101
[593]102 dependencies $fileName "$srcObjName$objSuf:$suffix$srcName$srcSuf"
103 }
104
[1176]105 puts -nonewline "${srcPrefix}_OBJ += $suffix"
[593]106 puts [join $srcObjFiles $suffix]
[1176]107 puts {}
[1171]108
[1168]109 puts {ifeq ($(HAS_PYTHIA8),true)}
[1167]110 puts -nonewline "${srcPrefix}_OBJ += $suffix"
111 puts [join $srcObjFilesPythia8 $suffix]
112 puts {endif}
[1176]113 puts {}
[593]114}
115
116proc tclDeps {} {
117
118 global prefix suffix srcSuf objSuf
[1128]119
[593]120 set source [glob -nocomplain {external/tcl/*.c}]
[1128]121
[593]122 set srcObjFiles {}
[1128]123
[593]124 foreach fileName $source {
125 if {$fileName == "tcl/tclc.c" || $fileName == "tcl/tcl.c"} continue
[1128]126
[593]127 regsub {\.c} $fileName {} srcName
128 set srcObjName $prefix$srcName
[1128]129
[593]130 lappend srcObjFiles $srcObjName$objSuf
[1128]131
[593]132 dependencies $fileName "$srcObjName$objSuf:$suffix$fileName"
133 }
[1128]134
[1177]135 puts -nonewline "TCL_OBJ += $suffix"
[593]136 puts [join $srcObjFiles $suffix]
[1176]137 puts {}
[593]138}
139
[1176]140proc executableDeps {args} {
[593]141
142 global prefix suffix objSuf exeSuf
[1128]143
[1176]144 set executable [eval glob -nocomplain $args]
[1128]145
[593]146 set exeFiles {}
[1128]147
[593]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
[1128]155
[593]156 puts "$exeName$exeSuf:$suffix$exeObjName$objSuf"
[1176]157 puts {}
[1128]158
[593]159 dependencies $fileName "$exeObjName$objSuf:$suffix$fileName"
160 }
[1128]161
[593]162 if [info exists exeFiles] {
[1176]163 puts -nonewline "EXECUTABLE += $suffix"
[593]164 puts [join $exeFiles $suffix]
[1176]165 puts {}
[593]166 }
167 if [info exists exeObjFiles] {
[1176]168 puts -nonewline "EXECUTABLE_OBJ += $suffix"
[593]169 puts [join $exeObjFiles $suffix]
[1176]170 puts {}
[593]171 }
172}
173
174proc headerDeps {} {
175 global suffix headerFiles
[1128]176
[593]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
[857]191include doc/Makefile.arch
[593]192
193ifeq ($(ARCH),macosx64)
194UNDEFOPT = dynamic_lookup
195endif
196
197SrcSuf = cc
198
[1038]199CXXFLAGS += $(ROOTCFLAGS) -Wno-write-strings -D_FILE_OFFSET_BITS=64 -DDROP_CGAL -I. -Iexternal -Iexternal/tcl
[1097]200DELPHES_LIBS = $(shell $(RC) --libs) -lEG $(SYSLIBS)
201DISPLAY_LIBS = $(shell $(RC) --evelibs) $(SYSLIBS)
[824]202
[1176]203ifneq ($(CMSSW_FWLITE_INCLUDE_PATH),)
204HAS_CMSSW = true
[1179]205CXXFLAGS += -std=c++0x -I$(subst :, -I,$(CMSSW_FWLITE_INCLUDE_PATH))
206DELPHES_LIBS += -L$(subst include,lib,$(subst :, -L,$(CMSSW_FWLITE_INCLUDE_PATH)))
[1176]207ifneq ($(CMSSW_RELEASE_BASE),)
208CXXFLAGS += -I$(CMSSW_RELEASE_BASE)/src
209endif
210ifneq ($(LD_LIBRARY_PATH),)
[1179]211DELPHES_LIBS += -L$(subst include,lib,$(subst :, -L,$(LD_LIBRARY_PATH)))
[1176]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
[1167]222ifneq ($(PYTHIA8),)
[1168]223HAS_PYTHIA8 = true
[1177]224CXXFLAGS += -I$(PYTHIA8)/include
[1186]225DELPHES_LIBS += -L$(PYTHIA8)/lib -lpythia8 -lLHAPDF -lgfortran -lz
[1168]226else
227ifneq ($(PYTHIA8DATA),)
228HAS_PYTHIA8 = true
[1177]229CXXFLAGS += -I$(PYTHIA8DATA)/../include
[1186]230DELPHES_LIBS += -L$(PYTHIA8DATA)/../lib -lpythia8 -lLHAPDF -lgfortran -lz
[1167]231endif
[1168]232endif
[1167]233
[593]234###
235
[1097]236DELPHES = libDelphes.$(DllSuf)
237DELPHESLIB = libDelphes.lib
[593]238
[1097]239DISPLAY = libDelphesDisplay.$(DllSuf)
240DISPLAYLIB = libDelphesDisplay.lib
241
[850]242VERSION = $(shell cat VERSION)
[857]243DISTDIR = Delphes-$(VERSION)
[851]244DISTTAR = $(DISTDIR).tar.gz
[850]245
[593]246all:
247
248}
249
[1176]250executableDeps {converters/*.cpp} {examples/*.cpp}
[593]251
[1176]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}
[1177]267dictDeps {DELPHES_DICT} {modules/Pythia8LinkDef.h}
[1176]268puts {endif}
269puts {}
270
[1177]271dictDeps {DELPHES_DICT} {classes/ClassesLinkDef.h} {modules/ModulesLinkDef.h} {external/ExRootAnalysis/ExRootAnalysisLinkDef.h}
[593]272
[1177]273dictDeps {DISPLAY_DICT} {display/DisplayLinkDef.h}
[593]274
[1097]275sourceDeps {DELPHES} {classes/*.cc} {modules/*.cc} {external/ExRootAnalysis/*.cc} {external/fastjet/*.cc} {external/fastjet/tools/*.cc} {external/fastjet/plugins/*/*.cc}
276
277sourceDeps {DISPLAY} {display/*.cc}
278
[593]279tclDeps
280
281headerDeps
282
283puts {
284
285###
286
[1097]287all: $(DELPHES) $(EXECUTABLE)
[593]288
[1097]289display: $(DISPLAY)
290
291$(DELPHES): $(DELPHES_DICT_OBJ) $(DELPHES_OBJ) $(TCL_OBJ)
[593]292 @mkdir -p $(@D)
293 @echo ">> Building $@"
294ifeq ($(ARCH),aix5)
[1097]295 @$(MAKESHARED) $(OutPutOpt) $@ $(DELPHES_LIBS) -p 0 $^
[593]296else
297ifeq ($(PLATFORM),macosx)
298# We need to make both the .dylib and the .so
[1097]299 @$(LD) $(SOFLAGS)$@ $(LDFLAGS) $^ $(OutPutOpt) $@ $(DELPHES_LIBS)
[743]300ifneq ($(subst $(MACOSX_MINOR),,1234),1234)
301ifeq ($(MACOSX_MINOR),4)
302 @ln -sf $@ $(subst .$(DllSuf),.so,$@)
303endif
304endif
[593]305else
306ifeq ($(PLATFORM),win32)
307 @bindexplib $* $^ > $*.def
[1097]308 @lib -nologo -MACHINE:IX86 $^ -def:$*.def $(OutPutOpt)$(DELPHESLIB)
309 @$(LD) $(SOFLAGS) $(LDFLAGS) $^ $*.exp $(DELPHES_LIBS) $(OutPutOpt)$@
[593]310 @$(MT_DLL)
311else
[1097]312 @$(LD) $(SOFLAGS) $(LDFLAGS) $^ $(OutPutOpt) $@ $(DELPHES_LIBS)
[593]313 @$(MT_DLL)
314endif
315endif
316endif
317
[1097]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)
340 @$(MT_DLL)
341endif
342endif
343endif
344
[593]345clean:
[1097]346 @rm -f $(DELPHES_DICT_OBJ) $(DISPLAY_DICT_OBJ) $(DELPHES_OBJ) $(DISPLAY_OBJ) $(TCL_OBJ) core
347 @rm -rf tmp
[593]348
349distclean: clean
[1097]350 @rm -f $(DELPHES) $(DELPHESLIB) $(DISPLAY) $(DISPLAYLIB) $(EXECUTABLE)
[593]351
[850]352dist:
[851]353 @echo ">> Building $(DISTTAR)"
[850]354 @mkdir -p $(DISTDIR)
[1113]355 @cp -a CREDITS README VERSION Makefile configure classes converters display doc examples external modules python readers $(DISTDIR)
[851]356 @find $(DISTDIR) -depth -name .\* -exec rm -rf {} \;
357 @tar -czf $(DISTTAR) $(DISTDIR)
[850]358 @rm -rf $(DISTDIR)
359
[593]360###
361
362.SUFFIXES: .$(SrcSuf) .$(ObjSuf) .$(DllSuf)
363
364%Dict.$(SrcSuf):
365 @mkdir -p $(@D)
366 @echo ">> Generating $@"
[1177]367 @rootcint -f $@ -c -Iexternal $<
[593]368 @echo "#define private public" > $@.arch
369 @echo "#define protected public" >> $@.arch
370 @mv $@ $@.base
371 @cat $@.arch $< $@.base > $@
372 @rm $@.arch $@.base
373
[1097]374$(DELPHES_OBJ): tmp/%.$(ObjSuf): %.$(SrcSuf)
[593]375 @mkdir -p $(@D)
376 @echo ">> Compiling $<"
377 @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@
378
[1097]379$(DISPLAY_OBJ): tmp/%.$(ObjSuf): %.$(SrcSuf)
[593]380 @mkdir -p $(@D)
381 @echo ">> Compiling $<"
382 @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@
383
[1097]384$(DELPHES_DICT_OBJ): %.$(ObjSuf): %.$(SrcSuf)
385 @mkdir -p $(@D)
386 @echo ">> Compiling $<"
387 @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@
388
389$(DISPLAY_DICT_OBJ): %.$(ObjSuf): %.$(SrcSuf)
390 @mkdir -p $(@D)
391 @echo ">> Compiling $<"
392 @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@
393
[593]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
[1097]404$(EXECUTABLE): %$(ExeSuf): $(DELPHES_DICT_OBJ) $(DELPHES_OBJ) $(TCL_OBJ)
[593]405 @echo ">> Building $@"
[1097]406 @$(LD) $(LDFLAGS) $^ $(DELPHES_LIBS) $(OutPutOpt)$@
[593]407
408###
409
410}
Note: See TracBrowser for help on using the repository browser.