blob: d34c570ea343b98e878605aeeaf47a2bda799f02 [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
Anestis Bechtsoudisf1812722015-08-19 10:12:19 +030034 else
35 $(error Unsuported / Unknown APP_API '$(APP_ABI)')
36 endif
37
Anestis Bechtsoudiscfc39fb2015-08-06 10:31:36 +030038 # 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)
79endif
80
81# Main honggfuzz module
Anestis Bechtsoudisc1f6faa2015-07-31 05:32:19 +030082include $(CLEAR_VARS)
83
84LOCAL_MODULE := honggfuzz
85LOCAL_SRC_FILES := honggfuzz.c log.c files.c fuzz.c report.c mangle.c util.c
86LOCAL_CFLAGS := -std=c11 -I. \
87 -D_GNU_SOURCE \
Anestis Bechtsoudiscfc39fb2015-08-06 10:31:36 +030088 -Wall -Wextra -Wno-initializer-overrides -Wno-override-init \
89 -Wno-unknown-warning-option -Werror -funroll-loops -O2
Anestis Bechtsoudisc1f6faa2015-07-31 05:32:19 +030090LOCAL_LDFLAGS := -lm
91
Anestis Bechtsoudiscfc39fb2015-08-06 10:31:36 +030092ifeq ($(ANDROID_WITH_PTRACE),true)
93 LOCAL_C_INCLUDES := third_party/android/libunwind/include third_party/android/capstone/include
Anestis Bechtsoudisd38754a2015-08-26 13:09:56 +030094 LOCAL_STATIC_LIBRARIES := libunwind-arch libunwind libunwind-ptrace libunwind-dwarf-generic libcapstone
Anestis Bechtsoudiscfc39fb2015-08-06 10:31:36 +030095 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 "********************************************************************")))
101else
102 ARCH_SRCS := posix/arch.c
103 ARCH := POSIX
104 $(info $(shell (echo "********************************************************************")))
Anestis Bechtsoudis61a8f4f2015-08-20 08:39:26 +0300105 $(info $(shell (echo "Android POSIX build: Will allow debuggerd to also process crashes")))
Anestis Bechtsoudiscfc39fb2015-08-06 10:31:36 +0300106 $(info $(shell (echo "********************************************************************")))
107endif
Anestis Bechtsoudisc1f6faa2015-07-31 05:32:19 +0300108
109LOCAL_SRC_FILES += $(ARCH_SRCS)
110LOCAL_CFLAGS += -D_HF_ARCH_${ARCH}
111
112include $(BUILD_EXECUTABLE)