/[PAMELA software]/c3po/Makefile
ViewVC logotype

Contents of /c3po/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download)
Fri Jul 21 11:32:02 2006 UTC (18 years, 4 months ago) by pam-fi
Branch point for: C3PO, MAIN
Initial revision

1 # Converter Flight Data software
2 # SOFTWARE VERSION
3 VER= v1r00
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
48 DIRBIN=bin
49 DIRSRC=src
50 DIRINC=inc
51 DIRDOC=doc
52 DIRMACROS=macros
53 DIRF77=F77
54 # Here the PAMELA environmental variables to be checked
55 PAM_ENV= PAM_BIN_env PAM_LIB_env PAM_INC_env PAM_DOC_env PAM_YODA_env
56 # Here the local variables used to build the targets
57 #-------------------------------------------------
58 FSRCS=${DIRF77}/rzfile.f \
59 ${DIRF77}/ntuples_functions.f
60 FOBJS=$(FSRCS:${DIRF77}/%.f=${DIRLIB}/%.o)
61 #-------------------------------------------------
62 CSRCS=
63 COBJS=$(CSRCS:${DIRSRC}%.cpp=${DIRLIB}/%.o)
64 #-------------------------------------------------
65 # librerie utilizzabili da root (ci deve essere anche il ***LinkDef.h )
66 LIBROOTSRCS=
67 LIBROOTLIBS=$(LIBROOTSRCS:${DIRSRC}/%.cpp=${DIRLIB}/lib%_${VER}.so)
68 LIBROOTOBJS=
69 LIBROOTCLIBS=
70 FULLROOTCLIBS=$(LIBROOTCLIBS:%=${DIRLIB}/%_${VER}.so)
71 #-------------------------------------------------
72 # librerie C++ NON utilizzabili da root
73 LIBCPPSRCS=
74 LIBCPPLIBS=$(LIBCPPSRCS:${DIRSRC}/%.cpp=${DIRLIB}/lib%_${VER}.so)
75 LIBCPPCLIBS=
76 FULLCPPCLIBS=$(LIBCPPCLIBS:%=${DIRLIB}/%_${VER}.so)
77 #-------------------------------------------------
78 # librerie F77 NON utilizzabili da root
79 LIBF77SRCS=
80 LIBF77OBJS= $(LIBF77SRCS:${DIRSRC}/F77/%.f=${DIRLIB}/%.o)
81 LIBF77LIBS= $(LIBF77SRCS:${DIRSRC}/F77/%.f=${DIRLIB}/lib%_${VER}.so)
82 LIBF77CLIBS=
83 FULLF77CLIBS=$(LIBF77CLIBS:%=${DIRLIB}/%_${VER}.so)
84 #-------------------------------------------------
85 FULLLIBS=${FULLROOTCLIBS} ${FULLCPPCLIBS} ${FULLF77CLIBS}
86
87 #-------------------------------------------------
88 # eseguibile
89 CXXEXESRCS=${DIRSRC}/C3PO.cpp
90 CXXEXEOBJS=$(CXXEXESRCS:${DIRSRC}%.cpp=${DIRLIB}%.o)
91 CXXEXELIBS:=C3PO
92 #-------------------------------------------------
93 # variabili per l'installazione
94 EXESRCS=${DIRBIN}/C3PO
95 INCSRCS=
96 MACROSSRCS=
97 CALIBFILES=
98 DOCFILES=
99 # Here the Variables used for info target
100 PACKAGE=Flight Data Convereter software
101 EXECUTABLES=${EXESRCS}
102 LIBS= ${FULLLIBS} ${OTHERLIBS}
103 DOCS=
104 SRCS=
105 MACROS= ${MACROSSRCS}
106 INCLUDE= ${INCSRCS}
107 #
108 TOBEDEL = junk
109 ROOTINC=$$${shell root-config --incdir}
110 NROOTINC=${shell root-config --incdir}
111 # Let's start
112 ##all : test mkbindir mklibdir mkverpath ${LIBF77LIBS} ${LIBROOTLIBS} ${LIBCPPLIBS} ${FOBJS} ${COBJS} ${CXXEXELIBS}
113 #all : test mkbindir mklibdir mkverpath ${LIBF77LIBS} ${LIBROOTLIBS} ${LIBCPPLIBS}
114 all : test mkbindir mklibdir ${LIBF77LIBS} ${LIBROOTLIBS} ${LIBCPPLIBS} ${CXXEXELIBS}
115 all:
116 @echo -e ${GREEN} ""
117 @(${EGREEN} " Finished, now you can install the package \n (use: make install or make upgrade or make forceinstall) "; ${RESET})
118 @echo -e ${GREEN} ""
119 @${RESET}
120
121 # Here some general rules to produce objects in our local dir
122 ${DIRLIB}/%.o: ${DIRSRC}/%.cpp
123 # @(${EYELLOW} " C++ object ------------------------")
124 @(${EGREEN} "Creating C++ object file: "${WHITE} "$@"; ${RESET})
125 @${CXX} ${CXXFLAGS} -c -o $@ ${DIRSRC}/`basename ${@} .o`.cpp -I${PAM_INC} -I${PAM_YODA}/include/yoda/ -I${DIRTOP}/${DIRINC} -I${PAM_YODA}/include/utils/ `root-config --cflags`
126
127 ${DIRLIB}/%.o : ${DIRF77}/%.f
128 # @(${EYELLOW} " F77 object ------------------------")
129 @(${EGREEN} "Creating F77 object file: "${WHITE} "$@"; ${RESET})
130 @${F77} ${F77FLAGS} -c -o $@ ${DIRF77}/`basename ${@} .o`.f -I${DIRTOP}/${DIRF77}/common -I${NROOTINC}
131
132 # .so from .o fortran
133 ${LIBF77LIBS}: ${LIBF77OBJS}
134 @(${EYELLOW} " F77 shared library --------------------------")
135 @(${EGREEN} "Creating library: "${WHITE} "$@"; ${RESET})
136 @${CXX} ${CXXFLAGS} -Xlinker -soname=$(@F) -shared -o $@ -lg2c $^ `cernlib mathlib`
137
138 ${LIBROOTLIBS}: ${LIBROOTSRCS} ${FOBJS}
139 @(${EYELLOW} " ROOT library ------------------------")
140 @(${EGREEN} "Creating file: "${WHITE} "`basename $(@F) _${VER}.so | sed s/lib//`Dict.cpp"; ${RESET})
141 #
142 # Create *Dict.cpp and *Dict.h
143 #
144 @${ROOTCINT} -f ${DIRSRC}/`basename $(@F) _${VER}.so | sed s/lib//`Dict.cpp -c -I${ROOTINC} -I${PAM_INC} -I${PAM_YODA}/include/yoda/ -I${PAM_YODA}/include/utils/ ${DIRINC}/`basename $(@F) _${VER}.so | sed s/lib//`.h ${DIRINC}/`basename $(@F) _${VER}.so | sed s/lib//`LinkDef.h
145 #
146 # create .o
147 #
148 @(${EGREEN} "Compiling file: "${WHITE} "`basename $(@F) _${VER}.so | sed s/lib//`.cpp"; ${RESET})
149 @${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} -I${PAM_INC} -I${PAM_YODA}/include/yoda/ -I${PAM_YODA}/include/utils/ -I${NROOTINC};
150 @(${EGREEN} "Compiling file: "${WHITE} "`basename $(@F) _${VER}.so | sed s/lib//`Dict.cpp"; ${RESET})
151 @${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${PAM_YODA}/include/utils/ -I${NROOTINC};
152 @ln -sf ${DIRTOP}/${DIRLIB}/$(@F) ${DIRTOP}/${DIRLIB}/$(patsubst %_${VER}.so,%.so,$(@F))
153 #
154 # create .so
155 #
156 @(${EGREEN} "Compiling shared library: "${WHITE} "$@"; ${RESET})
157 @${CXX} ${CXXFLAGS} -Xlinker -soname=$(@F) -shared -o $@ -lg2c -I${DIRTOP}/${DIRINC} -I${DIRTOP} -I${PAM_YODA}/include/yoda -I${PAM_YODA}/include/utils/ -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
158 @ln -sf ${DIRTOP}/${DIRLIB}/$(@F) ${DIRTOP}/${DIRLIB}/$(patsubst %_${VER}.so,%.so,$(@F))
159 @(${EYELLOW} " -------------------------------------")
160
161 ${LIBCPPLIBS}: ${LIBCPPSRCS}
162 #
163 # create .o
164 #
165 @(${EGREEN} "Compiling file: "${WHITE} "`basename $(@F) _${VER}.so | sed s/lib//`.cpp"; ${RESET})
166 @${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${PAM_INC} -I${PAM_YODA}/include/yoda/ -I${PAM_YODA}/include/utils/ -I${NROOTINC};
167 #
168 # create .so
169 #
170 @(${EGREEN} "Compiling shared library: "${WHITE} "$@"; ${RESET})
171 @${CXX} ${CXXFLAGS} -Xlinker -soname=$(@F) -shared -o $@ -lg2c -I${DIRTOP}/${DIRINC} -I${PAM_INC} -I${PAM_YODA}/include/yoda/ -I${PAM_YODA}/include/utils/ ${DIRTOP}/${DIRLIB}/`basename $(@F) _${VER}.so | sed s/lib//`.o ${OTHERLIBS} 1>/dev/null
172 @ln -sf ${DIRTOP}/${DIRLIB}/$(@F) ${DIRTOP}/${DIRLIB}/$(patsubst %_${VER}.so,%.so,$(@F))
173
174
175 ${CXXEXELIBS}: ${COBJS} ${FOBJS} ${CXXEXEOBJS}
176 @(${EVIOLET} "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *")
177 @(${EGREEN} "Creating exec file: "${WHITE} "$@"; ${RESET})
178 @${CXX} ${CXXFLAGS} -o ${DIRBIN}/$@ ${DIRLIB}/$@.o -I${DIRTOP}/${DIRINC} -I${PAM_INC} -I${PAM_YODA}/include/yoda/ -I${PAM_YODA}/include/utils/ ${PAM_YODA}/lib/libyoda.so ${PAM_YODA}/lib/libutils.so ${PAM_YODA}/lib/lib*Level2.so ${PAM_YODA}/lib/lib*Info.so ${PAM_YODA}/lib/libGLTables.so ${FOBJS} ${COBJS} ${FULLLIBS} ${OTHERLIBS} -lThread -lg2c `root-config --cflags --glibs` `cernlib mathlib`;
179
180
181 # A small target to check environmental variables
182 %_env:
183 @${test_env}
184
185 .PHONY: install installdoc installlib installmacros installinc installexe installcmacro
186 .PHONY: clean depclean info mkbindir mklibdir testcern testpamenv test
187
188 mkbindir: ${DIRBIN}
189 ${DIRBIN}:
190 @${test_and_mk}
191
192 mklibdir: ${DIRLIB}
193 ${DIRLIB}:
194 @${test_and_mk}
195
196 # Here what has to be deleted in clean target
197 clean: TOBEDEL= ${DIRSRC}/*.o ${DIRSRC}/*Dict.cpp ${DIRSRC}/*Dict.h ${FOBJS} ${FULLLIBS} ${DIRBIN}/${CXXEXELIBS} ${COBJS} ${CXXEXEOBJS}
198 clean:
199 @${test_and_rm}
200
201 distclean: clean
202 distclean: TOBEDEL= ${DIRBIN} ${DIRLIB}
203 distclean:
204 @${test_and_rm}
205
206 forceinstall: FORCE=-f
207 forceinstall: install
208
209 upgrade: FORCE=-u
210 upgrade: install
211
212 install: installlib installinc installmacros installcalib installdoc installcmacro installexe
213
214 installlib: LINK=y
215 installlib: TOBEMOVED= $(FULLLIBS:${DIRLIB}%=${PAM_LIB}%)
216 installlib: ORIGIN=${DIRLIB}
217 installlib:
218 @${test_and_cp}
219
220 installcmacro: LINK=y
221 installcmacro: TOBEMOVED= $(FULLMACROCLIBS:${DIRLIB}%=${PAM_LIB}%)
222 installcmacro: ORIGIN=${DIRLIB}
223 installcmacro:
224 @${test_and_cp}
225
226 installinc: TOBEMOVED= $(INCSRCS:${DIRINC}/%=${PAM_INC}/%)
227 installinc: ORIGIN=${DIRINC}
228 installinc:
229 @${test_and_cp}
230
231 installexe: TOBEMOVED= $(EXESRCS:${DIRBIN}/%=${PAM_BIN}/%)
232 installexe: ORIGIN=${DIRBIN}
233 installexe:
234 @${test_and_cp}
235
236 installmacros: TOBEMOVED= $(MACROSSRCS:${DIRMACROS}/%=${PAM_MACROS}/%)
237 installmacros: ORIGIN=${DIRMACROS}
238 installmacros:
239 @${test_and_cp}
240
241 installcalib: TOBEMOVED= $(CALIBFILES:${DIRCALIB}/%=${PAM_CALIB}/%)
242 installcalib: ORIGIN=${DIRCALIB}
243 installcalib:
244 @${test_and_cp}
245
246 installdoc: TOBEMOVED= $(DOCFILES:${DIRDOC}/%=${PAM_DOC}/%)
247 installdoc: ORIGIN=${DIRDOC}
248 installdoc:
249 @${test_and_cp}
250
251 mkverpath:
252 # @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
253 # @sleep 0.8
254
255
256
257 info:
258 @echo " "
259 @${EGREEN} "Infos for package :" ${WHITE} ${PACKAGE}
260 @${EGREEN} " VERSION :" ${WHITE} ${VER}
261 @${EGREEN} " EXECUTABLES :" ${WHITE} ${EXECUTABLES}
262 @${EGREEN} " INCLUDES :" ${WHITE} ${INCLUDE}
263 @${EGREEN} " LIBS :" ${WHITE} ${LIBS}
264 @${EGREEN} " DOCS :" ${WHITE} ${DOCS}
265 @${EGREEN} " SRCS :" ${WHITE} ${SRCS}
266 @${EGREEN} " MACROS :" ${WHITE} ${MACROS}
267 @echo " "
268 @${RESET}
269
270 test: testpamenv
271
272 testpamenv: ${PAM_ENV}
273
274 root-config: OPT=--cflags
275 root-config:
276 @${test_cmd}
277
278 # Here follows some usefull macros
279 define test_and_cp
280 wd=`pwd`;\
281 for i in ${TOBEMOVED} ; do \
282 wv=$${i##/*/}; \
283 dest=$${i/$${wv}/}; \
284 ${EGREEN} "Testing for :" ${WHITE} "$${i}" ; ${RESET}; \
285 if [ ! "${FORCE}" ] ; then \
286 if [ ! -f $${i} ]; then \
287 ${EGREEN} "Copying : "${WHITE} ${ORIGIN}/$${i##/*/} ;\
288 ${EGREEN} " to: "${WHITE} $${i} ; ${RESET}; \
289 cp ${ORIGIN}/$${i##/*/} $${i}; \
290 else \
291 ${ERED} "File already exist !!!! Please delete it " ${WHITE}; ${RESET}; \
292 fi;\
293 else \
294 if [ "${FORCE}" == "-u" ] ; then \
295 if [ "`basename $${i}`" != "`basename $${i} _${VER}.so`" ]; then \
296 ${EYELLOW} "Removing: "${WHITE} ${PAM_LIB}/`basename $${i} _${VER}.so`_v*r*.so; ${RESET}; \
297 rm -f ${PAM_LIB}/`basename $${i} _${VER}.so`_v*r*.so ; \
298 ${EGREEN} "Copying : "${WHITE} ${ORIGIN}/$${i##/*/} ;\
299 ${EGREEN} " to: "${WHITE} $${i} ; ${RESET}; \
300 cp ${ORIGIN}/$${i##/*/} $${i}; \
301 else \
302 ${EYELLOW} " Forcing copy: "${WHITE} ${ORIGIN}/$${i##/*/} ;\
303 ${EYELLOW} " to: "${WHITE} $${i} ; ${RESET}; \
304 cp -f ${ORIGIN}/$${i##/*/} $${i}; \
305 fi; \
306 else \
307 ${EYELLOW} " Forcing copy: "${WHITE} ${ORIGIN}/$${i##/*/} ;\
308 ${EYELLOW} " to: "${WHITE} $${i} ; ${RESET}; \
309 cp ${FORCE} ${ORIGIN}/$${i##/*/} $${i}; \
310 fi;\
311 fi ;\
312 if [ ! -z ${LINK} ] ; then \
313 ${EGREEN} "Creating symlink from : "${WHITE} $${wv/_${VER}/} ;\
314 ${EGREEN} " to : "${WHITE} $${i##/*/} ; ${RESET}; \
315 cd $${dest}; \
316 ln -sf $${wv} $${wv/_${VER}/}; \
317 cd $${wd}; \
318 fi \
319 done
320 endef
321
322 define test_and_mk
323 ${EGREEN} "Testing for :" ${WHITE} "$@"; ${RESET}
324 test -d "$@" || \
325 (${EGREEN} "Creating : "${WHITE} "$@"; ${RESET}; mkdir -p $@)
326 endef
327
328 define test_env
329 ${EGREEN} "Testing for env:" ${WHITE} $(patsubst %_env,%,$@); ${RESET}
330 printenv $(patsubst %_env,%,$@) 1>/dev/null || \
331 (${ERED} "ERROR, variable : "${WHITE} $(patsubst %_env,%,$@) \
332 ${RED} "not defined !!! Check your env. settings"; \
333 ${RESET}; exit 1)
334 ${EGREEN} " Defined:" ${WHITE} $${$(patsubst %_env,%,$@)}; ${RESET}
335 endef
336
337 define test_cmd
338 ${EGREEN} "Testing for cmd:" ${WHITE} $@ ${OPT}; ${RESET}
339 $@ ${OPT} 1>/dev/null 2>&1 || \
340 (${ERED} "ERROR, command : "${WHITE} $@ ${OPT}\
341 ${RED} "not found !!! Check your installation"; \
342 ${RESET}; exit 1)
343 ${EGREEN} " Present:" ${WHITE} $@ ${OPT}; ${RESET}
344 endef
345
346 define test_and_rm
347 for i in ${TOBEDEL}; do \
348 test -d $${i} || (${ERED} "Removing file :"${WHITE} $${i}; ${RESET}; \
349 rm -f $${i} ); \
350 test ! -d $${i} || (${ERED} "Removing dir :"${WHITE} $${i}; ${RESET}; \
351 rm -rf $${i} ); \
352 done
353 endef

  ViewVC Help
Powered by ViewVC 1.1.23