/[PAMELA software]/PamelaLevel2/Makefile
ViewVC logotype

Contents of /PamelaLevel2/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.28 - (show annotations) (download)
Tue Aug 4 13:58:46 2009 UTC (15 years, 4 months ago) by mocchiut
Branch: MAIN
Changes since 1.27: +17 -5 lines
Changed to work with GCC 4.x (gfortran) + ROOT >= 5.24

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

  ViewVC Help
Powered by ViewVC 1.1.23