/[PAMELA software]/calo/flight/FUTILITIES/Makefile
ViewVC logotype

Annotation of /calo/flight/FUTILITIES/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations) (download)
Wed Mar 22 15:07:44 2006 UTC (18 years, 8 months ago) by mocchiut
Branch: MAIN
Branch point for: FUTILITIES
Initial revision

1 mocchiut 1.1 # Flight UTILITIES = FUTILITIES
2     # SOFTWARE VERSION
3     VER= v1r01
4     # An almost general purpouse Makefile for PAMELA repository
5     # Let's start with some usefull definition for colorize the echo
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     # C
25     CC=gcc
26     #CFLAGS=-Wall -O -fPIC -pthread -g
27     CFLAGS=-Wall -O -fPIC -pthread
28     # Enviroment:
29     GCCVER=`gcc --version | head -1`
30     UNAMEA=`uname -a`
31     TODAY=`date`
32     # F77
33     F77=g77
34     #F77FLAGS= -Wall -Wno-globals -fvxt -fno-automatic -fbounds-check -g -extend_source -static -fno-backslash
35     F77FLAGS= -Wall -Wno-globals -fvxt -fno-automatic -fbounds-check -extend_source -static -fno-backslash
36     # C++
37     CXX=g++
38     #CXXFLAGS=-Wall -O -fPIC -pthread -g
39     CXXFLAGS=-Wall -O -fPIC -pthread
40     # ROOTCINT
41     ROOTCINT=rootcint
42     # Here the variables definig the local directories
43     DIRTOP=${shell pwd}
44     DIRLIB=lib/${ARCH}
45     DIRBIN=bin/${ARCH}
46     DIRSRC=src
47     DIRINC=inc
48     DIRDOC=doc
49     DIRMACROS=macros
50     DIRCALIB=calib
51     # Here the PAMELA environmental variables to be checked
52     PAM_ENV= PAM_BIN_env PAM_LIB_env PAM_INC_env PAM_DOC_env PAM_MACROS_env PAM_CALIB_env PAM_YODA_env
53     # Here the local variables used to build the targets
54    
55     MACROSRCS=${DIRMACROS}/FUTpathtoc.cxx \
56     ${DIRMACROS}/caloclasses.cxx \
57     ${DIRMACROS}/FCaloFUNCTIONS.cxx \
58     ${DIRMACROS}/FCaloLEVEL1.cxx \
59     ${DIRMACROS}/FCaloMIP.cxx \
60     ${DIRMACROS}/FCaloMATRA.cxx \
61     ${DIRMACROS}/FCaloPLANES.cxx \
62     ${DIRMACROS}/FCaloPULSE.cxx \
63     ${DIRMACROS}/FCaloCALIBSCAN.cxx \
64     ${DIRMACROS}/FCaloFINDCALIBS.cxx \
65     ${DIRMACROS}/FCaloADC2MIP.cxx
66     # ${DIRMACROS}/FCaloTRKCALOALIG.cxx
67    
68     MACROSLIBS=$(MACROSRCS:${DIRMACROS}/%.cxx=${DIRLIB}/lib%_${VER}.so)
69     MACROCLIBS=libFUTpathtoc libcaloclasses libFCaloFUNCTIONS libFCaloLEVEL1 libFCaloMIP libFCaloMATRA libFCaloPLANES libFCaloPULSE libFCaloCALIBSCAN libFCaloFINDCALIBS libFCaloADC2MIP
70     #libFCaloTRKCALOALIG
71     FULLMACROCLIBS=$(MACROCLIBS:%=${DIRLIB}/%_${VER}.so)
72     FULLLINKMACROCLIBS=$(MACROCLIBS:%=${DIRLIB}/%.so)
73    
74     CXXEXESRCS=${DIRSRC}/FCaloLEVEL1.cc \
75     ${DIRSRC}/FCaloMIP.cc \
76     ${DIRSRC}/FCaloMATRA.cc \
77     ${DIRSRC}/FCaloPLANES.cc \
78     ${DIRSRC}/FCaloPULSE.cc \
79     ${DIRSRC}/FCaloCALIBSCAN.cc \
80     ${DIRSRC}/FCaloFINDCALIBS.cc \
81     ${DIRSRC}/FCaloADC2MIP.cc
82     # ${DIRSRC}/FCaloTRKCALOALIG.cc
83     CXXEXEOBJS=$(CXXEXESRCS:${DIRSRC}%.cc=${DIRBIN}%.o)
84     CXXEXELIBS:=FCaloLEVEL1 FCaloMIP FCaloMATRA FCaloPLANES FCaloPULSE FCaloCALIBSCAN FCaloFINDCALIBS FCaloADC2MIP
85     #FCaloTRKCALOALIG
86     EXESRCS= ${DIRBIN}/FCaloLEVEL1 ${DIRBIN}/FCaloMIP ${DIRBIN}/FCaloMATRA ${DIRBIN}/FCaloPLANES ${DIRBIN}/FCaloPULSE ${DIRBIN}/FCaloCALIBSCAN ${DIRBIN}/FCaloFINDCALIBS ${DIRBIN}/FCaloADC2MIP
87     #${DIRBIN}/FCaloTRKCALOALIG
88     INCSRCS=
89    
90     MACROSSRCS= ${DIRMACROS}/rootlogon.C ${DIRMACROS}/FCaloLEVEL1.C ${DIRMACROS}/FCaloMIP.C ${DIRMACROS}/FCaloMATRA.C ${DIRMACROS}/FCaloPLANES.C ${DIRMACROS}/FCaloPULSE.C ${DIRMACROS}/FCaloCALIBSCAN.C ${DIRMACROS}/FCaloFINDCALIBS.C ${DIRMACROS}/FCaloADC2MIP.C
91     #${DIRMACROS}/FCaloTRKCALOALIG.C
92     CALIBFILES=
93    
94     DOCFILES=
95    
96     # Here the Variables used for info target
97     PACKAGE=Calorimeter flight quick look software
98     EXECUTABLES=
99     LIBS= ${FLIBS} ${FOBJS} ${CLIBS} ${COBJS} ${CXXEXEOBJS}
100     DOCS=
101     SRCS= ${FSRCS} ${CRSCS} ${CXXEXESRCS}
102     MACROS= ${MACROSSRCS}
103     #
104     TOBEDEL = junk
105     ROOTINC=$$${shell root-config --incdir}
106     NROOTINC=${shell root-config --incdir}
107     # Let's start
108     all : test mkbindir mklibdir mkpathtoc ${MACROSLIBS} ${CXXEXELIBS}
109     all:
110     @echo -e ${GREEN} ""
111     @(${EGREEN} " Finished, now you can install the package \n (use: make install or make upgrade or make forceinstall) "; ${RESET})
112     @echo -e ${GREEN} ""
113     @${RESET}
114    
115     # Here some general rules to produce objects in our local dir
116     ${DIRBIN}/%.o: ${DIRSRC}/%.cc
117     @(${EGREEN} "Creating object file: "${WHITE} "$@"; ${RESET})
118     @${CXX} ${CXXFLAGS} -c -o $@ ${DIRSRC}/`basename ${@} .o`.cc -I${DIRINC} -I${PAM_INC} -I${PAM_YODA}/include/yoda/ `root-config --cflags`
119    
120     ${MACROSLIBS}: ${MACROSRCS}
121     @(${EGREEN} "Creating file: "${WHITE} "`basename $(@F) _${VER}.so | sed s/lib//`Dict.cxx"; ${RESET})
122     #
123     # Create *Dict.cxx and *Dict.h
124     #
125     @${ROOTCINT} -f ${DIRMACROS}/`basename $(@F) _${VER}.so | sed s/lib//`Dict.cxx -c -I${ROOTINC} ${DIRINC}/`basename $(@F) _${VER}.so | sed s/lib//`fun.h ${DIRINC}/`basename $(@F) _${VER}.so | sed s/lib//`LinkDef.h
126     #
127     # create .o
128     #
129     @(${EGREEN} "Compiling file: "${WHITE} "`basename $(@F) _${VER}.so | sed s/lib//`.cxx"; ${RESET})
130     @cd ${DIRMACROS} &>/dev/null && ${CXX} ${CXXFLAGS} -c `basename $(@F) _${VER}.so | sed s/lib//`.cxx -I${PAM_INC} -I${DIRTOP}/${DIRINC} -I${DIRTOP} -I${PAM_YODA}/include/yoda/ -I${NROOTINC};
131     @(${EGREEN} "Compiling file: "${WHITE} "`basename $(@F) _${VER}.so | sed s/lib//`Dict.cxx"; ${RESET})
132     @cd ${DIRMACROS} &>/dev/null && ${CXX} ${CXXFLAGS} -c `basename $(@F) _${VER}.so | sed s/lib//`Dict.cxx -I${PAM_INC} -I${DIRTOP}/${DIRINC} -I${DIRTOP} -I${PAM_YODA}/include/yoda/ -I${NROOTINC};
133     #
134     # create .so
135     #
136     @(${EGREEN} "Compiling shared library: "${WHITE} "$@"; ${RESET})
137     @${CXX} ${CXXFLAGS} -Xlinker -soname=$(@F) -shared -o $@ -lg2c -I${PAM_INC} -I${DIRTOP}/${DIRINC} -I${DIRTOP} -I${PAM_YODA}/include/yoda/ ${DIRTOP}/${DIRMACROS}/`basename $(@F) _${VER}.so | sed s/lib//`.o ${DIRTOP}/${DIRMACROS}/`basename $(@F) _${VER}.so | sed s/lib//`Dict.o 1>/dev/null
138    
139     ${CXXEXELIBS}: ${CXXEXEOBJS}
140     @(${EGREEN} "Creating exec file: "${WHITE} "$@"; ${RESET})
141     @${CXX} ${CXXFLAGS} -o ${DIRBIN}/$@ ${DIRBIN}/$@.o -I${DIRINC} -I${PAM_INC} -I${PAM_YODA}/include/yoda/ ${PAM_YODA}/lib/libyoda.so ${DIRTOP}/${DIRLIB}/libFUTpathtoc_${VER}.so ${DIRTOP}/${DIRLIB}/libcaloclasses_${VER}.so ${DIRTOP}/${DIRLIB}/libFCaloFUNCTIONS_${VER}.so ${DIRTOP}/${DIRLIB}/lib$@_${VER}.so -lThread `root-config --cflags --glibs`;
142    
143     # A small target to check environmental variables
144     %_env:
145     @${test_env}
146    
147     .PHONY: install installdoc installlib installmacros installinc installexe installcmacro
148     .PHONY: clean depclean info mkbindir mklibdir testcern testpamenv test
149    
150     mkbindir: ${DIRBIN}
151     ${DIRBIN}:
152     @${test_and_mk}
153    
154     mklibdir: ${DIRLIB}
155     ${DIRLIB}:
156     @${test_and_mk}
157    
158     # Here what has to be deleted in clean target
159     clean: TOBEDEL= ${DIRMACROS}/*.o ${DIRMACROS}/*Dict.cxx ${DIRMACROS}/*Dict.h ${FOBJS} ${FULLLIBS} ${DIRBIN}/${CXXEXELIBS} ${COBJS} ${CXXEXEOBJS} ${FULLLINKFLIBS} ${FULLLINKCLIBS} ${FULLMACROCLIBS} ${FULLLINKMACROCLIBS}
160     clean:
161     @${test_and_rm}
162    
163     distclean: clean
164     distclean: TOBEDEL= ${DIRBIN} ${DIRLIB}
165     distclean:
166     @${test_and_rm}
167    
168     forceinstall: FORCE=-f
169     forceinstall: install
170    
171     upgrade: FORCE=-u
172     upgrade: install
173    
174     install: installlib installinc installmacros installcalib installdoc installexe installcmacro
175    
176     installlib: LINK=y
177     installlib: TOBEMOVED= $(FULLLIBS:${DIRLIB}%=${PAM_LIB}%)
178     installlib: ORIGIN=${DIRLIB}
179     installlib:
180     @${test_and_cp}
181    
182     installcmacro: LINK=y
183     installcmacro: TOBEMOVED= $(FULLMACROCLIBS:${DIRLIB}%=${PAM_LIB}%)
184     installcmacro: ORIGIN=${DIRLIB}
185     installcmacro:
186     @${test_and_cp}
187    
188     installinc: TOBEMOVED= $(INCSRCS:${DIRINC}/%=${PAM_INC}/%)
189     installinc: ORIGIN=${DIRINC}
190     installinc:
191     @${test_and_cp}
192    
193     installexe: TOBEMOVED= $(EXESRCS:${DIRBIN}/%=${PAM_BIN}/%)
194     installexe: ORIGIN=${DIRBIN}
195     installexe:
196     @${test_and_cp}
197    
198     installmacros: TOBEMOVED= $(MACROSSRCS:${DIRMACROS}/%=${PAM_MACROS}/%)
199     installmacros: ORIGIN=${DIRMACROS}
200     installmacros:
201     @${test_and_cp}
202    
203     installcalib: TOBEMOVED= $(CALIBFILES:${DIRCALIB}/%=${PAM_CALIB}/%)
204     installcalib: ORIGIN=${DIRCALIB}
205     installcalib:
206     @${test_and_cp}
207    
208     installdoc: TOBEMOVED= $(DOCFILES:${DIRDOC}/%=${PAM_DOC}/%)
209     installdoc: ORIGIN=${DIRDOC}
210     installdoc:
211     @${test_and_cp}
212    
213     mkpathtoc:
214     @if [ "${PAM_CCO}" == "" ]; then echo '#include <TSystem.h>' > ${DIRTOP}/${DIRMACROS}/FUTpathtoc.cxx; echo ' const char *pathtocalibration(){ return((const char*)gSystem->Getenv("PAM_CALIB"));}' >> ${DIRTOP}/${DIRMACROS}/FUTpathtoc.cxx; echo ' void info(){ printf("\nUTILITIES flight package version: ${VER}\n\nCompiled on '${TODAY}' with: '${GCCVER}'\n\nOn: '${UNAMEA}'\n\n"); }' >> ${DIRTOP}/${DIRMACROS}/FUTpathtoc.cxx; fi
215     @if [ "${PAM_CCO}" != "" ]; then echo '#include <TSystem.h>' > ${DIRTOP}/${DIRMACROS}/FUTpathtoc.cxx; echo ' const char *pathtocalibration(){ return((const char*)"'${PAM_CALIB}'/");}' >> ${DIRTOP}/${DIRMACROS}/FUTpathtoc.cxx; echo ' void info(){ printf("\nUTILITIES flight package version: ${VER}\n\nCompiled on '${TODAY}' with: '${GCCVER}'\n\nOn: '${UNAMEA}'\n\n"); }' >> ${DIRTOP}/${DIRMACROS}/FUTpathtoc.cxx; fi
216     @sleep 0.8
217    
218    
219     info:
220     @echo " "
221     @${EGREEN} "Infos for package :" ${WHITE} ${PACKAGE}
222     @${EGREEN} " VERSION :" ${WHITE} ${VER}
223     @${EGREEN} " EXECUTABLES :" ${WHITE} ${EXECUTABLES}
224     @${EGREEN} " LIBS :" ${WHITE} ${LIBS}
225     @${EGREEN} " DOCS :" ${WHITE} ${DOCS}
226     @${EGREEN} " SRCS :" ${WHITE} ${SRCS}
227     @${EGREEN} " MACROS :" ${WHITE} ${MACROS}
228     @echo " "
229     @${RESET}
230    
231     test: testpamenv
232    
233     testpamenv: ${PAM_ENV}
234    
235     root-config: OPT=--cflags
236     root-config:
237     @${test_cmd}
238    
239     # Here follows some usefull macros
240     define test_and_cp
241     wd=`pwd`;\
242     for i in ${TOBEMOVED} ; do \
243     wv=$${i##/*/}; \
244     dest=$${i/$${wv}/}; \
245     ${EGREEN} "Testing for :" ${WHITE} "$${i}" ; ${RESET}; \
246     if [ ! "${FORCE}" ] ; then \
247     if [ ! -f $${i} ]; then \
248     ${EGREEN} "Copying : "${WHITE} ${ORIGIN}/$${i##/*/} ;\
249     ${EGREEN} " to: "${WHITE} $${i} ; ${RESET}; \
250     cp ${ORIGIN}/$${i##/*/} $${i}; \
251     else \
252     ${ERED} "File already exist !!!! Please delete it " ${WHITE}; ${RESET}; \
253     fi;\
254     else \
255     if [ "${FORCE}" == "-u" ] ; then \
256     if [ "`basename $${i}`" != "`basename $${i} _${VER}.so`" ]; then \
257     ${EYELLOW} "Removing: "${WHITE} ${PAM_LIB}/`basename $${i} _${VER}.so`_v*r*.so; ${RESET}; \
258     rm -f ${PAM_LIB}/`basename $${i} _${VER}.so`_v*r*.so ; \
259     ${EGREEN} "Copying : "${WHITE} ${ORIGIN}/$${i##/*/} ;\
260     ${EGREEN} " to: "${WHITE} $${i} ; ${RESET}; \
261     cp ${ORIGIN}/$${i##/*/} $${i}; \
262     else \
263     ${EYELLOW} " Forcing copy: "${WHITE} ${ORIGIN}/$${i##/*/} ;\
264     ${EYELLOW} " to: "${WHITE} $${i} ; ${RESET}; \
265     cp -f ${ORIGIN}/$${i##/*/} $${i}; \
266     fi; \
267     else \
268     ${EYELLOW} " Forcing copy: "${WHITE} ${ORIGIN}/$${i##/*/} ;\
269     ${EYELLOW} " to: "${WHITE} $${i} ; ${RESET}; \
270     cp ${FORCE} ${ORIGIN}/$${i##/*/} $${i}; \
271     fi;\
272     fi ;\
273     if [ ! -z ${LINK} ] ; then \
274     ${EGREEN} "Creating symlink from : "${WHITE} $${wv/_${VER}/} ;\
275     ${EGREEN} " to : "${WHITE} $${i##/*/} ; ${RESET}; \
276     cd $${dest}; \
277     ln -sf $${wv} $${wv/_${VER}/}; \
278     cd $${wd}; \
279     fi \
280     done
281     endef
282    
283     define test_and_mk
284     ${EGREEN} "Testing for :" ${WHITE} "$@"; ${RESET}
285     test -d "$@" || \
286     (${EGREEN} "Creating : "${WHITE} "$@"; ${RESET}; mkdir -p $@)
287     endef
288    
289     define test_env
290     ${EGREEN} "Testing for env:" ${WHITE} $(patsubst %_env,%,$@); ${RESET}
291     printenv $(patsubst %_env,%,$@) 1>/dev/null || \
292     (${ERED} "ERROR, variable : "${WHITE} $(patsubst %_env,%,$@) \
293     ${RED} "not defined !!! Check your env. settings"; \
294     ${RESET}; exit 1)
295     ${EGREEN} " Defined:" ${WHITE} $${$(patsubst %_env,%,$@)}; ${RESET}
296     endef
297    
298     define test_cmd
299     ${EGREEN} "Testing for cmd:" ${WHITE} $@ ${OPT}; ${RESET}
300     $@ ${OPT} 1>/dev/null 2>&1 || \
301     (${ERED} "ERROR, command : "${WHITE} $@ ${OPT}\
302     ${RED} "not found !!! Check your installation"; \
303     ${RESET}; exit 1)
304     ${EGREEN} " Present:" ${WHITE} $@ ${OPT}; ${RESET}
305     endef
306    
307     define test_and_rm
308     for i in ${TOBEDEL}; do \
309     test -d $${i} || (${ERED} "Removing file :"${WHITE} $${i}; ${RESET}; \
310     rm -f $${i} ); \
311     test ! -d $${i} || (${ERED} "Removing dir :"${WHITE} $${i}; ${RESET}; \
312     rm -rf $${i} ); \
313     done
314     endef

  ViewVC Help
Powered by ViewVC 1.1.23