--- DarthVader/Makefile 2006/06/17 12:12:48 1.1.1.2 +++ DarthVader/Makefile 2007/02/16 18:01:33 1.30 @@ -1,6 +1,6 @@ -# Trigger flight analysis software -# SOFTWARE VERSION -VER= v3r00 +# DarthVader flight analysis software +# SOFTWARE VERSION IS +VER= v3r01 # An almost general purpouse Makefile for PAMELA repository # Let's start with some usefull definition for colorize the echo RED='\E[1;31;40m' @@ -21,6 +21,8 @@ # Reset the terminal RESET=tput sgr0 # Here the variables used to override the standard make flags +#MAKE +MAKE=make # C CC=gcc #CFLAGS=-Wall -O -fPIC -pthread -g @@ -32,26 +34,30 @@ # F77 F77=g77 #F77FLAGS= -Wall -Wno-globals -fvxt -fno-automatic -fbounds-check -g -extend_source -static -fno-backslash -F77FLAGS= -Wall -Wno-globals -fvxt -fno-automatic -fbounds-check -extend_source -static -fno-backslash +F77FLAGS= -Wall -Wno-globals -fPIC -fvxt -fno-automatic -fbounds-check -extend_source -static -fno-backslash # C++ CXX=g++ #CXXFLAGS=-Wall -O -fPIC -pthread -g -CXXFLAGS=-Wall -O -fPIC -pthread +CXXFLAGS=-Wall -O4 -fPIC -pthread # ROOTCINT ROOTCINT=rootcint +#CERNLIB +CERNLIB=./docs/cernlib_pam +#CERNLIB=cernlib + # Here the variables definig the local directories DIRTOP=${shell pwd} -DIRLIB=../lib/${ARCH} -DIRBIN=../bin/${ARCH} -#DIRLIB=lib/${ARCH} -#DIRBIN=bin/${ARCH} +#DIRLIB=../lib/${ARCH} +#DIRBIN=../bin/${ARCH} +DIRLIB=lib/${ARCH} +DIRBIN=bin/${ARCH} DIRSRC=src DIRINC=inc DIRDOC=doc DIRMACROS=macros -DIRCALIB=calib +DIRCALIB=param # Here the PAMELA environmental variables to be checked -PAM_ENV= PAM_BIN_env PAM_LIB_env PAM_INC_env PAM_DOC_env PAM_YODA_env +PAM_ENV= PAM_BIN_env PAM_LIB_env PAM_INC_env PAM_DOC_env PAM_CALIB_env PAM_YODA_env # Here the local variables used to build the targets # -- F77 - no libraries -- @@ -59,54 +65,60 @@ FOBJS=$(FSRCS:${DIRSRC}%.for=${DIRLIB}%.o) # -- CPP - no libraries -- -CPPSRCS= +CPPSRCS=${DIRSRC}/DarthVaderVerl2.cpp CPPOBJS=$(CPPSRCS:${DIRSRC}%.cpp=${DIRLIB}%.o) # -- C - no libraries -- -CSRCS= +CSRCS= COBJS=$(CSRCS:${DIRSRC}%.c=${DIRLIB}%.o) # -- CPP - ROOT libraries -- -LIBROOTSRCS=${DIRSRC}/TrigLevel2.cpp +LIBROOTSRCS= LIBROOTLIBS=$(LIBROOTSRCS:${DIRSRC}/%.cpp=${DIRLIB}/lib%_${VER}.so) -LIBROOTCLIBS=libTrigLevel2 +LIBROOTCLIBS= FULLROOTCLIBS=$(LIBROOTCLIBS:%=${DIRLIB}/%_${VER}.so) # -- CPP - NON-ROOT libraries -- -LIBCPPSRCS= ${DIRSRC}/TrigCore.cpp \ - ${DIRSRC}/TrigVerl2.cpp +LIBCPPSRCS= LIBCPPLIBS=$(LIBCPPSRCS:${DIRSRC}/%.cpp=${DIRLIB}/lib%_${VER}.so) -LIBCPPCLIBS=libTrigCore libTrigVerl2 +LIBCPPCLIBS= FULLLIBCPPLIBS=$(LIBCPPCLIBS:%=${DIRLIB}/%_${VER}.so) # -- CPP - Executables -- -CXXEXESRCS=${DIRSRC}/TriggerLevel2.cpp +CXXEXESRCS=${DIRSRC}/DarthVader.cpp CXXEXEOBJS=$(CXXEXESRCS:${DIRSRC}%.cpp=${DIRLIB}%.o) -CXXEXELIBS:=TriggerLevel2 +CXXEXELIBS:=DarthVader + +# -- list of objects needed to link +##OBJS=$(shell cd ${DIRLIB}&>/dev/null;for file in `ls *.*`; do if [ $${file} != "" ] && [ $${file} != "DarthVader.o" ] && [ $${file} != "R2-D2.o" ]; then echo ${DIRLIB}/$${file}; fi; done) +OBJS=$(shell cd ${DIRLIB}&>/dev/null;for file in `ls lib*.so`; do if [ $${file} != "" ]; then echo ${DIRLIB}/$${file}; fi; done) ${CPPOBJS} +DARTHVLIB=${DIRLIB}/libDarthVader_${VER}.so -# -- list of tracker objects needed to link -TRKOBJS=${DIRLIB}/libGLTables.so ${DIRLIB}/libRunInfo.so # -- directory where to find tracker headers needed to compile -SUBDIR=../GLTables ../RunInfo +#TRKHEAD=${DIRTOP}/../tracker/inc +#TRKHEAD=-I${PAM_INC} -ITrackerLevel2/inc/ -IRunInfo/inc/ -IGLTables/inc/ + +# +SUBDIR=./RunInfo ./S4Level2 ./NDLevel2 ./TrackerLevel2 ./TriggerLevel2 ./ToFLevel2 ./CalorimeterLevel2 ./AnticounterLevel2 ./OrbitalInfo SUBINC=$(shell for dir in `echo ${SUBDIR}`; do echo -I$${dir}/inc; done) # List of all libraries we want to install -FULLLIBS = ${FULLROOTCLIBS} ${FULLLIBCPPLIBS} +FULLLIBS = ${FULLROOTCLIBS} ${FULLLIBCPPLIBS} ${DARTHVLIB} # Other objects to install -EXESRCS=${DIRBIN}/TriggerLevel2 +EXESRCS=${DIRBIN}/DarthVader -INCSRCS=${DIRINC}/TrigLevel2.h +INCSRCS= MACROSSRCS= -CALIBFILES= +CALIBFILES=${DIRCALIB}/trk-param ${DIRCALIB}/cal-param ${DIRCALIB}/tof-param ${DIRCALIB}/orb-param DOCFILES= # Here the Variables used for info target -PACKAGE=Trigger analysis flight software +PACKAGE=PAMELA analysis flight software EXECUTABLES= ${EXESRCS} LIBS= ${FULLLIBS} DOCS= @@ -118,16 +130,30 @@ TOBEDEL = junk ROOTINC=$$${shell root-config --incdir} NROOTINC=${shell root-config --incdir} +# Directories where you place detectors software +#SUBDIR=./GLTables ./RunInfo ./TrackerLevel2 ./CalorimeterLevel2 + # Let's start #all: test mkbindir mklibdir mkverpath ${FOBJS} ${CPPOBJS} ${LIBROOTLIBS} ${LIBCPPLIBS} ${CXXEXELIBS} -all: prepare libs + all: + @for dir in `echo ${SUBDIR}`; do \ + echo "Making all in $${dir}"; \ + (cd $${dir} && ${MAKE} all); \ + done; make locall + +locall: prepare libs exe +locall: @echo -e ${GREEN} "" @(${EGREEN} " Finished, now you can install the package \n (use: make install or make upgrade or make forceinstall) "; ${RESET}) @echo -e ${GREEN} "" @${RESET} -standalone: all exe +#subdir: +# @for dir in `echo ${SUBDIR}`; do \ +# echo "Making ${target} in $${dir}"; \ +# (cd $${dir} && ${MAKE} ${target}); \ +# done; prepare: test mkbindir mklibdir mkverpath @@ -138,11 +164,11 @@ # Here some general rules to produce objects in our local dir ${DIRLIB}/%.o: ${DIRSRC}/%.cpp @(${EGREEN} "Creating CPP object file: "${WHITE} "`basename $@`"; ${RESET}) - @${CXX} ${CXXFLAGS} -c -o $@ ${DIRSRC}/`basename ${@} .o`.cpp -I${DIRINC} ${SUBINC} -I${PAM_YODA}/include/yoda/ -I${PAM_YODA}/include/utils/ `root-config --cflags` + @${CXX} ${CXXFLAGS} -c -o $@ ${DIRSRC}/`basename ${@} .o`.cpp -I${DIRINC} ${SUBINC} -I${PAM_YODA}/include/yoda/ -I${PAM_INC}/ `root-config --cflags` ${DIRLIB}/%.o: ${DIRSRC}/%.c @(${EGREEN} "Creating C object file: "${WHITE} "`basename $@`"; ${RESET}) - @${CXX} ${CXXFLAGS} -c -o $@ ${DIRSRC}/`basename ${@} .o`.c -I${DIRINC} ${SUBINC} -I${PAM_YODA}/include/yoda/ `root-config --cflags` + @${CXX} ${CXXFLAGS} -c -o $@ ${DIRSRC}/`basename ${@} .o`.c -I${DIRINC} -I${PAM_YODA}/include/yoda/ -I${PAM_INC}/ `root-config --cflags` ${DIRLIB}/%.o: ${DIRSRC}/%.for @(${EGREEN} "Creating F77 object file: "${WHITE} "`basename $@`"; ${RESET}) @@ -153,19 +179,19 @@ # # Create *Dict.cpp and *Dict.h # - @${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 + @${ROOTCINT} -f ${DIRSRC}/`basename $(@F) _${VER}.so | sed s/lib//`Dict.cpp -c -I${ROOTINC} -I${PAM_YODA}/include/yoda/ -I${PAM_INC}/ ${DIRINC}/`basename $(@F) _${VER}.so | sed s/lib//`.h ${DIRINC}/`basename $(@F) _${VER}.so | sed s/lib//`LinkDef.h # # create .o # @(${EGREEN} "Compiling CPP file: "${WHITE} "`basename $(@F) _${VER}.so | sed s/lib//`.cpp"; ${RESET}) - @${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}; + @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${PAM_INC}/ -I${NROOTINC}; @(${EGREEN} "Compiling CPP file: "${WHITE} "`basename $(@F) _${VER}.so | sed s/lib//`Dict.cpp"; ${RESET}) - @${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}; + @cd ${DIRSRC} &>/dev/null && ${CXX} ${CXXFLAGS} -c `basename $(@F) _${VER}.so | sed s/lib//`Dict.cpp -I${DIRTOP}/${DIRINC} -I${DIRTOP} -I${PAM_YODA}/include/yoda/ -I${PAM_INC}/ -I${NROOTINC}; # # create .so # @(${EGREEN} "Creating shared library: "${WHITE} "`basename $@`"; ${RESET}) - @${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 + @${CXX} ${CXXFLAGS} -Xlinker -soname=$(@F) -shared -o $@ -lg2c -I${DIRTOP}/${DIRINC} -I${DIRTOP} -I${PAM_YODA}/include/yoda/ -I${PAM_INC}/ ${DIRTOP}/${DIRSRC}/`basename $(@F) _${VER}.so | sed s/lib//`.o ${DIRTOP}/${DIRSRC}/`basename $(@F) _${VER}.so | sed s/lib//`Dict.o 1>/dev/null @ln -sf ${DIRTOP}/${DIRLIB}/$(@F) ${DIRTOP}/${DIRLIB}/$(patsubst %_${VER}.so,%.so,$(@F)) ${LIBCPPLIBS}: ${LIBSRCS} ${COBJS} ${FOBJS} @@ -173,17 +199,20 @@ # create .o # @(${EGREEN} "Compiling CPP file: "${WHITE} "`basename $(@F) _${VER}.so | sed s/lib//`.cpp"; ${RESET}) - @${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}; + @cd ${DIRSRC} &>/dev/null && ${CXX} ${CXXFLAGS} -c `basename $(@F) _${VER}.so | sed s/lib//`.cpp -I${DIRTOP}/${DIRINC} -I${DIRTOP} ${SUBINC} -I${PAM_YODA}/include/yoda/ -I${PAM_INC}/ -I${NROOTINC}; # # create .so # @(${EGREEN} "Creating shared library: "${WHITE} "`basename $@`"; ${RESET}) - @${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 + @${CXX} ${CXXFLAGS} -Xlinker -soname=$(@F) -shared -o $@ -lg2c -I${DIRTOP}/${DIRINC} -I${DIRTOP} ${SUBINC} -I${PAM_YODA}/include/yoda/ -I${PAM_INC}/ ${DIRTOP}/${DIRSRC}/`basename $(@F) _${VER}.so | sed s/lib//`.o ${FOBJS} ${COBJS} 1>/dev/null @ln -sf ${DIRTOP}/${DIRLIB}/$(@F) ${DIRTOP}/${DIRLIB}/$(patsubst %_${VER}.so,%.so,$(@F)) ${CXXEXELIBS}: ${CPPOBJS} ${COBJS} ${CXXEXEOBJS} @(${EGREEN} "Creating exec file: "${WHITE} "$@"; ${RESET}) - @${CXX} ${CXXFLAGS} -o ${DIRBIN}/$@ ${DIRLIB}/$@.o ${FULLROOTCLIBS} ${FULLLIBCPPLIBS} ${TRKOBJS} ${CPPOBJS} ${COBJS} ${FOBJS} ${PAM_YODA}/lib/libyoda.so -lThread `root-config --cflags --glibs` `cernlib mathlib` + @${CXX} ${CXXFLAGS} -o ${DIRBIN}/$@ ${DIRTOP}/${DIRLIB}/$@.o ${OBJS} ${PAM_LIB}/libGLTables.so ${PAM_LIB}/libsgp4.so ${PAM_YODA}/lib/libyoda.so -lThread `root-config --cflags --glibs` `${CERNLIB} mathlib` + @${CXX} ${CXXFLAGS} -Xlinker -soname=libDarthVader_${VER}.so -shared -o ${DIRTOP}/${DIRLIB}/libDarthVader_${VER}.so -lg2c ${DIRTOP}/${DIRLIB}/libAcLevel2.so ${DIRTOP}/${DIRLIB}/libCaloLevel1.so ${DIRTOP}/${DIRLIB}/libCaloLevel2.so ${PAM_LIB}/libsgp4.so ${DIRTOP}/${DIRLIB}/libNDLevel2.so ${DIRTOP}/${DIRLIB}/libS4Level2.so ${DIRTOP}/${DIRLIB}/libToFLevel2.so ${DIRTOP}/${DIRLIB}/libTrigLevel2.so ${DIRTOP}/${DIRLIB}/libTrkLevel2.so ${DIRTOP}/${DIRLIB}/libTrkLevel1.so ${DIRTOP}/${DIRLIB}/libTrkLevel0.so ${DIRTOP}/${DIRLIB}/libTrkHough.so ${DIRTOP}/${DIRLIB}/libTrkCalib.so ${DIRTOP}/${DIRLIB}/libTrkParams.so ${PAM_LIB}/libGLTables.so ${DIRTOP}/${DIRLIB}/libRunInfo.so ${DIRTOP}/${DIRLIB}/libOrbitalInfo.so `${CERNLIB} mathlib` + +# @${CXX} ${CXXFLAGS} -o ${DIRBIN}/$@ ${DIRTOP}/${DIRLIB}/$@.o ${OBJS} ${PAM_YODA}/lib/libyoda.so ${PAM_YODA}/lib/libutils.so -lThread `root-config --cflags --glibs` `cernlib mathlib` # A small target to check environmental variables %_env: @@ -201,31 +230,64 @@ @${test_and_mk} # Here what has to be deleted in clean target -clean: TOBEDEL= ${DIRSRC}/*.o ${DIRSRC}/*Dict.cpp ${DIRSRC}/*Dict.h ${FOBJS} ${FULLLIBS} ${DIRBIN}/${CXXEXELIBS} ${CPPOBJS} ${CXXEXEOBJS} ${FULLLINKCLIBS} ${FULLMACROCLIBS} ${FULLLINKMACROCLIBS} ${DIRSRC}/TrigVerl2.cpp -clean: - @${test_and_rm} +clean: + @for dir in `echo ${SUBDIR}`; do \ + echo "Making clean in $${dir}"; \ + (cd $${dir} && ${MAKE} clean); \ + done; make locclean -distclean: clean -distclean: TOBEDEL= ${DIRBIN} ${DIRLIB} -distclean: +locclean: TOBEDEL= ${DIRSRC}/*.o ${DIRSRC}/*Dict.cpp ${DIRSRC}/*Dict.h ${FOBJS} ${FULLLIBS} ${DIRBIN}/${CXXEXELIBS} ${CPPOBJS} ${CXXEXEOBJS} ${FULLLINKCLIBS} ${FULLMACROCLIBS} ${FULLLINKMACROCLIBS} ${DIRSRC}/DarthVaderVerl2.cpp +locclean: @${test_and_rm} +distclean: + @for dir in `echo ${SUBDIR}`; do \ + echo "Making distclean in $${dir}"; \ + (cd $${dir} && ${MAKE} distclean); \ + done; make locdistclean + +locdistclean: clean +locdistclean: TOBEDEL= ${DIRBIN} ${DIRLIB} +locdistclean: + @${test_and_rm} -forceinstall: FORCE=-f -forceinstall: install - -forceinstallstandalone: FORCE=-f -forceinstallstandalone: installstandalone - -upgrade: FORCE=-u -upgrade: install -upgradestandalone: FORCE=-u -upgradestandalone: installstandalone +forceinstall: + @for dir in `echo ${SUBDIR}`; do \ + echo "Making forceinstall in $${dir}"; \ + (cd $${dir} && ${MAKE} forceinstall); \ + done; make locforceinstall + +locforceinstall: FORCE=-f +locforceinstall: install + +upgrade: + @for dir in `echo ${SUBDIR}`; do \ + echo "Making upgrade in $${dir}"; \ + (cd $${dir} && ${MAKE} upgrade); \ + done; make locupgrade + +locupgrade: FORCE=-u +locupgrade: locinstall + +upgradenc: + @for dir in `echo ${SUBDIR}`; do \ + echo "Making upgrade in $${dir}"; \ + (cd $${dir} && ${MAKE} upgrade); \ + done; make locupgradenc + +locupgradenc: FORCE=-u +locupgradenc: locinstallnc + +install: + @for dir in `echo ${SUBDIR}`; do \ + echo "Making install in $${dir}"; \ + (cd $${dir} && ${MAKE} install); \ + done; make locinstall -install: installlib installinc installmacros installcalib installdoc installcmacro +locinstall: installlib installinc installmacros installcalib installdoc installexe installcmacro -installstandalone: install installexe +locinstallnc: installlib installinc installmacros installdoc installexe installcmacro installlib: LINK=y installlib: TOBEMOVED= $(FULLLIBS:${DIRLIB}%=${PAM_LIB}%) @@ -257,7 +319,7 @@ installcalib: TOBEMOVED= $(CALIBFILES:${DIRCALIB}/%=${PAM_CALIB}/%) installcalib: ORIGIN=${DIRCALIB} installcalib: - @${test_and_cp} + @${cp_dir} installdoc: TOBEMOVED= $(DOCFILES:${DIRDOC}/%=${PAM_DOC}/%) installdoc: ORIGIN=${DIRDOC} @@ -265,7 +327,7 @@ @${test_and_cp} mkverpath: - @echo '#include ' > ${DIRTOP}/${DIRSRC}/TrigVerl2.cpp; echo ' char *TrigInfo(bool print){ if ( print ) printf("\nTrigger Level2 flight package version: ${VER}\n\nCompiled on '${TODAY}' with: '${GCCVER}'\n\nOn: '${UNAMEA}'\n\n"); return("${VER}"); }' >> ${DIRTOP}/${DIRSRC}/TrigVerl2.cpp + @echo '#include ' > ${DIRTOP}/${DIRSRC}/DarthVaderVerl2.cpp; echo ' char *DarthVaderInfo(bool print){ if ( print ) printf("\nPAMELA Level2 flight package version: ${VER}\n\nCompiled on '${TODAY}' with: '${GCCVER}'\n\nOn: '${UNAMEA}'\n\n"); return("${VER}"); }' >> ${DIRTOP}/${DIRSRC}/DarthVaderVerl2.cpp @sleep 0.8 @@ -335,6 +397,17 @@ done endef +define cp_dir +wd=`pwd`;\ +for i in ${TOBEMOVED} ; do \ +wv=$${i##/*/}; \ +dest=$${i/$${wv}/}; \ +${EYELLOW} " Copying directory: "${WHITE} ${ORIGIN}/$${i##/*/} ;\ +${EYELLOW} " to: "${WHITE} ${PAM_CALIB} ; ${RESET}; \ +cp -rf ${ORIGIN}/$${i##/*/} ${PAM_CALIB}; \ +done +endef + define test_and_mk ${EGREEN} "Testing for :" ${WHITE} "$@"; ${RESET} test -d "$@" || \