blob: 9c7dcdaaf0d74eb5e83f50561af87ea3d3137037 [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)
15 ASM:=$(if $(filter yes,$(CONFIG_GCC)),.asm.s,.asm)
16else
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] $$@"
52 $$(qexec)$$(SRC_PATH_BARE)/build/make/rtcd.sh --arch=$$(TGT_ISA) \
53 --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
Ronald S. Bultje4b2c2b92012-11-01 11:09:58 -0700118 INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/$(VP9_PREFIX)/%
John Koleszar0ea50ce2010-05-18 11:58:33 -0400119 CODEC_DOC_SRCS += vpx/vp8.h vpx/vp8cx.h
Ronald S. Bultje4b2c2b92012-11-01 11:09:58 -0700120 CODEC_DOC_SECTIONS += vp9 vp9_encoder
John Koleszar0ea50ce2010-05-18 11:58:33 -0400121endif
122
Ronald S. Bultje4b2c2b92012-11-01 11:09:58 -0700123ifeq ($(CONFIG_VP9_DECODER),yes)
124 VP9_PREFIX=vp9/
125 include $(SRC_PATH_BARE)/$(VP9_PREFIX)vp9dx.mk
126 CODEC_SRCS-yes += $(addprefix $(VP9_PREFIX),$(call enabled,VP9_DX_SRCS))
127 CODEC_EXPORTS-yes += $(addprefix $(VP9_PREFIX),$(VP9_DX_EXPORTS))
128 CODEC_SRCS-yes += $(VP9_PREFIX)vp9dx.mk vpx/vp8.h vpx/vp8dx.h
John Koleszar0ea50ce2010-05-18 11:58:33 -0400129 INSTALL-LIBS-yes += include/vpx/vp8.h include/vpx/vp8dx.h
Ronald S. Bultje4b2c2b92012-11-01 11:09:58 -0700130 INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/$(VP9_PREFIX)/%
John Koleszar0ea50ce2010-05-18 11:58:33 -0400131 CODEC_DOC_SRCS += vpx/vp8.h vpx/vp8dx.h
Ronald S. Bultje4b2c2b92012-11-01 11:09:58 -0700132 CODEC_DOC_SECTIONS += vp9 vp9_decoder
John Koleszar0ea50ce2010-05-18 11:58:33 -0400133endif
134
135
136ifeq ($(CONFIG_ENCODERS),yes)
137 CODEC_DOC_SECTIONS += encoder
138endif
139ifeq ($(CONFIG_DECODERS),yes)
140 CODEC_DOC_SECTIONS += decoder
141endif
142
143
144ifeq ($(CONFIG_MSVS),yes)
145CODEC_LIB=$(if $(CONFIG_STATIC_MSVCRT),vpxmt,vpxmd)
James Berry0cc044f2012-05-02 18:09:54 -0400146GTEST_LIB=$(if $(CONFIG_STATIC_MSVCRT),gtestmt,gtestmd)
John Koleszar0ea50ce2010-05-18 11:58:33 -0400147# This variable uses deferred expansion intentionally, since the results of
148# $(wildcard) may change during the course of the Make.
149VS_PLATFORMS = $(foreach d,$(wildcard */Release/$(CODEC_LIB).lib),$(word 1,$(subst /, ,$(d))))
John Koleszar0ea50ce2010-05-18 11:58:33 -0400150endif
151
152# The following pairs define a mapping of locations in the distribution
153# tree to locations in the source/build trees.
John Koleszarb7492342010-05-24 11:39:59 -0400154INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/vpx/%
155INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/vpx_ports/%
John Koleszar670af3a2010-05-26 15:57:42 -0400156INSTALL_MAPS += $(LIBSUBDIR)/% %
John Koleszar0ea50ce2010-05-18 11:58:33 -0400157INSTALL_MAPS += src/% $(SRC_PATH_BARE)/%
158ifeq ($(CONFIG_MSVS),yes)
John Koleszar670af3a2010-05-26 15:57:42 -0400159INSTALL_MAPS += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/% $(p)/Release/%)
160INSTALL_MAPS += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/% $(p)/Debug/%)
John Koleszar0ea50ce2010-05-18 11:58:33 -0400161endif
162
John Koleszar0ea50ce2010-05-18 11:58:33 -0400163CODEC_SRCS-$(BUILD_LIBVPX) += build/make/version.sh
John Koleszara9100492011-08-19 14:06:00 -0400164CODEC_SRCS-$(BUILD_LIBVPX) += build/make/rtcd.sh
John Koleszar5ebe94f2012-12-23 07:20:10 -0800165CODEC_SRCS-$(BUILD_LIBVPX) += vpx_ports/emmintrin_compat.h
166CODEC_SRCS-$(BUILD_LIBVPX) += vpx_ports/vpx_once.h
John Koleszar0ea50ce2010-05-18 11:58:33 -0400167CODEC_SRCS-$(BUILD_LIBVPX) += $(BUILD_PFX)vpx_config.c
168INSTALL-SRCS-no += $(BUILD_PFX)vpx_config.c
John Koleszar23963022013-01-16 16:44:33 -0800169ifeq ($(ARCH_X86)$(ARCH_X86_64),yes)
Ronald S. Bultje42a7f682012-06-19 15:34:49 -0700170CODEC_SRCS-$(BUILD_LIBVPX) += third_party/x86inc/x86inc.asm
John Koleszar23963022013-01-16 16:44:33 -0800171endif
John Koleszar7aa97a32010-06-03 10:29:04 -0400172CODEC_EXPORTS-$(BUILD_LIBVPX) += vpx/exports_com
173CODEC_EXPORTS-$(CONFIG_ENCODERS) += vpx/exports_enc
174CODEC_EXPORTS-$(CONFIG_DECODERS) += vpx/exports_dec
John Koleszar0ea50ce2010-05-18 11:58:33 -0400175
John Koleszarb7492342010-05-24 11:39:59 -0400176INSTALL-LIBS-yes += include/vpx/vpx_codec.h
177INSTALL-LIBS-yes += include/vpx/vpx_image.h
178INSTALL-LIBS-yes += include/vpx/vpx_integer.h
179INSTALL-LIBS-yes += include/vpx/vpx_codec_impl_top.h
180INSTALL-LIBS-yes += include/vpx/vpx_codec_impl_bottom.h
181INSTALL-LIBS-$(CONFIG_DECODERS) += include/vpx/vpx_decoder.h
John Koleszarb7492342010-05-24 11:39:59 -0400182INSTALL-LIBS-$(CONFIG_ENCODERS) += include/vpx/vpx_encoder.h
John Koleszar0ea50ce2010-05-18 11:58:33 -0400183ifeq ($(CONFIG_EXTERNAL_BUILD),yes)
184ifeq ($(CONFIG_MSVS),yes)
John Koleszar670af3a2010-05-26 15:57:42 -0400185INSTALL-LIBS-yes += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/$(CODEC_LIB).lib)
186INSTALL-LIBS-$(CONFIG_DEBUG_LIBS) += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/$(CODEC_LIB)d.lib)
187INSTALL-LIBS-$(CONFIG_SHARED) += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/vpx.dll)
188INSTALL-LIBS-$(CONFIG_SHARED) += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/vpx.exp)
John Koleszar0ea50ce2010-05-18 11:58:33 -0400189endif
190else
James Zern495b2412011-07-25 15:40:36 -0700191INSTALL-LIBS-$(CONFIG_STATIC) += $(LIBSUBDIR)/libvpx.a
John Koleszar670af3a2010-05-26 15:57:42 -0400192INSTALL-LIBS-$(CONFIG_DEBUG_LIBS) += $(LIBSUBDIR)/libvpx_g.a
John Koleszar0ea50ce2010-05-18 11:58:33 -0400193endif
194
John Koleszar5ebe94f2012-12-23 07:20:10 -0800195CODEC_SRCS=$(call enabled,CODEC_SRCS)
John Koleszar0ea50ce2010-05-18 11:58:33 -0400196INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(CODEC_SRCS)
197INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(call enabled,CODEC_EXPORTS)
198
John Koleszar5e562c72011-08-12 14:59:10 -0400199
200# Generate a list of all enabled sources, in particular for exporting to gyp
201# based build systems.
202libvpx_srcs.txt:
203 @echo " [CREATE] $@"
204 @echo $(CODEC_SRCS) | xargs -n1 echo | sort -u > $@
205
206
John Koleszar0ea50ce2010-05-18 11:58:33 -0400207ifeq ($(CONFIG_EXTERNAL_BUILD),yes)
208ifeq ($(CONFIG_MSVS),yes)
209
Martin Storsjo0b4637e2013-05-17 00:56:46 +0300210obj_int_extract.$(VCPROJ_SFX): $(SRC_PATH_BARE)/build/make/obj_int_extract.c
Johann128d2c22011-03-02 09:44:39 -0500211 @cp $(SRC_PATH_BARE)/build/x86-msvs/obj_int_extract.bat .
212 @echo " [CREATE] $@"
Martin Storsjo0b4637e2013-05-17 00:56:46 +0300213 $(qexec)$(GEN_VCPROJ) \
Johann128d2c22011-03-02 09:44:39 -0500214 --exe \
215 --target=$(TOOLCHAIN) \
216 --name=obj_int_extract \
217 --ver=$(CONFIG_VS_VERSION) \
218 --proj-guid=E1360C65-D375-4335-8057-7ED99CC3F9B2 \
219 $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \
220 --out=$@ $^ \
221 -I. \
222 -I"$(SRC_PATH_BARE)" \
223
Martin Storsjo0b4637e2013-05-17 00:56:46 +0300224PROJECTS-$(BUILD_LIBVPX) += obj_int_extract.$(VCPROJ_SFX)
Johann128d2c22011-03-02 09:44:39 -0500225
John Koleszar0ea50ce2010-05-18 11:58:33 -0400226vpx.def: $(call enabled,CODEC_EXPORTS)
227 @echo " [CREATE] $@"
James Zerne8d58d32012-08-15 11:47:13 -0700228 $(qexec)$(SRC_PATH_BARE)/build/make/gen_msvs_def.sh\
John Koleszar0ea50ce2010-05-18 11:58:33 -0400229 --name=vpx\
230 --out=$@ $^
231CLEAN-OBJS += vpx.def
232
Martin Storsjo9a5cac02013-05-18 19:57:19 +0300233vpx.$(VCPROJ_SFX): $(CODEC_SRCS) vpx.def obj_int_extract.$(VCPROJ_SFX)
John Koleszar0ea50ce2010-05-18 11:58:33 -0400234 @echo " [CREATE] $@"
Martin Storsjo0b4637e2013-05-17 00:56:46 +0300235 $(qexec)$(GEN_VCPROJ) \
Jim Bankoski1b16e742012-07-23 12:32:59 -0700236 $(if $(CONFIG_SHARED),--dll,--lib) \
237 --target=$(TOOLCHAIN) \
John Koleszar0ea50ce2010-05-18 11:58:33 -0400238 $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \
Johann128d2c22011-03-02 09:44:39 -0500239 --name=vpx \
240 --proj-guid=DCE19DAF-69AC-46DB-B14A-39F0FAA5DB74 \
241 --module-def=vpx.def \
242 --ver=$(CONFIG_VS_VERSION) \
243 --out=$@ $(CFLAGS) $^ \
244 --src-path-bare="$(SRC_PATH_BARE)" \
John Koleszar0ea50ce2010-05-18 11:58:33 -0400245
Martin Storsjo0b4637e2013-05-17 00:56:46 +0300246PROJECTS-$(BUILD_LIBVPX) += vpx.$(VCPROJ_SFX)
John Koleszar0ea50ce2010-05-18 11:58:33 -0400247
Martin Storsjo0b4637e2013-05-17 00:56:46 +0300248vpx.$(VCPROJ_SFX): vpx_config.asm
249vpx.$(VCPROJ_SFX): $(RTCD)
John Koleszar0ea50ce2010-05-18 11:58:33 -0400250
251endif
252else
253LIBVPX_OBJS=$(call objs,$(CODEC_SRCS))
254OBJS-$(BUILD_LIBVPX) += $(LIBVPX_OBJS)
John Koleszar06f58c02011-08-03 09:20:37 -0400255LIBS-$(if $(BUILD_LIBVPX),$(CONFIG_STATIC)) += $(BUILD_PFX)libvpx.a $(BUILD_PFX)libvpx_g.a
John Koleszar0ea50ce2010-05-18 11:58:33 -0400256$(BUILD_PFX)libvpx_g.a: $(LIBVPX_OBJS)
John Koleszar7aa97a32010-06-03 10:29:04 -0400257
jimbankoski45e551b2012-07-25 19:39:33 -0700258
John Koleszar7aa97a32010-06-03 10:29:04 -0400259BUILD_LIBVPX_SO := $(if $(BUILD_LIBVPX),$(CONFIG_SHARED))
jimbankoski45e551b2012-07-25 19:39:33 -0700260
261ifeq ($(filter darwin%,$(TGT_OS)),$(TGT_OS))
262LIBVPX_SO := libvpx.$(VERSION_MAJOR).dylib
263EXPORT_FILE := libvpx.syms
264LIBVPX_SO_SYMLINKS := $(addprefix $(LIBSUBDIR)/, \
265 libvpx.dylib )
266else
John Koleszar7aa97a32010-06-03 10:29:04 -0400267LIBVPX_SO := libvpx.so.$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH)
jimbankoski45e551b2012-07-25 19:39:33 -0700268EXPORT_FILE := libvpx.ver
269SYM_LINK := libvpx.so
John Koleszar7aa97a32010-06-03 10:29:04 -0400270LIBVPX_SO_SYMLINKS := $(addprefix $(LIBSUBDIR)/, \
271 libvpx.so libvpx.so.$(VERSION_MAJOR) \
272 libvpx.so.$(VERSION_MAJOR).$(VERSION_MINOR))
jimbankoski45e551b2012-07-25 19:39:33 -0700273endif
274
275LIBS-$(BUILD_LIBVPX_SO) += $(BUILD_PFX)$(LIBVPX_SO)\
276 $(notdir $(LIBVPX_SO_SYMLINKS))
277$(BUILD_PFX)$(LIBVPX_SO): $(LIBVPX_OBJS) $(EXPORT_FILE)
278$(BUILD_PFX)$(LIBVPX_SO): extralibs += -lm
279$(BUILD_PFX)$(LIBVPX_SO): SONAME = libvpx.so.$(VERSION_MAJOR)
280$(BUILD_PFX)$(LIBVPX_SO): EXPORTS_FILE = $(EXPORT_FILE)
John Koleszar7aa97a32010-06-03 10:29:04 -0400281
282libvpx.ver: $(call enabled,CODEC_EXPORTS)
283 @echo " [CREATE] $@"
284 $(qexec)echo "{ global:" > $@
285 $(qexec)for f in $?; do awk '{print $$2";"}' < $$f >>$@; done
286 $(qexec)echo "local: *; };" >> $@
287CLEAN-OBJS += libvpx.ver
288
jimbankoski45e551b2012-07-25 19:39:33 -0700289libvpx.syms: $(call enabled,CODEC_EXPORTS)
290 @echo " [CREATE] $@"
291 $(qexec)awk '{print "_"$$2}' $^ >$@
292CLEAN-OBJS += libvpx.syms
293
James Zern495b2412011-07-25 15:40:36 -0700294define libvpx_symlink_template
295$(1): $(2)
jimbankoski45e551b2012-07-25 19:39:33 -0700296 @echo " [LN] $(2) $$@"
John Koleszar5ebe94f2012-12-23 07:20:10 -0800297 $(qexec)mkdir -p $$(dir $$@)
jimbankoski45e551b2012-07-25 19:39:33 -0700298 $(qexec)ln -sf $(2) $$@
James Zern495b2412011-07-25 15:40:36 -0700299endef
300
301$(eval $(call libvpx_symlink_template,\
302 $(addprefix $(BUILD_PFX),$(notdir $(LIBVPX_SO_SYMLINKS))),\
303 $(BUILD_PFX)$(LIBVPX_SO)))
304$(eval $(call libvpx_symlink_template,\
305 $(addprefix $(DIST_DIR)/,$(LIBVPX_SO_SYMLINKS)),\
John Koleszar5ebe94f2012-12-23 07:20:10 -0800306 $(LIBVPX_SO)))
John Koleszar7aa97a32010-06-03 10:29:04 -0400307
jimbankoski45e551b2012-07-25 19:39:33 -0700308
309INSTALL-LIBS-$(BUILD_LIBVPX_SO) += $(LIBVPX_SO_SYMLINKS)
310INSTALL-LIBS-$(BUILD_LIBVPX_SO) += $(LIBSUBDIR)/$(LIBVPX_SO)
311
Ralph Giles607f8422011-03-28 12:04:51 -0700312
313LIBS-$(BUILD_LIBVPX) += vpx.pc
314vpx.pc: config.mk libs.mk
315 @echo " [CREATE] $@"
316 $(qexec)echo '# pkg-config file from libvpx $(VERSION_STRING)' > $@
317 $(qexec)echo 'prefix=$(PREFIX)' >> $@
318 $(qexec)echo 'exec_prefix=$${prefix}' >> $@
Takanori MATSUURAa7eea3e2012-04-20 15:11:46 -0700319 $(qexec)echo 'libdir=$${prefix}/$(LIBSUBDIR)' >> $@
Ralph Giles607f8422011-03-28 12:04:51 -0700320 $(qexec)echo 'includedir=$${prefix}/include' >> $@
321 $(qexec)echo '' >> $@
322 $(qexec)echo 'Name: vpx' >> $@
323 $(qexec)echo 'Description: WebM Project VPx codec implementation' >> $@
324 $(qexec)echo 'Version: $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH)' >> $@
325 $(qexec)echo 'Requires:' >> $@
326 $(qexec)echo 'Conflicts:' >> $@
Ronald S. Bultjea742a732012-06-25 09:58:09 -0700327 $(qexec)echo 'Libs: -L$${libdir} -lvpx -lm' >> $@
Johannb46d58a2013-01-18 11:31:22 -0800328ifeq ($(HAVE_PTHREAD_H),yes)
John Koleszarbd6ffaa2012-08-21 10:54:30 -0700329 $(qexec)echo 'Libs.private: -lm -lpthread' >> $@
Johannb46d58a2013-01-18 11:31:22 -0800330else
331 $(qexec)echo 'Libs.private: -lm' >> $@
332endif
Ralph Giles607f8422011-03-28 12:04:51 -0700333 $(qexec)echo 'Cflags: -I$${includedir}' >> $@
334INSTALL-LIBS-yes += $(LIBSUBDIR)/pkgconfig/vpx.pc
335INSTALL_MAPS += $(LIBSUBDIR)/pkgconfig/%.pc %.pc
336CLEAN-OBJS += vpx.pc
John Koleszar0ea50ce2010-05-18 11:58:33 -0400337endif
338
339LIBS-$(LIPO_LIBVPX) += libvpx.a
340$(eval $(if $(LIPO_LIBVPX),$(call lipo_lib_template,libvpx.a)))
341
342#
343# Rule to make assembler configuration file from C configuration file
344#
345ifeq ($(ARCH_X86)$(ARCH_X86_64),yes)
346# YASM
347$(BUILD_PFX)vpx_config.asm: $(BUILD_PFX)vpx_config.h
348 @echo " [CREATE] $@"
349 @egrep "#define [A-Z0-9_]+ [01]" $< \
350 | awk '{print $$2 " equ " $$3}' > $@
351else
352ADS2GAS=$(if $(filter yes,$(CONFIG_GCC)),| $(ASM_CONVERSION))
353$(BUILD_PFX)vpx_config.asm: $(BUILD_PFX)vpx_config.h
354 @echo " [CREATE] $@"
355 @egrep "#define [A-Z0-9_]+ [01]" $< \
356 | awk '{print $$2 " EQU " $$3}' $(ADS2GAS) > $@
357 @echo " END" $(ADS2GAS) >> $@
358CLEAN-OBJS += $(BUILD_PFX)vpx_config.asm
359endif
360
361#
362# Add assembler dependencies for configuration and offsets
363#
Johann128d2c22011-03-02 09:44:39 -0500364$(filter %.s.o,$(OBJS-yes)): $(BUILD_PFX)vpx_config.asm
365$(filter %$(ASM).o,$(OBJS-yes)): $(BUILD_PFX)vpx_config.asm
John Koleszar0ea50ce2010-05-18 11:58:33 -0400366
Johann40dcae92011-02-04 17:44:31 -0500367
John Koleszar0ea50ce2010-05-18 11:58:33 -0400368$(shell $(SRC_PATH_BARE)/build/make/version.sh "$(SRC_PATH_BARE)" $(BUILD_PFX)vpx_version.h)
369CLEAN-OBJS += $(BUILD_PFX)vpx_version.h
370
John Koleszara9100492011-08-19 14:06:00 -0400371
James Berry07c71ef2011-11-04 11:48:30 -0400372##
373## libvpx test directives
374##
James Berry07c71ef2011-11-04 11:48:30 -0400375ifeq ($(CONFIG_UNIT_TESTS),yes)
John Koleszar00748632012-06-20 14:45:22 -0700376LIBVPX_TEST_DATA_PATH ?= .
John Koleszare82d2612012-05-16 16:25:51 -0700377
378include $(SRC_PATH_BARE)/test/test.mk
379LIBVPX_TEST_SRCS=$(addprefix test/,$(call enabled,LIBVPX_TEST_SRCS))
KO Myung-Huna3444562013-02-22 12:35:18 +0900380LIBVPX_TEST_BINS=./test_libvpx$(EXE_SFX)
John Koleszar00748632012-06-20 14:45:22 -0700381LIBVPX_TEST_DATA=$(addprefix $(LIBVPX_TEST_DATA_PATH)/,\
382 $(call enabled,LIBVPX_TEST_DATA))
383libvpx_test_data_url=http://downloads.webmproject.org/test_data/libvpx/$(1)
384
385$(LIBVPX_TEST_DATA):
386 @echo " [DOWNLOAD] $@"
387 $(qexec)trap 'rm -f $@' INT TERM &&\
388 curl -L -o $@ $(call libvpx_test_data_url,$(@F))
389
390testdata:: $(LIBVPX_TEST_DATA)
391 $(qexec)if [ -x "$$(which sha1sum)" ]; then\
392 echo "Checking test data:";\
John Koleszaracd147c2012-06-29 12:15:00 -0700393 if [ -n "$(LIBVPX_TEST_DATA)" ]; then\
394 for f in $(call enabled,LIBVPX_TEST_DATA); do\
395 grep $$f $(SRC_PATH_BARE)/test/test-data.sha1 |\
396 (cd $(LIBVPX_TEST_DATA_PATH); sha1sum -c);\
397 done; \
398 fi; \
John Koleszar00748632012-06-20 14:45:22 -0700399 else\
400 echo "Skipping test data integrity check, sha1sum not found.";\
401 fi
John Koleszare82d2612012-05-16 16:25:51 -0700402
James Berry07c71ef2011-11-04 11:48:30 -0400403ifeq ($(CONFIG_EXTERNAL_BUILD),yes)
404ifeq ($(CONFIG_MSVS),yes)
405
Martin Storsjo0b4637e2013-05-17 00:56:46 +0300406gtest.$(VCPROJ_SFX): $(SRC_PATH_BARE)/third_party/googletest/src/src/gtest-all.cc
James Berry07c71ef2011-11-04 11:48:30 -0400407 @echo " [CREATE] $@"
Martin Storsjo0b4637e2013-05-17 00:56:46 +0300408 $(qexec)$(GEN_VCPROJ) \
James Berry07c71ef2011-11-04 11:48:30 -0400409 --lib \
410 --target=$(TOOLCHAIN) \
411 $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \
412 --name=gtest \
413 --proj-guid=EC00E1EC-AF68-4D92-A255-181690D1C9B1 \
414 --ver=$(CONFIG_VS_VERSION) \
415 --src-path-bare="$(SRC_PATH_BARE)" \
Yaowu Xuc2021002012-12-04 12:28:10 -0800416 -D_VARIADIC_MAX=10 \
Martin Storsjo0b4637e2013-05-17 00:56:46 +0300417 --out=gtest.$(VCPROJ_SFX) $(SRC_PATH_BARE)/third_party/googletest/src/src/gtest-all.cc \
James Berry07c71ef2011-11-04 11:48:30 -0400418 -I. -I"$(SRC_PATH_BARE)/third_party/googletest/src/include" -I"$(SRC_PATH_BARE)/third_party/googletest/src"
419
Martin Storsjo0b4637e2013-05-17 00:56:46 +0300420PROJECTS-$(CONFIG_MSVS) += gtest.$(VCPROJ_SFX)
James Berry07c71ef2011-11-04 11:48:30 -0400421
Martin Storsjo9a5cac02013-05-18 19:57:19 +0300422test_libvpx.$(VCPROJ_SFX): $(LIBVPX_TEST_SRCS) vpx.$(VCPROJ_SFX) gtest.$(VCPROJ_SFX)
John Koleszar7f63bfa2012-06-01 10:43:47 -0700423 @echo " [CREATE] $@"
Martin Storsjo0b4637e2013-05-17 00:56:46 +0300424 $(qexec)$(GEN_VCPROJ) \
John Koleszar7f63bfa2012-06-01 10:43:47 -0700425 --exe \
426 --target=$(TOOLCHAIN) \
427 --name=test_libvpx \
Yaowu Xuc2021002012-12-04 12:28:10 -0800428 -D_VARIADIC_MAX=10 \
John Koleszar7f63bfa2012-06-01 10:43:47 -0700429 --proj-guid=CD837F5F-52D8-4314-A370-895D614166A7 \
430 --ver=$(CONFIG_VS_VERSION) \
431 $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \
432 --out=$@ $(INTERNAL_CFLAGS) $(CFLAGS) \
James Berry07c71ef2011-11-04 11:48:30 -0400433 -I. -I"$(SRC_PATH_BARE)/third_party/googletest/src/include" \
Martin Storsjoa37e84d2013-05-19 12:21:29 +0300434 -L. -l$(CODEC_LIB) -l$(GTEST_LIB) $^
James Berry07c71ef2011-11-04 11:48:30 -0400435
Martin Storsjo0b4637e2013-05-17 00:56:46 +0300436PROJECTS-$(CONFIG_MSVS) += test_libvpx.$(VCPROJ_SFX)
James Berry07c71ef2011-11-04 11:48:30 -0400437
John Koleszar00748632012-06-20 14:45:22 -0700438test:: testdata
James Zern8b4b28a2013-04-05 11:56:54 -0700439 @set -e; for t in $(addprefix $(TGT_OS:win64=x64)/Release/,$(notdir $(LIBVPX_TEST_BINS:.cc=.exe))); do $$t; done
James Berry07c71ef2011-11-04 11:48:30 -0400440endif
441else
442
443include $(SRC_PATH_BARE)/third_party/googletest/gtest.mk
444GTEST_SRCS := $(addprefix third_party/googletest/src/,$(call enabled,GTEST_SRCS))
445GTEST_OBJS=$(call objs,$(GTEST_SRCS))
John Koleszar8631c1b2012-05-22 10:37:20 -0700446$(GTEST_OBJS) $(GTEST_OBJS:.o=.d): CXXFLAGS += -I$(SRC_PATH_BARE)/third_party/googletest/src
447$(GTEST_OBJS) $(GTEST_OBJS:.o=.d): CXXFLAGS += -I$(SRC_PATH_BARE)/third_party/googletest/src/include
James Berry07c71ef2011-11-04 11:48:30 -0400448OBJS-$(BUILD_LIBVPX) += $(GTEST_OBJS)
449LIBS-$(BUILD_LIBVPX) += $(BUILD_PFX)libgtest.a $(BUILD_PFX)libgtest_g.a
450$(BUILD_PFX)libgtest_g.a: $(GTEST_OBJS)
451
John Koleszare82d2612012-05-16 16:25:51 -0700452LIBVPX_TEST_OBJS=$(sort $(call objs,$(LIBVPX_TEST_SRCS)))
453$(LIBVPX_TEST_OBJS) $(LIBVPX_TEST_OBJS:.o=.d): CXXFLAGS += -I$(SRC_PATH_BARE)/third_party/googletest/src
454$(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 -0400455OBJS-$(BUILD_LIBVPX) += $(LIBVPX_TEST_OBJS)
James Zern97fd7c52012-08-15 11:45:12 -0700456BINS-$(BUILD_LIBVPX) += $(LIBVPX_TEST_BINS)
James Berry07c71ef2011-11-04 11:48:30 -0400457
John Koleszare82d2612012-05-16 16:25:51 -0700458# Install test sources only if codec source is included
459INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(patsubst $(SRC_PATH_BARE)/%,%,\
460 $(shell find $(SRC_PATH_BARE)/third_party/googletest -type f))
461INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(LIBVPX_TEST_SRCS)
462
John Koleszaracd147c2012-06-29 12:15:00 -0700463CODEC_LIB=$(if $(CONFIG_DEBUG_LIBS),vpx_g,vpx)
464CODEC_LIB_SUF=$(if $(CONFIG_SHARED),.so,.a)
James Berry07c71ef2011-11-04 11:48:30 -0400465$(foreach bin,$(LIBVPX_TEST_BINS),\
John Koleszaracd147c2012-06-29 12:15:00 -0700466 $(if $(BUILD_LIBVPX),$(eval $(bin): \
467 lib$(CODEC_LIB)$(CODEC_LIB_SUF) libgtest.a ))\
James Berry07c71ef2011-11-04 11:48:30 -0400468 $(if $(BUILD_LIBVPX),$(eval $(call linkerxx_template,$(bin),\
John Koleszare82d2612012-05-16 16:25:51 -0700469 $(LIBVPX_TEST_OBJS) \
James Berry07c71ef2011-11-04 11:48:30 -0400470 -L. -lvpx -lgtest -lpthread -lm)\
471 )))\
472 $(if $(LIPO_LIBS),$(eval $(call lipo_bin_template,$(bin))))\
473
John Koleszar00748632012-06-20 14:45:22 -0700474test:: $(LIBVPX_TEST_BINS) testdata
James Berry07c71ef2011-11-04 11:48:30 -0400475 @set -e; for t in $(LIBVPX_TEST_BINS); do $$t; done
476
477endif
478endif
479
480##
481## documentation directives
482##
John Koleszar0ea50ce2010-05-18 11:58:33 -0400483CLEAN-OBJS += libs.doxy
484DOCS-yes += libs.doxy
485libs.doxy: $(CODEC_DOC_SRCS)
486 @echo " [CREATE] $@"
487 @rm -f $@
488 @echo "INPUT += $^" >> $@
489 @echo "PREDEFINED = VPX_CODEC_DISABLE_COMPAT" >> $@
490 @echo "INCLUDE_PATH += ." >> $@;
491 @echo "ENABLED_SECTIONS += $(sort $(CODEC_DOC_SECTIONS))" >> $@
John Koleszare82d2612012-05-16 16:25:51 -0700492
John Koleszara9c75972012-11-08 17:09:30 -0800493## Generate rtcd.h for all objects
494$(OBJS-yes:.o=.d): $(RTCD)
John Koleszarb72373d2012-10-31 13:13:19 -0700495
496## Update the global src list
497SRCS += $(CODEC_SRCS) $(LIBVPX_TEST_SRCS) $(GTEST_SRCS)