[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 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 |
|
---|
| 124 | proc stdhepExecutableDeps {} {
|
---|
| 125 |
|
---|
| 126 | global prefix suffix objSuf exeSuf
|
---|
| 127 |
|
---|
[188] | 128 | set executable [glob -nocomplain {Delphes.cpp} {Resolutions.cpp} {Examples/Trigger_Only.cpp} {Examples/Analysis_Ex.cpp} {Examples/Frog_on_analysis_output.cpp}]
|
---|
[2] | 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 |
|
---|
| 159 | proc 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 |
|
---|
| 194 | proc headerDeps {} {
|
---|
| 195 | global suffix headerFiles
|
---|
| 196 |
|
---|
| 197 | foreach fileName [array names headerFiles] {
|
---|
| 198 | dependencies $fileName "$fileName:" 0 "\t@touch \$@"
|
---|
| 199 | }
|
---|
| 200 | }
|
---|
| 201 |
|
---|
| 202 | puts {
|
---|
| 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 |
|
---|
| 211 | include $(ROOTSYS)/test/Makefile.arch
|
---|
| 212 |
|
---|
| 213 | ifeq ($(ARCH),macosx64)
|
---|
| 214 | UNDEFOPT = dynamic_lookup
|
---|
| 215 | endif
|
---|
| 216 |
|
---|
[425] | 217 |
|
---|
| 218 | ifneq (,$(findstring macos,$(ARCH)))
|
---|
| 219 | CXXFLAGS += -Dmacos
|
---|
[432] | 220 | else
|
---|
| 221 | ifneq (,$(findstring win,$(ARCH)))
|
---|
[427] | 222 | CXXFLAGS += -Dwindows
|
---|
| 223 | else
|
---|
| 224 | CXXFLAGS += -Dlinux
|
---|
[425] | 225 | endif
|
---|
[432] | 226 | endif
|
---|
[425] | 227 |
|
---|
| 228 |
|
---|
[2] | 229 | SrcSuf = cc
|
---|
| 230 |
|
---|
[350] | 231 | CXXFLAGS += $(ROOTCFLAGS) -DDROP_CGAL -I. -Iinterface -IUtilities/mcfio -IUtilities/stdhep -IUtilities/Hector/include -IUtilities/CDFCones/interface -IExamples -IUtilities/FROG/Includes/FROG -IUtilities/ExRootAnalysis/interface -IUtilities/Fastjet/include/fastjet -IUtilities/Fastjet/plugins/CDFCones -IUtilities/Fastjet/plugins/CDFCones/interface -IUtilities/Fastjet/plugins/SISCone -IUtilities/CLHEP/Units -IUtilities/HepMC/interface
|
---|
[296] | 232 | # -pg -g
|
---|
[2] | 233 | LIBS = $(ROOTLIBS) -lEG $(SYSLIBS)
|
---|
| 234 | GLIBS = $(ROOTGLIBS) $(SYSLIBS)
|
---|
[425] | 235 |
|
---|
[2] | 236 | ###
|
---|
| 237 |
|
---|
[296] | 238 | #SHARED = lib/libUtilities.$(DllSuf) lib/libHector.$(DllSuf)
|
---|
| 239 | SHARED = lib/libUtilities.$(DllSuf)
|
---|
[201] | 240 | VERSION=$(shell cat VERSION)
|
---|
| 241 | FOLDER=Delphes_V_$(VERSION)
|
---|
| 242 | TARBALL=$(FOLDER).tar.gz
|
---|
| 243 | TESTFILE=tt_jj_small.hep
|
---|
[2] | 244 |
|
---|
| 245 | all:
|
---|
| 246 |
|
---|
| 247 | }
|
---|
| 248 |
|
---|
[78] | 249 | executableDeps {*.cpp} {Examples/*.cpp}
|
---|
[2] | 250 |
|
---|
[84] | 251 | dictDeps {DICT} {Utilities/ExRootAnalysis/src/*LinkDef.h} {src/*LinkDef.h} {Examples/src/*LinkDef.h}
|
---|
[2] | 252 |
|
---|
[350] | 253 | sourceDeps {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} {Utilities/HepMC/src/*.cc}
|
---|
[2] | 254 |
|
---|
| 255 | stdhepDeps
|
---|
| 256 |
|
---|
| 257 | headerDeps
|
---|
| 258 |
|
---|
| 259 | puts {
|
---|
| 260 |
|
---|
| 261 | ###
|
---|
| 262 |
|
---|
| 263 | all: $(SHARED) $(EXECUTABLE) $(STDHEP_EXECUTABLE)
|
---|
[138] | 264 | @echo "Delphes has been compiled"
|
---|
| 265 | @echo "Ready to run"
|
---|
[2] | 266 |
|
---|
[533] | 267 | $(SHARED): $(DICT_OBJ) $(SOURCE_OBJ) $(STDHEP_OBJ)
|
---|
[2] | 268 | @mkdir -p $(@D)
|
---|
| 269 | @echo ">> Building $@"
|
---|
| 270 | ifeq ($(ARCH),aix)
|
---|
| 271 | @/usr/ibmcxx/bin/makeC++SharedLib $(OutPutOpt) $@ $(LIBS) -p 0 $^
|
---|
| 272 | else
|
---|
| 273 | ifeq ($(ARCH),aix5)
|
---|
| 274 | @/usr/vacpp/bin/makeC++SharedLib $(OutPutOpt) $@ $(LIBS) -p 0 $^
|
---|
| 275 | else
|
---|
| 276 | ifeq ($(PLATFORM),macosx)
|
---|
| 277 | # We need to make both the .dylib and the .so
|
---|
| 278 | @$(LD) $(SOFLAGS) $^ $(OutPutOpt) $@
|
---|
| 279 | @$(LD) -bundle -undefined $(UNDEFOPT) $(LDFLAGS) $^ $(LIBS) $(OutPutOpt) $(subst .$(DllSuf),.so,$@)
|
---|
| 280 | else
|
---|
| 281 | ifeq ($(PLATFORM),win32)
|
---|
| 282 | @bindexplib $* $^ > $*.def
|
---|
| 283 | @lib -nologo -MACHINE:IX86 $^ -def:$*.def $(OutPutOpt)$(EVENTLIB)
|
---|
| 284 | @$(LD) $(SOFLAGS) $(LDFLAGS) $^ $*.exp $(LIBS) $(OutPutOpt)$@
|
---|
| 285 | @$(MT_DLL)
|
---|
| 286 | else
|
---|
| 287 | @$(LD) $(SOFLAGS) $(LDFLAGS) $^ $(OutPutOpt) $@ $(EXPLLINKLIBS)
|
---|
| 288 | @$(MT_DLL)
|
---|
| 289 | endif
|
---|
| 290 | endif
|
---|
| 291 | endif
|
---|
| 292 | endif
|
---|
| 293 |
|
---|
| 294 | clean:
|
---|
| 295 | @rm -f $(DICT_OBJ) $(SOURCE_OBJ) $(STDHEP_OBJ) core
|
---|
| 296 |
|
---|
| 297 | distclean: clean
|
---|
[174] | 298 | @rm -f $(SHARED) $(EXECUTABLE) $(STDHEP_EXECUTABLE) *vis *geom
|
---|
| 299 | @rm -rf tmp
|
---|
[2] | 300 |
|
---|
[174] | 301 |
|
---|
[2] | 302 | ###
|
---|
| 303 |
|
---|
| 304 | .SUFFIXES: .$(SrcSuf) .$(ObjSuf) .$(DllSuf)
|
---|
| 305 |
|
---|
| 306 | %Dict.$(SrcSuf):
|
---|
| 307 | @mkdir -p $(@D)
|
---|
| 308 | @echo ">> Generating $@"
|
---|
| 309 | @rootcint -f $@ -c $<
|
---|
| 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 | $(SOURCE_OBJ): tmp/%.$(ObjSuf): %.$(SrcSuf)
|
---|
| 317 | @mkdir -p $(@D)
|
---|
| 318 | @echo ">> Compiling $<"
|
---|
| 319 | @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@
|
---|
| 320 |
|
---|
| 321 | $(DICT_OBJ): %.$(ObjSuf): %.$(SrcSuf)
|
---|
| 322 | @mkdir -p $(@D)
|
---|
| 323 | @echo ">> Compiling $<"
|
---|
| 324 | @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@
|
---|
| 325 |
|
---|
| 326 | $(STDHEP_OBJ): tmp/%.$(ObjSuf): %.c
|
---|
| 327 | @mkdir -p $(@D)
|
---|
| 328 | @echo ">> Compiling $<"
|
---|
| 329 | @gcc $(CXXFLAGS) -c $< $(OutPutOpt)$@
|
---|
| 330 |
|
---|
| 331 | $(STDHEP_EXECUTABLE_OBJ): tmp/%.$(ObjSuf): %.cpp
|
---|
| 332 | @mkdir -p $(@D)
|
---|
| 333 | @echo ">> Compiling $<"
|
---|
| 334 | @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@
|
---|
| 335 |
|
---|
| 336 | $(EXECUTABLE_OBJ): tmp/%.$(ObjSuf): %.cpp
|
---|
| 337 | @mkdir -p $(@D)
|
---|
| 338 | @echo ">> Compiling $<"
|
---|
| 339 | @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@
|
---|
| 340 |
|
---|
| 341 | $(EXECUTABLE): %$(ExeSuf): $(DICT_OBJ) $(SOURCE_OBJ) $(STDHEP_OBJ)
|
---|
| 342 | @echo ">> Building $@"
|
---|
| 343 | @$(LD) $(LDFLAGS) $^ $(LIBS) $(OutPutOpt)$@
|
---|
| 344 |
|
---|
| 345 | ###
|
---|
| 346 |
|
---|
[201] | 347 | tar $(TARBALL):
|
---|
| 348 | @echo Building tarball of sources
|
---|
| 349 | @mkdir $(FOLDER)
|
---|
[533] | 350 | @rsync -qavztup --exclude=CVS* CREDITS VERSION FAQ Delphes.cpp Resolutions.cpp Resolutions_ATLAS.cpp Makefile rootlogon.C genMakefile.tcl interface lib routines src data Examples Utilities $(FOLDER)
|
---|
[201] | 351 | @rm -f $(FOLDER)/$(SHARED)
|
---|
[203] | 352 | @rm -f $(FOLDER)/Utilities/FROG/frog
|
---|
[201] | 353 | @rm -f $(FOLDER)/Utilities/FROG/Lib/*.o
|
---|
| 354 | @rm -f $(FOLDER)/Utilities/FROG/Lib/libfrog.*
|
---|
| 355 | @tar czf $(TARBALL) $(FOLDER)
|
---|
| 356 | @rm -rf $(FOLDER)
|
---|
| 357 | @mkdir $(FOLDER)
|
---|
| 358 | @cp tt_jj_small.hep TEST_small_tt.list $(FOLDER)
|
---|
| 359 | @tar czf $(TESTFILE).tar.gz $(FOLDER)
|
---|
| 360 | @rm -rf $(FOLDER)
|
---|
| 361 | @echo Done : `ls $(TARBALL) $(TESTFILE).tar.gz`
|
---|
| 362 |
|
---|
| 363 |
|
---|
[2] | 364 | }
|
---|