blob: 1cb73eae982c349f6c955f827d26fde71cfde3c2 [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
Ying Wang75e8fcb2014-10-07 13:03:29 -070033ifneq ($(filter $(my_cxx_stl),libc++ libc++_static),)
34 my_cflags += -D_USING_LIBCXX
35 my_c_includes += external/libcxx/include
36 ifeq ($(my_cxx_stl),libc++)
37 my_shared_libraries += libc++
38 else
39 my_static_libraries += libc++_static
40 endif
41
42 ifdef LOCAL_IS_HOST_MODULE
43 my_cppflags += -nostdinc++
44 my_ldflags += -nodefaultlibs
Dan Albert8bf4cc92015-03-03 14:10:27 -080045 my_ldlibs += -lpthread -lm
Dan Albert4f2afde2015-03-03 17:42:28 -080046 ifeq (,$(BUILD_HOST_static))
47 my_ldlibs += $(HOST_dynamic_gcclibs)
48 else
49 my_ldlibs += $(HOST_static_gcclibs)
50 endif
Ying Wang75e8fcb2014-10-07 13:03:29 -070051 endif
52else ifneq ($(filter $(my_cxx_stl),stlport stlport_static),)
Dan Albertb49987e2014-10-16 09:53:51 -070053 ifndef LOCAL_IS_HOST_MODULE
54 my_c_includes += external/stlport/stlport bionic/libstdc++/include \
55 bionic
56 ifeq ($(my_cxx_stl),stlport)
57 my_shared_libraries += libstdc++ libstlport
58 else
59 my_static_libraries += libstdc++ libstlport_static
60 endif
Ying Wang75e8fcb2014-10-07 13:03:29 -070061 endif
62else ifeq ($(my_cxx_stl),ndk)
63 # Using an NDK STL. Handled farther up in this file.
64 ifndef LOCAL_IS_HOST_MODULE
65 my_system_shared_libraries += libstdc++
66 endif
Dan Albert93e8cf72014-10-16 21:18:15 -070067else ifeq ($(my_cxx_stl),libstdc++)
Ying Wang75e8fcb2014-10-07 13:03:29 -070068 # Using bionic's basic libstdc++. Not actually an STL. Only around until the
69 # tree is in good enough shape to not need it.
70 ifndef LOCAL_IS_HOST_MODULE
71 my_c_includes += bionic/libstdc++/include
72 my_system_shared_libraries += libstdc++
73 endif
74 # Host builds will use GNU libstdc++.
75else ifeq ($(my_cxx_stl),none)
76 ifdef LOCAL_IS_HOST_MODULE
77 my_cppflags += -nostdinc++
Dan Albert8bf4cc92015-03-03 14:10:27 -080078 my_ldflags += -nodefaultlibs
Dan Albert4f2afde2015-03-03 17:42:28 -080079 ifeq (,$(BUILD_HOST_static))
80 my_ldlibs += $(HOST_dynamic_gcclibs)
81 else
82 my_ldlibs += $(HOST_static_gcclibs)
83 endif
Ying Wang75e8fcb2014-10-07 13:03:29 -070084 endif
85else
86 $(error $(my_cxx_stl) is not a supported STL.)
87endif