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