| 1 | 
pamelats | 
1.7 | 
# PamelaDigitizer | 
| 2 | 
  | 
  | 
# SOFTWARE VERSION | 
| 3 | 
mocchiut | 
1.18 | 
VER= v3r06 | 
| 4 | 
pamelats | 
1.7 | 
# 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 | 
mocchiut | 
1.9 | 
#CFLAGS=-Wall -O -fPIC -pthread -g ${PAM_BIT} | 
| 29 | 
  | 
  | 
CFLAGS=-Wall -O -fPIC -pthread ${PAM_BIT} | 
| 30 | 
pamelats | 
1.7 | 
# Enviroment: | 
| 31 | 
  | 
  | 
GCCVER=`gcc --version | head -1` | 
| 32 | 
  | 
  | 
UNAMEA=`uname -a` | 
| 33 | 
  | 
  | 
TODAY=`date` | 
| 34 | 
  | 
  | 
# F77 | 
| 35 | 
  | 
  | 
F77=g77 | 
| 36 | 
mocchiut | 
1.9 | 
#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 | 
pamelats | 
1.7 | 
# C++ | 
| 39 | 
  | 
  | 
CXX=g++ | 
| 40 | 
  | 
  | 
# ROOTCINT | 
| 41 | 
  | 
  | 
ROOTCINT=rootcint | 
| 42 | 
  | 
  | 
 | 
| 43 | 
  | 
  | 
# Compilers settings | 
| 44 | 
  | 
  | 
ROOTCFLAGS  =`root-config --cflags` | 
| 45 | 
mocchiut | 
1.13 | 
ROOTLDFLAGS =`root-config --ldflags`  | 
| 46 | 
mayorov | 
1.19 | 
ROOTLIBS    =`root-config --libs` -lHbook -lminicern | 
| 47 | 
mocchiut | 
1.13 | 
#CERNLIBS    =`cernlib_noshift kernlib,packlib,genlib` | 
| 48 | 
  | 
  | 
CERNLIBS    = | 
| 49 | 
mocchiut | 
1.16 | 
#F77LIBS     =-lg2c -lnsl | 
| 50 | 
mocchiut | 
1.18 | 
F77LIBS     =-lnsl | 
| 51 | 
pamelats | 
1.7 | 
SYSLIBS     =-lm -ldl -rdynamic | 
| 52 | 
  | 
  | 
LD          =g++ | 
| 53 | 
mocchiut | 
1.9 | 
CXXFLAGS= -O3 -Wall -fPIC ${ROOTCFLAGS} ${PAM_BIT} | 
| 54 | 
  | 
  | 
#CXXFLAGS= -g -Wall -O ${ROOTCFLAGS} ${PAM_BIT} | 
| 55 | 
pamelats | 
1.7 | 
# flags needed on the pamelatov's: | 
| 56 | 
pamelats | 
1.12 | 
 | 
| 57 | 
  | 
  | 
#LDFLAGS = $(PAM_BIT) -g -lmathlib -lpacklib -lkernlib -llapack -lg2c -lm -lnsl -lcrypt -L/cern/2005/lib | 
| 58 | 
  | 
  | 
#LDFLAGS = -g -llapack -lg2c -lm -lnsl -lcrypt -L/cern/2005/lib | 
| 59 | 
  | 
  | 
LDFLAGS = $(PAM_BIT) $(CERNLIBS) | 
| 60 | 
  | 
  | 
#LDFLAGS = -lmathlib -lpacklib -lkernlib -llapack -lg2c -lm -lnsl -lcrypt -L/cern/2005/lib $(PAM_BIT) | 
| 61 | 
  | 
  | 
 | 
| 62 | 
mocchiut | 
1.11 | 
#LDFLAGS = -g -llapack -lg2c -lm -lnsl -lcrypt -L/cern/2005/lib $(PAM_BIT) | 
| 63 | 
  | 
  | 
 | 
| 64 | 
pamelats | 
1.15 | 
CXXSRCS= Digitizer.cxx DigitizePSCU.cxx DigitizeCalo.cxx DigitizeTOF.cxx DigitizeAC.cxx DigitizeS4.cxx DigitizeND.cxx  Write.cxx DigitizeTRK.cxx Pamelagp2Digits.cxx DigitVersion.cxx | 
| 65 | 
mocchiut | 
1.11 | 
OBJS=$(CXXSRCS:%.cxx=%.o) | 
| 66 | 
  | 
  | 
 | 
| 67 | 
  | 
  | 
CPPSRCS= CRC.cpp calcrc.cpp  | 
| 68 | 
  | 
  | 
CPOBJS=$(CPPSRCS:%.cpp=%.o) | 
| 69 | 
pamelats | 
1.7 | 
 | 
| 70 | 
  | 
  | 
HEAS =$(SRCS:.cpp=.h) | 
| 71 | 
mocchiut | 
1.11 | 
#OBJS =$(SRCS:.cpp=.o) | 
| 72 | 
pamelats | 
1.7 | 
DEPS =$(SRCS:.cpp=.d) | 
| 73 | 
  | 
  | 
CLAS =$(DICS:.cpp= ) | 
| 74 | 
  | 
  | 
CLASH=$(DICS:.cpp=.h) | 
| 75 | 
  | 
  | 
JUNK =$(addsuffix ~,${SRCS}) $(addsuffix ~,${HEAS})  | 
| 76 | 
  | 
  | 
DICO =$(addsuffix Dict.o, ${CLAS}) | 
| 77 | 
  | 
  | 
DICH =$(addsuffix Dict.h, ${CLAS}) | 
| 78 | 
  | 
  | 
 | 
| 79 | 
mocchiut | 
1.11 | 
all: prepare libs Pamelagp2Digits | 
| 80 | 
pamelats | 
1.7 | 
        @echo -e ${GREEN} "" | 
| 81 | 
  | 
  | 
        @(${EGREEN} " Finished, now you can install the package \n  (use: make install) "; ${RESET}) | 
| 82 | 
  | 
  | 
        @echo -e ${GREEN} "" | 
| 83 | 
  | 
  | 
        @${RESET} | 
| 84 | 
  | 
  | 
 | 
| 85 | 
mocchiut | 
1.11 | 
prepare: mkverpath | 
| 86 | 
  | 
  | 
 | 
| 87 | 
  | 
  | 
libs: $(CPOBJS) ${OBJS} ${DICO} | 
| 88 | 
pamelats | 
1.7 | 
 | 
| 89 | 
mocchiut | 
1.11 | 
 | 
| 90 | 
  | 
  | 
#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}  | 
| 91 | 
  | 
  | 
Pamelagp2Digits:  | 
| 92 | 
  | 
  | 
        @(${EWHITE} " Compiling Pamelagp2Digits... \n ") | 
| 93 | 
  | 
  | 
        @ $(LD) $(LDFLAGS) -o $@ $^ ${ROOTLIBS} ${CERNLIBS} ${F77LIBS} ${SYSLIBS} ${PAM_LIB}/libGLTables.so ${PAM_LIB}/libsgp4.so ${PAM_YODA}/lib/libyoda.so ${OBJS} $(CPOBJS) | 
| 94 | 
pamelats | 
1.7 | 
        @rm -f *.o | 
| 95 | 
  | 
  | 
 | 
| 96 | 
  | 
  | 
Digitizer: Digitizer.o ${OBJS} ${DICO} | 
| 97 | 
mocchiut | 
1.13 | 
        $(LD) $(LDFLAGS) -o $@ $^ ${ROOTLIBS} ${CERNLIBS} ${F77LIBS} ${SYSLIBS} | 
| 98 | 
pamelats | 
1.7 | 
 | 
| 99 | 
  | 
  | 
depend: ${DEPS} | 
| 100 | 
  | 
  | 
 | 
| 101 | 
mocchiut | 
1.11 | 
 | 
| 102 | 
  | 
  | 
%.d: %.cxx | 
| 103 | 
pamelats | 
1.7 | 
        @echo Creating dependencies for $<  | 
| 104 | 
  | 
  | 
        @$(CXX) -MM $(CXXFLAGS) $< -o $@ | 
| 105 | 
  | 
  | 
 | 
| 106 | 
  | 
  | 
.SUFFIXES: .cxx | 
| 107 | 
  | 
  | 
%.o: %.cxx | 
| 108 | 
mocchiut | 
1.11 | 
        @(${EGREEN} "Creating CXX object file: "${WHITE} "`basename $@`"; ${RESET}) | 
| 109 | 
  | 
  | 
        @$(CXX) $(CXXFLAGS) -c $< `root-config --cflags` -I${PAM_YODA}/include/yoda/ -I${PAM_INC}/ | 
| 110 | 
pamelats | 
1.7 | 
 | 
| 111 | 
mocchiut | 
1.11 | 
.SUFFIXES: .cpp | 
| 112 | 
  | 
  | 
%.o: %.cpp | 
| 113 | 
  | 
  | 
        @(${EGREEN} "Creating CPP object file: "${WHITE} "`basename $@`"; ${RESET}) | 
| 114 | 
  | 
  | 
        @$(CXX) $(CXXFLAGS) -c $< `root-config --cflags` -I${PAM_YODA}/include/yoda/ -I${PAM_INC}/ | 
| 115 | 
pamelats | 
1.7 | 
 | 
| 116 | 
  | 
  | 
.PHONY: clean  | 
| 117 | 
  | 
  | 
 | 
| 118 | 
  | 
  | 
mkverpath: | 
| 119 | 
  | 
  | 
        @(${EGREEN} creating file DigitVersion.cxx; ${RESET}) | 
| 120 | 
mocchiut | 
1.17 | 
        @echo '#include <TSystem.h>' >  DigitVersion.cxx; echo ' const 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 | 
| 121 | 
mocchiut | 
1.11 | 
        @sleep 1.2 | 
| 122 | 
pamelats | 
1.7 | 
 | 
| 123 | 
  | 
  | 
clean: | 
| 124 | 
  | 
  | 
 | 
| 125 | 
  | 
  | 
 | 
| 126 | 
  | 
  | 
        @(${EGREEN} Removing object files .....) | 
| 127 | 
  | 
  | 
        @rm -f *~ | 
| 128 | 
mocchiut | 
1.11 | 
        @rm -f ${OBJS} ${CPOBJS} ${DICO} *.o | 
| 129 | 
  | 
  | 
        @echo " Removing dependencies files ....." | 
| 130 | 
pamelats | 
1.7 | 
        @rm -f ${DEPS} | 
| 131 | 
mocchiut | 
1.11 | 
        @echo " Removing dictionary files ....." | 
| 132 | 
pamelats | 
1.7 | 
        @rm -f ${JUNK} ${DICH} | 
| 133 | 
mocchiut | 
1.11 | 
        @echo " Removing temporary files ....." | 
| 134 | 
  | 
  | 
        @rm -f ${JUNK} | 
| 135 | 
  | 
  | 
        @rm -f DigitVersion.cxx;  | 
| 136 | 
  | 
  | 
        @echo " Removing Pamelagp2Digits ....." | 
| 137 | 
pamelats | 
1.7 | 
        @rm -f ${JUNK} | 
| 138 | 
mocchiut | 
1.11 | 
        @rm -f Pamelagp2Digits; ${RESET} | 
| 139 | 
mocchiut | 
1.13 | 
        @touch DigitVersion.cxx | 
| 140 | 
pamelats | 
1.7 | 
 | 
| 141 | 
  | 
  | 
install: | 
| 142 | 
  | 
  | 
#       @echo "TEST: copying the executable in the PAM_BIN directory";  | 
| 143 | 
  | 
  | 
        @(${EGREEN} "copying the executable in the PAM_BIN directory"; ${RESET}) | 
| 144 | 
  | 
  | 
        cp Pamelagp2Digits ${PAM_BIN}/. |