/[PAMELA software]/calo/flight/MyDetector2Level2/Makefile
ViewVC logotype

Contents of /calo/flight/MyDetector2Level2/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (show annotations) (download) (vendor branch)
Tue Apr 18 13:12:39 2006 UTC (18 years, 7 months ago) by mocchiut
Branch: v0r00
CVS Tags: start
Changes since 1.1: +0 -0 lines
Error occurred while calculating annotation data.
Imported sources

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

  ViewVC Help
Powered by ViewVC 1.1.23