Collection of DPF-based plugins for packaging
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

94 lines
2.6KB

  1. # ===========================================================================
  2. # https://www.gnu.org/software/autoconf-archive/ax_llvm.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_LLVM([llvm-libs])
  8. #
  9. # DESCRIPTION
  10. #
  11. # Test for the existence of llvm, and make sure that it can be linked with
  12. # the llvm-libs argument that is passed on to llvm-config i.e.:
  13. #
  14. # llvm --libs <llvm-libs>
  15. #
  16. # llvm-config will also include any libraries that are depended upon.
  17. #
  18. # LICENSE
  19. #
  20. # Copyright (c) 2008 Andy Kitchen <agimbleinthewabe@gmail.com>
  21. #
  22. # Copying and distribution of this file, with or without modification, are
  23. # permitted in any medium without royalty provided the copyright notice
  24. # and this notice are preserved. This file is offered as-is, without any
  25. # warranty.
  26. #serial 16
  27. AC_DEFUN([AX_LLVM],
  28. [
  29. AC_ARG_WITH([llvm],
  30. AS_HELP_STRING([--with-llvm@<:@=DIR@:>@], [use llvm (default is yes) - it is possible to specify the root directory for llvm (optional)]),
  31. [
  32. if test "$withval" = "no"; then
  33. want_llvm="no"
  34. elif test "$withval" = "yes"; then
  35. want_llvm="yes"
  36. ac_llvm_config_path=`which llvm-config`
  37. else
  38. want_llvm="yes"
  39. ac_llvm_config_path="$withval"
  40. fi
  41. ],
  42. [want_llvm="yes"])
  43. succeeded=no
  44. if test -z "$ac_llvm_config_path"; then
  45. ac_llvm_config_path=`which llvm-config`
  46. fi
  47. if test "x$want_llvm" = "xyes"; then
  48. if test -e "$ac_llvm_config_path"; then
  49. LLVM_CPPFLAGS=`$ac_llvm_config_path --cxxflags`
  50. LLVM_LDFLAGS="$($ac_llvm_config_path --ldflags) $($ac_llvm_config_path --libs $1)"
  51. AC_REQUIRE([AC_PROG_CXX])
  52. CPPFLAGS_SAVED="$CPPFLAGS"
  53. CPPFLAGS="$CPPFLAGS $LLVM_CPPFLAGS"
  54. export CPPFLAGS
  55. LDFLAGS_SAVED="$LDFLAGS"
  56. LDFLAGS="$LDFLAGS $LLVM_LDFLAGS"
  57. export LDFLAGS
  58. AC_CACHE_CHECK(can compile with and link with llvm([$1]),
  59. ax_cv_llvm,
  60. [AC_LANG_PUSH([C++])
  61. AC_LINK_IFELSE([AC_LANG_PROGRAM([[@%:@include <llvm/Module.h>
  62. ]],
  63. [[llvm::Module *M = new llvm::Module("test"); return 0;]])],
  64. ax_cv_llvm=yes, ax_cv_llvm=no)
  65. AC_LANG_POP([C++])
  66. ])
  67. if test "x$ax_cv_llvm" = "xyes"; then
  68. succeeded=yes
  69. fi
  70. CPPFLAGS="$CPPFLAGS_SAVED"
  71. LDFLAGS="$LDFLAGS_SAVED"
  72. else
  73. succeeded=no
  74. fi
  75. fi
  76. if test "$succeeded" != "yes" ; then
  77. AC_MSG_ERROR([[We could not detect the llvm libraries make sure that llvm-config is on your path or specified by --with-llvm.]])
  78. else
  79. AC_SUBST(LLVM_CPPFLAGS)
  80. AC_SUBST(LLVM_LDFLAGS)
  81. AC_DEFINE(HAVE_LLVM,,[define if the llvm library is available])
  82. fi
  83. ])