diff --git a/Makefile b/Makefile index 753c3e4..54d1ed1 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ SRCS = main.c parse.c pkg.c bsdstubs.c getopt_long.c fragment.c argvsplit.c fil 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: mkdir -p $(DESTDIR)/$(datarootdir)/aclocal diff --git a/pkg.c b/pkg.c index 345d263..bc29b7d 100644 --- a/pkg.c +++ b/pkg.c @@ -89,9 +89,20 @@ pkg_find(const char *name, unsigned int flags) if (!(flags & PKGF_ENV_ONLY)) { - snprintf(locbuf, sizeof locbuf, "%s/%s" PKG_CONFIG_EXT, PKG_DEFAULT_PATH, name); - if ((f = fopen(locbuf, "r")) != NULL) - return parse_file(locbuf, f); + count = path_split(PKG_DEFAULT_PATH, &path); + + 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;