/[PAMELA software]/calo/flight/FCaloREPROC/Makefile
ViewVC logotype

Annotation of /calo/flight/FCaloREPROC/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.8 - (hide annotations) (download)
Sat Sep 1 13:48:11 2018 UTC (6 years, 3 months ago) by mayorov
Branch: MAIN
CVS Tags: HEAD
Changes since 1.7: +1 -1 lines
Update for CentOS 7

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

  ViewVC Help
Powered by ViewVC 1.1.23