/[PAMELA software]/DarthVader/OrbitalInfo/Makefile
ViewVC logotype

Contents of /DarthVader/OrbitalInfo/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.24 - (show annotations) (download)
Tue Jan 13 13:51:42 2009 UTC (15 years, 11 months ago) by mocchiut
Branch: MAIN
CVS Tags: v6r01, v6r00
Changes since 1.23: +1 -1 lines
Version updated

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

  ViewVC Help
Powered by ViewVC 1.1.23