]>
Commit | Line | Data |
---|---|---|
a37f8fd6 VB |
1 | # =========================================================================== |
2 | # http://www.gnu.org/software/autoconf-archive/ax_ld_check_flag.html | |
3 | # =========================================================================== | |
4 | # | |
5 | # SYNOPSIS | |
6 | # | |
d24247ed | 7 | # AX_LDFLAGS_OPTION(FLAG-TO-CHECK,[VAR],[NOTFOUND]) |
a37f8fd6 VB |
8 | # |
9 | # DESCRIPTION | |
10 | # | |
8d92800b VB |
11 | # This macro tests if the C compiler supports the flag FLAG-TO-CHECK. If |
12 | # successfull add it to VAR. | |
a37f8fd6 VB |
13 | # |
14 | # This code is inspired from KDE_CHECK_COMPILER_FLAG macro. Thanks to | |
15 | # Bogdan Drozdowski <bogdandr@op.pl> for testing and bug fixes. | |
16 | # | |
8d92800b VB |
17 | # This version has been (heavily) modified by Vincent Bernat |
18 | # <bernat@luffy.cx> to match AX_CFLAGS_GCC_OPTION. | |
19 | # | |
a37f8fd6 VB |
20 | # LICENSE |
21 | # | |
22 | # Copyright (c) 2008 Francesco Salvestrini <salvestrini@users.sourceforge.net> | |
23 | # | |
24 | # This program is free software; you can redistribute it and/or modify it | |
25 | # under the terms of the GNU General Public License as published by the | |
26 | # Free Software Foundation; either version 2 of the License, or (at your | |
27 | # option) any later version. | |
28 | # | |
29 | # This program is distributed in the hope that it will be useful, but | |
30 | # WITHOUT ANY WARRANTY; without even the implied warranty of | |
31 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | |
32 | # Public License for more details. | |
33 | # | |
34 | # You should have received a copy of the GNU General Public License along | |
35 | # with this program. If not, see <http://www.gnu.org/licenses/>. | |
36 | # | |
37 | # As a special exception, the respective Autoconf Macro's copyright owner | |
38 | # gives unlimited permission to copy, distribute and modify the configure | |
39 | # scripts that are the output of Autoconf when processing the Macro. You | |
40 | # need not follow the terms of the GNU General Public License when using | |
41 | # or distributing such scripts, even though portions of the text of the | |
42 | # Macro appear in them. The GNU General Public License (GPL) does govern | |
43 | # all other use of the material that constitutes the Autoconf Macro. | |
44 | # | |
45 | # This special exception to the GPL applies to versions of the Autoconf | |
46 | # Macro released by the Autoconf Archive. When you make and distribute a | |
47 | # modified version of the Autoconf Macro, you may extend this special | |
48 | # exception to the GPL to apply to your modified version as well. | |
49 | ||
50 | #serial 6 | |
51 | ||
8d92800b | 52 | AC_DEFUN([AX_LDFLAGS_OPTION],[ |
a37f8fd6 | 53 | AC_PREREQ([2.61]) |
a37f8fd6 VB |
54 | AC_REQUIRE([AC_PROG_SED]) |
55 | ||
56 | flag=`echo "$1" | $SED 'y% .=/+-(){}<>:*,%_______________%'` | |
57 | ||
58 | AC_CACHE_CHECK([whether the linker accepts the $1 flag], | |
59 | [ax_cv_ld_check_flag_$flag],[ | |
60 | ||
8d92800b VB |
61 | AC_LANG_SAVE |
62 | AC_LANG_C | |
a37f8fd6 VB |
63 | |
64 | save_LDFLAGS="$LDFLAGS" | |
84942a4a | 65 | LDFLAGS="-Werror $LDFLAGS $[]m4_ifval($2,$2,) $1" |
a37f8fd6 | 66 | AC_LINK_IFELSE([ |
8d92800b | 67 | AC_LANG_PROGRAM([],[]) |
a37f8fd6 VB |
68 | ],[ |
69 | eval "ax_cv_ld_check_flag_$flag=yes" | |
70 | ],[ | |
71 | eval "ax_cv_ld_check_flag_$flag=no" | |
72 | ]) | |
73 | ||
74 | LDFLAGS="$save_LDFLAGS" | |
75 | ||
8d92800b | 76 | AC_LANG_RESTORE |
a37f8fd6 VB |
77 | |
78 | ]) | |
79 | ||
80 | AS_IF([eval "test \"`echo '$ax_cv_ld_check_flag_'$flag`\" = yes"],[ | |
8d92800b | 81 | m4_ifval($2,$2,LDFLAGS)="$[]m4_ifval($2,$2,LDFLAGS) $1" |
d24247ed VB |
82 | ],[ |
83 | :; $3 | |
a37f8fd6 VB |
84 | ]) |
85 | ]) |