shared library support (.so)

This patch adds support for building shared libraries when configured
with the --enable-shared switch.

Building DLLs would require more invasive changes to the sample
utilities than I want to make in this patch, since on Windows you can't
use the address of an imported symbol in a static initializer. The best
way to work around this is proably to build the codec interface mapping
table with an init() function, but dll support is of questionable value
anyway, since most windows users will probably use a media framework
lib like webmdshow, which links this library in staticly.

Change-Id: Iafb48900549b0c6b67f4a05d3b790b2643d026f4
This commit is contained in:
John Koleszar 2010-06-03 10:29:04 -04:00 committed by John Koleszar
parent 9a27722b98
commit 7aa97a35b5
11 changed files with 104 additions and 18 deletions

View File

@ -220,6 +220,20 @@ $(1):
$(qexec)$$(AR) $$(ARFLAGS) $$@ $$?
endef
define so_template
# Not using a pattern rule here because we don't want to generate empty
# archives when they are listed as a dependency in files not responsible
# for creating them.
#
# This needs further abstraction for dealing with non-GNU linkers.
$(1):
$(if $(quiet),@echo " [LD] $$@")
$(qexec)$$(LD) -shared $$(LDFLAGS) \
-Wl,--no-undefined -Wl,-soname,$$(SONAME) \
-Wl,--version-script,$$(SO_VERSION_SCRIPT) -o $$@ \
$$(filter %.o,$$?)
endef
define lipo_lib_template
$(1): $(addsuffix /$(1),$(FAT_ARCHS))
$(if $(quiet),@echo " [LIPO] $$@")
@ -283,6 +297,7 @@ LIBS=$(call enabled,LIBS)
.libs: $(LIBS)
@touch $@
$(foreach lib,$(filter %_g.a,$(LIBS)),$(eval $(call archive_template,$(lib))))
$(foreach lib,$(filter %so.$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH),$(LIBS)),$(eval $(call so_template,$(lib))))
INSTALL-LIBS=$(call cond_enabled,CONFIG_INSTALL_LIBS,INSTALL-LIBS)
ifeq ($(MAKECMDGOALS),dist)

20
configure vendored
View File

@ -39,6 +39,7 @@ Advanced options:
${toggle_spatial_resampling} spatial sampling (scaling) support
${toggle_realtime_only} enable this option while building for real-time encoding
${toggle_runtime_cpu_detect} runtime cpu detection
${toggle_shared} shared library support
Codecs:
Codecs can be selectively enabled or disabled individually, or by family:
@ -242,6 +243,7 @@ CONFIG_LIST="
static_msvcrt
spatial_resampling
realtime_only
shared
"
CMDLINE_SELECT="
extra_warnings
@ -280,6 +282,7 @@ CMDLINE_SELECT="
mem_tracker
spatial_resampling
realtime_only
shared
"
process_cmdline() {
@ -369,6 +372,12 @@ process_targets() {
if [ -f "${source_path}/build/make/version.sh" ]; then
local ver=`"$source_path/build/make/version.sh" --bare $source_path`
DIST_DIR="${DIST_DIR}-${ver}"
ver=${ver%%-*}
VERSION_PATCH=${ver##*.}
ver=${ver%.*}
VERSION_MINOR=${ver##*.}
ver=${ver#v}
VERSION_MAJOR=${ver%.*}
fi
enabled child || cat <<EOF >> config.mk
ifeq (\$(MAKECMDGOALS),dist)
@ -377,6 +386,11 @@ else
DIST_DIR?=\$(DESTDIR)${prefix}
endif
LIBSUBDIR=${libdir##${prefix}/}
VERSION_MAJOR=${VERSION_MAJOR}
VERSION_MINOR=${VERSION_MINOR}
VERSION_PATCH=${VERSION_PATCH}
EOF
enabled child || echo "CONFIGURE_ARGS?=${CONFIGURE_ARGS}" >> config.mk
@ -396,6 +410,12 @@ EOF
}
process_detect() {
if enabled shared; then
# Can only build shared libs on a subset of platforms. Doing this check
# here rather than at option parse time because the target auto-detect
# magic happens after the command line has been parsed.
enabled linux || die "--enable-shared only supported on ELF for now"
fi
if [ -z "$CC" ]; then
echo "Bypassing toolchain for environment detection."
enable external_build

29
libs.mk
View File

@ -92,7 +92,9 @@ CODEC_SRCS-$(BUILD_LIBVPX) += vpx_ports/x86.h
CODEC_SRCS-$(BUILD_LIBVPX) += vpx_ports/x86_abi_support.asm
endif
CODEC_SRCS-$(ARCH_ARM) += $(BUILD_PFX)vpx_config.asm
CODEC_EXPORTS-$(BUILD_LIBVPX) += vpx/exports
CODEC_EXPORTS-$(BUILD_LIBVPX) += vpx/exports_com
CODEC_EXPORTS-$(CONFIG_ENCODERS) += vpx/exports_enc
CODEC_EXPORTS-$(CONFIG_DECODERS) += vpx/exports_dec
INSTALL-LIBS-yes += include/vpx/vpx_codec.h
INSTALL-LIBS-yes += include/vpx/vpx_image.h
@ -175,6 +177,31 @@ LIBVPX_OBJS=$(call objs,$(CODEC_SRCS))
OBJS-$(BUILD_LIBVPX) += $(LIBVPX_OBJS)
LIBS-$(BUILD_LIBVPX) += $(BUILD_PFX)libvpx.a $(BUILD_PFX)libvpx_g.a
$(BUILD_PFX)libvpx_g.a: $(LIBVPX_OBJS)
BUILD_LIBVPX_SO := $(if $(BUILD_LIBVPX),$(CONFIG_SHARED))
LIBVPX_SO := libvpx.so.$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH)
LIBS-$(BUILD_LIBVPX_SO) += $(BUILD_PFX)$(LIBVPX_SO)
$(BUILD_PFX)$(LIBVPX_SO): $(LIBVPX_OBJS) libvpx.ver
$(BUILD_PFX)$(LIBVPX_SO): LDFLAGS += -lm -pthread
$(BUILD_PFX)$(LIBVPX_SO): SONAME = libvpx.so.$(VERSION_MAJOR)
$(BUILD_PFX)$(LIBVPX_SO): SO_VERSION_SCRIPT = libvpx.ver
LIBVPX_SO_SYMLINKS := $(addprefix $(LIBSUBDIR)/, \
libvpx.so libvpx.so.$(VERSION_MAJOR) \
libvpx.so.$(VERSION_MAJOR).$(VERSION_MINOR))
libvpx.ver: $(call enabled,CODEC_EXPORTS)
@echo " [CREATE] $@"
$(qexec)echo "{ global:" > $@
$(qexec)for f in $?; do awk '{print $$2";"}' < $$f >>$@; done
$(qexec)echo "local: *; };" >> $@
CLEAN-OBJS += libvpx.ver
$(addprefix $(DIST_DIR)/,$(LIBVPX_SO_SYMLINKS)):
@echo " [LN] $@"
$(qexec)ln -sf $(LIBVPX_SO) $@
INSTALL-LIBS-$(CONFIG_SHARED) += $(LIBVPX_SO_SYMLINKS)
INSTALL-LIBS-$(CONFIG_SHARED) += $(LIBSUBDIR)/$(LIBVPX_SO)
endif
LIBS-$(LIPO_LIBVPX) += libvpx.a

1
vp8/exports_dec Normal file
View File

@ -0,0 +1 @@
data vpx_codec_vp8_dx_algo

1
vp8/exports_enc Normal file
View File

@ -0,0 +1 @@
data vpx_codec_vp8_cx_algo

View File

@ -10,6 +10,9 @@
include $(SRC_PATH_BARE)/$(VP8_PREFIX)vp8_common.mk
VP8_CX_EXPORTS += exports_enc
VP8_CX_SRCS-yes += $(VP8_COMMON_SRCS-yes)
VP8_CX_SRCS-no += $(VP8_COMMON_SRCS-no)
VP8_CX_SRCS_REMOVE-yes += $(VP8_COMMON_SRCS_REMOVE-yes)

View File

@ -10,6 +10,9 @@
include $(SRC_PATH_BARE)/$(VP8_PREFIX)vp8_common.mk
VP8_DX_EXPORTS += exports_dec
VP8_DX_SRCS-yes += $(VP8_COMMON_SRCS-yes)
VP8_DX_SRCS-no += $(VP8_COMMON_SRCS-no)
VP8_DX_SRCS_REMOVE-yes += $(VP8_COMMON_SRCS_REMOVE-yes)

View File

@ -1,17 +0,0 @@
text vpx_dec_control
text vpx_dec_decode
text vpx_dec_destroy
text vpx_dec_err_to_string
text vpx_dec_error
text vpx_dec_error_detail
text vpx_dec_get_caps
text vpx_dec_get_frame
text vpx_dec_get_mem_map
text vpx_dec_get_stream_info
text vpx_dec_iface_name
text vpx_dec_init_ver
text vpx_dec_peek_stream_info
text vpx_dec_register_put_frame_cb
text vpx_dec_register_put_slice_cb
text vpx_dec_set_mem_map
text vpx_dec_xma_init_ver

16
vpx/exports_com Normal file
View File

@ -0,0 +1,16 @@
text vpx_codec_build_config
text vpx_codec_control_
text vpx_codec_destroy
text vpx_codec_err_to_string
text vpx_codec_error
text vpx_codec_error_detail
text vpx_codec_get_caps
text vpx_codec_iface_name
text vpx_codec_version
text vpx_codec_version_extra_str
text vpx_codec_version_str
text vpx_img_alloc
text vpx_img_flip
text vpx_img_free
text vpx_img_set_rect
text vpx_img_wrap

9
vpx/exports_dec Normal file
View File

@ -0,0 +1,9 @@
text vpx_codec_dec_init_ver
text vpx_codec_decode
text vpx_codec_get_frame
text vpx_codec_get_mem_map
text vpx_codec_get_stream_info
text vpx_codec_peek_stream_info
text vpx_codec_register_put_frame_cb
text vpx_codec_register_put_slice_cb
text vpx_codec_set_mem_map

8
vpx/exports_enc Normal file
View File

@ -0,0 +1,8 @@
text vpx_codec_enc_config_default
text vpx_codec_enc_config_set
text vpx_codec_enc_init_ver
text vpx_codec_encode
text vpx_codec_get_cx_data
text vpx_codec_get_global_headers
text vpx_codec_get_preview_frame
text vpx_codec_set_cx_data_buf