/[PAMELA software]/tracker/flight/TrkNuclei/Makefile
ViewVC logotype

Annotation of /tracker/flight/TrkNuclei/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations) (download)
Tue Mar 30 07:56:41 2010 UTC (14 years, 8 months ago) by mocchiut
Branch: MAIN
Changes since 1.1: +3 -3 lines
Added flag for 32bit compilation on 64bit arch

1 pam-fi 1.1 # SOFTWARE VERSION
2     VER= v0r00
3     # An almost general purpouse Makefile for PAMELA repository
4     # Let's start with some usefull definition for colorize the echo
5     RED='\E[1;31;40m'
6     GREEN='\E[1;32;40m'
7     YELLOW='\E[1;33;40m'
8     BLUE='\E[1;34;40m'
9     WHITE='\E[1;37;40m'
10     VIOLET='\E[1;35;40m'
11     CYAN='\E[1;36;40m'
12     # Here the echo definition to use them
13     EVIOLET=echo -e ${VIOLET}
14     ECYAN=echo -e ${CYAN}
15     ERED=echo -e ${RED}
16     EGREEN=echo -e ${GREEN}
17     EYELLOW=echo -e ${YELLOW}
18     EBLUE=echo -e ${BLUE}
19     EWHITE=echo -e ${WHITE}
20     # Reset the terminal
21     RESET=tput sgr0
22     # Here the variables used to override the standard make flags
23     # C
24     CC=gcc
25     #CFLAGS=-Wall -O -fPIC -pthread -g
26 mocchiut 1.2 CFLAGS=-Wall -O -fPIC -pthread ${PAM_BIT}
27 pam-fi 1.1 # Enviroment:
28     GCCVER=`gcc --version | head -1`
29     UNAMEA=`uname -a`
30     TODAY=`date`
31     # F77
32     F77=g77
33     #F77FLAGS= -Wall -Wno-globals -fvxt -fno-automatic -fbounds-check -g -extend_source -static -fno-backslash
34 mocchiut 1.2 F77FLAGS= -Wall -Wno-globals -fvxt -fno-automatic -fbounds-check -extend_source -static -fno-backslash ${PAM_BIT}
35 pam-fi 1.1 # C++
36     CXX=g++
37     #CXXFLAGS=-Wall -O -fPIC -pthread -g
38 mocchiut 1.2 CXXFLAGS=-Wall -O -fPIC -pthread ${PAM_BIT}
39 pam-fi 1.1 # ROOTCINT
40     ROOTCINT=rootcint
41     # Here the variables definig the local directories
42     DIRTOP=${shell pwd}
43     DIRLIB=lib/${ARCH}/
44     DIRBIN=bin/${ARCH}/
45     DIRSRC=src
46     DIRINC=inc
47     DIRDOC=doc
48     DIRMACROS=macros
49     DIRCALIB=calib
50     # Here the PAMELA environmental variables to be checked
51     PAM_ENV= PAM_BIN_env PAM_LIB_env PAM_INC_env PAM_DOC_env PAM_CALIB_env PAM_YODA_env
52     # Here the local variables used to build the targets
53     #-------------------------------------------------
54     FSRCS=
55     FOBJS=$(FSRCS:${DIRSRC}/F77/%.f=${DIRLIB}/%.o)
56     #-------------------------------------------------
57     CSRCS=
58     COBJS=$(CSRCS:${DIRSRC}%.cpp=${DIRLIB}/%.o)
59     #-------------------------------------------------
60     # librerie utilizzabili da root (ci deve essere anche il ***LinkDef.h )
61     LIBROOTSRCS=${DIRSRC}/TrkNuclei.cpp
62     LIBROOTLIBS=$(LIBROOTSRCS:${DIRSRC}/%.cpp=${DIRLIB}/lib%_${VER}.so)
63     LIBROOTOBJS=
64     LIBROOTCLIBS=libTrkNuclei
65     FULLROOTCLIBS=$(LIBROOTCLIBS:%=${DIRLIB}/%_${VER}.so)
66     #-------------------------------------------------
67     # librerie C++ NON utilizzabili da root
68     LIBCPPSRCS=#${DIRSRC}/PamLevel2.cpp
69     LIBCPPLIBS=$(LIBCPPSRCS:${DIRSRC}/%.cpp=${DIRLIB}/lib%_${VER}.so)
70     LIBCPPCLIBS=#libPamLevel2
71     FULLCPPCLIBS=$(LIBCPPCLIBS:%=${DIRLIB}/%_${VER}.so)
72     #-------------------------------------------------
73     # librerie F77 NON utilizzabili da root
74     LIBF77SRCS=
75     LIBF77OBJS= $(LIBF77SRCS:${DIRSRC}/F77/%.f=${DIRLIB}/%.o)
76     LIBF77LIBS= $(LIBF77SRCS:${DIRSRC}/F77/%.f=${DIRLIB}/lib%_${VER}.so)
77     LIBF77CLIBS=
78     FULLF77CLIBS=$(LIBF77CLIBS:%=${DIRLIB}/%_${VER}.so)
79     #-------------------------------------------------
80     FULLLIBS=${FULLROOTCLIBS} ${FULLCPPCLIBS} ${FULLF77CLIBS}
81    
82     #-------------------------------------------------
83     # eseguibile
84     CXXEXESRCS=
85     CXXEXEOBJS=$(CXXEXESRCS:${DIRSRC}%.cpp=${DIRLIB}%.o)
86     CXXEXELIBS:=
87    
88     OTHERLIBS=
89     #-------------------------------------------------
90     # variabili per l'installazione
91     EXESRCS=
92     INCSRCS=${DIRINC}/TrkNuclei.h
93     MACROSSRCS=
94     CALIBFILES=
95     DOCFILES=
96     # Here the Variables used for info target
97     PACKAGE=
98     EXECUTABLES=${EXESRCS}
99     LIBS= ${FULLLIBS} ${OTHERLIBS}
100     DOCS=
101     SRCS=
102     MACROS= ${MACROSSRCS}
103     INCLUDE= ${INCSRCS}
104     #
105     TOBEDEL = junk
106     ROOTINC=$$${shell root-config --incdir}
107     NROOTINC=${shell root-config --incdir}
108     # Let's start
109     all : test mkbindir mklibdir ${LIBF77LIBS} ${LIBROOTLIBS} ${LIBCPPLIBS} ${CXXEXELIBS}
110     all:
111     @echo -e ${GREEN} ""
112     @(${EGREEN} " Finished, now you can install the package \n (use: make install or make upgrade or make forceinstall) "; ${RESET})
113     @echo -e ${GREEN} ""
114     @${RESET}
115    
116     # Here some general rules to produce objects in our local dir
117     ${DIRLIB}/%.o: ${DIRSRC}/%.cpp
118     @(${EYELLOW} " C++ object ------------------------")
119     @(${EGREEN} "Creating object file: "${WHITE} "$@"; ${RESET})
120     @${CXX} ${CXXFLAGS} -c -o $@ ${DIRSRC}/`basename ${@} .o`.cpp -I${DIRINC} -I${PAM_INC} -I${PAM_YODA}/include/yoda/ `root-config --cflags`
121    
122     ${DIRLIB}/%.o : ${DIRSRC}/F77/%.f
123     @(${EYELLOW} " F77 object ------------------------")
124     @(${EGREEN} "Creating object file: "${WHITE} "$@"; ${RESET})
125     @${F77} ${F77FLAGS} -c -o $@ ${DIRSRC}/F77/`basename ${@} .o`.f -I${DIRINC}/F77 -I${NROOTINC} -I${PAM_YODA}/include/yoda
126    
127    
128     # .so from .o fortran
129     ${LIBF77LIBS}: ${LIBF77OBJS}
130     @(${EYELLOW} " F77 shared library --------------------------")
131     @(${EGREEN} "Creating library: "${WHITE} "$@"; ${RESET})
132     @${CXX} ${CXXFLAGS} -Xlinker -soname=$(@F) -shared -o $@ $^ -lg2c `doc/cernlib_pam mathlib`
133    
134    
135     ${LIBROOTLIBS}: ${LIBROOTSRCS} ${FOBJS}
136     @(${EYELLOW} " ROOT library ------------------------")
137     @(${EGREEN} "Creating file: "${WHITE} "`basename $(@F) _${VER}.so | sed s/lib//`Dict.cpp"; ${RESET})
138     #
139     # Create *Dict.cpp and *Dict.h
140     #
141     # @${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
142     @${ROOTCINT} -f ${DIRSRC}/`basename $(@F) _${VER}.so | sed s/lib//`Dict.cpp -c -I${PAM_INC} -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
143     #
144     # order of include directories changed since RunInfo.h can be found (with completely different definition) in YODA while we want to load the DV one!
145     # should be fixed some time changing names...
146     #
147     # create .o
148     #
149     @(${EGREEN} "Compiling file: "${WHITE} "`basename $(@F) _${VER}.so | sed s/lib//`.cpp"; ${RESET})
150     @cd ${DIRSRC} &>/dev/null && ${CXX} ${CXXFLAGS} -c `basename $(@F) _${VER}.so | sed s/lib//`.cpp -I${DIRTOP}/${DIRINC} -I${DIRTOP} -I${PAM_INC} -I${PAM_YODA}/include/yoda/ -I${NROOTINC};
151     @(${EGREEN} "Compiling file: "${WHITE} "`basename $(@F) _${VER}.so | sed s/lib//`Dict.cpp"; ${RESET})
152     @cd ${DIRSRC} &>/dev/null && ${CXX} ${CXXFLAGS} -c `basename $(@F) _${VER}.so | sed s/lib//`Dict.cpp -I${DIRTOP}/${DIRINC} -I${DIRTOP} -I${PAM_INC} -I${PAM_YODA}/include/yoda/ -I${NROOTINC};
153     #
154     # create .so
155     #
156     @(${EGREEN} "Compiling shared library: "${WHITE} "$@"; ${RESET})
157     @${CXX} ${CXXFLAGS} -Xlinker -soname=$(@F) -shared -o $@ -lg2c -I${DIRTOP}/${DIRINC} -I${DIRTOP} -I${PAM_YODA}/include/yoda -I${PAM_INC} ${DIRTOP}/${DIRSRC}/`basename $(@F) _${VER}.so | sed s/lib//`.o ${DIRTOP}/${DIRSRC}/`basename $(@F) _${VER}.so | sed s/lib//`Dict.o ${LIBROOTOBJS} `doc/cernlib_pam mathlib` 1>/dev/null
158     # @ln -sf ${DIRTOP}/${DIRLIB}/$(@F) ${DIRTOP}/${DIRLIB}/$(patsubst %_${VER}.so,%.so,$(@F))
159    
160     ${LIBCPPLIBS}: ${LIBCPPSRCS}
161     #
162     # create .o
163     #
164     @(${EGREEN} "Compiling file: "${WHITE} "`basename $(@F) _${VER}.so | sed s/lib//`.cpp"; ${RESET})
165     @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} -I${PAM_INC} ;
166     #
167     # create .so
168     #
169     @(${EGREEN} "Compiling shared library: "${WHITE} "$@"; ${RESET})
170     @${CXX} ${CXXFLAGS} -Xlinker -soname=$(@F) -shared -o $@ -lg2c -I${DIRTOP}/${DIRINC} -I${DIRTOP} -I${PAM_YODA}/include/yoda/ -I${PAM_INC} ${DIRTOP}/${DIRSRC}/`basename $(@F) _${VER}.so | sed s/lib//`.o 1>/dev/null
171    
172    
173     ${CXXEXELIBS}: ${COBJS} ${FOBJS} ${CXXEXEOBJS}
174     @(${EVIOLET} "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *")
175     @(${EGREEN} "Creating exec file: "${WHITE} "$@"; ${RESET})
176     @${CXX} ${CXXFLAGS} -o ${DIRBIN}/$@ ${DIRLIB}/$@.o -I${DIRTOP}/${DIRINC} -I${PAM_INC} -I${PAM_YODA}/include/yoda/ ${PAM_YODA}/lib/libyoda.so ${FOBJS} ${COBJS} ${FULLLIBS} ${OTHERLIBS} -lThread `root-config --cflags --glibs` `doc/cernlib_pam mathlib` ;
177    
178     # A small target to check environmental variables
179     %_env:
180     @${test_env}
181    
182     .PHONY: install installdoc installlib installmacros installinc installexe installcmacro
183     .PHONY: clean depclean info mkbindir mklibdir testcern testpamenv test
184    
185     mkbindir: ${DIRBIN}
186     ${DIRBIN}:
187     @${test_and_mk}
188    
189     mklibdir: ${DIRLIB}
190     ${DIRLIB}:
191     @${test_and_mk}
192    
193     # Here what has to be deleted in clean target
194     clean: TOBEDEL= ${DIRSRC}/*.o ${DIRSRC}/*Dict.cpp ${DIRSRC}/*Dict.h ${FOBJS} ${FULLLIBS} ${DIRBIN}/${CXXEXELIBS} ${COBJS} ${CXXEXEOBJS}
195     clean:
196     @${test_and_rm}
197    
198     distclean: clean
199     distclean: TOBEDEL= ${DIRBIN} ${DIRLIB}
200     distclean:
201     @${test_and_rm}
202    
203     forceinstall: FORCE=-f
204     forceinstall: install
205    
206     upgrade: FORCE=-u
207     upgrade: install
208    
209     install: installlib installinc installmacros installcalib installdoc installexe installcmacro
210    
211     installlib: LINK=y
212     installlib: TOBEMOVED= $(FULLLIBS:${DIRLIB}%=${PAM_LIB}%)
213     installlib: ORIGIN=${DIRLIB}
214     installlib:
215     @${test_and_cp}
216    
217     installcmacro: LINK=y
218     installcmacro: TOBEMOVED= $(FULLMACROCLIBS:${DIRLIB}%=${PAM_LIB}%)
219     installcmacro: ORIGIN=${DIRLIB}
220     installcmacro:
221     @${test_and_cp}
222    
223     installinc: TOBEMOVED= $(INCSRCS:${DIRINC}/%=${PAM_INC}/%)
224     installinc: ORIGIN=${DIRINC}
225     installinc:
226     @${test_and_cp}
227    
228     installexe: TOBEMOVED= $(EXESRCS:${DIRBIN}/%=${PAM_BIN}/%)
229     installexe: ORIGIN=${DIRBIN}
230     installexe:
231     @${test_and_cp}
232    
233     installmacros: TOBEMOVED= $(MACROSSRCS:${DIRMACROS}/%=${PAM_MACROS}/%)
234     installmacros: ORIGIN=${DIRMACROS}
235     installmacros:
236     @${test_and_cp}
237    
238     installcalib: TOBEMOVED= $(CALIBFILES:${DIRCALIB}/%=${PAM_CALIB}/%)
239     installcalib: ORIGIN=${DIRCALIB}
240     installcalib:
241     @${test_and_cp}
242    
243     installdoc: TOBEMOVED= $(DOCFILES:${DIRDOC}/%=${PAM_DOC}/%)
244     installdoc: ORIGIN=${DIRDOC}
245     installdoc:
246     @${test_and_cp}
247    
248     #mkverpath:
249     # @echo '#include <TSystem.h>' > ${DIRTOP}/${DIRSRC}/TrkVerl2.cpp; echo ' void info(){ printf("\nTracker Level2 flight package version: ${VER}\n\nCompiled on '${TODAY}' with: '${GCCVER}'\n\nOn: '${UNAMEA}'\n\n"); }' >> ${DIRTOP}/${DIRSRC}/TrkVerl2.cpp
250     # @sleep 0.8
251    
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} " INCLUDES :" ${WHITE} ${INCLUDE}
260     @${EGREEN} " LIBS :" ${WHITE} ${LIBS}
261     @${EGREEN} " DOCS :" ${WHITE} ${DOCS}
262     @${EGREEN} " SRCS :" ${WHITE} ${SRCS}
263     @${EGREEN} " MACROS :" ${WHITE} ${MACROS}
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 test_and_mk
320     ${EGREEN} "Testing for :" ${WHITE} "$@"; ${RESET}
321     test -d "$@" || \
322     (${EGREEN} "Creating : "${WHITE} "$@"; ${RESET}; mkdir -p $@)
323     endef
324    
325     define test_env
326     ${EGREEN} "Testing for env:" ${WHITE} $(patsubst %_env,%,$@); ${RESET}
327     printenv $(patsubst %_env,%,$@) 1>/dev/null || \
328     (${ERED} "ERROR, variable : "${WHITE} $(patsubst %_env,%,$@) \
329     ${RED} "not defined !!! Check your env. settings"; \
330     ${RESET}; exit 1)
331     ${EGREEN} " Defined:" ${WHITE} $${$(patsubst %_env,%,$@)}; ${RESET}
332     endef
333    
334     define test_cmd
335     ${EGREEN} "Testing for cmd:" ${WHITE} $@ ${OPT}; ${RESET}
336     $@ ${OPT} 1>/dev/null 2>&1 || \
337     (${ERED} "ERROR, command : "${WHITE} $@ ${OPT}\
338     ${RED} "not found !!! Check your installation"; \
339     ${RESET}; exit 1)
340     ${EGREEN} " Present:" ${WHITE} $@ ${OPT}; ${RESET}
341     endef
342    
343     define test_and_rm
344     for i in ${TOBEDEL}; do \
345     test -d $${i} || (${ERED} "Removing file :"${WHITE} $${i}; ${RESET}; \
346     rm -f $${i} ); \
347     test ! -d $${i} || (${ERED} "Removing dir :"${WHITE} $${i}; ${RESET}; \
348     rm -rf $${i} ); \
349     done
350     endef

  ViewVC Help
Powered by ViewVC 1.1.23