[PATCH][W32] W32 and MSys compatibility

LRN lrn1986 at gmail.com
Fri Mar 30 22:27:54 PDT 2012


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Apply on top of 0.26

06-fix-define-variable-invocation-to-avoid-msys-path-mangling.mingw32.patch:
Otherwise tests won't pass when running in MSys.

07-fix-w32-readme.mingw32.patch:
A simple documentation fix (reflecting the fact that pkg-config is not
being built against glib-1.2 anymore)

08-no-need-for-0x0D-we-are-in-text-mode.mingw32.patch:
stdout is opened in text mode, which means that W32 CRT adds \r
automatically. Printing it manually produces one extra \r, and
pkg-config fails to pass some tests because of that.

09-fix-pkgconfig-pc-path-on.mingw32.patch:
Can't use deprecated w32 functions with new glib :(
Also leaks a bit less memory (no that anyone would notice...)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJPdpXYAAoJEOs4Jb6SI2CwcRAIALd+mKh/utbQZB6gy2TyNkRh
TayrhRX2yevExZVd7wSeaG9s4nlDaqisW9kcpI1DdlnjyWgrPUTqhVLkc6XowGnM
IICtAEIwDG68mTfaQ8pbzh3xVeSukVMCIpk+nlmQDwwLXJZTgYjoCXWeeBvsnhtT
tv8J0EMUSVxQ7vm5/RGjqIyPGYjgb2tNJ8y8Y5+PKABG3tTV/DrBue8WbPElaSIx
YZ4UTFBPPX36ykZKD2d7GybRkzMPfygCuPiqOYkcRdC7IzrqAbw6JHARXTO3CFI9
tZw7II7Wt9i1dGzeWVUENXaMmbebfAgIBHIeyO5NVdyWciAeZ798GbiTGrgkIk0=
=LuAC
-----END PGP SIGNATURE-----
-------------- next part --------------
--- check/check-define-variable	2009-08-15 23:44:19 +0400
+++ check/check-define-variable	2011-04-08 20:18:40 +0400
@@ -9,7 +9,14 @@
 
 . ${srcdir}/common
 
+case ${MACHTYPE} in
+  *-msys)
+ARGS="--define-variable=includedir=\\/includedir/ --cflags simple"
+    ;;
+  *)
 ARGS="--define-variable=includedir=/includedir/ --cflags simple"
+    ;;
+esac
 RESULT="-I/includedir/"
 
 run_test
-------------- next part --------------
--- README.win32	2009-08-15 23:44:19 +0400
+++ README.win32	2011-04-08 20:27:11 +0400
@@ -37,16 +37,4 @@
 "prefix" for its installation prefix. At least GLib, ATK, Pango and
 GTK does this.
 
-On Unix, pkg-config is built using its own copy of GLib 1.2.8. On
-Windows, we use the normal GLib available for Windows (2.0.x). Yes,
-this does introduce a kind of circular dependency. But, that can be
-worked around. The circular dependency only appears if one uses the
-configure mechanism to build GLib. GLib's configure script checks for
-pkg-config. pkg-config depends on GLib. Thus, starting from scratch,
-with no GLib and no pkg-config, using configure, there would indeed be
-a Catch-22 situation. However, GLib can be built just fine using the
-manually written makefiles for mingw or MSVC. And if somebody does
-want to build GLib on Win32 using configure, she can first install a
-prebuilt pkgconfig.
-
 --Tor Lillqvist <tml at iki.fi>
-------------- next part --------------
--- main.c.orig	2011-08-06 06:24:02 +0400
+++ main.c	2011-08-06 06:27:02 +0400
@@ -752,11 +752,7 @@
     }
 
   if (need_newline)
-#ifdef G_OS_WIN32
-    printf ("\r\n");
-#else
     printf ("\n");
-#endif
 
   return 0;
 }
-------------- next part --------------
--- pkg.h.orig	2011-04-13 22:16:23 +0400
+++ pkg.h	2012-03-31 06:11:46 +0400
@@ -22,17 +22,6 @@
 
 #include <glib.h>
 
-#ifdef G_OS_WIN32
-/* No hardcoded paths in the binary, thanks */
-/* It's OK to leak this */
-#undef PKG_CONFIG_PC_PATH
-#define PKG_CONFIG_PC_PATH \
-  g_strconcat (g_win32_get_package_installation_subdirectory (NULL, NULL, "lib/pkgconfig"), \
-	       ";", \
-	       g_win32_get_package_installation_subdirectory (NULL, NULL, "share/pkgconfig"), \
-	       NULL)
-#endif
-
 typedef enum
 {
   LESS_THAN,
@@ -142,6 +131,10 @@
 extern int dont_define_prefix;
 /* The name of the variable that acts as prefix, unless it is "prefix" */
 extern char *prefix_variable;
+/* Path to pkg-config installation directory, it is used instead of
+ * PKG_CONFIG_PC_PATH for finding /lib/pkgconfig and /share/pkgconfig
+ */
+extern char *pkg_config_pc_path;
 
 /* If TRUE, output flags in MSVC syntax. */
 extern int msvc_syntax;
--- main.c.orig	2011-05-15 13:06:06 +0400
+++ main.c	2012-03-31 06:39:45 +0400
@@ -40,6 +40,9 @@
 static int want_verbose_errors = 0;
 static int want_stdout_errors = 0;
 char *pcsysrootdir = NULL;
+#ifdef G_OS_WIN32
+char *pkg_config_pc_path = NULL;
+#endif
 
 void
 debug_spew (const char *format, ...)
@@ -293,6 +296,30 @@
       debug_spew ("PKG_CONFIG_DEBUG_SPEW variable enabling debug spew\n");
     }
 
+#ifdef G_OS_WIN32
+    pkg_config_pc_path = g_win32_get_package_installation_directory_of_module (NULL);
+    if (pkg_config_pc_path == NULL)
+      {
+        /* This variable is used later to add pc_path to the virtual pkg-config
+         * package. Can't proceed without it. This only happens when
+         * GetModuleFilename() fails; if it does - that failure should be
+         * investigated and fixed.
+         */
+         verbose_error ("Failed to get pkg_config_pc_path\n");
+         exit (1);
+      }
+    else
+      {
+        char *lpath, *shpath;
+        lpath = g_build_filename (pkg_config_pc_path, "lib", "pkgconfig", NULL);
+        shpath = g_build_filename (pkg_config_pc_path, "share", "pkgconfig", NULL);
+        free (pkg_config_pc_path);
+        pkg_config_pc_path = g_strconcat (lpath, G_SEARCHPATH_SEPARATOR_S, shpath, NULL);
+        free (lpath);
+        free (shpath);
+      }
+#endif
+
   search_path = getenv ("PKG_CONFIG_PATH");
   if (search_path) 
     {
@@ -304,7 +331,11 @@
     }
   else
     {
+#ifdef G_OS_WIN32
+      add_search_dirs(pkg_config_pc_path, G_SEARCHPATH_SEPARATOR_S);
+#else
       add_search_dirs(PKG_CONFIG_PC_PATH, G_SEARCHPATH_SEPARATOR_S);
+#endif
     }
 
   pcsysrootdir = getenv ("PKG_CONFIG_SYSROOT_DIR");
--- pkg.c.orig	2011-05-15 16:04:08 +0400
+++ pkg.c	2012-03-31 06:12:08 +0400
@@ -240,7 +240,11 @@
 
   if (pkg->vars == NULL)
     pkg->vars = g_hash_table_new (g_str_hash, g_str_equal);
+#ifdef G_OS_WIN32
+  g_hash_table_insert (pkg->vars, "pc_path", pkg_config_pc_path);
+#else
   g_hash_table_insert (pkg->vars, "pc_path", PKG_CONFIG_PC_PATH);
+#endif
 
   debug_spew ("Adding virtual 'pkg-config' package to list of known packages\n");
   g_hash_table_insert (packages, pkg->key, pkg);


More information about the pkg-config mailing list