Android.mk revision 16d1af167f8e36a9aa4a07ae77034ad519b00463
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 property_benchmark.cpp \ 35 string_benchmark.cpp \ 36 time_benchmark.cpp \ 37 38# Build benchmarks for the device (with bionic's .so). Run with: 39# adb shell bionic-benchmarks 40include $(CLEAR_VARS) 41LOCAL_MODULE := bionic-benchmarks 42LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 43LOCAL_CFLAGS += $(benchmark_c_flags) 44LOCAL_C_INCLUDES += external/stlport/stlport bionic/ bionic/libstdc++/include 45LOCAL_SHARED_LIBRARIES += libstlport 46LOCAL_SRC_FILES := $(benchmark_src_files) 47include $(BUILD_EXECUTABLE) 48 49# ----------------------------------------------------------------------------- 50# Unit tests. 51# ----------------------------------------------------------------------------- 52 53test_c_flags = \ 54 -fstack-protector-all \ 55 -g \ 56 -Wall -Wextra \ 57 -Werror \ 58 -fno-builtin \ 59 60test_src_files = \ 61 dirent_test.cpp \ 62 eventfd_test.cpp \ 63 fenv_test.cpp \ 64 fortify1_test.cpp \ 65 fortify2_test.cpp \ 66 getauxval_test.cpp \ 67 getcwd_test.cpp \ 68 libc_logging_test.cpp \ 69 libgen_test.cpp \ 70 malloc_test.cpp \ 71 math_test.cpp \ 72 netdb_test.cpp \ 73 pthread_test.cpp \ 74 regex_test.cpp \ 75 signal_test.cpp \ 76 stack_protector_test.cpp \ 77 stdio_test.cpp \ 78 stdlib_test.cpp \ 79 string_test.cpp \ 80 strings_test.cpp \ 81 stubs_test.cpp \ 82 system_properties_test.cpp \ 83 time_test.cpp \ 84 unistd_test.cpp \ 85 86test_dynamic_ldflags = -Wl,--export-dynamic -Wl,-u,DlSymTestFunction 87test_dynamic_src_files = \ 88 dlfcn_test.cpp \ 89 90# Build tests for the device (with bionic's .so). Run with: 91# adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests 92include $(CLEAR_VARS) 93LOCAL_MODULE := bionic-unit-tests 94LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 95LOCAL_CFLAGS += $(test_c_flags) 96LOCAL_LDFLAGS += $(test_dynamic_ldflags) 97LOCAL_SHARED_LIBRARIES += libdl 98LOCAL_SRC_FILES := $(test_src_files) $(test_dynamic_src_files) 99LOCAL_WHOLE_STATIC_LIBRARIES := bionic-unit-tests-clang 100include $(BUILD_NATIVE_TEST) 101 102# Build tests for the device (with bionic's .a). Run with: 103# adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static 104include $(CLEAR_VARS) 105LOCAL_MODULE := bionic-unit-tests-static 106LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 107LOCAL_CFLAGS += $(test_c_flags) 108LOCAL_FORCE_STATIC_EXECUTABLE := true 109LOCAL_SRC_FILES := $(test_src_files) 110LOCAL_STATIC_LIBRARIES += libstlport_static libstdc++ libm libc 111LOCAL_WHOLE_STATIC_LIBRARIES := bionic-unit-tests-clang 112include $(BUILD_NATIVE_TEST) 113 114# ----------------------------------------------------------------------------- 115# Test library for the unit tests. 116# ----------------------------------------------------------------------------- 117 118# Build no-elf-hash-table-library.so to test dlopen(3) on a library that 119# only has a GNU-style hash table. MIPS doesn't support GNU hash style. 120ifneq ($(TARGET_ARCH),mips) 121include $(CLEAR_VARS) 122LOCAL_MODULE := no-elf-hash-table-library 123LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 124LOCAL_SRC_FILES := empty.cpp 125LOCAL_LDFLAGS := -Wl,--hash-style=gnu 126include $(BUILD_SHARED_LIBRARY) 127endif 128 129# ----------------------------------------------------------------------------- 130# Unit tests built against glibc. 131# ----------------------------------------------------------------------------- 132 133# Build tests for the host (with glibc). 134# Note that this will build against glibc, so it's not useful for testing 135# bionic's implementation, but it does let you use glibc as a reference 136# implementation for testing the tests themselves. 137ifeq ($(HOST_OS)-$(HOST_ARCH),linux-x86) 138include $(CLEAR_VARS) 139LOCAL_MODULE := bionic-unit-tests-glibc 140LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 141LOCAL_CFLAGS += $(test_c_flags) 142LOCAL_LDFLAGS += -lpthread -ldl 143LOCAL_LDFLAGS += $(test_dynamic_ldflags) 144LOCAL_SRC_FILES := $(test_src_files) $(test_dynamic_src_files) 145include $(BUILD_HOST_NATIVE_TEST) 146endif 147 148# ----------------------------------------------------------------------------- 149# Unit tests which depend on clang as the compiler 150# ----------------------------------------------------------------------------- 151include $(CLEAR_VARS) 152LOCAL_SRC_FILES := fortify1_test_clang.cpp fortify2_test_clang.cpp 153LOCAL_MODULE := bionic-unit-tests-clang 154LOCAL_CLANG := true 155 156# -Wno-error=unused-parameter needed as 157# external/stlport/stlport/stl/_threads.c (included from 158# external/gtest/include/gtest/gtest.h) does not compile cleanly under 159# clang. TODO: fix this. 160LOCAL_CFLAGS += $(test_c_flags) -Wno-error=unused-parameter 161 162LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 163LOCAL_C_INCLUDES += bionic \ 164 bionic/libstdc++/include \ 165 external/stlport/stlport \ 166 external/gtest/include 167 168include $(BUILD_STATIC_LIBRARY) 169 170endif # !BUILD_TINY_ANDROID 171