/[PAMELA software]/DarthVader/NDLevel2/Makefile
ViewVC logotype

Contents of /DarthVader/NDLevel2/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.12 - (show annotations) (download)
Tue Jan 13 13:51:40 2009 UTC (15 years, 11 months ago) by mocchiut
Branch: MAIN
CVS Tags: v6r01, v6r00
Changes since 1.11: +1 -1 lines
Version updated

1 #ND flight analysis software
2 # SOFTWARE VERSION
3 VER= v4r00
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 -O -fPIC -pthread -g ${PAM_BIT}
27 CFLAGS=-Wall -O3 -funroll-loops -fPIC -pthread ${PAM_BIT}
28 # Enviroment:
29 GCCVER=`gcc --version | head -1`
30 UNAMEA=`uname -a`
31 TODAY=`date`
32 # F77
33 F77=g77
34 #F77FLAGS= -Wall -Wno-globals -fvxt -fno-automatic -fbounds-check -g -extend_source -static -fno-backslash ${PAM_BIT}
35 F77FLAGS= -Wall -funroll-loops -Wno-globals -fPIC -fvxt -fno-automatic -fbounds-check -extend_source -static -fno-backslash ${PAM_BIT}
36 # C++
37 CXX=g++
38 #CXXFLAGS=-Wall -O -fPIC -pthread -g ${PAM_BIT}
39 CXXFLAGS=-Wall -O3 -funroll-loops -fPIC -pthread ${PAM_BIT}
40 # ROOTCINT
41 ROOTCINT=rootcint
42 # Here the variables definig the local directories
43 DIRTOP=${shell pwd}
44 DIRLIB=../lib/${ARCH}
45 DIRBIN=../bin/${ARCH}
46 #DIRLIB=lib/${ARCH}
47 #DIRBIN=bin/${ARCH}
48 DIRSRC=src
49 DIRINC=inc
50 DIRDOC=doc
51 DIRMACROS=macros
52 DIRCALIB=calib
53 # Here the PAMELA environmental variables to be checked
54 PAM_ENV= PAM_BIN_env PAM_LIB_env PAM_INC_env PAM_DOC_env PAM_YODA_env
55
56 # Here the local variables used to build the targets
57 # -- F77 - no libraries --
58 FSRCS=
59 FOBJS=$(FSRCS:${DIRSRC}%.for=${DIRLIB}%.o)
60
61 # -- CPP - no libraries --
62 CPPSRCS=
63 CPPOBJS=$(CPPSRCS:${DIRSRC}%.cpp=${DIRLIB}%.o)
64
65 # -- C - no libraries --
66 CSRCS=
67 COBJS=$(CSRCS:${DIRSRC}%.c=${DIRLIB}%.o)
68
69 # -- CPP - ROOT libraries --
70 LIBROOTSRCS=${DIRSRC}/NDLevel2.cpp
71
72 LIBROOTLIBS=$(LIBROOTSRCS:${DIRSRC}/%.cpp=${DIRLIB}/lib%_${VER}.so)
73 LIBROOTCLIBS=libNDLevel2
74 FULLROOTCLIBS=$(LIBROOTCLIBS:%=${DIRLIB}/%_${VER}.so)
75
76 # -- CPP - NON-ROOT libraries --
77 LIBCPPSRCS= ${DIRSRC}/NDCore.cpp \
78 ${DIRSRC}/NDVerl2.cpp
79 LIBCPPLIBS=$(LIBCPPSRCS:${DIRSRC}/%.cpp=${DIRLIB}/lib%_${VER}.so)
80 LIBCPPCLIBS=libNDCore libNDVerl2
81 FULLLIBCPPLIBS=$(LIBCPPCLIBS:%=${DIRLIB}/%_${VER}.so)
82
83 # -- CPP - Executables --
84 CXXEXESRCS=${DIRSRC}/ND_LEVEL2.cpp
85 CXXEXEOBJS=$(CXXEXESRCS:${DIRSRC}%.cpp=${DIRLIB}%.o)
86 CXXEXELIBS:=ND_LEVEL2
87
88 # -- list of tracker objects needed to link
89 TRKOBJS=${PAM_LIB}/libGLTables.so ${DIRLIB}/libRunInfo.so
90
91 # -- directory where to find tracker headers needed to compile
92 SUBDIR=../RunInfo
93 SUBINC=$(shell for dir in `echo ${SUBDIR}`; do echo -I$${dir}/inc; done)
94
95 # List of all libraries we want to install
96 FULLLIBS = ${FULLROOTCLIBS} ${FULLLIBCPPLIBS}
97
98 # Other objects to install
99 EXESRCS=${DIRBIN}/ND_LEVEL2
100
101 INCSRCS=${DIRINC}/NDLevel2.h ${DIRINC}/NDStruct.h
102
103 MACROSSRCS=
104
105 CALIBFILES=
106
107 DOCFILES=
108
109 # Here the Variables used for info target
110 PACKAGE=Neutron Detector analysis flight software
111 EXECUTABLES= ${EXESRCS}
112 LIBS= ${FULLLIBS}
113 DOCS=
114 SRCS=
115 #SRCS= ${FSRCS} ${CRSCS} ${CXXEXESRCS} ${LIBROOTSRCS} ${LIBCPPSRCS}
116 MACROS= ${MACROSSRCS}
117 INCLUDE= ${INCSRCS}
118 #
119 TOBEDEL = junk
120 ROOTINC=$$${shell root-config --incdir}
121 NROOTINC=${shell root-config --incdir}
122 # Let's start
123 #all: test mkbindir mklibdir mkverpath ${FOBJS} ${CPPOBJS} ${LIBROOTLIBS} ${LIBCPPLIBS} ${CXXEXELIBS}
124 all: prepare libs
125 all:
126 @echo -e ${GREEN} ""
127 @(${EGREEN} " Finished, now you can install the package \n (use: make install or make upgrade or make forceinstall) "; ${RESET})
128 @echo -e ${GREEN} ""
129 @${RESET}
130
131 standalone: all exe
132
133 prepare: test mkbindir mklibdir mkverpath
134
135 exe: prepare ${CXXEXELIBS}
136
137 libs: prepare ${LIBROOTLIBS} ${LIBCPPLIBS}
138
139 # Here some general rules to produce objects in our local dir
140 ${DIRLIB}/%.o: ${DIRSRC}/%.cpp
141 @(${EGREEN} "Creating CPP object file: "${WHITE} "`basename $@`"; ${RESET})
142 @${CXX} ${CXXFLAGS} -c -o $@ ${DIRSRC}/`basename ${@} .o`.cpp -I${DIRINC} ${SUBINC} -I${PAM_YODA}/include/yoda/ -I${PAM_INC}/ `root-config --cflags`
143
144 ${DIRLIB}/%.o: ${DIRSRC}/%.c
145 @(${EGREEN} "Creating C object file: "${WHITE} "`basename $@`"; ${RESET})
146 @${CXX} ${CXXFLAGS} -c -o $@ ${DIRSRC}/`basename ${@} .o`.c -I${DIRINC} ${SUBINC} -I${PAM_YODA}/include/yoda/ -I${PAM_INC}/ `root-config --cflags`
147
148 ${DIRLIB}/%.o: ${DIRSRC}/%.for
149 @(${EGREEN} "Creating F77 object file: "${WHITE} "`basename $@`"; ${RESET})
150 @${F77} ${F77FLAGS} -c -o $@ ${DIRSRC}/`basename ${@} .o`.for -I${DIRINC}
151
152 ${LIBROOTLIBS}: ${LIBROOTSRCS}
153 @(${EGREEN} "ROOTCINT - creating file: "${WHITE} "`basename $(@F) _${VER}.so | sed s/lib//`Dict.cpp"; ${RESET})
154 #
155 # Create *Dict.cpp and *Dict.h
156 #
157 @${ROOTCINT} -f ${DIRSRC}/`basename $(@F) _${VER}.so | sed s/lib//`Dict.cpp -c -I${DIRINC} -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
158 #
159 # create .o
160 #
161 @(${EGREEN} "Compiling CPP file: "${WHITE} "`basename $(@F) _${VER}.so | sed s/lib//`.cpp"; ${RESET})
162 @${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};
163 @(${EGREEN} "Compiling CPP file: "${WHITE} "`basename $(@F) _${VER}.so | sed s/lib//`Dict.cpp"; ${RESET})
164 @${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} ${SUBINC} -I${PAM_YODA}/include/yoda/ -I${PAM_INC}/ -I${NROOTINC};
165 #
166 # create .so
167 #
168 @(${EGREEN} "Creating shared library: "${WHITE} "`basename $@`"; ${RESET})
169 @${CXX} ${CXXFLAGS} -Xlinker -soname=$(@F) -shared -o $@ -lg2c -I${DIRTOP}/${DIRINC} -I${DIRTOP} -I${PAM_YODA}/include/yoda/ ${SUBINC} -I${PAM_INC}/ ${DIRTOP}/${DIRLIB}/`basename $(@F) _${VER}.so | sed s/lib//`.o ${DIRTOP}/${DIRLIB}/`basename $(@F) _${VER}.so | sed s/lib//`Dict.o 1>/dev/null
170 @ln -sf ${DIRTOP}/${DIRLIB}/$(@F) ${DIRTOP}/${DIRLIB}/$(patsubst %_${VER}.so,%.so,$(@F))
171
172 ${LIBCPPLIBS}: ${LIBSRCS} ${COBJS} ${FOBJS}
173 #
174 # create .o
175 #
176 @(${EGREEN} "Compiling CPP file: "${WHITE} "`basename $(@F) _${VER}.so | sed s/lib//`.cpp"; ${RESET})
177 @${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};
178 #
179 # create .so
180 #
181 @(${EGREEN} "Creating shared library: "${WHITE} "`basename $@`"; ${RESET})
182 @${CXX} ${CXXFLAGS} -Xlinker -soname=$(@F) -shared -o $@ -lg2c -I${DIRTOP}/${DIRINC} -I${DIRTOP} ${SUBINC} -I${PAM_YODA}/include/yoda/ -I${PAM_INC}/ ${DIRTOP}/${DIRLIB}/`basename $(@F) _${VER}.so | sed s/lib//`.o ${FOBJS} ${COBJS} 1>/dev/null
183 @ln -sf ${DIRTOP}/${DIRLIB}/$(@F) ${DIRTOP}/${DIRLIB}/$(patsubst %_${VER}.so,%.so,$(@F))
184
185
186 ${CXXEXELIBS}: ${CPPOBJS} ${COBJS} ${CXXEXEOBJS}
187 @(${EGREEN} "Creating exec file: "${WHITE} "$@"; ${RESET})
188 @${CXX} ${CXXFLAGS} -o ${DIRBIN}/$@ ${DIRLIB}/$@.o ${FULLROOTCLIBS} ${FULLLIBCPPLIBS} ${TRKOBJS} ${CPPOBJS} ${COBJS} ${FOBJS} ${PAM_YODA}/lib/libyoda.so -lThread `root-config --cflags --glibs` `cernlib mathlib`
189
190 # A small target to check environmental variables
191 %_env:
192 @${test_env}
193
194 .PHONY: install installdoc installlib installmacros installinc installexe installcmacro
195 .PHONY: clean depclean info mkbindir mklibdir testcern testpamenv test
196
197 mkbindir: ${DIRBIN}
198 ${DIRBIN}:
199 @${test_and_mk}
200
201 mklibdir: ${DIRLIB}
202 ${DIRLIB}:
203 @${test_and_mk}
204
205 # Here what has to be deleted in clean target
206 clean: TOBEDEL= ${DIRSRC}/*.o ${DIRSRC}/*Dict.cpp ${DIRSRC}/*Dict.h ${FOBJS} ${FULLLIBS} ${DIRBIN}/${CXXEXELIBS} ${CPPOBJS} ${CXXEXEOBJS} ${FULLLINKCLIBS} ${FULLMACROCLIBS} ${FULLLINKMACROCLIBS} ${DIRSRC}/NDVerl2.cpp
207 clean:
208 @${test_and_rm}
209
210 distclean: clean
211 distclean: TOBEDEL= ${DIRBIN} ${DIRLIB}
212 distclean:
213 @${test_and_rm}
214
215 forceinstall: FORCE=-f
216 forceinstall: install
217
218 forceinstallstandalone: FORCE=-f
219 forceinstallstandalone: installstandalone
220
221 upgrade: FORCE=-u
222 upgrade: install
223
224 upgradestandalone: FORCE=-u
225 upgradestandalone: installstandalone
226
227 install: installlib installinc installmacros installcalib installdoc installcmacro
228
229 installstandalone: install installexe
230
231 installlib: LINK=y
232 installlib: TOBEMOVED= $(FULLLIBS:${DIRLIB}%=${PAM_LIB}%)
233 installlib: ORIGIN=${DIRLIB}
234 installlib:
235 @${test_and_cp}
236
237 installcmacro: LINK=y
238 installcmacro: TOBEMOVED= $(FULLMACROCLIBS:${DIRLIB}%=${PAM_LIB}%)
239 installcmacro: ORIGIN=${DIRLIB}
240 installcmacro:
241 @${test_and_cp}
242
243 installinc: TOBEMOVED= $(INCSRCS:${DIRINC}/%=${PAM_INC}/%)
244 installinc: ORIGIN=${DIRINC}
245 installinc:
246 @${test_and_cp}
247
248 installexe: TOBEMOVED= $(EXESRCS:${DIRBIN}/%=${PAM_BIN}/%)
249 installexe: ORIGIN=${DIRBIN}
250 installexe:
251 @${test_and_cp}
252
253 installmacros: TOBEMOVED= $(MACROSSRCS:${DIRMACROS}/%=${PAM_MACROS}/%)
254 installmacros: ORIGIN=${DIRMACROS}
255 installmacros:
256 @${test_and_cp}
257
258 installcalib: TOBEMOVED= $(CALIBFILES:${DIRCALIB}/%=${PAM_CALIB}/%)
259 installcalib: ORIGIN=${DIRCALIB}
260 installcalib:
261 @${test_and_cp}
262
263 installdoc: TOBEMOVED= $(DOCFILES:${DIRDOC}/%=${PAM_DOC}/%)
264 installdoc: ORIGIN=${DIRDOC}
265 installdoc:
266 @${test_and_cp}
267
268 mkverpath:
269 @echo '#include <TSystem.h>' > ${DIRTOP}/${DIRSRC}/NDVerl2.cpp; echo ' 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
270 @sleep 0.8
271
272
273
274 info:
275 @echo " "
276 @${EGREEN} "Infos for package :" ${WHITE} ${PACKAGE}
277 @${EGREEN} " VERSION :" ${WHITE} ${VER}
278 @${EGREEN} " EXECUTABLES :" ${WHITE} ${EXECUTABLES}
279 @${EGREEN} " LIBS :" ${WHITE} ${LIBS}
280 @${EGREEN} " DOCS :" ${WHITE} ${DOCS}
281 @${EGREEN} " SRCS :" ${WHITE} ${SRCS}
282 @${EGREEN} " MACROS :" ${WHITE} ${MACROS}
283 @${EGREEN} " INCLUDE :" ${WHITE} ${INCLUDE}
284 @echo " "
285 @${RESET}
286
287 test: testpamenv
288
289 testpamenv: ${PAM_ENV}
290
291 root-config: OPT=--cflags
292 root-config:
293 @${test_cmd}
294
295 # Here follows some usefull macros
296 define test_and_cp
297 wd=`pwd`;\
298 for i in ${TOBEMOVED} ; do \
299 wv=$${i##/*/}; \
300 dest=$${i/$${wv}/}; \
301 ${EGREEN} "Testing for :" ${WHITE} "$${i}" ; ${RESET}; \
302 if [ ! "${FORCE}" ] ; then \
303 if [ ! -f $${i} ]; then \
304 ${EGREEN} "Copying : "${WHITE} ${ORIGIN}/$${i##/*/} ;\
305 ${EGREEN} " to: "${WHITE} $${i} ; ${RESET}; \
306 cp ${ORIGIN}/$${i##/*/} $${i}; \
307 else \
308 ${ERED} "File already exist !!!! Please delete it " ${WHITE}; ${RESET}; \
309 fi;\
310 else \
311 if [ "${FORCE}" == "-u" ] ; then \
312 if [ "`basename $${i}`" != "`basename $${i} _${VER}.so`" ]; then \
313 ${EYELLOW} "Removing: "${WHITE} ${PAM_LIB}/`basename $${i} _${VER}.so`_v*r*.so; ${RESET}; \
314 rm -f ${PAM_LIB}/`basename $${i} _${VER}.so`_v*r*.so ; \
315 ${EGREEN} "Copying : "${WHITE} ${ORIGIN}/$${i##/*/} ;\
316 ${EGREEN} " to: "${WHITE} $${i} ; ${RESET}; \
317 cp ${ORIGIN}/$${i##/*/} $${i}; \
318 else \
319 ${EYELLOW} " Forcing copy: "${WHITE} ${ORIGIN}/$${i##/*/} ;\
320 ${EYELLOW} " to: "${WHITE} $${i} ; ${RESET}; \
321 cp -f ${ORIGIN}/$${i##/*/} $${i}; \
322 fi; \
323 else \
324 ${EYELLOW} " Forcing copy: "${WHITE} ${ORIGIN}/$${i##/*/} ;\
325 ${EYELLOW} " to: "${WHITE} $${i} ; ${RESET}; \
326 cp ${FORCE} ${ORIGIN}/$${i##/*/} $${i}; \
327 fi;\
328 fi ;\
329 if [ ! -z ${LINK} ] ; then \
330 ${EGREEN} "Creating symlink from : "${WHITE} $${wv/_${VER}/} ;\
331 ${EGREEN} " to : "${WHITE} $${i##/*/} ; ${RESET}; \
332 cd $${dest}; \
333 ln -sf $${wv} $${wv/_${VER}/}; \
334 cd $${wd}; \
335 fi \
336 done
337 endef
338
339 define test_and_mk
340 ${EGREEN} "Testing for :" ${WHITE} "$@"; ${RESET}
341 test -d "$@" || \
342 (${EGREEN} "Creating : "${WHITE} "$@"; ${RESET}; mkdir -p $@)
343 endef
344
345 define test_env
346 ${EGREEN} "Testing for env:" ${WHITE} $(patsubst %_env,%,$@); ${RESET}
347 printenv $(patsubst %_env,%,$@) 1>/dev/null || \
348 (${ERED} "ERROR, variable : "${WHITE} $(patsubst %_env,%,$@) \
349 ${RED} "not defined !!! Check your env. settings"; \
350 ${RESET}; exit 1)
351 ${EGREEN} " Defined:" ${WHITE} $${$(patsubst %_env,%,$@)}; ${RESET}
352 endef
353
354 define test_cmd
355 ${EGREEN} "Testing for cmd:" ${WHITE} $@ ${OPT}; ${RESET}
356 $@ ${OPT} 1>/dev/null 2>&1 || \
357 (${ERED} "ERROR, command : "${WHITE} $@ ${OPT}\
358 ${RED} "not found !!! Check your installation"; \
359 ${RESET}; exit 1)
360 ${EGREEN} " Present:" ${WHITE} $@ ${OPT}; ${RESET}
361 endef
362
363 define test_and_rm
364 for i in ${TOBEDEL}; do \
365 test -d $${i} || (${ERED} "Removing file :"${WHITE} $${i}; ${RESET}; \
366 rm -f $${i} ); \
367 test ! -d $${i} || (${ERED} "Removing dir :"${WHITE} $${i}; ${RESET}; \
368 rm -rf $${i} ); \
369 done
370 endef

  ViewVC Help
Powered by ViewVC 1.1.23