#!/bin/bash # # This configure script is hand-generated, not auto-generated. # It creates the file kaldi.mk, which is %included by the Makefiles # in the subdirectories. # The file kaldi.mk is editable by hand-- for example, you may want to # remove the options -g -O0 -DKALDI_PARANOID, or edit the # -DKALDI_DOUBLE_PRECISION option (to be 1 not 0), # Example command lines: # ./configure # ./configure --shared ## shared libraries. # ./configure --mkl-root=/opt/intel/mkl # ./configure --mkl-root=/opt/intel/mkl --threaded-math=yes # ./configure --openblas-root=../tools/OpenBLAS/install # before doing # # this, cd to ../tools and type "make openblas". Note: # # this is not working correctly on all platforms, do "make test" # # and look out for segmentation faults. #This should be incremented after every significant change of the configure script #I.e. after each change that affects the kaldi.mk or the build system as whole CONFIGURE_VERSION=2 function rel2abs { if [ ! -z "$1" ]; then local retval=`cd $1 2>/dev/null && pwd || exit 1` echo $retval fi } function read_dirname { local dir_name=`expr "X$1" : '[^=]*=\(.*\)'`; local retval=`rel2abs $dir_name` [ -z $retval ] && echo "Bad option '$1': no such directory" && exit 1; echo $retval } function is_set { local myvar=${1:-notset} if [ "$myvar" == "notset" ]; then return 1 else return 0 fi } ## First do some checks. These verify that all the things are ## here that should be here. if [ "`basename $PWD`" != "src" ]; then echo 'You must run "configure" from the src/ directory.' exit 1 fi ## Default locations for FST and linear algebra libraries. MATHLIB='ATLAS' ATLASROOT=`rel2abs ../tools/ATLAS/` FSTROOT=`rel2abs ../tools/openfst` # Avoid using any variables that are set in the shell. unset MKLROOT unset CLAPACKROOT unset OPENBLASROOT unset MKLLIBDIR function usage { echo 'Usage: ./configure [--static|--shared] [--threaded-atlas={yes|no}] [--atlas-root=ATLASROOT] [--fst-root=FSTROOT] [--openblas-root=OPENBLASROOOT] [--clapack-root=CLAPACKROOT] [--mkl-root=MKLROOT] [--mkl-libdir=MKLLIBDIR] [--omp-libdir=OMPDIR] [--static-fst={yes|no}] [--static-math={yes|no}] [--threaded-math={yes|no}] [--mathlib=ATLAS|MKL|CLAPACK|OPENBLAS] [--use-cuda={yes|no}] [--cudatk-dir=CUDATKDIR]'; } threaded_atlas=false # By default, use the un-threaded version of ATLAS. threaded_math=${threaded_atlas} static_math=false static_fst=false use_cuda=true dynamic_kaldi=false cmd_line="$0 $@" # Save the command line to include in kaldi.mk while [ $# -gt 0 ]; do case "$1" in --help) usage; exit 0 ;; --version) echo $CONFIGURE_VERSION; exit 0 ;; --static) # FIXME depends on order of options first--static/--shared then --static-math -> it will override it dynamic_kaldi=false; static_math=true; static_fst=true; shift ;; --shared) dynamic_kaldi=true; static_math=false; static_fst=false; shift ;; --atlas-root=*) ATLASROOT=`read_dirname $1`; shift ;; --threaded-atlas=yes) threaded_atlas=true; shift ;; --threaded-atlas=no) threaded_atlas=false; shift ;; --threaded-math=yes) threaded_atlas=true; threaded_math=true; shift ;; --threaded-math=no) threaded_atlas=false; threaded_math=false; shift ;; --use-cuda=yes) use_cuda=true; shift ;; --use-cuda=no) use_cuda=false; shift ;; --static-math=yes) static_math=true; shift ;; --static-math=no) static_math=false; shift ;; --static-fst=yes) static_fst=true; shift ;; --static-fst=no) static_fst=false; shift ;; --fst-root=*) FSTROOT=`read_dirname $1`; shift ;; --clapack-root=*) CLAPACKROOT=`read_dirname $1`; shift ;; --openblas-root=*) OPENBLASROOT=`read_dirname $1`; shift ;; --mkl-root=*) MKLROOT=`read_dirname $1`; shift ;; --mkl-libdir=*) MKLLIBDIR=`read_dirname $1`; shift ;; --omp-libdir=*) OMPLIBDIR=`read_dirname $1`; shift ;; --mathlib=*) MATHLIB=`expr "X$1" : '[^=]*=\(.*\)'`; shift ;; --cudatk-dir=*) CUDATKDIR=`read_dirname $1`; shift ;; #CUDA is used in src/cudamatrix and src/nnet{,bin} only *) echo "Unknown argument: $1, exiting"; usage; exit 1 ;; esac done function failure { echo "***configure failed: $* ***" >&2 if [ -f kaldi.mk ]; then rm kaldi.mk; fi exit 1; } function check_exists { if [ ! -f $1 ]; then failure "$1 not found."; fi } function linux_configure_mkllibdir { local mklroot=$1 if [ -d $mklroot/lib/em64t ]; then echo $mklroot/lib/em64t elif [ -d $mklroot/lib/intel64 ]; then echo $mklroot/lib/intel64 else return 1; fi } function linux_configure_mkl_libraries { local mkllibdir=$1 local static=$2 local threaded=$3 #these lines were generated using the Intel Link Line Advisor 2.2 local threaded_libs="mkl_intel_lp64 mkl_intel_thread mkl_core" local sequential_libs="mkl_intel_lp64 mkl_sequential mkl_core" if ! $static && $threaded ; then for file in $threaded_libs; do local libfile=$mkllibdir/lib$file.so check_exists $libfile done echo "-L$mkllibdir -Wl,-rpath=$mkllibdir -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 -lpthread -lm" elif ! $static && ! $threaded ; then for file in $sequential_libs; do local libfile=$mkllibdir/lib$file.so check_exists $libfile done echo "-L$mkllibdir -Wl,-rpath=$mkllibdir -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -liomp5 -lpthread -lm" elif $static && $threaded ; then local linkline="" test -f "$mkllibdir/libmkl_solver_lp64.a" && linkline="$linkline $mkllibdir/libmkl_solver_lp64.a" linkline="$linkline -Wl,--start-group" for file in $threaded_libs; do local libfile=$mkllibdir/lib$file.a check_exists $libfile linkline="$linkline $libfile" done #linkline="$linkline -Wl,--end-group -liomp5 -lpthread -lm " linkline="$linkline -Wl,--end-group " echo $linkline elif $static && ! $threaded ; then local linkline="" test -f "$mkllibdir/libmkl_solver_lp64_sequential.a" && linkline="$linkline $mkllibdir/libmkl_solver_lp64_sequential.a" linkline="$linkline -Wl,--start-group" for file in $sequential_libs; do local libfile=$mkllibdir/lib$file.a check_exists $libfile linkline="$linkline $libfile" done #linkline="$linkline -Wl,--end-group -liomp5 -lpthread -lm " linkline="$linkline -Wl,--end-group " echo $linkline else return 1; fi } function linux_configure_mkl_includes { test -d $1/include && echo "$1/include" && return; test -d $2/../../include && echo "$2/../../include" && return; failure "Could not find the MKL include directory" } function check_library { local libpath=$1 local libname=$2 local libext=$3 local full_libname="$libpath/$libname.$libext" ##echo "Testing $full_libname" >&2 test -f "$full_libname" && return ; return 1 } function linux_configure_omplibdir { local mklroot=$1 local mkllibdir=$2 local libexts=$3 ##First we try to use the library in the same directory ##where the mkl libraries reside ##Afterwards, just try some possibilities for different MKL layouts for libext in $libexts; do echo "Testing $libext from [$libexts] " >&2 check_library $mkllibdir "libiomp5" $libext \ && echo `readlink -f $mkllibdir` && return local testdir=`(cd $mklroot; cd ..; cd lib/intel64;pwd)` test -d $testdir && check_library $testdir "libiomp5" $libext && echo `readlink -f $testdir` && return; local testdir=`(cd $mklroot; cd ..; cd lib/em64t;pwd)` test -d $testdir && check_library $testdir "libiomp5" $libext && echo `readlink -f $testdir` && return; local testdir=`(cd $mkllibdir; cd ../../..; cd lib/intel64;pwd)` test -d $testdir && check_library $testdir "libiomp5" $libext && echo `readlink -f $testdir` && return; local testdir=`(cd $mklroot; cd ../../..; cd lib/em64t;pwd)` test -d $testdir && check_library $testdir "libiomp5" $libext && echo `readlink -f $testdir` && return; done #failure "Could not find the library iomp5, use the configure switch --omp-libdir" return 1 } #Check if at least one of these variables is set #If yes, we want to switch to using the MKL is_set $MKLLIBDIR && echo "Force-configuring KALDI to use MKL" && export MATHLIB="MKL" is_set $MKLROOT && echo "Force-configuring KALDI to use MKL"&& export MATHLIB="MKL" is_set $CLAPACKROOT && echo "Force-configuring KALDI to use CLAPACK"&& export MATHLIB="CLAPACK" is_set $OPENBLASROOT && echo "Force-configuring KALDI to use OPENBLAS"&& export MATHLIB="OPENBLAS" ## ##CUDA is used in src/cudamatrix and src/nnet{,bin} only. ##It is used to accelerate the neural network training, ##the rest of kaldi is running on CPUs. ## function linux_configure_cuda { #check for CUDA toolkit in the system if [ ! $CUDATKDIR ]; then for base in /usr/local/share/cuda /usr/local/cuda /pkgs_local/cuda-3.2/ /opt/nvidia_cuda/cuda-5.0/ /usr/; do if [ -f $base/bin/nvcc ]; then CUDATKDIR=$base fi done fi if [ $CUDATKDIR ]; then if [ ! -f $CUDATKDIR/bin/nvcc ]; then failure "Cannnot find nvcc in CUDATKDIR=$CUDATKDIR" fi echo "Using CUDA toolkit $CUDATKDIR (nvcc compiler and runtime libraries)" echo >> kaldi.mk echo "#Next section enables CUDA for compilation" >> kaldi.mk echo CUDA = true >> kaldi.mk echo CUDATKDIR = $CUDATKDIR >> kaldi.mk if [ "`uname -m`" == "x86_64" ]; then cat makefiles/linux_x86_64_cuda.mk >> kaldi.mk else cat makefiles/linux_cuda.mk >> kaldi.mk fi else echo "CUDA will not be used! If you have already installed cuda drivers and cuda toolkit, try using --cudatk-dir=... option. Note: this is only relevant for neural net experiments" fi } function fix_cxx_flag { CXXCOMPILER=`grep "CXX = " kaldi.mk | awk '{print $3}'` if [ $CXXCOMPILER=="g++" ]; then $CXXCOMPILER -dumpversion | \ awk '{if(NR==1 && $1<"4.4") print "sed \"s/-Wno-unused-local-typedefs//g\" \ kaldi.mk > tmpf; mv tmpf kaldi.mk; "}' | sh - fi } function linux_atlas_failure { # function we use when we couldn't find # ATLAS libs. echo ATLASINC = [somewhere]/include >> kaldi.mk echo ATLASLIBS = [somewhere]/liblapack.a [somewhere]/libcblas.a [somewhere]/libatlas.a [somewhere]/libf77blas.a $ATLASLIBDIR >> kaldi.mk cat makefiles/linux_atlas.mk >> kaldi.mk fix_cxx_flag echo "** $* ***" echo "** ERROR **" echo "**Configure cannot proceed automatically, but by editing kaldi.mk" echo "** you may be able to proceed (replace [somewhere] with a directory);" echo "** or install the ATLAS package on your machine (if you are system " echo " administrator, you can do it easily by searching the atlas packages " echo " with commands like 'apt-cache search libatlas' or 'yum search atlas'," echo " and install the packages with commands 'apt-get install' or 'yum install') " echo " e.g. 'apt-get install libatlas-dev libatlas-base-dev';" echo "** or try going to ../tools and running install_atlas.sh, and running" echo " this script (configure) again." exit 1; } function linux_check_static { # will exit with success if $dir seems to contain ATLAS libraries with # right architecture (compatible with default "nm") echo "int main(void) { return 0; }" > test_linking.cc; if [ -f $dir/libatlas.a ]; then # candidate... # Note: on the next line, the variable assignment # LANG=en_US should apply just to the program called on that line. if LANG=en_US gcc -o test_linking test_linking.cc -u ATL_flushcache $dir/libatlas.a 2>&1 | grep -i "incompatible" >/dev/null; then echo "Directory $dir may contain ATLAS libraries but seems to be wrong architecture"; rm test_linking test_linking.cc 2>/dev/null return 1; fi rm test_linking test_linking.cc 2>/dev/null return 0; else rm test_linking.cc return 1; fi } function linux_configure_debian_ubuntu { m=$1 ATLASLIBS="/usr/lib$m/atlas-base/libatlas.so.3gf /usr/lib$m/atlas-base/libf77blas.so.3gf /usr/lib$m/atlas-base/libcblas.so.3gf /usr/lib$m/atlas-base/liblapack_atlas.so.3gf" for f in $ATLASLIBS; do [ ! -f $f ] && return 1; done echo ATLASINC = $ATLASROOT/include >> kaldi.mk echo ATLASLIBS = $ATLASLIBS >> kaldi.mk cat makefiles/linux_atlas.mk >> kaldi.mk fix_cxx_flag echo "Successfully configured for Debian/Ubuntu Linux [dynamic libraries] with ATLASLIBS =$ATLASLIBS" $use_cuda && linux_configure_cuda exit 0; } function linux_configure_debian7 { ATLASLIBS="/usr/lib/atlas-base/libatlas.so.3.0 /usr/lib/atlas-base/libf77blas.so.3.0 /usr/lib/atlas-base/libcblas.so.3 /usr/lib/atlas-base/liblapack_atlas.so.3" for f in $ATLASLIBS; do [ ! -f $f ] && return 1; done libdir=$(dirname $(echo $ATLASLIBS | awk '{print $1}')) [ -z "$libdir" ] && echo "Error getting libdir in linux_configure_debian7" && exit 1; echo ATLASINC = $ATLASROOT/include >> kaldi.mk echo ATLASLIBS = $ATLASLIBS -Wl,-rpath=$libdir >> kaldi.mk echo cat makefiles/linux_atlas.mk >> kaldi.mk fix_cxx_flag echo "Successfully configured for Debian 7 [dynamic libraries] with ATLASLIBS =$ATLASLIBS" $use_cuda && linux_configure_cuda exit 0; } function linux_configure_static { if $threaded_atlas; then pt=pt; else pt=""; fi if [ -z $ATLASLIBDIR ]; then # Note: it'll pick up the last one below. for dir in /usr{,/local}/lib{64,}{,/atlas,/atlas-sse2,/atlas-sse3} \ /usr/local/atlas/lib{,64} `pwd`/../tools/ATLAS/build/install/lib/ $ATLASROOT/lib; do linux_check_static && ATLASLIBDIR=$dir done if [ -z $ATLASLIBDIR ]; then # Note: it'll pick up the last one below. echo "Could not find libatlas.a in any of the generic-Linux places, but we'll try other stuff..." return 1; fi elif [ ! -f $ATLASLIBDIR/libatlas.a ]; then echo "Could not find libatlas.a in '$ATLASLIBDIR'" return 1; fi echo "Looking for ATLAS libs in $ATLASLIBDIR" ATLASLIBS= # The Lapack part of ATLAS seems to appear under various different names.. but it # should always have symbols like ATL_cgetrf defined, so we test for this, # for all the names we have encountered. for libname in liblapack liblapack_atlas libclapack; do if [ -f $ATLASLIBDIR/${libname}.a -a "$ATLASLIBS" == "" ]; then if nm $ATLASLIBDIR/${libname}.a | grep ATL_cgetrf >/dev/null; then ATLASLIBS=$ATLASLIBDIR/${libname}.a echo "Using library $ATLASLIBS as ATLAS's CLAPACK library." fi fi done if [ "$ATLASLIBS" == "" ]; then echo Could not find any libraries $ATLASLIBDIR/{liblapack,liblapack_atlas,libclapack} that seem to be an ATLAS CLAPACK library. return ; fi for x in lib${pt}cblas.a libatlas.a lib${pt}f77blas.a; do if [ ! -f $ATLASLIBDIR/$x ]; then echo "Configuring static ATLAS libraries failed: Could not find library $x in directory $ATLASLIBDIR" return 1; fi ATLASLIBS="$ATLASLIBS $ATLASLIBDIR/$x" done if $threaded_atlas; then ATLASLIBS="$ATLASLIBS"; fi echo ATLASINC = $ATLASROOT/include >> kaldi.mk echo ATLASLIBS = $ATLASLIBS >> kaldi.mk cat makefiles/linux_atlas.mk >> kaldi.mk fix_cxx_flag $use_cuda && linux_configure_cuda echo "Successfully configured for Linux [static libraries] with ATLASLIBS =$ATLASLIBS" exit 0; } function linux_check_dynamic { # will exit with success if $dir seems to contain ATLAS libraries with # right architecture (compatible with default "nm") if [ -f $dir/libatlas.so ]; then # candidate... if nm --dynamic $dir/libatlas.so 2>&1 | grep "File format not recognized" >/dev/null; then echo "Directory $dir may contain dynamic ATLAS libraries but seems to be wrong architecture"; return 1; fi echo "Atlas found in $dir"; return 0; else echo "... no libatlas.so in $dir"; return 1; fi } function linux_configure_dynamic { if $threaded_atlas; then pt=pt; else pt=""; fi if [ -z $ATLASLIBDIR ]; then # Note: it'll pick up the last one below. for dir in /usr{,/local}/lib{,64}{,/atlas,/atlas-sse2,/atlas-sse3} \ `pwd`/../tools/ATLAS/build/install/lib/ $ATLASROOT/lib; do linux_check_dynamic && ATLASLIBDIR=$dir done if [ -z $ATLASLIBDIR ]; then echo "Could not find libatlas.so in any of the obvious places, will most likely try static:" return 1; fi elif [ ! -f $ATLASLIBDIR/libatlas.so ]; then echo "Could not find libatlas.so in '$ATLASLIBDIR'" return 1; fi echo "Looking for ATLAS libs in $ATLASLIBDIR" ATLASLIBS= # The Lapack part of ATLAS seems to appear under various different names.. but it # should always have symbols like ATL_cgetrf defined, so we test for this, # for all the names we have encountered. for libname in lapack lapack_atlas clapack; do if [ -f $ATLASLIBDIR/lib${libname}.so -a "$ATLASLIBS" == "" ]; then if nm --dynamic $ATLASLIBDIR/lib${libname}.so | grep ATL_cgetrf >/dev/null; then ATLASLIBS="-L$ATLASLIBDIR -l${libname}" echo "Using library $ATLASLIBS as ATLAS's CLAPACK library." fi fi done if [ "$ATLASLIBS" == "" ]; then echo Could not find any libraries $ATLASLIBDIR/{liblapack,liblapack_atlas,libclapack} that seem to be an ATLAS CLAPACK library. return 1; fi for x in ${pt}cblas atlas ${pt}f77blas; do if [ ! -f $ATLASLIBDIR/lib$x.so ]; then echo "Configuring dynamic ATLAS libraries failed: Could not find library $x in directory $ATLASLIBDIR" return 1; fi ATLASLIBS="$ATLASLIBS -l$x" done if $threaded_atlas; then ATLASLIBS="$ATLASLIBS"; fi echo ATLASINC = $ATLASROOT/include >> kaldi.mk echo ATLASLIBS = $ATLASLIBS >> kaldi.mk cat makefiles/linux_atlas.mk >> kaldi.mk fix_cxx_flag $use_cuda && linux_configure_cuda echo "Successfully configured for Linux [dynamic libraries] with ATLASLIBS =$ATLASLIBS" exit 0; } echo "Configuring ..." if [ ! -f makefiles/common.mk ]; then failure makefiles/common.mk not found fi echo "Checking OpenFST library in $FSTROOT ..." if [ ! -f $FSTROOT/include/fst/fst.h ]; then failure "Could not find file $FSTROOT/include/fst/fst.h: you may not have installed OpenFst. See ../tools/INSTALL" fi echo Checking OpenFst library was patched. if ! grep "multiple repeated" $FSTROOT/include/fst/minimize.h >/dev/null; then echo "** ERROR **" echo "** $FSTROOT/include/fst/minimize.h seems not to be patched:" echo "patch not applied? FST tools will not work in our recipe." exit 1; fi # back up the old one in case we modified it if [ -f kaldi.mk ]; then echo "Backing up kaldi.mk to kaldi.mk.bak" cp kaldi.mk kaldi.mk.bak fi printf "# This file was generated using the following command:\n# $cmd_line\n\n" > kaldi.mk cat makefiles/common.mk >> kaldi.mk if $dynamic_kaldi ; then KALDILIBDIR=`pwd`/lib echo "KALDI_FLAVOR := dynamic" >> kaldi.mk echo "KALDILIBDIR := $KALDILIBDIR" >> kaldi.mk fi echo "CONFIGURE_VERSION := $CONFIGURE_VERSION" >> kaldi.mk # Most of the OS-specific steps below will append to kaldi.mk echo "Doing OS specific configurations ..." # Check for Darwin at first, because we later call uname -o (for Cygwin) # which crashes on Darwin. Also the linear algebra libraries on Macs are # used differently (through the Accelerate framework) than on Linux. if [ "`uname`" == "Darwin" ]; then echo "On Darwin: checking for Accelerate framework ..." if [ ! -e /System/Library/Frameworks/Accelerate.framework ]; then failure "Need the Accelerate.framework to compile on Darwin." fi if [ ! -f $FSTROOT/lib/libfst.a ]; then failure "Static OpenFST library not found: See ../tools/INSTALL" fi echo FSTROOT = $FSTROOT >> kaldi.mk # posix_memalign and gcc -rdynamic options not present on OS X 10.5.* osx_ver=`sw_vers | grep ProductVersion | awk '{print $2}' | awk '{split($0,a,"\."); print a[1] "." a[2]; }'` echo "Configuring for OS X version $osx_ver ..." if [ "$osx_ver" == "10.5" ]; then check_exists makefiles/darwin_10_5.mk cat makefiles/darwin_10_5.mk >> kaldi.mk elif [ "$osx_ver" == "10.6" ]; then check_exists makefiles/darwin_10_6.mk cat makefiles/darwin_10_6.mk >> kaldi.mk elif [ "$osx_ver" == "10.7" ]; then check_exists makefiles/darwin_10_7.mk cat makefiles/darwin_10_7.mk >> kaldi.mk elif [ "$osx_ver" == "10.8" ]; then check_exists makefiles/darwin_10_8.mk cat makefiles/darwin_10_8.mk >> kaldi.mk elif [ "$osx_ver" == "10.9" ]; then check_exists makefiles/darwin_10_9.mk cat makefiles/darwin_10_9.mk >> kaldi.mk else failure "OS X version '$osx_ver' not supported" fi echo "Configuration succeeded for platform Darwin." exit 0 fi if [ "`uname -o`" == "Cygwin" ]; then echo "On Cygwin: checking for linear algebra libraries ..." if [ ! -f ../tools/CLAPACK/clapack.h ]; then failure "could not find file ../tools/CLAPACK/clapack.h" fi if [ ! -f /usr/lib/lapack/cygblas-0.dll ]; then failure "please first install package liblapack0" fi echo FSTROOT = $FSTROOT >> kaldi.mk cat makefiles/cygwin.mk >> kaldi.mk echo "Configuration succeeded for platform cygwin" exit 0 fi if [ "`uname`" == "Linux" ]; then if $static_fst ; then OPENFSTLIBS="$FSTROOT/lib/libfst.a" fst_type='a' else OPENFSTLIBS="-L${FSTROOT}/lib -lfst" OPENFSTLDFLAGS="-Wl,-rpath=${FSTROOT}/lib" fst_type='so' fi if [ ! -f "$FSTROOT/lib/libfst.${fst_type}" ]; then failure "Static=[$static_fst] OpenFST library not found: See ../tools/INSTALL" fi echo OPENFSTLIBS = $OPENFSTLIBS >> kaldi.mk echo OPENFSTLDFLAGS = $OPENFSTLDFLAGS >> kaldi.mk echo FSTROOT = $FSTROOT >> kaldi.mk echo "On Linux: Checking for linear algebra header files ..." if [ "$MATHLIB" == "ATLAS" ]; then if [ ! -f $ATLASROOT/include/cblas.h ] || [ ! -f $ATLASROOT/include/clapack.h ] ; then failure "Could not find required header files cblas.h or clapack.h in ATLAS dir '$ATLASROOT/include'" fi echo "Using ATLAS as the linear algebra library." # Finding out where the libraries are located: # First we look for the static libraries and then look for dynamic ones. # We're looking for four libraries, all in the same directory, named # libcblas.a, libatlas.a, libf77blas.a, and a library that's variously # named liblapack.a, libclapack.a, or liblapack_atlas.a, but which exports # the symbol ATL_cgetrf. # Note: there is a different type of ATLAS installation that is not # covered. We saw a case where there was a directory called /usr/lib/atlas # containing {liblapack.a,libblas.a}, and linking against just these two # libraries worked. if $static_math; then # Prefer static to dynamic math. linux_configure_static || \ linux_configure_dynamic || \ linux_configure_debian_ubuntu 64 || \ linux_configure_debian_ubuntu || \ linux_configure_debian7 || \ linux_atlas_failure "Failed to configure ATLAS lbiraries"; else # Prefer dynamic to static math. linux_configure_dynamic || \ linux_configure_static || \ linux_configure_debian_ubuntu 64 || \ linux_configure_debian_ubuntu || \ linux_configure_debian7 || \ linux_atlas_failure "Failed to configure ATLAS lbiraries"; fi elif [ "$MATHLIB" == "MKL" ]; then if [ "`uname -m`" != "x86_64" ]; then failure "MKL on Linux only supported for Intel(R) 64 architecture (x86_64). See makefiles/linux_64_mkl.mk to manually configure for other platforms." fi if is_set "$MKLROOT" -a ! is_set "$MKLLIBDIR"; then echo -n "Configuring MKL library directory: " MKLLIBDIR=`linux_configure_mkllibdir $MKLROOT` if [ $? -ne 0 ]; then failure "MKL libraries could not be found. Please use the switch --mkl-libdir " else echo "Found: $MKLLIBDIR" fi fi MKL_LINK_LINE=`linux_configure_mkl_libraries "$MKLLIBDIR" $static_math $threaded_math` || exit 1 MKL_COMPILE_LINE=`linux_configure_mkl_includes "$MKLROOT" "$MKLLIBDIR"` || exit 1 echo "MKL include directory configured as: $MKL_COMPILE_LINE" MKL_COMPILE_LINE=" -I${MKL_COMPILE_LINE} " if ! is_set $OMPLIBDIR ; then if $static_math ; then OMPLIBDIR=`linux_configure_omplibdir "$MKLROOT" "$MKLLIBDIR" "a"` else OMPLIBDIR=`linux_configure_omplibdir "$MKLROOT" "$MKLLIBDIR" "so"` fi fi check_library $OMPLIBDIR "libiomp5" "a" || check_library $OMPLIBDIR "libiomp5" "so" \ || failure "Could not find the iomp5 library, have your tried the --omp-libdir switch?" echo "OMP library directory configured as: $OMPLIBDIR" OMP_LINK_LINE='' # TODO(arnab): in the following conditional, the $static_math test is needed since # the OpenMP library is assumed to be dynamic. if [ "$OMPLIBDIR" != "$MKLLIBDIR" ] ; then OMP_LINK_LINE="-L${OMPLIBDIR}" #if the libiomp5 library is dynamic, we add the rpath attribute if ! $static_math ; then OMP_LINK_LINE="$OMP_LINK_LINE -Wl,-rpath=$OMPLIBDIR" else OMP_LINK_LINE="$OMP_LINK_LINE -Wl,-Bstatic -liomp5 -Wl,-Bdynamic" fi fi echo "Using Intel MKL as the linear algebra library." echo MKLROOT = $MKLROOT >> kaldi.mk if [ ! -z $MKLLIBDIR ]; then echo MKLLIB = $MKLLIBDIR >> kaldi.mk fi echo FSTROOT = $FSTROOT >> kaldi.mk check_exists makefiles/linux_x86_64_mkl.mk cat makefiles/linux_x86_64_mkl.mk >> kaldi.mk fix_cxx_flag echo "MKLFLAGS = ${MKL_LINK_LINE} ${OMP_LINK_LINE} " >> kaldi.mk $use_cuda && linux_configure_cuda echo "Successfully configured for Linux with MKL libs from $MKLROOT" exit 0; elif [ "$MATHLIB" == "CLAPACK" ]; then if [ -z "$CLAPACKROOT" ]; then failure "Must specify the location of CLAPACK with --clapack-root option (and it must exist)" fi if [ ! -f ../tools/CLAPACK/clapack.h ]; then failure could not find file ../tools/CLAPACK/clapack.h fi if [ ! -d "$CLAPACKROOT" ]; then failure "The directory $CLAPACKROOT does not exist" fi # Also check for cblas.h and f2c.h echo "Using CLAPACK as the linear algebra library." if [ ! -f makefiles/linux_clapack.mk ]; then failure "makefiles/linux_clapack.mk not found." fi cat makefiles/linux_clapack.mk >> kaldi.mk fix_cxx_flag echo "Warning (CLAPACK): this part of the configure process is not properly tested and will not work." $use_cuda && linux_configure_cuda echo "Successfully configured for Linux with CLAPACK libs from $CLAPACKROOT" exit 0 elif [ "$MATHLIB" == "OPENBLAS" ]; then OPENBLASROOT=`rel2abs "$OPENBLASROOT"` if [ -z "$OPENBLASROOT" ]; then failure "Must specify the location of OPENBLAS with --openblas-root option (and it must exist)" fi if [ ! -f $OPENBLASROOT/lib/libopenblas.so ]; then failure "Expected to find the file $OPENBLASROOT/lib/libopenblas.so" fi echo "Your math library seems to be OpenBLAS. Configuring appropriately." cat makefiles/linux_openblas.mk >> kaldi.mk fix_cxx_flag if $static_math; then echo "Configuring static OpenBlas since --static-math=yes" OPENBLASLIBS="$OPENBLASROOT/lib/libopenblas.a -lgfortran" else echo "Configuring dynamically loaded OpenBlas since --static-math=no (the default)" OPENBLASLIBS="-L$OPENBLASROOT/lib -lopenblas -lgfortran -Wl,-rpath=$OPENBLASROOT/lib" fi echo "OPENBLASLIBS = $OPENBLASLIBS" >> kaldi.mk echo "OPENBLASROOT = $OPENBLASROOT" >> kaldi.mk echo "Warning (OPENBLAS): this part of the configure process is not properly tested and will not work." $use_cuda && linux_configure_cuda echo "Successfully configured OpenBLAS from $OPENBLASROOT." exit 0; else failure "Unsupported linear algebra library '$MATHLIB'" fi fi failure Could not detect platform or we have not yet worked out the appropriate configuration for this platform. Please contact the developers.