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