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

Contents of /DarthVader/S4Level2/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.7 - (show annotations) (download)
Tue Nov 7 17:12:50 2006 UTC (18 years ago) by mocchiut
Branch: MAIN
Changes since 1.6: +4 -4 lines
TClassTable::Add bug fixed

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

  ViewVC Help
Powered by ViewVC 1.1.23