/[PAMELA software]/quicklook/tof/Makefile
ViewVC logotype

Diff of /quicklook/tof/Makefile

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by campana, Thu May 11 10:07:39 2006 UTC revision 1.2 by campana, Wed May 17 16:35:59 2006 UTC
# Line 1  Line 1 
1  # Flight quick look - FQLOOK  # Flight quick look - FQLOOK
2  # SOFTWARE VERSION  # SOFTWARE VERSION
3  VER= v1r00  VER= v1r06
4  # An almost general purpouse Makefile for PAMELA repository  # An almost general purpouse Makefile for PAMELA repository
5  # Let's start with some usefull definition for colorize the echo  # Let's start with some usefull definition for colorize the echo
6  RED='\E[1;31;40m'  RED='\E[1;31;40m'
7  GREEN='\E[1;32;40m'  GREEN='\E[1;32;40m'
8  YELLOW='\E[1;33;40m'  YELLOW='\E[1;33;40m'
9  BLUE='\E[1;34;40m'  BLUE='\E[1;34;40m'
10  WHITE='\E[1;37;40m'  WHITE='\E[1;37;40m'
11  VIOLET='\E[1;35;40m'  VIOLET='\E[1;35;40m'
12  CYAN='\E[1;36;40m'  CYAN='\E[1;36;40m'
13  # Here the echo definition to use them  # Here the echo definition to use them
14  EVIOLET=echo -e ${VIOLET}  EVIOLET=echo -e ${VIOLET}
15  ECYAN=echo -e ${CYAN}  ECYAN=echo -e ${CYAN}
16  ERED=echo -e ${RED}  ERED=echo -e ${RED}
17  EGREEN=echo -e ${GREEN}  EGREEN=echo -e ${GREEN}
18  EYELLOW=echo -e ${YELLOW}  EYELLOW=echo -e ${YELLOW}
19  EBLUE=echo -e ${BLUE}  EBLUE=echo -e ${BLUE}
20  EWHITE=echo -e ${WHITE}  EWHITE=echo -e ${WHITE}
21  # Reset the terminal  # Reset the terminal
22  RESET=tput sgr0  RESET=tput sgr0
23  # Here the variables used to override the standard make flags  # Here the variables used to override the standard make flags
24  # C++  # C
25  CXX=g++  CC=gcc
26  CXXFLAGS=-Wall  CFLAGS=-Wall -O -fPIC -pthread
27  # Here the variables definig the local directories  # Enviroment:
28  DIRTOP=${shell pwd}  GCCVER=`gcc --version | head -1`
29  DIRLIB=lib  UNAMEA=`uname -a`
30  DIRBIN=bin  TODAY=`date`
31  DIRSRC=src  # F77
32  DIRDOC=doc  F77=g77
33  DIRMACROS=macros  F77FLAGS=  -Wall -Wno-globals -fvxt -fno-automatic -fbounds-check -g -extend_source -static -fno-backslash
34  # Here the  PAMELA environmental variables to be checked  # C++
35  PAM_ENV= PAM_BIN_env PAM_LIB_env PAM_INC_env PAM_DOC_env PAM_MACROS_env PAM_CALIB_env PAM_YODA_env  CXX=g++
36  # Here the local variables used to build the targets  CXXFLAGS=-Wall -O -fPIC -pthread
37    # ROOTCINT
38  CXXEXESRCS=${DIRSRC}/TofScan.cpp  ROOTCINT=rootcint
39  CXXEXELIBS=$(CXXEXESRCS:${DIRSRC}/%.cpp=%)  # Here the variables definig the local directories
40  EXESRCS= ${DIRBIN}/TofScan  DIRTOP=${shell pwd}
41  DOCFILES=  DIRLIB=lib
42    DIRBIN=bin
43  # Here the Variables used for info target  DIRSRC=src
44  PACKAGE=ToF flight quick look software  DIRINC=inc
45  EXECUTABLES=  DIRDOC=doc
46  LIBS= ${FLIBS} ${FOBJS} ${CLIBS} ${COBJS} ${CXXEXEOBJS}  DIRMACROS=macros
47  DOCS=  DIRCALIB=
48  SRCS= ${FSRCS} ${CRSCS} ${CXXEXESRCS}  # Here the  PAMELA environmental variables to be checked
49  MACROS= ${MACROSSRCS}  PAM_ENV= PAM_BIN_env PAM_LIB_env PAM_INC_env PAM_DOC_env PAM_MACROS_env PAM_CALIB_env PAM_YODA_env
50  NROOTINC=${shell root-config --incdir}  # Here the local variables used to build the targets
51  #  
52  TOBEDEL =  CXXEXESRCS=${DIRSRC}/TofScan.cpp
53  # Let's start  CXXEXELIBS=$(CXXEXESRCS:${DIRSRC}/%.cpp=%)
54  all : test mkbindir mklibdir ${CXXEXELIBS}  EXESRCS= ${DIRBIN}/TofScan
55  all:  DOCFILES=
56          @echo -e ${GREEN} ""  
57          @(${EGREEN} " Finished, now you can install the package \n  (use: make install or make upgrade or make forceinstall) "; ${RESET})  # Here the Variables used for info target
58          @echo -e ${GREEN} ""  PACKAGE=ToF flight quick look software
59          @${RESET}  EXECUTABLES=
60    LIBS= ${FLIBS} ${FOBJS} ${CLIBS} ${COBJS} ${CXXEXEOBJS}
61  # Here some general rules to produce objects in our local dir  DOCS=
62  ${CXXEXELIBS}: ${CXXEXESRCS}  SRCS= ${FSRCS} ${CRSCS} ${CXXEXESRCS}
63          @(${EGREEN} "Creating exec file: "${WHITE} "$@"; ${RESET})  MACROS= ${MACROSSRCS}
64          ${CXX} ${CXXFLAGS} -c ${DIRSRC}/$@.cpp -o ${DIRLIB}/$@.o -I${PAM_INC} -I${PAM_YODA}/include/yoda/ -I${NROOTINC};  NROOTINC=${shell root-config --incdir}
65          ${CXX} ${CXXFLAGS} -o ${DIRBIN}/$@ ${DIRLIB}/$@.o -I${PAM_INC} -I${PAM_YODA}/include/yoda/ ${PAM_YODA}/lib/libyoda.so `root-config --cflags --glibs`;  #
66    TOBEDEL =
67  # A small target to check environmental variables  # Let's start
68  %_env:  all : test mkbindir mklibdir ${MACROSLIBS} ${CXXEXELIBS}
69          @${test_env}  all:
70            @echo -e ${GREEN} ""
71  .PHONY: install installexe          @(${EGREEN} " Finished, now you can install the package \n  (use: make install or make upgrade or make forceinstall) "; ${RESET})
72  .PHONY: clean depclean info mklibdir testcern testpamenv test          @echo -e ${GREEN} ""
73            @${RESET}
74  mkbindir: ${DIRBIN}  
75  ${DIRBIN}:  # Here some general rules to produce objects in our local dir
76          @${test_and_mk}  ${CXXEXELIBS}: ${CXXEXESRCS}
77            @(${EGREEN} "Creating exec file: "${WHITE} "$@"; ${RESET})
78  mklibdir: ${DIRLIB}          ${CXX} ${CXXFLAGS} -c ${DIRSRC}/$@.cpp -o ${DIRLIB}/$@.o -I${PAM_INC} -I${PAM_YODA}/include/yoda/ -I${NROOTINC};
79  ${DIRLIB}:          ${CXX} ${CXXFLAGS} -o ${DIRBIN}/$@ ${DIRLIB}/$@.o -I${PAM_INC} -I${PAM_YODA}/include/yoda/ ${PAM_YODA}/lib/libyoda.so `root-config --cflags --glibs`;
80          @${test_and_mk}  
81    # A small target to check environmental variables
82  # Here what has to be deleted in clean target  %_env:
83  clean: TOBEDEL= ${DIRBIN}            @${test_env}
84  clean:  
85          @${test_and_rm}  .PHONY: install installdoc installlib installmacros installinc installexe installcmacro
86    .PHONY: clean depclean info mkbindir mklibdir testcern testpamenv test
87  distclean: clean  
88  distclean: TOBEDEL= ${DIRBIN} ${DIRLIB}  mkbindir: ${DIRBIN}
89  distclean:  ${DIRBIN}:
90          @${test_and_rm}          @${test_and_mk}
91    
92  forceinstall: FORCE=-f  mklibdir: ${DIRLIB}
93  forceinstall: install  ${DIRLIB}:
94            @${test_and_mk}
95  upgrade: FORCE=-u  
96  upgrade: install  # Here what has to be deleted in clean target
97    clean: TOBEDEL= ${DIRBIN}
98  install: installexe  clean:
99            @${test_and_rm}
100  installexe: TOBEMOVED= $(EXESRCS:${DIRBIN}/%=${PAM_BIN}/%)  
101  installexe: ORIGIN=${DIRBIN}  distclean: clean
102  installexe:  distclean: TOBEDEL= ${DIRBIN} ${DIRLIB}
103          @${test_and_cp}  distclean:
104            @${test_and_rm}
105  installdoc: TOBEMOVED= $(DOCFILES:${DIRDOC}/%=${PAM_DOC}/%)  
106  installdoc: ORIGIN=${DIRDOC}  forceinstall: FORCE=-f
107  installdoc:  forceinstall: install
108          @${test_and_cp}  
109    upgrade: FORCE=-u
110  info:  upgrade: install
111          @echo " "  
112          @${EGREEN} "Infos for package :" ${WHITE} ${PACKAGE}  install: installexe
113          @${EGREEN} "          VERSION :" ${WHITE} ${VER}  
114          @${EGREEN} "      EXECUTABLES :" ${WHITE} ${EXECUTABLES}  installlib: LINK=y
115          @${EGREEN} "             LIBS :" ${WHITE} ${LIBS}  installlib: TOBEMOVED= $(FULLLIBS:${DIRLIB}%=${PAM_LIB}%)
116          @${EGREEN} "             DOCS :" ${WHITE} ${DOCS}  installlib: ORIGIN=${DIRLIB}
117          @${EGREEN} "             SRCS :" ${WHITE} ${SRCS}  installlib:
118          @${EGREEN} "           MACROS :" ${WHITE} ${MACROS}          @${test_and_cp}
119          @echo " "  
120          @${RESET}  installcmacro: LINK=y
121    installcmacro: TOBEMOVED= $(FULLMACROCLIBS:${DIRLIB}%=${PAM_LIB}%)
122  test: testpamenv  installcmacro: ORIGIN=${DIRLIB}
123    installcmacro:
124  testpamenv: ${PAM_ENV}          @${test_and_cp}
125    
126  root-config: OPT=--cflags  installinc: TOBEMOVED= $(INCSRCS:${DIRINC}/%=${PAM_INC}/%)
127  root-config:  installinc: ORIGIN=${DIRINC}
128          @${test_cmd}  installinc:
129            @${test_and_cp}
130  # Here follows some usefull macros  
131  define  test_and_cp  installexe: TOBEMOVED= $(EXESRCS:${DIRBIN}/%=${PAM_BIN}/%)
132  wd=`pwd`;\  installexe: ORIGIN=${DIRBIN}
133  for i in ${TOBEMOVED} ; do \  installexe:
134  wv=$${i##/*/}; \          @${test_and_cp}
135  dest=$${i/$${wv}/}; \  
136  ${EGREEN} "Testing for :" ${WHITE} "$${i}" ; ${RESET}; \  installmacros: TOBEMOVED= $(MACROSSRCS:${DIRMACROS}/%=${PAM_MACROS}/%)
137  if [ ! "${FORCE}" ] ; then \  installmacros: ORIGIN=${DIRMACROS}
138   if [ ! -f $${i} ]; then  \  installmacros:
139    ${EGREEN} "Copying : "${WHITE} ${ORIGIN}/$${i##/*/} ;\          @${test_and_cp}
140    ${EGREEN} "      to: "${WHITE} $${i} ; ${RESET}; \  
141    cp ${ORIGIN}/$${i##/*/} $${i}; \  installcalib: TOBEMOVED= $(CALIBFILES:${DIRCALIB}/%=${PAM_CALIB}/%)
142   else \  installcalib: ORIGIN=${DIRCALIB}
143     ${ERED} "File already exist !!!! Please delete it " ${WHITE}; ${RESET}; \  installcalib:
144   fi;\          @${test_and_cp}
145  else \  
146     if [ "${FORCE}" == "-u" ] ; then \  installdoc: TOBEMOVED= $(DOCFILES:${DIRDOC}/%=${PAM_DOC}/%)
147       if [ "`basename $${i}`" != "`basename $${i} _${VER}.so`" ]; then \  installdoc: ORIGIN=${DIRDOC}
148         ${EYELLOW} "Removing: "${WHITE} ${PAM_LIB}/`basename $${i} _${VER}.so`_v*r*.so; ${RESET}; \  installdoc:
149         rm -f ${PAM_LIB}/`basename $${i} _${VER}.so`_v*r*.so ; \          @${test_and_cp}
150         ${EGREEN} "Copying : "${WHITE} ${ORIGIN}/$${i##/*/} ;\  
151         ${EGREEN} "      to: "${WHITE} $${i} ; ${RESET}; \  info:
152         cp ${ORIGIN}/$${i##/*/} $${i}; \          @echo " "
153       else \          @${EGREEN} "Infos for package :" ${WHITE} ${PACKAGE}
154         ${EYELLOW} " Forcing copy: "${WHITE} ${ORIGIN}/$${i##/*/} ;\          @${EGREEN} "          VERSION :" ${WHITE} ${VER}
155         ${EYELLOW} "          to: "${WHITE} $${i} ; ${RESET}; \          @${EGREEN} "      EXECUTABLES :" ${WHITE} ${EXECUTABLES}
156         cp -f ${ORIGIN}/$${i##/*/} $${i}; \          @${EGREEN} "             LIBS :" ${WHITE} ${LIBS}
157       fi; \          @${EGREEN} "             DOCS :" ${WHITE} ${DOCS}
158     else \          @${EGREEN} "             SRCS :" ${WHITE} ${SRCS}
159       ${EYELLOW} " Forcing copy: "${WHITE} ${ORIGIN}/$${i##/*/} ;\          @${EGREEN} "           MACROS :" ${WHITE} ${MACROS}
160       ${EYELLOW} "          to: "${WHITE} $${i} ; ${RESET}; \          @echo " "
161       cp ${FORCE} ${ORIGIN}/$${i##/*/} $${i}; \          @${RESET}
162     fi;\  
163  fi ;\  test: testpamenv
164  if [ ! -z ${LINK} ] ; then \  
165    ${EGREEN} "Creating symlink from : "${WHITE} $${wv/_${VER}/} ;\  testpamenv: ${PAM_ENV}
166    ${EGREEN} "                   to : "${WHITE} $${i##/*/} ; ${RESET}; \  
167    cd $${dest}; \  root-config: OPT=--cflags
168    ln -sf $${wv} $${wv/_${VER}/}; \  root-config:
169    cd $${wd}; \          @${test_cmd}
170  fi \  
171  done  # Here follows some usefull macros
172  endef  define  test_and_cp
173    wd=`pwd`;\
174  define  test_and_mk  for i in ${TOBEMOVED} ; do \
175  ${EGREEN} "Testing for :" ${WHITE} "$@"; ${RESET}  wv=$${i##/*/}; \
176  test -d "$@" || \  dest=$${i/$${wv}/}; \
177  (${EGREEN} "Creating : "${WHITE} "$@"; ${RESET}; mkdir -p $@)  ${EGREEN} "Testing for :" ${WHITE} "$${i}" ; ${RESET}; \
178  endef  if [ ! "${FORCE}" ] ; then \
179     if [ ! -f $${i} ]; then  \
180  define  test_env    ${EGREEN} "Copying : "${WHITE} ${ORIGIN}/$${i##/*/} ;\
181  ${EGREEN} "Testing for env:" ${WHITE} $(patsubst %_env,%,$@); ${RESET}    ${EGREEN} "      to: "${WHITE} $${i} ; ${RESET}; \
182  printenv $(patsubst %_env,%,$@) 1>/dev/null || \    cp ${ORIGIN}/$${i##/*/} $${i}; \
183  (${ERED} "ERROR, variable : "${WHITE} $(patsubst %_env,%,$@) \   else \
184  ${RED} "not defined !!! Check your env. settings"; \     ${ERED} "File already exist !!!! Please delete it " ${WHITE}; ${RESET}; \
185  ${RESET}; exit 1)   fi;\
186  ${EGREEN} " Defined:" ${WHITE} $${$(patsubst %_env,%,$@)}; ${RESET}  else \
187  endef     if [ "${FORCE}" == "-u" ] ; then \
188         if [ "`basename $${i}`" != "`basename $${i} _${VER}.so`" ]; then \
189  define  test_cmd         ${EYELLOW} "Removing: "${WHITE} ${PAM_LIB}/`basename $${i} _${VER}.so`_v*r*.so; ${RESET}; \
190  ${EGREEN} "Testing for cmd:" ${WHITE} $@ ${OPT}; ${RESET}         rm -f ${PAM_LIB}/`basename $${i} _${VER}.so`_v*r*.so ; \
191  $@ ${OPT} 1>/dev/null 2>&1 || \         ${EGREEN} "Copying : "${WHITE} ${ORIGIN}/$${i##/*/} ;\
192  (${ERED} "ERROR, command : "${WHITE} $@ ${OPT}\         ${EGREEN} "      to: "${WHITE} $${i} ; ${RESET}; \
193  ${RED} "not found !!! Check your installation"; \         cp ${ORIGIN}/$${i##/*/} $${i}; \
194  ${RESET}; exit 1)       else \
195  ${EGREEN} " Present:" ${WHITE} $@ ${OPT}; ${RESET}         ${EYELLOW} " Forcing copy: "${WHITE} ${ORIGIN}/$${i##/*/} ;\
196  endef         ${EYELLOW} "          to: "${WHITE} $${i} ; ${RESET}; \
197           cp -f ${ORIGIN}/$${i##/*/} $${i}; \
198  define  test_and_rm       fi; \
199  for i in ${TOBEDEL}; do \     else \
200  test -d $${i} || (${ERED} "Removing file :"${WHITE} $${i}; ${RESET}; \       ${EYELLOW} " Forcing copy: "${WHITE} ${ORIGIN}/$${i##/*/} ;\
201  rm -f $${i} ); \       ${EYELLOW} "          to: "${WHITE} $${i} ; ${RESET}; \
202  test ! -d $${i} || (${ERED} "Removing dir :"${WHITE} $${i}; ${RESET}; \       cp ${FORCE} ${ORIGIN}/$${i##/*/} $${i}; \
203  rm -rf $${i} ); \     fi;\
204  done  fi ;\
205  endef  if [ ! -z ${LINK} ] ; then \
206      ${EGREEN} "Creating symlink from : "${WHITE} $${wv/_${VER}/} ;\
207      ${EGREEN} "                   to : "${WHITE} $${i##/*/} ; ${RESET}; \
208      cd $${dest}; \
209      ln -sf $${wv} $${wv/_${VER}/}; \
210      cd $${wd}; \
211    fi \
212    done
213    endef
214    
215    define  test_and_mk
216    ${EGREEN} "Testing for :" ${WHITE} "$@"; ${RESET}
217    test -d "$@" || \
218    (${EGREEN} "Creating : "${WHITE} "$@"; ${RESET}; mkdir -p $@)
219    endef
220    
221    define  test_env
222    ${EGREEN} "Testing for env:" ${WHITE} $(patsubst %_env,%,$@); ${RESET}
223    printenv $(patsubst %_env,%,$@) 1>/dev/null || \
224    (${ERED} "ERROR, variable : "${WHITE} $(patsubst %_env,%,$@) \
225    ${RED} "not defined !!! Check your env. settings"; \
226    ${RESET}; exit 1)
227    ${EGREEN} " Defined:" ${WHITE} $${$(patsubst %_env,%,$@)}; ${RESET}
228    endef
229    
230    define  test_cmd
231    ${EGREEN} "Testing for cmd:" ${WHITE} $@ ${OPT}; ${RESET}
232    $@ ${OPT} 1>/dev/null 2>&1 || \
233    (${ERED} "ERROR, command : "${WHITE} $@ ${OPT}\
234    ${RED} "not found !!! Check your installation"; \
235    ${RESET}; exit 1)
236    ${EGREEN} " Present:" ${WHITE} $@ ${OPT}; ${RESET}
237    endef
238    
239    define  test_and_rm
240    for i in ${TOBEDEL}; do \
241    test -d $${i} || (${ERED} "Removing file :"${WHITE} $${i}; ${RESET}; \
242    rm -f $${i} ); \
243    test ! -d $${i} || (${ERED} "Removing dir :"${WHITE} $${i}; ${RESET}; \
244    rm -rf $${i} ); \
245    done
246    endef

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

  ViewVC Help
Powered by ViewVC 1.1.23