blob: 3461f03d70d00146c4395ad97e6b6d28b2c63226 [file] [log] [blame]
Ying Wang75e8fcb2014-10-07 13:03:29 -07001#############################################################
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
Ying Wang75e8fcb2014-10-07 13:03:29 -07007# Select the appropriate C++ STL
8ifeq ($(strip $(LOCAL_CXX_STL)),default)
9 ifndef LOCAL_SDK_VERSION
Dan Albert93766b22014-10-16 19:07:41 -070010 # Platform code. Select the appropriate STL.
11 ifndef USE_MINGW
Ying Wang75e8fcb2014-10-07 13:03:29 -070012 my_cxx_stl := libc++
Dan Albert8bf4cc92015-03-03 14:10:27 -080013 ifdef LOCAL_IS_HOST_MODULE
14 ifneq (,$(BUILD_HOST_static))
15 my_cxx_stl := libc++_static
16 endif
17 endif
Ying Wang75e8fcb2014-10-07 13:03:29 -070018 else
Dan Albert93766b22014-10-16 19:07:41 -070019 # libc++ is not supported on mingw.
Dan Albert93e8cf72014-10-16 21:18:15 -070020 my_cxx_stl := libstdc++
Ying Wang75e8fcb2014-10-07 13:03:29 -070021 endif
22 else
23 my_cxx_stl := ndk
24 endif
25else
26 my_cxx_stl := $(strip $(LOCAL_CXX_STL))
27endif
28
Dan Albert4f2afde2015-03-03 17:42:28 -080029# Yes, this is actually what the clang driver does.
30HOST_dynamic_gcclibs := -lgcc_s -lgcc -lc -lgcc_s -lgcc
31HOST_static_gcclibs := -Wl,--start-group -lgcc -lgcc_eh -lc -Wl,--end-group
32
Dan Albertb5eb9052015-03-03 18:30:27 -080033my_link_type := dynamic
34ifdef LOCAL_IS_HOST_MODULE
35 ifneq (,$(BUILD_HOST_static))
36 my_link_type := static
37 endif
38 ifeq (-static,$(filter -static,$(my_ldflags)))
39 my_link_type := static
40 endif
41else
42 ifeq (true,$(LOCAL_FORCE_STATIC_EXECUTABLE))
43 my_link_type := static
44 endif
45endif
46
Ying Wang75e8fcb2014-10-07 13:03:29 -070047ifneq ($(filter $(my_cxx_stl),libc++ libc++_static),)
48 my_cflags += -D_USING_LIBCXX
49 my_c_includes += external/libcxx/include
50 ifeq ($(my_cxx_stl),libc++)
51 my_shared_libraries += libc++
52 else
53 my_static_libraries += libc++_static
54 endif
55
56 ifdef LOCAL_IS_HOST_MODULE
57 my_cppflags += -nostdinc++
58 my_ldflags += -nodefaultlibs
Dan Albert8bf4cc92015-03-03 14:10:27 -080059 my_ldlibs += -lpthread -lm
Dan Albertb5eb9052015-03-03 18:30:27 -080060 my_ldlibs += $($(my_prefix)$(my_link_type)_gcclibs)
Ying Wang75e8fcb2014-10-07 13:03:29 -070061 endif
62else ifneq ($(filter $(my_cxx_stl),stlport stlport_static),)
Dan Albertb49987e2014-10-16 09:53:51 -070063 ifndef LOCAL_IS_HOST_MODULE
64 my_c_includes += external/stlport/stlport bionic/libstdc++/include \
65 bionic
66 ifeq ($(my_cxx_stl),stlport)
67 my_shared_libraries += libstdc++ libstlport
68 else
69 my_static_libraries += libstdc++ libstlport_static
70 endif
Ying Wang75e8fcb2014-10-07 13:03:29 -070071 endif
72else ifeq ($(my_cxx_stl),ndk)
73 # Using an NDK STL. Handled farther up in this file.
74 ifndef LOCAL_IS_HOST_MODULE
75 my_system_shared_libraries += libstdc++
76 endif
Dan Albert93e8cf72014-10-16 21:18:15 -070077else ifeq ($(my_cxx_stl),libstdc++)
Ying Wang75e8fcb2014-10-07 13:03:29 -070078 # Using bionic's basic libstdc++. Not actually an STL. Only around until the
79 # tree is in good enough shape to not need it.
80 ifndef LOCAL_IS_HOST_MODULE
81 my_c_includes += bionic/libstdc++/include
82 my_system_shared_libraries += libstdc++
83 endif
84 # Host builds will use GNU libstdc++.
85else ifeq ($(my_cxx_stl),none)
86 ifdef LOCAL_IS_HOST_MODULE
87 my_cppflags += -nostdinc++
Dan Albert8bf4cc92015-03-03 14:10:27 -080088 my_ldflags += -nodefaultlibs
Dan Albertb5eb9052015-03-03 18:30:27 -080089 my_ldlibs += $($(my_prefix)$(my_link_type)_gcclibs)
Ying Wang75e8fcb2014-10-07 13:03:29 -070090 endif
91else
92 $(error $(my_cxx_stl) is not a supported STL.)
93endif