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 |
|
---|
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 |
|
---|
105 | proc 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 |
|
---|
129 | proc 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 |
|
---|
164 | proc headerDeps {} {
|
---|
165 | global suffix headerFiles
|
---|
166 |
|
---|
167 | foreach fileName [array names headerFiles] {
|
---|
168 | dependencies $fileName "$fileName:" 0 "\t@touch \$@"
|
---|
169 | }
|
---|
170 | }
|
---|
171 |
|
---|
172 | puts {
|
---|
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 |
|
---|
181 | include doc/Makefile.arch
|
---|
182 |
|
---|
183 | ifeq ($(ARCH),macosx64)
|
---|
184 | UNDEFOPT = dynamic_lookup
|
---|
185 | endif
|
---|
186 |
|
---|
187 | SrcSuf = cc
|
---|
188 |
|
---|
189 | CXXFLAGS += $(ROOTCFLAGS) -Wno-write-strings -D_FILE_OFFSET_BITS=64 -DDROP_CGAL -I. -Iexternal -Iexternal/tcl
|
---|
190 | LIBS = $(shell $(RC) --evelibs) $(SYSLIBS)
|
---|
191 |
|
---|
192 | ###
|
---|
193 |
|
---|
194 | SHARED = libDelphes.$(DllSuf)
|
---|
195 | SHAREDLIB = libDelphes.lib
|
---|
196 |
|
---|
197 | VERSION = $(shell cat VERSION)
|
---|
198 | DISTDIR = Delphes-$(VERSION)
|
---|
199 | DISTTAR = $(DISTDIR).tar.gz
|
---|
200 |
|
---|
201 | all:
|
---|
202 |
|
---|
203 | }
|
---|
204 |
|
---|
205 | executableDeps
|
---|
206 |
|
---|
207 | dictDeps {DICT} {classes/*LinkDef.h} {modules/*LinkDef.h} {external/ExRootAnalysis/*LinkDef.h}
|
---|
208 |
|
---|
209 | sourceDeps {SOURCE} {classes/*.cc} {modules/*.cc} {external/ExRootAnalysis/*.cc} {external/fastjet/*.cc} {external/fastjet/tools/*.cc} {external/fastjet/plugins/*/*.cc}
|
---|
210 |
|
---|
211 | tclDeps
|
---|
212 |
|
---|
213 | headerDeps
|
---|
214 |
|
---|
215 | puts {
|
---|
216 |
|
---|
217 | ###
|
---|
218 |
|
---|
219 | all: $(SHARED) $(EXECUTABLE) $(STDHEP_EXECUTABLE)
|
---|
220 |
|
---|
221 | $(SHARED): $(DICT_OBJ) $(SOURCE_OBJ) $(TCL_OBJ)
|
---|
222 | @mkdir -p $(@D)
|
---|
223 | @echo ">> Building $@"
|
---|
224 | ifeq ($(ARCH),aix5)
|
---|
225 | @$(MAKESHARED) $(OutPutOpt) $@ $(LIBS) -p 0 $^
|
---|
226 | else
|
---|
227 | ifeq ($(PLATFORM),macosx)
|
---|
228 | # We need to make both the .dylib and the .so
|
---|
229 | @$(LD) $(SOFLAGS)$@ $(LDFLAGS) $^ $(OutPutOpt) $@ $(LIBS)
|
---|
230 | ifneq ($(subst $(MACOSX_MINOR),,1234),1234)
|
---|
231 | ifeq ($(MACOSX_MINOR),4)
|
---|
232 | @ln -sf $@ $(subst .$(DllSuf),.so,$@)
|
---|
233 | endif
|
---|
234 | endif
|
---|
235 | else
|
---|
236 | ifeq ($(PLATFORM),win32)
|
---|
237 | @bindexplib $* $^ > $*.def
|
---|
238 | @lib -nologo -MACHINE:IX86 $^ -def:$*.def $(OutPutOpt)$(SHAREDLIB)
|
---|
239 | @$(LD) $(SOFLAGS) $(LDFLAGS) $^ $*.exp $(LIBS) $(OutPutOpt)$@
|
---|
240 | @$(MT_DLL)
|
---|
241 | else
|
---|
242 | @$(LD) $(SOFLAGS) $(LDFLAGS) $^ $(OutPutOpt) $@ $(LIBS)
|
---|
243 | @$(MT_DLL)
|
---|
244 | endif
|
---|
245 | endif
|
---|
246 | endif
|
---|
247 |
|
---|
248 | clean:
|
---|
249 | @rm -f $(DICT_OBJ) $(SOURCE_OBJ) $(TCL_OBJ) $(STDHEP_OBJ) core
|
---|
250 |
|
---|
251 | distclean: clean
|
---|
252 | @rm -f $(SHARED) $(SHAREDLIB) $(EXECUTABLE)
|
---|
253 |
|
---|
254 | dist:
|
---|
255 | @echo ">> Building $(DISTTAR)"
|
---|
256 | @mkdir -p $(DISTDIR)
|
---|
257 | @cp -a CREDITS README VERSION Makefile configure classes converters doc examples external modules readers $(DISTDIR)
|
---|
258 | @find $(DISTDIR) -depth -name .\* -exec rm -rf {} \;
|
---|
259 | @tar -czf $(DISTTAR) $(DISTDIR)
|
---|
260 | @rm -rf $(DISTDIR)
|
---|
261 |
|
---|
262 | ###
|
---|
263 |
|
---|
264 | .SUFFIXES: .$(SrcSuf) .$(ObjSuf) .$(DllSuf)
|
---|
265 |
|
---|
266 | %Dict.$(SrcSuf):
|
---|
267 | @mkdir -p $(@D)
|
---|
268 | @echo ">> Generating $@"
|
---|
269 | @rootcint -f $@ -c -Iexternal $<
|
---|
270 | @echo "#define private public" > $@.arch
|
---|
271 | @echo "#define protected public" >> $@.arch
|
---|
272 | @mv $@ $@.base
|
---|
273 | @cat $@.arch $< $@.base > $@
|
---|
274 | @rm $@.arch $@.base
|
---|
275 |
|
---|
276 | $(SOURCE_OBJ): tmp/%.$(ObjSuf): %.$(SrcSuf)
|
---|
277 | @mkdir -p $(@D)
|
---|
278 | @echo ">> Compiling $<"
|
---|
279 | @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@
|
---|
280 |
|
---|
281 | $(DICT_OBJ): %.$(ObjSuf): %.$(SrcSuf)
|
---|
282 | @mkdir -p $(@D)
|
---|
283 | @echo ">> Compiling $<"
|
---|
284 | @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@
|
---|
285 |
|
---|
286 | $(TCL_OBJ): tmp/%.$(ObjSuf): %.c
|
---|
287 | @mkdir -p $(@D)
|
---|
288 | @echo ">> Compiling $<"
|
---|
289 | @gcc $(CXXFLAGS) -c $< $(OutPutOpt)$@
|
---|
290 |
|
---|
291 | $(EXECUTABLE_OBJ): tmp/%.$(ObjSuf): %.cpp
|
---|
292 | @mkdir -p $(@D)
|
---|
293 | @echo ">> Compiling $<"
|
---|
294 | @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@
|
---|
295 |
|
---|
296 | $(EXECUTABLE): %$(ExeSuf): $(DICT_OBJ) $(SOURCE_OBJ) $(TCL_OBJ)
|
---|
297 | @echo ">> Building $@"
|
---|
298 | @$(LD) $(LDFLAGS) $^ $(LIBS) $(OutPutOpt)$@
|
---|
299 |
|
---|
300 | ###
|
---|
301 |
|
---|
302 | }
|
---|