Blame m4/warn-on-use.m4

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