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

Annotation of /DarthVader/OrbitalInfo/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.16 - (hide annotations) (download)
Tue Sep 23 07:41:48 2008 UTC (16 years, 2 months ago) by mocchiut
Branch: MAIN
Changes since 1.15: +6 -6 lines
Added -m32 flag to enable cross compilation

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

  ViewVC Help
Powered by ViewVC 1.1.23