summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Koleszar <jkoleszar@google.com>2010-06-03 10:29:04 -0400
committerJohn Koleszar <john.koleszar@on2.com>2010-06-05 16:47:23 -0400
commit7aa97a35b515bfb7d7bbcdee4db376f815343e44 (patch)
tree3b83c5bc42bb89ae561e06c89c19be9c2377d05f
parent9a27722b98ba58282efbf668864259139d4faa18 (diff)
downloadlibvpx-7aa97a35b515bfb7d7bbcdee4db376f815343e44.tar
libvpx-7aa97a35b515bfb7d7bbcdee4db376f815343e44.tar.gz
libvpx-7aa97a35b515bfb7d7bbcdee4db376f815343e44.tar.bz2
libvpx-7aa97a35b515bfb7d7bbcdee4db376f815343e44.zip
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
-rwxr-xr-xbuild/make/Makefile15
-rwxr-xr-xconfigure20
-rw-r--r--libs.mk29
-rw-r--r--vp8/exports_dec1
-rw-r--r--vp8/exports_enc1
-rw-r--r--vp8/vp8cx.mk3
-rw-r--r--vp8/vp8dx.mk3
-rw-r--r--vpx/exports17
-rw-r--r--vpx/exports_com16
-rw-r--r--vpx/exports_dec9
-rw-r--r--vpx/exports_enc8
11 files changed, 104 insertions, 18 deletions
diff --git a/build/make/Makefile b/build/make/Makefile
index 6dd1279fc..ba2578e93 100755
--- a/build/make/Makefile
+++ b/build/make/Makefile
@@ -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)
diff --git a/configure b/configure
index d7d041c27..f2b42bef4 100755
--- a/configure
+++ b/configure
@@ -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
diff --git a/libs.mk b/libs.mk
index be237a137..c6b08d21b 100644
--- a/libs.mk
+++ b/libs.mk
@@ -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
diff --git a/vp8/exports_dec b/vp8/exports_dec
new file mode 100644
index 000000000..f9b985c86
--- /dev/null
+++ b/vp8/exports_dec
@@ -0,0 +1 @@
+data vpx_codec_vp8_dx_algo
diff --git a/vp8/exports_enc b/vp8/exports_enc
new file mode 100644
index 000000000..996701113
--- /dev/null
+++ b/vp8/exports_enc
@@ -0,0 +1 @@
+data vpx_codec_vp8_cx_algo
diff --git a/vp8/vp8cx.mk b/vp8/vp8cx.mk
index a512ff910..544a3b3fa 100644
--- a/vp8/vp8cx.mk
+++ b/vp8/vp8cx.mk
@@ -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)
diff --git a/vp8/vp8dx.mk b/vp8/vp8dx.mk
index 44b4b495d..24f18b7cd 100644
--- a/vp8/vp8dx.mk
+++ b/vp8/vp8dx.mk
@@ -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)
diff --git a/vpx/exports b/vpx/exports
deleted file mode 100644
index f5e7473bc..000000000
--- a/vpx/exports
+++ /dev/null
@@ -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
diff --git a/vpx/exports_com b/vpx/exports_com
new file mode 100644
index 000000000..2ab05099f
--- /dev/null
+++ b/vpx/exports_com
@@ -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
diff --git a/vpx/exports_dec b/vpx/exports_dec
new file mode 100644
index 000000000..ed121f7ec
--- /dev/null
+++ b/vpx/exports_dec
@@ -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
diff --git a/vpx/exports_enc b/vpx/exports_enc
new file mode 100644
index 000000000..3d5674926
--- /dev/null
+++ b/vpx/exports_enc
@@ -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