OSDN Git Service

cheets-libffi: Use assembly variant suitable for Android toolchain
[android-x86/external-libffi.git] / Android.mk
1 # Copyright (C) 2015 The Android Open Source Project
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #      http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 LOCAL_PATH:= $(call my-dir)
16
17 LIBFFI_TEMPLATE_SUBST := -e s/@VERSION@/3.2.1/
18 LIBFFI_TEMPLATE_SUBST += -e s/@TARGET@/FAKE_TARGET_/
19 LIBFFI_TEMPLATE_SUBST += -e s/@HAVE_LONG_DOUBLE@/CONF_HAVE_LONG_DOUBLE/
20 LIBFFI_TEMPLATE_SUBST += -e s/@HAVE_LONG_DOUBLE_VARIANT@/CONF_HAVE_LONG_DOUBLE_VARIANT/
21 LIBFFI_TEMPLATE_SUBST += -e s/@FFI_EXEC_TRAMPOLINE_TABLE@/CONF_FFI_EXEC_TRAMPOLINE_TABLE/
22
23 include $(CLEAR_VARS)
24
25 # Note: AOSP has (or had) a platform/external/libffi used by Dalvik/MIPS.
26 # To avoid confusion, we call our version of the library cheets-libffi.
27 LOCAL_MODULE := cheets-libffi
28 LOCAL_MODULE_TAGS := optional
29
30 ffi_arch := $(TARGET_ARCH)
31 ffi_os := $(TARGET_OS)
32
33 # Note: We created the "<OS>-<arch>" include directories to ease configuration
34 # for each target.
35 LOCAL_C_INCLUDES := \
36         $(LOCAL_PATH)/include \
37         $(LOCAL_PATH)/$(ffi_os)-$(ffi_arch) \
38
39 LOCAL_CFLAGS += -Wno-unused-parameter
40 LOCAL_CFLAGS += -Wno-sign-compare
41
42 ifeq ($(ffi_os)-$(ffi_arch),linux-arm)
43 LOCAL_SRC_FILES := src/arm/sysv.S src/arm/ffi.c
44 endif
45
46 ifeq ($(ffi_os)-$(ffi_arch),linux-x86)
47 LOCAL_SRC_FILES := src/x86/ffi.c src/x86/sysv.S
48 LOCAL_ASFLAGS += -DHAVE_AS_X86_PCREL
49 endif
50
51 ifeq ($(ffi_os)-$(ffi_arch),linux-x86_64)
52 LOCAL_SRC_FILES := src/x86/ffi64.c src/x86/unix64.S
53 LOCAL_ASFLAGS += -DHAVE_AS_X86_PCREL
54 endif
55
56 ifeq ($(LOCAL_SRC_FILES),)
57 $(error The os/architecture $(ffi_os)-$(ffi_arch) is not supported by cheets-libffi.)
58 endif
59
60 LOCAL_SRC_FILES += \
61         src/debug.c \
62         src/java_raw_api.c \
63         src/prep_cif.c \
64         src/raw_api.c \
65         src/types.c
66
67 # --- Generate include/ffi-real.h from include/ffi.h.in
68 GEN := $(addprefix $(LOCAL_PATH)/include/, \
69                                                 ffi.h \
70                                 )
71 LOCAL_ADDITIONAL_DEPENDENCIES += $(GEN)
72 $(GEN) : PRIVATE_PATH := $(LOCAL_PATH)
73 $(GEN) : PRIVATE_CUSTOM_TOOL = sed $(LIBFFI_TEMPLATE_SUBST) < $< > $@
74 $(GEN) : $(LOCAL_PATH)/include/%.h : $(LOCAL_PATH)/include/%.h.in
75         $(transform-generated-source)
76 # Note: The line above must be indented with tabs.
77
78 include $(BUILD_STATIC_LIBRARY)