diff --git a/pkg.c b/pkg.c index 9bf8552..e8a4905 100644 --- a/pkg.c +++ b/pkg.c @@ -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; }