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 ($(VPX_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-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 69endif 70 71ifeq ($(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 78endif 79 80ifeq ($(CONFIG_VP9),yes) 81 VP9_PREFIX=vp9/ 82 include $(SRC_PATH_BARE)/$(VP9_PREFIX)vp9_common.mk 83endif 84 85ifeq ($(CONFIG_VP9_ENCODER),yes) 86 VP9_PREFIX=vp9/ 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 97 98 RC_RTC_SRCS := $(addprefix $(VP9_PREFIX),$(call enabled,VP9_CX_SRCS)) 99 RC_RTC_SRCS += $(VP9_PREFIX)vp9cx.mk vpx/vp8.h vpx/vp8cx.h 100 RC_RTC_SRCS += vpx/vpx_ext_ratectrl.h 101 RC_RTC_SRCS += $(VP9_PREFIX)ratectrl_rtc.cc 102 RC_RTC_SRCS += $(VP9_PREFIX)ratectrl_rtc.h 103 INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(VP9_PREFIX)ratectrl_rtc.cc 104 INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(VP9_PREFIX)ratectrl_rtc.h 105endif 106 107ifeq ($(CONFIG_VP9_DECODER),yes) 108 VP9_PREFIX=vp9/ 109 include $(SRC_PATH_BARE)/$(VP9_PREFIX)vp9dx.mk 110 CODEC_SRCS-yes += $(addprefix $(VP9_PREFIX),$(call enabled,VP9_DX_SRCS)) 111 CODEC_EXPORTS-yes += $(addprefix $(VP9_PREFIX),$(VP9_DX_EXPORTS)) 112 CODEC_SRCS-yes += $(VP9_PREFIX)vp9dx.mk vpx/vp8.h vpx/vp8dx.h 113 INSTALL-LIBS-yes += include/vpx/vp8.h include/vpx/vp8dx.h 114 INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/$(VP9_PREFIX)/% 115 CODEC_DOC_SRCS += vpx/vp8.h vpx/vp8dx.h 116 CODEC_DOC_SECTIONS += vp9 vp9_decoder 117endif 118 119ifeq ($(CONFIG_ENCODERS),yes) 120 CODEC_DOC_SECTIONS += encoder 121endif 122ifeq ($(CONFIG_DECODERS),yes) 123 CODEC_DOC_SECTIONS += decoder 124endif 125 126ifeq ($(CONFIG_MSVS),yes) 127CODEC_LIB=$(if $(CONFIG_STATIC_MSVCRT),vpxmt,vpxmd) 128GTEST_LIB=$(if $(CONFIG_STATIC_MSVCRT),gtestmt,gtestmd) 129RC_RTC_LIB=$(if $(CONFIG_STATIC_MSVCRT),vp9rcmt,vp9rcmd) 130# This variable uses deferred expansion intentionally, since the results of 131# $(wildcard) may change during the course of the Make. 132VS_PLATFORMS = $(foreach d,$(wildcard */Release/$(CODEC_LIB).lib),$(word 1,$(subst /, ,$(d)))) 133endif 134 135# The following pairs define a mapping of locations in the distribution 136# tree to locations in the source/build trees. 137INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/vpx/% 138INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/vpx_ports/% 139INSTALL_MAPS += $(LIBSUBDIR)/% % 140INSTALL_MAPS += src/% $(SRC_PATH_BARE)/% 141ifeq ($(CONFIG_MSVS),yes) 142INSTALL_MAPS += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/% $(p)/Release/%) 143INSTALL_MAPS += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/% $(p)/Debug/%) 144endif 145 146CODEC_SRCS-yes += build/make/version.sh 147CODEC_SRCS-yes += build/make/rtcd.pl 148CODEC_SRCS-yes += vpx_ports/emmintrin_compat.h 149CODEC_SRCS-yes += vpx_ports/mem_ops.h 150CODEC_SRCS-yes += vpx_ports/mem_ops_aligned.h 151CODEC_SRCS-yes += vpx_ports/vpx_once.h 152CODEC_SRCS-yes += $(BUILD_PFX)vpx_config.c 153INSTALL-SRCS-no += $(BUILD_PFX)vpx_config.c 154ifeq ($(VPX_ARCH_X86)$(VPX_ARCH_X86_64),yes) 155INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += third_party/x86inc/x86inc.asm 156INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += vpx_dsp/x86/bitdepth_conversion_sse2.asm 157endif 158CODEC_EXPORTS-yes += vpx/exports_com 159CODEC_EXPORTS-$(CONFIG_ENCODERS) += vpx/exports_enc 160CODEC_EXPORTS-$(CONFIG_DECODERS) += vpx/exports_dec 161 162INSTALL-LIBS-yes += include/vpx/vpx_codec.h 163INSTALL-LIBS-yes += include/vpx/vpx_frame_buffer.h 164INSTALL-LIBS-yes += include/vpx/vpx_image.h 165INSTALL-LIBS-yes += include/vpx/vpx_integer.h 166INSTALL-LIBS-$(CONFIG_DECODERS) += include/vpx/vpx_decoder.h 167INSTALL-LIBS-$(CONFIG_ENCODERS) += include/vpx/vpx_encoder.h 168ifeq ($(CONFIG_EXTERNAL_BUILD),yes) 169ifeq ($(CONFIG_MSVS),yes) 170INSTALL-LIBS-yes += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/$(CODEC_LIB).lib) 171INSTALL-LIBS-$(CONFIG_DEBUG_LIBS) += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/$(CODEC_LIB)d.lib) 172INSTALL-LIBS-$(CONFIG_SHARED) += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/vpx.dll) 173INSTALL-LIBS-$(CONFIG_SHARED) += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/vpx.exp) 174endif 175else 176INSTALL-LIBS-$(CONFIG_STATIC) += $(LIBSUBDIR)/libvpx.a 177INSTALL-LIBS-$(CONFIG_DEBUG_LIBS) += $(LIBSUBDIR)/libvpx_g.a 178endif 179 180ifeq ($(CONFIG_VP9_ENCODER)$(CONFIG_RATE_CTRL),yesyes) 181 SIMPLE_ENCODE_SRCS := $(call enabled,CODEC_SRCS) 182 SIMPLE_ENCODE_SRCS += $(VP9_PREFIX)simple_encode.cc 183 SIMPLE_ENCODE_SRCS += $(VP9_PREFIX)simple_encode.h 184 SIMPLE_ENCODE_SRCS += ivfenc.h 185 SIMPLE_ENCODE_SRCS += ivfenc.c 186 INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(VP9_PREFIX)simple_encode.cc 187 INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(VP9_PREFIX)simple_encode.h 188endif 189 190CODEC_SRCS=$(call enabled,CODEC_SRCS) 191 192INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(CODEC_SRCS) 193INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(call enabled,CODEC_EXPORTS) 194 195 196# Generate a list of all enabled sources, in particular for exporting to gyp 197# based build systems. 198libvpx_srcs.txt: 199 @echo " [CREATE] $@" 200 @echo $(CODEC_SRCS) | xargs -n1 echo | LC_ALL=C sort -u > $@ 201CLEAN-OBJS += libvpx_srcs.txt 202 203# Assembly files that are included, but don't define symbols themselves. 204# Filtered out to avoid Windows build warnings. 205ASM_INCLUDES := \ 206 third_party/x86inc/x86inc.asm \ 207 vpx_config.asm \ 208 vpx_ports/x86_abi_support.asm \ 209 vpx_dsp/x86/bitdepth_conversion_sse2.asm \ 210 211ifeq ($(CONFIG_EXTERNAL_BUILD),yes) 212ifeq ($(CONFIG_MSVS),yes) 213 214vpx.def: $(call enabled,CODEC_EXPORTS) 215 @echo " [CREATE] $@" 216 $(qexec)$(SRC_PATH_BARE)/build/make/gen_msvs_def.sh\ 217 --name=vpx\ 218 --out=$@ $^ 219CLEAN-OBJS += vpx.def 220 221vpx.$(VCPROJ_SFX): VCPROJ_SRCS=$(filter-out $(addprefix %, $(ASM_INCLUDES)), $^) 222 223vpx.$(VCPROJ_SFX): $(CODEC_SRCS) vpx.def 224 @echo " [CREATE] $@" 225 $(qexec)$(GEN_VCPROJ) \ 226 $(if $(CONFIG_SHARED),--dll,--lib) \ 227 --target=$(TOOLCHAIN) \ 228 $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \ 229 --name=vpx \ 230 --proj-guid=DCE19DAF-69AC-46DB-B14A-39F0FAA5DB74 \ 231 --module-def=vpx.def \ 232 --ver=$(CONFIG_VS_VERSION) \ 233 --src-path-bare="$(SRC_PATH_BARE)" \ 234 --out=$@ $(CFLAGS) \ 235 --as=$(AS) \ 236 $(filter $(SRC_PATH_BARE)/vp8/%.c, $(VCPROJ_SRCS)) \ 237 $(filter $(SRC_PATH_BARE)/vp8/%.h, $(VCPROJ_SRCS)) \ 238 $(filter $(SRC_PATH_BARE)/vp9/%.c, $(VCPROJ_SRCS)) \ 239 $(filter $(SRC_PATH_BARE)/vp9/%.h, $(VCPROJ_SRCS)) \ 240 $(filter $(SRC_PATH_BARE)/vpx/%, $(VCPROJ_SRCS)) \ 241 $(filter $(SRC_PATH_BARE)/vpx_dsp/%, $(VCPROJ_SRCS)) \ 242 $(filter-out $(addprefix $(SRC_PATH_BARE)/, \ 243 vp8/%.c vp8/%.h vp9/%.c vp9/%.h vpx/% vpx_dsp/%), \ 244 $(VCPROJ_SRCS)) \ 245 --src-path-bare="$(SRC_PATH_BARE)" \ 246 247PROJECTS-yes += vpx.$(VCPROJ_SFX) 248 249vpx.$(VCPROJ_SFX): vpx_config.asm 250vpx.$(VCPROJ_SFX): $(RTCD) 251 252vp9rc.$(VCPROJ_SFX): \ 253 VCPROJ_SRCS=$(filter-out $(addprefix %, $(ASM_INCLUDES)), $^) 254 255vp9rc.$(VCPROJ_SFX): $(RC_RTC_SRCS) 256 @echo " [CREATE] $@" 257 $(qexec)$(GEN_VCPROJ) \ 258 $(if $(CONFIG_SHARED),--dll,--lib) \ 259 --target=$(TOOLCHAIN) \ 260 $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \ 261 --name=vp9rc \ 262 --proj-guid=C26FF952-9494-4838-9A3F-7F3D4F613385 \ 263 --ver=$(CONFIG_VS_VERSION) \ 264 --src-path-bare="$(SRC_PATH_BARE)" \ 265 --out=$@ $(CFLAGS) \ 266 --as=$(AS) \ 267 $(filter $(SRC_PATH_BARE)/vp9/%.c, $(VCPROJ_SRCS)) \ 268 $(filter $(SRC_PATH_BARE)/vp9/%.cc, $(VCPROJ_SRCS)) \ 269 $(filter $(SRC_PATH_BARE)/vp9/%.h, $(VCPROJ_SRCS)) \ 270 $(filter $(SRC_PATH_BARE)/vpx/%, $(VCPROJ_SRCS)) \ 271 $(filter $(SRC_PATH_BARE)/vpx_dsp/%, $(VCPROJ_SRCS)) \ 272 $(filter-out $(addprefix $(SRC_PATH_BARE)/, \ 273 vp8/%.c vp8/%.h vp9/%.c vp9/%.cc vp9/%.h vpx/% \ 274 vpx_dsp/%), \ 275 $(VCPROJ_SRCS)) \ 276 --src-path-bare="$(SRC_PATH_BARE)" \ 277 278PROJECTS-yes += vp9rc.$(VCPROJ_SFX) 279 280vp9rc.$(VCPROJ_SFX): vpx_config.asm 281vp9rc.$(VCPROJ_SFX): $(RTCD) 282 283endif # ifeq ($(CONFIG_MSVS),yes) 284else # ifeq ($(CONFIG_EXTERNAL_BUILD),yes) 285LIBVPX_OBJS=$(call objs, $(filter-out $(ASM_INCLUDES), $(CODEC_SRCS))) 286OBJS-yes += $(LIBVPX_OBJS) 287LIBS-$(if yes,$(CONFIG_STATIC)) += $(BUILD_PFX)libvpx.a $(BUILD_PFX)libvpx_g.a 288$(BUILD_PFX)libvpx_g.a: $(LIBVPX_OBJS) 289 290# Updating version info. 291# https://www.gnu.org/software/libtool/manual/libtool.html#Updating-version-info 292# For libtool: c=<current>, a=<age>, r=<revision> 293# libtool generates .so file as .so.[c-a].a.r, while -version-info c:r:a is 294# passed to libtool. 295# 296# libvpx library file is generated as libvpx.so.<MAJOR>.<MINOR>.<PATCH> 297# MAJOR = c-a, MINOR = a, PATCH = r 298# 299# To determine SO_VERSION_{MAJOR,MINOR,PATCH}, calculate c,a,r with current 300# SO_VERSION_* then follow the rules in the link to detemine the new version 301# (c1, a1, r1) and set MAJOR to [c1-a1], MINOR to a1 and PATCH to r1 302SO_VERSION_MAJOR := 7 303SO_VERSION_MINOR := 0 304SO_VERSION_PATCH := 0 305ifeq ($(filter darwin%,$(TGT_OS)),$(TGT_OS)) 306LIBVPX_SO := libvpx.$(SO_VERSION_MAJOR).dylib 307SHARED_LIB_SUF := .dylib 308EXPORT_FILE := libvpx.syms 309LIBVPX_SO_SYMLINKS := $(addprefix $(LIBSUBDIR)/, \ 310 libvpx.dylib ) 311else 312ifeq ($(filter iphonesimulator%,$(TGT_OS)),$(TGT_OS)) 313LIBVPX_SO := libvpx.$(SO_VERSION_MAJOR).dylib 314SHARED_LIB_SUF := .dylib 315EXPORT_FILE := libvpx.syms 316LIBVPX_SO_SYMLINKS := $(addprefix $(LIBSUBDIR)/, libvpx.dylib) 317else 318ifeq ($(filter os2%,$(TGT_OS)),$(TGT_OS)) 319LIBVPX_SO := libvpx$(SO_VERSION_MAJOR).dll 320SHARED_LIB_SUF := _dll.a 321EXPORT_FILE := libvpx.def 322LIBVPX_SO_SYMLINKS := 323LIBVPX_SO_IMPLIB := libvpx_dll.a 324else 325LIBVPX_SO := libvpx.so.$(SO_VERSION_MAJOR).$(SO_VERSION_MINOR).$(SO_VERSION_PATCH) 326SHARED_LIB_SUF := .so 327EXPORT_FILE := libvpx.ver 328LIBVPX_SO_SYMLINKS := $(addprefix $(LIBSUBDIR)/, \ 329 libvpx.so libvpx.so.$(SO_VERSION_MAJOR) \ 330 libvpx.so.$(SO_VERSION_MAJOR).$(SO_VERSION_MINOR)) 331endif 332endif 333endif 334 335LIBS-$(CONFIG_SHARED) += $(BUILD_PFX)$(LIBVPX_SO)\ 336 $(notdir $(LIBVPX_SO_SYMLINKS)) \ 337 $(if $(LIBVPX_SO_IMPLIB), $(BUILD_PFX)$(LIBVPX_SO_IMPLIB)) 338$(BUILD_PFX)$(LIBVPX_SO): $(LIBVPX_OBJS) $(EXPORT_FILE) 339$(BUILD_PFX)$(LIBVPX_SO): extralibs += -lm 340$(BUILD_PFX)$(LIBVPX_SO): SONAME = libvpx.so.$(SO_VERSION_MAJOR) 341$(BUILD_PFX)$(LIBVPX_SO): EXPORTS_FILE = $(EXPORT_FILE) 342 343libvpx.def: $(call enabled,CODEC_EXPORTS) 344 @echo " [CREATE] $@" 345 $(qexec)echo LIBRARY $(LIBVPX_SO:.dll=) INITINSTANCE TERMINSTANCE > $@ 346 $(qexec)echo "DATA MULTIPLE NONSHARED" >> $@ 347 $(qexec)echo "EXPORTS" >> $@ 348 $(qexec)awk '!/vpx_svc_*/ {print "_"$$2}' $^ >>$@ 349CLEAN-OBJS += libvpx.def 350 351libvpx_dll.a: $(LIBVPX_SO) 352 @echo " [IMPLIB] $@" 353 $(qexec)emximp -o $@ $< 354CLEAN-OBJS += libvpx_dll.a 355 356define libvpx_symlink_template 357$(1): $(2) 358 @echo " [LN] $(2) $$@" 359 $(qexec)mkdir -p $$(dir $$@) 360 $(qexec)ln -sf $(2) $$@ 361endef 362 363$(eval $(call libvpx_symlink_template,\ 364 $(addprefix $(BUILD_PFX),$(notdir $(LIBVPX_SO_SYMLINKS))),\ 365 $(BUILD_PFX)$(LIBVPX_SO))) 366$(eval $(call libvpx_symlink_template,\ 367 $(addprefix $(DIST_DIR)/,$(LIBVPX_SO_SYMLINKS)),\ 368 $(LIBVPX_SO))) 369 370 371INSTALL-LIBS-$(CONFIG_SHARED) += $(LIBVPX_SO_SYMLINKS) 372INSTALL-LIBS-$(CONFIG_SHARED) += $(LIBSUBDIR)/$(LIBVPX_SO) 373INSTALL-LIBS-$(CONFIG_SHARED) += $(if $(LIBVPX_SO_IMPLIB),$(LIBSUBDIR)/$(LIBVPX_SO_IMPLIB)) 374 375 376LIBS-yes += vpx.pc 377vpx.pc: config.mk libs.mk 378 @echo " [CREATE] $@" 379 $(qexec)echo '# pkg-config file from libvpx $(VERSION_STRING)' > $@ 380 $(qexec)echo 'prefix=$(PREFIX)' >> $@ 381 $(qexec)echo 'exec_prefix=$${prefix}' >> $@ 382 $(qexec)echo 'libdir=$${prefix}/$(LIBSUBDIR)' >> $@ 383 $(qexec)echo 'includedir=$${prefix}/include' >> $@ 384 $(qexec)echo '' >> $@ 385 $(qexec)echo 'Name: vpx' >> $@ 386 $(qexec)echo 'Description: WebM Project VPx codec implementation' >> $@ 387 $(qexec)echo 'Version: $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH)' >> $@ 388 $(qexec)echo 'Requires:' >> $@ 389 $(qexec)echo 'Conflicts:' >> $@ 390 $(qexec)echo 'Libs: -L$${libdir} -lvpx -lm' >> $@ 391ifeq ($(HAVE_PTHREAD_H),yes) 392 $(qexec)echo 'Libs.private: -lm -lpthread' >> $@ 393else 394 $(qexec)echo 'Libs.private: -lm' >> $@ 395endif 396 $(qexec)echo 'Cflags: -I$${includedir}' >> $@ 397INSTALL-LIBS-yes += $(LIBSUBDIR)/pkgconfig/vpx.pc 398INSTALL_MAPS += $(LIBSUBDIR)/pkgconfig/%.pc %.pc 399CLEAN-OBJS += vpx.pc 400 401ifeq ($(CONFIG_VP9_ENCODER),yes) 402 RC_RTC_OBJS=$(call objs,$(RC_RTC_SRCS)) 403 RC_RTC_OBJS=$(call objs,$(RC_RTC_SRCS)) 404 OBJS-yes += $(RC_RTC_OBJS) 405 LIBS-yes += $(BUILD_PFX)libvp9rc.a $(BUILD_PFX)libvp9rc_g.a 406 $(BUILD_PFX)libvp9rc_g.a: $(RC_RTC_OBJS) 407endif 408 409ifeq ($(CONFIG_VP9_ENCODER)$(CONFIG_RATE_CTRL),yesyes) 410 SIMPLE_ENCODE_OBJS=$(call objs,$(SIMPLE_ENCODE_SRCS)) 411 OBJS-yes += $(SIMPLE_ENCODE_OBJS) 412 LIBS-yes += $(BUILD_PFX)libsimple_encode.a $(BUILD_PFX)libsimple_encode_g.a 413 $(BUILD_PFX)libsimple_encode_g.a: $(SIMPLE_ENCODE_OBJS) 414endif 415 416endif # ifeq ($(CONFIG_EXTERNAL_BUILD),yes) 417 418libvpx.ver: $(call enabled,CODEC_EXPORTS) 419 @echo " [CREATE] $@" 420 $(qexec)echo "{ global:" > $@ 421 $(qexec)for f in $?; do awk '{print $$2";"}' < $$f >>$@; done 422 $(qexec)echo "local: *; };" >> $@ 423CLEAN-OBJS += libvpx.ver 424 425libvpx.syms: $(call enabled,CODEC_EXPORTS) 426 @echo " [CREATE] $@" 427 $(qexec)awk '{print "_"$$2}' $^ >$@ 428CLEAN-OBJS += libvpx.syms 429 430# 431# Rule to make assembler configuration file from C configuration file 432# 433ifeq ($(VPX_ARCH_X86)$(VPX_ARCH_X86_64),yes) 434# YASM 435$(BUILD_PFX)vpx_config.asm: $(BUILD_PFX)vpx_config.h 436 @echo " [CREATE] $@" 437 @LC_ALL=C egrep "#define [A-Z0-9_]+ [01]" $< \ 438 | awk '{print $$2 " equ " $$3}' > $@ 439else 440ADS2GAS=$(if $(filter yes,$(CONFIG_GCC)),| $(ASM_CONVERSION)) 441$(BUILD_PFX)vpx_config.asm: $(BUILD_PFX)vpx_config.h 442 @echo " [CREATE] $@" 443 @LC_ALL=C egrep "#define [A-Z0-9_]+ [01]" $< \ 444 | awk '{print $$2 " EQU " $$3}' $(ADS2GAS) > $@ 445 @echo " END" $(ADS2GAS) >> $@ 446CLEAN-OBJS += $(BUILD_PFX)vpx_config.asm 447endif 448 449# 450# Add assembler dependencies for configuration. 451# 452$(filter %.S.o,$(OBJS-yes)): $(BUILD_PFX)vpx_config.asm 453$(filter %$(ASM).o,$(OBJS-yes)): $(BUILD_PFX)vpx_config.asm 454 455 456$(shell $(SRC_PATH_BARE)/build/make/version.sh "$(SRC_PATH_BARE)" $(BUILD_PFX)vpx_version.h) 457CLEAN-OBJS += $(BUILD_PFX)vpx_version.h 458 459# 460# Add include path for libwebm sources. 461# 462ifeq ($(CONFIG_WEBM_IO),yes) 463 CXXFLAGS += -I$(SRC_PATH_BARE)/third_party/libwebm 464endif 465 466## 467## libvpx test directives 468## 469ifeq ($(CONFIG_UNIT_TESTS),yes) 470LIBVPX_TEST_DATA_PATH ?= . 471 472include $(SRC_PATH_BARE)/test/test.mk 473 474# addprefix_clean behaves like addprefix if the target doesn't start with "../" 475# However, if the target starts with "../", instead of adding prefix, 476# it will remove "../". 477# Using addprefix_clean, we can avoid two different targets building the 478# same file, i.e. 479# test/../ivfenc.c.d: ivfenc.o 480# ivfenc.c.d: ivfenc.o 481# Note that the other way to solve this problem is using "realpath". 482# The "realpath" is supported by make 3.81 or later. 483addprefix_clean=$(patsubst $(1)../%,%,$(addprefix $(1), $(2))) 484LIBVPX_TEST_SRCS=$(call addprefix_clean,test/,$(call enabled,LIBVPX_TEST_SRCS)) 485 486LIBVPX_TEST_BIN=./test_libvpx$(EXE_SFX) 487LIBVPX_TEST_DATA=$(addprefix $(LIBVPX_TEST_DATA_PATH)/,\ 488 $(call enabled,LIBVPX_TEST_DATA)) 489libvpx_test_data_url=https://storage.googleapis.com/downloads.webmproject.org/test_data/libvpx/$(1) 490 491TEST_INTRA_PRED_SPEED_BIN=./test_intra_pred_speed$(EXE_SFX) 492TEST_INTRA_PRED_SPEED_SRCS=$(call addprefix_clean,test/,\ 493 $(call enabled,TEST_INTRA_PRED_SPEED_SRCS)) 494TEST_INTRA_PRED_SPEED_OBJS := $(sort $(call objs,$(TEST_INTRA_PRED_SPEED_SRCS))) 495 496ifeq ($(CONFIG_VP9_ENCODER),yes) 497RC_INTERFACE_TEST_BIN=./test_rc_interface$(EXE_SFX) 498RC_INTERFACE_TEST_SRCS=$(call addprefix_clean,test/,\ 499 $(call enabled,RC_INTERFACE_TEST_SRCS)) 500RC_INTERFACE_TEST_OBJS := $(sort $(call objs,$(RC_INTERFACE_TEST_SRCS))) 501endif 502 503SIMPLE_ENCODE_TEST_BIN=./test_simple_encode$(EXE_SFX) 504SIMPLE_ENCODE_TEST_SRCS=$(call addprefix_clean,test/,\ 505 $(call enabled,SIMPLE_ENCODE_TEST_SRCS)) 506SIMPLE_ENCODE_TEST_OBJS := $(sort $(call objs,$(SIMPLE_ENCODE_TEST_SRCS))) 507 508libvpx_test_srcs.txt: 509 @echo " [CREATE] $@" 510 @echo $(LIBVPX_TEST_SRCS) | xargs -n1 echo | LC_ALL=C sort -u > $@ 511CLEAN-OBJS += libvpx_test_srcs.txt 512 513# Attempt to download the file using curl, retrying once if it fails for a 514# partial file (18). 515$(LIBVPX_TEST_DATA): $(SRC_PATH_BARE)/test/test-data.sha1 516 @echo " [DOWNLOAD] $@" 517 $(qexec)( \ 518 trap 'rm -f $@' INT TERM; \ 519 curl="curl -S -s --retry 1 -L -o $@ $(call libvpx_test_data_url,$(@F))"; \ 520 $$curl; ret=$$?; \ 521 case "$$ret" in \ 522 18) $$curl -C - ;; \ 523 *) exit $$ret ;; \ 524 esac \ 525 ) 526 527testdata:: $(LIBVPX_TEST_DATA) 528 $(qexec)[ -x "$$(which sha1sum)" ] && sha1sum=sha1sum;\ 529 [ -x "$$(which shasum)" ] && sha1sum=shasum;\ 530 [ -x "$$(which sha1)" ] && sha1sum=sha1;\ 531 if [ -n "$${sha1sum}" ]; then\ 532 set -e;\ 533 echo "Checking test data:";\ 534 for f in $(call enabled,LIBVPX_TEST_DATA); do\ 535 grep $$f $(SRC_PATH_BARE)/test/test-data.sha1 |\ 536 (cd $(LIBVPX_TEST_DATA_PATH); $${sha1sum} -c);\ 537 done; \ 538 else\ 539 echo "Skipping test data integrity check, sha1sum not found.";\ 540 fi 541 542ifeq ($(CONFIG_EXTERNAL_BUILD),yes) 543ifeq ($(CONFIG_MSVS),yes) 544 545gtest.$(VCPROJ_SFX): $(SRC_PATH_BARE)/third_party/googletest/src/src/gtest-all.cc 546 @echo " [CREATE] $@" 547 $(qexec)$(GEN_VCPROJ) \ 548 --lib \ 549 --target=$(TOOLCHAIN) \ 550 $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \ 551 --name=gtest \ 552 --proj-guid=EC00E1EC-AF68-4D92-A255-181690D1C9B1 \ 553 --ver=$(CONFIG_VS_VERSION) \ 554 --src-path-bare="$(SRC_PATH_BARE)" \ 555 --as=$(AS) \ 556 -D_VARIADIC_MAX=10 \ 557 --out=gtest.$(VCPROJ_SFX) $(SRC_PATH_BARE)/third_party/googletest/src/src/gtest-all.cc \ 558 -I. -I"$(SRC_PATH_BARE)/third_party/googletest/src/include" -I"$(SRC_PATH_BARE)/third_party/googletest/src" 559 560PROJECTS-$(CONFIG_MSVS) += gtest.$(VCPROJ_SFX) 561 562test_libvpx.$(VCPROJ_SFX): $(LIBVPX_TEST_SRCS) vpx.$(VCPROJ_SFX) gtest.$(VCPROJ_SFX) 563 @echo " [CREATE] $@" 564 $(qexec)$(GEN_VCPROJ) \ 565 --exe \ 566 --target=$(TOOLCHAIN) \ 567 --name=test_libvpx \ 568 -D_VARIADIC_MAX=10 \ 569 --proj-guid=CD837F5F-52D8-4314-A370-895D614166A7 \ 570 --ver=$(CONFIG_VS_VERSION) \ 571 --src-path-bare="$(SRC_PATH_BARE)" \ 572 --as=$(AS) \ 573 $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \ 574 --out=$@ $(INTERNAL_CFLAGS) $(CFLAGS) \ 575 -I. -I"$(SRC_PATH_BARE)/third_party/googletest/src/include" \ 576 $(if $(CONFIG_WEBM_IO),-I"$(SRC_PATH_BARE)/third_party/libwebm") \ 577 -L. -l$(CODEC_LIB) -l$(GTEST_LIB) $^ 578 579PROJECTS-$(CONFIG_MSVS) += test_libvpx.$(VCPROJ_SFX) 580 581LIBVPX_TEST_BIN := $(addprefix $(TGT_OS:win64=x64)/Release/,$(notdir $(LIBVPX_TEST_BIN))) 582 583ifneq ($(strip $(TEST_INTRA_PRED_SPEED_OBJS)),) 584PROJECTS-$(CONFIG_MSVS) += test_intra_pred_speed.$(VCPROJ_SFX) 585test_intra_pred_speed.$(VCPROJ_SFX): $(TEST_INTRA_PRED_SPEED_SRCS) vpx.$(VCPROJ_SFX) gtest.$(VCPROJ_SFX) 586 @echo " [CREATE] $@" 587 $(qexec)$(GEN_VCPROJ) \ 588 --exe \ 589 --target=$(TOOLCHAIN) \ 590 --name=test_intra_pred_speed \ 591 -D_VARIADIC_MAX=10 \ 592 --proj-guid=CD837F5F-52D8-4314-A370-895D614166A7 \ 593 --ver=$(CONFIG_VS_VERSION) \ 594 --src-path-bare="$(SRC_PATH_BARE)" \ 595 --as=$(AS) \ 596 $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \ 597 --out=$@ $(INTERNAL_CFLAGS) $(CFLAGS) \ 598 -I. -I"$(SRC_PATH_BARE)/third_party/googletest/src/include" \ 599 -L. -l$(CODEC_LIB) -l$(GTEST_LIB) $^ 600endif # TEST_INTRA_PRED_SPEED 601 602ifeq ($(CONFIG_VP9_ENCODER),yes) 603ifneq ($(strip $(RC_INTERFACE_TEST_OBJS)),) 604PROJECTS-$(CONFIG_MSVS) += test_rc_interface.$(VCPROJ_SFX) 605test_rc_interface.$(VCPROJ_SFX): $(RC_INTERFACE_TEST_SRCS) vpx.$(VCPROJ_SFX) \ 606 vp9rc.$(VCPROJ_SFX) gtest.$(VCPROJ_SFX) 607 @echo " [CREATE] $@" 608 $(qexec)$(GEN_VCPROJ) \ 609 --exe \ 610 --target=$(TOOLCHAIN) \ 611 --name=test_rc_interface \ 612 -D_VARIADIC_MAX=10 \ 613 --proj-guid=30458F88-1BC6-4689-B41C-50F3737AAB27 \ 614 --ver=$(CONFIG_VS_VERSION) \ 615 --as=$(AS) \ 616 --src-path-bare="$(SRC_PATH_BARE)" \ 617 $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \ 618 --out=$@ $(INTERNAL_CFLAGS) $(CFLAGS) \ 619 -I. -I"$(SRC_PATH_BARE)/third_party/googletest/src/include" \ 620 -L. -l$(CODEC_LIB) -l$(RC_RTC_LIB) -l$(GTEST_LIB) $^ 621endif # RC_INTERFACE_TEST 622endif # CONFIG_VP9_ENCODER 623endif 624else 625 626include $(SRC_PATH_BARE)/third_party/googletest/gtest.mk 627GTEST_SRCS := $(addprefix third_party/googletest/src/,$(call enabled,GTEST_SRCS)) 628GTEST_OBJS=$(call objs,$(GTEST_SRCS)) 629ifeq ($(filter win%,$(TGT_OS)),$(TGT_OS)) 630# Disabling pthreads globally will cause issues on darwin and possibly elsewhere 631$(GTEST_OBJS) $(GTEST_OBJS:.o=.d): CXXFLAGS += -DGTEST_HAS_PTHREAD=0 632endif 633GTEST_INCLUDES := -I$(SRC_PATH_BARE)/third_party/googletest/src 634GTEST_INCLUDES += -I$(SRC_PATH_BARE)/third_party/googletest/src/include 635$(GTEST_OBJS) $(GTEST_OBJS:.o=.d): CXXFLAGS += $(GTEST_INCLUDES) 636OBJS-yes += $(GTEST_OBJS) 637LIBS-yes += $(BUILD_PFX)libgtest.a $(BUILD_PFX)libgtest_g.a 638$(BUILD_PFX)libgtest_g.a: $(GTEST_OBJS) 639 640LIBVPX_TEST_OBJS=$(sort $(call objs,$(LIBVPX_TEST_SRCS))) 641$(LIBVPX_TEST_OBJS) $(LIBVPX_TEST_OBJS:.o=.d): CXXFLAGS += $(GTEST_INCLUDES) 642OBJS-yes += $(LIBVPX_TEST_OBJS) 643BINS-yes += $(LIBVPX_TEST_BIN) 644 645CODEC_LIB=$(if $(CONFIG_DEBUG_LIBS),vpx_g,vpx) 646CODEC_LIB_SUF=$(if $(CONFIG_SHARED),$(SHARED_LIB_SUF),.a) 647TEST_LIBS := lib$(CODEC_LIB)$(CODEC_LIB_SUF) libgtest.a 648$(LIBVPX_TEST_BIN): $(TEST_LIBS) 649$(eval $(call linkerxx_template,$(LIBVPX_TEST_BIN), \ 650 $(LIBVPX_TEST_OBJS) \ 651 -L. -lvpx -lgtest $(extralibs) -lm)) 652 653ifneq ($(strip $(TEST_INTRA_PRED_SPEED_OBJS)),) 654$(TEST_INTRA_PRED_SPEED_OBJS) $(TEST_INTRA_PRED_SPEED_OBJS:.o=.d): CXXFLAGS += $(GTEST_INCLUDES) 655OBJS-yes += $(TEST_INTRA_PRED_SPEED_OBJS) 656BINS-yes += $(TEST_INTRA_PRED_SPEED_BIN) 657 658$(TEST_INTRA_PRED_SPEED_BIN): $(TEST_LIBS) 659$(eval $(call linkerxx_template,$(TEST_INTRA_PRED_SPEED_BIN), \ 660 $(TEST_INTRA_PRED_SPEED_OBJS) \ 661 -L. -lvpx -lgtest $(extralibs) -lm)) 662endif # TEST_INTRA_PRED_SPEED 663 664ifeq ($(CONFIG_VP9_ENCODER),yes) 665ifneq ($(strip $(RC_INTERFACE_TEST_OBJS)),) 666$(RC_INTERFACE_TEST_OBJS) $(RC_INTERFACE_TEST_OBJS:.o=.d): \ 667 CXXFLAGS += $(GTEST_INCLUDES) 668OBJS-yes += $(RC_INTERFACE_TEST_OBJS) 669BINS-yes += $(RC_INTERFACE_TEST_BIN) 670 671$(RC_INTERFACE_TEST_BIN): $(TEST_LIBS) libvp9rc.a 672$(eval $(call linkerxx_template,$(RC_INTERFACE_TEST_BIN), \ 673 $(RC_INTERFACE_TEST_OBJS) \ 674 -L. -lvpx -lgtest -lvp9rc $(extralibs) -lm)) 675endif # RC_INTERFACE_TEST 676endif # CONFIG_VP9_ENCODER 677 678ifneq ($(strip $(SIMPLE_ENCODE_TEST_OBJS)),) 679$(SIMPLE_ENCODE_TEST_OBJS) $(SIMPLE_ENCODE_TEST_OBJS:.o=.d): \ 680 CXXFLAGS += $(GTEST_INCLUDES) 681OBJS-yes += $(SIMPLE_ENCODE_TEST_OBJS) 682BINS-yes += $(SIMPLE_ENCODE_TEST_BIN) 683 684$(SIMPLE_ENCODE_TEST_BIN): $(TEST_LIBS) libsimple_encode.a 685$(eval $(call linkerxx_template,$(SIMPLE_ENCODE_TEST_BIN), \ 686 $(SIMPLE_ENCODE_TEST_OBJS) \ 687 -L. -lsimple_encode -lvpx -lgtest $(extralibs) -lm)) 688endif # SIMPLE_ENCODE_TEST 689 690endif # CONFIG_UNIT_TESTS 691 692# Install test sources only if codec source is included 693INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(patsubst $(SRC_PATH_BARE)/%,%,\ 694 $(shell find $(SRC_PATH_BARE)/third_party/googletest -type f)) 695INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(LIBVPX_TEST_SRCS) 696INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(TEST_INTRA_PRED_SPEED_SRCS) 697INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(RC_INTERFACE_TEST_SRCS) 698 699define test_shard_template 700test:: test_shard.$(1) 701test-no-data-check:: test_shard_ndc.$(1) 702test_shard.$(1) test_shard_ndc.$(1): $(LIBVPX_TEST_BIN) 703 @set -e; \ 704 export GTEST_SHARD_INDEX=$(1); \ 705 export GTEST_TOTAL_SHARDS=$(2); \ 706 $(LIBVPX_TEST_BIN) 707test_shard.$(1): testdata 708.PHONY: test_shard.$(1) 709endef 710 711NUM_SHARDS := 10 712SHARDS := 0 1 2 3 4 5 6 7 8 9 713$(foreach s,$(SHARDS),$(eval $(call test_shard_template,$(s),$(NUM_SHARDS)))) 714 715endif 716 717## 718## documentation directives 719## 720CLEAN-OBJS += libs.doxy 721DOCS-yes += libs.doxy 722libs.doxy: $(CODEC_DOC_SRCS) 723 @echo " [CREATE] $@" 724 @rm -f $@ 725 @echo "INPUT += $^" >> $@ 726 @echo "INCLUDE_PATH += ." >> $@; 727 @echo "ENABLED_SECTIONS += $(sort $(CODEC_DOC_SECTIONS))" >> $@ 728 729## Generate rtcd.h for all objects 730ifeq ($(CONFIG_DEPENDENCY_TRACKING),yes) 731$(OBJS-yes:.o=.d): $(RTCD) 732else 733$(OBJS-yes): $(RTCD) 734endif 735 736## Update the global src list 737SRCS += $(CODEC_SRCS) $(LIBVPX_TEST_SRCS) $(GTEST_SRCS) 738SRCS += $(RC_INTERFACE_TEST_SRCS) 739 740## 741## vpxdec/vpxenc tests. 742## 743ifeq ($(CONFIG_UNIT_TESTS),yes) 744TEST_BIN_PATH = . 745ifeq ($(CONFIG_MSVS),yes) 746# MSVC will build both Debug and Release configurations of tools in a 747# sub directory named for the current target. Assume the user wants to 748# run the Release tools, and assign TEST_BIN_PATH accordingly. 749# TODO(tomfinegan): Is this adequate for ARM? 750# TODO(tomfinegan): Support running the debug versions of tools? 751TEST_BIN_PATH := $(addsuffix /$(TGT_OS:win64=x64)/Release, $(TEST_BIN_PATH)) 752endif 753utiltest utiltest-no-data-check: 754 $(qexec)$(SRC_PATH_BARE)/test/vpxdec.sh \ 755 --test-data-path $(LIBVPX_TEST_DATA_PATH) \ 756 --bin-path $(TEST_BIN_PATH) 757 $(qexec)$(SRC_PATH_BARE)/test/vpxenc.sh \ 758 --test-data-path $(LIBVPX_TEST_DATA_PATH) \ 759 --bin-path $(TEST_BIN_PATH) 760utiltest: testdata 761else 762utiltest utiltest-no-data-check: 763 @echo Unit tests must be enabled to make the utiltest target. 764endif 765 766## 767## Example tests. 768## 769ifeq ($(CONFIG_UNIT_TESTS),yes) 770# All non-MSVC targets output example targets in a sub dir named examples. 771EXAMPLES_BIN_PATH = examples 772ifeq ($(CONFIG_MSVS),yes) 773# MSVC will build both Debug and Release configurations of the examples in a 774# sub directory named for the current target. Assume the user wants to 775# run the Release tools, and assign EXAMPLES_BIN_PATH accordingly. 776# TODO(tomfinegan): Is this adequate for ARM? 777# TODO(tomfinegan): Support running the debug versions of tools? 778EXAMPLES_BIN_PATH := $(TGT_OS:win64=x64)/Release 779endif 780exampletest exampletest-no-data-check: examples 781 $(qexec)$(SRC_PATH_BARE)/test/examples.sh \ 782 --test-data-path $(LIBVPX_TEST_DATA_PATH) \ 783 --bin-path $(EXAMPLES_BIN_PATH) 784exampletest: testdata 785else 786exampletest exampletest-no-data-check: 787 @echo Unit tests must be enabled to make the exampletest target. 788endif 789