bakelite icon indicating copy to clipboard operation
bakelite copied to clipboard

misc: build with macOS

Open roarkanize opened this issue 3 years ago • 3 comments

this pull request makes the changes needed to allow bakelite to build in macOS successfully, namely:

  • introducing a new file endian.h which does the proper macros to supply the expected functions in macOS, or simply includes <endian.h> in other platforms
  • including the <sys/random.h> header on macOS for all the files using getentropy(2)
  • defining pipe2 as a function on macOS for store.c, since it's not supplied by the standard library
  • defining the expected fields to struct stat as macros, since they have different names on macOS

changes have been tested in both Linux (Fedora 35) and macOS (macOS 12.3.1) and it builds, backups and restores successfully in both platforms

(I am aware that defining pipe2 like this can result in race conditions, but it's the only solution, sadly)

roarkanize avatar Apr 03 '22 15:04 roarkanize

Maybe a sort of configure script looking for these specific features would be a better solution instead? I'm currently installing a couple virtual machines to test on other platforms as well, so maybe I could expand the scope of this to encompass more platforms than just macOS

ghost avatar Apr 03 '22 17:04 ghost

A portable implementation for the endian.h macros and for getentropy(2) are still pending, but I was wondering, is it really worth it, considering (nearly) all UNIX-like OSes have them?

ghost avatar Apr 04 '22 15:04 ghost

For getentropy, there is no portable implementation or safe fallback that widely works. What we can easily do though is just declare it ourselves (int getentropy(void*, size_t);) so as not to care if unistd.h didn't declare it. Then, if the system doesn't have it, you need to provide a library giving a safe version via LDFLAGS (but AIUI OSX does have it so that's a non-issue).

richfelker avatar Apr 04 '22 16:04 richfelker