summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJorn Amundsen <jorn.amundsen@ntnu.no>2010-05-09 09:49:13 +0200
committerTollef Fog Heen <tfheen@err.no>2010-05-09 09:49:13 +0200
commit4b80e49ff8e232d9094354a15f6b911a997a94d4 (patch)
tree8688da061fb8ef7f175bdfcbc08791e05958a783
parentc5a3105f418c8fc9efe2e63909cce2fbab95ce97 (diff)
downloadpkg-config-4b80e49ff8e232d9094354a15f6b911a997a94d4.tar.gz
Add listing of variables
Fixes Freedesktop #133
-rw-r--r--main.c31
-rw-r--r--pkg-config.15
2 files changed, 35 insertions, 1 deletions
diff --git a/main.c b/main.c
index b9442fc..dba1729 100644
--- a/main.c
+++ b/main.c
@@ -163,6 +163,14 @@ pkg_uninstalled (Package *pkg)
return FALSE;
}
+void
+print_hashtable_key (gpointer key,
+ gpointer value,
+ gpointer user_data)
+{
+ printf("%s\n", (gchar*)key);
+}
+
int
main (int argc, char **argv)
{
@@ -186,6 +194,7 @@ main (int argc, char **argv)
static char *required_max_version = NULL;
static char *required_pkgconfig_version = NULL;
static int want_silence_errors = 0;
+ static int want_variable_list = 0;
int result;
GString *str;
GSList *packages = NULL;
@@ -233,6 +242,8 @@ main (int argc, char **argv)
"set variable NAME to VALUE", "NAME=VALUE" },
{ "exists", 0, POPT_ARG_NONE, &want_exists, 0,
"return 0 if the module(s) exist" },
+ { "print-variables", 0, POPT_ARG_NONE, &want_variable_list, 0,
+ "output list of variables defined by the module" },
{ "uninstalled", 0, POPT_ARG_NONE, &want_uninstalled, 0,
"return 0 if the uninstalled version of one or more module(s) or their dependencies will be used" },
{ "atleast-version", 0, POPT_ARG_STRING, &required_atleast_version, 0,
@@ -348,7 +359,8 @@ main (int argc, char **argv)
want_other_libs ||
want_I_cflags ||
want_other_cflags ||
- want_list)
+ want_list ||
+ want_variable_list)
{
debug_spew ("Error printing enabled by default due to use of --version, --libs, --cflags, --libs-only-l, --libs-only-L, --libs-only-other, --cflags-only-I, --cflags-only-other or --list. Value of --silence-errors: %d\n", want_silence_errors);
@@ -506,6 +518,23 @@ main (int argc, char **argv)
return 1;
}
+ if (want_variable_list)
+ {
+ GSList *tmp;
+ gchar *str;
+ tmp = packages;
+ while (tmp != NULL)
+ {
+ Package *pkg = tmp->data;
+ g_hash_table_foreach(pkg->vars,
+ &print_hashtable_key,
+ NULL);
+ tmp = g_slist_next (tmp);
+ if (tmp) printf ("\n");
+ }
+ need_newline = FALSE;
+ }
+
}
g_string_free (str, TRUE);
diff --git a/pkg-config.1 b/pkg-config.1
index d1cfed6..80954eb 100644
--- a/pkg-config.1
+++ b/pkg-config.1
@@ -33,6 +33,7 @@ pkg-config \- Return metainformation about installed libraries
[\-\-libs-only-l] [\-\-cflags-only-I]
[\-\-variable=VARIABLENAME]
[\-\-define-variable=VARIABLENAME=VARIABLEVALUE]
+[\-\-print-variables]
[\-\-uninstalled]
[\-\-exists] [\-\-atleast-version=VERSION] [\-\-exact-version=VERSION]
[\-\-max-version=VERSION] [\-\-list\-all] [LIBRARIES...]
@@ -158,6 +159,10 @@ can say:
/foo
.fi
.TP
+.I "--print-variables"
+Returns a list of all variables defined in the package.
+
+.TP
.I "--uninstalled"
Normally if you request the package "foo" and the package
"foo-uninstalled" exists, \fIpkg-config\fP will prefer the