Require an --experimental-bitstream flag at runtime for encoding profile 1.
[aom.git] / libs.mk
blobeac61f289faf7a678632c9ffd3c4e2c4f0e5d232
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 # Calculate platform- and compiler-specific offsets for hand coded assembly
23 ifeq ($(filter icc gcc,$(TGT_CC)), $(TGT_CC))
24 OFFSET_PATTERN:='^[a-zA-Z0-9_]* EQU'
25 define asm_offsets_template
26 $$(BUILD_PFX)$(1): $$(BUILD_PFX)$(2).S
27 @echo " [CREATE] $$@"
28 $$(qexec)LC_ALL=C grep $$(OFFSET_PATTERN) $$< | tr -d '$$$$\#' $$(ADS2GAS) > $$@
29 $$(BUILD_PFX)$(2).S: $(2)
30 CLEAN-OBJS += $$(BUILD_PFX)$(1) $(2).S
31 endef
32 else
33 ifeq ($(filter rvct,$(TGT_CC)), $(TGT_CC))
34 define asm_offsets_template
35 $$(BUILD_PFX)$(1): obj_int_extract
36 $$(BUILD_PFX)$(1): $$(BUILD_PFX)$(2).o
37 @echo " [CREATE] $$@"
38 $$(qexec)./obj_int_extract rvds $$< $$(ADS2GAS) > $$@
39 OBJS-yes += $$(BUILD_PFX)$(2).o
40 CLEAN-OBJS += $$(BUILD_PFX)$(1)
41 $$(filter %$$(ASM).o,$$(OBJS-yes)): $$(BUILD_PFX)$(1)
42 endef
43 endif # rvct
44 endif # !gcc
47 # Rule to generate runtime cpu detection files
49 define rtcd_h_template
50 $$(BUILD_PFX)$(1).h: $$(SRC_PATH_BARE)/$(2)
51 @echo " [CREATE] $$@"
52 $$(qexec)$$(SRC_PATH_BARE)/build/make/rtcd.sh --arch=$$(TGT_ISA) \
53 --sym=$(1) \
54 --config=$$(CONFIG_DIR)$$(target)$$(if $$(FAT_ARCHS),,-$$(TOOLCHAIN)).mk \
55 $$(RTCD_OPTIONS) $$^ > $$@
56 CLEAN-OBJS += $$(BUILD_PFX)$(1).h
57 RTCD += $$(BUILD_PFX)$(1).h
58 endef
60 CODEC_SRCS-yes += CHANGELOG
61 CODEC_SRCS-yes += libs.mk
63 # If this is a universal (fat) binary, then all the subarchitectures have
64 # already been built and our job is to stitch them together. The
65 # BUILD_LIBVPX variable indicates whether we should be building
66 # (compiling, linking) the library. The LIPO_LIBVPX variable indicates
67 # that we're stitching.
68 $(eval $(if $(filter universal%,$(TOOLCHAIN)),LIPO_LIBVPX,BUILD_LIBVPX):=yes)
70 include $(SRC_PATH_BARE)/vpx/vpx_codec.mk
71 CODEC_SRCS-yes += $(addprefix vpx/,$(call enabled,API_SRCS))
72 CODEC_DOC_SRCS += $(addprefix vpx/,$(call enabled,API_DOC_SRCS))
74 include $(SRC_PATH_BARE)/vpx_mem/vpx_mem.mk
75 CODEC_SRCS-yes += $(addprefix vpx_mem/,$(call enabled,MEM_SRCS))
77 include $(SRC_PATH_BARE)/vpx_scale/vpx_scale.mk
78 CODEC_SRCS-yes += $(addprefix vpx_scale/,$(call enabled,SCALE_SRCS))
80 include $(SRC_PATH_BARE)/vpx_ports/vpx_ports.mk
81 CODEC_SRCS-yes += $(addprefix vpx_ports/,$(call enabled,PORTS_SRCS))
83 ifneq ($(CONFIG_VP8_ENCODER)$(CONFIG_VP8_DECODER),)
84 VP8_PREFIX=vp8/
85 include $(SRC_PATH_BARE)/$(VP8_PREFIX)vp8_common.mk
86 endif
88 ifeq ($(CONFIG_VP8_ENCODER),yes)
89 include $(SRC_PATH_BARE)/$(VP8_PREFIX)vp8cx.mk
90 CODEC_SRCS-yes += $(addprefix $(VP8_PREFIX),$(call enabled,VP8_CX_SRCS))
91 CODEC_EXPORTS-yes += $(addprefix $(VP8_PREFIX),$(VP8_CX_EXPORTS))
92 INSTALL-LIBS-yes += include/vpx/vp8.h include/vpx/vp8cx.h
93 INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/$(VP8_PREFIX)/%
94 CODEC_DOC_SECTIONS += vp8 vp8_encoder
95 endif
97 ifeq ($(CONFIG_VP8_DECODER),yes)
98 include $(SRC_PATH_BARE)/$(VP8_PREFIX)vp8dx.mk
99 CODEC_SRCS-yes += $(addprefix $(VP8_PREFIX),$(call enabled,VP8_DX_SRCS))
100 CODEC_EXPORTS-yes += $(addprefix $(VP8_PREFIX),$(VP8_DX_EXPORTS))
101 INSTALL-LIBS-yes += include/vpx/vp8.h include/vpx/vp8dx.h
102 INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/$(VP8_PREFIX)/%
103 CODEC_DOC_SECTIONS += vp8 vp8_decoder
104 endif
106 ifneq ($(CONFIG_VP9_ENCODER)$(CONFIG_VP9_DECODER),)
107 VP9_PREFIX=vp9/
108 include $(SRC_PATH_BARE)/$(VP9_PREFIX)vp9_common.mk
109 endif
111 ifeq ($(CONFIG_VP9_ENCODER),yes)
112 VP9_PREFIX=vp9/
113 include $(SRC_PATH_BARE)/$(VP9_PREFIX)vp9cx.mk
114 CODEC_SRCS-yes += $(addprefix $(VP9_PREFIX),$(call enabled,VP9_CX_SRCS))
115 CODEC_EXPORTS-yes += $(addprefix $(VP9_PREFIX),$(VP9_CX_EXPORTS))
116 CODEC_SRCS-yes += $(VP9_PREFIX)vp9cx.mk vpx/vp8.h vpx/vp8cx.h
117 INSTALL-LIBS-yes += include/vpx/vp8.h include/vpx/vp8cx.h
118 INSTALL-LIBS-yes += include/vpx/svc_context.h
119 INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/$(VP9_PREFIX)/%
120 CODEC_DOC_SRCS += vpx/vp8.h vpx/vp8cx.h
121 CODEC_DOC_SECTIONS += vp9 vp9_encoder
122 endif
124 ifeq ($(CONFIG_VP9_DECODER),yes)
125 VP9_PREFIX=vp9/
126 include $(SRC_PATH_BARE)/$(VP9_PREFIX)vp9dx.mk
127 CODEC_SRCS-yes += $(addprefix $(VP9_PREFIX),$(call enabled,VP9_DX_SRCS))
128 CODEC_EXPORTS-yes += $(addprefix $(VP9_PREFIX),$(VP9_DX_EXPORTS))
129 CODEC_SRCS-yes += $(VP9_PREFIX)vp9dx.mk vpx/vp8.h vpx/vp8dx.h
130 INSTALL-LIBS-yes += include/vpx/vp8.h include/vpx/vp8dx.h
131 INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/$(VP9_PREFIX)/%
132 CODEC_DOC_SRCS += vpx/vp8.h vpx/vp8dx.h
133 CODEC_DOC_SECTIONS += vp9 vp9_decoder
134 endif
137 ifeq ($(CONFIG_ENCODERS),yes)
138 CODEC_DOC_SECTIONS += encoder
139 endif
140 ifeq ($(CONFIG_DECODERS),yes)
141 CODEC_DOC_SECTIONS += decoder
142 endif
145 ifeq ($(CONFIG_MSVS),yes)
146 CODEC_LIB=$(if $(CONFIG_STATIC_MSVCRT),vpxmt,vpxmd)
147 GTEST_LIB=$(if $(CONFIG_STATIC_MSVCRT),gtestmt,gtestmd)
148 # This variable uses deferred expansion intentionally, since the results of
149 # $(wildcard) may change during the course of the Make.
150 VS_PLATFORMS = $(foreach d,$(wildcard */Release/$(CODEC_LIB).lib),$(word 1,$(subst /, ,$(d))))
151 endif
153 # The following pairs define a mapping of locations in the distribution
154 # tree to locations in the source/build trees.
155 INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/vpx/%
156 INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/vpx_ports/%
157 INSTALL_MAPS += $(LIBSUBDIR)/% %
158 INSTALL_MAPS += src/% $(SRC_PATH_BARE)/%
159 ifeq ($(CONFIG_MSVS),yes)
160 INSTALL_MAPS += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/% $(p)/Release/%)
161 INSTALL_MAPS += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/% $(p)/Debug/%)
162 endif
164 CODEC_SRCS-$(BUILD_LIBVPX) += build/make/version.sh
165 CODEC_SRCS-$(BUILD_LIBVPX) += build/make/rtcd.sh
166 CODEC_SRCS-$(BUILD_LIBVPX) += vpx_ports/emmintrin_compat.h
167 CODEC_SRCS-$(BUILD_LIBVPX) += vpx_ports/vpx_once.h
168 CODEC_SRCS-$(BUILD_LIBVPX) += $(BUILD_PFX)vpx_config.c
169 INSTALL-SRCS-no += $(BUILD_PFX)vpx_config.c
170 ifeq ($(ARCH_X86)$(ARCH_X86_64),yes)
171 CODEC_SRCS-$(BUILD_LIBVPX) += third_party/x86inc/x86inc.asm
172 endif
173 CODEC_EXPORTS-$(BUILD_LIBVPX) += vpx/exports_com
174 CODEC_EXPORTS-$(CONFIG_ENCODERS) += vpx/exports_enc
175 CODEC_EXPORTS-$(CONFIG_DECODERS) += vpx/exports_dec
177 INSTALL-LIBS-yes += include/vpx/vpx_codec.h
178 INSTALL-LIBS-yes += include/vpx/vpx_frame_buffer.h
179 INSTALL-LIBS-yes += include/vpx/vpx_image.h
180 INSTALL-LIBS-yes += include/vpx/vpx_integer.h
181 INSTALL-LIBS-$(CONFIG_DECODERS) += include/vpx/vpx_decoder.h
182 INSTALL-LIBS-$(CONFIG_ENCODERS) += include/vpx/vpx_encoder.h
183 ifeq ($(CONFIG_EXTERNAL_BUILD),yes)
184 ifeq ($(CONFIG_MSVS),yes)
185 INSTALL-LIBS-yes += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/$(CODEC_LIB).lib)
186 INSTALL-LIBS-$(CONFIG_DEBUG_LIBS) += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/$(CODEC_LIB)d.lib)
187 INSTALL-LIBS-$(CONFIG_SHARED) += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/vpx.dll)
188 INSTALL-LIBS-$(CONFIG_SHARED) += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/vpx.exp)
189 endif
190 else
191 INSTALL-LIBS-$(CONFIG_STATIC) += $(LIBSUBDIR)/libvpx.a
192 INSTALL-LIBS-$(CONFIG_DEBUG_LIBS) += $(LIBSUBDIR)/libvpx_g.a
193 endif
195 CODEC_SRCS=$(call enabled,CODEC_SRCS)
196 INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(CODEC_SRCS)
197 INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(call enabled,CODEC_EXPORTS)
200 # Generate a list of all enabled sources, in particular for exporting to gyp
201 # based build systems.
202 libvpx_srcs.txt:
203 @echo " [CREATE] $@"
204 @echo $(CODEC_SRCS) | xargs -n1 echo | sort -u > $@
205 CLEAN-OBJS += libvpx_srcs.txt
208 ifeq ($(CONFIG_EXTERNAL_BUILD),yes)
209 ifeq ($(CONFIG_MSVS),yes)
211 obj_int_extract.bat: $(SRC_PATH_BARE)/build/$(MSVS_ARCH_DIR)/obj_int_extract.bat
212 @cp $^ $@
214 obj_int_extract.$(VCPROJ_SFX): obj_int_extract.bat
215 obj_int_extract.$(VCPROJ_SFX): $(SRC_PATH_BARE)/build/make/obj_int_extract.c
216 @echo " [CREATE] $@"
217 $(qexec)$(GEN_VCPROJ) \
218 --exe \
219 --target=$(TOOLCHAIN) \
220 --name=obj_int_extract \
221 --ver=$(CONFIG_VS_VERSION) \
222 --proj-guid=E1360C65-D375-4335-8057-7ED99CC3F9B2 \
223 $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \
224 --out=$@ $^ \
225 -I. \
226 -I"$(SRC_PATH_BARE)" \
228 PROJECTS-$(BUILD_LIBVPX) += obj_int_extract.$(VCPROJ_SFX)
230 vpx.def: $(call enabled,CODEC_EXPORTS)
231 @echo " [CREATE] $@"
232 $(qexec)$(SRC_PATH_BARE)/build/make/gen_msvs_def.sh\
233 --name=vpx\
234 --out=$@ $^
235 CLEAN-OBJS += vpx.def
237 vpx.$(VCPROJ_SFX): $(CODEC_SRCS) vpx.def obj_int_extract.$(VCPROJ_SFX)
238 @echo " [CREATE] $@"
239 $(qexec)$(GEN_VCPROJ) \
240 $(if $(CONFIG_SHARED),--dll,--lib) \
241 --target=$(TOOLCHAIN) \
242 $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \
243 --name=vpx \
244 --proj-guid=DCE19DAF-69AC-46DB-B14A-39F0FAA5DB74 \
245 --module-def=vpx.def \
246 --ver=$(CONFIG_VS_VERSION) \
247 --out=$@ $(CFLAGS) $^ \
248 --src-path-bare="$(SRC_PATH_BARE)" \
250 PROJECTS-$(BUILD_LIBVPX) += vpx.$(VCPROJ_SFX)
252 vpx.$(VCPROJ_SFX): vpx_config.asm
253 vpx.$(VCPROJ_SFX): $(RTCD)
255 endif
256 else
257 LIBVPX_OBJS=$(call objs,$(CODEC_SRCS))
258 OBJS-$(BUILD_LIBVPX) += $(LIBVPX_OBJS)
259 LIBS-$(if $(BUILD_LIBVPX),$(CONFIG_STATIC)) += $(BUILD_PFX)libvpx.a $(BUILD_PFX)libvpx_g.a
260 $(BUILD_PFX)libvpx_g.a: $(LIBVPX_OBJS)
263 BUILD_LIBVPX_SO := $(if $(BUILD_LIBVPX),$(CONFIG_SHARED))
265 ifeq ($(filter darwin%,$(TGT_OS)),$(TGT_OS))
266 LIBVPX_SO := libvpx.$(VERSION_MAJOR).dylib
267 EXPORT_FILE := libvpx.syms
268 LIBVPX_SO_SYMLINKS := $(addprefix $(LIBSUBDIR)/, \
269 libvpx.dylib )
270 else
271 LIBVPX_SO := libvpx.so.$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH)
272 EXPORT_FILE := libvpx.ver
273 SYM_LINK := libvpx.so
274 LIBVPX_SO_SYMLINKS := $(addprefix $(LIBSUBDIR)/, \
275 libvpx.so libvpx.so.$(VERSION_MAJOR) \
276 libvpx.so.$(VERSION_MAJOR).$(VERSION_MINOR))
277 endif
279 LIBS-$(BUILD_LIBVPX_SO) += $(BUILD_PFX)$(LIBVPX_SO)\
280 $(notdir $(LIBVPX_SO_SYMLINKS))
281 $(BUILD_PFX)$(LIBVPX_SO): $(LIBVPX_OBJS) $(EXPORT_FILE)
282 $(BUILD_PFX)$(LIBVPX_SO): extralibs += -lm
283 $(BUILD_PFX)$(LIBVPX_SO): SONAME = libvpx.so.$(VERSION_MAJOR)
284 $(BUILD_PFX)$(LIBVPX_SO): EXPORTS_FILE = $(EXPORT_FILE)
286 libvpx.ver: $(call enabled,CODEC_EXPORTS)
287 @echo " [CREATE] $@"
288 $(qexec)echo "{ global:" > $@
289 $(qexec)for f in $?; do awk '{print $$2";"}' < $$f >>$@; done
290 $(qexec)echo "local: *; };" >> $@
291 CLEAN-OBJS += libvpx.ver
293 libvpx.syms: $(call enabled,CODEC_EXPORTS)
294 @echo " [CREATE] $@"
295 $(qexec)awk '{print "_"$$2}' $^ >$@
296 CLEAN-OBJS += libvpx.syms
298 define libvpx_symlink_template
299 $(1): $(2)
300 @echo " [LN] $(2) $$@"
301 $(qexec)mkdir -p $$(dir $$@)
302 $(qexec)ln -sf $(2) $$@
303 endef
305 $(eval $(call libvpx_symlink_template,\
306 $(addprefix $(BUILD_PFX),$(notdir $(LIBVPX_SO_SYMLINKS))),\
307 $(BUILD_PFX)$(LIBVPX_SO)))
308 $(eval $(call libvpx_symlink_template,\
309 $(addprefix $(DIST_DIR)/,$(LIBVPX_SO_SYMLINKS)),\
310 $(LIBVPX_SO)))
313 INSTALL-LIBS-$(BUILD_LIBVPX_SO) += $(LIBVPX_SO_SYMLINKS)
314 INSTALL-LIBS-$(BUILD_LIBVPX_SO) += $(LIBSUBDIR)/$(LIBVPX_SO)
317 LIBS-$(BUILD_LIBVPX) += vpx.pc
318 vpx.pc: config.mk libs.mk
319 @echo " [CREATE] $@"
320 $(qexec)echo '# pkg-config file from libvpx $(VERSION_STRING)' > $@
321 $(qexec)echo 'prefix=$(PREFIX)' >> $@
322 $(qexec)echo 'exec_prefix=$${prefix}' >> $@
323 $(qexec)echo 'libdir=$${prefix}/$(LIBSUBDIR)' >> $@
324 $(qexec)echo 'includedir=$${prefix}/include' >> $@
325 $(qexec)echo '' >> $@
326 $(qexec)echo 'Name: vpx' >> $@
327 $(qexec)echo 'Description: WebM Project VPx codec implementation' >> $@
328 $(qexec)echo 'Version: $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH)' >> $@
329 $(qexec)echo 'Requires:' >> $@
330 $(qexec)echo 'Conflicts:' >> $@
331 $(qexec)echo 'Libs: -L$${libdir} -lvpx -lm' >> $@
332 ifeq ($(HAVE_PTHREAD_H),yes)
333 $(qexec)echo 'Libs.private: -lm -lpthread' >> $@
334 else
335 $(qexec)echo 'Libs.private: -lm' >> $@
336 endif
337 $(qexec)echo 'Cflags: -I$${includedir}' >> $@
338 INSTALL-LIBS-yes += $(LIBSUBDIR)/pkgconfig/vpx.pc
339 INSTALL_MAPS += $(LIBSUBDIR)/pkgconfig/%.pc %.pc
340 CLEAN-OBJS += vpx.pc
341 endif
343 LIBS-$(LIPO_LIBVPX) += libvpx.a
344 $(eval $(if $(LIPO_LIBVPX),$(call lipo_lib_template,libvpx.a)))
347 # Rule to make assembler configuration file from C configuration file
349 ifeq ($(ARCH_X86)$(ARCH_X86_64),yes)
350 # YASM
351 $(BUILD_PFX)vpx_config.asm: $(BUILD_PFX)vpx_config.h
352 @echo " [CREATE] $@"
353 @egrep "#define [A-Z0-9_]+ [01]" $< \
354 | awk '{print $$2 " equ " $$3}' > $@
355 else
356 ADS2GAS=$(if $(filter yes,$(CONFIG_GCC)),| $(ASM_CONVERSION))
357 $(BUILD_PFX)vpx_config.asm: $(BUILD_PFX)vpx_config.h
358 @echo " [CREATE] $@"
359 @egrep "#define [A-Z0-9_]+ [01]" $< \
360 | awk '{print $$2 " EQU " $$3}' $(ADS2GAS) > $@
361 @echo " END" $(ADS2GAS) >> $@
362 CLEAN-OBJS += $(BUILD_PFX)vpx_config.asm
363 endif
366 # Add assembler dependencies for configuration and offsets
368 $(filter %.s.o,$(OBJS-yes)): $(BUILD_PFX)vpx_config.asm
369 $(filter %$(ASM).o,$(OBJS-yes)): $(BUILD_PFX)vpx_config.asm
372 $(shell $(SRC_PATH_BARE)/build/make/version.sh "$(SRC_PATH_BARE)" $(BUILD_PFX)vpx_version.h)
373 CLEAN-OBJS += $(BUILD_PFX)vpx_version.h
377 ## libvpx test directives
379 ifeq ($(CONFIG_UNIT_TESTS),yes)
380 LIBVPX_TEST_DATA_PATH ?= .
382 include $(SRC_PATH_BARE)/test/test.mk
383 LIBVPX_TEST_SRCS=$(addprefix test/,$(call enabled,LIBVPX_TEST_SRCS))
384 LIBVPX_TEST_BINS=./test_libvpx$(EXE_SFX)
385 LIBVPX_TEST_DATA=$(addprefix $(LIBVPX_TEST_DATA_PATH)/,\
386 $(call enabled,LIBVPX_TEST_DATA))
387 libvpx_test_data_url=http://downloads.webmproject.org/test_data/libvpx/$(1)
389 libvpx_test_srcs.txt:
390 @echo " [CREATE] $@"
391 @echo $(LIBVPX_TEST_SRCS) | xargs -n1 echo | sort -u > $@
392 CLEAN-OBJS += libvpx_test_srcs.txt
394 $(LIBVPX_TEST_DATA): $(SRC_PATH_BARE)/test/test-data.sha1
395 @echo " [DOWNLOAD] $@"
396 $(qexec)trap 'rm -f $@' INT TERM &&\
397 curl -L -o $@ $(call libvpx_test_data_url,$(@F))
399 testdata:: $(LIBVPX_TEST_DATA)
400 $(qexec)if [ -x "$$(which sha1sum)" ]; then\
401 echo "Checking test data:";\
402 if [ -n "$(LIBVPX_TEST_DATA)" ]; then\
403 for f in $(call enabled,LIBVPX_TEST_DATA); do\
404 grep $$f $(SRC_PATH_BARE)/test/test-data.sha1 |\
405 (cd $(LIBVPX_TEST_DATA_PATH); sha1sum -c);\
406 done; \
407 fi; \
408 else\
409 echo "Skipping test data integrity check, sha1sum not found.";\
412 ifeq ($(CONFIG_EXTERNAL_BUILD),yes)
413 ifeq ($(CONFIG_MSVS),yes)
415 gtest.$(VCPROJ_SFX): $(SRC_PATH_BARE)/third_party/googletest/src/src/gtest-all.cc
416 @echo " [CREATE] $@"
417 $(qexec)$(GEN_VCPROJ) \
418 --lib \
419 --target=$(TOOLCHAIN) \
420 $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \
421 --name=gtest \
422 --proj-guid=EC00E1EC-AF68-4D92-A255-181690D1C9B1 \
423 --ver=$(CONFIG_VS_VERSION) \
424 --src-path-bare="$(SRC_PATH_BARE)" \
425 -D_VARIADIC_MAX=10 \
426 --out=gtest.$(VCPROJ_SFX) $(SRC_PATH_BARE)/third_party/googletest/src/src/gtest-all.cc \
427 -I. -I"$(SRC_PATH_BARE)/third_party/googletest/src/include" -I"$(SRC_PATH_BARE)/third_party/googletest/src"
429 PROJECTS-$(CONFIG_MSVS) += gtest.$(VCPROJ_SFX)
431 test_libvpx.$(VCPROJ_SFX): $(LIBVPX_TEST_SRCS) vpx.$(VCPROJ_SFX) gtest.$(VCPROJ_SFX)
432 @echo " [CREATE] $@"
433 $(qexec)$(GEN_VCPROJ) \
434 --exe \
435 --target=$(TOOLCHAIN) \
436 --name=test_libvpx \
437 -D_VARIADIC_MAX=10 \
438 --proj-guid=CD837F5F-52D8-4314-A370-895D614166A7 \
439 --ver=$(CONFIG_VS_VERSION) \
440 $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \
441 --out=$@ $(INTERNAL_CFLAGS) $(CFLAGS) \
442 -I. -I"$(SRC_PATH_BARE)/third_party/googletest/src/include" \
443 -L. -l$(CODEC_LIB) -l$(GTEST_LIB) $^
445 PROJECTS-$(CONFIG_MSVS) += test_libvpx.$(VCPROJ_SFX)
447 LIBVPX_TEST_BINS := $(addprefix $(TGT_OS:win64=x64)/Release/,$(notdir $(LIBVPX_TEST_BINS)))
448 endif
449 else
451 include $(SRC_PATH_BARE)/third_party/googletest/gtest.mk
452 GTEST_SRCS := $(addprefix third_party/googletest/src/,$(call enabled,GTEST_SRCS))
453 GTEST_OBJS=$(call objs,$(GTEST_SRCS))
454 ifeq ($(filter win%,$(TGT_OS)),$(TGT_OS))
455 # Disabling pthreads globally will cause issues on darwin and possibly elsewhere
456 $(GTEST_OBJS) $(GTEST_OBJS:.o=.d): CXXFLAGS += -DGTEST_HAS_PTHREAD=0
457 endif
458 $(GTEST_OBJS) $(GTEST_OBJS:.o=.d): CXXFLAGS += -I$(SRC_PATH_BARE)/third_party/googletest/src
459 $(GTEST_OBJS) $(GTEST_OBJS:.o=.d): CXXFLAGS += -I$(SRC_PATH_BARE)/third_party/googletest/src/include
460 OBJS-$(BUILD_LIBVPX) += $(GTEST_OBJS)
461 LIBS-$(BUILD_LIBVPX) += $(BUILD_PFX)libgtest.a $(BUILD_PFX)libgtest_g.a
462 $(BUILD_PFX)libgtest_g.a: $(GTEST_OBJS)
464 LIBVPX_TEST_OBJS=$(sort $(call objs,$(LIBVPX_TEST_SRCS)))
465 $(LIBVPX_TEST_OBJS) $(LIBVPX_TEST_OBJS:.o=.d): CXXFLAGS += -I$(SRC_PATH_BARE)/third_party/googletest/src
466 $(LIBVPX_TEST_OBJS) $(LIBVPX_TEST_OBJS:.o=.d): CXXFLAGS += -I$(SRC_PATH_BARE)/third_party/googletest/src/include
467 OBJS-$(BUILD_LIBVPX) += $(LIBVPX_TEST_OBJS)
468 BINS-$(BUILD_LIBVPX) += $(LIBVPX_TEST_BINS)
470 CODEC_LIB=$(if $(CONFIG_DEBUG_LIBS),vpx_g,vpx)
471 CODEC_LIB_SUF=$(if $(CONFIG_SHARED),.so,.a)
472 $(foreach bin,$(LIBVPX_TEST_BINS),\
473 $(if $(BUILD_LIBVPX),$(eval $(bin): \
474 lib$(CODEC_LIB)$(CODEC_LIB_SUF) libgtest.a ))\
475 $(if $(BUILD_LIBVPX),$(eval $(call linkerxx_template,$(bin),\
476 $(LIBVPX_TEST_OBJS) \
477 -L. -lvpx -lgtest $(extralibs) -lm)\
478 )))\
479 $(if $(LIPO_LIBS),$(eval $(call lipo_bin_template,$(bin))))\
481 endif
483 # Install test sources only if codec source is included
484 INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(patsubst $(SRC_PATH_BARE)/%,%,\
485 $(shell find $(SRC_PATH_BARE)/third_party/googletest -type f))
486 INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(LIBVPX_TEST_SRCS)
488 define test_shard_template
489 test:: test_shard.$(1)
490 test_shard.$(1): $(LIBVPX_TEST_BINS) testdata
491 @set -e; \
492 for t in $(LIBVPX_TEST_BINS); do \
493 export GTEST_SHARD_INDEX=$(1); \
494 export GTEST_TOTAL_SHARDS=$(2); \
495 $$$$t; \
496 done
497 .PHONY: test_shard.$(1)
498 endef
500 NUM_SHARDS := 10
501 SHARDS := 0 1 2 3 4 5 6 7 8 9
502 $(foreach s,$(SHARDS),$(eval $(call test_shard_template,$(s),$(NUM_SHARDS))))
504 endif
507 ## documentation directives
509 CLEAN-OBJS += libs.doxy
510 DOCS-yes += libs.doxy
511 libs.doxy: $(CODEC_DOC_SRCS)
512 @echo " [CREATE] $@"
513 @rm -f $@
514 @echo "INPUT += $^" >> $@
515 @echo "PREDEFINED = VPX_CODEC_DISABLE_COMPAT" >> $@
516 @echo "INCLUDE_PATH += ." >> $@;
517 @echo "ENABLED_SECTIONS += $(sort $(CODEC_DOC_SECTIONS))" >> $@
519 ## Generate rtcd.h for all objects
520 $(OBJS-yes:.o=.d): $(RTCD)
522 ## Update the global src list
523 SRCS += $(CODEC_SRCS) $(LIBVPX_TEST_SRCS) $(GTEST_SRCS)