1###########################################################
2## Generate clang/Basic/Version.inc
3###########################################################
4ifeq ($(LOCAL_MODULE_CLASS),)
5    LOCAL_MODULE_CLASS := STATIC_LIBRARIES
6endif
7
8intermediates := $(call local-generated-sources-dir)
9
10LLVMVersion := $(shell grep PACKAGE_VERSION $(LLVM_ROOT_PATH)/host/include/llvm/Config/config.h | sed -e 's/\#define PACKAGE_VERSION "\(.*\)"/\1/g')
11
12# Compute the Clang version from the LLVM version, unless specified explicitly.
13# (Copy from include/clang/Basic/Makefile)
14CLANG_VERSION := $(subst svn,,$(LLVMVersion))
15CLANG_VERSION_COMPONENTS := $(subst ., ,$(CLANG_VERSION))
16CLANG_VERSION_MAJOR := $(word 1,$(CLANG_VERSION_COMPONENTS))
17CLANG_VERSION_MINOR := $(word 2,$(CLANG_VERSION_COMPONENTS))
18CLANG_VERSION_PATCHLEVEL := $(word 3,$(CLANG_VERSION_COMPONENTS))
19ifeq ($(CLANG_VERSION_PATCHLEVEL),)
20    CLANG_HAS_VERSION_PATCHLEVEL := 0
21else
22    CLANG_HAS_VERSION_PATCHLEVEL := 1
23endif
24
25LOCAL_GENERATED_SOURCES += $(intermediates)/include/clang/Basic/Version.inc
26$(intermediates)/include/clang/Basic/Version.inc: $(CLANG_ROOT_PATH)/include/clang/Basic/Version.inc.in \
27  $(LLVM_ROOT_PATH)/host/include/llvm/Config/config.h
28	@echo "Updating Clang version info."
29	@mkdir -p $(dir $@)
30	$(hide) sed -e "s#@CLANG_VERSION@#$(CLANG_VERSION)#g" \
31	-e "s#@CLANG_VERSION_MAJOR@#$(CLANG_VERSION_MAJOR)#g" \
32	-e "s#@CLANG_VERSION_MINOR@#$(CLANG_VERSION_MINOR)#g" \
33	-e "s#@CLANG_VERSION_PATCHLEVEL@#$(CLANG_VERSION_PATCHLEVEL)#g" \
34	-e "s#@CLANG_HAS_VERSION_PATCHLEVEL@#$(CLANG_HAS_VERSION_PATCHLEVEL)#g" \
35	$< > $@
36