[593] | 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
|
---|
[610] | 27 | } elseif [file exists external/$file] {
|
---|
| 28 | lappend list external/$file
|
---|
| 29 | set headerFiles(external/$file) 1
|
---|
| 30 | }
|
---|
[593] | 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 |
|
---|
[802] | 133 | set executable [glob -nocomplain {readers/*.cpp} {converters/*.cpp}]
|
---|
[593] | 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 |
|
---|
[857] | 181 | include doc/Makefile.arch
|
---|
[593] | 182 |
|
---|
| 183 | ifeq ($(ARCH),macosx64)
|
---|
| 184 | UNDEFOPT = dynamic_lookup
|
---|
| 185 | endif
|
---|
| 186 |
|
---|
| 187 | SrcSuf = cc
|
---|
| 188 |
|
---|
[1038] | 189 | CXXFLAGS += $(ROOTCFLAGS) -Wno-write-strings -D_FILE_OFFSET_BITS=64 -DDROP_CGAL -I. -Iexternal -Iexternal/tcl
|
---|
[1097] | 190 | DELPHES_LIBS = $(shell $(RC) --libs) -lEG $(SYSLIBS)
|
---|
| 191 | DISPLAY_LIBS = $(shell $(RC) --evelibs) $(SYSLIBS)
|
---|
[824] | 192 |
|
---|
[593] | 193 | ###
|
---|
| 194 |
|
---|
[1097] | 195 | DELPHES = libDelphes.$(DllSuf)
|
---|
| 196 | DELPHESLIB = libDelphes.lib
|
---|
[593] | 197 |
|
---|
[1097] | 198 | DISPLAY = libDelphesDisplay.$(DllSuf)
|
---|
| 199 | DISPLAYLIB = libDelphesDisplay.lib
|
---|
| 200 |
|
---|
[850] | 201 | VERSION = $(shell cat VERSION)
|
---|
[857] | 202 | DISTDIR = Delphes-$(VERSION)
|
---|
[851] | 203 | DISTTAR = $(DISTDIR).tar.gz
|
---|
[850] | 204 |
|
---|
[593] | 205 | all:
|
---|
| 206 |
|
---|
| 207 | }
|
---|
| 208 |
|
---|
| 209 | executableDeps
|
---|
| 210 |
|
---|
[1097] | 211 | dictDeps {DELPHES_DICT} {classes/*LinkDef.h} {modules/*LinkDef.h} {external/ExRootAnalysis/*LinkDef.h}
|
---|
[593] | 212 |
|
---|
[1097] | 213 | dictDeps {DISPLAY_DICT} {display/*LinkDef.h}
|
---|
[593] | 214 |
|
---|
[1097] | 215 | sourceDeps {DELPHES} {classes/*.cc} {modules/*.cc} {external/ExRootAnalysis/*.cc} {external/fastjet/*.cc} {external/fastjet/tools/*.cc} {external/fastjet/plugins/*/*.cc}
|
---|
| 216 |
|
---|
| 217 | sourceDeps {DISPLAY} {display/*.cc}
|
---|
| 218 |
|
---|
[593] | 219 | tclDeps
|
---|
| 220 |
|
---|
| 221 | headerDeps
|
---|
| 222 |
|
---|
| 223 | puts {
|
---|
| 224 |
|
---|
| 225 | ###
|
---|
| 226 |
|
---|
[1097] | 227 | all: $(DELPHES) $(EXECUTABLE)
|
---|
[593] | 228 |
|
---|
[1097] | 229 | display: $(DISPLAY)
|
---|
| 230 |
|
---|
| 231 | $(DELPHES): $(DELPHES_DICT_OBJ) $(DELPHES_OBJ) $(TCL_OBJ)
|
---|
[593] | 232 | @mkdir -p $(@D)
|
---|
| 233 | @echo ">> Building $@"
|
---|
| 234 | ifeq ($(ARCH),aix5)
|
---|
[1097] | 235 | @$(MAKESHARED) $(OutPutOpt) $@ $(DELPHES_LIBS) -p 0 $^
|
---|
[593] | 236 | else
|
---|
| 237 | ifeq ($(PLATFORM),macosx)
|
---|
| 238 | # We need to make both the .dylib and the .so
|
---|
[1097] | 239 | @$(LD) $(SOFLAGS)$@ $(LDFLAGS) $^ $(OutPutOpt) $@ $(DELPHES_LIBS)
|
---|
[743] | 240 | ifneq ($(subst $(MACOSX_MINOR),,1234),1234)
|
---|
| 241 | ifeq ($(MACOSX_MINOR),4)
|
---|
| 242 | @ln -sf $@ $(subst .$(DllSuf),.so,$@)
|
---|
| 243 | endif
|
---|
| 244 | endif
|
---|
[593] | 245 | else
|
---|
| 246 | ifeq ($(PLATFORM),win32)
|
---|
| 247 | @bindexplib $* $^ > $*.def
|
---|
[1097] | 248 | @lib -nologo -MACHINE:IX86 $^ -def:$*.def $(OutPutOpt)$(DELPHESLIB)
|
---|
| 249 | @$(LD) $(SOFLAGS) $(LDFLAGS) $^ $*.exp $(DELPHES_LIBS) $(OutPutOpt)$@
|
---|
[593] | 250 | @$(MT_DLL)
|
---|
| 251 | else
|
---|
[1097] | 252 | @$(LD) $(SOFLAGS) $(LDFLAGS) $^ $(OutPutOpt) $@ $(DELPHES_LIBS)
|
---|
[593] | 253 | @$(MT_DLL)
|
---|
| 254 | endif
|
---|
| 255 | endif
|
---|
| 256 | endif
|
---|
| 257 |
|
---|
[1097] | 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)
|
---|
| 280 | @$(MT_DLL)
|
---|
| 281 | endif
|
---|
| 282 | endif
|
---|
| 283 | endif
|
---|
| 284 |
|
---|
[593] | 285 | clean:
|
---|
[1097] | 286 | @rm -f $(DELPHES_DICT_OBJ) $(DISPLAY_DICT_OBJ) $(DELPHES_OBJ) $(DISPLAY_OBJ) $(TCL_OBJ) core
|
---|
| 287 | @rm -rf tmp
|
---|
[593] | 288 |
|
---|
| 289 | distclean: clean
|
---|
[1097] | 290 | @rm -f $(DELPHES) $(DELPHESLIB) $(DISPLAY) $(DISPLAYLIB) $(EXECUTABLE)
|
---|
[593] | 291 |
|
---|
[850] | 292 | dist:
|
---|
[851] | 293 | @echo ">> Building $(DISTTAR)"
|
---|
[850] | 294 | @mkdir -p $(DISTDIR)
|
---|
[1113] | 295 | @cp -a CREDITS README VERSION Makefile configure classes converters display doc examples external modules python readers $(DISTDIR)
|
---|
[851] | 296 | @find $(DISTDIR) -depth -name .\* -exec rm -rf {} \;
|
---|
| 297 | @tar -czf $(DISTTAR) $(DISTDIR)
|
---|
[850] | 298 | @rm -rf $(DISTDIR)
|
---|
| 299 |
|
---|
[593] | 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 |
|
---|
[1097] | 314 | $(DELPHES_OBJ): tmp/%.$(ObjSuf): %.$(SrcSuf)
|
---|
[593] | 315 | @mkdir -p $(@D)
|
---|
| 316 | @echo ">> Compiling $<"
|
---|
| 317 | @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@
|
---|
| 318 |
|
---|
[1097] | 319 | $(DISPLAY_OBJ): tmp/%.$(ObjSuf): %.$(SrcSuf)
|
---|
[593] | 320 | @mkdir -p $(@D)
|
---|
| 321 | @echo ">> Compiling $<"
|
---|
| 322 | @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@
|
---|
| 323 |
|
---|
[1097] | 324 | $(DELPHES_DICT_OBJ): %.$(ObjSuf): %.$(SrcSuf)
|
---|
| 325 | @mkdir -p $(@D)
|
---|
| 326 | @echo ">> Compiling $<"
|
---|
| 327 | @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@
|
---|
| 328 |
|
---|
| 329 | $(DISPLAY_DICT_OBJ): %.$(ObjSuf): %.$(SrcSuf)
|
---|
| 330 | @mkdir -p $(@D)
|
---|
| 331 | @echo ">> Compiling $<"
|
---|
| 332 | @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@
|
---|
| 333 |
|
---|
[593] | 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 |
|
---|
[1097] | 344 | $(EXECUTABLE): %$(ExeSuf): $(DELPHES_DICT_OBJ) $(DELPHES_OBJ) $(TCL_OBJ)
|
---|
[593] | 345 | @echo ">> Building $@"
|
---|
[1097] | 346 | @$(LD) $(LDFLAGS) $^ $(DELPHES_LIBS) $(OutPutOpt)$@
|
---|
[593] | 347 |
|
---|
| 348 | ###
|
---|
| 349 |
|
---|
| 350 | }
|
---|