Fork me on GitHub

source: svn/trunk/genMakefile.tcl@ 185

Last change on this file since 185 was 174, checked in by Xavier Rouby, 16 years ago

'distclean' taget updated

  • Property svn:executable set to *
File size: 7.8 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 }
28 }
29 }
30
31 if {[llength $list] > 0} {
32 puts -nonewline $firstLine
33 foreach file $list {puts -nonewline $suffix$file}
34 if {$command != {}} {
35 puts ""
36 puts $command
37 }
38 puts ""
39 } elseif {$force} {
40 puts -nonewline $firstLine
41 if {$command != {}} {
42 puts ""
43 puts $command
44 }
45 puts ""
46 }
47
48 close $fid
49}
50
51proc dictDeps {dictVar args} {
52
53 global prefix suffix srcSuf objSuf
54
55 set dict [eval glob -nocomplain $args]
56
57 set dictSrcFiles {}
58 set dictObjFiles {}
59
60 foreach fileName $dict {
61 regsub {LinkDef\.h} $fileName {Dict} dictName
62 set dictName $prefix$dictName
63
64 lappend dictSrcFiles $dictName$srcSuf
65 lappend dictObjFiles $dictName$objSuf
66
67 dependencies $fileName "$dictName$srcSuf:$suffix$fileName"
68 }
69
70 puts -nonewline "${dictVar} = $suffix"
71 puts [join $dictSrcFiles $suffix]
72 puts ""
73
74 puts -nonewline "${dictVar}_OBJ = $suffix"
75 puts [join $dictObjFiles $suffix]
76 puts ""
77
78}
79
80proc sourceDeps {srcPrefix args} {
81
82 global prefix suffix srcSuf objSuf
83
84 set source [eval glob -nocomplain $args]
85
86 set srcObjFiles {}
87
88 foreach fileName $source {
89 regsub {\.cc} $fileName {} srcName
90 set srcObjName $prefix$srcName
91
92 lappend srcObjFiles $srcObjName$objSuf
93
94 dependencies $fileName "$srcObjName$objSuf:$suffix$srcName$srcSuf"
95 }
96
97 puts -nonewline "${srcPrefix}_OBJ = $suffix"
98 puts [join $srcObjFiles $suffix]
99 puts ""
100}
101
102proc stdhepDeps {} {
103
104 global prefix suffix srcSuf objSuf
105
106 set source [glob -nocomplain {Utilities/mcfio/*.c} {Utilities/stdhep/*.c}]
107
108 set srcObjFiles {}
109
110 foreach fileName $source {
111 regsub {\.c} $fileName {} srcName
112 set srcObjName $prefix$srcName
113
114 lappend srcObjFiles $srcObjName$objSuf
115
116 dependencies $fileName "$srcObjName$objSuf:$suffix$fileName"
117 }
118
119 puts -nonewline "STDHEP_OBJ = $suffix"
120 puts [join $srcObjFiles $suffix]
121 puts ""
122}
123
124proc stdhepExecutableDeps {} {
125
126 global prefix suffix objSuf exeSuf
127
128 set executable [glob -nocomplain {Delphes.cpp} {Resolutions.cpp} {Examples/Trigger_Only.cpp} {Exemples/Analysis_Ex.cpp}]
129
130 set exeFiles {}
131
132 foreach fileName $executable {
133 regsub {\.cpp} $fileName {} exeObjName
134 set exeObjName $prefix$exeObjName
135 set exeName [file tail $exeObjName]
136
137 lappend exeFiles $exeName$exeSuf
138 lappend exeObjFiles $exeObjName$objSuf
139
140 puts "$exeName$exeSuf:$suffix$exeObjName$objSuf"
141 puts ""
142
143 dependencies $fileName "$exeObjName$objSuf:$suffix$fileName"
144 }
145
146 if [info exists exeFiles] {
147 puts -nonewline "STDHEP_EXECUTABLE = $suffix"
148 puts [join $exeFiles $suffix]
149 puts ""
150 }
151 if [info exists exeObjFiles] {
152 puts -nonewline "STDHEP_EXECUTABLE_OBJ = $suffix"
153 puts [join $exeObjFiles $suffix]
154 puts ""
155 }
156
157}
158
159proc executableDeps {args} {
160
161 global prefix suffix objSuf exeSuf
162
163 set executable [eval glob -nocomplain $args]
164
165 set exeFiles {}
166
167 foreach fileName $executable {
168 regsub {\.cpp} $fileName {} exeObjName
169 set exeObjName $prefix$exeObjName
170 set exeName [file tail $exeObjName]
171
172 lappend exeFiles $exeName$exeSuf
173 lappend exeObjFiles $exeObjName$objSuf
174
175 puts "$exeName$exeSuf:$suffix$exeObjName$objSuf"
176 puts ""
177
178 dependencies $fileName "$exeObjName$objSuf:$suffix$fileName"
179 }
180
181 if [info exists exeFiles] {
182 puts -nonewline "EXECUTABLE = $suffix"
183 puts [join $exeFiles $suffix]
184 puts ""
185 }
186 if [info exists exeObjFiles] {
187 puts -nonewline "EXECUTABLE_OBJ = $suffix"
188 puts [join $exeObjFiles $suffix]
189 puts ""
190 }
191
192}
193
194proc headerDeps {} {
195 global suffix headerFiles
196
197 foreach fileName [array names headerFiles] {
198 dependencies $fileName "$fileName:" 0 "\t@touch \$@"
199 }
200}
201
202puts {
203#
204# Makefile for Delphes, a Fast Simulator for general-purpose detectors at the LHC
205#
206# Author: S. Ovyn, X. Rouby - UCL, Louvain-la-Neuve
207# -- inspired by P. Demin's work on ExRootAnalysis (UCL, Louvain-la-Neuve)
208# -- the multi-platform configuration is taken from ROOT (root/test/Makefile.arch)
209#
210
211include $(ROOTSYS)/test/Makefile.arch
212
213ifeq ($(ARCH),macosx64)
214UNDEFOPT = dynamic_lookup
215endif
216
217SrcSuf = cc
218
219#CXXFLAGS += $(ROOTCFLAGS) -DDROP_CGAL -Iinterface -IUtilities/CDFCones/interface -IUtilities/ExRootAnalysis/interface -IUtilities/mcfio -IUtilities/stdhep -IUtilities/Hector/include
220CXXFLAGS += $(ROOTCFLAGS) -DDROP_CGAL -I. -IUtilities/mcfio -IUtilities/stdhep -IUtilities/Hector/include -IUtilities/CDFCones/interface -IExamples
221LIBS = $(ROOTLIBS) -lEG $(SYSLIBS)
222GLIBS = $(ROOTGLIBS) $(SYSLIBS)
223
224###
225
226SHARED = lib/libUtilities.$(DllSuf) lib/libHector.$(DllSuf)
227
228all:
229
230}
231
232executableDeps {*.cpp} {Examples/*.cpp}
233
234dictDeps {DICT} {Utilities/ExRootAnalysis/src/*LinkDef.h} {src/*LinkDef.h} {Examples/src/*LinkDef.h}
235
236sourceDeps {SOURCE} {src/*.cc} {Utilities/ExRootAnalysis/src/*.cc} {Utilities/Hector/src/*.cc} {Utilities/CDFCones/src/*cc} {Utilities/Fastjet/src/*.cc} {Utilities/Fastjet/plugins/CDFCones/*.cc} {Utilities/Fastjet/plugins/CDFCones/src/*.cc} {Utilities/Fastjet/plugins/SISCone/*.cc} {Utilities/Fastjet/plugins/SISCone/src/*.cc} {Examples/src/*.cc}
237
238stdhepDeps
239
240headerDeps
241
242puts {
243
244###
245
246all: $(SHARED) $(EXECUTABLE) $(STDHEP_EXECUTABLE)
247 @echo "Delphes has been compiled"
248 @echo "Ready to run"
249
250$(SHARED): $(DICT_OBJ) $(SOURCE_OBJ)
251 @mkdir -p $(@D)
252 @echo ">> Building $@"
253ifeq ($(ARCH),aix)
254 @/usr/ibmcxx/bin/makeC++SharedLib $(OutPutOpt) $@ $(LIBS) -p 0 $^
255else
256ifeq ($(ARCH),aix5)
257 @/usr/vacpp/bin/makeC++SharedLib $(OutPutOpt) $@ $(LIBS) -p 0 $^
258else
259ifeq ($(PLATFORM),macosx)
260# We need to make both the .dylib and the .so
261 @$(LD) $(SOFLAGS) $^ $(OutPutOpt) $@
262 @$(LD) -bundle -undefined $(UNDEFOPT) $(LDFLAGS) $^ $(LIBS) $(OutPutOpt) $(subst .$(DllSuf),.so,$@)
263else
264ifeq ($(PLATFORM),win32)
265 @bindexplib $* $^ > $*.def
266 @lib -nologo -MACHINE:IX86 $^ -def:$*.def $(OutPutOpt)$(EVENTLIB)
267 @$(LD) $(SOFLAGS) $(LDFLAGS) $^ $*.exp $(LIBS) $(OutPutOpt)$@
268 @$(MT_DLL)
269else
270 @$(LD) $(SOFLAGS) $(LDFLAGS) $^ $(OutPutOpt) $@ $(EXPLLINKLIBS)
271 @$(MT_DLL)
272endif
273endif
274endif
275endif
276
277clean:
278 @rm -f $(DICT_OBJ) $(SOURCE_OBJ) $(STDHEP_OBJ) core
279
280distclean: clean
281 @rm -f $(SHARED) $(EXECUTABLE) $(STDHEP_EXECUTABLE) *vis *geom
282 @rm -rf tmp
283
284
285###
286
287.SUFFIXES: .$(SrcSuf) .$(ObjSuf) .$(DllSuf)
288
289%Dict.$(SrcSuf):
290 @mkdir -p $(@D)
291 @echo ">> Generating $@"
292 @rootcint -f $@ -c $<
293 @echo "#define private public" > $@.arch
294 @echo "#define protected public" >> $@.arch
295 @mv $@ $@.base
296 @cat $@.arch $< $@.base > $@
297 @rm $@.arch $@.base
298
299$(SOURCE_OBJ): tmp/%.$(ObjSuf): %.$(SrcSuf)
300 @mkdir -p $(@D)
301 @echo ">> Compiling $<"
302 @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@
303
304$(DICT_OBJ): %.$(ObjSuf): %.$(SrcSuf)
305 @mkdir -p $(@D)
306 @echo ">> Compiling $<"
307 @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@
308
309$(STDHEP_OBJ): tmp/%.$(ObjSuf): %.c
310 @mkdir -p $(@D)
311 @echo ">> Compiling $<"
312 @gcc $(CXXFLAGS) -c $< $(OutPutOpt)$@
313
314$(STDHEP_EXECUTABLE_OBJ): tmp/%.$(ObjSuf): %.cpp
315 @mkdir -p $(@D)
316 @echo ">> Compiling $<"
317 @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@
318
319$(EXECUTABLE_OBJ): tmp/%.$(ObjSuf): %.cpp
320 @mkdir -p $(@D)
321 @echo ">> Compiling $<"
322 @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@
323
324$(EXECUTABLE): %$(ExeSuf): $(DICT_OBJ) $(SOURCE_OBJ) $(STDHEP_OBJ)
325 @echo ">> Building $@"
326 @$(LD) $(LDFLAGS) $^ $(LIBS) $(OutPutOpt)$@
327
328###
329
330}
Note: See TracBrowser for help on using the repository browser.