2 ## Copyright (c) 2010 The WebM project authors. All Rights Reserved.
4 ## Use of this source code is governed by a BSD-style license
5 ## that can be found in the LICENSE file in the root of the source
6 ## tree. An additional intellectual property rights grant can be found
7 ## in the file PATENTS. All contributing project authors may
8 ## be found in the AUTHORS file in the root of the source tree.
12 # ARM assembly files are written in RVCT-style. We use some make magic to
13 # filter those files to allow GCC compilation
14 ifeq ($(VPX_ARCH_ARM),yes)
15 ASM:=$(if $(filter yes,$(CONFIG_GCC)$(CONFIG_MSVS)),.asm.S,.asm)
21 # Rule to generate runtime cpu detection files
23 define rtcd_h_template
24 $$(BUILD_PFX)$(1).h: $$(SRC_PATH_BARE)/$(2)
26 $$(qexec)$$(SRC_PATH_BARE)/build/make/rtcd.pl --arch=$$(TGT_ISA) \
28 --config=$$(CONFIG_DIR)$$(target)-$$(TOOLCHAIN).mk \
29 $$(RTCD_OPTIONS) $$^ > $$@
30 CLEAN-OBJS += $$(BUILD_PFX)$(1).h
31 RTCD += $$(BUILD_PFX)$(1).h
34 CODEC_SRCS-yes += CHANGELOG
35 CODEC_SRCS-yes += libs.mk
37 include $(SRC_PATH_BARE)/vpx/vpx_codec.mk
38 CODEC_SRCS-yes += $(addprefix vpx/,$(call enabled,API_SRCS))
39 CODEC_DOC_SRCS += $(addprefix vpx/,$(call enabled,API_DOC_SRCS))
41 include $(SRC_PATH_BARE)/vpx_mem/vpx_mem.mk
42 CODEC_SRCS-yes += $(addprefix vpx_mem/,$(call enabled,MEM_SRCS))
44 include $(SRC_PATH_BARE)/vpx_scale/vpx_scale.mk
45 CODEC_SRCS-yes += $(addprefix vpx_scale/,$(call enabled,SCALE_SRCS))
47 include $(SRC_PATH_BARE)/vpx_ports/vpx_ports.mk
48 CODEC_SRCS-yes += $(addprefix vpx_ports/,$(call enabled,PORTS_SRCS))
50 include $(SRC_PATH_BARE)/vpx_dsp/vpx_dsp.mk
51 CODEC_SRCS-yes += $(addprefix vpx_dsp/,$(call enabled,DSP_SRCS))
53 include $(SRC_PATH_BARE)/vpx_util/vpx_util.mk
54 CODEC_SRCS-yes += $(addprefix vpx_util/,$(call enabled,UTIL_SRCS))
56 ifeq ($(CONFIG_VP8),yes)
58 include $(SRC_PATH_BARE)/$(VP8_PREFIX)vp8_common.mk
61 ifeq ($(CONFIG_VP8_ENCODER),yes)
62 include $(SRC_PATH_BARE)/$(VP8_PREFIX)vp8cx.mk
63 CODEC_SRCS-yes += $(addprefix $(VP8_PREFIX),$(call enabled,VP8_CX_SRCS))
64 CODEC_EXPORTS-yes += $(addprefix $(VP8_PREFIX),$(VP8_CX_EXPORTS))
65 INSTALL-LIBS-yes += include/vpx/vp8.h include/vpx/vp8cx.h
66 INSTALL-LIBS-yes += include/vpx/vpx_ext_ratectrl.h
67 INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/$(VP8_PREFIX)/%
68 CODEC_DOC_SECTIONS += vp8 vp8_encoder
71 ifeq ($(CONFIG_VP8_DECODER),yes)
72 include $(SRC_PATH_BARE)/$(VP8_PREFIX)vp8dx.mk
73 CODEC_SRCS-yes += $(addprefix $(VP8_PREFIX),$(call enabled,VP8_DX_SRCS))
74 CODEC_EXPORTS-yes += $(addprefix $(VP8_PREFIX),$(VP8_DX_EXPORTS))
75 INSTALL-LIBS-yes += include/vpx/vp8.h include/vpx/vp8dx.h
76 INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/$(VP8_PREFIX)/%
77 CODEC_DOC_SECTIONS += vp8 vp8_decoder
80 ifeq ($(CONFIG_VP9),yes)
82 include $(SRC_PATH_BARE)/$(VP9_PREFIX)vp9_common.mk
85 ifeq ($(CONFIG_VP9_ENCODER),yes)
87 include $(SRC_PATH_BARE)/$(VP9_PREFIX)vp9cx.mk
88 CODEC_SRCS-yes += $(addprefix $(VP9_PREFIX),$(call enabled,VP9_CX_SRCS))
89 CODEC_EXPORTS-yes += $(addprefix $(VP9_PREFIX),$(VP9_CX_EXPORTS))
90 CODEC_SRCS-yes += $(VP9_PREFIX)vp9cx.mk vpx/vp8.h vpx/vp8cx.h
91 CODEC_SRCS-yes += vpx/vpx_ext_ratectrl.h
92 INSTALL-LIBS-yes += include/vpx/vp8.h include/vpx/vp8cx.h
93 INSTALL-LIBS-yes += include/vpx/vpx_ext_ratectrl.h
94 INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/$(VP9_PREFIX)/%
95 CODEC_DOC_SRCS += vpx/vp8.h vpx/vp8cx.h vpx/vpx_ext_ratectrl.h
96 CODEC_DOC_SECTIONS += vp9 vp9_encoder
99 RC_RTC_SRCS := vpx/vp8.h vpx/vp8cx.h
100 RC_RTC_SRCS += vpx/vpx_ext_ratectrl.h
101 RC_RTC_SRCS += vpx/internal/vpx_ratectrl_rtc.h
102 ifeq ($(CONFIG_VP9_ENCODER),yes)
104 RC_RTC_SRCS += $(addprefix $(VP9_PREFIX),$(call enabled,VP9_CX_SRCS))
105 RC_RTC_SRCS += $(VP9_PREFIX)vp9cx.mk
106 RC_RTC_SRCS += $(VP9_PREFIX)ratectrl_rtc.cc
107 RC_RTC_SRCS += $(VP9_PREFIX)ratectrl_rtc.h
108 INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(VP9_PREFIX)ratectrl_rtc.cc
109 INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(VP9_PREFIX)ratectrl_rtc.h
111 ifeq ($(CONFIG_VP8_ENCODER),yes)
113 RC_RTC_SRCS += $(addprefix $(VP8_PREFIX),$(call enabled,VP8_CX_SRCS))
114 RC_RTC_SRCS += $(VP8_PREFIX)vp8_ratectrl_rtc.cc
115 RC_RTC_SRCS += $(VP8_PREFIX)vp8_ratectrl_rtc.h
116 INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(VP8_PREFIX)vp8_ratectrl_rtc.cc
117 INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(VP8_PREFIX)vp8_ratectrl_rtc.h
120 ifeq ($(CONFIG_VP9_DECODER),yes)
122 include $(SRC_PATH_BARE)/$(VP9_PREFIX)vp9dx.mk
123 CODEC_SRCS-yes += $(addprefix $(VP9_PREFIX),$(call enabled,VP9_DX_SRCS))
124 CODEC_EXPORTS-yes += $(addprefix $(VP9_PREFIX),$(VP9_DX_EXPORTS))
125 CODEC_SRCS-yes += $(VP9_PREFIX)vp9dx.mk vpx/vp8.h vpx/vp8dx.h
126 INSTALL-LIBS-yes += include/vpx/vp8.h include/vpx/vp8dx.h
127 INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/$(VP9_PREFIX)/%
128 CODEC_DOC_SRCS += vpx/vp8.h vpx/vp8dx.h
129 CODEC_DOC_SECTIONS += vp9 vp9_decoder
132 ifeq ($(CONFIG_ENCODERS),yes)
133 CODEC_DOC_SECTIONS += encoder
135 ifeq ($(CONFIG_DECODERS),yes)
136 CODEC_DOC_SECTIONS += decoder
139 ifeq ($(CONFIG_MSVS),yes)
140 CODEC_LIB=$(if $(CONFIG_STATIC_MSVCRT),vpxmt,vpxmd)
141 GTEST_LIB=$(if $(CONFIG_STATIC_MSVCRT),gtestmt,gtestmd)
142 RC_RTC_LIB=$(if $(CONFIG_STATIC_MSVCRT),vpxrcmt,vpxrcmd)
143 # This variable uses deferred expansion intentionally, since the results of
144 # $(wildcard) may change during the course of the Make.
145 VS_PLATFORMS = $(foreach d,$(wildcard */Release/$(CODEC_LIB).lib),$(word 1,$(subst /, ,$(d))))
148 # The following pairs define a mapping of locations in the distribution
149 # tree to locations in the source/build trees.
150 INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/vpx/%
151 INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/vpx_ports/%
152 INSTALL_MAPS += $(LIBSUBDIR)/% %
153 INSTALL_MAPS += src/% $(SRC_PATH_BARE)/%
154 ifeq ($(CONFIG_MSVS),yes)
155 INSTALL_MAPS += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/% $(p)/Release/%)
156 INSTALL_MAPS += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/% $(p)/Debug/%)
159 CODEC_SRCS-yes += build/make/version.sh
160 CODEC_SRCS-yes += build/make/rtcd.pl
161 CODEC_SRCS-yes += vpx_ports/emmintrin_compat.h
162 CODEC_SRCS-yes += vpx_ports/mem_ops.h
163 CODEC_SRCS-yes += vpx_ports/mem_ops_aligned.h
164 CODEC_SRCS-yes += vpx_ports/vpx_once.h
165 CODEC_SRCS-yes += $(BUILD_PFX)vpx_config.c
166 INSTALL-SRCS-no += $(BUILD_PFX)vpx_config.c
167 ifeq ($(VPX_ARCH_X86)$(VPX_ARCH_X86_64),yes)
168 INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += third_party/x86inc/x86inc.asm
169 INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += vpx_dsp/x86/bitdepth_conversion_sse2.asm
171 CODEC_EXPORTS-yes += vpx/exports_com
172 CODEC_EXPORTS-$(CONFIG_ENCODERS) += vpx/exports_enc
173 CODEC_EXPORTS-$(CONFIG_DECODERS) += vpx/exports_dec
175 INSTALL-LIBS-yes += include/vpx/vpx_codec.h
176 INSTALL-LIBS-yes += include/vpx/vpx_frame_buffer.h
177 INSTALL-LIBS-yes += include/vpx/vpx_image.h
178 INSTALL-LIBS-yes += include/vpx/vpx_integer.h
179 INSTALL-LIBS-$(CONFIG_DECODERS) += include/vpx/vpx_decoder.h
180 INSTALL-LIBS-$(CONFIG_ENCODERS) += include/vpx/vpx_encoder.h
181 ifeq ($(CONFIG_EXTERNAL_BUILD),yes)
182 ifeq ($(CONFIG_MSVS),yes)
183 INSTALL-LIBS-yes += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/$(CODEC_LIB).lib)
184 INSTALL-LIBS-$(CONFIG_DEBUG_LIBS) += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/$(CODEC_LIB)d.lib)
185 INSTALL-LIBS-$(CONFIG_SHARED) += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/vpx.dll)
186 INSTALL-LIBS-$(CONFIG_SHARED) += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/vpx.exp)
189 INSTALL-LIBS-$(CONFIG_STATIC) += $(LIBSUBDIR)/libvpx.a
190 INSTALL-LIBS-$(CONFIG_DEBUG_LIBS) += $(LIBSUBDIR)/libvpx_g.a
193 ifeq ($(CONFIG_VP9_ENCODER)$(CONFIG_RATE_CTRL),yesyes)
194 SIMPLE_ENCODE_SRCS := $(call enabled,CODEC_SRCS)
195 SIMPLE_ENCODE_SRCS += $(VP9_PREFIX)simple_encode.cc
196 SIMPLE_ENCODE_SRCS += $(VP9_PREFIX)simple_encode.h
197 SIMPLE_ENCODE_SRCS += ivfenc.h
198 SIMPLE_ENCODE_SRCS += ivfenc.c
199 INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(VP9_PREFIX)simple_encode.cc
200 INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(VP9_PREFIX)simple_encode.h
203 CODEC_SRCS=$(call enabled,CODEC_SRCS)
205 INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(CODEC_SRCS)
206 INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(call enabled,CODEC_EXPORTS)
209 # Generate a list of all enabled sources, in particular for exporting to gyp
210 # based build systems.
213 @echo $(CODEC_SRCS) | xargs -n1 echo | LC_ALL=C sort -u > $@
214 CLEAN-OBJS += libvpx_srcs.txt
216 # Assembly files that are included, but don't define symbols themselves.
217 # Filtered out to avoid Windows build warnings.
219 third_party/x86inc/x86inc.asm \
221 vpx_ports/x86_abi_support.asm \
222 vpx_dsp/x86/bitdepth_conversion_sse2.asm \
224 ifeq ($(CONFIG_EXTERNAL_BUILD),yes)
225 ifeq ($(CONFIG_MSVS),yes)
227 vpx.def: $(call enabled,CODEC_EXPORTS)
229 $(qexec)$(SRC_PATH_BARE)/build/make/gen_msvs_def.sh\
232 CLEAN-OBJS += vpx.def
234 vpx.$(VCPROJ_SFX): VCPROJ_SRCS=$(filter-out $(addprefix %, $(ASM_INCLUDES)), $^)
236 vpx.$(VCPROJ_SFX): $(CODEC_SRCS) vpx.def
238 $(qexec)$(GEN_VCPROJ) \
239 $(if $(CONFIG_SHARED),--dll,--lib) \
240 --target=$(TOOLCHAIN) \
241 $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \
243 --proj-guid=DCE19DAF-69AC-46DB-B14A-39F0FAA5DB74 \
244 --module-def=vpx.def \
245 --ver=$(CONFIG_VS_VERSION) \
246 --src-path-bare="$(SRC_PATH_BARE)" \
249 $(filter $(SRC_PATH_BARE)/vp8/%.c, $(VCPROJ_SRCS)) \
250 $(filter $(SRC_PATH_BARE)/vp8/%.h, $(VCPROJ_SRCS)) \
251 $(filter $(SRC_PATH_BARE)/vp9/%.c, $(VCPROJ_SRCS)) \
252 $(filter $(SRC_PATH_BARE)/vp9/%.h, $(VCPROJ_SRCS)) \
253 $(filter $(SRC_PATH_BARE)/vpx/%, $(VCPROJ_SRCS)) \
254 $(filter $(SRC_PATH_BARE)/vpx_dsp/%, $(VCPROJ_SRCS)) \
255 $(filter-out $(addprefix $(SRC_PATH_BARE)/, \
256 vp8/%.c vp8/%.h vp9/%.c vp9/%.h vpx/% vpx_dsp/%), \
258 --src-path-bare="$(SRC_PATH_BARE)" \
260 PROJECTS-yes += vpx.$(VCPROJ_SFX)
262 vpx.$(VCPROJ_SFX): vpx_config.asm
263 vpx.$(VCPROJ_SFX): $(RTCD)
265 vpxrc.$(VCPROJ_SFX): \
266 VCPROJ_SRCS=$(filter-out $(addprefix %, $(ASM_INCLUDES)), $^)
268 vpxrc.$(VCPROJ_SFX): $(RC_RTC_SRCS)
270 $(qexec)$(GEN_VCPROJ) \
271 $(if $(CONFIG_SHARED),--dll,--lib) \
272 --target=$(TOOLCHAIN) \
273 $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \
275 --proj-guid=C26FF952-9494-4838-9A3F-7F3D4F613385 \
276 --ver=$(CONFIG_VS_VERSION) \
277 --src-path-bare="$(SRC_PATH_BARE)" \
280 $(filter $(SRC_PATH_BARE)/vp9/%.c, $(VCPROJ_SRCS)) \
281 $(filter $(SRC_PATH_BARE)/vp9/%.cc, $(VCPROJ_SRCS)) \
282 $(filter $(SRC_PATH_BARE)/vp9/%.h, $(VCPROJ_SRCS)) \
283 $(filter $(SRC_PATH_BARE)/vpx/%, $(VCPROJ_SRCS)) \
284 $(filter $(SRC_PATH_BARE)/vpx_dsp/%, $(VCPROJ_SRCS)) \
285 $(filter-out $(addprefix $(SRC_PATH_BARE)/, \
286 vp8/%.c vp8/%.h vp9/%.c vp9/%.cc vp9/%.h vpx/% \
289 --src-path-bare="$(SRC_PATH_BARE)" \
291 PROJECTS-yes += vpxrc.$(VCPROJ_SFX)
293 vpxrc.$(VCPROJ_SFX): vpx_config.asm
294 vpxrc.$(VCPROJ_SFX): $(RTCD)
296 endif # ifeq ($(CONFIG_MSVS),yes)
297 else # ifeq ($(CONFIG_EXTERNAL_BUILD),yes)
298 LIBVPX_OBJS=$(call objs, $(filter-out $(ASM_INCLUDES), $(CODEC_SRCS)))
299 OBJS-yes += $(LIBVPX_OBJS)
300 LIBS-$(if yes,$(CONFIG_STATIC)) += $(BUILD_PFX)libvpx.a $(BUILD_PFX)libvpx_g.a
301 $(BUILD_PFX)libvpx_g.a: $(LIBVPX_OBJS)
303 # Updating version info.
304 # https://www.gnu.org/software/libtool/manual/libtool.html#Updating-version-info
305 # For libtool: c=<current>, a=<age>, r=<revision>
306 # libtool generates .so file as .so.[c-a].a.r, while -version-info c:r:a is
309 # libvpx library file is generated as libvpx.so.<MAJOR>.<MINOR>.<PATCH>
310 # MAJOR = c-a, MINOR = a, PATCH = r
312 # To determine SO_VERSION_{MAJOR,MINOR,PATCH}, calculate c,a,r with current
313 # SO_VERSION_* then follow the rules in the link to detemine the new version
314 # (c1, a1, r1) and set MAJOR to [c1-a1], MINOR to a1 and PATCH to r1
315 SO_VERSION_MAJOR := 7
316 SO_VERSION_MINOR := 1
317 SO_VERSION_PATCH := 0
318 ifeq ($(filter darwin%,$(TGT_OS)),$(TGT_OS))
319 LIBVPX_SO := libvpx.$(SO_VERSION_MAJOR).dylib
320 SHARED_LIB_SUF := .dylib
321 EXPORT_FILE := libvpx.syms
322 LIBVPX_SO_SYMLINKS := $(addprefix $(LIBSUBDIR)/, \
325 ifeq ($(filter iphonesimulator%,$(TGT_OS)),$(TGT_OS))
326 LIBVPX_SO := libvpx.$(SO_VERSION_MAJOR).dylib
327 SHARED_LIB_SUF := .dylib
328 EXPORT_FILE := libvpx.syms
329 LIBVPX_SO_SYMLINKS := $(addprefix $(LIBSUBDIR)/, libvpx.dylib)
331 ifeq ($(filter os2%,$(TGT_OS)),$(TGT_OS))
332 LIBVPX_SO := libvpx$(SO_VERSION_MAJOR).dll
333 SHARED_LIB_SUF := _dll.a
334 EXPORT_FILE := libvpx.def
335 LIBVPX_SO_SYMLINKS :=
336 LIBVPX_SO_IMPLIB := libvpx_dll.a
338 LIBVPX_SO := libvpx.so.$(SO_VERSION_MAJOR).$(SO_VERSION_MINOR).$(SO_VERSION_PATCH)
339 SHARED_LIB_SUF := .so
340 EXPORT_FILE := libvpx.ver
341 LIBVPX_SO_SYMLINKS := $(addprefix $(LIBSUBDIR)/, \
342 libvpx.so libvpx.so.$(SO_VERSION_MAJOR) \
343 libvpx.so.$(SO_VERSION_MAJOR).$(SO_VERSION_MINOR))
348 LIBS-$(CONFIG_SHARED) += $(BUILD_PFX)$(LIBVPX_SO)\
349 $(notdir $(LIBVPX_SO_SYMLINKS)) \
350 $(if $(LIBVPX_SO_IMPLIB), $(BUILD_PFX)$(LIBVPX_SO_IMPLIB))
351 $(BUILD_PFX)$(LIBVPX_SO): $(LIBVPX_OBJS) $(EXPORT_FILE)
352 $(BUILD_PFX)$(LIBVPX_SO): extralibs += -lm
353 $(BUILD_PFX)$(LIBVPX_SO): SONAME = libvpx.so.$(SO_VERSION_MAJOR)
354 $(BUILD_PFX)$(LIBVPX_SO): EXPORTS_FILE = $(EXPORT_FILE)
356 libvpx.def: $(call enabled,CODEC_EXPORTS)
358 $(qexec)echo LIBRARY $(LIBVPX_SO:.dll=) INITINSTANCE TERMINSTANCE > $@
359 $(qexec)echo "DATA MULTIPLE NONSHARED" >> $@
360 $(qexec)echo "EXPORTS" >> $@
361 $(qexec)awk '!/vpx_svc_*/ {print "_"$$2}' $^ >>$@
362 CLEAN-OBJS += libvpx.def
364 libvpx_dll.a: $(LIBVPX_SO)
366 $(qexec)emximp -o $@ $<
367 CLEAN-OBJS += libvpx_dll.a
369 define libvpx_symlink_template
371 @echo " [LN] $(2) $$@"
372 $(qexec)mkdir -p $$(dir $$@)
373 $(qexec)ln -sf $(2) $$@
376 $(eval $(call libvpx_symlink_template,\
377 $(addprefix $(BUILD_PFX),$(notdir $(LIBVPX_SO_SYMLINKS))),\
378 $(BUILD_PFX)$(LIBVPX_SO)))
379 $(eval $(call libvpx_symlink_template,\
380 $(addprefix $(DIST_DIR)/,$(LIBVPX_SO_SYMLINKS)),\
384 INSTALL-LIBS-$(CONFIG_SHARED) += $(LIBVPX_SO_SYMLINKS)
385 INSTALL-LIBS-$(CONFIG_SHARED) += $(LIBSUBDIR)/$(LIBVPX_SO)
386 INSTALL-LIBS-$(CONFIG_SHARED) += $(if $(LIBVPX_SO_IMPLIB),$(LIBSUBDIR)/$(LIBVPX_SO_IMPLIB))
390 vpx.pc: config.mk libs.mk
392 $(qexec)echo '# pkg-config file from libvpx $(VERSION_STRING)' > $@
393 $(qexec)echo 'prefix=$(PREFIX)' >> $@
394 $(qexec)echo 'exec_prefix=$${prefix}' >> $@
395 $(qexec)echo 'libdir=$${prefix}/$(LIBSUBDIR)' >> $@
396 $(qexec)echo 'includedir=$${prefix}/include' >> $@
397 $(qexec)echo '' >> $@
398 $(qexec)echo 'Name: vpx' >> $@
399 $(qexec)echo 'Description: WebM Project VPx codec implementation' >> $@
400 $(qexec)echo 'Version: $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH)' >> $@
401 $(qexec)echo 'Requires:' >> $@
402 $(qexec)echo 'Conflicts:' >> $@
403 $(qexec)echo 'Libs: -L$${libdir} -lvpx -lm' >> $@
404 ifeq ($(HAVE_PTHREAD_H),yes)
405 $(qexec)echo 'Libs.private: -lm -lpthread' >> $@
407 $(qexec)echo 'Libs.private: -lm' >> $@
409 $(qexec)echo 'Cflags: -I$${includedir}' >> $@
410 INSTALL-LIBS-yes += $(LIBSUBDIR)/pkgconfig/vpx.pc
411 INSTALL_MAPS += $(LIBSUBDIR)/pkgconfig/%.pc %.pc
414 ifeq ($(CONFIG_ENCODERS),yes)
415 RC_RTC_OBJS=$(call objs,$(RC_RTC_SRCS))
416 OBJS-yes += $(RC_RTC_OBJS)
417 LIBS-yes += $(BUILD_PFX)libvpxrc.a $(BUILD_PFX)libvpxrc_g.a
418 $(BUILD_PFX)libvpxrc_g.a: $(RC_RTC_OBJS)
421 ifeq ($(CONFIG_VP9_ENCODER)$(CONFIG_RATE_CTRL),yesyes)
422 SIMPLE_ENCODE_OBJS=$(call objs,$(SIMPLE_ENCODE_SRCS))
423 OBJS-yes += $(SIMPLE_ENCODE_OBJS)
424 LIBS-yes += $(BUILD_PFX)libsimple_encode.a $(BUILD_PFX)libsimple_encode_g.a
425 $(BUILD_PFX)libsimple_encode_g.a: $(SIMPLE_ENCODE_OBJS)
428 endif # ifeq ($(CONFIG_EXTERNAL_BUILD),yes)
430 libvpx.ver: $(call enabled,CODEC_EXPORTS)
432 $(qexec)echo "{ global:" > $@
433 $(qexec)for f in $?; do awk '{print $$2";"}' < $$f >>$@; done
434 $(qexec)echo "local: *; };" >> $@
435 CLEAN-OBJS += libvpx.ver
437 libvpx.syms: $(call enabled,CODEC_EXPORTS)
439 $(qexec)awk '{print "_"$$2}' $^ >$@
440 CLEAN-OBJS += libvpx.syms
443 # Rule to make assembler configuration file from C configuration file
445 ifeq ($(VPX_ARCH_X86)$(VPX_ARCH_X86_64),yes)
447 $(BUILD_PFX)vpx_config.asm: $(BUILD_PFX)vpx_config.h
449 @LC_ALL=C egrep "#define [A-Z0-9_]+ [01]" $< \
450 | awk '{print $$2 " equ " $$3}' > $@
452 ADS2GAS=$(if $(filter yes,$(CONFIG_GCC)),| $(ASM_CONVERSION))
453 $(BUILD_PFX)vpx_config.asm: $(BUILD_PFX)vpx_config.h
455 @LC_ALL=C egrep "#define [A-Z0-9_]+ [01]" $< \
456 | awk '{print $$2 " EQU " $$3}' $(ADS2GAS) > $@
457 @echo " END" $(ADS2GAS) >> $@
458 CLEAN-OBJS += $(BUILD_PFX)vpx_config.asm
462 # Add assembler dependencies for configuration.
464 $(filter %.S.o,$(OBJS-yes)): $(BUILD_PFX)vpx_config.asm
465 $(filter %$(ASM).o,$(OBJS-yes)): $(BUILD_PFX)vpx_config.asm
468 $(shell $(SRC_PATH_BARE)/build/make/version.sh "$(SRC_PATH_BARE)" $(BUILD_PFX)vpx_version.h)
469 CLEAN-OBJS += $(BUILD_PFX)vpx_version.h
472 # Add include path for libwebm sources.
474 ifeq ($(CONFIG_WEBM_IO),yes)
475 CXXFLAGS += -I$(SRC_PATH_BARE)/third_party/libwebm
479 ## libvpx test directives
481 ifeq ($(CONFIG_UNIT_TESTS),yes)
482 LIBVPX_TEST_DATA_PATH ?= .
484 include $(SRC_PATH_BARE)/test/test.mk
486 # addprefix_clean behaves like addprefix if the target doesn't start with "../"
487 # However, if the target starts with "../", instead of adding prefix,
488 # it will remove "../".
489 # Using addprefix_clean, we can avoid two different targets building the
491 # test/../ivfenc.c.d: ivfenc.o
492 # ivfenc.c.d: ivfenc.o
493 # Note that the other way to solve this problem is using "realpath".
494 # The "realpath" is supported by make 3.81 or later.
495 addprefix_clean=$(patsubst $(1)../%,%,$(addprefix $(1), $(2)))
496 LIBVPX_TEST_SRCS=$(call addprefix_clean,test/,$(call enabled,LIBVPX_TEST_SRCS))
498 LIBVPX_TEST_BIN=./test_libvpx$(EXE_SFX)
499 LIBVPX_TEST_DATA=$(addprefix $(LIBVPX_TEST_DATA_PATH)/,\
500 $(call enabled,LIBVPX_TEST_DATA))
501 libvpx_test_data_url=https://storage.googleapis.com/downloads.webmproject.org/test_data/libvpx/$(1)
503 TEST_INTRA_PRED_SPEED_BIN=./test_intra_pred_speed$(EXE_SFX)
504 TEST_INTRA_PRED_SPEED_SRCS=$(call addprefix_clean,test/,\
505 $(call enabled,TEST_INTRA_PRED_SPEED_SRCS))
506 TEST_INTRA_PRED_SPEED_OBJS := $(sort $(call objs,$(TEST_INTRA_PRED_SPEED_SRCS)))
508 ifeq ($(CONFIG_ENCODERS),yes)
509 RC_INTERFACE_TEST_BIN=./test_rc_interface$(EXE_SFX)
510 RC_INTERFACE_TEST_SRCS=$(call addprefix_clean,test/,\
511 $(call enabled,RC_INTERFACE_TEST_SRCS))
512 RC_INTERFACE_TEST_OBJS := $(sort $(call objs,$(RC_INTERFACE_TEST_SRCS)))
515 SIMPLE_ENCODE_TEST_BIN=./test_simple_encode$(EXE_SFX)
516 SIMPLE_ENCODE_TEST_SRCS=$(call addprefix_clean,test/,\
517 $(call enabled,SIMPLE_ENCODE_TEST_SRCS))
518 SIMPLE_ENCODE_TEST_OBJS := $(sort $(call objs,$(SIMPLE_ENCODE_TEST_SRCS)))
520 libvpx_test_srcs.txt:
522 @echo $(LIBVPX_TEST_SRCS) | xargs -n1 echo | LC_ALL=C sort -u > $@
523 CLEAN-OBJS += libvpx_test_srcs.txt
525 # Attempt to download the file using curl, retrying once if it fails for a
527 $(LIBVPX_TEST_DATA): $(SRC_PATH_BARE)/test/test-data.sha1
528 @echo " [DOWNLOAD] $@"
530 trap 'rm -f $@' INT TERM; \
531 curl="curl -S -s --retry 1 -L -o $@ $(call libvpx_test_data_url,$(@F))"; \
539 testdata:: $(LIBVPX_TEST_DATA)
540 $(qexec)[ -x "$$(which sha1sum)" ] && sha1sum=sha1sum;\
541 [ -x "$$(which shasum)" ] && sha1sum=shasum;\
542 [ -x "$$(which sha1)" ] && sha1sum=sha1;\
543 if [ -n "$${sha1sum}" ]; then\
545 echo "Checking test data:";\
546 for f in $(call enabled,LIBVPX_TEST_DATA); do\
547 grep $$f $(SRC_PATH_BARE)/test/test-data.sha1 |\
548 (cd $(LIBVPX_TEST_DATA_PATH); $${sha1sum} -c);\
551 echo "Skipping test data integrity check, sha1sum not found.";\
554 ifeq ($(CONFIG_EXTERNAL_BUILD),yes)
555 ifeq ($(CONFIG_MSVS),yes)
557 gtest.$(VCPROJ_SFX): $(SRC_PATH_BARE)/third_party/googletest/src/src/gtest-all.cc
559 $(qexec)$(GEN_VCPROJ) \
561 --target=$(TOOLCHAIN) \
562 $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \
564 --proj-guid=EC00E1EC-AF68-4D92-A255-181690D1C9B1 \
565 --ver=$(CONFIG_VS_VERSION) \
566 --src-path-bare="$(SRC_PATH_BARE)" \
569 --out=gtest.$(VCPROJ_SFX) $(SRC_PATH_BARE)/third_party/googletest/src/src/gtest-all.cc \
570 -I. -I"$(SRC_PATH_BARE)/third_party/googletest/src/include" -I"$(SRC_PATH_BARE)/third_party/googletest/src"
572 PROJECTS-$(CONFIG_MSVS) += gtest.$(VCPROJ_SFX)
574 test_libvpx.$(VCPROJ_SFX): $(LIBVPX_TEST_SRCS) vpx.$(VCPROJ_SFX) gtest.$(VCPROJ_SFX)
576 $(qexec)$(GEN_VCPROJ) \
578 --target=$(TOOLCHAIN) \
581 --proj-guid=CD837F5F-52D8-4314-A370-895D614166A7 \
582 --ver=$(CONFIG_VS_VERSION) \
583 --src-path-bare="$(SRC_PATH_BARE)" \
585 $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \
586 --out=$@ $(INTERNAL_CFLAGS) $(CFLAGS) \
587 -I. -I"$(SRC_PATH_BARE)/third_party/googletest/src/include" \
588 $(if $(CONFIG_WEBM_IO),-I"$(SRC_PATH_BARE)/third_party/libwebm") \
589 -L. -l$(CODEC_LIB) -l$(GTEST_LIB) $^
591 PROJECTS-$(CONFIG_MSVS) += test_libvpx.$(VCPROJ_SFX)
593 LIBVPX_TEST_BIN := $(addprefix $(TGT_OS:win64=x64)/Release/,$(notdir $(LIBVPX_TEST_BIN)))
595 ifneq ($(strip $(TEST_INTRA_PRED_SPEED_OBJS)),)
596 PROJECTS-$(CONFIG_MSVS) += test_intra_pred_speed.$(VCPROJ_SFX)
597 test_intra_pred_speed.$(VCPROJ_SFX): $(TEST_INTRA_PRED_SPEED_SRCS) vpx.$(VCPROJ_SFX) gtest.$(VCPROJ_SFX)
599 $(qexec)$(GEN_VCPROJ) \
601 --target=$(TOOLCHAIN) \
602 --name=test_intra_pred_speed \
604 --proj-guid=CD837F5F-52D8-4314-A370-895D614166A7 \
605 --ver=$(CONFIG_VS_VERSION) \
606 --src-path-bare="$(SRC_PATH_BARE)" \
608 $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \
609 --out=$@ $(INTERNAL_CFLAGS) $(CFLAGS) \
610 -I. -I"$(SRC_PATH_BARE)/third_party/googletest/src/include" \
611 -L. -l$(CODEC_LIB) -l$(GTEST_LIB) $^
612 endif # TEST_INTRA_PRED_SPEED
614 ifeq ($(CONFIG_ENCODERS),yes)
615 ifneq ($(strip $(RC_INTERFACE_TEST_OBJS)),)
616 PROJECTS-$(CONFIG_MSVS) += test_rc_interface.$(VCPROJ_SFX)
617 test_rc_interface.$(VCPROJ_SFX): $(RC_INTERFACE_TEST_SRCS) vpx.$(VCPROJ_SFX) \
618 vpxrc.$(VCPROJ_SFX) gtest.$(VCPROJ_SFX)
620 $(qexec)$(GEN_VCPROJ) \
622 --target=$(TOOLCHAIN) \
623 --name=test_rc_interface \
625 --proj-guid=30458F88-1BC6-4689-B41C-50F3737AAB27 \
626 --ver=$(CONFIG_VS_VERSION) \
628 --src-path-bare="$(SRC_PATH_BARE)" \
629 $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \
630 --out=$@ $(INTERNAL_CFLAGS) $(CFLAGS) \
631 -I. -I"$(SRC_PATH_BARE)/third_party/googletest/src/include" \
632 -L. -l$(CODEC_LIB) -l$(RC_RTC_LIB) -l$(GTEST_LIB) $^
633 endif # RC_INTERFACE_TEST
634 endif # CONFIG_VP9_ENCODER
638 include $(SRC_PATH_BARE)/third_party/googletest/gtest.mk
639 GTEST_SRCS := $(addprefix third_party/googletest/src/,$(call enabled,GTEST_SRCS))
640 GTEST_OBJS=$(call objs,$(GTEST_SRCS))
641 ifeq ($(filter win%,$(TGT_OS)),$(TGT_OS))
642 # Disabling pthreads globally will cause issues on darwin and possibly elsewhere
643 $(GTEST_OBJS) $(GTEST_OBJS:.o=.d): CXXFLAGS += -DGTEST_HAS_PTHREAD=0
645 GTEST_INCLUDES := -I$(SRC_PATH_BARE)/third_party/googletest/src
646 GTEST_INCLUDES += -I$(SRC_PATH_BARE)/third_party/googletest/src/include
647 $(GTEST_OBJS) $(GTEST_OBJS:.o=.d): CXXFLAGS += $(GTEST_INCLUDES)
648 OBJS-yes += $(GTEST_OBJS)
649 LIBS-yes += $(BUILD_PFX)libgtest.a $(BUILD_PFX)libgtest_g.a
650 $(BUILD_PFX)libgtest_g.a: $(GTEST_OBJS)
652 LIBVPX_TEST_OBJS=$(sort $(call objs,$(LIBVPX_TEST_SRCS)))
653 $(LIBVPX_TEST_OBJS) $(LIBVPX_TEST_OBJS:.o=.d): CXXFLAGS += $(GTEST_INCLUDES)
654 OBJS-yes += $(LIBVPX_TEST_OBJS)
655 BINS-yes += $(LIBVPX_TEST_BIN)
657 CODEC_LIB=$(if $(CONFIG_DEBUG_LIBS),vpx_g,vpx)
658 CODEC_LIB_SUF=$(if $(CONFIG_SHARED),$(SHARED_LIB_SUF),.a)
659 TEST_LIBS := lib$(CODEC_LIB)$(CODEC_LIB_SUF) libgtest.a
660 $(LIBVPX_TEST_BIN): $(TEST_LIBS)
661 $(eval $(call linkerxx_template,$(LIBVPX_TEST_BIN), \
662 $(LIBVPX_TEST_OBJS) \
663 -L. -lvpx -lgtest $(extralibs) -lm))
665 ifneq ($(strip $(TEST_INTRA_PRED_SPEED_OBJS)),)
666 $(TEST_INTRA_PRED_SPEED_OBJS) $(TEST_INTRA_PRED_SPEED_OBJS:.o=.d): CXXFLAGS += $(GTEST_INCLUDES)
667 OBJS-yes += $(TEST_INTRA_PRED_SPEED_OBJS)
668 BINS-yes += $(TEST_INTRA_PRED_SPEED_BIN)
670 $(TEST_INTRA_PRED_SPEED_BIN): $(TEST_LIBS)
671 $(eval $(call linkerxx_template,$(TEST_INTRA_PRED_SPEED_BIN), \
672 $(TEST_INTRA_PRED_SPEED_OBJS) \
673 -L. -lvpx -lgtest $(extralibs) -lm))
674 endif # TEST_INTRA_PRED_SPEED
676 ifeq ($(CONFIG_ENCODERS),yes)
677 ifneq ($(strip $(RC_INTERFACE_TEST_OBJS)),)
678 $(RC_INTERFACE_TEST_OBJS) $(RC_INTERFACE_TEST_OBJS:.o=.d): \
679 CXXFLAGS += $(GTEST_INCLUDES)
680 OBJS-yes += $(RC_INTERFACE_TEST_OBJS)
681 BINS-yes += $(RC_INTERFACE_TEST_BIN)
683 $(RC_INTERFACE_TEST_BIN): $(TEST_LIBS) libvpxrc.a
684 $(eval $(call linkerxx_template,$(RC_INTERFACE_TEST_BIN), \
685 $(RC_INTERFACE_TEST_OBJS) \
686 -L. -lvpx -lgtest -lvpxrc $(extralibs) -lm))
687 endif # RC_INTERFACE_TEST
688 endif # CONFIG_ENCODERS
690 ifneq ($(strip $(SIMPLE_ENCODE_TEST_OBJS)),)
691 $(SIMPLE_ENCODE_TEST_OBJS) $(SIMPLE_ENCODE_TEST_OBJS:.o=.d): \
692 CXXFLAGS += $(GTEST_INCLUDES)
693 OBJS-yes += $(SIMPLE_ENCODE_TEST_OBJS)
694 BINS-yes += $(SIMPLE_ENCODE_TEST_BIN)
696 $(SIMPLE_ENCODE_TEST_BIN): $(TEST_LIBS) libsimple_encode.a
697 $(eval $(call linkerxx_template,$(SIMPLE_ENCODE_TEST_BIN), \
698 $(SIMPLE_ENCODE_TEST_OBJS) \
699 -L. -lsimple_encode -lvpx -lgtest $(extralibs) -lm))
700 endif # SIMPLE_ENCODE_TEST
702 endif # CONFIG_UNIT_TESTS
704 # Install test sources only if codec source is included
705 INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(patsubst $(SRC_PATH_BARE)/%,%,\
706 $(shell find $(SRC_PATH_BARE)/third_party/googletest -type f))
707 INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(LIBVPX_TEST_SRCS)
708 INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(TEST_INTRA_PRED_SPEED_SRCS)
709 INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(RC_INTERFACE_TEST_SRCS)
711 define test_shard_template
712 test:: test_shard.$(1)
713 test-no-data-check:: test_shard_ndc.$(1)
714 test_shard.$(1) test_shard_ndc.$(1): $(LIBVPX_TEST_BIN)
716 export GTEST_SHARD_INDEX=$(1); \
717 export GTEST_TOTAL_SHARDS=$(2); \
719 test_shard.$(1): testdata
720 .PHONY: test_shard.$(1)
724 SHARDS := 0 1 2 3 4 5 6 7 8 9
725 $(foreach s,$(SHARDS),$(eval $(call test_shard_template,$(s),$(NUM_SHARDS))))
730 ## documentation directives
732 CLEAN-OBJS += libs.doxy
733 DOCS-yes += libs.doxy
734 libs.doxy: $(CODEC_DOC_SRCS)
737 @echo "INPUT += $^" >> $@
738 @echo "INCLUDE_PATH += ." >> $@;
739 @echo "ENABLED_SECTIONS += $(sort $(CODEC_DOC_SECTIONS))" >> $@
741 ## Generate rtcd.h for all objects
742 ifeq ($(CONFIG_DEPENDENCY_TRACKING),yes)
743 $(OBJS-yes:.o=.d): $(RTCD)
748 ## Update the global src list
749 SRCS += $(CODEC_SRCS) $(LIBVPX_TEST_SRCS) $(GTEST_SRCS)
750 SRCS += $(RC_INTERFACE_TEST_SRCS)
753 ## vpxdec/vpxenc tests.
755 ifeq ($(CONFIG_UNIT_TESTS),yes)
757 ifeq ($(CONFIG_MSVS),yes)
758 # MSVC will build both Debug and Release configurations of tools in a
759 # sub directory named for the current target. Assume the user wants to
760 # run the Release tools, and assign TEST_BIN_PATH accordingly.
761 # TODO(tomfinegan): Is this adequate for ARM?
762 # TODO(tomfinegan): Support running the debug versions of tools?
763 TEST_BIN_PATH := $(addsuffix /$(TGT_OS:win64=x64)/Release, $(TEST_BIN_PATH))
765 utiltest utiltest-no-data-check:
766 $(qexec)$(SRC_PATH_BARE)/test/vpxdec.sh \
767 --test-data-path $(LIBVPX_TEST_DATA_PATH) \
768 --bin-path $(TEST_BIN_PATH)
769 $(qexec)$(SRC_PATH_BARE)/test/vpxenc.sh \
770 --test-data-path $(LIBVPX_TEST_DATA_PATH) \
771 --bin-path $(TEST_BIN_PATH)
774 utiltest utiltest-no-data-check:
775 @echo Unit tests must be enabled to make the utiltest target.
781 ifeq ($(CONFIG_UNIT_TESTS),yes)
782 # All non-MSVC targets output example targets in a sub dir named examples.
783 EXAMPLES_BIN_PATH = examples
784 ifeq ($(CONFIG_MSVS),yes)
785 # MSVC will build both Debug and Release configurations of the examples in a
786 # sub directory named for the current target. Assume the user wants to
787 # run the Release tools, and assign EXAMPLES_BIN_PATH accordingly.
788 # TODO(tomfinegan): Is this adequate for ARM?
789 # TODO(tomfinegan): Support running the debug versions of tools?
790 EXAMPLES_BIN_PATH := $(TGT_OS:win64=x64)/Release
792 exampletest exampletest-no-data-check: examples
793 $(qexec)$(SRC_PATH_BARE)/test/examples.sh \
794 --test-data-path $(LIBVPX_TEST_DATA_PATH) \
795 --bin-path $(EXAMPLES_BIN_PATH)
796 exampletest: testdata
798 exampletest exampletest-no-data-check:
799 @echo Unit tests must be enabled to make the exampletest target.