1 ################################################################################
5 ################################################################################
8 CLANG_SITE = http://llvm.org/releases/$(CLANG_VERSION)
9 CLANG_SOURCE = cfe-$(CLANG_VERSION).src.tar.xz
11 CLANG_LICENSE_FILES = LICENSE.TXT
12 CLANG_SUPPORTS_IN_SOURCE_BUILD = NO
13 CLANG_INSTALL_STAGING = YES
15 HOST_CLANG_DEPENDENCIES = host-llvm host-libxml2
16 CLANG_DEPENDENCIES = llvm host-clang
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
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
36 CLANG_CONF_OPTS += -DCMAKE_CROSSCOMPILING=1
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
42 HOST_CLANG_CONF_OPTS += \
43 -DCLANG_BUILD_EXAMPLES=OFF \
44 -DCLANG_INCLUDE_DOCS=OFF \
45 -DCLANG_INCLUDE_TESTS=OFF
48 -DCLANG_BUILD_EXAMPLES=OFF \
49 -DCLANG_INCLUDE_DOCS=OFF \
50 -DCLANG_INCLUDE_TESTS=OFF
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
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 from target.
60 define CLANG_DELETE_BINARIES_FROM_TARGET
61 rm -f $(TARGET_DIR)/usr/bin/clang*
63 CLANG_POST_INSTALL_TARGET_HOOKS += CLANG_DELETE_BINARIES_FROM_TARGET
65 # clang-tblgen is not installed by default, however it is necessary
66 # for cross-compiling clang
67 define HOST_CLANG_INSTALL_CLANG_TBLGEN
68 $(INSTALL) -D -m 0755 $(HOST_CLANG_BUILDDIR)/bin/clang-tblgen \
69 $(HOST_DIR)/usr/bin/clang-tblgen
71 HOST_CLANG_POST_INSTALL_HOOKS = HOST_CLANG_INSTALL_CLANG_TBLGEN
73 $(eval $(cmake-package))
74 $(eval $(host-cmake-package))