1 AS_INIT[]m4_divert_push([HEADER-COPYRIGHT])
2 # defs -- Defines for Libtool testing environment.
4 # Copyright (C) 2003, 2004, 2005, 2007, 2008, 2009, 2010 Free Software
6 # Written by Gord Matzigkeit, 1996
7 # Rewritten by Gary V. Vaughan, 2003
9 # This file is part of GNU Libtool.
11 # GNU Libtool is free software; you can redistribute it and/or
12 # modify it under the terms of the GNU General Public License as
13 # published by the Free Software Foundation; either version 2 of
14 # the License, or (at your option) any later version.
16 # GNU Libtool is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with GNU Libtool; see the file COPYING. If not, a copy
23 # can be downloaded from http://www.gnu.org/licenses/gpl.html,
24 # or obtained by writing to the Free Software Foundation, Inc.,
25 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29 m4_include([general.m4sh])
32 : ${AUTOCONF="autoconf"}
33 : ${AUTORECONF="autoreconf"}
34 : ${LIBTOOL="./libtool"}
36 # Sed that helps us avoid accidentally triggering echo(1) options like -n.
37 Xsed="$SED -e 1s/^X//"
39 # Disable usage of config.site for autoconf, unless DJGPP is present.
40 # The DJGPP port of autoconf requires config.site, to work correctly.
41 if test -z "$DJGPP"; then
42 CONFIG_SITE=/nonexistent
45 # How verbose should we be? Default is test output in log file.
46 # Setting VERBOSE=debug puts the shell in debug mode.
55 if test -z "$srcdir"; then
56 srcdir=`$ECHO "$0" | $SED "$dirname; s,/tests\$,,"`
57 test "$srcdir" = "$0" && srcdir=.
61 # Echo message with prefix.
64 func_echo "=== " ${1+"$@"}
68 # Echo message to standard error, and skip the rest of this test.
76 # Echo message to standard error, and fail this test.
79 func_fatal_error ${1+"$@"}
82 # func_get_config varname_list src [failp] [regex]
88 my_failp="false"; test -z "$3" || my_failp=:
92 if test -z "$my_regex"; then
100 for my_varname in $my_varname_list; do
101 if $my_build_regex; then
102 $my_first || my_regex="$my_regex|"
104 my_regex="$my_regex$my_varname"
106 eval $my_varname=NONE
108 $my_build_regex && my_regex="$my_regex)="
109 eval `eval "$my_src" | eval "$EGREP \"$my_regex\""`
111 for my_varname in $my_varname_list; do
112 if eval test x\"\$$my_varname\" = xNONE; then
113 func_error "$my_varname not set in \`$my_src'"
114 $my_failp && my_exitp=:
118 $my_exitp && exit $EXIT_FAILURE
122 # Extract some variables from the libtool configuration.
123 func_get_config "objext
130 build_alias" "$LIBTOOL --config" ": fatal"
137 # An absolute path to a test installation directory.
138 func_mkdir_p "$prefix"
139 prefix=`cd $prefix && pwd`
146 test -d $prefix && rm -rf $prefix
151 # Make sure a directory exists, and then change to it.
157 # Maybe we have a VPATH build, in which case, create a new subdir.
158 func_mkdir_p "$my_dir"
160 # Change to our build directory.
161 cd "$my_dir" || func_fatal_error "couldn't cd to \`$my_dir'"
165 # func_require prereq file [...]
166 # If FILE does not exist, give a fatal error regarding running PREREQ first.
170 my_prereq="$1"; shift
173 for my_file in $my_files; do
175 || func_skip "You must run ${my_prereq}.test before running $0"
179 # func_configure_nofail [args ...]
180 # Configure the demonstration.
181 func_configure_nofail ()
185 func_dirname_and_basename "`pwd`"
186 my_dir=$func_basename_result
187 my_testdir="$srcdir/tests/$my_dir"
188 conf_status=$EXIT_FAILURE
190 test -n "$my_args" && my_args=" $my_args"
191 my_args="--srcdir="\""$my_testdir"\"" --prefix="\""$prefix"\""$my_args"
192 test -n "$host_alias" && my_args="$my_args --host=\"$host_alias\""
193 test -n "$build_alias" && my_args="$my_args --build=\"$build_alias\""
195 func_msg "Configuring in $my_dir"
197 test -f "$my_testdir/configure" || ${AUTORECONF} --force --install $my_testdir
198 if test -f "$my_testdir/configure"; then
200 eval func_msg $SHELL "$my_testdir/configure" $my_args
201 if eval $SHELL "$my_testdir/configure" $my_args; then
202 conf_status=$EXIT_SUCCESS
204 func_msg "FAILED: Configuring in $my_testdir"
210 # func_configure [args ...]
211 # Configure the demonstration, fail on error.
214 func_configure_nofail ${1+"$@"}
215 if test "$conf_status" -eq "$EXIT_FAILURE"; then
220 # func_check_static_shared staticp sharedp
221 # Determine whether the generated libtool script is configured properly
222 # for the expected STATICP and SHAREDP library building
223 func_check_static_shared ()
229 if func_grep "^build_old_libs=$staticp" libtool &&
230 func_grep "^build_libtool_libs=$sharedp" libtool; then :
238 # func_make [args ...]
239 # Do the actual build.
244 func_dirname_and_basename "`pwd`"
245 func_msg "Running \`$MAKE $my_args' in $func_basename_result"
247 eval $MAKE $my_args || exit $EXIT_FAIL
252 # Possibly clean up the distribution.
253 func_make_distclean ()
256 if test -f Makefile; then
259 rm -rf autom4te.cache config.cache
263 # func_make_uninstall
264 # See that there were no files leftover in $prefix.
265 # Ignore dotfiles, so that .nfsXXX files don't screw up the test.
266 func_make_uninstall ()
271 leftovers=`find $prefix ! -type d ! -name '.*' -print`
272 if test -n "$leftovers"; then
273 func_msg "Leftover after make uninstall:"
280 # func_exec_init mode
284 func_dirname_and_basename "`pwd`"
285 func_msg "Executing $1 programs in $func_basename_result"
287 # Windows hosts search for dlls in the command path
288 PATH=$prefix/lib:$PATH
290 exec_status=$EXIT_SUCCESS
293 # func_exec_check program [msg ...]
294 # Check to see if PROGRAM was built. If not display MSG.
300 if test -f "$my_program"; then :
303 func_error "$0: $my_program did not build ${1+$@}"
304 exec_status=$EXIT_FAILURE
308 # func_exec program [exp_output] [msg ...]
309 # Check to see if PROGRAM really runs, and produces EXP_OUTPUT if given.
310 # If not display MSG.
316 func_dirname_and_basename "`pwd`"
317 my_dir=$func_basename_result
319 test -n "$my_exp_output" \
320 && my_exp_output="| $EGREP -e "\""$my_exp_output"\"
322 if eval $my_program $my_exp_output; then :
325 test "x$1" = x || shift
326 func_error "$0: cannot execute $my_program ${1+$@}"
328 if test "$build" != "$host"; then
329 func_msg "This may be ok since you seem to be cross-compiling."
330 exec_status=$EXIT_SKIP
332 # Simple check to see if they are superuser.
333 if test $exec_status = $EXIT_FAILURE || test -w /; then :
335 func_msg "You may need to run $0 as the superuser."
337 exec_status=$EXIT_FAILURE
342 # Shared global variables for test scripts
343 prefix=./_inst-`echo "$0" | sed 's,.*/,,; s,-.*,,'`
344 srcdir=`cd $srcdir && pwd`
345 m4dir=$srcdir/libltdl/m4
346 auxdir=$srcdir/libltdl/config
347 scripts="$auxdir/ltmain.m4sh $srcdir/libtoolize.m4sh"
349 # Unset some MAKE... variables that may cause $MAKE to act like a
350 # recursively invoked sub-make. Any $MAKE invocation in a test is
351 # conceptually an independent invocation.
352 unset MFLAGS MAKEFLAGS MAKELEVEL __MKLVL__ MAKE_JOBS_FIFO
354 # On AIX, shared libraries remain loaded in memory after use if they
355 # are world-readable, until root issues slibclean. On NFS, this causes
356 # a testsuite rerun to fail to clean up test group directories. Avoid
357 # this with a suitable umask. Do not do this on other systems, for
358 # example HP-UX suffers unless shared libraries are mode 555.
363 func_msg "Running $progname"