1# =========================================================================== 2# http://www.gnu.org/software/autoconf-archive/ax_cflags_sun_option.html 3# =========================================================================== 4# 5# SYNOPSIS 6# 7# AX_CFLAGS_SUN_OPTION (optionflag [,[shellvar][,[A][,[NA]]]) 8# 9# DESCRIPTION 10# 11# AX_CFLAGS_SUN_OPTION(+xtreme) would show a message as like "checking 12# CFLAGS for sun/cc +xtreme ... yes" and adds the optionflag to CFLAGS if 13# it is understood. You can override the shellvar-default of CFLAGS of 14# course. The order of arguments stems from the explicit macros like 15# AX_CFLAGS_WARN_ALL. 16# 17# The cousin AX_CXXFLAGS_SUN_OPTION would check for an option to add to 18# CXXFLAGS - and it uses the autoconf setup for C++ instead of C (since it 19# is possible to use different compilers for C and C++). 20# 21# The macro is a lot simpler than any special AX_CFLAGS_* macro (or 22# ax_cxx_rtti.m4 macro) but allows to check for arbitrary options. 23# However, if you use this macro in a few places, it would be great if you 24# would make up a new function-macro and submit it to the ac-archive. 25# 26# - $1 option-to-check-for : required ("-option" as non-value) 27# - $2 shell-variable-to-add-to : CFLAGS (or CXXFLAGS in the other case) 28# - $3 action-if-found : add value to shellvariable 29# - $4 action-if-not-found : nothing 30# 31# note: in earlier versions, $1-$2 were swapped. We try to detect the 32# situation and accept a $2=~/-/ as being the old option-to-check-for. 33# 34# see also: AX_CFLAGS_GCC_OPTION for the widely used original variant. 35# 36# LICENSE 37# 38# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de> 39# 40# This program is free software; you can redistribute it and/or modify it 41# under the terms of the GNU General Public License as published by the 42# Free Software Foundation; either version 2 of the License, or (at your 43# option) any later version. 44# 45# This program is distributed in the hope that it will be useful, but 46# WITHOUT ANY WARRANTY; without even the implied warranty of 47# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 48# Public License for more details. 49# 50# You should have received a copy of the GNU General Public License along 51# with this program. If not, see <http://www.gnu.org/licenses/>. 52# 53# As a special exception, the respective Autoconf Macro's copyright owner 54# gives unlimited permission to copy, distribute and modify the configure 55# scripts that are the output of Autoconf when processing the Macro. You 56# need not follow the terms of the GNU General Public License when using 57# or distributing such scripts, even though portions of the text of the 58# Macro appear in them. The GNU General Public License (GPL) does govern 59# all other use of the material that constitutes the Autoconf Macro. 60# 61# This special exception to the GPL applies to versions of the Autoconf 62# Macro released by the Autoconf Archive. When you make and distribute a 63# modified version of the Autoconf Macro, you may extend this special 64# exception to the GPL to apply to your modified version as well. 65 66#serial 7 67 68AC_DEFUN([AX_CFLAGS_SUN_OPTION_OLD], [dnl 69AS_VAR_PUSHDEF([FLAGS],[CFLAGS])dnl 70AS_VAR_PUSHDEF([VAR],[ax_cv_cflags_sun_option_$2])dnl 71AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for sun/cc m4_ifval($2,$2,-option)], 72VAR,[AS_VAR_SET([VAR],["no, unknown"]) 73 AC_LANG_SAVE 74 AC_LANG_C 75 ac_save_[]FLAGS="$[]FLAGS" 76for ac_arg dnl 77in "+xstrconst -Xc % m4_ifval($2,$2,-option)" dnl Solaris C 78 # 79do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` 80 AC_TRY_COMPILE([],[return 0;], 81 [AS_VAR_SET([VAR],[`echo $ac_arg | sed -e 's,.*% *,,'`]); break]) 82done 83 FLAGS="$ac_save_[]FLAGS" 84 AC_LANG_RESTORE 85]) 86m4_ifdef([AS_VAR_COPY],[AS_VAR_COPY([var],[VAR])],[var=AS_VAR_GET([VAR])]) 87case ".$var" in 88 .ok|.ok,*) m4_ifvaln($3,$3) ;; 89 .|.no|.no,*) m4_ifvaln($4,$4) ;; 90 *) m4_ifvaln($3,$3,[ 91 if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $var " 2>&1 >/dev/null 92 then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $var]) 93 else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $var"]) 94 m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $var" 95 fi ]) ;; 96esac 97AS_VAR_POPDEF([VAR])dnl 98AS_VAR_POPDEF([FLAGS])dnl 99]) 100 101 102dnl the only difference - the LANG selection... and the default FLAGS 103 104AC_DEFUN([AX_CXXFLAGS_SUN_OPTION_OLD], [dnl 105AS_VAR_PUSHDEF([FLAGS],[CXXFLAGS])dnl 106AS_VAR_PUSHDEF([VAR],[ax_cv_cxxflags_sun_option_$2])dnl 107AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for sun/cc m4_ifval($2,$2,-option)], 108VAR,[AS_VAR_SET([VAR],["no, unknown"]) 109 AC_LANG_SAVE 110 AC_LANG_CPLUSPLUS 111 ac_save_[]FLAGS="$[]FLAGS" 112for ac_arg dnl 113in "+xstrconst -Xc % m4_ifval($2,$2,-option)" dnl Solaris C 114 # 115do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` 116 AC_TRY_COMPILE([],[return 0;], 117 [AS_VAR_SET([VAR],[`echo $ac_arg | sed -e 's,.*% *,,'`]); break]) 118done 119 FLAGS="$ac_save_[]FLAGS" 120 AC_LANG_RESTORE 121]) 122m4_ifdef([AS_VAR_COPY],[AS_VAR_COPY([var],[VAR])],[var=AS_VAR_GET([VAR])]) 123case ".$var" in 124 .ok|.ok,*) m4_ifvaln($3,$3) ;; 125 .|.no|.no,*) m4_ifvaln($4,$4) ;; 126 *) m4_ifvaln($3,$3,[ 127 if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $var " 2>&1 >/dev/null 128 then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $var]) 129 else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $var"]) 130 m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $var" 131 fi ]) ;; 132esac 133AS_VAR_POPDEF([VAR])dnl 134AS_VAR_POPDEF([FLAGS])dnl 135]) 136 137dnl ----------------------------------------------------------------------- 138 139AC_DEFUN([AX_CFLAGS_SUN_OPTION_NEW], [dnl 140AS_VAR_PUSHDEF([FLAGS],[CFLAGS])dnl 141AS_VAR_PUSHDEF([VAR],[ax_cv_cflags_sun_option_$1])dnl 142AC_CACHE_CHECK([m4_ifval($2,$2,FLAGS) for sun/cc m4_ifval($1,$1,-option)], 143VAR,[AS_VAR_SET([VAR],["no, unknown"]) 144 AC_LANG_SAVE 145 AC_LANG_C 146 ac_save_[]FLAGS="$[]FLAGS" 147for ac_arg dnl 148in "+xstrconst -Xc % m4_ifval($1,$1,-option)" dnl Solaris C 149 # 150do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` 151 AC_TRY_COMPILE([],[return 0;], 152 [AS_VAR_SET([VAR],[`echo $ac_arg | sed -e 's,.*% *,,'`]); break]) 153done 154 FLAGS="$ac_save_[]FLAGS" 155 AC_LANG_RESTORE 156]) 157m4_ifdef([AS_VAR_COPY],[AS_VAR_COPY([var],[VAR])],[var=AS_VAR_GET([VAR])]) 158case ".$var" in 159 .ok|.ok,*) m4_ifvaln($3,$3) ;; 160 .|.no|.no,*) m4_ifvaln($4,$4) ;; 161 *) m4_ifvaln($3,$3,[ 162 if echo " $[]m4_ifval($2,$2,FLAGS) " | grep " $var " 2>&1 >/dev/null 163 then AC_RUN_LOG([: m4_ifval($2,$2,FLAGS) does contain $var]) 164 else AC_RUN_LOG([: m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $var"]) 165 m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $var" 166 fi ]) ;; 167esac 168AS_VAR_POPDEF([VAR])dnl 169AS_VAR_POPDEF([FLAGS])dnl 170]) 171 172 173dnl the only difference - the LANG selection... and the default FLAGS 174 175AC_DEFUN([AX_CXXFLAGS_SUN_OPTION_NEW], [dnl 176AS_VAR_PUSHDEF([FLAGS],[CXXFLAGS])dnl 177AS_VAR_PUSHDEF([VAR],[ax_cv_cxxflags_sun_option_$1])dnl 178AC_CACHE_CHECK([m4_ifval($2,$2,FLAGS) for sun/cc m4_ifval($1,$1,-option)], 179VAR,[AS_VAR_SET([VAR],["no, unknown"]) 180 AC_LANG_SAVE 181 AC_LANG_CPLUSPLUS 182 ac_save_[]FLAGS="$[]FLAGS" 183for ac_arg dnl 184in "+xstrconst -Xc % m4_ifval($1,$1,-option)" dnl Solaris C 185 # 186do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` 187 AC_TRY_COMPILE([],[return 0;], 188 [AS_VAR_SET([VAR],[`echo $ac_arg | sed -e 's,.*% *,,'`]); break]) 189done 190 FLAGS="$ac_save_[]FLAGS" 191 AC_LANG_RESTORE 192]) 193m4_ifdef([AS_VAR_COPY],[AS_VAR_COPY([var],[VAR])],[var=AS_VAR_GET([VAR])]) 194case ".$var" in 195 .ok|.ok,*) m4_ifvaln($3,$3) ;; 196 .|.no|.no,*) m4_ifvaln($4,$4) ;; 197 *) m4_ifvaln($3,$3,[ 198 if echo " $[]m4_ifval($2,$2,FLAGS) " | grep " $var " 2>&1 >/dev/null 199 then AC_RUN_LOG([: m4_ifval($2,$2,FLAGS) does contain $var]) 200 else AC_RUN_LOG([: m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $var"]) 201 m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $var" 202 fi ]) ;; 203esac 204AS_VAR_POPDEF([VAR])dnl 205AS_VAR_POPDEF([FLAGS])dnl 206]) 207 208AC_DEFUN([AX_CFLAGS_SUN_OPTION],[ifelse(m4_bregexp([$2],[-]),-1, 209[AX_CFLAGS_SUN_OPTION_NEW($@)],[AX_CFLAGS_SUN_OPTION_OLD($@)])]) 210 211AC_DEFUN([AX_CXXFLAGS_SUN_OPTION],[ifelse(m4_bregexp([$2],[-]),-1, 212[AX_CXXFLAGS_SUN_OPTION_NEW($@)],[AX_CXXFLAGS_SUN_OPTION_OLD($@)])]) 213