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