Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:47:00

0001 #
0002 # Makefile for MusEcal
0003 #
0004 # To link with other packages, add:
0005 #
0006 # CXXFLAGS   += -I${ANOTHERPKG}/src ... 
0007 # ROOTGLIBS  += -lRooFitCore -lRooFit
0008 # ROOTGLIBS  += -L${ANOTHERPKG}/lib -lANOTHERPKG
0009 # ...
0010 
0011 PKGNAME := MusEcal
0012 
0013 MusEcal := .
0014 
0015 ### global options
0016 
0017 # Architecture
0018 ARCH         := $(shell root-config --arch)
0019 
0020 # File suffixes
0021 OBJSUFFIX  := o
0022 DEPSUFFIX  := d
0023 DLLSUFFIX  := so
0024 
0025 # File directories
0026 OBJDIR     := .o
0027 DEPDIR     := .d
0028 BINDIR     := $(MusEcal)/bin
0029 
0030 # output directories
0031 SOLIBDIR   := $(MusEcal)/lib
0032 SOLIB      := $(SOLIBDIR)/lib$(PKGNAME).$(DLLSUFFIX)
0033 
0034 __dummy := $(shell mkdir -p $(OBJDIR) $(DEPDIR) $(BINDIR) $(SOLIBDIR))
0035 
0036 ### compilator, linker, flags and options
0037 CXX        := g++
0038 LD         := g++
0039 OUTPUTOPT  := -o
0040 OPTFLAGS   := -g -O2 -Wall -fPIC -Wno-deprecated
0041 CXXFLAGS   := $(OPTFLAGS)
0042 LDFLAGS    := -shared
0043 LIBS       :=
0044 
0045 # Architecture dependant options
0046 -include $(ARCH).mk
0047 
0048 
0049 ### processing of the modules
0050 # find the modules to include and compile
0051 MODULES    := $(subst /module.mk,,$(wildcard */module.mk))
0052 
0053 __dummy := $(shell ./genmak.sh $(MODULES))
0054 
0055 all: lib prog
0056 
0057 # the source files to compile (without suffix)
0058 SRC        :=
0059 PROG       :=
0060 PROGSRC    :=
0061 #VPATH      :=
0062 
0063 -include gen.mk
0064 
0065 ### build targets and include path for compilation
0066 OBJS       := $(addprefix ${OBJDIR}/, $(addsuffix .$(OBJSUFFIX), $(SRC)))
0067 DEPS       := $(addprefix ${DEPDIR}/, $(addsuffix .$(DEPSUFFIX), $(SRC)))
0068 DEPS       += $(addprefix ${DEPDIR}/, $(addsuffix .$(DEPSUFFIX), $(PROGSRC)))
0069 CXXFLAGS   += -I. -I.. -I${MECore}/src $(patsubst %, -I%, $(MODULES))
0070 
0071 ### External libraries
0072 # ROOT
0073 ROOTCFLAGS := $(shell root-config --cflags)
0074 # add CMSSW library path to link to proper libraries...
0075 CMSSW_LIBS  = -L$(subst :, -L, $(LD_LIBRARY_PATH) ) -L/lib
0076 CMSSW_LIBS_PARSED= $(subst ;,, $(CMSSW_LIBS) )
0077 ROOTGLIBS  := $(CMSSW_LIBS_PARSED)
0078 ROOTGLIBS  += $(shell root-config --glibs) -lMinuit -lHtml -lEG -lThread
0079 #ROOTGLIBS  += -L${MECore}/lib -lMECore
0080 ROOTGLIBS  += -lCalibCalorimetryEcalLaserAnalyzer
0081 
0082 # add possible new dependencies
0083 # -lMinuit2
0084 #ROOTGLIBS  += -L../HAF/lib -lHAF
0085 #ROOTGLIBS  += -L../DataFormats/lib -lCandidate
0086 
0087 ROOTCINT   := rootcint
0088 CXXFLAGS   += $(ROOTCFLAGS)
0089 LIBS       += $(ROOTGLIBS) 
0090 
0091 # libxml2
0092 #CXXFLAGS   += $(shell xml2-config --cflags)
0093 #LIBS       += $(shell xml2-config --libs)
0094 
0095 ### Rules
0096 .PHONY: all clean
0097 
0098 .PRECIOUS: ${OBJDIR}/%.bin %SK.cc %.hh
0099 
0100 lib: $(SOLIB)
0101 
0102 prog: $(PROG)
0103 
0104 #gen.mk dictgen.mk: $(MODULES)
0105 #       ./genmak.sh $(MODULES)
0106 
0107 # the main library rule
0108 $(SOLIB): $(OBJS)
0109         @echo "Linking $^"
0110         @$(LD) $(LDFLAGS) $^ $(LIBS) $(FLIBS) $(OUTPUTOPT) $@
0111         @echo "Successfully completed $@"
0112 
0113 -include dictgen.mk
0114 
0115 cleanAll:
0116         @echo "Cleaning up..."
0117         @echo $(DEPS)
0118         @echo $(OBJS)
0119         @echo $(SOLIB)
0120         @echo $(PROG)
0121         @echo $(PROGSRC)
0122 
0123 # clean rule
0124 clean:
0125         @echo "Cleaning up..."
0126         @echo $(DEPS)
0127         @echo $(OBJS)
0128         @echo $(SOLIB)
0129         @rm -f $(DEPS) $(OBJS) $(SOLIB) $(foreach i,$(MODULES),$(i)/dict_$(i).*) gen.mk dictgen.mk
0130 
0131 ######
0132 
0133 # .o building rules
0134 ${OBJDIR}/%.$(OBJSUFFIX) : %.cxx ${DEPDIR}/%.$(DEPSUFFIX)
0135         @echo "Compiling $<"
0136         @$(CXX) $(CXXFLAGS) -c $< -o $@
0137 
0138 ${OBJDIR}/%.$(OBJSUFFIX) : %.cpp ${DEPDIR}/%.$(DEPSUFFIX)
0139         @echo "Compiling $<"
0140         @$(CXX) $(CXXFLAGS) -c $< -o $@
0141 
0142 ${OBJDIR}/%.$(OBJSUFFIX) : %.cc ${DEPDIR}/%.$(DEPSUFFIX)
0143         @echo "Compiling $<"
0144         @$(CXX) $(CXXFLAGS) -c $< -o $@
0145 
0146 # .d building rules
0147 ${DEPDIR}/%.$(DEPSUFFIX): %.cxx
0148 #       @echo "Making $@"
0149         @$(CXX) -MM $(CXXFLAGS) $< \
0150         | sed 's|\('`basename $*`'\)\.o[ :]*|'$(OBJDIR)'/'`dirname $*`'/\1.o '$(DEPDIR)'/'`dirname $*`'/\1.d : |g' \
0151         > $@
0152 
0153 ${DEPDIR}/%.$(DEPSUFFIX): %.cpp
0154 #       @echo "Making $@"
0155         @$(CXX) -MM $(CXXFLAGS) $< \
0156         | sed 's|\('`basename $*`'\)\.o[ :]*|'$(OBJDIR)'/'`dirname $*`'/\1.o '$(DEPDIR)'/'`dirname $*`'/\1.d : |g' \
0157         > $@
0158 
0159 ${DEPDIR}/%.$(DEPSUFFIX): %.cc
0160 #       @echo "Making $@"
0161         @$(CXX) -MM $(CXXFLAGS) $< \
0162         | sed 's|\('`basename $*`'\)\.o[ :]*|'$(OBJDIR)'/'`dirname $*`'/\1.o '$(DEPDIR)'/'`dirname $*`'/\1.d : |g' \
0163         > $@
0164 
0165 # .bin building rules
0166 ${OBJDIR}/%.bin: ${OBJDIR}/%.$(OBJSUFFIX) | $(SOLIB)
0167         @echo "Making $<"
0168         @$(CXX) $(CXXFLAGS) $(LIBS) -L$(SOLIBDIR) -l$(PKGNAME) $^ -o $@
0169 
0170 ifneq ($(MAKECMDGOALS),clean)
0171 -include $(DEPS)
0172 endif
0173