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

Annotation of /chewbacca/YodaProfiler/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.9 - (hide annotations) (download)
Mon Dec 14 14:58:36 2009 UTC (15 years ago) by mocchiut
Branch: MAIN
Changes since 1.8: +1 -1 lines
Versioning number aligned to reduction number

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

  ViewVC Help
Powered by ViewVC 1.1.23