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# Calculate platform- and compiler-specific offsets for hand coded assembly 22# 23ifeq ($(filter icc gcc,$(TGT_CC)), $(TGT_CC)) 24OFFSET_PATTERN:='^[a-zA-Z0-9_]* EQU' 25define asm_offsets_template 26$$(BUILD_PFX)$(1): $$(BUILD_PFX)$(2).S 27 @echo " [CREATE] $$@" 28 $$(qexec)LC_ALL=C grep $$(OFFSET_PATTERN) $$< | tr -d '$$$$\#' $$(ADS2GAS) > $$@ 29$$(BUILD_PFX)$(2).S: $(2) 30CLEAN-OBJS += $$(BUILD_PFX)$(1) $(2).S 31endef 32else 33 ifeq ($(filter rvct,$(TGT_CC)), $(TGT_CC)) 34define asm_offsets_template 35$$(BUILD_PFX)$(1): obj_int_extract 36$$(BUILD_PFX)$(1): $$(BUILD_PFX)$(2).o 37 @echo " [CREATE] $$@" 38 $$(qexec)./obj_int_extract rvds $$< $$(ADS2GAS) > $$@ 39OBJS-yes += $$(BUILD_PFX)$(2).o 40CLEAN-OBJS += $$(BUILD_PFX)$(1) 41$$(filter %$$(ASM).o,$$(OBJS-yes)): $$(BUILD_PFX)$(1) 42endef 43endif # rvct 44endif # !gcc 45 46# 47# Rule to generate runtime cpu detection files 48# 49define rtcd_h_template 50$$(BUILD_PFX)$(1).h: $$(SRC_PATH_BARE)/$(2) 51 @echo " [CREATE] $$@" 52 $$(qexec)$$(SRC_PATH_BARE)/build/make/rtcd.pl --arch=$$(TGT_ISA) \ 53 --sym=$(1) \ 54 --config=$$(CONFIG_DIR)$$(target)$$(if $$(FAT_ARCHS),,-$$(TOOLCHAIN)).mk \ 55 $$(RTCD_OPTIONS) $$^ > $$@ 56CLEAN-OBJS += $$(BUILD_PFX)$(1).h 57RTCD += $$(BUILD_PFX)$(1).h 58endef 59 60CODEC_SRCS-yes += CHANGELOG 61CODEC_SRCS-yes += libs.mk 62 63# If this is a universal (fat) binary, then all the subarchitectures have 64# already been built and our job is to stitch them together. The 65# BUILD_LIBVPX variable indicates whether we should be building 66# (compiling, linking) the library. The LIPO_LIBVPX variable indicates 67# that we're stitching. 68$(eval $(if $(filter universal%,$(TOOLCHAIN)),LIPO_LIBVPX,BUILD_LIBVPX):=yes) 69 70include $(SRC_PATH_BARE)/vpx/vpx_codec.mk 71CODEC_SRCS-yes += $(addprefix vpx/,$(call enabled,API_SRCS)) 72CODEC_DOC_SRCS += $(addprefix vpx/,$(call enabled,API_DOC_SRCS)) 73 74include $(SRC_PATH_BARE)/vpx_mem/vpx_mem.mk 75CODEC_SRCS-yes += $(addprefix vpx_mem/,$(call enabled,MEM_SRCS)) 76 77include $(SRC_PATH_BARE)/vpx_scale/vpx_scale.mk 78CODEC_SRCS-yes += $(addprefix vpx_scale/,$(call enabled,SCALE_SRCS)) 79 80include $(SRC_PATH_BARE)/vpx_ports/vpx_ports.mk 81CODEC_SRCS-yes += $(addprefix vpx_ports/,$(call enabled,PORTS_SRCS)) 82 83ifneq ($(CONFIG_VP8_ENCODER)$(CONFIG_VP8_DECODER),) 84 VP8_PREFIX=vp8/ 85 include $(SRC_PATH_BARE)/$(VP8_PREFIX)vp8_common.mk 86endif 87 88ifeq ($(CONFIG_VP8_ENCODER),yes) 89 include $(SRC_PATH_BARE)/$(VP8_PREFIX)vp8cx.mk 90 CODEC_SRCS-yes += $(addprefix $(VP8_PREFIX),$(call enabled,VP8_CX_SRCS)) 91 CODEC_EXPORTS-yes += $(addprefix $(VP8_PREFIX),$(VP8_CX_EXPORTS)) 92 INSTALL-LIBS-yes += include/vpx/vp8.h include/vpx/vp8cx.h 93 INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/$(VP8_PREFIX)/% 94 CODEC_DOC_SECTIONS += vp8 vp8_encoder 95endif 96 97ifeq ($(CONFIG_VP8_DECODER),yes) 98 include $(SRC_PATH_BARE)/$(VP8_PREFIX)vp8dx.mk 99 CODEC_SRCS-yes += $(addprefix $(VP8_PREFIX),$(call enabled,VP8_DX_SRCS)) 100 CODEC_EXPORTS-yes += $(addprefix $(VP8_PREFIX),$(VP8_DX_EXPORTS)) 101 INSTALL-LIBS-yes += include/vpx/vp8.h include/vpx/vp8dx.h 102 INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/$(VP8_PREFIX)/% 103 CODEC_DOC_SECTIONS += vp8 vp8_decoder 104endif 105 106ifneq ($(CONFIG_VP9_ENCODER)$(CONFIG_VP9_DECODER),) 107 VP9_PREFIX=vp9/ 108 include $(SRC_PATH_BARE)/$(VP9_PREFIX)vp9_common.mk 109endif 110 111ifeq ($(CONFIG_VP9_ENCODER),yes) 112 VP9_PREFIX=vp9/ 113 include $(SRC_PATH_BARE)/$(VP9_PREFIX)vp9cx.mk 114 CODEC_SRCS-yes += $(addprefix $(VP9_PREFIX),$(call enabled,VP9_CX_SRCS)) 115 CODEC_EXPORTS-yes += $(addprefix $(VP9_PREFIX),$(VP9_CX_EXPORTS)) 116 CODEC_SRCS-yes += $(VP9_PREFIX)vp9cx.mk vpx/vp8.h vpx/vp8cx.h 117 INSTALL-LIBS-yes += include/vpx/vp8.h include/vpx/vp8cx.h 118 INSTALL-LIBS-yes += include/vpx/svc_context.h 119 INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/$(VP9_PREFIX)/% 120 CODEC_DOC_SRCS += vpx/vp8.h vpx/vp8cx.h 121 CODEC_DOC_SECTIONS += vp9 vp9_encoder 122endif 123 124ifeq ($(CONFIG_VP9_DECODER),yes) 125 VP9_PREFIX=vp9/ 126 include $(SRC_PATH_BARE)/$(VP9_PREFIX)vp9dx.mk 127 CODEC_SRCS-yes += $(addprefix $(VP9_PREFIX),$(call enabled,VP9_DX_SRCS)) 128 CODEC_EXPORTS-yes += $(addprefix $(VP9_PREFIX),$(VP9_DX_EXPORTS)) 129 CODEC_SRCS-yes += $(VP9_PREFIX)vp9dx.mk vpx/vp8.h vpx/vp8dx.h 130 INSTALL-LIBS-yes += include/vpx/vp8.h include/vpx/vp8dx.h 131 INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/$(VP9_PREFIX)/% 132 CODEC_DOC_SRCS += vpx/vp8.h vpx/vp8dx.h 133 CODEC_DOC_SECTIONS += vp9 vp9_decoder 134endif 135 136 137ifeq ($(CONFIG_ENCODERS),yes) 138 CODEC_DOC_SECTIONS += encoder 139endif 140ifeq ($(CONFIG_DECODERS),yes) 141 CODEC_DOC_SECTIONS += decoder 142endif 143 144 145ifeq ($(CONFIG_MSVS),yes) 146CODEC_LIB=$(if $(CONFIG_STATIC_MSVCRT),vpxmt,vpxmd) 147GTEST_LIB=$(if $(CONFIG_STATIC_MSVCRT),gtestmt,gtestmd) 148# This variable uses deferred expansion intentionally, since the results of 149# $(wildcard) may change during the course of the Make. 150VS_PLATFORMS = $(foreach d,$(wildcard */Release/$(CODEC_LIB).lib),$(word 1,$(subst /, ,$(d)))) 151endif 152 153# The following pairs define a mapping of locations in the distribution 154# tree to locations in the source/build trees. 155INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/vpx/% 156INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/vpx_ports/% 157INSTALL_MAPS += $(LIBSUBDIR)/% % 158INSTALL_MAPS += src/% $(SRC_PATH_BARE)/% 159ifeq ($(CONFIG_MSVS),yes) 160INSTALL_MAPS += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/% $(p)/Release/%) 161INSTALL_MAPS += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/% $(p)/Debug/%) 162endif 163 164CODEC_SRCS-$(BUILD_LIBVPX) += build/make/version.sh 165CODEC_SRCS-$(BUILD_LIBVPX) += build/make/rtcd.pl 166CODEC_SRCS-$(BUILD_LIBVPX) += vpx_ports/emmintrin_compat.h 167CODEC_SRCS-$(BUILD_LIBVPX) += vpx_ports/mem_ops.h 168CODEC_SRCS-$(BUILD_LIBVPX) += vpx_ports/mem_ops_aligned.h 169CODEC_SRCS-$(BUILD_LIBVPX) += vpx_ports/vpx_once.h 170CODEC_SRCS-$(BUILD_LIBVPX) += $(BUILD_PFX)vpx_config.c 171INSTALL-SRCS-no += $(BUILD_PFX)vpx_config.c 172ifeq ($(ARCH_X86)$(ARCH_X86_64),yes) 173CODEC_SRCS-$(BUILD_LIBVPX) += third_party/x86inc/x86inc.asm 174endif 175CODEC_EXPORTS-$(BUILD_LIBVPX) += vpx/exports_com 176CODEC_EXPORTS-$(CONFIG_ENCODERS) += vpx/exports_enc 177CODEC_EXPORTS-$(CONFIG_DECODERS) += vpx/exports_dec 178 179INSTALL-LIBS-yes += include/vpx/vpx_codec.h 180INSTALL-LIBS-yes += include/vpx/vpx_frame_buffer.h 181INSTALL-LIBS-yes += include/vpx/vpx_image.h 182INSTALL-LIBS-yes += include/vpx/vpx_integer.h 183INSTALL-LIBS-$(CONFIG_DECODERS) += include/vpx/vpx_decoder.h 184INSTALL-LIBS-$(CONFIG_ENCODERS) += include/vpx/vpx_encoder.h 185ifeq ($(CONFIG_EXTERNAL_BUILD),yes) 186ifeq ($(CONFIG_MSVS),yes) 187INSTALL-LIBS-yes += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/$(CODEC_LIB).lib) 188INSTALL-LIBS-$(CONFIG_DEBUG_LIBS) += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/$(CODEC_LIB)d.lib) 189INSTALL-LIBS-$(CONFIG_SHARED) += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/vpx.dll) 190INSTALL-LIBS-$(CONFIG_SHARED) += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/vpx.exp) 191endif 192else 193INSTALL-LIBS-$(CONFIG_STATIC) += $(LIBSUBDIR)/libvpx.a 194INSTALL-LIBS-$(CONFIG_DEBUG_LIBS) += $(LIBSUBDIR)/libvpx_g.a 195endif 196 197CODEC_SRCS=$(call enabled,CODEC_SRCS) 198INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(CODEC_SRCS) 199INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(call enabled,CODEC_EXPORTS) 200 201 202# Generate a list of all enabled sources, in particular for exporting to gyp 203# based build systems. 204libvpx_srcs.txt: 205 @echo " [CREATE] $@" 206 @echo $(CODEC_SRCS) | xargs -n1 echo | sort -u > $@ 207CLEAN-OBJS += libvpx_srcs.txt 208 209 210ifeq ($(CONFIG_EXTERNAL_BUILD),yes) 211ifeq ($(CONFIG_MSVS),yes) 212 213obj_int_extract.bat: $(SRC_PATH_BARE)/build/$(MSVS_ARCH_DIR)/obj_int_extract.bat 214 @cp $^ $@ 215 216obj_int_extract.$(VCPROJ_SFX): obj_int_extract.bat 217obj_int_extract.$(VCPROJ_SFX): $(SRC_PATH_BARE)/build/make/obj_int_extract.c 218 @echo " [CREATE] $@" 219 $(qexec)$(GEN_VCPROJ) \ 220 --exe \ 221 --target=$(TOOLCHAIN) \ 222 --name=obj_int_extract \ 223 --ver=$(CONFIG_VS_VERSION) \ 224 --proj-guid=E1360C65-D375-4335-8057-7ED99CC3F9B2 \ 225 $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \ 226 --out=$@ $^ \ 227 -I. \ 228 -I"$(SRC_PATH_BARE)" \ 229 230PROJECTS-$(BUILD_LIBVPX) += obj_int_extract.$(VCPROJ_SFX) 231 232vpx.def: $(call enabled,CODEC_EXPORTS) 233 @echo " [CREATE] $@" 234 $(qexec)$(SRC_PATH_BARE)/build/make/gen_msvs_def.sh\ 235 --name=vpx\ 236 --out=$@ $^ 237CLEAN-OBJS += vpx.def 238 239# Assembly files that are included, but don't define symbols themselves. 240# Filtered out to avoid Visual Studio build warnings. 241ASM_INCLUDES := \ 242 third_party/x86inc/x86inc.asm \ 243 vpx_config.asm \ 244 vpx_ports/x86_abi_support.asm \ 245 246vpx.$(VCPROJ_SFX): $(CODEC_SRCS) vpx.def obj_int_extract.$(VCPROJ_SFX) 247 @echo " [CREATE] $@" 248 $(qexec)$(GEN_VCPROJ) \ 249 $(if $(CONFIG_SHARED),--dll,--lib) \ 250 --target=$(TOOLCHAIN) \ 251 $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \ 252 --name=vpx \ 253 --proj-guid=DCE19DAF-69AC-46DB-B14A-39F0FAA5DB74 \ 254 --module-def=vpx.def \ 255 --ver=$(CONFIG_VS_VERSION) \ 256 --out=$@ $(CFLAGS) \ 257 $(filter-out $(addprefix %, $(ASM_INCLUDES)), $^) \ 258 --src-path-bare="$(SRC_PATH_BARE)" \ 259 260PROJECTS-$(BUILD_LIBVPX) += vpx.$(VCPROJ_SFX) 261 262vpx.$(VCPROJ_SFX): vpx_config.asm 263vpx.$(VCPROJ_SFX): $(RTCD) 264 265endif 266else 267LIBVPX_OBJS=$(call objs,$(CODEC_SRCS)) 268OBJS-$(BUILD_LIBVPX) += $(LIBVPX_OBJS) 269LIBS-$(if $(BUILD_LIBVPX),$(CONFIG_STATIC)) += $(BUILD_PFX)libvpx.a $(BUILD_PFX)libvpx_g.a 270$(BUILD_PFX)libvpx_g.a: $(LIBVPX_OBJS) 271 272 273BUILD_LIBVPX_SO := $(if $(BUILD_LIBVPX),$(CONFIG_SHARED)) 274 275ifeq ($(filter darwin%,$(TGT_OS)),$(TGT_OS)) 276LIBVPX_SO := libvpx.$(VERSION_MAJOR).dylib 277EXPORT_FILE := libvpx.syms 278LIBVPX_SO_SYMLINKS := $(addprefix $(LIBSUBDIR)/, \ 279 libvpx.dylib ) 280else 281LIBVPX_SO := libvpx.so.$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH) 282EXPORT_FILE := libvpx.ver 283SYM_LINK := libvpx.so 284LIBVPX_SO_SYMLINKS := $(addprefix $(LIBSUBDIR)/, \ 285 libvpx.so libvpx.so.$(VERSION_MAJOR) \ 286 libvpx.so.$(VERSION_MAJOR).$(VERSION_MINOR)) 287endif 288 289LIBS-$(BUILD_LIBVPX_SO) += $(BUILD_PFX)$(LIBVPX_SO)\ 290 $(notdir $(LIBVPX_SO_SYMLINKS)) 291$(BUILD_PFX)$(LIBVPX_SO): $(LIBVPX_OBJS) $(EXPORT_FILE) 292$(BUILD_PFX)$(LIBVPX_SO): extralibs += -lm 293$(BUILD_PFX)$(LIBVPX_SO): SONAME = libvpx.so.$(VERSION_MAJOR) 294$(BUILD_PFX)$(LIBVPX_SO): EXPORTS_FILE = $(EXPORT_FILE) 295 296libvpx.ver: $(call enabled,CODEC_EXPORTS) 297 @echo " [CREATE] $@" 298 $(qexec)echo "{ global:" > $@ 299 $(qexec)for f in $?; do awk '{print $$2";"}' < $$f >>$@; done 300 $(qexec)echo "local: *; };" >> $@ 301CLEAN-OBJS += libvpx.ver 302 303libvpx.syms: $(call enabled,CODEC_EXPORTS) 304 @echo " [CREATE] $@" 305 $(qexec)awk '{print "_"$$2}' $^ >$@ 306CLEAN-OBJS += libvpx.syms 307 308define libvpx_symlink_template 309$(1): $(2) 310 @echo " [LN] $(2) $$@" 311 $(qexec)mkdir -p $$(dir $$@) 312 $(qexec)ln -sf $(2) $$@ 313endef 314 315$(eval $(call libvpx_symlink_template,\ 316 $(addprefix $(BUILD_PFX),$(notdir $(LIBVPX_SO_SYMLINKS))),\ 317 $(BUILD_PFX)$(LIBVPX_SO))) 318$(eval $(call libvpx_symlink_template,\ 319 $(addprefix $(DIST_DIR)/,$(LIBVPX_SO_SYMLINKS)),\ 320 $(LIBVPX_SO))) 321 322 323INSTALL-LIBS-$(BUILD_LIBVPX_SO) += $(LIBVPX_SO_SYMLINKS) 324INSTALL-LIBS-$(BUILD_LIBVPX_SO) += $(LIBSUBDIR)/$(LIBVPX_SO) 325 326 327LIBS-$(BUILD_LIBVPX) += vpx.pc 328vpx.pc: config.mk libs.mk 329 @echo " [CREATE] $@" 330 $(qexec)echo '# pkg-config file from libvpx $(VERSION_STRING)' > $@ 331 $(qexec)echo 'prefix=$(PREFIX)' >> $@ 332 $(qexec)echo 'exec_prefix=$${prefix}' >> $@ 333 $(qexec)echo 'libdir=$${prefix}/$(LIBSUBDIR)' >> $@ 334 $(qexec)echo 'includedir=$${prefix}/include' >> $@ 335 $(qexec)echo '' >> $@ 336 $(qexec)echo 'Name: vpx' >> $@ 337 $(qexec)echo 'Description: WebM Project VPx codec implementation' >> $@ 338 $(qexec)echo 'Version: $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH)' >> $@ 339 $(qexec)echo 'Requires:' >> $@ 340 $(qexec)echo 'Conflicts:' >> $@ 341 $(qexec)echo 'Libs: -L$${libdir} -lvpx -lm' >> $@ 342ifeq ($(HAVE_PTHREAD_H),yes) 343 $(qexec)echo 'Libs.private: -lm -lpthread' >> $@ 344else 345 $(qexec)echo 'Libs.private: -lm' >> $@ 346endif 347 $(qexec)echo 'Cflags: -I$${includedir}' >> $@ 348INSTALL-LIBS-yes += $(LIBSUBDIR)/pkgconfig/vpx.pc 349INSTALL_MAPS += $(LIBSUBDIR)/pkgconfig/%.pc %.pc 350CLEAN-OBJS += vpx.pc 351endif 352 353LIBS-$(LIPO_LIBVPX) += libvpx.a 354$(eval $(if $(LIPO_LIBVPX),$(call lipo_lib_template,libvpx.a))) 355 356# 357# Rule to make assembler configuration file from C configuration file 358# 359ifeq ($(ARCH_X86)$(ARCH_X86_64),yes) 360# YASM 361$(BUILD_PFX)vpx_config.asm: $(BUILD_PFX)vpx_config.h 362 @echo " [CREATE] $@" 363 @egrep "#define [A-Z0-9_]+ [01]" $< \ 364 | awk '{print $$2 " equ " $$3}' > $@ 365else 366ADS2GAS=$(if $(filter yes,$(CONFIG_GCC)),| $(ASM_CONVERSION)) 367$(BUILD_PFX)vpx_config.asm: $(BUILD_PFX)vpx_config.h 368 @echo " [CREATE] $@" 369 @egrep "#define [A-Z0-9_]+ [01]" $< \ 370 | awk '{print $$2 " EQU " $$3}' $(ADS2GAS) > $@ 371 @echo " END" $(ADS2GAS) >> $@ 372CLEAN-OBJS += $(BUILD_PFX)vpx_config.asm 373endif 374 375# 376# Add assembler dependencies for configuration and offsets 377# 378$(filter %.s.o,$(OBJS-yes)): $(BUILD_PFX)vpx_config.asm 379$(filter %$(ASM).o,$(OBJS-yes)): $(BUILD_PFX)vpx_config.asm 380 381 382$(shell $(SRC_PATH_BARE)/build/make/version.sh "$(SRC_PATH_BARE)" $(BUILD_PFX)vpx_version.h) 383CLEAN-OBJS += $(BUILD_PFX)vpx_version.h 384 385 386## 387## libvpx test directives 388## 389ifeq ($(CONFIG_UNIT_TESTS),yes) 390LIBVPX_TEST_DATA_PATH ?= . 391 392include $(SRC_PATH_BARE)/test/test.mk 393LIBVPX_TEST_SRCS=$(addprefix test/,$(call enabled,LIBVPX_TEST_SRCS)) 394LIBVPX_TEST_BINS=./test_libvpx$(EXE_SFX) 395LIBVPX_TEST_DATA=$(addprefix $(LIBVPX_TEST_DATA_PATH)/,\ 396 $(call enabled,LIBVPX_TEST_DATA)) 397libvpx_test_data_url=http://downloads.webmproject.org/test_data/libvpx/$(1) 398 399libvpx_test_srcs.txt: 400 @echo " [CREATE] $@" 401 @echo $(LIBVPX_TEST_SRCS) | xargs -n1 echo | sort -u > $@ 402CLEAN-OBJS += libvpx_test_srcs.txt 403 404$(LIBVPX_TEST_DATA): $(SRC_PATH_BARE)/test/test-data.sha1 405 @echo " [DOWNLOAD] $@" 406 $(qexec)trap 'rm -f $@' INT TERM &&\ 407 curl -L -o $@ $(call libvpx_test_data_url,$(@F)) 408 409testdata:: $(LIBVPX_TEST_DATA) 410 $(qexec)if [ -x "$$(which sha1sum)" ]; then\ 411 echo "Checking test data:";\ 412 if [ -n "$(LIBVPX_TEST_DATA)" ]; then\ 413 for f in $(call enabled,LIBVPX_TEST_DATA); do\ 414 grep $$f $(SRC_PATH_BARE)/test/test-data.sha1 |\ 415 (cd $(LIBVPX_TEST_DATA_PATH); sha1sum -c);\ 416 done; \ 417 fi; \ 418 else\ 419 echo "Skipping test data integrity check, sha1sum not found.";\ 420 fi 421 422ifeq ($(CONFIG_EXTERNAL_BUILD),yes) 423ifeq ($(CONFIG_MSVS),yes) 424 425gtest.$(VCPROJ_SFX): $(SRC_PATH_BARE)/third_party/googletest/src/src/gtest-all.cc 426 @echo " [CREATE] $@" 427 $(qexec)$(GEN_VCPROJ) \ 428 --lib \ 429 --target=$(TOOLCHAIN) \ 430 $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \ 431 --name=gtest \ 432 --proj-guid=EC00E1EC-AF68-4D92-A255-181690D1C9B1 \ 433 --ver=$(CONFIG_VS_VERSION) \ 434 --src-path-bare="$(SRC_PATH_BARE)" \ 435 -D_VARIADIC_MAX=10 \ 436 --out=gtest.$(VCPROJ_SFX) $(SRC_PATH_BARE)/third_party/googletest/src/src/gtest-all.cc \ 437 -I. -I"$(SRC_PATH_BARE)/third_party/googletest/src/include" -I"$(SRC_PATH_BARE)/third_party/googletest/src" 438 439PROJECTS-$(CONFIG_MSVS) += gtest.$(VCPROJ_SFX) 440 441test_libvpx.$(VCPROJ_SFX): $(LIBVPX_TEST_SRCS) vpx.$(VCPROJ_SFX) gtest.$(VCPROJ_SFX) 442 @echo " [CREATE] $@" 443 $(qexec)$(GEN_VCPROJ) \ 444 --exe \ 445 --target=$(TOOLCHAIN) \ 446 --name=test_libvpx \ 447 -D_VARIADIC_MAX=10 \ 448 --proj-guid=CD837F5F-52D8-4314-A370-895D614166A7 \ 449 --ver=$(CONFIG_VS_VERSION) \ 450 $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \ 451 --out=$@ $(INTERNAL_CFLAGS) $(CFLAGS) \ 452 -I. -I"$(SRC_PATH_BARE)/third_party/googletest/src/include" \ 453 -L. -l$(CODEC_LIB) -l$(GTEST_LIB) $^ 454 455PROJECTS-$(CONFIG_MSVS) += test_libvpx.$(VCPROJ_SFX) 456 457LIBVPX_TEST_BINS := $(addprefix $(TGT_OS:win64=x64)/Release/,$(notdir $(LIBVPX_TEST_BINS))) 458endif 459else 460 461include $(SRC_PATH_BARE)/third_party/googletest/gtest.mk 462GTEST_SRCS := $(addprefix third_party/googletest/src/,$(call enabled,GTEST_SRCS)) 463GTEST_OBJS=$(call objs,$(GTEST_SRCS)) 464ifeq ($(filter win%,$(TGT_OS)),$(TGT_OS)) 465# Disabling pthreads globally will cause issues on darwin and possibly elsewhere 466$(GTEST_OBJS) $(GTEST_OBJS:.o=.d): CXXFLAGS += -DGTEST_HAS_PTHREAD=0 467endif 468$(GTEST_OBJS) $(GTEST_OBJS:.o=.d): CXXFLAGS += -I$(SRC_PATH_BARE)/third_party/googletest/src 469$(GTEST_OBJS) $(GTEST_OBJS:.o=.d): CXXFLAGS += -I$(SRC_PATH_BARE)/third_party/googletest/src/include 470OBJS-$(BUILD_LIBVPX) += $(GTEST_OBJS) 471LIBS-$(BUILD_LIBVPX) += $(BUILD_PFX)libgtest.a $(BUILD_PFX)libgtest_g.a 472$(BUILD_PFX)libgtest_g.a: $(GTEST_OBJS) 473 474LIBVPX_TEST_OBJS=$(sort $(call objs,$(LIBVPX_TEST_SRCS))) 475$(LIBVPX_TEST_OBJS) $(LIBVPX_TEST_OBJS:.o=.d): CXXFLAGS += -I$(SRC_PATH_BARE)/third_party/googletest/src 476$(LIBVPX_TEST_OBJS) $(LIBVPX_TEST_OBJS:.o=.d): CXXFLAGS += -I$(SRC_PATH_BARE)/third_party/googletest/src/include 477OBJS-$(BUILD_LIBVPX) += $(LIBVPX_TEST_OBJS) 478BINS-$(BUILD_LIBVPX) += $(LIBVPX_TEST_BINS) 479 480CODEC_LIB=$(if $(CONFIG_DEBUG_LIBS),vpx_g,vpx) 481CODEC_LIB_SUF=$(if $(CONFIG_SHARED),.so,.a) 482$(foreach bin,$(LIBVPX_TEST_BINS),\ 483 $(if $(BUILD_LIBVPX),$(eval $(bin): \ 484 lib$(CODEC_LIB)$(CODEC_LIB_SUF) libgtest.a ))\ 485 $(if $(BUILD_LIBVPX),$(eval $(call linkerxx_template,$(bin),\ 486 $(LIBVPX_TEST_OBJS) \ 487 -L. -lvpx -lgtest $(extralibs) -lm)\ 488 )))\ 489 $(if $(LIPO_LIBS),$(eval $(call lipo_bin_template,$(bin))))\ 490 491endif 492 493# Install test sources only if codec source is included 494INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(patsubst $(SRC_PATH_BARE)/%,%,\ 495 $(shell find $(SRC_PATH_BARE)/third_party/googletest -type f)) 496INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(LIBVPX_TEST_SRCS) 497 498define test_shard_template 499test:: test_shard.$(1) 500test_shard.$(1): $(LIBVPX_TEST_BINS) testdata 501 @set -e; \ 502 for t in $(LIBVPX_TEST_BINS); do \ 503 export GTEST_SHARD_INDEX=$(1); \ 504 export GTEST_TOTAL_SHARDS=$(2); \ 505 $$$$t; \ 506 done 507.PHONY: test_shard.$(1) 508endef 509 510NUM_SHARDS := 10 511SHARDS := 0 1 2 3 4 5 6 7 8 9 512$(foreach s,$(SHARDS),$(eval $(call test_shard_template,$(s),$(NUM_SHARDS)))) 513 514endif 515 516## 517## documentation directives 518## 519CLEAN-OBJS += libs.doxy 520DOCS-yes += libs.doxy 521libs.doxy: $(CODEC_DOC_SRCS) 522 @echo " [CREATE] $@" 523 @rm -f $@ 524 @echo "INPUT += $^" >> $@ 525 @echo "PREDEFINED = VPX_CODEC_DISABLE_COMPAT" >> $@ 526 @echo "INCLUDE_PATH += ." >> $@; 527 @echo "ENABLED_SECTIONS += $(sort $(CODEC_DOC_SECTIONS))" >> $@ 528 529## Generate rtcd.h for all objects 530$(OBJS-yes:.o=.d): $(RTCD) 531 532## Update the global src list 533SRCS += $(CODEC_SRCS) $(LIBVPX_TEST_SRCS) $(GTEST_SRCS) 534