1 #
2 # Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 #
5 # This code is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License version 2 only, as
7 # published by the Free Software Foundation. Oracle designates this
8 # particular file as subject to the "Classpath" exception as provided
9 # by Oracle in the LICENSE file that accompanied this code.
10 #
11 # This code is distributed in the hope that it will be useful, but WITHOUT
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 # version 2 for more details (a copy is included in the LICENSE file that
15 # accompanied this code).
16 #
17 # You should have received a copy of the GNU General Public License version
18 # 2 along with this work; if not, write to the Free Software Foundation,
19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 #
21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 # or visit www.oracle.com if you need additional information or have any
23 # questions.
24 #
25
26 ################################################################################
27 # Setup libclang from llvm project
28 ################################################################################
29 AC_DEFUN_ONCE([LIB_SETUP_LIBCLANG],
30 [
31 AC_ARG_WITH([libclang], [AS_HELP_STRING([--with-libclang=<path to llvm>],
32 [Specify path of llvm installation contains libclang. Pre-built llvm
33 binary can be downloaded from http://llvm.org/releases/download.html])],
34 [],
35 [with_libclang=yes]
36 )
37
38 if test "x$with_libclang" = "xno"; then
39 ENABLE_LIBCLANG="no"
40 else
41 ENABLE_LIBCLANG="yes"
42 AC_ARG_WITH([libclang-include], [AS_HELP_STRING([--with-libclang-include=<path>],
43 [Specify where to find libclang header files, clang-c/Index.h ])],
44 [CLANG_INCLUDE_PATH="$withval"],
45 [CLANG_INLCUDE_PATH=""]
46 )
47 AC_ARG_WITH([libclang-lib], [AS_HELP_STRING([--with-libclang-lib=<path>],
48 [Specify where to find libclang binary, so/dylib/dll ])],
49 [CLANG_LIB_PATH="$withval"],
50 [CLANG_LIB_PATH=""]
51 )
52
53 if test "x$with_libclang" != "xyes"; then
54 CLANG_INCLUDE_PATH="$with_libclang/include"
55 CLANG_LIB_PATH="$with_libclang/lib"
56 fi
57
58 if test "x$CLANG_INCLUDE_PATH" != "x"; then
59 LIBCLANG_CPPFLAGS="-I$CLANG_INCLUDE_PATH"
60 else
61 LIBCLANG_CPPFLAGS=""
62 fi
63 if test "x$CLANG_LIB_PATH" != "x"; then
64 LIBCLANG_LDFLAGS="-L$CLANG_LIB_PATH -Wl,-rpath,$CLANG_LIB_PATH"
65 else
66 LIBCLANG_LDFLAGS=""
67 fi
68
69 OLD_CPPFLAGS=$CPPFLAGS
70 OLD_LDFLAGS=$LDFLAGS
71 OLD_LIBS=$LIBS
72
73 CPPFLAGS="$LIBCLANG_CPPFLAGS"
74 LDFLAGS="$LIBCLANG_LDFLAGS"
75 LIBS=""
76 AC_CHECK_HEADER("clang-c/Index.h", [], [ENABLE_LIBCLANG="no"])
77 if test "x$ENABLE_LIBCLANG" = "xyes"; then
78 AC_CHECK_LIB(clang, clang_getClangVersion, [], [ENABLE_LIBCLANG="no"])
79 fi
80
81 if test "x$ENABLE_LIBCLANG" = "xno"; then
82 AC_MSG_NOTICE([Cannot locate libclang! You can download pre-built llvm
83 binary from http://llvm.org/releases/download.html, then specify the
84 location using --with-libclang])
85 fi
86
87 LIBCLANG_LIBS="$LIBS"
88
89 LIBS="$OLD_LIBS"
90 LDFLAGS="$OLD_LDFLAGS"
91 CPPFLAGS="$OLD_CPPFLAGS"
92 fi
93
94 if test "x$ENABLE_LIBCLANG" = "xno"; then
95 CLANG_INCLUDE_PATH=""
96 CLANG_LIB_PATH=""
97 LIBCLANG_CPPFLAGS=""
98 LIBCLANG_LDFLAGS=""
99 LIBCLANG_LIBS=""
100 fi
101
102 AC_SUBST(ENABLE_LIBCLANG)
103 AC_SUBST(CLANG_INCLUDE_PATH)
104 AC_SUBST(CLANG_LIB_PATH)
105 AC_SUBST(LIBCLANG_CPPFLAGS)
106 AC_SUBST(LIBCLANG_LDFLAGS)
107 AC_SUBST(LIBCLANG_LIBS)
108 ])
--- EOF ---