view m4/warn-on-use.m4 @ 14894:b22360ddefc4

gnulib-tool: Better isolation between different gnulib-tool invocations. * gnulib-tool: New option --witness-c-macro. (witness_c_macro): New variable. (func_emit_lib_Makefile_am): If --witness-c-macro was specified, let AM_CPPFLAGS define it as a C macro. (func_emit_tests_Makefile_am): Likewise. (func_import): Store witness_c_macro setting in gnulib-cache.m4 and read it from there. * m4/gnulib-common.m4 (gl_MODULE_INDICATOR_CONDITION): Define through m4_define, not AC_DEFUN. (gl_MODULE_INDICATOR_SET_VARIABLE_AUX, gl_MODULE_INDICATOR_SET_VARIABLE_AUX_OR): New macros. (gl_MODULE_INDICATOR_SET_VARIABLE): Use them. * modules/arpa_inet (Makefile.am): Use sed expression s/.../.../, not s|...|...|, to substitute the values of the GNULIB_* module indicator variables. * modules/dirent (Makefile.am): Likewise. * modules/fcntl-h (Makefile.am): Likewise. * modules/iconv-h (Makefile.am): Likewise. * modules/langinfo (Makefile.am): Likewise. * modules/locale (Makefile.am): Likewise. * modules/math (Makefile.am): Likewise. * modules/netdb (Makefile.am): Likewise. * modules/poll-h (Makefile.am): Likewise. * modules/pty (Makefile.am): Likewise. * modules/search (Makefile.am): Likewise. * modules/signal (Makefile.am): Likewise. * modules/spawn (Makefile.am): Likewise. * modules/stdio (Makefile.am): Likewise. * modules/stdlib (Makefile.am): Likewise. * modules/string (Makefile.am): Likewise. * modules/sys_ioctl (Makefile.am): Likewise. * modules/sys_select (Makefile.am): Likewise. * modules/sys_socket (Makefile.am): Likewise. * modules/sys_stat (Makefile.am): Likewise. * modules/sys_times (Makefile.am): Likewise. * modules/sys_utsname (Makefile.am): Likewise. * modules/sys_wait (Makefile.am): Likewise. * modules/termios (Makefile.am): Likewise. * modules/time (Makefile.am): Likewise. * modules/unistd (Makefile.am): Likewise. * modules/wchar (Makefile.am): Likewise.
author Bruno Haible <bruno@clisp.org>
date Wed, 08 Jun 2011 13:23:56 +0200
parents 97fc9a21a8fb
children f10877c6816b
line wrap: on
line source

# warn-on-use.m4 serial 2
dnl Copyright (C) 2010-2011 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_WARN_ON_USE_PREPARE(INCLUDES, NAMES)
# ---------------------------------------
# For each whitespace-separated element in the list of NAMES, define
# HAVE_RAW_DECL_name if the function has a declaration among INCLUDES
# even after being undefined as a macro.
#
# See warn-on-use.h for some hints on how to poison function names, as
# well as ideas on poisoning global variables and macros.  NAMES may
# include global variables, but remember that only functions work with
# _GL_WARN_ON_USE.  Typically, INCLUDES only needs to list a single
# header, but if the replacement header pulls in other headers because
# some systems declare functions in the wrong header, then INCLUDES
# should do likewise.
#
# If you assume C89, then it is generally safe to assume declarations
# for functions declared in that standard (such as gets) without
# needing gl_WARN_ON_USE_PREPARE.
AC_DEFUN([gl_WARN_ON_USE_PREPARE],
[
  m4_foreach_w([gl_decl], [$2],
    [AH_TEMPLATE([HAVE_RAW_DECL_]AS_TR_CPP(m4_defn([gl_decl])),
      [Define to 1 if ]m4_defn([gl_decl])[ is declared even after
       undefining macros.])])dnl
  for gl_func in m4_flatten([$2]); do
    AS_VAR_PUSHDEF([gl_Symbol], [gl_cv_have_raw_decl_$gl_func])dnl
    AC_CACHE_CHECK([whether $gl_func is declared without a macro],
      gl_Symbol,
      [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$1],
[@%:@undef $gl_func
  (void) $gl_func;])],
        [AS_VAR_SET(gl_Symbol, [yes])], [AS_VAR_SET(gl_Symbol, [no])])])
     AS_VAR_IF(gl_Symbol, [yes],
       [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_RAW_DECL_$gl_func]), [1])
       dnl shortcut - if the raw declaration exists, then set a cache
       dnl variable to allow skipping any later AC_CHECK_DECL efforts
       eval ac_cv_have_decl_$gl_func=yes])
    AS_VAR_POPDEF([gl_Symbol])dnl
  done
])