Merge "fix denoiser for temporal patterns and rd"
[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' >> $@
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         LC_ALL=C grep $(OFFSET_PATTERN) $< | tr -d '$$\#' $(ADS2GAS) > $@
289     $(BUILD_PFX)$(VP8_PREFIX)common/asm_com_offsets.c.S: $(VP8_PREFIX)common/asm_com_offsets.c
290     CLEAN-OBJS += $(BUILD_PFX)asm_com_offsets.asm $(BUILD_PFX)$(VP8_PREFIX)common/asm_com_offsets.c.S
291
292     $(BUILD_PFX)asm_enc_offsets.asm: $(BUILD_PFX)$(VP8_PREFIX)encoder/asm_enc_offsets.c.S
293         LC_ALL=C grep $(OFFSET_PATTERN) $< | tr -d '$$\#' $(ADS2GAS) > $@
294     $(BUILD_PFX)$(VP8_PREFIX)encoder/asm_enc_offsets.c.S: $(VP8_PREFIX)encoder/asm_enc_offsets.c
295     CLEAN-OBJS += $(BUILD_PFX)asm_enc_offsets.asm $(BUILD_PFX)$(VP8_PREFIX)encoder/asm_enc_offsets.c.S
296
297     $(BUILD_PFX)asm_dec_offsets.asm: $(BUILD_PFX)$(VP8_PREFIX)decoder/asm_dec_offsets.c.S
298         LC_ALL=C grep $(OFFSET_PATTERN) $< | tr -d '$$\#' $(ADS2GAS) > $@
299     $(BUILD_PFX)$(VP8_PREFIX)decoder/asm_dec_offsets.c.S: $(VP8_PREFIX)decoder/asm_dec_offsets.c
300     CLEAN-OBJS += $(BUILD_PFX)asm_dec_offsets.asm $(BUILD_PFX)$(VP8_PREFIX)decoder/asm_dec_offsets.c.S
301 else
302   ifeq ($(filter rvct,$(TGT_CC)), $(TGT_CC))
303     asm_com_offsets.asm: obj_int_extract
304     asm_com_offsets.asm: $(VP8_PREFIX)common/asm_com_offsets.c.o
305         ./obj_int_extract rvds $< $(ADS2GAS) > $@
306     OBJS-yes += $(VP8_PREFIX)common/asm_com_offsets.c.o
307     CLEAN-OBJS += asm_com_offsets.asm
308     $(filter %$(ASM).o,$(OBJS-yes)): $(BUILD_PFX)asm_com_offsets.asm
309
310     asm_enc_offsets.asm: obj_int_extract
311     asm_enc_offsets.asm: $(VP8_PREFIX)encoder/asm_enc_offsets.c.o
312         ./obj_int_extract rvds $< $(ADS2GAS) > $@
313     OBJS-yes += $(VP8_PREFIX)encoder/asm_enc_offsets.c.o
314     CLEAN-OBJS += asm_enc_offsets.asm
315     $(filter %$(ASM).o,$(OBJS-yes)): $(BUILD_PFX)asm_enc_offsets.asm
316
317     asm_dec_offsets.asm: obj_int_extract
318     asm_dec_offsets.asm: $(VP8_PREFIX)decoder/asm_dec_offsets.c.o
319         ./obj_int_extract rvds $< $(ADS2GAS) > $@
320     OBJS-yes += $(VP8_PREFIX)decoder/asm_dec_offsets.c.o
321     CLEAN-OBJS += asm_dec_offsets.asm
322     $(filter %$(ASM).o,$(OBJS-yes)): $(BUILD_PFX)asm_dec_offsets.asm
323   endif
324 endif
325
326 $(shell $(SRC_PATH_BARE)/build/make/version.sh "$(SRC_PATH_BARE)" $(BUILD_PFX)vpx_version.h)
327 CLEAN-OBJS += $(BUILD_PFX)vpx_version.h
328
329 #
330 # Rule to generate runtime cpu detection files
331 #
332 $(BUILD_PFX)vpx_rtcd.h: $(SRC_PATH_BARE)/$(sort $(filter %rtcd_defs.sh,$(CODEC_SRCS)))
333         @echo "    [CREATE] $@"
334         $(qexec)$(SRC_PATH_BARE)/build/make/rtcd.sh --arch=$(TGT_ISA) \
335           --sym=vpx_rtcd \
336           --config=$(target)$(if $(FAT_ARCHS),,-$(TOOLCHAIN)).mk \
337           $(RTCD_OPTIONS) $^ > $@
338 CLEAN-OBJS += $(BUILD_PFX)vpx_rtcd.h
339
340 CODEC_DOC_SRCS += vpx/vpx_codec.h \
341                   vpx/vpx_decoder.h \
342                   vpx/vpx_encoder.h \
343                   vpx/vpx_image.h
344
345 ##
346 ## libvpx test directives
347 ##
348 ifeq ($(CONFIG_UNIT_TESTS),yes)
349
350 include $(SRC_PATH_BARE)/test/test.mk
351 LIBVPX_TEST_SRCS=$(addprefix test/,$(call enabled,LIBVPX_TEST_SRCS))
352 LIBVPX_TEST_BINS=./test_libvpx
353
354 ifeq ($(CONFIG_EXTERNAL_BUILD),yes)
355 ifeq ($(CONFIG_MSVS),yes)
356
357 gtest.vcproj: $(SRC_PATH_BARE)/third_party/googletest/src/src/gtest-all.cc
358         @echo "    [CREATE] $@"
359         $(SRC_PATH_BARE)/build/make/gen_msvs_proj.sh \
360             --lib \
361             --target=$(TOOLCHAIN) \
362             $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \
363             --name=gtest \
364             --proj-guid=EC00E1EC-AF68-4D92-A255-181690D1C9B1 \
365             --ver=$(CONFIG_VS_VERSION) \
366             --src-path-bare="$(SRC_PATH_BARE)" \
367             --out=gtest.vcproj $(SRC_PATH_BARE)/third_party/googletest/src/src/gtest-all.cc \
368             -I. -I"$(SRC_PATH_BARE)/third_party/googletest/src/include" -I"$(SRC_PATH_BARE)/third_party/googletest/src"
369
370 PROJECTS-$(CONFIG_MSVS) += gtest.vcproj
371
372 define unit_test_vcproj_template
373 $(notdir $(1:.cc=.vcproj)): $(SRC_PATH_BARE)/$(1)
374         @echo "    [vcproj] $$@"
375         $$(SRC_PATH_BARE)/build/make/gen_msvs_proj.sh\
376             --exe\
377             --target=$$(TOOLCHAIN)\
378             --name=$(notdir $(1:.cc=))\
379             --ver=$$(CONFIG_VS_VERSION)\
380             $$(if $$(CONFIG_STATIC_MSVCRT),--static-crt) \
381             --out=$$@ $$(INTERNAL_CFLAGS) $$(CFLAGS) \
382             -I. -I"$(SRC_PATH_BARE)/third_party/googletest/src/include" \
383             -L. -l$(CODEC_LIB) -lwinmm -l$(GTEST_LIB) $$^
384 endef
385
386 $(foreach proj,$(LIBVPX_TEST_BINS),\
387     $(eval $(call unit_test_vcproj_template,$(proj))))
388
389 PROJECTS-$(CONFIG_MSVS) += $(foreach proj,$(LIBVPX_TEST_BINS),\
390      $(notdir $(proj:.cc=.vcproj)))
391
392 test::
393         @set -e; for t in $(addprefix Win32/Release/,$(notdir $(LIBVPX_TEST_BINS:.cc=.exe))); do $$t; done
394 endif
395 else
396
397 include $(SRC_PATH_BARE)/third_party/googletest/gtest.mk
398 GTEST_SRCS := $(addprefix third_party/googletest/src/,$(call enabled,GTEST_SRCS))
399 GTEST_OBJS=$(call objs,$(GTEST_SRCS))
400 $(GTEST_OBJS) $(GTEST_OBJS:.o=.d): CXXFLAGS += -I$(SRC_PATH_BARE)/third_party/googletest/src
401 $(GTEST_OBJS) $(GTEST_OBJS:.o=.d): CXXFLAGS += -I$(SRC_PATH_BARE)/third_party/googletest/src/include
402 OBJS-$(BUILD_LIBVPX) += $(GTEST_OBJS)
403 LIBS-$(BUILD_LIBVPX) += $(BUILD_PFX)libgtest.a $(BUILD_PFX)libgtest_g.a
404 $(BUILD_PFX)libgtest_g.a: $(GTEST_OBJS)
405
406 LIBVPX_TEST_OBJS=$(sort $(call objs,$(LIBVPX_TEST_SRCS)))
407 $(LIBVPX_TEST_OBJS) $(LIBVPX_TEST_OBJS:.o=.d): CXXFLAGS += -I$(SRC_PATH_BARE)/third_party/googletest/src
408 $(LIBVPX_TEST_OBJS) $(LIBVPX_TEST_OBJS:.o=.d): CXXFLAGS += -I$(SRC_PATH_BARE)/third_party/googletest/src/include
409 OBJS-$(BUILD_LIBVPX) += $(LIBVPX_TEST_OBJS)
410
411 # Install test sources only if codec source is included
412 INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(patsubst $(SRC_PATH_BARE)/%,%,\
413     $(shell find $(SRC_PATH_BARE)/third_party/googletest -type f))
414 INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(LIBVPX_TEST_SRCS)
415
416 $(foreach bin,$(LIBVPX_TEST_BINS),\
417     $(if $(BUILD_LIBVPX),$(eval $(bin): libvpx.a libgtest.a ))\
418     $(if $(BUILD_LIBVPX),$(eval $(call linkerxx_template,$(bin),\
419         $(LIBVPX_TEST_OBJS) \
420         -L. -lvpx -lgtest -lpthread -lm)\
421         )))\
422     $(if $(LIPO_LIBS),$(eval $(call lipo_bin_template,$(bin))))\
423
424 test:: $(LIBVPX_TEST_BINS)
425         @set -e; for t in $(LIBVPX_TEST_BINS); do $$t; done
426
427 endif
428 endif
429
430 ##
431 ## documentation directives
432 ##
433 CLEAN-OBJS += libs.doxy
434 DOCS-yes += libs.doxy
435 libs.doxy: $(CODEC_DOC_SRCS)
436         @echo "    [CREATE] $@"
437         @rm -f $@
438         @echo "INPUT += $^" >> $@
439         @echo "PREDEFINED = VPX_CODEC_DISABLE_COMPAT" >> $@
440         @echo "INCLUDE_PATH += ." >> $@;
441         @echo "ENABLED_SECTIONS += $(sort $(CODEC_DOC_SECTIONS))" >> $@
442
443 ## Generate vpx_rtcd.h for all objects
444 $(OBJS-yes:.o=.d): $(BUILD_PFX)vpx_rtcd.h