Package: pkg-config Version: 0.21-1 Tags: patch Followup-For: Bug #217902 Hi,
Someone asked for this on #debian-devel today so I threw a patch together without first checking the BTS. This patch adds a --arch option that you pass a triple arch-os-gnu and it then searches /usr/lib/arch-os-gnu/pkgconfig for .pc files. I have no experience with multiarch, but this is what was asked for. I don't know how this approach compares to the other one. There are 3 things I would address in this patch before it would be accepted any way. 1) free the strings if necessary. 2) Check that the --arch argument contains no .. or / etc. 3) Support multiple bases in the ./configure argument, so that say usr/local/lib and usr/lib can both be supported. Let me know what you think of the patch. James
Index: main.c =================================================================== --- main.c.orig 2006-10-08 20:01:29.000000000 +0100 +++ main.c 2006-10-08 21:11:45.000000000 +0100 @@ -201,6 +201,7 @@ char **search_dirs; char **iter; gboolean need_newline; + char *cross_arch = NULL; const char *pkgname; Package *pkg; @@ -257,6 +258,8 @@ "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" }, + { "arch", 0, POPT_ARG_STRING, &cross_arch, 0, + "Output information for the given architecture" }, #ifdef G_OS_WIN32 { "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 " @@ -281,20 +284,6 @@ debug_spew ("PKG_CONFIG_DEBUG_SPEW variable enabling debug spew\n"); } - search_path = getenv ("PKG_CONFIG_PATH"); - if (search_path) - { - add_search_dirs(search_path, G_SEARCHPATH_SEPARATOR_S); - } - if (getenv("PKG_CONFIG_LIBDIR") != NULL) - { - add_search_dirs(getenv("PKG_CONFIG_LIBDIR"), G_SEARCHPATH_SEPARATOR_S); - } - else - { - add_search_dirs(PKG_CONFIG_PC_PATH, G_SEARCHPATH_SEPARATOR_S); - } - #ifdef G_OS_WIN32 { /* Add search directories from the Registry */ @@ -375,6 +364,26 @@ return 1; } + search_path = getenv ("PKG_CONFIG_PATH"); + if (search_path) + { + add_search_dirs(search_path, G_SEARCHPATH_SEPARATOR_S); + } + if (getenv("PKG_CONFIG_LIBDIR") != NULL) + { + add_search_dirs(getenv("PKG_CONFIG_LIBDIR"), G_SEARCHPATH_SEPARATOR_S); + } + else if (cross_arch != NULL) + { + char *dir = strndup(PKG_CONFIG_MULTI_BASE_PATH, 25); + char *arch = strndup(cross_arch, 25); + add_search_dir(strncat(strncat(dir, arch, 50), "/pkgconfig/", 61)); + } + else + { + add_search_dirs(PKG_CONFIG_PC_PATH, G_SEARCHPATH_SEPARATOR_S); + } + /* Error printing is determined as follows: * - for --cflags, --libs, etc. it's on by default Index: Makefile.am =================================================================== --- Makefile.am.orig 2006-10-08 20:18:12.000000000 +0100 +++ Makefile.am 2006-10-08 20:55:05.000000000 +0100 @@ -16,7 +16,9 @@ bin_PROGRAMS = pkg-config [EMAIL PROTECTED]@ -INCLUDES=-DPKG_CONFIG_PC_PATH="\"$(pc_path)\"" $(included_glib_includes) +INCLUDES=-DPKG_CONFIG_PC_PATH="\"$(pc_path)\"" \ + -DPKG_CONFIG_MULTI_BASE_PATH="\"$(pc_multiarch_path)/\"" \ + $(included_glib_includes) pkg_config_SOURCES= \ pkg.h \ Index: configure.in =================================================================== --- configure.in.orig 2006-10-08 20:14:20.000000000 +0100 +++ configure.in 2006-10-08 20:18:05.000000000 +0100 @@ -22,7 +22,18 @@ ]) +AC_DEFUN([PKG_CONFIG_FIND_PC_MULTI_PATH], +[AC_ARG_WITH(pc_multiarch_path, + [ --with-pc-multiarch-path Override the default base path for use in multiarch mode ], + [ pc_multiarch_path="$withval" + AC_MSG_CHECKING([for default base path for use in multiarch mode]) + AC_MSG_RESULT([$pc_multiarch_path])], + [pc_multiarch_path="$libdir"]) + AC_SUBST([pc_multiarch_path]) +]) + PKG_CONFIG_FIND_PC_PATH +PKG_CONFIG_FIND_PC_MULTI_PATH # # Code taken from gtk+-2.0's configure.in. Index: pkg-config.1 =================================================================== --- pkg-config.1.orig 2006-10-08 21:13:21.000000000 +0100 +++ pkg-config.1 2006-10-08 21:16:09.000000000 +0100 @@ -35,7 +35,7 @@ [\-\-define-variable=VARIABLENAME=VARIABLEVALUE] [\-\-uninstalled] [\-\-exists] [\-\-atleast-version=VERSION] [\-\-exact-version=VERSION] -[\-\-max-version=VERSION] [LIBRARIES...] +[\-\-max-version=VERSION] [\-\-arch=ARCH] [LIBRARIES...] .SH DESCRIPTION The \fIpkg-config\fP program is used to retrieve information about @@ -217,6 +217,12 @@ the .pc files, else a too large number of libraries will ordinarily be output. +.TP +.I "--arch=ARCH" +For use in multiarch situations. Pass it a triple arch-os-gnu and it will +search $libdir/arch-os-gnu/pkgconfig for the .pc files. It can only use that +one location currently. + .SH ENVIRONMENT VARIABLES .TP