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

Contents of /calo/flight/CaloHK/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


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

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

  ViewVC Help
Powered by ViewVC 1.1.23