Android.mk revision c45087bffa528c0809f0df2e0a3708eba7018b33
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 stack_unwinding_test.cpp \ 78 stdio_test.cpp \ 79 stdlib_test.cpp \ 80 string_test.cpp \ 81 strings_test.cpp \ 82 stubs_test.cpp \ 83 system_properties_test.cpp \ 84 time_test.cpp \ 85 unistd_test.cpp \ 86 87test_dynamic_ldflags = -Wl,--export-dynamic -Wl,-u,DlSymTestFunction 88test_dynamic_src_files = \ 89 dlfcn_test.cpp \ 90 91include $(CLEAR_VARS) 92LOCAL_MODULE := bionic-unit-tests-unwind-test-impl 93LOCAL_CFLAGS += $(test_c_flags) -fexceptions -fnon-call-exceptions 94LOCAL_SRC_FILES := stack_unwinding_test_impl.c 95include $(BUILD_STATIC_LIBRARY) 96 97include $(CLEAR_VARS) 98LOCAL_MODULE := bionic-unit-tests-unwind-test-impl-host 99LOCAL_CFLAGS += $(test_c_flags) -fexceptions -fnon-call-exceptions 100LOCAL_SRC_FILES := stack_unwinding_test_impl.c 101include $(BUILD_HOST_STATIC_LIBRARY) 102 103# Build tests for the device (with bionic's .so). Run with: 104# adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests 105include $(CLEAR_VARS) 106LOCAL_MODULE := bionic-unit-tests 107LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 108LOCAL_CFLAGS += $(test_c_flags) 109LOCAL_LDFLAGS += $(test_dynamic_ldflags) 110LOCAL_SHARED_LIBRARIES += libdl 111LOCAL_SRC_FILES := $(test_src_files) $(test_dynamic_src_files) 112LOCAL_WHOLE_STATIC_LIBRARIES := bionic-unit-tests-clang 113LOCAL_STATIC_LIBRARIES += bionic-unit-tests-unwind-test-impl 114include $(BUILD_NATIVE_TEST) 115 116# Build tests for the device (with bionic's .a). Run with: 117# adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static 118include $(CLEAR_VARS) 119LOCAL_MODULE := bionic-unit-tests-static 120LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 121LOCAL_CFLAGS += $(test_c_flags) 122LOCAL_FORCE_STATIC_EXECUTABLE := true 123LOCAL_SRC_FILES := $(test_src_files) 124LOCAL_STATIC_LIBRARIES += libstlport_static libstdc++ libm libc bionic-unit-tests-unwind-test-impl 125LOCAL_WHOLE_STATIC_LIBRARIES := bionic-unit-tests-clang 126include $(BUILD_NATIVE_TEST) 127 128# ----------------------------------------------------------------------------- 129# Test library for the unit tests. 130# ----------------------------------------------------------------------------- 131 132# Build no-elf-hash-table-library.so to test dlopen(3) on a library that 133# only has a GNU-style hash table. MIPS doesn't support GNU hash style. 134ifneq ($(TARGET_ARCH),mips) 135include $(CLEAR_VARS) 136LOCAL_MODULE := no-elf-hash-table-library 137LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 138LOCAL_SRC_FILES := empty.cpp 139LOCAL_LDFLAGS := -Wl,--hash-style=gnu 140include $(BUILD_SHARED_LIBRARY) 141endif 142 143# ----------------------------------------------------------------------------- 144# Unit tests built against glibc. 145# ----------------------------------------------------------------------------- 146 147# Build tests for the host (with glibc). 148# Note that this will build against glibc, so it's not useful for testing 149# bionic's implementation, but it does let you use glibc as a reference 150# implementation for testing the tests themselves. 151ifeq ($(HOST_OS)-$(HOST_ARCH),linux-x86) 152include $(CLEAR_VARS) 153LOCAL_MODULE := bionic-unit-tests-glibc 154LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 155LOCAL_CFLAGS += $(test_c_flags) 156LOCAL_LDFLAGS += -lpthread -ldl 157LOCAL_LDFLAGS += $(test_dynamic_ldflags) 158LOCAL_SRC_FILES := $(test_src_files) $(test_dynamic_src_files) 159LOCAL_STATIC_LIBRARIES += bionic-unit-tests-unwind-test-impl-host 160include $(BUILD_HOST_NATIVE_TEST) 161endif 162 163# ----------------------------------------------------------------------------- 164# Unit tests which depend on clang as the compiler 165# ----------------------------------------------------------------------------- 166include $(CLEAR_VARS) 167LOCAL_SRC_FILES := fortify1_test_clang.cpp fortify2_test_clang.cpp 168LOCAL_MODULE := bionic-unit-tests-clang 169LOCAL_CLANG := true 170 171# -Wno-error=unused-parameter needed as 172# external/stlport/stlport/stl/_threads.c (included from 173# external/gtest/include/gtest/gtest.h) does not compile cleanly under 174# clang. TODO: fix this. 175LOCAL_CFLAGS += $(test_c_flags) -Wno-error=unused-parameter 176 177LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 178LOCAL_C_INCLUDES += bionic \ 179 bionic/libstdc++/include \ 180 external/stlport/stlport \ 181 external/gtest/include 182 183include $(BUILD_STATIC_LIBRARY) 184 185endif # !BUILD_TINY_ANDROID 186