aboutsummaryrefslogtreecommitdiff
path: root/libpkgconf/client.c
diff options
context:
space:
mode:
Diffstat (limited to 'libpkgconf/client.c')
-rw-r--r--libpkgconf/client.c52
1 files changed, 43 insertions, 9 deletions
diff --git a/libpkgconf/client.c b/libpkgconf/client.c
index 811e043..f4155b3 100644
--- a/libpkgconf/client.c
+++ b/libpkgconf/client.c
@@ -48,17 +48,39 @@ trace_path_list(const pkgconf_client_t *client, const char *desc, pkgconf_list_t
/*
* !doc
*
- * .. c:function:: void pkgconf_client_init(pkgconf_client_t *client, pkgconf_error_handler_func_t error_handler)
+ * .. c:function:: void pkgconf_client_dir_list_build(pkgconf_client_t *client)
+ *
+ * Bootstraps the package search paths. If the ``PKGCONF_PKG_PKGF_ENV_ONLY`` `flag` is set on the client,
+ * then only the ``PKG_CONFIG_PATH`` environment variable will be used, otherwise both the
+ * ``PKG_CONFIG_PATH`` and ``PKG_CONFIG_LIBDIR`` environment variables will be used.
+ *
+ * :param pkgconf_client_t* client: The pkgconf client object to bootstrap.
+ * :return: nothing
+ */
+void
+pkgconf_client_dir_list_build(pkgconf_client_t *client, const pkgconf_cross_personality_t *personality)
+{
+ pkgconf_path_build_from_environ("PKG_CONFIG_PATH", NULL, &client->dir_list, true);
+
+ if (!(client->flags & PKGCONF_PKG_PKGF_ENV_ONLY) && (pkgconf_path_build_from_environ("PKG_CONFIG_LIBDIR", NULL, &client->dir_list, true)) < 1)
+ pkgconf_path_copy_list(&client->dir_list, &personality->dir_list);
+}
+
+/*
+ * !doc
+ *
+ * .. c:function:: void pkgconf_client_init(pkgconf_client_t *client, pkgconf_error_handler_func_t error_handler, void *error_handler_data, const pkgconf_cross_personality_t *personality)
*
* Initialise a pkgconf client object.
*
* :param pkgconf_client_t* client: The client to initialise.
* :param pkgconf_error_handler_func_t error_handler: An optional error handler to use for logging errors.
* :param void* error_handler_data: user data passed to optional error handler
+ * :param pkgconf_cross_personality_t* personality: the cross-compile personality to use for defaults
* :return: nothing
*/
void
-pkgconf_client_init(pkgconf_client_t *client, pkgconf_error_handler_func_t error_handler, void *error_handler_data)
+pkgconf_client_init(pkgconf_client_t *client, pkgconf_error_handler_func_t error_handler, void *error_handler_data, const pkgconf_cross_personality_t *personality)
{
client->error_handler_data = error_handler_data;
client->error_handler = error_handler;
@@ -70,15 +92,26 @@ pkgconf_client_init(pkgconf_client_t *client, pkgconf_error_handler_func_t error
pkgconf_client_set_error_handler(client, error_handler, error_handler_data);
pkgconf_client_set_warn_handler(client, NULL, NULL);
- pkgconf_client_set_sysroot_dir(client, NULL);
+ pkgconf_client_set_sysroot_dir(client, personality->sysroot_dir);
pkgconf_client_set_buildroot_dir(client, NULL);
pkgconf_client_set_prefix_varname(client, NULL);
- pkgconf_path_build_from_environ("PKG_CONFIG_SYSTEM_LIBRARY_PATH", SYSTEM_LIBDIR, &client->filter_libdirs, false);
- pkgconf_path_build_from_environ("PKG_CONFIG_SYSTEM_INCLUDE_PATH", SYSTEM_INCLUDEDIR, &client->filter_includedirs, false);
+ if(getenv("PKG_CONFIG_SYSTEM_LIBRARY_PATH") == NULL)
+ pkgconf_path_copy_list(&client->filter_libdirs, &personality->filter_libdirs);
+ else
+ pkgconf_path_build_from_environ("PKG_CONFIG_SYSTEM_LIBRARY_PATH", NULL, &client->filter_libdirs, false);
+
+ if(getenv("PKG_CONFIG_SYSTEM_INCLUDE_PATH") == NULL)
+ pkgconf_path_copy_list(&client->filter_includedirs, &personality->filter_includedirs);
+ else
+ pkgconf_path_build_from_environ("PKG_CONFIG_SYSTEM_INCLUDE_PATH", NULL, &client->filter_includedirs, false);
/* GCC uses these environment variables to define system include paths, so we should check them. */
+#ifdef __HAIKU__
+ pkgconf_path_build_from_environ("BELIBRARIES", NULL, &client->filter_libdirs, false);
+#else
pkgconf_path_build_from_environ("LIBRARY_PATH", NULL, &client->filter_libdirs, false);
+#endif
pkgconf_path_build_from_environ("CPATH", NULL, &client->filter_includedirs, false);
pkgconf_path_build_from_environ("C_INCLUDE_PATH", NULL, &client->filter_includedirs, false);
pkgconf_path_build_from_environ("CPLUS_INCLUDE_PATH", NULL, &client->filter_includedirs, false);
@@ -98,20 +131,21 @@ pkgconf_client_init(pkgconf_client_t *client, pkgconf_error_handler_func_t error
/*
* !doc
*
- * .. c:function:: pkgconf_client_t* pkgconf_client_new(pkgconf_error_handler_func_t error_handler)
+ * .. c:function:: pkgconf_client_t* pkgconf_client_new(pkgconf_error_handler_func_t error_handler, void *error_handler_data, const pkgconf_cross_personality_t *personality)
*
* Allocate and initialise a pkgconf client object.
*
* :param pkgconf_error_handler_func_t error_handler: An optional error handler to use for logging errors.
* :param void* error_handler_data: user data passed to optional error handler
+ * :param pkgconf_cross_personality_t* personality: cross-compile personality to use
* :return: A pkgconf client object.
* :rtype: pkgconf_client_t*
*/
pkgconf_client_t *
-pkgconf_client_new(pkgconf_error_handler_func_t error_handler, void *error_handler_data)
+pkgconf_client_new(pkgconf_error_handler_func_t error_handler, void *error_handler_data, const pkgconf_cross_personality_t *personality)
{
pkgconf_client_t *out = calloc(sizeof(pkgconf_client_t), 1);
- pkgconf_client_init(out, error_handler, error_handler_data);
+ pkgconf_client_init(out, error_handler, error_handler_data, personality);
return out;
}
@@ -324,7 +358,7 @@ pkgconf_trace(const pkgconf_client_t *client, const char *filename, size_t linen
size_t len;
va_list va;
- if (client == NULL)
+ if (client == NULL || client->trace_handler == NULL)
return false;
len = snprintf(errbuf, sizeof errbuf, "%s:" SIZE_FMT_SPECIFIER " [%s]: ", filename, lineno, funcname);