Add symbol versioning for shared libraries
authorMåns Rullgård <mans@mansr.com>
Sat, 16 Jan 2010 04:49:02 +0000 (04:49 +0000)
committerMåns Rullgård <mans@mansr.com>
Sat, 16 Jan 2010 04:49:02 +0000 (04:49 +0000)
Based on patch by Reinhard Tartler <siretart tauware de>

Originally committed as revision 21236 to svn://svn.ffmpeg.org/ffmpeg/trunk

common.mak
configure
libavcodec/libavcodec.v [new file with mode: 0644]
libavdevice/libavdevice.v [new file with mode: 0644]
libavfilter/libavfilter.v [new file with mode: 0644]
libavformat/libavformat.v [new file with mode: 0644]
libavutil/libavutil.v [new file with mode: 0644]
libpostproc/libpostproc.v [new file with mode: 0644]
subdir.mak

index 8ce4648..deb3e78 100644 (file)
@@ -9,6 +9,7 @@ vpath %.c   $(SRC_DIR)
 vpath %.h   $(SRC_DIR)
 vpath %.S   $(SRC_DIR)
 vpath %.asm $(SRC_DIR)
 vpath %.h   $(SRC_DIR)
 vpath %.S   $(SRC_DIR)
 vpath %.asm $(SRC_DIR)
+vpath %.v   $(SRC_DIR)
 
 ifeq ($(SRC_DIR),$(SRC_PATH_BARE))
 BUILD_ROOT_REL = .
 
 ifeq ($(SRC_DIR),$(SRC_PATH_BARE))
 BUILD_ROOT_REL = .
@@ -33,6 +34,9 @@ CPPFLAGS := -DHAVE_AV_CONFIG_H -I$(BUILD_ROOT_REL) -I$(SRC_PATH) $(CPPFLAGS)
 
 %$(EXESUF): %.c
 
 
 %$(EXESUF): %.c
 
+%.ver: %.v
+       sed 's/$$MAJOR/$($(basename $(@F))_VERSION_MAJOR)/' $^ > $@
+
 SVN_ENTRIES = $(SRC_PATH_BARE)/.svn/entries
 ifeq ($(wildcard $(SVN_ENTRIES)),$(SVN_ENTRIES))
 $(BUILD_ROOT_REL)/version.h: $(SVN_ENTRIES)
 SVN_ENTRIES = $(SRC_PATH_BARE)/.svn/entries
 ifeq ($(wildcard $(SVN_ENTRIES)),$(SVN_ENTRIES))
 $(BUILD_ROOT_REL)/version.h: $(SVN_ENTRIES)
@@ -77,7 +81,7 @@ $(HOSTPROGS): %$(HOSTEXESUF): %.o
 DEPS := $(OBJS:.o=.d)
 depend dep: $(DEPS)
 
 DEPS := $(OBJS:.o=.d)
 depend dep: $(DEPS)
 
-CLEANSUFFIXES     = *.d *.o *~ *.ho *.map
+CLEANSUFFIXES     = *.d *.o *~ *.ho *.map *.ver
 DISTCLEANSUFFIXES = *.pc
 LIBSUFFIXES       = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a *.exp
 
 DISTCLEANSUFFIXES = *.pc
 LIBSUFFIXES       = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a *.exp
 
index c9cf2d1..62a7f98 100755 (executable)
--- a/configure
+++ b/configure
@@ -1561,6 +1561,7 @@ tmpfile TMPE  $EXESUF
 tmpfile TMPH  .h
 tmpfile TMPO  .o
 tmpfile TMPS  .S
 tmpfile TMPH  .h
 tmpfile TMPO  .o
 tmpfile TMPS  .S
+tmpfile TMPV  .ver
 tmpfile TMPSH .sh
 
 unset -f mktemp
 tmpfile TMPSH .sh
 
 unset -f mktemp
@@ -2568,6 +2569,10 @@ check_ldflags -Wl,--as-needed
 check_ldflags '-Wl,-rpath-link,\$(BUILD_ROOT)/libpostproc -Wl,-rpath-link,\$(BUILD_ROOT)/libswscale -Wl,-rpath-link,\$(BUILD_ROOT)/libavfilter -Wl,-rpath-link,\$(BUILD_ROOT)/libavdevice -Wl,-rpath-link,\$(BUILD_ROOT)/libavformat -Wl,-rpath-link,\$(BUILD_ROOT)/libavcodec -Wl,-rpath-link,\$(BUILD_ROOT)/libavutil'
 check_ldflags -Wl,-Bsymbolic
 
 check_ldflags '-Wl,-rpath-link,\$(BUILD_ROOT)/libpostproc -Wl,-rpath-link,\$(BUILD_ROOT)/libswscale -Wl,-rpath-link,\$(BUILD_ROOT)/libavfilter -Wl,-rpath-link,\$(BUILD_ROOT)/libavdevice -Wl,-rpath-link,\$(BUILD_ROOT)/libavformat -Wl,-rpath-link,\$(BUILD_ROOT)/libavcodec -Wl,-rpath-link,\$(BUILD_ROOT)/libavutil'
 check_ldflags -Wl,-Bsymbolic
 
+echo "X{};" > $TMPV
+test_ldflags -Wl,--version-script,$TMPV &&
+    append SHFLAGS '-Wl,--version-script,\$(SUBDIR)lib\$(NAME).ver'
+
 if enabled small; then
     check_cflags -Os            # not all compilers support -Os
     optimizations="small"
 if enabled small; then
     check_cflags -Os            # not all compilers support -Os
     optimizations="small"
diff --git a/libavcodec/libavcodec.v b/libavcodec/libavcodec.v
new file mode 100644 (file)
index 0000000..561a42c
--- /dev/null
@@ -0,0 +1,3 @@
+LIBAVCODEC_$MAJOR {
+        global: *;
+};
diff --git a/libavdevice/libavdevice.v b/libavdevice/libavdevice.v
new file mode 100644 (file)
index 0000000..663af85
--- /dev/null
@@ -0,0 +1,4 @@
+LIBAVDEVICE_$MAJOR {
+        global: avdevice_*;
+        local: *;
+};
diff --git a/libavfilter/libavfilter.v b/libavfilter/libavfilter.v
new file mode 100644 (file)
index 0000000..83e8887
--- /dev/null
@@ -0,0 +1,4 @@
+LIBAVFILTER_$MAJOR {
+        global: avfilter_*; av_*;
+        local: *;
+};
diff --git a/libavformat/libavformat.v b/libavformat/libavformat.v
new file mode 100644 (file)
index 0000000..da2311e
--- /dev/null
@@ -0,0 +1,3 @@
+LIBAVFORMAT_$MAJOR {
+        global: *;
+};
diff --git a/libavutil/libavutil.v b/libavutil/libavutil.v
new file mode 100644 (file)
index 0000000..ec52f2b
--- /dev/null
@@ -0,0 +1,4 @@
+LIBAVUTIL_$MAJOR {
+        global: av_*; ff_*; avutil_*;
+        local: *;
+};
diff --git a/libpostproc/libpostproc.v b/libpostproc/libpostproc.v
new file mode 100644 (file)
index 0000000..e65d76f
--- /dev/null
@@ -0,0 +1,4 @@
+LIBPOSTPROC_$MAJOR {
+        global: postproc_*; pp_*;
+        local: *;
+};
index 6948211..e0ac681 100644 (file)
@@ -51,7 +51,7 @@ install-libs: install-lib$(NAME)-shared
 $(SUBDIR)$(SLIBNAME): $(SUBDIR)$(SLIBNAME_WITH_MAJOR)
        cd ./$(SUBDIR) && $(LN_S) $(SLIBNAME_WITH_MAJOR) $(SLIBNAME)
 
 $(SUBDIR)$(SLIBNAME): $(SUBDIR)$(SLIBNAME_WITH_MAJOR)
        cd ./$(SUBDIR) && $(LN_S) $(SLIBNAME_WITH_MAJOR) $(SLIBNAME)
 
-$(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(OBJS)
+$(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(OBJS) $(SUBDIR)lib$(NAME).ver
        $(SLIB_CREATE_DEF_CMD)
        $(LD) $(SHFLAGS) $(FFLDFLAGS) -o $$@ $$(filter %.o,$$^) $(FFEXTRALIBS) $(EXTRAOBJS)
        $(SLIB_EXTRA_CMD)
        $(SLIB_CREATE_DEF_CMD)
        $(LD) $(SHFLAGS) $(FFLDFLAGS) -o $$@ $$(filter %.o,$$^) $(FFEXTRALIBS) $(EXTRAOBJS)
        $(SLIB_EXTRA_CMD)