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

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