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

Annotation of /DarthVader/AnticounterLevel2/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations) (download)
Fri May 19 13:15:59 2006 UTC (18 years, 6 months ago) by mocchiut
Branch: MAIN
Branch point for: DarthVader
Initial revision

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

  ViewVC Help
Powered by ViewVC 1.1.23