pkg-config support for linux-x-mingw cross compile tools



When compiling applications and libraries on my linux-x-mingw
cross compile system I have a small problem in that the normal
win32 mungling of prefixes is not performed. This patch allows
the use of --target=*-*-mingw* to enable this functionality.

--- pkgconfig-0.12.0/configure.in	Thu Mar  7 21:57:42 2002
+++ pkgconfig-0.12.0-win32/configure.in	Fri Jun 14 13:57:16 2002
@@ -39,6 +39,18 @@
   AC_CONFIG_SUBDIRS(glib-1.2.8)
 fi # !native_win32
 
+AC_MSG_CHECKING([for Win32 target system])
+case "$target" in
+  *-*-mingw*)
+    target_win32=yes
+    AC_DEFINE(ENABLE_PREFIX_MUNGLING, 1, [Replace prefix with guestimated value])
+  ;;
+  *)
+    target_win32=no
+  ;;
+esac
+AC_MSG_RESULT([$target_win32])
+
 AM_PROG_LIBTOOL
 
 AC_PROG_CC
--- pkgconfig-0.12.0/main.c	Fri Feb  1 22:14:59 2002
+++ pkgconfig-0.12.0-win32/main.c	Fri Jun 14 12:13:09 2002
@@ -210,12 +210,14 @@
       "show verbose information about missing or conflicting packages" },
     { "errors-to-stdout", 0, POPT_ARG_NONE, &want_stdout_errors, 0,
       "print errors from --print-errors to stdout not stderr" },
-#ifdef G_OS_WIN32
+#ifdef ENABLE_PREFIX_MUNGLING
     { "dont-define-prefix", 0, POPT_ARG_NONE, &dont_define_prefix, 0,
       "don't try to override the value of prefix for each .pc file found with "
       "a guesstimated value based on the location of the .pc file" },
     { "prefix-variable", 0, POPT_ARG_STRING, &prefix_variable, 0,
       "set the name of the variable that pkg-config automatically sets", "PREFIX" },
+#endif
+#ifdef G_OS_WIN32
     { "msvc-syntax", 0, POPT_ARG_NONE, &msvc_syntax, 0,
       "output -l and -L flags for the Microsoft compiler (cl)" },
 #endif
--- pkgconfig-0.12.0/pkg.h	Wed Nov 28 18:55:59 2001
+++ pkgconfig-0.12.0-win32/pkg.h	Fri Jun 14 16:26:59 2002
@@ -94,13 +94,15 @@
 /* If TRUE, do not automatically prefer uninstalled versions */
 extern gboolean disable_uninstalled;
 
-#ifdef G_OS_WIN32
+#ifdef ENABLE_PREFIX_MUNGLING
 /* If TRUE, do not automatically define "prefix"  while
  * parsing each .pc file */
 extern int dont_define_prefix;
 /* The name of the variable that acts as prefix, unless it is "prefix" */
 extern char *prefix_variable;
+#endif
 
+#ifdef G_OS_WIN32
 /* If TRUE, output flags in MSVC syntax. */
 extern int msvc_syntax;
 #endif
--- pkgconfig-0.12.0/parse.c	Fri Feb  1 22:15:23 2002
+++ pkgconfig-0.12.0-win32/parse.c	Fri Jun 14 17:23:14 2002
@@ -14,9 +14,12 @@
 #endif
 #include <sys/types.h>
 
-#ifdef G_OS_WIN32
+#ifdef ENABLE_PREFIX_MUNGLING
 int dont_define_prefix = FALSE;
 char *prefix_variable = "prefix";
+#endif
+
+#ifdef G_OS_WIN32
 int msvc_syntax = FALSE;
 #endif
 
@@ -833,7 +836,7 @@
       if (pkg->vars == NULL)
         pkg->vars = g_hash_table_new (g_str_hash, g_str_equal);
 
-#ifdef G_OS_WIN32
+#ifdef ENABLE_PREFIX_MUNGLING
       if (!dont_define_prefix && strcmp (tag, prefix_variable) == 0)
 	{
 	  /* This is the prefix variable. Try to guesstimate a value for it
@@ -842,12 +845,21 @@
 
 	  gchar *prefix = pkg->pcfiledir;
 	  const int prefix_len = strlen (prefix);
+#ifdef G_OS_WIN32
 	  const char *const lib_pkgconfig = "\\lib\\pkgconfig";
+#else
+	  const char *const lib_pkgconfig = "/lib/pkgconfig";
+#endif
 	  const int lib_pkgconfig_len = strlen (lib_pkgconfig);
 
 	  if (strlen (prefix) > lib_pkgconfig_len &&
+#ifdef G_OS_WIN32
 	      g_ascii_strcasecmp (prefix + prefix_len - lib_pkgconfig_len,
 				  lib_pkgconfig) == 0)
+#else
+	      strcmp (prefix + prefix_len - lib_pkgconfig_len,
+				  lib_pkgconfig) == 0)
+#endif
 	    {
 	      /* It ends in lib\pkgconfig. Good. */
 	      
@@ -856,6 +868,7 @@
 	      prefix = g_strdup (prefix);
 	      prefix[prefix_len - lib_pkgconfig_len] = '\0';
 	      
+#ifdef G_OS_WIN32
 	      /* Turn backslashes into slashes or
 	       * poptParseArgvString() will eat them when ${prefix}
 	       * has been expanded in parse_libs().
@@ -867,6 +880,7 @@
 		    *p = '/';
 		  p++;
 		}
+#endif
 	      varname = g_strdup (tag);
 	      debug_spew (" Variable declaration, '%s' overridden with '%s'\n",
 			  tag, prefix);


-- 
Ali Harlow                              Email: ali avrc city ac uk
Research programmer                     Tel:   (020) 7040 4348
Applied Vision Research Centre          Intl: +44 20 7040 4348
City University                         Fax:   (020) 7040 5515
London                                  Intl: +44 20 7040 5515




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