1 ##############################################################################
2 #
3 #  Copyright (C) 2014 Google, Inc.
4 #
5 #  Licensed under the Apache License, Version 2.0 (the "License");
6 #  you may not use this file except in compliance with the License.
7 #  You may obtain a copy of the License at:
8 #
9 #  http://www.apache.org/licenses/LICENSE-2.0
10 #
11 #  Unless required by applicable law or agreed to in writing, software
12 #  distributed under the License is distributed on an "AS IS" BASIS,
13 #  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 #  See the License for the specific language governing permissions and
15 #  limitations under the License.
16 #
17 ##############################################################################
18
19LOCAL_PATH := $(call my-dir)
20
21# Common variables
22# ========================================================
23btcoreCommonSrc := \
24    src/bdaddr.c \
25    src/device_class.c \
26    src/hal_util.c \
27    src/module.c \
28    src/osi_module.c \
29    src/property.c \
30    src/uuid.c
31
32btcoreCommonTestSrc := \
33    ./test/bdaddr_test.cpp \
34    ./test/device_class_test.cpp \
35    ./test/property_test.cpp \
36    ./test/uuid_test.cpp \
37    ../osi/test/AllocationTestHarness.cpp
38
39btcoreCommonIncludes := \
40    $(LOCAL_PATH)/include \
41    $(LOCAL_PATH)/..
42
43# libbtcore static library for target
44# ========================================================
45include $(CLEAR_VARS)
46LOCAL_C_INCLUDES := $(btcoreCommonIncludes)
47LOCAL_SRC_FILES := $(btcoreCommonSrc)
48LOCAL_MODULE := libbtcore
49LOCAL_MODULE_TAGS := optional
50LOCAL_SHARED_LIBRARIES := libc liblog
51LOCAL_MODULE_CLASS := STATIC_LIBRARIES
52
53LOCAL_CFLAGS += $(bluetooth_CFLAGS)
54LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS)
55LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS)
56
57include $(BUILD_STATIC_LIBRARY)
58
59# libbtcore static library for host
60# ========================================================
61ifeq ($(HOST_OS),linux)
62include $(CLEAR_VARS)
63LOCAL_C_INCLUDES := $(btcoreCommonIncludes)
64LOCAL_SRC_FILES := $(btcoreCommonSrc)
65LOCAL_MODULE := libbtcore-host
66LOCAL_MODULE_TAGS := optional
67LOCAL_SHARED_LIBRARIES := liblog
68LOCAL_MODULE_CLASS := STATIC_LIBRARIES
69
70# TODO(armansito): Setting _GNU_SOURCE isn't very platform-independent but
71# should be compatible for a Linux host OS. We should figure out what to do for
72# a non-Linux host OS.
73LOCAL_CFLAGS += $(bluetooth_CFLAGS) -D_GNU_SOURCE
74LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS)
75LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS)
76
77include $(BUILD_HOST_STATIC_LIBRARY)
78endif
79
80# Note: It's good to get the tests compiled both for the host and the target so
81# we get to test with both Bionic libc and glibc
82
83# libbtcore unit tests for target
84# ========================================================
85include $(CLEAR_VARS)
86LOCAL_C_INCLUDES := $(btcoreCommonIncludes)
87LOCAL_SRC_FILES := $(btcoreCommonTestSrc)
88LOCAL_MODULE := net_test_btcore
89LOCAL_MODULE_TAGS := tests
90LOCAL_SHARED_LIBRARIES := liblog
91LOCAL_STATIC_LIBRARIES := libbtcore libosi
92
93LOCAL_CFLAGS += $(bluetooth_CFLAGS)
94LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS)
95LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS)
96
97include $(BUILD_NATIVE_TEST)
98
99# libbtcore unit tests for host
100# ========================================================
101ifeq ($(HOST_OS),linux)
102include $(CLEAR_VARS)
103LOCAL_C_INCLUDES := $(btcoreCommonIncludes)
104LOCAL_SRC_FILES := $(btcoreCommonTestSrc)
105LOCAL_MODULE := net_test_btcore
106LOCAL_MODULE_TAGS := tests
107LOCAL_SHARED_LIBRARIES := liblog
108LOCAL_STATIC_LIBRARIES := libbtcore-host libosi-host
109
110LOCAL_CFLAGS += $(bluetooth_CFLAGS)
111LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS)
112LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS)
113
114include $(BUILD_HOST_NATIVE_TEST)
115endif
116