[gupnp: 2/5] Fix compile on windows



commit 397bd1c4f5a40fdf7fc500132f7c781ab626706c
Author: Jens Georg <mail jensge org>
Date:   Thu Aug 19 23:40:25 2010 +0300

    Fix compile on windows

 configure.ac                     |    9 ++++++---
 libgupnp/Makefile.am             |    8 ++++++--
 libgupnp/gupnp-context-manager.c |    6 ++++--
 libgupnp/gupnp-context.c         |   18 ++++++++++++------
 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, 63 insertions(+), 14 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index ff0ee5f..7ace3b7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -34,8 +34,9 @@ AM_CONDITIONAL(HAVE_GTEST, [test x$gtest = xyes])
 AC_MSG_CHECKING([operating system])
 case "$target_os" in
      mingw*|cygwin*)
+        os_win32=yes
         AC_MSG_RESULT(Win32)
-        UUID=uuid
+        UUID=
         ;;
      darwin*)
         AC_MSG_RESULT(Darwin)
@@ -54,14 +55,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/connman/unix/linux@:>@],
                         [Context Manager backend to use]),,
             [with_context_manager="none"])
+fi
 
 if test "x$with_context_manager" = "xnone"; then
         case "$target_os" in
diff --git a/libgupnp/Makefile.am b/libgupnp/Makefile.am
index a2ae67e..5702a5a 100644
--- a/libgupnp/Makefile.am
+++ b/libgupnp/Makefile.am
@@ -1,7 +1,10 @@
 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
+					   gupnp-unix-context-manager.h
 if USE_NETWORK_MANAGER
 CONTEXT_MANAGER_IMPL += gupnp-network-manager.c  \
 		        gupnp-network-manager.h
@@ -13,6 +16,7 @@ CONTEXT_MANAGER_IMPL += gupnp-connman-manager.c  \
 CONTEXT_MANAGER_CFLAGS = -DUSE_CONNMAN
 endif
 endif
+endif
 
 if HAVE_NETLINK
 CONTEXT_MANAGER_IMPL += \
@@ -79,7 +83,7 @@ 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			\
diff --git a/libgupnp/gupnp-context-manager.c b/libgupnp/gupnp-context-manager.c
index 2888a1b..724b94f 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"
@@ -336,7 +337,8 @@ gupnp_context_manager_create (guint port)
 #endif
         GUPnPContextManager *impl;
         GType impl_type = G_TYPE_INVALID;
-
+#ifdef G_OS_WIN32
+#else
 #ifdef USE_NETWORK_MANAGER
 #include "gupnp-network-manager.h"
         system_bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, NULL);
@@ -360,7 +362,7 @@ gupnp_context_manager_create (guint port)
 #else
                 impl_type = GUPNP_TYPE_UNIX_CONTEXT_MANAGER;
 #endif
-
+#endif /* G_OS_WIN32 */
         impl = g_object_new (impl_type,
                              "port", port,
                              NULL);
diff --git a/libgupnp/gupnp-context.c b/libgupnp/gupnp-context.c
index 014969b..a1535aa 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>
@@ -115,6 +116,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);
@@ -123,6 +128,7 @@ make_server_id (void)
                                 sysinfo.sysname,
                                 sysinfo.release,
                                 VERSION);
+#endif
 }
 
 static void
@@ -547,19 +553,19 @@ _gupnp_context_get_server_url (GUPnPContext *context)
  * gupnp_context_new:
  * @main_context: (allow-none): Deprecated: 0.17.2: Always set to %NULL. If you
  * want to use a different context, use g_main_context_push_thread_default().
- * @interface: (allow-none): The network interface to use, or %NULL to
+ * @iface: (allow-none): The network interface to use, or %NULL to
  * auto-detect.
  * @port: Port to run on, or 0 if you don't care what port is used.
  * @error: A location to store a #GError, or %NULL
  *
- * Create a new #GUPnPContext with the specified @main_context, @interface and
+ * Create a new #GUPnPContext with the specified @main_context, @iface and
  * @port.
  *
  * Return value: A new #GUPnPContext object, or %NULL on an error
  **/
 GUPnPContext *
 gupnp_context_new (GMainContext *main_context,
-                   const char   *interface,
+                   const char   *iface,
                    guint         port,
                    GError      **error)
 {
@@ -571,7 +577,7 @@ gupnp_context_new (GMainContext *main_context,
         return g_initable_new (GUPNP_TYPE_CONTEXT,
                                NULL,
                                error,
-                               "interface", interface,
+                               "interface", iface,
                                "port", port,
                                NULL);
 }
diff --git a/libgupnp/gupnp-context.h b/libgupnp/gupnp-context.h
index d26e790..a2e2f9e 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 4578a0f..e6aba2d 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"
@@ -1077,6 +1080,9 @@ subscription_response (GUPnPService *service,
 static char *
 generate_sid (void)
 {
+#ifdef G_OS_WIN32
+        return NULL;
+#else
         uuid_t id;
         char out[39];
 
@@ -1084,6 +1090,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 9964f10..161907f 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_type_init ();
         setlocale (LC_ALL, "");
@@ -134,10 +137,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 8a3fbbb..2569b62 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,
@@ -282,9 +285,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 597b000..c9a8fd8 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_type_init ();
         setlocale (LC_ALL, "");
@@ -184,9 +187,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 da294cf..046e6c6 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]);
@@ -119,9 +121,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);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]