blob: 85c5f8a02eee33454767a197fd63f2a344682925 [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#
21# Calculate platform- and compiler-specific offsets for hand coded assembly
22#
23ifeq ($(filter icc gcc,$(TGT_CC)), $(TGT_CC))
24OFFSET_PATTERN:='^[a-zA-Z0-9_]* EQU'
25define asm_offsets_template
John Koleszar1760c392012-11-27 15:54:54 -080026$$(BUILD_PFX)$(1): $$(BUILD_PFX)$(2).S
John Koleszar7b8dfcb2012-11-06 16:59:01 -080027 @echo " [CREATE] $$@"
28 $$(qexec)LC_ALL=C grep $$(OFFSET_PATTERN) $$< | tr -d '$$$$\#' $$(ADS2GAS) > $$@
John Koleszar1760c392012-11-27 15:54:54 -080029$$(BUILD_PFX)$(2).S: $(2)
30CLEAN-OBJS += $$(BUILD_PFX)$(1) $(2).S
John Koleszar7b8dfcb2012-11-06 16:59:01 -080031endef
32else
33 ifeq ($(filter rvct,$(TGT_CC)), $(TGT_CC))
34define asm_offsets_template
35$$(BUILD_PFX)$(1): obj_int_extract
John Koleszar1760c392012-11-27 15:54:54 -080036$$(BUILD_PFX)$(1): $$(BUILD_PFX)$(2).o
John Koleszar7b8dfcb2012-11-06 16:59:01 -080037 @echo " [CREATE] $$@"
38 $$(qexec)./obj_int_extract rvds $$< $$(ADS2GAS) > $$@
John Koleszar1760c392012-11-27 15:54:54 -080039OBJS-yes += $$(BUILD_PFX)$(2).o
John Koleszar7b8dfcb2012-11-06 16:59:01 -080040CLEAN-OBJS += $$(BUILD_PFX)$(1)
41$$(filter %$$(ASM).o,$$(OBJS-yes)): $$(BUILD_PFX)$(1)
42endef
43endif # rvct
44endif # !gcc
45
John Koleszara9c75972012-11-08 17:09:30 -080046#
47# Rule to generate runtime cpu detection files
48#
49define rtcd_h_template
50$$(BUILD_PFX)$(1).h: $$(SRC_PATH_BARE)/$(2)
51 @echo " [CREATE] $$@"
James Zern805078a2014-02-23 16:33:14 -080052 $$(qexec)$$(SRC_PATH_BARE)/build/make/rtcd.pl --arch=$$(TGT_ISA) \
John Koleszara9c75972012-11-08 17:09:30 -080053 --sym=$(1) \
Johann3810bca2013-04-17 10:52:50 -070054 --config=$$(CONFIG_DIR)$$(target)$$(if $$(FAT_ARCHS),,-$$(TOOLCHAIN)).mk \
John Koleszara9c75972012-11-08 17:09:30 -080055 $$(RTCD_OPTIONS) $$^ > $$@
56CLEAN-OBJS += $$(BUILD_PFX)$(1).h
57RTCD += $$(BUILD_PFX)$(1).h
58endef
John Koleszar7b8dfcb2012-11-06 16:59:01 -080059
Johann5d88a822012-03-05 16:36:23 -080060CODEC_SRCS-yes += CHANGELOG
John Koleszar4d86ef32010-06-22 08:44:48 -040061CODEC_SRCS-yes += libs.mk
62
Johanna5ffcdd2012-11-15 16:28:20 -080063# 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)
69
John Koleszarb7492342010-05-24 11:39:59 -040070include $(SRC_PATH_BARE)/vpx/vpx_codec.mk
71CODEC_SRCS-yes += $(addprefix vpx/,$(call enabled,API_SRCS))
Johann999f31f2012-11-15 17:19:44 -080072CODEC_DOC_SRCS += $(addprefix vpx/,$(call enabled,API_DOC_SRCS))
John Koleszar0ea50ce2010-05-18 11:58:33 -040073
74include $(SRC_PATH_BARE)/vpx_mem/vpx_mem.mk
75CODEC_SRCS-yes += $(addprefix vpx_mem/,$(call enabled,MEM_SRCS))
76
77include $(SRC_PATH_BARE)/vpx_scale/vpx_scale.mk
78CODEC_SRCS-yes += $(addprefix vpx_scale/,$(call enabled,SCALE_SRCS))
79
Johanna5ffcdd2012-11-15 16:28:20 -080080include $(SRC_PATH_BARE)/vpx_ports/vpx_ports.mk
81CODEC_SRCS-yes += $(addprefix vpx_ports/,$(call enabled,PORTS_SRCS))
82
John Koleszar7b8dfcb2012-11-06 16:59:01 -080083ifneq ($(CONFIG_VP8_ENCODER)$(CONFIG_VP8_DECODER),)
84 VP8_PREFIX=vp8/
85 include $(SRC_PATH_BARE)/$(VP8_PREFIX)vp8_common.mk
86endif
John Koleszar0ea50ce2010-05-18 11:58:33 -040087
88ifeq ($(CONFIG_VP8_ENCODER),yes)
John Koleszar0ea50ce2010-05-18 11:58:33 -040089 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))
John Koleszar2bf8fb52012-05-02 16:37:37 -070092 INSTALL-LIBS-yes += include/vpx/vp8.h include/vpx/vp8cx.h
John Koleszarb7492342010-05-24 11:39:59 -040093 INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/$(VP8_PREFIX)/%
John Koleszar0ea50ce2010-05-18 11:58:33 -040094 CODEC_DOC_SECTIONS += vp8 vp8_encoder
95endif
96
97ifeq ($(CONFIG_VP8_DECODER),yes)
John Koleszar0ea50ce2010-05-18 11:58:33 -040098 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))
John Koleszarb7492342010-05-24 11:39:59 -0400101 INSTALL-LIBS-yes += include/vpx/vp8.h include/vpx/vp8dx.h
102 INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/$(VP8_PREFIX)/%
John Koleszar0ea50ce2010-05-18 11:58:33 -0400103 CODEC_DOC_SECTIONS += vp8 vp8_decoder
104endif
105
John Koleszar7b8dfcb2012-11-06 16:59:01 -0800106ifneq ($(CONFIG_VP9_ENCODER)$(CONFIG_VP9_DECODER),)
107 VP9_PREFIX=vp9/
108 include $(SRC_PATH_BARE)/$(VP9_PREFIX)vp9_common.mk
109endif
John Koleszar0ea50ce2010-05-18 11:58:33 -0400110
Ronald S. Bultje4b2c2b92012-11-01 11:09:58 -0700111ifeq ($(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))
John Koleszar7b8dfcb2012-11-06 16:59:01 -0800116 CODEC_SRCS-yes += $(VP9_PREFIX)vp9cx.mk vpx/vp8.h vpx/vp8cx.h
John Koleszar7b8dfcb2012-11-06 16:59:01 -0800117 INSTALL-LIBS-yes += include/vpx/vp8.h include/vpx/vp8cx.h
Ivan Maltz1ed0e1b2013-10-23 11:53:37 -0700118 INSTALL-LIBS-yes += include/vpx/svc_context.h
Ronald S. Bultje4b2c2b92012-11-01 11:09:58 -0700119 INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/$(VP9_PREFIX)/%
John Koleszar0ea50ce2010-05-18 11:58:33 -0400120 CODEC_DOC_SRCS += vpx/vp8.h vpx/vp8cx.h
Ronald S. Bultje4b2c2b92012-11-01 11:09:58 -0700121 CODEC_DOC_SECTIONS += vp9 vp9_encoder
John Koleszar0ea50ce2010-05-18 11:58:33 -0400122endif
123
Ronald S. Bultje4b2c2b92012-11-01 11:09:58 -0700124ifeq ($(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
John Koleszar0ea50ce2010-05-18 11:58:33 -0400130 INSTALL-LIBS-yes += include/vpx/vp8.h include/vpx/vp8dx.h
Ronald S. Bultje4b2c2b92012-11-01 11:09:58 -0700131 INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/$(VP9_PREFIX)/%
John Koleszar0ea50ce2010-05-18 11:58:33 -0400132 CODEC_DOC_SRCS += vpx/vp8.h vpx/vp8dx.h
Ronald S. Bultje4b2c2b92012-11-01 11:09:58 -0700133 CODEC_DOC_SECTIONS += vp9 vp9_decoder
John Koleszar0ea50ce2010-05-18 11:58:33 -0400134endif
135
136
137ifeq ($(CONFIG_ENCODERS),yes)
138 CODEC_DOC_SECTIONS += encoder
139endif
140ifeq ($(CONFIG_DECODERS),yes)
141 CODEC_DOC_SECTIONS += decoder
142endif
143
144
145ifeq ($(CONFIG_MSVS),yes)
146CODEC_LIB=$(if $(CONFIG_STATIC_MSVCRT),vpxmt,vpxmd)
James Berry0cc044f2012-05-02 18:09:54 -0400147GTEST_LIB=$(if $(CONFIG_STATIC_MSVCRT),gtestmt,gtestmd)
John Koleszar0ea50ce2010-05-18 11:58:33 -0400148# This variable uses deferred expansion intentionally, since the results of
149# $(wildcard) may change during the course of the Make.
150VS_PLATFORMS = $(foreach d,$(wildcard */Release/$(CODEC_LIB).lib),$(word 1,$(subst /, ,$(d))))
John Koleszar0ea50ce2010-05-18 11:58:33 -0400151endif
152
153# The following pairs define a mapping of locations in the distribution
154# tree to locations in the source/build trees.
John Koleszarb7492342010-05-24 11:39:59 -0400155INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/vpx/%
156INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/vpx_ports/%
John Koleszar670af3a2010-05-26 15:57:42 -0400157INSTALL_MAPS += $(LIBSUBDIR)/% %
John Koleszar0ea50ce2010-05-18 11:58:33 -0400158INSTALL_MAPS += src/% $(SRC_PATH_BARE)/%
159ifeq ($(CONFIG_MSVS),yes)
John Koleszar670af3a2010-05-26 15:57:42 -0400160INSTALL_MAPS += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/% $(p)/Release/%)
161INSTALL_MAPS += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/% $(p)/Debug/%)
John Koleszar0ea50ce2010-05-18 11:58:33 -0400162endif
163
John Koleszar0ea50ce2010-05-18 11:58:33 -0400164CODEC_SRCS-$(BUILD_LIBVPX) += build/make/version.sh
James Zern805078a2014-02-23 16:33:14 -0800165CODEC_SRCS-$(BUILD_LIBVPX) += build/make/rtcd.pl
John Koleszar5ebe94f2012-12-23 07:20:10 -0800166CODEC_SRCS-$(BUILD_LIBVPX) += vpx_ports/emmintrin_compat.h
Dmitry Kovalevbb65be92014-02-27 15:05:46 -0800167CODEC_SRCS-$(BUILD_LIBVPX) += vpx_ports/mem_ops.h
168CODEC_SRCS-$(BUILD_LIBVPX) += vpx_ports/mem_ops_aligned.h
John Koleszar5ebe94f2012-12-23 07:20:10 -0800169CODEC_SRCS-$(BUILD_LIBVPX) += vpx_ports/vpx_once.h
John Koleszar0ea50ce2010-05-18 11:58:33 -0400170CODEC_SRCS-$(BUILD_LIBVPX) += $(BUILD_PFX)vpx_config.c
171INSTALL-SRCS-no += $(BUILD_PFX)vpx_config.c
John Koleszar23963022013-01-16 16:44:33 -0800172ifeq ($(ARCH_X86)$(ARCH_X86_64),yes)
Ronald S. Bultje42a7f682012-06-19 15:34:49 -0700173CODEC_SRCS-$(BUILD_LIBVPX) += third_party/x86inc/x86inc.asm
John Koleszar23963022013-01-16 16:44:33 -0800174endif
John Koleszar7aa97a32010-06-03 10:29:04 -0400175CODEC_EXPORTS-$(BUILD_LIBVPX) += vpx/exports_com
176CODEC_EXPORTS-$(CONFIG_ENCODERS) += vpx/exports_enc
177CODEC_EXPORTS-$(CONFIG_DECODERS) += vpx/exports_dec
John Koleszar0ea50ce2010-05-18 11:58:33 -0400178
John Koleszarb7492342010-05-24 11:39:59 -0400179INSTALL-LIBS-yes += include/vpx/vpx_codec.h
Frank Galligane8e15272014-02-05 17:44:42 -0800180INSTALL-LIBS-yes += include/vpx/vpx_frame_buffer.h
John Koleszarb7492342010-05-24 11:39:59 -0400181INSTALL-LIBS-yes += include/vpx/vpx_image.h
182INSTALL-LIBS-yes += include/vpx/vpx_integer.h
John Koleszarb7492342010-05-24 11:39:59 -0400183INSTALL-LIBS-$(CONFIG_DECODERS) += include/vpx/vpx_decoder.h
John Koleszarb7492342010-05-24 11:39:59 -0400184INSTALL-LIBS-$(CONFIG_ENCODERS) += include/vpx/vpx_encoder.h
John Koleszar0ea50ce2010-05-18 11:58:33 -0400185ifeq ($(CONFIG_EXTERNAL_BUILD),yes)
186ifeq ($(CONFIG_MSVS),yes)
John Koleszar670af3a2010-05-26 15:57:42 -0400187INSTALL-LIBS-yes += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/$(CODEC_LIB).lib)
188INSTALL-LIBS-$(CONFIG_DEBUG_LIBS) += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/$(CODEC_LIB)d.lib)
189INSTALL-LIBS-$(CONFIG_SHARED) += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/vpx.dll)
190INSTALL-LIBS-$(CONFIG_SHARED) += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/vpx.exp)
John Koleszar0ea50ce2010-05-18 11:58:33 -0400191endif
192else
James Zern495b2412011-07-25 15:40:36 -0700193INSTALL-LIBS-$(CONFIG_STATIC) += $(LIBSUBDIR)/libvpx.a
John Koleszar670af3a2010-05-26 15:57:42 -0400194INSTALL-LIBS-$(CONFIG_DEBUG_LIBS) += $(LIBSUBDIR)/libvpx_g.a
John Koleszar0ea50ce2010-05-18 11:58:33 -0400195endif
196
John Koleszar5ebe94f2012-12-23 07:20:10 -0800197CODEC_SRCS=$(call enabled,CODEC_SRCS)
John Koleszar0ea50ce2010-05-18 11:58:33 -0400198INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(CODEC_SRCS)
199INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(call enabled,CODEC_EXPORTS)
200
John Koleszar5e562c72011-08-12 14:59:10 -0400201
202# Generate a list of all enabled sources, in particular for exporting to gyp
203# based build systems.
204libvpx_srcs.txt:
205 @echo " [CREATE] $@"
206 @echo $(CODEC_SRCS) | xargs -n1 echo | sort -u > $@
Jim Bankoski975df8c2013-06-20 15:05:42 -0700207CLEAN-OBJS += libvpx_srcs.txt
John Koleszar5e562c72011-08-12 14:59:10 -0400208
209
John Koleszar0ea50ce2010-05-18 11:58:33 -0400210ifeq ($(CONFIG_EXTERNAL_BUILD),yes)
211ifeq ($(CONFIG_MSVS),yes)
212
James Zern1c3de842014-01-29 17:26:02 -0800213obj_int_extract.bat: $(SRC_PATH_BARE)/build/$(MSVS_ARCH_DIR)/obj_int_extract.bat
214 @cp $^ $@
215
216obj_int_extract.$(VCPROJ_SFX): obj_int_extract.bat
Martin Storsjo0b4637e2013-05-17 00:56:46 +0300217obj_int_extract.$(VCPROJ_SFX): $(SRC_PATH_BARE)/build/make/obj_int_extract.c
Johann128d2c22011-03-02 09:44:39 -0500218 @echo " [CREATE] $@"
Martin Storsjo0b4637e2013-05-17 00:56:46 +0300219 $(qexec)$(GEN_VCPROJ) \
Johann128d2c22011-03-02 09:44:39 -0500220 --exe \
221 --target=$(TOOLCHAIN) \
222 --name=obj_int_extract \
223 --ver=$(CONFIG_VS_VERSION) \
224 --proj-guid=E1360C65-D375-4335-8057-7ED99CC3F9B2 \
225 $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \
226 --out=$@ $^ \
227 -I. \
228 -I"$(SRC_PATH_BARE)" \
229
Martin Storsjo0b4637e2013-05-17 00:56:46 +0300230PROJECTS-$(BUILD_LIBVPX) += obj_int_extract.$(VCPROJ_SFX)
Johann128d2c22011-03-02 09:44:39 -0500231
John Koleszar0ea50ce2010-05-18 11:58:33 -0400232vpx.def: $(call enabled,CODEC_EXPORTS)
233 @echo " [CREATE] $@"
James Zerne8d58d32012-08-15 11:47:13 -0700234 $(qexec)$(SRC_PATH_BARE)/build/make/gen_msvs_def.sh\
John Koleszar0ea50ce2010-05-18 11:58:33 -0400235 --name=vpx\
236 --out=$@ $^
237CLEAN-OBJS += vpx.def
238
James Zernb92f7bc2014-03-04 19:46:29 -0800239# Assembly files that are included, but don't define symbols themselves.
240# Filtered out to avoid Visual Studio build warnings.
241ASM_INCLUDES := \
242 third_party/x86inc/x86inc.asm \
243 vpx_config.asm \
244 vpx_ports/x86_abi_support.asm \
245
Martin Storsjo9a5cac02013-05-18 19:57:19 +0300246vpx.$(VCPROJ_SFX): $(CODEC_SRCS) vpx.def obj_int_extract.$(VCPROJ_SFX)
John Koleszar0ea50ce2010-05-18 11:58:33 -0400247 @echo " [CREATE] $@"
Martin Storsjo0b4637e2013-05-17 00:56:46 +0300248 $(qexec)$(GEN_VCPROJ) \
Jim Bankoski1b16e742012-07-23 12:32:59 -0700249 $(if $(CONFIG_SHARED),--dll,--lib) \
250 --target=$(TOOLCHAIN) \
John Koleszar0ea50ce2010-05-18 11:58:33 -0400251 $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \
Johann128d2c22011-03-02 09:44:39 -0500252 --name=vpx \
253 --proj-guid=DCE19DAF-69AC-46DB-B14A-39F0FAA5DB74 \
254 --module-def=vpx.def \
255 --ver=$(CONFIG_VS_VERSION) \
James Zernb92f7bc2014-03-04 19:46:29 -0800256 --out=$@ $(CFLAGS) \
257 $(filter-out $(addprefix %, $(ASM_INCLUDES)), $^) \
Johann128d2c22011-03-02 09:44:39 -0500258 --src-path-bare="$(SRC_PATH_BARE)" \
John Koleszar0ea50ce2010-05-18 11:58:33 -0400259
Martin Storsjo0b4637e2013-05-17 00:56:46 +0300260PROJECTS-$(BUILD_LIBVPX) += vpx.$(VCPROJ_SFX)
John Koleszar0ea50ce2010-05-18 11:58:33 -0400261
Martin Storsjo0b4637e2013-05-17 00:56:46 +0300262vpx.$(VCPROJ_SFX): vpx_config.asm
263vpx.$(VCPROJ_SFX): $(RTCD)
John Koleszar0ea50ce2010-05-18 11:58:33 -0400264
265endif
266else
267LIBVPX_OBJS=$(call objs,$(CODEC_SRCS))
268OBJS-$(BUILD_LIBVPX) += $(LIBVPX_OBJS)
John Koleszar06f58c02011-08-03 09:20:37 -0400269LIBS-$(if $(BUILD_LIBVPX),$(CONFIG_STATIC)) += $(BUILD_PFX)libvpx.a $(BUILD_PFX)libvpx_g.a
John Koleszar0ea50ce2010-05-18 11:58:33 -0400270$(BUILD_PFX)libvpx_g.a: $(LIBVPX_OBJS)
John Koleszar7aa97a32010-06-03 10:29:04 -0400271
jimbankoski45e551b2012-07-25 19:39:33 -0700272
John Koleszar7aa97a32010-06-03 10:29:04 -0400273BUILD_LIBVPX_SO := $(if $(BUILD_LIBVPX),$(CONFIG_SHARED))
jimbankoski45e551b2012-07-25 19:39:33 -0700274
275ifeq ($(filter darwin%,$(TGT_OS)),$(TGT_OS))
276LIBVPX_SO := libvpx.$(VERSION_MAJOR).dylib
277EXPORT_FILE := libvpx.syms
278LIBVPX_SO_SYMLINKS := $(addprefix $(LIBSUBDIR)/, \
279 libvpx.dylib )
280else
John Koleszar7aa97a32010-06-03 10:29:04 -0400281LIBVPX_SO := libvpx.so.$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH)
jimbankoski45e551b2012-07-25 19:39:33 -0700282EXPORT_FILE := libvpx.ver
283SYM_LINK := libvpx.so
John Koleszar7aa97a32010-06-03 10:29:04 -0400284LIBVPX_SO_SYMLINKS := $(addprefix $(LIBSUBDIR)/, \
285 libvpx.so libvpx.so.$(VERSION_MAJOR) \
286 libvpx.so.$(VERSION_MAJOR).$(VERSION_MINOR))
jimbankoski45e551b2012-07-25 19:39:33 -0700287endif
288
289LIBS-$(BUILD_LIBVPX_SO) += $(BUILD_PFX)$(LIBVPX_SO)\
290 $(notdir $(LIBVPX_SO_SYMLINKS))
291$(BUILD_PFX)$(LIBVPX_SO): $(LIBVPX_OBJS) $(EXPORT_FILE)
292$(BUILD_PFX)$(LIBVPX_SO): extralibs += -lm
293$(BUILD_PFX)$(LIBVPX_SO): SONAME = libvpx.so.$(VERSION_MAJOR)
294$(BUILD_PFX)$(LIBVPX_SO): EXPORTS_FILE = $(EXPORT_FILE)
John Koleszar7aa97a32010-06-03 10:29:04 -0400295
296libvpx.ver: $(call enabled,CODEC_EXPORTS)
297 @echo " [CREATE] $@"
298 $(qexec)echo "{ global:" > $@
299 $(qexec)for f in $?; do awk '{print $$2";"}' < $$f >>$@; done
300 $(qexec)echo "local: *; };" >> $@
301CLEAN-OBJS += libvpx.ver
302
jimbankoski45e551b2012-07-25 19:39:33 -0700303libvpx.syms: $(call enabled,CODEC_EXPORTS)
304 @echo " [CREATE] $@"
305 $(qexec)awk '{print "_"$$2}' $^ >$@
306CLEAN-OBJS += libvpx.syms
307
James Zern495b2412011-07-25 15:40:36 -0700308define libvpx_symlink_template
309$(1): $(2)
jimbankoski45e551b2012-07-25 19:39:33 -0700310 @echo " [LN] $(2) $$@"
John Koleszar5ebe94f2012-12-23 07:20:10 -0800311 $(qexec)mkdir -p $$(dir $$@)
jimbankoski45e551b2012-07-25 19:39:33 -0700312 $(qexec)ln -sf $(2) $$@
James Zern495b2412011-07-25 15:40:36 -0700313endef
314
315$(eval $(call libvpx_symlink_template,\
316 $(addprefix $(BUILD_PFX),$(notdir $(LIBVPX_SO_SYMLINKS))),\
317 $(BUILD_PFX)$(LIBVPX_SO)))
318$(eval $(call libvpx_symlink_template,\
319 $(addprefix $(DIST_DIR)/,$(LIBVPX_SO_SYMLINKS)),\
John Koleszar5ebe94f2012-12-23 07:20:10 -0800320 $(LIBVPX_SO)))
John Koleszar7aa97a32010-06-03 10:29:04 -0400321
jimbankoski45e551b2012-07-25 19:39:33 -0700322
323INSTALL-LIBS-$(BUILD_LIBVPX_SO) += $(LIBVPX_SO_SYMLINKS)
324INSTALL-LIBS-$(BUILD_LIBVPX_SO) += $(LIBSUBDIR)/$(LIBVPX_SO)
325
Ralph Giles607f8422011-03-28 12:04:51 -0700326
327LIBS-$(BUILD_LIBVPX) += vpx.pc
328vpx.pc: config.mk libs.mk
329 @echo " [CREATE] $@"
330 $(qexec)echo '# pkg-config file from libvpx $(VERSION_STRING)' > $@
331 $(qexec)echo 'prefix=$(PREFIX)' >> $@
332 $(qexec)echo 'exec_prefix=$${prefix}' >> $@
Takanori MATSUURAa7eea3e2012-04-20 15:11:46 -0700333 $(qexec)echo 'libdir=$${prefix}/$(LIBSUBDIR)' >> $@
Ralph Giles607f8422011-03-28 12:04:51 -0700334 $(qexec)echo 'includedir=$${prefix}/include' >> $@
335 $(qexec)echo '' >> $@
336 $(qexec)echo 'Name: vpx' >> $@
337 $(qexec)echo 'Description: WebM Project VPx codec implementation' >> $@
338 $(qexec)echo 'Version: $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH)' >> $@
339 $(qexec)echo 'Requires:' >> $@
340 $(qexec)echo 'Conflicts:' >> $@
Ronald S. Bultjea742a732012-06-25 09:58:09 -0700341 $(qexec)echo 'Libs: -L$${libdir} -lvpx -lm' >> $@
Johannb46d58a2013-01-18 11:31:22 -0800342ifeq ($(HAVE_PTHREAD_H),yes)
John Koleszarbd6ffaa2012-08-21 10:54:30 -0700343 $(qexec)echo 'Libs.private: -lm -lpthread' >> $@
Johannb46d58a2013-01-18 11:31:22 -0800344else
345 $(qexec)echo 'Libs.private: -lm' >> $@
346endif
Ralph Giles607f8422011-03-28 12:04:51 -0700347 $(qexec)echo 'Cflags: -I$${includedir}' >> $@
348INSTALL-LIBS-yes += $(LIBSUBDIR)/pkgconfig/vpx.pc
349INSTALL_MAPS += $(LIBSUBDIR)/pkgconfig/%.pc %.pc
350CLEAN-OBJS += vpx.pc
John Koleszar0ea50ce2010-05-18 11:58:33 -0400351endif
352
353LIBS-$(LIPO_LIBVPX) += libvpx.a
354$(eval $(if $(LIPO_LIBVPX),$(call lipo_lib_template,libvpx.a)))
355
356#
357# Rule to make assembler configuration file from C configuration file
358#
359ifeq ($(ARCH_X86)$(ARCH_X86_64),yes)
360# YASM
361$(BUILD_PFX)vpx_config.asm: $(BUILD_PFX)vpx_config.h
362 @echo " [CREATE] $@"
363 @egrep "#define [A-Z0-9_]+ [01]" $< \
364 | awk '{print $$2 " equ " $$3}' > $@
365else
366ADS2GAS=$(if $(filter yes,$(CONFIG_GCC)),| $(ASM_CONVERSION))
367$(BUILD_PFX)vpx_config.asm: $(BUILD_PFX)vpx_config.h
368 @echo " [CREATE] $@"
369 @egrep "#define [A-Z0-9_]+ [01]" $< \
370 | awk '{print $$2 " EQU " $$3}' $(ADS2GAS) > $@
371 @echo " END" $(ADS2GAS) >> $@
372CLEAN-OBJS += $(BUILD_PFX)vpx_config.asm
373endif
374
375#
376# Add assembler dependencies for configuration and offsets
377#
Johann128d2c22011-03-02 09:44:39 -0500378$(filter %.s.o,$(OBJS-yes)): $(BUILD_PFX)vpx_config.asm
379$(filter %$(ASM).o,$(OBJS-yes)): $(BUILD_PFX)vpx_config.asm
John Koleszar0ea50ce2010-05-18 11:58:33 -0400380
Johann40dcae92011-02-04 17:44:31 -0500381
John Koleszar0ea50ce2010-05-18 11:58:33 -0400382$(shell $(SRC_PATH_BARE)/build/make/version.sh "$(SRC_PATH_BARE)" $(BUILD_PFX)vpx_version.h)
383CLEAN-OBJS += $(BUILD_PFX)vpx_version.h
384
John Koleszara9100492011-08-19 14:06:00 -0400385
James Berry07c71ef2011-11-04 11:48:30 -0400386##
387## libvpx test directives
388##
James Berry07c71ef2011-11-04 11:48:30 -0400389ifeq ($(CONFIG_UNIT_TESTS),yes)
John Koleszar00748632012-06-20 14:45:22 -0700390LIBVPX_TEST_DATA_PATH ?= .
John Koleszare82d2612012-05-16 16:25:51 -0700391
392include $(SRC_PATH_BARE)/test/test.mk
393LIBVPX_TEST_SRCS=$(addprefix test/,$(call enabled,LIBVPX_TEST_SRCS))
KO Myung-Huna3444562013-02-22 12:35:18 +0900394LIBVPX_TEST_BINS=./test_libvpx$(EXE_SFX)
John Koleszar00748632012-06-20 14:45:22 -0700395LIBVPX_TEST_DATA=$(addprefix $(LIBVPX_TEST_DATA_PATH)/,\
396 $(call enabled,LIBVPX_TEST_DATA))
397libvpx_test_data_url=http://downloads.webmproject.org/test_data/libvpx/$(1)
398
James Zern4a7cebe2013-06-25 13:50:30 -0700399libvpx_test_srcs.txt:
400 @echo " [CREATE] $@"
401 @echo $(LIBVPX_TEST_SRCS) | xargs -n1 echo | sort -u > $@
402CLEAN-OBJS += libvpx_test_srcs.txt
403
Adrian Grange5b236662013-09-16 11:46:00 -0700404$(LIBVPX_TEST_DATA): $(SRC_PATH_BARE)/test/test-data.sha1
John Koleszar00748632012-06-20 14:45:22 -0700405 @echo " [DOWNLOAD] $@"
406 $(qexec)trap 'rm -f $@' INT TERM &&\
407 curl -L -o $@ $(call libvpx_test_data_url,$(@F))
408
409testdata:: $(LIBVPX_TEST_DATA)
410 $(qexec)if [ -x "$$(which sha1sum)" ]; then\
411 echo "Checking test data:";\
John Koleszaracd147c2012-06-29 12:15:00 -0700412 if [ -n "$(LIBVPX_TEST_DATA)" ]; then\
413 for f in $(call enabled,LIBVPX_TEST_DATA); do\
414 grep $$f $(SRC_PATH_BARE)/test/test-data.sha1 |\
415 (cd $(LIBVPX_TEST_DATA_PATH); sha1sum -c);\
416 done; \
417 fi; \
John Koleszar00748632012-06-20 14:45:22 -0700418 else\
419 echo "Skipping test data integrity check, sha1sum not found.";\
420 fi
John Koleszare82d2612012-05-16 16:25:51 -0700421
James Berry07c71ef2011-11-04 11:48:30 -0400422ifeq ($(CONFIG_EXTERNAL_BUILD),yes)
423ifeq ($(CONFIG_MSVS),yes)
424
Martin Storsjo0b4637e2013-05-17 00:56:46 +0300425gtest.$(VCPROJ_SFX): $(SRC_PATH_BARE)/third_party/googletest/src/src/gtest-all.cc
James Berry07c71ef2011-11-04 11:48:30 -0400426 @echo " [CREATE] $@"
Martin Storsjo0b4637e2013-05-17 00:56:46 +0300427 $(qexec)$(GEN_VCPROJ) \
James Berry07c71ef2011-11-04 11:48:30 -0400428 --lib \
429 --target=$(TOOLCHAIN) \
430 $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \
431 --name=gtest \
432 --proj-guid=EC00E1EC-AF68-4D92-A255-181690D1C9B1 \
433 --ver=$(CONFIG_VS_VERSION) \
434 --src-path-bare="$(SRC_PATH_BARE)" \
Yaowu Xuc2021002012-12-04 12:28:10 -0800435 -D_VARIADIC_MAX=10 \
Martin Storsjo0b4637e2013-05-17 00:56:46 +0300436 --out=gtest.$(VCPROJ_SFX) $(SRC_PATH_BARE)/third_party/googletest/src/src/gtest-all.cc \
James Berry07c71ef2011-11-04 11:48:30 -0400437 -I. -I"$(SRC_PATH_BARE)/third_party/googletest/src/include" -I"$(SRC_PATH_BARE)/third_party/googletest/src"
438
Martin Storsjo0b4637e2013-05-17 00:56:46 +0300439PROJECTS-$(CONFIG_MSVS) += gtest.$(VCPROJ_SFX)
James Berry07c71ef2011-11-04 11:48:30 -0400440
Martin Storsjo9a5cac02013-05-18 19:57:19 +0300441test_libvpx.$(VCPROJ_SFX): $(LIBVPX_TEST_SRCS) vpx.$(VCPROJ_SFX) gtest.$(VCPROJ_SFX)
John Koleszar7f63bfa2012-06-01 10:43:47 -0700442 @echo " [CREATE] $@"
Martin Storsjo0b4637e2013-05-17 00:56:46 +0300443 $(qexec)$(GEN_VCPROJ) \
John Koleszar7f63bfa2012-06-01 10:43:47 -0700444 --exe \
445 --target=$(TOOLCHAIN) \
446 --name=test_libvpx \
Yaowu Xuc2021002012-12-04 12:28:10 -0800447 -D_VARIADIC_MAX=10 \
John Koleszar7f63bfa2012-06-01 10:43:47 -0700448 --proj-guid=CD837F5F-52D8-4314-A370-895D614166A7 \
449 --ver=$(CONFIG_VS_VERSION) \
450 $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \
451 --out=$@ $(INTERNAL_CFLAGS) $(CFLAGS) \
James Berry07c71ef2011-11-04 11:48:30 -0400452 -I. -I"$(SRC_PATH_BARE)/third_party/googletest/src/include" \
Martin Storsjoa37e84d2013-05-19 12:21:29 +0300453 -L. -l$(CODEC_LIB) -l$(GTEST_LIB) $^
James Berry07c71ef2011-11-04 11:48:30 -0400454
Martin Storsjo0b4637e2013-05-17 00:56:46 +0300455PROJECTS-$(CONFIG_MSVS) += test_libvpx.$(VCPROJ_SFX)
James Berry07c71ef2011-11-04 11:48:30 -0400456
James Zern7059c1d2013-05-31 16:08:09 -0700457LIBVPX_TEST_BINS := $(addprefix $(TGT_OS:win64=x64)/Release/,$(notdir $(LIBVPX_TEST_BINS)))
James Berry07c71ef2011-11-04 11:48:30 -0400458endif
459else
460
461include $(SRC_PATH_BARE)/third_party/googletest/gtest.mk
462GTEST_SRCS := $(addprefix third_party/googletest/src/,$(call enabled,GTEST_SRCS))
463GTEST_OBJS=$(call objs,$(GTEST_SRCS))
James Zerne4d2c252013-06-26 18:35:11 -0700464ifeq ($(filter win%,$(TGT_OS)),$(TGT_OS))
465# Disabling pthreads globally will cause issues on darwin and possibly elsewhere
466$(GTEST_OBJS) $(GTEST_OBJS:.o=.d): CXXFLAGS += -DGTEST_HAS_PTHREAD=0
467endif
John Koleszar8631c1b2012-05-22 10:37:20 -0700468$(GTEST_OBJS) $(GTEST_OBJS:.o=.d): CXXFLAGS += -I$(SRC_PATH_BARE)/third_party/googletest/src
469$(GTEST_OBJS) $(GTEST_OBJS:.o=.d): CXXFLAGS += -I$(SRC_PATH_BARE)/third_party/googletest/src/include
James Berry07c71ef2011-11-04 11:48:30 -0400470OBJS-$(BUILD_LIBVPX) += $(GTEST_OBJS)
471LIBS-$(BUILD_LIBVPX) += $(BUILD_PFX)libgtest.a $(BUILD_PFX)libgtest_g.a
472$(BUILD_PFX)libgtest_g.a: $(GTEST_OBJS)
473
John Koleszare82d2612012-05-16 16:25:51 -0700474LIBVPX_TEST_OBJS=$(sort $(call objs,$(LIBVPX_TEST_SRCS)))
475$(LIBVPX_TEST_OBJS) $(LIBVPX_TEST_OBJS:.o=.d): CXXFLAGS += -I$(SRC_PATH_BARE)/third_party/googletest/src
476$(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 -0400477OBJS-$(BUILD_LIBVPX) += $(LIBVPX_TEST_OBJS)
James Zern97fd7c52012-08-15 11:45:12 -0700478BINS-$(BUILD_LIBVPX) += $(LIBVPX_TEST_BINS)
James Berry07c71ef2011-11-04 11:48:30 -0400479
John Koleszaracd147c2012-06-29 12:15:00 -0700480CODEC_LIB=$(if $(CONFIG_DEBUG_LIBS),vpx_g,vpx)
481CODEC_LIB_SUF=$(if $(CONFIG_SHARED),.so,.a)
James Berry07c71ef2011-11-04 11:48:30 -0400482$(foreach bin,$(LIBVPX_TEST_BINS),\
John Koleszaracd147c2012-06-29 12:15:00 -0700483 $(if $(BUILD_LIBVPX),$(eval $(bin): \
484 lib$(CODEC_LIB)$(CODEC_LIB_SUF) libgtest.a ))\
James Berry07c71ef2011-11-04 11:48:30 -0400485 $(if $(BUILD_LIBVPX),$(eval $(call linkerxx_template,$(bin),\
John Koleszare82d2612012-05-16 16:25:51 -0700486 $(LIBVPX_TEST_OBJS) \
James Zerne4d2c252013-06-26 18:35:11 -0700487 -L. -lvpx -lgtest $(extralibs) -lm)\
James Berry07c71ef2011-11-04 11:48:30 -0400488 )))\
489 $(if $(LIPO_LIBS),$(eval $(call lipo_bin_template,$(bin))))\
490
James Berry07c71ef2011-11-04 11:48:30 -0400491endif
James Zern7059c1d2013-05-31 16:08:09 -0700492
Johann0239f112014-01-08 15:45:14 -0800493# Install test sources only if codec source is included
494INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(patsubst $(SRC_PATH_BARE)/%,%,\
495 $(shell find $(SRC_PATH_BARE)/third_party/googletest -type f))
496INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(LIBVPX_TEST_SRCS)
497
James Zern7059c1d2013-05-31 16:08:09 -0700498define test_shard_template
499test:: test_shard.$(1)
500test_shard.$(1): $(LIBVPX_TEST_BINS) testdata
501 @set -e; \
502 for t in $(LIBVPX_TEST_BINS); do \
503 export GTEST_SHARD_INDEX=$(1); \
504 export GTEST_TOTAL_SHARDS=$(2); \
505 $$$$t; \
506 done
507.PHONY: test_shard.$(1)
508endef
509
510NUM_SHARDS := 10
511SHARDS := 0 1 2 3 4 5 6 7 8 9
512$(foreach s,$(SHARDS),$(eval $(call test_shard_template,$(s),$(NUM_SHARDS))))
513
James Berry07c71ef2011-11-04 11:48:30 -0400514endif
515
516##
517## documentation directives
518##
John Koleszar0ea50ce2010-05-18 11:58:33 -0400519CLEAN-OBJS += libs.doxy
520DOCS-yes += libs.doxy
521libs.doxy: $(CODEC_DOC_SRCS)
522 @echo " [CREATE] $@"
523 @rm -f $@
524 @echo "INPUT += $^" >> $@
525 @echo "PREDEFINED = VPX_CODEC_DISABLE_COMPAT" >> $@
526 @echo "INCLUDE_PATH += ." >> $@;
527 @echo "ENABLED_SECTIONS += $(sort $(CODEC_DOC_SECTIONS))" >> $@
John Koleszare82d2612012-05-16 16:25:51 -0700528
John Koleszara9c75972012-11-08 17:09:30 -0800529## Generate rtcd.h for all objects
530$(OBJS-yes:.o=.d): $(RTCD)
John Koleszarb72373d2012-10-31 13:13:19 -0700531
532## Update the global src list
533SRCS += $(CODEC_SRCS) $(LIBVPX_TEST_SRCS) $(GTEST_SRCS)
Tom Finegan7b7c8432014-04-22 10:38:43 -0700534
535##
536## vpxdec/vpxenc tests.
537##
538ifeq ($(CONFIG_UNIT_TESTS),yes)
539TEST_BIN_PATH = .
540ifeq ($(CONFIG_MSVS),yes)
541# MSVC will build both Debug and Release configurations of tools in a
542# sub directory named for the current target. Assume the user wants to
543# run the Release tools, and assign TEST_BIN_PATH accordingly.
544# TODO(tomfinegan): Is this adequate for ARM?
545# TODO(tomfinegan): Support running the debug versions of tools?
546TEST_BIN_PATH := $(addsuffix /$(TGT_OS:win64=x64)/Release, $(TEST_BIN_PATH))
547endif
548utiltest: testdata
549 $(qexec)$(SRC_PATH_BARE)/test/vpxdec.sh \
550 --test-data-path $(LIBVPX_TEST_DATA_PATH) \
551 --bin-path $(TEST_BIN_PATH)
552 $(qexec)$(SRC_PATH_BARE)/test/vpxenc.sh \
553 --test-data-path $(LIBVPX_TEST_DATA_PATH) \
554 --bin-path $(TEST_BIN_PATH)
555else
556utiltest:
557 @echo Unit tests must be enabled to make the utiltest target.
558endif