+/* Can return NULL: _info may not support 'libs'. */
+static char **get_one_libs(const void *ctx, const char *dir,
+ char *(*get_info)(const void *ctx, const char *dir))
+{
+ char *cmd, **lines;
+
+ cmd = talloc_asprintf(ctx, "%s libs", get_info(ctx, dir));
+ lines = lines_from_cmd(cmd, "%s", cmd);
+ /* Strip final NULL. */
+ if (lines)
+ lines = talloc_realloc(NULL, lines, char *,
+ talloc_array_length(lines)-1);
+ return lines;
+}
+
+/* O(n^2) but n is small. */
+static char **add_deps(char **deps1, char **deps2)
+{
+ unsigned int i, len;
+
+ len = talloc_array_length(deps1);
+
+ for (i = 0; deps2[i]; i++) {
+ if (have_dep(deps1, deps2[i]))
+ continue;
+ deps1 = talloc_realloc(NULL, deps1, char *, len + 1);
+ deps1[len-1] = talloc_steal(deps1, deps2[i]);
+ deps1[len++] = NULL;
+ }
+ return deps1;
+}
+
+char **get_libs(const void *ctx, const char *dir, const char *style,
+ char *(*get_info)(const void *ctx, const char *dir))