diff --git a/CMakeLists.txt b/CMakeLists.txt index d984dd1..32d46b3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) @@ -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 diff --git a/qefi.cpp b/qefi.cpp index f197ef2..9a32e93 100644 --- a/qefi.cpp +++ b/qefi.cpp @@ -686,6 +686,10 @@ extern "C" { #include #endif #include + +#ifdef EFIVAR_FREEBSD_PATCH +efi_guid_t efi_guid_zero = {0}; +#endif } bool qefi_is_available() @@ -822,7 +826,7 @@ void qefi_set_variable_uint16(QUuid uuid, QString name, quint16 value) *((uint16_t *)buffer) = qToLittleEndian(value); return_code = efi_set_variable(guid, c_name, buffer, 2, default_write_attribute -#ifndef EFIVAR_OLD_API +#ifndef EFIVAR_WITHOUT_MODE , 0644 #endif ); @@ -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 );