Home | History | Annotate | Line # | Download | only in m4
      1  1.1  riastrad # ===========================================================================
      2  1.1  riastrad #     https://www.gnu.org/software/autoconf-archive/ax_check_define.html
      3  1.1  riastrad # ===========================================================================
      4  1.1  riastrad #
      5  1.1  riastrad # SYNOPSIS
      6  1.1  riastrad #
      7  1.1  riastrad #   AC_CHECK_DEFINE([symbol], [ACTION-IF-FOUND], [ACTION-IF-NOT])
      8  1.1  riastrad #   AX_CHECK_DEFINE([includes],[symbol], [ACTION-IF-FOUND], [ACTION-IF-NOT])
      9  1.1  riastrad #
     10  1.1  riastrad # DESCRIPTION
     11  1.1  riastrad #
     12  1.1  riastrad #   Complements AC_CHECK_FUNC but it does not check for a function but for a
     13  1.1  riastrad #   define to exist. Consider a usage like:
     14  1.1  riastrad #
     15  1.1  riastrad #    AC_CHECK_DEFINE(__STRICT_ANSI__, CFLAGS="$CFLAGS -D_XOPEN_SOURCE=500")
     16  1.1  riastrad #
     17  1.1  riastrad # LICENSE
     18  1.1  riastrad #
     19  1.1  riastrad #   Copyright (c) 2008 Guido U. Draheim <guidod (a] gmx.de>
     20  1.1  riastrad #
     21  1.1  riastrad #   This program is free software; you can redistribute it and/or modify it
     22  1.1  riastrad #   under the terms of the GNU General Public License as published by the
     23  1.1  riastrad #   Free Software Foundation; either version 3 of the License, or (at your
     24  1.1  riastrad #   option) any later version.
     25  1.1  riastrad #
     26  1.1  riastrad #   This program is distributed in the hope that it will be useful, but
     27  1.1  riastrad #   WITHOUT ANY WARRANTY; without even the implied warranty of
     28  1.1  riastrad #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
     29  1.1  riastrad #   Public License for more details.
     30  1.1  riastrad #
     31  1.1  riastrad #   You should have received a copy of the GNU General Public License along
     32  1.1  riastrad #   with this program. If not, see <https://www.gnu.org/licenses/>.
     33  1.1  riastrad #
     34  1.1  riastrad #   As a special exception, the respective Autoconf Macro's copyright owner
     35  1.1  riastrad #   gives unlimited permission to copy, distribute and modify the configure
     36  1.1  riastrad #   scripts that are the output of Autoconf when processing the Macro. You
     37  1.1  riastrad #   need not follow the terms of the GNU General Public License when using
     38  1.1  riastrad #   or distributing such scripts, even though portions of the text of the
     39  1.1  riastrad #   Macro appear in them. The GNU General Public License (GPL) does govern
     40  1.1  riastrad #   all other use of the material that constitutes the Autoconf Macro.
     41  1.1  riastrad #
     42  1.1  riastrad #   This special exception to the GPL applies to versions of the Autoconf
     43  1.1  riastrad #   Macro released by the Autoconf Archive. When you make and distribute a
     44  1.1  riastrad #   modified version of the Autoconf Macro, you may extend this special
     45  1.1  riastrad #   exception to the GPL to apply to your modified version as well.
     46  1.1  riastrad 
     47  1.1  riastrad #serial 9
     48  1.1  riastrad 
     49  1.1  riastrad AU_ALIAS([AC_CHECK_DEFINED], [AC_CHECK_DEFINE])
     50  1.1  riastrad AC_DEFUN([AC_CHECK_DEFINE],[
     51  1.1  riastrad AS_VAR_PUSHDEF([ac_var],[ac_cv_defined_$1])dnl
     52  1.1  riastrad AC_CACHE_CHECK([for $1 defined], ac_var,
     53  1.1  riastrad AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
     54  1.1  riastrad   #ifdef $1
     55  1.1  riastrad   int ok;
     56  1.1  riastrad   #else
     57  1.1  riastrad   choke me
     58  1.1  riastrad   #endif
     59  1.1  riastrad ]])],[AS_VAR_SET(ac_var, yes)],[AS_VAR_SET(ac_var, no)]))
     60  1.1  riastrad AS_IF([test AS_VAR_GET(ac_var) != "no"], [$2], [$3])dnl
     61  1.1  riastrad AS_VAR_POPDEF([ac_var])dnl
     62  1.1  riastrad ])
     63  1.1  riastrad 
     64  1.1  riastrad AU_ALIAS([AX_CHECK_DEFINED], [AX_CHECK_DEFINE])
     65  1.1  riastrad AC_DEFUN([AX_CHECK_DEFINE],[
     66  1.1  riastrad AS_VAR_PUSHDEF([ac_var],[ac_cv_defined_$2_$1])dnl
     67  1.1  riastrad AC_CACHE_CHECK([for $2 defined in $1], ac_var,
     68  1.1  riastrad AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <$1>]], [[
     69  1.1  riastrad   #ifdef $2
     70  1.1  riastrad   int ok;
     71  1.1  riastrad   #else
     72  1.1  riastrad   choke me
     73  1.1  riastrad   #endif
     74  1.1  riastrad ]])],[AS_VAR_SET(ac_var, yes)],[AS_VAR_SET(ac_var, no)]))
     75  1.1  riastrad AS_IF([test AS_VAR_GET(ac_var) != "no"], [$3], [$4])dnl
     76  1.1  riastrad AS_VAR_POPDEF([ac_var])dnl
     77  1.1  riastrad ])
     78  1.1  riastrad 
     79  1.1  riastrad AC_DEFUN([AX_CHECK_FUNC],
     80  1.1  riastrad [AS_VAR_PUSHDEF([ac_var], [ac_cv_func_$2])dnl
     81  1.1  riastrad AC_CACHE_CHECK([for $2], ac_var,
     82  1.1  riastrad dnl AC_LANG_FUNC_LINK_TRY
     83  1.1  riastrad [AC_LINK_IFELSE([AC_LANG_PROGRAM([$1
     84  1.1  riastrad                 #undef $2
     85  1.1  riastrad                 char $2 ();],[
     86  1.1  riastrad                 char (*f) () = $2;
     87  1.1  riastrad                 return f != $2; ])],
     88  1.1  riastrad                 [AS_VAR_SET(ac_var, yes)],
     89  1.1  riastrad                 [AS_VAR_SET(ac_var, no)])])
     90  1.1  riastrad AS_IF([test AS_VAR_GET(ac_var) = yes], [$3], [$4])dnl
     91  1.1  riastrad AS_VAR_POPDEF([ac_var])dnl
     92  1.1  riastrad ])# AC_CHECK_FUNC
     93