/[PAMELA software]/DarthVader/CalorimeterLevel2/Makefile
ViewVC logotype

Contents of /DarthVader/CalorimeterLevel2/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.22 - (show annotations) (download)
Fri Mar 30 11:17:13 2007 UTC (17 years, 8 months ago) by mocchiut
Branch: MAIN
Changes since 1.21: +1 -1 lines
Shift inversion on X views bug fixed

1 # Calorimeter flight analysis software
2 # SOFTWARE VERSION
3 VER= v4r06
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 -O4 -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 -fPIC -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 -O4 -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 #DIRLIB=lib/${ARCH}
47 #DIRBIN=bin/${ARCH}
48 DIRSRC=src
49 DIRINC=inc
50 DIRDOC=doc
51 DIRMACROS=macros
52 DIRCALIB=calib
53 # Here the PAMELA environmental variables to be checked
54 PAM_ENV= PAM_BIN_env PAM_LIB_env PAM_INC_env PAM_DOC_env PAM_YODA_env
55
56 # Here the local variables used to build the targets
57 # -- F77 - no libraries --
58 FSRCS=${DIRSRC}/direction.for \
59 ${DIRSRC}/lastriscia.for \
60 ${DIRSRC}/millim.for \
61 ${DIRSRC}/nshower.for \
62 ${DIRSRC}/nointer.for \
63 ${DIRSRC}/elio.for \
64 ${DIRSRC}/nuclei.for \
65 ${DIRSRC}/cluster.for \
66 ${DIRSRC}/cluster2.for \
67 ${DIRSRC}/laterale.for \
68 ${DIRSRC}/baric.for \
69 ${DIRSRC}/selftrig.for \
70 ${DIRSRC}/calol2cm.for \
71 ${DIRSRC}/calol2tr.for
72 FOBJS=$(FSRCS:${DIRSRC}%.for=${DIRLIB}%.o)
73
74 # -- CPP - no libraries --
75 CPPSRCS=
76 CPPOBJS=$(CPPSRCS:${DIRSRC}%.cpp=${DIRLIB}%.o)
77
78 # -- C - no libraries --
79 CSRCS=${DIRSRC}/delay.c
80 COBJS=$(CSRCS:${DIRSRC}%.c=${DIRLIB}%.o)
81
82 # -- CPP - ROOT libraries --
83 LIBROOTSRCS=${DIRSRC}/CaloLevel0.cpp \
84 ${DIRSRC}/CaloLevel1.cpp \
85 ${DIRSRC}/CaloLevel2.cpp
86
87 LIBROOTLIBS=$(LIBROOTSRCS:${DIRSRC}/%.cpp=${DIRLIB}/lib%_${VER}.so)
88 #LIBROOTOBJS=${DIRLIB}/millim.o
89 LIBROOTOBJS=${FOBJS} ${COBJS}
90 LIBROOTCLIBS=libCaloLevel2 libCaloLevel1 libCaloLevel0
91 FULLROOTCLIBS=$(LIBROOTCLIBS:%=${DIRLIB}/%_${VER}.so)
92
93 # -- CPP - NON-ROOT libraries --
94 LIBCPPSRCS=${DIRSRC}/CaloCore.cpp \
95 ${DIRSRC}/CaloVerl2.cpp
96 LIBCPPLIBS=$(LIBCPPSRCS:${DIRSRC}/%.cpp=${DIRLIB}/lib%_${VER}.so)
97 LIBCPPCLIBS=libCaloCore libCaloVerl2
98 FULLLIBCPPLIBS=$(LIBCPPCLIBS:%=${DIRLIB}/%_${VER}.so)
99
100 # -- CPP - Executables --
101 CXXEXESRCS=${DIRSRC}/CalorimeterLevel2.cpp
102 CXXEXEOBJS=$(CXXEXESRCS:${DIRSRC}%.cpp=${DIRLIB}%.o)
103 CXXEXELIBS:=CalorimeterLevel2
104
105 # -- list of tracker objects needed to link
106 TRKOBJS=${DIRLIB}/libTrkLevel2.so ${PAM_LIB}/libGLTables.so ${DIRLIB}/libRunInfo.so
107
108 # -- directory where to find tracker headers needed to compile
109 SUBDIR=../RunInfo ../TrackerLevel2
110 SUBINC=$(shell for dir in `echo ${SUBDIR}`; do echo -I$${dir}/inc; done)
111
112 # List of all libraries we want to install
113 FULLLIBS = ${FULLROOTCLIBS} ${FULLLIBCPPLIBS}
114
115 # Other objects to install
116 EXESRCS=${DIRBIN}/CalorimeterLevel2
117
118 INCSRCS=${DIRINC}/CaloLevel0.h ${DIRINC}/CaloLevel1.h ${DIRINC}/CaloLevel2.h ${DIRINC}/CaloStruct.h ${DIRINC}/CaloCore.h
119
120 MACROSSRCS=
121
122 CALIBFILES=
123
124 DOCFILES=
125
126 # Here the Variables used for info target
127 PACKAGE=Calorimeter analysis flight software
128 EXECUTABLES= ${EXESRCS}
129 LIBS= ${FULLLIBS}
130 DOCS=
131 SRCS=
132 #SRCS= ${FSRCS} ${CRSCS} ${CXXEXESRCS} ${LIBROOTSRCS} ${LIBCPPSRCS}
133 MACROS= ${MACROSSRCS}
134 INCLUDE= ${INCSRCS}
135 #
136 TOBEDEL = junk
137 ROOTINC=$$${shell root-config --incdir}
138 NROOTINC=${shell root-config --incdir}
139 # Let's start
140 #all: test mkbindir mklibdir mkverpath ${FOBJS} ${CPPOBJS} ${LIBROOTLIBS} ${LIBCPPLIBS} ${CXXEXELIBS}
141 all: prepare libs
142 all:
143 @echo -e ${GREEN} ""
144 @(${EGREEN} " Finished, now you can install the package \n (use: make install or make upgrade or make forceinstall) "; ${RESET})
145 @echo -e ${GREEN} ""
146 @${RESET}
147
148 standalone: all exe
149
150 prepare: test mkbindir mklibdir mkverpath
151
152 exe: prepare ${CXXEXELIBS}
153
154 libs: prepare ${LIBROOTLIBS} ${LIBCPPLIBS}
155
156 # Here some general rules to produce objects in our local dir
157 ${DIRLIB}/%.o: ${DIRSRC}/%.cpp
158 @(${EGREEN} "Creating CPP object file: "${WHITE} "`basename $@`"; ${RESET})
159 @${CXX} ${CXXFLAGS} -c -o $@ ${DIRSRC}/`basename ${@} .o`.cpp -I${DIRINC} ${SUBINC} -I${PAM_YODA}/include/yoda/ -I${PAM_INC}/ `root-config --cflags`
160
161 ${DIRLIB}/%.o: ${DIRSRC}/%.c
162 @(${EGREEN} "Creating C object file: "${WHITE} "`basename $@`"; ${RESET})
163 @${CXX} ${CXXFLAGS} -c -o $@ ${DIRSRC}/`basename ${@} .o`.c -I${DIRINC} ${SUBINC} -I${PAM_YODA}/include/yoda/ -I${PAM_INC}/ `root-config --cflags`
164
165 ${DIRLIB}/%.o: ${DIRSRC}/%.for
166 @(${EGREEN} "Creating F77 object file: "${WHITE} "`basename $@`"; ${RESET})
167 @${F77} ${F77FLAGS} -c -o $@ ${DIRSRC}/`basename ${@} .o`.for -I${DIRINC}
168
169 ${LIBROOTLIBS}: ${LIBROOTSRCS} ${COBJS} ${FOBJS}
170 @(${EGREEN} "ROOTCINT - creating file: "${WHITE} "`basename $(@F) _${VER}.so | sed s/lib//`Dict.cpp"; ${RESET})
171 #
172 # Create *Dict.cpp and *Dict.h
173 #
174 @${ROOTCINT} -f ${DIRSRC}/`basename $(@F) _${VER}.so | sed s/lib//`Dict.cpp -c -I${DIRINC} -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
175 #
176 # create .o
177 #
178 @(${EGREEN} "Compiling CPP file: "${WHITE} "`basename $(@F) _${VER}.so | sed s/lib//`.cpp"; ${RESET})
179 @${CXX} ${CXXFLAGS} -c ${DIRTOP}/${DIRSRC}/`basename $(@F) _${VER}.so | sed s/lib//`.cpp -o ${DIRTOP}/${DIRLIB}/`basename $(@F) _${VER}.so | sed s/lib//`.o -I${DIRTOP}/${DIRINC} -I${DIRTOP} ${SUBINC} -I${PAM_YODA}/include/yoda/ -I${PAM_INC}/ -I${NROOTINC};
180 @(${EGREEN} "Compiling CPP file: "${WHITE} "`basename $(@F) _${VER}.so | sed s/lib//`Dict.cpp"; ${RESET})
181 @${CXX} ${CXXFLAGS} -c ${DIRTOP}/${DIRSRC}/`basename $(@F) _${VER}.so | sed s/lib//`Dict.cpp -o ${DIRTOP}/${DIRLIB}/`basename $(@F) _${VER}.so | sed s/lib//`Dict.o -I${DIRTOP}/${DIRINC} -I${DIRTOP} ${SUBINC} -I${PAM_YODA}/include/yoda/ -I${PAM_INC}/ -I${NROOTINC};
182 #
183 # create .so
184 #
185 @(${EGREEN} "Creating shared library: "${WHITE} "`basename $@`"; ${RESET})
186 @${CXX} ${CXXFLAGS} -Xlinker -soname=$(@F) -shared -o $@ -lg2c -I${DIRTOP}/${DIRINC} -I${DIRTOP} -I${PAM_YODA}/include/yoda/ ${SUBINC} -I${PAM_INC}/ ${DIRTOP}/${DIRLIB}/`basename $(@F) _${VER}.so | sed s/lib//`.o ${DIRTOP}/${DIRLIB}/`basename $(@F) _${VER}.so | sed s/lib//`Dict.o ${LIBROOTOBJS} 1>/dev/null
187 @ln -sf ${DIRTOP}/${DIRLIB}/$(@F) ${DIRTOP}/${DIRLIB}/$(patsubst %_${VER}.so,%.so,$(@F))
188
189 ${LIBCPPLIBS}: ${LIBSRCS} ${COBJS} ${FOBJS}
190 #
191 # create .o
192 #
193 @(${EGREEN} "Compiling CPP file: "${WHITE} "`basename $(@F) _${VER}.so | sed s/lib//`.cpp"; ${RESET})
194 @${CXX} ${CXXFLAGS} -c ${DIRTOP}/${DIRSRC}/`basename $(@F) _${VER}.so | sed s/lib//`.cpp -o ${DIRTOP}/${DIRLIB}/`basename $(@F) _${VER}.so | sed s/lib//`.o -I${DIRTOP}/${DIRINC} ${SUBINC} -I${PAM_YODA}/include/yoda/ -I${PAM_INC}/ -I${NROOTINC};
195 #
196 # create .so
197 #
198 @(${EGREEN} "Creating shared library: "${WHITE} "`basename $@`"; ${RESET})
199 @${CXX} ${CXXFLAGS} -Xlinker -soname=$(@F) -shared -o $@ -lg2c -I${DIRTOP}/${DIRINC} -I${DIRTOP} ${SUBINC} ${SUBINC} -I${PAM_YODA}/include/yoda/ -I${PAM_INC}/ ${DIRTOP}/${DIRLIB}/`basename $(@F) _${VER}.so | sed s/lib//`.o ${FOBJS} ${COBJS} 1>/dev/null
200 @ln -sf ${DIRTOP}/${DIRLIB}/$(@F) ${DIRTOP}/${DIRLIB}/$(patsubst %_${VER}.so,%.so,$(@F))
201
202 ${CXXEXELIBS}: ${CPPOBJS} ${COBJS} ${CXXEXEOBJS}
203 @(${EGREEN} "Creating exec file: "${WHITE} "$@"; ${RESET})
204 # @${CXX} ${CXXFLAGS} -o ${DIRBIN}/$@ ${DIRLIB}/$@.o ${FULLROOTCLIBS} ${FULLLIBCPPLIBS} ${CPPOBJS} ${FOBJS} ${TRKOBJS} ${PAM_YODA}/lib/libyoda.so -I${DIRINC} ${SUBINC} -I${PAM_YODA}/include/yoda/ -lThread `root-config --cflags --glibs` `cernlib mathlib`
205 @${CXX} ${CXXFLAGS} -o ${DIRBIN}/$@ ${DIRLIB}/$@.o ${FULLROOTCLIBS} ${FULLLIBCPPLIBS} ${TRKOBJS} ${CPPOBJS} ${COBJS} ${FOBJS} ${PAM_YODA}/lib/libyoda.so -lThread `root-config --cflags --glibs` `cernlib mathlib`
206
207 # A small target to check environmental variables
208 %_env:
209 @${test_env}
210
211 .PHONY: install installdoc installlib installmacros installinc installexe installcmacro
212 .PHONY: clean depclean info mkbindir mklibdir testcern testpamenv test
213
214 mkbindir: ${DIRBIN}
215 ${DIRBIN}:
216 @${test_and_mk}
217
218 mklibdir: ${DIRLIB}
219 ${DIRLIB}:
220 @${test_and_mk}
221
222 # Here what has to be deleted in clean target
223 clean: TOBEDEL= ${DIRSRC}/*.o ${DIRSRC}/*Dict.cpp ${DIRSRC}/*Dict.h ${FOBJS} ${FULLLIBS} ${DIRBIN}/${CXXEXELIBS} ${CPPOBJS} ${CXXEXEOBJS} ${FULLLINKCLIBS} ${FULLMACROCLIBS} ${FULLLINKMACROCLIBS} ${DIRSRC}/CaloVerl2.cpp
224 clean:
225 @${test_and_rm}
226
227 distclean: clean
228 distclean: TOBEDEL= ${DIRBIN} ${DIRLIB}
229 distclean:
230 @${test_and_rm}
231
232 forceinstall: FORCE=-f
233 forceinstall: install
234 forceinstallstandalone: FORCE=-f
235 forceinstallstandalone: installstandalone
236
237 upgrade: FORCE=-u
238 upgrade: install
239 upgradestandalone: FORCE=-u
240 upgradestandalone: installstandalone
241
242 install: installlib installinc installmacros installcalib installdoc installcmacro
243
244 installstandalone: install installexe
245
246 installlib: LINK=y
247 installlib: TOBEMOVED= $(FULLLIBS:${DIRLIB}%=${PAM_LIB}%)
248 installlib: ORIGIN=${DIRLIB}
249 installlib:
250 @${test_and_cp}
251
252 installcmacro: LINK=y
253 installcmacro: TOBEMOVED= $(FULLMACROCLIBS:${DIRLIB}%=${PAM_LIB}%)
254 installcmacro: ORIGIN=${DIRLIB}
255 installcmacro:
256 @${test_and_cp}
257
258 installinc: TOBEMOVED= $(INCSRCS:${DIRINC}/%=${PAM_INC}/%)
259 installinc: ORIGIN=${DIRINC}
260 installinc:
261 @${test_and_cp}
262
263 installexe: TOBEMOVED= $(EXESRCS:${DIRBIN}/%=${PAM_BIN}/%)
264 installexe: ORIGIN=${DIRBIN}
265 installexe:
266 @${test_and_cp}
267
268 installmacros: TOBEMOVED= $(MACROSSRCS:${DIRMACROS}/%=${PAM_MACROS}/%)
269 installmacros: ORIGIN=${DIRMACROS}
270 installmacros:
271 @${test_and_cp}
272
273 installcalib: TOBEMOVED= $(CALIBFILES:${DIRCALIB}/%=${PAM_CALIB}/%)
274 installcalib: ORIGIN=${DIRCALIB}
275 installcalib:
276 @${test_and_cp}
277
278 installdoc: TOBEMOVED= $(DOCFILES:${DIRDOC}/%=${PAM_DOC}/%)
279 installdoc: ORIGIN=${DIRDOC}
280 installdoc:
281 @${test_and_cp}
282
283 mkverpath:
284 @echo '#include <TSystem.h>' > ${DIRTOP}/${DIRSRC}/CaloVerl2.cpp; echo ' char *CaloInfo(bool print){ if ( print ) printf("\nCalorimeter Level2 flight package version: ${VER}\n\nCompiled on '${TODAY}' with: '${GCCVER}'\n\nOn: '${UNAMEA}'\n\n"); return("${VER}"); }' >> ${DIRTOP}/${DIRSRC}/CaloVerl2.cpp
285 @sleep 0.8
286
287
288
289 info:
290 @echo " "
291 @${EGREEN} "Infos for package :" ${WHITE} ${PACKAGE}
292 @${EGREEN} " VERSION :" ${WHITE} ${VER}
293 @${EGREEN} " EXECUTABLES :" ${WHITE} ${EXECUTABLES}
294 @${EGREEN} " LIBS :" ${WHITE} ${LIBS}
295 @${EGREEN} " DOCS :" ${WHITE} ${DOCS}
296 @${EGREEN} " SRCS :" ${WHITE} ${SRCS}
297 @${EGREEN} " MACROS :" ${WHITE} ${MACROS}
298 @${EGREEN} " INCLUDE :" ${WHITE} ${INCLUDE}
299 @echo " "
300 @${RESET}
301
302 test: testpamenv
303
304 testpamenv: ${PAM_ENV}
305
306 root-config: OPT=--cflags
307 root-config:
308 @${test_cmd}
309
310 # Here follows some usefull macros
311 define test_and_cp
312 wd=`pwd`;\
313 for i in ${TOBEMOVED} ; do \
314 wv=$${i##/*/}; \
315 dest=$${i/$${wv}/}; \
316 ${EGREEN} "Testing for :" ${WHITE} "$${i}" ; ${RESET}; \
317 if [ ! "${FORCE}" ] ; then \
318 if [ ! -f $${i} ]; then \
319 ${EGREEN} "Copying : "${WHITE} ${ORIGIN}/$${i##/*/} ;\
320 ${EGREEN} " to: "${WHITE} $${i} ; ${RESET}; \
321 cp ${ORIGIN}/$${i##/*/} $${i}; \
322 else \
323 ${ERED} "File already exist !!!! Please delete it " ${WHITE}; ${RESET}; \
324 fi;\
325 else \
326 if [ "${FORCE}" == "-u" ] ; then \
327 if [ "`basename $${i}`" != "`basename $${i} _${VER}.so`" ]; then \
328 ${EYELLOW} "Removing: "${WHITE} ${PAM_LIB}/`basename $${i} _${VER}.so`_v*r*.so; ${RESET}; \
329 rm -f ${PAM_LIB}/`basename $${i} _${VER}.so`_v*r*.so ; \
330 ${EGREEN} "Copying : "${WHITE} ${ORIGIN}/$${i##/*/} ;\
331 ${EGREEN} " to: "${WHITE} $${i} ; ${RESET}; \
332 cp ${ORIGIN}/$${i##/*/} $${i}; \
333 else \
334 ${EYELLOW} " Forcing copy: "${WHITE} ${ORIGIN}/$${i##/*/} ;\
335 ${EYELLOW} " to: "${WHITE} $${i} ; ${RESET}; \
336 cp -f ${ORIGIN}/$${i##/*/} $${i}; \
337 fi; \
338 else \
339 ${EYELLOW} " Forcing copy: "${WHITE} ${ORIGIN}/$${i##/*/} ;\
340 ${EYELLOW} " to: "${WHITE} $${i} ; ${RESET}; \
341 cp ${FORCE} ${ORIGIN}/$${i##/*/} $${i}; \
342 fi;\
343 fi ;\
344 if [ ! -z ${LINK} ] ; then \
345 ${EGREEN} "Creating symlink from : "${WHITE} $${wv/_${VER}/} ;\
346 ${EGREEN} " to : "${WHITE} $${i##/*/} ; ${RESET}; \
347 cd $${dest}; \
348 ln -sf $${wv} $${wv/_${VER}/}; \
349 cd $${wd}; \
350 fi \
351 done
352 endef
353
354 define test_and_mk
355 ${EGREEN} "Testing for :" ${WHITE} "$@"; ${RESET}
356 test -d "$@" || \
357 (${EGREEN} "Creating : "${WHITE} "$@"; ${RESET}; mkdir -p $@)
358 endef
359
360 define test_env
361 ${EGREEN} "Testing for env:" ${WHITE} $(patsubst %_env,%,$@); ${RESET}
362 printenv $(patsubst %_env,%,$@) 1>/dev/null || \
363 (${ERED} "ERROR, variable : "${WHITE} $(patsubst %_env,%,$@) \
364 ${RED} "not defined !!! Check your env. settings"; \
365 ${RESET}; exit 1)
366 ${EGREEN} " Defined:" ${WHITE} $${$(patsubst %_env,%,$@)}; ${RESET}
367 endef
368
369 define test_cmd
370 ${EGREEN} "Testing for cmd:" ${WHITE} $@ ${OPT}; ${RESET}
371 $@ ${OPT} 1>/dev/null 2>&1 || \
372 (${ERED} "ERROR, command : "${WHITE} $@ ${OPT}\
373 ${RED} "not found !!! Check your installation"; \
374 ${RESET}; exit 1)
375 ${EGREEN} " Present:" ${WHITE} $@ ${OPT}; ${RESET}
376 endef
377
378 define test_and_rm
379 for i in ${TOBEDEL}; do \
380 test -d $${i} || (${ERED} "Removing file :"${WHITE} $${i}; ${RESET}; \
381 rm -f $${i} ); \
382 test ! -d $${i} || (${ERED} "Removing dir :"${WHITE} $${i}; ${RESET}; \
383 rm -rf $${i} ); \
384 done
385 endef

  ViewVC Help
Powered by ViewVC 1.1.23