/[PAMELA software]/calo/ground/COMMON/Makefile
ViewVC logotype

Contents of /calo/ground/COMMON/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download)
Tue Dec 6 10:18:52 2005 UTC (19 years ago) by mocchiut
Branch: MAIN
Branch point for: COMMON
Initial revision

1 # CALO COMMON
2 # SOFTWARE VERSION
3 VER= v2r00
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 CFLAGS=-Wall -fPIC -O3
27 # Enviroment:
28 GCCVER=`gcc --version | head -1`
29 UNAMEA=`uname -a`
30 TODAY=`date`
31 # F77
32 F77=g77
33 #F77FLAGS= -Wall -fbounds-check -g -extend_source -static -fno-backslash
34 F77FLAGS= -Wall -O -Wno-globals -fvxt -fno-automatic -fbounds-check -g -extend_source -static -fno-backslash -fPIC
35 # C++
36 CXX=g++
37 CXXFLAGS=-Wall -fPIC -O3
38 # Here the variables definig the local directories
39 DIRTOP=${shell pwd}
40 DIRLIB=lib/${ARCH}
41 DIRBIN=bin/${ARCH}
42 DIRSRC=src
43 DIRINC=inc
44 DIRDOC=doc
45 DIRMACROS=macros
46 DIRCALIB=calib
47 # Here the PAMELA environmental variables to be checked
48 PAM_ENV= PAM_BIN_env PAM_LIB_env PAM_INC_env PAM_DOC_env PAM_MACROS_env PAM_CALIB_env PAM_YODA_env
49 # Here the local variables used to build the targets
50 FSRCS=
51
52 FOBJS=$(FSRCS:${DIRSRC}%.for=${DIRBIN}%.o)
53 FLIBS=
54 FULLFLIBS=$(FLIBS:%=${DIRLIB}/lib%_${VER}.so)
55 FULLLINKFLIBS=$(FLIBS:%=${DIRLIB}/lib%.so)
56
57 CSRCS=${DIRSRC}/qumy.c \
58 ${DIRSRC}/readmy.c
59
60 COBJS=$(CSRCS:${DIRSRC}%.c=${DIRBIN}%.o)
61 CLIBS=qumy readmy
62 FULLCLIBS=$(CLIBS:%=${DIRLIB}/lib%_${VER}.so)
63 FULLLINKCLIBS=$(CLIBS:%=${DIRLIB}/lib%.so)
64
65 CXXSRCS=${DIRSRC}/libqumy.C \
66 ${DIRSRC}/libreadmy.C
67 FULLCXXLIBS=$(CXXSRCS:${DIRSRC}/%.C=${DIRLIB}/%_C_${VER}.so)
68
69 MACROSRCS=${DIRMACROS}/CaloFINDCALIBS.c
70 MACROSLIBS=$(MACROSRCS:${DIRMACROS}/%.c=${DIRLIB}/%_c_${VER}.so)
71 MACROCLIBS=CaloFINDCALIBS_c
72 FULLMACROCLIBS=$(MACROCLIBS:%=${DIRLIB}/%_${VER}.so)
73 FULLLINKMACROCLIBS=$(MACROCLIBS:%=${DIRLIB}/%.so)
74
75 HSRCS=${DIRINC}/caloclasses.h
76 FULLHLIBS=$(HSRCS:${DIRINC}/%.h=${DIRLIB}/%_h_${VER}.so)
77
78 CXXEXESRCS=${DIRSRC}/calocommon.cc
79 CXXEXEOBJS=$(CXXEXESRCS:${DIRSRC}%.cc=${DIRBIN}%.o)
80 CXXEXELIBS:=calocommon
81
82 #FULLLIBS=$(sort ${FULLFLIBS} ${FULLCXXLIBS} )
83 FULLLIBS=${FULLFLIBS} ${FULLCXXLIBS} ${FULLCLIBS} ${FULLHLIBS}
84 #FULLLIBS=${ROOTCINTLIBS} ${FULLFLIBS} ${FULLCXXLIBS} ${FULLCLIBS}
85
86 EXESRCS= ${DIRBIN}/calocommon
87
88 INCSRCS= ${DIRINC}/calomysqlstruct.h ${DIRINC}/CaloFunctions.h ${DIRINC}/caloclasses.h
89
90 MACROSSRCS=${DIRMACROS}/rootlogon.C ${DIRMACROS}/CaloFINDCALIBS.c ${DIRMACROS}/CaloFINDCALIBS.C
91
92 CALIBFILES=${DIRCALIB}/CaloADC2MIP.root
93
94 DOCFILES=${DIRDOC}/calorimeterCOMMON.README.pdf ${DIRDOC}/packages
95
96 # Here the Variables used for info target
97 PACKAGE=Calorimeter ground software common files and libraries
98 EXECUTABLES=calocommon
99 LIBS= ${FLIBS} ${FOBJS} ${CLIBS} ${COBJS} ${CXXEXEOBJS}
100 DOCS=
101 SRCS= ${FSRCS} ${CRSCS} ${CXXEXESRCS}
102 MACROS= ${MACROSSRCS}
103 #
104 TOBEDEL = junk
105 # mysql include directory
106 INCMYSQL=$(shell mysql_config --cflags)
107 INCROOT=$(shell root-config --incdir)
108 LIBSROOT=$(shell root-config --libs)
109
110 # Let's start
111 all : test mkbindir mklibdir ${CXXEXELIBS} ${FULLFLIBS} ${FULLCXXLIBS} ${MACROSLIBS} ${FULLHLIBS}
112 #all : test mkbindir mklibdir ${ROOTCINTLIBS} ${CXXEXELIBS} ${FULLFLIBS} ${FULLCXXLIBS}
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 @if [ "$(shell ${PAM_BIN}/CaloLEVEL2 --version 2>/dev/null | grep version | tr -d [a-z:A-Z\ ])" ]; then (${EVIOLET} "WARNING: the installation will break dependencies of CALOLEVEL2"; ${RESET}); (${EVIOLET} "WARNING: re-compile CALOLEVEL2 package after the installation"; ${RESET}); echo -e ${GREEN} ""; fi
118 @${RESET}
119
120 # Here some general rules to produce objects in our local dir
121
122 # .o from fortran
123 ${DIRBIN}/%.o : ${DIRSRC}/%.for
124 @(${EGREEN} "Creating object file: "${WHITE} "$@"; ${RESET})
125 @${F77} ${F77FLAGS} -c -o $@ $< -I${DIRINC}
126
127 ${DIRBIN}/calocommon.o: ${CXXEXESRCS}
128 @(${EGREEN} "Creating object file: "${WHITE} "$@"; ${RESET})
129 @cat ${DIRSRC}/`basename ${@} .o`.cc > ${DIRSRC}/temp.cc;
130 @echo 'printf("\nCaloCOMMON version: ${VER}\n\nCompiled on '${TODAY}' with: '${GCCVER}'\n\nOn: '${UNAMEA}'\n\n"); }' >> ${DIRSRC}/temp.cc
131 @${CXX} ${CXXFLAGS} -c -o $@ ${DIRSRC}/temp.cc -I${DIRINC}
132
133 # .o from C
134 ${DIRBIN}/%.o : ${DIRSRC}/%.c
135 @(${EGREEN} "Creating object file: "${WHITE} "$@"; ${RESET})
136 @${CC} ${CFLAGS} -c -o $@ $< -I${DIRINC} ${INCMYSQL}
137
138
139 # .so from .o fortran
140 ${FULLFLIBS}: ${FOBJS}
141 @(${EGREEN} "Creating library: "${WHITE} "$@"; ${RESET})
142 @${CXX} ${CXXFLAGS} -Xlinker -soname=$(@F) -shared -o $@ $^ -lg2c `cernlib mathlib`
143 @(${EGREEN} "Creating symlink from : "${WHITE} "$@"; ${RESET})
144 @(${EGREEN} " to : "${WHITE} "${DIRLIB}/`basename $@ _${VER}.so`.so"; ${RESET})
145 @ln -sf `basename $@` ${DIRLIB}/`basename $@ _${VER}.so`.so
146
147 # .so from .o c
148 ${FULLCLIBS}: ${COBJS}
149 @(${EGREEN} "Creating library: "${WHITE} "$@"; ${RESET})
150 @${CXX} ${CXXFLAGS} -Xlinker -soname=$(@F) -shared -o $@ $^ -lg2c `mysql_config --cflags --libs`
151 # @${CXX} ${CXXFLAGS} -Xlinker -soname=$(@F) -shared -o $@ $^ `mysql_config --cflags --libs`
152 @(${EGREEN} "Creating symlink from : "${WHITE} "$@"; ${RESET})
153 @(${EGREEN} " to : "${WHITE} "${DIRLIB}/`basename $@ _${VER}.so`.so"; ${RESET})
154 @ln -sf `basename $@` ${DIRLIB}/`basename $@ _${VER}.so`.so
155
156 ${MACROSLIBS}: ${MACROSRCS}
157 @(${EGREEN} "Compiling macro: "${WHITE} "$@"; ${RESET})
158 # ${CXX} ${CXXFLAGS} -Xlinker -soname=$(@F) -shared -o $@ $^ -lg2c -I${DIRTOP}/${DIRINC} -I${PAM_INC} -I${PAM_YODASRC} -I${INCROOT} ${LIBSROOT} -L${DIRTOP}/${DIRLIB} -L${PAM_YODALIB} -lyoda -lqumy -lreadmy -lqumy_C -lreadmy_C
159 @echo '.include ${DIRTOP}/${DIRINC}' > build_so.txt
160 @echo 'TString *junk=new TString();' >> build_so.txt
161 @echo '*junk=gSystem->GetDynamicPath();' >> build_so.txt
162 @echo '*junk+=":${DIRLIB}";' >> build_so.txt
163 @echo 'gSystem->SetDynamicPath(junk.Data());' >> build_so.txt
164 @echo 'char *lmac = gSystem->ExpandPathName("$$PAM_INC");'>>build_so.txt
165 @echo 'gInterpreter->AddIncludePath(lmac);'>>build_so.txt
166 @echo 'char *pamyoda = gSystem->ExpandPathName("$$PAM_YODA");' >>build_so.txt
167 @echo 'stringstream incy;' >>build_so.txt
168 @echo 'incy.str("");' >>build_so.txt
169 @echo 'incy << pamyoda << "/include/yoda/";' >>build_so.txt
170 @echo 'gInterpreter->AddIncludePath(incy.str().c_str());' >>build_so.txt
171 @echo 'incy.str("");' >>build_so.txt
172 @echo 'incy << pamyoda << "/event/";'>>build_so.txt
173 @echo 'gInterpreter->AddIncludePath(incy.str().c_str());'>>build_so.txt
174 @echo 'gSystem->cd("'${DIRMACROS}'");' >> build_so.txt
175 @echo 'char *pamyodalib = gSystem->ExpandPathName("$$PAM_YODA");' >>build_so.txt
176 @echo 'stringstream libYODA;'>>build_so.txt
177 @echo 'libYODA.str("");' >>build_so.txt
178 @echo 'libYODA << pamyodalib << "/lib/libyoda.so";'>>build_so.txt
179 @echo 'gSystem->Load(libYODA.str().c_str());'>>build_so.txt
180 @echo 'libYODA.str("");' >>build_so.txt
181 @echo 'libYODA << "${DIRTOP}/${DIRLIB}/libreadmy.so";'>>build_so.txt
182 @echo 'gSystem->Load(libYODA.str().c_str());'>>build_so.txt
183 @echo 'libYODA.str("");' >>build_so.txt
184 @echo 'libYODA << "${DIRTOP}/${DIRLIB}/libqumy.so";'>>build_so.txt
185 @echo 'gSystem->Load(libYODA.str().c_str());'>>build_so.txt
186 @echo 'libYODA.str("");' >>build_so.txt
187 @echo 'libYODA << "${DIRTOP}/${DIRLIB}/libreadmy_C.so";'>>build_so.txt
188 @echo 'gSystem->Load(libYODA.str().c_str());'>>build_so.txt
189 @echo 'libYODA.str("");' >>build_so.txt
190 @echo 'libYODA << "${DIRTOP}/${DIRLIB}/libqumy_C.so";'>>build_so.txt
191 @echo 'gSystem->Load(libYODA.str().c_str());'>>build_so.txt
192 @echo '.L $(patsubst %_c_${VER}.so,%.c++O,$(@F))' >> build_so.txt
193 @echo '.q' >> build_so.txt
194 @root -l -b &>/dev/null < build_so.txt
195 @mv -f ${DIRMACROS}/$(patsubst %_c_${VER}.so,%_c.so,$(@F)) ${DIRLIB}/$(@F)
196 @rm -f build_so.txt
197
198 ${FULLCXXLIBS}: ${FULLCLIBS} ${FULLFLIBS} ${CXXSRCS}
199 @(${EGREEN} "Creating ROOT sharable lib: "${WHITE} "$@"; ${RESET})
200 @${CXX} ${CXXFLAGS} -Xlinker -soname=$(@F) -shared -o $@ $^ -lg2c -I${DIRTOP}/${DIRINC} -I${INCROOT} ${LIBSROOT} -L${DIRTOP}/${DIRLIB} -lqumy -lreadmy
201 @(${EGREEN} "Creating symlink from : "${WHITE} "$@"; ${RESET})
202 @(${EGREEN} " to : "${WHITE} "${DIRLIB}/`basename $@ _${VER}.so`.so"; ${RESET})
203 @ln -sf `basename $@` ${DIRLIB}/`basename $@ _${VER}.so`.so
204
205 ${FULLHLIBS}: ${FULLCLIBS} ${FULLFLIBS} ${CXXSRCS} ${HSRCS}
206 @(${EGREEN} "Creating ROOT sharable lib: "${WHITE} "$@"; ${RESET})
207 @echo '.include ${DIRTOP}/${DIRINC}' > build_so.txt
208 @echo 'TString *junk=new TString();' >> build_so.txt
209 @echo '*junk=gSystem->GetDynamicPath();' >> build_so.txt
210 @echo '*junk+=":${DIRLIB}";' >> build_so.txt
211 @echo 'gSystem->SetDynamicPath(junk.Data());' >> build_so.txt
212 @echo 'gSystem->cd("'${DIRINC}'");' >> build_so.txt
213 @echo '.L $(patsubst %_h_${VER}.so,%.h++O,$(@F))' >> build_so.txt
214 @echo '.q' >> build_so.txt
215 @root -l -b &>/dev/null < build_so.txt
216 @mv -f ${DIRINC}/$(patsubst %_h_${VER}.so,%_h.so,$(@F)) ${DIRLIB}/$(@F)
217 @rm -f build_so.txt
218
219 ${CXXEXELIBS}: ${CXXEXEOBJS}
220 @(${EGREEN} "Creating exec file: "${WHITE} "$@"; ${RESET})
221 @${CXX} ${CXXFLAGS} -o ${DIRBIN}/$@ $^
222 @rm -f ${DIRSRC}/temp.cc
223
224
225
226 # A small target to check environmental variables
227 %_env:
228 @${test_env}
229
230 .PHONY: install installdoc installlib installmacros installinc installexe installcmacro
231 .PHONY: clean depclean info mkbindir mklibdir testcern testpamenv test
232
233 mkbindir: ${DIRBIN}
234 ${DIRBIN}:
235 @${test_and_mk}
236
237 mklibdir: ${DIRLIB}
238 ${DIRLIB}:
239 @${test_and_mk}
240
241 # Here what has to be deleted in clean target
242 clean: TOBEDEL= ${FOBJS} ${FULLLIBS} ${DIRBIN}/${CXXEXELIBS} ${COBJS} ${CXXEXEOBJS} ${FULLLINKFLIBS} ${FULLLINKCLIBS}
243 clean:
244 @${test_and_rm}
245
246 distclean: clean
247 distclean: TOBEDEL= ${DIRBIN} ${DIRLIB}
248 distclean:
249 @${test_and_rm}
250
251 forceinstall: FORCE=-f
252 forceinstall: install
253
254 upgrade: FORCE=-u
255 upgrade: install
256
257 install: installlib installinc installmacros installcalib installdoc installexe installcmacro
258
259 installlib: LINK=y
260 installlib: TOBEMOVED= $(FULLLIBS:${DIRLIB}%=${PAM_LIB}%)
261 installlib: ORIGIN=${DIRLIB}
262 installlib:
263 @${test_and_cp}
264
265 installcmacro: LINK=y
266 installcmacro: TOBEMOVED= $(FULLMACROCLIBS:${DIRLIB}%=${PAM_LIB}%)
267 installcmacro: ORIGIN=${DIRLIB}
268 installcmacro:
269 @${test_and_cp}
270
271 installinc: TOBEMOVED= $(INCSRCS:${DIRINC}/%=${PAM_INC}/%)
272 installinc: ORIGIN=${DIRINC}
273 installinc:
274 @${test_and_cp}
275
276 installexe: TOBEMOVED= $(EXESRCS:${DIRBIN}/%=${PAM_BIN}/%)
277 installexe: ORIGIN=${DIRBIN}
278 installexe:
279 @${test_and_cp}
280
281 installmacros: TOBEMOVED= $(MACROSSRCS:${DIRMACROS}/%=${PAM_MACROS}/%)
282 installmacros: ORIGIN=${DIRMACROS}
283 installmacros:
284 @${test_and_cp}
285
286 installcalib: TOBEMOVED= $(CALIBFILES:${DIRCALIB}/%=${PAM_CALIB}/%)
287 installcalib: ORIGIN=${DIRCALIB}
288 installcalib:
289 @${test_and_cp}
290
291 installdoc: TOBEMOVED= $(DOCFILES:${DIRDOC}/%=${PAM_DOC}/%)
292 installdoc: ORIGIN=${DIRDOC}
293 installdoc:
294 @${test_and_cp}
295
296 info:
297 @echo " "
298 @${EGREEN} "Infos for package :" ${WHITE} ${PACKAGE}
299 @${EGREEN} " VERSION :" ${WHITE} ${VER}
300 @${EGREEN} " EXECUTABLES :" ${WHITE} ${EXECUTABLES}
301 @${EGREEN} " LIBS :" ${WHITE} ${LIBS}
302 @${EGREEN} " DOCS :" ${WHITE} ${DOCS}
303 @${EGREEN} " SRCS :" ${WHITE} ${SRCS}
304 @${EGREEN} " MACROS :" ${WHITE} ${MACROS}
305 @echo " "
306 @${RESET}
307
308 test: testpamenv testcernlib testmysql
309
310 testpamenv: ${PAM_ENV}
311
312 testcernlib: cernlib root-config
313
314 testmysql: mysql_config
315
316 mysql_config: OPT=--cflags
317 mysql_config:
318 @$(test_cmd)
319
320 cernlib:
321 @${test_cmd}
322
323 root-config: OPT=--cflags
324 root-config:
325 @${test_cmd}
326
327 # Here follows some usefull macros
328 define test_and_cp
329 wd=`pwd`;\
330 for i in ${TOBEMOVED} ; do \
331 wv=$${i##/*/}; \
332 dest=$${i/$${wv}/}; \
333 ${EGREEN} "Testing for :" ${WHITE} "$${i}" ; ${RESET}; \
334 if [ ! "${FORCE}" ] ; then \
335 if [ ! -f $${i} ]; then \
336 ${EGREEN} "Copying : "${WHITE} ${ORIGIN}/$${i##/*/} ;\
337 ${EGREEN} " to: "${WHITE} $${i} ; ${RESET}; \
338 cp ${ORIGIN}/$${i##/*/} $${i}; \
339 else \
340 ${ERED} "File already exist !!!! Please delete it " ${WHITE}; ${RESET}; \
341 fi;\
342 else \
343 if [ "${FORCE}" == "-u" ] ; then \
344 if [ "`basename $${i}`" != "`basename $${i} _${VER}.so`" ]; then \
345 ${EYELLOW} "Removing: "${WHITE} ${PAM_LIB}/`basename $${i} _${VER}.so`_v*r*.so; ${RESET}; \
346 rm -f ${PAM_LIB}/`basename $${i} _${VER}.so`_v*r*.so ; \
347 ${EGREEN} "Copying : "${WHITE} ${ORIGIN}/$${i##/*/} ;\
348 ${EGREEN} " to: "${WHITE} $${i} ; ${RESET}; \
349 cp ${ORIGIN}/$${i##/*/} $${i}; \
350 else \
351 ${EYELLOW} " Forcing copy: "${WHITE} ${ORIGIN}/$${i##/*/} ;\
352 ${EYELLOW} " to: "${WHITE} $${i} ; ${RESET}; \
353 cp -f ${ORIGIN}/$${i##/*/} $${i}; \
354 fi; \
355 else \
356 ${EYELLOW} " Forcing copy: "${WHITE} ${ORIGIN}/$${i##/*/} ;\
357 ${EYELLOW} " to: "${WHITE} $${i} ; ${RESET}; \
358 cp ${FORCE} ${ORIGIN}/$${i##/*/} $${i}; \
359 fi;\
360 fi ;\
361 if [ ! -z ${LINK} ] ; then \
362 ${EGREEN} "Creating symlink from : "${WHITE} $${wv/_${VER}/} ;\
363 ${EGREEN} " to : "${WHITE} $${i##/*/} ; ${RESET}; \
364 cd $${dest}; \
365 ln -sf $${wv} $${wv/_${VER}/}; \
366 cd $${wd}; \
367 fi \
368 done
369 endef
370
371 define test_and_mk
372 ${EGREEN} "Testing for :" ${WHITE} "$@"; ${RESET}
373 test -d "$@" || \
374 (${EGREEN} "Creating : "${WHITE} "$@"; ${RESET}; mkdir -p $@)
375 endef
376
377 define test_env
378 ${EGREEN} "Testing for env:" ${WHITE} $(patsubst %_env,%,$@); ${RESET}
379 printenv $(patsubst %_env,%,$@) 1>/dev/null || \
380 (${ERED} "ERROR, variable : "${WHITE} $(patsubst %_env,%,$@) \
381 ${RED} "not defined !!! Check your env. settings"; \
382 ${RESET}; exit 1)
383 ${EGREEN} " Defined:" ${WHITE} $${$(patsubst %_env,%,$@)}; ${RESET}
384 endef
385
386 define test_cmd
387 ${EGREEN} "Testing for cmd:" ${WHITE} $@ ${OPT}; ${RESET}
388 $@ ${OPT} 1>/dev/null 2>&1 || \
389 (${ERED} "ERROR, command : "${WHITE} $@ ${OPT}\
390 ${RED} "not found !!! Check your installation"; \
391 ${RESET}; exit 1)
392 ${EGREEN} " Present:" ${WHITE} $@ ${OPT}; ${RESET}
393 endef
394
395 define test_and_rm
396 for i in ${TOBEDEL}; do \
397 test -d $${i} || (${ERED} "Removing file :"${WHITE} $${i}; ${RESET}; \
398 rm -f $${i} ); \
399 test ! -d $${i} || (${ERED} "Removing dir :"${WHITE} $${i}; ${RESET}; \
400 rm -rf $${i} ); \
401 done
402 endef

  ViewVC Help
Powered by ViewVC 1.1.23