AC_HEADER_MAJOR: port to glibc 2.25master
commit3e874ae37c97c8a6d19f4ea12f3c66eb3f309f11
authorEric Blake <eblake@redhat.com>
Wed, 14 Sep 2016 13:17:06 +0000 (14 08:17 -0500)
committerEric Blake <eblake@redhat.com>
Thu, 15 Sep 2016 00:37:38 +0000 (14 19:37 -0500)
tree1bb87d63838ea2e6564965e62fd0f6f98d277582
parent565a6dc50cfa01cec2fb4db894026689cdf4970c
AC_HEADER_MAJOR: port to glibc 2.25

glibc 2.25 is deprecating the namespace pollution of <sys/types.h>
injecting major(), minor(), and makedev() into the compilation
environment, with a warning that insists that users include
<sys/sysmacros.h> instead.  However, because the expansion of
AC_HEADER_MAJOR didn't bother checking sys/sysmacros.h until
after probing whether sys/types.h pollutes the namespace, it was
not defining MAJOR_IN_SYSMACROS, with the result that code
compiled with -Werror chokes on the deprecation warnings because
it was not including sysmacros.h.

In addition to fixing autoconf (which only benefits projects
that rebuild configure after this fix is released), we can also
give a hint to distros on how they can populate config.site with
a cache variable to force pre-existing configure scripts without
the updated macro to behave sanely in the presence of glibc 2.25
(the documentation is especially useful since that cache variable
is no longer present in autoconf after this patch).

Note that mingw lacks major/minor/makedev in any of its standard
headers; for that platform, the behavior of this macro is unchanged
(code using the recommended include formula will get a compile error
when trying to use major(), whether before or after this patch); but
for now, it is assumed that programs actually concerned with
creating devices are not worried about portability to mingw.  If
desired, a later patch could tighten AC_HEADER_MAJOR to fail at
configure time if the macros are unavailable in any of the three
system headers, but that semantic change is not worth mixing into
this patch.

* lib/autoconf/headers.m4 (AC_HEADER_MAJOR): Drop check for
major within sys/types.h; it interferes with the need to check
sysmacros.h first.
* doc/autoconf.texi (Particular Headers) <AC_HEADER_MAJOR>: Expand
details on usage, and on workarounds for non-updated projects.

Signed-off-by: Eric Blake <eblake@redhat.com>
doc/autoconf.texi
lib/autoconf/headers.m4