/[PAMELA software]/YodaProfiler/Makefile
ViewVC logotype

Contents of /YodaProfiler/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (show annotations) (download)
Thu Sep 7 08:34:17 2006 UTC (18 years, 2 months ago) by mocchiut
Branch: MAIN
Changes since 1.4: +1 -1 lines
First release of the new profiler

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

  ViewVC Help
Powered by ViewVC 1.1.23