Skip to content

Commit

Permalink
Merge pull request #19 from Inokinoki/improve-freebsd-build
Browse files Browse the repository at this point in the history
Improve build on FreeBSD
  • Loading branch information
Inokinoki authored Nov 11, 2024
2 parents d4d79b4 + 09bc89a commit 32003ed
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
18 changes: 17 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,16 @@ target_compile_definitions(QEFI PRIVATE QEFI_LIBRARY)

find_package(PkgConfig)
if(PkgConfig_FOUND)
pkg_check_modules(EFIVAR efivar)
pkg_check_modules(EFIVAR efivar>=0.15)
if(NOT DEFINED EFIVAR_FOUND)
# Find and link efivar<0.15: no mode
pkg_check_modules(EFIVAR efivar)
if(EFIVAR_FOUND)
# Consider it as an old lib (without mode and return non-zero)
# TODO(Inoki): to check https://github.com/rhboot/efivar/commit/7bd2e309aeec210509d215c803a762725591ccc7
add_definitions(-DEFIVAR_WITHOUT_MODE)
endif()
endif()
endif()

if(APP_DATA_DUMMY_BACKEND)
Expand All @@ -58,6 +67,13 @@ if(USE_EFIVAR_OLD_API)
add_definitions(-DEFIVAR_OLD_API)
endif()

if(PATCH_FREEBSD_EFIVAR)
# Patch efivar 0.15 build for FreeBSD
# TODO(Inoki): check 0.15 build for FreeBSD
add_definitions(-DEFIVAR_FREEBSD_PATCH)
target_link_libraries(QEFI PRIVATE geom)
endif()

install(
TARGETS QEFI
EXPORT QEFITargets
Expand Down
8 changes: 6 additions & 2 deletions qefi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,10 @@ extern "C" {
#include <efivar.h>
#endif
#include <unistd.h>

#ifdef EFIVAR_FREEBSD_PATCH
efi_guid_t efi_guid_zero = {0};
#endif
}

bool qefi_is_available()
Expand Down Expand Up @@ -822,7 +826,7 @@ void qefi_set_variable_uint16(QUuid uuid, QString name, quint16 value)
*((uint16_t *)buffer) = qToLittleEndian<quint16>(value);
return_code = efi_set_variable(guid, c_name, buffer, 2,
default_write_attribute
#ifndef EFIVAR_OLD_API
#ifndef EFIVAR_WITHOUT_MODE
, 0644
#endif
);
Expand All @@ -848,7 +852,7 @@ void qefi_set_variable(QUuid uuid, QString name, QByteArray value)

return_code = efi_set_variable(guid, c_name, (uint8_t *)value.data(), value.size(),
default_write_attribute
#ifndef EFIVAR_OLD_API
#ifndef EFIVAR_WITHOUT_MODE
, 0644
#endif
);
Expand Down

0 comments on commit 32003ed

Please sign in to comment.