分类: LINUX
2009-05-16 15:22:24
$PKG_CONFIG_DIR = /home/xiewei/stuff/workspace/staging/armv7a-linux-gnueabi/usr/lib/pkgconfig $PKG_CONFIG_PATH = /home/xiewei/stuff/workspace/staging/armv7a-linux- gnueabi/usr/lib/pkgconfig:/home/xiewei/stuff/workspace/staging/armv7a-linux-gnueabi/usr/share/pkgconfig $PKG_CONFIG_DISABLE_UNINSTALLED = yes $PKG_CONFIG_SYSROOT_DIR = /home/xiewei/stuff/workspace/staging/armv7a-linux-gnueabi |
以pkg-config --cflags glib-2.0为例,
pkg-config启动后,按照如下顺序来添加pc查找的目录:
PKG_CONFIG_PATH -> PKG_CONFIG_LIBDIR -> PKG_CONFIG_PC_PATH |
main.c +285 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); } Makefile.am:INCLUDES=-DPKG_CONFIG_PC_PATH="\"$(pc_path)\"" $(included_glib_includes) Makefile: libdir = /home/xiewei/stuff/workspace/staging/i686-linux/usr/lib datadir = /home/xiewei/stuff/workspace/staging/i686-linux/usr/share pc_path = ${libdir}/pkgconfig:${datadir}/pkgconfig |
pkg.c +247 package_init(): packages = g_hash_table_new (g_str_hash, g_str_equal); // package->key和package指针的对应 locations = g_hash_table_new (g_str_hash, g_str_equal); // pkgname和filename全称的对应(包括从/开始的路径和文件名称) path_positions = g_hash_table_new (g_str_hash, g_str_equal); // 该pkgname和查找目录列表中的第几个目录对应 |
对于glib-2.0.pc, pkg->key = "glibc-2.0", pkg->name = "GLib"
通过dent->d_name = "glibc-2.0.pc" 找到 pkgname = "glibc-2.0",
package->key正常情况下,和pkgname是一样的。
第一次查找到给出的debug信息:
File 'glib-2.0.pc' appears to be a .pc file
第二次查找到给出的debug信息:
File 'glib-2.0.pc' ignored, we already know about package 'glib-2.0'
有一点需要注意的是,如果环境变量中定义了PKG_CONFIG_SYSROOT_DIR,则会在返回-I及-L的后面先紧跟着这个SYSROOT,然后才是正常的/usr/include
等。
代码: pkg.c +466 string_list_to_string (GSList *list) if (pcsysrootdir != NULL && 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); } |