remove debug msg and remove NDEBUG flag to llvm CFLAGS
[scilab.git] / scilab / m4 / llvm.m4
1 dnl
2 dnl Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 dnl Copyright (C) Scilab Enterprises - 2014 - Calixte DENIZET
4 dnl 
5 dnl This file must be used under the terms of the CeCILL.
6 dnl This source file is licensed as described in the file COPYING, which
7 dnl you should have received as part of this distribution.  The terms
8 dnl are also available at    
9 dnl http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
10 dnl
11 dnl AC_LLVM_CONFIG
12 dnl ------------------------------------------------------
13 dnl Check if llvm-config is usable and working
14 dnl
15 AC_DEFUN([AC_LLVM_CONFIG], [
16
17 AC_ARG_WITH([llvm-config],
18                 AC_HELP_STRING([--with-llvm-config=DIR],[Set the path to llvm-config (or yes to autodetect)]),
19                 [with_llvm_config=$withval],
20                 [with_llvm_config="yes"]
21                 )
22
23 if test "${with_llvm_config}" != "yes" -a "${with_llvm_config}" != "no"; then
24         AC_MSG_CHECKING([LLVM, for llvm-config])
25         LLVM_CONFIG_BIN="${with_llvm_config}/llvm-config"
26         if test -x "${LLVM_CONFIG_BIN}"; then
27                 AC_MSG_RESULT([$LLVM_CONFIG_BIN])
28         else
29                 AC_MSG_ERROR([Cannot find llvm-config. Please check the path you provided])
30         fi
31 else
32         AC_PATH_PROG(LLVM_CONFIG_BIN, llvm-config, [no])
33         if test "x${LLVM_CONFIG_BIN}" = "xno"; then
34                 AC_MSG_ERROR([Cannot find llvm-config. Please check your installation of LLVM])
35         fi
36 fi
37
38 LLVM_VERSION="`${LLVM_CONFIG_BIN} --version`"
39 LLVM_MAJOR="`echo  ${LLVM_VERSION} | sed 's/\([[0-9]]*\).*/\1/'`"
40 LLVM_MINOR="`echo  ${LLVM_VERSION} | sed 's/\([[0-9]]*\).\([[0-9]]*\).*/\2/'`"
41 LLVM_SUBMINOR="`echo  ${LLVM_VERSION} | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\).*/\3/'`"
42
43 CHK_LLVM_MAJOR=3
44 CHK_LLVM_MINOR=4
45
46 AC_MSG_CHECKING([if LLVM is version $CHK_LLVM_MAJOR.$CHK_LLVM_MINOR or later])
47
48 if test "${LLVM_MAJOR}" -le "${CHK_LLVM_MAJOR}" -a "${LLVM_MINOR}" -lt "${CHK_LLVM_MINOR}" -o "${LLVM_MAJOR}" != "${CHK_LLVM_MAJOR}"; then
49         AC_MSG_ERROR([Version $CHK_LLVM_MAJOR.$CHK_LLVM_MINOR of LLVM expected (at least)])
50 else
51         AC_MSG_RESULT([yes])
52 fi
53
54 LLVM_INCLUDE="-I`${LLVM_CONFIG_BIN} --includedir`"
55 LLVM_LDFLAGS="-L`${LLVM_CONFIG_BIN} --libdir`"
56 LLVM_LIBS="-lLLVM-${LLVM_MAJOR}.${LLVM_MINOR}"
57 LLVM_LIBS_STATIC="`${LLVM_CONFIG_BIN} --libfiles core mcjit native`"
58 LLVM_CPPFLAGS="`${LLVM_CONFIG_BIN} --cppflags | sed 's/-I[[^ ]]*[[ ]]*//g' | sed 's/-DNDEBUG//g'`"
59
60
61
62 AC_SUBST(LLVM_VERSION)
63 AC_SUBST(LLVM_CONFIG_BIN)
64 AC_SUBST(LLVM_INCLUDE)
65 AC_SUBST(LLVM_LDFLAGS)
66 AC_SUBST(LLVM_LIBS)
67 AC_SUBST(LLVM_LIBS_STATIC)
68 AC_SUBST(LLVM_CPPFLAGS)
69
70 AC_DEFINE([WITH_LLVM_CONFIG], [], [With llvm-config])
71 ])