[PATCH 1/4] Fix compile on windows
- From: Jens Georg <mail jensge org>
- To: gupnp-list gnome org
- Subject: [PATCH 1/4] Fix compile on windows
- Date: Sat, 18 Jun 2011 12:42:06 +0200
---
configure.ac | 10 +++++++---
libgupnp/Makefile.am | 15 ++++++++++-----
libgupnp/gupnp-context-manager.c | 6 ++++--
libgupnp/gupnp-context.c | 10 ++++++++--
libgupnp/gupnp-context.h | 2 +-
libgupnp/gupnp-service.c | 7 +++++++
tests/test-browsing.c | 7 +++++++
tests/test-introspection.c | 7 +++++++
tests/test-proxy.c | 7 +++++++
tests/test-server.c | 6 ++++++
10 files changed, 64 insertions(+), 13 deletions(-)
diff --git a/configure.ac b/configure.ac
index 5210a55..4b84271 100644
--- a/configure.ac
+++ b/configure.ac
@@ -17,10 +17,12 @@ AC_FUNC_MMAP
AC_SYS_LARGEFILE
AC_MSG_CHECKING([operating system])
+os_win32=no
case "$host_os" in
mingw*|cygwin*)
+ os_win32=yes
AC_MSG_RESULT(Win32)
- UUID=uuid
+ UUID=
;;
darwin*)
AC_MSG_RESULT(Darwin)
@@ -39,14 +41,16 @@ PKG_CHECK_MODULES(LIBGUPNP, glib-2.0 >= 2.24.0 \
libsoup-2.4 >= 2.28.2 \
libxml-2.0 \
$UUID)
-
PKG_CHECK_MODULES(GTHREAD, gthread-2.0)
-AC_ARG_WITH([context_manager],
+AM_CONDITIONAL(OS_WIN32, test "x$os_win32" = "xyes")
+if test "x$os_win32" = "xno"; then
+ AC_ARG_WITH([context_manager],
AS_HELP_STRING(
[--with-context-manager=@<:@network-manager/unix@:>@],
[Context Manager backend to use]),,
[with_context_manager="unix"])
+fi
AC_MSG_CHECKING([Context Manager backend to use])
AC_MSG_RESULT([${with_context_manager}])
diff --git a/libgupnp/Makefile.am b/libgupnp/Makefile.am
index 6857259..f4c4e31 100644
--- a/libgupnp/Makefile.am
+++ b/libgupnp/Makefile.am
@@ -1,12 +1,19 @@
LTVERSION = 4:0:0
+if OS_WIN32
+WIN32_LDFLAGS = -no-undefined
+else
+CONTEXT_MANAGER_IMPL = gupnp-unix-context-manager.c \
+ gupnp-unix-context-manager.h
if USE_NETWORK_MANAGER
-CONTEXT_MANAGER_IMPL = gupnp-network-manager.c \
+CONTEXT_MANAGER_IMPL += gupnp-network-manager.c \
gupnp-network-manager.h
CONTEXT_MANAGER_CFLAGS = -DUSE_NETWORK_MANAGER
+CONTEXT_MANAGER_LIBS =
else
-CONTEXT_MANAGER_IMPL =
CONTEXT_MANAGER_CFLAGS =
+CONTEXT_MANAGER_LIBS =
+endif
endif
if USE_CONIC
@@ -68,15 +75,13 @@ gupnp-marshal.h: gupnp-marshal.list
BUILT_SOURCES = gupnp-marshal.c gupnp-marshal.h
-libgupnp_1_0_la_LDFLAGS = -version-info $(LTVERSION)
+libgupnp_1_0_la_LDFLAGS = -version-info $(LTVERSION) $(WIN32_LDFLAGS)
libgupnp_1_0_la_SOURCES = $(introspection_sources) \
http-headers.c \
http-headers.h \
gupnp-context-private.h \
$(CONTEXT_MANAGER_IMPL) \
- gupnp-unix-context-manager.c \
- gupnp-unix-context-manager.h \
gupnp-device-info-private.h \
gupnp-error-private.h \
gupnp-resource-factory-private.h \
diff --git a/libgupnp/gupnp-context-manager.c b/libgupnp/gupnp-context-manager.c
index 193e8b7..00f06ee 100644
--- a/libgupnp/gupnp-context-manager.c
+++ b/libgupnp/gupnp-context-manager.c
@@ -37,6 +37,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <libsoup/soup-address.h>
+#include <glib.h>
#include <glib/gstdio.h>
#include "gupnp.h"
@@ -367,7 +368,8 @@ gupnp_context_manager_new (GMainContext *main_context,
GUPnPContextManager *manager;
GUPnPContextManager *impl;
GType impl_type = G_TYPE_INVALID;
-
+#ifdef G_OS_WIN32
+#else
#ifdef USE_NETWORK_MANAGER
#include "gupnp-network-manager.h"
@@ -377,7 +379,7 @@ gupnp_context_manager_new (GMainContext *main_context,
if (impl_type == G_TYPE_INVALID)
impl_type = GUPNP_TYPE_UNIX_CONTEXT_MANAGER;
-
+#endif /* G_OS_WIN32 */
impl = g_object_new (impl_type,
"main-context", main_context,
"port", port,
diff --git a/libgupnp/gupnp-context.c b/libgupnp/gupnp-context.c
index 964f3a5..663928d 100644
--- a/libgupnp/gupnp-context.c
+++ b/libgupnp/gupnp-context.c
@@ -40,9 +40,10 @@
#include <fcntl.h>
#include <stdlib.h>
#include <stdio.h>
+#include <glib.h>
+#ifndef G_OS_WIN32
#include <sys/utsname.h>
-#include <sys/ioctl.h>
-#include <sys/socket.h>
+#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <libsoup/soup-address.h>
@@ -114,6 +115,10 @@ static GInitableIface* initable_parent_iface = NULL;
static char *
make_server_id (void)
{
+#ifdef G_OS_WIN32
+ return g_strdup_printf ("Microsoft Windows UPnP/1.0 GUPnP/%s",
+ VERSION);
+#else
struct utsname sysinfo;
uname (&sysinfo);
@@ -122,6 +127,7 @@ make_server_id (void)
sysinfo.sysname,
sysinfo.release,
VERSION);
+#endif
}
static void
diff --git a/libgupnp/gupnp-context.h b/libgupnp/gupnp-context.h
index c46d2ff..8bff521 100644
--- a/libgupnp/gupnp-context.h
+++ b/libgupnp/gupnp-context.h
@@ -80,7 +80,7 @@ struct _GUPnPContextClass {
GUPnPContext *
gupnp_context_new (GMainContext *main_context,
- const char *interface,
+ const char *iface,
guint port,
GError **error);
diff --git a/libgupnp/gupnp-service.c b/libgupnp/gupnp-service.c
index 562fc0c..146d609 100644
--- a/libgupnp/gupnp-service.c
+++ b/libgupnp/gupnp-service.c
@@ -30,7 +30,10 @@
#include <gobject/gvaluecollector.h>
#include <gmodule.h>
#include <libsoup/soup-date.h>
+#ifdef G_OS_WIN32
+#else
#include <uuid/uuid.h>
+#endif
#include <string.h>
#include "gupnp-service.h"
#include "gupnp-root-device.h"
@@ -1069,6 +1072,9 @@ subscription_response (GUPnPService *service,
static char *
generate_sid (void)
{
+#ifdef G_OS_WIN32
+ return NULL;
+#else
uuid_t id;
char out[39];
@@ -1076,6 +1082,7 @@ generate_sid (void)
uuid_unparse (id, out);
return g_strdup_printf ("uuid:%s", out);
+#endif
}
/* Subscription expired */
diff --git a/tests/test-browsing.c b/tests/test-browsing.c
index a35d1a8..f10127d 100644
--- a/tests/test-browsing.c
+++ b/tests/test-browsing.c
@@ -24,6 +24,7 @@
#include <string.h>
#include <locale.h>
#include <signal.h>
+#include <glib.h>
GMainLoop *main_loop;
@@ -95,7 +96,9 @@ main (int argc, char **argv)
GError *error;
GUPnPContext *context;
GUPnPControlPoint *cp;
+#ifndef G_OS_WIN32
struct sigaction sig_action;
+#endif /* G_OS_WIN32 */
g_thread_init (NULL);
g_type_init ();
@@ -135,10 +138,14 @@ main (int argc, char **argv)
main_loop = g_main_loop_new (NULL, FALSE);
+#ifndef G_OS_WIN32
/* Hook the handler for SIGTERM */
memset (&sig_action, 0, sizeof (sig_action));
sig_action.sa_handler = interrupt_signal_handler;
sigaction (SIGINT, &sig_action, NULL);
+#else
+ signal(SIGINT, interrupt_signal_handler);
+#endif /* G_OS_WIN32 */
g_main_loop_run (main_loop);
g_main_loop_unref (main_loop);
diff --git a/tests/test-introspection.c b/tests/test-introspection.c
index 7fee447..b1dc939 100644
--- a/tests/test-introspection.c
+++ b/tests/test-introspection.c
@@ -26,6 +26,7 @@
#include <stdlib.h>
#include <string.h>
#include <signal.h>
+#include <glib.h>
GMainLoop *main_loop;
@@ -235,7 +236,9 @@ main (int argc, char **argv)
GUPnPContext *context;
GUPnPControlPoint *cp;
GOptionContext *option_context;
+#ifndef G_OS_WIN32
struct sigaction sig_action;
+#endif /* G_OS_WIN32 */
option_context = g_option_context_new ("- test GUPnP introspection");
g_option_context_add_main_entries (option_context,
@@ -283,9 +286,13 @@ main (int argc, char **argv)
main_loop = g_main_loop_new (NULL, FALSE);
/* Hook the handler for SIGTERM */
+#ifndef G_OS_WIN32
memset (&sig_action, 0, sizeof (sig_action));
sig_action.sa_handler = interrupt_signal_handler;
sigaction (SIGINT, &sig_action, NULL);
+#else
+ signal(SIGINT,interrupt_signal_handler);
+#endif /* G_OS_WIN32 */
g_main_loop_run (main_loop);
g_main_loop_unref (main_loop);
diff --git a/tests/test-proxy.c b/tests/test-proxy.c
index f4f04cf..2b1ec1a 100644
--- a/tests/test-proxy.c
+++ b/tests/test-proxy.c
@@ -24,6 +24,7 @@
#include <string.h>
#include <locale.h>
#include <signal.h>
+#include <glib.h>
GMainLoop *main_loop;
@@ -151,7 +152,9 @@ main (int argc, char **argv)
GError *error;
GUPnPContext *context;
GUPnPControlPoint *cp;
+#ifndef G_OS_WIN32
struct sigaction sig_action;
+#endif /* G_OS_WIN32 */
g_thread_init (NULL);
g_type_init ();
@@ -185,9 +188,13 @@ main (int argc, char **argv)
main_loop = g_main_loop_new (NULL, FALSE);
/* Hook the handler for SIGTERM */
+#ifndef G_OS_WIN32
memset (&sig_action, 0, sizeof (sig_action));
sig_action.sa_handler = interrupt_signal_handler;
sigaction (SIGINT, &sig_action, NULL);
+#else
+ signal(SIGINT,interrupt_signal_handler);
+#endif /* G_OS_WIN32 */
g_main_loop_run (main_loop);
g_main_loop_unref (main_loop);
diff --git a/tests/test-server.c b/tests/test-server.c
index edf0709..0364895 100644
--- a/tests/test-server.c
+++ b/tests/test-server.c
@@ -62,7 +62,9 @@ main (int argc, char **argv)
GUPnPContext *context;
GUPnPRootDevice *dev;
GUPnPServiceInfo *content_dir;
+#ifndef G_OS_WIN32
struct sigaction sig_action;
+#endif /* G_OS_WIN32 */
if (argc < 2) {
g_printerr ("Usage: %s DESCRIPTION_FILE\n", argv[0]);
@@ -120,9 +122,13 @@ main (int argc, char **argv)
main_loop = g_main_loop_new (NULL, FALSE);
/* Hook the handler for SIGTERM */
+#ifndef G_OS_WIN32
memset (&sig_action, 0, sizeof (sig_action));
sig_action.sa_handler = interrupt_signal_handler;
sigaction (SIGINT, &sig_action, NULL);
+#else
+ signal(SIGINT, interrupt_signal_handler);
+#endif /* G_OS_WIN32 */
g_main_loop_run (main_loop);
g_main_loop_unref (main_loop);
--
1.7.5.4
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]