source: trunk/m4/yat_add_flag.m4 @ 2497

Last change on this file since 2497 was 2497, checked in by Peter, 10 years ago

Avoid using deprecated macros AX_{CXXCPP,CXX,LD}_CHECK_FLAG. Instead
use use new macro provided in ax_check_flag.m4 in autoconf macro archive.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Date
File size: 2.7 KB
Line 
1## $Id: yat_add_flag.m4 2497 2011-06-26 17:33:29Z peter $
2
3# SYNOPSIS
4#
5#   YAT_CPP_ADD_FLAG([FLAGS], [FLAG])
6#
7#   YAT_CXX_ADD_FLAG([FLAGS], [FLAG])
8#
9#   YAT_LD_ADD_FLAG([FLAGS], [FLAG])
10#
11# DESCRIPTION
12#
13#   Check that FLAG is not already included in FLAGS and test that
14#   FLAG is supported by C++ compiler. If true FLAG is appended to
15#   FLAGS.
16#
17# LAST MODIFICATION
18#
19#   $Date: 2011-06-26 17:33:29 +0000 (Sun, 26 Jun 2011) $
20#
21# COPYLEFT
22#
23#   Copyright (C) 2008, 2009 Peter Johansson
24#
25#   This file is part of the yat library, http://dev.thep.lu.se/yat
26#
27#   The yat library is free software; you can redistribute it and/or
28#   modify it under the terms of the GNU General Public License as
29#   published by the Free Software Foundation; either version 3 of the
30#   License, or (at your option) any later version.
31#
32#   The yat library is distributed in the hope that it will be useful,
33#   but WITHOUT ANY WARRANTY; without even the implied warranty of
34#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
35#   General Public License for more details.
36#
37#   You should have received a copy of the GNU General Public License
38#   along with yat. If not, see <http://www.gnu.org/licenses/>.
39#
40
41#
42# serial 5 
43#
44# see http://www.gnu.org/software/automake/manual/automake.html#Serials
45
46AC_DEFUN([YAT_CPP_ADD_FLAG],
47[
48  AC_PREREQ([2.63]) dnl we use AS_VAR_IF
49  AC_REQUIRE([AC_PROG_SED])
50  for yat_flag in $2; do
51    # ignore flag if
52    # 1) it is -I/usr/include
53    # 2) it is -I/usr/local/include and CXX is g++
54    # 3) it is -D* and * is already defined in $1, $CPPFLAGS, or AC_DEFINE
55    ignore=no
56    AS_CASE([$yat_flag],
57            [-I/usr/include], [ignore=yes],
58            [-I/usr/local/include],[AS_IF([test "x$CXX" = "xg++"],[ignore=yes])],
59            [-D*], [yat_def=`AS_ECHO([$yat_flag]) | $SED 's,^-D,,;s,=.*,,'`;
60                    yat_save_CPPFLAGS="$CPPFLAGS"
61                    m4_if([$1], [CPPFLAGS], [], [CPPFLAGS="$$1 $CPPFLAGS"])
62                    AC_CHECK_DECL([$yat_def],[ignore=yes])
63                    CPPFLAGS="$yat_save_CPPFLAGS"])
64
65    AS_VAR_IF([ignore], [no],
66              [AX_CHECK_PREPROC_FLAG([$yat_flag],
67                                     [AX_APPEND_FLAG([$yat_flag], [$1])])])
68  done
69]) # YAT_CPP_ADD_FLAG
70
71
72AC_DEFUN([YAT_CXX_ADD_FLAG],
73[
74  AC_PREREQ([2.59]) dnl we use AX_APPEND_COMPILE_FLAGS
75  AX_APPEND_COMPILE_FLAGS([$2], [$1])
76]) # YAT_CXX_ADD_FLAG
77
78AC_DEFUN([YAT_LD_ADD_FLAG],
79[
80  AC_PREREQ([2.59]) dnl we use AX_APPEND_LINK_FLAGS
81  for yat_flag in $2; do
82    # ignore flag if
83    # 1) it is -L/usr/lib
84    # 2) it is -L/usr/local/lib and CXX is g++
85    AS_IF([test "x$yat_flag" = "x-L/usr/lib"],,
86          [test "x$CXX" = "xg++" && test "x$yat_flag" = "x-L/usr/local/lib"],,
87          [AX_APPEND_LINK_FLAGS([$yat_flag], [$1])])
88  done
89]) # YAT_LD_ADD_FLAG
Note: See TracBrowser for help on using the repository browser.