1 |
# |
2 |
# TEMPLATE for flight data processing |
3 |
# |
4 |
# Created F.Cafagna, modified E.Mocchiutti |
5 |
# Modified 23 Jan 2006 - S.Orsi |
6 |
# |
7 |
# SOFTWARE VERSION |
8 |
VER= v2r00 |
9 |
# REQUIRES CALOCOMMON and ROOT2PAW versions |
10 |
COMMONVER=v1r10 |
11 |
# installed calocommon version |
12 |
COMPCOMVER=`echo ${COMMONVER} | tr -d [a-z:A-Z]` |
13 |
INSTCOMVER=`${PAM_BIN}/calocommon |head -2 |tail -1 | tr -d [a-z:A-Z]` |
14 |
# some usefull definition for colorize the echo |
15 |
RED='\E[1;31;40m' |
16 |
GREEN='\E[1;32;40m' |
17 |
YELLOW='\E[1;33;40m' |
18 |
BLUE='\E[1;34;40m' |
19 |
WHITE='\E[1;37;40m' |
20 |
VIOLET='\E[1;35;40m' |
21 |
CYAN='\E[1;36;40m' |
22 |
# Here the echo definition to use them |
23 |
EVIOLET=echo -e ${VIOLET} |
24 |
ECYAN=echo -e ${CYAN} |
25 |
ERED=echo -e ${RED} |
26 |
EGREEN=echo -e ${GREEN} |
27 |
EYELLOW=echo -e ${YELLOW} |
28 |
EBLUE=echo -e ${BLUE} |
29 |
EWHITE=echo -e ${WHITE} |
30 |
# Reset the terminal |
31 |
RESET=tput sgr0 |
32 |
# Here the variables used to override the standard make flags |
33 |
# C |
34 |
CC=gcc |
35 |
CFLAGS= -Wall -O3 -fPIC |
36 |
# Environment: |
37 |
GCCVER=`gcc --version | head -1` |
38 |
UNAMEA=`uname -a` |
39 |
TODAY=`date` |
40 |
# |
41 |
# F77 |
42 |
F77=g77 |
43 |
F77FLAGS= -Wall -Wno-globals -fno-bounds-check -g -extend_source -static -fno-backslash -O -fPIC |
44 |
# C++ |
45 |
CXX=g++ |
46 |
CXXFLAGS= -Wall -O3 -fPIC |
47 |
# Here the variables definig the local directories |
48 |
DIRTOP=${shell pwd} |
49 |
DIRLIB=lib/${ARCH} |
50 |
DIRBIN=bin/${ARCH} |
51 |
DIRSRC=src |
52 |
DIRINC=inc |
53 |
DIRDOC=doc |
54 |
DIRMACROS=macros |
55 |
DIRCALIB=calib |
56 |
# Here the PAMELA environmental variables to be checked |
57 |
PAM_ENV= PAM_BIN_env PAM_LIB_env PAM_INC_env PAM_DOC_env PAM_MACROS_env PAM_CALIB_env PAM_YODA_env |
58 |
# Here the local variables used to build the targets |
59 |
# |
60 |
# here a list of fortran file to compile |
61 |
# |
62 |
FSRCS= |
63 |
|
64 |
FOBJS=$(FSRCS:${DIRSRC}%.for=${DIRBIN}%.o) |
65 |
# here a list of libraries to create (can contain more fortran compiled objects linked together) |
66 |
FLIBS= |
67 |
FULLFLIBS=$(FLIBS:%=${DIRLIB}/lib%_${VER}.so) |
68 |
FULLLINKFLIBS=$(FLIBS:%=${DIRLIB}/lib%.so) |
69 |
|
70 |
# |
71 |
# here the name of the ROOT main macro that must be compiled (noticed that it is the .cra macro with .c extension) |
72 |
# |
73 |
MACROSRCS=${DIRMACROS}/ACEXE.c |
74 |
MACROSLIBS=$(MACROSRCS:${DIRMACROS}/%.c=${DIRLIB}/%_c_${VER}.so) |
75 |
MACROCLIBS=ACEXE_c |
76 |
FULLMACROCLIBS=$(MACROCLIBS:%=${DIRLIB}/%_${VER}.so) |
77 |
FULLLINKMACROCLIBS=$(MACROCLIBS:%=${DIRLIB}/%.so) |
78 |
|
79 |
CSRCS= |
80 |
COBJS=$(CSRCS:${DIRSRC}%.c=${DIRBIN}%.o) |
81 |
CLIBS= |
82 |
FULLCLIBS=$(CLIBS:%=${DIRLIB}/lib%_${VER}.so) |
83 |
FULLLINKCLIBS=$(CLIBS:%=${DIRLIB}/lib%.so) |
84 |
CXXSRCS= |
85 |
|
86 |
FULLCXXLIBS=$(CXXSRCS:${DIRSRC}/%.C=${DIRLIB}/%_C_${VER}.so) |
87 |
|
88 |
HSRCS=${DIRINC}/acl2class.h |
89 |
FULLHLIBS=$(HSRCS:${DIRINC}/%.h=${DIRLIB}/%_h_${VER}.so) |
90 |
# |
91 |
# here the name of the main program |
92 |
# |
93 |
CXXEXESRCS=${DIRSRC}/ACL2.cc |
94 |
CXXEXEOBJS=$(CXXEXESRCS:${DIRSRC}%.cc=${DIRBIN}%.o) |
95 |
CXXEXELIBS:=ACL2 |
96 |
|
97 |
#FULLLIBS=$(sort ${FULLFLIBS} ${FULLCXXLIBS} ) |
98 |
FULLLIBS=${FULLFLIBS} ${FULLCXXLIBS} ${FULLCLIBS} ${FULLHLIBS} |
99 |
|
100 |
EXESRCS= ${DIRBIN}/ACL2 |
101 |
|
102 |
INCSRCS= ${DIRINC}/acl2class.h |
103 |
|
104 |
MACROSSRCS= |
105 |
|
106 |
CALIBFILES= |
107 |
|
108 |
DOCFILES= ${DIRDOC}/ACL2.README |
109 |
# Here the Variables used for info target |
110 |
PACKAGE=AC flight software level 2 |
111 |
EXECUTABLES=ACL2 |
112 |
LIBS= ${FLIBS} ${FOBJS} ${CLIBS} ${COBJS} ${CXXEXEOBJS} |
113 |
DOCS= |
114 |
SRCS= ${FSRCS} ${CRSCS} ${CXXEXESRCS} |
115 |
MACROS= ${MACROSSRCS} |
116 |
# |
117 |
TOBEDEL = junk |
118 |
# Let's start |
119 |
all : test mkbindir mklibdir complete ${FULLHLIBS} ${FULLCLIBS} ${FULLFLIBS} ${FULLCXXLIBS} ${MACROSLIBS} ${CXXEXELIBS} |
120 |
all: |
121 |
@echo -e ${GREEN} "" |
122 |
@(${EGREEN} " Finished, now you can install the package \n (use: make install or make upgrade or make forceinstall) "; ${RESET}) |
123 |
@echo -e ${GREEN} "" |
124 |
@${RESET} |
125 |
|
126 |
# Here some general rules to produce objects in our local dir |
127 |
# .o from fortran |
128 |
${DIRBIN}/%.o : ${DIRSRC}/%.for |
129 |
@(${EGREEN} "Creating object file: "${WHITE} "$@"; ${RESET}) |
130 |
@${F77} ${F77FLAGS} -c -o $@ $< -I${DIRINC} |
131 |
|
132 |
${DIRBIN}/%.o: ${DIRSRC}/%.cc |
133 |
@(${EGREEN} "Creating object file: "${WHITE} "$@"; ${RESET}) |
134 |
@cat ${DIRSRC}/`basename ${@} .o`.cc > ${DIRSRC}/temp.cc; |
135 |
@echo ' ' >> ${DIRSRC}/temp.cc |
136 |
@echo 'void info(){ printf("\nAC version: ${VER}\n\nCompiled on '${TODAY}' with: '${GCCVER}'\n\nOn: '${UNAMEA}'\n\n"); }' >> ${DIRSRC}/temp.cc |
137 |
@${CXX} ${CXXFLAGS} -c -o $@ ${DIRSRC}/temp.cc -I${DIRINC} -I${PAM_INC} -I${PAM_YODA}/include/yoda/ `root-config --cflags` |
138 |
|
139 |
# .o from c |
140 |
${DIRBIN}/%.o : ${DIRSRC}/%.c |
141 |
@(${EGREEN} "Creating object file: "${WHITE} "$@"; ${RESET}) |
142 |
@${CC} ${CFLAGS} -c -o $@ $< -I${DIRINC} |
143 |
|
144 |
|
145 |
# .so from .o fortran |
146 |
${FULLFLIBS}: ${FOBJS} |
147 |
@(${EGREEN} "Creating library: "${WHITE} "$@"; ${RESET}) |
148 |
@${CXX} ${CXXFLAGS} -Xlinker -soname=$(@F) -shared -o $@ $^ -lg2c `cernlib mathlib` |
149 |
@(${EGREEN} "Creating symlink from : "${WHITE} "$@"; ${RESET}) |
150 |
@(${EGREEN} " to : "${WHITE} "${DIRLIB}/`basename $@ _${VER}.so`.so"; ${RESET}) |
151 |
@ln -sf `basename $@` ${DIRLIB}/`basename $@ _${VER}.so`.so |
152 |
|
153 |
# .so from .o c |
154 |
${FULLCLIBS}: ${COBJS} |
155 |
@(${EGREEN} "Creating library: "${WHITE} "$@"; ${RESET}) |
156 |
@${CXX} ${CXXFLAGS} -Xlinker -soname=$(@F) -shared -o $@ $^ -lg2c |
157 |
@(${EGREEN} "Creating symlink from : "${WHITE} "$@"; ${RESET}) |
158 |
@(${EGREEN} " to : "${WHITE} "${DIRLIB}/`basename $@ _${VER}.so`.so"; ${RESET}) |
159 |
@ln -sf `basename $@` ${DIRLIB}/`basename $@ _${VER}.so`.so |
160 |
|
161 |
${FULLCXXLIBS}: ${FULLCLIBS} ${FULLFLIBS} ${CXXSRCS} |
162 |
@(${EGREEN} "Creating ROOT sharable lib: "${WHITE} "$@"; ${RESET}) |
163 |
@echo '.include ${DIRTOP}/${DIRINC}' > build_so.txt |
164 |
@echo 'TString *junk=new TString();' >> build_so.txt |
165 |
@echo '*junk=gSystem->GetDynamicPath();' >> build_so.txt |
166 |
@echo ' // cout << junk->Data() << endl;' >> build_so.txt |
167 |
@echo '*junk+=":${DIRLIB}";' >> build_so.txt |
168 |
@echo 'gSystem->SetDynamicPath(junk.Data());' >> build_so.txt |
169 |
@echo 'gSystem->Load("${DIRLIB}/'`basename $@ _C_${VER}.so`'.so")' >> build_so.txt |
170 |
@echo 'gSystem->cd("'${DIRSRC}'");' >> build_so.txt |
171 |
@echo '.L $(patsubst %_C_${VER}.so,%.C++O,$(@F))' >> build_so.txt |
172 |
@echo '.q' >> build_so.txt |
173 |
@root -l -b 1>/dev/null < build_so.txt |
174 |
@mv -f ${DIRSRC}/$(patsubst %_C_${VER}.so,%_C.so,$(@F)) ${DIRLIB}/$(@F) |
175 |
@rm -f build_so.txt |
176 |
@(${EGREEN} "Creating symlink from : "${WHITE} "$(patsubst %.so,%_C.so,$(@F))"; ${RESET}) |
177 |
@(${EGREEN} " to : "${WHITE} "$(patsubst %_C_${VER}.so,%_C.so,$(@F))"; ${RESET}) |
178 |
@ln -sf ${DIRTOP}/${DIRLIB}/$(@F) ${DIRTOP}/${DIRLIB}/$(patsubst %_C_${VER}.so,%_C.so,$(@F)) |
179 |
|
180 |
${FULLHLIBS}: ${FULLCLIBS} ${FULLFLIBS} ${CXXSRCS} ${HSRCS} |
181 |
@(${EGREEN} "Creating ROOT sharable lib: "${WHITE} "$@"; ${RESET}) |
182 |
@echo '.include ${DIRTOP}/${DIRINC}' > build_so.txt |
183 |
@echo 'TString *junk=new TString();' >> build_so.txt |
184 |
@echo '*junk=gSystem->GetDynamicPath();' >> build_so.txt |
185 |
@echo '*junk+=":${DIRLIB}";' >> build_so.txt |
186 |
@echo 'gSystem->SetDynamicPath(junk.Data());' >> build_so.txt |
187 |
@echo 'gSystem->cd("'${DIRINC}'");' >> build_so.txt |
188 |
@echo '.L $(patsubst %_h_${VER}.so,%.h++O,$(@F))' >> build_so.txt |
189 |
@echo '.q' >> build_so.txt |
190 |
@root -l -b 1>/dev/null < build_so.txt |
191 |
@mv -f ${DIRINC}/$(patsubst %_h_${VER}.so,%_h.so,$(@F)) ${DIRLIB}/$(@F) |
192 |
@(${EGREEN} "Creating symlink from : "${WHITE} "$@"; ${RESET}) |
193 |
@(${EGREEN} " to : "${WHITE} "${DIRLIB}/`basename $@ _${VER}.so`.so"; ${RESET}) |
194 |
@ln -sf `basename $@` ${DIRLIB}/`basename $@ _${VER}.so`.so |
195 |
@rm -f build_so.txt |
196 |
|
197 |
${MACROSLIBS}: ${MACROSRCS} |
198 |
@(${EGREEN} "Compiling macro: "${WHITE} "$@"; ${RESET}) |
199 |
@echo '.include ${DIRTOP}/${DIRINC}' > build_so.txt |
200 |
@echo 'TString *junk=new TString();' >> build_so.txt |
201 |
@echo '*junk=gSystem->GetDynamicPath();' >> build_so.txt |
202 |
@echo '*junk+=":${DIRLIB}";' >> build_so.txt |
203 |
@echo 'gSystem->SetDynamicPath(junk.Data());' >> build_so.txt |
204 |
@echo 'char *lmac = gSystem->ExpandPathName("$$PAM_INC");'>>build_so.txt |
205 |
@echo 'gInterpreter->AddIncludePath(lmac);'>>build_so.txt |
206 |
@echo 'char *pamyoda = gSystem->ExpandPathName("$$PAM_YODA");' >>build_so.txt |
207 |
@echo 'stringstream incy;' >>build_so.txt |
208 |
@echo 'incy.str("");' >>build_so.txt |
209 |
@echo 'incy << pamyoda << "/include/yoda/";' >>build_so.txt |
210 |
@echo 'gInterpreter->AddIncludePath(incy.str().c_str());' >>build_so.txt |
211 |
@echo 'stringstream oss;' >>build_so.txt |
212 |
@echo 'oss << pamyoda << "/techmodel/";' >>build_so.txt |
213 |
@echo 'gInterpreter->AddIncludePath(oss.str().c_str());' >> build_so.txt |
214 |
@echo 'oss.str("");' >> build_so.txt |
215 |
@echo 'oss << pamyoda << "/event/";' >>build_so.txt |
216 |
@echo 'gInterpreter->AddIncludePath(oss.str().c_str());' >> build_so.txt |
217 |
@echo 'oss.str("");' >> build_so.txt |
218 |
@echo 'gSystem->cd("'${DIRMACROS}'");' >> build_so.txt |
219 |
@echo 'char *pamyodalib = gSystem->ExpandPathName("$$PAM_YODA");' >>build_so.txt |
220 |
# |
221 |
# load the YODA library |
222 |
# |
223 |
@echo 'char *libYODA;'>>build_so.txt |
224 |
@echo 'oss << pamyodalib << "/lib/libyoda.so";' >>build_so.txt |
225 |
@echo 'gSystem->Load(oss.str().c_str());'>>build_so.txt |
226 |
@echo 'oss.str("");' >> build_so.txt |
227 |
@echo 'char *pamlib = gSystem->ExpandPathName("$$PAM_LIB");'>>build_so.txt |
228 |
# |
229 |
# here we load libraries just compiled with this package |
230 |
# |
231 |
@echo 'char *pamsrclib;'>>build_so.txt |
232 |
@echo 'pamsrclib = "'${DIRTOP}'/'${DIRLIB}'/";'>>build_so.txt |
233 |
@echo 'oss.str("");' >>build_so.txt |
234 |
@echo 'oss << pamsrclib << "/acl2class_h.so";'>>build_so.txt |
235 |
@echo 'gSystem->Load(oss.str().c_str());'>>build_so.txt |
236 |
@echo 'oss.str("");' >> build_so.txt |
237 |
# |
238 |
# compile the macro |
239 |
# |
240 |
@echo '.L $(patsubst %_c_${VER}.so,%.c++O,$(@F))' >> build_so.txt |
241 |
@echo '.q' >> build_so.txt |
242 |
# |
243 |
# to see output of macro compilation comment the following line... |
244 |
# @root -l -b &>/dev/null < build_so.txt |
245 |
# and uncomment this one: |
246 |
@root -l -b 1>/dev/null < build_so.txt |
247 |
# |
248 |
@mv -f ${DIRMACROS}/$(patsubst %_c_${VER}.so,%_c.so,$(@F)) ${DIRLIB}/$(@F) |
249 |
@rm -f build_so.txt |
250 |
|
251 |
|
252 |
${CXXEXELIBS}: ${CXXEXEOBJS} |
253 |
@(${EGREEN} "Creating exec file: "${WHITE} "$@"; ${RESET}) |
254 |
@${CXX} ${CXXFLAGS} -o ${DIRBIN}/$@ $^ -I${DIRINC} -I${PAM_YODA}/include/yoda ${PAM_YODA}/lib/libyoda.so ${DIRTOP}/${DIRLIB}/ACEXE_c_${VER}.so ${DIRTOP}/${DIRLIB}/acl2class_h_${VER}.so `root-config --cflags --glibs` |
255 |
@rm -f ${DIRSRC}/temp.cc |
256 |
|
257 |
# A small target to check environmental variables |
258 |
%_env: |
259 |
@${test_env} |
260 |
|
261 |
.PHONY: install installdoc installlib installmacros installinc installexe installcmacro |
262 |
.PHONY: clean depclean info mkbindir mklibdir testcern testpamenv test |
263 |
|
264 |
mkbindir: ${DIRBIN} |
265 |
${DIRBIN}: |
266 |
@${test_and_mk} |
267 |
|
268 |
mklibdir: ${DIRLIB} |
269 |
${DIRLIB}: |
270 |
@${test_and_mk} |
271 |
|
272 |
# Here what has to be deleted in clean target |
273 |
clean: TOBEDEL= ${FOBJS} ${FULLLIBS} ${DIRBIN}/${CXXEXELIBS} ${COBJS} ${CXXEXEOBJS} ${FULLLINKFLIBS} ${FULLLINKCLIBS} ${FULLMACROCLIBS} ${FULLLINKMACROCLIBS} |
274 |
clean: |
275 |
@${test_and_rm} |
276 |
|
277 |
distclean: clean |
278 |
distclean: TOBEDEL= ${DIRBIN} ${DIRLIB} |
279 |
distclean: |
280 |
@${test_and_rm} |
281 |
|
282 |
forceinstall: FORCE=-f |
283 |
forceinstall: install |
284 |
|
285 |
upgrade: FORCE=-u |
286 |
upgrade: install |
287 |
|
288 |
install: installlib installinc installmacros installcalib installdoc installexe installcmacro |
289 |
install: |
290 |
@rm -f ${DIRTOP}/${DIRMACROS}/ACEXE.c |
291 |
|
292 |
installlib: LINK=y |
293 |
installlib: TOBEMOVED= $(FULLLIBS:${DIRLIB}%=${PAM_LIB}%) |
294 |
installlib: ORIGIN=${DIRLIB} |
295 |
installlib: |
296 |
@${test_and_cp} |
297 |
|
298 |
installinc: TOBEMOVED= $(INCSRCS:${DIRINC}/%=${PAM_INC}/%) |
299 |
installinc: ORIGIN=${DIRINC} |
300 |
installinc: |
301 |
@${test_and_cp} |
302 |
|
303 |
installexe: TOBEMOVED= $(EXESRCS:${DIRBIN}/%=${PAM_BIN}/%) |
304 |
installexe: ORIGIN=${DIRBIN} |
305 |
installexe: |
306 |
@${test_and_cp} |
307 |
|
308 |
installmacros: TOBEMOVED= $(MACROSSRCS:${DIRMACROS}/%=${PAM_MACROS}/%) |
309 |
installmacros: ORIGIN=${DIRMACROS} |
310 |
installmacros: |
311 |
@${test_and_cp} |
312 |
|
313 |
installcmacro: LINK=y |
314 |
installcmacro: TOBEMOVED= $(FULLMACROCLIBS:${DIRLIB}%=${PAM_LIB}%) |
315 |
installcmacro: ORIGIN=${DIRLIB} |
316 |
installcmacro: |
317 |
@${test_and_cp} |
318 |
|
319 |
installcalib: TOBEMOVED= $(CALIBFILES:${DIRCALIB}/%=${PAM_CALIB}/%) |
320 |
installcalib: ORIGIN=${DIRCALIB} |
321 |
installcalib: |
322 |
@${test_and_cp} |
323 |
|
324 |
installdoc: TOBEMOVED= $(DOCFILES:${DIRDOC}/%=${PAM_DOC}/%) |
325 |
installdoc: ORIGIN=${DIRDOC} |
326 |
installdoc: |
327 |
@${test_and_cp} |
328 |
|
329 |
info: |
330 |
@echo " " |
331 |
@${EGREEN} "Infos for package :" ${WHITE} ${PACKAGE} |
332 |
@${EGREEN} " VERSION :" ${WHITE} ${VER} |
333 |
@${EGREEN} " EXECUTABLES :" ${WHITE} ${EXECUTABLES} |
334 |
@${EGREEN} " LIBS :" ${WHITE} ${LIBS} |
335 |
@${EGREEN} " DOCS :" ${WHITE} ${DOCS} |
336 |
@${EGREEN} " SRCS :" ${WHITE} ${SRCS} |
337 |
@${EGREEN} " MACROS :" ${WHITE} ${MACROS} |
338 |
@echo " " |
339 |
@${RESET} |
340 |
|
341 |
test: testpamenv testcernlib |
342 |
# testcalocommon |
343 |
|
344 |
complete: |
345 |
@if [ "${PAM_CCO}" == "" ]; then cat ${DIRTOP}/${DIRMACROS}/ACEXE.cra > ${DIRTOP}/${DIRMACROS}/ACEXE.c; echo 'const char *pathtocalibration(){ return((const char*)gSystem->Getenv("PAM_CALIB"));}' >> ${DIRTOP}/${DIRMACROS}/ACEXE.c; fi |
346 |
@if [ "${PAM_CCO}" != "" ]; then cat ${DIRTOP}/${DIRMACROS}/ACEXE.cra > ${DIRTOP}/${DIRMACROS}/ACEXE.c; echo 'const char *pathtocalibration(){ return((const char*)"'${PAM_CALIB}'/");}' >> ${DIRTOP}/${DIRMACROS}/ACEXE.c; fi |
347 |
|
348 |
testpamenv: ${PAM_ENV} |
349 |
|
350 |
testcernlib: cernlib root-config |
351 |
|
352 |
#testcalocommon: '${PAM_BIN}'/calocommon |
353 |
# @if [ ${INSTCOMVER} -lt ${COMPCOMVER} ]; then ${ERED} " ERROR: AC ${VER} requires package CALOCOMMON version ${COMMONVER} "; ${RESET} ; exit 1; fi |
354 |
|
355 |
#'${PAM_BIN}'/calocommon: |
356 |
# @$(test_cmd) |
357 |
|
358 |
#'${PAM_LIB}'/libtrack.so: |
359 |
# @$(test_exist) |
360 |
|
361 |
#'${PAM_LIB}'/libreadb2maps.so: |
362 |
# @$(test_exist) |
363 |
|
364 |
cernlib: |
365 |
@${test_cmd} |
366 |
|
367 |
root-config: OPT=--cflags |
368 |
root-config: |
369 |
@${test_cmd} |
370 |
|
371 |
# Here follows some usefull macros |
372 |
define test_and_cp |
373 |
wd=`pwd`;\ |
374 |
for i in ${TOBEMOVED} ; do \ |
375 |
wv=$${i##/*/}; \ |
376 |
dest=$${i/$${wv}/}; \ |
377 |
${EGREEN} "Testing for :" ${WHITE} "$${i}" ; ${RESET}; \ |
378 |
if [ ! "${FORCE}" ] ; then \ |
379 |
if [ ! -f $${i} ]; then \ |
380 |
${EGREEN} "Copying : "${WHITE} ${ORIGIN}/$${i##/*/} ;\ |
381 |
${EGREEN} " to: "${WHITE} $${i} ; ${RESET}; \ |
382 |
cp ${ORIGIN}/$${i##/*/} $${i}; \ |
383 |
else \ |
384 |
${ERED} "File already exist !!!! Please delete it " ${WHITE}; ${RESET}; \ |
385 |
fi;\ |
386 |
else \ |
387 |
if [ "${FORCE}" == "-u" ] ; then \ |
388 |
if [ "`basename $${i}`" != "`basename $${i} _${VER}.so`" ]; then \ |
389 |
${EYELLOW} "Removing: "${WHITE} ${PAM_LIB}/`basename $${i} _${VER}.so`_v*r*.so; ${RESET}; \ |
390 |
rm -f ${PAM_LIB}/`basename $${i} _${VER}.so`_v*r*.so ; \ |
391 |
${EGREEN} "Copying : "${WHITE} ${ORIGIN}/$${i##/*/} ;\ |
392 |
${EGREEN} " to: "${WHITE} $${i} ; ${RESET}; \ |
393 |
cp ${ORIGIN}/$${i##/*/} $${i}; \ |
394 |
else \ |
395 |
${EYELLOW} " Forcing copy: "${WHITE} ${ORIGIN}/$${i##/*/} ;\ |
396 |
${EYELLOW} " to: "${WHITE} $${i} ; ${RESET}; \ |
397 |
cp -f ${ORIGIN}/$${i##/*/} $${i}; \ |
398 |
fi; \ |
399 |
else \ |
400 |
${EYELLOW} " Forcing copy: "${WHITE} ${ORIGIN}/$${i##/*/} ;\ |
401 |
${EYELLOW} " to: "${WHITE} $${i} ; ${RESET}; \ |
402 |
cp ${FORCE} ${ORIGIN}/$${i##/*/} $${i}; \ |
403 |
fi;\ |
404 |
fi ;\ |
405 |
if [ ! -z ${LINK} ] ; then \ |
406 |
${EGREEN} "Creating symlink from : "${WHITE} $${wv/_${VER}/} ;\ |
407 |
${EGREEN} " to : "${WHITE} $${i##/*/} ; ${RESET}; \ |
408 |
cd $${dest}; \ |
409 |
ln -sf $${wv} $${wv/_${VER}/}; \ |
410 |
cd $${wd}; \ |
411 |
fi \ |
412 |
done |
413 |
endef |
414 |
|
415 |
define test_and_mk |
416 |
${EGREEN} "Testing for :" ${WHITE} "$@"; ${RESET} |
417 |
test -d "$@" || \ |
418 |
(${EGREEN} "Creating : "${WHITE} "$@"; ${RESET}; mkdir -p $@) |
419 |
endef |
420 |
|
421 |
define test_env |
422 |
${EGREEN} "Testing for env:" ${WHITE} $(patsubst %_env,%,$@); ${RESET} |
423 |
printenv $(patsubst %_env,%,$@) 1>/dev/null || \ |
424 |
(${ERED} "ERROR, variable : "${WHITE} $(patsubst %_env,%,$@) \ |
425 |
${RED} "not defined !!! Check your env. settings"; \ |
426 |
${RESET}; exit 1) |
427 |
${EGREEN} " Defined:" ${WHITE} $${$(patsubst %_env,%,$@)}; ${RESET} |
428 |
endef |
429 |
|
430 |
define test_cmd |
431 |
${EGREEN} "Testing for cmd:" ${WHITE} $@ ${OPT}; ${RESET} |
432 |
$@ ${OPT} 1>/dev/null 2>&1 || \ |
433 |
(${ERED} "ERROR, command : "${WHITE} $@ ${OPT}\ |
434 |
${RED} "not found !!! Check your installation"; \ |
435 |
${RESET}; exit 1) |
436 |
${EGREEN} " Present:" ${WHITE} $@ ${OPT}; ${RESET} |
437 |
endef |
438 |
|
439 |
define test_exist |
440 |
${EGREEN} "Testing for library:" ${WHITE} $@ ${OPT}; ${RESET} |
441 |
ls $@ 1>/dev/null 2>&1 || \ |
442 |
(${ERED} "ERROR, library : "${WHITE} $@ ${OPT}\ |
443 |
${RED} " Not found !!! Check your installation"; \ |
444 |
${RESET}; exit 1) |
445 |
${EGREEN} " Present:" ${WHITE} $@ ${OPT}; ${RESET} |
446 |
endef |
447 |
|
448 |
define test_and_rm |
449 |
for i in ${TOBEDEL}; do \ |
450 |
test -d $${i} || (${ERED} "Removing file :"${WHITE} $${i}; ${RESET}; \ |
451 |
rm -f $${i} ); \ |
452 |
test ! -d $${i} || (${ERED} "Removing dir :"${WHITE} $${i}; ${RESET}; \ |
453 |
rm -rf $${i} ); \ |
454 |
done |
455 |
endef |