1 1.1 riastrad # =========================================================================== 2 1.1 riastrad # http://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html 3 1.1 riastrad # =========================================================================== 4 1.1 riastrad # 5 1.1 riastrad # SYNOPSIS 6 1.1 riastrad # 7 1.1 riastrad # AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS]) 8 1.1 riastrad # 9 1.1 riastrad # DESCRIPTION 10 1.1 riastrad # 11 1.1 riastrad # Check whether the given FLAG works with the current language's compiler 12 1.1 riastrad # or gives an error. (Warnings, however, are ignored) 13 1.1 riastrad # 14 1.1 riastrad # ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on 15 1.1 riastrad # success/failure. 16 1.1 riastrad # 17 1.1 riastrad # If EXTRA-FLAGS is defined, it is added to the current language's default 18 1.1 riastrad # flags (e.g. CFLAGS) when the check is done. The check is thus made with 19 1.1 riastrad # the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to 20 1.1 riastrad # force the compiler to issue an error when a bad flag is given. 21 1.1 riastrad # 22 1.1 riastrad # INPUT gives an alternative input source to AC_COMPILE_IFELSE. 23 1.1 riastrad # 24 1.1 riastrad # NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this 25 1.1 riastrad # macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG. 26 1.1 riastrad # 27 1.1 riastrad # LICENSE 28 1.1 riastrad # 29 1.1 riastrad # Copyright (c) 2008 Guido U. Draheim <guidod (a] gmx.de> 30 1.1 riastrad # Copyright (c) 2011 Maarten Bosmans <mkbosmans (a] gmail.com> 31 1.1 riastrad # 32 1.1 riastrad # This program is free software: you can redistribute it and/or modify it 33 1.1 riastrad # under the terms of the GNU General Public License as published by the 34 1.1 riastrad # Free Software Foundation, either version 3 of the License, or (at your 35 1.1 riastrad # option) any later version. 36 1.1 riastrad # 37 1.1 riastrad # This program is distributed in the hope that it will be useful, but 38 1.1 riastrad # WITHOUT ANY WARRANTY; without even the implied warranty of 39 1.1 riastrad # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 40 1.1 riastrad # Public License for more details. 41 1.1 riastrad # 42 1.1 riastrad # You should have received a copy of the GNU General Public License along 43 1.1 riastrad # with this program. If not, see <https://www.gnu.org/licenses/>. 44 1.1 riastrad # 45 1.1 riastrad # As a special exception, the respective Autoconf Macro's copyright owner 46 1.1 riastrad # gives unlimited permission to copy, distribute and modify the configure 47 1.1 riastrad # scripts that are the output of Autoconf when processing the Macro. You 48 1.1 riastrad # need not follow the terms of the GNU General Public License when using 49 1.1 riastrad # or distributing such scripts, even though portions of the text of the 50 1.1 riastrad # Macro appear in them. The GNU General Public License (GPL) does govern 51 1.1 riastrad # all other use of the material that constitutes the Autoconf Macro. 52 1.1 riastrad # 53 1.1 riastrad # This special exception to the GPL applies to versions of the Autoconf 54 1.1 riastrad # Macro released by the Autoconf Archive. When you make and distribute a 55 1.1 riastrad # modified version of the Autoconf Macro, you may extend this special 56 1.1 riastrad # exception to the GPL to apply to your modified version as well. 57 1.1 riastrad 58 1.1 riastrad #serial 5 59 1.1 riastrad 60 1.1 riastrad AC_DEFUN([AX_CHECK_COMPILE_FLAG], 61 1.1 riastrad [AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF 62 1.1 riastrad AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl 63 1.1 riastrad AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [ 64 1.1 riastrad ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS 65 1.1 riastrad _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1" 66 1.1 riastrad AC_TRY_LINK([#include <time.h>], 67 1.1 riastrad [time_t x; int fodder = 0; if (fodder > -1000 && time(&x)) return (int) x], 68 1.1 riastrad [AS_VAR_SET(CACHEVAR,[yes])], 69 1.1 riastrad [AS_VAR_SET(CACHEVAR,[no])]) 70 1.1 riastrad _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags]) 71 1.1 riastrad AS_VAR_IF(CACHEVAR,yes, 72 1.1 riastrad [m4_default([$2], :)], 73 1.1 riastrad [m4_default([$3], :)]) 74 1.1 riastrad AS_VAR_POPDEF([CACHEVAR])dnl 75 1.1 riastrad ])dnl AX_CHECK_COMPILE_FLAGS 76