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

Contents of /DarthVader/CalorimeterLevel2/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.40 - (show annotations) (download)
Fri Oct 31 15:48:52 2008 UTC (16 years, 1 month ago) by mocchiut
Branch: MAIN
Changes since 1.39: +6 -3 lines
Compilation variables changed to speed up execution

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

  ViewVC Help
Powered by ViewVC 1.1.23