summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2014-11-19 13:43:44 +0000
committerRichard Hughes <richard@hughsie.com>2014-11-19 16:48:14 +0000
commit5da6ecc2765012f81f2d4d502dec5c6f5d3728be (patch)
treef0c1db59563d27001e74e7b3951388bf4b2cb318
parent020b194de9e661b78a8368b7fcd9e9f0bc67a67c (diff)
downloadcolord-5da6ecc2765012f81f2d4d502dec5c6f5d3728be.tar.gz
Fix compile using mingw64
Although I don't think colord makes a lot of sense on non-Linux platforms, compiling for w64 seems to mean that we get a different set of compiler warnings which benefits the Linux platform too. Plus, the libraries might make sense on Windows one day.
-rw-r--r--README.md44
-rw-r--r--configure.ac11
-rw-r--r--lib/colord/Makefile.am7
-rw-r--r--lib/colord/cd-client.c8
-rw-r--r--m4/ax_check_define.m492
-rw-r--r--src/Makefile.am7
-rw-r--r--src/cd-main.c27
7 files changed, 188 insertions, 8 deletions
diff --git a/README.md b/README.md
index c53b156..c55f1ca 100644
--- a/README.md
+++ b/README.md
@@ -20,3 +20,47 @@ What colord does:
setting the display profile for all users and all sessions.
See [the website](http://www.freedesktop.org/software/colord/) for more details.
+
+Compiling for Linux
+===================
+
+Ensure the following packages are installed:
+
+* dbus-devel
+* docbook-utils
+* gettext
+* glib2-devel
+* gobject-introspection-devel
+* gtk-doc
+* intltool
+* lcms2-devel
+* libgudev1-devel
+* libgusb-devel
+* polkit-devel
+* sqlite-devel
+* systemd-devel
+* vala-tools
+
+Then just do `./autogen.sh && make`
+
+Compiling for Microsoft Windows
+===============================
+
+* Ensure wine is installed
+
+* Compile with a lot of restricted options, e.g.
+
+ mingw64-configure \
+ --disable-argyllcms-sensor \
+ --disable-bash-completion \
+ --disable-examples \
+ --disable-polkit \
+ --disable-print-profiles \
+ --disable-sane \
+ --disable-session-example \
+ --disable-systemd-login \
+ --disable-udev \
+ --disable-unix \
+ --without-pic \
+ --with-systemdsystemunitdir=/tmp \
+ --with-udevrulesdir=/tmp && make
diff --git a/configure.ac b/configure.ac
index dcb38bf..c59f1bf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -149,7 +149,16 @@ dnl ---------------------------------------------------------------------------
dnl - Check library dependencies
dnl ---------------------------------------------------------------------------
COLORD_REQUIRES_PRIVATE="lcms2"
-PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.36.0 gobject-2.0 gthread-2.0 gio-2.0 >= 2.25.9 gio-unix-2.0 gmodule-2.0)
+PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.36.0 gobject-2.0 gthread-2.0 gio-2.0 >= 2.25.9 gmodule-2.0)
+
+dnl ---------------------------------------------------------------------------
+dnl - Check Linux-specific dependencies
+dnl ---------------------------------------------------------------------------
+AC_CHECK_DEFINE(__unix__, enable_unix="yes")
+if test x$enable_unix != xno; then
+ PKG_CHECK_MODULES(GLIB_UNIX, gio-unix-2.0)
+fi
+
AC_ARG_ENABLE(gusb, AS_HELP_STRING([--enable-gusb],[Enable GUSB support]),
enable_gusb=$enableval, enable_gusb=yes)
if test x$enable_gusb != xno; then
diff --git a/lib/colord/Makefile.am b/lib/colord/Makefile.am
index e2c21b7..3fee25b 100644
--- a/lib/colord/Makefile.am
+++ b/lib/colord/Makefile.am
@@ -7,6 +7,7 @@ endif
AM_CPPFLAGS = \
$(GLIB_CFLAGS) \
+ $(GLIB_UNIX_CFLAGS) \
$(LCMS_CFLAGS) \
$(PIE_CFLAGS) \
$(UDEV_CFLAGS) \
@@ -82,7 +83,8 @@ libcolordprivate_la_LIBADD = \
$(LIBM) \
$(UDEV_LIBS) \
$(LCMS_LIBS) \
- $(GLIB_LIBS)
+ $(GLIB_LIBS) \
+ $(GLIB_UNIX_LIBS)
libcolordprivate_la_LDFLAGS = \
$(PIE_LDFLAGS) \
-version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
@@ -105,6 +107,7 @@ libcolord_la_SOURCES = \
libcolord_la_LIBADD = \
$(UDEV_LIBS) \
$(GLIB_LIBS) \
+ $(GLIB_UNIX_LIBS) \
libcolordprivate.la
libcolord_la_LDFLAGS = \
-version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
@@ -137,6 +140,7 @@ cd_test_daemon_SOURCES = \
cd_test_daemon_LDADD = \
$(GLIB_LIBS) \
+ $(GLIB_UNIX_LIBS) \
$(lib_LTLIBRARIES)
cd_test_daemon_CFLAGS = $(WARNINGFLAGS_C)
@@ -148,6 +152,7 @@ cd_test_private_SOURCES = \
cd_test_private_LDADD = \
$(GLIB_LIBS) \
+ $(GLIB_UNIX_LIBS) \
$(UDEV_LIBS) \
$(lib_LTLIBRARIES)
diff --git a/lib/colord/cd-client.c b/lib/colord/cd-client.c
index 5fc4f73..62b2e8f 100644
--- a/lib/colord/cd-client.c
+++ b/lib/colord/cd-client.c
@@ -38,7 +38,9 @@
#include <sys/types.h>
#include <gio/gio.h>
+#ifdef __unix__
#include <gio/gunixfdlist.h>
+#endif
#include <glib/gstdio.h>
#include <glib.h>
@@ -709,10 +711,8 @@ cd_client_create_profile (CdClient *client,
GAsyncReadyCallback callback,
gpointer user_data)
{
- const gchar *filename;
GDBusConnection *connection;
gint fd = -1;
- gint retval;
GList *list, *l;
GVariant *body;
GVariantBuilder builder;
@@ -757,10 +757,13 @@ cd_client_create_profile (CdClient *client,
"CreateProfileWithFd");
/* get fd if possible top avoid open() in daemon */
+#ifdef __unix__
if (properties != NULL) {
+ const gchar *filename;
filename = g_hash_table_lookup (properties,
CD_PROFILE_PROPERTY_FILENAME);
if (filename != NULL) {
+ gint retval;
fd = open (filename, O_RDONLY);
if (fd < 0) {
g_simple_async_result_set_error (res,
@@ -782,6 +785,7 @@ cd_client_create_profile (CdClient *client,
close (fd);
}
}
+#endif
/* set parameters */
body = g_variant_new ("(ssha{ss})",
diff --git a/m4/ax_check_define.m4 b/m4/ax_check_define.m4
new file mode 100644
index 0000000..4bc6948
--- /dev/null
+++ b/m4/ax_check_define.m4
@@ -0,0 +1,92 @@
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_check_define.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AC_CHECK_DEFINE([symbol], [ACTION-IF-FOUND], [ACTION-IF-NOT])
+# AX_CHECK_DEFINE([includes],[symbol], [ACTION-IF-FOUND], [ACTION-IF-NOT])
+#
+# DESCRIPTION
+#
+# Complements AC_CHECK_FUNC but it does not check for a function but for a
+# define to exist. Consider a usage like:
+#
+# AC_CHECK_DEFINE(__STRICT_ANSI__, CFLAGS="$CFLAGS -D_XOPEN_SOURCE=500")
+#
+# LICENSE
+#
+# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 3 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# As a special exception, the respective Autoconf Macro's copyright owner
+# gives unlimited permission to copy, distribute and modify the configure
+# scripts that are the output of Autoconf when processing the Macro. You
+# need not follow the terms of the GNU General Public License when using
+# or distributing such scripts, even though portions of the text of the
+# Macro appear in them. The GNU General Public License (GPL) does govern
+# all other use of the material that constitutes the Autoconf Macro.
+#
+# This special exception to the GPL applies to versions of the Autoconf
+# Macro released by the Autoconf Archive. When you make and distribute a
+# modified version of the Autoconf Macro, you may extend this special
+# exception to the GPL to apply to your modified version as well.
+
+#serial 8
+
+AU_ALIAS([AC_CHECK_DEFINED], [AC_CHECK_DEFINE])
+AC_DEFUN([AC_CHECK_DEFINE],[
+AS_VAR_PUSHDEF([ac_var],[ac_cv_defined_$1])dnl
+AC_CACHE_CHECK([for $1 defined], ac_var,
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
+ #ifdef $1
+ int ok;
+ #else
+ choke me
+ #endif
+]])],[AS_VAR_SET(ac_var, yes)],[AS_VAR_SET(ac_var, no)]))
+AS_IF([test AS_VAR_GET(ac_var) != "no"], [$2], [$3])dnl
+AS_VAR_POPDEF([ac_var])dnl
+])
+
+AU_ALIAS([AX_CHECK_DEFINED], [AX_CHECK_DEFINE])
+AC_DEFUN([AX_CHECK_DEFINE],[
+AS_VAR_PUSHDEF([ac_var],[ac_cv_defined_$2_$1])dnl
+AC_CACHE_CHECK([for $2 defined in $1], ac_var,
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <$1>]], [[
+ #ifdef $2
+ int ok;
+ #else
+ choke me
+ #endif
+]])],[AS_VAR_SET(ac_var, yes)],[AS_VAR_SET(ac_var, no)]))
+AS_IF([test AS_VAR_GET(ac_var) != "no"], [$3], [$4])dnl
+AS_VAR_POPDEF([ac_var])dnl
+])
+
+AC_DEFUN([AX_CHECK_FUNC],
+[AS_VAR_PUSHDEF([ac_var], [ac_cv_func_$2])dnl
+AC_CACHE_CHECK([for $2], ac_var,
+dnl AC_LANG_FUNC_LINK_TRY
+[AC_LINK_IFELSE([AC_LANG_PROGRAM([$1
+ #undef $2
+ char $2 ();],[
+ char (*f) () = $2;
+ return f != $2; ])],
+ [AS_VAR_SET(ac_var, yes)],
+ [AS_VAR_SET(ac_var, no)])])
+AS_IF([test AS_VAR_GET(ac_var) = yes], [$3], [$4])dnl
+AS_VAR_POPDEF([ac_var])dnl
+])# AC_CHECK_FUNC
diff --git a/src/Makefile.am b/src/Makefile.am
index 5e3a22f..335f5ad 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -12,6 +12,7 @@ dist_introspection_DATA = \
AM_CPPFLAGS = \
$(PIE_CFLAGS) \
$(GLIB_CFLAGS) \
+ $(GLIB_UNIX_CFLAGS) \
$(POLKIT_CFLAGS) \
$(LCMS_CFLAGS) \
$(GUDEV_CFLAGS) \
@@ -105,7 +106,8 @@ colord_LDADD = \
$(GUSB_LIBS) \
$(LIBSYSTEMD_LOGIN_LIBS) \
$(COLORD_PRIVATE_LIBS) \
- $(GLIB_LIBS)
+ $(GLIB_LIBS) \
+ $(GLIB_UNIX_LIBS)
colord_LDFLAGS = \
$(PIE_LDFLAGS) \
@@ -152,7 +154,8 @@ cd_self_test_LDADD = \
$(LCMS_LIBS) \
$(SQLITE_LIBS) \
$(LIBSYSTEMD_LOGIN_LIBS) \
- $(GLIB_LIBS)
+ $(GLIB_LIBS) \
+ $(GLIB_UNIX_LIBS)
cd_self_test_CFLAGS = $(WARNINGFLAGS_C)
diff --git a/src/cd-main.c b/src/cd-main.c
index 5c7166b..fa71739 100644
--- a/src/cd-main.c
+++ b/src/cd-main.c
@@ -23,7 +23,9 @@
#include <stdlib.h>
#include <gio/gio.h>
+#ifdef __unix__
#include <gio/gunixfdlist.h>
+#endif
#include <glib/gi18n.h>
#include <locale.h>
@@ -910,7 +912,6 @@ cd_main_daemon_method_call (GDBusConnection *connection, const gchar *sender,
const gchar *scope_tmp = NULL;
gboolean register_on_bus = TRUE;
gboolean ret;
- gint fd = -1;
guint i;
guint pid;
guint uid;
@@ -1455,8 +1456,10 @@ cd_main_daemon_method_call (GDBusConnection *connection, const gchar *sender,
if (g_strcmp0 (method_name, "CreateProfile") == 0 ||
g_strcmp0 (method_name, "CreateProfileWithFd") == 0) {
+#ifdef __unix__
GDBusMessage *message;
GUnixFDList *fd_list;
+#endif
gint32 fd_handle = 0;
/* require auth */
@@ -1548,9 +1551,11 @@ cd_main_daemon_method_call (GDBusConnection *connection, const gchar *sender,
}
/* get any file descriptor in the message */
+#ifdef __unix__
message = g_dbus_method_invocation_get_message (invocation);
fd_list = g_dbus_message_get_unix_fd_list (message);
if (fd_list != NULL && g_unix_fd_list_get_length (fd_list) == 1) {
+ gint fd;
fd = g_unix_fd_list_get (fd_list, fd_handle, &error);
if (fd < 0) {
g_warning ("CdMain: failed to get fd from message: %s",
@@ -1582,7 +1587,25 @@ cd_main_daemon_method_call (GDBusConnection *connection, const gchar *sender,
return;
}
}
-
+#else
+ if (filename != NULL) {
+ ret = cd_profile_load_from_filename (profile,
+ filename,
+ &error);
+ if (!ret) {
+ g_warning ("CdMain: failed to profile from filename: %s",
+ error->message);
+ g_dbus_method_invocation_return_gerror (invocation, error);
+ return;
+ }
+ } else {
+ g_dbus_method_invocation_return_error (invocation,
+ CD_CLIENT_ERROR,
+ CD_CLIENT_ERROR_NOT_SUPPORTED,
+ "no FD support");
+ return;
+ }
+#endif
/* auto add profiles from the database and metadata */
cd_main_profile_auto_add_from_db (priv, profile);
cd_main_profile_auto_add_from_md (priv, profile);