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

Annotation of /DarthVader/RunInfo/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (hide annotations) (download)
Tue Sep 5 13:21:10 2006 UTC (18 years, 2 months ago) by mocchiut
Branch: MAIN
CVS Tags: v2r00BETA
Changes since 1.4: +1 -1 lines
THIS VERSION DOES NOT COMPILE - S4 and RunInfo are fixed

1 mocchiut 1.1 # RunInfo software
2     # SOFTWARE VERSION
3 mocchiut 1.5 VER= v1r03
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     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
53     #
54 mocchiut 1.4 SUBDIR=
55     SUBINC=-I${PAM_YODA}/include/yoda/ -I${PAM_INC}/
56     #SUBINC=$(shell for dir in `echo ${SUBDIR}`; do echo -I$${dir}/inc; done)
57 mocchiut 1.1
58     # Here the local variables used to build the targets
59     # -- F77 - no libraries --
60     FSRCS=
61     FOBJS=$(FSRCS:${DIRSRC}%.for=${DIRLIB}%.o)
62    
63     # -- CPP - no libraries --
64     CPPSRCS=${DIRSRC}/RunInfoVerl2.cpp
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}/RunInfo.cpp
73     LIBROOTLIBS=$(LIBROOTSRCS:${DIRSRC}/%.cpp=${DIRLIB}/lib%_${VER}.so)
74     LIBROOTCLIBS=libRunInfo
75     FULLROOTCLIBS=$(LIBROOTCLIBS:%=${DIRLIB}/%_${VER}.so)
76    
77     # -- CPP - NON-ROOT libraries --
78     #LIBCPPSRCS=
79     LIBCPPSRCS=${DIRSRC}/RunInfoCore.cpp
80    
81     LIBCPPLIBS=$(LIBCPPSRCS:${DIRSRC}/%.cpp=${DIRLIB}/lib%_${VER}.so)
82     LIBCPPCLIBS=libRunInfoCore
83     #LIBCPPCLIBS=
84     FULLLIBCPPLIBS=$(LIBCPPCLIBS:%=${DIRLIB}/%_${VER}.so)
85    
86     # -- CPP - Executables --
87     CXXEXESRCS=${DIRSRC}/RunInfoLevel2.cpp
88     CXXEXEOBJS=$(CXXEXESRCS:${DIRSRC}%.cpp=${DIRLIB}%.o)
89     CXXEXELIBS=RunInfoLevel2
90    
91     # Other needed libraries
92 mocchiut 1.4 OTHOBJS = ${PAM_LIB}/libGLTables.so
93 mocchiut 1.1
94     # List of all libraries we want to install
95     FULLLIBS = ${FULLROOTCLIBS} ${FULLLIBCPPLIBS}
96    
97     # Other objects to install
98 mocchiut 1.2 EXESRCS=${DIRBIN}/RunInfoLevel2
99 mocchiut 1.1
100 pam-fi 1.3 INCSRCS=${DIRINC}/RunInfo.h ${DIRINC}/RunInfoCore.h ${DIRINC}/RunInfoStruct.h
101 mocchiut 1.1
102     MACROSSRCS=
103    
104     CALIBFILES=
105    
106     DOCFILES=
107    
108     # Here the Variables used for info target
109     PACKAGE=RunInfo flight software
110     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 ${FOBJS} ${CPPOBJS} ${LIBROOTLIBS} ${LIBCPPLIBS} ${CXXEXELIBS}
123     all: prepare libs
124     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     standalone: all exe
131    
132     prepare: test mkbindir mklibdir mkversion
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     @${CXX} ${CXXFLAGS} -c -o $@ ${DIRSRC}/`basename ${@} .o`.cpp -I${DIRINC} ${SUBINC} -I/wizard3/pamela/sw/src/offline/pamlevel2/calorimeter/inc `root-config --cflags`
142    
143     ${DIRLIB}/%.o: ${DIRSRC}/%.c
144     @(${EGREEN} "Creating C object file: "${WHITE} "`basename $@`"; ${RESET})
145 mocchiut 1.4 @${CXX} ${CXXFLAGS} -c -o $@ ${DIRSRC}/`basename ${@} .o`.c -I${DIRINC} ${SUBINC} `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} ${SUBINC} ${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     @${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${NROOTINC};
162     @(${EGREEN} "Compiling CPP file: "${WHITE} "`basename $(@F) _${VER}.so | sed s/lib//`Dict.cpp"; ${RESET})
163     @${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${NROOTINC};
164     #
165     # create .so
166     #
167     @(${EGREEN} "Creating shared library: "${WHITE} "`basename $@`"; ${RESET})
168     @${CXX} ${CXXFLAGS} -Xlinker -soname=$(@F) -shared -o $@ -lg2c -I${DIRTOP}/${DIRINC} -I${DIRTOP} ${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     @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     @${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${NROOTINC};
177     #
178     # create .so
179     #
180     @(${EGREEN} "Creating shared library: "${WHITE} "`basename $@`"; ${RESET})
181     @${CXX} ${CXXFLAGS} -Xlinker -soname=$(@F) -shared -o $@ -lg2c -I${DIRTOP}/${DIRINC} -I${DIRTOP} ${SUBINC} ${DIRTOP}/${DIRLIB}/`basename $(@F) _${VER}.so | sed s/lib//`.o ${FOBJS} ${COBJS} 1>/dev/null
182     @ln -sf ${DIRTOP}/${DIRLIB}/$(@F) ${DIRTOP}/${DIRLIB}/$(patsubst %_${VER}.so,%.so,$(@F))
183    
184     ${CXXEXELIBS}: ${CPPOBJS} ${COBJS} ${CXXEXEOBJS}
185     @(${EGREEN} "Creating exec file: "${WHITE} "`basename $@ Level2`"; ${RESET})
186     @${CXX} ${CXXFLAGS} -o ${DIRBIN}/$@ ${DIRLIB}/$@.o ${OTHOBJS} ${FULLROOTCLIBS} ${FULLLIBCPPLIBS} ${CPPOBJS} ${FOBJS} ${PAM_YODA}/lib/libyoda.so -I${DIRINC} ${SUBINC} -I${PAM_YODA}/include/yoda/ -lThread `root-config --cflags --glibs` `cernlib mathlib`
187    
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     clean: TOBEDEL= ${DIRSRC}/*.o ${DIRSRC}/*Dict.cpp ${DIRSRC}/*Dict.h ${FOBJS} ${FULLLIBS} ${DIRBIN}/${CXXEXELIBS} ${CPPOBJS} ${CXXEXEOBJS} ${FULLLINKCLIBS} ${FULLMACROCLIBS} ${FULLLINKMACROCLIBS} ${DIRSRC}/RunInfoVerl2.cpp
205     clean:
206     @${test_and_rm}
207    
208     distclean: clean
209     distclean: TOBEDEL= ${DIRBIN} ${DIRLIB}
210     distclean:
211     @${test_and_rm}
212    
213     forceinstall: FORCE=-f
214     forceinstall: install
215    
216     forceinstallstandalone: FORCE=-f
217     forceinstallstandalone: installstandalone
218    
219     upgrade: FORCE=-u
220     upgrade: install
221    
222     upgradestandalone: FORCE=-u
223     upgradestandalone: installstandalone
224    
225     install: installlib installinc installmacros installcalib installdoc installcmacro
226    
227     installstandalone: install installexe
228    
229     installlib: LINK=y
230     installlib: TOBEMOVED= $(FULLLIBS:${DIRLIB}%=${PAM_LIB}%)
231     installlib: ORIGIN=${DIRLIB}
232     installlib:
233     @${test_and_cp}
234    
235     installcmacro: LINK=y
236     installcmacro: TOBEMOVED= $(FULLMACROCLIBS:${DIRLIB}%=${PAM_LIB}%)
237     installcmacro: ORIGIN=${DIRLIB}
238     installcmacro:
239     @${test_and_cp}
240    
241     installinc: TOBEMOVED= $(INCSRCS:${DIRINC}/%=${PAM_INC}/%)
242     installinc: ORIGIN=${DIRINC}
243     installinc:
244     @${test_and_cp}
245    
246     installexe: TOBEMOVED= $(EXESRCS:${DIRBIN}/%=${PAM_BIN}/%)
247     installexe: ORIGIN=${DIRBIN}
248     installexe:
249     @${test_and_cp}
250    
251     installmacros: TOBEMOVED= $(MACROSSRCS:${DIRMACROS}/%=${PAM_MACROS}/%)
252     installmacros: ORIGIN=${DIRMACROS}
253     installmacros:
254     @${test_and_cp}
255    
256     installcalib: TOBEMOVED= $(CALIBFILES:${DIRCALIB}/%=${PAM_CALIB}/%)
257     installcalib: ORIGIN=${DIRCALIB}
258     installcalib:
259     @${test_and_cp}
260    
261     installdoc: TOBEMOVED= $(DOCFILES:${DIRDOC}/%=${PAM_DOC}/%)
262     installdoc: ORIGIN=${DIRDOC}
263     installdoc:
264     @${test_and_cp}
265    
266     mkversion:
267     @echo '#include <TSystem.h>' > ${DIRTOP}/${DIRSRC}/RunInfoVerl2.cpp; echo ' char *RunInfoInfo(bool print){ if ( print ) printf("\nRunInfo package version: ${VER}\n\nCompiled on '${TODAY}' with: '${GCCVER}'\n\nOn: '${UNAMEA}'\n\n"); return("${VER}"); }' >> ${DIRTOP}/${DIRSRC}/RunInfoVerl2.cpp
268     @sleep 0.8
269    
270    
271     info:
272     @echo " "
273     @${EGREEN} "Infos for package :" ${WHITE} ${PACKAGE}
274     @${EGREEN} " VERSION :" ${WHITE} ${VER}
275     @${EGREEN} " EXECUTABLES :" ${WHITE} ${EXECUTABLES}
276     @${EGREEN} " LIBS :" ${WHITE} ${LIBS}
277     @${EGREEN} " DOCS :" ${WHITE} ${DOCS}
278     @${EGREEN} " SRCS :" ${WHITE} ${SRCS}
279     @${EGREEN} " MACROS :" ${WHITE} ${MACROS}
280     @${EGREEN} " INCLUDE :" ${WHITE} ${INCLUDE}
281     @echo " "
282     @${RESET}
283    
284     test: testpamenv
285    
286     testpamenv: ${PAM_ENV}
287    
288     root-config: OPT=--cflags
289     root-config:
290     @${test_cmd}
291    
292     # Here follows some usefull macros
293     define test_and_cp
294     wd=`pwd`;\
295     for i in ${TOBEMOVED} ; do \
296     wv=$${i##/*/}; \
297     dest=$${i/$${wv}/}; \
298     ${EGREEN} "Testing for :" ${WHITE} "$${i}" ; ${RESET}; \
299     if [ ! "${FORCE}" ] ; then \
300     if [ ! -f $${i} ]; then \
301     ${EGREEN} "Copying : "${WHITE} ${ORIGIN}/$${i##/*/} ;\
302     ${EGREEN} " to: "${WHITE} $${i} ; ${RESET}; \
303     cp ${ORIGIN}/$${i##/*/} $${i}; \
304     else \
305     ${ERED} "File already exist !!!! Please delete it " ${WHITE}; ${RESET}; \
306     fi;\
307     else \
308     if [ "${FORCE}" == "-u" ] ; then \
309     if [ "`basename $${i}`" != "`basename $${i} _${VER}.so`" ]; then \
310     ${EYELLOW} "Removing: "${WHITE} ${PAM_LIB}/`basename $${i} _${VER}.so`_v*r*.so; ${RESET}; \
311     rm -f ${PAM_LIB}/`basename $${i} _${VER}.so`_v*r*.so ; \
312     ${EGREEN} "Copying : "${WHITE} ${ORIGIN}/$${i##/*/} ;\
313     ${EGREEN} " to: "${WHITE} $${i} ; ${RESET}; \
314     cp ${ORIGIN}/$${i##/*/} $${i}; \
315     else \
316     ${EYELLOW} " Forcing copy: "${WHITE} ${ORIGIN}/$${i##/*/} ;\
317     ${EYELLOW} " to: "${WHITE} $${i} ; ${RESET}; \
318     cp -f ${ORIGIN}/$${i##/*/} $${i}; \
319     fi; \
320     else \
321     ${EYELLOW} " Forcing copy: "${WHITE} ${ORIGIN}/$${i##/*/} ;\
322     ${EYELLOW} " to: "${WHITE} $${i} ; ${RESET}; \
323     cp ${FORCE} ${ORIGIN}/$${i##/*/} $${i}; \
324     fi;\
325     fi ;\
326     if [ ! -z ${LINK} ] ; then \
327     ${EGREEN} "Creating symlink from : "${WHITE} $${wv/_${VER}/} ;\
328     ${EGREEN} " to : "${WHITE} $${i##/*/} ; ${RESET}; \
329     cd $${dest}; \
330     ln -sf $${wv} $${wv/_${VER}/}; \
331     cd $${wd}; \
332     fi \
333     done
334     endef
335    
336     define test_and_mk
337     ${EGREEN} "Testing for :" ${WHITE} "$@"; ${RESET}
338     test -d "$@" || \
339     (${EGREEN} "Creating : "${WHITE} "$@"; ${RESET}; mkdir -p $@)
340     endef
341    
342     define test_env
343     ${EGREEN} "Testing for env:" ${WHITE} $(patsubst %_env,%,$@); ${RESET}
344     printenv $(patsubst %_env,%,$@) 1>/dev/null || \
345     (${ERED} "ERROR, variable : "${WHITE} $(patsubst %_env,%,$@) \
346     ${RED} "not defined !!! Check your env. settings"; \
347     ${RESET}; exit 1)
348     ${EGREEN} " Defined:" ${WHITE} $${$(patsubst %_env,%,$@)}; ${RESET}
349     endef
350    
351     define test_cmd
352     ${EGREEN} "Testing for cmd:" ${WHITE} $@ ${OPT}; ${RESET}
353     $@ ${OPT} 1>/dev/null 2>&1 || \
354     (${ERED} "ERROR, command : "${WHITE} $@ ${OPT}\
355     ${RED} "not found !!! Check your installation"; \
356     ${RESET}; exit 1)
357     ${EGREEN} " Present:" ${WHITE} $@ ${OPT}; ${RESET}
358     endef
359    
360     define test_and_rm
361     for i in ${TOBEDEL}; do \
362     test -d $${i} || (${ERED} "Removing file :"${WHITE} $${i}; ${RESET}; \
363     rm -f $${i} ); \
364     test ! -d $${i} || (${ERED} "Removing dir :"${WHITE} $${i}; ${RESET}; \
365     rm -rf $${i} ); \
366     done
367     endef

  ViewVC Help
Powered by ViewVC 1.1.23