mirror of
git://git.savannah.gnu.org/libtool.git
synced 2024-12-27 07:09:26 +08:00
bfce27f524
* config/general.m4sh, config/getopt.m4sh: New files with factored out functionality from... * config/ltmain.in, libtoolize.in: ...here. m4_include the shared code, and call AS_SHELL_SANITIZE. Also quote all `[' and `]' to survive m4 run. (func_serial): No need to double up m4sh quotes after a `#'. (func_check_macros): Escape `dnl' to stop m4sh interpreting it as a macro. * tests/defs.in: New file expanded into tests/defs by autom4te. * m4/libtool.m4 (_LT_DECL_EGREP): Also require fgrep for the tests that use it. * Makefile.am ($(top_srcdir)/config/ltmain.sh): Now built with M4SH. (libtoolize): Ditto. * bootstrap: Set M4SH for call to make. * HACKING: No need to sync to AS_SHELL_SANITIZE by hand any more.
248 lines
7.0 KiB
Plaintext
248 lines
7.0 KiB
Plaintext
m4_if([# general.m4sh -- general shell script boiler plate -*- Autoconf -*-
|
|
# Written by Gary V. Vaughan <gary@gnu.org>, 2004
|
|
|
|
# Copyright (C) 2004 Free Software Foundation, Inc.
|
|
# This is free software; see the source for copying conditions. There is NO
|
|
# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful, but
|
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
# General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program; if not, write to the Free Software
|
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
#
|
|
# As a special exception to the GNU General Public License, if you
|
|
# distribute this file as part of a program that contains a
|
|
# configuration script generated by Autoconf, you may include it under
|
|
# the same distribution terms that you use for the rest of that program.
|
|
])dnl
|
|
|
|
: ${CP="cp -f"}
|
|
: ${ECHO="echo"}
|
|
: ${EGREP="@EGREP@"}
|
|
: ${FGREP="@FGREP@"}
|
|
: ${GREP="@GREP@"}
|
|
: ${LN_S="@LN_S@"}
|
|
: ${MAKE="make"}
|
|
: ${MKDIR="mkdir"}
|
|
: ${MV="mv -f"}
|
|
: ${RM="rm -f"}
|
|
: ${SED="@SED@"}
|
|
|
|
# Global variables:
|
|
EXIT_SUCCESS=0
|
|
EXIT_FAILURE=1
|
|
EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing.
|
|
EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake.
|
|
|
|
exit_status=$EXIT_SUCCESS
|
|
|
|
# Make sure IFS has a sensible default
|
|
: ${IFS="
|
|
"}
|
|
|
|
dirname="s,/[[^/]]*$,,"
|
|
basename="s,^.*/,,g"
|
|
|
|
# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
|
|
# is ksh but when the shell is invoked as "sh" and the current value of
|
|
# the _XPG environment variable is not equal to 1 (one), the special
|
|
# positional parameter $0, within a function call, is the name of the
|
|
# function.
|
|
progpath="$0"
|
|
|
|
# The name of this program:
|
|
progname=`$ECHO "$progpath" | $SED "$basename"`
|
|
|
|
# Make sure we have an absolute path for reexecution:
|
|
case $progpath in
|
|
[[\\/]]*|[[A-Za-z]]:\\*) ;;
|
|
*) progdir=`$ECHO "$progpath" | $SED "$dirname"`
|
|
progdir=`cd "$progdir" && pwd`
|
|
progpath="$progdir/$progname"
|
|
;;
|
|
esac
|
|
|
|
# Sed substitution that helps us do robust quoting. It backslashifies
|
|
# metacharacters that are still active within double-quoted strings.
|
|
Xsed="${SED}"' -e 1s/^X//'
|
|
sed_quote_subst='s/\([[\\`\\"$\\\\]]\)/\\\1/g'
|
|
# test EBCDIC or ASCII
|
|
case `$ECHO A|tr A '\301'` in
|
|
A) # EBCDIC based system
|
|
SP2NL="tr '\100' '\n'"
|
|
NL2SP="tr '\r\n' '\100\100'"
|
|
;;
|
|
*) # Assume ASCII based system
|
|
SP2NL="tr '\040' '\012'"
|
|
NL2SP="tr '\015\012' '\040\040'"
|
|
;;
|
|
esac
|
|
|
|
# Standard options:
|
|
opt_dry_run=false
|
|
opt_help=false
|
|
opt_quiet=false
|
|
opt_verbose=false
|
|
|
|
# func_echo arg...
|
|
# Echo program name prefixed message, along with the current mode
|
|
# name if it has been set yet.
|
|
func_echo ()
|
|
{
|
|
$ECHO $progname${mode+: }$mode: ${1+"$@"}
|
|
}
|
|
|
|
# func_verbose arg...
|
|
# Echo program name prefixed message in verbose mode only.
|
|
func_verbose ()
|
|
{
|
|
$opt_verbose && func_echo ${1+"$@"}
|
|
}
|
|
|
|
# func_error arg...
|
|
# Echo program name prefixed message to standard error.
|
|
func_error ()
|
|
{
|
|
$ECHO $progname${mode+: }$mode: ${1+"$@"} 1>&2
|
|
}
|
|
|
|
# func_warning arg...
|
|
# Echo program name prefixed warning message to standard error.
|
|
func_warning ()
|
|
{
|
|
$ECHO $progname${mode+: }$mode: warning: ${1+"$@"} 1>&2
|
|
}
|
|
|
|
# func_fatal_error arg...
|
|
# Echo program name prefixed message to standard error, and exit.
|
|
func_fatal_error ()
|
|
{
|
|
func_error ${1+"$@"}
|
|
exit $EXIT_FAILURE
|
|
}
|
|
|
|
# func_fatal_help arg...
|
|
# Echo program name prefixed message to standard error, followed by
|
|
# a help hint, and exit.
|
|
func_fatal_help ()
|
|
{
|
|
func_error ${1+"$@"}
|
|
func_fatal_error "$help"
|
|
}
|
|
help="Try \`$progname --help' for more information." ## default
|
|
|
|
|
|
# func_grep expression filename
|
|
# Check whether EXPRESSION matches any line of FILENAME, without output.
|
|
func_grep ()
|
|
{
|
|
$GREP "$1" "$2" >/dev/null 2>&1
|
|
}
|
|
|
|
|
|
# func_mkdir_p directory-path
|
|
# Make sure the entire path to DIRECTORY-PATH is available.
|
|
func_mkdir_p ()
|
|
{
|
|
my_directory_path="$1"
|
|
my_dir_list=
|
|
|
|
if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
|
|
|
|
# Protect directory names starting with `-'
|
|
case $my_directory_path in
|
|
-*) my_directory_path="./$my_directory_path" ;;
|
|
esac
|
|
|
|
# While some portion of DIR does not yet exist...
|
|
while test ! -d "$my_directory_path"; do
|
|
# ...make a list in topmost first order. Use a colon delimited
|
|
# list incase some portion of path contains whitespace.
|
|
my_dir_list="$my_directory_path:$my_dir_list"
|
|
|
|
# If the last portion added has no slash in it, the list is done
|
|
case $my_directory_path in */*) ;; *) break ;; esac
|
|
|
|
# ...otherwise throw away the child directory and loop
|
|
my_directory_path=`$ECHO "$my_directory_path" | $SED "$dirname"`
|
|
done
|
|
my_dir_list=`$ECHO $my_dir_list | $SED 's,:*$,,'`
|
|
|
|
save_mkdir_p_IFS="$IFS"; IFS=':'
|
|
for my_dir in $my_dir_list; do
|
|
IFS="$save_mkdir_p_IFS"
|
|
# mkdir can fail with a `File exist' error if two processes
|
|
# try to create one of the directories concurrently. Don't
|
|
# stop in that case!
|
|
$MKDIR "$my_dir" 2>/dev/null || :
|
|
done
|
|
IFS="$save_mkdir_p_IFS"
|
|
|
|
# Bail out if we (or some other process) failed to create a directory.
|
|
test -d "$my_directory_path" || \
|
|
func_fatal_error "Failed to create \`$1'"
|
|
fi
|
|
}
|
|
|
|
|
|
# func_mktempdir
|
|
# Make a temporary directory that won't clash with other running
|
|
# libtool processes, and avoids race conditions if possible
|
|
func_mktempdir ()
|
|
{
|
|
my_template="${TMPDIR-/tmp}/libtool"
|
|
|
|
if test "$opt_dry_run" = ":"; then
|
|
# Return a directory name, but don't create it in dry-run mode
|
|
my_tmpdir="${my_template}-$$"
|
|
else
|
|
|
|
# If mktemp works, use that first and foremost
|
|
my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
|
|
|
|
if test ! -d "$my_tmpdir"; then
|
|
# Failing that, at least try and use $RANDOM to avoid a race
|
|
my_tmpdir="${my_template}-${RANDOM-0}$$"
|
|
|
|
save_mktempdir_umask=`umask`
|
|
umask 0077
|
|
$MKDIR "$my_tmpdir"
|
|
umask $save_mktempdir_umask
|
|
fi
|
|
|
|
# If we're not in dry-run mode, bomb out on failure
|
|
test -d "$my_tmpdir" || \
|
|
func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
|
|
fi
|
|
|
|
$ECHO "$my_tmpdir"
|
|
}
|
|
|
|
|
|
# func_quote_for_eval arg
|
|
# Aesthetically quote ARG to be evaled later.
|
|
func_quote_for_eval ()
|
|
{
|
|
my_arg="$1"
|
|
|
|
case $my_arg in
|
|
# Double-quote args containing other shell metacharacters.
|
|
# Many Bourne shells cannot handle close brackets correctly
|
|
# in scan sets, so we specify it separately.
|
|
*[[\@<:@\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]]*|*@:>@*|"")
|
|
my_arg="\"$my_arg\""
|
|
;;
|
|
esac
|
|
|
|
func_quote_for_eval_result="$my_arg"
|
|
}
|