/[PAMELA software]/calo/flight/FQLOOK/Makefile
ViewVC logotype

Contents of /calo/flight/FQLOOK/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (show annotations) (download)
Mon Mar 13 14:49:30 2006 UTC (18 years, 9 months ago) by mocchiut
Branch: MAIN
CVS Tags: v1r02
Changes since 1.2: +1 -1 lines
Bug: include files from YODA from the wrong directory, fixed.

1 # Flight quick look - FQLOOK
2 # SOFTWARE VERSION
3 VER= v1r02
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
27 # Enviroment:
28 GCCVER=`gcc --version | head -1`
29 UNAMEA=`uname -a`
30 TODAY=`date`
31 # F77
32 F77=g77
33 F77FLAGS= -Wall -Wno-globals -fvxt -fno-automatic -fbounds-check -g -extend_source -static -fno-backslash
34 # C++
35 CXX=g++
36 CXXFLAGS=-Wall
37 # ROOTCINT
38 ROOTCINT=rootcint
39 # Here the variables definig the local directories
40 DIRTOP=${shell pwd}
41 DIRLIB=lib/${ARCH}
42 DIRBIN=bin/${ARCH}
43 DIRSRC=src
44 DIRINC=inc
45 DIRDOC=doc
46 DIRMACROS=macros
47 DIRCALIB=calib
48 # Here the PAMELA environmental variables to be checked
49 PAM_ENV= PAM_BIN_env PAM_LIB_env PAM_INC_env PAM_DOC_env PAM_MACROS_env PAM_CALIB_env PAM_YODA_env
50 # Here the local variables used to build the targets
51
52 MACROSRCS=${DIRMACROS}/FCaloQLOOK.cxx \
53 ${DIRMACROS}/FCaloCHKCALIB.cxx
54 MACROSLIBS=$(MACROSRCS:${DIRMACROS}/%.cxx=${DIRLIB}/%_cxx_${VER}.so)
55 MACROCLIBS=FCaloQLOOK_cxx FCaloCHKCALIB_cxx
56 FULLMACROCLIBS=$(MACROCLIBS:%=${DIRLIB}/%_${VER}.so)
57 FULLLINKMACROCLIBS=$(MACROCLIBS:%=${DIRLIB}/%.so)
58
59 CXXEXESRCS=${DIRSRC}/FCaloQLOOK.cc ${DIRSRC}/FCaloCHKCALIB.cc
60 CXXEXEOBJS=$(CXXEXESRCS:${DIRSRC}%.cc=${DIRBIN}%.o)
61 CXXEXELIBS:=FCaloQLOOK FCaloCHKCALIB
62
63 EXESRCS= ${DIRBIN}/FCaloQLOOK ${DIRBIN}/FCaloCHKCALIB
64
65 INCSRCS=
66
67 MACROSSRCS=${DIRMACROS}/FCaloQLOOK.C ${DIRMACROS}/FCaloCHKCALIB.C
68
69 CALIBFILES=
70
71 DOCFILES=${DIRDOC}/fcaloQLOOK.README.pdf ${DIRDOC}/FQL-calo-doc.pdf
72
73 # Here the Variables used for info target
74 PACKAGE=Calorimeter flight quick look software
75 EXECUTABLES=
76 LIBS= ${FLIBS} ${FOBJS} ${CLIBS} ${COBJS} ${CXXEXEOBJS}
77 DOCS=
78 SRCS= ${FSRCS} ${CRSCS} ${CXXEXESRCS}
79 MACROS= ${MACROSSRCS}
80 #
81 TOBEDEL = junk
82 ROOTINC=$$${shell root-config --incdir}
83 # Let's start
84 all : test mkbindir mklibdir ${MACROSLIBS} ${CXXEXELIBS}
85 all:
86 @echo -e ${GREEN} ""
87 @(${EGREEN} " Finished, now you can install the package \n (use: make install or make upgrade or make forceinstall) "; ${RESET})
88 @echo -e ${GREEN} ""
89 @${RESET}
90
91 # Here some general rules to produce objects in our local dir
92 ${DIRBIN}/%.o: ${DIRSRC}/%.cc
93 @(${EGREEN} "Creating object file: "${WHITE} "$@"; ${RESET})
94 @cat ${DIRSRC}/`basename ${@} .o`.cc > ${DIRSRC}/temp.cc;
95 @echo ' ' >> ${DIRSRC}/temp.cc
96 @echo 'void info(){ printf("\nQLOOK flight package version: ${VER}\n\nCompiled on '${TODAY}' with: '${GCCVER}'\n\nOn: '${UNAMEA}'\n\n"); }' >> ${DIRSRC}/temp.cc
97 @${CXX} ${CXXFLAGS} -c -o $@ ${DIRSRC}/temp.cc -I${DIRINC} -I${PAM_INC} -I${PAM_YODA}/include/yoda/ `root-config --cflags`
98
99 ${MACROSLIBS}: ${MACROSRCS}
100 @(${EGREEN} "Compiling macro: "${WHITE} "$@"; ${RESET})
101 @${ROOTCINT} -f ${DIRMACROS}/`basename $(@F) _cxx_${VER}.so`link.cxx -c -I${ROOTINC} ${DIRINC}/`basename $(@F) _cxx_${VER}.so`fun.h ${DIRINC}/`basename $(@F) _cxx_${VER}.so`LinkDef.h
102 @${CXX} ${CXXFLAGS} -Xlinker -soname=$(@F) -shared -o $@ ${DIRMACROS}/`basename $(@F) _cxx_${VER}.so`.cxx ${DIRMACROS}/`basename $(@F) _cxx_${VER}.so`link.cxx -lg2c -I${PAM_INC} -I${DIRTOP}/${DIRINC} -I${DIRTOP} -I${PAM_YODA}/include/yoda/ ${PAM_YODA}/lib/libyoda.so `root-config --cflags --glibs` 1>/dev/null
103
104 ${CXXEXELIBS}: ${CXXEXEOBJS}
105 @(${EGREEN} "Creating exec file: "${WHITE} "$@"; ${RESET})
106 @${CXX} ${CXXFLAGS} -o ${DIRBIN}/$@ ${DIRBIN}/$@.o -I${DIRINC} -I${PAM_INC} -I${PAM_YODA}/include/yoda/ ${PAM_YODA}/lib/libyoda.so ${DIRTOP}/${DIRLIB}/$@_cxx_${VER}.so `root-config --cflags --glibs`;
107 @rm -f ${DIRSRC}/temp.cc
108
109 # A small target to check environmental variables
110 %_env:
111 @${test_env}
112
113 .PHONY: install installdoc installlib installmacros installinc installexe installcmacro
114 .PHONY: clean depclean info mkbindir mklibdir testcern testpamenv test
115
116 mkbindir: ${DIRBIN}
117 ${DIRBIN}:
118 @${test_and_mk}
119
120 mklibdir: ${DIRLIB}
121 ${DIRLIB}:
122 @${test_and_mk}
123
124 # Here what has to be deleted in clean target
125 clean: TOBEDEL= ${DIRMACROS}/*link.cxx ${DIRMACROS}/*link.h ${FOBJS} ${FULLLIBS} ${DIRBIN}/${CXXEXELIBS} ${COBJS} ${CXXEXEOBJS} ${FULLLINKFLIBS} ${FULLLINKCLIBS} ${FULLMACROCLIBS} ${FULLLINKMACROCLIBS}
126 clean:
127 @${test_and_rm}
128
129 distclean: clean
130 distclean: TOBEDEL= ${DIRBIN} ${DIRLIB}
131 distclean:
132 @${test_and_rm}
133
134 forceinstall: FORCE=-f
135 forceinstall: install
136
137 upgrade: FORCE=-u
138 upgrade: install
139
140 install: installlib installinc installmacros installcalib installdoc installexe installcmacro
141
142 installlib: LINK=y
143 installlib: TOBEMOVED= $(FULLLIBS:${DIRLIB}%=${PAM_LIB}%)
144 installlib: ORIGIN=${DIRLIB}
145 installlib:
146 @${test_and_cp}
147
148 installcmacro: LINK=y
149 installcmacro: TOBEMOVED= $(FULLMACROCLIBS:${DIRLIB}%=${PAM_LIB}%)
150 installcmacro: ORIGIN=${DIRLIB}
151 installcmacro:
152 @${test_and_cp}
153
154 installinc: TOBEMOVED= $(INCSRCS:${DIRINC}/%=${PAM_INC}/%)
155 installinc: ORIGIN=${DIRINC}
156 installinc:
157 @${test_and_cp}
158
159 installexe: TOBEMOVED= $(EXESRCS:${DIRBIN}/%=${PAM_BIN}/%)
160 installexe: ORIGIN=${DIRBIN}
161 installexe:
162 @${test_and_cp}
163
164 installmacros: TOBEMOVED= $(MACROSSRCS:${DIRMACROS}/%=${PAM_MACROS}/%)
165 installmacros: ORIGIN=${DIRMACROS}
166 installmacros:
167 @${test_and_cp}
168
169 installcalib: TOBEMOVED= $(CALIBFILES:${DIRCALIB}/%=${PAM_CALIB}/%)
170 installcalib: ORIGIN=${DIRCALIB}
171 installcalib:
172 @${test_and_cp}
173
174 installdoc: TOBEMOVED= $(DOCFILES:${DIRDOC}/%=${PAM_DOC}/%)
175 installdoc: ORIGIN=${DIRDOC}
176 installdoc:
177 @${test_and_cp}
178
179 info:
180 @echo " "
181 @${EGREEN} "Infos for package :" ${WHITE} ${PACKAGE}
182 @${EGREEN} " VERSION :" ${WHITE} ${VER}
183 @${EGREEN} " EXECUTABLES :" ${WHITE} ${EXECUTABLES}
184 @${EGREEN} " LIBS :" ${WHITE} ${LIBS}
185 @${EGREEN} " DOCS :" ${WHITE} ${DOCS}
186 @${EGREEN} " SRCS :" ${WHITE} ${SRCS}
187 @${EGREEN} " MACROS :" ${WHITE} ${MACROS}
188 @echo " "
189 @${RESET}
190
191 test: testpamenv
192
193 testpamenv: ${PAM_ENV}
194
195 root-config: OPT=--cflags
196 root-config:
197 @${test_cmd}
198
199 # Here follows some usefull macros
200 define test_and_cp
201 wd=`pwd`;\
202 for i in ${TOBEMOVED} ; do \
203 wv=$${i##/*/}; \
204 dest=$${i/$${wv}/}; \
205 ${EGREEN} "Testing for :" ${WHITE} "$${i}" ; ${RESET}; \
206 if [ ! "${FORCE}" ] ; then \
207 if [ ! -f $${i} ]; then \
208 ${EGREEN} "Copying : "${WHITE} ${ORIGIN}/$${i##/*/} ;\
209 ${EGREEN} " to: "${WHITE} $${i} ; ${RESET}; \
210 cp ${ORIGIN}/$${i##/*/} $${i}; \
211 else \
212 ${ERED} "File already exist !!!! Please delete it " ${WHITE}; ${RESET}; \
213 fi;\
214 else \
215 if [ "${FORCE}" == "-u" ] ; then \
216 if [ "`basename $${i}`" != "`basename $${i} _${VER}.so`" ]; then \
217 ${EYELLOW} "Removing: "${WHITE} ${PAM_LIB}/`basename $${i} _${VER}.so`_v*r*.so; ${RESET}; \
218 rm -f ${PAM_LIB}/`basename $${i} _${VER}.so`_v*r*.so ; \
219 ${EGREEN} "Copying : "${WHITE} ${ORIGIN}/$${i##/*/} ;\
220 ${EGREEN} " to: "${WHITE} $${i} ; ${RESET}; \
221 cp ${ORIGIN}/$${i##/*/} $${i}; \
222 else \
223 ${EYELLOW} " Forcing copy: "${WHITE} ${ORIGIN}/$${i##/*/} ;\
224 ${EYELLOW} " to: "${WHITE} $${i} ; ${RESET}; \
225 cp -f ${ORIGIN}/$${i##/*/} $${i}; \
226 fi; \
227 else \
228 ${EYELLOW} " Forcing copy: "${WHITE} ${ORIGIN}/$${i##/*/} ;\
229 ${EYELLOW} " to: "${WHITE} $${i} ; ${RESET}; \
230 cp ${FORCE} ${ORIGIN}/$${i##/*/} $${i}; \
231 fi;\
232 fi ;\
233 if [ ! -z ${LINK} ] ; then \
234 ${EGREEN} "Creating symlink from : "${WHITE} $${wv/_${VER}/} ;\
235 ${EGREEN} " to : "${WHITE} $${i##/*/} ; ${RESET}; \
236 cd $${dest}; \
237 ln -sf $${wv} $${wv/_${VER}/}; \
238 cd $${wd}; \
239 fi \
240 done
241 endef
242
243 define test_and_mk
244 ${EGREEN} "Testing for :" ${WHITE} "$@"; ${RESET}
245 test -d "$@" || \
246 (${EGREEN} "Creating : "${WHITE} "$@"; ${RESET}; mkdir -p $@)
247 endef
248
249 define test_env
250 ${EGREEN} "Testing for env:" ${WHITE} $(patsubst %_env,%,$@); ${RESET}
251 printenv $(patsubst %_env,%,$@) 1>/dev/null || \
252 (${ERED} "ERROR, variable : "${WHITE} $(patsubst %_env,%,$@) \
253 ${RED} "not defined !!! Check your env. settings"; \
254 ${RESET}; exit 1)
255 ${EGREEN} " Defined:" ${WHITE} $${$(patsubst %_env,%,$@)}; ${RESET}
256 endef
257
258 define test_cmd
259 ${EGREEN} "Testing for cmd:" ${WHITE} $@ ${OPT}; ${RESET}
260 $@ ${OPT} 1>/dev/null 2>&1 || \
261 (${ERED} "ERROR, command : "${WHITE} $@ ${OPT}\
262 ${RED} "not found !!! Check your installation"; \
263 ${RESET}; exit 1)
264 ${EGREEN} " Present:" ${WHITE} $@ ${OPT}; ${RESET}
265 endef
266
267 define test_and_rm
268 for i in ${TOBEDEL}; do \
269 test -d $${i} || (${ERED} "Removing file :"${WHITE} $${i}; ${RESET}; \
270 rm -f $${i} ); \
271 test ! -d $${i} || (${ERED} "Removing dir :"${WHITE} $${i}; ${RESET}; \
272 rm -rf $${i} ); \
273 done
274 endef

  ViewVC Help
Powered by ViewVC 1.1.23