Skip to content

build: adapt to macOS

Zweihorn requested to merge Zweihorn/libbsd-macports:libbsd-macports-001 into main

As a Mac OS X / macOS user I became interested in "explicit_bzero" thus aiming to establish a MacPorts new 'libbsd' port. See my project wiki for further details.

By including this Merge Request (MR) libbsd should build successfully on macOS by help of the patches comprised in this MR and the build was successfully tested on macOS, see the b.m. Pull Request (PR) 19785 at MacPorts and the check results for macos-11, -12, -13 included there. However, note issue #23 (closed) and the failed test case. Additionally, a new Portfile was established accordingly, but such definitons are specific to MacPorts and were not included in this MR.

In the outcome of this MR a subset of BSD utilities to be built on a macOS platform is defined as:

  1. closefrom
  2. dehumanize_number
  3. explicit_bzero
  4. expand_number
  5. flopen
  6. freezero
  7. humanize_number
  8. pidfile
  9. reallocarray
  10. recallocarray
  11. setproctitle
  12. strtoi
  13. strtou
  14. timeconv

Please note the complete set of BSD functions remains even with this MR and will be available to all builds of libbsd on operating systems outside the macOS build as should be appropriate.

This MR solely addresses the build process to allow for a build on macOS and is based on the existing files of the autotools chain. There is no change to the code of any utility. The patches (besides the b.m. workaround) should be reusable and should have no true influence on the build process to other operating systems.

The patch files included from b.m. PR 19785 at MacPorts are:

  • - introducing new need_X flags as applicable for macOS and reordering most of the statements alphabetically to not get lost
  • - making use of a.m. flags to reduce to a subset of utilities and reordering most of the statements alphabetically
  • patch016-src_Makefile.am_libbsd.sym.diff - cleaning the symbol table based on a workaround for macOS kindly provided by the maintainer i.e. @guillem
  • - making use of a.m. flags to reduce tests as applicable and reordering most of the statements alphabetically
  • - combining existing manual pages by making use of a.m. flags to reduce make of manual pages as applicable to macOS and reordering most of the statements alphabetically

The build of the 'include' files was left untouched intentionally.

Re: #19 (comment 2017684)



To the beginning there are the three commits:

  1. "build: add ".DS-Store" to .gitignore" - to avoid poluting the repository with macOS custom attributes
  2. "build: adapt to macOS" - the main content of this MR
  3. "build: adapt to macOS (workaround)" - should be revised accordingly, I presume

Please find further details in the commit messages included.


  • This is my first major contribution and first MR ever to this project.
  • Apparently, all Pipelines failed and I have to ignore this for the moment.
  • I could squash commits later, if this would help the acceptance of this MR.
  • Any help and further advice very welcome.

Looking forward to a new learning experience and the chance for a beneficial collaboration.

Edited by Zweihorn

Merge request reports