Bruno Haible wrote: > Configure outputs when cross-compiling: > > checking for GNU libc compatible malloc... no > checking for GNU libc compatible realloc... no > > Here's a proposed patch for improving the guess for glibc targets. > Again, the question is whether to modify the macro in Autoconf proper. > > > 2012-05-01 Bruno Haible <br...@clisp.org> > > *alloc-gnu, eealloc: Avoid "guessing no" when cross-compiling to glibc. > * m4/malloc.m4 (_gl_FUNC_MALLOC_IF): New macro. > (gl_FUNC_MALLOC_GNU): Invoke it instead of _AC_FUNC_MALLOC_IF. > * m4/realloc.m4 (_gl_FUNC_REALLOC_IF): New macro. > (gl_FUNC_REALLOC_GNU): Invoke it instead of _AC_FUNC_REALLOC_IF. > * m4/calloc.m4 (_AC_FUNC_CALLOC_IF): Require AC_CANONICAL_HOST. When > cross-compiling, choose the first alternative on glibc systems. > * m4/eealloc.m4 (gl_EEMALLOC): Require AC_CANONICAL_HOST. When > cross-compiling, set gl_cv_func_malloc_0_nonnull to 1 on glibc systems. > (gl_EEREALLOC): Require AC_CANONICAL_HOST. When cross-compiling, set > gl_cv_func_realloc_0_nonnull to 1 on glibc systems. > > --- m4/malloc.m4.orig Tue May 1 23:34:29 2012 > +++ m4/malloc.m4 Tue May 1 23:27:22 2012 > @@ -1,9 +1,32 @@ > -# malloc.m4 serial 13 > +# malloc.m4 serial 14 > dnl Copyright (C) 2007, 2009-2012 Free Software Foundation, Inc. > dnl This file is free software; the Free Software Foundation > dnl gives unlimited permission to copy and/or distribute it, > dnl with or without modifications, as long as this notice is preserved. > > +# _gl_FUNC_MALLOC_IF([IF-WORKS], [IF-NOT]) > +# ---------------------------------------- > +# Like _AC_FUNC_MALLOC_IF, defined in Autoconf, with improved > cross-compilation > +# guess. > +AC_DEFUN([_gl_FUNC_MALLOC_IF], > +[ > + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles > + if test $cross_compiling = no; then > + _AC_FUNC_MALLOC_IF([$1], [$2]) > + else > + case "$host_os" in > + # Guess yes on glibc systems. > + *-gnu*) > + $1 > + ;; > + # If we don't know, assume the worst. > + *) > + $2 > + ;; > + esac
This all looks correct. Thanks. However, I would find the above code easier to read if it were written on fewer lines: case "$host_os" in *-gnu*) $1 ;; # Guess yes on glibc systems. *) $2 ;; # If we don't know, assume the worst. esac