pkg: add support for compiling in more than one default pkg-config search path

Some packages install to /usr/share/pkgconfig instead of /usr/lib/pkgconfig.
pull/15/head
William Pitcock 2012-05-05 20:24:45 -05:00
parent 7f7ad67bb2
commit 83ba295077
2 changed files with 15 additions and 4 deletions

View File

@ -3,7 +3,7 @@ SRCS = main.c parse.c pkg.c bsdstubs.c getopt_long.c fragment.c argvsplit.c fil
include buildsys.mk include buildsys.mk
CFLAGS += -DLIBDIR=\"${libdir}\" -DINCLUDEDIR=\"${includedir}\" -DPKG_DEFAULT_PATH=\"${libdir}/pkgconfig\" -Wall -Wextra -Wformat=2 -std=gnu99 -D_FORTIFY_SOURCE=2 CFLAGS += -DLIBDIR=\"${libdir}\" -DINCLUDEDIR=\"${includedir}\" -DPKG_DEFAULT_PATH=\"${libdir}/pkgconfig:${datadir}/pkgconfig\" -Wall -Wextra -Wformat=2 -std=gnu99 -D_FORTIFY_SOURCE=2
install-extra: install-extra:
mkdir -p $(DESTDIR)/$(datarootdir)/aclocal mkdir -p $(DESTDIR)/$(datarootdir)/aclocal

17
pkg.c
View File

@ -89,9 +89,20 @@ pkg_find(const char *name, unsigned int flags)
if (!(flags & PKGF_ENV_ONLY)) if (!(flags & PKGF_ENV_ONLY))
{ {
snprintf(locbuf, sizeof locbuf, "%s/%s" PKG_CONFIG_EXT, PKG_DEFAULT_PATH, name); count = path_split(PKG_DEFAULT_PATH, &path);
if ((f = fopen(locbuf, "r")) != NULL)
return parse_file(locbuf, f); while (iter < count)
{
snprintf(locbuf, sizeof locbuf, "%s/%s" PKG_CONFIG_EXT, path[iter], name);
free(path[iter]);
if ((f = fopen(locbuf, "r")) != NULL)
return parse_file(locbuf, f);
iter++;
}
free(path);
} }
return NULL; return NULL;