From 2d2e0ddc6d83eee97ca7dec38cbf24ddbc724e44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 9 Oct 2023 13:28:30 +0800 Subject: [PATCH] Libc (FreeBSD): detect FBSD version --- CMakeLists.txt | 9 ++++++++- src/detection/libc/libc_bsd.c | 13 +++++++++++++ src/detection/libc/libc_nosupport.c | 9 --------- 3 files changed, 21 insertions(+), 10 deletions(-) create mode 100644 src/detection/libc/libc_bsd.c delete mode 100644 src/detection/libc/libc_nosupport.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 94cbd5ae5..6be4f1535 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -495,7 +495,7 @@ elseif(BSD) src/detection/host/host_bsd.c src/detection/lm/lm_linux.c src/detection/icons/icons_linux.c - src/detection/libc/libc_nosupport.c + src/detection/libc/libc_bsd.c src/detection/localip/localip_linux.c src/detection/gamepad/gamepad_bsd.c src/detection/media/media_linux.c @@ -677,6 +677,13 @@ if(APPLE AND EXISTS "/usr/bin/otool") target_compile_definitions(libfastfetch PUBLIC FF_LIBSYSTEM_VERSION="${CMAKE_MATCH_1}") endif() endif() +if(BSD AND EXISTS "/usr/local/bin/objdump") + execute_process(COMMAND /bin/sh -c "/usr/local/bin/objdump -T /lib/libc.so.* | grep 'FBSD_[^ )]*' -o | sort -Vru | head -1" + OUTPUT_VARIABLE OBJDUMP_T_RESULT) + if("${OBJDUMP_T_RESULT}" MATCHES "FBSD_([0-9]+\\.[0-9]+)") + target_compile_definitions(libfastfetch PUBLIC FF_FBSD_VERSION="${CMAKE_MATCH_1}") + endif() +endif() target_compile_definitions(libfastfetch PUBLIC _GNU_SOURCE _XOPEN_SOURCE __STDC_WANT_LIB_EXT1__=1) if(WIN32) diff --git a/src/detection/libc/libc_bsd.c b/src/detection/libc/libc_bsd.c new file mode 100644 index 000000000..0b6ee4943 --- /dev/null +++ b/src/detection/libc/libc_bsd.c @@ -0,0 +1,13 @@ +#include "libc.h" + +const char* ffDetectLibc(FFLibcResult* result) +{ + result->name = "FBSD"; + +#ifdef FF_FBSD_VERSION + result->version = FF_FBSD_VERSION; +#else + result->version = NULL; +#endif + return NULL; +} diff --git a/src/detection/libc/libc_nosupport.c b/src/detection/libc/libc_nosupport.c deleted file mode 100644 index 0c6a968a3..000000000 --- a/src/detection/libc/libc_nosupport.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "libc.h" - -#define FF_STR_INDIR(x) #x -#define FF_STR(x) FF_STR_INDIR(x) - -const char* ffDetectLibc(FF_MAYBE_UNUSED FFLibcResult* result) -{ - return "Not supported on this platform"; -}