OSDN Git Service

x86: Use yasm from prebuilts and don't depend on host install
[android-x86/external-ffmpeg.git] / android / build.mk
1 #
2 # Copyright (C) 2013 The Android-x86 Open Source Project
3 #
4 # Licensed under the GNU General Public License Version 2 or later.
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.gnu.org/licenses/gpl.html
9 #
10
11 ifndef FFDROID_DIR
12 FFDROID_DIR := $(call my-dir)
13 endif
14
15 define RESET
16 $(1) :=
17 $(1)-yes :=
18 endef
19
20 FF_VARS := FFLIBS OBJS ARMV5TE-OBJS ARMV6-OBJS VFP-OBJS NEON-OBJS MIPSFPU-OBJS MIPS32R2-OBJS MIPSDSPR1-OBJS MIPSDSPR2-OBJS ALTIVEC-OBJS VIS-OBJS MMX-OBJS YASM-OBJS
21
22 FFMPEG_ARCH := $(TARGET_ARCH)
23
24 FFMPEG_2ND_ARCH := false
25 ifneq ($(TARGET_2ND_ARCH_VARIANT),)
26    ifeq ($(TARGET_PREFER_32_BIT_APPS),true)
27        ifeq ($(FFMPEG_MULTILIB),64)
28           FFMPEG_2ND_ARCH := true
29        endif
30    else
31        ifeq ($(FFMPEG_MULTILIB),32)
32           FFMPEG_2ND_ARCH := true
33        endif
34    endif
35 endif
36
37 ifeq ($(FFMPEG_2ND_ARCH), true)
38     FFMPEG_ARCH := $(TARGET_2ND_ARCH)
39 endif
40
41 ifeq ($(FFMPEG_ARCH),arm64)
42     FFMPEG_ARCH := aarch64
43 endif
44
45 $(foreach V,$(FF_VARS),$(eval $(call RESET,$(V))))
46 #$(warning INCLUDING $(wildcard $(LOCAL_PATH)/$(FFMPEG_ARCH)/Makefile) for $(FFMPEG_2ND_ARCH) - $(NEON-OBJS) - $(FF_VARS))
47
48 include $(CLEAR_VARS)
49 include $(FFDROID_DIR)/ffmpeg.mk
50 SUBDIR := $(FFDROID_DIR)/include/
51 include $(LOCAL_PATH)/Makefile $(wildcard $(LOCAL_PATH)/$(FFMPEG_ARCH)/Makefile)
52 include $(FFMPEG_DIR)arch.mak
53
54 # remove duplicate objects
55 OBJS := $(sort $(OBJS) $(OBJS-yes))
56
57 ASM_SUFFIX := $(if $(filter x86,$(FFMPEG_ARCH)),asm,S)
58 ALL_S_FILES := $(subst $(LOCAL_PATH)/,,$(wildcard $(LOCAL_PATH)/$(FFMPEG_ARCH)/*.$(ASM_SUFFIX)))
59 ALL_S_FILES := $(if $(filter S,$(ASM_SUFFIX)),$(ALL_S_FILES),$(filter $(patsubst %.o,%.asm,$(YASM-OBJS) $(YASM-OBJS-yes)),$(ALL_S_FILES)))
60
61 ifneq ($(ALL_S_FILES),)
62 S_OBJS := $(ALL_S_FILES:%.$(ASM_SUFFIX)=%.o)
63 C_OBJS := $(filter-out $(S_OBJS),$(OBJS))
64 S_OBJS := $(filter $(S_OBJS),$(OBJS))
65 else
66 C_OBJS := $(OBJS)
67 S_OBJS :=
68 endif
69
70 C_FILES := $(C_OBJS:%.o=%.c)
71 S_FILES := $(S_OBJS:%.o=%.$(ASM_SUFFIX))
72
73 LOCAL_MODULE := lib$(NAME)
74 LOCAL_MODULE_TAGS := optional
75 LOCAL_MODULE_CLASS := SHARED_LIBRARIES
76 LOCAL_ARM_MODE := arm
77
78 LOCAL_SRC_FILES := $(C_FILES) $(if $(filter S,$(ASM_SUFFIX)),$(S_FILES))
79
80 intermediates := $(local-intermediates-dir)
81 ifeq ($(FFMPEG_ARCH),x86)
82 GEN := $(S_OBJS:%=$(intermediates)/%)
83 $(GEN): YASM := prebuilts/misc/$(BUILD_OS)-$(HOST_PREBUILT_ARCH)/yasm/yasm
84 $(GEN): YASMFLAGS := -felf -DPIC $(LOCAL_C_INCLUDES:%=-I%)
85 $(GEN): PRIVATE_CUSTOM_TOOL = $(YASM) $(YASMFLAGS) -Pconfig.asm -o $@ $<
86 $(GEN): $(intermediates)/%.o: $(LOCAL_PATH)/%.asm $(SUBDIR)config.asm
87         $(transform-generated-source)
88 LOCAL_GENERATED_SOURCES += $(GEN)
89 endif
90
91 LOCAL_CFLAGS += \
92         -O3 -std=c99 -fno-math-errno -fno-signed-zeros -fno-tree-vectorize -fomit-frame-pointer \
93         -Wdisabled-optimization -Wpointer-arith \
94         -Wwrite-strings -Wtype-limits -Wundef -Wmissing-prototypes \
95         -Wno-pointer-to-int-cast -Wstrict-prototypes -Wempty-body -Wno-parentheses \
96         -Wno-switch -Wno-format-zero-length -Wno-pointer-sign \
97         -Werror=format-security -Werror=implicit-function-declaration -Werror=missing-prototypes \
98         -Werror=return-type -Werror=vla -Wformat -Wno-maybe-uninitialized
99
100 LOCAL_LDFLAGS := -Wl,--no-fatal-warnings
101
102 LOCAL_SHARED_LIBRARIES := $(sort $(FFLIBS-yes:%=lib%) $(FFLIBS:%=lib%))