1## 2## Copyright (c) 2010 The WebM project authors. All Rights Reserved. 3## 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. 9## 10 11 12# ARM assembly files are written in RVCT-style. We use some make magic to 13# filter those files to allow GCC compilation 14ifeq ($(ARCH_ARM),yes) 15 ASM:=$(if $(filter yes,$(CONFIG_GCC)$(CONFIG_MSVS)),.asm.S,.asm) 16else 17 ASM:=.asm 18endif 19 20# 21# Rule to generate runtime cpu detection files 22# 23define rtcd_h_template 24$$(BUILD_PFX)$(1).h: $$(SRC_PATH_BARE)/$(2) 25 @echo " [CREATE] $$@" 26 $$(qexec)$$(SRC_PATH_BARE)/build/make/rtcd.pl --arch=$$(TGT_ISA) \ 27 --sym=$(1) \ 28 --config=$$(CONFIG_DIR)$$(target)-$$(TOOLCHAIN).mk \ 29 $$(RTCD_OPTIONS) $$^ > $$@ 30CLEAN-OBJS += $$(BUILD_PFX)$(1).h 31RTCD += $$(BUILD_PFX)$(1).h 32endef 33 34CODEC_SRCS-yes += CHANGELOG 35CODEC_SRCS-yes += libs.mk 36 37include $(SRC_PATH_BARE)/vpx/vpx_codec.mk 38CODEC_SRCS-yes += $(addprefix vpx/,$(call enabled,API_SRCS)) 39CODEC_DOC_SRCS += $(addprefix vpx/,$(call enabled,API_DOC_SRCS)) 40 41include $(SRC_PATH_BARE)/vpx_mem/vpx_mem.mk 42CODEC_SRCS-yes += $(addprefix vpx_mem/,$(call enabled,MEM_SRCS)) 43 44include $(SRC_PATH_BARE)/vpx_scale/vpx_scale.mk 45CODEC_SRCS-yes += $(addprefix vpx_scale/,$(call enabled,SCALE_SRCS)) 46 47include $(SRC_PATH_BARE)/vpx_ports/vpx_ports.mk 48CODEC_SRCS-yes += $(addprefix vpx_ports/,$(call enabled,PORTS_SRCS)) 49 50include $(SRC_PATH_BARE)/vpx_dsp/vpx_dsp.mk 51CODEC_SRCS-yes += $(addprefix vpx_dsp/,$(call enabled,DSP_SRCS)) 52 53include $(SRC_PATH_BARE)/vpx_util/vpx_util.mk 54CODEC_SRCS-yes += $(addprefix vpx_util/,$(call enabled,UTIL_SRCS)) 55 56ifeq ($(CONFIG_VP8),yes) 57 VP8_PREFIX=vp8/ 58 include $(SRC_PATH_BARE)/$(VP8_PREFIX)vp8_common.mk 59endif 60 61ifeq ($(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_MAPS += include/vpx/% $(SRC_PATH_BARE)/$(VP8_PREFIX)/% 67 CODEC_DOC_SECTIONS += vp8 vp8_encoder 68endif 69 70ifeq ($(CONFIG_VP8_DECODER),yes) 71 include $(SRC_PATH_BARE)/$(VP8_PREFIX)vp8dx.mk 72 CODEC_SRCS-yes += $(addprefix $(VP8_PREFIX),$(call enabled,VP8_DX_SRCS)) 73 CODEC_EXPORTS-yes += $(addprefix $(VP8_PREFIX),$(VP8_DX_EXPORTS)) 74 INSTALL-LIBS-yes += include/vpx/vp8.h include/vpx/vp8dx.h 75 INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/$(VP8_PREFIX)/% 76 CODEC_DOC_SECTIONS += vp8 vp8_decoder 77endif 78 79ifeq ($(CONFIG_VP9),yes) 80 VP9_PREFIX=vp9/ 81 include $(SRC_PATH_BARE)/$(VP9_PREFIX)vp9_common.mk 82endif 83 84ifeq ($(CONFIG_VP9_ENCODER),yes) 85 VP9_PREFIX=vp9/ 86 include $(SRC_PATH_BARE)/$(VP9_PREFIX)vp9cx.mk 87 CODEC_SRCS-yes += $(addprefix $(VP9_PREFIX),$(call enabled,VP9_CX_SRCS)) 88 CODEC_EXPORTS-yes += $(addprefix $(VP9_PREFIX),$(VP9_CX_EXPORTS)) 89 CODEC_SRCS-yes += $(VP9_PREFIX)vp9cx.mk vpx/vp8.h vpx/vp8cx.h 90 INSTALL-LIBS-yes += include/vpx/vp8.h include/vpx/vp8cx.h 91 INSTALL-LIBS-$(CONFIG_SPATIAL_SVC) += include/vpx/svc_context.h 92 INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/$(VP9_PREFIX)/% 93 CODEC_DOC_SRCS += vpx/vp8.h vpx/vp8cx.h 94 CODEC_DOC_SECTIONS += vp9 vp9_encoder 95endif 96 97ifeq ($(CONFIG_VP9_DECODER),yes) 98 VP9_PREFIX=vp9/ 99 include $(SRC_PATH_BARE)/$(VP9_PREFIX)vp9dx.mk 100 CODEC_SRCS-yes += $(addprefix $(VP9_PREFIX),$(call enabled,VP9_DX_SRCS)) 101 CODEC_EXPORTS-yes += $(addprefix $(VP9_PREFIX),$(VP9_DX_EXPORTS)) 102 CODEC_SRCS-yes += $(VP9_PREFIX)vp9dx.mk vpx/vp8.h vpx/vp8dx.h 103 INSTALL-LIBS-yes += include/vpx/vp8.h include/vpx/vp8dx.h 104 INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/$(VP9_PREFIX)/% 105 CODEC_DOC_SRCS += vpx/vp8.h vpx/vp8dx.h 106 CODEC_DOC_SECTIONS += vp9 vp9_decoder 107endif 108 109ifeq ($(CONFIG_ENCODERS),yes) 110 CODEC_DOC_SECTIONS += encoder 111endif 112ifeq ($(CONFIG_DECODERS),yes) 113 CODEC_DOC_SECTIONS += decoder 114endif 115 116# Suppress -Wextra warnings in third party code. 117$(BUILD_PFX)third_party/googletest/%.cc.o: CXXFLAGS += -Wno-missing-field-initializers 118# Suppress -Wextra warnings in first party code pending investigation. 119# https://bugs.chromium.org/p/webm/issues/detail?id=1069 120$(BUILD_PFX)vp8/encoder/onyx_if.c.o: CFLAGS += -Wno-unknown-warning-option -Wno-clobbered 121$(BUILD_PFX)vp8/decoder/onyxd_if.c.o: CFLAGS += -Wno-unknown-warning-option -Wno-clobbered 122 123ifeq ($(CONFIG_MSVS),yes) 124CODEC_LIB=$(if $(CONFIG_STATIC_MSVCRT),vpxmt,vpxmd) 125GTEST_LIB=$(if $(CONFIG_STATIC_MSVCRT),gtestmt,gtestmd) 126# This variable uses deferred expansion intentionally, since the results of 127# $(wildcard) may change during the course of the Make. 128VS_PLATFORMS = $(foreach d,$(wildcard */Release/$(CODEC_LIB).lib),$(word 1,$(subst /, ,$(d)))) 129endif 130 131# The following pairs define a mapping of locations in the distribution 132# tree to locations in the source/build trees. 133INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/vpx/% 134INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/vpx_ports/% 135INSTALL_MAPS += $(LIBSUBDIR)/% % 136INSTALL_MAPS += src/% $(SRC_PATH_BARE)/% 137ifeq ($(CONFIG_MSVS),yes) 138INSTALL_MAPS += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/% $(p)/Release/%) 139INSTALL_MAPS += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/% $(p)/Debug/%) 140endif 141 142CODEC_SRCS-yes += build/make/version.sh 143CODEC_SRCS-yes += build/make/rtcd.pl 144CODEC_SRCS-yes += vpx_ports/emmintrin_compat.h 145CODEC_SRCS-yes += vpx_ports/mem_ops.h 146CODEC_SRCS-yes += vpx_ports/mem_ops_aligned.h 147CODEC_SRCS-yes += vpx_ports/vpx_once.h 148CODEC_SRCS-yes += $(BUILD_PFX)vpx_config.c 149INSTALL-SRCS-no += $(BUILD_PFX)vpx_config.c 150ifeq ($(ARCH_X86)$(ARCH_X86_64),yes) 151INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += third_party/x86inc/x86inc.asm 152INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += vpx_dsp/x86/bitdepth_conversion_sse2.asm 153endif 154CODEC_EXPORTS-yes += vpx/exports_com 155CODEC_EXPORTS-$(CONFIG_ENCODERS) += vpx/exports_enc 156ifeq ($(CONFIG_SPATIAL_SVC),yes) 157CODEC_EXPORTS-$(CONFIG_ENCODERS) += vpx/exports_spatial_svc 158endif 159CODEC_EXPORTS-$(CONFIG_DECODERS) += vpx/exports_dec 160 161INSTALL-LIBS-yes += include/vpx/vpx_codec.h 162INSTALL-LIBS-yes += include/vpx/vpx_frame_buffer.h 163INSTALL-LIBS-yes += include/vpx/vpx_image.h 164INSTALL-LIBS-yes += include/vpx/vpx_integer.h 165INSTALL-LIBS-$(CONFIG_DECODERS) += include/vpx/vpx_decoder.h 166INSTALL-LIBS-$(CONFIG_ENCODERS) += include/vpx/vpx_encoder.h 167ifeq ($(CONFIG_EXTERNAL_BUILD),yes) 168ifeq ($(CONFIG_MSVS),yes) 169INSTALL-LIBS-yes += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/$(CODEC_LIB).lib) 170INSTALL-LIBS-$(CONFIG_DEBUG_LIBS) += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/$(CODEC_LIB)d.lib) 171INSTALL-LIBS-$(CONFIG_SHARED) += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/vpx.dll) 172INSTALL-LIBS-$(CONFIG_SHARED) += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/vpx.exp) 173endif 174else 175INSTALL-LIBS-$(CONFIG_STATIC) += $(LIBSUBDIR)/libvpx.a 176INSTALL-LIBS-$(CONFIG_DEBUG_LIBS) += $(LIBSUBDIR)/libvpx_g.a 177endif 178 179CODEC_SRCS=$(call enabled,CODEC_SRCS) 180INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(CODEC_SRCS) 181INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(call enabled,CODEC_EXPORTS) 182 183 184# Generate a list of all enabled sources, in particular for exporting to gyp 185# based build systems. 186libvpx_srcs.txt: 187 @echo " [CREATE] $@" 188 @echo $(CODEC_SRCS) | xargs -n1 echo | LC_ALL=C sort -u > $@ 189CLEAN-OBJS += libvpx_srcs.txt 190 191 192ifeq ($(CONFIG_EXTERNAL_BUILD),yes) 193ifeq ($(CONFIG_MSVS),yes) 194 195vpx.def: $(call enabled,CODEC_EXPORTS) 196 @echo " [CREATE] $@" 197 $(qexec)$(SRC_PATH_BARE)/build/make/gen_msvs_def.sh\ 198 --name=vpx\ 199 --out=$@ $^ 200CLEAN-OBJS += vpx.def 201 202# Assembly files that are included, but don't define symbols themselves. 203# Filtered out to avoid Visual Studio build warnings. 204ASM_INCLUDES := \ 205 third_party/x86inc/x86inc.asm \ 206 vpx_config.asm \ 207 vpx_ports/x86_abi_support.asm \ 208 vpx_dsp/x86/bitdepth_conversion_sse2.asm \ 209 210vpx.$(VCPROJ_SFX): $(CODEC_SRCS) vpx.def 211 @echo " [CREATE] $@" 212 $(qexec)$(GEN_VCPROJ) \ 213 $(if $(CONFIG_SHARED),--dll,--lib) \ 214 --target=$(TOOLCHAIN) \ 215 $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \ 216 --name=vpx \ 217 --proj-guid=DCE19DAF-69AC-46DB-B14A-39F0FAA5DB74 \ 218 --module-def=vpx.def \ 219 --ver=$(CONFIG_VS_VERSION) \ 220 --src-path-bare="$(SRC_PATH_BARE)" \ 221 --out=$@ $(CFLAGS) \ 222 $(filter-out $(addprefix %, $(ASM_INCLUDES)), $^) \ 223 --src-path-bare="$(SRC_PATH_BARE)" \ 224 225PROJECTS-yes += vpx.$(VCPROJ_SFX) 226 227vpx.$(VCPROJ_SFX): vpx_config.asm 228vpx.$(VCPROJ_SFX): $(RTCD) 229 230endif 231else 232LIBVPX_OBJS=$(call objs,$(CODEC_SRCS)) 233OBJS-yes += $(LIBVPX_OBJS) 234LIBS-$(if yes,$(CONFIG_STATIC)) += $(BUILD_PFX)libvpx.a $(BUILD_PFX)libvpx_g.a 235$(BUILD_PFX)libvpx_g.a: $(LIBVPX_OBJS) 236 237SO_VERSION_MAJOR := 4 238SO_VERSION_MINOR := 1 239SO_VERSION_PATCH := 0 240ifeq ($(filter darwin%,$(TGT_OS)),$(TGT_OS)) 241LIBVPX_SO := libvpx.$(SO_VERSION_MAJOR).dylib 242SHARED_LIB_SUF := .dylib 243EXPORT_FILE := libvpx.syms 244LIBVPX_SO_SYMLINKS := $(addprefix $(LIBSUBDIR)/, \ 245 libvpx.dylib ) 246else 247ifeq ($(filter iphonesimulator%,$(TGT_OS)),$(TGT_OS)) 248LIBVPX_SO := libvpx.$(SO_VERSION_MAJOR).dylib 249SHARED_LIB_SUF := .dylib 250EXPORT_FILE := libvpx.syms 251LIBVPX_SO_SYMLINKS := $(addprefix $(LIBSUBDIR)/, libvpx.dylib) 252else 253ifeq ($(filter os2%,$(TGT_OS)),$(TGT_OS)) 254LIBVPX_SO := libvpx$(SO_VERSION_MAJOR).dll 255SHARED_LIB_SUF := _dll.a 256EXPORT_FILE := libvpx.def 257LIBVPX_SO_SYMLINKS := 258LIBVPX_SO_IMPLIB := libvpx_dll.a 259else 260LIBVPX_SO := libvpx.so.$(SO_VERSION_MAJOR).$(SO_VERSION_MINOR).$(SO_VERSION_PATCH) 261SHARED_LIB_SUF := .so 262EXPORT_FILE := libvpx.ver 263LIBVPX_SO_SYMLINKS := $(addprefix $(LIBSUBDIR)/, \ 264 libvpx.so libvpx.so.$(SO_VERSION_MAJOR) \ 265 libvpx.so.$(SO_VERSION_MAJOR).$(SO_VERSION_MINOR)) 266endif 267endif 268endif 269 270LIBS-$(CONFIG_SHARED) += $(BUILD_PFX)$(LIBVPX_SO)\ 271 $(notdir $(LIBVPX_SO_SYMLINKS)) \ 272 $(if $(LIBVPX_SO_IMPLIB), $(BUILD_PFX)$(LIBVPX_SO_IMPLIB)) 273$(BUILD_PFX)$(LIBVPX_SO): $(LIBVPX_OBJS) $(EXPORT_FILE) 274$(BUILD_PFX)$(LIBVPX_SO): extralibs += -lm 275$(BUILD_PFX)$(LIBVPX_SO): SONAME = libvpx.so.$(SO_VERSION_MAJOR) 276$(BUILD_PFX)$(LIBVPX_SO): EXPORTS_FILE = $(EXPORT_FILE) 277 278libvpx.ver: $(call enabled,CODEC_EXPORTS) 279 @echo " [CREATE] $@" 280 $(qexec)echo "{ global:" > $@ 281 $(qexec)for f in $?; do awk '{print $$2";"}' < $$f >>$@; done 282 $(qexec)echo "local: *; };" >> $@ 283CLEAN-OBJS += libvpx.ver 284 285libvpx.syms: $(call enabled,CODEC_EXPORTS) 286 @echo " [CREATE] $@" 287 $(qexec)awk '{print "_"$$2}' $^ >$@ 288CLEAN-OBJS += libvpx.syms 289 290libvpx.def: $(call enabled,CODEC_EXPORTS) 291 @echo " [CREATE] $@" 292 $(qexec)echo LIBRARY $(LIBVPX_SO:.dll=) INITINSTANCE TERMINSTANCE > $@ 293 $(qexec)echo "DATA MULTIPLE NONSHARED" >> $@ 294 $(qexec)echo "EXPORTS" >> $@ 295 $(qexec)awk '!/vpx_svc_*/ {print "_"$$2}' $^ >>$@ 296CLEAN-OBJS += libvpx.def 297 298libvpx_dll.a: $(LIBVPX_SO) 299 @echo " [IMPLIB] $@" 300 $(qexec)emximp -o $@ $< 301CLEAN-OBJS += libvpx_dll.a 302 303define libvpx_symlink_template 304$(1): $(2) 305 @echo " [LN] $(2) $$@" 306 $(qexec)mkdir -p $$(dir $$@) 307 $(qexec)ln -sf $(2) $$@ 308endef 309 310$(eval $(call libvpx_symlink_template,\ 311 $(addprefix $(BUILD_PFX),$(notdir $(LIBVPX_SO_SYMLINKS))),\ 312 $(BUILD_PFX)$(LIBVPX_SO))) 313$(eval $(call libvpx_symlink_template,\ 314 $(addprefix $(DIST_DIR)/,$(LIBVPX_SO_SYMLINKS)),\ 315 $(LIBVPX_SO))) 316 317 318INSTALL-LIBS-$(CONFIG_SHARED) += $(LIBVPX_SO_SYMLINKS) 319INSTALL-LIBS-$(CONFIG_SHARED) += $(LIBSUBDIR)/$(LIBVPX_SO) 320INSTALL-LIBS-$(CONFIG_SHARED) += $(if $(LIBVPX_SO_IMPLIB),$(LIBSUBDIR)/$(LIBVPX_SO_IMPLIB)) 321 322 323LIBS-yes += vpx.pc 324vpx.pc: config.mk libs.mk 325 @echo " [CREATE] $@" 326 $(qexec)echo '# pkg-config file from libvpx $(VERSION_STRING)' > $@ 327 $(qexec)echo 'prefix=$(PREFIX)' >> $@ 328 $(qexec)echo 'exec_prefix=$${prefix}' >> $@ 329 $(qexec)echo 'libdir=$${prefix}/$(LIBSUBDIR)' >> $@ 330 $(qexec)echo 'includedir=$${prefix}/include' >> $@ 331 $(qexec)echo '' >> $@ 332 $(qexec)echo 'Name: vpx' >> $@ 333 $(qexec)echo 'Description: WebM Project VPx codec implementation' >> $@ 334 $(qexec)echo 'Version: $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH)' >> $@ 335 $(qexec)echo 'Requires:' >> $@ 336 $(qexec)echo 'Conflicts:' >> $@ 337 $(qexec)echo 'Libs: -L$${libdir} -lvpx -lm' >> $@ 338ifeq ($(HAVE_PTHREAD_H),yes) 339 $(qexec)echo 'Libs.private: -lm -lpthread' >> $@ 340else 341 $(qexec)echo 'Libs.private: -lm' >> $@ 342endif 343 $(qexec)echo 'Cflags: -I$${includedir}' >> $@ 344INSTALL-LIBS-yes += $(LIBSUBDIR)/pkgconfig/vpx.pc 345INSTALL_MAPS += $(LIBSUBDIR)/pkgconfig/%.pc %.pc 346CLEAN-OBJS += vpx.pc 347endif 348 349# 350# Rule to make assembler configuration file from C configuration file 351# 352ifeq ($(ARCH_X86)$(ARCH_X86_64),yes) 353# YASM 354$(BUILD_PFX)vpx_config.asm: $(BUILD_PFX)vpx_config.h 355 @echo " [CREATE] $@" 356 @egrep "#define [A-Z0-9_]+ [01]" $< \ 357 | awk '{print $$2 " equ " $$3}' > $@ 358else 359ADS2GAS=$(if $(filter yes,$(CONFIG_GCC)),| $(ASM_CONVERSION)) 360$(BUILD_PFX)vpx_config.asm: $(BUILD_PFX)vpx_config.h 361 @echo " [CREATE] $@" 362 @egrep "#define [A-Z0-9_]+ [01]" $< \ 363 | awk '{print $$2 " EQU " $$3}' $(ADS2GAS) > $@ 364 @echo " END" $(ADS2GAS) >> $@ 365CLEAN-OBJS += $(BUILD_PFX)vpx_config.asm 366endif 367 368# 369# Add assembler dependencies for configuration. 370# 371$(filter %.S.o,$(OBJS-yes)): $(BUILD_PFX)vpx_config.asm 372$(filter %$(ASM).o,$(OBJS-yes)): $(BUILD_PFX)vpx_config.asm 373 374 375$(shell $(SRC_PATH_BARE)/build/make/version.sh "$(SRC_PATH_BARE)" $(BUILD_PFX)vpx_version.h) 376CLEAN-OBJS += $(BUILD_PFX)vpx_version.h 377 378# 379# Add include path for libwebm sources. 380# 381ifeq ($(CONFIG_WEBM_IO),yes) 382 CXXFLAGS += -I$(SRC_PATH_BARE)/third_party/libwebm 383endif 384 385## 386## libvpx test directives 387## 388ifeq ($(CONFIG_UNIT_TESTS),yes) 389LIBVPX_TEST_DATA_PATH ?= . 390 391include $(SRC_PATH_BARE)/test/test.mk 392LIBVPX_TEST_SRCS=$(addprefix test/,$(call enabled,LIBVPX_TEST_SRCS)) 393LIBVPX_TEST_BIN=./test_libvpx$(EXE_SFX) 394LIBVPX_TEST_DATA=$(addprefix $(LIBVPX_TEST_DATA_PATH)/,\ 395 $(call enabled,LIBVPX_TEST_DATA)) 396libvpx_test_data_url=https://storage.googleapis.com/downloads.webmproject.org/test_data/libvpx/$(1) 397 398TEST_INTRA_PRED_SPEED_BIN=./test_intra_pred_speed$(EXE_SFX) 399TEST_INTRA_PRED_SPEED_SRCS=$(addprefix test/,$(call enabled,TEST_INTRA_PRED_SPEED_SRCS)) 400TEST_INTRA_PRED_SPEED_OBJS := $(sort $(call objs,$(TEST_INTRA_PRED_SPEED_SRCS))) 401 402libvpx_test_srcs.txt: 403 @echo " [CREATE] $@" 404 @echo $(LIBVPX_TEST_SRCS) | xargs -n1 echo | LC_ALL=C sort -u > $@ 405CLEAN-OBJS += libvpx_test_srcs.txt 406 407$(LIBVPX_TEST_DATA): $(SRC_PATH_BARE)/test/test-data.sha1 408 @echo " [DOWNLOAD] $@" 409 $(qexec)trap 'rm -f $@' INT TERM &&\ 410 curl --retry 1 -L -o $@ $(call libvpx_test_data_url,$(@F)) 411 412testdata:: $(LIBVPX_TEST_DATA) 413 $(qexec)[ -x "$$(which sha1sum)" ] && sha1sum=sha1sum;\ 414 [ -x "$$(which shasum)" ] && sha1sum=shasum;\ 415 [ -x "$$(which sha1)" ] && sha1sum=sha1;\ 416 if [ -n "$${sha1sum}" ]; then\ 417 set -e;\ 418 echo "Checking test data:";\ 419 for f in $(call enabled,LIBVPX_TEST_DATA); do\ 420 grep $$f $(SRC_PATH_BARE)/test/test-data.sha1 |\ 421 (cd $(LIBVPX_TEST_DATA_PATH); $${sha1sum} -c);\ 422 done; \ 423 else\ 424 echo "Skipping test data integrity check, sha1sum not found.";\ 425 fi 426 427ifeq ($(CONFIG_EXTERNAL_BUILD),yes) 428ifeq ($(CONFIG_MSVS),yes) 429 430gtest.$(VCPROJ_SFX): $(SRC_PATH_BARE)/third_party/googletest/src/src/gtest-all.cc 431 @echo " [CREATE] $@" 432 $(qexec)$(GEN_VCPROJ) \ 433 --lib \ 434 --target=$(TOOLCHAIN) \ 435 $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \ 436 --name=gtest \ 437 --proj-guid=EC00E1EC-AF68-4D92-A255-181690D1C9B1 \ 438 --ver=$(CONFIG_VS_VERSION) \ 439 --src-path-bare="$(SRC_PATH_BARE)" \ 440 -D_VARIADIC_MAX=10 \ 441 --out=gtest.$(VCPROJ_SFX) $(SRC_PATH_BARE)/third_party/googletest/src/src/gtest-all.cc \ 442 -I. -I"$(SRC_PATH_BARE)/third_party/googletest/src/include" -I"$(SRC_PATH_BARE)/third_party/googletest/src" 443 444PROJECTS-$(CONFIG_MSVS) += gtest.$(VCPROJ_SFX) 445 446test_libvpx.$(VCPROJ_SFX): $(LIBVPX_TEST_SRCS) vpx.$(VCPROJ_SFX) gtest.$(VCPROJ_SFX) 447 @echo " [CREATE] $@" 448 $(qexec)$(GEN_VCPROJ) \ 449 --exe \ 450 --target=$(TOOLCHAIN) \ 451 --name=test_libvpx \ 452 -D_VARIADIC_MAX=10 \ 453 --proj-guid=CD837F5F-52D8-4314-A370-895D614166A7 \ 454 --ver=$(CONFIG_VS_VERSION) \ 455 --src-path-bare="$(SRC_PATH_BARE)" \ 456 $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \ 457 --out=$@ $(INTERNAL_CFLAGS) $(CFLAGS) \ 458 -I. -I"$(SRC_PATH_BARE)/third_party/googletest/src/include" \ 459 $(if $(CONFIG_WEBM_IO),-I"$(SRC_PATH_BARE)/third_party/libwebm") \ 460 -L. -l$(CODEC_LIB) -l$(GTEST_LIB) $^ 461 462PROJECTS-$(CONFIG_MSVS) += test_libvpx.$(VCPROJ_SFX) 463 464LIBVPX_TEST_BIN := $(addprefix $(TGT_OS:win64=x64)/Release/,$(notdir $(LIBVPX_TEST_BIN))) 465 466ifneq ($(strip $(TEST_INTRA_PRED_SPEED_OBJS)),) 467PROJECTS-$(CONFIG_MSVS) += test_intra_pred_speed.$(VCPROJ_SFX) 468test_intra_pred_speed.$(VCPROJ_SFX): $(TEST_INTRA_PRED_SPEED_SRCS) vpx.$(VCPROJ_SFX) gtest.$(VCPROJ_SFX) 469 @echo " [CREATE] $@" 470 $(qexec)$(GEN_VCPROJ) \ 471 --exe \ 472 --target=$(TOOLCHAIN) \ 473 --name=test_intra_pred_speed \ 474 -D_VARIADIC_MAX=10 \ 475 --proj-guid=CD837F5F-52D8-4314-A370-895D614166A7 \ 476 --ver=$(CONFIG_VS_VERSION) \ 477 --src-path-bare="$(SRC_PATH_BARE)" \ 478 $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \ 479 --out=$@ $(INTERNAL_CFLAGS) $(CFLAGS) \ 480 -I. -I"$(SRC_PATH_BARE)/third_party/googletest/src/include" \ 481 -L. -l$(CODEC_LIB) -l$(GTEST_LIB) $^ 482endif # TEST_INTRA_PRED_SPEED 483endif 484else 485 486include $(SRC_PATH_BARE)/third_party/googletest/gtest.mk 487GTEST_SRCS := $(addprefix third_party/googletest/src/,$(call enabled,GTEST_SRCS)) 488GTEST_OBJS=$(call objs,$(GTEST_SRCS)) 489ifeq ($(filter win%,$(TGT_OS)),$(TGT_OS)) 490# Disabling pthreads globally will cause issues on darwin and possibly elsewhere 491$(GTEST_OBJS) $(GTEST_OBJS:.o=.d): CXXFLAGS += -DGTEST_HAS_PTHREAD=0 492endif 493GTEST_INCLUDES := -I$(SRC_PATH_BARE)/third_party/googletest/src 494GTEST_INCLUDES += -I$(SRC_PATH_BARE)/third_party/googletest/src/include 495$(GTEST_OBJS) $(GTEST_OBJS:.o=.d): CXXFLAGS += $(GTEST_INCLUDES) 496OBJS-yes += $(GTEST_OBJS) 497LIBS-yes += $(BUILD_PFX)libgtest.a $(BUILD_PFX)libgtest_g.a 498$(BUILD_PFX)libgtest_g.a: $(GTEST_OBJS) 499 500LIBVPX_TEST_OBJS=$(sort $(call objs,$(LIBVPX_TEST_SRCS))) 501$(LIBVPX_TEST_OBJS) $(LIBVPX_TEST_OBJS:.o=.d): CXXFLAGS += $(GTEST_INCLUDES) 502OBJS-yes += $(LIBVPX_TEST_OBJS) 503BINS-yes += $(LIBVPX_TEST_BIN) 504 505CODEC_LIB=$(if $(CONFIG_DEBUG_LIBS),vpx_g,vpx) 506CODEC_LIB_SUF=$(if $(CONFIG_SHARED),$(SHARED_LIB_SUF),.a) 507TEST_LIBS := lib$(CODEC_LIB)$(CODEC_LIB_SUF) libgtest.a 508$(LIBVPX_TEST_BIN): $(TEST_LIBS) 509$(eval $(call linkerxx_template,$(LIBVPX_TEST_BIN), \ 510 $(LIBVPX_TEST_OBJS) \ 511 -L. -lvpx -lgtest $(extralibs) -lm)) 512 513ifneq ($(strip $(TEST_INTRA_PRED_SPEED_OBJS)),) 514$(TEST_INTRA_PRED_SPEED_OBJS) $(TEST_INTRA_PRED_SPEED_OBJS:.o=.d): CXXFLAGS += $(GTEST_INCLUDES) 515OBJS-yes += $(TEST_INTRA_PRED_SPEED_OBJS) 516BINS-yes += $(TEST_INTRA_PRED_SPEED_BIN) 517 518$(TEST_INTRA_PRED_SPEED_BIN): $(TEST_LIBS) 519$(eval $(call linkerxx_template,$(TEST_INTRA_PRED_SPEED_BIN), \ 520 $(TEST_INTRA_PRED_SPEED_OBJS) \ 521 -L. -lvpx -lgtest $(extralibs) -lm)) 522endif # TEST_INTRA_PRED_SPEED 523 524endif # CONFIG_UNIT_TESTS 525 526# Install test sources only if codec source is included 527INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(patsubst $(SRC_PATH_BARE)/%,%,\ 528 $(shell find $(SRC_PATH_BARE)/third_party/googletest -type f)) 529INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(LIBVPX_TEST_SRCS) 530INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(TEST_INTRA_PRED_SPEED_SRCS) 531 532define test_shard_template 533test:: test_shard.$(1) 534test-no-data-check:: test_shard_ndc.$(1) 535test_shard.$(1) test_shard_ndc.$(1): $(LIBVPX_TEST_BIN) 536 @set -e; \ 537 export GTEST_SHARD_INDEX=$(1); \ 538 export GTEST_TOTAL_SHARDS=$(2); \ 539 $(LIBVPX_TEST_BIN) 540test_shard.$(1): testdata 541.PHONY: test_shard.$(1) 542endef 543 544NUM_SHARDS := 10 545SHARDS := 0 1 2 3 4 5 6 7 8 9 546$(foreach s,$(SHARDS),$(eval $(call test_shard_template,$(s),$(NUM_SHARDS)))) 547 548endif 549 550## 551## documentation directives 552## 553CLEAN-OBJS += libs.doxy 554DOCS-yes += libs.doxy 555libs.doxy: $(CODEC_DOC_SRCS) 556 @echo " [CREATE] $@" 557 @rm -f $@ 558 @echo "INPUT += $^" >> $@ 559 @echo "INCLUDE_PATH += ." >> $@; 560 @echo "ENABLED_SECTIONS += $(sort $(CODEC_DOC_SECTIONS))" >> $@ 561 562## Generate rtcd.h for all objects 563ifeq ($(CONFIG_DEPENDENCY_TRACKING),yes) 564$(OBJS-yes:.o=.d): $(RTCD) 565else 566$(OBJS-yes): $(RTCD) 567endif 568 569## Update the global src list 570SRCS += $(CODEC_SRCS) $(LIBVPX_TEST_SRCS) $(GTEST_SRCS) 571 572## 573## vpxdec/vpxenc tests. 574## 575ifeq ($(CONFIG_UNIT_TESTS),yes) 576TEST_BIN_PATH = . 577ifeq ($(CONFIG_MSVS),yes) 578# MSVC will build both Debug and Release configurations of tools in a 579# sub directory named for the current target. Assume the user wants to 580# run the Release tools, and assign TEST_BIN_PATH accordingly. 581# TODO(tomfinegan): Is this adequate for ARM? 582# TODO(tomfinegan): Support running the debug versions of tools? 583TEST_BIN_PATH := $(addsuffix /$(TGT_OS:win64=x64)/Release, $(TEST_BIN_PATH)) 584endif 585utiltest utiltest-no-data-check: 586 $(qexec)$(SRC_PATH_BARE)/test/vpxdec.sh \ 587 --test-data-path $(LIBVPX_TEST_DATA_PATH) \ 588 --bin-path $(TEST_BIN_PATH) 589 $(qexec)$(SRC_PATH_BARE)/test/vpxenc.sh \ 590 --test-data-path $(LIBVPX_TEST_DATA_PATH) \ 591 --bin-path $(TEST_BIN_PATH) 592utiltest: testdata 593else 594utiltest utiltest-no-data-check: 595 @echo Unit tests must be enabled to make the utiltest target. 596endif 597 598## 599## Example tests. 600## 601ifeq ($(CONFIG_UNIT_TESTS),yes) 602# All non-MSVC targets output example targets in a sub dir named examples. 603EXAMPLES_BIN_PATH = examples 604ifeq ($(CONFIG_MSVS),yes) 605# MSVC will build both Debug and Release configurations of the examples in a 606# sub directory named for the current target. Assume the user wants to 607# run the Release tools, and assign EXAMPLES_BIN_PATH accordingly. 608# TODO(tomfinegan): Is this adequate for ARM? 609# TODO(tomfinegan): Support running the debug versions of tools? 610EXAMPLES_BIN_PATH := $(TGT_OS:win64=x64)/Release 611endif 612exampletest exampletest-no-data-check: examples 613 $(qexec)$(SRC_PATH_BARE)/test/examples.sh \ 614 --test-data-path $(LIBVPX_TEST_DATA_PATH) \ 615 --bin-path $(EXAMPLES_BIN_PATH) 616exampletest: testdata 617else 618exampletest exampletest-no-data-check: 619 @echo Unit tests must be enabled to make the exampletest target. 620endif 621