#!/bin/sh # # Configuration script, to be run before compilation # # Author: M. Kirsanov if [ x$BASH_VERSION = x ]; then echo warning: you are not using bash shell on which this script is tested fi # # User-changeable part ------------------------------- # #LCG platform. Can be needed if external libraries are specified if [ x$MYLCGPLATFORM = x ]; then export MYLCGPLATFORM=slc4_ia32_gcc34 fi # Defaults export COMPMODE=OPT export SHAREDLIBS=no for arg in $* ; do if [ "x$arg" = "x--enable-debug" ] ; then COMPMODE=DBG elif [ "x$arg" = "x--enable-shared" ] ; then SHAREDLIBS=yes elif [ "x$arg" = "x--enable-64bits" ] ; then ENABLE64=-m64 elif [ "x$arg" = "x--help" ] ; then echo "Usage: ./configure [options] , where options are:" echo "--help : prints this help" echo "--enable-debug : turns on debugging flags and turns off optimization" echo "--enable-shared : turns on shared library creation (default no)" echo "--enable-64bits : turns on 64 bits compilation flags" echo "--lcgplatform=name : LCG platform name, default is slc4_ia32_gcc34" echo "--with-hepmc=path : path to HepMC library to build interface (default is not build)" echo "--with-hepmcversion=v : HepMC version (simplified alternative when using CERN AFS LCG external, e.g. =2.04.00)" echo echo "Use the following environment variables to force the configuration process or add flags:" echo "USRCXXFLAGS - to add flags. Use this variable to add -fPIC to the compilation flags for the static libraries" echo "USRLDFLAGSSHARED - to add flags to the shared library build command" echo "USRSHAREDSUFFIX - to force shared libraries suffix to be like this (default on MacOSX is dylib)" exit elif [ x`echo x${arg} | grep "="` != x ] ; then option=`echo ${arg} | awk -F = '{print $1}'` value=`echo ${arg} | awk -F = '{print $2}'` if [ "x${option}" = "x--lcgplatform" ] ; then MYLCGPLATFORM=${value} elif [ "x${option}" = "x--with-hepmcversion" ] ; then HEPMCVERSION=${value} elif [ "x${option}" = "x--with-hepmc" ] ; then HEPMCLOCATION=${value} else echo "${arg}: wrong option. Ignored." >&2 fi fi done echo compilation mode is $COMPMODE echo sharedlibs = $SHAREDLIBS # Environment variables for building HepMC interface library. Note that # the HepMC interface library is used by the examples main31, main32. # Attention: if you have already run these examples and you change HepMC # version you should reset your LD_LIBRARY_PATH # The default values here correspond to CERN AFS lcg external # if [ "x${HEPMCVERSION}" != "x" ] ; then if [ "x${HEPMCLOCATION}" = "x" ] ; then export HEPMCLOCATION=/afs/cern.ch/sw/lcg/external/HepMC/${HEPMCVERSION}/${MYLCGPLATFORM} fi fi # If you want to assign these variables by hand: # #export HEPMCVERSION=2.04.00 #export HEPMCLOCATION=/afs/cern.ch/sw/lcg/external/HepMC/${HEPMCVERSION}/${MYLCGPLATFORM} if [ "x${HEPMCVERSION}" = "x" ] ; then if [ "x${HEPMCLOCATION}" != "x" ] ; then # try to find out which HepMC version test1=`echo $HEPMCLOCATION | grep \/1.` test2=`echo $HEPMCLOCATION | grep \/2.` echo $test1 echo $test2 if [ "x${test1}" != "x" ] ; then echo "Warning: HepMC 1 cannot be used anymore; Please use HepMC 2" echo " The interface will not be built" export HEPMCLOCATION= fi if [ "x${test2}" != "x" ] ; then export HEPMCVERSION=2.`echo $HEPMCLOCATION | awk -F \/2. '{print $2}' | awk -F \/ '{print $1}'` fi fi fi if [ "x${HEPMCVERSION}" != "x" ] ; then export HEPMCMAINVERSION=`echo ${HEPMCVERSION} | awk -F . '{print$1}'` if [ ${HEPMCMAINVERSION} = 1 ] ; then echo "Warning: HepMC 1 cannot be used anymore; Please use HepMC 2" echo " The interface will not be built" export HEPMCLOCATION= fi fi if [ "x${HEPMCLOCATION}" != "x" ] ; then if [ "x${HEPMCVERSION}" = "x" ] ; then echo "Warning: hepmc specifyed, but cannot find out which HepMC version" echo "Warning: if you specify HepMC 1 the compilation of interface will fail" fi fi # # User-changeable part, experts ----------------------------- # # export FFLAGS_OPT="-O2 -Wuninitialized" # -Wuninitialized outputs many irrelevant warnings and therefore obscurs export FFLAGS_OPT="-O2 -fbounds-check" export FFLAGS_DBG=-g export CFLAGS_OPT="-O2 -fbounds-check" export CFLAGS_DBG=-g export CXXFLAGS_OPT="-O2 -ansi -pedantic -W -Wall -Wshadow -fbounds-check ${ENABLE64}" export CXXFLAGS_DBG="-g -ansi -pedantic -W -Wall -Wshadow -fbounds-check ${ENABLE64}" # # Find platform. # export ARCH0="`uname`" export ARCH=${ARCH0} export theGcc=`g++ --version | head -n 1 | awk '{print$3}' | awk -F . '{print $1}'` if [ ${theGcc} = 4 ]; then export ARCH=${ARCH}-gcc4 fi echo Platform is $ARCH #default platform settings: export FC=g77 export CC=gcc export FFLAGS="${FFLAGS_OPT}" export CFLAGS="${CFLAGS_OPT}" export CXXFLAGS="${CXXFLAGS_OPT}" export FLIBS="-lfrtbegin -lg2c" if [ ${COMPMODE} = OPT ]; then export FFLAGS="${FFLAGS_OPT}" export CFLAGS="${CFLAGS_OPT}" export CXXFLAGS="${CXXFLAGS_OPT}" fi if [ ${COMPMODE} = DBG ]; then export FFLAGS="${FFLAGS_DBG}" export CFLAGS="${CFLAGS_DBG}" export CXXFLAGS="${CXXFLAGS_DBG}" fi LDFLAGSSHARED="${CXXFLAGS} -pthread -fPIC -shared" LDFLAGLIBNAME="-Wl,-soname" SHAREDSUFFIX=so if [ $ARCH = Linux ]; then export FC=g77 export FFLAGS="${FFLAGS_OPT} -Wno-globals" export CFLAGS="${CFLAGS_OPT}" export CXXFLAGS="${CXXFLAGS_OPT}" export FLIBS="-lfrtbegin -lg2c" if [ ${COMPMODE} = OPT ]; then export FFLAGS="${FFLAGS_OPT}" export CFLAGS="${CFLAGS_OPT}" export CXXFLAGS="${CXXFLAGS_OPT}" fi if [ ${COMPMODE} = DBG ]; then export FFLAGS="${FFLAGS_DBG} -Wno-globals" export CFLAGS="${CFLAGS_DBG}" export CXXFLAGS="${CXXFLAGS_DBG}" fi LDFLAGSSHARED="${CXXFLAGS} -pthread -fPIC -shared" LDFLAGLIBNAME="-Wl,-soname" SHAREDSUFFIX=so fi # Linux platform with gcc4: new Fortran90 compiler. if [ $ARCH = Linux-gcc4 ]; then export FC=gfortran export FFLAGS="${FFLAGS_OPT}" export CFLAGS="${CFLAGS_OPT}" export CXXFLAGS="${CXXFLAGS_OPT}" export FLIBS="-lgfortran -lgfortranbegin" if [ ${COMPMODE} = OPT ]; then export FFLAGS="${FFLAGS_OPT}" export CFLAGS="${CFLAGS_OPT}" export CXXFLAGS="${CXXFLAGS_OPT}" fi if [ ${COMPMODE} = DBG ]; then export FFLAGS="${FFLAGS_DBG}" export CFLAGS="${CFLAGS_DBG}" export CXXFLAGS="${CXXFLAGS_DBG}" fi LDFLAGSSHARED="${CXXFLAGS} -pthread -fPIC -shared" LDFLAGLIBNAME="-Wl,-soname" SHAREDSUFFIX=so fi # Mac-OSX with gcc4 if [ $ARCH = Darwin-gcc4 ]; then export FC=gfortran export FFLAGS="${FFLAGS_OPT}" export CFLAGS="${CFLAGS_OPT}" export CXXFLAGS="${CXXFLAGS_OPT}" export FLIBS="-lgfortran" if [ ${COMPMODE} = OPT ]; then export FFLAGS="${FFLAGS_OPT}" export CFLAGS="${CFLAGS_OPT}" export CXXFLAGS="${CXXFLAGS_OPT}" fi if [ ${COMPMODE} = DBG ]; then export FFLAGS="${FFLAGS_DBG}" export CFLAGS="${CFLAGS_DBG}" export CXXFLAGS="${CXXFLAGS_DBG}" fi LDFLAGSSHARED="${CXXFLAGS} -dynamiclib -single_module -flat_namespace -undefined suppress" LDFLAGLIBNAME="-Wl,-dylib_install_name" SHAREDSUFFIX=dylib fi # Mac-OSX with gcc3; is not tested if [ $ARCH = Darwin ]; then export FC=g77 export FFLAGS="${FFLAGS_OPT}" export CFLAGS="${CFLAGS_OPT}" export CXXFLAGS="${CXXFLAGS_OPT}" export FLIBS="-lfrtbegin -lg2c" if [ ${COMPMODE} = OPT ]; then export FFLAGS="${FFLAGS_OPT}" export CFLAGS="${CFLAGS_OPT}" export CXXFLAGS="${CXXFLAGS_OPT}" fi if [ ${COMPMODE} = DBG ]; then export FFLAGS="${FFLAGS_DBG}" export CFLAGS="${CFLAGS_DBG}" export CXXFLAGS="${CXXFLAGS_DBG}" fi LDFLAGSSHARED="${CXXFLAGS} -dynamiclib -single_module -flat_namespace -undefined suppress" LDFLAGLIBNAME="-Wl,-dylib_install_name" SHAREDSUFFIX=dylib fi CXXFLAGS="${CXXFLAGS} $USRCXXFLAGS" LDFLAGSSHARED="${LDFLAGSSHARED} $USRLDFLAGSSHARED" if [ "x${USRSHAREDSUFFIX}" != "x" ] ; then SHAREDSUFFIX="${USRSHAREDSUFFIX}" fi #Platform & opt/dbg - independent flags and variables: # # End of the user-changeable part --------------------------- # # Checks # if [ $?HEPMCLOCATION ]; then if [ x${HEPMCLOCATION} != x ]; then if [ ! -d ${HEPMCLOCATION}/include ]; then echo "Warning: bad HEPMCLOCATION: directory ${HEPMCLOCATION}/include does not exist" echo " The interface will not be built" export HEPMCLOCATION= fi if [ ! -d ${HEPMCLOCATION}/lib ]; then echo "Warning: bad HEPMCLOCATION: directory ${HEPMCLOCATION}/lib does not exist" echo " The interface will not be built" export HEPMCLOCATION= fi fi fi rm -f config.mk echo SHELL = /bin/sh > config.mk echo ARCH = ${ARCH} >> config.mk echo MYLCGPLATFORM = ${MYLCGPLATFORM} >> config.mk echo SHAREDLIBS = ${SHAREDLIBS} >> config.mk echo FC = ${FC} >> config.mk echo CC = ${CC} >> config.mk echo FFLAGS = ${FFLAGS} >> config.mk echo CFLAGS = ${CFLAGS} >> config.mk echo CXXFLAGS = ${CXXFLAGS} >> config.mk echo FLIBS = ${FLIBS} >> config.mk echo LDFLAGSSHARED = ${LDFLAGSSHARED} >> config.mk echo LDFLAGLIBNAME = ${LDFLAGLIBNAME} >> config.mk echo SHAREDSUFFIX = ${SHAREDSUFFIX} >> config.mk # if [ x${HEPMCLOCATION} != x ]; then if [ x${HEPMCVERSION} != x ]; then echo HEPMCVERSION = ${HEPMCVERSION} >> config.mk fi echo HEPMCLOCATION = ${HEPMCLOCATION} >> config.mk fi # # # rm -f examples/config.sh rm -f examples/config.csh if [ x${HEPMCLOCATION} != x ]; then if [ $ARCH0 != Darwin ]; then echo "#!/bin/csh" > examples/config.csh echo 'if( ! $?LD_LIBRARY_PATH ) then' >> examples/config.csh echo " setenv LD_LIBRARY_PATH ${HEPMCLOCATION}/lib" >> examples/config.csh echo "else" >> examples/config.csh echo " setenv LD_LIBRARY_PATH" '${LD_LIBRARY_PATH}'":${HEPMCLOCATION}/lib" >> examples/config.csh echo "endif" >> examples/config.csh echo "#!/bin/sh" > examples/config.sh echo 'if [ ! $?LD_LIBRARY_PATH ]; then' >> examples/config.sh echo " export LD_LIBRARY_PATH=${HEPMCLOCATION}/lib" >> examples/config.sh echo fi >> examples/config.sh echo 'if [ $?LD_LIBRARY_PATH ]; then' >> examples/config.sh echo " export LD_LIBRARY_PATH="'${LD_LIBRARY_PATH}'":${HEPMCLOCATION}/lib" >> examples/config.sh echo fi >> examples/config.sh else echo "#!/bin/csh" > examples/config.csh echo 'if( ! $?DYLD_LIBRARY_PATH ) then' >> examples/config.csh echo " setenv DYLD_LIBRARY_PATH ${HEPMCLOCATION}/lib" >> examples/config.csh echo "else" >> examples/config.csh echo " setenv DYLD_LIBRARY_PATH" '${DYLD_LIBRARY_PATH}'":${HEPMCLOCATION}/lib" >> examples/config.csh echo "endif" >> examples/config.csh echo "#!/bin/sh" > examples/config.sh echo 'if [ ! $?DYLD_LIBRARY_PATH ]; then' >> examples/config.sh echo " export DYLD_LIBRARY_PATH=${HEPMCLOCATION}/lib" >> examples/config.sh echo fi >> examples/config.sh echo 'if [ $?DYLD_LIBRARY_PATH ]; then' >> examples/config.sh echo " export DYLD_LIBRARY_PATH="'${DYLD_LIBRARY_PATH}'":${HEPMCLOCATION}/lib" >> examples/config.sh echo fi >> examples/config.sh fi fi