# ROOT2PAW # SOFTWARE VERSION VER= v3r00 # REQUIRES CALOCOMMON version COMMONVER=v1r8 # installed calocommon version COMPCOMVER=`echo ${COMMONVER} | tr -d [a-z:A-Z]` INSTCOMVER=`${PAM_BIN}/calocommon |head -2 |tail -1 | tr -d [a-z:A-Z]` # An almost general purpouse Makefile for PAMELA repository # Let's start with some usefull definition for colorize the echo RED='\E[1;31;40m' GREEN='\E[1;32;40m' YELLOW='\E[1;33;40m' VIOLET='\E[1;35;40m' CYAN='\E[1;36;40m' BLUE='\E[1;34;40m' WHITE='\E[1;37;40m' # Here the echo definition to use them EVIOLET=echo -e ${VIOLET} ECYAN=echo -e ${CYAN} ERED=echo -e ${RED} EGREEN=echo -e ${GREEN} EYELLOW=echo -e ${YELLOW} EBLUE=echo -e ${BLUE} EWHITE=echo -e ${WHITE} # Reset the terminal RESET=tput sgr0 # Here the variables used to override the standard make flags # C CC=gcc CFLAGS=-Wall -fPIC -O3 # Enviroment: GCCVER=`gcc --version | head -1` UNAMEA=`uname -a` TODAY=`date` # F77 F77=g77 #F77FLAGS= -Wall -fbounds-check -g -extend_source -static -fno-backslash F77FLAGS= -O -Wall -Wno-globals -fPIC -fvxt -fno-automatic -fbounds-check -g -extend_source -static -fno-backslash # C++ CXX=g++ CXXFLAGS=-Wall -fPIC -O3 # Here the variables definig the local directories DIRTOP=${shell pwd} DIRLIB=lib/${ARCH} DIRBIN=bin/${ARCH} DIRSRC=src DIRINC=inc DIRDOC=doc DIRMACROS=macros DIRCALIB=calib # Here the PAMELA environmental variables to be checked PAM_ENV= PAM_BIN_env PAM_LIB_env PAM_INC_env PAM_DOC_env PAM_MACROS_env PAM_CALIB_env PAM_YODA_env # Here the local variables used to build the targets FSRCS=${DIRSRC}/optrklev1.for \ ${DIRSRC}/retrklev1.for \ ${DIRSRC}/cltrklev1.for \ ${DIRSRC}/optrklev2.for \ ${DIRSRC}/retrklev2.for \ ${DIRSRC}/cltrklev2.for \ ${DIRSRC}/cltoflev1.for \ ${DIRSRC}/optoflev1.for \ ${DIRSRC}/retoflev1.for \ ${DIRSRC}/claclev1.for \ ${DIRSRC}/opaclev1.for \ ${DIRSRC}/fiaclev1.for FOBJS=$(FSRCS:${DIRSRC}%.for=${DIRBIN}%.o) FLIBS=optrklev1 retrklev1 cltrklev1 optrklev2 retrklev2 cltrklev2 opaclev1 fiaclev1 claclev1 optoflev1 retoflev1 cltoflev1 FULLFLIBS=$(FLIBS:%=${DIRLIB}/lib%_${VER}.so) FULLLINKFLIBS=$(FLIBS:%=${DIRLIB}/lib%.so) MACROSRCS=${DIRMACROS}/GroundDataConvert.c MACROSLIBS=$(MACROSRCS:${DIRMACROS}/%.c=${DIRLIB}/%_c_${VER}.so) MACROCLIBS=GroundDataConvert_c FULLMACROCLIBS=$(MACROCLIBS:%=${DIRLIB}/%_${VER}.so) FULLLINKMACROCLIBS=$(MACROCLIBS:%=${DIRLIB}/%.so) HSRCS=${DIRINC}/aclev1class.h FULLHLIBS=$(HSRCS:${DIRINC}/%.h=${DIRLIB}/%_h_${VER}.so) CSRCS= COBJS=$(CSRCS:${DIRSRC}%.c=${DIRBIN}%.o) CLIBS= FULLCLIBS=$(CLIBS:%=${DIRLIB}/lib%_${VER}.so) FULLLINKCLIBS=$(CLIBS:%=${DIRLIB}/lib%.so) CXXSRCS=${DIRSRC}/liboptrklev1.C \ ${DIRSRC}/libretrklev1.C \ ${DIRSRC}/libcltrklev1.C \ ${DIRSRC}/liboptoflev1.C \ ${DIRSRC}/libretoflev1.C \ ${DIRSRC}/libcltoflev1.C \ ${DIRSRC}/liboptrklev2.C \ ${DIRSRC}/libretrklev2.C \ ${DIRSRC}/libcltrklev2.C \ ${DIRSRC}/libopaclev1.C \ ${DIRSRC}/libfiaclev1.C \ ${DIRSRC}/libclaclev1.C FULLCXXLIBS=$(CXXSRCS:${DIRSRC}/%.C=${DIRLIB}/%_C_${VER}.so) CXXEXESRCS=${DIRSRC}/GroundDataConvert.cc CXXEXEOBJS=$(CXXEXESRCS:${DIRSRC}%.cc=${DIRBIN}%.o) CXXEXELIBS:=GroundDataConvert #FULLLIBS=$(sort ${FULLFLIBS} ${FULLCXXLIBS} ) FULLLIBS=${FULLFLIBS} ${FULLCXXLIBS} ${FULLCLIBS} ${FULLHLIBS} EXESRCS= ${DIRBIN}/GroundDataConvert INCSRCS= ${DIRINC}/ctrkstruct.h ${DIRINC}/ctrkinclude.h ${DIRINC}/cacstruct.h ${DIRINC}/ctofstruct.h ${DIRINC}/ctofinclude.h ${DIRINC}/trklev1struct.h ${DIRINC}/aclev1class.h MACROSSRCS=${DIRMACROS}/GroundDataConvert.c CALIBFILES= DOCFILES=${DIRDOC}/examples.c ${DIRDOC}/root2paw.README.pdf # Here the Variables used for info target PACKAGE=PAMELA ground data software converter EXECUTABLES=GroundDataConvert LIBS= ${FLIBS} ${FOBJS} ${CLIBS} ${COBJS} ${CXXEXEOBJS} DOCS= SRCS= ${FSRCS} ${CRSCS} ${CXXEXESRCS} MACROS= ${MACROSSRCS} # TOBEDEL = junk # Let's start all : test mkbindir mklibdir ${FULLFLIBS} ${FULLCXXLIBS} ${FULLHLIBS} ${MACROSLIBS} ${CXXEXELIBS} all: @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} "" @if [ "$(shell ${PAM_BIN}/CaloLEVEL2 --version 2>/dev/null | grep version | tr -d [a-z:A-Z\ ])" ]; then (${EVIOLET} "WARNING: the installation will break dependencies of CALOLEVEL2"; ${RESET}); (${EVIOLET} "WARNING: re-compile CALOLEVEL2 package after the installation"; ${RESET}); echo -e ${GREEN} ""; fi @${RESET} # Here some general rules to produce objects in our local dir # .o from fortran ${DIRBIN}/%.o : ${DIRSRC}/%.for @(${EGREEN} "Creating object file: "${WHITE} "$@"; ${RESET}) @${F77} ${F77FLAGS} -c -o $@ $< -I${DIRINC} ${DIRBIN}/%.o: ${DIRSRC}/%.cc @(${EGREEN} "Creating object file: "${WHITE} "$@"; ${RESET}) @cat ${DIRSRC}/`basename ${@} .o`.cc > ${DIRSRC}/temp.cc; @echo ' ' >> ${DIRSRC}/temp.cc @echo 'void info(){ printf("\nROOT2PAW package version: ${VER}\n\nCompiled on '${TODAY}' with: '${GCCVER}'\n\nOn: '${UNAMEA}'\n\n"); }' >> ${DIRSRC}/temp.cc @${CXX} ${CXXFLAGS} -c -o $@ ${DIRSRC}/temp.cc -I${DIRINC} -I${PAM_INC} -I${PAM_YODA}/include/yoda/ `root-config --cflags` # .o from C ${DIRBIN}/%.o : ${DIRSRC}/%.c @(${EGREEN} "Creating object file: "${WHITE} "$@"; ${RESET}) @${CC} ${CFLAGS} -c -o $@ $< -I${DIRINC} # .so from .o fortran ${FULLFLIBS}: ${FOBJS} @(${EGREEN} "Creating library: "${WHITE} "$@"; ${RESET}) @${CXX} ${CXXFLAGS} -Xlinker -soname=$(@F) -shared -o $@ $^ -lg2c `cernlib mathlib` @(${EGREEN} "Creating symlink from : "${WHITE} "$@"; ${RESET}) @(${EGREEN} " to : "${WHITE} "${DIRLIB}/`basename $@ _${VER}.so`.so"; ${RESET}) @ln -sf `basename $@` ${DIRLIB}/`basename $@ _${VER}.so`.so # .so from .o c ${FULLCLIBS}: ${COBJS} @(${EGREEN} "Creating library: "${WHITE} "$@"; ${RESET}) @${CXX} ${CXXFLAGS} -Xlinker -soname=$(@F) -shared -o $@ $^ -lg2c `mysql_config --cflags --libs` @(${EGREEN} "Creating symlink from : "${WHITE} "$@"; ${RESET}) @(${EGREEN} " to : "${WHITE} "${DIRLIB}/`basename $@ _${VER}.so`.so"; ${RESET}) @ln -sf `basename $@` ${DIRLIB}/`basename $@ _${VER}.so`.so ${FULLCXXLIBS}: ${FULLCLIBS} ${FULLFLIBS} ${CXXSRCS} @(${EGREEN} "Creating ROOT sharable lib: "${WHITE} "$@"; ${RESET}) @echo '.include ${DIRTOP}/${DIRINC}' > build_so.txt @echo 'TString *junk=new TString();' >> build_so.txt @echo '*junk=gSystem->GetDynamicPath();' >> build_so.txt @echo ' // cout << junk->Data() << endl;' >> build_so.txt @echo '*junk+=":${DIRLIB}";' >> build_so.txt @echo 'gSystem->SetDynamicPath(junk.Data());' >> build_so.txt @echo 'gSystem->Load("${DIRLIB}/'`basename $@ _C_${VER}.so`'.so")' >> build_so.txt @echo 'gSystem->cd("'${DIRSRC}'");' >> build_so.txt @echo '.L $(patsubst %_C_${VER}.so,%.C++,$(@F))' >> build_so.txt @echo '.q' >> build_so.txt @root -l -b &>/dev/null < build_so.txt @mv -f ${DIRSRC}/$(patsubst %_C_${VER}.so,%_C.so,$(@F)) ${DIRLIB}/$(@F) @rm -f build_so.txt ${FULLHLIBS}: ${FULLCLIBS} ${FULLFLIBS} ${CXXSRCS} ${HSRCS} @(${EGREEN} "Creating ROOT sharable lib: "${WHITE} "$@"; ${RESET}) @echo '.include ${DIRTOP}/${DIRINC}' > build_so.txt @echo 'TString *junk=new TString();' >> build_so.txt @echo '*junk=gSystem->GetDynamicPath();' >> build_so.txt @echo '*junk+=":${DIRLIB}";' >> build_so.txt @echo 'gSystem->SetDynamicPath(junk.Data());' >> build_so.txt @echo 'gSystem->cd("'${DIRINC}'");' >> build_so.txt @echo '.L $(patsubst %_h_${VER}.so,%.h++O,$(@F))' >> build_so.txt @echo '.q' >> build_so.txt @root -l -b &>/dev/null < build_so.txt @mv -f ${DIRINC}/$(patsubst %_h_${VER}.so,%_h.so,$(@F)) ${DIRLIB}/$(@F) @rm -f build_so.txt ${MACROSLIBS}: ${MACROSRCS} @(${EGREEN} "Compiling macro: "${WHITE} "$@"; ${RESET}) @echo '.include ${DIRTOP}/${DIRINC}' > build_so.txt @echo 'TString *junk=new TString();' >> build_so.txt @echo '*junk=gSystem->GetDynamicPath();' >> build_so.txt @echo '*junk+=":${DIRLIB}";' >> build_so.txt @echo 'gSystem->SetDynamicPath(junk.Data());' >> build_so.txt @echo 'char *lmac = gSystem->ExpandPathName("$$PAM_INC");'>>build_so.txt @echo 'gInterpreter->AddIncludePath(lmac);'>>build_so.txt @echo 'char *pamyoda = gSystem->ExpandPathName("$$PAM_YODA");' >>build_so.txt @echo 'stringstream incy;' >>build_so.txt @echo 'incy.str("");' >>build_so.txt @echo 'incy << pamyoda << "/include/yoda/";' >>build_so.txt @echo 'gInterpreter->AddIncludePath(incy.str().c_str());' >>build_so.txt @echo 'incy.str("");' >>build_so.txt @echo 'incy << pamyoda << "/event/";'>>build_so.txt @echo 'gInterpreter->AddIncludePath(incy.str().c_str());'>>build_so.txt @echo 'gSystem->cd("'${DIRMACROS}'");' >> build_so.txt @echo 'char *pamyodalib = gSystem->ExpandPathName("$$PAM_YODA");' >>build_so.txt @echo 'stringstream libYODA;'>>build_so.txt @echo 'libYODA.str("");' >>build_so.txt @echo 'libYODA << pamyodalib << "/lib/libyoda.so";'>>build_so.txt @echo 'gSystem->Load(libYODA.str().c_str());'>>build_so.txt @echo 'libYODA.str("");' >>build_so.txt @echo 'libYODA << "'${DIRTOP}/${DIRLIB}'/aclev1class_h_'${VER}'.so";'>>build_so.txt @echo 'gSystem->Load(libYODA.str().c_str());'>>build_so.txt @echo 'libYODA.str("");' >>build_so.txt @echo 'libYODA << "'${DIRTOP}/${DIRLIB}'/liboptrklev1";'>>build_so.txt @echo 'gSystem->Load(libYODA.str().c_str());'>>build_so.txt @echo 'libYODA.str("");' >>build_so.txt @echo 'libYODA << "'${DIRTOP}/${DIRLIB}'/liboptrklev1_C_'${VER}'";'>>build_so.txt @echo 'gSystem->Load(libYODA.str().c_str());'>>build_so.txt @echo 'libYODA.str("");' >>build_so.txt @echo 'libYODA << "'${DIRTOP}/${DIRLIB}'/libcltrklev1";'>>build_so.txt @echo 'gSystem->Load(libYODA.str().c_str());'>>build_so.txt @echo 'libYODA.str("");' >>build_so.txt @echo 'libYODA << "'${DIRTOP}/${DIRLIB}'/libcltrklev1_C_'${VER}'";'>>build_so.txt @echo 'gSystem->Load(libYODA.str().c_str());'>>build_so.txt @echo 'libYODA.str("");' >>build_so.txt @echo 'libYODA << "'${DIRTOP}/${DIRLIB}'/libretrklev1";'>>build_so.txt @echo 'gSystem->Load(libYODA.str().c_str());'>>build_so.txt @echo 'libYODA.str("");' >>build_so.txt @echo 'libYODA << "'${DIRTOP}/${DIRLIB}'/libretrklev1_C_'${VER}'";'>>build_so.txt @echo 'gSystem->Load(libYODA.str().c_str());'>>build_so.txt @echo 'libYODA.str("");' >>build_so.txt @echo 'libYODA << "'${DIRTOP}/${DIRLIB}'/liboptrklev2";'>>build_so.txt @echo 'gSystem->Load(libYODA.str().c_str());'>>build_so.txt @echo 'libYODA.str("");' >>build_so.txt @echo 'libYODA << "'${DIRTOP}/${DIRLIB}'/liboptrklev2_C_'${VER}'";'>>build_so.txt @echo 'gSystem->Load(libYODA.str().c_str());'>>build_so.txt @echo 'libYODA.str("");' >>build_so.txt @echo 'libYODA << "'${DIRTOP}/${DIRLIB}'/libcltrklev2";'>>build_so.txt @echo 'gSystem->Load(libYODA.str().c_str());'>>build_so.txt @echo 'libYODA.str("");' >>build_so.txt @echo 'libYODA << "'${DIRTOP}/${DIRLIB}'/libcltrklev2_C_'${VER}'";'>>build_so.txt @echo 'gSystem->Load(libYODA.str().c_str());'>>build_so.txt @echo 'libYODA.str("");' >>build_so.txt @echo 'libYODA << "'${DIRTOP}/${DIRLIB}'/libretrklev2";'>>build_so.txt @echo 'gSystem->Load(libYODA.str().c_str());'>>build_so.txt @echo 'libYODA.str("");' >>build_so.txt @echo 'libYODA << "'${DIRTOP}/${DIRLIB}'/libretrklev2_C_'${VER}'";'>>build_so.txt @echo 'gSystem->Load(libYODA.str().c_str());'>>build_so.txt @echo 'libYODA.str("");' >>build_so.txt @echo 'libYODA << "'${DIRTOP}/${DIRLIB}'/liboptoflev1";'>>build_so.txt @echo 'gSystem->Load(libYODA.str().c_str());'>>build_so.txt @echo 'libYODA.str("");' >>build_so.txt @echo 'libYODA << "'${DIRTOP}/${DIRLIB}'/liboptoflev1_C_'${VER}'";'>>build_so.txt @echo 'gSystem->Load(libYODA.str().c_str());'>>build_so.txt @echo 'libYODA.str("");' >>build_so.txt @echo 'libYODA << "'${DIRTOP}/${DIRLIB}'/libcltoflev1";'>>build_so.txt @echo 'gSystem->Load(libYODA.str().c_str());'>>build_so.txt @echo 'libYODA.str("");' >>build_so.txt @echo 'libYODA << "'${DIRTOP}/${DIRLIB}'/libcltoflev1_C_'${VER}'";'>>build_so.txt @echo 'gSystem->Load(libYODA.str().c_str());'>>build_so.txt @echo 'libYODA.str("");' >>build_so.txt @echo 'libYODA << "'${DIRTOP}/${DIRLIB}'/libretoflev1";'>>build_so.txt @echo 'gSystem->Load(libYODA.str().c_str());'>>build_so.txt @echo 'libYODA.str("");' >>build_so.txt @echo 'libYODA << "'${DIRTOP}/${DIRLIB}'/libretoflev1_C_'${VER}'";'>>build_so.txt @echo 'gSystem->Load(libYODA.str().c_str());'>>build_so.txt @echo 'libYODA.str("");' >>build_so.txt @echo 'libYODA << "'${DIRTOP}/${DIRLIB}'/libopaclev1";'>>build_so.txt @echo 'gSystem->Load(libYODA.str().c_str());'>>build_so.txt @echo 'libYODA.str("");' >>build_so.txt @echo 'libYODA << "'${DIRTOP}/${DIRLIB}'/libopaclev1_C_'${VER}'";'>>build_so.txt @echo 'gSystem->Load(libYODA.str().c_str());'>>build_so.txt @echo 'libYODA.str("");' >>build_so.txt @echo 'libYODA << "'${DIRTOP}/${DIRLIB}'/libclaclev1";'>>build_so.txt @echo 'gSystem->Load(libYODA.str().c_str());'>>build_so.txt @echo 'libYODA.str("");' >>build_so.txt @echo 'libYODA << "'${DIRTOP}/${DIRLIB}'/libclaclev1_C_'${VER}'";'>>build_so.txt @echo 'gSystem->Load(libYODA.str().c_str());'>>build_so.txt @echo 'libYODA.str("");' >>build_so.txt @echo 'libYODA << "'${DIRTOP}/${DIRLIB}'/libfiaclev1";'>>build_so.txt @echo 'gSystem->Load(libYODA.str().c_str());'>>build_so.txt @echo 'libYODA.str("");' >>build_so.txt @echo 'libYODA << "'${DIRTOP}/${DIRLIB}'/libfiaclev1_C_'${VER}'";'>>build_so.txt @echo 'gSystem->Load(libYODA.str().c_str());'>>build_so.txt @echo '.L $(patsubst %_c_${VER}.so,%.c++O,$(@F))' >> build_so.txt @echo '.q' >> build_so.txt @root -l -b &>/dev/null < build_so.txt @mv -f ${DIRMACROS}/$(patsubst %_c_${VER}.so,%_c.so,$(@F)) ${DIRLIB}/$(@F) @rm -f build_so.txt ${CXXEXELIBS}: ${CXXEXEOBJS} @(${EGREEN} "Creating exec file: "${WHITE} "$@"; ${RESET}) @${CXX} ${CXXFLAGS} -o ${DIRBIN}/$@ ${DIRBIN}/$@.o -I${DIRINC} -I${PAM_INC} -I${PAM_YODA}/include/yoda/ ${DIRTOP}/${DIRLIB}/aclev1class_h_${VER}.so ${PAM_YODA}/lib/libyoda.so ${DIRTOP}/${DIRLIB}/libfiaclev1.so ${DIRTOP}/${DIRLIB}/libfiaclev1_C_${VER}.so ${DIRTOP}/${DIRLIB}/libopaclev1.so ${DIRTOP}/${DIRLIB}/libopaclev1_C_${VER}.so ${DIRTOP}/${DIRLIB}/libclaclev1.so ${DIRTOP}/${DIRLIB}/libclaclev1_C_${VER}.so ${DIRTOP}/${DIRLIB}/libretrklev1.so ${DIRTOP}/${DIRLIB}/libretrklev1_C_${VER}.so ${DIRTOP}/${DIRLIB}/liboptrklev1.so ${DIRTOP}/${DIRLIB}/liboptrklev1_C_${VER}.so ${DIRTOP}/${DIRLIB}/libcltrklev1.so ${DIRTOP}/${DIRLIB}/libcltrklev1_C_${VER}.so ${DIRTOP}/${DIRLIB}/libretoflev1.so ${DIRTOP}/${DIRLIB}/libretoflev1_C_${VER}.so ${DIRTOP}/${DIRLIB}/liboptoflev1.so ${DIRTOP}/${DIRLIB}/liboptoflev1_C_${VER}.so ${DIRTOP}/${DIRLIB}/libcltoflev1.so ${DIRTOP}/${DIRLIB}/libcltoflev1_C_${VER}.so ${DIRTOP}/${DIRLIB}/libretrklev2.so ${DIRTOP}/${DIRLIB}/libretrklev2_C_${VER}.so ${DIRTOP}/${DIRLIB}/liboptrklev2.so ${DIRTOP}/${DIRLIB}/liboptrklev2_C_${VER}.so ${DIRTOP}/${DIRLIB}/libcltrklev2.so ${DIRTOP}/${DIRLIB}/libcltrklev2_C_${VER}.so ${DIRTOP}/${DIRLIB}/$@_c_${VER}.so `root-config --cflags --glibs` @rm -f ${DIRSRC}/temp.cc # A small target to check environmental variables %_env: @${test_env} .PHONY: install installdoc installlib installmacros installinc .PHONY: clean depclean info mkbindir mklibdir testcern testpamenv test mkbindir: ${DIRBIN} ${DIRBIN}: @${test_and_mk} mklibdir: ${DIRLIB} ${DIRLIB}: @${test_and_mk} # Here what has to be deleted in clean target clean: TOBEDEL= ${FOBJS} ${FULLLIBS} ${DIRBIN}/${CXXEXELIBS} ${COBJS} ${CXXEXEOBJS} ${FULLLINKFLIBS} ${FULLLINKCLIBS} ${FULLMACROCLIBS} ${FULLLINKMACROCLIBS} clean: @${test_and_rm} distclean: clean distclean: TOBEDEL= ${DIRBIN} ${DIRLIB} distclean: @${test_and_rm} forceinstall: FORCE=-f forceinstall: install upgrade: FORCE=-u upgrade: install install: installlib installinc installmacros installcalib installdoc installexe installcmacro installlib: LINK=y installlib: TOBEMOVED= $(FULLLIBS:${DIRLIB}%=${PAM_LIB}%) installlib: ORIGIN=${DIRLIB} installlib: @${test_and_cp} installinc: TOBEMOVED= $(INCSRCS:${DIRINC}/%=${PAM_INC}/%) installinc: ORIGIN=${DIRINC} installinc: @${test_and_cp} installexe: TOBEMOVED= $(EXESRCS:${DIRBIN}/%=${PAM_BIN}/%) installexe: ORIGIN=${DIRBIN} installexe: @${test_and_cp} installcmacro: LINK=y installcmacro: TOBEMOVED= $(FULLMACROCLIBS:${DIRLIB}%=${PAM_LIB}%) installcmacro: ORIGIN=${DIRLIB} installcmacro: @${test_and_cp} installmacros: TOBEMOVED= $(MACROSSRCS:${DIRMACROS}/%=${PAM_MACROS}/%) installmacros: ORIGIN=${DIRMACROS} installmacros: @${test_and_cp} installcalib: TOBEMOVED= $(CALIBFILES:${DIRCALIB}/%=${PAM_CALIB}/%) installcalib: ORIGIN=${DIRCALIB} installcalib: @${test_and_cp} installdoc: TOBEMOVED= $(DOCFILES:${DIRDOC}/%=${PAM_DOC}/%) installdoc: ORIGIN=${DIRDOC} installdoc: @${test_and_cp} info: @echo " " @${EGREEN} "Infos for package :" ${WHITE} ${PACKAGE} @${EGREEN} " VERSION :" ${WHITE} ${VER} @${EGREEN} " EXECUTABLES :" ${WHITE} ${EXECUTABLES} @${EGREEN} " LIBS :" ${WHITE} ${LIBS} @${EGREEN} " DOCS :" ${WHITE} ${DOCS} @${EGREEN} " SRCS :" ${WHITE} ${SRCS} @${EGREEN} " MACROS :" ${WHITE} ${MACROS} @echo " " @${RESET} test: testpamenv testcernlib testmysql testcalocommon testpamenv: ${PAM_ENV} testcernlib: cernlib root-config testmysql: mysql_config testcalocommon: '${PAM_BIN}'/calocommon @if [ ${INSTCOMVER} -lt ${COMPCOMVER} ]; then ${ERED} " ERROR: root2paw ${VER} requires package CALOCOMMON version ${COMMONVER} "; ${RESET} ; exit 1; fi mysql_config: OPT=--cflags mysql_config: @$(test_cmd) '${PAM_BIN}'/calocommon: @$(test_cmd) cernlib: @${test_cmd} root-config: OPT=--cflags root-config: @${test_cmd} # Here follows some usefull macros define test_and_cp wd=`pwd`;\ for i in ${TOBEMOVED} ; do \ wv=$${i##/*/}; \ dest=$${i/$${wv}/}; \ ${EGREEN} "Testing for :" ${WHITE} "$${i}" ; ${RESET}; \ if [ ! "${FORCE}" ] ; then \ if [ ! -f $${i} ]; then \ ${EGREEN} "Copying : "${WHITE} ${ORIGIN}/$${i##/*/} ;\ ${EGREEN} " to: "${WHITE} $${i} ; ${RESET}; \ cp ${ORIGIN}/$${i##/*/} $${i}; \ else \ ${ERED} "File already exist !!!! Please delete it " ${WHITE}; ${RESET}; \ fi;\ else \ if [ "${FORCE}" == "-u" ] ; then \ if [ "`basename $${i}`" != "`basename $${i} _${VER}.so`" ]; then \ ${EYELLOW} "Removing: "${WHITE} ${PAM_LIB}/`basename $${i} _${VER}.so`_v*r*.so; ${RESET}; \ rm -f ${PAM_LIB}/`basename $${i} _${VER}.so`_v*r*.so ; \ ${EGREEN} "Copying : "${WHITE} ${ORIGIN}/$${i##/*/} ;\ ${EGREEN} " to: "${WHITE} $${i} ; ${RESET}; \ cp ${ORIGIN}/$${i##/*/} $${i}; \ else \ ${EYELLOW} " Forcing copy: "${WHITE} ${ORIGIN}/$${i##/*/} ;\ ${EYELLOW} " to: "${WHITE} $${i} ; ${RESET}; \ cp -f ${ORIGIN}/$${i##/*/} $${i}; \ fi; \ else \ ${EYELLOW} " Forcing copy: "${WHITE} ${ORIGIN}/$${i##/*/} ;\ ${EYELLOW} " to: "${WHITE} $${i} ; ${RESET}; \ cp ${FORCE} ${ORIGIN}/$${i##/*/} $${i}; \ fi;\ fi ;\ if [ ! -z ${LINK} ] ; then \ ${EGREEN} "Creating symlink from : "${WHITE} $${wv/_${VER}/} ;\ ${EGREEN} " to : "${WHITE} $${i##/*/} ; ${RESET}; \ cd $${dest}; \ ln -sf $${wv} $${wv/_${VER}/}; \ cd $${wd}; \ fi \ done endef define test_and_mk ${EGREEN} "Testing for :" ${WHITE} "$@"; ${RESET} test -d "$@" || \ (${EGREEN} "Creating : "${WHITE} "$@"; ${RESET}; mkdir -p $@) endef define test_env ${EGREEN} "Testing for env:" ${WHITE} $(patsubst %_env,%,$@); ${RESET} printenv $(patsubst %_env,%,$@) 1>/dev/null || \ (${ERED} "ERROR, variable : "${WHITE} $(patsubst %_env,%,$@) \ ${RED} "not defined !!! Check your env. settings"; \ ${RESET}; exit 1) ${EGREEN} " Defined:" ${WHITE} $${$(patsubst %_env,%,$@)}; ${RESET} endef define test_cmd ${EGREEN} "Testing for cmd:" ${WHITE} $@ ${OPT}; ${RESET} $@ ${OPT} 1>/dev/null 2>&1 || \ (${ERED} "ERROR, command : "${WHITE} $@ ${OPT}\ ${RED} "not found !!! Check your installation"; \ ${RESET}; exit 1) ${EGREEN} " Present:" ${WHITE} $@ ${OPT}; ${RESET} endef define test_and_rm for i in ${TOBEDEL}; do \ test -d $${i} || (${ERED} "Removing file :"${WHITE} $${i}; ${RESET}; \ rm -f $${i} ); \ test ! -d $${i} || (${ERED} "Removing dir :"${WHITE} $${i}; ${RESET}; \ rm -rf $${i} ); \ done endef