Android.mk revision 3e898476c7230b60a0f76968e64ff25f475b48c0
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    -fno-builtin \
30
31benchmark_src_files = \
32    benchmark_main.cpp \
33    math_benchmark.cpp \
34    string_benchmark.cpp \
35
36# Build benchmarks for the device (with bionic's .so). Run with:
37#   adb shell bionic-benchmarks
38include $(CLEAR_VARS)
39LOCAL_MODULE := bionic-benchmarks
40LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
41LOCAL_CFLAGS += $(benchmark_c_flags)
42LOCAL_C_INCLUDES += external/stlport/stlport bionic/ bionic/libstdc++/include
43LOCAL_SHARED_LIBRARIES += libstlport
44LOCAL_SRC_FILES := $(benchmark_src_files)
45include $(BUILD_EXECUTABLE)
46
47# -----------------------------------------------------------------------------
48# Unit tests.
49# -----------------------------------------------------------------------------
50
51test_c_flags = \
52    -fstack-protector-all \
53    -g \
54    -Wall -Wextra \
55    -Werror \
56    -fno-builtin \
57
58test_src_files = \
59    debug_format_test.cpp \
60    dirent_test.cpp \
61    fenv_test.cpp \
62    getauxval_test.cpp \
63    getcwd_test.cpp \
64    libgen_test.cpp \
65    math_test.cpp \
66    pthread_test.cpp \
67    regex_test.cpp \
68    signal_test.cpp \
69    stack_protector_test.cpp \
70    stdio_test.cpp \
71    stdlib_test.cpp \
72    string_test.cpp \
73    stubs_test.cpp \
74    unistd_test.cpp \
75
76test_dynamic_ldflags = -Wl,--export-dynamic -Wl,-u,DlSymTestFunction
77test_dynamic_src_files = \
78    dlfcn_test.cpp \
79
80# Build tests for the device (with bionic's .so). Run with:
81#   adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests
82include $(CLEAR_VARS)
83LOCAL_MODULE := bionic-unit-tests
84LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
85LOCAL_CFLAGS += $(test_c_flags)
86LOCAL_LDFLAGS += $(test_dynamic_ldflags)
87LOCAL_SHARED_LIBRARIES += libdl
88LOCAL_SRC_FILES := $(test_src_files) $(test_dynamic_src_files)
89include $(BUILD_NATIVE_TEST)
90
91# Build tests for the device (with bionic's .a). Run with:
92#   adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static
93include $(CLEAR_VARS)
94LOCAL_MODULE := bionic-unit-tests-static
95LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
96LOCAL_CFLAGS += $(test_c_flags)
97LOCAL_FORCE_STATIC_EXECUTABLE := true
98LOCAL_SRC_FILES := $(test_src_files)
99LOCAL_STATIC_LIBRARIES += libstlport_static libstdc++ libm libc
100include $(BUILD_NATIVE_TEST)
101
102# -----------------------------------------------------------------------------
103# Test library for the unit tests.
104# -----------------------------------------------------------------------------
105
106# Build no-elf-hash-table-library.so to test dlopen(3) on a library that
107# only has a GNU-style hash table. MIPS doesn't support GNU hash style.
108ifneq ($(TARGET_ARCH),mips)
109include $(CLEAR_VARS)
110LOCAL_MODULE := no-elf-hash-table-library
111LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
112LOCAL_SRC_FILES := empty.cpp
113LOCAL_LDFLAGS := -Wl,--hash-style=gnu
114include $(BUILD_SHARED_LIBRARY)
115endif
116
117# -----------------------------------------------------------------------------
118# Unit tests built against glibc.
119# -----------------------------------------------------------------------------
120
121# Build tests for the host (with glibc).
122# Note that this will build against glibc, so it's not useful for testing
123# bionic's implementation, but it does let you use glibc as a reference
124# implementation for testing the tests themselves.
125ifeq ($(HOST_OS)-$(HOST_ARCH),linux-x86)
126include $(CLEAR_VARS)
127LOCAL_CXX := /usr/bin/g++ # Avoid the host prebuilt so we test the real glibc.
128LOCAL_MODULE := bionic-unit-tests-glibc
129LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
130LOCAL_CFLAGS += $(test_c_flags)
131LOCAL_LDFLAGS += -lpthread -ldl
132LOCAL_LDFLAGS += $(test_dynamic_ldflags)
133LOCAL_SRC_FILES := $(test_src_files) $(test_dynamic_src_files)
134include $(BUILD_HOST_NATIVE_TEST)
135endif
136
137endif # !BUILD_TINY_ANDROID
138