blob: a8003b2e159eb8c9dd1904cf13cf730fe594c1b2 [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 Bechtsoudisd1fccd52016-05-06 13:11:27 +030018# Enable Linux ptrace() instead of POSIX signal interface by default
Anestis Bechtsoudiscfc39fb2015-08-06 10:31:36 +030019ANDROID_WITH_PTRACE ?= true
20
Anestis Bechtsoudiscfc39fb2015-08-06 10:31:36 +030021ifeq ($(ANDROID_WITH_PTRACE),true)
Anestis Bechtsoudisf1812722015-08-19 10:12:19 +030022 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 Bechtsoudisf1812722015-08-19 10:12:19 +030034 else
35 $(error Unsuported / Unknown APP_API '$(APP_ABI)')
36 endif
37
Anestis Bechtsoudisbe7fa272015-09-10 17:27:44 +030038 # 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 Bechtsoudis66cbb082015-09-11 20:15:15 +030041 else ifeq ($(APP_ABI),$(filter $(APP_ABI),armeabi-v7a))
Anestis Bechtsoudisbe7fa272015-09-10 17:27:44 +030042 OPENSSL_ARMCAP_ABI := "7"
43 endif
44
Anestis Bechtsoudiscfc39fb2015-08-06 10:31:36 +030045 # 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 Bechtsoudisa4003c52016-05-06 13:04:48 +030048 $(error libunwind-$(UNW_ARCH) is missing. Please execute \
Anestis Bechtsoudiscfc39fb2015-08-06 10:31:36 +030049 '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 Bechtsoudisa4003c52016-05-06 13:04:48 +030078 $(error libcapstone is missing. Please execute \
Anestis Bechtsoudiscfc39fb2015-08-06 10:31:36 +030079 '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)
86endif
87
Anestis Bechtsoudisd1fccd52016-05-06 13:11:27 +030088ifneq (,$(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)
98endif
99
Anestis Bechtsoudiscfc39fb2015-08-06 10:31:36 +0300100# Main honggfuzz module
Anestis Bechtsoudisc1f6faa2015-07-31 05:32:19 +0300101include $(CLEAR_VARS)
102
103LOCAL_MODULE := honggfuzz
Jaggereafa0712016-04-02 00:01:06 +0200104LOCAL_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 Bechtsoudisc1f6faa2015-07-31 05:32:19 +0300105LOCAL_CFLAGS := -std=c11 -I. \
106 -D_GNU_SOURCE \
Anestis Bechtsoudiscfc39fb2015-08-06 10:31:36 +0300107 -Wall -Wextra -Wno-initializer-overrides -Wno-override-init \
Anestis Bechtsoudisc06f8b32015-12-26 14:48:05 +0200108 -Wno-unknown-warning-option -Werror -funroll-loops -O2 \
109 -Wframe-larger-than=51200
Anestis Bechtsoudisc1f6faa2015-07-31 05:32:19 +0300110LOCAL_LDFLAGS := -lm
111
Anestis Bechtsoudiscfc39fb2015-08-06 10:31:36 +0300112ifeq ($(ANDROID_WITH_PTRACE),true)
113 LOCAL_C_INCLUDES := third_party/android/libunwind/include third_party/android/capstone/include
Anestis Bechtsoudisd38754a2015-08-26 13:09:56 +0300114 LOCAL_STATIC_LIBRARIES := libunwind-arch libunwind libunwind-ptrace libunwind-dwarf-generic libcapstone
Anestis Bechtsoudiscfc39fb2015-08-06 10:31:36 +0300115 LOCAL_CFLAGS += -D__HF_USE_CAPSTONE__
Jagger3db1d952016-03-10 02:02:46 +0100116 ARCH_SRCS := linux/arch.c linux/ptrace_utils.c linux/perf.c linux/unwind.c linux/pt.c
Anestis Bechtsoudiscfc39fb2015-08-06 10:31:36 +0300117 ARCH := LINUX
Anestis Bechtsoudis66cbb082015-09-11 20:15:15 +0300118 ifeq ($(ARCH_ABI),arm)
119 LOCAL_CFLAGS += -DOPENSSL_ARMCAP_ABI='$(OPENSSL_ARMCAP_ABI)'
120 endif
Anestis Bechtsoudiscfc39fb2015-08-06 10:31:36 +0300121 $(info $(shell (echo "********************************************************************")))
122 $(info $(shell (echo "Android PTRACE build: Will prevent debuggerd from processing crashes")))
123 $(info $(shell (echo "********************************************************************")))
124else
125 ARCH_SRCS := posix/arch.c
126 ARCH := POSIX
127 $(info $(shell (echo "********************************************************************")))
Anestis Bechtsoudis61a8f4f2015-08-20 08:39:26 +0300128 $(info $(shell (echo "Android POSIX build: Will allow debuggerd to also process crashes")))
Anestis Bechtsoudiscfc39fb2015-08-06 10:31:36 +0300129 $(info $(shell (echo "********************************************************************")))
130endif
Anestis Bechtsoudisc1f6faa2015-07-31 05:32:19 +0300131
132LOCAL_SRC_FILES += $(ARCH_SRCS)
Anestis Bechtsoudis66cbb082015-09-11 20:15:15 +0300133LOCAL_CFLAGS += -D_HF_ARCH_${ARCH}
Anestis Bechtsoudisc1f6faa2015-07-31 05:32:19 +0300134
Anestis Bechtsoudisd1fccd52016-05-06 13:11:27 +0300135ifneq (,$(findstring clang,$(NDK_TOOLCHAIN)))
136 LOCAL_CFLAGS += -fblocks
137 LOCAL_STATIC_LIBRARIES += libblocksruntime
138endif
139
Anestis Bechtsoudisc1f6faa2015-07-31 05:32:19 +0300140include $(BUILD_EXECUTABLE)