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