From bdc8e297b8cc2c36cf9e9ce41007cade06d2ee3f Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Sat, 12 Sep 2015 21:44:59 +0200 Subject: Check llvm version. Fix ghdldrv --post for llvm. --- configure | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) (limited to 'configure') diff --git a/configure b/configure index 48da0c6af..333ea472e 100755 --- a/configure +++ b/configure @@ -36,10 +36,22 @@ else echoc= fi -# Read gcc version from README file +# Read required gcc version from README file gcc_version=`grep '^gcc version' $srcdir/README | sed -e 's/gcc version \([0-9.]*\) \[.*\]\.$/\1/'` +# Read required llvm version from README file +llvm_version=`grep '^llvm version' $srcdir/README | + sed -e 's/llvm version \([0-9.]*\) \[.*\]\.$/\1/'` + +# Check $1 is a prefix of $2 +function check_version() +{ + exp_ver=`echo $1 | sed 's/\./v/g'` + tool_ver=`echo $2 | sed 's/\./v/g'` + echo $tool_ver | grep -q "^$exp_ver" +} + # Decode options for opt do optarg=`expr x"$opt" : 'x[^=]*=\(.*\)'` @@ -68,14 +80,14 @@ Options [defaults in brackets]: --prefix=PREFIX install in PREFIX [$prefix] --srcdir=SRCDIR source code path [$srcdir] --with-gcc=DIR use gcc backend from DIR (needs gcc $gcc_version) - --with-llvm=DIR use llvm installed in DIR + --with-llvm=DIR use llvm installed in DIR (needs llvm $llvm_version) EOF exit 0 fi # Sanity checks # Check that gnatmake exists -if ! $GNATMAKE --version 2> /dev/null; then +if ! $GNATMAKE --version >/dev/null 2>&1; then echo "Sorry, you need GNAT to build GHDL. See the README" echo "(gnatmake executable is: $GNATMAKE)" exit 1 @@ -108,7 +120,7 @@ if test $backend = gcc; then exit 1 fi base_ver=`cat $gcc_src_dir/gcc/BASE-VER` - if test x$base_ver != x$gcc_version; then + if ! check_version $gcc_version $base_ver; then echo "Mismatch gcc version from $gcc_src_dir" echo "Need gcc version $gcc_version" exit 1 @@ -118,11 +130,17 @@ fi # For llvm backend, check llvm-config if test $backend = llvm; then llvm_cmd="$llvm_prefix/bin/llvm-config --version" - if ! $llvm_cmd > /dev/null 2>&1; then + llvm_ver=`$llvm_cmd 2>/dev/null` + if [ $? != 0 ]; then echo "cannot run $llvm_cmd" exit 1 fi - # For llvm, the c++ compiler is for linking so that the standard c++ + if ! check_version $llvm_version $llvm_ver; then + echo "Mismatch llvm version $llvm_ver from $llvm_prefix" + echo "Need llvm version $llvm_version" + exit 1 + fi + # For llvm, the c++ compiler isused for linking so that the standard c++ # library is included. However, the linker needs the no_compact_unwind # flag because code generated by gcc is not compatible with compact unwind. case "$build" in @@ -190,7 +208,7 @@ sed -e "s%@COMPILER_GCC@%ghdl1-gcc%" \ -e "s%@COMPILER_DEBUG@%ghdl1-debug%" \ -e "s%@COMPILER_MCODE@%ghdl1-mcode%" \ -e "s%@COMPILER_LLVM@%bin/ghdl1-llvm%" \ - -e "s%@POST_PROCESSOR@%oread-gcc%" \ + -e "s%@POST_PROCESSOR@%oread-$backend%" \ -e "s%@INSTALL_PREFIX@%$prefix%" \ -e "s%@LIB_PREFIX@%$libdirsuffix%" \ < $srcdir/src/ghdldrv/default_pathes.ads.in > default_pathes.ads -- cgit v1.2.3