mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-10-28 11:25:21 +01:00
pkgconf: determine the default paths dynamically
This automatically computes the correct PKG_CONFIG_PATH with LOCALBASE from the environment (when set) or from the "user.localbase" sysctl, in this order. Reviewed by: des Approved by: des Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D57246
This commit is contained in:
1 parent
cf851111b0
commit
c146f5ae30
2 files changed
+61
-2
No files matched your search
@@ -19,6 +19,12 @@
|
||||
#include <libpkgconf/stdinc.h>
|
||||
#include <libpkgconf/libpkgconf.h>
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
# include <sys/param.h>
|
||||
# include <sys/sysctl.h>
|
||||
# include <err.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* !doc
|
||||
*
|
||||
@@ -89,6 +95,34 @@ build_default_search_path(pkgconf_list_t* dirlist)
|
||||
free(paths);
|
||||
paths = NULL;
|
||||
}
|
||||
#elif defined(__FreeBSD__)
|
||||
pkgconf_buffer_t path1 = PKGCONF_BUFFER_INITIALIZER;
|
||||
pkgconf_buffer_t path2 = PKGCONF_BUFFER_INITIALIZER;
|
||||
char const *localbase;
|
||||
char buf[MAXPATHLEN];
|
||||
size_t len;
|
||||
|
||||
localbase = getenv("LOCALBASE");
|
||||
|
||||
if (localbase == NULL) {
|
||||
len = sizeof(buf);
|
||||
if (sysctlbyname("user.localbase", &buf, &len, NULL, 0) < 0)
|
||||
err(1, "sysctl(user.localbase)");
|
||||
|
||||
localbase = buf;
|
||||
}
|
||||
|
||||
if (!pkgconf_buffer_append(&path1, localbase) ||
|
||||
!pkgconf_buffer_append(&path1, "/libdata/pkgconfig"))
|
||||
err(1, NULL);
|
||||
pkgconf_path_add(pkgconf_buffer_str(&path1), dirlist, false);
|
||||
|
||||
pkgconf_path_add("/usr/libdata/pkgconfig", dirlist, false);
|
||||
|
||||
if (!pkgconf_buffer_append(&path2, localbase) ||
|
||||
!pkgconf_buffer_append(&path2, "/share/pkgconfig"))
|
||||
err(1, NULL);
|
||||
pkgconf_path_add(pkgconf_buffer_str(&path2), dirlist, false);
|
||||
#else
|
||||
pkgconf_path_split(PKG_DEFAULT_PATH, dirlist, false);
|
||||
#endif
|
||||
@@ -324,6 +358,12 @@ pkgconf_cross_personality_find(const char *triplet)
|
||||
#if ! defined(_WIN32) && ! defined(__HAIKU__)
|
||||
const char *envvar;
|
||||
#endif
|
||||
#if defined(__FreeBSD__)
|
||||
pkgconf_buffer_t path = PKGCONF_BUFFER_INITIALIZER;
|
||||
char const *localbase;
|
||||
char buf[MAXPATHLEN];
|
||||
size_t len;
|
||||
#endif
|
||||
|
||||
out = load_personality_with_path(triplet, NULL, false);
|
||||
if (out != NULL)
|
||||
@@ -362,7 +402,28 @@ pkgconf_cross_personality_find(const char *triplet)
|
||||
pkgconf_path_free(&plist);
|
||||
#endif
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
localbase = getenv("LOCALBASE");
|
||||
|
||||
if (localbase == NULL) {
|
||||
len = sizeof(buf);
|
||||
if (sysctlbyname("user.localbase", &buf, &len, NULL, 0) < 0)
|
||||
err(1, "sysctl(user.localbase)");
|
||||
|
||||
localbase = buf;
|
||||
}
|
||||
|
||||
pkgconf_path_add("/usr/share/pkgconfig/personality.d", &plist, true);
|
||||
pkgconf_path_add("/etc/pkgconfig/personality.d", &plist, true);
|
||||
|
||||
if (!pkgconf_buffer_append(&path, localbase) ||
|
||||
!pkgconf_buffer_append(&path,
|
||||
"/etc/pkgconfig/personality.d"))
|
||||
err(1, NULL);
|
||||
pkgconf_path_add(pkgconf_buffer_str(&path), &plist, true);
|
||||
#else
|
||||
pkgconf_path_split(PERSONALITY_PATH, &plist, true);
|
||||
#endif
|
||||
|
||||
PKGCONF_FOREACH_LIST_ENTRY(plist.head, n)
|
||||
{
|
||||
|
||||
@@ -39,8 +39,6 @@ INCS+= libpkgconf-api.h
|
||||
|
||||
WARNS?= 3
|
||||
|
||||
CFLAGS+= -DPERSONALITY_PATH=\"/usr/share/pkgconfig/personality.d:/etc/pkgconfig/personality.d:${LOCALBASE:U/usr/local}/etc/pkgconfig/personality.d\"
|
||||
CFLAGS+= -DPKG_DEFAULT_PATH=\"${LOCALBASE:U/usr/local}/libdata/pkgconfig:/usr/libdata/pkgconfig:${LOCALBASE:U/usr/local}/share/pkgconfig\"
|
||||
CFLAGS+= -DSYSTEM_INCLUDEDIR=\"/usr/include\"
|
||||
CFLAGS+= -DSYSTEM_LIBDIR=\"/usr/lib\"
|
||||
CFLAGS+= -I${SRCTOP}/lib/libpkgconf -I${PKGCONFDIR}
|
||||
|
||||
Reference in new issue
Block a user