Merge "Merging in the sixteenth subpel uv experiment" into experimental
[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 vpx/vp8e.h
39   CODEC_SRCS-$(ARCH_ARM) += $(VP8_PREFIX)vp8cx_arm.mk
40   INSTALL-LIBS-yes += include/vpx/vp8.h include/vpx/vp8e.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) += third_party/x86inc/x86inc.asm
106 CODEC_SRCS-$(BUILD_LIBVPX) += vpx_ports/x86_cpuid.c
107 endif
108 CODEC_SRCS-$(ARCH_ARM) += vpx_ports/arm_cpudetect.c
109 CODEC_SRCS-$(ARCH_ARM) += vpx_ports/arm.h
110 CODEC_EXPORTS-$(BUILD_LIBVPX) += vpx/exports_com
111 CODEC_EXPORTS-$(CONFIG_ENCODERS) += vpx/exports_enc
112 CODEC_EXPORTS-$(CONFIG_DECODERS) += vpx/exports_dec
113
114 INSTALL-LIBS-yes += include/vpx/vpx_codec.h
115 INSTALL-LIBS-yes += include/vpx/vpx_image.h
116 INSTALL-LIBS-yes += include/vpx/vpx_integer.h
117 INSTALL-LIBS-yes += include/vpx/vpx_codec_impl_top.h
118 INSTALL-LIBS-yes += include/vpx/vpx_codec_impl_bottom.h
119 INSTALL-LIBS-$(CONFIG_DECODERS) += include/vpx/vpx_decoder.h
120 INSTALL-LIBS-$(CONFIG_DECODERS) += include/vpx/vpx_decoder_compat.h
121 INSTALL-LIBS-$(CONFIG_ENCODERS) += include/vpx/vpx_encoder.h
122 ifeq ($(CONFIG_EXTERNAL_BUILD),yes)
123 ifeq ($(CONFIG_MSVS),yes)
124 INSTALL-LIBS-yes                  += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/$(CODEC_LIB).lib)
125 INSTALL-LIBS-$(CONFIG_DEBUG_LIBS) += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/$(CODEC_LIB)d.lib)
126 INSTALL-LIBS-$(CONFIG_SHARED) += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/vpx.dll)
127 INSTALL-LIBS-$(CONFIG_SHARED) += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/vpx.exp)
128 endif
129 else
130 INSTALL-LIBS-$(CONFIG_STATIC) += $(LIBSUBDIR)/libvpx.a
131 INSTALL-LIBS-$(CONFIG_DEBUG_LIBS) += $(LIBSUBDIR)/libvpx_g.a
132 endif
133
134 CODEC_SRCS=$(filter-out %_test.cc,$(call enabled,CODEC_SRCS))
135 INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(CODEC_SRCS)
136 INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(call enabled,CODEC_EXPORTS)
137
138
139 # Generate a list of all enabled sources, in particular for exporting to gyp
140 # based build systems.
141 libvpx_srcs.txt:
142         @echo "    [CREATE] $@"
143         @echo $(CODEC_SRCS) | xargs -n1 echo | sort -u > $@
144
145
146 ifeq ($(CONFIG_EXTERNAL_BUILD),yes)
147 ifeq ($(CONFIG_MSVS),yes)
148
149 obj_int_extract.vcproj: $(SRC_PATH_BARE)/build/make/obj_int_extract.c
150         @cp $(SRC_PATH_BARE)/build/x86-msvs/obj_int_extract.bat .
151         @echo "    [CREATE] $@"
152         $(SRC_PATH_BARE)/build/make/gen_msvs_proj.sh \
153     --exe \
154     --target=$(TOOLCHAIN) \
155     --name=obj_int_extract \
156     --ver=$(CONFIG_VS_VERSION) \
157     --proj-guid=E1360C65-D375-4335-8057-7ED99CC3F9B2 \
158     $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \
159     --out=$@ $^ \
160     -I. \
161     -I"$(SRC_PATH_BARE)" \
162
163 PROJECTS-$(BUILD_LIBVPX) += obj_int_extract.vcproj
164 PROJECTS-$(BUILD_LIBVPX) += obj_int_extract.bat
165
166 vpx.def: $(call enabled,CODEC_EXPORTS)
167         @echo "    [CREATE] $@"
168         $(SRC_PATH_BARE)/build/make/gen_msvs_def.sh\
169             --name=vpx\
170             --out=$@ $^
171 CLEAN-OBJS += vpx.def
172
173 vpx.vcproj: $(CODEC_SRCS) vpx.def
174         @echo "    [CREATE] $@"
175         $(SRC_PATH_BARE)/build/make/gen_msvs_proj.sh \
176             $(if $(CONFIG_SHARED),--dll,--lib) \
177             --target=$(TOOLCHAIN) \
178             $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \
179             --name=vpx \
180             --proj-guid=DCE19DAF-69AC-46DB-B14A-39F0FAA5DB74 \
181             --module-def=vpx.def \
182             --ver=$(CONFIG_VS_VERSION) \
183             --out=$@ $(CFLAGS) $^ \
184             --src-path-bare="$(SRC_PATH_BARE)" \
185
186 PROJECTS-$(BUILD_LIBVPX) += vpx.vcproj
187
188 vpx.vcproj: vpx_config.asm
189 vpx.vcproj: vpx_rtcd.h
190
191 endif
192 else
193 LIBVPX_OBJS=$(call objs,$(CODEC_SRCS))
194 OBJS-$(BUILD_LIBVPX) += $(LIBVPX_OBJS)
195 LIBS-$(if $(BUILD_LIBVPX),$(CONFIG_STATIC)) += $(BUILD_PFX)libvpx.a $(BUILD_PFX)libvpx_g.a
196 $(BUILD_PFX)libvpx_g.a: $(LIBVPX_OBJS)
197
198
199 BUILD_LIBVPX_SO         := $(if $(BUILD_LIBVPX),$(CONFIG_SHARED))
200
201 ifeq ($(filter darwin%,$(TGT_OS)),$(TGT_OS))
202 LIBVPX_SO               := libvpx.$(VERSION_MAJOR).dylib
203 EXPORT_FILE             := libvpx.syms
204 LIBVPX_SO_SYMLINKS      := $(addprefix $(LIBSUBDIR)/, \
205                              libvpx.dylib  )
206 else
207 LIBVPX_SO               := libvpx.so.$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH)
208 EXPORT_FILE             := libvpx.ver
209 SYM_LINK                := libvpx.so
210 LIBVPX_SO_SYMLINKS      := $(addprefix $(LIBSUBDIR)/, \
211                              libvpx.so libvpx.so.$(VERSION_MAJOR) \
212                              libvpx.so.$(VERSION_MAJOR).$(VERSION_MINOR))
213 endif
214
215 LIBS-$(BUILD_LIBVPX_SO) += $(BUILD_PFX)$(LIBVPX_SO)\
216                            $(notdir $(LIBVPX_SO_SYMLINKS))
217 $(BUILD_PFX)$(LIBVPX_SO): $(LIBVPX_OBJS) $(EXPORT_FILE)
218 $(BUILD_PFX)$(LIBVPX_SO): extralibs += -lm
219 $(BUILD_PFX)$(LIBVPX_SO): SONAME = libvpx.so.$(VERSION_MAJOR)
220 $(BUILD_PFX)$(LIBVPX_SO): EXPORTS_FILE = $(EXPORT_FILE)
221
222 libvpx.ver: $(call enabled,CODEC_EXPORTS)
223         @echo "    [CREATE] $@"
224         $(qexec)echo "{ global:" > $@
225         $(qexec)for f in $?; do awk '{print $$2";"}' < $$f >>$@; done
226         $(qexec)echo "local: *; };" >> $@
227 CLEAN-OBJS += libvpx.ver
228
229 libvpx.syms: $(call enabled,CODEC_EXPORTS)
230         @echo "    [CREATE] $@"
231         $(qexec)awk '{print "_"$$2}' $^ >$@
232 CLEAN-OBJS += libvpx.syms
233
234 define libvpx_symlink_template
235 $(1): $(2)
236         @echo "    [LN]     $(2) $$@"
237         $(qexec)ln -sf $(2) $$@
238 endef
239
240 $(eval $(call libvpx_symlink_template,\
241     $(addprefix $(BUILD_PFX),$(notdir $(LIBVPX_SO_SYMLINKS))),\
242     $(BUILD_PFX)$(LIBVPX_SO)))
243 $(eval $(call libvpx_symlink_template,\
244     $(addprefix $(DIST_DIR)/,$(LIBVPX_SO_SYMLINKS)),\
245     $(DIST_DIR)/$(LIBSUBDIR)/$(LIBVPX_SO)))
246
247
248 INSTALL-LIBS-$(BUILD_LIBVPX_SO) += $(LIBVPX_SO_SYMLINKS)
249 INSTALL-LIBS-$(BUILD_LIBVPX_SO) += $(LIBSUBDIR)/$(LIBVPX_SO)
250
251
252 LIBS-$(BUILD_LIBVPX) += vpx.pc
253 vpx.pc: config.mk libs.mk
254         @echo "    [CREATE] $@"
255         $(qexec)echo '# pkg-config file from libvpx $(VERSION_STRING)' > $@
256         $(qexec)echo 'prefix=$(PREFIX)' >> $@
257         $(qexec)echo 'exec_prefix=$${prefix}' >> $@
258         $(qexec)echo 'libdir=$${prefix}/$(LIBSUBDIR)' >> $@
259         $(qexec)echo 'includedir=$${prefix}/include' >> $@
260         $(qexec)echo '' >> $@
261         $(qexec)echo 'Name: vpx' >> $@
262         $(qexec)echo 'Description: WebM Project VPx codec implementation' >> $@
263         $(qexec)echo 'Version: $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH)' >> $@
264         $(qexec)echo 'Requires:' >> $@
265         $(qexec)echo 'Conflicts:' >> $@
266         $(qexec)echo 'Libs: -L$${libdir} -lvpx -lm' >> $@
267         $(qexec)echo 'Cflags: -I$${includedir}' >> $@
268 INSTALL-LIBS-yes += $(LIBSUBDIR)/pkgconfig/vpx.pc
269 INSTALL_MAPS += $(LIBSUBDIR)/pkgconfig/%.pc %.pc
270 CLEAN-OBJS += vpx.pc
271 endif
272
273 LIBS-$(LIPO_LIBVPX) += libvpx.a
274 $(eval $(if $(LIPO_LIBVPX),$(call lipo_lib_template,libvpx.a)))
275
276 #
277 # Rule to make assembler configuration file from C configuration file
278 #
279 ifeq ($(ARCH_X86)$(ARCH_X86_64),yes)
280 # YASM
281 $(BUILD_PFX)vpx_config.asm: $(BUILD_PFX)vpx_config.h
282         @echo "    [CREATE] $@"
283         @egrep "#define [A-Z0-9_]+ [01]" $< \
284             | awk '{print $$2 " equ " $$3}' > $@
285 else
286 ADS2GAS=$(if $(filter yes,$(CONFIG_GCC)),| $(ASM_CONVERSION))
287 $(BUILD_PFX)vpx_config.asm: $(BUILD_PFX)vpx_config.h
288         @echo "    [CREATE] $@"
289         @egrep "#define [A-Z0-9_]+ [01]" $< \
290             | awk '{print $$2 " EQU " $$3}' $(ADS2GAS) > $@
291         @echo "        END" $(ADS2GAS) >> $@
292 CLEAN-OBJS += $(BUILD_PFX)vpx_config.asm
293 endif
294
295 #
296 # Add assembler dependencies for configuration and offsets
297 #
298 $(filter %.s.o,$(OBJS-yes)):     $(BUILD_PFX)vpx_config.asm
299 $(filter %$(ASM).o,$(OBJS-yes)): $(BUILD_PFX)vpx_config.asm
300
301 #
302 # Calculate platform- and compiler-specific offsets for hand coded assembly
303 #
304
305 OFFSET_PATTERN:='^[a-zA-Z0-9_]* EQU'
306
307 ifeq ($(filter icc gcc,$(TGT_CC)), $(TGT_CC))
308     $(BUILD_PFX)asm_com_offsets.asm: $(BUILD_PFX)$(VP8_PREFIX)common/asm_com_offsets.c.S
309         @echo "    [CREATE] $@"
310         $(qexec)LC_ALL=C grep $(OFFSET_PATTERN) $< | tr -d '$$\#' $(ADS2GAS) > $@
311     $(BUILD_PFX)$(VP8_PREFIX)common/asm_com_offsets.c.S: $(VP8_PREFIX)common/asm_com_offsets.c
312     CLEAN-OBJS += $(BUILD_PFX)asm_com_offsets.asm $(BUILD_PFX)$(VP8_PREFIX)common/asm_com_offsets.c.S
313
314     $(BUILD_PFX)asm_enc_offsets.asm: $(BUILD_PFX)$(VP8_PREFIX)encoder/asm_enc_offsets.c.S
315         @echo "    [CREATE] $@"
316         $(qexec)LC_ALL=C grep $(OFFSET_PATTERN) $< | tr -d '$$\#' $(ADS2GAS) > $@
317     $(BUILD_PFX)$(VP8_PREFIX)encoder/asm_enc_offsets.c.S: $(VP8_PREFIX)encoder/asm_enc_offsets.c
318     CLEAN-OBJS += $(BUILD_PFX)asm_enc_offsets.asm $(BUILD_PFX)$(VP8_PREFIX)encoder/asm_enc_offsets.c.S
319
320     $(BUILD_PFX)asm_dec_offsets.asm: $(BUILD_PFX)$(VP8_PREFIX)decoder/asm_dec_offsets.c.S
321         @echo "    [CREATE] $@"
322         $(qexec)LC_ALL=C grep $(OFFSET_PATTERN) $< | tr -d '$$\#' $(ADS2GAS) > $@
323     $(BUILD_PFX)$(VP8_PREFIX)decoder/asm_dec_offsets.c.S: $(VP8_PREFIX)decoder/asm_dec_offsets.c
324     CLEAN-OBJS += $(BUILD_PFX)asm_dec_offsets.asm $(BUILD_PFX)$(VP8_PREFIX)decoder/asm_dec_offsets.c.S
325 else
326   ifeq ($(filter rvct,$(TGT_CC)), $(TGT_CC))
327     asm_com_offsets.asm: obj_int_extract
328     asm_com_offsets.asm: $(VP8_PREFIX)common/asm_com_offsets.c.o
329         @echo "    [CREATE] $@"
330         $(qexec)./obj_int_extract rvds $< $(ADS2GAS) > $@
331     OBJS-yes += $(VP8_PREFIX)common/asm_com_offsets.c.o
332     CLEAN-OBJS += asm_com_offsets.asm
333     $(filter %$(ASM).o,$(OBJS-yes)): $(BUILD_PFX)asm_com_offsets.asm
334
335     asm_enc_offsets.asm: obj_int_extract
336     asm_enc_offsets.asm: $(VP8_PREFIX)encoder/asm_enc_offsets.c.o
337         @echo "    [CREATE] $@"
338         $(qexec)./obj_int_extract rvds $< $(ADS2GAS) > $@
339     OBJS-yes += $(VP8_PREFIX)encoder/asm_enc_offsets.c.o
340     CLEAN-OBJS += asm_enc_offsets.asm
341     $(filter %$(ASM).o,$(OBJS-yes)): $(BUILD_PFX)asm_enc_offsets.asm
342
343     asm_dec_offsets.asm: obj_int_extract
344     asm_dec_offsets.asm: $(VP8_PREFIX)decoder/asm_dec_offsets.c.o
345         @echo "    [CREATE] $@"
346         $(qexec)./obj_int_extract rvds $< $(ADS2GAS) > $@
347     OBJS-yes += $(VP8_PREFIX)decoder/asm_dec_offsets.c.o
348     CLEAN-OBJS += asm_dec_offsets.asm
349     $(filter %$(ASM).o,$(OBJS-yes)): $(BUILD_PFX)asm_dec_offsets.asm
350   endif
351 endif
352
353 $(shell $(SRC_PATH_BARE)/build/make/version.sh "$(SRC_PATH_BARE)" $(BUILD_PFX)vpx_version.h)
354 CLEAN-OBJS += $(BUILD_PFX)vpx_version.h
355
356 #
357 # Rule to generate runtime cpu detection files
358 #
359 $(OBJS-yes:.o=.d): vpx_rtcd.h
360 vpx_rtcd.h: $(sort $(filter %rtcd_defs.sh,$(CODEC_SRCS)))
361         @echo "    [CREATE] $@"
362         $(qexec)$(SRC_PATH_BARE)/build/make/rtcd.sh --arch=$(TGT_ISA) \
363                   --sym=vpx_rtcd \
364                   --config=$(target)$(if $(FAT_ARCHS),,-$(TOOLCHAIN)).mk \
365                   $(RTCD_OPTIONS) $^ > $@
366 CLEAN-OBJS += $(BUILD_PFX)vpx_rtcd.h
367
368 CODEC_DOC_SRCS += vpx/vpx_codec.h \
369                   vpx/vpx_decoder.h \
370                   vpx/vpx_encoder.h \
371                   vpx/vpx_image.h
372
373 ##
374 ## libvpx test directives
375 ##
376
377 ifeq ($(CONFIG_UNIT_TESTS),yes)
378 LIBVPX_TEST_DATA_PATH ?= .
379
380 include $(SRC_PATH_BARE)/test/test.mk
381 LIBVPX_TEST_SRCS=$(addprefix test/,$(call enabled,LIBVPX_TEST_SRCS))
382 LIBVPX_TEST_BINS=./test_libvpx
383 LIBVPX_TEST_DATA=$(addprefix $(LIBVPX_TEST_DATA_PATH)/,\
384                      $(call enabled,LIBVPX_TEST_DATA))
385 libvpx_test_data_url=http://downloads.webmproject.org/test_data/libvpx/$(1)
386
387 $(LIBVPX_TEST_DATA):
388         @echo "    [DOWNLOAD] $@"
389         $(qexec)trap 'rm -f $@' INT TERM &&\
390             curl -L -o $@ $(call libvpx_test_data_url,$(@F))
391
392 testdata:: $(LIBVPX_TEST_DATA)
393         $(qexec)if [ -x "$$(which sha1sum)" ]; then\
394             echo "Checking test data:";\
395             (cd $(LIBVPX_TEST_DATA_PATH); sha1sum -c)\
396                 < $(SRC_PATH_BARE)/test/test-data.sha1; \
397         else\
398             echo "Skipping test data integrity check, sha1sum not found.";\
399         fi
400
401 ifeq ($(CONFIG_EXTERNAL_BUILD),yes)
402 ifeq ($(CONFIG_MSVS),yes)
403
404 gtest.vcproj: $(SRC_PATH_BARE)/third_party/googletest/src/src/gtest-all.cc
405         @echo "    [CREATE] $@"
406         $(SRC_PATH_BARE)/build/make/gen_msvs_proj.sh \
407             --lib \
408             --target=$(TOOLCHAIN) \
409             $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \
410             --name=gtest \
411             --proj-guid=EC00E1EC-AF68-4D92-A255-181690D1C9B1 \
412             --ver=$(CONFIG_VS_VERSION) \
413             --src-path-bare="$(SRC_PATH_BARE)" \
414             --out=gtest.vcproj $(SRC_PATH_BARE)/third_party/googletest/src/src/gtest-all.cc \
415             -I. -I"$(SRC_PATH_BARE)/third_party/googletest/src/include" -I"$(SRC_PATH_BARE)/third_party/googletest/src"
416
417 PROJECTS-$(CONFIG_MSVS) += gtest.vcproj
418
419 test_libvpx.vcproj: $(LIBVPX_TEST_SRCS)
420         @echo "    [CREATE] $@"
421         $(SRC_PATH_BARE)/build/make/gen_msvs_proj.sh \
422             --exe \
423             --target=$(TOOLCHAIN) \
424             --name=test_libvpx \
425             --proj-guid=CD837F5F-52D8-4314-A370-895D614166A7 \
426             --ver=$(CONFIG_VS_VERSION) \
427             $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \
428             --out=$@ $(INTERNAL_CFLAGS) $(CFLAGS) \
429             -I. -I"$(SRC_PATH_BARE)/third_party/googletest/src/include" \
430             -L. -l$(CODEC_LIB) -lwinmm -l$(GTEST_LIB) $^
431 ifeq ($(CONFIG_STATIC_MSVCRT),--static-crt)
432 lib_sfx=mt
433 else
434 lib_sfx=md
435 endif
436
437 define unit_test_vcproj_template
438 $(notdir $(1:.cc=.vcproj)): $(SRC_PATH_BARE)/$(1)
439         @echo "    [vcproj] $$@"
440         $$(SRC_PATH_BARE)/build/make/gen_msvs_proj.sh\
441             --exe\
442             --target=$$(TOOLCHAIN)\
443             --name=$(notdir $(1:.cc=))\
444             --ver=$$(CONFIG_VS_VERSION)\
445             $$(if $$(CONFIG_STATIC_MSVCRT),--static-crt) \
446             --out=$$@ $$(INTERNAL_CFLAGS) $$(CFLAGS) \
447             -I. -I"$(SRC_PATH_BARE)/third_party/googletest/src/include" \
448             -L. -lvpxmd -lwinmm -lgtest$(lib_sfx) $$^
449 endef
450
451 $(foreach proj,$(LIBVPX_TEST_BINS),\
452     $(eval $(call unit_test_vcproj_template,$(proj))))
453
454 PROJECTS-$(CONFIG_MSVS) += test_libvpx.vcproj
455
456 test:: testdata
457         @set -e; for t in $(addprefix Win32/Release/,$(notdir $(LIBVPX_TEST_BINS:.cc=.exe))); do $$t; done
458 endif
459 else
460
461 include $(SRC_PATH_BARE)/third_party/googletest/gtest.mk
462 GTEST_SRCS := $(addprefix third_party/googletest/src/,$(call enabled,GTEST_SRCS))
463 GTEST_OBJS=$(call objs,$(GTEST_SRCS))
464 $(GTEST_OBJS) $(GTEST_OBJS:.o=.d): CFLAGS += -I$(SRC_PATH_BARE)/third_party/googletest/src
465 $(GTEST_OBJS) $(GTEST_OBJS:.o=.d): CFLAGS += -I$(SRC_PATH_BARE)/third_party/googletest/src/include
466 OBJS-$(BUILD_LIBVPX) += $(GTEST_OBJS)
467 LIBS-$(BUILD_LIBVPX) += $(BUILD_PFX)libgtest.a $(BUILD_PFX)libgtest_g.a
468 $(BUILD_PFX)libgtest_g.a: $(GTEST_OBJS)
469
470 LIBVPX_TEST_OBJS=$(sort $(call objs,$(LIBVPX_TEST_SRCS)))
471 $(LIBVPX_TEST_OBJS) $(LIBVPX_TEST_OBJS:.o=.d): CFLAGS += -I$(SRC_PATH_BARE)/third_party/googletest/src
472 $(LIBVPX_TEST_OBJS) $(LIBVPX_TEST_OBJS:.o=.d): CFLAGS += -I$(SRC_PATH_BARE)/third_party/googletest/src/include
473 OBJS-$(BUILD_LIBVPX) += $(LIBVPX_TEST_OBJS)
474
475 # Install test sources only if codec source is included
476 INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(patsubst $(SRC_PATH_BARE)/%,%,\
477     $(shell find $(SRC_PATH_BARE)/third_party/googletest -type f))
478 INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(LIBVPX_TEST_SRCS)
479
480 $(foreach bin,$(LIBVPX_TEST_BINS),\
481     $(if $(BUILD_LIBVPX),$(eval $(bin): libvpx.a libgtest.a ))\
482     $(if $(BUILD_LIBVPX),$(eval $(call linkerxx_template,$(bin),\
483         $(LIBVPX_TEST_OBJS) \
484         -L. -lvpx -lgtest -lpthread -lm)\
485         )))\
486     $(if $(LIPO_LIBS),$(eval $(call lipo_bin_template,$(bin))))\
487
488 test:: $(LIBVPX_TEST_BINS) testdata
489         @set -e; for t in $(LIBVPX_TEST_BINS); do $$t; done
490
491 endif
492 endif
493
494 ##
495 ## documentation directives
496 ##
497 CLEAN-OBJS += libs.doxy
498 DOCS-yes += libs.doxy
499 libs.doxy: $(CODEC_DOC_SRCS)
500         @echo "    [CREATE] $@"
501         @rm -f $@
502         @echo "INPUT += $^" >> $@
503         @echo "PREDEFINED = VPX_CODEC_DISABLE_COMPAT" >> $@
504         @echo "INCLUDE_PATH += ." >> $@;
505         @echo "ENABLED_SECTIONS += $(sort $(CODEC_DOC_SECTIONS))" >> $@