OSDN Git Service

[DO NOT MERGE] Updating Security String to 2017-03-01 on lmp-dev am: 28dae4b62b ...
[android-x86/build.git] / core / cxx_stl_setup.mk
1 #############################################################
2 ## Set up flags based on LOCAL_CXX_STL.
3 ## Input variables: LOCAL_CXX_STL
4 ## Output variables: My_cflags, my_c_includes, my_shared_libraries, etc.
5 #############################################################
6
7 # Select the appropriate C++ STL
8 ifeq ($(strip $(LOCAL_CXX_STL)),default)
9     ifndef LOCAL_SDK_VERSION
10         # Platform code. Select the appropriate STL.
11         ifndef USE_MINGW
12             my_cxx_stl := libc++
13             ifdef LOCAL_IS_HOST_MODULE
14                 ifneq (,$(BUILD_HOST_static))
15                     my_cxx_stl := libc++_static
16                 endif
17             endif
18         else
19             # libc++ is not supported on mingw.
20             my_cxx_stl := libstdc++
21         endif
22     else
23         my_cxx_stl := ndk
24     endif
25 else
26     my_cxx_stl := $(strip $(LOCAL_CXX_STL))
27 endif
28
29 # Yes, this is actually what the clang driver does.
30 HOST_linux_dynamic_gcclibs := -lgcc_s -lgcc -lc -lgcc_s -lgcc
31 HOST_linux_static_gcclibs := -Wl,--start-group -lgcc -lgcc_eh -lc -Wl,--end-group
32 HOST_darwin_dynamic_gcclibs := -lc -lSystem
33 HOST_darwin_static_gcclibs := NO_STATIC_HOST_BINARIES_ON_DARWIN
34
35 my_link_type := dynamic
36 ifdef LOCAL_IS_HOST_MODULE
37     ifneq (,$(BUILD_HOST_static))
38         my_link_type := static
39     endif
40     ifeq (-static,$(filter -static,$(my_ldflags)))
41         my_link_type := static
42     endif
43 else
44     ifeq (true,$(LOCAL_FORCE_STATIC_EXECUTABLE))
45         my_link_type := static
46     endif
47 endif
48
49 ifneq ($(filter $(my_cxx_stl),libc++ libc++_static),)
50     my_cflags += -D_USING_LIBCXX
51     my_c_includes += external/libcxx/include
52     ifeq ($(my_cxx_stl),libc++)
53         my_shared_libraries += libc++
54     else
55         my_static_libraries += libc++_static
56         ifndef LOCAL_IS_HOST_MODULE
57             ifeq ($(LOCAL_FORCE_STATIC_EXECUTABLE),true)
58                 my_static_libraries += libm libc libdl
59             endif
60         endif
61     endif
62
63     ifdef LOCAL_IS_HOST_MODULE
64         my_cppflags += -nostdinc++
65         my_ldflags += -nodefaultlibs
66         my_ldlibs += -lpthread -lm
67         my_ldlibs += $($(my_prefix)$(HOST_OS)_$(my_link_type)_gcclibs)
68     else
69         ifeq (arm,$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))
70             my_static_libraries += libunwind_llvm
71             my_ldflags += -Wl,--exclude-libs,libunwind_llvm.a
72         endif
73
74         ifeq ($(my_link_type),static)
75             my_static_libraries += libdl
76         else
77             my_shared_libraries += libdl
78         endif
79     endif
80 else ifeq ($(my_cxx_stl),ndk)
81     # Using an NDK STL. Handled in binary.mk.
82     ifndef LOCAL_IS_HOST_MODULE
83         my_system_shared_libraries += libstdc++
84     endif
85 else ifeq ($(my_cxx_stl),libstdc++)
86     # Using bionic's basic libstdc++. Not actually an STL. Only around until the
87     # tree is in good enough shape to not need it.
88     ifndef LOCAL_IS_HOST_MODULE
89         my_c_includes += bionic/libstdc++/include
90         my_system_shared_libraries += libstdc++
91     endif
92     # Host builds will use GNU libstdc++.
93 else ifeq ($(my_cxx_stl),none)
94     ifdef LOCAL_IS_HOST_MODULE
95         my_cppflags += -nostdinc++
96         my_ldflags += -nodefaultlibs
97         my_ldlibs += $($(my_prefix)$(HOST_OS)_$(my_link_type)_gcclibs)
98     endif
99 else
100     $(error $(LOCAL_PATH): $(LOCAL_MODULE): $(my_cxx_stl) is not a supported STL.)
101 endif