--- pkgconfig-0.15.0.orig/configure.in +++ pkgconfig-0.15.0/configure.in @@ -1,11 +1,24 @@ -AC_INIT(pkg-config.1) +AC_PREREQ(2.57) +AC_INIT([pkgconfig], [0.15.0]) +AC_CONFIG_SRCDIR([pkg-config.1]) -AM_INIT_AUTOMAKE(pkgconfig, 0.15.0) +AM_INIT_AUTOMAKE(1.7) AM_MAINTAINER_MODE 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) + +AC_ARG_WITH([xprefix], AC_HELP_STRING([--enable-xprefix], [cross-compilation prefix override [[PREFIX/%s]]]), + xprefix=$enableval, xprefix='${prefix}/%s') +if test "x$xprefix" = "xno"; then + xprefix="" +fi +AC_SUBST(xprefix) + AM_PROG_LIBTOOL AC_PROG_CC @@ -30,1 +30,2 @@ -AC_OUTPUT([Makefile]) +AC_CONFIG_FILES(Makefile) +AC_OUTPUT() --- pkgconfig-0.15.0.orig/Makefile.am +++ pkgconfig-0.15.0/Makefile.am @@ -15,7 +15,9 @@ bin_PROGRAMS = pkg-config -INCLUDES=-DPKGLIBDIR="\"$(pkglibdir)\"" $(included_glib_includes) +AUTOMAKE_OPTIONS = 1.7 +INCLUDES=-DPKGLIBDIR="\"$(pkglibdir)\"" -DPKGXLIBDIR="\"$(xpkglibdir)\"" \ + -DXPREFIX="\"$(xprefix)\"" $(included_glib_includes) pkg_config_SOURCES= \ pkg.h \ --- pkgconfig-0.15.0.orig/pkg.m4 +++ pkgconfig-0.15.0/pkg.m4 @@ -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 --- pkgconfig-0.15.0.orig/pkg.c +++ pkgconfig-0.15.0/pkg.c @@ -49,6 +49,10 @@ #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) +#undef XPREFIX +#define XPREFIX g_strconcat (g_win32_get_package_installation_directory (PACKAGE, NULL), "\\%s", NULL) #endif static void verify_package (Package *pkg); @@ -61,6 +65,7 @@ static int scanned_dir_count = 0; gboolean disable_uninstalled = FALSE; +const char *prefix_override = NULL; void add_search_dir (const char *path) @@ -184,14 +189,35 @@ } void -package_init () +package_init (const char *argv0) { static gboolean initted = FALSE; const char *pkglibdir; + const char *path = strrchr (argv0, G_DIR_SEPARATOR); - pkglibdir = g_getenv ("PKG_CONFIG_LIBDIR"); - if (pkglibdir == NULL) - pkglibdir = PKGLIBDIR; + if (path) + argv0 = path + 1; + if (strlen (argv0) > 11 && !strcmp (argv0 + strlen (argv0) - 11, "-pkg-config")) + { + char *host = g_strndup (argv0, strlen (argv0) - 11); + const char *pkgxlibdir = g_getenv ("PKG_CONFIG_X_LIBDIR"); + const char *xprefix = g_getenv ("PKG_CONFIG_XPREFIX"); + if (!pkgxlibdir) + pkgxlibdir = PKGXLIBDIR; + if (!xprefix) + xprefix = XPREFIX; + pkglibdir = g_strdup_printf (pkgxlibdir, host); + prefix_override = g_strdup_printf (xprefix, host); + /* this is called once, leak pkglibdir */ + debug_spew ("Cross-compiling options for '%s', xprefix '%s'.\n", host, prefix_override); + free (host); + } + else + { + pkglibdir = g_getenv ("PKG_CONFIG_LIBDIR"); + if (pkglibdir == NULL) + pkglibdir = PKGLIBDIR; + } if (!initted) { --- pkgconfig-0.15.0.orig/pkg.h +++ pkgconfig-0.15.0/pkg.h @@ -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, @@ -123,6 +123,6 @@ /* If TRUE, output flags in MSVC syntax. */ extern int msvc_syntax; #endif - +extern const char *prefix_override; #endif --- pkgconfig-0.15.0.orig/main.c +++ pkgconfig-0.15.0/main.c @@ -414,7 +414,7 @@ return 1; } - package_init (); + package_init (argv[0]); if (want_list) { --- pkgconfig-0.15.0.orig/parse.c +++ pkgconfig-0.15.0/parse.c @@ -894,10 +895,17 @@ } varname = g_strdup (tag); - varval = trim_and_sub (pkg, p, path); - - debug_spew (" Variable declaration, '%s' has value '%s'\n", + if (prefix_override && *prefix_override && !strcmp (varname, "prefix")) + { + varval = g_strdup (prefix_override); + debug_spew ("Cross-compilation prefix override '%s'\n", varval); + } + else + { + varval = trim_and_sub (pkg, p, path); + debug_spew ("Variable declaration, '%s' has value '%s'\n", varname, varval); + } g_hash_table_insert (pkg->vars, varname, varval); }