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

Annotation of /DarthVader/CalorimeterLevel2/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.9 - (hide annotations) (download)
Tue Nov 14 14:08:48 2006 UTC (18 years, 1 month ago) by mocchiut
Branch: MAIN
Changes since 1.8: +1 -1 lines
Major calorimeter release, some news in DarthVader main

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

  ViewVC Help
Powered by ViewVC 1.1.23