Merge "Convert rc_max_intra_bitrate_pct to control"
[profile/ivi/libvpx.git] / libs.mk
1 ##
2 ##  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
3 ##
4 ##  Use of this source code is governed by a BSD-style license
5 ##  that can be found in the LICENSE file in the root of the source
6 ##  tree. An additional intellectual property rights grant can be found
7 ##  in the file PATENTS.  All contributing project authors may
8 ##  be found in the AUTHORS file in the root of the source tree.
9 ##
10
11
12 # ARM assembly files are written in RVCT-style. We use some make magic to
13 # filter those files to allow GCC compilation
14 ifeq ($(ARCH_ARM),yes)
15   ASM:=$(if $(filter yes,$(CONFIG_GCC)),.asm.s,.asm)
16 else
17   ASM:=.asm
18 endif
19
20 CODEC_SRCS-yes += libs.mk
21
22 include $(SRC_PATH_BARE)/vpx/vpx_codec.mk
23 CODEC_SRCS-yes += $(addprefix vpx/,$(call enabled,API_SRCS))
24
25 include $(SRC_PATH_BARE)/vpx_mem/vpx_mem.mk
26 CODEC_SRCS-yes += $(addprefix vpx_mem/,$(call enabled,MEM_SRCS))
27
28 include $(SRC_PATH_BARE)/vpx_scale/vpx_scale.mk
29 CODEC_SRCS-yes += $(addprefix vpx_scale/,$(call enabled,SCALE_SRCS))
30
31
32 ifeq ($(CONFIG_VP8_ENCODER),yes)
33   VP8_PREFIX=vp8/
34   include $(SRC_PATH_BARE)/$(VP8_PREFIX)vp8cx.mk
35   CODEC_SRCS-yes += $(addprefix $(VP8_PREFIX),$(call enabled,VP8_CX_SRCS))
36   CODEC_EXPORTS-yes += $(addprefix $(VP8_PREFIX),$(VP8_CX_EXPORTS))
37   CODEC_SRCS-yes += $(VP8_PREFIX)vp8cx.mk vpx/vp8.h vpx/vp8cx.h vpx/vp8e.h
38   INSTALL-LIBS-yes += include/vpx/vp8.h include/vpx/vp8e.h include/vpx/vp8cx.h
39   INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/$(VP8_PREFIX)/%
40   CODEC_DOC_SRCS += vpx/vp8.h vpx/vp8cx.h
41   CODEC_DOC_SECTIONS += vp8 vp8_encoder
42 endif
43
44 ifeq ($(CONFIG_VP8_DECODER),yes)
45   VP8_PREFIX=vp8/
46   include $(SRC_PATH_BARE)/$(VP8_PREFIX)vp8dx.mk
47   CODEC_SRCS-yes += $(addprefix $(VP8_PREFIX),$(call enabled,VP8_DX_SRCS))
48   CODEC_EXPORTS-yes += $(addprefix $(VP8_PREFIX),$(VP8_DX_EXPORTS))
49   CODEC_SRCS-yes += $(VP8_PREFIX)vp8dx.mk vpx/vp8.h vpx/vp8dx.h
50   INSTALL-LIBS-yes += include/vpx/vp8.h include/vpx/vp8dx.h
51   INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/$(VP8_PREFIX)/%
52   CODEC_DOC_SRCS += vpx/vp8.h vpx/vp8dx.h
53   CODEC_DOC_SECTIONS += vp8 vp8_decoder
54 endif
55
56
57 ifeq ($(CONFIG_ENCODERS),yes)
58   CODEC_DOC_SECTIONS += encoder
59 endif
60 ifeq ($(CONFIG_DECODERS),yes)
61   CODEC_DOC_SECTIONS += decoder
62 endif
63
64
65 ifeq ($(CONFIG_MSVS),yes)
66 CODEC_LIB=$(if $(CONFIG_STATIC_MSVCRT),vpxmt,vpxmd)
67 # This variable uses deferred expansion intentionally, since the results of
68 # $(wildcard) may change during the course of the Make.
69 VS_PLATFORMS = $(foreach d,$(wildcard */Release/$(CODEC_LIB).lib),$(word 1,$(subst /, ,$(d))))
70 endif
71
72 # The following pairs define a mapping of locations in the distribution
73 # tree to locations in the source/build trees.
74 INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/vpx/%
75 INSTALL_MAPS += include/vpx/% $(SRC_PATH_BARE)/vpx_ports/%
76 INSTALL_MAPS += $(LIBSUBDIR)/%     %
77 INSTALL_MAPS += src/%     $(SRC_PATH_BARE)/%
78 ifeq ($(CONFIG_MSVS),yes)
79 INSTALL_MAPS += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/%  $(p)/Release/%)
80 INSTALL_MAPS += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/%  $(p)/Debug/%)
81 endif
82
83 # If this is a universal (fat) binary, then all the subarchitectures have
84 # already been built and our job is to stitch them together. The
85 # BUILD_LIBVPX variable indicates whether we should be building
86 # (compiling, linking) the library. The LIPO_LIBVPX variable indicates
87 # that we're stitching.
88 $(eval $(if $(filter universal%,$(TOOLCHAIN)),LIPO_LIBVPX,BUILD_LIBVPX):=yes)
89
90 CODEC_SRCS-$(BUILD_LIBVPX) += build/make/version.sh
91 CODEC_SRCS-$(BUILD_LIBVPX) += vpx/vpx_integer.h
92 CODEC_SRCS-$(BUILD_LIBVPX) += vpx_ports/vpx_timer.h
93 CODEC_SRCS-$(BUILD_LIBVPX) += vpx_ports/mem.h
94 CODEC_SRCS-$(BUILD_LIBVPX) += $(BUILD_PFX)vpx_config.c
95 INSTALL-SRCS-no += $(BUILD_PFX)vpx_config.c
96 ifeq ($(ARCH_X86)$(ARCH_X86_64),yes)
97 CODEC_SRCS-$(BUILD_LIBVPX) += vpx_ports/emms.asm
98 CODEC_SRCS-$(BUILD_LIBVPX) += vpx_ports/x86.h
99 CODEC_SRCS-$(BUILD_LIBVPX) += vpx_ports/x86_abi_support.asm
100 CODEC_SRCS-$(BUILD_LIBVPX) += vpx_ports/x86_cpuid.c
101 endif
102 CODEC_SRCS-$(ARCH_ARM) += vpx_ports/arm_cpudetect.c
103 CODEC_SRCS-$(ARCH_ARM) += $(BUILD_PFX)vpx_config.asm
104 CODEC_EXPORTS-$(BUILD_LIBVPX) += vpx/exports_com
105 CODEC_EXPORTS-$(CONFIG_ENCODERS) += vpx/exports_enc
106 CODEC_EXPORTS-$(CONFIG_DECODERS) += vpx/exports_dec
107
108 INSTALL-LIBS-yes += include/vpx/vpx_codec.h
109 INSTALL-LIBS-yes += include/vpx/vpx_image.h
110 INSTALL-LIBS-yes += include/vpx/vpx_integer.h
111 INSTALL-LIBS-yes += include/vpx/vpx_codec_impl_top.h
112 INSTALL-LIBS-yes += include/vpx/vpx_codec_impl_bottom.h
113 INSTALL-LIBS-$(CONFIG_DECODERS) += include/vpx/vpx_decoder.h
114 INSTALL-LIBS-$(CONFIG_DECODERS) += include/vpx/vpx_decoder_compat.h
115 INSTALL-LIBS-$(CONFIG_ENCODERS) += include/vpx/vpx_encoder.h
116 ifeq ($(CONFIG_EXTERNAL_BUILD),yes)
117 ifeq ($(CONFIG_MSVS),yes)
118 INSTALL-LIBS-yes                  += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/$(CODEC_LIB).lib)
119 INSTALL-LIBS-$(CONFIG_DEBUG_LIBS) += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/$(CODEC_LIB)d.lib)
120 INSTALL-LIBS-$(CONFIG_SHARED) += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/vpx.dll)
121 INSTALL-LIBS-$(CONFIG_SHARED) += $(foreach p,$(VS_PLATFORMS),$(LIBSUBDIR)/$(p)/vpx.exp)
122 endif
123 else
124 INSTALL-LIBS-$(CONFIG_STATIC) += $(LIBSUBDIR)/libvpx.a
125 INSTALL-LIBS-$(CONFIG_DEBUG_LIBS) += $(LIBSUBDIR)/libvpx_g.a
126 endif
127
128 CODEC_SRCS=$(call enabled,CODEC_SRCS)
129 INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(CODEC_SRCS)
130 INSTALL-SRCS-$(CONFIG_CODEC_SRCS) += $(call enabled,CODEC_EXPORTS)
131
132 ifeq ($(CONFIG_EXTERNAL_BUILD),yes)
133 ifeq ($(CONFIG_MSVS),yes)
134
135 obj_int_extract.vcproj: $(SRC_PATH_BARE)/build/make/obj_int_extract.c
136         @cp $(SRC_PATH_BARE)/build/x86-msvs/obj_int_extract.bat .
137         @echo "    [CREATE] $@"
138         $(SRC_PATH_BARE)/build/make/gen_msvs_proj.sh \
139     --exe \
140     --target=$(TOOLCHAIN) \
141     --name=obj_int_extract \
142     --ver=$(CONFIG_VS_VERSION) \
143     --proj-guid=E1360C65-D375-4335-8057-7ED99CC3F9B2 \
144     $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \
145     --out=$@ $^ \
146     -I. \
147     -I"$(SRC_PATH_BARE)" \
148
149 PROJECTS-$(BUILD_LIBVPX) += obj_int_extract.vcproj
150 PROJECTS-$(BUILD_LIBVPX) += obj_int_extract.bat
151
152 vpx.def: $(call enabled,CODEC_EXPORTS)
153         @echo "    [CREATE] $@"
154         $(SRC_PATH_BARE)/build/make/gen_msvs_def.sh\
155             --name=vpx\
156             --out=$@ $^
157 CLEAN-OBJS += vpx.def
158
159 vpx.vcproj: $(CODEC_SRCS) vpx.def
160         @echo "    [CREATE] $@"
161         $(SRC_PATH_BARE)/build/make/gen_msvs_proj.sh \
162                         --lib \
163                         --target=$(TOOLCHAIN) \
164             $(if $(CONFIG_STATIC_MSVCRT),--static-crt) \
165             --name=vpx \
166             --proj-guid=DCE19DAF-69AC-46DB-B14A-39F0FAA5DB74 \
167             --module-def=vpx.def \
168             --ver=$(CONFIG_VS_VERSION) \
169             --out=$@ $(CFLAGS) $^ \
170             --src-path-bare="$(SRC_PATH_BARE)" \
171
172 PROJECTS-$(BUILD_LIBVPX) += vpx.vcproj
173
174 vpx.vcproj: vpx_config.asm
175
176 endif
177 else
178 LIBVPX_OBJS=$(call objs,$(CODEC_SRCS))
179 OBJS-$(BUILD_LIBVPX) += $(LIBVPX_OBJS)
180 LIBS-$(CONFIG_STATIC) += $(BUILD_PFX)libvpx.a $(BUILD_PFX)libvpx_g.a
181 $(BUILD_PFX)libvpx_g.a: $(LIBVPX_OBJS)
182
183 BUILD_LIBVPX_SO         := $(if $(BUILD_LIBVPX),$(CONFIG_SHARED))
184 LIBVPX_SO               := libvpx.so.$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH)
185 LIBS-$(BUILD_LIBVPX_SO) += $(BUILD_PFX)$(LIBVPX_SO)\
186                            $(notdir $(LIBVPX_SO_SYMLINKS))
187 $(BUILD_PFX)$(LIBVPX_SO): $(LIBVPX_OBJS) libvpx.ver
188 $(BUILD_PFX)$(LIBVPX_SO): extralibs += -lm
189 $(BUILD_PFX)$(LIBVPX_SO): SONAME = libvpx.so.$(VERSION_MAJOR)
190 $(BUILD_PFX)$(LIBVPX_SO): SO_VERSION_SCRIPT = libvpx.ver
191 LIBVPX_SO_SYMLINKS      := $(addprefix $(LIBSUBDIR)/, \
192                              libvpx.so libvpx.so.$(VERSION_MAJOR) \
193                              libvpx.so.$(VERSION_MAJOR).$(VERSION_MINOR))
194
195 libvpx.ver: $(call enabled,CODEC_EXPORTS)
196         @echo "    [CREATE] $@"
197         $(qexec)echo "{ global:" > $@
198         $(qexec)for f in $?; do awk '{print $$2";"}' < $$f >>$@; done
199         $(qexec)echo "local: *; };" >> $@
200 CLEAN-OBJS += libvpx.ver
201
202 define libvpx_symlink_template
203 $(1): $(2)
204         @echo "    [LN]      $$@"
205         $(qexec)ln -sf $(LIBVPX_SO) $$@
206 endef
207
208 $(eval $(call libvpx_symlink_template,\
209     $(addprefix $(BUILD_PFX),$(notdir $(LIBVPX_SO_SYMLINKS))),\
210     $(BUILD_PFX)$(LIBVPX_SO)))
211 $(eval $(call libvpx_symlink_template,\
212     $(addprefix $(DIST_DIR)/,$(LIBVPX_SO_SYMLINKS)),\
213     $(DIST_DIR)/$(LIBSUBDIR)/$(LIBVPX_SO)))
214
215 INSTALL-LIBS-$(CONFIG_SHARED) += $(LIBVPX_SO_SYMLINKS)
216 INSTALL-LIBS-$(CONFIG_SHARED) += $(LIBSUBDIR)/$(LIBVPX_SO)
217
218 LIBS-$(BUILD_LIBVPX) += vpx.pc
219 vpx.pc: config.mk libs.mk
220         @echo "    [CREATE] $@"
221         $(qexec)echo '# pkg-config file from libvpx $(VERSION_STRING)' > $@
222         $(qexec)echo 'prefix=$(PREFIX)' >> $@
223         $(qexec)echo 'exec_prefix=$${prefix}' >> $@
224         $(qexec)echo 'libdir=$${prefix}/lib' >> $@
225         $(qexec)echo 'includedir=$${prefix}/include' >> $@
226         $(qexec)echo '' >> $@
227         $(qexec)echo 'Name: vpx' >> $@
228         $(qexec)echo 'Description: WebM Project VPx codec implementation' >> $@
229         $(qexec)echo 'Version: $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH)' >> $@
230         $(qexec)echo 'Requires:' >> $@
231         $(qexec)echo 'Conflicts:' >> $@
232         $(qexec)echo 'Libs: -L$${libdir} -lvpx' >> $@
233         $(qexec)echo 'Cflags: -I$${includedir}' >> $@
234 INSTALL-LIBS-yes += $(LIBSUBDIR)/pkgconfig/vpx.pc
235 INSTALL_MAPS += $(LIBSUBDIR)/pkgconfig/%.pc %.pc
236 CLEAN-OBJS += vpx.pc
237 endif
238
239 LIBS-$(LIPO_LIBVPX) += libvpx.a
240 $(eval $(if $(LIPO_LIBVPX),$(call lipo_lib_template,libvpx.a)))
241
242 #
243 # Rule to make assembler configuration file from C configuration file
244 #
245 ifeq ($(ARCH_X86)$(ARCH_X86_64),yes)
246 # YASM
247 $(BUILD_PFX)vpx_config.asm: $(BUILD_PFX)vpx_config.h
248         @echo "    [CREATE] $@"
249         @egrep "#define [A-Z0-9_]+ [01]" $< \
250             | awk '{print $$2 " equ " $$3}' > $@
251 else
252 ADS2GAS=$(if $(filter yes,$(CONFIG_GCC)),| $(ASM_CONVERSION))
253 $(BUILD_PFX)vpx_config.asm: $(BUILD_PFX)vpx_config.h
254         @echo "    [CREATE] $@"
255         @egrep "#define [A-Z0-9_]+ [01]" $< \
256             | awk '{print $$2 " EQU " $$3}' $(ADS2GAS) > $@
257         @echo "        END" $(ADS2GAS) >> $@
258 CLEAN-OBJS += $(BUILD_PFX)vpx_config.asm
259 endif
260
261 #
262 # Add assembler dependencies for configuration and offsets
263 #
264 $(filter %.s.o,$(OBJS-yes)):     $(BUILD_PFX)vpx_config.asm
265 $(filter %$(ASM).o,$(OBJS-yes)): $(BUILD_PFX)vpx_config.asm
266
267 #
268 # Calculate platform- and compiler-specific offsets for hand coded assembly
269 #
270
271 ifeq ($(filter icc gcc,$(TGT_CC)), $(TGT_CC))
272     asm_com_offsets.asm: $(VP8_PREFIX)common/asm_com_offsets.c.S
273         grep EQU $< | tr -d '$$\#' $(ADS2GAS) > $@
274     $(VP8_PREFIX)common/asm_com_offsets.c.S: vp8/common/asm_com_offsets.c
275     CLEAN-OBJS += asm_com_offsets.asm $(VP8_PREFIX)common/asm_com_offsets.c.S
276
277     asm_enc_offsets.asm: $(VP8_PREFIX)encoder/asm_enc_offsets.c.S
278         grep EQU $< | tr -d '$$\#' $(ADS2GAS) > $@
279     $(VP8_PREFIX)encoder/asm_enc_offsets.c.S: vp8/encoder/asm_enc_offsets.c
280     CLEAN-OBJS += asm_enc_offsets.asm $(VP8_PREFIX)encoder/asm_enc_offsets.c.S
281
282     asm_dec_offsets.asm: $(VP8_PREFIX)decoder/asm_dec_offsets.c.S
283         grep EQU $< | tr -d '$$\#' $(ADS2GAS) > $@
284     $(VP8_PREFIX)decoder/asm_dec_offsets.c.S: vp8/decoder/asm_dec_offsets.c
285     CLEAN-OBJS += asm_dec_offsets.asm $(VP8_PREFIX)decoder/asm_dec_offsets.c.S
286 else
287   ifeq ($(filter rvct,$(TGT_CC)), $(TGT_CC))
288     asm_com_offsets.asm: obj_int_extract
289     asm_com_offsets.asm: $(VP8_PREFIX)common/asm_com_offsets.c.o
290         ./obj_int_extract rvds $< $(ADS2GAS) > $@
291     OBJS-yes += $(VP8_PREFIX)common/asm_com_offsets.c.o
292     CLEAN-OBJS += asm_com_offsets.asm
293     $(filter %$(ASM).o,$(OBJS-yes)): $(BUILD_PFX)asm_com_offsets.asm
294
295     asm_enc_offsets.asm: obj_int_extract
296     asm_enc_offsets.asm: $(VP8_PREFIX)encoder/asm_enc_offsets.c.o
297         ./obj_int_extract rvds $< $(ADS2GAS) > $@
298     OBJS-yes += $(VP8_PREFIX)encoder/asm_enc_offsets.c.o
299     CLEAN-OBJS += asm_enc_offsets.asm
300     $(filter %$(ASM).o,$(OBJS-yes)): $(BUILD_PFX)asm_enc_offsets.asm
301
302     asm_dec_offsets.asm: obj_int_extract
303     asm_dec_offsets.asm: $(VP8_PREFIX)decoder/asm_dec_offsets.c.o
304         ./obj_int_extract rvds $< $(ADS2GAS) > $@
305     OBJS-yes += $(VP8_PREFIX)decoder/asm_dec_offsets.c.o
306     CLEAN-OBJS += asm_dec_offsets.asm
307     $(filter %$(ASM).o,$(OBJS-yes)): $(BUILD_PFX)asm_dec_offsets.asm
308   endif
309 endif
310
311 $(shell $(SRC_PATH_BARE)/build/make/version.sh "$(SRC_PATH_BARE)" $(BUILD_PFX)vpx_version.h)
312 CLEAN-OBJS += $(BUILD_PFX)vpx_version.h
313
314 CODEC_DOC_SRCS += vpx/vpx_codec.h \
315                   vpx/vpx_decoder.h \
316                   vpx/vpx_encoder.h \
317                   vpx/vpx_image.h
318
319 CLEAN-OBJS += libs.doxy
320 DOCS-yes += libs.doxy
321 libs.doxy: $(CODEC_DOC_SRCS)
322         @echo "    [CREATE] $@"
323         @rm -f $@
324         @echo "INPUT += $^" >> $@
325         @echo "PREDEFINED = VPX_CODEC_DISABLE_COMPAT" >> $@
326         @echo "INCLUDE_PATH += ." >> $@;
327         @echo "ENABLED_SECTIONS += $(sort $(CODEC_DOC_SECTIONS))" >> $@