Anestis Bechtsoudis | c1f6faa | 2015-07-31 05:32:19 +0300 | [diff] [blame] | 1 | # honggfuzz - Android makefile |
| 2 | # ----------------------------------------- |
| 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 | LOCAL_PATH := $(abspath $(call my-dir)/..) |
Anestis Bechtsoudis | cfc39fb | 2015-08-06 10:31:36 +0300 | [diff] [blame] | 17 | |
Anestis Bechtsoudis | f181272 | 2015-08-19 10:12:19 +0300 | [diff] [blame] | 18 | # Enable Linux ptrace() instead of POSIX signal interface by default |
Anestis Bechtsoudis | cfc39fb | 2015-08-06 10:31:36 +0300 | [diff] [blame] | 19 | ANDROID_WITH_PTRACE ?= true |
| 20 | |
Anestis Bechtsoudis | cfc39fb | 2015-08-06 10:31:36 +0300 | [diff] [blame] | 21 | ifeq ($(ANDROID_WITH_PTRACE),true) |
Anestis Bechtsoudis | f181272 | 2015-08-19 10:12:19 +0300 | [diff] [blame] | 22 | ifeq ($(APP_ABI),$(filter $(APP_ABI),armeabi armeabi-v7a)) |
| 23 | ARCH_ABI := arm |
| 24 | UNW_ARCH := arm |
| 25 | else ifeq ($(APP_ABI),$(filter $(APP_ABI),x86)) |
| 26 | ARCH_ABI := x86 |
| 27 | UNW_ARCH := x86 |
| 28 | else ifeq ($(APP_ABI),$(filter $(APP_ABI),arm64-v8a)) |
| 29 | ARCH_ABI := arm64 |
| 30 | UNW_ARCH := aarch64 |
| 31 | else ifeq ($(APP_ABI),$(filter $(APP_ABI),x86_64)) |
| 32 | ARCH_ABI := x86_64 |
| 33 | UNW_ARCH := x86_64 |
| 34 | $(error $(APP_ABI) Android not supported with ptrace API (issues with libunwind)) |
| 35 | else |
| 36 | $(error Unsuported / Unknown APP_API '$(APP_ABI)') |
| 37 | endif |
| 38 | |
Anestis Bechtsoudis | cfc39fb | 2015-08-06 10:31:36 +0300 | [diff] [blame] | 39 | # Upstream libunwind compiled from sources with Android NDK toolchain |
| 40 | LIBUNWIND_A := third_party/android/libunwind/$(ARCH_ABI)/libunwind-$(UNW_ARCH).a |
| 41 | ifeq ("$(wildcard $(LIBUNWIND_A))","") |
| 42 | $(error libunwind-$(UNW_ARCH). is missing. Please execute \ |
| 43 | 'third_party/android/scripts/compile-libunwind.sh third_party/android/libunwind $(ARCH_ABI)') |
| 44 | endif |
| 45 | |
| 46 | include $(CLEAR_VARS) |
| 47 | LOCAL_MODULE := libunwind |
| 48 | LOCAL_SRC_FILES := third_party/android/libunwind/$(ARCH_ABI)/libunwind.a |
| 49 | LOCAL_EXPORT_C_INCLUDES := third_party/android/libunwind/include |
| 50 | include $(PREBUILT_STATIC_LIBRARY) |
| 51 | |
| 52 | include $(CLEAR_VARS) |
| 53 | LOCAL_MODULE := libunwind-arch |
| 54 | LOCAL_SRC_FILES := third_party/android/libunwind/$(ARCH_ABI)/libunwind-$(UNW_ARCH).a |
| 55 | LOCAL_EXPORT_C_INCLUDES := third_party/android/libunwind/include |
| 56 | include $(PREBUILT_STATIC_LIBRARY) |
| 57 | |
| 58 | include $(CLEAR_VARS) |
| 59 | LOCAL_MODULE := libunwind-ptrace |
| 60 | LOCAL_SRC_FILES := third_party/android/libunwind/$(ARCH_ABI)/libunwind-ptrace.a |
| 61 | LOCAL_EXPORT_C_INCLUDES := third_party/android/libunwind/include |
| 62 | include $(PREBUILT_STATIC_LIBRARY) |
| 63 | |
| 64 | LOCAL_MODULE := libunwind-dwarf-generic |
| 65 | LOCAL_SRC_FILES := third_party/android/libunwind/$(ARCH_ABI)/libunwind-dwarf-generic.a |
| 66 | LOCAL_EXPORT_C_INCLUDES := third_party/android/libunwind/include |
| 67 | include $(PREBUILT_STATIC_LIBRARY) |
| 68 | |
| 69 | # Upstream capstone compiled from sources with Android NDK toolchain |
| 70 | LIBCAPSTONE_A := third_party/android/capstone/$(ARCH_ABI)/libcapstone.a |
| 71 | ifeq ("$(wildcard $(LIBCAPSTONE_A))","") |
| 72 | $(error libunwind-$(UNW_ARCH). is missing. Please execute \ |
| 73 | 'third_party/android/scripts/compile-capstone.sh third_party/android/capstone $(ARCH_ABI)') |
| 74 | endif |
| 75 | include $(CLEAR_VARS) |
| 76 | LOCAL_MODULE := libcapstone |
| 77 | LOCAL_SRC_FILES := $(LIBCAPSTONE_A) |
| 78 | LOCAL_EXPORT_C_INCLUDES := third_party/android/capstone/include |
| 79 | include $(PREBUILT_STATIC_LIBRARY) |
| 80 | endif |
| 81 | |
| 82 | # Main honggfuzz module |
Anestis Bechtsoudis | c1f6faa | 2015-07-31 05:32:19 +0300 | [diff] [blame] | 83 | include $(CLEAR_VARS) |
| 84 | |
| 85 | LOCAL_MODULE := honggfuzz |
| 86 | LOCAL_SRC_FILES := honggfuzz.c log.c files.c fuzz.c report.c mangle.c util.c |
| 87 | LOCAL_CFLAGS := -std=c11 -I. \ |
| 88 | -D_GNU_SOURCE \ |
Anestis Bechtsoudis | cfc39fb | 2015-08-06 10:31:36 +0300 | [diff] [blame] | 89 | -Wall -Wextra -Wno-initializer-overrides -Wno-override-init \ |
| 90 | -Wno-unknown-warning-option -Werror -funroll-loops -O2 |
Anestis Bechtsoudis | c1f6faa | 2015-07-31 05:32:19 +0300 | [diff] [blame] | 91 | LOCAL_LDFLAGS := -lm |
| 92 | |
Anestis Bechtsoudis | cfc39fb | 2015-08-06 10:31:36 +0300 | [diff] [blame] | 93 | ifeq ($(ANDROID_WITH_PTRACE),true) |
| 94 | LOCAL_C_INCLUDES := third_party/android/libunwind/include third_party/android/capstone/include |
| 95 | LOCAL_STATIC_LIBRARIES := libunwind libunwind-arch libunwind-ptrace libunwind-dwarf-generic libcapstone |
| 96 | LOCAL_CFLAGS += -D__HF_USE_CAPSTONE__ |
| 97 | ARCH_SRCS := linux/arch.c linux/ptrace_utils.c linux/perf.c linux/unwind.c |
| 98 | ARCH := LINUX |
| 99 | $(info $(shell (echo "********************************************************************"))) |
| 100 | $(info $(shell (echo "Android PTRACE build: Will prevent debuggerd from processing crashes"))) |
| 101 | $(info $(shell (echo "********************************************************************"))) |
| 102 | else |
| 103 | ARCH_SRCS := posix/arch.c |
| 104 | ARCH := POSIX |
| 105 | $(info $(shell (echo "********************************************************************"))) |
Anestis Bechtsoudis | 61a8f4f | 2015-08-20 08:39:26 +0300 | [diff] [blame] | 106 | $(info $(shell (echo "Android POSIX build: Will allow debuggerd to also process crashes"))) |
Anestis Bechtsoudis | cfc39fb | 2015-08-06 10:31:36 +0300 | [diff] [blame] | 107 | $(info $(shell (echo "********************************************************************"))) |
| 108 | endif |
Anestis Bechtsoudis | c1f6faa | 2015-07-31 05:32:19 +0300 | [diff] [blame] | 109 | |
| 110 | LOCAL_SRC_FILES += $(ARCH_SRCS) |
| 111 | LOCAL_CFLAGS += -D_HF_ARCH_${ARCH} |
| 112 | |
| 113 | include $(BUILD_EXECUTABLE) |