Re: pkg-config
"J. Ali Harlow" <[email protected]> Mon, 28 Apr 2003 14:28:42 +0100
| Newsgroups | gmane.comp.video.gimp.windows.devel |
|---|---|
| Message-ID | <[email protected]> |
On 2003.04.28 12:01 Richard Atterer wrote: > On Sun, Apr 27, 2003 at 08:52:59PM +0300, Tor Lillqvist wrote: > > The pkg-config program has been especially enhanced to take care of > > this. When compiled for Win32 (*not* if compiled for Cygwin, which is > > just a particular kind of Unix), it automatically replaces the > > "prefix" variable in .pc filles with the actual prefix deduced at > > run-time from the location of the .pc file. > > IMHO this behaviour is not the best solution because it only works if you > build under Windows. I cross-compile from Linux, so I have to kludge around > the issue by setting PKG_CONFIG_PATH and using > "--define-variable=prefix=..." I wrote a patch to get pkg-config to work as expected when cross compiling. I did submit it but it doesn't seem to have been taken up - I'm not sure why. I attach a copy in case it is of use. -- Ali Harlow Email: [email protected] 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 ---------- --- 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); [Non-text portions of this message have been removed]