Optimize gnulib checkout.
[libsigsegv/ericb.git] / m4 / bold.m4
blob5f5420ecc13006a953b5aff58a7a0e243d9d794d
1 # bold.m4 serial 1 (libsigsegv-2.0)
2 dnl Copyright (C) 1999-2002 Ralf S. Engelschall <rse@engelschall.com>
3 dnl Copyright (C) 2002 Bruno Haible <bruno@clisp.org>
4 dnl This file is free software, distributed under the terms of the GNU
5 dnl General Public License.  As a special exception to the GNU General
6 dnl Public License, this file may be distributed as part of a program
7 dnl that contains a configuration script generated by Autoconf, under
8 dnl the same distribution terms as the rest of that program.
10 # Determine the escape sequences for switching bold output on and off.
11 AC_DEFUN([RSE_BOLD],
13   dnl Not pretty.
14   dnl AC_REQUIRE([AC_PROG_AWK])
16   case $TERM in
17     # for the most important terminal types we directly know the sequences
18     xterm*|vt220*)
19       term_bold=`${AWK:-awk} 'BEGIN { printf("%c%c%c%c", 27, 91, 49, 109); }' </dev/null 2>/dev/null`
20       term_norm=`${AWK:-awk} 'BEGIN { printf("%c%c%c", 27, 91, 109); }' </dev/null 2>/dev/null`
21       ;;
22     vt100*)
23       term_bold=`${AWK:-awk} 'BEGIN { printf("%c%c%c%c%c%c", 27, 91, 49, 109, 0, 0); }' </dev/null 2>/dev/null`
24       term_norm=`${AWK:-awk} 'BEGIN { printf("%c%c%c%c%c", 27, 91, 109, 0, 0); }' </dev/null 2>/dev/null`
25       ;;
26     # for all others, we try to use a possibly existing `tput' or `tcout' utility
27     *)
28       paths=`echo "$PATH" | sed -e 's/:/ /g'`
29       for tool in tput tcout; do
30         for dir in $paths; do
31           if test -r "$dir/$tool"; then
32             for seq in bold md smso; do # 'smso' is last
33               bold="`$dir/$tool $seq 2>/dev/null`"
34               if test -n "$bold"; then
35                 term_bold="$bold"
36                 break
37               fi
38             done
39             if test -n "$term_bold"; then
40               for seq in sgr0 me rmso reset; do # 'reset' is last
41                 norm="`$dir/$tool $seq 2>/dev/null`"
42                 if test -n "$norm"; then
43                   term_norm="$norm"
44                   break
45                 fi
46               done
47             fi
48             break
49           fi
50         done
51         if test -n "$term_bold" && test -n "$term_norm"; then
52           break
53         fi
54       done
55       ;;
56   esac
57   echo "$term_bold" | tr -d '\n' > termbold
58   echo "$term_norm" | tr -d '\n' > termnorm