Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
##########################################################################
# #
# This file is part of Frama-Clang #
# #
# Copyright (C) 2012-2018 #
# CEA (Commissariat à l'énergie atomique et aux énergies #
# alternatives) #
# #
# you can redistribute it and/or modify it under the terms of the GNU #
# Lesser General Public License as published by the Free Software #
# Foundation, version 2.1. #
# #
# It is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU Lesser General Public License for more details. #
# #
# See the GNU Lesser General Public License version 2.1 #
# for more details (enclosed in the file LICENSE). #
# #
##########################################################################
m4_define([plugin_file],Makefile.config.in)
m4_define([FRAMAC_SHARE_ENV],
[m4_normalize(m4_esyscmd([echo $FRAMAC_SHARE]))])
m4_define([FRAMAC_SHARE],
[m4_ifval(FRAMAC_SHARE_ENV,
[FRAMAC_SHARE_ENV],
[m4_esyscmd(frama-c -print-path)])])
m4_ifndef([FRAMAC_M4_MACROS],
[m4_include(FRAMAC_SHARE/configure.ac)])
check_plugin([frama_clang],PLUGIN_RELATIVE_PATH(plugin_file),
[C++ front-end for Frama-C],yes)
plugin_require_external(frama_clang,camlp4o)
# check for system C++ compiler, as we can't rely on clang++ itself because
# of potential incompatibilities with GNU libstdc++ v5.
# See https://llvm.org/bugs/show_bug.cgi?id=23529 for more details
AC_PROG_CXX()
configure_tool([CAMLP4O],[camlp4o],[camlp4o not found.],no)
check_plugin_dependencies()
AC_SUBST(CLANG_CXXFLAGS)
AC_SUBST(CLANG_CFLAGS)
AC_SUBST(CLANG_INCDIR)
AC_SUBST(CLANG_LINKFLAGS)
AC_SUBST(CLANG_SYSLIBS)
AC_SUBST(CLANG_BIN_DIR)
AC_SUBST(LLVM_LIBS)
AC_SUBST(DEFAULT_FC_C_HEADERS)
AC_SUBST(DEFAULT_FC_CXX_HEADERS)
AC_SUBST(RUN_TESTS)
DEFAULT_FC_C_HEADERS=$datarootdir/frama-c/libc
DEFAULT_FC_CXX_HEADERS=$datarootdir/libc++
AC_CHECK_PROGS([CLANG],[clang clang-9.0 clang-8.0 clang-7.0 clang-6.0],no)
AC_CHECK_PROGS([CLANGXX],[clang++ clang++-9.0 clang++-8.0 clang++-7.0 clang++6.0],no)
AC_CHECK_PROGS([LLVM_CONFIG],[llvm-config llvm-config-9.0 llvm-config-8.0 llvm-config-7.0 llvm-config-6.0],no)
if test "$LLVM_CONFIG" = "no"; then
plugin_disable(frama_clang,[llvm-config not found]);
fi
if test "$CLANG" = "no"; then
plugin_disable(frama_clang,[clang not found]);
fi
if test "$CLANG++" = "no"; then
plugin_disable(frama_clang,[clang++ not found]);
fi
if test "$LLVM_CONFIG" != "no"; then
AC_CHECK_FILE([$($LLVM_CONFIG --includedir)/clang],[],
[plugin_disable(frama_clang,clang dev headers not found.);])
fi
if test "$ENABLE_FRAMA_CLANG" != "no"; then
LLVM_VERSION=$($LLVM_CONFIG --version)
AC_MSG_CHECKING([LLVM version])
LLVM_SHARED_MODE=$($LLVM_CONFIG --shared-mode)
RUN_TESTS=no
case $LLVM_VERSION in
6.0.*) AC_MSG_RESULT([$LLVM_VERSION: Good]);;
7.0.*) AC_MSG_RESULT([$LLVM_VERSION: Good]);;
8.0.*) AC_MSG_RESULT([$LLVM_VERSION: Good]); RUN_TESTS=yes;;
9.0.*) AC_MSG_RESULT([$LLVM_VERSION: Good]); RUN_TESTS=yes;;
[[LLVM Version $LLVM_VERSION is not supported. Please install LLVM 6.0.x, 7.0.x, 8.0.x, or 9.0.x]]);;
esac
LLVM_CONFIG="$LLVM_CONFIG $LLVM_STATIC"
CLANG_CXX_COMMONFLAGS="$($LLVM_CONFIG --cppflags) -g -fPIC -fno-rtti"
CLANG_CFLAGS="$($LLVM_CONFIG --cppflags) -g -fPIC"
CLANG_INCDIR=$($LLVM_CONFIG --includedir)
CLANG_LINKFLAGS="$($LLVM_CONFIG --ldflags)"
CLANG_CXXFLAGS="$CLANG_CXX_COMMONFLAGS -std=c++11"
CLANG_SYSLIBS="$($LLVM_CONFIG --system-libs)"
CLANG_BIN_DIR="$($LLVM_CONFIG --bindir)"
if test "$LLVM_SHARED_MODE" = "shared"; then
LLVM_LIBS=$($LLVM_CONFIG --libs core);
else
LLVM_LIBS=$($LLVM_CONFIG --libs profiledata asmparser mc mcparser support bitreader option);
fi
fi
write_plugin_config(Makefile.config)