source: branches/0.7-stable/m4/ax_ld_check_flag.m4 @ 851

Last change on this file since 851 was 775, checked in by Peter Johansson, 13 years ago

moving m4 files to directory m4/. NOTE this change will break Makefiles, so you need to issue 'autoreconf -m'. Also adding a longlong.m4 that seems to have been missing before(?).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Date
File size: 3.0 KB
Line 
1# ===========================================================================
2#            http://autoconf-archive.cryp.to/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# LAST MODIFICATION
28#
29#   2008-04-12
30#
31# COPYLEFT
32#
33#   Copyright (c) 2008 Francesco Salvestrini <salvestrini@users.sourceforge.net>
34#
35#   This program is free software; you can redistribute it and/or modify it
36#   under the terms of the GNU General Public License as published by the
37#   Free Software Foundation; either version 2 of the License, or (at your
38#   option) any later version.
39#
40#   This program is distributed in the hope that it will be useful, but
41#   WITHOUT ANY WARRANTY; without even the implied warranty of
42#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
43#   Public License for more details.
44#
45#   You should have received a copy of the GNU General Public License along
46#   with this program. If not, see <http://www.gnu.org/licenses/>.
47#
48#   As a special exception, the respective Autoconf Macro's copyright owner
49#   gives unlimited permission to copy, distribute and modify the configure
50#   scripts that are the output of Autoconf when processing the Macro. You
51#   need not follow the terms of the GNU General Public License when using
52#   or distributing such scripts, even though portions of the text of the
53#   Macro appear in them. The GNU General Public License (GPL) does govern
54#   all other use of the material that constitutes the Autoconf Macro.
55#
56#   This special exception to the GPL applies to versions of the Autoconf
57#   Macro released by the Autoconf Macro Archive. When you make and
58#   distribute a modified version of the Autoconf Macro, you may extend this
59#   special exception to the GPL to apply to your modified version as well.
60
61AC_DEFUN([AX_LD_CHECK_FLAG],[
62  AC_PREREQ([2.61])
63  AC_REQUIRE([AC_PROG_CXX])
64  AC_REQUIRE([AC_PROG_SED])
65
66  flag=`echo "$1" | $SED 'y% .=/+-(){}<>:*,%_______________%'`
67
68  AC_CACHE_CHECK([whether the linker accepts the $1 flag],
69    [ax_cv_ld_check_flag_$flag],[
70
71    #AC_LANG_PUSH([C])
72
73    save_LDFLAGS="$LDFLAGS"
74    LDFLAGS="$LDFLAGS $1"
75    AC_LINK_IFELSE([
76      AC_LANG_PROGRAM([$2],[$3])
77    ],[
78      eval "ax_cv_ld_check_flag_$flag=yes"
79    ],[
80      eval "ax_cv_ld_check_flag_$flag=no"
81    ])
82
83    LDFLAGS="$save_LDFLAGS"
84
85    #AC_LANG_POP
86
87  ])
88
89  AS_IF([eval "test \"`echo '$ax_cv_ld_check_flag_'$flag`\" = yes"],[
90    :
91    $4
92  ],[
93    :
94    $5
95  ])
96])
Note: See TracBrowser for help on using the repository browser.