OSDN Git Service

Merge commit 'ac3c3ee678e51b05a2a7c30ce79465db46ba01fa'
[android-x86/external-ffmpeg.git] / Makefile
1 MAIN_MAKEFILE=1
2 include ffbuild/config.mak
3
4 vpath %.c    $(SRC_PATH)
5 vpath %.cpp  $(SRC_PATH)
6 vpath %.h    $(SRC_PATH)
7 vpath %.inc  $(SRC_PATH)
8 vpath %.m    $(SRC_PATH)
9 vpath %.S    $(SRC_PATH)
10 vpath %.asm  $(SRC_PATH)
11 vpath %.rc   $(SRC_PATH)
12 vpath %.v    $(SRC_PATH)
13 vpath %.texi $(SRC_PATH)
14 vpath %/fate_config.sh.template $(SRC_PATH)
15
16 AVPROGS-$(CONFIG_FFMPEG)   += ffmpeg
17 AVPROGS-$(CONFIG_FFPLAY)   += ffplay
18 AVPROGS-$(CONFIG_FFPROBE)  += ffprobe
19 AVPROGS-$(CONFIG_FFSERVER) += ffserver
20
21 AVPROGS    := $(AVPROGS-yes:%=%$(PROGSSUF)$(EXESUF))
22 INSTPROGS   = $(AVPROGS-yes:%=%$(PROGSSUF)$(EXESUF))
23 PROGS      += $(AVPROGS)
24
25 AVBASENAMES  = ffmpeg ffplay ffprobe ffserver
26 ALLAVPROGS   = $(AVBASENAMES:%=%$(PROGSSUF)$(EXESUF))
27 ALLAVPROGS_G = $(AVBASENAMES:%=%$(PROGSSUF)_g$(EXESUF))
28
29 $(foreach prog,$(AVBASENAMES),$(eval OBJS-$(prog) += cmdutils.o))
30 $(foreach prog,$(AVBASENAMES),$(eval OBJS-$(prog)-$(CONFIG_OPENCL) += cmdutils_opencl.o))
31
32 OBJS-ffmpeg                   += ffmpeg_opt.o ffmpeg_filter.o
33 OBJS-ffmpeg-$(CONFIG_VIDEOTOOLBOX) += ffmpeg_videotoolbox.o
34 OBJS-ffmpeg-$(CONFIG_LIBMFX)  += ffmpeg_qsv.o
35 OBJS-ffmpeg-$(CONFIG_VAAPI)   += ffmpeg_vaapi.o
36 ifndef CONFIG_VIDEOTOOLBOX
37 OBJS-ffmpeg-$(CONFIG_VDA)     += ffmpeg_videotoolbox.o
38 endif
39 OBJS-ffmpeg-$(CONFIG_CUVID)   += ffmpeg_cuvid.o
40 OBJS-ffmpeg-$(HAVE_DXVA2_LIB) += ffmpeg_dxva2.o
41 OBJS-ffmpeg-$(HAVE_VDPAU_X11) += ffmpeg_vdpau.o
42 OBJS-ffserver                 += ffserver_config.o
43
44 TESTTOOLS   = audiogen videogen rotozoom tiny_psnr tiny_ssim base64 audiomatch
45 HOSTPROGS  := $(TESTTOOLS:%=tests/%) doc/print_options
46
47 # $(FFLIBS-yes) needs to be in linking order
48 FFLIBS-$(CONFIG_AVDEVICE)   += avdevice
49 FFLIBS-$(CONFIG_AVFILTER)   += avfilter
50 FFLIBS-$(CONFIG_AVFORMAT)   += avformat
51 FFLIBS-$(CONFIG_AVCODEC)    += avcodec
52 FFLIBS-$(CONFIG_AVRESAMPLE) += avresample
53 FFLIBS-$(CONFIG_POSTPROC)   += postproc
54 FFLIBS-$(CONFIG_SWRESAMPLE) += swresample
55 FFLIBS-$(CONFIG_SWSCALE)    += swscale
56
57 FFLIBS := avutil
58
59 DATA_FILES := $(wildcard $(SRC_PATH)/presets/*.ffpreset) $(SRC_PATH)/doc/ffprobe.xsd
60 EXAMPLES_FILES := $(wildcard $(SRC_PATH)/doc/examples/*.c) $(SRC_PATH)/doc/examples/Makefile $(SRC_PATH)/doc/examples/README
61
62 SKIPHEADERS = compat/w32pthreads.h
63
64 # first so "all" becomes default target
65 all: all-yes
66
67 include $(SRC_PATH)/tools/Makefile
68 include $(SRC_PATH)/ffbuild/common.mak
69
70 FF_EXTRALIBS := $(FFEXTRALIBS)
71 FF_DEP_LIBS  := $(DEP_LIBS)
72 FF_STATIC_DEP_LIBS := $(STATIC_DEP_LIBS)
73
74 all: $(AVPROGS)
75
76 $(TOOLS): %$(EXESUF): %.o
77         $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS)
78
79 target_dec_%_fuzzer$(EXESUF): target_dec_%_fuzzer.o $(FF_DEP_LIBS)
80         $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH)
81
82 tools/cws2fws$(EXESUF): ELIBS = $(ZLIB)
83 tools/uncoded_frame$(EXESUF): $(FF_DEP_LIBS)
84 tools/uncoded_frame$(EXESUF): ELIBS = $(FF_EXTRALIBS)
85 tools/target_dec_%_fuzzer$(EXESUF): $(FF_DEP_LIBS)
86
87 CONFIGURABLE_COMPONENTS =                                           \
88     $(wildcard $(FFLIBS:%=$(SRC_PATH)/lib%/all*.c))                 \
89     $(SRC_PATH)/libavcodec/bitstream_filters.c                      \
90     $(SRC_PATH)/libavformat/protocols.c                             \
91
92 config.h: ffbuild/.config
93 ffbuild/.config: $(CONFIGURABLE_COMPONENTS)
94         @-tput bold 2>/dev/null
95         @-printf '\nWARNING: $(?) newer than config.h, rerun configure\n\n'
96         @-tput sgr0 2>/dev/null
97
98 SUBDIR_VARS := CLEANFILES EXAMPLES FFLIBS HOSTPROGS TESTPROGS TOOLS      \
99                HEADERS ARCH_HEADERS BUILT_HEADERS SKIPHEADERS            \
100                ARMV5TE-OBJS ARMV6-OBJS ARMV8-OBJS VFP-OBJS NEON-OBJS     \
101                ALTIVEC-OBJS VSX-OBJS MMX-OBJS YASM-OBJS                  \
102                MIPSFPU-OBJS MIPSDSPR2-OBJS MIPSDSP-OBJS MSA-OBJS         \
103                MMI-OBJS OBJS SLIBOBJS HOSTOBJS TESTOBJS
104
105 define RESET
106 $(1) :=
107 $(1)-yes :=
108 endef
109
110 ifdef CONFIG_RAISE_MAJOR
111 RAISE_MAJOR = 100
112 else
113 RAISE_MAJOR = 0
114 endif
115
116 define DOSUBDIR
117 $(foreach V,$(SUBDIR_VARS),$(eval $(call RESET,$(V))))
118 SUBDIR := $(1)/
119 include $(SRC_PATH)/$(1)/Makefile
120 -include $(SRC_PATH)/$(1)/$(ARCH)/Makefile
121 -include $(SRC_PATH)/$(1)/$(INTRINSICS)/Makefile
122 include $(SRC_PATH)/ffbuild/library.mak
123 endef
124
125 $(foreach D,$(FFLIBS),$(eval $(call DOSUBDIR,lib$(D))))
126
127 include $(SRC_PATH)/doc/Makefile
128
129 define DOPROG
130 OBJS-$(1) += $(1).o $(OBJS-$(1)-yes)
131 $(1)$(PROGSSUF)_g$(EXESUF): $$(OBJS-$(1))
132 $$(OBJS-$(1)): CFLAGS  += $(CFLAGS-$(1))
133 $(1)$(PROGSSUF)_g$(EXESUF): LDFLAGS += $(LDFLAGS-$(1))
134 $(1)$(PROGSSUF)_g$(EXESUF): FF_EXTRALIBS += $(EXTRALIBS-$(1))
135 -include $$(OBJS-$(1):.o=.d)
136 endef
137
138 $(foreach P,$(PROGS),$(eval $(call DOPROG,$(P:$(PROGSSUF)$(EXESUF)=))))
139
140 ffprobe.o cmdutils.o libavcodec/utils.o libavformat/utils.o libavdevice/avdevice.o libavfilter/avfilter.o libavutil/utils.o libpostproc/postprocess.o libswresample/swresample.o libswscale/utils.o : libavutil/ffversion.h
141
142 $(PROGS): %$(PROGSSUF)$(EXESUF): %$(PROGSSUF)_g$(EXESUF)
143         $(CP) $< $@
144         $(STRIP) $@
145
146 %$(PROGSSUF)_g$(EXESUF): %.o $(FF_DEP_LIBS)
147         $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $(OBJS-$*) $(FF_EXTRALIBS)
148
149 VERSION_SH  = $(SRC_PATH)/ffbuild/version.sh
150 GIT_LOG     = $(SRC_PATH)/.git/logs/HEAD
151
152 .version: $(wildcard $(GIT_LOG)) $(VERSION_SH) ffbuild/config.mak
153 .version: M=@
154
155 libavutil/ffversion.h .version:
156         $(M)$(VERSION_SH) $(SRC_PATH) libavutil/ffversion.h $(EXTRA_VERSION)
157         $(Q)touch .version
158
159 # force version.sh to run whenever version might have changed
160 -include .version
161
162 ifdef AVPROGS
163 install: install-progs install-data
164 endif
165
166 install: install-libs install-headers
167
168 install-libs: install-libs-yes
169
170 install-progs-yes:
171 install-progs-$(CONFIG_SHARED): install-libs
172
173 install-progs: install-progs-yes $(AVPROGS)
174         $(Q)mkdir -p "$(BINDIR)"
175         $(INSTALL) -c -m 755 $(INSTPROGS) "$(BINDIR)"
176
177 install-data: $(DATA_FILES) $(EXAMPLES_FILES)
178         $(Q)mkdir -p "$(DATADIR)/examples"
179         $(INSTALL) -m 644 $(DATA_FILES) "$(DATADIR)"
180         $(INSTALL) -m 644 $(EXAMPLES_FILES) "$(DATADIR)/examples"
181
182 uninstall: uninstall-libs uninstall-headers uninstall-progs uninstall-data
183
184 uninstall-progs:
185         $(RM) $(addprefix "$(BINDIR)/", $(ALLAVPROGS))
186
187 uninstall-data:
188         $(RM) -r "$(DATADIR)"
189
190 clean::
191         $(RM) $(ALLAVPROGS) $(ALLAVPROGS_G)
192         $(RM) $(CLEANSUFFIXES)
193         $(RM) $(CLEANSUFFIXES:%=compat/msvcrt/%)
194         $(RM) $(CLEANSUFFIXES:%=compat/atomics/pthread/%)
195         $(RM) $(CLEANSUFFIXES:%=compat/%)
196         $(RM) -r coverage-html
197         $(RM) -rf coverage.info coverage.info.in lcov
198
199 distclean::
200         $(RM) $(DISTCLEANSUFFIXES)
201         $(RM) .version avversion.h config.asm config.h mapfile  \
202                 ffbuild/.config ffbuild/config.* libavutil/avconfig.h \
203                 version.h libavutil/ffversion.h libavcodec/codec_names.h \
204                 libavcodec/bsf_list.c libavformat/protocol_list.c
205 ifeq ($(SRC_LINK),src)
206         $(RM) src
207 endif
208         $(RM) -rf doc/examples/pc-uninstalled
209
210 config:
211         $(SRC_PATH)/configure $(value FFMPEG_CONFIGURATION)
212
213 check: all alltools examples testprogs fate
214
215 include $(SRC_PATH)/tests/Makefile
216
217 $(sort $(OBJDIRS)):
218         $(Q)mkdir -p $@
219
220 # Dummy rule to stop make trying to rebuild removed or renamed headers
221 %.h:
222         @:
223
224 # Disable suffix rules.  Most of the builtin rules are suffix rules,
225 # so this saves some time on slow systems.
226 .SUFFIXES:
227
228 .PHONY: all all-yes alltools check *clean config install*
229 .PHONY: testprogs uninstall*