Since glibc 2.28, sys/types.h no longer includes sys/sysmacros.h which
defines the major and minor macros. Some BSDs don't have
sys/sysmacros.h, so sbase has been conditionally including
sys/sysmacros.h on glibc since 99c78763[0].
However, in the upcoming musl release, it too will remove the
sys/sysmacros.h include from sys/types.h[1]. To continue building with
musl, glibc, and on other operating systems, we have a few options:
1. Invert the ifdef by conditionally *omitting* the sysmacros.h
include on systems that don't have it rather than including it only on
glibc. I know this includes at least OpenBSD. Does anyone know of any
others?
2. Add a make variable to control whether sysmacros.h is included.
Users on systems without sysmacros.h will have to modify this variable
in config.mk or the make command-line.
3. Add a configure test to check the availability of sysmacros.h. This
would be the first such configure test in sbase, and I'm sure some of
you would disapprove. Personally, I wouldn't be happy with this option
either, but it does seem to be the only reliable way to automatically
determine whether sysmacros.h needs to be included.
Unfortunately there no longer seems to be any way to write a program
using major/minor that doesn't involve conditional inclusion and/or
configure tests. Right now I'm leaning towards option 2 by adding -D
HAVE_SYSMACROS_H to CFLAGS in config.mk, and guarding the sysmacros.h
include by ifdefs.
If anybody has a nice solution to this problem, please let me know.
[0]
https://git.suckless.org/sbase/commit/99c787631013bacf71c27dcac16d5a55b82be1c2.html
[1]
http://git.musl-libc.org/cgit/musl/commit/?id=a31a30a0076c284133c0f4dfa32b8b37883ac930
Received on Wed Jun 26 2019 - 07:40:05 CEST