cxx_stl_setup.mk revision d666bb100965c1465eec5e03af30a30d33fafebe
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 8ifeq ($(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 25else 26 my_cxx_stl := $(strip $(LOCAL_CXX_STL)) 27endif 28 29# Yes, this is actually what the clang driver does. 30HOST_linux_dynamic_gcclibs := -lgcc_s -lgcc -lc -lgcc_s -lgcc 31HOST_linux_static_gcclibs := -Wl,--start-group -lgcc -lgcc_eh -lc -Wl,--end-group 32HOST_darwin_dynamic_gcclibs := -lc -lSystem 33HOST_darwin_static_gcclibs := NO_STATIC_HOST_BINARIES_ON_DARWIN 34 35my_link_type := dynamic 36ifdef 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 43else 44 ifeq (true,$(LOCAL_FORCE_STATIC_EXECUTABLE)) 45 my_link_type := static 46 endif 47endif 48 49ifneq ($(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 endif 57 58 ifdef LOCAL_IS_HOST_MODULE 59 my_cppflags += -nostdinc++ 60 my_ldflags += -nodefaultlibs 61 my_ldlibs += -lpthread -lm 62 my_ldlibs += $($(my_prefix)$(HOST_OS)_$(my_link_type)_gcclibs) 63 endif 64else ifneq ($(filter $(my_cxx_stl),stlport stlport_static),) 65 ifndef LOCAL_IS_HOST_MODULE 66 my_c_includes += external/stlport/stlport bionic/libstdc++/include \ 67 bionic 68 ifeq ($(my_cxx_stl),stlport) 69 my_shared_libraries += libstdc++ libstlport 70 else 71 my_static_libraries += libstdc++ libstlport_static 72 endif 73 endif 74else ifeq ($(my_cxx_stl),ndk) 75 # Using an NDK STL. Handled farther up in this file. 76 ifndef LOCAL_IS_HOST_MODULE 77 my_system_shared_libraries += libstdc++ 78 endif 79else ifeq ($(my_cxx_stl),libstdc++) 80 # Using bionic's basic libstdc++. Not actually an STL. Only around until the 81 # tree is in good enough shape to not need it. 82 ifndef LOCAL_IS_HOST_MODULE 83 my_c_includes += bionic/libstdc++/include 84 my_system_shared_libraries += libstdc++ 85 endif 86 # Host builds will use GNU libstdc++. 87else ifeq ($(my_cxx_stl),none) 88 ifdef LOCAL_IS_HOST_MODULE 89 my_cppflags += -nostdinc++ 90 my_ldflags += -nodefaultlibs 91 my_ldlibs += $($(my_prefix)$(HOST_OS)_$(my_link_type)_gcclibs) 92 endif 93else 94 $(error $(my_cxx_stl) is not a supported STL.) 95endif 96