PACKAGE = PackageName #flags needed for the compilation ROOTCFLAGS := $(shell root-config --cflags) ROOTLIBS := $(shell root-config --libs) LINKLIBSIN = -L$(shell root-config --libdir) -lCore -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lGui -lRooStats -lRooFit -lHistFactory -lXMLParser -pthread -lRooFitCore -lm -ldl -lFoam -lMinuit -Llib INCLUDES += -IPackage -I$(shell root-config --incdir) CXX = g++ LD = g++ CXXFLAGS = -O2 -Wall -fPIC -std=c++17 LDFLAGS = -O2 SOFLAGS = -shared DICTHEAD = $(PACKAGE)_Dict.h DICTFILE = $(PACKAGE)_Dict.cxx DICTOBJ = $(PACKAGE)_Dict.o DICTLDEF = Root/LinkDef.h LIBFILE = lib/lib$(PACKAGE).so ROOTMAPFILE = lib/lib$(PACKAGE).rootmap CPPLIST = $(wildcard Root/*.cxx) # MACROLIST = $(wildcard util/*.cxx) HLIST = $(wildcard Package/*.h) OBJDIR = obj OLIST = $(patsubst %.cxx,%.o,$(CPPLIST)) OBJLIST = $(addprefix $(OBJDIR)/,$(notdir $(OLIST))) # BINLIST = $(patsubst %.cxx,%,$(MACROLIST)) .PHONY: all clean all: $(LIBFILE) # Implicit rule to compile all classes $(OBJDIR)/%.o : Root/%.cxx @echo "Compiling $<" @mkdir -p $(OBJDIR) @$(CXX) $(CXXFLAGS) -g -c $< -o $(OBJDIR)/$(notdir $@) $(INCLUDES) # ROOT6 rule to make the dictionary $(DICTFILE): $(HLIST) $(DICTLDEF) @echo "Generating dictionary $@" @$(ROOTSYS)/bin/rootcling -f $(DICTFILE) -s $(LIBFILE) -rml lib$(PACKAGE).so -rmf $(ROOTMAPFILE) -c $(INCLUDES) $^ $(OBJDIR)/$(DICTOBJ): $(DICTFILE) @echo "Compiling $<" @mkdir -p $(OBJDIR) @$(CXX) $(CXXFLAGS) -g -c $(INCLUDES) -o $@ $< # Rule to combine objects into a unix shared library $(LIBFILE): $(OBJLIST) $(OBJDIR)/$(DICTOBJ) @echo "Making shared library: $(LIBFILE)" @rm -f $(LIBFILE) @$(LD) $(CXXFLAGS) $(SOFLAGS) $(OBJLIST) $(OBJDIR)/$(DICTOBJ) -o $(LIBFILE) $(LINKLIBSIN) clean: @echo "Cleaning lib/ and obj/" @rm -rf lib/* obj/*