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