[2] | 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 | }
|
---|
| 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 |
|
---|
| 51 | proc 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 |
|
---|
| 80 | proc 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 |
|
---|
| 102 | proc tclDeps {} {
|
---|
| 103 |
|
---|
| 104 | global prefix suffix srcSuf objSuf
|
---|
| 105 |
|
---|
| 106 | set source [glob -nocomplain {tcl/*.c}]
|
---|
| 107 |
|
---|
| 108 | set srcObjFiles {}
|
---|
| 109 |
|
---|
| 110 | foreach fileName $source {
|
---|
| 111 | if {$fileName == "tcl/tclc.c" || $fileName == "tcl/tcl.c"} continue
|
---|
| 112 |
|
---|
| 113 | regsub {\.c} $fileName {} srcName
|
---|
| 114 | set srcObjName $prefix$srcName
|
---|
| 115 |
|
---|
| 116 | lappend srcObjFiles $srcObjName$objSuf
|
---|
| 117 |
|
---|
| 118 | dependencies $fileName "$srcObjName$objSuf:$suffix$fileName"
|
---|
| 119 | }
|
---|
| 120 |
|
---|
| 121 | puts -nonewline "TCL_OBJ = $suffix"
|
---|
| 122 | puts [join $srcObjFiles $suffix]
|
---|
| 123 | puts ""
|
---|
| 124 | }
|
---|
| 125 |
|
---|
| 126 | proc stdhepDeps {} {
|
---|
| 127 |
|
---|
| 128 | global prefix suffix srcSuf objSuf
|
---|
| 129 |
|
---|
| 130 | set source [glob -nocomplain {mcfio/*.c} {stdhep/*.c}]
|
---|
| 131 |
|
---|
| 132 | set srcObjFiles {}
|
---|
| 133 |
|
---|
| 134 | foreach fileName $source {
|
---|
| 135 | regsub {\.c} $fileName {} srcName
|
---|
| 136 | set srcObjName $prefix$srcName
|
---|
| 137 |
|
---|
| 138 | lappend srcObjFiles $srcObjName$objSuf
|
---|
| 139 |
|
---|
| 140 | dependencies $fileName "$srcObjName$objSuf:$suffix$fileName"
|
---|
| 141 | }
|
---|
| 142 |
|
---|
| 143 | puts -nonewline "STDHEP_OBJ = $suffix"
|
---|
| 144 | puts [join $srcObjFiles $suffix]
|
---|
| 145 | puts ""
|
---|
| 146 | }
|
---|
| 147 |
|
---|
| 148 | proc stdhepExecutableDeps {} {
|
---|
| 149 |
|
---|
| 150 | global prefix suffix objSuf exeSuf
|
---|
| 151 |
|
---|
| 152 | set executable [glob -nocomplain {test/ExRootSTDHEPConverter.cpp} \
|
---|
| 153 | {test/MatchingSTDHEPConverter.cpp}]
|
---|
| 154 |
|
---|
| 155 | set exeFiles {}
|
---|
| 156 |
|
---|
| 157 | foreach fileName $executable {
|
---|
| 158 | regsub {\.cpp} $fileName {} exeObjName
|
---|
| 159 | set exeObjName $prefix$exeObjName
|
---|
| 160 | set exeName [file tail $exeObjName]
|
---|
| 161 |
|
---|
| 162 | lappend exeFiles $exeName$exeSuf
|
---|
| 163 | lappend exeObjFiles $exeObjName$objSuf
|
---|
| 164 |
|
---|
| 165 | puts "$exeName$exeSuf:$suffix$exeObjName$objSuf"
|
---|
| 166 | puts ""
|
---|
| 167 |
|
---|
| 168 | dependencies $fileName "$exeObjName$objSuf:$suffix$fileName"
|
---|
| 169 | }
|
---|
| 170 |
|
---|
| 171 | if [info exists exeFiles] {
|
---|
| 172 | puts -nonewline "STDHEP_EXECUTABLE = $suffix"
|
---|
| 173 | puts [join $exeFiles $suffix]
|
---|
| 174 | puts ""
|
---|
| 175 | }
|
---|
| 176 | if [info exists exeObjFiles] {
|
---|
| 177 | puts -nonewline "STDHEP_EXECUTABLE_OBJ = $suffix"
|
---|
| 178 | puts [join $exeObjFiles $suffix]
|
---|
| 179 | puts ""
|
---|
| 180 | }
|
---|
| 181 |
|
---|
| 182 | }
|
---|
| 183 |
|
---|
| 184 | proc executableDeps {} {
|
---|
| 185 |
|
---|
| 186 | global prefix suffix objSuf exeSuf
|
---|
| 187 |
|
---|
| 188 | set executable [glob -nocomplain {test/*.cpp}]
|
---|
| 189 |
|
---|
| 190 | set exeFiles {}
|
---|
| 191 |
|
---|
| 192 | foreach fileName $executable {
|
---|
| 193 | if {$fileName == "test/ExRootSTDHEPConverter.cpp"} continue
|
---|
| 194 | if {$fileName == "test/MatchingSTDHEPConverter.cpp"} continue
|
---|
| 195 | regsub {\.cpp} $fileName {} exeObjName
|
---|
| 196 | set exeObjName $prefix$exeObjName
|
---|
| 197 | set exeName [file tail $exeObjName]
|
---|
| 198 |
|
---|
| 199 | lappend exeFiles $exeName$exeSuf
|
---|
| 200 | lappend exeObjFiles $exeObjName$objSuf
|
---|
| 201 |
|
---|
| 202 | puts "$exeName$exeSuf:$suffix$exeObjName$objSuf"
|
---|
| 203 | puts ""
|
---|
| 204 |
|
---|
| 205 | dependencies $fileName "$exeObjName$objSuf:$suffix$fileName"
|
---|
| 206 | }
|
---|
| 207 |
|
---|
| 208 | if [info exists exeFiles] {
|
---|
| 209 | puts -nonewline "EXECUTABLE = $suffix"
|
---|
| 210 | puts [join $exeFiles $suffix]
|
---|
| 211 | puts ""
|
---|
| 212 | }
|
---|
| 213 | if [info exists exeObjFiles] {
|
---|
| 214 | puts -nonewline "EXECUTABLE_OBJ = $suffix"
|
---|
| 215 | puts [join $exeObjFiles $suffix]
|
---|
| 216 | puts ""
|
---|
| 217 | }
|
---|
| 218 |
|
---|
| 219 | }
|
---|
| 220 |
|
---|
| 221 | proc headerDeps {} {
|
---|
| 222 | global suffix headerFiles
|
---|
| 223 |
|
---|
[6] | 224 | foreach fileName [array names headerFiles] {
|
---|
[2] | 225 | dependencies $fileName "$fileName:" 0 "\t@touch \$@"
|
---|
| 226 | }
|
---|
| 227 | }
|
---|
| 228 |
|
---|
| 229 | puts {
|
---|
| 230 | #
|
---|
| 231 | # Makefile for ExRootAnalysis
|
---|
| 232 | #
|
---|
| 233 | # Author: P. Demin - UCL, Louvain-la-Neuve
|
---|
| 234 | #
|
---|
[5] | 235 | # multi-platform configuration is taken from ROOT (root/test/Makefile.arch)
|
---|
[2] | 236 | #
|
---|
| 237 |
|
---|
[5] | 238 | include $(ROOTSYS)/test/Makefile.arch
|
---|
[2] | 239 |
|
---|
[5] | 240 | ifeq ($(ARCH),macosx64)
|
---|
| 241 | UNDEFOPT = dynamic_lookup
|
---|
[2] | 242 | endif
|
---|
| 243 |
|
---|
[5] | 244 | SrcSuf = cc
|
---|
[2] | 245 |
|
---|
[12] | 246 | CXXFLAGS += $(ROOTCFLAGS) -DDROP_CGAL -I. -Itcl -Imcfio -Istdhep -ISISCone -ICDFCones -ICDFCones/CDFcode
|
---|
[6] | 247 | LIBS = $(ROOTLIBS) -lEG $(SYSLIBS)
|
---|
[2] | 248 | GLIBS = $(ROOTGLIBS) $(SYSLIBS)
|
---|
| 249 |
|
---|
| 250 | ###
|
---|
| 251 |
|
---|
| 252 | STATIC = lib/libExRootAnalysisPGS.$(LibSuf)
|
---|
| 253 | SHARED = lib/libExRootAnalysis.$(DllSuf)
|
---|
| 254 |
|
---|
| 255 | all:
|
---|
| 256 |
|
---|
| 257 | }
|
---|
| 258 |
|
---|
| 259 | stdhepExecutableDeps
|
---|
| 260 |
|
---|
| 261 | executableDeps
|
---|
| 262 |
|
---|
| 263 | dictDeps {DICT} {src/*LinkDef.h} {modules/*LinkDef.h}
|
---|
| 264 |
|
---|
| 265 | dictDeps {PGS_DICT} {pgs/*LinkDef.h}
|
---|
| 266 |
|
---|
[12] | 267 | sourceDeps {SOURCE} {src/*.cc} {modules/*.cc} {SISCone/*.cc} {CDFCones/*.cc} {KtJet/*.cc} {CLHEP/src/*.cc}
|
---|
[2] | 268 |
|
---|
| 269 | sourceDeps {PGS_SOURCE} {src/ExRootClasses.cc} {src/ExRootTreeBranch.cc} {src/ExRootTreeWriter.cc}
|
---|
| 270 |
|
---|
| 271 | sourceDeps {PGS} {pgs/*.cc}
|
---|
| 272 |
|
---|
| 273 | stdhepDeps
|
---|
| 274 |
|
---|
| 275 | tclDeps
|
---|
| 276 |
|
---|
| 277 | headerDeps
|
---|
| 278 |
|
---|
| 279 | puts {
|
---|
| 280 |
|
---|
| 281 | ###
|
---|
| 282 |
|
---|
| 283 | all: $(SHARED) $(EXECUTABLE) $(STDHEP_EXECUTABLE)
|
---|
| 284 |
|
---|
| 285 | static: $(STATIC)
|
---|
| 286 |
|
---|
| 287 | $(STATIC): $(PGS_DICT_OBJ) $(PGS_SOURCE_OBJ) $(PGS_OBJ)
|
---|
| 288 | @mkdir -p $(@D)
|
---|
| 289 | $(AR) $(ARFLAGS) $@ $^
|
---|
| 290 | $(RANLIB) $@
|
---|
| 291 |
|
---|
| 292 | $(SHARED): $(DICT_OBJ) $(SOURCE_OBJ) $(TCL_OBJ)
|
---|
[5] | 293 | @mkdir -p $(@D)
|
---|
| 294 | @echo ">> Building $@"
|
---|
[2] | 295 | ifeq ($(ARCH),aix)
|
---|
[5] | 296 | @/usr/ibmcxx/bin/makeC++SharedLib $(OutPutOpt) $@ $(LIBS) -p 0 $^
|
---|
[2] | 297 | else
|
---|
| 298 | ifeq ($(ARCH),aix5)
|
---|
[5] | 299 | @/usr/vacpp/bin/makeC++SharedLib $(OutPutOpt) $@ $(LIBS) -p 0 $^
|
---|
[2] | 300 | else
|
---|
[5] | 301 | ifeq ($(PLATFORM),macosx)
|
---|
[2] | 302 | # We need to make both the .dylib and the .so
|
---|
[5] | 303 | @$(LD) $(SOFLAGS) $^ $(OutPutOpt) $@
|
---|
| 304 | @$(LD) -bundle -undefined $(UNDEFOPT) $(LDFLAGS) $^ $(LIBS) $(OutPutOpt) $(subst .$(DllSuf),.so,$@)
|
---|
[2] | 305 | else
|
---|
| 306 | ifeq ($(PLATFORM),win32)
|
---|
[5] | 307 | @bindexplib $* $^ > $*.def
|
---|
| 308 | @lib -nologo -MACHINE:IX86 $^ -def:$*.def $(OutPutOpt)$(EVENTLIB)
|
---|
| 309 | @$(LD) $(SOFLAGS) $(LDFLAGS) $^ $*.exp $(LIBS) $(OutPutOpt)$@
|
---|
| 310 | @$(MT_DLL)
|
---|
[2] | 311 | else
|
---|
[5] | 312 | @$(LD) $(SOFLAGS) $(LDFLAGS) $^ $(OutPutOpt) $@ $(EXPLLINKLIBS)
|
---|
| 313 | @$(MT_DLL)
|
---|
[2] | 314 | endif
|
---|
| 315 | endif
|
---|
| 316 | endif
|
---|
| 317 | endif
|
---|
| 318 |
|
---|
| 319 | clean:
|
---|
[5] | 320 | @rm -f $(PGS_DICT_OBJ) $(PGS_SOURCE_OBJ) $(PGS_OBJ) $(DICT_OBJ) $(SOURCE_OBJ) $(TCL_OBJ) $(STDHEP_OBJ) core
|
---|
[2] | 321 |
|
---|
| 322 | distclean: clean
|
---|
[5] | 323 | @rm -f $(SHARED) $(STATIC) $(EXECUTABLE) $(STDHEP_EXECUTABLE)
|
---|
[2] | 324 |
|
---|
| 325 | ###
|
---|
| 326 |
|
---|
| 327 | .SUFFIXES: .$(SrcSuf) .$(ObjSuf) .$(DllSuf)
|
---|
| 328 |
|
---|
| 329 | %Dict.$(SrcSuf):
|
---|
| 330 | @mkdir -p $(@D)
|
---|
| 331 | @echo ">> Generating $@"
|
---|
| 332 | @rootcint -f $@ -c $<
|
---|
| 333 | @echo "#define private public" > $@.arch
|
---|
| 334 | @echo "#define protected public" >> $@.arch
|
---|
| 335 | @mv $@ $@.base
|
---|
| 336 | @cat $@.arch $< $@.base > $@
|
---|
| 337 | @rm $@.arch $@.base
|
---|
| 338 |
|
---|
| 339 | $(SOURCE_OBJ): tmp/%.$(ObjSuf): %.$(SrcSuf)
|
---|
| 340 | @mkdir -p $(@D)
|
---|
| 341 | @echo ">> Compiling $<"
|
---|
| 342 | @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@
|
---|
| 343 |
|
---|
| 344 | $(PGS_OBJ): tmp/%.$(ObjSuf): %.$(SrcSuf)
|
---|
| 345 | @mkdir -p $(@D)
|
---|
| 346 | @echo ">> Compiling $<"
|
---|
| 347 | @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@
|
---|
| 348 |
|
---|
| 349 | $(DICT_OBJ): %.$(ObjSuf): %.$(SrcSuf)
|
---|
| 350 | @mkdir -p $(@D)
|
---|
| 351 | @echo ">> Compiling $<"
|
---|
| 352 | @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@
|
---|
| 353 |
|
---|
| 354 | $(PGS_DICT_OBJ): %.$(ObjSuf): %.$(SrcSuf)
|
---|
| 355 | @mkdir -p $(@D)
|
---|
| 356 | @echo ">> Compiling $<"
|
---|
| 357 | @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@
|
---|
| 358 |
|
---|
| 359 | $(TCL_OBJ): tmp/%.$(ObjSuf): %.c
|
---|
| 360 | @mkdir -p $(@D)
|
---|
| 361 | @echo ">> Compiling $<"
|
---|
| 362 | @gcc $(CXXFLAGS) -c $< $(OutPutOpt)$@
|
---|
| 363 |
|
---|
| 364 | $(STDHEP_OBJ): tmp/%.$(ObjSuf): %.c
|
---|
| 365 | @mkdir -p $(@D)
|
---|
| 366 | @echo ">> Compiling $<"
|
---|
| 367 | @gcc $(CXXFLAGS) -c $< $(OutPutOpt)$@
|
---|
| 368 |
|
---|
| 369 | $(STDHEP_EXECUTABLE_OBJ): tmp/%.$(ObjSuf): %.cpp
|
---|
| 370 | @mkdir -p $(@D)
|
---|
| 371 | @echo ">> Compiling $<"
|
---|
| 372 | @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@
|
---|
| 373 |
|
---|
| 374 | $(STDHEP_EXECUTABLE): %$(ExeSuf): $(DICT_OBJ) $(SOURCE_OBJ) $(TCL_OBJ) $(STDHEP_OBJ)
|
---|
| 375 | @echo ">> Building $@"
|
---|
| 376 | @$(LD) $(LDFLAGS) $^ $(LIBS) $(OutPutOpt)$@
|
---|
| 377 |
|
---|
| 378 | $(EXECUTABLE_OBJ): tmp/%.$(ObjSuf): %.cpp
|
---|
| 379 | @mkdir -p $(@D)
|
---|
| 380 | @echo ">> Compiling $<"
|
---|
| 381 | @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@
|
---|
| 382 |
|
---|
| 383 | $(EXECUTABLE): %$(ExeSuf): $(DICT_OBJ) $(SOURCE_OBJ) $(TCL_OBJ)
|
---|
| 384 | @echo ">> Building $@"
|
---|
| 385 | @$(LD) $(LDFLAGS) $^ $(LIBS) $(OutPutOpt)$@
|
---|
| 386 |
|
---|
| 387 | ###
|
---|
| 388 |
|
---|
| 389 | }
|
---|