/[PAMELA software]/YodaProfiler/Makefile
ViewVC logotype

Annotation of /YodaProfiler/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.8 - (hide annotations) (download)
Fri Oct 20 11:39:29 2006 UTC (18 years, 1 month ago) by mocchiut
Branch: MAIN
Changes since 1.7: +13 -18 lines
Create libsgp4.so shared lib; unified sgp4 code

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

  ViewVC Help
Powered by ViewVC 1.1.23