[osx] update librtmp to rel-2.3
authordavilla <davilla@svn>
Wed, 7 Jul 2010 19:18:27 +0000 (19:18 +0000)
committerdavilla <davilla@svn>
Wed, 7 Jul 2010 19:18:27 +0000 (19:18 +0000)
git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk@31652 568bbfeb-2a22-0410-94d2-cc84cf5bfa90

lib/librtmp/Makefile
lib/librtmp/darwin_package_librtmp.sh [new file with mode: 0755]
lib/librtmp/make_shared_lib_for_darwin-tag2.3.patch [new file with mode: 0644]

index e6f1065..5ef9b31 100644 (file)
@@ -1,5 +1,5 @@
 #
-#  rtmpdump build script.
+#  rtmpdump build script for OSX darwin.
 #
 #  A quick and dirty Makefile to download/build and install librtmp
 #
@@ -7,66 +7,48 @@
 #  10.4u.sdk is targeted so we can run on the AppleTV. Macports is assumed to
 #  be used and the required lib depends installed.
 #
-#  Linux: builds a simple.so without the proper .so version symlinks,
-#  maybe someone with good Linux makefile-fu can fix it up.
+#  Linux: builds using the existing librtmp make system
 #  
 #  Usage:
 #    make
 #    sudo make install
 
-# librtmp 2.2f is this svn version
-RTMPDUMP_VERS = 511
 # get OS type from shell
 OSTYPE = $(shell uname)
 
 ifeq ($(OSTYPE),Darwin)
-MACHINE = $(shell uname -m)
-ifeq ($(findstring Power,$(MACHINE)), Power)
-  arch = ppc
+  SYS=darwin
+  prefix=/opt/local
+  XCFLAGS=-mmacosx-version-min=10.4 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -I /opt/local/include
+  XLDFLAGS=-mmacosx-version-min=10.4 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -L/opt/local/lib
+  MACHINE = $(shell uname -m)
+  ifeq ($(findstring Power,$(MACHINE)), Power)
+    arch = ppc
+  else
+    arch = i386
+  endif
 else
-  arch = i386
-endif
-PREFIX=/opt/local
-XCFLAGS=-mmacosx-version-min=10.4 -isysroot /Developer/SDKs/MacOSX10.4u.sdk \
-        -fPIC -I /opt/local/include
-XLDFLAGS=-mmacosx-version-min=10.4 -isysroot /Developer/SDKs/MacOSX10.4u.sdk \
-         -bundle -flat_namespace -undefined suppress -arch $(arch) -L/opt/local/lib \
-         -lpthread -lssl -lcrypto -lz
-else
-PREFIX=/usr/local
-XCFLAGS=-fPIC -DPIC
-XLDFLAGS=-shared -fPIC -rdynamic -lpthread -lssl -lcrypto -lz
+  SYS=posix
 endif
 
-LIBRTMP = librtmp/librtmp.a
+LIBRTMP = librtmp/librtmp/librtmp.so
 
-all:: librtmp.so
-
-librtmp.so: $(LIBRTMP)
-ifeq ($(OSTYPE),Darwin)
-       $(CC) $(XLDFLAGS) -o $@ -Wl,-all_load $<
-else
-       $(CC) $(XLDFLAGS) -o $@ -Wl,--whole-archive $< -Wl,--no-whole-archive
-endif
+all:: librtmp/librtmp/librtmp.so
 
 $(LIBRTMP): librtmp/Makefile
-       make SYS=posix XCFLAGS="$(XCFLAGS)" XLDFLAGS="$(XLDFLAGS)" -C librtmp
+       make SYS=$(SYS) prefix=$(prefix) XCFLAGS="$(XCFLAGS)" XLDFLAGS="$(XLDFLAGS)" -C librtmp/librtmp
 
 librtmp/Makefile:
-       svn export --revision $(RTMPDUMP_VERS) svn://svn.mplayerhq.hu/rtmpdump/trunk/librtmp librtmp
+       svn export svn://svn.mplayerhq.hu/rtmpdump/tags/rel-2.3 librtmp
+ifeq ($(OSTYPE),Darwin)
+       cd librtmp; patch -p1 < ../make_shared_lib_for_darwin-tag2.3.patch
+endif
 
 install:
-       mkdir -p $(PREFIX)/include/librtmp
-       cp -f librtmp/amf.h $(PREFIX)/include/librtmp
-       cp -f librtmp/log.h $(PREFIX)/include/librtmp
-       cp -f librtmp/http.h $(PREFIX)/include/librtmp
-       cp -f librtmp/rtmp.h $(PREFIX)/include/librtmp
-       cp -f librtmp.so $(PREFIX)/lib
+       make SYS=$(SYS) prefix=$(prefix) -C librtmp/librtmp install
 
 clean:
-       rm -f librtmp.so
-       rm -rf includes
-       make -C librtmp clean
+       make SYS=$(SYS) prefix=$(prefix) -C librtmp/librtmp clean
 
 distclean::
-       rm -rf librtmp.so librtmp
+       rm -rf librtmp
diff --git a/lib/librtmp/darwin_package_librtmp.sh b/lib/librtmp/darwin_package_librtmp.sh
new file mode 100755 (executable)
index 0000000..8258892
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+SRC_LIB_RTMP="/opt/local/lib/librtmp.so.0"
+DST_LIB_RTMP="../../system/librtmp.so"
+
+if [ -f $SRC_LIB_RTMP ]; then
+  # copy librtmp into xbmc's system directory, we
+  # rename it to librtmp.so and skip the symlinking.
+  cp $SRC_LIB_RTMP $DST_LIB_RTMP
+
+  # rename any dependency libs to inside xbmc's app framework
+  for a in $(otool -L "$DST_LIB_RTMP" | grep opt | awk ' { print $1 } ') ; do 
+    echo "Processing $a"
+    install_name_tool -change "$a" @executable_path/../Frameworks/$(basename $a) "$DST_LIB_RTMP"
+  done
+fi
diff --git a/lib/librtmp/make_shared_lib_for_darwin-tag2.3.patch b/lib/librtmp/make_shared_lib_for_darwin-tag2.3.patch
new file mode 100644 (file)
index 0000000..1c65ce9
--- /dev/null
@@ -0,0 +1,53 @@
+Binary files librtmp-org/.DS_Store and librtmp/.DS_Store differ
+diff -uNrp librtmp-org/Makefile librtmp/Makefile
+--- librtmp-org/Makefile       2010-06-30 14:52:14.000000000 -0400
++++ librtmp/Makefile   2010-07-07 12:38:32.000000000 -0400
+@@ -33,10 +33,12 @@ MANDIR=$(DESTDIR)$(mandir)
+ LIBS_posix=
+ LIBS_mingw=-lws2_32 -lwinmm -lgdi32
++LIBS_darwin=
+ LIBS=$(CRYPTO_LIB) -lz $(LIBS_$(SYS)) $(XLIBS)
+ THREADLIB_posix=-lpthread
+ THREADLIB_mingw=
++THREADLIB_darwin=-lpthread
+ THREADLIB=$(THREADLIB_$(SYS))
+ SLIBS=$(THREADLIB) $(LIBS)
+@@ -45,6 +47,7 @@ INCRTMP=librtmp/rtmp_sys.h librtmp/rtmp.
+ EXT_posix=
+ EXT_mingw=.exe
++EXT_darwin=
+ EXT=$(EXT_$(SYS))
+ all:  $(LIBRTMP) progs
+diff -uNrp librtmp-org/librtmp/Makefile librtmp/librtmp/Makefile
+--- librtmp-org/librtmp/Makefile       2010-06-30 16:01:39.000000000 -0400
++++ librtmp/librtmp/Makefile   2010-07-07 14:10:25.000000000 -0400
+@@ -27,8 +27,15 @@ CRYPTO_DEF=$(DEF_$(CRYPTO))
+ SO_posix=so.0
+ SO_mingw=dll
++SO_darwin=so.0
+ SO_EXT=$(SO_$(SYS))
++SO_LDFLAGS_posix=-shared -Wl,-soname,$@
++SO_LDFLAGS_mingw=
++SO_LDFLAGS_darwin=-bundle -flat_namespace -undefined suppress -fno-common \
++  -headerpad_max_install_names $(XLDFLAGS)
++SO_LDFLAGS=$(SO_LDFLAGS_$(SYS))
++
+ SHARED=yes
+ SODEF_yes=-fPIC
+ SOLIB_yes=librtmp.$(SO_EXT)
+@@ -61,7 +68,7 @@ librtmp.a: $(OBJS)
+       $(AR) rs $@ $?
+ librtmp.$(SO_EXT): $(OBJS)
+-      $(CC) -shared -Wl,-soname,$@ $(LDFLAGS) -o $@ $^ $> $(CRYPTO_LIB)
++      $(CC) $(SO_LDFLAGS) $(LDFLAGS) -o $@ $^ $> $(CRYPTO_LIB)
+       ln -sf $@ librtmp.so
+ log.o: log.c log.h Makefile