Re: [PATCH 2/3] Modernize AC_INCLUDES_DEFAULT and friends.

Eric Blake <[email protected]>
Newsgroups gmane.comp.sysutils.autoconf.patches
Organization Red Hat, Inc.
Message-ID <[email protected]>
On 05/30/2013 03:19 PM, Zack Weinberg wrote:
>  * lib/autoconf/headers.m4 (_AC_INCLUDES_DEFAULT_REQUIREMENTS):
>    Include stddef.h, stdlib.h, and string.h unconditionally.
>    Don't include memory.h at all.
>    Don't use AC_HEADER_STDC.
>    Don't check for stddef.h, stdlib.h, string.h, or memory.h.
>    For compatibility, unconditionally define STDC_HEADERS,
>    HAVE_STDLIB_H, and HAVE_STRING_H.
>    (AN_HEADER list): Remove C89 headers, and memory.h from list.
>    (AC_HEADER_STDC): AU_DEFUN as an explicit invocation of
>    _AC_INCLUDES_DEFAULT_REQUIREMENTS.

This still feels fishy; but if the next patch cleans it up, I'm okay.

>    (AC_HEADER_TIME): AU_DEFUN, and define TIME_WITH_SYS_TIME unconditionally
>    as long as sys/time.h is present.
>    (AC_USG, AC_MEMORY_H): Assume existence of string.h.
>  * lib/autoconf/functions.m4 (_AC_FUNC_MALLOC_IF, _AC_FUNC_REALLOC_IF):
>    Don't use AC_HEADER_STDC. Assume stdlib.h exists.
>    (AC_FUNC_MKTIME): Don't use AC_HEADER_TIME.
>    (AC_FUNC_ALLOCA): Assume stdlib.h exists.
>    (_AC_LIBOBJ_FNMATCH): Assume wchar.h and wctype.h exist.
>    (_AC_LIBOBJ_GETLOADAVG): Assume locale.h exists.
>    (AC_FUNC_MMAP): Assume stdlib.h exists.
>  * tests/tools.at: Use AC_WORDS_BIGENDIAN instead of AC_STDC_HEADERS in
>    autoupdate test.
> 
>  * NEWS, doc/autoconf.texi: Document changes. Remove obsolete advice.
> 
> Signed-off-by: Zack Weinberg <[email protected]>
> ---

Thanks again for cleaning this up.  Between this and the proposal for
--rundir, I need to cut a release soon :)

> +come first in your @var{includes}.  For example, @file{net/if.h} may
> +require @file{sys/types.h}, @file{sys/socket.h}, or both, and
> +@code{AC_INCLUDES_DEFAULT} handles @file{sys/types.h} but not
> +@file{sys/socket.h}, so you should check for it like this:
> +
> +@example
> +AC_CHECK_HEADERS([sys/socket.h])
> +AC_CHECK_HEADERS([net/if.h], [], [],
> +[AC_INCLUDES_DEFAULT
> +#ifdef HAVE_SYS_SOCKET_H
> +# include <sys/socket.h>
> +#endif
> +])

Thank you - this is definitely useful.

> +++ b/lib/autoconf/functions.m4

> @@ -1013,8 +1003,7 @@ test $ac_cv_func_memcmp_working = no && AC_LIBOBJ([memcmp])
>  # --------------
>  AN_FUNCTION([mktime], [AC_FUNC_MKTIME])
>  AC_DEFUN([AC_FUNC_MKTIME],
> -[AC_REQUIRE([AC_HEADER_TIME])dnl
> -AC_CHECK_HEADERS_ONCE(sys/time.h unistd.h)
> +[AC_CHECK_HEADERS_ONCE(sys/time.h unistd.h)

As long as you're touching this, add proper quoting to the lines you touch:

AC_CHECK_HEADERS_ONCE([sys/time.h unistd.h])

> +dnl For backward compatibility, provide unconditional AC_DEFINEs of
> +dnl HAVE_STDLIB_H, HAVE_STRING_H, and STDC_HEADERS.
> +AC_DEFINE(HAVE_STDLIB_H, 1,

Again, new code should be a model of proper quoting:

AC_DEFINE([HAVE_STDLIB_H], [1],

> +  [Always define to 1, for backward compatibility.
> +   You can assume <stdlib.h> exists.])
> +AC_DEFINE(HAVE_STRING_H, 1,
> +  [Always define to 1, for backward compatibility.
> +   You can assume <string.h> exists.])
> +AC_DEFINE(STDC_HEADERS, 1,
> +  [Always define to 1, for backward compatibility.
> +   You can assume the C90 standard headers exist.])

and so on

> @@ -601,62 +594,17 @@ fi
>  ])# AC_HEADER_STDBOOL
>  
>  
> -# AC_HEADER_STDC
> +# AU::AC_HEADER_STDC
>  # --------------

The divider is now too short.

> +AU_DEFUN([AC_HEADER_STDC],
> +[
> +# Autoupdate added the following line to ensure that your configure
> +# script's behavior did not change.  It is probably safe to remove.
> +_AC_INCLUDES_DEFAULT_REQUIREMENTS
> +],

I'd still prefer we create and expose a public macro for this purpose,
rather than updating to an _AC_ macro.

>  
> -# AC_HEADER_TIME
> +# AU::AC_HEADER_TIME
>  # --------------

Another too-short divider.

>  
>  # AU::AC_USG
>  # ----------
> -# Define `USG' if string functions are in strings.h.
> +# Define `USG' if string functions are *not* in strings.h.

Have we seriously been documenting it incorrectly for this long?

Looking nice!

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc (application/pgp-signature, 621 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.14 (GNU/Linux)
Comment: Public key at http://people.redhat.com/eblake/eblake.gpg
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBCAAGBQJSMTBxAAoJEKeha0olJ0Nq128H/iwsZxlePC3n5CKWd1vpyyP+
CVEHsEjK8le8+Txxc6wgDzFbGhVz3zMI7l8shgLRhZcv49KkOooaLn1MJMgAUaGO
VMoJgw4xzm/DDU4VHYIB3H390txNcHRqeOxeJ46MES0g0vo4362Juzd8okcCPuef
rb9NVuPnmn651nxvEK2zsRhsPDa8OEKBR5gfFlJnWN1eYs7+D/ESEK4tpLnlcSSH
G0rLQKEbSCdeToA4+Ba/pNS+IV4gIoke99l34rgrgaXTiJnnCtkxGW9cwmM5CBc1
nyu30+1G1ti8rzP/hqAumNSL1tqKfxBs2C4MkrNLlS/DQYQqv7dd/LvtPzo7cF0=
=qum1
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.