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

Contents of /DarthVader/CalorimeterLevel2/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.39 - (show annotations) (download)
Tue Sep 23 07:41:45 2008 UTC (16 years, 2 months ago) by mocchiut
Branch: MAIN
Changes since 1.38: +6 -6 lines
Added -m32 flag to enable cross compilation

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

  ViewVC Help
Powered by ViewVC 1.1.23