We have recently encountered some build failures with makepkg on macOS: https://github.com/Homebrew/homebrew-core/pull/109029 and I have attached the patch we used to fix them.


There were two problems:


lib/libalpm/diskspace.c fails to build because f_mntonname is undefined in statvfs on macOS and statfs should be used instead.  The usage of statvfs is gated by HAVE_STRUCT_STATVFS_FLAG, but this only checks if the statvfs.h header exists but does not verify if the statvfs struct defines all the members it is expected to have.  We solved this by further gating the usage on the OS not being Darwin, though it may be better to require the OS to be Linux if other Unix variants are not expected to have the right struct in statvfs.h


The second issue we encountered was lib/libalpm/util.c failed to build because MSG_NOSIGNAL is not defined on macOS before Big Sur.  To resolve this we defined at to be 0 if it was not defined.  This may also be helpful if there are other Unix variants that also don’t define this constant.


Please let me know if there are questions about these issues.