• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# This file is dual licensed under the MIT and the University of Illinois Open
2# Source Licenses. See LICENSE.TXT for details.
3
4LOCAL_PATH := $(call my-dir)
5
6# Normally, we distribute the NDK with prebuilt binaries of libc++
7# in $LOCAL_PATH/libs/<abi>/. However,
8#
9
10LIBCXX_FORCE_REBUILD := $(strip $(LIBCXX_FORCE_REBUILD))
11ifndef LIBCXX_FORCE_REBUILD
12  ifeq (,$(strip $(wildcard $(LOCAL_PATH)/libs/$(TARGET_ARCH_ABI)/libc++_static$(TARGET_LIB_EXTENSION))))
13    $(call __ndk_info,WARNING: Rebuilding libc++ libraries from sources!)
14    $(call __ndk_info,You might want to use $$NDK/build/tools/build-cxx-stl.sh --stl=libc++)
15    $(call __ndk_info,in order to build prebuilt versions to speed up your builds!)
16    LIBCXX_FORCE_REBUILD := true
17  endif
18endif
19
20libcxx_includes := $(LOCAL_PATH)/libcxx/include
21libcxx_export_includes := $(libcxx_includes)
22libcxx_sources := \
23    algorithm.cpp \
24    bind.cpp \
25    chrono.cpp \
26    condition_variable.cpp \
27    debug.cpp \
28    exception.cpp \
29    future.cpp \
30    hash.cpp \
31    ios.cpp \
32    iostream.cpp \
33    locale.cpp \
34    memory.cpp \
35    mutex.cpp \
36    new.cpp \
37    optional.cpp \
38    random.cpp \
39    regex.cpp \
40    shared_mutex.cpp \
41    stdexcept.cpp \
42    string.cpp \
43    strstream.cpp \
44    system_error.cpp \
45    thread.cpp \
46    typeinfo.cpp \
47    utility.cpp \
48    valarray.cpp \
49    support/android/locale_android.cpp
50
51libcxx_sources := $(libcxx_sources:%=libcxx/src/%)
52
53# For now, this library can only be used to build C++11 binaries.
54libcxx_export_cxxflags := -std=c++11
55
56ifeq (,$(filter clang%,$(NDK_TOOLCHAIN_VERSION)))
57# Add -fno-strict-aliasing because __list_imp::_end_ breaks TBAA rules by declaring
58# simply as __list_node_base then casted to __list_node derived from that.  See
59# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61571 for details
60libcxx_export_cxxflags += -fno-strict-aliasing
61endif
62
63libcxx_cxxflags := $(libcxx_export_cxxflags)
64libcxx_cflags := -D__STDC_FORMAT_MACROS
65
66ifneq ($(LIBCXX_FORCE_REBUILD),true)
67
68$(call ndk_log,Using prebuilt libc++ libraries)
69
70android_support_c_includes := $(LOCAL_PATH)/../../android/support/include
71
72include $(CLEAR_VARS)
73LOCAL_MODULE := c++_static
74LOCAL_SRC_FILES := libs/$(TARGET_ARCH_ABI)/lib$(LOCAL_MODULE)$(TARGET_LIB_EXTENSION)
75LOCAL_EXPORT_C_INCLUDES := $(libcxx_export_includes) $(android_support_c_includes)
76LOCAL_EXPORT_CPPFLAGS := $(libcxx_export_cxxflags)
77include $(PREBUILT_STATIC_LIBRARY)
78
79include $(CLEAR_VARS)
80LOCAL_MODULE := c++_shared
81LOCAL_SRC_FILES := libs/$(TARGET_ARCH_ABI)/lib$(LOCAL_MODULE)$(TARGET_SONAME_EXTENSION)
82LOCAL_EXPORT_C_INCLUDES := $(libcxx_export_includes) $(android_support_c_includes)
83LOCAL_EXPORT_CPPFLAGS := $(libcxx_export_cxxflags)
84include $(PREBUILT_SHARED_LIBRARY)
85
86else
87# LIBCXX_FORCE_REBUILD == true
88
89$(call ndk_log,Rebuilding libc++ libraries from sources)
90
91include $(CLEAR_VARS)
92LOCAL_MODULE := c++_static
93LOCAL_SRC_FILES := $(libcxx_sources)
94LOCAL_C_INCLUDES := $(android_support_c_includes) $(libcxx_includes)
95LOCAL_CFLAGS := $(libcxx_cflags)
96LOCAL_CPPFLAGS := $(libcxx_cxxflags)
97LOCAL_CPP_FEATURES := rtti exceptions
98LOCAL_EXPORT_C_INCLUDES := $(libcxx_export_includes)
99LOCAL_EXPORT_CPPFLAGS := $(libcxx_export_cxxflags)
100LOCAL_STATIC_LIBRARIES := libc++abi android_support
101include $(BUILD_STATIC_LIBRARY)
102
103include $(CLEAR_VARS)
104LOCAL_MODULE := c++_shared
105LOCAL_WHOLE_STATIC_LIBRARIES := c++_static
106LOCAL_EXPORT_C_INCLUDES := $(libcxx_export_includes)
107LOCAL_EXPORT_CPPFLAGS := $(libcxx_export_cxxflags)
108LOCAL_STATIC_LIBRARIES := libc++abi android_support
109
110# We use the LLVM unwinder for all the 32-bit ARM targets.
111ifneq (,$(filter armeabi%,$(TARGET_ARCH_ABI)))
112    LOCAL_STATIC_LIBRARIES += libunwind
113endif
114
115# But only need -latomic for armeabi.
116ifeq ($(TARGET_ARCH_ABI),armeabi)
117    LOCAL_LDLIBS := -latomic
118endif
119include $(BUILD_SHARED_LIBRARY)
120
121endif # LIBCXX_FORCE_REBUILD == true
122
123$(call import-module, android/support)
124$(call import-module, cxx-stl/llvm-libc++abi)
125