[d7d2da3] | 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
|
---|
[00bcbe6] | 190 | DELPHES_LIBS = $(shell $(RC) --libs) -lEG $(SYSLIBS)
|
---|
| 191 | DISPLAY_LIBS = $(shell $(RC) --evelibs) $(SYSLIBS)
|
---|
[d7d2da3] | 192 |
|
---|
| 193 | ###
|
---|
| 194 |
|
---|
[00bcbe6] | 195 | DELPHES = libDelphes.$(DllSuf)
|
---|
| 196 | DELPHESLIB = libDelphes.lib
|
---|
| 197 |
|
---|
| 198 | DISPLAY = libDelphesDisplay.$(DllSuf)
|
---|
| 199 | DISPLAYLIB = libDelphesDisplay.lib
|
---|
[d7d2da3] | 200 |
|
---|
| 201 | VERSION = $(shell cat VERSION)
|
---|
| 202 | DISTDIR = Delphes-$(VERSION)
|
---|
| 203 | DISTTAR = $(DISTDIR).tar.gz
|
---|
| 204 |
|
---|
| 205 | all:
|
---|
| 206 |
|
---|
| 207 | }
|
---|
| 208 |
|
---|
| 209 | executableDeps
|
---|
| 210 |
|
---|
[00bcbe6] | 211 | dictDeps {DELPHES_DICT} {classes/*LinkDef.h} {modules/*LinkDef.h} {external/ExRootAnalysis/*LinkDef.h}
|
---|
| 212 |
|
---|
| 213 | dictDeps {DISPLAY_DICT} {display/*LinkDef.h}
|
---|
| 214 |
|
---|
| 215 | sourceDeps {DELPHES} {classes/*.cc} {modules/*.cc} {external/ExRootAnalysis/*.cc} {external/fastjet/*.cc} {external/fastjet/tools/*.cc} {external/fastjet/plugins/*/*.cc}
|
---|
[d7d2da3] | 216 |
|
---|
[00bcbe6] | 217 | sourceDeps {DISPLAY} {display/*.cc}
|
---|
[d7d2da3] | 218 |
|
---|
| 219 | tclDeps
|
---|
| 220 |
|
---|
| 221 | headerDeps
|
---|
| 222 |
|
---|
| 223 | puts {
|
---|
| 224 |
|
---|
| 225 | ###
|
---|
| 226 |
|
---|
[00bcbe6] | 227 | all: $(DELPHES) $(EXECUTABLE)
|
---|
[d7d2da3] | 228 |
|
---|
[00bcbe6] | 229 | display: $(DISPLAY)
|
---|
| 230 |
|
---|
| 231 | $(DELPHES): $(DELPHES_DICT_OBJ) $(DELPHES_OBJ) $(TCL_OBJ)
|
---|
[d7d2da3] | 232 | @mkdir -p $(@D)
|
---|
| 233 | @echo ">> Building $@"
|
---|
| 234 | ifeq ($(ARCH),aix5)
|
---|
[00bcbe6] | 235 | @$(MAKESHARED) $(OutPutOpt) $@ $(DELPHES_LIBS) -p 0 $^
|
---|
[d7d2da3] | 236 | else
|
---|
| 237 | ifeq ($(PLATFORM),macosx)
|
---|
| 238 | # We need to make both the .dylib and the .so
|
---|
[00bcbe6] | 239 | @$(LD) $(SOFLAGS)$@ $(LDFLAGS) $^ $(OutPutOpt) $@ $(DELPHES_LIBS)
|
---|
[d7d2da3] | 240 | ifneq ($(subst $(MACOSX_MINOR),,1234),1234)
|
---|
| 241 | ifeq ($(MACOSX_MINOR),4)
|
---|
| 242 | @ln -sf $@ $(subst .$(DllSuf),.so,$@)
|
---|
| 243 | endif
|
---|
| 244 | endif
|
---|
| 245 | else
|
---|
| 246 | ifeq ($(PLATFORM),win32)
|
---|
| 247 | @bindexplib $* $^ > $*.def
|
---|
[00bcbe6] | 248 | @lib -nologo -MACHINE:IX86 $^ -def:$*.def $(OutPutOpt)$(DELPHESLIB)
|
---|
| 249 | @$(LD) $(SOFLAGS) $(LDFLAGS) $^ $*.exp $(DELPHES_LIBS) $(OutPutOpt)$@
|
---|
[d7d2da3] | 250 | @$(MT_DLL)
|
---|
| 251 | else
|
---|
[00bcbe6] | 252 | @$(LD) $(SOFLAGS) $(LDFLAGS) $^ $(OutPutOpt) $@ $(DELPHES_LIBS)
|
---|
| 253 | @$(MT_DLL)
|
---|
| 254 | endif
|
---|
| 255 | endif
|
---|
| 256 | endif
|
---|
| 257 |
|
---|
| 258 | $(DISPLAY): $(DELPHES_DICT_OBJ) $(DISPLAY_DICT_OBJ) $(DELPHES_OBJ) $(DISPLAY_OBJ) $(TCL_OBJ)
|
---|
| 259 | @mkdir -p $(@D)
|
---|
| 260 | @echo ">> Building $@"
|
---|
| 261 | ifeq ($(ARCH),aix5)
|
---|
| 262 | @$(MAKESHARED) $(OutPutOpt) $@ $(DISPLAY_LIBS) -p 0 $^
|
---|
| 263 | else
|
---|
| 264 | ifeq ($(PLATFORM),macosx)
|
---|
| 265 | # We need to make both the .dylib and the .so
|
---|
| 266 | @$(LD) $(SOFLAGS)$@ $(LDFLAGS) $^ $(OutPutOpt) $@ $(DISPLAY_LIBS)
|
---|
| 267 | ifneq ($(subst $(MACOSX_MINOR),,1234),1234)
|
---|
| 268 | ifeq ($(MACOSX_MINOR),4)
|
---|
| 269 | @ln -sf $@ $(subst .$(DllSuf),.so,$@)
|
---|
| 270 | endif
|
---|
| 271 | endif
|
---|
| 272 | else
|
---|
| 273 | ifeq ($(PLATFORM),win32)
|
---|
| 274 | @bindexplib $* $^ > $*.def
|
---|
| 275 | @lib -nologo -MACHINE:IX86 $^ -def:$*.def $(OutPutOpt)$(DISPLAYLIB)
|
---|
| 276 | @$(LD) $(SOFLAGS) $(LDFLAGS) $^ $*.exp $(DISPLAY_LIBS) $(OutPutOpt)$@
|
---|
| 277 | @$(MT_DLL)
|
---|
| 278 | else
|
---|
| 279 | @$(LD) $(SOFLAGS) $(LDFLAGS) $^ $(OutPutOpt) $@ $(DISPLAY_LIBS)
|
---|
[d7d2da3] | 280 | @$(MT_DLL)
|
---|
| 281 | endif
|
---|
| 282 | endif
|
---|
| 283 | endif
|
---|
| 284 |
|
---|
| 285 | clean:
|
---|
[00bcbe6] | 286 | @rm -f $(DELPHES_DICT_OBJ) $(DISPLAY_DICT_OBJ) $(DELPHES_OBJ) $(DISPLAY_OBJ) $(TCL_OBJ) core
|
---|
| 287 | @rm -rf tmp
|
---|
[d7d2da3] | 288 |
|
---|
| 289 | distclean: clean
|
---|
[00bcbe6] | 290 | @rm -f $(DELPHES) $(DELPHESLIB) $(DISPLAY) $(DISPLAYLIB) $(EXECUTABLE)
|
---|
[d7d2da3] | 291 |
|
---|
| 292 | dist:
|
---|
| 293 | @echo ">> Building $(DISTTAR)"
|
---|
| 294 | @mkdir -p $(DISTDIR)
|
---|
[809e3a9] | 295 | @cp -a CREDITS README VERSION Makefile configure classes converters display doc examples external modules python readers $(DISTDIR)
|
---|
[d7d2da3] | 296 | @find $(DISTDIR) -depth -name .\* -exec rm -rf {} \;
|
---|
| 297 | @tar -czf $(DISTTAR) $(DISTDIR)
|
---|
| 298 | @rm -rf $(DISTDIR)
|
---|
| 299 |
|
---|
| 300 | ###
|
---|
| 301 |
|
---|
| 302 | .SUFFIXES: .$(SrcSuf) .$(ObjSuf) .$(DllSuf)
|
---|
| 303 |
|
---|
| 304 | %Dict.$(SrcSuf):
|
---|
| 305 | @mkdir -p $(@D)
|
---|
| 306 | @echo ">> Generating $@"
|
---|
| 307 | @rootcint -f $@ -c -Iexternal $<
|
---|
| 308 | @echo "#define private public" > $@.arch
|
---|
| 309 | @echo "#define protected public" >> $@.arch
|
---|
| 310 | @mv $@ $@.base
|
---|
| 311 | @cat $@.arch $< $@.base > $@
|
---|
| 312 | @rm $@.arch $@.base
|
---|
| 313 |
|
---|
[00bcbe6] | 314 | $(DELPHES_OBJ): tmp/%.$(ObjSuf): %.$(SrcSuf)
|
---|
| 315 | @mkdir -p $(@D)
|
---|
| 316 | @echo ">> Compiling $<"
|
---|
| 317 | @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@
|
---|
| 318 |
|
---|
| 319 | $(DISPLAY_OBJ): tmp/%.$(ObjSuf): %.$(SrcSuf)
|
---|
| 320 | @mkdir -p $(@D)
|
---|
| 321 | @echo ">> Compiling $<"
|
---|
| 322 | @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@
|
---|
| 323 |
|
---|
| 324 | $(DELPHES_DICT_OBJ): %.$(ObjSuf): %.$(SrcSuf)
|
---|
[d7d2da3] | 325 | @mkdir -p $(@D)
|
---|
| 326 | @echo ">> Compiling $<"
|
---|
| 327 | @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@
|
---|
| 328 |
|
---|
[00bcbe6] | 329 | $(DISPLAY_DICT_OBJ): %.$(ObjSuf): %.$(SrcSuf)
|
---|
[d7d2da3] | 330 | @mkdir -p $(@D)
|
---|
| 331 | @echo ">> Compiling $<"
|
---|
| 332 | @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@
|
---|
| 333 |
|
---|
| 334 | $(TCL_OBJ): tmp/%.$(ObjSuf): %.c
|
---|
| 335 | @mkdir -p $(@D)
|
---|
| 336 | @echo ">> Compiling $<"
|
---|
| 337 | @gcc $(CXXFLAGS) -c $< $(OutPutOpt)$@
|
---|
| 338 |
|
---|
| 339 | $(EXECUTABLE_OBJ): tmp/%.$(ObjSuf): %.cpp
|
---|
| 340 | @mkdir -p $(@D)
|
---|
| 341 | @echo ">> Compiling $<"
|
---|
| 342 | @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@
|
---|
| 343 |
|
---|
[00bcbe6] | 344 | $(EXECUTABLE): %$(ExeSuf): $(DELPHES_DICT_OBJ) $(DELPHES_OBJ) $(TCL_OBJ)
|
---|
[d7d2da3] | 345 | @echo ">> Building $@"
|
---|
[00bcbe6] | 346 | @$(LD) $(LDFLAGS) $^ $(DELPHES_LIBS) $(OutPutOpt)$@
|
---|
[d7d2da3] | 347 |
|
---|
| 348 | ###
|
---|
| 349 |
|
---|
| 350 | }
|
---|