/[PAMELA software]/DarthVader/Makefile
ViewVC logotype

Contents of /DarthVader/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (show annotations) (download)
Fri Jul 14 14:08:29 2006 UTC (18 years, 4 months ago) by mocchiut
Branch: MAIN
CVS Tags: v1r01beta
Changes since 1.5: +1 -1 lines
Bug fixed in GetMatrix ToF method

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

  ViewVC Help
Powered by ViewVC 1.1.23