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