1 |
#ND flight analysis software |
2 |
# SOFTWARE VERSION |
3 |
VER= v4r02 |
4 |
include ../Make.def |
5 |
# Here the variables definig the local directories |
6 |
DIRTOP=${shell pwd} |
7 |
DIRLIB=../lib/${ARCH} |
8 |
DIRBIN=../bin/${ARCH} |
9 |
#DIRLIB=lib/${ARCH} |
10 |
#DIRBIN=bin/${ARCH} |
11 |
DIRSRC=src |
12 |
DIRINC=inc |
13 |
DIRDOC=doc |
14 |
DIRMACROS=macros |
15 |
DIRCALIB=calib |
16 |
# Here the PAMELA environmental variables to be checked |
17 |
PAM_ENV= PAM_BIN_env PAM_LIB_env PAM_INC_env PAM_DOC_env PAM_YODA_env |
18 |
|
19 |
# Here the local variables used to build the targets |
20 |
# -- F77 - no libraries -- |
21 |
FSRCS= |
22 |
FOBJS=$(FSRCS:${DIRSRC}%.for=${DIRLIB}%.o) |
23 |
|
24 |
# -- CPP - no libraries -- |
25 |
CPPSRCS= |
26 |
CPPOBJS=$(CPPSRCS:${DIRSRC}%.cpp=${DIRLIB}%.o) |
27 |
|
28 |
# -- C - no libraries -- |
29 |
CSRCS= |
30 |
COBJS=$(CSRCS:${DIRSRC}%.c=${DIRLIB}%.o) |
31 |
|
32 |
# -- CPP - ROOT libraries -- |
33 |
LIBROOTSRCS=${DIRSRC}/NDLevel2.cpp |
34 |
|
35 |
LIBROOTLIBS=$(LIBROOTSRCS:${DIRSRC}/%.cpp=${DIRLIB}/lib%_${VER}.so) |
36 |
LIBROOTCLIBS=libNDLevel2 |
37 |
FULLROOTCLIBS=$(LIBROOTCLIBS:%=${DIRLIB}/%_${VER}.so) |
38 |
|
39 |
# -- CPP - NON-ROOT libraries -- |
40 |
LIBCPPSRCS= ${DIRSRC}/NDCore.cpp \ |
41 |
${DIRSRC}/NDVerl2.cpp |
42 |
LIBCPPLIBS=$(LIBCPPSRCS:${DIRSRC}/%.cpp=${DIRLIB}/lib%_${VER}.so) |
43 |
LIBCPPCLIBS=libNDCore libNDVerl2 |
44 |
FULLLIBCPPLIBS=$(LIBCPPCLIBS:%=${DIRLIB}/%_${VER}.so) |
45 |
|
46 |
# -- CPP - Executables -- |
47 |
CXXEXESRCS=${DIRSRC}/ND_LEVEL2.cpp |
48 |
CXXEXEOBJS=$(CXXEXESRCS:${DIRSRC}%.cpp=${DIRLIB}%.o) |
49 |
CXXEXELIBS:=ND_LEVEL2 |
50 |
|
51 |
# -- list of tracker objects needed to link |
52 |
TRKOBJS=${PAM_LIB}/libGLTables.so ${DIRLIB}/libRunInfo.so |
53 |
|
54 |
# -- directory where to find tracker headers needed to compile |
55 |
SUBDIR=../RunInfo |
56 |
SUBINC=$(shell for dir in `echo ${SUBDIR}`; do echo -I$${dir}/inc; done) |
57 |
|
58 |
# List of all libraries we want to install |
59 |
FULLLIBS = ${FULLROOTCLIBS} ${FULLLIBCPPLIBS} |
60 |
|
61 |
# Other objects to install |
62 |
EXESRCS=${DIRBIN}/ND_LEVEL2 |
63 |
|
64 |
INCSRCS=${DIRINC}/NDLevel2.h ${DIRINC}/NDStruct.h |
65 |
|
66 |
MACROSSRCS= |
67 |
|
68 |
CALIBFILES= |
69 |
|
70 |
DOCFILES= |
71 |
|
72 |
# Here the Variables used for info target |
73 |
PACKAGE=Neutron Detector analysis flight software |
74 |
EXECUTABLES= ${EXESRCS} |
75 |
LIBS= ${FULLLIBS} |
76 |
DOCS= |
77 |
SRCS= |
78 |
#SRCS= ${FSRCS} ${CRSCS} ${CXXEXESRCS} ${LIBROOTSRCS} ${LIBCPPSRCS} |
79 |
MACROS= ${MACROSSRCS} |
80 |
INCLUDE= ${INCSRCS} |
81 |
# |
82 |
TOBEDEL = junk |
83 |
ROOTINC=$$${shell root-config --incdir} |
84 |
NROOTINC=${shell root-config --incdir} |
85 |
# Let's start |
86 |
#all: test mkbindir mklibdir mkverpath ${FOBJS} ${CPPOBJS} ${LIBROOTLIBS} ${LIBCPPLIBS} ${CXXEXELIBS} |
87 |
all: prepare libs |
88 |
all: |
89 |
@echo -e ${GREEN} "" |
90 |
@${RESET} |
91 |
|
92 |
standalone: all exe |
93 |
|
94 |
prepare: test mkbindir mklibdir mkverpath |
95 |
|
96 |
exe: prepare ${CXXEXELIBS} |
97 |
|
98 |
libs: prepare ${LIBROOTLIBS} ${LIBCPPLIBS} |
99 |
|
100 |
include ../Make.dect |
101 |
|
102 |
# A small target to check environmental variables |
103 |
%_env: |
104 |
@${test_env} |
105 |
|
106 |
.PHONY: install installdoc installlib installmacros installinc installexe installcmacro |
107 |
.PHONY: clean depclean info mkbindir mklibdir testcern testpamenv test |
108 |
|
109 |
mkbindir: ${DIRBIN} |
110 |
${DIRBIN}: |
111 |
@${test_and_mk} |
112 |
|
113 |
mklibdir: ${DIRLIB} |
114 |
${DIRLIB}: |
115 |
@${test_and_mk} |
116 |
|
117 |
# Here what has to be deleted in clean target |
118 |
clean: TOBEDEL= ${DIRSRC}/*.o ${DIRSRC}/*Dict.cpp ${DIRSRC}/*Dict.h ${FOBJS} ${FULLLIBS} ${DIRBIN}/${CXXEXELIBS} ${CPPOBJS} ${CXXEXEOBJS} ${FULLLINKCLIBS} ${FULLMACROCLIBS} ${FULLLINKMACROCLIBS} ${DIRSRC}/NDVerl2.cpp |
119 |
clean: |
120 |
@${test_and_rm} |
121 |
|
122 |
distclean: clean |
123 |
distclean: TOBEDEL= ${DIRBIN} ${DIRLIB} |
124 |
distclean: |
125 |
@${test_and_rm} |
126 |
|
127 |
forceinstall: FORCE=-f |
128 |
forceinstall: install |
129 |
|
130 |
forceinstallstandalone: FORCE=-f |
131 |
forceinstallstandalone: installstandalone |
132 |
|
133 |
upgrade: FORCE=-u |
134 |
upgrade: install |
135 |
|
136 |
upgradestandalone: FORCE=-u |
137 |
upgradestandalone: installstandalone |
138 |
|
139 |
install: installlib installinc installmacros installcalib installdoc installcmacro |
140 |
|
141 |
installstandalone: install installexe |
142 |
|
143 |
installlib: LINK=y |
144 |
installlib: TOBEMOVED= $(FULLLIBS:${DIRLIB}%=${PAM_LIB}%) |
145 |
installlib: ORIGIN=${DIRLIB} |
146 |
installlib: |
147 |
@${test_and_cp} |
148 |
|
149 |
installcmacro: LINK=y |
150 |
installcmacro: TOBEMOVED= $(FULLMACROCLIBS:${DIRLIB}%=${PAM_LIB}%) |
151 |
installcmacro: ORIGIN=${DIRLIB} |
152 |
installcmacro: |
153 |
@${test_and_cp} |
154 |
|
155 |
installinc: TOBEMOVED= $(INCSRCS:${DIRINC}/%=${PAM_INC}/%) |
156 |
installinc: ORIGIN=${DIRINC} |
157 |
installinc: |
158 |
@${test_and_cp} |
159 |
|
160 |
installexe: TOBEMOVED= $(EXESRCS:${DIRBIN}/%=${PAM_BIN}/%) |
161 |
installexe: ORIGIN=${DIRBIN} |
162 |
installexe: |
163 |
@${test_and_cp} |
164 |
|
165 |
installmacros: TOBEMOVED= $(MACROSSRCS:${DIRMACROS}/%=${PAM_MACROS}/%) |
166 |
installmacros: ORIGIN=${DIRMACROS} |
167 |
installmacros: |
168 |
@${test_and_cp} |
169 |
|
170 |
installcalib: TOBEMOVED= $(CALIBFILES:${DIRCALIB}/%=${PAM_CALIB}/%) |
171 |
installcalib: ORIGIN=${DIRCALIB} |
172 |
installcalib: |
173 |
@${test_and_cp} |
174 |
|
175 |
installdoc: TOBEMOVED= $(DOCFILES:${DIRDOC}/%=${PAM_DOC}/%) |
176 |
installdoc: ORIGIN=${DIRDOC} |
177 |
installdoc: |
178 |
@${test_and_cp} |
179 |
|
180 |
mkverpath: |
181 |
@echo '#include <TSystem.h>' > ${DIRTOP}/${DIRSRC}/NDVerl2.cpp; echo 'const char *NDInfo(bool print){ if ( print ) printf("\nND Level2 flight package version: ${VER}\n\nCompiled on '${TODAY}' with: '${GCCVER}'\n\nOn: '${UNAMEA}'\n\n"); return("${VER}"); }' >> ${DIRTOP}/${DIRSRC}/NDVerl2.cpp |
182 |
@sleep 0.8 |
183 |
|
184 |
|
185 |
|
186 |
info: |
187 |
@echo " " |
188 |
@${EGREEN} "Infos for package :" ${WHITE} ${PACKAGE} |
189 |
@${EGREEN} " VERSION :" ${WHITE} ${VER} |
190 |
@${EGREEN} " EXECUTABLES :" ${WHITE} ${EXECUTABLES} |
191 |
@${EGREEN} " LIBS :" ${WHITE} ${LIBS} |
192 |
@${EGREEN} " DOCS :" ${WHITE} ${DOCS} |
193 |
@${EGREEN} " SRCS :" ${WHITE} ${SRCS} |
194 |
@${EGREEN} " MACROS :" ${WHITE} ${MACROS} |
195 |
@${EGREEN} " INCLUDE :" ${WHITE} ${INCLUDE} |
196 |
@echo " " |
197 |
@${RESET} |
198 |
|
199 |
test: testpamenv |
200 |
|
201 |
testpamenv: ${PAM_ENV} |
202 |
|
203 |
root-config: OPT=--cflags |
204 |
root-config: |
205 |
@${test_cmd} |
206 |
|
207 |
# Here follows some usefull macros |
208 |
define test_and_cp |
209 |
wd=`pwd`;\ |
210 |
for i in ${TOBEMOVED} ; do \ |
211 |
wv=$${i##/*/}; \ |
212 |
dest=$${i/$${wv}/}; \ |
213 |
${EGREEN} "Testing for :" ${WHITE} "$${i}" ; ${RESET}; \ |
214 |
if [ ! "${FORCE}" ] ; then \ |
215 |
if [ ! -f $${i} ]; then \ |
216 |
${EGREEN} "Copying : "${WHITE} ${ORIGIN}/$${i##/*/} ;\ |
217 |
${EGREEN} " to: "${WHITE} $${i} ; ${RESET}; \ |
218 |
cp ${ORIGIN}/$${i##/*/} $${i}; \ |
219 |
else \ |
220 |
${ERED} "File already exist !!!! Please delete it " ${WHITE}; ${RESET}; \ |
221 |
fi;\ |
222 |
else \ |
223 |
if [ "${FORCE}" == "-u" ] ; then \ |
224 |
if [ "`basename $${i}`" != "`basename $${i} _${VER}.so`" ]; then \ |
225 |
${EYELLOW} "Removing: "${WHITE} ${PAM_LIB}/`basename $${i} _${VER}.so`_v*r*.so; ${RESET}; \ |
226 |
rm -f ${PAM_LIB}/`basename $${i} _${VER}.so`_v*r*.so ; \ |
227 |
${EGREEN} "Copying : "${WHITE} ${ORIGIN}/$${i##/*/} ;\ |
228 |
${EGREEN} " to: "${WHITE} $${i} ; ${RESET}; \ |
229 |
cp ${ORIGIN}/$${i##/*/} $${i}; \ |
230 |
else \ |
231 |
${EYELLOW} " Forcing copy: "${WHITE} ${ORIGIN}/$${i##/*/} ;\ |
232 |
${EYELLOW} " to: "${WHITE} $${i} ; ${RESET}; \ |
233 |
cp -f ${ORIGIN}/$${i##/*/} $${i}; \ |
234 |
fi; \ |
235 |
else \ |
236 |
${EYELLOW} " Forcing copy: "${WHITE} ${ORIGIN}/$${i##/*/} ;\ |
237 |
${EYELLOW} " to: "${WHITE} $${i} ; ${RESET}; \ |
238 |
cp ${FORCE} ${ORIGIN}/$${i##/*/} $${i}; \ |
239 |
fi;\ |
240 |
fi ;\ |
241 |
if [ ! -z ${LINK} ] ; then \ |
242 |
${EGREEN} "Creating symlink from : "${WHITE} $${wv/_${VER}/} ;\ |
243 |
${EGREEN} " to : "${WHITE} $${i##/*/} ; ${RESET}; \ |
244 |
cd $${dest}; \ |
245 |
ln -sf $${wv} $${wv/_${VER}/}; \ |
246 |
cd $${wd}; \ |
247 |
fi \ |
248 |
done |
249 |
endef |
250 |
|
251 |
define test_and_mk |
252 |
${EGREEN} "Testing for :" ${WHITE} "$@"; ${RESET} |
253 |
test -d "$@" || \ |
254 |
(${EGREEN} "Creating : "${WHITE} "$@"; ${RESET}; mkdir -p $@) |
255 |
endef |
256 |
|
257 |
define test_env |
258 |
${EGREEN} "Testing for env:" ${WHITE} $(patsubst %_env,%,$@); ${RESET} |
259 |
printenv $(patsubst %_env,%,$@) 1>/dev/null || \ |
260 |
(${ERED} "ERROR, variable : "${WHITE} $(patsubst %_env,%,$@) \ |
261 |
${RED} "not defined !!! Check your env. settings"; \ |
262 |
${RESET}; exit 1) |
263 |
${EGREEN} " Defined:" ${WHITE} $${$(patsubst %_env,%,$@)}; ${RESET} |
264 |
endef |
265 |
|
266 |
define test_cmd |
267 |
${EGREEN} "Testing for cmd:" ${WHITE} $@ ${OPT}; ${RESET} |
268 |
$@ ${OPT} 1>/dev/null 2>&1 || \ |
269 |
(${ERED} "ERROR, command : "${WHITE} $@ ${OPT}\ |
270 |
${RED} "not found !!! Check your installation"; \ |
271 |
${RESET}; exit 1) |
272 |
${EGREEN} " Present:" ${WHITE} $@ ${OPT}; ${RESET} |
273 |
endef |
274 |
|
275 |
define test_and_rm |
276 |
for i in ${TOBEDEL}; do \ |
277 |
test -d $${i} || (${ERED} "Removing file :"${WHITE} $${i}; ${RESET}; \ |
278 |
rm -f $${i} ); \ |
279 |
test ! -d $${i} || (${ERED} "Removing dir :"${WHITE} $${i}; ${RESET}; \ |
280 |
rm -rf $${i} ); \ |
281 |
done |
282 |
endef |