blob: 2b072b66e1e96af42748fa831b099e77fdb3410b [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
James Zernf12ebfc2014-05-14 19:45:20 -0700118 INSTALL-LIBS-$(CONFIG_SPATIAL_SVC) += 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 \
James Zernf66590c2014-06-02 16:42:14 -0700225 --src-path-bare="$(SRC_PATH_BARE)" \
Johann128d2c22011-03-02 09:44:39 -0500226 $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \
227 --out=$@ $^ \
228 -I. \
229 -I"$(SRC_PATH_BARE)" \
230
Martin Storsjo0b4637e2013-05-17 00:56:46 +0300231PROJECTS-$(BUILD_LIBVPX) += obj_int_extract.$(VCPROJ_SFX)
Johann128d2c22011-03-02 09:44:39 -0500232
John Koleszar0ea50ce2010-05-18 11:58:33 -0400233vpx.def: $(call enabled,CODEC_EXPORTS)
234 @echo " [CREATE] $@"
James Zerne8d58d32012-08-15 11:47:13 -0700235 $(qexec)$(SRC_PATH_BARE)/build/make/gen_msvs_def.sh\
John Koleszar0ea50ce2010-05-18 11:58:33 -0400236 --name=vpx\
237 --out=$@ $^
238CLEAN-OBJS += vpx.def
239
James Zernb92f7bc2014-03-04 19:46:29 -0800240# Assembly files that are included, but don't define symbols themselves.
241# Filtered out to avoid Visual Studio build warnings.
242ASM_INCLUDES := \
243 third_party/x86inc/x86inc.asm \
244 vpx_config.asm \
245 vpx_ports/x86_abi_support.asm \
246
Martin Storsjo9a5cac02013-05-18 19:57:19 +0300247vpx.$(VCPROJ_SFX): $(CODEC_SRCS) vpx.def obj_int_extract.$(VCPROJ_SFX)
John Koleszar0ea50ce2010-05-18 11:58:33 -0400248 @echo " [CREATE] $@"
Martin Storsjo0b4637e2013-05-17 00:56:46 +0300249 $(qexec)$(GEN_VCPROJ) \
Jim Bankoski1b16e742012-07-23 12:32:59 -0700250 $(if $(CONFIG_SHARED),--dll,--lib) \
251 --target=$(TOOLCHAIN) \
John Koleszar0ea50ce2010-05-18 11:58:33 -0400252 $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \
Johann128d2c22011-03-02 09:44:39 -0500253 --name=vpx \
254 --proj-guid=DCE19DAF-69AC-46DB-B14A-39F0FAA5DB74 \
255 --module-def=vpx.def \
256 --ver=$(CONFIG_VS_VERSION) \
James Zernf66590c2014-06-02 16:42:14 -0700257 --src-path-bare="$(SRC_PATH_BARE)" \
James Zernb92f7bc2014-03-04 19:46:29 -0800258 --out=$@ $(CFLAGS) \
259 $(filter-out $(addprefix %, $(ASM_INCLUDES)), $^) \
Johann128d2c22011-03-02 09:44:39 -0500260 --src-path-bare="$(SRC_PATH_BARE)" \
John Koleszar0ea50ce2010-05-18 11:58:33 -0400261
Martin Storsjo0b4637e2013-05-17 00:56:46 +0300262PROJECTS-$(BUILD_LIBVPX) += vpx.$(VCPROJ_SFX)
John Koleszar0ea50ce2010-05-18 11:58:33 -0400263
Martin Storsjo0b4637e2013-05-17 00:56:46 +0300264vpx.$(VCPROJ_SFX): vpx_config.asm
265vpx.$(VCPROJ_SFX): $(RTCD)
John Koleszar0ea50ce2010-05-18 11:58:33 -0400266
267endif
268else
269LIBVPX_OBJS=$(call objs,$(CODEC_SRCS))
270OBJS-$(BUILD_LIBVPX) += $(LIBVPX_OBJS)
John Koleszar06f58c02011-08-03 09:20:37 -0400271LIBS-$(if $(BUILD_LIBVPX),$(CONFIG_STATIC)) += $(BUILD_PFX)libvpx.a $(BUILD_PFX)libvpx_g.a
John Koleszar0ea50ce2010-05-18 11:58:33 -0400272$(BUILD_PFX)libvpx_g.a: $(LIBVPX_OBJS)
John Koleszar7aa97a32010-06-03 10:29:04 -0400273
jimbankoski45e551b2012-07-25 19:39:33 -0700274
John Koleszar7aa97a32010-06-03 10:29:04 -0400275BUILD_LIBVPX_SO := $(if $(BUILD_LIBVPX),$(CONFIG_SHARED))
jimbankoski45e551b2012-07-25 19:39:33 -0700276
277ifeq ($(filter darwin%,$(TGT_OS)),$(TGT_OS))
278LIBVPX_SO := libvpx.$(VERSION_MAJOR).dylib
279EXPORT_FILE := libvpx.syms
280LIBVPX_SO_SYMLINKS := $(addprefix $(LIBSUBDIR)/, \
281 libvpx.dylib )
282else
John Koleszar7aa97a32010-06-03 10:29:04 -0400283LIBVPX_SO := libvpx.so.$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH)
jimbankoski45e551b2012-07-25 19:39:33 -0700284EXPORT_FILE := libvpx.ver
285SYM_LINK := libvpx.so
John Koleszar7aa97a32010-06-03 10:29:04 -0400286LIBVPX_SO_SYMLINKS := $(addprefix $(LIBSUBDIR)/, \
287 libvpx.so libvpx.so.$(VERSION_MAJOR) \
288 libvpx.so.$(VERSION_MAJOR).$(VERSION_MINOR))
jimbankoski45e551b2012-07-25 19:39:33 -0700289endif
290
291LIBS-$(BUILD_LIBVPX_SO) += $(BUILD_PFX)$(LIBVPX_SO)\
292 $(notdir $(LIBVPX_SO_SYMLINKS))
293$(BUILD_PFX)$(LIBVPX_SO): $(LIBVPX_OBJS) $(EXPORT_FILE)
294$(BUILD_PFX)$(LIBVPX_SO): extralibs += -lm
295$(BUILD_PFX)$(LIBVPX_SO): SONAME = libvpx.so.$(VERSION_MAJOR)
296$(BUILD_PFX)$(LIBVPX_SO): EXPORTS_FILE = $(EXPORT_FILE)
John Koleszar7aa97a32010-06-03 10:29:04 -0400297
298libvpx.ver: $(call enabled,CODEC_EXPORTS)
299 @echo " [CREATE] $@"
300 $(qexec)echo "{ global:" > $@
301 $(qexec)for f in $?; do awk '{print $$2";"}' < $$f >>$@; done
302 $(qexec)echo "local: *; };" >> $@
303CLEAN-OBJS += libvpx.ver
304
jimbankoski45e551b2012-07-25 19:39:33 -0700305libvpx.syms: $(call enabled,CODEC_EXPORTS)
306 @echo " [CREATE] $@"
307 $(qexec)awk '{print "_"$$2}' $^ >$@
308CLEAN-OBJS += libvpx.syms
309
James Zern495b2412011-07-25 15:40:36 -0700310define libvpx_symlink_template
311$(1): $(2)
jimbankoski45e551b2012-07-25 19:39:33 -0700312 @echo " [LN] $(2) $$@"
John Koleszar5ebe94f2012-12-23 07:20:10 -0800313 $(qexec)mkdir -p $$(dir $$@)
jimbankoski45e551b2012-07-25 19:39:33 -0700314 $(qexec)ln -sf $(2) $$@
James Zern495b2412011-07-25 15:40:36 -0700315endef
316
317$(eval $(call libvpx_symlink_template,\
318 $(addprefix $(BUILD_PFX),$(notdir $(LIBVPX_SO_SYMLINKS))),\
319 $(BUILD_PFX)$(LIBVPX_SO)))
320$(eval $(call libvpx_symlink_template,\
321 $(addprefix $(DIST_DIR)/,$(LIBVPX_SO_SYMLINKS)),\
John Koleszar5ebe94f2012-12-23 07:20:10 -0800322 $(LIBVPX_SO)))
John Koleszar7aa97a32010-06-03 10:29:04 -0400323
jimbankoski45e551b2012-07-25 19:39:33 -0700324
325INSTALL-LIBS-$(BUILD_LIBVPX_SO) += $(LIBVPX_SO_SYMLINKS)
326INSTALL-LIBS-$(BUILD_LIBVPX_SO) += $(LIBSUBDIR)/$(LIBVPX_SO)
327
Ralph Giles607f8422011-03-28 12:04:51 -0700328
329LIBS-$(BUILD_LIBVPX) += vpx.pc
330vpx.pc: config.mk libs.mk
331 @echo " [CREATE] $@"
332 $(qexec)echo '# pkg-config file from libvpx $(VERSION_STRING)' > $@
333 $(qexec)echo 'prefix=$(PREFIX)' >> $@
334 $(qexec)echo 'exec_prefix=$${prefix}' >> $@
Takanori MATSUURAa7eea3e2012-04-20 15:11:46 -0700335 $(qexec)echo 'libdir=$${prefix}/$(LIBSUBDIR)' >> $@
Ralph Giles607f8422011-03-28 12:04:51 -0700336 $(qexec)echo 'includedir=$${prefix}/include' >> $@
337 $(qexec)echo '' >> $@
338 $(qexec)echo 'Name: vpx' >> $@
339 $(qexec)echo 'Description: WebM Project VPx codec implementation' >> $@
340 $(qexec)echo 'Version: $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH)' >> $@
341 $(qexec)echo 'Requires:' >> $@
342 $(qexec)echo 'Conflicts:' >> $@
Ronald S. Bultjea742a732012-06-25 09:58:09 -0700343 $(qexec)echo 'Libs: -L$${libdir} -lvpx -lm' >> $@
Johannb46d58a2013-01-18 11:31:22 -0800344ifeq ($(HAVE_PTHREAD_H),yes)
John Koleszarbd6ffaa2012-08-21 10:54:30 -0700345 $(qexec)echo 'Libs.private: -lm -lpthread' >> $@
Johannb46d58a2013-01-18 11:31:22 -0800346else
347 $(qexec)echo 'Libs.private: -lm' >> $@
348endif
Ralph Giles607f8422011-03-28 12:04:51 -0700349 $(qexec)echo 'Cflags: -I$${includedir}' >> $@
350INSTALL-LIBS-yes += $(LIBSUBDIR)/pkgconfig/vpx.pc
351INSTALL_MAPS += $(LIBSUBDIR)/pkgconfig/%.pc %.pc
352CLEAN-OBJS += vpx.pc
John Koleszar0ea50ce2010-05-18 11:58:33 -0400353endif
354
355LIBS-$(LIPO_LIBVPX) += libvpx.a
356$(eval $(if $(LIPO_LIBVPX),$(call lipo_lib_template,libvpx.a)))
357
358#
359# Rule to make assembler configuration file from C configuration file
360#
361ifeq ($(ARCH_X86)$(ARCH_X86_64),yes)
362# YASM
363$(BUILD_PFX)vpx_config.asm: $(BUILD_PFX)vpx_config.h
364 @echo " [CREATE] $@"
365 @egrep "#define [A-Z0-9_]+ [01]" $< \
366 | awk '{print $$2 " equ " $$3}' > $@
367else
368ADS2GAS=$(if $(filter yes,$(CONFIG_GCC)),| $(ASM_CONVERSION))
369$(BUILD_PFX)vpx_config.asm: $(BUILD_PFX)vpx_config.h
370 @echo " [CREATE] $@"
371 @egrep "#define [A-Z0-9_]+ [01]" $< \
372 | awk '{print $$2 " EQU " $$3}' $(ADS2GAS) > $@
373 @echo " END" $(ADS2GAS) >> $@
374CLEAN-OBJS += $(BUILD_PFX)vpx_config.asm
375endif
376
377#
378# Add assembler dependencies for configuration and offsets
379#
Johann128d2c22011-03-02 09:44:39 -0500380$(filter %.s.o,$(OBJS-yes)): $(BUILD_PFX)vpx_config.asm
381$(filter %$(ASM).o,$(OBJS-yes)): $(BUILD_PFX)vpx_config.asm
John Koleszar0ea50ce2010-05-18 11:58:33 -0400382
Johann40dcae92011-02-04 17:44:31 -0500383
John Koleszar0ea50ce2010-05-18 11:58:33 -0400384$(shell $(SRC_PATH_BARE)/build/make/version.sh "$(SRC_PATH_BARE)" $(BUILD_PFX)vpx_version.h)
385CLEAN-OBJS += $(BUILD_PFX)vpx_version.h
386
John Koleszara9100492011-08-19 14:06:00 -0400387
James Berry07c71ef2011-11-04 11:48:30 -0400388##
389## libvpx test directives
390##
James Berry07c71ef2011-11-04 11:48:30 -0400391ifeq ($(CONFIG_UNIT_TESTS),yes)
John Koleszar00748632012-06-20 14:45:22 -0700392LIBVPX_TEST_DATA_PATH ?= .
John Koleszare82d2612012-05-16 16:25:51 -0700393
394include $(SRC_PATH_BARE)/test/test.mk
395LIBVPX_TEST_SRCS=$(addprefix test/,$(call enabled,LIBVPX_TEST_SRCS))
KO Myung-Huna3444562013-02-22 12:35:18 +0900396LIBVPX_TEST_BINS=./test_libvpx$(EXE_SFX)
John Koleszar00748632012-06-20 14:45:22 -0700397LIBVPX_TEST_DATA=$(addprefix $(LIBVPX_TEST_DATA_PATH)/,\
398 $(call enabled,LIBVPX_TEST_DATA))
399libvpx_test_data_url=http://downloads.webmproject.org/test_data/libvpx/$(1)
400
James Zern4a7cebe2013-06-25 13:50:30 -0700401libvpx_test_srcs.txt:
402 @echo " [CREATE] $@"
403 @echo $(LIBVPX_TEST_SRCS) | xargs -n1 echo | sort -u > $@
404CLEAN-OBJS += libvpx_test_srcs.txt
405
Adrian Grange5b236662013-09-16 11:46:00 -0700406$(LIBVPX_TEST_DATA): $(SRC_PATH_BARE)/test/test-data.sha1
John Koleszar00748632012-06-20 14:45:22 -0700407 @echo " [DOWNLOAD] $@"
408 $(qexec)trap 'rm -f $@' INT TERM &&\
409 curl -L -o $@ $(call libvpx_test_data_url,$(@F))
410
411testdata:: $(LIBVPX_TEST_DATA)
412 $(qexec)if [ -x "$$(which sha1sum)" ]; then\
413 echo "Checking test data:";\
John Koleszaracd147c2012-06-29 12:15:00 -0700414 if [ -n "$(LIBVPX_TEST_DATA)" ]; then\
415 for f in $(call enabled,LIBVPX_TEST_DATA); do\
416 grep $$f $(SRC_PATH_BARE)/test/test-data.sha1 |\
417 (cd $(LIBVPX_TEST_DATA_PATH); sha1sum -c);\
418 done; \
419 fi; \
John Koleszar00748632012-06-20 14:45:22 -0700420 else\
421 echo "Skipping test data integrity check, sha1sum not found.";\
422 fi
John Koleszare82d2612012-05-16 16:25:51 -0700423
James Berry07c71ef2011-11-04 11:48:30 -0400424ifeq ($(CONFIG_EXTERNAL_BUILD),yes)
425ifeq ($(CONFIG_MSVS),yes)
426
Martin Storsjo0b4637e2013-05-17 00:56:46 +0300427gtest.$(VCPROJ_SFX): $(SRC_PATH_BARE)/third_party/googletest/src/src/gtest-all.cc
James Berry07c71ef2011-11-04 11:48:30 -0400428 @echo " [CREATE] $@"
Martin Storsjo0b4637e2013-05-17 00:56:46 +0300429 $(qexec)$(GEN_VCPROJ) \
James Berry07c71ef2011-11-04 11:48:30 -0400430 --lib \
431 --target=$(TOOLCHAIN) \
432 $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \
433 --name=gtest \
434 --proj-guid=EC00E1EC-AF68-4D92-A255-181690D1C9B1 \
435 --ver=$(CONFIG_VS_VERSION) \
436 --src-path-bare="$(SRC_PATH_BARE)" \
Yaowu Xuc2021002012-12-04 12:28:10 -0800437 -D_VARIADIC_MAX=10 \
Martin Storsjo0b4637e2013-05-17 00:56:46 +0300438 --out=gtest.$(VCPROJ_SFX) $(SRC_PATH_BARE)/third_party/googletest/src/src/gtest-all.cc \
James Berry07c71ef2011-11-04 11:48:30 -0400439 -I. -I"$(SRC_PATH_BARE)/third_party/googletest/src/include" -I"$(SRC_PATH_BARE)/third_party/googletest/src"
440
Martin Storsjo0b4637e2013-05-17 00:56:46 +0300441PROJECTS-$(CONFIG_MSVS) += gtest.$(VCPROJ_SFX)
James Berry07c71ef2011-11-04 11:48:30 -0400442
Martin Storsjo9a5cac02013-05-18 19:57:19 +0300443test_libvpx.$(VCPROJ_SFX): $(LIBVPX_TEST_SRCS) vpx.$(VCPROJ_SFX) gtest.$(VCPROJ_SFX)
John Koleszar7f63bfa2012-06-01 10:43:47 -0700444 @echo " [CREATE] $@"
Martin Storsjo0b4637e2013-05-17 00:56:46 +0300445 $(qexec)$(GEN_VCPROJ) \
John Koleszar7f63bfa2012-06-01 10:43:47 -0700446 --exe \
447 --target=$(TOOLCHAIN) \
448 --name=test_libvpx \
Yaowu Xuc2021002012-12-04 12:28:10 -0800449 -D_VARIADIC_MAX=10 \
John Koleszar7f63bfa2012-06-01 10:43:47 -0700450 --proj-guid=CD837F5F-52D8-4314-A370-895D614166A7 \
451 --ver=$(CONFIG_VS_VERSION) \
James Zernf66590c2014-06-02 16:42:14 -0700452 --src-path-bare="$(SRC_PATH_BARE)" \
John Koleszar7f63bfa2012-06-01 10:43:47 -0700453 $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \
454 --out=$@ $(INTERNAL_CFLAGS) $(CFLAGS) \
James Berry07c71ef2011-11-04 11:48:30 -0400455 -I. -I"$(SRC_PATH_BARE)/third_party/googletest/src/include" \
Martin Storsjoa37e84d2013-05-19 12:21:29 +0300456 -L. -l$(CODEC_LIB) -l$(GTEST_LIB) $^
James Berry07c71ef2011-11-04 11:48:30 -0400457
Martin Storsjo0b4637e2013-05-17 00:56:46 +0300458PROJECTS-$(CONFIG_MSVS) += test_libvpx.$(VCPROJ_SFX)
James Berry07c71ef2011-11-04 11:48:30 -0400459
James Zern7059c1d2013-05-31 16:08:09 -0700460LIBVPX_TEST_BINS := $(addprefix $(TGT_OS:win64=x64)/Release/,$(notdir $(LIBVPX_TEST_BINS)))
James Berry07c71ef2011-11-04 11:48:30 -0400461endif
462else
463
464include $(SRC_PATH_BARE)/third_party/googletest/gtest.mk
465GTEST_SRCS := $(addprefix third_party/googletest/src/,$(call enabled,GTEST_SRCS))
466GTEST_OBJS=$(call objs,$(GTEST_SRCS))
James Zerne4d2c252013-06-26 18:35:11 -0700467ifeq ($(filter win%,$(TGT_OS)),$(TGT_OS))
468# Disabling pthreads globally will cause issues on darwin and possibly elsewhere
469$(GTEST_OBJS) $(GTEST_OBJS:.o=.d): CXXFLAGS += -DGTEST_HAS_PTHREAD=0
470endif
John Koleszar8631c1b2012-05-22 10:37:20 -0700471$(GTEST_OBJS) $(GTEST_OBJS:.o=.d): CXXFLAGS += -I$(SRC_PATH_BARE)/third_party/googletest/src
472$(GTEST_OBJS) $(GTEST_OBJS:.o=.d): CXXFLAGS += -I$(SRC_PATH_BARE)/third_party/googletest/src/include
James Berry07c71ef2011-11-04 11:48:30 -0400473OBJS-$(BUILD_LIBVPX) += $(GTEST_OBJS)
474LIBS-$(BUILD_LIBVPX) += $(BUILD_PFX)libgtest.a $(BUILD_PFX)libgtest_g.a
475$(BUILD_PFX)libgtest_g.a: $(GTEST_OBJS)
476
John Koleszare82d2612012-05-16 16:25:51 -0700477LIBVPX_TEST_OBJS=$(sort $(call objs,$(LIBVPX_TEST_SRCS)))
478$(LIBVPX_TEST_OBJS) $(LIBVPX_TEST_OBJS:.o=.d): CXXFLAGS += -I$(SRC_PATH_BARE)/third_party/googletest/src
479$(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 -0400480OBJS-$(BUILD_LIBVPX) += $(LIBVPX_TEST_OBJS)
James Zern97fd7c52012-08-15 11:45:12 -0700481BINS-$(BUILD_LIBVPX) += $(LIBVPX_TEST_BINS)
James Berry07c71ef2011-11-04 11:48:30 -0400482
John Koleszaracd147c2012-06-29 12:15:00 -0700483CODEC_LIB=$(if $(CONFIG_DEBUG_LIBS),vpx_g,vpx)
484CODEC_LIB_SUF=$(if $(CONFIG_SHARED),.so,.a)
James Berry07c71ef2011-11-04 11:48:30 -0400485$(foreach bin,$(LIBVPX_TEST_BINS),\
John Koleszaracd147c2012-06-29 12:15:00 -0700486 $(if $(BUILD_LIBVPX),$(eval $(bin): \
487 lib$(CODEC_LIB)$(CODEC_LIB_SUF) libgtest.a ))\
James Berry07c71ef2011-11-04 11:48:30 -0400488 $(if $(BUILD_LIBVPX),$(eval $(call linkerxx_template,$(bin),\
John Koleszare82d2612012-05-16 16:25:51 -0700489 $(LIBVPX_TEST_OBJS) \
James Zerne4d2c252013-06-26 18:35:11 -0700490 -L. -lvpx -lgtest $(extralibs) -lm)\
James Berry07c71ef2011-11-04 11:48:30 -0400491 )))\
492 $(if $(LIPO_LIBS),$(eval $(call lipo_bin_template,$(bin))))\
493
James Berry07c71ef2011-11-04 11:48:30 -0400494endif
James Zern7059c1d2013-05-31 16:08:09 -0700495
Johann0239f112014-01-08 15:45:14 -0800496# Install test sources only if codec source is included
497INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(patsubst $(SRC_PATH_BARE)/%,%,\
498 $(shell find $(SRC_PATH_BARE)/third_party/googletest -type f))
499INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(LIBVPX_TEST_SRCS)
500
James Zern7059c1d2013-05-31 16:08:09 -0700501define test_shard_template
502test:: test_shard.$(1)
503test_shard.$(1): $(LIBVPX_TEST_BINS) testdata
504 @set -e; \
505 for t in $(LIBVPX_TEST_BINS); do \
506 export GTEST_SHARD_INDEX=$(1); \
507 export GTEST_TOTAL_SHARDS=$(2); \
508 $$$$t; \
509 done
510.PHONY: test_shard.$(1)
511endef
512
513NUM_SHARDS := 10
514SHARDS := 0 1 2 3 4 5 6 7 8 9
515$(foreach s,$(SHARDS),$(eval $(call test_shard_template,$(s),$(NUM_SHARDS))))
516
James Berry07c71ef2011-11-04 11:48:30 -0400517endif
518
519##
520## documentation directives
521##
John Koleszar0ea50ce2010-05-18 11:58:33 -0400522CLEAN-OBJS += libs.doxy
523DOCS-yes += libs.doxy
524libs.doxy: $(CODEC_DOC_SRCS)
525 @echo " [CREATE] $@"
526 @rm -f $@
527 @echo "INPUT += $^" >> $@
528 @echo "PREDEFINED = VPX_CODEC_DISABLE_COMPAT" >> $@
529 @echo "INCLUDE_PATH += ." >> $@;
530 @echo "ENABLED_SECTIONS += $(sort $(CODEC_DOC_SECTIONS))" >> $@
John Koleszare82d2612012-05-16 16:25:51 -0700531
John Koleszara9c75972012-11-08 17:09:30 -0800532## Generate rtcd.h for all objects
533$(OBJS-yes:.o=.d): $(RTCD)
John Koleszarb72373d2012-10-31 13:13:19 -0700534
535## Update the global src list
536SRCS += $(CODEC_SRCS) $(LIBVPX_TEST_SRCS) $(GTEST_SRCS)
Tom Finegan7b7c8432014-04-22 10:38:43 -0700537
538##
539## vpxdec/vpxenc tests.
540##
541ifeq ($(CONFIG_UNIT_TESTS),yes)
542TEST_BIN_PATH = .
543ifeq ($(CONFIG_MSVS),yes)
544# MSVC will build both Debug and Release configurations of tools in a
545# sub directory named for the current target. Assume the user wants to
546# run the Release tools, and assign TEST_BIN_PATH accordingly.
547# TODO(tomfinegan): Is this adequate for ARM?
548# TODO(tomfinegan): Support running the debug versions of tools?
549TEST_BIN_PATH := $(addsuffix /$(TGT_OS:win64=x64)/Release, $(TEST_BIN_PATH))
550endif
551utiltest: testdata
552 $(qexec)$(SRC_PATH_BARE)/test/vpxdec.sh \
553 --test-data-path $(LIBVPX_TEST_DATA_PATH) \
554 --bin-path $(TEST_BIN_PATH)
555 $(qexec)$(SRC_PATH_BARE)/test/vpxenc.sh \
556 --test-data-path $(LIBVPX_TEST_DATA_PATH) \
557 --bin-path $(TEST_BIN_PATH)
558else
559utiltest:
560 @echo Unit tests must be enabled to make the utiltest target.
561endif
Tom Fineganbc27d7e2014-05-15 21:34:42 -0700562
563##
564## Example tests.
565##
566ifeq ($(CONFIG_UNIT_TESTS),yes)
567# All non-MSVC targets output example targets in a sub dir named examples.
568EXAMPLES_BIN_PATH = examples
569ifeq ($(CONFIG_MSVS),yes)
570# MSVC will build both Debug and Release configurations of the examples in a
571# sub directory named for the current target. Assume the user wants to
572# run the Release tools, and assign EXAMPLES_BIN_PATH accordingly.
573# TODO(tomfinegan): Is this adequate for ARM?
574# TODO(tomfinegan): Support running the debug versions of tools?
575EXAMPLES_BIN_PATH := $(TGT_OS:win64=x64)/Release
576endif
577exampletest: examples testdata
578 $(qexec)$(SRC_PATH_BARE)/test/examples.sh \
579 --test-data-path $(LIBVPX_TEST_DATA_PATH) \
580 --bin-path $(EXAMPLES_BIN_PATH)
581else
582exampletest:
583 @echo Unit tests must be enabled to make the exampletest target.
584endif