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