Add definition of AS_ECHO for compatibility with Autoconf before 2.62.
[sliver-openvswitch.git] / m4 / as_echo.m4
1 # This file is part of Autoconf.                          -*- Autoconf -*-
2 # M4 sugar for common shell constructs.
3 # Requires GNU M4 and M4sugar.
4 #
5 # Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
6 # 2009, 2010 Free Software Foundation, Inc.
7
8 # This file is part of Autoconf.  This program is free
9 # software; you can redistribute it and/or modify it under the
10 # terms of the GNU General Public License as published by the
11 # Free Software Foundation, either version 3 of the License, or
12 # (at your option) any later version.
13 #
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 # GNU General Public License for more details.
18 #
19 # Under Section 7 of GPL version 3, you are granted additional
20 # permissions described in the Autoconf Configure Script Exception,
21 # version 3.0, as published by the Free Software Foundation.
22 #
23 # You should have received a copy of the GNU General Public License
24 # and a copy of the Autoconf Configure Script Exception along with
25 # this program; see the files COPYINGv3 and COPYING.EXCEPTION
26 # respectively.  If not, see <http://www.gnu.org/licenses/>.
27
28 # Written by Akim Demaille, Pavel Roskin, Alexandre Oliva, Lars J. Aas
29 # and many other people.
30
31 # Define AS_ECHO for compatibility with Autoconf before version 2.62.
32 m4_ifndef([AS_ECHO], [
33
34 # AS_ECHO(WORD)
35 # -------------
36 # Output WORD followed by a newline.  WORD must be a single shell word
37 # (typically a quoted string).  The bytes of WORD are output as-is, even
38 # if it starts with "-" or contains "\".
39 m4_defun_init([AS_ECHO],
40 [AS_REQUIRE([_$0_PREPARE])],
41 [$as_echo $1])
42
43
44 # AS_ECHO_N(WORD)
45 # ---------------
46 # Like AS_ECHO(WORD), except do not output the trailing newline.
47 m4_defun_init([AS_ECHO_N],
48 [AS_REQUIRE([_AS_ECHO_PREPARE])],
49 [$as_echo_n $1])
50
51
52 # _AS_ECHO_PREPARE
53 # ----------------
54 # Arrange for $as_echo 'FOO' to echo FOO without escape-interpretation;
55 # and similarly for $as_echo_n, which omits the trailing newline.
56 # 'FOO' is an optional single argument; a missing FOO is treated as empty.
57 m4_defun([_AS_ECHO_PREPARE],
58 [[as_nl='
59 '
60 export as_nl
61 # Printing a long string crashes Solaris 7 /usr/bin/printf.
62 as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
63 as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
64 as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
65 # Prefer a ksh shell builtin over an external printf program on Solaris,
66 # but without wasting forks for bash or zsh.
67 if test -z "$BASH_VERSION$ZSH_VERSION" \
68     && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
69   as_echo='print -r --'
70   as_echo_n='print -rn --'
71 elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
72   as_echo='printf %s\n'
73   as_echo_n='printf %s'
74 else
75   if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
76     as_echo_body='eval /usr/ucb/echo -n "$][1$as_nl"'
77     as_echo_n='/usr/ucb/echo -n'
78   else
79     as_echo_body='eval expr "X$][1" : "X\\(.*\\)"'
80     as_echo_n_body='eval
81       arg=$][1;
82       case $arg in @%:@(
83       *"$as_nl"*)
84         expr "X$arg" : "X\\(.*\\)$as_nl";
85         arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
86       esac;
87       expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
88     '
89     export as_echo_n_body
90     as_echo_n='sh -c $as_echo_n_body as_echo'
91   fi
92   export as_echo_body
93   as_echo='sh -c $as_echo_body as_echo'
94 fi
95 ]])# _AS_ECHO_PREPARE
96 ])