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

Annotation of /calo/flight/FQLOOK/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.12 - (hide annotations) (download)
Mon Jul 10 13:54:59 2006 UTC (18 years, 5 months ago) by mocchiut
Branch: MAIN
CVS Tags: v1r10
Changes since 1.11: +1 -1 lines
Changed executables input format (now uses flags)

1 mocchiut 1.1 # Flight quick look - FQLOOK
2     # SOFTWARE VERSION
3 mocchiut 1.12 VER= v1r10
4 mocchiut 1.1 # 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 mocchiut 1.8 CFLAGS=-Wall -O -fPIC -pthread
27 mocchiut 1.1 # Enviroment:
28     GCCVER=`gcc --version | head -1`
29     UNAMEA=`uname -a`
30     TODAY=`date`
31     # F77
32     F77=g77
33     F77FLAGS= -Wall -Wno-globals -fvxt -fno-automatic -fbounds-check -g -extend_source -static -fno-backslash
34     # C++
35     CXX=g++
36 mocchiut 1.8 CXXFLAGS=-Wall -O -fPIC -pthread
37 mocchiut 1.1 # ROOTCINT
38     ROOTCINT=rootcint
39     # Here the variables definig the local directories
40     DIRTOP=${shell pwd}
41     DIRLIB=lib/${ARCH}
42     DIRBIN=bin/${ARCH}
43     DIRSRC=src
44     DIRINC=inc
45     DIRDOC=doc
46     DIRMACROS=macros
47     DIRCALIB=calib
48     # Here the PAMELA environmental variables to be checked
49     PAM_ENV= PAM_BIN_env PAM_LIB_env PAM_INC_env PAM_DOC_env PAM_MACROS_env PAM_CALIB_env PAM_YODA_env
50     # Here the local variables used to build the targets
51    
52     MACROSRCS=${DIRMACROS}/FCaloQLOOK.cxx \
53     ${DIRMACROS}/FCaloCHKCALIB.cxx
54 mocchiut 1.4 MACROSLIBS=$(MACROSRCS:${DIRMACROS}/%.cxx=${DIRLIB}/lib%_${VER}.so)
55     MACROCLIBS=libFCaloQLOOK libFCaloCHKCALIB
56 mocchiut 1.1 FULLMACROCLIBS=$(MACROCLIBS:%=${DIRLIB}/%_${VER}.so)
57     FULLLINKMACROCLIBS=$(MACROCLIBS:%=${DIRLIB}/%.so)
58    
59     CXXEXESRCS=${DIRSRC}/FCaloQLOOK.cc ${DIRSRC}/FCaloCHKCALIB.cc
60     CXXEXEOBJS=$(CXXEXESRCS:${DIRSRC}%.cc=${DIRBIN}%.o)
61     CXXEXELIBS:=FCaloQLOOK FCaloCHKCALIB
62    
63     EXESRCS= ${DIRBIN}/FCaloQLOOK ${DIRBIN}/FCaloCHKCALIB
64    
65     INCSRCS=
66    
67     MACROSSRCS=${DIRMACROS}/FCaloQLOOK.C ${DIRMACROS}/FCaloCHKCALIB.C
68    
69     CALIBFILES=
70    
71 mocchiut 1.5 DOCFILES=${DIRDOC}/fcaloQLOOK.README.pdf ${DIRDOC}/FQL-calo-opmanual.pdf ${DIRDOC}/FQL-calo-opmanual.doc
72 mocchiut 1.1
73     # Here the Variables used for info target
74     PACKAGE=Calorimeter flight quick look software
75     EXECUTABLES=
76     LIBS= ${FLIBS} ${FOBJS} ${CLIBS} ${COBJS} ${CXXEXEOBJS}
77     DOCS=
78     SRCS= ${FSRCS} ${CRSCS} ${CXXEXESRCS}
79     MACROS= ${MACROSSRCS}
80     #
81     TOBEDEL = junk
82     ROOTINC=$$${shell root-config --incdir}
83     # Let's start
84     all : test mkbindir mklibdir ${MACROSLIBS} ${CXXEXELIBS}
85     all:
86     @echo -e ${GREEN} ""
87     @(${EGREEN} " Finished, now you can install the package \n (use: make install or make upgrade or make forceinstall) "; ${RESET})
88     @echo -e ${GREEN} ""
89     @${RESET}
90    
91     # Here some general rules to produce objects in our local dir
92     ${DIRBIN}/%.o: ${DIRSRC}/%.cc
93     @(${EGREEN} "Creating object file: "${WHITE} "$@"; ${RESET})
94     @cat ${DIRSRC}/`basename ${@} .o`.cc > ${DIRSRC}/temp.cc;
95     @echo ' ' >> ${DIRSRC}/temp.cc
96     @echo 'void info(){ printf("\nQLOOK flight package version: ${VER}\n\nCompiled on '${TODAY}' with: '${GCCVER}'\n\nOn: '${UNAMEA}'\n\n"); }' >> ${DIRSRC}/temp.cc
97     @${CXX} ${CXXFLAGS} -c -o $@ ${DIRSRC}/temp.cc -I${DIRINC} -I${PAM_INC} -I${PAM_YODA}/include/yoda/ `root-config --cflags`
98    
99 mocchiut 1.6
100 mocchiut 1.1 ${MACROSLIBS}: ${MACROSRCS}
101     @(${EGREEN} "Compiling macro: "${WHITE} "$@"; ${RESET})
102 mocchiut 1.4 @${ROOTCINT} -f ${DIRMACROS}/`basename $(@F) _${VER}.so | sed s/lib//`link.cxx -c -I${ROOTINC} ${DIRINC}/`basename $(@F) _${VER}.so | sed s/lib//`fun.h ${DIRINC}/`basename $(@F) _${VER}.so | sed s/lib//`LinkDef.h
103     @${CXX} ${CXXFLAGS} -Xlinker -soname=$(@F) -shared -o $@ ${DIRMACROS}/`basename $(@F) _${VER}.so | sed s/lib//`.cxx ${DIRMACROS}/`basename $(@F) _${VER}.so | sed s/lib//`link.cxx -lg2c -I${PAM_INC} -I${DIRTOP}/${DIRINC} -I${DIRTOP} -I${PAM_YODA}/include/yoda/ ${PAM_YODA}/lib/libyoda.so `root-config --cflags --glibs` 1>/dev/null
104 mocchiut 1.1
105     ${CXXEXELIBS}: ${CXXEXEOBJS}
106     @(${EGREEN} "Creating exec file: "${WHITE} "$@"; ${RESET})
107 mocchiut 1.4 @${CXX} ${CXXFLAGS} -o ${DIRBIN}/$@ ${DIRBIN}/$@.o -I${DIRINC} -I${PAM_INC} -I${PAM_YODA}/include/yoda/ ${PAM_YODA}/lib/libyoda.so ${DIRTOP}/${DIRLIB}/lib$@_${VER}.so `root-config --cflags --glibs`;
108 mocchiut 1.1 @rm -f ${DIRSRC}/temp.cc
109    
110     # A small target to check environmental variables
111     %_env:
112     @${test_env}
113    
114     .PHONY: install installdoc installlib installmacros installinc installexe installcmacro
115     .PHONY: clean depclean info mkbindir mklibdir testcern testpamenv test
116    
117     mkbindir: ${DIRBIN}
118     ${DIRBIN}:
119     @${test_and_mk}
120    
121     mklibdir: ${DIRLIB}
122     ${DIRLIB}:
123     @${test_and_mk}
124    
125     # Here what has to be deleted in clean target
126     clean: TOBEDEL= ${DIRMACROS}/*link.cxx ${DIRMACROS}/*link.h ${FOBJS} ${FULLLIBS} ${DIRBIN}/${CXXEXELIBS} ${COBJS} ${CXXEXEOBJS} ${FULLLINKFLIBS} ${FULLLINKCLIBS} ${FULLMACROCLIBS} ${FULLLINKMACROCLIBS}
127     clean:
128     @${test_and_rm}
129    
130     distclean: clean
131     distclean: TOBEDEL= ${DIRBIN} ${DIRLIB}
132     distclean:
133     @${test_and_rm}
134    
135     forceinstall: FORCE=-f
136     forceinstall: install
137    
138     upgrade: FORCE=-u
139     upgrade: install
140    
141     install: installlib installinc installmacros installcalib installdoc installexe installcmacro
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     info:
181     @echo " "
182     @${EGREEN} "Infos for package :" ${WHITE} ${PACKAGE}
183     @${EGREEN} " VERSION :" ${WHITE} ${VER}
184     @${EGREEN} " EXECUTABLES :" ${WHITE} ${EXECUTABLES}
185     @${EGREEN} " LIBS :" ${WHITE} ${LIBS}
186     @${EGREEN} " DOCS :" ${WHITE} ${DOCS}
187     @${EGREEN} " SRCS :" ${WHITE} ${SRCS}
188     @${EGREEN} " MACROS :" ${WHITE} ${MACROS}
189     @echo " "
190     @${RESET}
191    
192     test: testpamenv
193    
194     testpamenv: ${PAM_ENV}
195    
196     root-config: OPT=--cflags
197     root-config:
198     @${test_cmd}
199    
200     # Here follows some usefull macros
201     define test_and_cp
202     wd=`pwd`;\
203     for i in ${TOBEMOVED} ; do \
204     wv=$${i##/*/}; \
205     dest=$${i/$${wv}/}; \
206     ${EGREEN} "Testing for :" ${WHITE} "$${i}" ; ${RESET}; \
207     if [ ! "${FORCE}" ] ; then \
208     if [ ! -f $${i} ]; then \
209     ${EGREEN} "Copying : "${WHITE} ${ORIGIN}/$${i##/*/} ;\
210     ${EGREEN} " to: "${WHITE} $${i} ; ${RESET}; \
211     cp ${ORIGIN}/$${i##/*/} $${i}; \
212     else \
213     ${ERED} "File already exist !!!! Please delete it " ${WHITE}; ${RESET}; \
214     fi;\
215     else \
216     if [ "${FORCE}" == "-u" ] ; then \
217     if [ "`basename $${i}`" != "`basename $${i} _${VER}.so`" ]; then \
218     ${EYELLOW} "Removing: "${WHITE} ${PAM_LIB}/`basename $${i} _${VER}.so`_v*r*.so; ${RESET}; \
219     rm -f ${PAM_LIB}/`basename $${i} _${VER}.so`_v*r*.so ; \
220     ${EGREEN} "Copying : "${WHITE} ${ORIGIN}/$${i##/*/} ;\
221     ${EGREEN} " to: "${WHITE} $${i} ; ${RESET}; \
222     cp ${ORIGIN}/$${i##/*/} $${i}; \
223     else \
224     ${EYELLOW} " Forcing copy: "${WHITE} ${ORIGIN}/$${i##/*/} ;\
225     ${EYELLOW} " to: "${WHITE} $${i} ; ${RESET}; \
226     cp -f ${ORIGIN}/$${i##/*/} $${i}; \
227     fi; \
228     else \
229     ${EYELLOW} " Forcing copy: "${WHITE} ${ORIGIN}/$${i##/*/} ;\
230     ${EYELLOW} " to: "${WHITE} $${i} ; ${RESET}; \
231     cp ${FORCE} ${ORIGIN}/$${i##/*/} $${i}; \
232     fi;\
233     fi ;\
234     if [ ! -z ${LINK} ] ; then \
235     ${EGREEN} "Creating symlink from : "${WHITE} $${wv/_${VER}/} ;\
236     ${EGREEN} " to : "${WHITE} $${i##/*/} ; ${RESET}; \
237     cd $${dest}; \
238     ln -sf $${wv} $${wv/_${VER}/}; \
239     cd $${wd}; \
240     fi \
241     done
242     endef
243    
244     define test_and_mk
245     ${EGREEN} "Testing for :" ${WHITE} "$@"; ${RESET}
246     test -d "$@" || \
247     (${EGREEN} "Creating : "${WHITE} "$@"; ${RESET}; mkdir -p $@)
248     endef
249    
250     define test_env
251     ${EGREEN} "Testing for env:" ${WHITE} $(patsubst %_env,%,$@); ${RESET}
252     printenv $(patsubst %_env,%,$@) 1>/dev/null || \
253     (${ERED} "ERROR, variable : "${WHITE} $(patsubst %_env,%,$@) \
254     ${RED} "not defined !!! Check your env. settings"; \
255     ${RESET}; exit 1)
256     ${EGREEN} " Defined:" ${WHITE} $${$(patsubst %_env,%,$@)}; ${RESET}
257     endef
258    
259     define test_cmd
260     ${EGREEN} "Testing for cmd:" ${WHITE} $@ ${OPT}; ${RESET}
261     $@ ${OPT} 1>/dev/null 2>&1 || \
262     (${ERED} "ERROR, command : "${WHITE} $@ ${OPT}\
263     ${RED} "not found !!! Check your installation"; \
264     ${RESET}; exit 1)
265     ${EGREEN} " Present:" ${WHITE} $@ ${OPT}; ${RESET}
266     endef
267    
268     define test_and_rm
269     for i in ${TOBEDEL}; do \
270     test -d $${i} || (${ERED} "Removing file :"${WHITE} $${i}; ${RESET}; \
271     rm -f $${i} ); \
272     test ! -d $${i} || (${ERED} "Removing dir :"${WHITE} $${i}; ${RESET}; \
273     rm -rf $${i} ); \
274     done
275     endef

  ViewVC Help
Powered by ViewVC 1.1.23