/[PAMELA software]/DarthVader/Makefile
ViewVC logotype

Annotation of /DarthVader/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.2 - (hide annotations) (download) (vendor branch)
Sat Jun 17 12:12:48 2006 UTC (18 years, 5 months ago) by mocchiut
Branch: DarthVader, TriggerLevel2
CVS Tags: v0r01, start
Changes since 1.1.1.1: +54 -111 lines
Imported sources

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

  ViewVC Help
Powered by ViewVC 1.1.23