[rtmpdump] [PATCH] building darwin shared lib

Scott D. Davilla davilla at xbmc.org
Wed Jul 7 22:24:09 CEST 2010


As promised, build fixes for darwin platform. Darwin supports two 
types of shared libs, bundles (similar to Linux .so files) and 
dylibs. The main difference is bundles can be unloaded, dylibs 
cannot, so we build librtmp as a bundle so we can unload it.

Note that in the lib Makefile, darwin needs XLDFLAGS ref'ed as also 
on darwin, we can build against various SDKs (10.4/10.5/10.6). This 
would get set via some external Makefile for building on a newer OSX 
version to be runtime compatible under an older OSX. See 
http://trac.xbmc.org/browser/trunk/lib/librtmp/Makefile for how we 
use it to build librtmp for XBMC for Mac.


diff -uNrp librtmp-org/Makefile librtmp-mod/Makefile
--- librtmp-org/Makefile	2010-07-01 08:00:43.000000000 -0400
+++ librtmp-mod/Makefile	2010-07-07 15:43:03.000000000 -0400
@@ -34,10 +34,12 @@ MANDIR=$(DESTDIR)$(mandir)

  LIBS_posix=
  LIBS_mingw=-lws2_32 -lwinmm -lgdi32
+LIBS_darwin=
  LIBS=$(CRYPTO_LIB) $(LIBS_$(SYS)) $(XLIBS)

  THREADLIB_posix=-lpthread
  THREADLIB_mingw=
+THREADLIB_darwin=-lpthread
  THREADLIB=$(THREADLIB_$(SYS))
  SLIBS=$(THREADLIB) $(LIBS)

@@ -46,6 +48,7 @@ INCRTMP=librtmp/rtmp_sys.h librtmp/rtmp.

  EXT_posix=
  EXT_mingw=.exe
+EXT_posix=
  EXT=$(EXT_$(SYS))

  all:	$(LIBRTMP) progs
diff -uNrp librtmp-org/librtmp/Makefile librtmp-mod/librtmp/Makefile
--- librtmp-org/librtmp/Makefile	2010-06-30 16:01:12.000000000 -0400
+++ librtmp-mod/librtmp/Makefile	2010-07-07 15:44: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


More information about the rtmpdump mailing list