Commit 7aa97a35 authored by John Koleszar's avatar John Koleszar Committed by John Koleszar

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
parent 9a27722b
...@@ -220,6 +220,20 @@ $(1): ...@@ -220,6 +220,20 @@ $(1):
$(qexec)$$(AR) $$(ARFLAGS) $$@ $$? $(qexec)$$(AR) $$(ARFLAGS) $$@ $$?
endef 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 define lipo_lib_template
$(1): $(addsuffix /$(1),$(FAT_ARCHS)) $(1): $(addsuffix /$(1),$(FAT_ARCHS))
$(if $(quiet),@echo " [LIPO] $$@") $(if $(quiet),@echo " [LIPO] $$@")
...@@ -283,6 +297,7 @@ LIBS=$(call enabled,LIBS) ...@@ -283,6 +297,7 @@ LIBS=$(call enabled,LIBS)
.libs: $(LIBS) .libs: $(LIBS)
@touch $@ @touch $@
$(foreach lib,$(filter %_g.a,$(LIBS)),$(eval $(call archive_template,$(lib)))) $(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) INSTALL-LIBS=$(call cond_enabled,CONFIG_INSTALL_LIBS,INSTALL-LIBS)
ifeq ($(MAKECMDGOALS),dist) ifeq ($(MAKECMDGOALS),dist)
......
...@@ -39,6 +39,7 @@ Advanced options: ...@@ -39,6 +39,7 @@ Advanced options:
${toggle_spatial_resampling} spatial sampling (scaling) support ${toggle_spatial_resampling} spatial sampling (scaling) support
${toggle_realtime_only} enable this option while building for real-time encoding ${toggle_realtime_only} enable this option while building for real-time encoding
${toggle_runtime_cpu_detect} runtime cpu detection ${toggle_runtime_cpu_detect} runtime cpu detection
${toggle_shared} shared library support
Codecs: Codecs:
Codecs can be selectively enabled or disabled individually, or by family: Codecs can be selectively enabled or disabled individually, or by family:
...@@ -242,6 +243,7 @@ CONFIG_LIST=" ...@@ -242,6 +243,7 @@ CONFIG_LIST="
static_msvcrt static_msvcrt
spatial_resampling spatial_resampling
realtime_only realtime_only
shared
" "
CMDLINE_SELECT=" CMDLINE_SELECT="
extra_warnings extra_warnings
...@@ -280,6 +282,7 @@ CMDLINE_SELECT=" ...@@ -280,6 +282,7 @@ CMDLINE_SELECT="
mem_tracker mem_tracker
spatial_resampling spatial_resampling
realtime_only realtime_only
shared
" "
process_cmdline() { process_cmdline() {
...@@ -369,6 +372,12 @@ process_targets() { ...@@ -369,6 +372,12 @@ process_targets() {
if [ -f "${source_path}/build/make/version.sh" ]; then if [ -f "${source_path}/build/make/version.sh" ]; then
local ver=`"$source_path/build/make/version.sh" --bare $source_path` local ver=`"$source_path/build/make/version.sh" --bare $source_path`
DIST_DIR="${DIST_DIR}-${ver}" DIST_DIR="${DIST_DIR}-${ver}"
ver=${ver%%-*}
VERSION_PATCH=${ver##*.}
ver=${ver%.*}
VERSION_MINOR=${ver##*.}
ver=${ver#v}
VERSION_MAJOR=${ver%.*}
fi fi
enabled child || cat <<EOF >> config.mk enabled child || cat <<EOF >> config.mk
ifeq (\$(MAKECMDGOALS),dist) ifeq (\$(MAKECMDGOALS),dist)
...@@ -377,6 +386,11 @@ else ...@@ -377,6 +386,11 @@ else
DIST_DIR?=\$(DESTDIR)${prefix} DIST_DIR?=\$(DESTDIR)${prefix}
endif endif
LIBSUBDIR=${libdir##${prefix}/} LIBSUBDIR=${libdir##${prefix}/}
VERSION_MAJOR=${VERSION_MAJOR}
VERSION_MINOR=${VERSION_MINOR}
VERSION_PATCH=${VERSION_PATCH}
EOF EOF
enabled child || echo "CONFIGURE_ARGS?=${CONFIGURE_ARGS}" >> config.mk enabled child || echo "CONFIGURE_ARGS?=${CONFIGURE_ARGS}" >> config.mk
...@@ -396,6 +410,12 @@ EOF ...@@ -396,6 +410,12 @@ EOF
} }
process_detect() { 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 if [ -z "$CC" ]; then
echo "Bypassing toolchain for environment detection." echo "Bypassing toolchain for environment detection."
enable external_build enable external_build
......
...@@ -92,7 +92,9 @@ CODEC_SRCS-$(BUILD_LIBVPX) += vpx_ports/x86.h ...@@ -92,7 +92,9 @@ CODEC_SRCS-$(BUILD_LIBVPX) += vpx_ports/x86.h
CODEC_SRCS-$(BUILD_LIBVPX) += vpx_ports/x86_abi_support.asm CODEC_SRCS-$(BUILD_LIBVPX) += vpx_ports/x86_abi_support.asm
endif endif
CODEC_SRCS-$(ARCH_ARM) += $(BUILD_PFX)vpx_config.asm 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_codec.h
INSTALL-LIBS-yes += include/vpx/vpx_image.h INSTALL-LIBS-yes += include/vpx/vpx_image.h
...@@ -175,6 +177,31 @@ LIBVPX_OBJS=$(call objs,$(CODEC_SRCS)) ...@@ -175,6 +177,31 @@ LIBVPX_OBJS=$(call objs,$(CODEC_SRCS))
OBJS-$(BUILD_LIBVPX) += $(LIBVPX_OBJS) OBJS-$(BUILD_LIBVPX) += $(LIBVPX_OBJS)
LIBS-$(BUILD_LIBVPX) += $(BUILD_PFX)libvpx.a $(BUILD_PFX)libvpx_g.a LIBS-$(BUILD_LIBVPX) += $(BUILD_PFX)libvpx.a $(BUILD_PFX)libvpx_g.a
$(BUILD_PFX)libvpx_g.a: $(LIBVPX_OBJS) $(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 endif
LIBS-$(LIPO_LIBVPX) += libvpx.a LIBS-$(LIPO_LIBVPX) += libvpx.a
......
data vpx_codec_vp8_dx_algo
data vpx_codec_vp8_cx_algo
...@@ -10,6 +10,9 @@ ...@@ -10,6 +10,9 @@
include $(SRC_PATH_BARE)/$(VP8_PREFIX)vp8_common.mk 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-yes += $(VP8_COMMON_SRCS-yes)
VP8_CX_SRCS-no += $(VP8_COMMON_SRCS-no) VP8_CX_SRCS-no += $(VP8_COMMON_SRCS-no)
VP8_CX_SRCS_REMOVE-yes += $(VP8_COMMON_SRCS_REMOVE-yes) VP8_CX_SRCS_REMOVE-yes += $(VP8_COMMON_SRCS_REMOVE-yes)
......
...@@ -10,6 +10,9 @@ ...@@ -10,6 +10,9 @@
include $(SRC_PATH_BARE)/$(VP8_PREFIX)vp8_common.mk 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-yes += $(VP8_COMMON_SRCS-yes)
VP8_DX_SRCS-no += $(VP8_COMMON_SRCS-no) VP8_DX_SRCS-no += $(VP8_COMMON_SRCS-no)
VP8_DX_SRCS_REMOVE-yes += $(VP8_COMMON_SRCS_REMOVE-yes) VP8_DX_SRCS_REMOVE-yes += $(VP8_COMMON_SRCS_REMOVE-yes)
......
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
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
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
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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment