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 ($(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 ifneq ($(CONFIG_VP8_ENCODER)$(CONFIG_VP8_DECODER),)
55 include $(SRC_PATH_BARE)/$(VP8_PREFIX)vp8_common.mk
58 ifeq ($(CONFIG_VP8_ENCODER),yes)
59 include $(SRC_PATH_BARE)/$(VP8_PREFIX)vp8cx.mk
60 CODEC_SRCS-yes += $(addprefix $(VP8_PREFIX),$(call enabled,VP8_CX_SRCS))
61 CODEC_EXPORTS-yes += $(addprefix $(VP8_PREFIX),$(VP8_CX_EXPORTS))
62 INSTALL-LIBS-yes += include/vpx/vp8.h include/vpx/vp8cx.h
63 INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/$(VP8_PREFIX)/%
64 CODEC_DOC_SECTIONS += vp8 vp8_encoder
67 ifeq ($(CONFIG_VP8_DECODER),yes)
68 include $(SRC_PATH_BARE)/$(VP8_PREFIX)vp8dx.mk
69 CODEC_SRCS-yes += $(addprefix $(VP8_PREFIX),$(call enabled,VP8_DX_SRCS))
70 CODEC_EXPORTS-yes += $(addprefix $(VP8_PREFIX),$(VP8_DX_EXPORTS))
71 INSTALL-LIBS-yes += include/vpx/vp8.h include/vpx/vp8dx.h
72 INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/$(VP8_PREFIX)/%
73 CODEC_DOC_SECTIONS += vp8 vp8_decoder
76 ifneq ($(CONFIG_VP9_ENCODER)$(CONFIG_VP9_DECODER),)
78 include $(SRC_PATH_BARE)/$(VP9_PREFIX)vp9_common.mk
81 ifeq ($(CONFIG_VP9_ENCODER),yes)
83 include $(SRC_PATH_BARE)/$(VP9_PREFIX)vp9cx.mk
84 CODEC_SRCS-yes += $(addprefix $(VP9_PREFIX),$(call enabled,VP9_CX_SRCS))
85 CODEC_EXPORTS-yes += $(addprefix $(VP9_PREFIX),$(VP9_CX_EXPORTS))
86 CODEC_SRCS-yes += $(VP9_PREFIX)vp9cx.mk vpx/vp8.h vpx/vp8cx.h
87 INSTALL-LIBS-yes += include/vpx/vp8.h include/vpx/vp8cx.h
88 INSTALL-LIBS-$(CONFIG_SPATIAL_SVC) += include/vpx/svc_context.h
89 INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/$(VP9_PREFIX)/%
90 CODEC_DOC_SRCS += vpx/vp8.h vpx/vp8cx.h
91 CODEC_DOC_SECTIONS += vp9 vp9_encoder
94 ifeq ($(CONFIG_VP9_DECODER),yes)
96 include $(SRC_PATH_BARE)/$(VP9_PREFIX)vp9dx.mk
97 CODEC_SRCS-yes += $(addprefix $(VP9_PREFIX),$(call enabled,VP9_DX_SRCS))
98 CODEC_EXPORTS-yes += $(addprefix $(VP9_PREFIX),$(VP9_DX_EXPORTS))
99 CODEC_SRCS-yes += $(VP9_PREFIX)vp9dx.mk vpx/vp8.h vpx/vp8dx.h
100 INSTALL-LIBS-yes += include/vpx/vp8.h include/vpx/vp8dx.h
101 INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/$(VP9_PREFIX)/%
102 CODEC_DOC_SRCS += vpx/vp8.h vpx/vp8dx.h
103 CODEC_DOC_SECTIONS += vp9 vp9_decoder
107 $(BUILD_PFX)$(VP9_PREFIX)%.c.o: CFLAGS += -Wextra
109 ifeq ($(CONFIG_ENCODERS),yes)
110 CODEC_DOC_SECTIONS += encoder
112 ifeq ($(CONFIG_DECODERS),yes)
113 CODEC_DOC_SECTIONS += decoder
117 ifeq ($(CONFIG_MSVS),yes)
118 CODEC_LIB=$(if $(CONFIG_STATIC_MSVCRT),vpxmt,vpxmd)
119 GTEST_LIB=$(if $(CONFIG_STATIC_MSVCRT),gtestmt,gtestmd)
120 # This variable uses deferred expansion intentionally, since the results of
121 # $(wildcard) may change during the course of the Make.
122 VS_PLATFORMS = $(foreach d,$(wildcard */Release/$(CODEC_LIB).lib),$(word 1,$(subst /, ,$(d))))
125 # The following pairs define a mapping of locations in the distribution
126 # tree to locations in the source/build trees.
127 INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/vpx/%
128 INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/vpx_ports/%
129 INSTALL_MAPS += $(LIBSUBDIR)/% %
130 INSTALL_MAPS += src/% $(SRC_PATH_BARE)/%
131 ifeq ($(CONFIG_MSVS),yes)
132 INSTALL_MAPS += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/% $(p)/Release/%)
133 INSTALL_MAPS += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/% $(p)/Debug/%)
136 CODEC_SRCS-yes += build/make/version.sh
137 CODEC_SRCS-yes += build/make/rtcd.pl
138 CODEC_SRCS-yes += vpx_ports/emmintrin_compat.h
139 CODEC_SRCS-yes += vpx_ports/mem_ops.h
140 CODEC_SRCS-yes += vpx_ports/mem_ops_aligned.h
141 CODEC_SRCS-yes += vpx_ports/vpx_once.h
142 CODEC_SRCS-yes += $(BUILD_PFX)vpx_config.c
143 INSTALL-SRCS-no += $(BUILD_PFX)vpx_config.c
144 ifeq ($(ARCH_X86)$(ARCH_X86_64),yes)
145 INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += third_party/x86inc/x86inc.asm
147 CODEC_EXPORTS-yes += vpx/exports_com
148 CODEC_EXPORTS-$(CONFIG_ENCODERS) += vpx/exports_enc
149 CODEC_EXPORTS-$(CONFIG_DECODERS) += vpx/exports_dec
151 INSTALL-LIBS-yes += include/vpx/vpx_codec.h
152 INSTALL-LIBS-yes += include/vpx/vpx_frame_buffer.h
153 INSTALL-LIBS-yes += include/vpx/vpx_image.h
154 INSTALL-LIBS-yes += include/vpx/vpx_integer.h
155 INSTALL-LIBS-$(CONFIG_DECODERS) += include/vpx/vpx_decoder.h
156 INSTALL-LIBS-$(CONFIG_ENCODERS) += include/vpx/vpx_encoder.h
157 ifeq ($(CONFIG_EXTERNAL_BUILD),yes)
158 ifeq ($(CONFIG_MSVS),yes)
159 INSTALL-LIBS-yes += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/$(CODEC_LIB).lib)
160 INSTALL-LIBS-$(CONFIG_DEBUG_LIBS) += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/$(CODEC_LIB)d.lib)
161 INSTALL-LIBS-$(CONFIG_SHARED) += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/vpx.dll)
162 INSTALL-LIBS-$(CONFIG_SHARED) += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/vpx.exp)
165 INSTALL-LIBS-$(CONFIG_STATIC) += $(LIBSUBDIR)/libvpx.a
166 INSTALL-LIBS-$(CONFIG_DEBUG_LIBS) += $(LIBSUBDIR)/libvpx_g.a
169 CODEC_SRCS=$(call enabled,CODEC_SRCS)
170 INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(CODEC_SRCS)
171 INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(call enabled,CODEC_EXPORTS)
174 # Generate a list of all enabled sources, in particular for exporting to gyp
175 # based build systems.
178 @echo $(CODEC_SRCS) | xargs -n1 echo | LC_ALL=C sort -u > $@
179 CLEAN-OBJS += libvpx_srcs.txt
182 ifeq ($(CONFIG_EXTERNAL_BUILD),yes)
183 ifeq ($(CONFIG_MSVS),yes)
185 vpx.def: $(call enabled,CODEC_EXPORTS)
187 $(qexec)$(SRC_PATH_BARE)/build/make/gen_msvs_def.sh\
190 CLEAN-OBJS += vpx.def
192 # Assembly files that are included, but don't define symbols themselves.
193 # Filtered out to avoid Visual Studio build warnings.
195 third_party/x86inc/x86inc.asm \
197 vpx_ports/x86_abi_support.asm \
199 vpx.$(VCPROJ_SFX): $(CODEC_SRCS) vpx.def
201 $(qexec)$(GEN_VCPROJ) \
202 $(if $(CONFIG_SHARED),--dll,--lib) \
203 --target=$(TOOLCHAIN) \
204 $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \
206 --proj-guid=DCE19DAF-69AC-46DB-B14A-39F0FAA5DB74 \
207 --module-def=vpx.def \
208 --ver=$(CONFIG_VS_VERSION) \
209 --src-path-bare="$(SRC_PATH_BARE)" \
211 $(filter-out $(addprefix %, $(ASM_INCLUDES)), $^) \
212 --src-path-bare="$(SRC_PATH_BARE)" \
214 PROJECTS-yes += vpx.$(VCPROJ_SFX)
216 vpx.$(VCPROJ_SFX): vpx_config.asm
217 vpx.$(VCPROJ_SFX): $(RTCD)
221 LIBVPX_OBJS=$(call objs,$(CODEC_SRCS))
222 OBJS-yes += $(LIBVPX_OBJS)
223 LIBS-$(if yes,$(CONFIG_STATIC)) += $(BUILD_PFX)libvpx.a $(BUILD_PFX)libvpx_g.a
224 $(BUILD_PFX)libvpx_g.a: $(LIBVPX_OBJS)
226 SO_VERSION_MAJOR := 2
227 SO_VERSION_MINOR := 0
228 SO_VERSION_PATCH := 0
229 ifeq ($(filter darwin%,$(TGT_OS)),$(TGT_OS))
230 LIBVPX_SO := libvpx.$(SO_VERSION_MAJOR).dylib
231 SHARED_LIB_SUF := .dylib
232 EXPORT_FILE := libvpx.syms
233 LIBVPX_SO_SYMLINKS := $(addprefix $(LIBSUBDIR)/, \
236 ifeq ($(filter os2%,$(TGT_OS)),$(TGT_OS))
237 LIBVPX_SO := libvpx$(SO_VERSION_MAJOR).dll
238 SHARED_LIB_SUF := _dll.a
239 EXPORT_FILE := libvpx.def
240 LIBVPX_SO_SYMLINKS :=
241 LIBVPX_SO_IMPLIB := libvpx_dll.a
243 LIBVPX_SO := libvpx.so.$(SO_VERSION_MAJOR).$(SO_VERSION_MINOR).$(SO_VERSION_PATCH)
244 SHARED_LIB_SUF := .so
245 EXPORT_FILE := libvpx.ver
246 LIBVPX_SO_SYMLINKS := $(addprefix $(LIBSUBDIR)/, \
247 libvpx.so libvpx.so.$(SO_VERSION_MAJOR) \
248 libvpx.so.$(SO_VERSION_MAJOR).$(SO_VERSION_MINOR))
252 LIBS-$(CONFIG_SHARED) += $(BUILD_PFX)$(LIBVPX_SO)\
253 $(notdir $(LIBVPX_SO_SYMLINKS)) \
254 $(if $(LIBVPX_SO_IMPLIB), $(BUILD_PFX)$(LIBVPX_SO_IMPLIB))
255 $(BUILD_PFX)$(LIBVPX_SO): $(LIBVPX_OBJS) $(EXPORT_FILE)
256 $(BUILD_PFX)$(LIBVPX_SO): extralibs += -lm
257 $(BUILD_PFX)$(LIBVPX_SO): SONAME = libvpx.so.$(SO_VERSION_MAJOR)
258 $(BUILD_PFX)$(LIBVPX_SO): EXPORTS_FILE = $(EXPORT_FILE)
260 libvpx.ver: $(call enabled,CODEC_EXPORTS)
262 $(qexec)echo "{ global:" > $@
263 $(qexec)for f in $?; do awk '{print $$2";"}' < $$f >>$@; done
264 $(qexec)echo "local: *; };" >> $@
265 CLEAN-OBJS += libvpx.ver
267 libvpx.syms: $(call enabled,CODEC_EXPORTS)
269 $(qexec)awk '{print "_"$$2}' $^ >$@
270 CLEAN-OBJS += libvpx.syms
272 libvpx.def: $(call enabled,CODEC_EXPORTS)
274 $(qexec)echo LIBRARY $(LIBVPX_SO:.dll=) INITINSTANCE TERMINSTANCE > $@
275 $(qexec)echo "DATA MULTIPLE NONSHARED" >> $@
276 $(qexec)echo "EXPORTS" >> $@
277 $(qexec)awk '!/vpx_svc_*/ {print "_"$$2}' $^ >>$@
278 CLEAN-OBJS += libvpx.def
280 libvpx_dll.a: $(LIBVPX_SO)
282 $(qexec)emximp -o $@ $<
283 CLEAN-OBJS += libvpx_dll.a
285 define libvpx_symlink_template
287 @echo " [LN] $(2) $$@"
288 $(qexec)mkdir -p $$(dir $$@)
289 $(qexec)ln -sf $(2) $$@
292 $(eval $(call libvpx_symlink_template,\
293 $(addprefix $(BUILD_PFX),$(notdir $(LIBVPX_SO_SYMLINKS))),\
294 $(BUILD_PFX)$(LIBVPX_SO)))
295 $(eval $(call libvpx_symlink_template,\
296 $(addprefix $(DIST_DIR)/,$(LIBVPX_SO_SYMLINKS)),\
300 INSTALL-LIBS-$(CONFIG_SHARED) += $(LIBVPX_SO_SYMLINKS)
301 INSTALL-LIBS-$(CONFIG_SHARED) += $(LIBSUBDIR)/$(LIBVPX_SO)
302 INSTALL-LIBS-$(CONFIG_SHARED) += $(if $(LIBVPX_SO_IMPLIB),$(LIBSUBDIR)/$(LIBVPX_SO_IMPLIB))
306 vpx.pc: config.mk libs.mk
308 $(qexec)echo '# pkg-config file from libvpx $(VERSION_STRING)' > $@
309 $(qexec)echo 'prefix=$(PREFIX)' >> $@
310 $(qexec)echo 'exec_prefix=$${prefix}' >> $@
311 $(qexec)echo 'libdir=$${prefix}/$(LIBSUBDIR)' >> $@
312 $(qexec)echo 'includedir=$${prefix}/include' >> $@
313 $(qexec)echo '' >> $@
314 $(qexec)echo 'Name: vpx' >> $@
315 $(qexec)echo 'Description: WebM Project VPx codec implementation' >> $@
316 $(qexec)echo 'Version: $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH)' >> $@
317 $(qexec)echo 'Requires:' >> $@
318 $(qexec)echo 'Conflicts:' >> $@
319 $(qexec)echo 'Libs: -L$${libdir} -lvpx -lm' >> $@
320 ifeq ($(HAVE_PTHREAD_H),yes)
321 $(qexec)echo 'Libs.private: -lm -lpthread' >> $@
323 $(qexec)echo 'Libs.private: -lm' >> $@
325 $(qexec)echo 'Cflags: -I$${includedir}' >> $@
326 INSTALL-LIBS-yes += $(LIBSUBDIR)/pkgconfig/vpx.pc
327 INSTALL_MAPS += $(LIBSUBDIR)/pkgconfig/%.pc %.pc
332 # Rule to make assembler configuration file from C configuration file
334 ifeq ($(ARCH_X86)$(ARCH_X86_64),yes)
336 $(BUILD_PFX)vpx_config.asm: $(BUILD_PFX)vpx_config.h
338 @egrep "#define [A-Z0-9_]+ [01]" $< \
339 | awk '{print $$2 " equ " $$3}' > $@
341 ADS2GAS=$(if $(filter yes,$(CONFIG_GCC)),| $(ASM_CONVERSION))
342 $(BUILD_PFX)vpx_config.asm: $(BUILD_PFX)vpx_config.h
344 @egrep "#define [A-Z0-9_]+ [01]" $< \
345 | awk '{print $$2 " EQU " $$3}' $(ADS2GAS) > $@
346 @echo " END" $(ADS2GAS) >> $@
347 CLEAN-OBJS += $(BUILD_PFX)vpx_config.asm
351 # Add assembler dependencies for configuration.
353 $(filter %.s.o,$(OBJS-yes)): $(BUILD_PFX)vpx_config.asm
354 $(filter %$(ASM).o,$(OBJS-yes)): $(BUILD_PFX)vpx_config.asm
357 $(shell $(SRC_PATH_BARE)/build/make/version.sh "$(SRC_PATH_BARE)" $(BUILD_PFX)vpx_version.h)
358 CLEAN-OBJS += $(BUILD_PFX)vpx_version.h
362 ## libvpx test directives
364 ifeq ($(CONFIG_UNIT_TESTS),yes)
365 LIBVPX_TEST_DATA_PATH ?= .
367 include $(SRC_PATH_BARE)/test/test.mk
368 LIBVPX_TEST_SRCS=$(addprefix test/,$(call enabled,LIBVPX_TEST_SRCS))
369 LIBVPX_TEST_BIN=./test_libvpx$(EXE_SFX)
370 LIBVPX_TEST_DATA=$(addprefix $(LIBVPX_TEST_DATA_PATH)/,\
371 $(call enabled,LIBVPX_TEST_DATA))
372 libvpx_test_data_url=http://downloads.webmproject.org/test_data/libvpx/$(1)
374 TEST_INTRA_PRED_SPEED_BIN=./test_intra_pred_speed$(EXE_SFX)
375 TEST_INTRA_PRED_SPEED_SRCS=$(addprefix test/,$(call enabled,TEST_INTRA_PRED_SPEED_SRCS))
376 TEST_INTRA_PRED_SPEED_OBJS := $(sort $(call objs,$(TEST_INTRA_PRED_SPEED_SRCS)))
378 libvpx_test_srcs.txt:
380 @echo $(LIBVPX_TEST_SRCS) | xargs -n1 echo | LC_ALL=C sort -u > $@
381 CLEAN-OBJS += libvpx_test_srcs.txt
383 $(LIBVPX_TEST_DATA): $(SRC_PATH_BARE)/test/test-data.sha1
384 @echo " [DOWNLOAD] $@"
385 $(qexec)trap 'rm -f $@' INT TERM &&\
386 curl -L -o $@ $(call libvpx_test_data_url,$(@F))
388 testdata:: $(LIBVPX_TEST_DATA)
389 $(qexec)[ -x "$$(which sha1sum)" ] && sha1sum=sha1sum;\
390 [ -x "$$(which shasum)" ] && sha1sum=shasum;\
391 [ -x "$$(which sha1)" ] && sha1sum=sha1;\
392 if [ -n "$${sha1sum}" ]; then\
394 echo "Checking test data:";\
395 if [ -n "$(LIBVPX_TEST_DATA)" ]; then\
396 for f in $(call enabled,LIBVPX_TEST_DATA); do\
397 grep $$f $(SRC_PATH_BARE)/test/test-data.sha1 |\
398 (cd $(LIBVPX_TEST_DATA_PATH); $${sha1sum} -c);\
402 echo "Skipping test data integrity check, sha1sum not found.";\
405 ifeq ($(CONFIG_EXTERNAL_BUILD),yes)
406 ifeq ($(CONFIG_MSVS),yes)
408 gtest.$(VCPROJ_SFX): $(SRC_PATH_BARE)/third_party/googletest/src/src/gtest-all.cc
410 $(qexec)$(GEN_VCPROJ) \
412 --target=$(TOOLCHAIN) \
413 $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \
415 --proj-guid=EC00E1EC-AF68-4D92-A255-181690D1C9B1 \
416 --ver=$(CONFIG_VS_VERSION) \
417 --src-path-bare="$(SRC_PATH_BARE)" \
419 --out=gtest.$(VCPROJ_SFX) $(SRC_PATH_BARE)/third_party/googletest/src/src/gtest-all.cc \
420 -I. -I"$(SRC_PATH_BARE)/third_party/googletest/src/include" -I"$(SRC_PATH_BARE)/third_party/googletest/src"
422 PROJECTS-$(CONFIG_MSVS) += gtest.$(VCPROJ_SFX)
424 test_libvpx.$(VCPROJ_SFX): $(LIBVPX_TEST_SRCS) vpx.$(VCPROJ_SFX) gtest.$(VCPROJ_SFX)
426 $(qexec)$(GEN_VCPROJ) \
428 --target=$(TOOLCHAIN) \
431 --proj-guid=CD837F5F-52D8-4314-A370-895D614166A7 \
432 --ver=$(CONFIG_VS_VERSION) \
433 --src-path-bare="$(SRC_PATH_BARE)" \
434 $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \
435 --out=$@ $(INTERNAL_CFLAGS) $(CFLAGS) \
436 -I. -I"$(SRC_PATH_BARE)/third_party/googletest/src/include" \
437 -L. -l$(CODEC_LIB) -l$(GTEST_LIB) $^
439 PROJECTS-$(CONFIG_MSVS) += test_libvpx.$(VCPROJ_SFX)
441 LIBVPX_TEST_BIN := $(addprefix $(TGT_OS:win64=x64)/Release/,$(notdir $(LIBVPX_TEST_BIN)))
443 ifneq ($(strip $(TEST_INTRA_PRED_SPEED_OBJS)),)
444 PROJECTS-$(CONFIG_MSVS) += test_intra_pred_speed.$(VCPROJ_SFX)
445 test_intra_pred_speed.$(VCPROJ_SFX): $(TEST_INTRA_PRED_SPEED_SRCS) vpx.$(VCPROJ_SFX) gtest.$(VCPROJ_SFX)
447 $(qexec)$(GEN_VCPROJ) \
449 --target=$(TOOLCHAIN) \
450 --name=test_intra_pred_speed \
452 --proj-guid=CD837F5F-52D8-4314-A370-895D614166A7 \
453 --ver=$(CONFIG_VS_VERSION) \
454 --src-path-bare="$(SRC_PATH_BARE)" \
455 $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \
456 --out=$@ $(INTERNAL_CFLAGS) $(CFLAGS) \
457 -I. -I"$(SRC_PATH_BARE)/third_party/googletest/src/include" \
458 -L. -l$(CODEC_LIB) -l$(GTEST_LIB) $^
459 endif # TEST_INTRA_PRED_SPEED
463 include $(SRC_PATH_BARE)/third_party/googletest/gtest.mk
464 GTEST_SRCS := $(addprefix third_party/googletest/src/,$(call enabled,GTEST_SRCS))
465 GTEST_OBJS=$(call objs,$(GTEST_SRCS))
466 ifeq ($(filter win%,$(TGT_OS)),$(TGT_OS))
467 # Disabling pthreads globally will cause issues on darwin and possibly elsewhere
468 $(GTEST_OBJS) $(GTEST_OBJS:.o=.d): CXXFLAGS += -DGTEST_HAS_PTHREAD=0
470 GTEST_INCLUDES := -I$(SRC_PATH_BARE)/third_party/googletest/src
471 GTEST_INCLUDES += -I$(SRC_PATH_BARE)/third_party/googletest/src/include
472 $(GTEST_OBJS) $(GTEST_OBJS:.o=.d): CXXFLAGS += $(GTEST_INCLUDES)
473 OBJS-yes += $(GTEST_OBJS)
474 LIBS-yes += $(BUILD_PFX)libgtest.a $(BUILD_PFX)libgtest_g.a
475 $(BUILD_PFX)libgtest_g.a: $(GTEST_OBJS)
477 LIBVPX_TEST_OBJS=$(sort $(call objs,$(LIBVPX_TEST_SRCS)))
478 $(LIBVPX_TEST_OBJS) $(LIBVPX_TEST_OBJS:.o=.d): CXXFLAGS += $(GTEST_INCLUDES)
479 OBJS-yes += $(LIBVPX_TEST_OBJS)
480 BINS-yes += $(LIBVPX_TEST_BIN)
482 CODEC_LIB=$(if $(CONFIG_DEBUG_LIBS),vpx_g,vpx)
483 CODEC_LIB_SUF=$(if $(CONFIG_SHARED),$(SHARED_LIB_SUF),.a)
484 TEST_LIBS := lib$(CODEC_LIB)$(CODEC_LIB_SUF) libgtest.a
485 $(LIBVPX_TEST_BIN): $(TEST_LIBS)
486 $(eval $(call linkerxx_template,$(LIBVPX_TEST_BIN), \
487 $(LIBVPX_TEST_OBJS) \
488 -L. -lvpx -lgtest $(extralibs) -lm))
490 ifneq ($(strip $(TEST_INTRA_PRED_SPEED_OBJS)),)
491 $(TEST_INTRA_PRED_SPEED_OBJS) $(TEST_INTRA_PRED_SPEED_OBJS:.o=.d): CXXFLAGS += $(GTEST_INCLUDES)
492 OBJS-yes += $(TEST_INTRA_PRED_SPEED_OBJS)
493 BINS-yes += $(TEST_INTRA_PRED_SPEED_BIN)
495 $(TEST_INTRA_PRED_SPEED_BIN): $(TEST_LIBS)
496 $(eval $(call linkerxx_template,$(TEST_INTRA_PRED_SPEED_BIN), \
497 $(TEST_INTRA_PRED_SPEED_OBJS) \
498 -L. -lvpx -lgtest $(extralibs) -lm))
499 endif # TEST_INTRA_PRED_SPEED
501 endif # CONFIG_UNIT_TESTS
503 # Install test sources only if codec source is included
504 INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(patsubst $(SRC_PATH_BARE)/%,%,\
505 $(shell find $(SRC_PATH_BARE)/third_party/googletest -type f))
506 INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(LIBVPX_TEST_SRCS)
507 INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(TEST_INTRA_PRED_SPEED_SRCS)
509 define test_shard_template
510 test:: test_shard.$(1)
511 test_shard.$(1): $(LIBVPX_TEST_BIN) testdata
513 export GTEST_SHARD_INDEX=$(1); \
514 export GTEST_TOTAL_SHARDS=$(2); \
516 .PHONY: test_shard.$(1)
520 SHARDS := 0 1 2 3 4 5 6 7 8 9
521 $(foreach s,$(SHARDS),$(eval $(call test_shard_template,$(s),$(NUM_SHARDS))))
526 ## documentation directives
528 CLEAN-OBJS += libs.doxy
529 DOCS-yes += libs.doxy
530 libs.doxy: $(CODEC_DOC_SRCS)
533 @echo "INPUT += $^" >> $@
534 @echo "INCLUDE_PATH += ." >> $@;
535 @echo "ENABLED_SECTIONS += $(sort $(CODEC_DOC_SECTIONS))" >> $@
537 ## Generate rtcd.h for all objects
538 ifeq ($(CONFIG_DEPENDENCY_TRACKING),yes)
539 $(OBJS-yes:.o=.d): $(RTCD)
544 ## Update the global src list
545 SRCS += $(CODEC_SRCS) $(LIBVPX_TEST_SRCS) $(GTEST_SRCS)
548 ## vpxdec/vpxenc tests.
550 ifeq ($(CONFIG_UNIT_TESTS),yes)
552 ifeq ($(CONFIG_MSVS),yes)
553 # MSVC will build both Debug and Release configurations of tools in a
554 # sub directory named for the current target. Assume the user wants to
555 # run the Release tools, and assign TEST_BIN_PATH accordingly.
556 # TODO(tomfinegan): Is this adequate for ARM?
557 # TODO(tomfinegan): Support running the debug versions of tools?
558 TEST_BIN_PATH := $(addsuffix /$(TGT_OS:win64=x64)/Release, $(TEST_BIN_PATH))
561 $(qexec)$(SRC_PATH_BARE)/test/vpxdec.sh \
562 --test-data-path $(LIBVPX_TEST_DATA_PATH) \
563 --bin-path $(TEST_BIN_PATH)
564 $(qexec)$(SRC_PATH_BARE)/test/vpxenc.sh \
565 --test-data-path $(LIBVPX_TEST_DATA_PATH) \
566 --bin-path $(TEST_BIN_PATH)
569 @echo Unit tests must be enabled to make the utiltest target.
575 ifeq ($(CONFIG_UNIT_TESTS),yes)
576 # All non-MSVC targets output example targets in a sub dir named examples.
577 EXAMPLES_BIN_PATH = examples
578 ifeq ($(CONFIG_MSVS),yes)
579 # MSVC will build both Debug and Release configurations of the examples in a
580 # sub directory named for the current target. Assume the user wants to
581 # run the Release tools, and assign EXAMPLES_BIN_PATH accordingly.
582 # TODO(tomfinegan): Is this adequate for ARM?
583 # TODO(tomfinegan): Support running the debug versions of tools?
584 EXAMPLES_BIN_PATH := $(TGT_OS:win64=x64)/Release
586 exampletest: examples testdata
587 $(qexec)$(SRC_PATH_BARE)/test/examples.sh \
588 --test-data-path $(LIBVPX_TEST_DATA_PATH) \
589 --bin-path $(EXAMPLES_BIN_PATH)
592 @echo Unit tests must be enabled to make the exampletest target.