1 |
# Tracker flight analysis software |
2 |
# SOFTWARE VERSION |
3 |
VER= v2r00 |
4 |
DEBUG=0 |
5 |
# An almost general purpouse Makefile for PAMELA repository |
6 |
# Let's start with some usefull definition for colorize the echo |
7 |
RED='\E[1;31;40m' |
8 |
GREEN='\E[1;32;40m' |
9 |
YELLOW='\E[1;33;40m' |
10 |
BLUE='\E[1;34;40m' |
11 |
WHITE='\E[1;37;40m' |
12 |
VIOLET='\E[1;35;40m' |
13 |
CYAN='\E[1;36;40m' |
14 |
# Here the echo definition to use them |
15 |
EVIOLET=echo -e ${VIOLET} |
16 |
ECYAN=echo -e ${CYAN} |
17 |
ERED=echo -e ${RED} |
18 |
EGREEN=echo -e ${GREEN} |
19 |
EYELLOW=echo -e ${YELLOW} |
20 |
EBLUE=echo -e ${BLUE} |
21 |
EWHITE=echo -e ${WHITE} |
22 |
# Reset the terminal |
23 |
RESET=tput sgr0 |
24 |
# Here the variables used to override the standard make flags |
25 |
# C |
26 |
CC=gcc |
27 |
#CFLAGS=-Wall -O -fPIC -pthread -g |
28 |
CFLAGS=-Wall -O -fPIC -pthread |
29 |
# Enviroment: |
30 |
GCCVER=`gcc --version | head -1` |
31 |
UNAMEA=`uname -a` |
32 |
TODAY=`date` |
33 |
# F77 |
34 |
F77=g77 |
35 |
#F77FLAGS= -Wall -Wno-globals -fvxt -fno-automatic -fbounds-check -g -extend_source -static -fno-backslash |
36 |
F77FLAGS= -Wall -Wno-globals -fvxt -fno-automatic -fbounds-check -extend_source -static -fno-backslash |
37 |
# C++ |
38 |
CXX=g++ |
39 |
#CXXFLAGS=-Wall -O -fPIC -pthread -g -D'DEBUG=${DEBUG}' |
40 |
#CXXFLAGS=-Wall -O -fPIC -pthread -g -D'DEBUG=0' |
41 |
#CXXFLAGS=-Wall -O -fPIC -pthread -fpermissive |
42 |
CXXFLAGS=-Wall -O -fPIC -pthread |
43 |
# ROOTCINT |
44 |
ROOTCINT=rootcint |
45 |
# Here the variables definig the local directories |
46 |
DIRTOP=${shell pwd} |
47 |
#DIRLIB=lib/${ARCH}/ |
48 |
#DIRBIN=bin/${ARCH}/ |
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_YODA_env |
58 |
# Here the local variables used to build the targets |
59 |
#------------------------------------------------- |
60 |
FSRCS=${DIRSRC}/F77/fillpedsig.f \ |
61 |
${DIRSRC}/F77/readallparam.f \ |
62 |
${DIRSRC}/F77/functions.f \ |
63 |
${DIRSRC}/F77/cncomp.f \ |
64 |
${DIRSRC}/F77/filladc.f \ |
65 |
${DIRSRC}/F77/reductionflight.f \ |
66 |
${DIRSRC}/F77/functionspfa.f \ |
67 |
${DIRSRC}/F77/mini.f \ |
68 |
${DIRSRC}/F77/tricircle.f \ |
69 |
${DIRSRC}/F77/analysissubroutines.f \ |
70 |
${DIRSRC}/F77/analysisflight.f \ |
71 |
${DIRSRC}/F77/readB.f \ |
72 |
${DIRSRC}/F77/interB.f \ |
73 |
${DIRSRC}/F77/track.f \ |
74 |
${DIRSRC}/F77/grkuta.f |
75 |
|
76 |
FOBJS=$(FSRCS:${DIRSRC}/F77/%.f=${DIRLIB}/%.o) |
77 |
#------------------------------------------------- |
78 |
CSRCS= |
79 |
COBJS=$(CSRCS:${DIRSRC}%.cpp=${DIRLIB}/%.o) |
80 |
#------------------------------------------------- |
81 |
# librerie utilizzabili da root (ci deve essere anche il ***LinkDef.h ) |
82 |
LIBROOTSRCS= ${DIRSRC}/TrkLevel2.cpp \ |
83 |
${DIRSRC}/TrkLevel1.cpp |
84 |
#LIBROOTSRCS= |
85 |
LIBROOTLIBS=$(LIBROOTSRCS:${DIRSRC}/%.cpp=${DIRLIB}/lib%_${VER}.so) |
86 |
LIBROOTOBJS=${DIRLIB}/readB.o ${DIRLIB}/interB.o ${DIRLIB}/track.o ${DIRLIB}/grkuta.o ${DIRLIB}/functionspfa.o ${DIRLIB}/readallparam.o ${DIRLIB}/functions.o ${DIRLIB}/mini.o ${DIRLIB}/tricircle.o |
87 |
LIBROOTCLIBS=libTrkLevel2 libTrkLevel1 |
88 |
#LIBROOTCLIBS= |
89 |
FULLROOTCLIBS=$(LIBROOTCLIBS:%=${DIRLIB}/%_${VER}.so) |
90 |
#------------------------------------------------- |
91 |
# librerie C++ NON utilizzabili da root |
92 |
#LIBCPPSRCS= ${DIRSRC}/TrkLevel2.cpp \ |
93 |
# ${DIRSRC}/TrkLevel0.cpp |
94 |
LIBCPPSRCS=${DIRSRC}/TrkLevel0.cpp \ |
95 |
${DIRSRC}/TrkStruct.cpp \ |
96 |
${DIRSRC}/TrkProcess.cpp \ |
97 |
${DIRSRC}/TrkVerl2.cpp \ |
98 |
${DIRSRC}/TrkCore.cpp |
99 |
LIBCPPLIBS=$(LIBCPPSRCS:${DIRSRC}/%.cpp=${DIRLIB}/lib%_${VER}.so) |
100 |
#LIBCPPCLIBS=libTrkLevel2 libTrkLevel0 |
101 |
LIBCPPCLIBS=libTrkLevel0 libTrkStruct libTrkProcess libTrkCore libTrkVerl2 |
102 |
FULLCPPCLIBS=$(LIBCPPCLIBS:%=${DIRLIB}/%_${VER}.so) |
103 |
#------------------------------------------------- |
104 |
# librerie F77 NON utilizzabili da root |
105 |
LIBF77SRCS= |
106 |
LIBF77OBJS= $(LIBF77SRCS:${DIRSRC}/F77/%.f=${DIRLIB}/%.o) |
107 |
LIBF77LIBS= $(LIBF77SRCS:${DIRSRC}/F77/%.f=${DIRLIB}/lib%_${VER}.so) |
108 |
LIBF77CLIBS= |
109 |
FULLF77CLIBS=$(LIBF77CLIBS:%=${DIRLIB}/%_${VER}.so) |
110 |
#------------------------------------------------- |
111 |
FULLLIBS=${FULLROOTCLIBS} ${FULLCPPCLIBS} ${FULLF77CLIBS} |
112 |
|
113 |
#------------------------------------------------- |
114 |
# eseguibile |
115 |
CXXEXESRCS=${DIRSRC}/TrackerLevel2.cpp |
116 |
CXXEXEOBJS=$(CXXEXESRCS:${DIRSRC}%.cpp=${DIRLIB}%.o) |
117 |
CXXEXELIBS:=TrackerLevel2 |
118 |
|
119 |
OTHERLIBS=${PAM_LIB}/libGLTables.so ${DIRLIB}/libRunInfo.so |
120 |
SUBDIR=../RunInfo |
121 |
SUBINC=$(shell for dir in `echo ${SUBDIR}`; do echo -I$${dir}/inc; done) |
122 |
|
123 |
#------------------------------------------------- |
124 |
# variabili per l'installazione |
125 |
EXESRCS=${DIRBIN}/TrackerLevel2 |
126 |
INCSRCS= \ |
127 |
${DIRINC}/TrkLevel2.h \ |
128 |
${DIRINC}/TrkLevel1.h \ |
129 |
${DIRINC}/TrkLevel0.h \ |
130 |
${DIRINC}/TrkStruct.h \ |
131 |
${DIRINC}/TrkProcess.h \ |
132 |
${DIRINC}/TrkCore.h \ |
133 |
${DIRINC}/TrkVerl2.h |
134 |
MACROSSRCS= |
135 |
CALIBFILES= |
136 |
DOCFILES= |
137 |
# Here the Variables used for info target |
138 |
PACKAGE=Tracker flight software |
139 |
EXECUTABLES=${EXESRCS} |
140 |
LIBS= ${FULLLIBS} ${OTHERLIBS} |
141 |
DOCS= |
142 |
SRCS= |
143 |
MACROS= ${MACROSSRCS} |
144 |
INCLUDE= ${INCSRCS} |
145 |
# |
146 |
TOBEDEL = junk |
147 |
ROOTINC=$$${shell root-config --incdir} |
148 |
NROOTINC=${shell root-config --incdir} |
149 |
# Let's start |
150 |
#all : test mkbindir mklibdir mkverpath ${LIBF77LIBS} ${LIBROOTLIBS} ${LIBCPPLIBS} ${FOBJS} ${COBJS} ${CXXEXELIBS} |
151 |
all : test mkbindir mklibdir mkverpath ${LIBF77LIBS} ${LIBROOTLIBS} ${LIBCPPLIBS} |
152 |
all: |
153 |
@echo -e ${GREEN} "" |
154 |
@(${EGREEN} " Finished, now you can install the package \n (use: make install or make upgrade or make forceinstall) "; ${RESET}) |
155 |
@echo -e ${GREEN} "" |
156 |
@${RESET} |
157 |
|
158 |
standalone: all ${CXXEXELIBS} |
159 |
|
160 |
# Here some general rules to produce objects in our local dir |
161 |
${DIRLIB}/%.o: ${DIRSRC}/%.cpp |
162 |
# @(${EYELLOW} " C++ object ------------------------") |
163 |
@(${EGREEN} "Creating C++ object file: "${WHITE} "$@"; ${RESET}) |
164 |
@${CXX} ${CXXFLAGS} -c -o $@ ${DIRSRC}/`basename ${@} .o`.cpp -I${DIRTOP}/${DIRINC} ${SUBINC} -I${PAM_YODA}/include/yoda/ -I${PAM_INC}/ `root-config --cflags` |
165 |
|
166 |
${DIRLIB}/%.o : ${DIRSRC}/F77/%.f |
167 |
# @(${EYELLOW} " F77 object ------------------------") |
168 |
@(${EGREEN} "Creating F77 object file: "${WHITE} "$@"; ${RESET}) |
169 |
@${F77} ${F77FLAGS} -c -o $@ ${DIRSRC}/F77/`basename ${@} .o`.f -I${DIRTOP}/${DIRINC}/F77 -I${NROOTINC} ${SUBINC} -I${PAM_YODA}/include/yoda -I${PAM_INC}/ |
170 |
|
171 |
# .so from .o fortran |
172 |
${LIBF77LIBS}: ${LIBF77OBJS} |
173 |
@(${EYELLOW} " F77 shared library --------------------------") |
174 |
@(${EGREEN} "Creating library: "${WHITE} "$@"; ${RESET}) |
175 |
# @${CXX} ${CXXFLAGS} -Xlinker -soname=$(@F) -shared -o $@ $^ `cernlib mathlib` /usr/lib/libg2c.so.0 |
176 |
## @${CXX} ${CXXFLAGS} -Xlinker -soname=$(@F) -shared -o $@ -lg2c $^ `cernlib mathlib` |
177 |
@${CXX} ${CXXFLAGS} -Xlinker -soname=$(@F) -shared -o $@ -lg2c $^ |
178 |
|
179 |
${LIBROOTLIBS}: ${LIBROOTSRCS} ${FOBJS} |
180 |
@(${EYELLOW} " ROOT library ------------------------") |
181 |
@(${EGREEN} "Creating file: "${WHITE} "`basename $(@F) _${VER}.so | sed s/lib//`Dict.cpp"; ${RESET}) |
182 |
# |
183 |
# Create *Dict.cpp and *Dict.h |
184 |
# |
185 |
@${ROOTCINT} -f ${DIRSRC}/`basename $(@F) _${VER}.so | sed s/lib//`Dict.cpp -c -I${ROOTINC} -I${PAM_YODA}/include/yoda/ -I${PAM_INC}/ ${DIRINC}/`basename $(@F) _${VER}.so | sed s/lib//`.h ${DIRINC}/`basename $(@F) _${VER}.so | sed s/lib//`LinkDef.h |
186 |
# |
187 |
# create .o |
188 |
# |
189 |
@(${EGREEN} "Compiling file: "${WHITE} "`basename $(@F) _${VER}.so | sed s/lib//`.cpp"; ${RESET}) |
190 |
@${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${PAM_INC}/ -I${NROOTINC}; |
191 |
@(${EGREEN} "Compiling file: "${WHITE} "`basename $(@F) _${VER}.so | sed s/lib//`Dict.cpp"; ${RESET}) |
192 |
@${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} -I${PAM_INC} -I${PAM_YODA}/include/yoda/ -I${NROOTINC}; |
193 |
@ln -sf ${DIRTOP}/${DIRLIB}/$(@F) ${DIRTOP}/${DIRLIB}/$(patsubst %_${VER}.so,%.so,$(@F)) |
194 |
# |
195 |
# create .so |
196 |
# |
197 |
@(${EGREEN} "Compiling shared library: "${WHITE} "$@"; ${RESET}) |
198 |
## @${CXX} ${CXXFLAGS} -Xlinker -soname=$(@F) -shared -o $@ -lg2c -I${DIRTOP}/${DIRINC} -I${DIRTOP} -I${PAM_YODA}/include/yoda -I${PAM_INC} ${DIRTOP}/${DIRLIB}/`basename $(@F) _${VER}.so | sed s/lib//`.o ${DIRTOP}/${DIRLIB}/`basename $(@F) _${VER}.so | sed s/lib//`Dict.o ${LIBROOTOBJS} `cernlib mathlib` 1>/dev/null |
199 |
@${CXX} ${CXXFLAGS} -Xlinker -soname=$(@F) -shared -o $@ -lg2c -I${DIRTOP}/${DIRINC} -I${DIRTOP} -I${PAM_YODA}/include/yoda -I${PAM_INC} ${DIRTOP}/${DIRLIB}/`basename $(@F) _${VER}.so | sed s/lib//`.o ${DIRTOP}/${DIRLIB}/`basename $(@F) _${VER}.so | sed s/lib//`Dict.o ${LIBROOTOBJS} 1>/dev/null |
200 |
# ${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 |
201 |
@ln -sf ${DIRTOP}/${DIRLIB}/$(@F) ${DIRTOP}/${DIRLIB}/$(patsubst %_${VER}.so,%.so,$(@F)) |
202 |
@(${EYELLOW} " -------------------------------------") |
203 |
|
204 |
${LIBCPPLIBS}: ${LIBCPPSRCS} |
205 |
# |
206 |
# create .o |
207 |
# |
208 |
@(${EGREEN} "Compiling file: "${WHITE} "`basename $(@F) _${VER}.so | sed s/lib//`.cpp"; ${RESET}) |
209 |
@${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} ${SUBINC} -I${PAM_YODA}/include/yoda/ -I${PAM_INC}/ -I${NROOTINC}; |
210 |
# |
211 |
# create .so |
212 |
# |
213 |
@(${EGREEN} "Compiling shared library: "${WHITE} "$@"; ${RESET}) |
214 |
@${CXX} ${CXXFLAGS} -Xlinker -soname=$(@F) -shared -o $@ -lg2c -I${DIRTOP}/${DIRINC} ${SUBINC} -I${PAM_YODA}/include/yoda/ -I${PAM_INC}/ ${DIRTOP}/${DIRLIB}/`basename $(@F) _${VER}.so | sed s/lib//`.o ${OTHERLIBS} ${FOBJS} 1>/dev/null |
215 |
@ln -sf ${DIRTOP}/${DIRLIB}/$(@F) ${DIRTOP}/${DIRLIB}/$(patsubst %_${VER}.so,%.so,$(@F)) |
216 |
|
217 |
|
218 |
${CXXEXELIBS}: ${COBJS} ${FOBJS} ${CXXEXEOBJS} |
219 |
@(${EVIOLET} "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *") |
220 |
@(${EGREEN} "Creating exec file: "${WHITE} "$@"; ${RESET}) |
221 |
# @${CXX} ${CXXFLAGS} -o ${DIRBIN}/$@ ${DIRLIB}/$@.o -I${DIRTOP}/${DIRINC} ${SUBINC} -I${PAM_YODA}/include/yoda/ -I${PAM_YODA}/include/utils/ ${PAM_YODA}/lib/libyoda.so ${PAM_YODA}/lib/libutils.so ${FOBJS} ${COBJS} ${FULLLIBS} ${OTHERLIBS} -lThread `root-config --cflags --glibs` `cernlib mathlib` /usr/lib/libg2c.so.0; |
222 |
@${CXX} ${CXXFLAGS} -o ${DIRBIN}/$@ ${DIRLIB}/$@.o -I${DIRTOP}/${DIRINC} ${SUBINC} -I${PAM_YODA}/include/yoda/ -I${PAM_INC}/ ${PAM_YODA}/lib/libyoda.so ${FOBJS} ${COBJS} ${FULLLIBS} ${OTHERLIBS} -lThread -lg2c `root-config --cflags --glibs` `cernlib_noshift mathlib`; |
223 |
|
224 |
|
225 |
# A small target to check environmental variables |
226 |
%_env: |
227 |
@${test_env} |
228 |
|
229 |
.PHONY: install installdoc installlib installmacros installinc installexe installcmacro |
230 |
.PHONY: clean depclean info mkbindir mklibdir testcern testpamenv test |
231 |
|
232 |
mkbindir: ${DIRBIN} |
233 |
${DIRBIN}: |
234 |
@${test_and_mk} |
235 |
|
236 |
mklibdir: ${DIRLIB} |
237 |
${DIRLIB}: |
238 |
@${test_and_mk} |
239 |
|
240 |
# Here what has to be deleted in clean target |
241 |
clean: TOBEDEL= ${DIRSRC}/*.o ${DIRSRC}/*Dict.cpp ${DIRSRC}/*Dict.h ${FOBJS} ${FULLLIBS} ${DIRBIN}/${CXXEXELIBS} ${COBJS} ${CXXEXEOBJS} ${DIRSRC}/TrkVerl2.cpp |
242 |
clean: |
243 |
@${test_and_rm} |
244 |
|
245 |
distclean: clean |
246 |
distclean: TOBEDEL= ${DIRBIN} ${DIRLIB} |
247 |
distclean: |
248 |
@${test_and_rm} |
249 |
|
250 |
forceinstall: FORCE=-f |
251 |
forceinstall: install |
252 |
|
253 |
upgrade: FORCE=-u |
254 |
upgrade: install |
255 |
upgradestandalone: FORCE=-u |
256 |
upgradestandalone: installstandalone |
257 |
|
258 |
install: installlib installinc installmacros installcalib installdoc installcmacro |
259 |
installstandalone: install installexe |
260 |
|
261 |
installlib: LINK=y |
262 |
installlib: TOBEMOVED= $(FULLLIBS:${DIRLIB}%=${PAM_LIB}%) |
263 |
installlib: ORIGIN=${DIRLIB} |
264 |
installlib: |
265 |
@${test_and_cp} |
266 |
|
267 |
installcmacro: LINK=y |
268 |
installcmacro: TOBEMOVED= $(FULLMACROCLIBS:${DIRLIB}%=${PAM_LIB}%) |
269 |
installcmacro: ORIGIN=${DIRLIB} |
270 |
installcmacro: |
271 |
@${test_and_cp} |
272 |
|
273 |
installinc: TOBEMOVED= $(INCSRCS:${DIRINC}/%=${PAM_INC}/%) |
274 |
installinc: ORIGIN=${DIRINC} |
275 |
installinc: |
276 |
@${test_and_cp} |
277 |
|
278 |
installexe: TOBEMOVED= $(EXESRCS:${DIRBIN}/%=${PAM_BIN}/%) |
279 |
installexe: ORIGIN=${DIRBIN} |
280 |
installexe: |
281 |
@${test_and_cp} |
282 |
|
283 |
installmacros: TOBEMOVED= $(MACROSSRCS:${DIRMACROS}/%=${PAM_MACROS}/%) |
284 |
installmacros: ORIGIN=${DIRMACROS} |
285 |
installmacros: |
286 |
@${test_and_cp} |
287 |
|
288 |
installcalib: TOBEMOVED= $(CALIBFILES:${DIRCALIB}/%=${PAM_CALIB}/%) |
289 |
installcalib: ORIGIN=${DIRCALIB} |
290 |
installcalib: |
291 |
@${test_and_cp} |
292 |
|
293 |
installdoc: TOBEMOVED= $(DOCFILES:${DIRDOC}/%=${PAM_DOC}/%) |
294 |
installdoc: ORIGIN=${DIRDOC} |
295 |
installdoc: |
296 |
@${test_and_cp} |
297 |
|
298 |
mkverpath: |
299 |
# @echo '#include <TSystem.h>' > ${DIRTOP}/${DIRSRC}/TrkVerl2.cpp; echo ' void info(){ printf("\nTracker Level2 flight package version: ${VER}\n\nCompiled on '${TODAY}' with: '${GCCVER}'\n\nOn: '${UNAMEA}'\n\n"); }' >> ${DIRTOP}/${DIRSRC}/TrkVerl2.cpp |
300 |
@echo '#include <TSystem.h>' > ${DIRTOP}/${DIRSRC}/TrkVerl2.cpp; echo ' char *TrkInfo(bool print){ if ( print ) printf("\nTracker Level2 flight package version: ${VER}\n\nCompiled on '${TODAY}' with: '${GCCVER}'\n\nOn: '${UNAMEA}'\n\n"); return("${VER}"); }' >> ${DIRTOP}/${DIRSRC}/TrkVerl2.cpp |
301 |
@sleep 0.8 |
302 |
|
303 |
|
304 |
|
305 |
info: |
306 |
@echo " " |
307 |
@${EGREEN} "Infos for package :" ${WHITE} ${PACKAGE} |
308 |
@${EGREEN} " VERSION :" ${WHITE} ${VER} |
309 |
@${EGREEN} " EXECUTABLES :" ${WHITE} ${EXECUTABLES} |
310 |
@${EGREEN} " INCLUDES :" ${WHITE} ${INCLUDE} |
311 |
@${EGREEN} " LIBS :" ${WHITE} ${LIBS} |
312 |
@${EGREEN} " DOCS :" ${WHITE} ${DOCS} |
313 |
@${EGREEN} " SRCS :" ${WHITE} ${SRCS} |
314 |
@${EGREEN} " MACROS :" ${WHITE} ${MACROS} |
315 |
@echo " " |
316 |
@${RESET} |
317 |
|
318 |
test: testpamenv |
319 |
|
320 |
testpamenv: ${PAM_ENV} |
321 |
|
322 |
root-config: OPT=--cflags |
323 |
root-config: |
324 |
@${test_cmd} |
325 |
|
326 |
# Here follows some usefull macros |
327 |
define test_and_cp |
328 |
wd=`pwd`;\ |
329 |
for i in ${TOBEMOVED} ; do \ |
330 |
wv=$${i##/*/}; \ |
331 |
dest=$${i/$${wv}/}; \ |
332 |
${EGREEN} "Testing for :" ${WHITE} "$${i}" ; ${RESET}; \ |
333 |
if [ ! "${FORCE}" ] ; then \ |
334 |
if [ ! -f $${i} ]; then \ |
335 |
${EGREEN} "Copying : "${WHITE} ${ORIGIN}/$${i##/*/} ;\ |
336 |
${EGREEN} " to: "${WHITE} $${i} ; ${RESET}; \ |
337 |
cp ${ORIGIN}/$${i##/*/} $${i}; \ |
338 |
else \ |
339 |
${ERED} "File already exist !!!! Please delete it " ${WHITE}; ${RESET}; \ |
340 |
fi;\ |
341 |
else \ |
342 |
if [ "${FORCE}" == "-u" ] ; then \ |
343 |
if [ "`basename $${i}`" != "`basename $${i} _${VER}.so`" ]; then \ |
344 |
${EYELLOW} "Removing: "${WHITE} ${PAM_LIB}/`basename $${i} _${VER}.so`_v*r*.so; ${RESET}; \ |
345 |
rm -f ${PAM_LIB}/`basename $${i} _${VER}.so`_v*r*.so ; \ |
346 |
${EGREEN} "Copying : "${WHITE} ${ORIGIN}/$${i##/*/} ;\ |
347 |
${EGREEN} " to: "${WHITE} $${i} ; ${RESET}; \ |
348 |
cp ${ORIGIN}/$${i##/*/} $${i}; \ |
349 |
else \ |
350 |
${EYELLOW} " Forcing copy: "${WHITE} ${ORIGIN}/$${i##/*/} ;\ |
351 |
${EYELLOW} " to: "${WHITE} $${i} ; ${RESET}; \ |
352 |
cp -f ${ORIGIN}/$${i##/*/} $${i}; \ |
353 |
fi; \ |
354 |
else \ |
355 |
${EYELLOW} " Forcing copy: "${WHITE} ${ORIGIN}/$${i##/*/} ;\ |
356 |
${EYELLOW} " to: "${WHITE} $${i} ; ${RESET}; \ |
357 |
cp ${FORCE} ${ORIGIN}/$${i##/*/} $${i}; \ |
358 |
fi;\ |
359 |
fi ;\ |
360 |
if [ ! -z ${LINK} ] ; then \ |
361 |
${EGREEN} "Creating symlink from : "${WHITE} $${wv/_${VER}/} ;\ |
362 |
${EGREEN} " to : "${WHITE} $${i##/*/} ; ${RESET}; \ |
363 |
cd $${dest}; \ |
364 |
ln -sf $${wv} $${wv/_${VER}/}; \ |
365 |
cd $${wd}; \ |
366 |
fi \ |
367 |
done |
368 |
endef |
369 |
|
370 |
define test_and_mk |
371 |
${EGREEN} "Testing for :" ${WHITE} "$@"; ${RESET} |
372 |
test -d "$@" || \ |
373 |
(${EGREEN} "Creating : "${WHITE} "$@"; ${RESET}; mkdir -p $@) |
374 |
endef |
375 |
|
376 |
define test_env |
377 |
${EGREEN} "Testing for env:" ${WHITE} $(patsubst %_env,%,$@); ${RESET} |
378 |
printenv $(patsubst %_env,%,$@) 1>/dev/null || \ |
379 |
(${ERED} "ERROR, variable : "${WHITE} $(patsubst %_env,%,$@) \ |
380 |
${RED} "not defined !!! Check your env. settings"; \ |
381 |
${RESET}; exit 1) |
382 |
${EGREEN} " Defined:" ${WHITE} $${$(patsubst %_env,%,$@)}; ${RESET} |
383 |
endef |
384 |
|
385 |
define test_cmd |
386 |
${EGREEN} "Testing for cmd:" ${WHITE} $@ ${OPT}; ${RESET} |
387 |
$@ ${OPT} 1>/dev/null 2>&1 || \ |
388 |
(${ERED} "ERROR, command : "${WHITE} $@ ${OPT}\ |
389 |
${RED} "not found !!! Check your installation"; \ |
390 |
${RESET}; exit 1) |
391 |
${EGREEN} " Present:" ${WHITE} $@ ${OPT}; ${RESET} |
392 |
endef |
393 |
|
394 |
define test_and_rm |
395 |
for i in ${TOBEDEL}; do \ |
396 |
test -d $${i} || (${ERED} "Removing file :"${WHITE} $${i}; ${RESET}; \ |
397 |
rm -f $${i} ); \ |
398 |
test ! -d $${i} || (${ERED} "Removing dir :"${WHITE} $${i}; ${RESET}; \ |
399 |
rm -rf $${i} ); \ |
400 |
done |
401 |
endef |