Fork me on GitHub

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

Last change on this file since 1119 was 1113, checked in by Pavel Demin, 12 years ago

add python directory to the tar file

File size: 8.0 KB
Line 
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 }
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
54proc 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
83proc sourceDeps {srcPrefix args} {
84
85 global prefix suffix srcSuf objSuf
86
87 set source [eval glob -nocomplain $args]
88
89 set srcObjFiles {}
90
91 foreach fileName $source {
92 regsub {\.cc} $fileName {} srcName
93 set srcObjName $prefix$srcName
94
95 lappend srcObjFiles $srcObjName$objSuf
96
97 dependencies $fileName "$srcObjName$objSuf:$suffix$srcName$srcSuf"
98 }
99
100 puts -nonewline "${srcPrefix}_OBJ = $suffix"
101 puts [join $srcObjFiles $suffix]
102 puts ""
103}
104
105proc tclDeps {} {
106
107 global prefix suffix srcSuf objSuf
108
109 set source [glob -nocomplain {external/tcl/*.c}]
110
111 set srcObjFiles {}
112
113 foreach fileName $source {
114 if {$fileName == "tcl/tclc.c" || $fileName == "tcl/tcl.c"} continue
115
116 regsub {\.c} $fileName {} srcName
117 set srcObjName $prefix$srcName
118
119 lappend srcObjFiles $srcObjName$objSuf
120
121 dependencies $fileName "$srcObjName$objSuf:$suffix$fileName"
122 }
123
124 puts -nonewline "TCL_OBJ = $suffix"
125 puts [join $srcObjFiles $suffix]
126 puts ""
127}
128
129proc executableDeps {} {
130
131 global prefix suffix objSuf exeSuf
132
133 set executable [glob -nocomplain {readers/*.cpp} {converters/*.cpp}]
134
135 set exeFiles {}
136
137 foreach fileName $executable {
138 regsub {\.cpp} $fileName {} exeObjName
139 set exeObjName $prefix$exeObjName
140 set exeName [file tail $exeObjName]
141
142 lappend exeFiles $exeName$exeSuf
143 lappend exeObjFiles $exeObjName$objSuf
144
145 puts "$exeName$exeSuf:$suffix$exeObjName$objSuf"
146 puts ""
147
148 dependencies $fileName "$exeObjName$objSuf:$suffix$fileName"
149 }
150
151 if [info exists exeFiles] {
152 puts -nonewline "EXECUTABLE = $suffix"
153 puts [join $exeFiles $suffix]
154 puts ""
155 }
156 if [info exists exeObjFiles] {
157 puts -nonewline "EXECUTABLE_OBJ = $suffix"
158 puts [join $exeObjFiles $suffix]
159 puts ""
160 }
161
162}
163
164proc headerDeps {} {
165 global suffix headerFiles
166
167 foreach fileName [array names headerFiles] {
168 dependencies $fileName "$fileName:" 0 "\t@touch \$@"
169 }
170}
171
172puts {
173#
174# Makefile for ExRootAnalysis
175#
176# Author: P. Demin - UCL, Louvain-la-Neuve
177#
178# multi-platform configuration is taken from ROOT (root/test/Makefile.arch)
179#
180
181include doc/Makefile.arch
182
183ifeq ($(ARCH),macosx64)
184UNDEFOPT = dynamic_lookup
185endif
186
187SrcSuf = cc
188
189CXXFLAGS += $(ROOTCFLAGS) -Wno-write-strings -D_FILE_OFFSET_BITS=64 -DDROP_CGAL -I. -Iexternal -Iexternal/tcl
190DELPHES_LIBS = $(shell $(RC) --libs) -lEG $(SYSLIBS)
191DISPLAY_LIBS = $(shell $(RC) --evelibs) $(SYSLIBS)
192
193###
194
195DELPHES = libDelphes.$(DllSuf)
196DELPHESLIB = libDelphes.lib
197
198DISPLAY = libDelphesDisplay.$(DllSuf)
199DISPLAYLIB = libDelphesDisplay.lib
200
201VERSION = $(shell cat VERSION)
202DISTDIR = Delphes-$(VERSION)
203DISTTAR = $(DISTDIR).tar.gz
204
205all:
206
207}
208
209executableDeps
210
211dictDeps {DELPHES_DICT} {classes/*LinkDef.h} {modules/*LinkDef.h} {external/ExRootAnalysis/*LinkDef.h}
212
213dictDeps {DISPLAY_DICT} {display/*LinkDef.h}
214
215sourceDeps {DELPHES} {classes/*.cc} {modules/*.cc} {external/ExRootAnalysis/*.cc} {external/fastjet/*.cc} {external/fastjet/tools/*.cc} {external/fastjet/plugins/*/*.cc}
216
217sourceDeps {DISPLAY} {display/*.cc}
218
219tclDeps
220
221headerDeps
222
223puts {
224
225###
226
227all: $(DELPHES) $(EXECUTABLE)
228
229display: $(DISPLAY)
230
231$(DELPHES): $(DELPHES_DICT_OBJ) $(DELPHES_OBJ) $(TCL_OBJ)
232 @mkdir -p $(@D)
233 @echo ">> Building $@"
234ifeq ($(ARCH),aix5)
235 @$(MAKESHARED) $(OutPutOpt) $@ $(DELPHES_LIBS) -p 0 $^
236else
237ifeq ($(PLATFORM),macosx)
238# We need to make both the .dylib and the .so
239 @$(LD) $(SOFLAGS)$@ $(LDFLAGS) $^ $(OutPutOpt) $@ $(DELPHES_LIBS)
240ifneq ($(subst $(MACOSX_MINOR),,1234),1234)
241ifeq ($(MACOSX_MINOR),4)
242 @ln -sf $@ $(subst .$(DllSuf),.so,$@)
243endif
244endif
245else
246ifeq ($(PLATFORM),win32)
247 @bindexplib $* $^ > $*.def
248 @lib -nologo -MACHINE:IX86 $^ -def:$*.def $(OutPutOpt)$(DELPHESLIB)
249 @$(LD) $(SOFLAGS) $(LDFLAGS) $^ $*.exp $(DELPHES_LIBS) $(OutPutOpt)$@
250 @$(MT_DLL)
251else
252 @$(LD) $(SOFLAGS) $(LDFLAGS) $^ $(OutPutOpt) $@ $(DELPHES_LIBS)
253 @$(MT_DLL)
254endif
255endif
256endif
257
258$(DISPLAY): $(DELPHES_DICT_OBJ) $(DISPLAY_DICT_OBJ) $(DELPHES_OBJ) $(DISPLAY_OBJ) $(TCL_OBJ)
259 @mkdir -p $(@D)
260 @echo ">> Building $@"
261ifeq ($(ARCH),aix5)
262 @$(MAKESHARED) $(OutPutOpt) $@ $(DISPLAY_LIBS) -p 0 $^
263else
264ifeq ($(PLATFORM),macosx)
265# We need to make both the .dylib and the .so
266 @$(LD) $(SOFLAGS)$@ $(LDFLAGS) $^ $(OutPutOpt) $@ $(DISPLAY_LIBS)
267ifneq ($(subst $(MACOSX_MINOR),,1234),1234)
268ifeq ($(MACOSX_MINOR),4)
269 @ln -sf $@ $(subst .$(DllSuf),.so,$@)
270endif
271endif
272else
273ifeq ($(PLATFORM),win32)
274 @bindexplib $* $^ > $*.def
275 @lib -nologo -MACHINE:IX86 $^ -def:$*.def $(OutPutOpt)$(DISPLAYLIB)
276 @$(LD) $(SOFLAGS) $(LDFLAGS) $^ $*.exp $(DISPLAY_LIBS) $(OutPutOpt)$@
277 @$(MT_DLL)
278else
279 @$(LD) $(SOFLAGS) $(LDFLAGS) $^ $(OutPutOpt) $@ $(DISPLAY_LIBS)
280 @$(MT_DLL)
281endif
282endif
283endif
284
285clean:
286 @rm -f $(DELPHES_DICT_OBJ) $(DISPLAY_DICT_OBJ) $(DELPHES_OBJ) $(DISPLAY_OBJ) $(TCL_OBJ) core
287 @rm -rf tmp
288
289distclean: clean
290 @rm -f $(DELPHES) $(DELPHESLIB) $(DISPLAY) $(DISPLAYLIB) $(EXECUTABLE)
291
292dist:
293 @echo ">> Building $(DISTTAR)"
294 @mkdir -p $(DISTDIR)
295 @cp -a CREDITS README VERSION Makefile configure classes converters display doc examples external modules python readers $(DISTDIR)
296 @find $(DISTDIR) -depth -name .\* -exec rm -rf {} \;
297 @tar -czf $(DISTTAR) $(DISTDIR)
298 @rm -rf $(DISTDIR)
299
300###
301
302.SUFFIXES: .$(SrcSuf) .$(ObjSuf) .$(DllSuf)
303
304%Dict.$(SrcSuf):
305 @mkdir -p $(@D)
306 @echo ">> Generating $@"
307 @rootcint -f $@ -c -Iexternal $<
308 @echo "#define private public" > $@.arch
309 @echo "#define protected public" >> $@.arch
310 @mv $@ $@.base
311 @cat $@.arch $< $@.base > $@
312 @rm $@.arch $@.base
313
314$(DELPHES_OBJ): tmp/%.$(ObjSuf): %.$(SrcSuf)
315 @mkdir -p $(@D)
316 @echo ">> Compiling $<"
317 @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@
318
319$(DISPLAY_OBJ): tmp/%.$(ObjSuf): %.$(SrcSuf)
320 @mkdir -p $(@D)
321 @echo ">> Compiling $<"
322 @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@
323
324$(DELPHES_DICT_OBJ): %.$(ObjSuf): %.$(SrcSuf)
325 @mkdir -p $(@D)
326 @echo ">> Compiling $<"
327 @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@
328
329$(DISPLAY_DICT_OBJ): %.$(ObjSuf): %.$(SrcSuf)
330 @mkdir -p $(@D)
331 @echo ">> Compiling $<"
332 @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@
333
334$(TCL_OBJ): tmp/%.$(ObjSuf): %.c
335 @mkdir -p $(@D)
336 @echo ">> Compiling $<"
337 @gcc $(CXXFLAGS) -c $< $(OutPutOpt)$@
338
339$(EXECUTABLE_OBJ): tmp/%.$(ObjSuf): %.cpp
340 @mkdir -p $(@D)
341 @echo ">> Compiling $<"
342 @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@
343
344$(EXECUTABLE): %$(ExeSuf): $(DELPHES_DICT_OBJ) $(DELPHES_OBJ) $(TCL_OBJ)
345 @echo ">> Building $@"
346 @$(LD) $(LDFLAGS) $^ $(DELPHES_LIBS) $(OutPutOpt)$@
347
348###
349
350}
Note: See TracBrowser for help on using the repository browser.