fix missing -lnetcdff when netcdf built as shared libraries #8
[WPS-merge.git] / external / jasper-1.900.29 / ac_m4 / m4_ax_cflags_gcc_option.m4
blobca5896277b1cc11e448e47ca4a543c1d37144958
1 dnl @synopsis AX_CFLAGS_GCC_OPTION (optionflag [,[shellvar][,[A][,[NA]]])
2 dnl
3 dnl AX_CFLAGS_GCC_OPTION(-fvomit-frame) would show a message as like
4 dnl "checking CFLAGS for gcc -fvomit-frame ... yes" and adds the
5 dnl optionflag to CFLAGS if it is understood. You can override the
6 dnl shellvar-default of CFLAGS of course. The order of arguments stems
7 dnl from the explicit macros like AX_CFLAGS_WARN_ALL.
8 dnl
9 dnl The cousin AX_CXXFLAGS_GCC_OPTION would check for an option to add
10 dnl to CXXFLAGS - and it uses the autoconf setup for C++ instead of C
11 dnl (since it is possible to use different compilers for C and C++).
12 dnl
13 dnl The macro is a lot simpler than any special AX_CFLAGS_* macro (or
14 dnl ac_cxx_rtti.m4 macro) but allows to check for arbitrary options.
15 dnl However, if you use this macro in a few places, it would be great
16 dnl if you would make up a new function-macro and submit it to the
17 dnl ac-archive.
18 dnl
19 dnl   - $1 option-to-check-for : required ("-option" as non-value)
20 dnl   - $2 shell-variable-to-add-to : CFLAGS (or CXXFLAGS in the other case)
21 dnl   - $3 action-if-found : add value to shellvariable
22 dnl   - $4 action-if-not-found : nothing
23 dnl
24 dnl note: in earlier versions, $1-$2 were swapped. We try to detect the
25 dnl situation and accept a $2=~/-/ as being the old
26 dnl option-to-check-for.
27 dnl
28 dnl also: there are other variants that emerged from the original macro
29 dnl variant which did just test an option to be possibly added.
30 dnl However, some compilers accept an option silently, or possibly for
31 dnl just another option that was not intended. Therefore, we have to do
32 dnl a generic test for a compiler family. For gcc we check "-pedantic"
33 dnl being accepted which is also understood by compilers who just want
34 dnl to be compatible with gcc even when not being made from gcc
35 dnl sources.
36 dnl
37 dnl see also:
38 dnl
39 dnl       AX_CFLAGS_SUN_OPTION               AX_CFLAGS_HPUX_OPTION
40 dnl       AX_CFLAGS_AIX_OPTION               AX_CFLAGS_IRIX_OPTION
41 dnl
42 dnl @category C
43 dnl @author Guido U. Draheim <guidod@gmx.de>
44 dnl @version 2006-12-12
45 dnl @license GPLWithACException
47 AC_DEFUN([AX_CFLAGS_GCC_OPTION_OLD], [dnl
48 AS_VAR_PUSHDEF([FLAGS],[CFLAGS])dnl
49 AS_VAR_PUSHDEF([VAR],[ac_cv_cflags_gcc_option_$2])dnl
50 AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for gcc m4_ifval($2,$2,-option)],
51 VAR,[VAR="no, unknown"
52  AC_LANG_SAVE
53  AC_LANG_C
54  ac_save_[]FLAGS="$[]FLAGS"
55 for ac_arg dnl
56 in "-pedantic -Werror % m4_ifval($2,$2,-option)"  dnl   GCC
57    "-pedantic % m4_ifval($2,$2,-option) %% no, obsolete"  dnl new GCC
58    #
59 do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
60    AC_TRY_COMPILE([],[return 0;],
61    [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
62 done
63  FLAGS="$ac_save_[]FLAGS"
64  AC_LANG_RESTORE
66 case ".$VAR" in
67      .ok|.ok,*) m4_ifvaln($3,$3) ;;
68    .|.no|.no,*) m4_ifvaln($4,$4) ;;
69    *) m4_ifvaln($3,$3,[
70    if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
71    then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR])
72    else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"])
73                       m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"
74    fi ]) ;;
75 esac
76 AS_VAR_POPDEF([VAR])dnl
77 AS_VAR_POPDEF([FLAGS])dnl
81 dnl the only difference - the LANG selection... and the default FLAGS
83 AC_DEFUN([AX_CXXFLAGS_GCC_OPTION_OLD], [dnl
84 AS_VAR_PUSHDEF([FLAGS],[CXXFLAGS])dnl
85 AS_VAR_PUSHDEF([VAR],[ac_cv_cxxflags_gcc_option_$2])dnl
86 AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for gcc m4_ifval($2,$2,-option)],
87 VAR,[VAR="no, unknown"
88  AC_LANG_SAVE
89  AC_LANG_CPLUSPLUS
90  ac_save_[]FLAGS="$[]FLAGS"
91 for ac_arg dnl
92 in "-pedantic -Werror % m4_ifval($2,$2,-option)"  dnl   GCC
93    "-pedantic % m4_ifval($2,$2,-option) %% no, obsolete"  dnl new GCC
94    #
95 do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
96    AC_TRY_COMPILE([],[return 0;],
97    [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
98 done
99  FLAGS="$ac_save_[]FLAGS"
100  AC_LANG_RESTORE
102 case ".$VAR" in
103      .ok|.ok,*) m4_ifvaln($3,$3) ;;
104    .|.no|.no,*) m4_ifvaln($4,$4) ;;
105    *) m4_ifvaln($3,$3,[
106    if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
107    then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR])
108    else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"])
109                       m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"
110    fi ]) ;;
111 esac
112 AS_VAR_POPDEF([VAR])dnl
113 AS_VAR_POPDEF([FLAGS])dnl
116 dnl -------------------------------------------------------------------------
118 AC_DEFUN([AX_CFLAGS_GCC_OPTION_NEW], [dnl
119 AS_VAR_PUSHDEF([FLAGS],[CFLAGS])dnl
120 AS_VAR_PUSHDEF([VAR],[ac_cv_cflags_gcc_option_$1])dnl
121 AC_CACHE_CHECK([m4_ifval($2,$2,FLAGS) for gcc m4_ifval($1,$1,-option)],
122 VAR,[VAR="no, unknown"
123  AC_LANG_SAVE
124  AC_LANG_C
125  ac_save_[]FLAGS="$[]FLAGS"
126 for ac_arg dnl
127 in "-pedantic -Werror % m4_ifval($1,$1,-option)"  dnl   GCC
128    "-pedantic % m4_ifval($1,$1,-option) %% no, obsolete"  dnl new GCC
129    #
130 do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
131    AC_TRY_COMPILE([],[return 0;],
132    [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
133 done
134  FLAGS="$ac_save_[]FLAGS"
135  AC_LANG_RESTORE
137 case ".$VAR" in
138      .ok|.ok,*) m4_ifvaln($3,$3) ;;
139    .|.no|.no,*) m4_ifvaln($4,$4) ;;
140    *) m4_ifvaln($3,$3,[
141    if echo " $[]m4_ifval($2,$2,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
142    then AC_RUN_LOG([: m4_ifval($2,$2,FLAGS) does contain $VAR])
143    else AC_RUN_LOG([: m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR"])
144                       m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR"
145    fi ]) ;;
146 esac
147 AS_VAR_POPDEF([VAR])dnl
148 AS_VAR_POPDEF([FLAGS])dnl
152 dnl the only difference - the LANG selection... and the default FLAGS
154 AC_DEFUN([AX_CXXFLAGS_GCC_OPTION_NEW], [dnl
155 AS_VAR_PUSHDEF([FLAGS],[CXXFLAGS])dnl
156 AS_VAR_PUSHDEF([VAR],[ac_cv_cxxflags_gcc_option_$1])dnl
157 AC_CACHE_CHECK([m4_ifval($2,$2,FLAGS) for gcc m4_ifval($1,$1,-option)],
158 VAR,[VAR="no, unknown"
159  AC_LANG_SAVE
160  AC_LANG_CPLUSPLUS
161  ac_save_[]FLAGS="$[]FLAGS"
162 for ac_arg dnl
163 in "-pedantic -Werror % m4_ifval($1,$1,-option)"  dnl   GCC
164    "-pedantic % m4_ifval($1,$1,-option) %% no, obsolete"  dnl new GCC
165    #
166 do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
167    AC_TRY_COMPILE([],[return 0;],
168    [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break])
169 done
170  FLAGS="$ac_save_[]FLAGS"
171  AC_LANG_RESTORE
173 case ".$VAR" in
174      .ok|.ok,*) m4_ifvaln($3,$3) ;;
175    .|.no|.no,*) m4_ifvaln($4,$4) ;;
176    *) m4_ifvaln($3,$3,[
177    if echo " $[]m4_ifval($2,$2,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
178    then AC_RUN_LOG([: m4_ifval($2,$2,FLAGS) does contain $VAR])
179    else AC_RUN_LOG([: m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR"])
180                       m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR"
181    fi ]) ;;
182 esac
183 AS_VAR_POPDEF([VAR])dnl
184 AS_VAR_POPDEF([FLAGS])dnl
187 AC_DEFUN([AX_CFLAGS_GCC_OPTION],[ifelse(m4_bregexp([$2],[-]),-1,
188 [AX_CFLAGS_GCC_OPTION_NEW($@)],[AX_CFLAGS_GCC_OPTION_OLD($@)])])
190 AC_DEFUN([AX_CXXFLAGS_GCC_OPTION],[ifelse(m4_bregexp([$2],[-]),-1,
191 [AX_CXXFLAGS_GCC_OPTION_NEW($@)],[AX_CXXFLAGS_GCC_OPTION_OLD($@)])])