diff -up pkg-config-0.28/pkg.c.envvar pkg-config-0.28/pkg.c --- pkg-config-0.28/pkg.c.envvar 2013-01-22 14:11:59.000000000 +0100 +++ pkg-config-0.28/pkg.c 2015-06-09 21:19:51.648018495 +0200 @@ -1012,6 +1012,24 @@ define_global_variable (const char *varn } char * +var_to_env_var (const char *pkg, const char *var) +{ + char *new = g_strconcat ("PKG_CONFIG_", pkg, "_", var, NULL); + char *p; + for (p = new; *p != 0; p++) + { + char c = g_ascii_toupper (*p); + + if (!g_ascii_isalnum (c)) + c = '_'; + + *p = c; + } + + return new; +} + +char * package_get_var (Package *pkg, const char *var) { @@ -1019,7 +1037,20 @@ package_get_var (Package *pkg, if (globals) varval = g_strdup (g_hash_table_lookup (globals, var)); - + + if (pkg->key) + { + char *env_var = var_to_env_var (pkg->key, var); + const char *env_var_content = g_getenv (env_var); + g_free (env_var); + if (env_var_content) + { + debug_spew ("Overriding variable '%s' from environment\n", var); + return g_strdup (env_var_content); + } + } + + if (varval == NULL && pkg->vars) varval = g_strdup (g_hash_table_lookup (pkg->vars, var)); diff -up pkg-config-0.28/pkg-config.1.envvar pkg-config-0.28/pkg-config.1 --- pkg-config-0.28/pkg-config.1.envvar 2015-06-09 21:21:27.009637301 +0200 +++ pkg-config-0.28/pkg-config.1 2015-06-09 21:35:31.503400424 +0200 @@ -297,6 +297,11 @@ equal to /var/target (same rule apply to .TP .I "PKG_CONFIG_LIBDIR" Replaces the default \fIpkg-config\fP search directory, usually \fI/usr/lib/pkgconfig\fP +.TP +.I "PKG_CONFIG_$PACKAGE_$VARIABLE" +Overrides the variable VARIABLE in the package PACKAGE. For example, +setting PKG_CONFIG_GLADEUI_2_0_CATALOGDIR will override the +variable "catalogdir" in the "gladeui-2.0" package. .\" .SH QUERYING PKG-CONFIG'S DEFAULTS .I pkg-config