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