]> rtime.felk.cvut.cz Git - coffee/buildroot.git/blob - package/clang/clang.mk
package/clang: link libclang against libLLVM.so
[coffee/buildroot.git] / package / clang / clang.mk
1 ################################################################################
2 #
3 # clang
4 #
5 ################################################################################
6
7 CLANG_VERSION = 5.0.1
8 CLANG_SITE = http://llvm.org/releases/$(CLANG_VERSION)
9 CLANG_SOURCE = cfe-$(CLANG_VERSION).src.tar.xz
10 CLANG_LICENSE = NCSA
11 CLANG_LICENSE_FILES = LICENSE.TXT
12 CLANG_SUPPORTS_IN_SOURCE_BUILD = NO
13 CLANG_INSTALL_STAGING = YES
14
15 HOST_CLANG_DEPENDENCIES = host-llvm host-libxml2
16 CLANG_DEPENDENCIES = llvm host-clang
17
18 # This option is needed, otherwise multiple shared libs
19 # (libclangAST.so, libclangBasic.so, libclangFrontend.so, etc.) will
20 # be generated. As a final shared lib containing all these components
21 # (libclang.so) is also generated, this resulted in the following
22 # error when trying to use tools that use libclang:
23 # $ CommandLine Error: Option 'track-memory' registered more than once!
24 # $ LLVM ERROR: inconsistency in registered CommandLine options
25 # By setting BUILD_SHARED_LIBS to OFF, we generate multiple static
26 # libraries (the same way as host's clang build) and finally
27 # libclang.so to be installed on the target.
28 CLANG_CONF_OPTS += -DBUILD_SHARED_LIBS=OFF
29
30 # Default is Debug build, which requires considerably more disk space
31 # and build time. Release build is selected for host and target
32 # because the linker can run out of memory in Debug mode.
33 HOST_CLANG_CONF_OPTS += -DCMAKE_BUILD_TYPE=Release
34 CLANG_CONF_OPTS += -DCMAKE_BUILD_TYPE=Release
35
36 CLANG_CONF_OPTS += -DCMAKE_CROSSCOMPILING=1
37
38 # We need to build tools because libclang is a tool
39 HOST_CLANG_CONF_OPTS += -DCLANG_BUILD_TOOLS=ON
40 CLANG_CONF_OPTS += -DCLANG_BUILD_TOOLS=ON
41
42 HOST_CLANG_CONF_OPTS += \
43         -DCLANG_BUILD_EXAMPLES=OFF \
44         -DCLANG_INCLUDE_DOCS=OFF \
45         -DCLANG_INCLUDE_TESTS=OFF
46
47 CLANG_CONF_OPTS += \
48         -DCLANG_BUILD_EXAMPLES=OFF \
49         -DCLANG_INCLUDE_DOCS=OFF \
50         -DCLANG_INCLUDE_TESTS=OFF
51
52 HOST_CLANG_CONF_OPTS += -DLLVM_CONFIG:FILEPATH=$(HOST_DIR)/bin/llvm-config
53 CLANG_CONF_OPTS += -DLLVM_CONFIG:FILEPATH=$(STAGING_DIR)/usr/bin/llvm-config \
54         -DCLANG_TABLEGEN:FILEPATH=$(HOST_DIR)/usr/bin/clang-tblgen \
55         -DLLVM_TABLEGEN_EXE:FILEPATH=$(HOST_DIR)/usr/bin/llvm-tblgen
56
57 # Clang can't be used as compiler on the target since there are no
58 # development files (headers) and other build tools. So remove clang
59 # binaries and some other unnecessary files from target.
60 CLANG_FILES_TO_REMOVE = \
61         /usr/bin/clang* \
62         /usr/bin/c-index-test \
63         /usr/bin/git-clang-format \
64         /usr/bin/scan-build \
65         /usr/bin/scan-view \
66         /usr/libexec/c++-analyzer \
67         /usr/libexec/ccc-analyzer \
68         /usr/share/clang \
69         /usr/share/opt-viewer \
70         /usr/share/scan-build \
71         /usr/share/scan-view \
72         /usr/share/man/man1/scan-build.1 \
73         /usr/lib/clang
74
75 define CLANG_CLEANUP_TARGET
76         rm -rf $(addprefix $(TARGET_DIR),$(CLANG_FILES_TO_REMOVE))
77 endef
78 CLANG_POST_INSTALL_TARGET_HOOKS += CLANG_CLEANUP_TARGET
79
80 # clang-tblgen is not installed by default, however it is necessary
81 # for cross-compiling clang
82 define HOST_CLANG_INSTALL_CLANG_TBLGEN
83         $(INSTALL) -D -m 0755 $(HOST_CLANG_BUILDDIR)/bin/clang-tblgen \
84                 $(HOST_DIR)/usr/bin/clang-tblgen
85 endef
86 HOST_CLANG_POST_INSTALL_HOOKS = HOST_CLANG_INSTALL_CLANG_TBLGEN
87
88 # This option must be enabled to link libclang dynamically against libLLVM.so
89 HOST_CLANG_CONF_OPTS += -DLLVM_LINK_LLVM_DYLIB=ON
90 CLANG_CONF_OPTS += -DLLVM_LINK_LLVM_DYLIB=ON
91
92 $(eval $(cmake-package))
93 $(eval $(host-cmake-package))