pkg: add support for relative path finding on windows (issue #17)

pull/29/head
William Pitcock 2012-05-12 02:26:55 -05:00
parent 6519f6abdc
commit 524133cd91
1 changed files with 21 additions and 0 deletions

21
pkg.c
View File

@ -92,11 +92,32 @@ static inline const char *
get_pkgconfig_path(void)
{
const char *env_path;
#ifdef _WIN32
static char outbuf[MAX_PATH];
char namebuf[MAX_PATH];
char *p;
#endif
env_path = getenv("PKG_CONFIG_LIBDIR");
if (env_path != NULL)
return env_path;
#ifdef _WIN32
GetModuleFileName(NULL, namebuf, sizeof namebuf);
p = strrchr(namebuf, '\\');
if (p == NULL)
p = strrchr(namebuf, '/');
if (p == NULL)
return PKG_DEFAULT_PATH;
*p = '\0';
strlcpy(outbuf, namebuf, sizeof outbuf);
strlcat(outbuf, "/lib/pkgconfig", sizeof outbuf);
return outbuf;
#endif
return PKG_DEFAULT_PATH;
}