[vlc-commits] commit: Contribs: port libupnp to mingw and make it compile ( Jean-Baptiste Kempf )

git at videolan.org git at videolan.org
Wed Aug 11 12:56:19 CEST 2010


vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Wed Aug 11 12:55:00 2010 +0200| [2e3a8c064b0bbe7cccec85b4a2bb9082ef7d8433] | committer: Jean-Baptiste Kempf 

Contribs: port libupnp to mingw and make it compile

This is untested for the VLC module

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2e3a8c064b0bbe7cccec85b4a2bb9082ef7d8433
---

 extras/contrib/src/Makefile                        |   11 ++-
 extras/contrib/src/Patches/libupnp-configure.patch |  100 ++++++++++++++++++++
 extras/contrib/src/Patches/libupnp-mingw.patch     |   40 ++++++++
 3 files changed, 150 insertions(+), 1 deletions(-)

diff --git a/extras/contrib/src/Makefile b/extras/contrib/src/Makefile
index 04608aa..6d6fcd0 100644
--- a/extras/contrib/src/Makefile
+++ b/extras/contrib/src/Makefile
@@ -2407,9 +2407,18 @@ libupnp-$(UPNP_VERSION).tar.bz2:
 
 libupnp: libupnp-$(UPNP_VERSION).tar.bz2
 	$(EXTRACT_BZ2)
+	patch -p0 < Patches/libupnp-mingw.patch
+ifdef HAVE_WIN32
+	patch -p0 < Patches/libupnp-configure.patch
+	cd $@; libtoolize&& autoreconf
+endif
+
+ifdef HAVE_WIN32
+LIBUPNP_ECFLAGS=-DPTW32_STATIC_LIB
+endif
 
 .libupnp: libupnp
-	(cd $<; $(HOSTCC) ./configure $(HOSTCONF) --prefix=$(PREFIX) --disable-samples --without-documentation --disable-webserver CFLAGS="$(CFLAGS) -O3" && make && make install)
+	(cd $<; $(HOSTCC) ./configure $(HOSTCONF) --prefix=$(PREFIX) --disable-samples --without-documentation --enable-static --disable-webserver CFLAGS="$(CFLAGS) -O3 -DUPNP_STATIC_LIB $(LIBUPNP_ECFLAGS)" && make && make install)
 	touch $@
 
 CLEAN_FILE += .libupnp
diff --git a/extras/contrib/src/Patches/libupnp-configure.patch b/extras/contrib/src/Patches/libupnp-configure.patch
new file mode 100644
index 0000000..3d35558
--- /dev/null
+++ b/extras/contrib/src/Patches/libupnp-configure.patch
@@ -0,0 +1,100 @@
+--- libupnp.old/configure.ac	2008-04-25 13:41:16.000000000 +0200
++++ libupnp/configure.ac	2010-08-11 00:41:04.000000000 +0200
+@@ -332,19 +332,13 @@
+ # so just abort if a header file is not found.
+ AC_CHECK_HEADERS(
+ 	[ \
+-	arpa/inet.h \
+ 	fcntl.h \
+ 	inttypes.h \
+ 	limits.h \
+-	netdb.h \
+-	netinet/in.h \
+ 	stdlib.h \
+ 	string.h \
+-	sys/ioctl.h \
+-	sys/socket.h \
+ 	sys/time.h \
+ 	sys/timeb.h \
+-	syslog.h \
+ 	unistd.h \
+ 	],
+ 	[],
+@@ -370,39 +364,39 @@
+ # Checks for POSIX Threads
+ #
+ echo "--------------------------- pthread stuff -------------------------------------"
+-ACX_PTHREAD(
+-	[],
+-	[AC_MSG_ERROR([POSIX threads are required to build this program])])
++#ACX_PTHREAD(
++#	[],
++#	[AC_MSG_ERROR([POSIX threads are required to build this program])])
+ #
+ # Update environment variables for pthreads
+ #
+-CC="$PTHREAD_CC"
+-CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
+-LIBS="$PTHREAD_LIBS $LIBS"
++#CC="$PTHREAD_CC"
++#CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
++#LIBS="$PTHREAD_LIBS $LIBS"
+ #
+ # Determine if pthread_rwlock_t is available
+ #
+-echo "----------------------- pthread_rwlock_t stuff --------------------------------"
+-AC_MSG_CHECKING([if pthread_rwlock_t is available])
+-AC_LANG([C])
+-AC_COMPILE_IFELSE(
+-	[AC_LANG_PROGRAM(
+-		[#include <pthread.h>],
+-		[pthread_rwlock_t *x;])],
+-	[AC_DEFINE([UPNP_USE_RWLOCK], [1], [Use pthread_rwlock_t])
+-		AC_MSG_RESULT([yes, supported without any options])],
+-	[AC_COMPILE_IFELSE(
+-		[AC_LANG_PROGRAM(
+-			[#define _GNU_SOURCE
+-			#include <pthread.h>],
+-			[pthread_rwlock_t *x;])],
+-		[AC_DEFINE([UPNP_USE_RWLOCK], [1], [Use pthread_rwlock_t])
+-			CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
+-			AC_MSG_RESULT([yes, definition of _GNU_SOURCE required])],
+-		[AC_DEFINE([UPNP_USE_RWLOCK], [0], [Do not use pthread_rwlock_t])
+-			AC_MSG_RESULT([no, needs to fallback to pthread_mutex])
+-			AC_MSG_ERROR([pthread_rwlock_t not available])])])
+-echo "-------------------------------------------------------------------------------"
++#echo "----------------------- pthread_rwlock_t stuff --------------------------------"
++#AC_MSG_CHECKING([if pthread_rwlock_t is available])
++#AC_LANG([C])
++#AC_COMPILE_IFELSE(
++#	[AC_LANG_PROGRAM(
++#		[#include <pthread.h>],
++#		[pthread_rwlock_t *x;])],
++#	[AC_DEFINE([UPNP_USE_RWLOCK], [1], [Use pthread_rwlock_t])
++#		AC_MSG_RESULT([yes, supported without any options])],
++#	[AC_COMPILE_IFELSE(
++#		[AC_LANG_PROGRAM(
++#			[#define _GNU_SOURCE
++#			#include <pthread.h>],
++#			[pthread_rwlock_t *x;])],
++#		[AC_DEFINE([UPNP_USE_RWLOCK], [1], [Use pthread_rwlock_t])
++#			CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
++#			AC_MSG_RESULT([yes, definition of _GNU_SOURCE required])],
++#		[AC_DEFINE([UPNP_USE_RWLOCK], [0], [Do not use pthread_rwlock_t])
++#			AC_MSG_RESULT([no, needs to fallback to pthread_mutex])
++#			AC_MSG_ERROR([pthread_rwlock_t not available])])])
++#echo "-------------------------------------------------------------------------------"
+ 
+ 
+ AC_CONFIG_FILES([
+--- libupnp.old/configure.ac	2010-08-11 00:41:04.000000000 +0200
++++ libupnp/configure.ac	2010-08-11 12:32:48.000000000 +0200
+@@ -349,7 +349,7 @@
+ # Checks for typedefs, structures, and compiler characteristics
+ #	
+ AC_C_CONST
+-TYPE_SOCKLEN_T
++#TYPE_SOCKLEN_T
+ 
+ 
+ #
diff --git a/extras/contrib/src/Patches/libupnp-mingw.patch b/extras/contrib/src/Patches/libupnp-mingw.patch
new file mode 100644
index 0000000..a928026
--- /dev/null
+++ b/extras/contrib/src/Patches/libupnp-mingw.patch
@@ -0,0 +1,40 @@
+--- libupnp.old/upnp/inc/upnp.h	2008-03-09 01:54:58.000000000 +0100
++++ libupnp/upnp/inc/upnp.h	2010-08-11 12:40:37.000000000 +0200
+@@ -74,14 +74,16 @@
+ 		typedef __int64 int64_t;
+ 		#define PRId64 "I64d"
+ 		#define PRIzu "lu"
+-	#endif
+-	#ifdef UPNP_USE_BCBPP
++	#elif defined UPNP_USE_BCBPP
+ 		/* define some things Borland Builder doesn't know */
+ 		#define UPNP_INLINE inline
+ 		typedef __int64 int64_t;
+ #warning The Borland C compiler is probably broken on PRId64, please someone provide a proper fix here
+ 		#define PRId64 "I64d"
+ 		#define PRIzu "zu"
++	#else
++		#define UPNP_INLINE inline
++		#define PRIzu "zu"
+ 	#endif
+ #else
+ 	#define EXPORT_SPEC
+--- libupnp.old/upnp/src/inc/unixutil.h	2008-02-10 02:55:34.000000000 +0100
++++ libupnp/upnp/src/inc/unixutil.h	2010-08-11 12:48:37.000000000 +0200
+@@ -38,7 +38,15 @@
+ #ifndef WIN32
+ 	#include <sys/socket.h>
+ #else
+-	typedef int socklen_t;
++	//typedef int socklen_t;
++	#if !defined(UNDER_CE)
++	#    define _NO_OLDNAMES 1
++	#    include <io.h>
++	#endif
++	#include <winsock2.h>
++	#include <ws2tcpip.h>
++	#define ENETUNREACH WSAENETUNREACH
++	#define net_errno (WSAGetLastError())
+ 	#define EAFNOSUPPORT 97
+ #endif
+ 



More information about the vlc-commits mailing list