Fork me on GitHub

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

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

update Makefile

File size: 8.0 KB
RevLine 
[593]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
[610]27 } elseif [file exists external/$file] {
28 lappend list external/$file
29 set headerFiles(external/$file) 1
30 }
[593]31 }
32 }
[1128]33
[593]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
[1128]51 close $fid
[593]52}
53
54proc dictDeps {dictVar args} {
55
56 global prefix suffix srcSuf objSuf
57
58 set dict [eval glob -nocomplain $args]
[1128]59
[593]60 set dictSrcFiles {}
61 set dictObjFiles {}
62
63 foreach fileName $dict {
64 regsub {LinkDef\.h} $fileName {Dict} dictName
65 set dictName $prefix$dictName
[1128]66
[593]67 lappend dictSrcFiles $dictName$srcSuf
68 lappend dictObjFiles $dictName$objSuf
[1128]69
[593]70 dependencies $fileName "$dictName$srcSuf:$suffix$fileName"
71 }
[1128]72
[593]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
[1128]86
[593]87 set source [eval glob -nocomplain $args]
[1128]88
[593]89 set srcObjFiles {}
[1128]90
[593]91 foreach fileName $source {
92 regsub {\.cc} $fileName {} srcName
93 set srcObjName $prefix$srcName
[1128]94
[593]95 lappend srcObjFiles $srcObjName$objSuf
[1128]96
[593]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
[1128]108
[593]109 set source [glob -nocomplain {external/tcl/*.c}]
[1128]110
[593]111 set srcObjFiles {}
[1128]112
[593]113 foreach fileName $source {
114 if {$fileName == "tcl/tclc.c" || $fileName == "tcl/tcl.c"} continue
[1128]115
[593]116 regsub {\.c} $fileName {} srcName
117 set srcObjName $prefix$srcName
[1128]118
[593]119 lappend srcObjFiles $srcObjName$objSuf
[1128]120
[593]121 dependencies $fileName "$srcObjName$objSuf:$suffix$fileName"
122 }
[1128]123
[593]124 puts -nonewline "TCL_OBJ = $suffix"
125 puts [join $srcObjFiles $suffix]
126 puts ""
127}
128
129proc executableDeps {} {
130
131 global prefix suffix objSuf exeSuf
[1128]132
[1127]133 set executable [glob -nocomplain {readers/*.cpp} {converters/*.cpp} {examples/*.cpp}]
[1128]134
[593]135 set exeFiles {}
[1128]136
[593]137 foreach fileName $executable {
[1127]138 if {$fileName == "examples/DelphesCMSFWLite.cpp"} continue
139
[593]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
[1128]146
[593]147 puts "$exeName$exeSuf:$suffix$exeObjName$objSuf"
148 puts ""
[1128]149
[593]150 dependencies $fileName "$exeObjName$objSuf:$suffix$fileName"
151 }
[1128]152
[593]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
[1128]168
[593]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
[857]183include doc/Makefile.arch
[593]184
185ifeq ($(ARCH),macosx64)
186UNDEFOPT = dynamic_lookup
187endif
188
189SrcSuf = cc
190
[1038]191CXXFLAGS += $(ROOTCFLAGS) -Wno-write-strings -D_FILE_OFFSET_BITS=64 -DDROP_CGAL -I. -Iexternal -Iexternal/tcl
[1097]192DELPHES_LIBS = $(shell $(RC) --libs) -lEG $(SYSLIBS)
193DISPLAY_LIBS = $(shell $(RC) --evelibs) $(SYSLIBS)
[824]194
[593]195###
196
[1097]197DELPHES = libDelphes.$(DllSuf)
198DELPHESLIB = libDelphes.lib
[593]199
[1097]200DISPLAY = libDelphesDisplay.$(DllSuf)
201DISPLAYLIB = libDelphesDisplay.lib
202
[850]203VERSION = $(shell cat VERSION)
[857]204DISTDIR = Delphes-$(VERSION)
[851]205DISTTAR = $(DISTDIR).tar.gz
[850]206
[593]207all:
208
209}
210
211executableDeps
212
[1097]213dictDeps {DELPHES_DICT} {classes/*LinkDef.h} {modules/*LinkDef.h} {external/ExRootAnalysis/*LinkDef.h}
[593]214
[1097]215dictDeps {DISPLAY_DICT} {display/*LinkDef.h}
[593]216
[1097]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
[593]221tclDeps
222
223headerDeps
224
225puts {
226
227###
228
[1097]229all: $(DELPHES) $(EXECUTABLE)
[593]230
[1097]231display: $(DISPLAY)
232
233$(DELPHES): $(DELPHES_DICT_OBJ) $(DELPHES_OBJ) $(TCL_OBJ)
[593]234 @mkdir -p $(@D)
235 @echo ">> Building $@"
236ifeq ($(ARCH),aix5)
[1097]237 @$(MAKESHARED) $(OutPutOpt) $@ $(DELPHES_LIBS) -p 0 $^
[593]238else
239ifeq ($(PLATFORM),macosx)
240# We need to make both the .dylib and the .so
[1097]241 @$(LD) $(SOFLAGS)$@ $(LDFLAGS) $^ $(OutPutOpt) $@ $(DELPHES_LIBS)
[743]242ifneq ($(subst $(MACOSX_MINOR),,1234),1234)
243ifeq ($(MACOSX_MINOR),4)
244 @ln -sf $@ $(subst .$(DllSuf),.so,$@)
245endif
246endif
[593]247else
248ifeq ($(PLATFORM),win32)
249 @bindexplib $* $^ > $*.def
[1097]250 @lib -nologo -MACHINE:IX86 $^ -def:$*.def $(OutPutOpt)$(DELPHESLIB)
251 @$(LD) $(SOFLAGS) $(LDFLAGS) $^ $*.exp $(DELPHES_LIBS) $(OutPutOpt)$@
[593]252 @$(MT_DLL)
253else
[1097]254 @$(LD) $(SOFLAGS) $(LDFLAGS) $^ $(OutPutOpt) $@ $(DELPHES_LIBS)
[593]255 @$(MT_DLL)
256endif
257endif
258endif
259
[1097]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
[593]287clean:
[1097]288 @rm -f $(DELPHES_DICT_OBJ) $(DISPLAY_DICT_OBJ) $(DELPHES_OBJ) $(DISPLAY_OBJ) $(TCL_OBJ) core
289 @rm -rf tmp
[593]290
291distclean: clean
[1097]292 @rm -f $(DELPHES) $(DELPHESLIB) $(DISPLAY) $(DISPLAYLIB) $(EXECUTABLE)
[593]293
[850]294dist:
[851]295 @echo ">> Building $(DISTTAR)"
[850]296 @mkdir -p $(DISTDIR)
[1113]297 @cp -a CREDITS README VERSION Makefile configure classes converters display doc examples external modules python readers $(DISTDIR)
[851]298 @find $(DISTDIR) -depth -name .\* -exec rm -rf {} \;
299 @tar -czf $(DISTTAR) $(DISTDIR)
[850]300 @rm -rf $(DISTDIR)
301
[593]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
[1097]316$(DELPHES_OBJ): tmp/%.$(ObjSuf): %.$(SrcSuf)
[593]317 @mkdir -p $(@D)
318 @echo ">> Compiling $<"
319 @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@
320
[1097]321$(DISPLAY_OBJ): tmp/%.$(ObjSuf): %.$(SrcSuf)
[593]322 @mkdir -p $(@D)
323 @echo ">> Compiling $<"
324 @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@
325
[1097]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
[593]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
[1097]346$(EXECUTABLE): %$(ExeSuf): $(DELPHES_DICT_OBJ) $(DELPHES_OBJ) $(TCL_OBJ)
[593]347 @echo ">> Building $@"
[1097]348 @$(LD) $(LDFLAGS) $^ $(DELPHES_LIBS) $(OutPutOpt)$@
[593]349
350###
351
352}
Note: See TracBrowser for help on using the repository browser.