/[PAMELA software]/DarthVader/Makefile
ViewVC logotype

Contents of /DarthVader/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download)
Fri May 19 13:15:25 2006 UTC (18 years, 6 months ago) by mocchiut
Branch: MAIN
Branch point for: DarthVader, TriggerLevel2
Initial revision

1 # DarthVader flight analysis software
2 # SOFTWARE VERSION
3 VER= v0r01
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 #MAKE
25 MAKE=make
26 # C
27 CC=gcc
28 #CFLAGS=-Wall -O -fPIC -pthread -g
29 CFLAGS=-Wall -O -fPIC -pthread
30 # Enviroment:
31 GCCVER=`gcc --version | head -1`
32 UNAMEA=`uname -a`
33 TODAY=`date`
34 # F77
35 F77=g77
36 #F77FLAGS= -Wall -Wno-globals -fvxt -fno-automatic -fbounds-check -g -extend_source -static -fno-backslash
37 F77FLAGS= -Wall -Wno-globals -fvxt -fno-automatic -fbounds-check -extend_source -static -fno-backslash
38 # C++
39 CXX=g++
40 #CXXFLAGS=-Wall -O -fPIC -pthread -g
41 CXXFLAGS=-Wall -O -fPIC -pthread
42 # ROOTCINT
43 ROOTCINT=rootcint
44 # Here the variables definig the local directories
45 DIRTOP=${shell pwd}
46 #DIRLIB=../lib/${ARCH}
47 #DIRBIN=../bin/${ARCH}
48 DIRLIB=lib/${ARCH}
49 DIRBIN=bin/${ARCH}
50 DIRSRC=src
51 DIRINC=inc
52 DIRDOC=doc
53 DIRMACROS=macros
54 DIRCALIB=param
55 # Here the PAMELA environmental variables to be checked
56 PAM_ENV= PAM_BIN_env PAM_LIB_env PAM_INC_env PAM_DOC_env PAM_CALIB_env PAM_YODA_env
57
58 # Here the local variables used to build the targets
59 # -- F77 - no libraries --
60 FSRCS=
61 FOBJS=$(FSRCS:${DIRSRC}%.for=${DIRLIB}%.o)
62
63 # -- CPP - no libraries --
64 CPPSRCS=${DIRSRC}/DarthVaderVerl2.cpp
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=
73
74 LIBROOTLIBS=$(LIBROOTSRCS:${DIRSRC}/%.cpp=${DIRLIB}/lib%_${VER}.so)
75 LIBROOTCLIBS=
76 FULLROOTCLIBS=$(LIBROOTCLIBS:%=${DIRLIB}/%_${VER}.so)
77
78 # -- CPP - NON-ROOT libraries --
79 LIBCPPSRCS=
80 LIBCPPLIBS=$(LIBCPPSRCS:${DIRSRC}/%.cpp=${DIRLIB}/lib%_${VER}.so)
81 LIBCPPCLIBS=
82 FULLLIBCPPLIBS=$(LIBCPPCLIBS:%=${DIRLIB}/%_${VER}.so)
83
84 # -- CPP - Executables --
85 CXXEXESRCS=${DIRSRC}/DarthVader.cpp
86 CXXEXEOBJS=$(CXXEXESRCS:${DIRSRC}%.cpp=${DIRLIB}%.o)
87 CXXEXELIBS:=DarthVader
88
89 # -- list of tracker objects needed to link
90 #TRKOBJS=${DIRTOP}/../lib2/libTrkLevel2.so ${DIRTOP}/../lib2/libtrack.so
91 #TRKOBJS=$(shell for lib in `ls ${DIRLIB}`; do echo ${lib}; done)
92 OBJS=${DIRLIB}/*
93 #TRKOBJS=
94
95 # -- directory where to find tracker headers needed to compile
96 #TRKHEAD=${DIRTOP}/../tracker/inc
97 #TRKHEAD=-I${PAM_INC} -ITrackerLevel2/inc/ -IRunInfo/inc/ -IGLTables/inc/
98
99 #
100 SUBDIR=./GLTables ./RunInfo ./S4Level2 ./NDLevel2 ./TrackerLevel2 ./TriggerLevel2 ./ToFLevel2 ./CalorimeterLevel2 ./AnticounterLevel2 ./OrbitalInfo
101 SUBINC=$(shell for dir in `echo ${SUBDIR}`; do echo -I$${dir}/inc; done)
102
103 # List of all libraries we want to install
104 FULLLIBS = ${FULLROOTCLIBS} ${FULLLIBCPPLIBS}
105
106 # Other objects to install
107 EXESRCS=${DIRBIN}/DarthVader
108
109 INCSRCS=
110
111 MACROSSRCS=
112
113 CALIBFILES=${DIRCALIB}/trk-param ${DIRCALIB}/cal-param ${DIRCALIB}/tof-param
114
115 DOCFILES=
116
117 # Here the Variables used for info target
118 PACKAGE=PAMELA analysis flight software
119 EXECUTABLES= ${EXESRCS}
120 LIBS= ${FULLLIBS}
121 DOCS=
122 SRCS=
123 #SRCS= ${FSRCS} ${CRSCS} ${CXXEXESRCS} ${LIBROOTSRCS} ${LIBCPPSRCS}
124 MACROS= ${MACROSSRCS}
125 INCLUDE= ${INCSRCS}
126 #
127 TOBEDEL = junk
128 ROOTINC=$$${shell root-config --incdir}
129 NROOTINC=${shell root-config --incdir}
130 # Directories where you place detectors software
131 #SUBDIR=./GLTables ./RunInfo ./TrackerLevel2 ./CalorimeterLevel2
132
133 # Let's start
134 #all: test mkbindir mklibdir mkverpath ${FOBJS} ${CPPOBJS} ${LIBROOTLIBS} ${LIBCPPLIBS} ${CXXEXELIBS}
135
136 all:
137 @for dir in `echo ${SUBDIR}`; do \
138 echo "Making all in $${dir}"; \
139 (cd $${dir} && ${MAKE} all); \
140 done; make locall
141
142 locall: prepare libs exe
143 locall:
144 @echo -e ${GREEN} ""
145 @(${EGREEN} " Finished, now you can install the package \n (use: make install or make upgrade or make forceinstall) "; ${RESET})
146 @echo -e ${GREEN} ""
147 @${RESET}
148
149 #subdir:
150 # @for dir in `echo ${SUBDIR}`; do \
151 # echo "Making ${target} in $${dir}"; \
152 # (cd $${dir} && ${MAKE} ${target}); \
153 # done;
154
155 prepare: test mkbindir mklibdir mkverpath
156
157 exe: prepare ${CXXEXELIBS}
158
159 libs: prepare ${LIBROOTLIBS} ${LIBCPPLIBS}
160
161 # Here some general rules to produce objects in our local dir
162 ${DIRLIB}/%.o: ${DIRSRC}/%.cpp
163 @(${EGREEN} "Creating CPP object file: "${WHITE} "`basename $@`"; ${RESET})
164 @${CXX} ${CXXFLAGS} -c -o $@ ${DIRSRC}/`basename ${@} .o`.cpp -I${DIRINC} ${SUBINC} -I${PAM_YODA}/include/yoda/ `root-config --cflags`
165
166 ${DIRLIB}/%.o: ${DIRSRC}/%.c
167 @(${EGREEN} "Creating C object file: "${WHITE} "`basename $@`"; ${RESET})
168 @${CXX} ${CXXFLAGS} -c -o $@ ${DIRSRC}/`basename ${@} .o`.c -I${DIRINC} -I${PAM_YODA}/include/yoda/ `root-config --cflags`
169
170 ${DIRLIB}/%.o: ${DIRSRC}/%.for
171 @(${EGREEN} "Creating F77 object file: "${WHITE} "`basename $@`"; ${RESET})
172 @${F77} ${F77FLAGS} -c -o $@ ${DIRSRC}/`basename ${@} .o`.for -I${DIRINC}
173
174 ${LIBROOTLIBS}: ${LIBROOTSRCS}
175 @(${EGREEN} "ROOTCINT - creating file: "${WHITE} "`basename $(@F) _${VER}.so | sed s/lib//`Dict.cpp"; ${RESET})
176 #
177 # Create *Dict.cpp and *Dict.h
178 #
179 @${ROOTCINT} -f ${DIRSRC}/`basename $(@F) _${VER}.so | sed s/lib//`Dict.cpp -c -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
180 #
181 # create .o
182 #
183 @(${EGREEN} "Compiling CPP file: "${WHITE} "`basename $(@F) _${VER}.so | sed s/lib//`.cpp"; ${RESET})
184 @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};
185 @(${EGREEN} "Compiling CPP file: "${WHITE} "`basename $(@F) _${VER}.so | sed s/lib//`Dict.cpp"; ${RESET})
186 @cd ${DIRSRC} &>/dev/null && ${CXX} ${CXXFLAGS} -c `basename $(@F) _${VER}.so | sed s/lib//`Dict.cpp -I${DIRTOP}/${DIRINC} -I${DIRTOP} -I${PAM_YODA}/include/yoda/ -I${NROOTINC};
187 #
188 # create .so
189 #
190 @(${EGREEN} "Creating shared library: "${WHITE} "`basename $@`"; ${RESET})
191 @${CXX} ${CXXFLAGS} -Xlinker -soname=$(@F) -shared -o $@ -lg2c -I${DIRTOP}/${DIRINC} -I${DIRTOP} -I${PAM_YODA}/include/yoda/ ${DIRTOP}/${DIRSRC}/`basename $(@F) _${VER}.so | sed s/lib//`.o ${DIRTOP}/${DIRSRC}/`basename $(@F) _${VER}.so | sed s/lib//`Dict.o 1>/dev/null
192 @ln -sf ${DIRTOP}/${DIRLIB}/$(@F) ${DIRTOP}/${DIRLIB}/$(patsubst %_${VER}.so,%.so,$(@F))
193
194 ${LIBCPPLIBS}: ${LIBSRCS} ${COBJS} ${FOBJS}
195 #
196 # create .o
197 #
198 @(${EGREEN} "Compiling CPP file: "${WHITE} "`basename $(@F) _${VER}.so | sed s/lib//`.cpp"; ${RESET})
199 @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} ${SUBINC};
200 #
201 # create .so
202 #
203 @(${EGREEN} "Creating shared library: "${WHITE} "`basename $@`"; ${RESET})
204 @${CXX} ${CXXFLAGS} -Xlinker -soname=$(@F) -shared -o $@ -lg2c -I${DIRTOP}/${DIRINC} -I${DIRTOP} -I${SUBINC} -I${PAM_YODA}/include/yoda/ ${DIRTOP}/${DIRSRC}/`basename $(@F) _${VER}.so | sed s/lib//`.o ${FOBJS} ${COBJS} 1>/dev/null
205 @ln -sf ${DIRTOP}/${DIRLIB}/$(@F) ${DIRTOP}/${DIRLIB}/$(patsubst %_${VER}.so,%.so,$(@F))
206
207 ${CXXEXELIBS}: ${CPPOBJS} ${COBJS} ${CXXEXEOBJS}
208 @(${EGREEN} "Creating exec file: "${WHITE} "$@"; ${RESET})
209 # @${CXX} ${CXXFLAGS} -o ${DIRBIN}/$@ ${DIRLIB}/$@.o ${FULLROOTCLIBS} ${FULLLIBCPPLIBS} ${CPPOBJS} ${FOBJS} ${TRKOBJS} ${PAM_YODA}/lib/libyoda.so -I${DIRINC} -I${PAM_INC} -I${PAM_YODA}/include/yoda/ -lThread `root-config --cflags --glibs` `cernlib mathlib`
210 @${CXX} ${CXXFLAGS} -o ${DIRBIN}/$@ ${OBJS} ${PAM_YODA}/lib/libyoda.so -lThread `root-config --cflags --glibs` `cernlib mathlib`
211
212 # A small target to check environmental variables
213 %_env:
214 @${test_env}
215
216 .PHONY: install installdoc installlib installmacros installinc installexe installcmacro
217 .PHONY: clean depclean info mkbindir mklibdir testcern testpamenv test
218
219 mkbindir: ${DIRBIN}
220 ${DIRBIN}:
221 @${test_and_mk}
222
223 mklibdir: ${DIRLIB}
224 ${DIRLIB}:
225 @${test_and_mk}
226
227 # Here what has to be deleted in clean target
228 clean:
229 @for dir in `echo ${SUBDIR}`; do \
230 echo "Making clean in $${dir}"; \
231 (cd $${dir} && ${MAKE} clean); \
232 done; make locclean
233
234 locclean: TOBEDEL= ${DIRSRC}/*.o ${DIRSRC}/*Dict.cpp ${DIRSRC}/*Dict.h ${FOBJS} ${FULLLIBS} ${DIRBIN}/${CXXEXELIBS} ${CPPOBJS} ${CXXEXEOBJS} ${FULLLINKCLIBS} ${FULLMACROCLIBS} ${FULLLINKMACROCLIBS} ${DIRSRC}/DarthVaderVerl2.cpp
235 locclean:
236 @${test_and_rm}
237
238 distclean:
239 @for dir in `echo ${SUBDIR}`; do \
240 echo "Making distclean in $${dir}"; \
241 (cd $${dir} && ${MAKE} distclean); \
242 done; make locdistclean
243
244 locdistclean: clean
245 locdistclean: TOBEDEL= ${DIRBIN} ${DIRLIB}
246 locdistclean:
247 @${test_and_rm}
248
249
250 forceinstall:
251 @for dir in `echo ${SUBDIR}`; do \
252 echo "Making forceinstall in $${dir}"; \
253 (cd $${dir} && ${MAKE} forceinstall); \
254 done; make locforceinstall
255
256 locforceinstall: FORCE=-f
257 locforceinstall: install
258
259 upgrade:
260 @for dir in `echo ${SUBDIR}`; do \
261 echo "Making upgrade in $${dir}"; \
262 (cd $${dir} && ${MAKE} upgrade); \
263 done; make locupgrade
264
265 locupgrade: FORCE=-u
266 locupgrade: locinstall
267
268 install:
269 @for dir in `echo ${SUBDIR}`; do \
270 echo "Making install in $${dir}"; \
271 (cd $${dir} && ${MAKE} install); \
272 done; make locinstall
273
274 locinstall: installlib installinc installmacros installcalib installdoc installexe installcmacro
275
276 installlib: LINK=y
277 installlib: TOBEMOVED= $(FULLLIBS:${DIRLIB}%=${PAM_LIB}%)
278 installlib: ORIGIN=${DIRLIB}
279 installlib:
280 @${test_and_cp}
281
282 installcmacro: LINK=y
283 installcmacro: TOBEMOVED= $(FULLMACROCLIBS:${DIRLIB}%=${PAM_LIB}%)
284 installcmacro: ORIGIN=${DIRLIB}
285 installcmacro:
286 @${test_and_cp}
287
288 installinc: TOBEMOVED= $(INCSRCS:${DIRINC}/%=${PAM_INC}/%)
289 installinc: ORIGIN=${DIRINC}
290 installinc:
291 @${test_and_cp}
292
293 installexe: TOBEMOVED= $(EXESRCS:${DIRBIN}/%=${PAM_BIN}/%)
294 installexe: ORIGIN=${DIRBIN}
295 installexe:
296 @${test_and_cp}
297
298 installmacros: TOBEMOVED= $(MACROSSRCS:${DIRMACROS}/%=${PAM_MACROS}/%)
299 installmacros: ORIGIN=${DIRMACROS}
300 installmacros:
301 @${test_and_cp}
302
303 installcalib: TOBEMOVED= $(CALIBFILES:${DIRCALIB}/%=${PAM_CALIB}/%)
304 installcalib: ORIGIN=${DIRCALIB}
305 installcalib:
306 @${cp_dir}
307
308 installdoc: TOBEMOVED= $(DOCFILES:${DIRDOC}/%=${PAM_DOC}/%)
309 installdoc: ORIGIN=${DIRDOC}
310 installdoc:
311 @${test_and_cp}
312
313 mkverpath:
314 @echo '#include <TSystem.h>' > ${DIRTOP}/${DIRSRC}/DarthVaderVerl2.cpp; echo ' char *DarthVaderInfo(bool print){ if ( print ) printf("\nPAMELA Level2 flight package version: ${VER}\n\nCompiled on '${TODAY}' with: '${GCCVER}'\n\nOn: '${UNAMEA}'\n\n"); return("${VER}"); }' >> ${DIRTOP}/${DIRSRC}/DarthVaderVerl2.cpp
315 @sleep 0.8
316
317
318
319 info:
320 @echo " "
321 @${EGREEN} "Infos for package :" ${WHITE} ${PACKAGE}
322 @${EGREEN} " VERSION :" ${WHITE} ${VER}
323 @${EGREEN} " EXECUTABLES :" ${WHITE} ${EXECUTABLES}
324 @${EGREEN} " LIBS :" ${WHITE} ${LIBS}
325 @${EGREEN} " DOCS :" ${WHITE} ${DOCS}
326 @${EGREEN} " SRCS :" ${WHITE} ${SRCS}
327 @${EGREEN} " MACROS :" ${WHITE} ${MACROS}
328 @${EGREEN} " INCLUDE :" ${WHITE} ${INCLUDE}
329 @echo " "
330 @${RESET}
331
332 test: testpamenv
333
334 testpamenv: ${PAM_ENV}
335
336 root-config: OPT=--cflags
337 root-config:
338 @${test_cmd}
339
340 # Here follows some usefull macros
341 define test_and_cp
342 wd=`pwd`;\
343 for i in ${TOBEMOVED} ; do \
344 wv=$${i##/*/}; \
345 dest=$${i/$${wv}/}; \
346 ${EGREEN} "Testing for :" ${WHITE} "$${i}" ; ${RESET}; \
347 if [ ! "${FORCE}" ] ; then \
348 if [ ! -f $${i} ]; then \
349 ${EGREEN} "Copying : "${WHITE} ${ORIGIN}/$${i##/*/} ;\
350 ${EGREEN} " to: "${WHITE} $${i} ; ${RESET}; \
351 cp ${ORIGIN}/$${i##/*/} $${i}; \
352 else \
353 ${ERED} "File already exist !!!! Please delete it " ${WHITE}; ${RESET}; \
354 fi;\
355 else \
356 if [ "${FORCE}" == "-u" ] ; then \
357 if [ "`basename $${i}`" != "`basename $${i} _${VER}.so`" ]; then \
358 ${EYELLOW} "Removing: "${WHITE} ${PAM_LIB}/`basename $${i} _${VER}.so`_v*r*.so; ${RESET}; \
359 rm -f ${PAM_LIB}/`basename $${i} _${VER}.so`_v*r*.so ; \
360 ${EGREEN} "Copying : "${WHITE} ${ORIGIN}/$${i##/*/} ;\
361 ${EGREEN} " to: "${WHITE} $${i} ; ${RESET}; \
362 cp ${ORIGIN}/$${i##/*/} $${i}; \
363 else \
364 ${EYELLOW} " Forcing copy: "${WHITE} ${ORIGIN}/$${i##/*/} ;\
365 ${EYELLOW} " to: "${WHITE} $${i} ; ${RESET}; \
366 cp -f ${ORIGIN}/$${i##/*/} $${i}; \
367 fi; \
368 else \
369 ${EYELLOW} " Forcing copy: "${WHITE} ${ORIGIN}/$${i##/*/} ;\
370 ${EYELLOW} " to: "${WHITE} $${i} ; ${RESET}; \
371 cp ${FORCE} ${ORIGIN}/$${i##/*/} $${i}; \
372 fi;\
373 fi ;\
374 if [ ! -z ${LINK} ] ; then \
375 ${EGREEN} "Creating symlink from : "${WHITE} $${wv/_${VER}/} ;\
376 ${EGREEN} " to : "${WHITE} $${i##/*/} ; ${RESET}; \
377 cd $${dest}; \
378 ln -sf $${wv} $${wv/_${VER}/}; \
379 cd $${wd}; \
380 fi \
381 done
382 endef
383
384 define cp_dir
385 wd=`pwd`;\
386 for i in ${TOBEMOVED} ; do \
387 wv=$${i##/*/}; \
388 dest=$${i/$${wv}/}; \
389 ${EYELLOW} " Copying directory: "${WHITE} ${ORIGIN}/$${i##/*/} ;\
390 ${EYELLOW} " to: "${WHITE} $${i} ; ${RESET}; \
391 cp -rf ${ORIGIN}/$${i##/*/} $${i}; \
392 done
393 endef
394
395 define test_and_mk
396 ${EGREEN} "Testing for :" ${WHITE} "$@"; ${RESET}
397 test -d "$@" || \
398 (${EGREEN} "Creating : "${WHITE} "$@"; ${RESET}; mkdir -p $@)
399 endef
400
401 define test_env
402 ${EGREEN} "Testing for env:" ${WHITE} $(patsubst %_env,%,$@); ${RESET}
403 printenv $(patsubst %_env,%,$@) 1>/dev/null || \
404 (${ERED} "ERROR, variable : "${WHITE} $(patsubst %_env,%,$@) \
405 ${RED} "not defined !!! Check your env. settings"; \
406 ${RESET}; exit 1)
407 ${EGREEN} " Defined:" ${WHITE} $${$(patsubst %_env,%,$@)}; ${RESET}
408 endef
409
410 define test_cmd
411 ${EGREEN} "Testing for cmd:" ${WHITE} $@ ${OPT}; ${RESET}
412 $@ ${OPT} 1>/dev/null 2>&1 || \
413 (${ERED} "ERROR, command : "${WHITE} $@ ${OPT}\
414 ${RED} "not found !!! Check your installation"; \
415 ${RESET}; exit 1)
416 ${EGREEN} " Present:" ${WHITE} $@ ${OPT}; ${RESET}
417 endef
418
419 define test_and_rm
420 for i in ${TOBEDEL}; do \
421 test -d $${i} || (${ERED} "Removing file :"${WHITE} $${i}; ${RESET}; \
422 rm -f $${i} ); \
423 test ! -d $${i} || (${ERED} "Removing dir :"${WHITE} $${i}; ${RESET}; \
424 rm -rf $${i} ); \
425 done
426 endef

  ViewVC Help
Powered by ViewVC 1.1.23