#!/usr/bin/env tclsh set prefix "tmp/" set suffix " \\\n\t" set srcSuf {.$(SrcSuf)} set objSuf {.$(ObjSuf)} set exeSuf {$(ExeSuf)} proc dependencies {fileName firstLine {force 1} {command {}}} { global suffix headerFiles sourceFiles if {[info exists sourceFiles($fileName)]} return set sourceFiles($fileName) 1 set list {} set fid [open $fileName] while {! [eof $fid]} { set line [gets $fid] if [regexp -- {^\s*#include\s*"((\w+/)+\w+\.(h|hh))"} $line] { set elements [split $line {"}] set file [lindex $elements 1] if [file exists $file] { lappend list $file set headerFiles($file) 1 } } } if {[llength $list] > 0} { puts -nonewline $firstLine foreach file $list {puts -nonewline $suffix$file} if {$command != {}} { puts "" puts $command } puts "" } elseif {$force} { puts -nonewline $firstLine if {$command != {}} { puts "" puts $command } puts "" } close $fid } proc dictDeps {dictVar args} { global prefix suffix srcSuf objSuf set dict [eval glob -nocomplain $args] set dictSrcFiles {} set dictObjFiles {} foreach fileName $dict { regsub {LinkDef\.h} $fileName {Dict} dictName set dictName $prefix$dictName lappend dictSrcFiles $dictName$srcSuf lappend dictObjFiles $dictName$objSuf dependencies $fileName "$dictName$srcSuf:$suffix$fileName" } puts -nonewline "${dictVar} = $suffix" puts [join $dictSrcFiles $suffix] puts "" puts -nonewline "${dictVar}_OBJ = $suffix" puts [join $dictObjFiles $suffix] puts "" } proc sourceDeps {srcPrefix args} { global prefix suffix srcSuf objSuf set source [eval glob -nocomplain $args] set srcObjFiles {} foreach fileName $source { regsub {\.cc} $fileName {} srcName set srcObjName $prefix$srcName lappend srcObjFiles $srcObjName$objSuf dependencies $fileName "$srcObjName$objSuf:$suffix$srcName$srcSuf" } puts -nonewline "${srcPrefix}_OBJ = $suffix" puts [join $srcObjFiles $suffix] puts "" } proc stdhepDeps {} { global prefix suffix srcSuf objSuf set source [glob -nocomplain {Utilities/mcfio/*.c} {Utilities/stdhep/*.c}] set srcObjFiles {} foreach fileName $source { regsub {\.c} $fileName {} srcName set srcObjName $prefix$srcName lappend srcObjFiles $srcObjName$objSuf dependencies $fileName "$srcObjName$objSuf:$suffix$fileName" } puts -nonewline "STDHEP_OBJ = $suffix" puts [join $srcObjFiles $suffix] puts "" } proc stdhepExecutableDeps {} { global prefix suffix objSuf exeSuf set executable [glob -nocomplain {Delphes.cpp} {Resolutions.cpp} {Examples/Trigger_Only.cpp} {Examples/Analysis_Ex.cpp} {Examples/Frog_on_analysis_output.cpp}] set exeFiles {} foreach fileName $executable { regsub {\.cpp} $fileName {} exeObjName set exeObjName $prefix$exeObjName set exeName [file tail $exeObjName] lappend exeFiles $exeName$exeSuf lappend exeObjFiles $exeObjName$objSuf puts "$exeName$exeSuf:$suffix$exeObjName$objSuf" puts "" dependencies $fileName "$exeObjName$objSuf:$suffix$fileName" } if [info exists exeFiles] { puts -nonewline "STDHEP_EXECUTABLE = $suffix" puts [join $exeFiles $suffix] puts "" } if [info exists exeObjFiles] { puts -nonewline "STDHEP_EXECUTABLE_OBJ = $suffix" puts [join $exeObjFiles $suffix] puts "" } } proc executableDeps {args} { global prefix suffix objSuf exeSuf set executable [eval glob -nocomplain $args] set exeFiles {} foreach fileName $executable { regsub {\.cpp} $fileName {} exeObjName set exeObjName $prefix$exeObjName set exeName [file tail $exeObjName] lappend exeFiles $exeName$exeSuf lappend exeObjFiles $exeObjName$objSuf puts "$exeName$exeSuf:$suffix$exeObjName$objSuf" puts "" dependencies $fileName "$exeObjName$objSuf:$suffix$fileName" } if [info exists exeFiles] { puts -nonewline "EXECUTABLE = $suffix" puts [join $exeFiles $suffix] puts "" } if [info exists exeObjFiles] { puts -nonewline "EXECUTABLE_OBJ = $suffix" puts [join $exeObjFiles $suffix] puts "" } } proc headerDeps {} { global suffix headerFiles foreach fileName [array names headerFiles] { dependencies $fileName "$fileName:" 0 "\t@touch \$@" } } puts { # # Makefile for Delphes, a Fast Simulator for general-purpose detectors at the LHC # # Author: S. Ovyn, X. Rouby - UCL, Louvain-la-Neuve # -- inspired by P. Demin's work on ExRootAnalysis (UCL, Louvain-la-Neuve) # -- the multi-platform configuration is taken from ROOT (root/test/Makefile.arch) # include $(ROOTSYS)/test/Makefile.arch ifeq ($(ARCH),macosx64) UNDEFOPT = dynamic_lookup endif SrcSuf = cc #CXXFLAGS += $(ROOTCFLAGS) -DDROP_CGAL -Iinterface -IUtilities/CDFCones/interface -IUtilities/ExRootAnalysis/interface -IUtilities/mcfio -IUtilities/stdhep -IUtilities/Hector/include CXXFLAGS += $(ROOTCFLAGS) -DDROP_CGAL -I. -IUtilities/mcfio -IUtilities/stdhep -IUtilities/Hector/include -IUtilities/CDFCones/interface -IExamples LIBS = $(ROOTLIBS) -lEG $(SYSLIBS) GLIBS = $(ROOTGLIBS) $(SYSLIBS) ### SHARED = lib/libUtilities.$(DllSuf) lib/libHector.$(DllSuf) VERSION=$(shell cat VERSION) FOLDER=Delphes_V_$(VERSION) TARBALL=$(FOLDER).tar.gz TESTFILE=tt_jj_small.hep all: } executableDeps {*.cpp} {Examples/*.cpp} dictDeps {DICT} {Utilities/ExRootAnalysis/src/*LinkDef.h} {src/*LinkDef.h} {Examples/src/*LinkDef.h} 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} stdhepDeps headerDeps puts { ### all: $(SHARED) $(EXECUTABLE) $(STDHEP_EXECUTABLE) @echo "Delphes has been compiled" @echo "Ready to run" $(SHARED): $(DICT_OBJ) $(SOURCE_OBJ) @mkdir -p $(@D) @echo ">> Building $@" ifeq ($(ARCH),aix) @/usr/ibmcxx/bin/makeC++SharedLib $(OutPutOpt) $@ $(LIBS) -p 0 $^ else ifeq ($(ARCH),aix5) @/usr/vacpp/bin/makeC++SharedLib $(OutPutOpt) $@ $(LIBS) -p 0 $^ else ifeq ($(PLATFORM),macosx) # We need to make both the .dylib and the .so @$(LD) $(SOFLAGS) $^ $(OutPutOpt) $@ @$(LD) -bundle -undefined $(UNDEFOPT) $(LDFLAGS) $^ $(LIBS) $(OutPutOpt) $(subst .$(DllSuf),.so,$@) else ifeq ($(PLATFORM),win32) @bindexplib $* $^ > $*.def @lib -nologo -MACHINE:IX86 $^ -def:$*.def $(OutPutOpt)$(EVENTLIB) @$(LD) $(SOFLAGS) $(LDFLAGS) $^ $*.exp $(LIBS) $(OutPutOpt)$@ @$(MT_DLL) else @$(LD) $(SOFLAGS) $(LDFLAGS) $^ $(OutPutOpt) $@ $(EXPLLINKLIBS) @$(MT_DLL) endif endif endif endif clean: @rm -f $(DICT_OBJ) $(SOURCE_OBJ) $(STDHEP_OBJ) core distclean: clean @rm -f $(SHARED) $(EXECUTABLE) $(STDHEP_EXECUTABLE) *vis *geom @rm -rf tmp ### .SUFFIXES: .$(SrcSuf) .$(ObjSuf) .$(DllSuf) %Dict.$(SrcSuf): @mkdir -p $(@D) @echo ">> Generating $@" @rootcint -f $@ -c $< @echo "#define private public" > $@.arch @echo "#define protected public" >> $@.arch @mv $@ $@.base @cat $@.arch $< $@.base > $@ @rm $@.arch $@.base $(SOURCE_OBJ): tmp/%.$(ObjSuf): %.$(SrcSuf) @mkdir -p $(@D) @echo ">> Compiling $<" @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@ $(DICT_OBJ): %.$(ObjSuf): %.$(SrcSuf) @mkdir -p $(@D) @echo ">> Compiling $<" @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@ $(STDHEP_OBJ): tmp/%.$(ObjSuf): %.c @mkdir -p $(@D) @echo ">> Compiling $<" @gcc $(CXXFLAGS) -c $< $(OutPutOpt)$@ $(STDHEP_EXECUTABLE_OBJ): tmp/%.$(ObjSuf): %.cpp @mkdir -p $(@D) @echo ">> Compiling $<" @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@ $(EXECUTABLE_OBJ): tmp/%.$(ObjSuf): %.cpp @mkdir -p $(@D) @echo ">> Compiling $<" @$(CXX) $(CXXFLAGS) -c $< $(OutPutOpt)$@ $(EXECUTABLE): %$(ExeSuf): $(DICT_OBJ) $(SOURCE_OBJ) $(STDHEP_OBJ) @echo ">> Building $@" @$(LD) $(LDFLAGS) $^ $(LIBS) $(OutPutOpt)$@ ### tar $(TARBALL): @echo Building tarball of sources @mkdir $(FOLDER) @rsync -qavztup --exclude=CVS* CREDITS README VERSION FAQ Delphes.cpp Resolutions.cpp Makefile rootlogon.C genMakefile.tcl interface lib routines src data Examples Utilities $(FOLDER) @rm -f $(FOLDER)/$(SHARED) @rm -f $(FOLDER)/Utilities/FROG/Lib/*.o @rm -f $(FOLDER)/Utilities/FROG/Lib/libfrog.* @tar czf $(TARBALL) $(FOLDER) @rm -rf $(FOLDER) @mkdir $(FOLDER) @cp tt_jj_small.hep TEST_small_tt.list $(FOLDER) @tar czf $(TESTFILE).tar.gz $(FOLDER) @rm -rf $(FOLDER) @echo Done : `ls $(TARBALL) $(TESTFILE).tar.gz` }