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

Contents of /DarthVader/OrbitalInfo/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.7 - (show annotations) (download)
Tue Sep 5 14:49:43 2006 UTC (18 years, 3 months ago) by mocchiut
Branch: MAIN
CVS Tags: v2r00BETA
Changes since 1.6: +1 -1 lines
_NOT_ COMPILING yet, fixed AC, ND, S4, RunInfo, OrbitalInfo and Trigger

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

  ViewVC Help
Powered by ViewVC 1.1.23