Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
Fix mg building on darwin by changing to new upstream #85627
For context, this is for the issue #71136.
This PR now sets the upstream to https://github.com/ibara/mg. For context I will leave the original comment (which patched the original upstream using patches from https://github.com/ibara/mg which apply missing header files on darwin) below.
I am not happy with this at all. It avoids using libbsd at all on darwin because there are conflicting header files, particularly the header string.h.
Ideally that would be the thing to fix upstream. But in the meantime, this patch should do the trick. This is taken from https://github.com/ibara/mg and the license of the patch is the same as
The patch declares a header file
From the OpenBSD source tree is
Now, the makefile GNUMakefile will not link against
I would really appreciate testing on NixOS and other Linux distributions!
This applies to the same version in 19.09 and nixpkgs-unstable.
Motivation for this change
This package is not marked as broken, but it is on macOS. It is a generally useful small emacs-like editor. The package in nixpkgs is also quite old, so it makes sense to update it to the most recent release from the upstream source repository.
I am not happy with this at all. It avoids using libbsd at all on darwin because there are conflicting header files, particularly the header string.h. Ideally that would be the thing to fix. But in the meantime, this patch should do the trick. It declares a header file apple.h, which files include if target is darwin (checks for presence of __APPLE__). This header file also references the three source files futimens.c, reallocarray.c and strtonum.c. The former and latter are from https://github.com/ibara/mg which is another portable fork, but building against more platforms. From the OpenBSD source tree is _null.h and tree.h. There is a check so that if __APPLE__ is present then it will include them from this source tree. Now,the makefile GNUMakefile will not link against libbsd on darwin, by checking the output of uname in much the same way as it did already for FreeBSD.
As per reasonable suggestion, instead of extensively patching the hboetes version of mg to work on MacOS using bits from ibara's mg, just set upstream to ibara's mg. This also removes the dependency on libbsd, although I'm not sure if this is a good or bad thing.