Skip to content

Commit

Permalink
Unbreak build on FreeBSD (keepassxreboot#3304)
Browse files Browse the repository at this point in the history
* Unbreak build on FreeBSD

```
In file included from src/core/Alloc.cpp:24:
/usr/include/malloc.h:3:2: error: "<malloc.h> has been replaced by <stdlib.h>"
 ^
src/core/Alloc.cpp:65:28: error: use of undeclared identifier 'malloc_usable_size'
    ::operator delete(ptr, malloc_usable_size(ptr));
                           ^
2 errors generated.
```

Non-standard APIs like `malloc_usable_size()` [1] are defined in
`malloc_np.h` on FreeBSD, so use it instead of `malloc.h` there.

[1] https://man.freebsd.org/jemalloc(3)

* Allow Browser HostInstaller to work on FreeBSD and other OS's

* Drop custom GNUInstallDirs cmake module and use cmake's own module

It seems to be an outdated version and cmake generally provides it
itself, so there should be no need for keepassxc to provide its own
custom version.

On FreeBSD this fixes the issue that man pages were installed into
the wrong directory, i.e., `/usr/local/share/man` vs `/usr/local/man`
as per FreeBSD's current packaging policy.

Signed-off-by: Tobias Kortkamp <[email protected]>
  • Loading branch information
Tobias Kortkamp authored and droidmonkey committed Jun 22, 2019
1 parent 07da5de commit ef3c2da
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 196 deletions.
188 changes: 0 additions & 188 deletions cmake/GNUInstallDirs.cmake

This file was deleted.

14 changes: 7 additions & 7 deletions src/browser/HostInstaller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,6 @@ HostInstaller::HostInstaller()
, TARGET_DIR_VIVALDI("/Library/Application Support/Vivaldi/NativeMessagingHosts")
, TARGET_DIR_TOR_BROWSER("/Library/Application Support/TorBrowser-Data/Browser/Mozilla/NativeMessagingHosts")
, TARGET_DIR_BRAVE("/Library/Application Support/BraveSoftware/Brave-Browser/NativeMessagingHosts")
#elif defined(Q_OS_LINUX)
, TARGET_DIR_CHROME("/.config/google-chrome/NativeMessagingHosts")
, TARGET_DIR_CHROMIUM("/.config/chromium/NativeMessagingHosts")
, TARGET_DIR_FIREFOX("/.mozilla/native-messaging-hosts")
, TARGET_DIR_VIVALDI("/.config/vivaldi/NativeMessagingHosts")
, TARGET_DIR_TOR_BROWSER("/.tor-browser/app/Browser/TorBrowser/Data/Browser/.mozilla/native-messaging-hosts")
, TARGET_DIR_BRAVE("/.config/BraveSoftware/Brave-Browser/NativeMessagingHosts")
#elif defined(Q_OS_WIN)
// clang-format off
, TARGET_DIR_CHROME("HKEY_CURRENT_USER\\Software\\Google\\Chrome\\NativeMessagingHosts\\org.keepassxc.keepassxc_browser")
Expand All @@ -56,6 +49,13 @@ HostInstaller::HostInstaller()
, TARGET_DIR_VIVALDI(TARGET_DIR_CHROME)
, TARGET_DIR_TOR_BROWSER(TARGET_DIR_FIREFOX)
, TARGET_DIR_BRAVE(TARGET_DIR_CHROME)
#else
, TARGET_DIR_CHROME("/.config/google-chrome/NativeMessagingHosts")
, TARGET_DIR_CHROMIUM("/.config/chromium/NativeMessagingHosts")
, TARGET_DIR_FIREFOX("/.mozilla/native-messaging-hosts")
, TARGET_DIR_VIVALDI("/.config/vivaldi/NativeMessagingHosts")
, TARGET_DIR_TOR_BROWSER("/.tor-browser/app/Browser/TorBrowser/Data/Browser/.mozilla/native-messaging-hosts")
, TARGET_DIR_BRAVE("/.config/BraveSoftware/Brave-Browser/NativeMessagingHosts")
#endif
{
}
Expand Down
4 changes: 3 additions & 1 deletion src/core/Alloc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
#include <QtGlobal>
#include <cstdint>
#include <sodium.h>
#ifdef Q_OS_MACOS
#if defined(Q_OS_MACOS)
#include <malloc/malloc.h>
#elif defined(Q_OS_FREEBSD)
#include <malloc_np.h>
#else
#include <malloc.h>
#endif
Expand Down

0 comments on commit ef3c2da

Please sign in to comment.