]> granicus.if.org Git - libvpx/blob - libs.mk
Merge "Remove unnecessary set postproc flags."
[libvpx] / 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)$(CONFIG_MSVS)),.asm.s,.asm)
16 else
17   ASM:=.asm
18 endif
19
20 #
21 # Rule to generate runtime cpu detection files
22 #
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)$$(if $$(FAT_ARCHS),,-$$(TOOLCHAIN)).mk \
29           $$(RTCD_OPTIONS) $$^ > $$@
30 CLEAN-OBJS += $$(BUILD_PFX)$(1).h
31 RTCD += $$(BUILD_PFX)$(1).h
32 endef
33
34 CODEC_SRCS-yes += CHANGELOG
35 CODEC_SRCS-yes += libs.mk
36
37 # If this is a universal (fat) binary, then all the subarchitectures have
38 # already been built and our job is to stitch them together. The
39 # BUILD_LIBVPX variable indicates whether we should be building
40 # (compiling, linking) the library. The LIPO_LIBVPX variable indicates
41 # that we're stitching.
42 $(eval $(if $(filter universal%,$(TOOLCHAIN)),LIPO_LIBVPX,BUILD_LIBVPX):=yes)
43
44 include $(SRC_PATH_BARE)/vpx/vpx_codec.mk
45 CODEC_SRCS-yes += $(addprefix vpx/,$(call enabled,API_SRCS))
46 CODEC_DOC_SRCS += $(addprefix vpx/,$(call enabled,API_DOC_SRCS))
47
48 include $(SRC_PATH_BARE)/vpx_mem/vpx_mem.mk
49 CODEC_SRCS-yes += $(addprefix vpx_mem/,$(call enabled,MEM_SRCS))
50
51 include $(SRC_PATH_BARE)/vpx_scale/vpx_scale.mk
52 CODEC_SRCS-yes += $(addprefix vpx_scale/,$(call enabled,SCALE_SRCS))
53
54 include $(SRC_PATH_BARE)/vpx_ports/vpx_ports.mk
55 CODEC_SRCS-yes += $(addprefix vpx_ports/,$(call enabled,PORTS_SRCS))
56
57 ifneq ($(CONFIG_VP8_ENCODER)$(CONFIG_VP8_DECODER),)
58   VP8_PREFIX=vp8/
59   include $(SRC_PATH_BARE)/$(VP8_PREFIX)vp8_common.mk
60 endif
61
62 ifeq ($(CONFIG_VP8_ENCODER),yes)
63   include $(SRC_PATH_BARE)/$(VP8_PREFIX)vp8cx.mk
64   CODEC_SRCS-yes += $(addprefix $(VP8_PREFIX),$(call enabled,VP8_CX_SRCS))
65   CODEC_EXPORTS-yes += $(addprefix $(VP8_PREFIX),$(VP8_CX_EXPORTS))
66   INSTALL-LIBS-yes += include/vpx/vp8.h include/vpx/vp8cx.h
67   INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/$(VP8_PREFIX)/%
68   CODEC_DOC_SECTIONS += vp8 vp8_encoder
69 endif
70
71 ifeq ($(CONFIG_VP8_DECODER),yes)
72   include $(SRC_PATH_BARE)/$(VP8_PREFIX)vp8dx.mk
73   CODEC_SRCS-yes += $(addprefix $(VP8_PREFIX),$(call enabled,VP8_DX_SRCS))
74   CODEC_EXPORTS-yes += $(addprefix $(VP8_PREFIX),$(VP8_DX_EXPORTS))
75   INSTALL-LIBS-yes += include/vpx/vp8.h include/vpx/vp8dx.h
76   INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/$(VP8_PREFIX)/%
77   CODEC_DOC_SECTIONS += vp8 vp8_decoder
78 endif
79
80 ifneq ($(CONFIG_VP9_ENCODER)$(CONFIG_VP9_DECODER),)
81   VP9_PREFIX=vp9/
82   include $(SRC_PATH_BARE)/$(VP9_PREFIX)vp9_common.mk
83 endif
84
85 ifeq ($(CONFIG_VP9_ENCODER),yes)
86   VP9_PREFIX=vp9/
87   include $(SRC_PATH_BARE)/$(VP9_PREFIX)vp9cx.mk
88   CODEC_SRCS-yes += $(addprefix $(VP9_PREFIX),$(call enabled,VP9_CX_SRCS))
89   CODEC_EXPORTS-yes += $(addprefix $(VP9_PREFIX),$(VP9_CX_EXPORTS))
90   CODEC_SRCS-yes += $(VP9_PREFIX)vp9cx.mk vpx/vp8.h vpx/vp8cx.h
91   INSTALL-LIBS-yes += include/vpx/vp8.h include/vpx/vp8cx.h
92   INSTALL-LIBS-$(CONFIG_SPATIAL_SVC) += include/vpx/svc_context.h
93   INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/$(VP9_PREFIX)/%
94   CODEC_DOC_SRCS += vpx/vp8.h vpx/vp8cx.h
95   CODEC_DOC_SECTIONS += vp9 vp9_encoder
96 endif
97
98 ifeq ($(CONFIG_VP9_DECODER),yes)
99   VP9_PREFIX=vp9/
100   include $(SRC_PATH_BARE)/$(VP9_PREFIX)vp9dx.mk
101   CODEC_SRCS-yes += $(addprefix $(VP9_PREFIX),$(call enabled,VP9_DX_SRCS))
102   CODEC_EXPORTS-yes += $(addprefix $(VP9_PREFIX),$(VP9_DX_EXPORTS))
103   CODEC_SRCS-yes += $(VP9_PREFIX)vp9dx.mk vpx/vp8.h vpx/vp8dx.h
104   INSTALL-LIBS-yes += include/vpx/vp8.h include/vpx/vp8dx.h
105   INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/$(VP9_PREFIX)/%
106   CODEC_DOC_SRCS += vpx/vp8.h vpx/vp8dx.h
107   CODEC_DOC_SECTIONS += vp9 vp9_decoder
108 endif
109
110 VP9_PREFIX=vp9/
111 $(BUILD_PFX)$(VP9_PREFIX)%.c.o: CFLAGS += -Wextra
112
113 ifeq ($(CONFIG_ENCODERS),yes)
114   CODEC_DOC_SECTIONS += encoder
115 endif
116 ifeq ($(CONFIG_DECODERS),yes)
117   CODEC_DOC_SECTIONS += decoder
118 endif
119
120
121 ifeq ($(CONFIG_MSVS),yes)
122 CODEC_LIB=$(if $(CONFIG_STATIC_MSVCRT),vpxmt,vpxmd)
123 GTEST_LIB=$(if $(CONFIG_STATIC_MSVCRT),gtestmt,gtestmd)
124 # This variable uses deferred expansion intentionally, since the results of
125 # $(wildcard) may change during the course of the Make.
126 VS_PLATFORMS = $(foreach d,$(wildcard */Release/$(CODEC_LIB).lib),$(word 1,$(subst /, ,$(d))))
127 endif
128
129 # The following pairs define a mapping of locations in the distribution
130 # tree to locations in the source/build trees.
131 INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/vpx/%
132 INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/vpx_ports/%
133 INSTALL_MAPS += $(LIBSUBDIR)/%     %
134 INSTALL_MAPS += src/%     $(SRC_PATH_BARE)/%
135 ifeq ($(CONFIG_MSVS),yes)
136 INSTALL_MAPS += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/%  $(p)/Release/%)
137 INSTALL_MAPS += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/%  $(p)/Debug/%)
138 endif
139
140 CODEC_SRCS-$(BUILD_LIBVPX) += build/make/version.sh
141 CODEC_SRCS-$(BUILD_LIBVPX) += build/make/rtcd.pl
142 CODEC_SRCS-$(BUILD_LIBVPX) += vpx_ports/emmintrin_compat.h
143 CODEC_SRCS-$(BUILD_LIBVPX) += vpx_ports/mem_ops.h
144 CODEC_SRCS-$(BUILD_LIBVPX) += vpx_ports/mem_ops_aligned.h
145 CODEC_SRCS-$(BUILD_LIBVPX) += vpx_ports/vpx_once.h
146 CODEC_SRCS-$(BUILD_LIBVPX) += $(BUILD_PFX)vpx_config.c
147 INSTALL-SRCS-no += $(BUILD_PFX)vpx_config.c
148 ifeq ($(ARCH_X86)$(ARCH_X86_64),yes)
149 INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += third_party/x86inc/x86inc.asm
150 endif
151 CODEC_EXPORTS-$(BUILD_LIBVPX) += vpx/exports_com
152 CODEC_EXPORTS-$(CONFIG_ENCODERS) += vpx/exports_enc
153 CODEC_EXPORTS-$(CONFIG_DECODERS) += vpx/exports_dec
154
155 INSTALL-LIBS-yes += include/vpx/vpx_codec.h
156 INSTALL-LIBS-yes += include/vpx/vpx_frame_buffer.h
157 INSTALL-LIBS-yes += include/vpx/vpx_image.h
158 INSTALL-LIBS-yes += include/vpx/vpx_integer.h
159 INSTALL-LIBS-$(CONFIG_DECODERS) += include/vpx/vpx_decoder.h
160 INSTALL-LIBS-$(CONFIG_ENCODERS) += include/vpx/vpx_encoder.h
161 ifeq ($(CONFIG_EXTERNAL_BUILD),yes)
162 ifeq ($(CONFIG_MSVS),yes)
163 INSTALL-LIBS-yes                  += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/$(CODEC_LIB).lib)
164 INSTALL-LIBS-$(CONFIG_DEBUG_LIBS) += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/$(CODEC_LIB)d.lib)
165 INSTALL-LIBS-$(CONFIG_SHARED) += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/vpx.dll)
166 INSTALL-LIBS-$(CONFIG_SHARED) += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/vpx.exp)
167 endif
168 else
169 INSTALL-LIBS-$(CONFIG_STATIC) += $(LIBSUBDIR)/libvpx.a
170 INSTALL-LIBS-$(CONFIG_DEBUG_LIBS) += $(LIBSUBDIR)/libvpx_g.a
171 endif
172
173 CODEC_SRCS=$(call enabled,CODEC_SRCS)
174 INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(CODEC_SRCS)
175 INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(call enabled,CODEC_EXPORTS)
176
177
178 # Generate a list of all enabled sources, in particular for exporting to gyp
179 # based build systems.
180 libvpx_srcs.txt:
181         @echo "    [CREATE] $@"
182         @echo $(CODEC_SRCS) | xargs -n1 echo | LC_ALL=C sort -u > $@
183 CLEAN-OBJS += libvpx_srcs.txt
184
185
186 ifeq ($(CONFIG_EXTERNAL_BUILD),yes)
187 ifeq ($(CONFIG_MSVS),yes)
188
189 vpx.def: $(call enabled,CODEC_EXPORTS)
190         @echo "    [CREATE] $@"
191         $(qexec)$(SRC_PATH_BARE)/build/make/gen_msvs_def.sh\
192             --name=vpx\
193             --out=$@ $^
194 CLEAN-OBJS += vpx.def
195
196 # Assembly files that are included, but don't define symbols themselves.
197 # Filtered out to avoid Visual Studio build warnings.
198 ASM_INCLUDES := \
199     third_party/x86inc/x86inc.asm \
200     vpx_config.asm \
201     vpx_ports/x86_abi_support.asm \
202
203 vpx.$(VCPROJ_SFX): $(CODEC_SRCS) vpx.def
204         @echo "    [CREATE] $@"
205         $(qexec)$(GEN_VCPROJ) \
206             $(if $(CONFIG_SHARED),--dll,--lib) \
207             --target=$(TOOLCHAIN) \
208             $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \
209             --name=vpx \
210             --proj-guid=DCE19DAF-69AC-46DB-B14A-39F0FAA5DB74 \
211             --module-def=vpx.def \
212             --ver=$(CONFIG_VS_VERSION) \
213             --src-path-bare="$(SRC_PATH_BARE)" \
214             --out=$@ $(CFLAGS) \
215             $(filter-out $(addprefix %, $(ASM_INCLUDES)), $^) \
216             --src-path-bare="$(SRC_PATH_BARE)" \
217
218 PROJECTS-$(BUILD_LIBVPX) += vpx.$(VCPROJ_SFX)
219
220 vpx.$(VCPROJ_SFX): vpx_config.asm
221 vpx.$(VCPROJ_SFX): $(RTCD)
222
223 endif
224 else
225 LIBVPX_OBJS=$(call objs,$(CODEC_SRCS))
226 OBJS-$(BUILD_LIBVPX) += $(LIBVPX_OBJS)
227 LIBS-$(if $(BUILD_LIBVPX),$(CONFIG_STATIC)) += $(BUILD_PFX)libvpx.a $(BUILD_PFX)libvpx_g.a
228 $(BUILD_PFX)libvpx_g.a: $(LIBVPX_OBJS)
229
230
231 BUILD_LIBVPX_SO         := $(if $(BUILD_LIBVPX),$(CONFIG_SHARED))
232
233 SO_VERSION_MAJOR := 2
234 SO_VERSION_MINOR := 0
235 SO_VERSION_PATCH := 0
236 ifeq ($(filter darwin%,$(TGT_OS)),$(TGT_OS))
237 LIBVPX_SO               := libvpx.$(SO_VERSION_MAJOR).dylib
238 EXPORT_FILE             := libvpx.syms
239 LIBVPX_SO_SYMLINKS      := $(addprefix $(LIBSUBDIR)/, \
240                              libvpx.dylib  )
241 else
242 LIBVPX_SO               := libvpx.so.$(SO_VERSION_MAJOR).$(SO_VERSION_MINOR).$(SO_VERSION_PATCH)
243 EXPORT_FILE             := libvpx.ver
244 LIBVPX_SO_SYMLINKS      := $(addprefix $(LIBSUBDIR)/, \
245                              libvpx.so libvpx.so.$(SO_VERSION_MAJOR) \
246                              libvpx.so.$(SO_VERSION_MAJOR).$(SO_VERSION_MINOR))
247 endif
248
249 LIBS-$(BUILD_LIBVPX_SO) += $(BUILD_PFX)$(LIBVPX_SO)\
250                            $(notdir $(LIBVPX_SO_SYMLINKS))
251 $(BUILD_PFX)$(LIBVPX_SO): $(LIBVPX_OBJS) $(EXPORT_FILE)
252 $(BUILD_PFX)$(LIBVPX_SO): extralibs += -lm
253 $(BUILD_PFX)$(LIBVPX_SO): SONAME = libvpx.so.$(SO_VERSION_MAJOR)
254 $(BUILD_PFX)$(LIBVPX_SO): EXPORTS_FILE = $(EXPORT_FILE)
255
256 libvpx.ver: $(call enabled,CODEC_EXPORTS)
257         @echo "    [CREATE] $@"
258         $(qexec)echo "{ global:" > $@
259         $(qexec)for f in $?; do awk '{print $$2";"}' < $$f >>$@; done
260         $(qexec)echo "local: *; };" >> $@
261 CLEAN-OBJS += libvpx.ver
262
263 libvpx.syms: $(call enabled,CODEC_EXPORTS)
264         @echo "    [CREATE] $@"
265         $(qexec)awk '{print "_"$$2}' $^ >$@
266 CLEAN-OBJS += libvpx.syms
267
268 define libvpx_symlink_template
269 $(1): $(2)
270         @echo "    [LN]     $(2) $$@"
271         $(qexec)mkdir -p $$(dir $$@)
272         $(qexec)ln -sf $(2) $$@
273 endef
274
275 $(eval $(call libvpx_symlink_template,\
276     $(addprefix $(BUILD_PFX),$(notdir $(LIBVPX_SO_SYMLINKS))),\
277     $(BUILD_PFX)$(LIBVPX_SO)))
278 $(eval $(call libvpx_symlink_template,\
279     $(addprefix $(DIST_DIR)/,$(LIBVPX_SO_SYMLINKS)),\
280     $(LIBVPX_SO)))
281
282
283 INSTALL-LIBS-$(BUILD_LIBVPX_SO) += $(LIBVPX_SO_SYMLINKS)
284 INSTALL-LIBS-$(BUILD_LIBVPX_SO) += $(LIBSUBDIR)/$(LIBVPX_SO)
285
286
287 LIBS-$(BUILD_LIBVPX) += vpx.pc
288 vpx.pc: config.mk libs.mk
289         @echo "    [CREATE] $@"
290         $(qexec)echo '# pkg-config file from libvpx $(VERSION_STRING)' > $@
291         $(qexec)echo 'prefix=$(PREFIX)' >> $@
292         $(qexec)echo 'exec_prefix=$${prefix}' >> $@
293         $(qexec)echo 'libdir=$${prefix}/$(LIBSUBDIR)' >> $@
294         $(qexec)echo 'includedir=$${prefix}/include' >> $@
295         $(qexec)echo '' >> $@
296         $(qexec)echo 'Name: vpx' >> $@
297         $(qexec)echo 'Description: WebM Project VPx codec implementation' >> $@
298         $(qexec)echo 'Version: $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH)' >> $@
299         $(qexec)echo 'Requires:' >> $@
300         $(qexec)echo 'Conflicts:' >> $@
301         $(qexec)echo 'Libs: -L$${libdir} -lvpx -lm' >> $@
302 ifeq ($(HAVE_PTHREAD_H),yes)
303         $(qexec)echo 'Libs.private: -lm -lpthread' >> $@
304 else
305         $(qexec)echo 'Libs.private: -lm' >> $@
306 endif
307         $(qexec)echo 'Cflags: -I$${includedir}' >> $@
308 INSTALL-LIBS-yes += $(LIBSUBDIR)/pkgconfig/vpx.pc
309 INSTALL_MAPS += $(LIBSUBDIR)/pkgconfig/%.pc %.pc
310 CLEAN-OBJS += vpx.pc
311 endif
312
313 LIBS-$(LIPO_LIBVPX) += libvpx.a
314 $(eval $(if $(LIPO_LIBVPX),$(call lipo_lib_template,libvpx.a)))
315
316 #
317 # Rule to make assembler configuration file from C configuration file
318 #
319 ifeq ($(ARCH_X86)$(ARCH_X86_64),yes)
320 # YASM
321 $(BUILD_PFX)vpx_config.asm: $(BUILD_PFX)vpx_config.h
322         @echo "    [CREATE] $@"
323         @egrep "#define [A-Z0-9_]+ [01]" $< \
324             | awk '{print $$2 " equ " $$3}' > $@
325 else
326 ADS2GAS=$(if $(filter yes,$(CONFIG_GCC)),| $(ASM_CONVERSION))
327 $(BUILD_PFX)vpx_config.asm: $(BUILD_PFX)vpx_config.h
328         @echo "    [CREATE] $@"
329         @egrep "#define [A-Z0-9_]+ [01]" $< \
330             | awk '{print $$2 " EQU " $$3}' $(ADS2GAS) > $@
331         @echo "        END" $(ADS2GAS) >> $@
332 CLEAN-OBJS += $(BUILD_PFX)vpx_config.asm
333 endif
334
335 #
336 # Add assembler dependencies for configuration.
337 #
338 $(filter %.s.o,$(OBJS-yes)):     $(BUILD_PFX)vpx_config.asm
339 $(filter %$(ASM).o,$(OBJS-yes)): $(BUILD_PFX)vpx_config.asm
340
341
342 $(shell $(SRC_PATH_BARE)/build/make/version.sh "$(SRC_PATH_BARE)" $(BUILD_PFX)vpx_version.h)
343 CLEAN-OBJS += $(BUILD_PFX)vpx_version.h
344
345
346 ##
347 ## libvpx test directives
348 ##
349 ifeq ($(CONFIG_UNIT_TESTS),yes)
350 LIBVPX_TEST_DATA_PATH ?= .
351
352 include $(SRC_PATH_BARE)/test/test.mk
353 LIBVPX_TEST_SRCS=$(addprefix test/,$(call enabled,LIBVPX_TEST_SRCS))
354 LIBVPX_TEST_BINS=./test_libvpx$(EXE_SFX)
355 LIBVPX_TEST_DATA=$(addprefix $(LIBVPX_TEST_DATA_PATH)/,\
356                      $(call enabled,LIBVPX_TEST_DATA))
357 libvpx_test_data_url=http://downloads.webmproject.org/test_data/libvpx/$(1)
358
359 libvpx_test_srcs.txt:
360         @echo "    [CREATE] $@"
361         @echo $(LIBVPX_TEST_SRCS) | xargs -n1 echo | LC_ALL=C sort -u > $@
362 CLEAN-OBJS += libvpx_test_srcs.txt
363
364 $(LIBVPX_TEST_DATA): $(SRC_PATH_BARE)/test/test-data.sha1
365         @echo "    [DOWNLOAD] $@"
366         $(qexec)trap 'rm -f $@' INT TERM &&\
367             curl -L -o $@ $(call libvpx_test_data_url,$(@F))
368
369 testdata:: $(LIBVPX_TEST_DATA)
370         $(qexec)[ -x "$$(which sha1sum)" ] && sha1sum=sha1sum;\
371           [ -x "$$(which shasum)" ] && sha1sum=shasum;\
372           [ -x "$$(which sha1)" ] && sha1sum=sha1;\
373           if [ -n "$${sha1sum}" ]; then\
374             set -e;\
375             echo "Checking test data:";\
376             if [ -n "$(LIBVPX_TEST_DATA)" ]; then\
377                 for f in $(call enabled,LIBVPX_TEST_DATA); do\
378                     grep $$f $(SRC_PATH_BARE)/test/test-data.sha1 |\
379                         (cd $(LIBVPX_TEST_DATA_PATH); $${sha1sum} -c);\
380                 done; \
381             fi; \
382         else\
383             echo "Skipping test data integrity check, sha1sum not found.";\
384         fi
385
386 ifeq ($(CONFIG_EXTERNAL_BUILD),yes)
387 ifeq ($(CONFIG_MSVS),yes)
388
389 gtest.$(VCPROJ_SFX): $(SRC_PATH_BARE)/third_party/googletest/src/src/gtest-all.cc
390         @echo "    [CREATE] $@"
391         $(qexec)$(GEN_VCPROJ) \
392             --lib \
393             --target=$(TOOLCHAIN) \
394             $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \
395             --name=gtest \
396             --proj-guid=EC00E1EC-AF68-4D92-A255-181690D1C9B1 \
397             --ver=$(CONFIG_VS_VERSION) \
398             --src-path-bare="$(SRC_PATH_BARE)" \
399             -D_VARIADIC_MAX=10 \
400             --out=gtest.$(VCPROJ_SFX) $(SRC_PATH_BARE)/third_party/googletest/src/src/gtest-all.cc \
401             -I. -I"$(SRC_PATH_BARE)/third_party/googletest/src/include" -I"$(SRC_PATH_BARE)/third_party/googletest/src"
402
403 PROJECTS-$(CONFIG_MSVS) += gtest.$(VCPROJ_SFX)
404
405 test_libvpx.$(VCPROJ_SFX): $(LIBVPX_TEST_SRCS) vpx.$(VCPROJ_SFX) gtest.$(VCPROJ_SFX)
406         @echo "    [CREATE] $@"
407         $(qexec)$(GEN_VCPROJ) \
408             --exe \
409             --target=$(TOOLCHAIN) \
410             --name=test_libvpx \
411             -D_VARIADIC_MAX=10 \
412             --proj-guid=CD837F5F-52D8-4314-A370-895D614166A7 \
413             --ver=$(CONFIG_VS_VERSION) \
414             --src-path-bare="$(SRC_PATH_BARE)" \
415             $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \
416             --out=$@ $(INTERNAL_CFLAGS) $(CFLAGS) \
417             -I. -I"$(SRC_PATH_BARE)/third_party/googletest/src/include" \
418             -L. -l$(CODEC_LIB) -l$(GTEST_LIB) $^
419
420 PROJECTS-$(CONFIG_MSVS) += test_libvpx.$(VCPROJ_SFX)
421
422 LIBVPX_TEST_BINS := $(addprefix $(TGT_OS:win64=x64)/Release/,$(notdir $(LIBVPX_TEST_BINS)))
423 endif
424 else
425
426 include $(SRC_PATH_BARE)/third_party/googletest/gtest.mk
427 GTEST_SRCS := $(addprefix third_party/googletest/src/,$(call enabled,GTEST_SRCS))
428 GTEST_OBJS=$(call objs,$(GTEST_SRCS))
429 ifeq ($(filter win%,$(TGT_OS)),$(TGT_OS))
430 # Disabling pthreads globally will cause issues on darwin and possibly elsewhere
431 $(GTEST_OBJS) $(GTEST_OBJS:.o=.d): CXXFLAGS += -DGTEST_HAS_PTHREAD=0
432 endif
433 $(GTEST_OBJS) $(GTEST_OBJS:.o=.d): CXXFLAGS += -I$(SRC_PATH_BARE)/third_party/googletest/src
434 $(GTEST_OBJS) $(GTEST_OBJS:.o=.d): CXXFLAGS += -I$(SRC_PATH_BARE)/third_party/googletest/src/include
435 OBJS-$(BUILD_LIBVPX) += $(GTEST_OBJS)
436 LIBS-$(BUILD_LIBVPX) += $(BUILD_PFX)libgtest.a $(BUILD_PFX)libgtest_g.a
437 $(BUILD_PFX)libgtest_g.a: $(GTEST_OBJS)
438
439 LIBVPX_TEST_OBJS=$(sort $(call objs,$(LIBVPX_TEST_SRCS)))
440 $(LIBVPX_TEST_OBJS) $(LIBVPX_TEST_OBJS:.o=.d): CXXFLAGS += -I$(SRC_PATH_BARE)/third_party/googletest/src
441 $(LIBVPX_TEST_OBJS) $(LIBVPX_TEST_OBJS:.o=.d): CXXFLAGS += -I$(SRC_PATH_BARE)/third_party/googletest/src/include
442 OBJS-$(BUILD_LIBVPX) += $(LIBVPX_TEST_OBJS)
443 BINS-$(BUILD_LIBVPX) += $(LIBVPX_TEST_BINS)
444
445 CODEC_LIB=$(if $(CONFIG_DEBUG_LIBS),vpx_g,vpx)
446 CODEC_LIB_SUF=$(if $(CONFIG_SHARED),.so,.a)
447 $(foreach bin,$(LIBVPX_TEST_BINS),\
448     $(if $(BUILD_LIBVPX),$(eval $(bin): \
449         lib$(CODEC_LIB)$(CODEC_LIB_SUF) libgtest.a ))\
450     $(if $(BUILD_LIBVPX),$(eval $(call linkerxx_template,$(bin),\
451         $(LIBVPX_TEST_OBJS) \
452         -L. -lvpx -lgtest $(extralibs) -lm)\
453         )))\
454     $(if $(LIPO_LIBS),$(eval $(call lipo_bin_template,$(bin))))\
455
456 endif
457
458 # Install test sources only if codec source is included
459 INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(patsubst $(SRC_PATH_BARE)/%,%,\
460     $(shell find $(SRC_PATH_BARE)/third_party/googletest -type f))
461 INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(LIBVPX_TEST_SRCS)
462
463 define test_shard_template
464 test:: test_shard.$(1)
465 test_shard.$(1): $(LIBVPX_TEST_BINS) testdata
466         @set -e; \
467          for t in $(LIBVPX_TEST_BINS); do \
468            export GTEST_SHARD_INDEX=$(1); \
469            export GTEST_TOTAL_SHARDS=$(2); \
470            $$$$t; \
471          done
472 .PHONY: test_shard.$(1)
473 endef
474
475 NUM_SHARDS := 10
476 SHARDS := 0 1 2 3 4 5 6 7 8 9
477 $(foreach s,$(SHARDS),$(eval $(call test_shard_template,$(s),$(NUM_SHARDS))))
478
479 endif
480
481 ##
482 ## documentation directives
483 ##
484 CLEAN-OBJS += libs.doxy
485 DOCS-yes += libs.doxy
486 libs.doxy: $(CODEC_DOC_SRCS)
487         @echo "    [CREATE] $@"
488         @rm -f $@
489         @echo "INPUT += $^" >> $@
490         @echo "INCLUDE_PATH += ." >> $@;
491         @echo "ENABLED_SECTIONS += $(sort $(CODEC_DOC_SECTIONS))" >> $@
492
493 ## Generate rtcd.h for all objects
494 ifeq ($(CONFIG_DEPENDENCY_TRACKING),yes)
495 $(OBJS-yes:.o=.d): $(RTCD)
496 else
497 $(OBJS-yes): $(RTCD)
498 endif
499
500 ## Update the global src list
501 SRCS += $(CODEC_SRCS) $(LIBVPX_TEST_SRCS) $(GTEST_SRCS)
502
503 ##
504 ## vpxdec/vpxenc tests.
505 ##
506 ifeq ($(CONFIG_UNIT_TESTS),yes)
507 TEST_BIN_PATH = .
508 ifeq ($(CONFIG_MSVS),yes)
509 # MSVC will build both Debug and Release configurations of tools in a
510 # sub directory named for the current target. Assume the user wants to
511 # run the Release tools, and assign TEST_BIN_PATH accordingly.
512 # TODO(tomfinegan): Is this adequate for ARM?
513 # TODO(tomfinegan): Support running the debug versions of tools?
514 TEST_BIN_PATH := $(addsuffix /$(TGT_OS:win64=x64)/Release, $(TEST_BIN_PATH))
515 endif
516 utiltest: testdata
517         $(qexec)$(SRC_PATH_BARE)/test/vpxdec.sh \
518                 --test-data-path $(LIBVPX_TEST_DATA_PATH) \
519                 --bin-path $(TEST_BIN_PATH)
520         $(qexec)$(SRC_PATH_BARE)/test/vpxenc.sh \
521                 --test-data-path $(LIBVPX_TEST_DATA_PATH) \
522                 --bin-path $(TEST_BIN_PATH)
523 else
524 utiltest:
525         @echo Unit tests must be enabled to make the utiltest target.
526 endif
527
528 ##
529 ## Example tests.
530 ##
531 ifeq ($(CONFIG_UNIT_TESTS),yes)
532 # All non-MSVC targets output example targets in a sub dir named examples.
533 EXAMPLES_BIN_PATH = examples
534 ifeq ($(CONFIG_MSVS),yes)
535 # MSVC will build both Debug and Release configurations of the examples in a
536 # sub directory named for the current target. Assume the user wants to
537 # run the Release tools, and assign EXAMPLES_BIN_PATH accordingly.
538 # TODO(tomfinegan): Is this adequate for ARM?
539 # TODO(tomfinegan): Support running the debug versions of tools?
540 EXAMPLES_BIN_PATH := $(TGT_OS:win64=x64)/Release
541 endif
542 exampletest: examples testdata
543         $(qexec)$(SRC_PATH_BARE)/test/examples.sh \
544                 --test-data-path $(LIBVPX_TEST_DATA_PATH) \
545                 --bin-path $(EXAMPLES_BIN_PATH)
546 else
547 exampletest:
548         @echo Unit tests must be enabled to make the exampletest target.
549 endif