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

Contents of /DarthVader/ToFLevel2/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.10 - (show annotations) (download)
Wed Dec 6 08:54:56 2006 UTC (17 years, 11 months ago) by mocchiut
Branch: MAIN
Changes since 1.9: +1 -1 lines
ToF software version upgraded

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

  ViewVC Help
Powered by ViewVC 1.1.23