Android.mk revision a0ee07829a9ba7e99ef68e8c12551301cc797f0f
1#
2# Copyright (C) 2012 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#      http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
17ifneq ($(BUILD_TINY_ANDROID), true)
18
19LOCAL_PATH := $(call my-dir)
20
21# -----------------------------------------------------------------------------
22# Benchmarks.
23# -----------------------------------------------------------------------------
24
25benchmark_c_flags = \
26    -O2 \
27    -Wall -Wextra \
28    -Werror \
29
30benchmark_src_files = \
31    benchmark_main.cpp \
32    string_benchmark.cpp \
33
34# Build benchmarks for the device (with bionic's .so). Run with:
35#   adb shell bionic-benchmarks
36include $(CLEAR_VARS)
37LOCAL_MODULE := bionic-benchmarks
38LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
39LOCAL_CFLAGS += $(benchmark_c_flags)
40LOCAL_C_INCLUDES += external/stlport/stlport bionic/ bionic/libstdc++/include
41LOCAL_SHARED_LIBRARIES += libstlport
42LOCAL_SRC_FILES := $(benchmark_src_files)
43include $(BUILD_EXECUTABLE)
44
45# -----------------------------------------------------------------------------
46# Unit tests.
47# -----------------------------------------------------------------------------
48
49test_c_flags = \
50    -fstack-protector-all \
51    -g \
52    -Wall -Wextra \
53    -Werror \
54    -fno-builtin \
55
56test_src_files = \
57    debug_format_test.cpp \
58    dirent_test.cpp \
59    fenv_test.cpp \
60    getauxval_test.cpp \
61    getcwd_test.cpp \
62    libgen_test.cpp \
63    math_test.cpp \
64    pthread_test.cpp \
65    regex_test.cpp \
66    signal_test.cpp \
67    stack_protector_test.cpp \
68    stdio_test.cpp \
69    stdlib_test.cpp \
70    string_test.cpp \
71    stubs_test.cpp \
72    unistd_test.cpp \
73
74test_dynamic_ldflags = -Wl,--export-dynamic -Wl,-u,DlSymTestFunction
75test_dynamic_src_files = \
76    dlfcn_test.cpp \
77
78# Build tests for the device (with bionic's .so). Run with:
79#   adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests
80include $(CLEAR_VARS)
81LOCAL_MODULE := bionic-unit-tests
82LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
83LOCAL_CFLAGS += $(test_c_flags)
84LOCAL_LDFLAGS += $(test_dynamic_ldflags)
85LOCAL_SHARED_LIBRARIES += libdl
86LOCAL_SRC_FILES := $(test_src_files) $(test_dynamic_src_files)
87include $(BUILD_NATIVE_TEST)
88
89# Build tests for the device (with bionic's .a). Run with:
90#   adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static
91include $(CLEAR_VARS)
92LOCAL_MODULE := bionic-unit-tests-static
93LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
94LOCAL_CFLAGS += $(test_c_flags)
95LOCAL_FORCE_STATIC_EXECUTABLE := true
96LOCAL_SRC_FILES := $(test_src_files)
97LOCAL_STATIC_LIBRARIES += libstlport_static libstdc++ libm libc
98include $(BUILD_NATIVE_TEST)
99
100# -----------------------------------------------------------------------------
101# Test library for the unit tests.
102# -----------------------------------------------------------------------------
103
104# Build no-elf-hash-table-library.so to test dlopen(3) on a library that
105# only has a GNU-style hash table. MIPS doesn't support GNU hash style.
106ifneq ($(TARGET_ARCH),mips)
107include $(CLEAR_VARS)
108LOCAL_MODULE := no-elf-hash-table-library
109LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
110LOCAL_SRC_FILES := empty.cpp
111LOCAL_LDFLAGS := -Wl,--hash-style=gnu
112include $(BUILD_SHARED_LIBRARY)
113endif
114
115# -----------------------------------------------------------------------------
116# Unit tests built against glibc.
117# -----------------------------------------------------------------------------
118
119# Build tests for the host (with glibc).
120# Note that this will build against glibc, so it's not useful for testing
121# bionic's implementation, but it does let you use glibc as a reference
122# implementation for testing the tests themselves.
123ifeq ($(HOST_OS)-$(HOST_ARCH),linux-x86)
124include $(CLEAR_VARS)
125LOCAL_MODULE := bionic-unit-tests-glibc
126LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
127LOCAL_CFLAGS += $(test_c_flags)
128LOCAL_LDFLAGS += -lpthread -ldl
129LOCAL_LDFLAGS += $(test_dynamic_ldflags)
130LOCAL_SRC_FILES := $(test_src_files) $(test_dynamic_src_files)
131include $(BUILD_HOST_NATIVE_TEST)
132endif
133
134endif # !BUILD_TINY_ANDROID
135