Take a xtrans.pc file like: prefix=/usr exec_prefix=${prefix} libdir=${exec_prefix}/lib includedir=${prefix}/include Name: XTrans Description: Abstract network code for X Version: 1.2.1 Cflags: -I${includedir} -D_BSD_SOURCE -DHAS_FCHOWN -DHAS_STICKY_DIR_BIT and call pkg-config from a bash like (all on one line): PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 PKG_CONFIG_PATH=/sources/emb_prj/dest/usr/lib/pkgconfig PKG_CONFIG_SYSROOT_DIR=/sources/emb_prj/dest pkg-config --cflags "xtrans" than all I get is: -I/sources/emb_prj/dest/usr/include instead of the expected: -D_BSD_SOURCE -DHAS_FCHOWN -DHAS_STICKY_DIR_BIT -I/sources/emb_prj/dest/usr/include The three preprocessor variable defs are missing. The problem does NOT occur if the env. var. PKG_CONFIG_SYSROOT_DIR is not defined. I could trace down the bug in the function 'string_list_to_string()' defined in pkg.c: static char * string_list_to_string (GSList *list) { GSList *tmp; GString *str = g_string_new (""); char *retval; tmp = list; while (tmp != NULL) { char *tmpstr = (char*) tmp->data; if (pcsysrootdir != NULL) { if (tmpstr[0] == '-' && (tmpstr[1] == 'I' || tmpstr[1] == 'L')) { g_string_append_c (str, '-'); g_string_append_c (str, tmpstr[1]); g_string_append (str, pcsysrootdir); g_string_append (str, tmpstr+2); } } else { g_string_append (str, tmpstr); } g_string_append_c (str, ' '); tmp = g_slist_next (tmp); } retval = str->str; g_string_free (str, FALSE); return retval; } If the var. 'pcsysrootdir' is not NULL *and* the 'tmpstr' does not start with '-I' or '-L' then the string 'tmpstr' won't be appended to the result 'str'.
Created attachment 21210 [details] [review] patch to fix bug This patch combines the two nested if statements in the above post. If -I or -L is not found, then the entire string is appended as one would expect. This has been tested and works on my system. I am now able to use pkg-config with a sysroot directory.
this one, and not the previously accepted http://lists.freedesktop.org/archives/pkg-config/2008-January/000255.html fixes SYSROOT support.
Fixed in 66d49f1.
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.