Skip to content

Commit 2d2e0dd

Browse files
committed
Libc (FreeBSD): detect FBSD version
1 parent 430da15 commit 2d2e0dd

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ elseif(BSD)
495495
src/detection/host/host_bsd.c
496496
src/detection/lm/lm_linux.c
497497
src/detection/icons/icons_linux.c
498-
src/detection/libc/libc_nosupport.c
498+
src/detection/libc/libc_bsd.c
499499
src/detection/localip/localip_linux.c
500500
src/detection/gamepad/gamepad_bsd.c
501501
src/detection/media/media_linux.c
@@ -677,6 +677,13 @@ if(APPLE AND EXISTS "/usr/bin/otool")
677677
target_compile_definitions(libfastfetch PUBLIC FF_LIBSYSTEM_VERSION="${CMAKE_MATCH_1}")
678678
endif()
679679
endif()
680+
if(BSD AND EXISTS "/usr/local/bin/objdump")
681+
execute_process(COMMAND /bin/sh -c "/usr/local/bin/objdump -T /lib/libc.so.* | grep 'FBSD_[^ )]*' -o | sort -Vru | head -1"
682+
OUTPUT_VARIABLE OBJDUMP_T_RESULT)
683+
if("${OBJDUMP_T_RESULT}" MATCHES "FBSD_([0-9]+\\.[0-9]+)")
684+
target_compile_definitions(libfastfetch PUBLIC FF_FBSD_VERSION="${CMAKE_MATCH_1}")
685+
endif()
686+
endif()
680687

681688
target_compile_definitions(libfastfetch PUBLIC _GNU_SOURCE _XOPEN_SOURCE __STDC_WANT_LIB_EXT1__=1)
682689
if(WIN32)

src/detection/libc/libc_bsd.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include "libc.h"
2+
3+
const char* ffDetectLibc(FFLibcResult* result)
4+
{
5+
result->name = "FBSD";
6+
7+
#ifdef FF_FBSD_VERSION
8+
result->version = FF_FBSD_VERSION;
9+
#else
10+
result->version = NULL;
11+
#endif
12+
return NULL;
13+
}

src/detection/libc/libc_nosupport.c

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)