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

Contents of /calo/flight/CaloElectron/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (show annotations) (download) (vendor branch)
Fri Mar 13 15:23:20 2009 UTC (15 years, 9 months ago) by pam-fi
Branch: pamela
CVS Tags: beta
Changes since 1.1: +0 -0 lines
CaloElectron beta version

1 # Calorimeter flight analysis software
2 # SOFTWARE VERSION
3 VER= v2r00
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_CALIB_env PAM_YODA_env
53 # Here the local variables used to build the targets
54 #-------------------------------------------------
55 FSRCS=
56 FOBJS=$(FSRCS:${DIRSRC}/F77/%.f=${DIRLIB}/%.o)
57 #-------------------------------------------------
58 CSRCS=
59 COBJS=$(CSRCS:${DIRSRC}%.cpp=${DIRLIB}/%.o)
60 #-------------------------------------------------
61 # librerie utilizzabili da root (ci deve essere anche il ***LinkDef.h )
62 LIBROOTSRCS= ${DIRSRC}/CaloElectron.cpp ${DIRSRC}/CaloHough.cpp ${DIRSRC}/CaloShape.cpp
63 LIBROOTLIBS=$(LIBROOTSRCS:${DIRSRC}/%.cpp=${DIRLIB}/lib%_${VER}.so)
64 LIBROOTOBJS=
65 LIBROOTCLIBS=libCaloElectron libCaloHough libCaloShape
66 FULLROOTCLIBS=$(LIBROOTCLIBS:%=${DIRLIB}/%_${VER}.so)
67 #-------------------------------------------------
68 # librerie C++ NON utilizzabili da root
69 LIBCPPSRCS=#${DIRSRC}/PamLevel2.cpp
70 LIBCPPLIBS=$(LIBCPPSRCS:${DIRSRC}/%.cpp=${DIRLIB}/lib%_${VER}.so)
71 LIBCPPCLIBS=#libPamLevel2
72 FULLCPPCLIBS=$(LIBCPPCLIBS:%=${DIRLIB}/%_${VER}.so)
73 #-------------------------------------------------
74 # librerie F77 NON utilizzabili da root
75 LIBF77SRCS=
76 LIBF77OBJS= $(LIBF77SRCS:${DIRSRC}/F77/%.f=${DIRLIB}/%.o)
77 LIBF77LIBS= $(LIBF77SRCS:${DIRSRC}/F77/%.f=${DIRLIB}/lib%_${VER}.so)
78 LIBF77CLIBS=
79 FULLF77CLIBS=$(LIBF77CLIBS:%=${DIRLIB}/%_${VER}.so)
80 #-------------------------------------------------
81 FULLLIBS=${FULLROOTCLIBS} ${FULLCPPCLIBS} ${FULLF77CLIBS}
82
83 #-------------------------------------------------
84 # eseguibile
85 CXXEXESRCS=
86 CXXEXEOBJS=$(CXXEXESRCS:${DIRSRC}%.cpp=${DIRLIB}%.o)
87 CXXEXELIBS:=
88
89 OTHERLIBS=
90 #-------------------------------------------------
91 # variabili per l'installazione
92 EXESRCS=
93 INCSRCS=${DIRINC}/CaloElectron.h ${DIRINC}/CaloHough.h ${DIRINC}/CaloShape.h
94 MACROSSRCS=
95 CALIBFILES=
96 DOCFILES=
97 # Here the Variables used for info target
98 PACKAGE=
99 EXECUTABLES=${EXESRCS}
100 LIBS= ${FULLLIBS} ${OTHERLIBS}
101 DOCS=
102 SRCS=
103 MACROS= ${MACROSSRCS}
104 INCLUDE= ${INCSRCS}
105 #
106 TOBEDEL = junk
107 ROOTINC=$$${shell root-config --incdir}
108 NROOTINC=${shell root-config --incdir}
109 # Let's start
110 all : test mkbindir mklibdir ${LIBF77LIBS} ${LIBROOTLIBS} ${LIBCPPLIBS} ${CXXEXELIBS}
111 all:
112 @echo -e ${GREEN} ""
113 @(${EGREEN} " Finished, now you can install the package \n (use: make install or make upgrade or make forceinstall) "; ${RESET})
114 @echo -e ${GREEN} ""
115 @${RESET}
116
117 # Here some general rules to produce objects in our local dir
118 ${DIRLIB}/%.o: ${DIRSRC}/%.cpp
119 @(${EYELLOW} " C++ object ------------------------")
120 @(${EGREEN} "Creating object file: "${WHITE} "$@"; ${RESET})
121 @${CXX} ${CXXFLAGS} -c -o $@ ${DIRSRC}/`basename ${@} .o`.cpp -I${DIRINC} -I${PAM_INC} -I${PAM_YODA}/include/yoda/ `root-config --cflags` -lMinuit
122
123 ${DIRLIB}/%.o : ${DIRSRC}/F77/%.f
124 @(${EYELLOW} " F77 object ------------------------")
125 @(${EGREEN} "Creating object file: "${WHITE} "$@"; ${RESET})
126 @${F77} ${F77FLAGS} -c -o $@ ${DIRSRC}/F77/`basename ${@} .o`.f -I${DIRINC}/F77 -I${NROOTINC} -I${PAM_YODA}/include/yoda
127
128
129 # .so from .o fortran
130 ${LIBF77LIBS}: ${LIBF77OBJS}
131 @(${EYELLOW} " F77 shared library --------------------------")
132 @(${EGREEN} "Creating library: "${WHITE} "$@"; ${RESET})
133 @${CXX} ${CXXFLAGS} -Xlinker -soname=$(@F) -shared -o $@ $^ -lg2c `doc/cernlib_pam mathlib`
134
135
136 ${LIBROOTLIBS}: ${LIBROOTSRCS} ${FOBJS}
137 @(${EYELLOW} " ROOT library ------------------------")
138 @(${EGREEN} "Creating file: "${WHITE} "`basename $(@F) _${VER}.so | sed s/lib//`Dict.cpp"; ${RESET})
139 #
140 # Create *Dict.cpp and *Dict.h
141 #
142 # @${ROOTCINT} -f ${DIRSRC}/`basename $(@F) _${VER}.so | sed s/lib//`Dict.cpp -c -I${ROOTINC} -I${PAM_YODA}/include/yoda/ -I${PAM_INC} ${DIRINC}/`basename $(@F) _${VER}.so | sed s/lib//`.h ${DIRINC}/`basename $(@F) _${VER}.so | sed s/lib//`LinkDef.h
143 @${ROOTCINT} -f ${DIRSRC}/`basename $(@F) _${VER}.so | sed s/lib//`Dict.cpp -c -I${PAM_INC} -I${ROOTINC} -I${PAM_YODA}/include/yoda/ ${DIRINC}/`basename $(@F) _${VER}.so | sed s/lib//`.h ${DIRINC}/`basename $(@F) _${VER}.so | sed s/lib//`LinkDef.h
144 #
145 # order of include directories changed since RunInfo.h can be found (with completely different definition) in YODA while we want to load the DV one!
146 # should be fixed some time changing names...
147 #
148 # create .o
149 #
150 @(${EGREEN} "Compiling file: "${WHITE} "`basename $(@F) _${VER}.so | sed s/lib//`.cpp"; ${RESET})
151 @cd ${DIRSRC} &>/dev/null && ${CXX} ${CXXFLAGS} -c `basename $(@F) _${VER}.so | sed s/lib//`.cpp -I${DIRTOP}/${DIRINC} -I${DIRTOP} -I${PAM_INC} -I${PAM_YODA}/include/yoda/ -I${NROOTINC};
152 @(${EGREEN} "Compiling file: "${WHITE} "`basename $(@F) _${VER}.so | sed s/lib//`Dict.cpp"; ${RESET})
153 @cd ${DIRSRC} &>/dev/null && ${CXX} ${CXXFLAGS} -c `basename $(@F) _${VER}.so | sed s/lib//`Dict.cpp -I${DIRTOP}/${DIRINC} -I${DIRTOP} -I${PAM_INC} -I${PAM_YODA}/include/yoda/ -I${NROOTINC};
154 #
155 # create .so
156 #
157 @(${EGREEN} "Compiling shared library: "${WHITE} "$@"; ${RESET})
158 @${CXX} ${CXXFLAGS} -Xlinker -soname=$(@F) -shared -o $@ -lg2c -I${DIRTOP}/${DIRINC} -I${DIRTOP} -I${PAM_YODA}/include/yoda -I${PAM_INC} ${DIRTOP}/${DIRSRC}/`basename $(@F) _${VER}.so | sed s/lib//`.o ${DIRTOP}/${DIRSRC}/`basename $(@F) _${VER}.so | sed s/lib//`Dict.o ${LIBROOTOBJS} `doc/cernlib_pam mathlib` 1>/dev/null
159 # @ln -sf ${DIRTOP}/${DIRLIB}/$(@F) ${DIRTOP}/${DIRLIB}/$(patsubst %_${VER}.so,%.so,$(@F))
160
161 ${LIBCPPLIBS}: ${LIBCPPSRCS}
162 #
163 # create .o
164 #
165 @(${EGREEN} "Compiling file: "${WHITE} "`basename $(@F) _${VER}.so | sed s/lib//`.cpp"; ${RESET})
166 @cd ${DIRSRC} &>/dev/null && ${CXX} ${CXXFLAGS} -c `basename $(@F) _${VER}.so | sed s/lib//`.cpp -I${DIRTOP}/${DIRINC} -I${DIRTOP} -I${PAM_YODA}/include/yoda/ -I${NROOTINC} -I${PAM_INC} ;
167 #
168 # create .so
169 #
170 @(${EGREEN} "Compiling shared library: "${WHITE} "$@"; ${RESET})
171 @${CXX} ${CXXFLAGS} -Xlinker -soname=$(@F) -shared -o $@ -lg2c -I${DIRTOP}/${DIRINC} -I${DIRTOP} -I${PAM_YODA}/include/yoda/ -I${PAM_INC} ${DIRTOP}/${DIRSRC}/`basename $(@F) _${VER}.so | sed s/lib//`.o 1>/dev/null
172
173
174 ${CXXEXELIBS}: ${COBJS} ${FOBJS} ${CXXEXEOBJS}
175 @(${EVIOLET} "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *")
176 @(${EGREEN} "Creating exec file: "${WHITE} "$@"; ${RESET})
177 @${CXX} ${CXXFLAGS} -o ${DIRBIN}/$@ ${DIRLIB}/$@.o -I${DIRTOP}/${DIRINC} -I${PAM_INC} -I${PAM_YODA}/include/yoda/ ${PAM_YODA}/lib/libyoda.so ${FOBJS} ${COBJS} ${FULLLIBS} ${OTHERLIBS} -lThread `root-config --cflags --glibs` -lMinuit `doc/cernlib_pam mathlib` ;
178
179 # A small target to check environmental variables
180 %_env:
181 @${test_env}
182
183 .PHONY: install installdoc installlib installmacros installinc installexe installcmacro
184 .PHONY: clean depclean info mkbindir mklibdir testcern testpamenv test
185
186 mkbindir: ${DIRBIN}
187 ${DIRBIN}:
188 @${test_and_mk}
189
190 mklibdir: ${DIRLIB}
191 ${DIRLIB}:
192 @${test_and_mk}
193
194 # Here what has to be deleted in clean target
195 clean: TOBEDEL= ${DIRSRC}/*.o ${DIRSRC}/*Dict.cpp ${DIRSRC}/*Dict.h ${FOBJS} ${FULLLIBS} ${DIRBIN}/${CXXEXELIBS} ${COBJS} ${CXXEXEOBJS}
196 clean:
197 @${test_and_rm}
198
199 distclean: clean
200 distclean: TOBEDEL= ${DIRBIN} ${DIRLIB}
201 distclean:
202 @${test_and_rm}
203
204 forceinstall: FORCE=-f
205 forceinstall: install
206
207 upgrade: FORCE=-u
208 upgrade: install
209
210 install: installlib installinc installmacros installcalib installdoc installexe installcmacro
211
212 installlib: LINK=y
213 installlib: TOBEMOVED= $(FULLLIBS:${DIRLIB}%=${PAM_LIB}%)
214 installlib: ORIGIN=${DIRLIB}
215 installlib:
216 @${test_and_cp}
217
218 installcmacro: LINK=y
219 installcmacro: TOBEMOVED= $(FULLMACROCLIBS:${DIRLIB}%=${PAM_LIB}%)
220 installcmacro: ORIGIN=${DIRLIB}
221 installcmacro:
222 @${test_and_cp}
223
224 installinc: TOBEMOVED= $(INCSRCS:${DIRINC}/%=${PAM_INC}/%)
225 installinc: ORIGIN=${DIRINC}
226 installinc:
227 @${test_and_cp}
228
229 installexe: TOBEMOVED= $(EXESRCS:${DIRBIN}/%=${PAM_BIN}/%)
230 installexe: ORIGIN=${DIRBIN}
231 installexe:
232 @${test_and_cp}
233
234 installmacros: TOBEMOVED= $(MACROSSRCS:${DIRMACROS}/%=${PAM_MACROS}/%)
235 installmacros: ORIGIN=${DIRMACROS}
236 installmacros:
237 @${test_and_cp}
238
239 installcalib: TOBEMOVED= $(CALIBFILES:${DIRCALIB}/%=${PAM_CALIB}/%)
240 installcalib: ORIGIN=${DIRCALIB}
241 installcalib:
242 @${test_and_cp}
243
244 installdoc: TOBEMOVED= $(DOCFILES:${DIRDOC}/%=${PAM_DOC}/%)
245 installdoc: ORIGIN=${DIRDOC}
246 installdoc:
247 @${test_and_cp}
248
249 #mkverpath:
250 # @echo '#include <TSystem.h>' > ${DIRTOP}/${DIRSRC}/TrkVerl2.cpp; echo ' void info(){ printf("\nTracker Level2 flight package version: ${VER}\n\nCompiled on '${TODAY}' with: '${GCCVER}'\n\nOn: '${UNAMEA}'\n\n"); }' >> ${DIRTOP}/${DIRSRC}/TrkVerl2.cpp
251 # @sleep 0.8
252
253
254
255 info:
256 @echo " "
257 @${EGREEN} "Infos for package :" ${WHITE} ${PACKAGE}
258 @${EGREEN} " VERSION :" ${WHITE} ${VER}
259 @${EGREEN} " EXECUTABLES :" ${WHITE} ${EXECUTABLES}
260 @${EGREEN} " INCLUDES :" ${WHITE} ${INCLUDE}
261 @${EGREEN} " LIBS :" ${WHITE} ${LIBS}
262 @${EGREEN} " DOCS :" ${WHITE} ${DOCS}
263 @${EGREEN} " SRCS :" ${WHITE} ${SRCS}
264 @${EGREEN} " MACROS :" ${WHITE} ${MACROS}
265 @echo " "
266 @${RESET}
267
268 test: testpamenv
269
270 testpamenv: ${PAM_ENV}
271
272 root-config: OPT=--cflags
273 root-config:
274 @${test_cmd}
275
276 # Here follows some usefull macros
277 define test_and_cp
278 wd=`pwd`;\
279 for i in ${TOBEMOVED} ; do \
280 wv=$${i##/*/}; \
281 dest=$${i/$${wv}/}; \
282 ${EGREEN} "Testing for :" ${WHITE} "$${i}" ; ${RESET}; \
283 if [ ! "${FORCE}" ] ; then \
284 if [ ! -f $${i} ]; then \
285 ${EGREEN} "Copying : "${WHITE} ${ORIGIN}/$${i##/*/} ;\
286 ${EGREEN} " to: "${WHITE} $${i} ; ${RESET}; \
287 cp ${ORIGIN}/$${i##/*/} $${i}; \
288 else \
289 ${ERED} "File already exist !!!! Please delete it " ${WHITE}; ${RESET}; \
290 fi;\
291 else \
292 if [ "${FORCE}" == "-u" ] ; then \
293 if [ "`basename $${i}`" != "`basename $${i} _${VER}.so`" ]; then \
294 ${EYELLOW} "Removing: "${WHITE} ${PAM_LIB}/`basename $${i} _${VER}.so`_v*r*.so; ${RESET}; \
295 rm -f ${PAM_LIB}/`basename $${i} _${VER}.so`_v*r*.so ; \
296 ${EGREEN} "Copying : "${WHITE} ${ORIGIN}/$${i##/*/} ;\
297 ${EGREEN} " to: "${WHITE} $${i} ; ${RESET}; \
298 cp ${ORIGIN}/$${i##/*/} $${i}; \
299 else \
300 ${EYELLOW} " Forcing copy: "${WHITE} ${ORIGIN}/$${i##/*/} ;\
301 ${EYELLOW} " to: "${WHITE} $${i} ; ${RESET}; \
302 cp -f ${ORIGIN}/$${i##/*/} $${i}; \
303 fi; \
304 else \
305 ${EYELLOW} " Forcing copy: "${WHITE} ${ORIGIN}/$${i##/*/} ;\
306 ${EYELLOW} " to: "${WHITE} $${i} ; ${RESET}; \
307 cp ${FORCE} ${ORIGIN}/$${i##/*/} $${i}; \
308 fi;\
309 fi ;\
310 if [ ! -z ${LINK} ] ; then \
311 ${EGREEN} "Creating symlink from : "${WHITE} $${wv/_${VER}/} ;\
312 ${EGREEN} " to : "${WHITE} $${i##/*/} ; ${RESET}; \
313 cd $${dest}; \
314 ln -sf $${wv} $${wv/_${VER}/}; \
315 cd $${wd}; \
316 fi \
317 done
318 endef
319
320 define test_and_mk
321 ${EGREEN} "Testing for :" ${WHITE} "$@"; ${RESET}
322 test -d "$@" || \
323 (${EGREEN} "Creating : "${WHITE} "$@"; ${RESET}; mkdir -p $@)
324 endef
325
326 define test_env
327 ${EGREEN} "Testing for env:" ${WHITE} $(patsubst %_env,%,$@); ${RESET}
328 printenv $(patsubst %_env,%,$@) 1>/dev/null || \
329 (${ERED} "ERROR, variable : "${WHITE} $(patsubst %_env,%,$@) \
330 ${RED} "not defined !!! Check your env. settings"; \
331 ${RESET}; exit 1)
332 ${EGREEN} " Defined:" ${WHITE} $${$(patsubst %_env,%,$@)}; ${RESET}
333 endef
334
335 define test_cmd
336 ${EGREEN} "Testing for cmd:" ${WHITE} $@ ${OPT}; ${RESET}
337 $@ ${OPT} 1>/dev/null 2>&1 || \
338 (${ERED} "ERROR, command : "${WHITE} $@ ${OPT}\
339 ${RED} "not found !!! Check your installation"; \
340 ${RESET}; exit 1)
341 ${EGREEN} " Present:" ${WHITE} $@ ${OPT}; ${RESET}
342 endef
343
344 define test_and_rm
345 for i in ${TOBEDEL}; do \
346 test -d $${i} || (${ERED} "Removing file :"${WHITE} $${i}; ${RESET}; \
347 rm -f $${i} ); \
348 test ! -d $${i} || (${ERED} "Removing dir :"${WHITE} $${i}; ${RESET}; \
349 rm -rf $${i} ); \
350 done
351 endef

  ViewVC Help
Powered by ViewVC 1.1.23