/pidgin/main: 1abeda205d6c: cross-win32: make dirs more flexible...

Tomasz Wasilczyk twasilczyk at pidgin.im
Tue Apr 15 10:51:51 EDT 2014


Changeset: 1abeda205d6c38756ff84a1d5fc81c076c277f58
Author:	 Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date:	 2014-04-15 16:51 +0200
Branch:	 default
URL: https://hg.pidgin.im/pidgin/main/rev/1abeda205d6c

Description:

cross-win32: make dirs more flexible, add them to the config.h

diffstat:

 configure.ac                                   |  34 ++++++++++++++++++
 doc/reference/libpurple/plugin_i18n.xml        |   2 +-
 finch/Makefile.am                              |   4 --
 finch/gntsound.c                               |   4 +-
 finch/libfinch.c                               |   4 +-
 finch/libgnt/wms/Makefile.am                   |   1 -
 finch/plugins/Makefile.am                      |   1 -
 libpurple/Makefile.am                          |   4 --
 libpurple/certificate.c                        |  15 ++++---
 libpurple/core.c                               |   2 +-
 libpurple/example/Makefile.am                  |   4 --
 libpurple/plugin.c                             |   2 +-
 libpurple/plugins/Makefile.am                  |   1 -
 libpurple/plugins/perl/Makefile.am             |   1 -
 libpurple/plugins/ssl/Makefile.am              |   2 -
 libpurple/prefs.c                              |  13 ++----
 libpurple/win32/win32dep.c                     |  16 +++++++-
 libpurple/win32/win32dep.h                     |  12 +-----
 m4macros/Makefile.am                           |   2 +-
 m4macros/as-ac-expand.m4                       |  49 ++++++++++++++++++++++++++
 pidgin/Makefile.am                             |   4 --
 pidgin/gtkblist.c                              |  34 ++++++++++-------
 pidgin/gtkconv-theme.c                         |   6 ++-
 pidgin/gtkconv.c                               |   8 ++--
 pidgin/gtkdialogs.c                            |   3 +-
 pidgin/gtkdnd-hints.c                          |   6 ++-
 pidgin/gtkdocklet.c                            |   3 +-
 pidgin/gtkprefs.c                              |   3 +-
 pidgin/gtksmiley-theme.c                       |   2 +-
 pidgin/gtksound.c                              |   6 +-
 pidgin/gtkutils.c                              |   9 ++--
 pidgin/libpidgin.c                             |   7 ++-
 pidgin/pidginstock.c                           |   2 +-
 pidgin/plugins/Makefile.am                     |   1 -
 pidgin/plugins/cap/Makefile.am                 |   1 -
 pidgin/plugins/disco/Makefile.am               |   1 -
 pidgin/plugins/disco/gtkdisco.c                |  12 ++++--
 pidgin/plugins/gestures/Makefile.am            |   1 -
 pidgin/plugins/gevolution/Makefile.am          |   1 -
 pidgin/plugins/musicmessaging/Makefile.am      |   1 -
 pidgin/plugins/musicmessaging/musicmessaging.c |   4 +-
 pidgin/plugins/ticker/Makefile.am              |   1 -
 42 files changed, 181 insertions(+), 108 deletions(-)

diffs (truncated from 826 to 300 lines):

diff --git a/configure.ac b/configure.ac
--- a/configure.ac
+++ b/configure.ac
@@ -145,6 +145,40 @@ AC_CHECK_SIZEOF(time_t, ,[
 
 AC_C_BIGENDIAN
 
+dnl Check for directories
+if test "x$is_win32" = "xyes" ; then
+	purple_datadir="wpurple_data_dir()"
+	purple_libdir="wpurple_lib_dir()"
+	pidgin_libdir="wpurple_lib_dir()"
+	finch_libdir="wpurple_lib_dir()"
+	purple_sysconfdir="wpurple_sysconf_dir()"
+	purple_localedir="wpurple_locale_dir()"
+else
+	AS_AC_EXPAND(purple_datadir, "$datadir")
+	purple_datadir="\"$purple_datadir\""
+	AS_AC_EXPAND(purple_sysconfdir, "$sysconfdir")
+	purple_sysconfdir="\"$purple_sysconfdir\""
+	AS_AC_EXPAND(purple_localedir, "$localedir")
+	purple_localedir="\"$purple_localedir\""
+
+	AS_AC_EXPAND(common_libdir, "$libdir")
+	purple_libdir="\"$common_libdir/purple-$PURPLE_MAJOR_VERSION\""
+	pidgin_libdir="\"$common_libdir/pidgin\""
+	finch_libdir="\"$common_libdir/finch\""
+fi
+AC_DEFINE_UNQUOTED([PURPLE_DATADIR], [$purple_datadir],
+	[datadir to use, may expand into a function call that returns const char *])
+AC_DEFINE_UNQUOTED([PURPLE_LIBDIR], [$purple_libdir],
+	[libdir to use for libpurple, may expand into a function call that returns const char *])
+AC_DEFINE_UNQUOTED([PIDGIN_LIBDIR], [$pidgin_libdir],
+	[libdir to use for Pidgin, may expand into a function call that returns const char *])
+AC_DEFINE_UNQUOTED([FINCH_LIBDIR], [$finch_libdir],
+	[libdir to use for Finch, may expand into a function call that returns const char *])
+AC_DEFINE_UNQUOTED([PURPLE_SYSCONFDIR], [$purple_sysconfdir],
+	[sysconfdir to use, may expand into a function call that returns const char *])
+AC_DEFINE_UNQUOTED([PURPLE_LOCALEDIR], [$purple_localedir],
+	[localedir to use, may expand into a function call that returns const char *])
+
 dnl Checks for library functions.
 AC_TYPE_SIGNAL
 AC_FUNC_STRFTIME
diff --git a/doc/reference/libpurple/plugin_i18n.xml b/doc/reference/libpurple/plugin_i18n.xml
--- a/doc/reference/libpurple/plugin_i18n.xml
+++ b/doc/reference/libpurple/plugin_i18n.xml
@@ -136,7 +136,7 @@ may vary, but it's the second parameter 
 Now add the following within your 'init_plugin' function:
 <programlisting>
 #ifdef ENABLE_NLS
-	bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
+	bindtextdomain(GETTEXT_PACKAGE, PURPLE_LOCALEDIR);
 	bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
 #endif /* ENABLE_NLS */
 
diff --git a/finch/Makefile.am b/finch/Makefile.am
--- a/finch/Makefile.am
+++ b/finch/Makefile.am
@@ -88,10 +88,6 @@ finch_LDADD = $(builddir)/libfinch.la $(
 
 AM_CPPFLAGS = \
 	-DSTANDALONE \
-	-DDATADIR=\"$(datadir)\" \
-	-DLIBDIR=\"$(libdir)/finch/\" \
-	-DLOCALEDIR=\"$(datadir)/locale\" \
-	-DSYSCONFDIR=\"$(sysconfdir)\" \
 	-I$(top_srcdir)/libpurple/ \
 	-I$(top_srcdir) \
 	-I$(srcdir)/libgnt/ \
diff --git a/finch/gntsound.c b/finch/gntsound.c
--- a/finch/gntsound.c
+++ b/finch/gntsound.c
@@ -608,8 +608,8 @@ finch_sound_play_event(PurpleSoundEventI
 		char *filename = g_strdup(purple_prefs_get_path(file_pref));
 		if (!filename || !strlen(filename)) {
 			g_free(filename);
-			/* XXX Consider creating a constant for "sounds/purple" to be shared with Pidgin */
-			filename = g_build_filename(DATADIR, "sounds", "purple", sounds[event].def, NULL);
+			filename = g_build_filename(PURPLE_DATADIR,
+				"sounds", "purple", sounds[event].def, NULL);
 		}
 
 		purple_sound_play_file(filename, NULL);
diff --git a/finch/libfinch.c b/finch/libfinch.c
--- a/finch/libfinch.c
+++ b/finch/libfinch.c
@@ -280,7 +280,7 @@ init_libpurple(int argc, char **argv)
 	};
 
 #ifdef ENABLE_NLS
-	bindtextdomain(PACKAGE, LOCALEDIR);
+	bindtextdomain(PACKAGE, PURPLE_LOCALEDIR);
 	bind_textdomain_codeset(PACKAGE, "UTF-8");
 	textdomain(PACKAGE);
 #endif
@@ -365,7 +365,7 @@ init_libpurple(int argc, char **argv)
 	purple_plugins_add_search_path(path);
 	g_free(path);
 
-	purple_plugins_add_search_path(LIBDIR);
+	purple_plugins_add_search_path(FINCH_LIBDIR);
 
 	if (!purple_core_init(FINCH_UI))
 	{
diff --git a/finch/libgnt/wms/Makefile.am b/finch/libgnt/wms/Makefile.am
--- a/finch/libgnt/wms/Makefile.am
+++ b/finch/libgnt/wms/Makefile.am
@@ -29,7 +29,6 @@ s_la_LIBADD =  \
 EXTRA_DIST = 
 
 AM_CPPFLAGS = \
-	-DDATADIR=\"$(datadir)\" \
 	-I$(top_srcdir)/libpurple \
 	-I$(top_srcdir)/finch \
 	-I$(top_srcdir)/finch/libgnt \
diff --git a/finch/plugins/Makefile.am b/finch/plugins/Makefile.am
--- a/finch/plugins/Makefile.am
+++ b/finch/plugins/Makefile.am
@@ -39,7 +39,6 @@ endif # PLUGINS
 EXTRA_DIST = pietray.py
 
 AM_CPPFLAGS = \
-	-DDATADIR=\"$(datadir)\" \
 	-I$(top_builddir)/libpurple \
 	-I$(top_srcdir)/libpurple \
 	-I$(top_srcdir) \
diff --git a/libpurple/Makefile.am b/libpurple/Makefile.am
--- a/libpurple/Makefile.am
+++ b/libpurple/Makefile.am
@@ -404,10 +404,6 @@ libpurple_la_LIBADD = \
 	-lm
 
 AM_CPPFLAGS = \
-	-DDATADIR=\"$(datadir)\" \
-	-DLIBDIR=\"$(libdir)/purple-$(PURPLE_MAJOR_VERSION)/\" \
-	-DLOCALEDIR=\"$(datadir)/locale\" \
-	-DSYSCONFDIR=\"$(sysconfdir)\" \
 	$(GLIB_CFLAGS) \
 	$(DEBUG_CFLAGS) \
 	$(DBUS_CFLAGS) \
diff --git a/libpurple/certificate.c b/libpurple/certificate.c
--- a/libpurple/certificate.c
+++ b/libpurple/certificate.c
@@ -918,15 +918,16 @@ x509_ca_init(void)
 {
 	/* Attempt to point at the appropriate system path */
 	if (NULL == x509_ca_paths) {
+#ifdef SSL_CERTIFICATES_DIR
+		x509_ca_paths = g_list_append(x509_ca_paths,
+			g_strdup(SSL_CERTIFICATES_DIR));
+#endif
 #ifdef _WIN32
-		x509_ca_paths = g_list_append(NULL, g_build_filename(DATADIR,
-						   "ca-certs", NULL));
+		x509_ca_paths = g_list_append(x509_ca_paths, g_build_filename(
+			PURPLE_DATADIR, "ca-certs", NULL));
 #else
-# ifdef SSL_CERTIFICATES_DIR
-		x509_ca_paths = g_list_append(NULL, g_strdup(SSL_CERTIFICATES_DIR));
-# endif
-		x509_ca_paths = g_list_append(x509_ca_paths,
-			g_build_filename(DATADIR, "purple", "ca-certs", NULL));
+		x509_ca_paths = g_list_append(x509_ca_paths, g_build_filename(
+			PURPLE_DATADIR, "purple", "ca-certs", NULL));
 #endif
 	}
 
diff --git a/libpurple/core.c b/libpurple/core.c
--- a/libpurple/core.c
+++ b/libpurple/core.c
@@ -107,7 +107,7 @@ purple_core_init(const char *ui)
 	g_return_val_if_fail(purple_get_core() == NULL, FALSE);
 
 #ifdef ENABLE_NLS
-	bindtextdomain(PACKAGE, LOCALEDIR);
+	bindtextdomain(PACKAGE, PURPLE_LOCALEDIR);
 #endif
 #ifdef _WIN32
 	wpurple_init();
diff --git a/libpurple/example/Makefile.am b/libpurple/example/Makefile.am
--- a/libpurple/example/Makefile.am
+++ b/libpurple/example/Makefile.am
@@ -12,10 +12,6 @@ nullclient_LDADD = \
 
 AM_CPPFLAGS = \
 	-DSTANDALONE \
-	-DDATADIR=\"$(datadir)\" \
-	-DLIBDIR=\"$(libdir)/purple-$(PURPLE_MAJOR_VERSION)/\" \
-	-DLOCALEDIR=\"$(datadir)/locale\" \
-	-DSYSCONFDIR=\"$(sysconfdir)\" \
 	-I$(top_builddir)/libpurple \
 	-I$(top_srcdir)/libpurple \
 	-I$(top_srcdir) \
diff --git a/libpurple/plugin.c b/libpurple/plugin.c
--- a/libpurple/plugin.c
+++ b/libpurple/plugin.c
@@ -1155,7 +1155,7 @@ void
 purple_plugins_init(void) {
 	void *handle = purple_plugins_get_handle();
 
-	purple_plugins_add_search_path(LIBDIR);
+	purple_plugins_add_search_path(PURPLE_LIBDIR);
 
 	purple_signal_register(handle, "plugin-load",
 						 purple_marshal_VOID__POINTER,
diff --git a/libpurple/plugins/Makefile.am b/libpurple/plugins/Makefile.am
--- a/libpurple/plugins/Makefile.am
+++ b/libpurple/plugins/Makefile.am
@@ -137,7 +137,6 @@ EXTRA_DIST = \
 	startup.py
 
 AM_CPPFLAGS = \
-	-DDATADIR=\"$(datadir)\" \
 	-I$(top_srcdir)/libpurple \
 	-I$(top_builddir)/libpurple \
 	$(DEBUG_CFLAGS) \
diff --git a/libpurple/plugins/perl/Makefile.am b/libpurple/plugins/perl/Makefile.am
--- a/libpurple/plugins/perl/Makefile.am
+++ b/libpurple/plugins/perl/Makefile.am
@@ -163,7 +163,6 @@ AM_CPPFLAGS = \
 	-I$(top_srcdir) \
 	-I$(top_srcdir)/libpurple \
 	-I$(top_builddir)/libpurple \
-	-DLIBDIR=\"$(libdir)/purple-$(PURPLE_MAJOR_VERSION)\" \
 	$(DEBUG_CFLAGS) \
 	$(GLIB_CFLAGS) \
 	$(PLUGIN_CFLAGS) \
diff --git a/libpurple/plugins/ssl/Makefile.am b/libpurple/plugins/ssl/Makefile.am
--- a/libpurple/plugins/ssl/Makefile.am
+++ b/libpurple/plugins/ssl/Makefile.am
@@ -31,8 +31,6 @@ ssl_nss_la_LIBADD    = $(GLIB_LIBS) $(NS
 endif # PLUGINS
 
 AM_CPPFLAGS = \
-	-DDATADIR=\"$(datadir)\" \
-	-DLIBDIR=\"$(libdir)/libpurple\" \
 	-I$(top_srcdir)/libpurple \
 	-I$(top_builddir)/libpurple \
 	$(DEBUG_CFLAGS) \
diff --git a/libpurple/prefs.c b/libpurple/prefs.c
--- a/libpurple/prefs.c
+++ b/libpurple/prefs.c
@@ -394,20 +394,15 @@ purple_prefs_load()
 	purple_debug_misc("prefs", "Reading %s", filename);
 
 	if(!g_file_get_contents(filename, &contents, &length, &error)) {
-#ifdef _WIN32
-		gchar *common_appdata = wpurple_get_special_folder(CSIDL_COMMON_APPDATA);
-#endif
+		const gchar *sysconfdir = PURPLE_SYSCONFDIR;
 		g_free(filename);
 		g_error_free(error);
 
 		error = NULL;
 
-#ifdef _WIN32
-		filename = g_build_filename(common_appdata ? common_appdata : "", "purple", "prefs.xml", NULL);
-		g_free(common_appdata);
-#else
-		filename = g_build_filename(SYSCONFDIR, "purple", "prefs.xml", NULL);
-#endif
+		if (sysconfdir == NULL)
+			sysconfdir = "";
+		filename = g_build_filename(PURPLE_SYSCONFDIR, "purple", "prefs.xml", NULL);
 
 		purple_debug_info("prefs", "Reading %s\n", filename);
 
diff --git a/libpurple/win32/win32dep.c b/libpurple/win32/win32dep.c
--- a/libpurple/win32/win32dep.c
+++ b/libpurple/win32/win32dep.c
@@ -34,7 +34,7 @@
  * LOCALS
  */
 static char *app_data_dir = NULL, *install_dir = NULL,
-	*lib_dir = NULL, *locale_dir = NULL;
+	*lib_dir = NULL, *locale_dir = NULL, *sysconf_dir = NULL;
 
 static HINSTANCE libpurpledll_hInstance = NULL;
 
@@ -208,6 +208,18 @@ const char *wpurple_data_dir(void) {
 	return app_data_dir;
 }
 
+const char *wpurple_sysconf_dir(void)
+{
+	static gboolean initialized = FALSE;
+
+	if (!initialized) {
+		sysconf_dir = wpurple_get_special_folder(CSIDL_COMMON_APPDATA);
+		initialized = TRUE;
+	}
+
+	return sysconf_dir;
+}
+
 /* Miscellaneous */
 
 gboolean wpurple_write_reg_string(HKEY rootkey, const char *subkey, const char *valname,
@@ -532,11 +544,13 @@ void wpurple_cleanup(void) {



More information about the Commits mailing list