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 | d1fccd5 | 2016-05-06 13:11:27 +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 | be7fa27 | 2015-09-10 17:27:44 +0300 | [diff] [blame] | 38 | # Additional libcrypto OpenSSL flags required to mitigate bug (ARM systems with API <= 21) |
| 39 | ifeq ($(APP_ABI),$(filter $(APP_ABI),armeabi)) |
| 40 | OPENSSL_ARMCAP_ABI := "5" |
Anestis Bechtsoudis | 66cbb08 | 2015-09-11 20:15:15 +0300 | [diff] [blame] | 41 | else ifeq ($(APP_ABI),$(filter $(APP_ABI),armeabi-v7a)) |
Anestis Bechtsoudis | be7fa27 | 2015-09-10 17:27:44 +0300 | [diff] [blame] | 42 | OPENSSL_ARMCAP_ABI := "7" |
| 43 | endif |
| 44 | |
Anestis Bechtsoudis | cfc39fb | 2015-08-06 10:31:36 +0300 | [diff] [blame] | 45 | # Upstream libunwind compiled from sources with Android NDK toolchain |
| 46 | LIBUNWIND_A := third_party/android/libunwind/$(ARCH_ABI)/libunwind-$(UNW_ARCH).a |
| 47 | ifeq ("$(wildcard $(LIBUNWIND_A))","") |
Anestis Bechtsoudis | a4003c5 | 2016-05-06 13:04:48 +0300 | [diff] [blame] | 48 | $(error libunwind-$(UNW_ARCH) is missing. Please execute \ |
Anestis Bechtsoudis | cfc39fb | 2015-08-06 10:31:36 +0300 | [diff] [blame] | 49 | 'third_party/android/scripts/compile-libunwind.sh third_party/android/libunwind $(ARCH_ABI)') |
| 50 | endif |
| 51 | |
| 52 | include $(CLEAR_VARS) |
| 53 | LOCAL_MODULE := libunwind |
| 54 | LOCAL_SRC_FILES := third_party/android/libunwind/$(ARCH_ABI)/libunwind.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-arch |
| 60 | LOCAL_SRC_FILES := third_party/android/libunwind/$(ARCH_ABI)/libunwind-$(UNW_ARCH).a |
| 61 | LOCAL_EXPORT_C_INCLUDES := third_party/android/libunwind/include |
| 62 | include $(PREBUILT_STATIC_LIBRARY) |
| 63 | |
| 64 | include $(CLEAR_VARS) |
| 65 | LOCAL_MODULE := libunwind-ptrace |
| 66 | LOCAL_SRC_FILES := third_party/android/libunwind/$(ARCH_ABI)/libunwind-ptrace.a |
| 67 | LOCAL_EXPORT_C_INCLUDES := third_party/android/libunwind/include |
| 68 | include $(PREBUILT_STATIC_LIBRARY) |
| 69 | |
| 70 | LOCAL_MODULE := libunwind-dwarf-generic |
| 71 | LOCAL_SRC_FILES := third_party/android/libunwind/$(ARCH_ABI)/libunwind-dwarf-generic.a |
| 72 | LOCAL_EXPORT_C_INCLUDES := third_party/android/libunwind/include |
| 73 | include $(PREBUILT_STATIC_LIBRARY) |
| 74 | |
| 75 | # Upstream capstone compiled from sources with Android NDK toolchain |
| 76 | LIBCAPSTONE_A := third_party/android/capstone/$(ARCH_ABI)/libcapstone.a |
| 77 | ifeq ("$(wildcard $(LIBCAPSTONE_A))","") |
Anestis Bechtsoudis | a4003c5 | 2016-05-06 13:04:48 +0300 | [diff] [blame] | 78 | $(error libcapstone is missing. Please execute \ |
Anestis Bechtsoudis | cfc39fb | 2015-08-06 10:31:36 +0300 | [diff] [blame] | 79 | 'third_party/android/scripts/compile-capstone.sh third_party/android/capstone $(ARCH_ABI)') |
| 80 | endif |
| 81 | include $(CLEAR_VARS) |
| 82 | LOCAL_MODULE := libcapstone |
| 83 | LOCAL_SRC_FILES := $(LIBCAPSTONE_A) |
| 84 | LOCAL_EXPORT_C_INCLUDES := third_party/android/capstone/include |
| 85 | include $(PREBUILT_STATIC_LIBRARY) |
| 86 | endif |
| 87 | |
Anestis Bechtsoudis | d1fccd5 | 2016-05-06 13:11:27 +0300 | [diff] [blame^] | 88 | ifneq (,$(findstring clang,$(NDK_TOOLCHAIN))) |
| 89 | LIBBRT_A := third_party/android/libBlocksRuntime/$(ARCH_ABI)/libblocksruntime.a |
| 90 | ifeq ("$(wildcard $(LIBBRT_A))","") |
| 91 | $(error libBlocksRuntime is missing. Please execute \ |
| 92 | 'third_party/android/scripts/compile-libBlocksRuntime.sh third_party/android/libBlocksRuntime $(ARCH_ABI)') |
| 93 | endif |
| 94 | include $(CLEAR_VARS) |
| 95 | LOCAL_MODULE := libblocksruntime |
| 96 | LOCAL_SRC_FILES := $(LIBBRT_A) |
| 97 | include $(PREBUILT_STATIC_LIBRARY) |
| 98 | endif |
| 99 | |
Anestis Bechtsoudis | cfc39fb | 2015-08-06 10:31:36 +0300 | [diff] [blame] | 100 | # Main honggfuzz module |
Anestis Bechtsoudis | c1f6faa | 2015-07-31 05:32:19 +0300 | [diff] [blame] | 101 | include $(CLEAR_VARS) |
| 102 | |
| 103 | LOCAL_MODULE := honggfuzz |
Jagger | eafa071 | 2016-04-02 00:01:06 +0200 | [diff] [blame] | 104 | LOCAL_SRC_FILES := honggfuzz.c cmdline.c display.c log.c files.c fuzz.c report.c mangle.c util.c sancov.c subproc.c |
Anestis Bechtsoudis | c1f6faa | 2015-07-31 05:32:19 +0300 | [diff] [blame] | 105 | LOCAL_CFLAGS := -std=c11 -I. \ |
| 106 | -D_GNU_SOURCE \ |
Anestis Bechtsoudis | cfc39fb | 2015-08-06 10:31:36 +0300 | [diff] [blame] | 107 | -Wall -Wextra -Wno-initializer-overrides -Wno-override-init \ |
Anestis Bechtsoudis | c06f8b3 | 2015-12-26 14:48:05 +0200 | [diff] [blame] | 108 | -Wno-unknown-warning-option -Werror -funroll-loops -O2 \ |
| 109 | -Wframe-larger-than=51200 |
Anestis Bechtsoudis | c1f6faa | 2015-07-31 05:32:19 +0300 | [diff] [blame] | 110 | LOCAL_LDFLAGS := -lm |
| 111 | |
Anestis Bechtsoudis | cfc39fb | 2015-08-06 10:31:36 +0300 | [diff] [blame] | 112 | ifeq ($(ANDROID_WITH_PTRACE),true) |
| 113 | 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] | 114 | LOCAL_STATIC_LIBRARIES := libunwind-arch libunwind libunwind-ptrace libunwind-dwarf-generic libcapstone |
Anestis Bechtsoudis | cfc39fb | 2015-08-06 10:31:36 +0300 | [diff] [blame] | 115 | LOCAL_CFLAGS += -D__HF_USE_CAPSTONE__ |
Jagger | 3db1d95 | 2016-03-10 02:02:46 +0100 | [diff] [blame] | 116 | ARCH_SRCS := linux/arch.c linux/ptrace_utils.c linux/perf.c linux/unwind.c linux/pt.c |
Anestis Bechtsoudis | cfc39fb | 2015-08-06 10:31:36 +0300 | [diff] [blame] | 117 | ARCH := LINUX |
Anestis Bechtsoudis | 66cbb08 | 2015-09-11 20:15:15 +0300 | [diff] [blame] | 118 | ifeq ($(ARCH_ABI),arm) |
| 119 | LOCAL_CFLAGS += -DOPENSSL_ARMCAP_ABI='$(OPENSSL_ARMCAP_ABI)' |
| 120 | endif |
Anestis Bechtsoudis | cfc39fb | 2015-08-06 10:31:36 +0300 | [diff] [blame] | 121 | $(info $(shell (echo "********************************************************************"))) |
| 122 | $(info $(shell (echo "Android PTRACE build: Will prevent debuggerd from processing crashes"))) |
| 123 | $(info $(shell (echo "********************************************************************"))) |
| 124 | else |
| 125 | ARCH_SRCS := posix/arch.c |
| 126 | ARCH := POSIX |
| 127 | $(info $(shell (echo "********************************************************************"))) |
Anestis Bechtsoudis | 61a8f4f | 2015-08-20 08:39:26 +0300 | [diff] [blame] | 128 | $(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] | 129 | $(info $(shell (echo "********************************************************************"))) |
| 130 | endif |
Anestis Bechtsoudis | c1f6faa | 2015-07-31 05:32:19 +0300 | [diff] [blame] | 131 | |
| 132 | LOCAL_SRC_FILES += $(ARCH_SRCS) |
Anestis Bechtsoudis | 66cbb08 | 2015-09-11 20:15:15 +0300 | [diff] [blame] | 133 | LOCAL_CFLAGS += -D_HF_ARCH_${ARCH} |
Anestis Bechtsoudis | c1f6faa | 2015-07-31 05:32:19 +0300 | [diff] [blame] | 134 | |
Anestis Bechtsoudis | d1fccd5 | 2016-05-06 13:11:27 +0300 | [diff] [blame^] | 135 | ifneq (,$(findstring clang,$(NDK_TOOLCHAIN))) |
| 136 | LOCAL_CFLAGS += -fblocks |
| 137 | LOCAL_STATIC_LIBRARIES += libblocksruntime |
| 138 | endif |
| 139 | |
Anestis Bechtsoudis | c1f6faa | 2015-07-31 05:32:19 +0300 | [diff] [blame] | 140 | include $(BUILD_EXECUTABLE) |