blob: 0471bd6ed54ad92834729abc2da30cdd9a4bdbe3 [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 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
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 Bechtsoudiscfc39fb2015-08-06 10:31:36 +030039 # 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)
80endif
81
82# Main honggfuzz module
Anestis Bechtsoudisc1f6faa2015-07-31 05:32:19 +030083include $(CLEAR_VARS)
84
85LOCAL_MODULE := honggfuzz
86LOCAL_SRC_FILES := honggfuzz.c log.c files.c fuzz.c report.c mangle.c util.c
87LOCAL_CFLAGS := -std=c11 -I. \
88 -D_GNU_SOURCE \
Anestis Bechtsoudiscfc39fb2015-08-06 10:31:36 +030089 -Wall -Wextra -Wno-initializer-overrides -Wno-override-init \
90 -Wno-unknown-warning-option -Werror -funroll-loops -O2
Anestis Bechtsoudisc1f6faa2015-07-31 05:32:19 +030091LOCAL_LDFLAGS := -lm
92
Anestis Bechtsoudiscfc39fb2015-08-06 10:31:36 +030093ifeq ($(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 "********************************************************************")))
102else
103 ARCH_SRCS := posix/arch.c
104 ARCH := POSIX
105 $(info $(shell (echo "********************************************************************")))
Anestis Bechtsoudis61a8f4f2015-08-20 08:39:26 +0300106 $(info $(shell (echo "Android POSIX build: Will allow debuggerd to also process crashes")))
Anestis Bechtsoudiscfc39fb2015-08-06 10:31:36 +0300107 $(info $(shell (echo "********************************************************************")))
108endif
Anestis Bechtsoudisc1f6faa2015-07-31 05:32:19 +0300109
110LOCAL_SRC_FILES += $(ARCH_SRCS)
111LOCAL_CFLAGS += -D_HF_ARCH_${ARCH}
112
113include $(BUILD_EXECUTABLE)