/[PAMELA software]/calo/flight/CaloDoubleShower/Makefile
ViewVC logotype

Annotation of /calo/flight/CaloDoubleShower/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations) (download)
Mon Sep 22 20:10:11 2008 UTC (16 years, 2 months ago) by mocchiut
Branch: MAIN
Changes since 1.1: +6 -6 lines
Added -m32 flag for cross compilation on 64bit machines

1 mocchiut 1.1 # Calorimeter double shower plugin
2     # SOFTWARE VERSION
3     VER= v1r00
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 mocchiut 1.2 #CFLAGS=-Wall -O -fPIC -pthread -g -m32
27     CFLAGS=-Wall -O -fPIC -pthread -m32
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.2 #F77FLAGS= -Wall -Wno-globals -fvxt -fno-automatic -fbounds-check -g -extend_source -static -fno-backslash -m32
35     F77FLAGS= -Wall -Wno-globals -fvxt -fno-automatic -fbounds-check -extend_source -static -fno-backslash -m32
36 mocchiut 1.1 # C++
37     CXX=g++
38 mocchiut 1.2 #CXXFLAGS=-Wall -O -fPIC -pthread -g -m32
39     CXXFLAGS=-Wall -O -fPIC -pthread -m32
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     DIRSRC=src
47     DIRINC=inc
48     DIRDOC=doc
49     DIRMACROS=macros
50     DIRCALIB=calib
51     # Here the PAMELA environmental variables to be checked
52     PAM_ENV= PAM_BIN_env PAM_LIB_env PAM_INC_env PAM_DOC_env PAM_CALIB_env PAM_YODA_env
53     # Here the local variables used to build the targets
54     #-------------------------------------------------
55     FSRCS=${DIRSRC}/getdblsh.for \
56     ${DIRSRC}/dblsc.for \
57     ${DIRSRC}/dubsc.for
58     FOBJS=$(FSRCS:${DIRSRC}/%.for=${DIRLIB}/%.o)
59     #-------------------------------------------------
60     CSRCS=
61     COBJS=$(CSRCS:${DIRSRC}%.cpp=${DIRLIB}/%.o)
62     #-------------------------------------------------
63     # librerie utilizzabili da root (ci deve essere anche il ***LinkDef.h )
64     LIBROOTSRCS=${DIRSRC}/CaloDoubleShower.cpp
65     LIBROOTLIBS=$(LIBROOTSRCS:${DIRSRC}/%.cpp=${DIRLIB}/lib%_${VER}.so)
66     LIBROOTOBJS=${FOBJS}
67     LIBROOTCLIBS=libCaloDoubleShower
68     FULLROOTCLIBS=$(LIBROOTCLIBS:%=${DIRLIB}/%_${VER}.so)
69     #-------------------------------------------------
70     # librerie C++ NON utilizzabili da root
71     LIBCPPSRCS=#${DIRSRC}/PamLevel2.cpp
72     LIBCPPLIBS=$(LIBCPPSRCS:${DIRSRC}/%.cpp=${DIRLIB}/lib%_${VER}.so)
73     LIBCPPCLIBS=#libPamLevel2
74     FULLCPPCLIBS=$(LIBCPPCLIBS:%=${DIRLIB}/%_${VER}.so)
75     #-------------------------------------------------
76     # librerie F77 NON utilizzabili da root
77     LIBF77SRCS=
78     LIBF77OBJS= $(LIBF77SRCS:${DIRSRC}/%.for=${DIRLIB}/%.o)
79     LIBF77LIBS= $(LIBF77SRCS:${DIRSRC}/%.for=${DIRLIB}/lib%_${VER}.so)
80     LIBF77CLIBS=
81     FULLF77CLIBS=$(LIBF77CLIBS:%=${DIRLIB}/%_${VER}.so)
82     #-------------------------------------------------
83     FULLLIBS=${FULLROOTCLIBS} ${FULLCPPCLIBS} ${FULLF77CLIBS}
84    
85     #-------------------------------------------------
86     # eseguibile
87     CXXEXESRCS=
88     CXXEXEOBJS=$(CXXEXESRCS:${DIRSRC}%.cpp=${DIRLIB}%.o)
89     CXXEXELIBS:=
90    
91     OTHERLIBS=${PAM_LIB}/libCaloLevel0.so ${PAM_LIB}/libCaloLevel1.so ${PAM_LIB}/libCaloLevel2.so ${PAM_LIB}/libCaloCore.so ${PAM_LIB}/libcaloclasses.so
92     #-------------------------------------------------
93     # variabili per l'installazione
94     EXESRCS=
95     INCSRCS=${DIRINC}/CaloDoubleShower.h
96     MACROSSRCS=
97     CALIBFILES=
98     DOCFILES=
99     # Here the Variables used for info target
100     PACKAGE=Tracker flight software
101     EXECUTABLES=${EXESRCS}
102     LIBS= ${FULLLIBS} ${OTHERLIBS}
103     DOCS=
104     SRCS=
105     MACROS= ${MACROSSRCS}
106     INCLUDE= ${INCSRCS}
107     #
108     TOBEDEL = junk
109     ROOTINC=$$${shell root-config --incdir}
110     NROOTINC=${shell root-config --incdir}
111     # Let's start
112     all : test mkbindir mklibdir ${LIBF77LIBS} ${LIBROOTLIBS} ${LIBCPPLIBS} ${CXXEXELIBS}
113     all:
114     @echo -e ${GREEN} ""
115     @(${EGREEN} " Finished, now you can install the package \n (use: make install or make upgrade or make forceinstall) "; ${RESET})
116     @echo -e ${GREEN} ""
117     @${RESET}
118    
119     # Here some general rules to produce objects in our local dir
120     ${DIRLIB}/%.o: ${DIRSRC}/%.cpp
121     @(${EYELLOW} " C++ object ------------------------")
122     @(${EGREEN} "Creating object file: "${WHITE} "$@"; ${RESET})
123     @${CXX} ${CXXFLAGS} -c -o $@ ${DIRSRC}/`basename ${@} .o`.cpp -I${DIRINC} -I${PAM_INC} -I${PAM_YODA}/include/yoda/ `root-config --cflags`
124    
125     ${DIRLIB}/%.o : ${DIRSRC}/%.for
126     @(${EYELLOW} " F77 object ------------------------")
127     @(${EGREEN} "Creating object file: "${WHITE} "$@"; ${RESET})
128     @${F77} ${F77FLAGS} -c -o $@ ${DIRSRC}/`basename ${@} .o`.for -I${DIRINC} -I${NROOTINC} -I${PAM_INC} -I${PAM_YODA}/include/yoda
129    
130    
131     # .so from .o fortran
132     ${LIBF77LIBS}: ${LIBF77OBJS}
133     @(${EYELLOW} " F77 shared library --------------------------")
134     @(${EGREEN} "Creating library: "${WHITE} "$@"; ${RESET})
135     @${CXX} ${CXXFLAGS} -Xlinker -soname=$(@F) -shared -o $@ $^ -lg2c `doc/cernlib_pam mathlib`
136    
137    
138     ${LIBROOTLIBS}: ${FOBJS} ${LIBROOTSRCS}
139     @(${EYELLOW} " ROOT library ------------------------")
140     @(${EGREEN} "Creating file: "${WHITE} "`basename $(@F) _${VER}.so | sed s/lib//`Dict.cpp"; ${RESET})
141     #
142     # Create *Dict.cpp and *Dict.h
143     #
144     # @${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
145     @${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
146     #
147     # 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!
148     # should be fixed some time changing names...
149     #
150     # create .o
151     #
152     @(${EGREEN} "Compiling file: "${WHITE} "`basename $(@F) _${VER}.so | sed s/lib//`.cpp"; ${RESET})
153     @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};
154     @(${EGREEN} "Compiling file: "${WHITE} "`basename $(@F) _${VER}.so | sed s/lib//`Dict.cpp"; ${RESET})
155     @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};
156     #
157     # create .so
158     #
159     @(${EGREEN} "Compiling shared library: "${WHITE} "$@"; ${RESET})
160     @${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
161     # @ln -sf ${DIRTOP}/${DIRLIB}/$(@F) ${DIRTOP}/${DIRLIB}/$(patsubst %_${VER}.so,%.so,$(@F))
162    
163     ${LIBCPPLIBS}: ${LIBCPPSRCS}
164     #
165     # create .o
166     #
167     @(${EGREEN} "Compiling file: "${WHITE} "`basename $(@F) _${VER}.so | sed s/lib//`.cpp"; ${RESET})
168     @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} ;
169     #
170     # create .so
171     #
172     @(${EGREEN} "Compiling shared library: "${WHITE} "$@"; ${RESET})
173     @${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
174    
175    
176     ${CXXEXELIBS}: ${COBJS} ${FOBJS} ${CXXEXEOBJS}
177     @(${EVIOLET} "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *")
178     @(${EGREEN} "Creating exec file: "${WHITE} "$@"; ${RESET})
179     @${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` ;
180    
181     # A small target to check environmental variables
182     %_env:
183     @${test_env}
184    
185     .PHONY: install installdoc installlib installmacros installinc installexe installcmacro
186     .PHONY: clean depclean info mkbindir mklibdir testcern testpamenv test
187    
188     mkbindir: ${DIRBIN}
189     ${DIRBIN}:
190     @${test_and_mk}
191    
192     mklibdir: ${DIRLIB}
193     ${DIRLIB}:
194     @${test_and_mk}
195    
196     # Here what has to be deleted in clean target
197     clean: TOBEDEL= ${DIRSRC}/*.o ${DIRSRC}/*Dict.cpp ${DIRSRC}/*Dict.h ${FOBJS} ${FULLLIBS} ${DIRBIN}/${CXXEXELIBS} ${COBJS} ${CXXEXEOBJS}
198     clean:
199     @${test_and_rm}
200    
201     distclean: clean
202     distclean: TOBEDEL= ${DIRBIN} ${DIRLIB}
203     distclean:
204     @${test_and_rm}
205    
206     forceinstall: FORCE=-f
207     forceinstall: install
208    
209     upgrade: FORCE=-u
210     upgrade: install
211    
212     install: installlib installinc installmacros installcalib installdoc installexe installcmacro
213    
214     installlib: LINK=y
215     installlib: TOBEMOVED= $(FULLLIBS:${DIRLIB}%=${PAM_LIB}%)
216     installlib: ORIGIN=${DIRLIB}
217     installlib:
218     @${test_and_cp}
219    
220     installcmacro: LINK=y
221     installcmacro: TOBEMOVED= $(FULLMACROCLIBS:${DIRLIB}%=${PAM_LIB}%)
222     installcmacro: ORIGIN=${DIRLIB}
223     installcmacro:
224     @${test_and_cp}
225    
226     installinc: TOBEMOVED= $(INCSRCS:${DIRINC}/%=${PAM_INC}/%)
227     installinc: ORIGIN=${DIRINC}
228     installinc:
229     @${test_and_cp}
230    
231     installexe: TOBEMOVED= $(EXESRCS:${DIRBIN}/%=${PAM_BIN}/%)
232     installexe: ORIGIN=${DIRBIN}
233     installexe:
234     @${test_and_cp}
235    
236     installmacros: TOBEMOVED= $(MACROSSRCS:${DIRMACROS}/%=${PAM_MACROS}/%)
237     installmacros: ORIGIN=${DIRMACROS}
238     installmacros:
239     @${test_and_cp}
240    
241     installcalib: TOBEMOVED= $(CALIBFILES:${DIRCALIB}/%=${PAM_CALIB}/%)
242     installcalib: ORIGIN=${DIRCALIB}
243     installcalib:
244     @${test_and_cp}
245    
246     installdoc: TOBEMOVED= $(DOCFILES:${DIRDOC}/%=${PAM_DOC}/%)
247     installdoc: ORIGIN=${DIRDOC}
248     installdoc:
249     @${test_and_cp}
250    
251     #mkverpath:
252     # @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
253     # @sleep 0.8
254    
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} " INCLUDES :" ${WHITE} ${INCLUDE}
263     @${EGREEN} " LIBS :" ${WHITE} ${LIBS}
264     @${EGREEN} " DOCS :" ${WHITE} ${DOCS}
265     @${EGREEN} " SRCS :" ${WHITE} ${SRCS}
266     @${EGREEN} " MACROS :" ${WHITE} ${MACROS}
267     @echo " "
268     @${RESET}
269    
270     test: testpamenv
271    
272     testpamenv: ${PAM_ENV}
273    
274     root-config: OPT=--cflags
275     root-config:
276     @${test_cmd}
277    
278     # Here follows some usefull macros
279     define test_and_cp
280     wd=`pwd`;\
281     for i in ${TOBEMOVED} ; do \
282     wv=$${i##/*/}; \
283     dest=$${i/$${wv}/}; \
284     ${EGREEN} "Testing for :" ${WHITE} "$${i}" ; ${RESET}; \
285     if [ ! "${FORCE}" ] ; then \
286     if [ ! -f $${i} ]; then \
287     ${EGREEN} "Copying : "${WHITE} ${ORIGIN}/$${i##/*/} ;\
288     ${EGREEN} " to: "${WHITE} $${i} ; ${RESET}; \
289     cp ${ORIGIN}/$${i##/*/} $${i}; \
290     else \
291     ${ERED} "File already exist !!!! Please delete it " ${WHITE}; ${RESET}; \
292     fi;\
293     else \
294     if [ "${FORCE}" == "-u" ] ; then \
295     if [ "`basename $${i}`" != "`basename $${i} _${VER}.so`" ]; then \
296     ${EYELLOW} "Removing: "${WHITE} ${PAM_LIB}/`basename $${i} _${VER}.so`_v*r*.so; ${RESET}; \
297     rm -f ${PAM_LIB}/`basename $${i} _${VER}.so`_v*r*.so ; \
298     ${EGREEN} "Copying : "${WHITE} ${ORIGIN}/$${i##/*/} ;\
299     ${EGREEN} " to: "${WHITE} $${i} ; ${RESET}; \
300     cp ${ORIGIN}/$${i##/*/} $${i}; \
301     else \
302     ${EYELLOW} " Forcing copy: "${WHITE} ${ORIGIN}/$${i##/*/} ;\
303     ${EYELLOW} " to: "${WHITE} $${i} ; ${RESET}; \
304     cp -f ${ORIGIN}/$${i##/*/} $${i}; \
305     fi; \
306     else \
307     ${EYELLOW} " Forcing copy: "${WHITE} ${ORIGIN}/$${i##/*/} ;\
308     ${EYELLOW} " to: "${WHITE} $${i} ; ${RESET}; \
309     cp ${FORCE} ${ORIGIN}/$${i##/*/} $${i}; \
310     fi;\
311     fi ;\
312     if [ ! -z ${LINK} ] ; then \
313     ${EGREEN} "Creating symlink from : "${WHITE} $${wv/_${VER}/} ;\
314     ${EGREEN} " to : "${WHITE} $${i##/*/} ; ${RESET}; \
315     cd $${dest}; \
316     ln -sf $${wv} $${wv/_${VER}/}; \
317     cd $${wd}; \
318     fi \
319     done
320     endef
321    
322     define test_and_mk
323     ${EGREEN} "Testing for :" ${WHITE} "$@"; ${RESET}
324     test -d "$@" || \
325     (${EGREEN} "Creating : "${WHITE} "$@"; ${RESET}; mkdir -p $@)
326     endef
327    
328     define test_env
329     ${EGREEN} "Testing for env:" ${WHITE} $(patsubst %_env,%,$@); ${RESET}
330     printenv $(patsubst %_env,%,$@) 1>/dev/null || \
331     (${ERED} "ERROR, variable : "${WHITE} $(patsubst %_env,%,$@) \
332     ${RED} "not defined !!! Check your env. settings"; \
333     ${RESET}; exit 1)
334     ${EGREEN} " Defined:" ${WHITE} $${$(patsubst %_env,%,$@)}; ${RESET}
335     endef
336    
337     define test_cmd
338     ${EGREEN} "Testing for cmd:" ${WHITE} $@ ${OPT}; ${RESET}
339     $@ ${OPT} 1>/dev/null 2>&1 || \
340     (${ERED} "ERROR, command : "${WHITE} $@ ${OPT}\
341     ${RED} "not found !!! Check your installation"; \
342     ${RESET}; exit 1)
343     ${EGREEN} " Present:" ${WHITE} $@ ${OPT}; ${RESET}
344     endef
345    
346     define test_and_rm
347     for i in ${TOBEDEL}; do \
348     test -d $${i} || (${ERED} "Removing file :"${WHITE} $${i}; ${RESET}; \
349     rm -f $${i} ); \
350     test ! -d $${i} || (${ERED} "Removing dir :"${WHITE} $${i}; ${RESET}; \
351     rm -rf $${i} ); \
352     done
353     endef

  ViewVC Help
Powered by ViewVC 1.1.23