blob: 249c6a50a91b8ab9d9dfded59dc4979f1000448c [file] [log] [blame]
Anestis Bechtsoudisc1f6faa2015-07-31 05:32:19 +03001# 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
16LOCAL_PATH := $(abspath $(call my-dir)/..)
Anestis Bechtsoudiscfc39fb2015-08-06 10:31:36 +030017
Anestis Bechtsoudisf1812722015-08-19 10:12:19 +030018# Enable Linux ptrace() instead of POSIX signal interface by default
Anestis Bechtsoudiscfc39fb2015-08-06 10:31:36 +030019ANDROID_WITH_PTRACE ?= true
20
Anestis Bechtsoudisd36315d2015-09-08 11:03:55 +030021# Make sure compiler toolchain is compatible / supported
22ifneq (,$(findstring clang,$(NDK_TOOLCHAIN)))
23 $(error Clang toolchains are not supported yet. Clang uses __aeabi_read_tp to \
24 implement thread_local, which isn't supported by bionic [$(NDK_TOOLCHAIN)])
25endif
26
Anestis Bechtsoudiscfc39fb2015-08-06 10:31:36 +030027ifeq ($(ANDROID_WITH_PTRACE),true)
Anestis Bechtsoudisf1812722015-08-19 10:12:19 +030028 ifeq ($(APP_ABI),$(filter $(APP_ABI),armeabi armeabi-v7a))
29 ARCH_ABI := arm
30 UNW_ARCH := arm
31 else ifeq ($(APP_ABI),$(filter $(APP_ABI),x86))
32 ARCH_ABI := x86
33 UNW_ARCH := x86
34 else ifeq ($(APP_ABI),$(filter $(APP_ABI),arm64-v8a))
35 ARCH_ABI := arm64
36 UNW_ARCH := aarch64
37 else ifeq ($(APP_ABI),$(filter $(APP_ABI),x86_64))
38 ARCH_ABI := x86_64
39 UNW_ARCH := x86_64
Anestis Bechtsoudisf1812722015-08-19 10:12:19 +030040 else
41 $(error Unsuported / Unknown APP_API '$(APP_ABI)')
42 endif
43
Anestis Bechtsoudisbe7fa272015-09-10 17:27:44 +030044 # Additional libcrypto OpenSSL flags required to mitigate bug (ARM systems with API <= 21)
45 ifeq ($(APP_ABI),$(filter $(APP_ABI),armeabi))
46 OPENSSL_ARMCAP_ABI := "5"
47 else
48 OPENSSL_ARMCAP_ABI := "7"
49 endif
50
Anestis Bechtsoudiscfc39fb2015-08-06 10:31:36 +030051 # Upstream libunwind compiled from sources with Android NDK toolchain
52 LIBUNWIND_A := third_party/android/libunwind/$(ARCH_ABI)/libunwind-$(UNW_ARCH).a
53 ifeq ("$(wildcard $(LIBUNWIND_A))","")
54 $(error libunwind-$(UNW_ARCH). is missing. Please execute \
55 'third_party/android/scripts/compile-libunwind.sh third_party/android/libunwind $(ARCH_ABI)')
56 endif
57
58 include $(CLEAR_VARS)
59 LOCAL_MODULE := libunwind
60 LOCAL_SRC_FILES := third_party/android/libunwind/$(ARCH_ABI)/libunwind.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-arch
66 LOCAL_SRC_FILES := third_party/android/libunwind/$(ARCH_ABI)/libunwind-$(UNW_ARCH).a
67 LOCAL_EXPORT_C_INCLUDES := third_party/android/libunwind/include
68 include $(PREBUILT_STATIC_LIBRARY)
69
70 include $(CLEAR_VARS)
71 LOCAL_MODULE := libunwind-ptrace
72 LOCAL_SRC_FILES := third_party/android/libunwind/$(ARCH_ABI)/libunwind-ptrace.a
73 LOCAL_EXPORT_C_INCLUDES := third_party/android/libunwind/include
74 include $(PREBUILT_STATIC_LIBRARY)
75
76 LOCAL_MODULE := libunwind-dwarf-generic
77 LOCAL_SRC_FILES := third_party/android/libunwind/$(ARCH_ABI)/libunwind-dwarf-generic.a
78 LOCAL_EXPORT_C_INCLUDES := third_party/android/libunwind/include
79 include $(PREBUILT_STATIC_LIBRARY)
80
81 # Upstream capstone compiled from sources with Android NDK toolchain
82 LIBCAPSTONE_A := third_party/android/capstone/$(ARCH_ABI)/libcapstone.a
83 ifeq ("$(wildcard $(LIBCAPSTONE_A))","")
84 $(error libunwind-$(UNW_ARCH). is missing. Please execute \
85 'third_party/android/scripts/compile-capstone.sh third_party/android/capstone $(ARCH_ABI)')
86 endif
87 include $(CLEAR_VARS)
88 LOCAL_MODULE := libcapstone
89 LOCAL_SRC_FILES := $(LIBCAPSTONE_A)
90 LOCAL_EXPORT_C_INCLUDES := third_party/android/capstone/include
91 include $(PREBUILT_STATIC_LIBRARY)
92endif
93
94# Main honggfuzz module
Anestis Bechtsoudisc1f6faa2015-07-31 05:32:19 +030095include $(CLEAR_VARS)
96
97LOCAL_MODULE := honggfuzz
Anestis Bechtsoudis46a69782015-09-08 22:26:53 +030098LOCAL_SRC_FILES := honggfuzz.c display.c log.c files.c fuzz.c report.c mangle.c util.c
Anestis Bechtsoudisc1f6faa2015-07-31 05:32:19 +030099LOCAL_CFLAGS := -std=c11 -I. \
100 -D_GNU_SOURCE \
Anestis Bechtsoudiscfc39fb2015-08-06 10:31:36 +0300101 -Wall -Wextra -Wno-initializer-overrides -Wno-override-init \
102 -Wno-unknown-warning-option -Werror -funroll-loops -O2
Anestis Bechtsoudisc1f6faa2015-07-31 05:32:19 +0300103LOCAL_LDFLAGS := -lm
104
Anestis Bechtsoudiscfc39fb2015-08-06 10:31:36 +0300105ifeq ($(ANDROID_WITH_PTRACE),true)
106 LOCAL_C_INCLUDES := third_party/android/libunwind/include third_party/android/capstone/include
Anestis Bechtsoudisd38754a2015-08-26 13:09:56 +0300107 LOCAL_STATIC_LIBRARIES := libunwind-arch libunwind libunwind-ptrace libunwind-dwarf-generic libcapstone
Anestis Bechtsoudiscfc39fb2015-08-06 10:31:36 +0300108 LOCAL_CFLAGS += -D__HF_USE_CAPSTONE__
109 ARCH_SRCS := linux/arch.c linux/ptrace_utils.c linux/perf.c linux/unwind.c
110 ARCH := LINUX
111 $(info $(shell (echo "********************************************************************")))
112 $(info $(shell (echo "Android PTRACE build: Will prevent debuggerd from processing crashes")))
113 $(info $(shell (echo "********************************************************************")))
114else
115 ARCH_SRCS := posix/arch.c
116 ARCH := POSIX
117 $(info $(shell (echo "********************************************************************")))
Anestis Bechtsoudis61a8f4f2015-08-20 08:39:26 +0300118 $(info $(shell (echo "Android POSIX build: Will allow debuggerd to also process crashes")))
Anestis Bechtsoudiscfc39fb2015-08-06 10:31:36 +0300119 $(info $(shell (echo "********************************************************************")))
120endif
Anestis Bechtsoudisc1f6faa2015-07-31 05:32:19 +0300121
122LOCAL_SRC_FILES += $(ARCH_SRCS)
Anestis Bechtsoudisbe7fa272015-09-10 17:27:44 +0300123LOCAL_CFLAGS += -D_HF_ARCH_${ARCH} -DOPENSSL_ARMCAP_ABI='$(OPENSSL_ARMCAP_ABI)'
Anestis Bechtsoudisc1f6faa2015-07-31 05:32:19 +0300124
125include $(BUILD_EXECUTABLE)