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

Contents of /calo/flight/CaloProfile/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.9 - (show annotations) (download)
Thu Jan 23 11:23:55 2014 UTC (10 years, 10 months ago) by mocchiut
Branch: MAIN
CVS Tags: HEAD
Changes since 1.8: +3 -3 lines
Compilation warnings using GCC4.7 fixed

1 # Calorimeter profile plugin
2 # SOFTWARE VERSION
3 VER= v3r02
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 ${PAM_BIT}
27 CFLAGS=-Wall -O3 -fPIC -pthread ${PAM_BIT}
28 #CFLAGS=-Wall -g -fPIC -pthread ${PAM_BIT}
29 # Enviroment:
30 GCCVER=`gcc --version | head -1`
31 UNAMEA=`uname -a`
32 TODAY=`date`
33 # F77
34 ifeq ($(GCC4),)
35 export GCCVERS=$(shell echo `gcc -dumpversion | sed 's/\./\ /g'`)
36 export GCCVERMAJ=$(word 1,$(GCCVERS))
37 export GCC4=$(shell echo `echo "${GCCVERMAJ} > 3" |bc -l`)
38 endif
39 ifeq ($(GCC4),1)
40 F77=gfortran
41 LG2C=-lgfortran
42 EXTRAOPT=
43 else
44 F77=g77
45 LG2C=-lg2c
46 EXTRAOPT=-Wno-globals -fvxt
47 endif
48 #F77FLAGS= -Wall -Wno-globals -fvxt -fno-automatic -fbounds-check -g -extend_source -static -fno-backslash ${PAM_BIT}
49 F77FLAGS= -Wall -funroll-loops -fPIC $(EXTRAOPT) -fno-automatic -fbounds-check -extend_source -static -fno-backslash ${PAM_BIT}
50 # C++
51 CXX=g++
52 #CXXFLAGS=-Wall -O -fPIC -pthread -g ${PAM_BIT}
53 CXXFLAGS=-Wall -O3 -fPIC -pthread ${PAM_BIT}
54 # ROOTCINT
55 ROOTCINT=rootcint
56 # Here the variables definig the local directories
57 DIRTOP=${shell pwd}
58 DIRLIB=lib/${ARCH}/
59 DIRBIN=bin/${ARCH}/
60 DIRSRC=src
61 DIRINC=inc
62 DIRDOC=doc
63 DIRMACROS=macros
64 DIRCALIB=calib
65 # Here the PAMELA environmental variables to be checked
66 PAM_ENV= PAM_BIN_env PAM_LIB_env PAM_INC_env PAM_DOC_env PAM_CALIB_env PAM_YODA_env
67 # Here the local variables used to build the targets
68 #-------------------------------------------------
69 FSRCS=
70 FOBJS=$(FSRCS:${DIRSRC}/F77/%.f=${DIRLIB}/%.o)
71 #-------------------------------------------------
72 CSRCS=
73 COBJS=$(CSRCS:${DIRSRC}%.cpp=${DIRLIB}/%.o)
74 #-------------------------------------------------
75 # librerie utilizzabili da root (ci deve essere anche il ***LinkDef.h )
76 LIBROOTSRCS=${DIRSRC}/CaloProfile.cpp
77 LIBROOTLIBS=$(LIBROOTSRCS:${DIRSRC}/%.cpp=${DIRLIB}/lib%_${VER}.so)
78 LIBROOTOBJS=
79 LIBROOTCLIBS=libCaloProfile
80 FULLROOTCLIBS=$(LIBROOTCLIBS:%=${DIRLIB}/%_${VER}.so)
81 #-------------------------------------------------
82 # librerie C++ NON utilizzabili da root
83 LIBCPPSRCS=
84 LIBCPPLIBS=$(LIBCPPSRCS:${DIRSRC}/%.cpp=${DIRLIB}/lib%_${VER}.so)
85 LIBCPPCLIBS=
86 FULLCPPCLIBS=$(LIBCPPCLIBS:%=${DIRLIB}/%_${VER}.so)
87 #-------------------------------------------------
88 # librerie F77 NON utilizzabili da root
89 LIBF77SRCS=
90 LIBF77OBJS= $(LIBF77SRCS:${DIRSRC}/F77/%.f=${DIRLIB}/%.o)
91 LIBF77LIBS= $(LIBF77SRCS:${DIRSRC}/F77/%.f=${DIRLIB}/lib%_${VER}.so)
92 LIBF77CLIBS=
93 FULLF77CLIBS=$(LIBF77CLIBS:%=${DIRLIB}/%_${VER}.so)
94 #-------------------------------------------------
95 FULLLIBS=${FULLROOTCLIBS} ${FULLCPPCLIBS} ${FULLF77CLIBS}
96
97 #-------------------------------------------------
98 # eseguibile
99 CXXEXESRCS=
100 CXXEXEOBJS=$(CXXEXESRCS:${DIRSRC}%.cpp=${DIRLIB}%.o)
101 CXXEXELIBS:=
102
103 OTHERLIBS=
104 #-------------------------------------------------
105 # variabili per l'installazione
106 EXESRCS=
107 INCSRCS=${DIRINC}/CaloProfile.h
108 MACROSSRCS=
109 CALIBFILES=
110 DOCFILES=
111 # Here the Variables used for info target
112 PACKAGE=Tracker flight software
113 EXECUTABLES=${EXESRCS}
114 LIBS= ${FULLLIBS} ${OTHERLIBS}
115 DOCS=
116 SRCS=
117 MACROS= ${MACROSSRCS}
118 INCLUDE= ${INCSRCS}
119 #
120 TOBEDEL = junk
121 ROOTINC=$$${shell root-config --incdir}
122 NROOTINC=${shell root-config --incdir}
123 ROOTVERS=$(shell echo `root-config --version | sed 's/\./\ /g' | sed 's/\//\ /g' `)
124 ROOTMAJ=$(word 1,$(ROOTVERS))
125 ROOTMIN=$(word 2,$(ROOTVERS))
126 # Let's start
127 all : test mkbindir mklibdir ${LIBF77LIBS} ${LIBROOTLIBS} ${LIBCPPLIBS} ${CXXEXELIBS}
128 all:
129 @echo -e ${GREEN} ""
130 @(${EGREEN} " Finished, now you can install the package \n (use: make install or make upgrade or make forceinstall) "; ${RESET})
131 @echo -e ${GREEN} ""
132 @if [ ${ROOTMAJ} -lt 5 ]||([ ${ROOTMAJ} -eq 5 ]&&[ ${ROOTMIN} -lt 24 ]); then (${ERED} " W A R N I N G ! ! old ROOT version (${ROOTMAJ}.${ROOTMIN})\n The longitudinal fit will fail - upgrade ROOT to version >= 5.24! \n"; ${RESET}); fi;
133 @echo -e ${GREEN} ""
134 @${RESET}
135
136 # Here some general rules to produce objects in our local dir
137 ${DIRLIB}/%.o: ${DIRSRC}/%.cpp
138 @(${EYELLOW} " C++ object ------------------------")
139 @(${EGREEN} "Creating object file: "${WHITE} "$@"; ${RESET})
140 @${CXX} ${CXXFLAGS} -c -o $@ ${DIRSRC}/`basename ${@} .o`.cpp -I${DIRINC} -I${PAM_INC} -I${PAM_YODA}/include/yoda/ `root-config --cflags`
141
142 ${DIRLIB}/%.o : ${DIRSRC}/F77/%.f
143 @(${EYELLOW} " F77 object ------------------------")
144 @(${EGREEN} "Creating object file: "${WHITE} "$@"; ${RESET})
145 @${F77} ${F77FLAGS} -c -o $@ ${DIRSRC}/F77/`basename ${@} .o`.f -I${DIRINC}/F77 -I${NROOTINC} -I${PAM_YODA}/include/yoda
146
147
148 # .so from .o fortran
149 ${LIBF77LIBS}: ${LIBF77OBJS}
150 @(${EYELLOW} " F77 shared library --------------------------")
151 @(${EGREEN} "Creating library: "${WHITE} "$@"; ${RESET})
152 @${CXX} ${CXXFLAGS} -Xlinker -soname=$(@F) -shared -o $@ $^ $(LG2C) `doc/cernlib_pam mathlib`
153
154
155 ${LIBROOTLIBS}: ${LIBROOTSRCS} ${FOBJS}
156 @(${EYELLOW} " ROOT library ------------------------")
157 @(${EGREEN} "Creating file: "${WHITE} "`basename $(@F) _${VER}.so | sed s/lib//`Dict.cpp"; ${RESET})
158 #
159 # Create *Dict.cpp and *Dict.h
160 #
161 # @${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
162 @${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
163 #
164 # 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!
165 # should be fixed some time changing names...
166 #
167 # create .o
168 #
169 @(${EGREEN} "Compiling file: "${WHITE} "`basename $(@F) _${VER}.so | sed s/lib//`.cpp"; ${RESET})
170 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};
171 @(${EGREEN} "Compiling file: "${WHITE} "`basename $(@F) _${VER}.so | sed s/lib//`Dict.cpp"; ${RESET})
172 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};
173 #
174 # create .so
175 #
176 @(${EGREEN} "Compiling shared library: "${WHITE} "$@"; ${RESET})
177 ${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
178 # @ln -sf ${DIRTOP}/${DIRLIB}/$(@F) ${DIRTOP}/${DIRLIB}/$(patsubst %_${VER}.so,%.so,$(@F))
179
180 ${LIBCPPLIBS}: ${LIBCPPSRCS}
181 #
182 # create .o
183 #
184 @(${EGREEN} "Compiling file: "${WHITE} "`basename $(@F) _${VER}.so | sed s/lib//`.cpp"; ${RESET})
185 @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};
186 #
187 # create .so
188 #
189 @(${EGREEN} "Compiling shared library: "${WHITE} "$@"; ${RESET})
190 @${CXX} ${CXXFLAGS} -Xlinker -soname=$(@F) -shared -o $@ $(LG2C) -I${DIRTOP}/${DIRINC} -I${DIRTOP} -I${PAM_INC} -I${PAM_YODA}/include/yoda/ ${DIRTOP}/${DIRSRC}/`basename $(@F) _${VER}.so | sed s/lib//`.o 1>/dev/null
191
192
193 ${CXXEXELIBS}: ${COBJS} ${FOBJS} ${CXXEXEOBJS}
194 @(${EVIOLET} "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *")
195 @(${EGREEN} "Creating exec file: "${WHITE} "$@"; ${RESET})
196 @${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` `doc/cernlib_pam mathlib` ;
197
198 # A small target to check environmental variables
199 %_env:
200 @${test_env}
201
202 .PHONY: install installdoc installlib installmacros installinc installexe installcmacro
203 .PHONY: clean depclean info mkbindir mklibdir testcern testpamenv test
204
205 mkbindir: ${DIRBIN}
206 ${DIRBIN}:
207 @${test_and_mk}
208
209 mklibdir: ${DIRLIB}
210 ${DIRLIB}:
211 @${test_and_mk}
212
213 # Here what has to be deleted in clean target
214 clean: TOBEDEL= ${DIRSRC}/*.o ${DIRSRC}/*Dict.cpp ${DIRSRC}/*Dict.h ${FOBJS} ${FULLLIBS} ${DIRBIN}/${CXXEXELIBS} ${COBJS} ${CXXEXEOBJS}
215 clean:
216 @${test_and_rm}
217
218 distclean: clean
219 distclean: TOBEDEL= ${DIRBIN} ${DIRLIB}
220 distclean:
221 @${test_and_rm}
222
223 forceinstall: FORCE=-f
224 forceinstall: install
225
226 upgrade: FORCE=-u
227 upgrade: install
228
229 install: installlib installinc installmacros installcalib installdoc installexe installcmacro
230
231 installlib: LINK=y
232 installlib: TOBEMOVED= $(FULLLIBS:${DIRLIB}%=${PAM_LIB}%)
233 installlib: ORIGIN=${DIRLIB}
234 installlib:
235 @${test_and_cp}
236
237 installcmacro: LINK=y
238 installcmacro: TOBEMOVED= $(FULLMACROCLIBS:${DIRLIB}%=${PAM_LIB}%)
239 installcmacro: ORIGIN=${DIRLIB}
240 installcmacro:
241 @${test_and_cp}
242
243 installinc: TOBEMOVED= $(INCSRCS:${DIRINC}/%=${PAM_INC}/%)
244 installinc: ORIGIN=${DIRINC}
245 installinc:
246 @${test_and_cp}
247
248 installexe: TOBEMOVED= $(EXESRCS:${DIRBIN}/%=${PAM_BIN}/%)
249 installexe: ORIGIN=${DIRBIN}
250 installexe:
251 @${test_and_cp}
252
253 installmacros: TOBEMOVED= $(MACROSSRCS:${DIRMACROS}/%=${PAM_MACROS}/%)
254 installmacros: ORIGIN=${DIRMACROS}
255 installmacros:
256 @${test_and_cp}
257
258 installcalib: TOBEMOVED= $(CALIBFILES:${DIRCALIB}/%=${PAM_CALIB}/%)
259 installcalib: ORIGIN=${DIRCALIB}
260 installcalib:
261 @${test_and_cp}
262
263 installdoc: TOBEMOVED= $(DOCFILES:${DIRDOC}/%=${PAM_DOC}/%)
264 installdoc: ORIGIN=${DIRDOC}
265 installdoc:
266 @${test_and_cp}
267
268 #mkverpath:
269 # @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
270 # @sleep 0.8
271
272
273
274 info:
275 @echo " "
276 @${EGREEN} "Infos for package :" ${WHITE} ${PACKAGE}
277 @${EGREEN} " VERSION :" ${WHITE} ${VER}
278 @${EGREEN} " EXECUTABLES :" ${WHITE} ${EXECUTABLES}
279 @${EGREEN} " INCLUDES :" ${WHITE} ${INCLUDE}
280 @${EGREEN} " LIBS :" ${WHITE} ${LIBS}
281 @${EGREEN} " DOCS :" ${WHITE} ${DOCS}
282 @${EGREEN} " SRCS :" ${WHITE} ${SRCS}
283 @${EGREEN} " MACROS :" ${WHITE} ${MACROS}
284 @echo " "
285 @${RESET}
286
287 test: testpamenv
288
289 testpamenv: ${PAM_ENV}
290
291 root-config: OPT=--cflags
292 root-config:
293 @${test_cmd}
294
295 # Here follows some usefull macros
296 define test_and_cp
297 wd=`pwd`;\
298 for i in ${TOBEMOVED} ; do \
299 wv=$${i##/*/}; \
300 dest=$${i/$${wv}/}; \
301 ${EGREEN} "Testing for :" ${WHITE} "$${i}" ; ${RESET}; \
302 if [ ! "${FORCE}" ] ; then \
303 if [ ! -f $${i} ]; then \
304 ${EGREEN} "Copying : "${WHITE} ${ORIGIN}/$${i##/*/} ;\
305 ${EGREEN} " to: "${WHITE} $${i} ; ${RESET}; \
306 cp ${ORIGIN}/$${i##/*/} $${i}; \
307 else \
308 ${ERED} "File already exist !!!! Please delete it " ${WHITE}; ${RESET}; \
309 fi;\
310 else \
311 if [ "${FORCE}" == "-u" ] ; then \
312 if [ "`basename $${i}`" != "`basename $${i} _${VER}.so`" ]; then \
313 ${EYELLOW} "Removing: "${WHITE} ${PAM_LIB}/`basename $${i} _${VER}.so`_v*r*.so; ${RESET}; \
314 rm -f ${PAM_LIB}/`basename $${i} _${VER}.so`_v*r*.so ; \
315 ${EGREEN} "Copying : "${WHITE} ${ORIGIN}/$${i##/*/} ;\
316 ${EGREEN} " to: "${WHITE} $${i} ; ${RESET}; \
317 cp ${ORIGIN}/$${i##/*/} $${i}; \
318 else \
319 ${EYELLOW} " Forcing copy: "${WHITE} ${ORIGIN}/$${i##/*/} ;\
320 ${EYELLOW} " to: "${WHITE} $${i} ; ${RESET}; \
321 cp -f ${ORIGIN}/$${i##/*/} $${i}; \
322 fi; \
323 else \
324 ${EYELLOW} " Forcing copy: "${WHITE} ${ORIGIN}/$${i##/*/} ;\
325 ${EYELLOW} " to: "${WHITE} $${i} ; ${RESET}; \
326 cp ${FORCE} ${ORIGIN}/$${i##/*/} $${i}; \
327 fi;\
328 fi ;\
329 if [ ! -z ${LINK} ] ; then \
330 ${EGREEN} "Creating symlink from : "${WHITE} $${wv/_${VER}/} ;\
331 ${EGREEN} " to : "${WHITE} $${i##/*/} ; ${RESET}; \
332 cd $${dest}; \
333 ln -sf $${wv} $${wv/_${VER}/}; \
334 cd $${wd}; \
335 fi \
336 done
337 endef
338
339 define test_and_mk
340 ${EGREEN} "Testing for :" ${WHITE} "$@"; ${RESET}
341 test -d "$@" || \
342 (${EGREEN} "Creating : "${WHITE} "$@"; ${RESET}; mkdir -p $@)
343 endef
344
345 define test_env
346 ${EGREEN} "Testing for env:" ${WHITE} $(patsubst %_env,%,$@); ${RESET}
347 printenv $(patsubst %_env,%,$@) 1>/dev/null || \
348 (${ERED} "ERROR, variable : "${WHITE} $(patsubst %_env,%,$@) \
349 ${RED} "not defined !!! Check your env. settings"; \
350 ${RESET}; exit 1)
351 ${EGREEN} " Defined:" ${WHITE} $${$(patsubst %_env,%,$@)}; ${RESET}
352 endef
353
354 define test_cmd
355 ${EGREEN} "Testing for cmd:" ${WHITE} $@ ${OPT}; ${RESET}
356 $@ ${OPT} 1>/dev/null 2>&1 || \
357 (${ERED} "ERROR, command : "${WHITE} $@ ${OPT}\
358 ${RED} "not found !!! Check your installation"; \
359 ${RESET}; exit 1)
360 ${EGREEN} " Present:" ${WHITE} $@ ${OPT}; ${RESET}
361 endef
362
363 define test_and_rm
364 for i in ${TOBEDEL}; do \
365 test -d $${i} || (${ERED} "Removing file :"${WHITE} $${i}; ${RESET}; \
366 rm -f $${i} ); \
367 test ! -d $${i} || (${ERED} "Removing dir :"${WHITE} $${i}; ${RESET}; \
368 rm -rf $${i} ); \
369 done
370 endef

  ViewVC Help
Powered by ViewVC 1.1.23