/[PAMELA software]/YodaProfiler/Makefile
ViewVC logotype

Contents of /YodaProfiler/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.7 - (show annotations) (download)
Tue Oct 17 15:19:46 2006 UTC (18 years, 1 month ago) by mocchiut
Branch: MAIN
Changes since 1.6: +6 -1 lines
Added TLE filling, minor bugs fixed

1 # YodaProfiler
2 # SOFTWARE VERSION
3 VER= v2r00
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}/YodaProfilerVerl2.cpp \
65 ${DIRSRC}/PamelaDBOperations.cpp \
66 ${DIRSRC}/cEci.cpp \
67 ${DIRSRC}/cJulian.cpp \
68 ${DIRSRC}/cTle.cpp \
69 ${DIRSRC}/cVector.cpp \
70 ${DIRSRC}/globals.cpp
71 CPPOBJS=$(CPPSRCS:${DIRSRC}%.cpp=${DIRLIB}%.o)
72
73 # -- C - no libraries --
74 CSRCS=
75 COBJS=$(CSRCS:${DIRSRC}%.c=${DIRLIB}%.o)
76
77 # -- CPP - ROOT libraries --
78 LIBROOTSRCS=${DIRSRC}/GLTables.cpp
79 # ${DIRSRC}/PacketTypeList.cpp
80 LIBROOTLIBS=$(LIBROOTSRCS:${DIRSRC}/%.cpp=${DIRLIB}/lib%_${VER}.so)
81 LIBROOTCLIBS=libGLTables #libPacketTypeList
82 FULLROOTCLIBS=$(LIBROOTCLIBS:%=${DIRLIB}/%_${VER}.so)
83
84 # -- CPP - NON-ROOT libraries --
85 LIBCPPSRCS=
86 LIBCPPLIBS=$(LIBCPPSRCS:${DIRSRC}/%.cpp=${DIRLIB}/lib%_${VER}.so)
87 LIBCPPCLIBS=
88 FULLLIBCPPLIBS=$(LIBCPPCLIBS:%=${DIRLIB}/%_${VER}.so)
89
90 # -- CPP - Executables --
91 CXXEXESRCS=${DIRSRC}/YodaProfiler.cpp
92 CXXEXEOBJS=$(CXXEXESRCS:${DIRSRC}%.cpp=${DIRLIB}%.o)
93 CXXEXELIBS:=YodaProfiler
94
95 # List of all libraries we want to install
96 FULLLIBS = ${FULLROOTCLIBS} ${FULLLIBCPPLIBS} ${DARTHVLIB}
97
98 # Other objects to install
99 EXESRCS=${DIRBIN}/YodaProfiler
100
101 INCSRCS=${DIRINC}/GLTables.h ${DIRINC}/GLTablesStruct.h
102
103 MACROSSRCS=
104
105 CALIBFILES=
106
107 DOCFILES=
108
109 # Here the Variables used for info target
110 PACKAGE=PAMELA analysis flight software
111 EXECUTABLES= ${EXESRCS}
112 LIBS= ${FULLLIBS}
113 DOCS=
114 SRCS=
115 #SRCS= ${FSRCS} ${CRSCS} ${CXXEXESRCS} ${LIBROOTSRCS} ${LIBCPPSRCS}
116 MACROS= ${MACROSSRCS}
117 INCLUDE= ${INCSRCS}
118 #
119 TOBEDEL = junk
120 ROOTINC=$$${shell root-config --incdir}
121 NROOTINC=${shell root-config --incdir}
122
123 # Let's start
124 all: test mkbindir mklibdir mkverpath ${FOBJS} ${CPPOBJS} ${LIBROOTLIBS} ${LIBCPPLIBS} ${CXXEXELIBS}
125 @echo -e ${GREEN} ""
126 @(${EGREEN} " Finished, now you can install the package \n (use: make install or make upgrade or make forceinstall) "; ${RESET})
127 @echo -e ${GREEN} ""
128 @${RESET}
129
130 # Here some general rules to produce objects in our local dir
131 ${DIRLIB}/%.o: ${DIRSRC}/%.cpp
132 @(${EGREEN} "Creating CPP object file: "${WHITE} "`basename $@`"; ${RESET})
133 @${CXX} ${CXXFLAGS} -c -o $@ ${DIRSRC}/`basename ${@} .o`.cpp -I${DIRINC} ${SUBINC} -I${PAM_YODA}/include/yoda/ -I${PAM_YODA}/include/utils/ `root-config --cflags`
134
135 ${DIRLIB}/%.o: ${DIRSRC}/%.c
136 @(${EGREEN} "Creating C object file: "${WHITE} "`basename $@`"; ${RESET})
137 @${CXX} ${CXXFLAGS} -c -o $@ ${DIRSRC}/`basename ${@} .o`.c -I${DIRINC} -I${PAM_YODA}/include/yoda/ -I${PAM_YODA}/include/utils/ `root-config --cflags`
138
139 ${DIRLIB}/%.o: ${DIRSRC}/%.for
140 @(${EGREEN} "Creating F77 object file: "${WHITE} "`basename $@`"; ${RESET})
141 @${F77} ${F77FLAGS} -c -o $@ ${DIRSRC}/`basename ${@} .o`.for -I${DIRINC}
142
143 ${LIBROOTLIBS}: ${LIBROOTSRCS}
144 @(${EGREEN} "ROOTCINT - creating file: "${WHITE} "`basename $(@F) _${VER}.so | sed s/lib//`Dict.cpp"; ${RESET})
145 #
146 # Create *Dict.cpp and *Dict.h
147 #
148 @${ROOTCINT} -f ${DIRSRC}/`basename $(@F) _${VER}.so | sed s/lib//`Dict.cpp -c -I${ROOTINC} -I${PAM_YODA}/include/yoda/ -I${PAM_YODA}/include/utils/ ${DIRINC}/`basename $(@F) _${VER}.so | sed s/lib//`.h ${DIRINC}/`basename $(@F) _${VER}.so | sed s/lib//`LinkDef.h
149 #
150 # create .o
151 #
152 @(${EGREEN} "Compiling CPP file: "${WHITE} "`basename $(@F) _${VER}.so | sed s/lib//`.cpp"; ${RESET})
153 @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${PAM_YODA}/include/utils/ -I${NROOTINC};
154 @(${EGREEN} "Compiling CPP file: "${WHITE} "`basename $(@F) _${VER}.so | sed s/lib//`Dict.cpp"; ${RESET})
155 @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${PAM_YODA}/include/utils/ -I${NROOTINC};
156 #
157 # create .so
158 #
159 @(${EGREEN} "Creating shared library: "${WHITE} "`basename $@`"; ${RESET})
160 @${CXX} ${CXXFLAGS} -Xlinker -soname=$(@F) -shared -o $@ -lg2c -I${DIRTOP}/${DIRINC} -I${DIRTOP} -I${PAM_YODA}/include/yoda/ -I${PAM_YODA}/include/utils/ ${DIRTOP}/${DIRSRC}/`basename $(@F) _${VER}.so | sed s/lib//`.o ${DIRTOP}/${DIRSRC}/`basename $(@F) _${VER}.so | sed s/lib//`Dict.o 1>/dev/null
161 @ln -sf ${DIRTOP}/${DIRLIB}/$(@F) ${DIRTOP}/${DIRLIB}/$(patsubst %_${VER}.so,%.so,$(@F))
162
163 ${LIBCPPLIBS}: ${LIBSRCS} ${COBJS} ${FOBJS}
164 #
165 # create .o
166 #
167 @(${EGREEN} "Compiling CPP file: "${WHITE} "`basename $(@F) _${VER}.so | sed s/lib//`.cpp"; ${RESET})
168 @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${PAM_YODA}/include/utils/ -I${NROOTINC} ${SUBINC};
169 #
170 # create .so
171 #
172 @(${EGREEN} "Creating shared library: "${WHITE} "`basename $@`"; ${RESET})
173 @${CXX} ${CXXFLAGS} -Xlinker -soname=$(@F) -shared -o $@ -lg2c -I${DIRTOP}/${DIRINC} -I${DIRTOP} -I${SUBINC} -I${PAM_YODA}/include/yoda/ -I${PAM_YODA}/include/utils/ ${DIRTOP}/${DIRSRC}/`basename $(@F) _${VER}.so | sed s/lib//`.o ${FOBJS} ${COBJS} 1>/dev/null
174 @ln -sf ${DIRTOP}/${DIRLIB}/$(@F) ${DIRTOP}/${DIRLIB}/$(patsubst %_${VER}.so,%.so,$(@F))
175
176 ${CXXEXELIBS}: ${CPPOBJS} ${COBJS} ${CXXEXEOBJS}
177 @(${EGREEN} "Creating exec file: "${WHITE} "$@"; ${RESET})
178 # @${CXX} ${CXXFLAGS} -o ${DIRBIN}/$@ ${DIRTOP}/${DIRLIB}/$@.o ${CPPOBJS} ${PAM_YODA}/lib/libyoda.so ${PAM_YODA}/lib/libutils.so -lThread `root-config --cflags --glibs` `cernlib mathlib`
179 # @${CXX} ${CXXFLAGS} -o ${DIRBIN}/$@ ${DIRTOP}/${DIRLIB}/$@.o ${DIRTOP}/${DIRLIB}/libPacketTypeList.so ${DIRTOP}/${DIRLIB}/libGLTables.so ${CPPOBJS} ${PAM_YODA}/lib/libyoda.so -lThread `root-config --cflags --glibs` `cernlib mathlib`
180
181 # @${CXX} ${CXXFLAGS} -o ${DIRBIN}/$@ ${DIRTOP}/${DIRLIB}/$@.o ${DIRTOP}/${DIRLIB}/libGLTables.so ${CPPOBJS} ${PAM_YODA}/lib/libyoda.so -lThread `root-config --cflags --glibs` `cernlib mathlib`
182 @${CXX} ${CXXFLAGS} -o ${DIRBIN}/$@ ${DIRTOP}/${DIRLIB}/$@.o ${DIRTOP}/${DIRLIB}/libGLTables.so ${CPPOBJS} ${PAM_YODA}/lib/libyoda.so -lThread `root-config --cflags --glibs`
183
184 # A small target to check environmental variables
185 %_env:
186 @${test_env}
187
188 .PHONY: install installdoc installlib installmacros installinc installexe installcmacro
189 .PHONY: clean depclean info mkbindir mklibdir testcern testpamenv test
190
191 mkbindir: ${DIRBIN}
192 ${DIRBIN}:
193 @${test_and_mk}
194
195 mklibdir: ${DIRLIB}
196 ${DIRLIB}:
197 @${test_and_mk}
198
199 # Here what has to be deleted in clean target
200 clean: TOBEDEL= ${DIRSRC}/*.o ${DIRSRC}/*Dict.cpp ${DIRSRC}/*Dict.h ${FOBJS} ${FULLLIBS} ${DIRBIN}/${CXXEXELIBS} ${CPPOBJS} ${CXXEXEOBJS} ${FULLLINKCLIBS} ${FULLMACROCLIBS} ${FULLLINKMACROCLIBS} ${DIRSRC}/YodaProfilerVerl2.cpp
201 clean:
202 @${test_and_rm}
203
204 distclean: clean
205 distclean: TOBEDEL= ${DIRBIN} ${DIRLIB}
206 distclean:
207 @${test_and_rm}
208
209 forceinstall: FORCE=-f
210 forceinstall: install
211
212 upgrade: FORCE=-u
213 upgrade: install
214
215 install: installlib installinc installmacros installcalib installdoc installexe installcmacro
216
217 installlib: LINK=y
218 installlib: TOBEMOVED= $(FULLLIBS:${DIRLIB}%=${PAM_LIB}%)
219 installlib: ORIGIN=${DIRLIB}
220 installlib:
221 @${test_and_cp}
222
223 installcmacro: LINK=y
224 installcmacro: TOBEMOVED= $(FULLMACROCLIBS:${DIRLIB}%=${PAM_LIB}%)
225 installcmacro: ORIGIN=${DIRLIB}
226 installcmacro:
227 @${test_and_cp}
228
229 installinc: TOBEMOVED= $(INCSRCS:${DIRINC}/%=${PAM_INC}/%)
230 installinc: ORIGIN=${DIRINC}
231 installinc:
232 @${test_and_cp}
233
234 installexe: TOBEMOVED= $(EXESRCS:${DIRBIN}/%=${PAM_BIN}/%)
235 installexe: ORIGIN=${DIRBIN}
236 installexe:
237 @${test_and_cp}
238
239 installmacros: TOBEMOVED= $(MACROSSRCS:${DIRMACROS}/%=${PAM_MACROS}/%)
240 installmacros: ORIGIN=${DIRMACROS}
241 installmacros:
242 @${test_and_cp}
243
244 installcalib: TOBEMOVED= $(CALIBFILES:${DIRCALIB}/%=${PAM_CALIB}/%)
245 installcalib: ORIGIN=${DIRCALIB}
246 installcalib:
247 @${cp_dir}
248
249 installdoc: TOBEMOVED= $(DOCFILES:${DIRDOC}/%=${PAM_DOC}/%)
250 installdoc: ORIGIN=${DIRDOC}
251 installdoc:
252 @${test_and_cp}
253
254 mkverpath:
255 @echo '#include <TSystem.h>' > ${DIRTOP}/${DIRSRC}/YodaProfilerVerl2.cpp; echo ' char *YodaProfilerInfo(bool print){ if ( print ) printf("\nPAMELA YodaProfiler version: ${VER}\n\nCompiled on '${TODAY}' with: '${GCCVER}'\n\nOn: '${UNAMEA}'\n\n"); return("${VER}"); }' >> ${DIRTOP}/${DIRSRC}/YodaProfilerVerl2.cpp
256 @sleep 0.8
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 cp_dir
325 wd=`pwd`;\
326 for i in ${TOBEMOVED} ; do \
327 wv=$${i##/*/}; \
328 dest=$${i/$${wv}/}; \
329 ${EYELLOW} " Copying directory: "${WHITE} ${ORIGIN}/$${i##/*/} ;\
330 ${EYELLOW} " to: "${WHITE} ${PAM_CALIB} ; ${RESET}; \
331 cp -rf ${ORIGIN}/$${i##/*/} ${PAM_CALIB}; \
332 done
333 endef
334
335 define test_and_mk
336 ${EGREEN} "Testing for :" ${WHITE} "$@"; ${RESET}
337 test -d "$@" || \
338 (${EGREEN} "Creating : "${WHITE} "$@"; ${RESET}; mkdir -p $@)
339 endef
340
341 define test_env
342 ${EGREEN} "Testing for env:" ${WHITE} $(patsubst %_env,%,$@); ${RESET}
343 printenv $(patsubst %_env,%,$@) 1>/dev/null || \
344 (${ERED} "ERROR, variable : "${WHITE} $(patsubst %_env,%,$@) \
345 ${RED} "not defined !!! Check your env. settings"; \
346 ${RESET}; exit 1)
347 ${EGREEN} " Defined:" ${WHITE} $${$(patsubst %_env,%,$@)}; ${RESET}
348 endef
349
350 define test_cmd
351 ${EGREEN} "Testing for cmd:" ${WHITE} $@ ${OPT}; ${RESET}
352 $@ ${OPT} 1>/dev/null 2>&1 || \
353 (${ERED} "ERROR, command : "${WHITE} $@ ${OPT}\
354 ${RED} "not found !!! Check your installation"; \
355 ${RESET}; exit 1)
356 ${EGREEN} " Present:" ${WHITE} $@ ${OPT}; ${RESET}
357 endef
358
359 define test_and_rm
360 for i in ${TOBEDEL}; do \
361 test -d $${i} || (${ERED} "Removing file :"${WHITE} $${i}; ${RESET}; \
362 rm -f $${i} ); \
363 test ! -d $${i} || (${ERED} "Removing dir :"${WHITE} $${i}; ${RESET}; \
364 rm -rf $${i} ); \
365 done
366 endef

  ViewVC Help
Powered by ViewVC 1.1.23