Blame gnulib/m4/warn-on-use.m4

Packit Service 51e54d
# warn-on-use.m4 serial 5
Packit Service 51e54d
dnl Copyright (C) 2010-2014 Free Software Foundation, Inc.
Packit Service 51e54d
dnl This file is free software; the Free Software Foundation
Packit Service 51e54d
dnl gives unlimited permission to copy and/or distribute it,
Packit Service 51e54d
dnl with or without modifications, as long as this notice is preserved.
Packit Service 51e54d
Packit Service 51e54d
# gl_WARN_ON_USE_PREPARE(INCLUDES, NAMES)
Packit Service 51e54d
# ---------------------------------------
Packit Service 51e54d
# For each whitespace-separated element in the list of NAMES, define
Packit Service 51e54d
# HAVE_RAW_DECL_name if the function has a declaration among INCLUDES
Packit Service 51e54d
# even after being undefined as a macro.
Packit Service 51e54d
#
Packit Service 51e54d
# See warn-on-use.h for some hints on how to poison function names, as
Packit Service 51e54d
# well as ideas on poisoning global variables and macros.  NAMES may
Packit Service 51e54d
# include global variables, but remember that only functions work with
Packit Service 51e54d
# _GL_WARN_ON_USE.  Typically, INCLUDES only needs to list a single
Packit Service 51e54d
# header, but if the replacement header pulls in other headers because
Packit Service 51e54d
# some systems declare functions in the wrong header, then INCLUDES
Packit Service 51e54d
# should do likewise.
Packit Service 51e54d
#
Packit Service 51e54d
# It is generally safe to assume declarations for functions declared
Packit Service 51e54d
# in the intersection of C89 and C11 (such as printf) without
Packit Service 51e54d
# needing gl_WARN_ON_USE_PREPARE.
Packit Service 51e54d
AC_DEFUN([gl_WARN_ON_USE_PREPARE],
Packit Service 51e54d
[
Packit Service 51e54d
  m4_foreach_w([gl_decl], [$2],
Packit Service 51e54d
    [AH_TEMPLATE([HAVE_RAW_DECL_]AS_TR_CPP(m4_defn([gl_decl])),
Packit Service 51e54d
      [Define to 1 if ]m4_defn([gl_decl])[ is declared even after
Packit Service 51e54d
       undefining macros.])])dnl
Packit Service 51e54d
dnl FIXME: gl_Symbol must be used unquoted until we can assume
Packit Service 51e54d
dnl autoconf 2.64 or newer.
Packit Service 51e54d
  for gl_func in m4_flatten([$2]); do
Packit Service 51e54d
    AS_VAR_PUSHDEF([gl_Symbol], [gl_cv_have_raw_decl_$gl_func])dnl
Packit Service 51e54d
    AC_CACHE_CHECK([whether $gl_func is declared without a macro],
Packit Service 51e54d
      gl_Symbol,
Packit Service 51e54d
      [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$1],
Packit Service 51e54d
[@%:@undef $gl_func
Packit Service 51e54d
  (void) $gl_func;])],
Packit Service 51e54d
        [AS_VAR_SET(gl_Symbol, [yes])], [AS_VAR_SET(gl_Symbol, [no])])])
Packit Service 51e54d
    AS_VAR_IF(gl_Symbol, [yes],
Packit Service 51e54d
      [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_RAW_DECL_$gl_func]), [1])
Packit Service 51e54d
       dnl shortcut - if the raw declaration exists, then set a cache
Packit Service 51e54d
       dnl variable to allow skipping any later AC_CHECK_DECL efforts
Packit Service 51e54d
       eval ac_cv_have_decl_$gl_func=yes])
Packit Service 51e54d
    AS_VAR_POPDEF([gl_Symbol])dnl
Packit Service 51e54d
  done
Packit Service 51e54d
])