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

Annotation of /DarthVader/ToFLevel2/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.17 - (hide annotations) (download)
Tue Apr 1 09:35:46 2008 UTC (16 years, 8 months ago) by pamela
Branch: MAIN
Changes since 1.16: +1 -1 lines
v2r01 - nuclei dedx and beta[12] bugs fixed

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

  ViewVC Help
Powered by ViewVC 1.1.23