/[PAMELA software]/rawreader/Makefile
ViewVC logotype

Contents of /rawreader/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download)
Fri Sep 1 10:55:56 2006 UTC (18 years, 3 months ago) by cafagna
Branch: MAIN
CVS Tags: v1r11
First release in the PAMELA environment, some cleanup in the include
files, module function and Makefile added

1 #
2 # RawReader makefile
3 #
4 # SOFTWARE VERSION
5 VER= v0r00
6 # An almost general purpouse Makefile for PAMELA repository
7 # Let's start with some usefull definition for colorize the echo
8 RED='\E[1;31;40m'
9 GREEN='\E[1;32;40m'
10 YELLOW='\E[1;33;40m'
11 BLUE='\E[1;34;40m'
12 WHITE='\E[1;37;40m'
13 VIOLET='\E[1;35;40m'
14 CYAN='\E[1;36;40m'
15 # Here the echo definition to use them
16 EVIOLET=echo -e ${VIOLET}
17 ECYAN=echo -e ${CYAN}
18 ERED=echo -e ${RED}
19 EGREEN=echo -e ${GREEN}
20 EYELLOW=echo -e ${YELLOW}
21 EBLUE=echo -e ${BLUE}
22 EWHITE=echo -e ${WHITE}
23 # Reset the terminal
24 RESET=tput sgr0
25 # Here the variables used to override the standard make flags
26 # C
27 CC=gcc
28 CFLAGS+= -Wall -O3 -fPIC
29 # F77
30 F77=g77
31 F77FLAGS= -Wall -Wno-globals -fno-bounds-check -g -extend_source -static -fno-backslash -O -fPIC
32 # C++
33 CXX=g++
34 CXXFLAGS+= -Wall -O3
35 # Linker
36 LD=g++
37 LDFLAGS+=
38 # Here the variables definig the local directories
39 DIRTOP=${shell pwd}
40 DIRLIB=lib/${ARCH}
41 DIRBIN=bin/${ARCH}
42 DIRSRC=src
43 DIRINC=inc
44 DIRDOC=doc
45 # Here the PAMELA environmental variables to be checked
46 PAM_ENV= PAM_BIN_env PAM_LIB_env PAM_INC_env PAM_DOC_env PAM_MACROS_env PAM_CALIB_env PAM_YODA_env
47 # Here the local variables used to build the targets
48
49 # Fortran sources if any
50 FSRCS=
51 FOBJS=$(FSRCS:${DIRSRC}%.for=${DIRBIN}%.o)
52 FLIBS=
53 FULLFLIBS=$(FLIBS:%=${DIRLIB}/lib%_${VER}.so)
54 FULLLINKFLIBS=$(FLIBS:%=${DIRLIB}/lib%.so)
55
56 # C sources if any
57 CSRCS=
58 COBJS=$(CSRCS:${DIRSRC}%.c=${DIRBIN}%.o)
59 CLIBS=
60 FULLCLIBS=$(CLIBS:%=${DIRLIB}/lib%_${VER}.so)
61 FULLLINKCLIBS=$(CLIBS:%=${DIRLIB}/lib%.so)
62
63 # C++ sources if any
64 CXXSRCS=$(patsubst %,${DIRSRC}/%, \
65 CRC16.cpp \
66 Crc.cpp \
67 CrcHeader.cpp \
68 FindRoute.cpp \
69 Main.cpp \
70 Read.cpp \
71 RunHeaderReader.cpp \
72 Trunc.cpp \
73 Verify.cpp \
74 filename.cpp \
75 sort.cpp )
76 CXXOBJS=$(CXXSRCS:${DIRSRC}/%.cpp=${DIRBIN}/%.o)
77 CXXLIBS=`root-config --libs` -lMySQL
78 CXXFLAGS+= `root-config --cflags` -I${DIRINC}
79 #
80 CALIBFILES=
81 DOCFILES=
82 # Here the Variables used for info target
83 PACKAGE=RawReader
84 EXECUTABLES=RawReader.exe
85 OBJS=${FOBJS} ${COBJS} ${CXXOBJS}
86 LIBS=${FLIBS} ${CLIBS} ${CXXLIBS}
87 DOCS=
88 SRCS=${FSRCS} ${CRSCS} ${CXXSRCS}
89 #
90 TOBEDEL = ${OBJS} ${EXECUTABLES}
91 # Let's start
92 # all: test mkbindir mklibdir ${EXECUTABLES}
93 all: mkbindir mklibdir ${EXECUTABLES}
94 @echo -e ${GREEN} ""
95 @(${EGREEN} " Finished, now you can install the package \n (use: make install or make upgrade or make forceinstall) "; ${RESET})
96 @echo -e ${GREEN} ""
97 @${RESET}
98
99 ${EXECUTABLES}: ${OBJS}
100 @(${EGREEN} "Creating executables: "${WHITE} "$@"; ${RESET})
101 @${LD} ${LDFLAGS} -o $@ $^ ${LIBS}
102
103 # Here some general rules to produce objects in our local dir
104 # .o from fortran
105 ${DIRBIN}/%.o : ${DIRSRC}/%.for
106 @(${EGREEN} "Creating object file: "${WHITE} "$@"; ${RESET})
107 @${F77} ${F77FLAGS} -c -o $@ $< -I${DIRINC}
108
109 ${DIRBIN}/%.o: ${DIRSRC}/%.cpp
110 @(${EGREEN} "Creating object file: "${WHITE} "$@"; ${RESET})
111 @${CXX} ${CXXFLAGS} -c -o $@ $< -I${DIRINC}
112
113 # .o from C
114 ${DIRBIN}/%.o : ${DIRSRC}/%.c
115 @(${EGREEN} "Creating object file: "${WHITE} "$@"; ${RESET})
116 @${CC} ${CFLAGS} -c -o $@ $< -I${DIRINC}
117
118
119 # .so from .o fortran
120 ${FULLFLIBS}: ${FOBJS}
121 @(${EGREEN} "Creating library: "${WHITE} "$@"; ${RESET})
122 @${CXX} ${CXXFLAGS} -Xlinker -soname=$(@F) -shared -o $@ $^ -lg2c `cernlib mathlib`
123 @(${EGREEN} "Creating symlink from : "${WHITE} "$@"; ${RESET})
124 @(${EGREEN} " to : "${WHITE} "${DIRLIB}/`basename $@ _${VER}.so`.so"; ${RESET})
125 @ln -sf `basename $@` ${DIRLIB}/`basename $@ _${VER}.so`.so
126
127 # .so from .o c
128 ${FULLCLIBS}: ${COBJS}
129 @(${EGREEN} "Creating library: "${WHITE} "$@"; ${RESET})
130 @${CXX} ${CXXFLAGS} -Xlinker -soname=$(@F) -shared -o $@ $^ -lg2c
131 @(${EGREEN} "Creating symlink from : "${WHITE} "$@"; ${RESET})
132 @(${EGREEN} " to : "${WHITE} "${DIRLIB}/`basename $@ _${VER}.so`.so"; ${RESET})
133 @ln -sf `basename $@` ${DIRLIB}/`basename $@ _${VER}.so`.so
134
135 # A small target to check environmental variables
136 %_env:
137 @${test_env}
138
139 .PHONY: install installdoc installlib installmacros installinc installexe installcmacro
140 .PHONY: clean depclean info mkbindir mklibdir testcern testpamenv test
141
142 mkbindir: ${DIRBIN}
143 ${DIRBIN}:
144 @${test_and_mk}
145
146 mklibdir: ${DIRLIB}
147 ${DIRLIB}:
148 @${test_and_mk}
149
150 # Here what has to be deleted in clean target
151 clean:
152 @${test_and_rm}
153
154 distclean: clean
155 distclean: TOBEDEL= ${DIRBIN} ${DIRLIB}
156 distclean:
157 @${test_and_rm}
158
159 forceinstall: FORCE=-f
160 forceinstall: install
161
162 upgrade: FORCE=-u
163 upgrade: install
164
165 #install: installlib installinc installmacros installcalib installdoc installexe installcmacro
166 install:
167
168 installlib: LINK=y
169 installlib: TOBEMOVED= $(FULLLIBS:${DIRLIB}%=${PAM_LIB}%)
170 installlib: ORIGIN=${DIRLIB}
171 installlib:
172 @${test_and_cp}
173
174 installinc: TOBEMOVED= $(INCSRCS:${DIRINC}/%=${PAM_INC}/%)
175 installinc: ORIGIN=${DIRINC}
176 installinc:
177 @${test_and_cp}
178
179 installexe: TOBEMOVED= $(EXESRCS:${DIRBIN}/%=${PAM_BIN}/%)
180 installexe: ORIGIN=${DIRBIN}
181 installexe:
182 @${test_and_cp}
183
184 installmacros: TOBEMOVED= $(MACROSSRCS:${DIRMACROS}/%=${PAM_MACROS}/%)
185 installmacros: ORIGIN=${DIRMACROS}
186 installmacros:
187 @${test_and_cp}
188
189 installcmacro: LINK=y
190 installcmacro: TOBEMOVED= $(FULLMACROCLIBS:${DIRLIB}%=${PAM_LIB}%)
191 installcmacro: ORIGIN=${DIRLIB}
192 installcmacro:
193 @${test_and_cp}
194
195 installcalib: TOBEMOVED= $(CALIBFILES:${DIRCALIB}/%=${PAM_CALIB}/%)
196 installcalib: ORIGIN=${DIRCALIB}
197 installcalib:
198 @${test_and_cp}
199
200 installdoc: TOBEMOVED= $(DOCFILES:${DIRDOC}/%=${PAM_DOC}/%)
201 installdoc: ORIGIN=${DIRDOC}
202 installdoc:
203 @${test_and_cp}
204
205 info:
206 @echo " "
207 @${EGREEN} "Infos for package :" ${WHITE} ${PACKAGE}
208 @${EGREEN} " VERSION :" ${WHITE} ${VER}
209 @${EGREEN} " EXECUTABLES :" ${WHITE} ${EXECUTABLES}
210 @${EGREEN} " LIBS :" ${WHITE} ${LIBS}
211 @${EGREEN} " SRCS :" ${WHITE} ${SRCS}
212 @${EGREEN} " OBJS :" ${WHITE} ${OBJS}
213 @${EGREEN} " DOCS :" ${WHITE} ${DOCS}
214 @${EGREEN} " MACROS :" ${WHITE} ${MACROS}
215 @echo " "
216 @${RESET}
217
218 test: testpamenv testcernlib testcalocommon testlibtrack testlibreadb2maps testroot2paw
219
220 testpamenv: ${PAM_ENV}
221
222 testcernlib: cernlib root-config
223
224 cernlib:
225 @${test_cmd}
226
227 root-config: OPT=--cflags
228 root-config:
229 @${test_cmd}
230
231 # Here follows some usefull macros
232 define test_and_cp
233 wd=`pwd`;\
234 for i in ${TOBEMOVED} ; do \
235 wv=$${i##/*/}; \
236 dest=$${i/$${wv}/}; \
237 ${EGREEN} "Testing for :" ${WHITE} "$${i}" ; ${RESET}; \
238 if [ ! "${FORCE}" ] ; then \
239 if [ ! -f $${i} ]; then \
240 ${EGREEN} "Copying : "${WHITE} ${ORIGIN}/$${i##/*/} ;\
241 ${EGREEN} " to: "${WHITE} $${i} ; ${RESET}; \
242 cp ${ORIGIN}/$${i##/*/} $${i}; \
243 else \
244 ${ERED} "File already exist !!!! Please delete it " ${WHITE}; ${RESET}; \
245 fi;\
246 else \
247 if [ "${FORCE}" == "-u" ] ; then \
248 if [ "`basename $${i}`" != "`basename $${i} _${VER}.so`" ]; then \
249 ${EYELLOW} "Removing: "${WHITE} ${PAM_LIB}/`basename $${i} _${VER}.so`_v*r*.so; ${RESET}; \
250 rm -f ${PAM_LIB}/`basename $${i} _${VER}.so`_v*r*.so ; \
251 ${EGREEN} "Copying : "${WHITE} ${ORIGIN}/$${i##/*/} ;\
252 ${EGREEN} " to: "${WHITE} $${i} ; ${RESET}; \
253 cp ${ORIGIN}/$${i##/*/} $${i}; \
254 else \
255 ${EYELLOW} " Forcing copy: "${WHITE} ${ORIGIN}/$${i##/*/} ;\
256 ${EYELLOW} " to: "${WHITE} $${i} ; ${RESET}; \
257 cp -f ${ORIGIN}/$${i##/*/} $${i}; \
258 fi; \
259 else \
260 ${EYELLOW} " Forcing copy: "${WHITE} ${ORIGIN}/$${i##/*/} ;\
261 ${EYELLOW} " to: "${WHITE} $${i} ; ${RESET}; \
262 cp ${FORCE} ${ORIGIN}/$${i##/*/} $${i}; \
263 fi;\
264 fi ;\
265 if [ ! -z ${LINK} ] ; then \
266 ${EGREEN} "Creating symlink from : "${WHITE} $${wv/_${VER}/} ;\
267 ${EGREEN} " to : "${WHITE} $${i##/*/} ; ${RESET}; \
268 cd $${dest}; \
269 ln -sf $${wv} $${wv/_${VER}/}; \
270 cd $${wd}; \
271 fi \
272 done
273 endef
274
275 define test_and_mk
276 ${EGREEN} "Testing for :" ${WHITE} "$@"; ${RESET}
277 test -d "$@" || \
278 (${EGREEN} "Creating : "${WHITE} "$@"; ${RESET}; mkdir -p $@)
279 endef
280
281 define test_env
282 ${EGREEN} "Testing for env:" ${WHITE} $(patsubst %_env,%,$@); ${RESET}
283 printenv $(patsubst %_env,%,$@) 1>/dev/null || \
284 (${ERED} "ERROR, variable : "${WHITE} $(patsubst %_env,%,$@) \
285 ${RED} "not defined !!! Check your env. settings"; \
286 ${RESET}; exit 1)
287 ${EGREEN} " Defined:" ${WHITE} $${$(patsubst %_env,%,$@)}; ${RESET}
288 endef
289
290 define test_cmd
291 ${EGREEN} "Testing for cmd:" ${WHITE} $@ ${OPT}; ${RESET}
292 $@ ${OPT} 1>/dev/null 2>&1 || \
293 (${ERED} "ERROR, command : "${WHITE} $@ ${OPT}\
294 ${RED} "not found !!! Check your installation"; \
295 ${RESET}; exit 1)
296 ${EGREEN} " Present:" ${WHITE} $@ ${OPT}; ${RESET}
297 endef
298
299 define test_exist
300 ${EGREEN} "Testing for library:" ${WHITE} $@ ${OPT}; ${RESET}
301 ls $@ 1>/dev/null 2>&1 || \
302 (${ERED} "ERROR, library : "${WHITE} $@ ${OPT}\
303 ${RED} " Not found !!! Check your installation"; \
304 ${RESET}; exit 1)
305 ${EGREEN} " Present:" ${WHITE} $@ ${OPT}; ${RESET}
306 endef
307
308 define test_and_rm
309 for i in ${TOBEDEL}; do \
310 test -d $${i} || (${ERED} "Removing file :"${WHITE} $${i}; ${RESET}; \
311 rm -f $${i} ); \
312 test ! -d $${i} || (${ERED} "Removing dir :"${WHITE} $${i}; ${RESET}; \
313 rm -rf $${i} ); \
314 done
315 endef

  ViewVC Help
Powered by ViewVC 1.1.23