/[PAMELA software]/chewbacca/YodaProfiler/Makefile
ViewVC logotype

Contents of /chewbacca/YodaProfiler/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download)
Tue Sep 23 07:20:29 2008 UTC (16 years, 2 months ago) by mocchiut
Branch: MAIN
Branch point for: v0r00
Initial revision

1 # YodaProfiler
2 # SOFTWARE VERSION
3 VER= v6r00
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 -O4 -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=docs
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=${DIRSRC}/sgp4.cpp
81 LIBCPPLIBS=$(LIBCPPSRCS:${DIRSRC}/%.cpp=${DIRLIB}/lib%_${VER}.so)
82 LIBCPPCLIBS=libsgp4
83 FULLLIBCPPLIBS=$(LIBCPPCLIBS:%=${DIRLIB}/%_${VER}.so)
84
85 # -- CPP - Executables --
86 CXXEXESRCS=${DIRSRC}/YodaProfiler.cpp \
87 ${DIRSRC}/R2-D2.cpp
88 CXXEXEOBJS=$(CXXEXESRCS:${DIRSRC}%.cpp=${DIRLIB}%.o)
89 CXXEXELIBS:=YodaProfiler R2-D2
90
91 # List of all libraries we want to install
92 FULLLIBS = ${FULLROOTCLIBS} ${FULLLIBCPPLIBS} ${DARTHVLIB}
93
94 # Other objects to install
95 EXESRCS=${DIRBIN}/YodaProfiler ${DIRBIN}/R2-D2
96
97 INCSRCS=${DIRINC}/GLTables.h ${DIRINC}/GLTablesStruct.h ${DIRINC}/sgp4.h
98
99 MACROSSRCS=
100
101 CALIBFILES=
102
103 DOCFILES=${DIRDOC}/retrieve_TLE.sh ${DIRDOC}/YodaProfilerManual.pdf ${DIRDOC}/PAMELAProductionDB.sql ${DIRDOC}/install_DB.sh
104
105 # Here the Variables used for info target
106 PACKAGE=PAMELA analysis flight software
107 EXECUTABLES= ${EXESRCS}
108 LIBS= ${FULLLIBS}
109 DOCS=
110 SRCS=
111 #SRCS= ${FSRCS} ${CRSCS} ${CXXEXESRCS} ${LIBROOTSRCS} ${LIBCPPSRCS}
112 MACROS= ${MACROSSRCS}
113 INCLUDE= ${INCSRCS}
114 #
115 TOBEDEL = junk
116 ROOTINC=$$${shell root-config --incdir}
117 NROOTINC=${shell root-config --incdir}
118
119 # Let's start
120 all: mkbindir mklibdir mkverpath ${FOBJS} ${CPPOBJS} ${LIBROOTLIBS} ${LIBCPPLIBS} ${CXXEXELIBS}
121 @echo -e ${GREEN} ""
122 @(${EGREEN} " Finished, now you can install the package \n (use: make install or make upgrade or make forceinstall) "; ${RESET})
123 @echo -e ${GREEN} ""
124 @${RESET}
125
126 # Here some general rules to produce objects in our local dir
127 ${DIRLIB}/%.o: ${DIRSRC}/%.cpp
128 @(${EGREEN} "Creating CPP object file: "${WHITE} "`basename $@`"; ${RESET})
129 @${CXX} ${CXXFLAGS} -c -o $@ ${DIRSRC}/`basename ${@} .o`.cpp -I${DIRINC} ${SUBINC} -I../event/ `root-config --cflags`
130
131 ${DIRLIB}/%.o: ${DIRSRC}/%.c
132 @(${EGREEN} "Creating C object file: "${WHITE} "`basename $@`"; ${RESET})
133 @${CXX} ${CXXFLAGS} -c -o $@ ${DIRSRC}/`basename ${@} .o`.c -I${DIRINC} -I../event/ `root-config --cflags`
134
135 ${DIRLIB}/%.o: ${DIRSRC}/%.for
136 @(${EGREEN} "Creating F77 object file: "${WHITE} "`basename $@`"; ${RESET})
137 @${F77} ${F77FLAGS} -c -o $@ ${DIRSRC}/`basename ${@} .o`.for -I${DIRINC}
138
139 ${LIBROOTLIBS}: ${LIBROOTSRCS}
140 @(${EGREEN} "ROOTCINT - creating file: "${WHITE} "`basename $(@F) _${VER}.so | sed s/lib//`Dict.cpp"; ${RESET})
141 #
142 # Create *Dict.cpp and *Dict.h
143 #
144 @${ROOTCINT} -f ${DIRSRC}/`basename $(@F) _${VER}.so | sed s/lib//`Dict.cpp -c -I${ROOTINC} -I../event/ ${DIRINC}/`basename $(@F) _${VER}.so | sed s/lib//`.h ${DIRINC}/`basename $(@F) _${VER}.so | sed s/lib//`LinkDef.h
145 #
146 # create .o
147 #
148 @(${EGREEN} "Compiling CPP file: "${WHITE} "`basename $(@F) _${VER}.so | sed s/lib//`.cpp"; ${RESET})
149 @cd ${DIRSRC} &>/dev/null && ${CXX} ${CXXFLAGS} -c `basename $(@F) _${VER}.so | sed s/lib//`.cpp -I${DIRTOP}/${DIRINC} -I${DIRTOP} -I../../event/ -I${NROOTINC};
150 @(${EGREEN} "Compiling CPP file: "${WHITE} "`basename $(@F) _${VER}.so | sed s/lib//`Dict.cpp"; ${RESET})
151 @cd ${DIRSRC} &>/dev/null && ${CXX} ${CXXFLAGS} -c `basename $(@F) _${VER}.so | sed s/lib//`Dict.cpp -I${DIRTOP}/${DIRINC} -I${DIRTOP} -I../../event/ -I${NROOTINC};
152 #
153 # create .so
154 #
155 @(${EGREEN} "Creating shared library: "${WHITE} "`basename $@`"; ${RESET})
156 @${CXX} ${CXXFLAGS} -Xlinker -soname=$(@F) -shared -o $@ -lg2c -I${DIRTOP}/${DIRINC} -I${DIRTOP} -I../event/ ${DIRTOP}/${DIRSRC}/`basename $(@F) _${VER}.so | sed s/lib//`.o ${DIRTOP}/${DIRSRC}/`basename $(@F) _${VER}.so | sed s/lib//`Dict.o 1>/dev/null
157 @ln -sf ${DIRTOP}/${DIRLIB}/$(@F) ${DIRTOP}/${DIRLIB}/$(patsubst %_${VER}.so,%.so,$(@F))
158
159 ${LIBCPPLIBS}: ${LIBSRCS} ${COBJS} ${FOBJS}
160 #
161 # create .o
162 #
163 @(${EGREEN} "Compiling CPP file: "${WHITE} "`basename $(@F) _${VER}.so | sed s/lib//`.cpp"; ${RESET})
164 @cd ${DIRSRC} &>/dev/null && ${CXX} ${CXXFLAGS} -c `basename $(@F) _${VER}.so | sed s/lib//`.cpp -I${DIRTOP}/${DIRINC} -I${DIRTOP} -I../event/ -I${NROOTINC} ${SUBINC};
165 #
166 # create .so
167 #
168 @(${EGREEN} "Creating shared library: "${WHITE} "`basename $@`"; ${RESET})
169 @${CXX} ${CXXFLAGS} -Xlinker -soname=$(@F) -shared -o $@ -lg2c -I${DIRTOP}/${DIRINC} -I${DIRTOP} -I${SUBINC} -I../event/ ${DIRTOP}/${DIRSRC}/`basename $(@F) _${VER}.so | sed s/lib//`.o ${FOBJS} ${COBJS} 1>/dev/null
170 @ln -sf ${DIRTOP}/${DIRLIB}/$(@F) ${DIRTOP}/${DIRLIB}/$(patsubst %_${VER}.so,%.so,$(@F))
171
172 ${CXXEXELIBS}: ${CPPOBJS} ${COBJS} ${CXXEXEOBJS}
173 @(${EGREEN} "Creating exec file: "${WHITE} "$@"; ${RESET})
174 @${CXX} ${CXXFLAGS} -o ${DIRBIN}/$@ ${DIRTOP}/${DIRLIB}/$@.o ${DIRTOP}/${DIRLIB}/libGLTables.so ${DIRTOP}/${DIRLIB}/libsgp4.so ${CPPOBJS} ../event/libyoda.so -lThread `root-config --cflags --glibs`
175
176 # A small target to check environmental variables
177 %_env:
178 @${test_env}
179
180 .PHONY: install installdoc installlib installmacros installinc installexe installcmacro
181 .PHONY: clean depclean info mkbindir mklibdir testcern testpamenv test
182
183 mkbindir: ${DIRBIN}
184 ${DIRBIN}:
185 @${test_and_mk}
186
187 mklibdir: ${DIRLIB}
188 ${DIRLIB}:
189 @${test_and_mk}
190
191 # Here what has to be deleted in clean target
192 clean: TOBEDEL= ${DIRSRC}/*.o ${DIRSRC}/*Dict.cpp ${DIRSRC}/*Dict.h ${FOBJS} ${FULLLIBS} ${DIRBIN}/${CXXEXELIBS} ${CPPOBJS} ${CXXEXEOBJS} ${FULLLINKCLIBS} ${FULLMACROCLIBS} ${FULLLINKMACROCLIBS} ${DIRSRC}/YodaProfilerVerl2.cpp
193 clean:
194 @${test_and_rm}
195
196 distclean: clean
197 distclean: TOBEDEL= ${DIRBIN} ${DIRLIB}
198 distclean:
199 @${test_and_rm}
200
201 forceinstall: FORCE=-f
202 forceinstall: install
203
204 upgrade: FORCE=-u
205 upgrade: install
206
207 install: test installlib installinc installmacros installcalib installdoc installexe installcmacro
208
209 installlib: LINK=y
210 installlib: TOBEMOVED= $(FULLLIBS:${DIRLIB}%=${PAM_LIB}%)
211 installlib: ORIGIN=${DIRLIB}
212 installlib:
213 @${test_and_cp}
214
215 installcmacro: LINK=y
216 installcmacro: TOBEMOVED= $(FULLMACROCLIBS:${DIRLIB}%=${PAM_LIB}%)
217 installcmacro: ORIGIN=${DIRLIB}
218 installcmacro:
219 @${test_and_cp}
220
221 installinc: TOBEMOVED= $(INCSRCS:${DIRINC}/%=${PAM_INC}/%)
222 installinc: ORIGIN=${DIRINC}
223 installinc:
224 @${test_and_cp}
225
226 installexe: TOBEMOVED= $(EXESRCS:${DIRBIN}/%=${PAM_BIN}/%)
227 installexe: ORIGIN=${DIRBIN}
228 installexe:
229 @${test_and_cp}
230
231 installmacros: TOBEMOVED= $(MACROSSRCS:${DIRMACROS}/%=${PAM_MACROS}/%)
232 installmacros: ORIGIN=${DIRMACROS}
233 installmacros:
234 @${test_and_cp}
235
236 installcalib: TOBEMOVED= $(CALIBFILES:${DIRCALIB}/%=${PAM_CALIB}/%)
237 installcalib: ORIGIN=${DIRCALIB}
238 installcalib:
239 @${cp_dir}
240
241 installdoc: TOBEMOVED= $(DOCFILES:${DIRDOC}/%=${PAM_DOC}/%)
242 installdoc: ORIGIN=${DIRDOC}
243 installdoc:
244 @${test_and_cp}
245
246 mkverpath:
247 @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
248 @sleep 0.8
249
250
251 info:
252 @echo " "
253 @${EGREEN} "Infos for package :" ${WHITE} ${PACKAGE}
254 @${EGREEN} " VERSION :" ${WHITE} ${VER}
255 @${EGREEN} " EXECUTABLES :" ${WHITE} ${EXECUTABLES}
256 @${EGREEN} " LIBS :" ${WHITE} ${LIBS}
257 @${EGREEN} " DOCS :" ${WHITE} ${DOCS}
258 @${EGREEN} " SRCS :" ${WHITE} ${SRCS}
259 @${EGREEN} " MACROS :" ${WHITE} ${MACROS}
260 @${EGREEN} " INCLUDE :" ${WHITE} ${INCLUDE}
261 @echo " "
262 @${RESET}
263
264 test: testpamenv
265 #test:
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