Fork me on GitHub

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

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

update Makefile

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