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

Annotation of /DarthVader/GLTables/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (hide annotations) (download) (vendor branch)
Fri May 19 13:15:58 2006 UTC (18 years, 6 months ago) by mocchiut
Branch: DarthVader
CVS Tags: v0r01, v0r02, v1r01beta, v1r00, start
Changes since 1.1: +0 -0 lines
Imported sources

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

  ViewVC Help
Powered by ViewVC 1.1.23