OSDN Git Service

ffmpeg: Adjust build hacks
[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 include $(CLEAR_VARS)
16 include $(FFDROID_DIR)/ffmpeg.mk
17
18 FFMPEG_ARCH_DIR := $(FFMPEG_ARCH)
19 ifeq ($(FFMPEG_ARCH),x86_64)
20     FFMPEG_ARCH_DIR := x86
21 endif
22
23 $(foreach V,$(FF_VARS),$(eval $(call RESET,$(V))))
24 #$(warning INCLUDING $(wildcard $(LOCAL_PATH)/$(FFMPEG_ARCH)/Makefile) for $(FFMPEG_2ND_ARCH) - $(NEON-OBJS) - $(FF_VARS))
25
26 SUBDIR := $(FFDROID_DIR)/include/
27 include $(LOCAL_PATH)/Makefile $(wildcard $(LOCAL_PATH)/$(FFMPEG_ARCH_DIR)/Makefile)
28 include $(FFMPEG_DIR)arch.mak
29
30 # remove duplicate objects
31 OBJS := $(sort $(OBJS) $(OBJS-yes))
32
33 ASM_SUFFIX := $(if $(filter x86,$(FFMPEG_ARCH_DIR)),asm,S)
34 ALL_S_FILES := $(subst $(LOCAL_PATH)/,,$(wildcard $(LOCAL_PATH)/$(FFMPEG_ARCH_DIR)/*.$(ASM_SUFFIX)))
35 ALL_S_FILES := $(if $(filter S,$(ASM_SUFFIX)),$(ALL_S_FILES),$(filter $(patsubst %.o,%.asm,$(YASM-OBJS) $(YASM-OBJS-yes)),$(ALL_S_FILES)))
36
37 ifneq ($(ALL_S_FILES),)
38 S_OBJS := $(ALL_S_FILES:%.$(ASM_SUFFIX)=%.o)
39 C_OBJS := $(filter-out $(S_OBJS),$(OBJS))
40 S_OBJS := $(filter $(S_OBJS),$(OBJS))
41 else
42 C_OBJS := $(OBJS)
43 S_OBJS :=
44 endif
45
46 C_FILES := $(C_OBJS:%.o=%.c)
47 S_FILES := $(S_OBJS:%.o=%.$(ASM_SUFFIX))
48
49 LOCAL_MODULE := lib$(NAME)
50 LOCAL_MODULE_TAGS := optional
51 LOCAL_MODULE_CLASS := SHARED_LIBRARIES
52 LOCAL_ARM_MODE := arm
53 ifdef TARGET_2ND_ARCH
54 LOCAL_MODULE_PATH_32 := $(TARGET_OUT_VENDOR)/lib
55 LOCAL_MODULE_PATH_64 := $(TARGET_OUT_VENDOR)/lib64
56 else
57 LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_SHARED_LIBRARIES)
58 endif
59
60 LOCAL_SRC_FILES := $(C_FILES) $(if $(filter S,$(ASM_SUFFIX)),$(S_FILES))
61
62 intermediates := $(local-intermediates-dir)
63 ifeq ($(FFMPEG_ARCH),x86)
64 GEN := $(S_OBJS:%=$(intermediates)/$(FFMPEG_ARCH)/%)
65 $(GEN): YASM := prebuilts/misc/$(BUILD_OS)-$(HOST_PREBUILT_ARCH)/yasm/yasm
66 $(GEN): YASMFLAGS := -felf -DPIC $(LOCAL_C_INCLUDES:%=-I%)
67 $(GEN): PRIVATE_CUSTOM_TOOL = $(YASM) $(YASMFLAGS) -Pconfig-x86.asm -o $@ $<
68 $(GEN): $(intermediates)/$(FFMPEG_ARCH)/%.o: $(LOCAL_PATH)/%.asm $(SUBDIR)config-x86.asm
69         $(transform-generated-source)
70 LOCAL_GENERATED_SOURCES_x86 += $(GEN)
71 else ifeq ($(FFMPEG_ARCH),x86_64)
72 GEN64 := $(S_OBJS:%=$(intermediates)/$(FFMPEG_ARCH)/%)
73 $(GEN64): YASM := prebuilts/misc/$(BUILD_OS)-$(HOST_PREBUILT_ARCH)/yasm/yasm
74 $(GEN64): YASMFLAGS := -felf -DPIC $(LOCAL_C_INCLUDES:%=-I%) -m amd64
75 $(GEN64): PRIVATE_CUSTOM_TOOL = $(YASM) $(YASMFLAGS) -Pconfig-x86_64.asm -o $@ $<
76 $(GEN64): $(intermediates)/$(FFMPEG_ARCH)/%.o: $(LOCAL_PATH)/%.asm $(SUBDIR)config-x86_64.asm
77         $(transform-generated-source)
78 LOCAL_GENERATED_SOURCES_x86_64 += $(GEN64)
79 endif
80
81 LOCAL_CFLAGS += \
82         -O3 -std=c99 -fno-math-errno -fno-signed-zeros -fomit-frame-pointer \
83         -Wno-pointer-to-int-cast -Wstrict-prototypes -Wempty-body -Wno-parentheses \
84         -Wno-switch -Wno-format-zero-length -Wno-pointer-sign -Wno-unused-parameter \
85         -Wno-unknown-attributes -Wno-missing-field-initializers -Wno-sign-compare \
86         -Werror=format-security -Werror=implicit-function-declaration -Werror=missing-prototypes \
87         -Werror=return-type -Werror=vla -Wformat -Wno-maybe-uninitialized -fPIC
88
89 LOCAL_LDFLAGS := -Wl,--no-fatal-warnings -Wl,-Bsymbolic
90
91 LOCAL_CLANG_ASFLAGS += -no-integrated-as
92
93 LOCAL_SHARED_LIBRARIES := $(sort $(FFLIBS-yes:%=lib%) $(FFLIBS:%=lib%))