/[PAMELA software]/tracker/flight/TrkNuclei/Makefile
ViewVC logotype

Contents of /tracker/flight/TrkNuclei/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (show annotations) (download)
Tue Mar 30 08:02:47 2010 UTC (14 years, 8 months ago) by mocchiut
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +18 -4 lines
Changes in the Makefile to compile under GCC4

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

  ViewVC Help
Powered by ViewVC 1.1.23