#------------------------------------------------------------------------------ # MAKEFILE : Viewing events software #------------------------------------------------------------------------------ #------------------------------------------------------------------------------ # Documentation @: # 1) http://root.cern.ch/root/CintGenerator.html # 2) http://root.cern.ch/root/Using.html # 3) ftp://root.cern.ch/root/doc/ROOTUsersGuideHTML/ch25s04.html # + remember to add VIEW_PATH and VIEW_LIB (path for the shared libraries you are # going to create) in .bashrc #------------------------------------------------------------------------------ # #------------------------------------------------------------------------------ # Defining the directory structure and some flags. #------------------------------------------------------------------------------ # # Compiler to be used. CC = g++ # Flags CPPFLAGS = -fPIC -Wall # Directories of the library. VIEW_SRC = $(VIEW_PATH)/src VIEW_OBJ = $(VIEW_PATH)/obj VIEW_INC = $(VIEW_PATH)/inc VIEW_LIB = $(VIEW_PATH)/lib VIEW_DICT = $(VIEW_PATH)/dict # Directories to be included. INC_DIRS = -I$(VIEW_INC) -I$(ROOTSYS)/include #INC_DIRS = -I$(ROOTSYS)/include #libraries to linked ROOTCFLAGS = $(shell root-config --cflags) ROOTLIBS = $(shell root-config --libs) ROOTGLIBS = $(shell root-config --glibs) # Classes and objects of the library CLASSES = TCustomizedBrowser CLASS_DICT = TCustomizedBrowser OBJS = $(CLASSES:=.o) OBJS_DICT = $(CLASS_DICT:=.h) # Main program to be linked to the shared library PROGS = Event_Signals PROGS_OUT = $(PROGS:=.out) #------------------------------------------------------------------------------ # Defining the compiling targets. #------------------------------------------------------------------------------ all: WelcomeMessage dictionary library exe #------------------------------------------------------------------------------ # Easy case: # try: Event_Signals.C # $(CC) $(CPPFLAGS) $(INC_DIRS) $(ROOTLIBS) -lm -ldl -rdynamic Event_Signals.C -o launch #------------------------------------------------------------------------------ # Wellcome message. #------------------------------------------------------------------------------ WelcomeMessage: @echo -e "\033[40m\033[0;1;32m ------------------------------ \033[0m" @echo -e "\033[40m\033[0;1;32m Library Makefile \033[0m" @echo -e "\033[40m\033[0;1;32m Version 1: 20th Septemb 2013 \033[0m" @echo -e "\033[40m\033[0;1;32m ------------------------------ \033[0m" @echo -e "\033[47m\033[0;1;33m ------------------------------ \033[0m" @echo -e "\033[47m\033[0;1;33m F. Belloni \033[0m" @echo -e "\033[47m\033[0;1;33m francescabelloni@gmail.com \033[0m" @echo -e "\033[47m\033[0;1;33m ------------------------------ \033[0m" #------------------------------------------------------------------------------ # Generate objects #------------------------------------------------------------------------------ %.o: $(VIEW_SRC)/%.cxx $(VIEW_INC)/%.h @echo -e "\033[40m\033[0;31m Compiling" $(@:.o=) " ........\033[0m" # # @$(CC) $(CPPFLAGS) $(ROOTLIBS) -lm -ldl -rdynamic -c $(INC_DIRS) -o $(VIEW_OBJ)/$@ $< @$(CC) $(CPPFLAGS) -c $(INC_DIRS) -o $(VIEW_OBJ)/$@ $< #------------------------------------------------------------------------------ # Generate a dictionary ( = include the classes you built in ROOT). # The command rootcint will generate both a *.cxx and *.h # After that you need to create an object out of the dictionary (line $(CC)..) #------------------------------------------------------------------------------ # dictionary: @echo -e "\033[40m\033[0;34m Generating dictionary ........\033[0m" cd $(VIEW_INC);\ rootcint -f TTrialDictionary.cxx -c $(OBJS_DICT) mv $(VIEW_INC)/TTrialDictionary.cxx $(VIEW_DICT)/TTrialDictionary.cxx mv $(VIEW_INC)/TTrialDictionary.h $(VIEW_DICT)/TTrialDictionary.h cd $(VIEW_DICT);\ $(CC) $(CPPFLAGS) -c $(INC_DIRS) -o $(VIEW_OBJ)/TTrialDictionary.o TTrialDictionary.cxx #------------------------------------------------------------------------------ # Generate a shared library containing the object created from your own classes # through the rule %.o and the dictionary you created #------------------------------------------------------------------------------ # library: $(OBJS) @echo -e "\033[40m\033[0;34m Linking library test \033[0m" @cd $(VIEW_OBJ); \ g++ -shared $(CPPFLAGS) -o $(VIEW_LIB)/libtry.so $^ TTrialDictionary.o #------------------------------------------------------------------------------ # Generate the executable #------------------------------------------------------------------------------ exe: @echo -e "\033[40m\033[0;32m Linking" $(@:.out=) "........\033[0m" @g++ $(CPPFLAGS) $(ROOTCFLAGS) $(ROOTLIBS) $(ROOTGLIBS) -o bin/Event_Signals -I$(ROOTSYS)/include -I$(VIEW_INC) -L$(ROOTSYS)/lib -L$(VIEW_LIB) Event_Signals.C -lCore -lCint -lMatrix -ltry -lGui -lHist -lTree -lGraf -lMinuit -lPhysics -lGpad -lGeom -ldl -lGraf3d #------------------------------------------------------------------------------ # Documentation. #------------------------------------------------------------------------------ # gendoc: # @echo -e "\033[40m\033[0;31m Generating documentation ........\033[0m" # @doxygen doc.dox # #------------------------------------------------------------------------------ # Object generation of each class. #------------------------------------------------------------------------------ # @echo -e "\033[40m\033[0;31m Compiling" $(@:.o=) " ........\033[0m" # @$(CC) $(CPPFLAGS) -c $(INC_DIRS) -o $(REST_OBJ)/$@ $< #------------------------------------------------------------------------------ # Cleaning. #------------------------------------------------------------------------------ clean: @echo -e "\033[40m\033[0;34m Removing objects ........\033[0m" @rm $(VIEW_OBJ)/*.o @rm $(VIEW_DICT)/*.cxx @rm $(VIEW_DICT)/*.h @rm $(VIEW_LIB)/libtry.so #------------------------------------------------------------------------------