| 1 | 
  | 
 # PamelaDigitizer | 
| 2 | 
  | 
 # SOFTWARE VERSION | 
| 3 | 
  | 
 VER= v3r03 | 
| 4 | 
  | 
 # An almost general purpouse Makefile for PAMELA repository | 
| 5 | 
  | 
 # Let's start with some useful definition to make the echo colored | 
| 6 | 
  | 
 RED='\E[1;31;40m' | 
| 7 | 
  | 
 GREEN='\E[1;32;40m' | 
| 8 | 
  | 
 YELLOW='\E[1;33;40m' | 
| 9 | 
  | 
 BLUE='\E[1;34;40m' | 
| 10 | 
  | 
 WHITE='\E[1;37;40m' | 
| 11 | 
  | 
 VIOLET='\E[1;35;40m' | 
| 12 | 
  | 
 CYAN='\E[1;36;40m' | 
| 13 | 
  | 
 # Here the echo definition to use them | 
| 14 | 
  | 
 EVIOLET=echo -e ${VIOLET} | 
| 15 | 
  | 
 ECYAN=echo -e ${CYAN} | 
| 16 | 
  | 
 ERED=echo -e ${RED} | 
| 17 | 
  | 
 EGREEN=echo -e ${GREEN} | 
| 18 | 
  | 
 EYELLOW=echo -e ${YELLOW} | 
| 19 | 
  | 
 EBLUE=echo -e ${BLUE} | 
| 20 | 
  | 
 EWHITE=echo -e ${WHITE} | 
| 21 | 
  | 
 # Reset the terminal | 
| 22 | 
  | 
 RESET=tput sgr0 | 
| 23 | 
  | 
 # Here the variables used to override the standard make flags | 
| 24 | 
  | 
 #MAKE | 
| 25 | 
  | 
 MAKE=make  | 
| 26 | 
  | 
 # C | 
| 27 | 
  | 
 CC=gcc | 
| 28 | 
  | 
 #CFLAGS=-Wall -O -fPIC -pthread -g ${PAM_BIT} | 
| 29 | 
  | 
 CFLAGS=-Wall -O -fPIC -pthread ${PAM_BIT} | 
| 30 | 
  | 
 # Enviroment: | 
| 31 | 
  | 
 GCCVER=`gcc --version | head -1` | 
| 32 | 
  | 
 UNAMEA=`uname -a` | 
| 33 | 
  | 
 TODAY=`date` | 
| 34 | 
  | 
 # F77 | 
| 35 | 
  | 
 F77=g77 | 
| 36 | 
  | 
 #F77FLAGS=  -Wall -Wno-globals -fvxt -fno-automatic -fbounds-check -g -extend_source  -static -fno-backslash ${PAM_BIT} | 
| 37 | 
  | 
 F77FLAGS=  -Wall -Wno-globals -fvxt -fno-automatic -fbounds-check -extend_source -static -fno-backslash ${PAM_BIT} | 
| 38 | 
  | 
 # C++ | 
| 39 | 
  | 
 CXX=g++ | 
| 40 | 
  | 
 # ROOTCINT | 
| 41 | 
  | 
 ROOTCINT=rootcint | 
| 42 | 
  | 
  | 
| 43 | 
 # Compilers settings | 
 # Compilers settings | 
| 44 | 
 ROOTCFLAGS  =`root-config --cflags` | 
 ROOTCFLAGS  =`root-config --cflags` | 
| 45 | 
 ROOTLDFLAGS =`root-config --ldflags` | 
 ROOTLDFLAGS =`root-config --ldflags`  | 
| 46 | 
 ROOTLIBS    =`root-config --libs` -lHbook | 
 ROOTLIBS    =`root-config --libs` -lHbook | 
| 47 | 
 CERNLIBS    =`cernlib_noshift kernlib,packlib,genlib` | 
 #CERNLIBS    =`cernlib_noshift kernlib,packlib,genlib` | 
| 48 | 
  | 
 CERNLIBS    = | 
| 49 | 
 F77LIBS     =-lg2c -lnsl | 
 F77LIBS     =-lg2c -lnsl | 
| 50 | 
 SYSLIBS     =-lm -ldl -rdynamic | 
 SYSLIBS     =-lm -ldl -rdynamic | 
| 51 | 
 LD          =g++ | 
 LD          =g++ | 
| 52 | 
 CXXFLAGS=-g -O -Wall -fPIC ${ROOTCFLAGS} | 
 CXXFLAGS= -O3 -Wall -fPIC ${ROOTCFLAGS} ${PAM_BIT} | 
| 53 | 
 #CXXFLAGS= -g -Wall -O ${ROOTCFLAGS} | 
 #CXXFLAGS= -g -Wall -O ${ROOTCFLAGS} ${PAM_BIT} | 
 | 
 LDFLAGS = -g | 
  | 
| 54 | 
 # flags needed on the pamelatov's: | 
 # flags needed on the pamelatov's: | 
| 55 | 
 #LDFLAGS = -g -lmathlib -lpacklib -lkernlib -llapack -lg2c -lm -lnsl -lcrypt -L/cern/2005/lib | 
  | 
| 56 | 
  | 
 #LDFLAGS = $(PAM_BIT) -g -lmathlib -lpacklib -lkernlib -llapack -lg2c -lm -lnsl -lcrypt -L/cern/2005/lib | 
| 57 | 
  | 
 #LDFLAGS = -g -llapack -lg2c -lm -lnsl -lcrypt -L/cern/2005/lib | 
| 58 | 
  | 
 LDFLAGS = $(PAM_BIT) $(CERNLIBS) | 
| 59 | 
  | 
 #LDFLAGS = -lmathlib -lpacklib -lkernlib -llapack -lg2c -lm -lnsl -lcrypt -L/cern/2005/lib $(PAM_BIT) | 
| 60 | 
  | 
  | 
| 61 | 
  | 
 #LDFLAGS = -g -llapack -lg2c -lm -lnsl -lcrypt -L/cern/2005/lib $(PAM_BIT) | 
| 62 | 
  | 
  | 
| 63 | 
  | 
 CXXSRCS=  Digitizer.cxx DigitizeRunHeader.cxx DigitizeCalo.cxx DigitizeTOF.cxx DigitizeAC.cxx DigitizeS4.cxx DigitizeND.cxx  Write.cxx DigitizeTRK.cxx Pamelagp2Digits.cxx DigitVersion.cxx | 
| 64 | 
  | 
 OBJS=$(CXXSRCS:%.cxx=%.o) | 
| 65 | 
  | 
  | 
| 66 | 
  | 
 CPPSRCS= CRC.cpp calcrc.cpp  | 
| 67 | 
  | 
 CPOBJS=$(CPPSRCS:%.cpp=%.o) | 
| 68 | 
  | 
  | 
| 69 | 
 HEAS =$(SRCS:.cpp=.h) | 
 HEAS =$(SRCS:.cpp=.h) | 
| 70 | 
 OBJS =$(SRCS:.cpp=.o) | 
 #OBJS =$(SRCS:.cpp=.o) | 
| 71 | 
 DEPS =$(SRCS:.cpp=.d) | 
 DEPS =$(SRCS:.cpp=.d) | 
| 72 | 
 CLAS =$(DICS:.cpp= ) | 
 CLAS =$(DICS:.cpp= ) | 
| 73 | 
 CLASH=$(DICS:.cpp=.h) | 
 CLASH=$(DICS:.cpp=.h) | 
| 75 | 
 DICO =$(addsuffix Dict.o, ${CLAS}) | 
 DICO =$(addsuffix Dict.o, ${CLAS}) | 
| 76 | 
 DICH =$(addsuffix Dict.h, ${CLAS}) | 
 DICH =$(addsuffix Dict.h, ${CLAS}) | 
| 77 | 
  | 
  | 
| 78 | 
 all: Pamelagp2Digits  | 
 all: prepare libs Pamelagp2Digits | 
| 79 | 
  | 
         @echo -e ${GREEN} "" | 
| 80 | 
  | 
         @(${EGREEN} " Finished, now you can install the package \n  (use: make install) "; ${RESET}) | 
| 81 | 
 Pamelagp2Digits:  CRC.o calcrc.o Pamelagp2Digits.o Digitizer.o ${OBJS} ${DICO} | 
         @echo -e ${GREEN} "" | 
| 82 | 
         $(LD) $(LDFLAGS) -o $@ $^ ${ROOTLIBS} ${CERNLIBS} ${F77LIBS} ${SYSLIBS} ${PAM_LIB}/libGLTables.so ${PAM_LIB}/libsgp4.so ${PAM_YODA}/lib/libyoda.so  | 
         @${RESET} | 
| 83 | 
  | 
  | 
| 84 | 
  | 
 prepare: mkverpath | 
| 85 | 
  | 
  | 
| 86 | 
  | 
 libs: $(CPOBJS) ${OBJS} ${DICO} | 
| 87 | 
  | 
  | 
| 88 | 
  | 
  | 
| 89 | 
  | 
 #Pamelagp2Digits: DigitVersion.o CRC.o calcrc.o Pamelagp2Digits.o Digitizer.o DigitizeRunHeader.o DigitizeCalo.o DigitizeTOF.o DigitizeAC.o DigitizeS4.o DigitizeND.o  Write.o DigitizeTRK.o ${OBJS} ${DICO}  | 
| 90 | 
  | 
 Pamelagp2Digits:  | 
| 91 | 
  | 
         @(${EWHITE} " Compiling Pamelagp2Digits... \n ") | 
| 92 | 
  | 
         @ $(LD) $(LDFLAGS) -o $@ $^ ${ROOTLIBS} ${CERNLIBS} ${F77LIBS} ${SYSLIBS} ${PAM_LIB}/libGLTables.so ${PAM_LIB}/libsgp4.so ${PAM_YODA}/lib/libyoda.so ${OBJS} $(CPOBJS) | 
| 93 | 
  | 
         @rm -f *.o | 
| 94 | 
  | 
  | 
| 95 | 
 Digitizer: Digitizer.o ${OBJS} ${DICO} | 
 Digitizer: Digitizer.o ${OBJS} ${DICO} | 
| 96 | 
         $(LD) $(LDFLAGS) -o $@ $^ ${ROOTLIBS} ${CERNLIBS} ${F77LIBS} ${SYSLIBS}  | 
         $(LD) $(LDFLAGS) -o $@ $^ ${ROOTLIBS} ${CERNLIBS} ${F77LIBS} ${SYSLIBS} | 
| 97 | 
  | 
  | 
| 98 | 
 depend: ${DEPS} | 
 depend: ${DEPS} | 
| 99 | 
  | 
  | 
| 100 | 
 %.d: %.cpp | 
  | 
| 101 | 
  | 
 %.d: %.cxx | 
| 102 | 
         @echo Creating dependencies for $<  | 
         @echo Creating dependencies for $<  | 
| 103 | 
         @$(CXX) -MM $(CXXFLAGS) $< -o $@ | 
         @$(CXX) -MM $(CXXFLAGS) $< -o $@ | 
| 104 | 
  | 
  | 
 | 
  | 
  | 
 | 
  | 
  | 
| 105 | 
 .SUFFIXES: .cxx | 
 .SUFFIXES: .cxx | 
| 106 | 
 .cxx.o: | 
 %.o: %.cxx | 
| 107 | 
         $(CXX) $(CXXFLAGS) -c $< `root-config --cflags` -I${PAM_YODA}/include/yoda/ -I${PAM_INC}/ | 
         @(${EGREEN} "Creating CXX object file: "${WHITE} "`basename $@`"; ${RESET}) | 
| 108 | 
  | 
         @$(CXX) $(CXXFLAGS) -c $< `root-config --cflags` -I${PAM_YODA}/include/yoda/ -I${PAM_INC}/ | 
| 109 | 
  | 
  | 
| 110 | 
  | 
 .SUFFIXES: .cpp | 
| 111 | 
  | 
 %.o: %.cpp | 
| 112 | 
  | 
         @(${EGREEN} "Creating CPP object file: "${WHITE} "`basename $@`"; ${RESET}) | 
| 113 | 
  | 
         @$(CXX) $(CXXFLAGS) -c $< `root-config --cflags` -I${PAM_YODA}/include/yoda/ -I${PAM_INC}/ | 
| 114 | 
  | 
  | 
| 115 | 
 .PHONY: clean  | 
 .PHONY: clean  | 
| 116 | 
  | 
  | 
| 117 | 
  | 
 mkverpath: | 
| 118 | 
  | 
         @(${EGREEN} creating file DigitVersion.cxx; ${RESET}) | 
| 119 | 
  | 
         @echo '#include <TSystem.h>' >  DigitVersion.cxx; echo ' char *DigitizerInfo(bool print){ if ( print ) printf("\nPAMELA PamelaDigitizer version: ${VER}\n\nCompiled on '${TODAY}' with: '${GCCVER}'\n\nOn: '${UNAMEA}'\n\n"); return("${VER}"); }' >>  DigitVersion.cxx | 
| 120 | 
  | 
         @sleep 1.2 | 
| 121 | 
  | 
  | 
| 122 | 
 clean: | 
 clean: | 
| 123 | 
         @echo Removing object files ..... | 
  | 
| 124 | 
         @rm -f ${OBJS} ${DICO} *.o | 
  | 
| 125 | 
         @echo Removing dependencies files ..... | 
         @(${EGREEN} Removing object files .....) | 
| 126 | 
  | 
         @rm -f *~ | 
| 127 | 
  | 
         @rm -f ${OBJS} ${CPOBJS} ${DICO} *.o | 
| 128 | 
  | 
         @echo " Removing dependencies files ....." | 
| 129 | 
         @rm -f ${DEPS} | 
         @rm -f ${DEPS} | 
| 130 | 
         @echo Removing dictionary files ..... | 
         @echo " Removing dictionary files ....." | 
| 131 | 
         @rm -f ${JUNK} ${DICH} | 
         @rm -f ${JUNK} ${DICH} | 
| 132 | 
         @echo Removing temporary files ..... | 
         @echo " Removing temporary files ....." | 
| 133 | 
         @rm -f ${JUNK} | 
         @rm -f ${JUNK} | 
| 134 | 
  | 
         @rm -f DigitVersion.cxx;  | 
| 135 | 
  | 
         @echo " Removing Pamelagp2Digits ....." | 
| 136 | 
  | 
         @rm -f ${JUNK} | 
| 137 | 
  | 
         @rm -f Pamelagp2Digits; ${RESET} | 
| 138 | 
  | 
         @touch DigitVersion.cxx | 
| 139 | 
  | 
  | 
| 140 | 
  | 
 install: | 
| 141 | 
  | 
 #       @echo "TEST: copying the executable in the PAM_BIN directory";  | 
| 142 | 
  | 
         @(${EGREEN} "copying the executable in the PAM_BIN directory"; ${RESET}) | 
| 143 | 
  | 
         cp Pamelagp2Digits ${PAM_BIN}/. |