blob: 38b4b11121bdc7dc4af3aca5a6deafe4ae3760b3 [file] [log] [blame]
John Koleszar0ea50ce2010-05-18 11:58:33 -04001##
John Koleszarc2140b82010-09-09 08:16:39 -04002## Copyright (c) 2010 The WebM project authors. All Rights Reserved.
John Koleszar0ea50ce2010-05-18 11:58:33 -04003##
John Koleszar94c52e42010-06-18 12:39:21 -04004## Use of this source code is governed by a BSD-style license
John Koleszar09202d82010-06-04 16:19:40 -04005## 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
John Koleszar94c52e42010-06-18 12:39:21 -04007## in the file PATENTS. All contributing project authors may
John Koleszar09202d82010-06-04 16:19:40 -04008## be found in the AUTHORS file in the root of the source tree.
John Koleszar0ea50ce2010-05-18 11:58:33 -04009##
10
11
Johann128d2c22011-03-02 09:44:39 -050012# ARM assembly files are written in RVCT-style. We use some make magic to
13# filter those files to allow GCC compilation
14ifeq ($(ARCH_ARM),yes)
Martin Storsjoad484fc2013-05-18 23:32:49 +030015 ASM:=$(if $(filter yes,$(CONFIG_GCC)$(CONFIG_MSVS)),.asm.s,.asm)
Johann128d2c22011-03-02 09:44:39 -050016else
17 ASM:=.asm
18endif
John Koleszar0ea50ce2010-05-18 11:58:33 -040019
John Koleszar7b8dfcb2012-11-06 16:59:01 -080020#
John Koleszara9c75972012-11-08 17:09:30 -080021# Rule to generate runtime cpu detection files
22#
23define rtcd_h_template
24$$(BUILD_PFX)$(1).h: $$(SRC_PATH_BARE)/$(2)
25 @echo " [CREATE] $$@"
James Zern805078a2014-02-23 16:33:14 -080026 $$(qexec)$$(SRC_PATH_BARE)/build/make/rtcd.pl --arch=$$(TGT_ISA) \
John Koleszara9c75972012-11-08 17:09:30 -080027 --sym=$(1) \
Johann3810bca2013-04-17 10:52:50 -070028 --config=$$(CONFIG_DIR)$$(target)$$(if $$(FAT_ARCHS),,-$$(TOOLCHAIN)).mk \
John Koleszara9c75972012-11-08 17:09:30 -080029 $$(RTCD_OPTIONS) $$^ > $$@
30CLEAN-OBJS += $$(BUILD_PFX)$(1).h
31RTCD += $$(BUILD_PFX)$(1).h
32endef
John Koleszar7b8dfcb2012-11-06 16:59:01 -080033
Johann5d88a822012-03-05 16:36:23 -080034CODEC_SRCS-yes += CHANGELOG
John Koleszar4d86ef32010-06-22 08:44:48 -040035CODEC_SRCS-yes += libs.mk
36
Johanna5ffcdd2012-11-15 16:28:20 -080037# 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
John Koleszarb7492342010-05-24 11:39:59 -040044include $(SRC_PATH_BARE)/vpx/vpx_codec.mk
45CODEC_SRCS-yes += $(addprefix vpx/,$(call enabled,API_SRCS))
Johann999f31f2012-11-15 17:19:44 -080046CODEC_DOC_SRCS += $(addprefix vpx/,$(call enabled,API_DOC_SRCS))
John Koleszar0ea50ce2010-05-18 11:58:33 -040047
48include $(SRC_PATH_BARE)/vpx_mem/vpx_mem.mk
49CODEC_SRCS-yes += $(addprefix vpx_mem/,$(call enabled,MEM_SRCS))
50
51include $(SRC_PATH_BARE)/vpx_scale/vpx_scale.mk
52CODEC_SRCS-yes += $(addprefix vpx_scale/,$(call enabled,SCALE_SRCS))
53
Johanna5ffcdd2012-11-15 16:28:20 -080054include $(SRC_PATH_BARE)/vpx_ports/vpx_ports.mk
55CODEC_SRCS-yes += $(addprefix vpx_ports/,$(call enabled,PORTS_SRCS))
56
John Koleszar7b8dfcb2012-11-06 16:59:01 -080057ifneq ($(CONFIG_VP8_ENCODER)$(CONFIG_VP8_DECODER),)
58 VP8_PREFIX=vp8/
59 include $(SRC_PATH_BARE)/$(VP8_PREFIX)vp8_common.mk
60endif
John Koleszar0ea50ce2010-05-18 11:58:33 -040061
62ifeq ($(CONFIG_VP8_ENCODER),yes)
John Koleszar0ea50ce2010-05-18 11:58:33 -040063 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))
John Koleszar2bf8fb52012-05-02 16:37:37 -070066 INSTALL-LIBS-yes += include/vpx/vp8.h include/vpx/vp8cx.h
John Koleszarb7492342010-05-24 11:39:59 -040067 INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/$(VP8_PREFIX)/%
John Koleszar0ea50ce2010-05-18 11:58:33 -040068 CODEC_DOC_SECTIONS += vp8 vp8_encoder
69endif
70
71ifeq ($(CONFIG_VP8_DECODER),yes)
John Koleszar0ea50ce2010-05-18 11:58:33 -040072 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))
John Koleszarb7492342010-05-24 11:39:59 -040075 INSTALL-LIBS-yes += include/vpx/vp8.h include/vpx/vp8dx.h
76 INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/$(VP8_PREFIX)/%
John Koleszar0ea50ce2010-05-18 11:58:33 -040077 CODEC_DOC_SECTIONS += vp8 vp8_decoder
78endif
79
John Koleszar7b8dfcb2012-11-06 16:59:01 -080080ifneq ($(CONFIG_VP9_ENCODER)$(CONFIG_VP9_DECODER),)
81 VP9_PREFIX=vp9/
82 include $(SRC_PATH_BARE)/$(VP9_PREFIX)vp9_common.mk
83endif
John Koleszar0ea50ce2010-05-18 11:58:33 -040084
Ronald S. Bultje4b2c2b92012-11-01 11:09:58 -070085ifeq ($(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))
John Koleszar7b8dfcb2012-11-06 16:59:01 -080090 CODEC_SRCS-yes += $(VP9_PREFIX)vp9cx.mk vpx/vp8.h vpx/vp8cx.h
John Koleszar7b8dfcb2012-11-06 16:59:01 -080091 INSTALL-LIBS-yes += include/vpx/vp8.h include/vpx/vp8cx.h
James Zernf12ebfc2014-05-14 19:45:20 -070092 INSTALL-LIBS-$(CONFIG_SPATIAL_SVC) += include/vpx/svc_context.h
Ronald S. Bultje4b2c2b92012-11-01 11:09:58 -070093 INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/$(VP9_PREFIX)/%
John Koleszar0ea50ce2010-05-18 11:58:33 -040094 CODEC_DOC_SRCS += vpx/vp8.h vpx/vp8cx.h
Ronald S. Bultje4b2c2b92012-11-01 11:09:58 -070095 CODEC_DOC_SECTIONS += vp9 vp9_encoder
John Koleszar0ea50ce2010-05-18 11:58:33 -040096endif
97
Ronald S. Bultje4b2c2b92012-11-01 11:09:58 -070098ifeq ($(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
John Koleszar0ea50ce2010-05-18 11:58:33 -0400104 INSTALL-LIBS-yes += include/vpx/vp8.h include/vpx/vp8dx.h
Ronald S. Bultje4b2c2b92012-11-01 11:09:58 -0700105 INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/$(VP9_PREFIX)/%
John Koleszar0ea50ce2010-05-18 11:58:33 -0400106 CODEC_DOC_SRCS += vpx/vp8.h vpx/vp8dx.h
Ronald S. Bultje4b2c2b92012-11-01 11:09:58 -0700107 CODEC_DOC_SECTIONS += vp9 vp9_decoder
John Koleszar0ea50ce2010-05-18 11:58:33 -0400108endif
109
Jim Bankoski1ae7f252014-08-22 13:32:14 -0700110VP9_PREFIX=vp9/
111$(BUILD_PFX)$(VP9_PREFIX)%.c.o: CFLAGS += -Wextra
John Koleszar0ea50ce2010-05-18 11:58:33 -0400112
113ifeq ($(CONFIG_ENCODERS),yes)
114 CODEC_DOC_SECTIONS += encoder
115endif
116ifeq ($(CONFIG_DECODERS),yes)
117 CODEC_DOC_SECTIONS += decoder
118endif
119
120
121ifeq ($(CONFIG_MSVS),yes)
122CODEC_LIB=$(if $(CONFIG_STATIC_MSVCRT),vpxmt,vpxmd)
James Berry0cc044f2012-05-02 18:09:54 -0400123GTEST_LIB=$(if $(CONFIG_STATIC_MSVCRT),gtestmt,gtestmd)
John Koleszar0ea50ce2010-05-18 11:58:33 -0400124# This variable uses deferred expansion intentionally, since the results of
125# $(wildcard) may change during the course of the Make.
126VS_PLATFORMS = $(foreach d,$(wildcard */Release/$(CODEC_LIB).lib),$(word 1,$(subst /, ,$(d))))
John Koleszar0ea50ce2010-05-18 11:58:33 -0400127endif
128
129# The following pairs define a mapping of locations in the distribution
130# tree to locations in the source/build trees.
John Koleszarb7492342010-05-24 11:39:59 -0400131INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/vpx/%
132INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/vpx_ports/%
John Koleszar670af3a2010-05-26 15:57:42 -0400133INSTALL_MAPS += $(LIBSUBDIR)/% %
John Koleszar0ea50ce2010-05-18 11:58:33 -0400134INSTALL_MAPS += src/% $(SRC_PATH_BARE)/%
135ifeq ($(CONFIG_MSVS),yes)
John Koleszar670af3a2010-05-26 15:57:42 -0400136INSTALL_MAPS += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/% $(p)/Release/%)
137INSTALL_MAPS += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/% $(p)/Debug/%)
John Koleszar0ea50ce2010-05-18 11:58:33 -0400138endif
139
John Koleszar0ea50ce2010-05-18 11:58:33 -0400140CODEC_SRCS-$(BUILD_LIBVPX) += build/make/version.sh
James Zern805078a2014-02-23 16:33:14 -0800141CODEC_SRCS-$(BUILD_LIBVPX) += build/make/rtcd.pl
John Koleszar5ebe94f2012-12-23 07:20:10 -0800142CODEC_SRCS-$(BUILD_LIBVPX) += vpx_ports/emmintrin_compat.h
Dmitry Kovalevbb65be92014-02-27 15:05:46 -0800143CODEC_SRCS-$(BUILD_LIBVPX) += vpx_ports/mem_ops.h
144CODEC_SRCS-$(BUILD_LIBVPX) += vpx_ports/mem_ops_aligned.h
John Koleszar5ebe94f2012-12-23 07:20:10 -0800145CODEC_SRCS-$(BUILD_LIBVPX) += vpx_ports/vpx_once.h
John Koleszar0ea50ce2010-05-18 11:58:33 -0400146CODEC_SRCS-$(BUILD_LIBVPX) += $(BUILD_PFX)vpx_config.c
147INSTALL-SRCS-no += $(BUILD_PFX)vpx_config.c
John Koleszar23963022013-01-16 16:44:33 -0800148ifeq ($(ARCH_X86)$(ARCH_X86_64),yes)
James Zerne707e952014-06-27 16:40:39 -0700149INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += third_party/x86inc/x86inc.asm
John Koleszar23963022013-01-16 16:44:33 -0800150endif
John Koleszar7aa97a32010-06-03 10:29:04 -0400151CODEC_EXPORTS-$(BUILD_LIBVPX) += vpx/exports_com
152CODEC_EXPORTS-$(CONFIG_ENCODERS) += vpx/exports_enc
153CODEC_EXPORTS-$(CONFIG_DECODERS) += vpx/exports_dec
John Koleszar0ea50ce2010-05-18 11:58:33 -0400154
John Koleszarb7492342010-05-24 11:39:59 -0400155INSTALL-LIBS-yes += include/vpx/vpx_codec.h
Frank Galligane8e15272014-02-05 17:44:42 -0800156INSTALL-LIBS-yes += include/vpx/vpx_frame_buffer.h
John Koleszarb7492342010-05-24 11:39:59 -0400157INSTALL-LIBS-yes += include/vpx/vpx_image.h
158INSTALL-LIBS-yes += include/vpx/vpx_integer.h
John Koleszarb7492342010-05-24 11:39:59 -0400159INSTALL-LIBS-$(CONFIG_DECODERS) += include/vpx/vpx_decoder.h
John Koleszarb7492342010-05-24 11:39:59 -0400160INSTALL-LIBS-$(CONFIG_ENCODERS) += include/vpx/vpx_encoder.h
John Koleszar0ea50ce2010-05-18 11:58:33 -0400161ifeq ($(CONFIG_EXTERNAL_BUILD),yes)
162ifeq ($(CONFIG_MSVS),yes)
John Koleszar670af3a2010-05-26 15:57:42 -0400163INSTALL-LIBS-yes += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/$(CODEC_LIB).lib)
164INSTALL-LIBS-$(CONFIG_DEBUG_LIBS) += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/$(CODEC_LIB)d.lib)
165INSTALL-LIBS-$(CONFIG_SHARED) += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/vpx.dll)
166INSTALL-LIBS-$(CONFIG_SHARED) += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/vpx.exp)
John Koleszar0ea50ce2010-05-18 11:58:33 -0400167endif
168else
James Zern495b2412011-07-25 15:40:36 -0700169INSTALL-LIBS-$(CONFIG_STATIC) += $(LIBSUBDIR)/libvpx.a
John Koleszar670af3a2010-05-26 15:57:42 -0400170INSTALL-LIBS-$(CONFIG_DEBUG_LIBS) += $(LIBSUBDIR)/libvpx_g.a
John Koleszar0ea50ce2010-05-18 11:58:33 -0400171endif
172
John Koleszar5ebe94f2012-12-23 07:20:10 -0800173CODEC_SRCS=$(call enabled,CODEC_SRCS)
John Koleszar0ea50ce2010-05-18 11:58:33 -0400174INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(CODEC_SRCS)
175INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(call enabled,CODEC_EXPORTS)
176
John Koleszar5e562c72011-08-12 14:59:10 -0400177
178# Generate a list of all enabled sources, in particular for exporting to gyp
179# based build systems.
180libvpx_srcs.txt:
181 @echo " [CREATE] $@"
182 @echo $(CODEC_SRCS) | xargs -n1 echo | sort -u > $@
Jim Bankoski975df8c2013-06-20 15:05:42 -0700183CLEAN-OBJS += libvpx_srcs.txt
John Koleszar5e562c72011-08-12 14:59:10 -0400184
185
John Koleszar0ea50ce2010-05-18 11:58:33 -0400186ifeq ($(CONFIG_EXTERNAL_BUILD),yes)
187ifeq ($(CONFIG_MSVS),yes)
188
John Koleszar0ea50ce2010-05-18 11:58:33 -0400189vpx.def: $(call enabled,CODEC_EXPORTS)
190 @echo " [CREATE] $@"
James Zerne8d58d32012-08-15 11:47:13 -0700191 $(qexec)$(SRC_PATH_BARE)/build/make/gen_msvs_def.sh\
John Koleszar0ea50ce2010-05-18 11:58:33 -0400192 --name=vpx\
193 --out=$@ $^
194CLEAN-OBJS += vpx.def
195
James Zernb92f7bc2014-03-04 19:46:29 -0800196# Assembly files that are included, but don't define symbols themselves.
197# Filtered out to avoid Visual Studio build warnings.
198ASM_INCLUDES := \
199 third_party/x86inc/x86inc.asm \
200 vpx_config.asm \
201 vpx_ports/x86_abi_support.asm \
202
Johann6eec73a2014-07-31 14:19:31 -0700203vpx.$(VCPROJ_SFX): $(CODEC_SRCS) vpx.def
John Koleszar0ea50ce2010-05-18 11:58:33 -0400204 @echo " [CREATE] $@"
Martin Storsjo0b4637e2013-05-17 00:56:46 +0300205 $(qexec)$(GEN_VCPROJ) \
Jim Bankoski1b16e742012-07-23 12:32:59 -0700206 $(if $(CONFIG_SHARED),--dll,--lib) \
207 --target=$(TOOLCHAIN) \
John Koleszar0ea50ce2010-05-18 11:58:33 -0400208 $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \
Johann128d2c22011-03-02 09:44:39 -0500209 --name=vpx \
210 --proj-guid=DCE19DAF-69AC-46DB-B14A-39F0FAA5DB74 \
211 --module-def=vpx.def \
212 --ver=$(CONFIG_VS_VERSION) \
James Zernf66590c2014-06-02 16:42:14 -0700213 --src-path-bare="$(SRC_PATH_BARE)" \
James Zernb92f7bc2014-03-04 19:46:29 -0800214 --out=$@ $(CFLAGS) \
215 $(filter-out $(addprefix %, $(ASM_INCLUDES)), $^) \
Johann128d2c22011-03-02 09:44:39 -0500216 --src-path-bare="$(SRC_PATH_BARE)" \
John Koleszar0ea50ce2010-05-18 11:58:33 -0400217
Martin Storsjo0b4637e2013-05-17 00:56:46 +0300218PROJECTS-$(BUILD_LIBVPX) += vpx.$(VCPROJ_SFX)
John Koleszar0ea50ce2010-05-18 11:58:33 -0400219
Martin Storsjo0b4637e2013-05-17 00:56:46 +0300220vpx.$(VCPROJ_SFX): vpx_config.asm
221vpx.$(VCPROJ_SFX): $(RTCD)
John Koleszar0ea50ce2010-05-18 11:58:33 -0400222
223endif
224else
225LIBVPX_OBJS=$(call objs,$(CODEC_SRCS))
226OBJS-$(BUILD_LIBVPX) += $(LIBVPX_OBJS)
John Koleszar06f58c02011-08-03 09:20:37 -0400227LIBS-$(if $(BUILD_LIBVPX),$(CONFIG_STATIC)) += $(BUILD_PFX)libvpx.a $(BUILD_PFX)libvpx_g.a
John Koleszar0ea50ce2010-05-18 11:58:33 -0400228$(BUILD_PFX)libvpx_g.a: $(LIBVPX_OBJS)
John Koleszar7aa97a32010-06-03 10:29:04 -0400229
jimbankoski45e551b2012-07-25 19:39:33 -0700230
John Koleszar7aa97a32010-06-03 10:29:04 -0400231BUILD_LIBVPX_SO := $(if $(BUILD_LIBVPX),$(CONFIG_SHARED))
jimbankoski45e551b2012-07-25 19:39:33 -0700232
233ifeq ($(filter darwin%,$(TGT_OS)),$(TGT_OS))
234LIBVPX_SO := libvpx.$(VERSION_MAJOR).dylib
235EXPORT_FILE := libvpx.syms
236LIBVPX_SO_SYMLINKS := $(addprefix $(LIBSUBDIR)/, \
237 libvpx.dylib )
238else
John Koleszar7aa97a32010-06-03 10:29:04 -0400239LIBVPX_SO := libvpx.so.$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH)
jimbankoski45e551b2012-07-25 19:39:33 -0700240EXPORT_FILE := libvpx.ver
241SYM_LINK := libvpx.so
John Koleszar7aa97a32010-06-03 10:29:04 -0400242LIBVPX_SO_SYMLINKS := $(addprefix $(LIBSUBDIR)/, \
243 libvpx.so libvpx.so.$(VERSION_MAJOR) \
244 libvpx.so.$(VERSION_MAJOR).$(VERSION_MINOR))
jimbankoski45e551b2012-07-25 19:39:33 -0700245endif
246
247LIBS-$(BUILD_LIBVPX_SO) += $(BUILD_PFX)$(LIBVPX_SO)\
248 $(notdir $(LIBVPX_SO_SYMLINKS))
249$(BUILD_PFX)$(LIBVPX_SO): $(LIBVPX_OBJS) $(EXPORT_FILE)
250$(BUILD_PFX)$(LIBVPX_SO): extralibs += -lm
251$(BUILD_PFX)$(LIBVPX_SO): SONAME = libvpx.so.$(VERSION_MAJOR)
252$(BUILD_PFX)$(LIBVPX_SO): EXPORTS_FILE = $(EXPORT_FILE)
John Koleszar7aa97a32010-06-03 10:29:04 -0400253
254libvpx.ver: $(call enabled,CODEC_EXPORTS)
255 @echo " [CREATE] $@"
256 $(qexec)echo "{ global:" > $@
257 $(qexec)for f in $?; do awk '{print $$2";"}' < $$f >>$@; done
258 $(qexec)echo "local: *; };" >> $@
259CLEAN-OBJS += libvpx.ver
260
jimbankoski45e551b2012-07-25 19:39:33 -0700261libvpx.syms: $(call enabled,CODEC_EXPORTS)
262 @echo " [CREATE] $@"
263 $(qexec)awk '{print "_"$$2}' $^ >$@
264CLEAN-OBJS += libvpx.syms
265
James Zern495b2412011-07-25 15:40:36 -0700266define libvpx_symlink_template
267$(1): $(2)
jimbankoski45e551b2012-07-25 19:39:33 -0700268 @echo " [LN] $(2) $$@"
John Koleszar5ebe94f2012-12-23 07:20:10 -0800269 $(qexec)mkdir -p $$(dir $$@)
jimbankoski45e551b2012-07-25 19:39:33 -0700270 $(qexec)ln -sf $(2) $$@
James Zern495b2412011-07-25 15:40:36 -0700271endef
272
273$(eval $(call libvpx_symlink_template,\
274 $(addprefix $(BUILD_PFX),$(notdir $(LIBVPX_SO_SYMLINKS))),\
275 $(BUILD_PFX)$(LIBVPX_SO)))
276$(eval $(call libvpx_symlink_template,\
277 $(addprefix $(DIST_DIR)/,$(LIBVPX_SO_SYMLINKS)),\
John Koleszar5ebe94f2012-12-23 07:20:10 -0800278 $(LIBVPX_SO)))
John Koleszar7aa97a32010-06-03 10:29:04 -0400279
jimbankoski45e551b2012-07-25 19:39:33 -0700280
281INSTALL-LIBS-$(BUILD_LIBVPX_SO) += $(LIBVPX_SO_SYMLINKS)
282INSTALL-LIBS-$(BUILD_LIBVPX_SO) += $(LIBSUBDIR)/$(LIBVPX_SO)
283
Ralph Giles607f8422011-03-28 12:04:51 -0700284
285LIBS-$(BUILD_LIBVPX) += vpx.pc
286vpx.pc: config.mk libs.mk
287 @echo " [CREATE] $@"
288 $(qexec)echo '# pkg-config file from libvpx $(VERSION_STRING)' > $@
289 $(qexec)echo 'prefix=$(PREFIX)' >> $@
290 $(qexec)echo 'exec_prefix=$${prefix}' >> $@
Takanori MATSUURAa7eea3e2012-04-20 15:11:46 -0700291 $(qexec)echo 'libdir=$${prefix}/$(LIBSUBDIR)' >> $@
Ralph Giles607f8422011-03-28 12:04:51 -0700292 $(qexec)echo 'includedir=$${prefix}/include' >> $@
293 $(qexec)echo '' >> $@
294 $(qexec)echo 'Name: vpx' >> $@
295 $(qexec)echo 'Description: WebM Project VPx codec implementation' >> $@
296 $(qexec)echo 'Version: $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH)' >> $@
297 $(qexec)echo 'Requires:' >> $@
298 $(qexec)echo 'Conflicts:' >> $@
Ronald S. Bultjea742a732012-06-25 09:58:09 -0700299 $(qexec)echo 'Libs: -L$${libdir} -lvpx -lm' >> $@
Johannb46d58a2013-01-18 11:31:22 -0800300ifeq ($(HAVE_PTHREAD_H),yes)
John Koleszarbd6ffaa2012-08-21 10:54:30 -0700301 $(qexec)echo 'Libs.private: -lm -lpthread' >> $@
Johannb46d58a2013-01-18 11:31:22 -0800302else
303 $(qexec)echo 'Libs.private: -lm' >> $@
304endif
Ralph Giles607f8422011-03-28 12:04:51 -0700305 $(qexec)echo 'Cflags: -I$${includedir}' >> $@
306INSTALL-LIBS-yes += $(LIBSUBDIR)/pkgconfig/vpx.pc
307INSTALL_MAPS += $(LIBSUBDIR)/pkgconfig/%.pc %.pc
308CLEAN-OBJS += vpx.pc
John Koleszar0ea50ce2010-05-18 11:58:33 -0400309endif
310
311LIBS-$(LIPO_LIBVPX) += libvpx.a
312$(eval $(if $(LIPO_LIBVPX),$(call lipo_lib_template,libvpx.a)))
313
314#
315# Rule to make assembler configuration file from C configuration file
316#
317ifeq ($(ARCH_X86)$(ARCH_X86_64),yes)
318# YASM
319$(BUILD_PFX)vpx_config.asm: $(BUILD_PFX)vpx_config.h
320 @echo " [CREATE] $@"
321 @egrep "#define [A-Z0-9_]+ [01]" $< \
322 | awk '{print $$2 " equ " $$3}' > $@
323else
324ADS2GAS=$(if $(filter yes,$(CONFIG_GCC)),| $(ASM_CONVERSION))
325$(BUILD_PFX)vpx_config.asm: $(BUILD_PFX)vpx_config.h
326 @echo " [CREATE] $@"
327 @egrep "#define [A-Z0-9_]+ [01]" $< \
328 | awk '{print $$2 " EQU " $$3}' $(ADS2GAS) > $@
329 @echo " END" $(ADS2GAS) >> $@
330CLEAN-OBJS += $(BUILD_PFX)vpx_config.asm
331endif
332
333#
Johann6eec73a2014-07-31 14:19:31 -0700334# Add assembler dependencies for configuration.
John Koleszar0ea50ce2010-05-18 11:58:33 -0400335#
Johann128d2c22011-03-02 09:44:39 -0500336$(filter %.s.o,$(OBJS-yes)): $(BUILD_PFX)vpx_config.asm
337$(filter %$(ASM).o,$(OBJS-yes)): $(BUILD_PFX)vpx_config.asm
John Koleszar0ea50ce2010-05-18 11:58:33 -0400338
Johann40dcae92011-02-04 17:44:31 -0500339
John Koleszar0ea50ce2010-05-18 11:58:33 -0400340$(shell $(SRC_PATH_BARE)/build/make/version.sh "$(SRC_PATH_BARE)" $(BUILD_PFX)vpx_version.h)
341CLEAN-OBJS += $(BUILD_PFX)vpx_version.h
342
John Koleszara9100492011-08-19 14:06:00 -0400343
James Berry07c71ef2011-11-04 11:48:30 -0400344##
345## libvpx test directives
346##
James Berry07c71ef2011-11-04 11:48:30 -0400347ifeq ($(CONFIG_UNIT_TESTS),yes)
John Koleszar00748632012-06-20 14:45:22 -0700348LIBVPX_TEST_DATA_PATH ?= .
John Koleszare82d2612012-05-16 16:25:51 -0700349
350include $(SRC_PATH_BARE)/test/test.mk
351LIBVPX_TEST_SRCS=$(addprefix test/,$(call enabled,LIBVPX_TEST_SRCS))
KO Myung-Huna3444562013-02-22 12:35:18 +0900352LIBVPX_TEST_BINS=./test_libvpx$(EXE_SFX)
John Koleszar00748632012-06-20 14:45:22 -0700353LIBVPX_TEST_DATA=$(addprefix $(LIBVPX_TEST_DATA_PATH)/,\
354 $(call enabled,LIBVPX_TEST_DATA))
355libvpx_test_data_url=http://downloads.webmproject.org/test_data/libvpx/$(1)
356
James Zern4a7cebe2013-06-25 13:50:30 -0700357libvpx_test_srcs.txt:
358 @echo " [CREATE] $@"
359 @echo $(LIBVPX_TEST_SRCS) | xargs -n1 echo | sort -u > $@
360CLEAN-OBJS += libvpx_test_srcs.txt
361
Adrian Grange5b236662013-09-16 11:46:00 -0700362$(LIBVPX_TEST_DATA): $(SRC_PATH_BARE)/test/test-data.sha1
John Koleszar00748632012-06-20 14:45:22 -0700363 @echo " [DOWNLOAD] $@"
364 $(qexec)trap 'rm -f $@' INT TERM &&\
365 curl -L -o $@ $(call libvpx_test_data_url,$(@F))
366
367testdata:: $(LIBVPX_TEST_DATA)
James Zernd6fd2292014-07-29 20:43:56 -0700368 $(qexec)[ -x "$$(which sha1sum)" ] && sha1sum=sha1sum;\
369 [ -x "$$(which shasum)" ] && sha1sum=shasum;\
370 [ -x "$$(which sha1)" ] && sha1sum=sha1;\
371 if [ -n "$${sha1sum}" ]; then\
James Zern23fbef22014-07-29 20:31:23 -0700372 set -e;\
John Koleszar00748632012-06-20 14:45:22 -0700373 echo "Checking test data:";\
John Koleszaracd147c2012-06-29 12:15:00 -0700374 if [ -n "$(LIBVPX_TEST_DATA)" ]; then\
375 for f in $(call enabled,LIBVPX_TEST_DATA); do\
376 grep $$f $(SRC_PATH_BARE)/test/test-data.sha1 |\
James Zernd6fd2292014-07-29 20:43:56 -0700377 (cd $(LIBVPX_TEST_DATA_PATH); $${sha1sum} -c);\
John Koleszaracd147c2012-06-29 12:15:00 -0700378 done; \
379 fi; \
John Koleszar00748632012-06-20 14:45:22 -0700380 else\
381 echo "Skipping test data integrity check, sha1sum not found.";\
382 fi
John Koleszare82d2612012-05-16 16:25:51 -0700383
James Berry07c71ef2011-11-04 11:48:30 -0400384ifeq ($(CONFIG_EXTERNAL_BUILD),yes)
385ifeq ($(CONFIG_MSVS),yes)
386
Martin Storsjo0b4637e2013-05-17 00:56:46 +0300387gtest.$(VCPROJ_SFX): $(SRC_PATH_BARE)/third_party/googletest/src/src/gtest-all.cc
James Berry07c71ef2011-11-04 11:48:30 -0400388 @echo " [CREATE] $@"
Martin Storsjo0b4637e2013-05-17 00:56:46 +0300389 $(qexec)$(GEN_VCPROJ) \
James Berry07c71ef2011-11-04 11:48:30 -0400390 --lib \
391 --target=$(TOOLCHAIN) \
392 $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \
393 --name=gtest \
394 --proj-guid=EC00E1EC-AF68-4D92-A255-181690D1C9B1 \
395 --ver=$(CONFIG_VS_VERSION) \
396 --src-path-bare="$(SRC_PATH_BARE)" \
Yaowu Xuc2021002012-12-04 12:28:10 -0800397 -D_VARIADIC_MAX=10 \
Martin Storsjo0b4637e2013-05-17 00:56:46 +0300398 --out=gtest.$(VCPROJ_SFX) $(SRC_PATH_BARE)/third_party/googletest/src/src/gtest-all.cc \
James Berry07c71ef2011-11-04 11:48:30 -0400399 -I. -I"$(SRC_PATH_BARE)/third_party/googletest/src/include" -I"$(SRC_PATH_BARE)/third_party/googletest/src"
400
Martin Storsjo0b4637e2013-05-17 00:56:46 +0300401PROJECTS-$(CONFIG_MSVS) += gtest.$(VCPROJ_SFX)
James Berry07c71ef2011-11-04 11:48:30 -0400402
Martin Storsjo9a5cac02013-05-18 19:57:19 +0300403test_libvpx.$(VCPROJ_SFX): $(LIBVPX_TEST_SRCS) vpx.$(VCPROJ_SFX) gtest.$(VCPROJ_SFX)
John Koleszar7f63bfa2012-06-01 10:43:47 -0700404 @echo " [CREATE] $@"
Martin Storsjo0b4637e2013-05-17 00:56:46 +0300405 $(qexec)$(GEN_VCPROJ) \
John Koleszar7f63bfa2012-06-01 10:43:47 -0700406 --exe \
407 --target=$(TOOLCHAIN) \
408 --name=test_libvpx \
Yaowu Xuc2021002012-12-04 12:28:10 -0800409 -D_VARIADIC_MAX=10 \
John Koleszar7f63bfa2012-06-01 10:43:47 -0700410 --proj-guid=CD837F5F-52D8-4314-A370-895D614166A7 \
411 --ver=$(CONFIG_VS_VERSION) \
James Zernf66590c2014-06-02 16:42:14 -0700412 --src-path-bare="$(SRC_PATH_BARE)" \
John Koleszar7f63bfa2012-06-01 10:43:47 -0700413 $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \
414 --out=$@ $(INTERNAL_CFLAGS) $(CFLAGS) \
James Berry07c71ef2011-11-04 11:48:30 -0400415 -I. -I"$(SRC_PATH_BARE)/third_party/googletest/src/include" \
Martin Storsjoa37e84d2013-05-19 12:21:29 +0300416 -L. -l$(CODEC_LIB) -l$(GTEST_LIB) $^
James Berry07c71ef2011-11-04 11:48:30 -0400417
Martin Storsjo0b4637e2013-05-17 00:56:46 +0300418PROJECTS-$(CONFIG_MSVS) += test_libvpx.$(VCPROJ_SFX)
James Berry07c71ef2011-11-04 11:48:30 -0400419
James Zern7059c1d2013-05-31 16:08:09 -0700420LIBVPX_TEST_BINS := $(addprefix $(TGT_OS:win64=x64)/Release/,$(notdir $(LIBVPX_TEST_BINS)))
James Berry07c71ef2011-11-04 11:48:30 -0400421endif
422else
423
424include $(SRC_PATH_BARE)/third_party/googletest/gtest.mk
425GTEST_SRCS := $(addprefix third_party/googletest/src/,$(call enabled,GTEST_SRCS))
426GTEST_OBJS=$(call objs,$(GTEST_SRCS))
James Zerne4d2c252013-06-26 18:35:11 -0700427ifeq ($(filter win%,$(TGT_OS)),$(TGT_OS))
428# Disabling pthreads globally will cause issues on darwin and possibly elsewhere
429$(GTEST_OBJS) $(GTEST_OBJS:.o=.d): CXXFLAGS += -DGTEST_HAS_PTHREAD=0
430endif
John Koleszar8631c1b2012-05-22 10:37:20 -0700431$(GTEST_OBJS) $(GTEST_OBJS:.o=.d): CXXFLAGS += -I$(SRC_PATH_BARE)/third_party/googletest/src
432$(GTEST_OBJS) $(GTEST_OBJS:.o=.d): CXXFLAGS += -I$(SRC_PATH_BARE)/third_party/googletest/src/include
James Berry07c71ef2011-11-04 11:48:30 -0400433OBJS-$(BUILD_LIBVPX) += $(GTEST_OBJS)
434LIBS-$(BUILD_LIBVPX) += $(BUILD_PFX)libgtest.a $(BUILD_PFX)libgtest_g.a
435$(BUILD_PFX)libgtest_g.a: $(GTEST_OBJS)
436
John Koleszare82d2612012-05-16 16:25:51 -0700437LIBVPX_TEST_OBJS=$(sort $(call objs,$(LIBVPX_TEST_SRCS)))
438$(LIBVPX_TEST_OBJS) $(LIBVPX_TEST_OBJS:.o=.d): CXXFLAGS += -I$(SRC_PATH_BARE)/third_party/googletest/src
439$(LIBVPX_TEST_OBJS) $(LIBVPX_TEST_OBJS:.o=.d): CXXFLAGS += -I$(SRC_PATH_BARE)/third_party/googletest/src/include
James Berry07c71ef2011-11-04 11:48:30 -0400440OBJS-$(BUILD_LIBVPX) += $(LIBVPX_TEST_OBJS)
James Zern97fd7c52012-08-15 11:45:12 -0700441BINS-$(BUILD_LIBVPX) += $(LIBVPX_TEST_BINS)
James Berry07c71ef2011-11-04 11:48:30 -0400442
John Koleszaracd147c2012-06-29 12:15:00 -0700443CODEC_LIB=$(if $(CONFIG_DEBUG_LIBS),vpx_g,vpx)
444CODEC_LIB_SUF=$(if $(CONFIG_SHARED),.so,.a)
James Berry07c71ef2011-11-04 11:48:30 -0400445$(foreach bin,$(LIBVPX_TEST_BINS),\
John Koleszaracd147c2012-06-29 12:15:00 -0700446 $(if $(BUILD_LIBVPX),$(eval $(bin): \
447 lib$(CODEC_LIB)$(CODEC_LIB_SUF) libgtest.a ))\
James Berry07c71ef2011-11-04 11:48:30 -0400448 $(if $(BUILD_LIBVPX),$(eval $(call linkerxx_template,$(bin),\
John Koleszare82d2612012-05-16 16:25:51 -0700449 $(LIBVPX_TEST_OBJS) \
James Zerne4d2c252013-06-26 18:35:11 -0700450 -L. -lvpx -lgtest $(extralibs) -lm)\
James Berry07c71ef2011-11-04 11:48:30 -0400451 )))\
452 $(if $(LIPO_LIBS),$(eval $(call lipo_bin_template,$(bin))))\
453
James Berry07c71ef2011-11-04 11:48:30 -0400454endif
James Zern7059c1d2013-05-31 16:08:09 -0700455
Johann0239f112014-01-08 15:45:14 -0800456# Install test sources only if codec source is included
457INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(patsubst $(SRC_PATH_BARE)/%,%,\
458 $(shell find $(SRC_PATH_BARE)/third_party/googletest -type f))
459INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(LIBVPX_TEST_SRCS)
460
James Zern7059c1d2013-05-31 16:08:09 -0700461define test_shard_template
462test:: test_shard.$(1)
463test_shard.$(1): $(LIBVPX_TEST_BINS) testdata
464 @set -e; \
465 for t in $(LIBVPX_TEST_BINS); do \
466 export GTEST_SHARD_INDEX=$(1); \
467 export GTEST_TOTAL_SHARDS=$(2); \
468 $$$$t; \
469 done
470.PHONY: test_shard.$(1)
471endef
472
473NUM_SHARDS := 10
474SHARDS := 0 1 2 3 4 5 6 7 8 9
475$(foreach s,$(SHARDS),$(eval $(call test_shard_template,$(s),$(NUM_SHARDS))))
476
James Berry07c71ef2011-11-04 11:48:30 -0400477endif
478
479##
480## documentation directives
481##
John Koleszar0ea50ce2010-05-18 11:58:33 -0400482CLEAN-OBJS += libs.doxy
483DOCS-yes += libs.doxy
484libs.doxy: $(CODEC_DOC_SRCS)
485 @echo " [CREATE] $@"
486 @rm -f $@
487 @echo "INPUT += $^" >> $@
John Koleszar0ea50ce2010-05-18 11:58:33 -0400488 @echo "INCLUDE_PATH += ." >> $@;
489 @echo "ENABLED_SECTIONS += $(sort $(CODEC_DOC_SECTIONS))" >> $@
John Koleszare82d2612012-05-16 16:25:51 -0700490
John Koleszara9c75972012-11-08 17:09:30 -0800491## Generate rtcd.h for all objects
492$(OBJS-yes:.o=.d): $(RTCD)
John Koleszarb72373d2012-10-31 13:13:19 -0700493
494## Update the global src list
495SRCS += $(CODEC_SRCS) $(LIBVPX_TEST_SRCS) $(GTEST_SRCS)
Tom Finegan7b7c8432014-04-22 10:38:43 -0700496
497##
498## vpxdec/vpxenc tests.
499##
500ifeq ($(CONFIG_UNIT_TESTS),yes)
501TEST_BIN_PATH = .
502ifeq ($(CONFIG_MSVS),yes)
503# MSVC will build both Debug and Release configurations of tools in a
504# sub directory named for the current target. Assume the user wants to
505# run the Release tools, and assign TEST_BIN_PATH accordingly.
506# TODO(tomfinegan): Is this adequate for ARM?
507# TODO(tomfinegan): Support running the debug versions of tools?
508TEST_BIN_PATH := $(addsuffix /$(TGT_OS:win64=x64)/Release, $(TEST_BIN_PATH))
509endif
510utiltest: testdata
511 $(qexec)$(SRC_PATH_BARE)/test/vpxdec.sh \
512 --test-data-path $(LIBVPX_TEST_DATA_PATH) \
513 --bin-path $(TEST_BIN_PATH)
514 $(qexec)$(SRC_PATH_BARE)/test/vpxenc.sh \
515 --test-data-path $(LIBVPX_TEST_DATA_PATH) \
516 --bin-path $(TEST_BIN_PATH)
517else
518utiltest:
519 @echo Unit tests must be enabled to make the utiltest target.
520endif
Tom Fineganbc27d7e2014-05-15 21:34:42 -0700521
522##
523## Example tests.
524##
525ifeq ($(CONFIG_UNIT_TESTS),yes)
526# All non-MSVC targets output example targets in a sub dir named examples.
527EXAMPLES_BIN_PATH = examples
528ifeq ($(CONFIG_MSVS),yes)
529# MSVC will build both Debug and Release configurations of the examples in a
530# sub directory named for the current target. Assume the user wants to
531# run the Release tools, and assign EXAMPLES_BIN_PATH accordingly.
532# TODO(tomfinegan): Is this adequate for ARM?
533# TODO(tomfinegan): Support running the debug versions of tools?
534EXAMPLES_BIN_PATH := $(TGT_OS:win64=x64)/Release
535endif
536exampletest: examples testdata
537 $(qexec)$(SRC_PATH_BARE)/test/examples.sh \
538 --test-data-path $(LIBVPX_TEST_DATA_PATH) \
539 --bin-path $(EXAMPLES_BIN_PATH)
540else
541exampletest:
542 @echo Unit tests must be enabled to make the exampletest target.
543endif