diff -ru pkgconfig-0.15.0/configure.in pkgconfig-0.15.0.new/configure.in --- pkgconfig-0.15.0/configure.in 2003-10-28 02:33:33.000000000 +0100 +++ pkgconfig-0.15.0.new/configure.in 2003-10-28 02:16:58.000000000 +0100 @@ -6,6 +6,10 @@ AM_CONFIG_HEADER(config.h) +AC_ARG_WITH([xpkglibdir], AC_HELP_STRING([--enable-xpkglibdir], [cross-compilation pkglibdir [[PREFIX/%s/lib/pkgconfig]]]), + xpkglibdir=$enableval, xpkglibdir='${prefix}/%s/lib/pkgconfig') +AC_SUBST(xpkglibdir) + AM_PROG_LIBTOOL AC_PROG_CC diff -ru pkgconfig-0.15.0/main.c pkgconfig-0.15.0.new/main.c --- pkgconfig-0.15.0/main.c 2003-01-15 06:01:00.000000000 +0100 +++ pkgconfig-0.15.0.new/main.c 2003-10-28 01:14:04.000000000 +0100 @@ -414,7 +414,7 @@ return 1; } - package_init (); + package_init (argv[0]); if (want_list) { diff -ru pkgconfig-0.15.0/Makefile.am pkgconfig-0.15.0.new/Makefile.am --- pkgconfig-0.15.0/Makefile.am 2002-09-12 22:47:07.000000000 +0200 +++ pkgconfig-0.15.0.new/Makefile.am 2003-10-28 02:17:09.000000000 +0100 @@ -15,7 +15,7 @@ bin_PROGRAMS = pkg-config -INCLUDES=-DPKGLIBDIR="\"$(pkglibdir)\"" $(included_glib_includes) +INCLUDES=-DPKGLIBDIR="\"$(pkglibdir)\"" -DPKGXLIBDIR="\"$(xpkglibdir)\"" $(included_glib_includes) pkg_config_SOURCES= \ pkg.h \ diff -ru pkgconfig-0.15.0/pkg.c pkgconfig-0.15.0.new/pkg.c --- pkgconfig-0.15.0/pkg.c 2003-10-28 02:33:33.000000000 +0100 +++ pkgconfig-0.15.0.new/pkg.c 2003-10-28 02:31:23.000000000 +0100 @@ -49,6 +49,8 @@ #undef PKGLIBDIR /* It's OK to leak this, as PKGLIBDIR is invoked only once */ #define PKGLIBDIR g_strconcat (g_win32_get_package_installation_directory (PACKAGE, NULL), "\\lib\\pkgconfig", NULL) +#undef PKGXLIBDIR +#define PKGXLIBDIR g_strconcat (g_win32_get_package_installation_directory (PACKAGE, NULL), "\\%s\\lib\\pkgconfig", NULL) #endif static void verify_package (Package *pkg); @@ -184,13 +186,27 @@ } void -package_init () +package_init (const char *argv0) { static gboolean initted = FALSE; const char *pkglibdir; pkglibdir = g_getenv ("PKG_CONFIG_LIBDIR"); if (pkglibdir == NULL) + { + const char *path = strrchr (argv0, G_DIR_SEPARATOR); + if (path) + argv0 = path + 1; + if (strlen (argv0) > 11 && !strcmp (argv0 + strlen (argv0) - 11, "-pkg-config")) + { + char *host = g_strndup (argv0, strlen (argv0) - 11); + pkglibdir = g_strdup_printf (PKGXLIBDIR, host); + /* this is called once, leak pkglibdir */ + debug_spew ("Cross-compiling options for '%s'.\n", host); + free (host); + } + } + if (pkglibdir == NULL) pkglibdir = PKGLIBDIR; if (!initted) diff -ru pkgconfig-0.15.0/pkg.h pkgconfig-0.15.0.new/pkg.h --- pkgconfig-0.15.0/pkg.h 2002-09-06 22:00:08.000000000 +0200 +++ pkgconfig-0.15.0.new/pkg.h 2003-10-28 01:14:32.000000000 +0100 @@ -92,7 +92,7 @@ void add_search_dir (const char *path); -void package_init (void); +void package_init (const char *argv0); int compare_versions (const char * a, const char *b); gboolean version_test (ComparisonType comparison, const char *a, diff -ru pkgconfig-0.15.0/pkg.m4 pkgconfig-0.15.0.new/pkg.m4 --- pkgconfig-0.15.0/pkg.m4 2002-02-03 18:16:48.000000000 +0100 +++ pkgconfig-0.15.0.new/pkg.m4 2003-10-28 01:09:10.000000000 +0100 @@ -2,11 +2,11 @@ dnl PKG_CHECK_MODULES(GSTUFF, gtk+-2.0 >= 1.3 glib = 1.3.4, action-if, action-not) dnl defines GSTUFF_LIBS, GSTUFF_CFLAGS, see pkg-config man page dnl also defines GSTUFF_PKG_ERRORS on error -AC_DEFUN(PKG_CHECK_MODULES, [ +AC_DEFUN([PKG_CHECK_MODULES], [ succeeded=no if test -z "$PKG_CONFIG"; then - AC_PATH_PROG(PKG_CONFIG, pkg-config, no) + AC_PATH_TOOL(PKG_CONFIG, pkg-config, no) fi if test "$PKG_CONFIG" = "no" ; then