Libc (FreeBSD): detect FBSD version

This commit is contained in:
李通洲 2023-10-09 13:28:30 +08:00
parent 430da1578d
commit 2d2e0ddc6d
No known key found for this signature in database
GPG Key ID: 269AD4F5325A22A3
3 changed files with 21 additions and 10 deletions

View File

@ -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)

View File

@ -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;
}

View File

@ -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";
}