Merge branch 'master' into testsuite-work
[platform/upstream/automake.git] / tests / defs
1 # -*- shell-script -*-
2 #
3 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 # 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation,
5 # Inc.
6 #
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2, or (at your option)
10 # any later version.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
20
21 # IMPORTANT NOTE: This file should execute correctly with any system's
22 # /bin/sh shell, and not only with configure-time detected $CONFIG_SHELL,
23 # until differently and explicitly specified.
24
25
26 ## -------------------------------------------------------- ##
27 ##  Source static setup and definitions for the testsuite.  ##
28 ## -------------------------------------------------------- ##
29
30 # This code needs to be 'set -e' clean.
31
32 # Ensure we are running from the right directory.
33 test -f ./defs-static || {
34    echo "$0: ./defs-static: not found in current directory" >&2
35    exit 99
36 }
37
38 # Source the shell sanitization and variables' definitions.
39 . ./defs-static || exit 99
40
41 # The name of the current test (without the `.test' suffix).
42 # Test scripts can override it if they need to (but this should
43 # be done carefully, and *before* including ./defs).
44 if test -z "$me"; then
45   # Guard against failure to spawn sed (seen on MSYS), or empty $argv0.
46   me=`echo "$argv0" | sed -e 's,.*[\\/],,;s/\.test$//'` \
47     && test -n "$me" \
48     || { echo "$argv0: failed to define \$me" >&2; exit 99; }
49 fi
50
51 ## ---------------------- ##
52 ##  Early sanity checks.  ##
53 ## ---------------------- ##
54
55 # A single whitespace character.
56 sp=' '
57 # A tabulation character.
58 tab='   '
59 # A newline character.
60 nl='
61 '
62
63 # As autoconf-generated configure scripts do, ensure that IFS
64 # is defined initially, so that saving and restoring $IFS works.
65 IFS=$sp$tab$nl
66
67 # Ensure $testsrcdir is set correctly.
68 test -f "$testsrcdir/defs-static.in" || {
69    echo "$me: $testsrcdir/defs-static.in not found, check \$testsrcdir" >&2
70    exit 99
71 }
72
73 # Ensure $testbuilddir is set correctly.
74 test -f "$testbuilddir/defs-static" || {
75    echo "$me: $testbuilddir/defs-static not found, check \$testbuilddir" >&2
76    exit 99
77 }
78
79
80 ## ------------------------------------ ##
81 ##  Ensure we run with a proper shell.  ##
82 ## ------------------------------------ ##
83
84 # Make sure we run with the shell detected at configure time (unless
85 # the user forbids it).
86 case ${AM_TESTS_REEXEC-yes} in
87   n|no|false|0)
88     ;;
89   *)
90     # Ensure we can find ourselves.
91     if test ! -f "$0"; then
92       echo "$me: unable to find myself: $0" >&2
93       exit 99
94     fi
95     AM_TESTS_REEXEC=no; export AM_TESTS_REEXEC
96     # Cannot simply do `opts=$-', since the content of $- is not
97     # portable among different shells.  So try to propagate only
98     # the portable and interesting options.
99     case $- in
100       *x*v*|*v*x) opts=-vx;;
101       *v*) opts=-v;;
102       *x*) opts=-x;;
103       *) opts=;;
104     esac
105     echo $me: exec $SHELL $opts "$0" "$*"
106     exec $SHELL $opts "$0" ${1+"$@"}
107     echo "$me: failed to re-execute with $SHELL" >&2
108     exit 99
109     ;;
110 esac
111
112 # NOTE: From this point on, we can assume this file is being executed
113 # by the configure-time detected $CONFIG_SHELL.
114
115
116 ## ---------------------- ##
117 ##  Environment cleanup.  ##
118 ## ---------------------- ##
119
120 # Unset some MAKE... variables that may cause $MAKE to act like a
121 # recursively invoked sub-make.  Any $MAKE invocation in a test is
122 # conceptually an independent invocation, not part of the main
123 # 'automake' build.
124 unset MFLAGS MAKEFLAGS AM_MAKEFLAGS MAKELEVEL __MKLVL__ MAKE_JOBS_FIFO
125 # Unset verbosity flag.
126 unset V
127 # Also unset variables that will let `make -e install' divert
128 # files into unwanted directories.
129 unset DESTDIR
130 unset prefix exec_prefix bindir datarootdir datadir docdir dvidir
131 unset htmldir includedir infodir libdir libexecdir localedir mandir
132 unset oldincludedir pdfdir psdir sbindir sharedstatedir sysconfdir
133 # Unset variables that might change the "make distcheck" behaviour.
134 unset DISTCHECK_CONFIGURE_FLAGS AM_DISTCHECK_CONFIGURE_FLAGS
135 # The tests call `make -e' but we do not want $srcdir from the environment
136 # to override the definition from the Makefile.
137 unset srcdir
138 # Also unset variables that control our test driver.  While not
139 # conceptually independent, they cause some changed semantics we
140 # need to control (and test for) in some of the tests to ensure
141 # backward-compatible behavior.
142 unset TESTS_ENVIRONMENT
143 unset DISABLE_HARD_ERRORS
144 unset TESTS
145 unset TEST_LOG_COMPILER
146 unset TEST_LOGS
147 unset RECHECK_LOGS
148 unset VERBOSE
149
150
151 ## ---------------------------- ##
152 ##  Auxiliary shell functions.  ##
153 ## ---------------------------- ##
154
155 # This is used in `Exit' and in the exit trap.  See comments in the latter
156 # for more information,
157 am__test_skipped=no
158
159 # We use a trap below for cleanup.  This requires us to go through
160 # hoops to get the right exit status transported through the signal.
161 # So use `Exit STATUS' instead of `exit STATUS' inside of the tests.
162 # Turn off errexit here so that we don't trip the bug with OSF1/Tru64
163 # sh inside this function.
164 Exit ()
165 {
166   set +e
167   # See comments in the exit trap for the reason we do this.
168   test 77 = $1 && am__test_skipped=yes
169   (exit $1); exit $1
170 }
171
172 # Print warnings (e.g., about skipped and failed tests) to this file
173 # number.  Override by putting, say:
174 #   stderr_fileno_=9; export stderr_fileno_; 9>&2
175 # at the *end* (yes, this is mandatory; see comments in Makefile.am) of
176 # the definition of AM_TESTS_ENVIRONMENT.
177 # This is useful when using automake's parallel tests mode, to print the
178 # reason for skip/failure to console, rather than to the *.log files.
179 : ${stderr_fileno_=2}
180
181 # Copied from Gnulib's `tests/init.sh'.
182 warn_ () { echo "$@" 1>&$stderr_fileno_; }
183 fail_ () { warn_ "$me: failed test: $@"; Exit 1; }
184 skip_ () { warn_ "$me: skipped test: $@"; Exit 77; }
185 fatal_ () { warn_ "$me: hard error: $@"; Exit 99; }
186 framework_failure_ () { warn_ "$me: set-up failure: $@"; Exit 99; }
187
188 # cross_compiling
189 # ---------------
190 # Tell whether we are cross-compiling.  This is especially useful to skip
191 # tests (or portions of them) that requires a native compiler.
192 cross_compiling ()
193 {
194   test x"$host_alias" != x && test x"$build_alias" != x"$host_alias"
195 }
196
197 # is_newest FILE FILES
198 # --------------------
199 # Return false if any file in FILES is newer than FILE.
200 # Resolve ties in favor of FILE.
201 is_newest ()
202 {
203   is_newest_files=`find "$@" -prune -newer "$1"`
204   test -z "$is_newest_files"
205 }
206
207 # AUTOMAKE_run status [options...]
208 # --------------------------------
209 # Run Automake with OPTIONS, and fail if automake
210 # does not exit with STATUS.
211 AUTOMAKE_run ()
212 {
213   expected_exitcode=$1
214   shift
215   exitcode=0
216   $AUTOMAKE ${1+"$@"} >stdout 2>stderr || exitcode=$?
217   cat stderr >&2
218   cat stdout
219   test $exitcode = $expected_exitcode || Exit 1
220 }
221
222 # AUTOMAKE_fails [options...]
223 # ---------------------------
224 # Run Automake with OPTIONS, and fail if automake
225 # does not exit with STATUS.
226 AUTOMAKE_fails ()
227 {
228   AUTOMAKE_run 1 ${1+"$@"}
229 }
230
231 # using_gmake
232 # -----------
233 # Return success if $MAKE is GNU make, return failure otherwise.
234 # Caches the result for speed reasons.
235 using_gmake ()
236 {
237   case $am__using_gmake in
238     yes)
239       return 0;;
240     no)
241       return 1;;
242     '')
243       # Use --version AND -v, because SGI Make doesn't fail on --version.
244       # Also grep for GNU because newer versions of FreeBSD make do
245       # not complain about `--version' (they seem to silently ignore it).
246       if $MAKE --version -v | grep GNU; then
247         am__using_gmake=yes
248         return 0
249       else
250         am__using_gmake=no
251         return 1
252       fi;;
253     *)
254       echo "invalid value for \$am__using_gmake: '$am__using_gmake'" >&2
255       Exit 99;;
256   esac
257 }
258 am__using_gmake="" # Avoid interferences from the environment.
259
260 # seq_ - print a sequence of numbers
261 # ----------------------------------
262 # This function simulates GNU seq(1) portably.  Valid usages:
263 #  - seq LAST
264 #  - seq FIRST LAST
265 #  - seq FIRST INCREMENT LAST
266 seq_ ()
267 {
268   case $# in
269     0) fatal_ "seq_: missing argument";;
270     1) seq_first=1  seq_incr=1  seq_last=$1;;
271     2) seq_first=$1 seq_incr=1  seq_last=$2;;
272     3) seq_first=$1 seq_incr=$2 seq_last=$3;;
273     *) fatal_ "seq_: too many arguments";;
274   esac
275   # Try to avoid forks if possible.
276   case "$BASH_VERSION" in
277     ""|[12].*)
278       : Not bash, or a too old bash version. ;;
279     *)
280       # Use eval to protect dumber shells from parsing errors.
281       eval 'for ((i = seq_first; i <= seq_last; i += seq_incr)); do
282               echo $i
283             done'
284       return 0;;
285   esac
286   # Else, use GNU seq if available.
287   seq "$@" && return 0
288   # Otherwise revert to a slower loop using expr(1).
289   i=$seq_first
290   while test $i -le $seq_last; do
291     echo $i
292     i=`expr $i + $seq_incr`
293   done
294 }
295
296 commented_sed_unindent_prog='
297   /^$/b                    # Nothing to do for empty lines.
298   x                        # Get x<indent> into pattern space.
299   /^$/{                    # No prior x<indent>, go prepare it.
300     g                      # Copy this 1st non-blank line into pattern space.
301     s/^\(['"$tab"' ]*\).*/x\1/   # Prepare x<indent> in pattern space.
302   }                        # Now: x<indent> in pattern and <line> in hold.
303   G                        # Build x<indent>\n<line> in pattern space, and
304   h                        # duplicate it into hold space.
305   s/\n.*$//                # Restore x<indent> in pattern space, and
306   x                        # exchange with the above duplicate in hold space.
307   s/^x\(.*\)\n\1//         # Remove leading <indent> from <line>.
308   s/^x.*\n//               # Restore <line> when there is no leading <indent>.
309 '
310
311 # unindent [input files...]
312 # -------------------------
313 # Remove the "proper" amount of leading whitespace from the given files,
314 # and output the result on stdout.  That amount is determined by looking
315 # at the leading whitespace of the first non-blank line in the input
316 # files.  If no input file is specified, standard input is implied.
317 unindent ()
318 {
319   if test x"$sed_unindent_prog" = x; then
320     sed_unindent_prog=`printf '%s\n' "$commented_sed_unindent_prog" | sed -e "s/  *# .*//"`
321   fi
322   sed "$sed_unindent_prog" ${1+"$@"}
323 }
324 sed_unindent_prog="" # Avoid interferences from the environment.
325
326 # get_shell_script SCRIPT-NAME
327 # -----------------------------
328 # Fetch an Automake-provided test script from the `lib/' directory into
329 # the current directory, and, if the `$test_prefer_config_shell' variable
330 # is set to "yes", modify its shebang line to use $SHELL instead of
331 # /bin/sh.
332 get_shell_script ()
333 {
334   if test x"$test_prefer_config_shell" = x"yes"; then
335     sed "1s|#!.*|#! $SHELL|" "$top_testsrcdir/lib/$1" > "$1"
336     chmod a+x "$1"
337   else
338     cp "$top_testsrcdir/lib/$1" .
339   fi
340   sed 10q "$1" # For debugging.
341 }
342
343 # require_xsi SHELL
344 # -----------------
345 # Skip the test if the given shell fails to support common XSI constructs.
346 require_xsi ()
347 {
348   test $# -eq 1 || fatal_ "require_xsi needs exactly one argument"
349   echo "$me: trying some XSI constructs with $1"
350   $1 -c "$xsi_shell_code" || skip_ "$1 lacks XSI features"
351 }
352 # Shell code supposed to work only with XSI shells.  Keep this in sync
353 # with libtool.m4:_LT_CHECK_SHELL_FEATURES.
354 xsi_shell_code='
355   _lt_dummy="a/b/c"
356   test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \
357       = c,a/b,b/c, \
358     && eval '\''test $(( 1 + 1 )) -eq 2 \
359     && test "${#_lt_dummy}" -eq 5'\'
360
361
362 ## ----------------------------------------------------------- ##
363 ##  Checks for required tools, and additional setups (if any)  ##
364 ##  required by them.                                          ##
365 ## ----------------------------------------------------------- ##
366
367 # Print it here, so that the user will see it also if the test
368 # will be skipped due to some tool missing in $PATH itself.
369 echo "$PATH"
370
371 # So that we can force the use of correct gcc, g++ etc., consistently
372 # with cross-compilation settings.
373 if cross_compiling; then
374   am__tool_prefix="$host_alias-"
375 else
376   am__tool_prefix=
377 fi
378
379 # Look for (and maybe set up) required tools and/or system features; skip
380 # the current test if they are not found.
381 for tool in : $required
382 do
383   # Check that each required tool is present.
384   case $tool in
385     :) ;;
386     cc)
387       test "$CC"  = false && skip_ "no C compiler available";;
388     c++)
389       test "$CXX" = false && skip_ "no C++ compiler available";;
390     fortran)
391       test "$FC"  = false && skip_ "no Fortran compiler available";;
392     fortran77)
393       test "$F77" = false && skip_ "no Fortran 77 compiler available";;
394     xsi-shell)
395       require_xsi "$SHELL";;
396     xsi-bin-sh)
397       require_xsi "/bin/sh";;
398     xsi-lib-shell)
399       if test x"$test_prefer_config_shell" = x"yes"; then
400         require_xsi "$SHELL"
401       else
402         require_xsi "/bin/sh"
403       fi
404       ;;
405     bzip2)
406       # Do not use --version, bzip2 still tries to compress stdin.
407       echo "$me: running bzip2 --help"
408       bzip2 --help \
409         || skip_ "required program \`bzip2' not available"
410       ;;
411     cl)
412       CC=cl
413       export CC
414       echo "$me: running $CC -?"
415       $CC -? || skip_ "Microsoft C compiler \`$CC' not available"
416       ;;
417     cscope)
418       # Sun cscope is interactive without redirection.
419       echo "$me: running cscope --version </dev/null"
420       cscope --version </dev/null \
421         || skip_ "required program \`cscope' not available"
422       ;;
423     etags)
424       # Exuberant Ctags will create a TAGS file even
425       # when asked for --help or --version.  (Emacs's etags
426       # does not have such problem.)  Use -o /dev/null
427       # to make sure we do not pollute the tests/ directory.
428       echo "$me: running etags --version -o /dev/null"
429       etags --version -o /dev/null \
430         || skip_ "required program \`etags' not available"
431       ;;
432     GNUmake)
433       for make_ in "$MAKE" gmake gnumake :; do
434         MAKE=$make_ am__using_gmake=''
435         test "$MAKE" =  : && break
436         echo "$me: determine whether $MAKE is GNU make"
437         using_gmake && break
438       done
439       test "$MAKE" = : && skip_ "this test requires GNU make"
440       export MAKE
441       unset make_
442       ;;
443     gcc)
444       # When gcc is required, export `CC=gcc' so that ./configure
445       # always use it.  This is important only when the user
446       # has defined CC in his environment, otherwise ./configure will
447       # prefer gcc to other compilers.
448       CC=${am__tool_prefix}gcc
449       export CC
450       echo "$me: running $CC --version"
451       $CC --version || skip_ "GNU C compiler not available"
452       echo "$me: running $CC -v"
453       $CC -v || skip_ "botched installation for GNU C compiler"
454       ;;
455     gcj)
456       GCJ=${am__tool_prefix}gcj
457       export GCJ
458       echo "$me: running $GCJ --version"
459       $GCJ --version || skip_ "GNU Java compiler not available"
460       echo "$me: running $GCJ -v"
461       $GCJ -v || skip_ "botched installation for GNU Java compiler"
462       ;;
463     g++)
464       CXX=${am__tool_prefix}g++
465       export CXX
466       echo "$me: running $CXX --version"
467       $CXX --version || skip_ "GNU C++ compiler not available"
468       echo "$me: running $CXX -v"
469       $CXX -v || skip_ "botched installation for GNU C++ compiler"
470       ;;
471     gfortran)
472       FC=${am__tool_prefix}gfortran
473       export FC
474       echo "$me: running $FC --version"
475       $FC --version || skip_ "GNU Fortran compiler not available"
476       echo "$me: running $FC -v"
477       $FC -v || skip_ "botched installation for GNU Fortran compiler"
478       case " $required " in
479         *\ g77\ *) ;;
480         *) F77=$FC; export F77;;
481       esac
482       ;;
483     g77)
484       F77=${am__tool_prefix}g77
485       export F77
486       echo "$me: running $F77 --version"
487       $F77 --version || skip_ "GNU Fortran 77 compiler not available"
488       echo "$me: running $F77 -v"
489       $F77 -v || skip_ "botched installation for GNU Fortran 77 compiler"
490       case " $required " in
491         *\ gfortran\ *) ;;
492         *) FC=$F77; export FC;;
493       esac
494       ;;
495     icc)
496       CC=icc
497       export CC
498       # There is no way to ask *only* the compiler's version.
499       # This tool always wants to do something (by default
500       # it will try link *nothing* and complain it cannot find
501       # main(); funny).  Use -help so it does not try linking anything.
502       echo "$me: running $CC -V -help"
503       $CC -V -help || skip_ "Intel C compiler \`$CC' not available"
504       ;;
505     javac)
506       # The Java compiler from JDK 1.5 (and presumably earlier versions)
507       # cannot handle the `-version' option by itself: it bails out
508       # telling that source files are missing.  Adding also the `-help'
509       # option seems to solve the problem.
510       echo "$me: running javac -version -help"
511       javac -version -help || skip_ "Sun Java compiler not available"
512       ;;
513     makedepend)
514       echo "$me: running makedepend -f-"
515       makedepend -f- \
516         || skip_ "required program \`makedepend' not available"
517       ;;
518     makeinfo-html)
519       # Make sure we have makeinfo, and it understands `--html'.
520       echo "$me: running makeinfo --html --version"
521       makeinfo --html --version \
522         || skip_ "cannot find a makeinfo program that groks the" \
523                  "\`--html' option"
524       ;;
525     non-root)
526       # Skip this test case if the user is root.
527       # We try to append to a read-only file to detect this.
528       priv_check_temp=priv-check.$$
529       touch $priv_check_temp || exit 99
530       chmod a-w $priv_check_temp || exit 99
531       (echo foo >> $priv_check_temp) >/dev/null 2>&1
532       overwrite_status=$?
533       rm -f $priv_check_temp
534       if test $overwrite_status -eq 0; then
535         skip_ "cannot drop file write permissions"
536       fi
537       unset priv_check_temp overwrite_status
538       ;;
539     perl-threads)
540       if test "$WANT_NO_THREADS" = "yes"; then
541         skip_ "Devel::Cover cannot cope with threads"
542       fi
543       ;;
544     native)
545       cross_compiling && skip_ "doesn't work in cross-compile mode"
546       ;;
547     python)
548       # Python doesn't support --version, it has -V
549       echo "$me: running python -V"
550       python -V || skip_ "python interpreter not available"
551       ;;
552     ro-dir)
553       # Skip this test case if read-only directories aren't supported
554       # (e.g., under DOS.)
555       ro_dir_temp=ro_dir.$$
556       mkdir $ro_dir_temp || exit 99
557       chmod a-w $ro_dir_temp || exit 99
558       (: > $ro_dir_temp/probe) >/dev/null 2>/dev/null
559       create_status=$?
560       rm -rf $ro_dir_temp
561       if test $create_status -eq 0; then
562         skip_ "cannot drop directory write permissions"
563       fi
564       unset ro_dir_temp create_status
565       ;;
566     rst2html)
567       # Try the variants that are tried in check.am.
568       while :; do
569         for r2h in $RST2HTML rst2html rst2html.py; do
570           echo "$me: running $r2h --version"
571           $r2h --version && break 2
572         done
573         skip_ "no proper rst2html program found"
574       done
575       unset r2h
576       ;;
577     runtest)
578       # DejaGnu's runtest program. We rely on being able to specify
579       # the program on the runtest command-line. This requires
580       # DejaGnu 1.4.3 or later.
581       echo "$me: running runtest SOMEPROGRAM=someprogram --version"
582       runtest SOMEPROGRAM=someprogram --version \
583         || skip_ "DejaGnu is not available"
584       ;;
585     tex)
586       # No all versions of Tex support `--version', so we use
587       # a configure check.
588       if test -z "$TEX"; then
589         skip_ "TeX is required, but it wasn't found by configure"
590       fi
591       ;;
592     texi2dvi-o)
593       # Texi2dvi supports `-o' since Texinfo 4.1.
594       echo "$me: running texi2dvi -o /dev/null --version"
595       texi2dvi -o /dev/null --version \
596         || skip_ "required program \`texi2dvi' not available"
597       ;;
598     flex)
599       # Since flex is required, we pick LEX for ./configure.
600       LEX=flex
601       export LEX
602       echo "$me: running flex --version"
603       flex --version || skip_ "required program \`flex' not available"
604       ;;
605     lex)
606       test "$LEX" = false && skip_ "no Lex program available"
607       if test -z "$LEX"; then
608         # The user hasn't explicitly specified any lex program in the
609         # environment, so we try to use flex, skipping the test if it's
610         # not found.
611         LEX=flex
612         export LEX
613         echo "$me: running flex --version"
614         flex --version || skip_ "required program \`flex' not available"
615       fi
616       ;;
617     yacc)
618       test "$YACC" = false && skip_ "no Yacc program available"
619       if test -z "$YACC"; then
620         # The user hasn't explicitly specified any yacc program in the
621         # environment, so we try to use bison, skipping the test if it's
622         # not found.
623         YACC='bison -y'
624         export YACC
625         echo "$me: running bison --version"
626         bison --version || skip_ "required program \`bison' not available"
627       fi
628       ;;
629     *)
630       # Generic case: the tool must support --version.
631       echo "$me: running $tool --version"
632       # It is not likely but possible that $tool is a special builtin,
633       # in which case the shell is allowed to exit after an error.
634       # So, please leave the subshell here.
635       ($tool --version) || skip_ "required program \`$tool' not available"
636       ;;
637   esac
638 done
639
640 # Using just `$testbuilddir' for the check here is ok, since the
641 # further temporary subdirectory where the test will be run is
642 # ensured not to contain any whitespace character.
643 case $testbuilddir in
644   *\ *|*\       *)
645     case " $required " in
646       *' libtool '* | *' libtoolize '* )
647         skip_ "libtool has problems with spaces in builddir name";;
648     esac
649     ;;
650 esac
651
652 # This test is necessary, although Automake's configure script bails out
653 # when $srcdir contains spaces.  This is because $testsrcdir is in not
654 # configure-time $srcdir, but is instead configure-time $abs_srcdir, and
655 # that is allowed to contain spaces.
656 case $testsrcdir in
657   *\ * |*\      *)
658     case " $required " in
659       *' libtool '* | *' libtoolize '* | *' gettext '* )
660         skip_ "spaces in srcdir name: libtool/gettext tests won't work";;
661    esac
662    ;;
663 esac
664
665 # We might need extra macros, e.g., from Libtool or Gettext.
666 # Find them on the system.
667 # Use `-I $top_testsrcdir/m4' in addition to `--acdir=$top_testsrcdir/m4',
668 # because the other `-I' directories added for libtool and gettext might
669 # contain files from an old version of Automake that we don't want to use.
670 # Use `-Wno-syntax' because we do not want our test suite to fail because
671 # some third-party .m4 file is underquoted.
672 case " $required " in
673   *' libtool '* | *' libtoolize '* | *' gettext '* )
674     aclocaldir=$testprefix/share/aclocal
675     extra_includes=""
676     if test -f $aclocaldir/dirlist; then
677        extra_includes=`
678        <$aclocaldir/dirlist \
679        sed  's/#.*//;s/[         ][      ]*$//g' \
680        | while read dir; do test ! -d "$dir" || echo "-I $dir"; done`
681     else :; fi
682
683     libtool_found=no
684     gettext_found=no
685     for d in $extra_includes $aclocaldir ; do
686       test "x$d" != x-I || continue
687       if test -f "$d/libtool.m4"; then
688         libtool_found=yes
689       fi
690       if test -f "$d/gettext.m4"; then
691         gettext_found=yes
692       fi
693     done
694     case " $required " in
695       *' libtool '*|*' libtoolize '*)
696         if test $libtool_found != yes; then
697           # Write more diagnostic to the log file than to the console.
698           echo "$me: \`libtool.m4' wasn't found in directories" \
699                "$aclocaldir $extra_includes"
700           skip_ "libtool m4 macros won't be found by aclocal"
701         fi
702         ;;
703       *' gettext '*)
704         if test $gettext_found != yes; then
705           # Write more diagnostic to the log file than to the console.
706           echo "$me: \`gettext.m4' wasn't found in directories" \
707                "$aclocaldir $extra_includes"
708           skip_ "gettext m4 macros won't be found by aclocal"
709         fi
710         ;;
711     esac
712     ACLOCAL="$ACLOCAL -Wno-syntax -I $top_testsrcdir/m4 $extra_includes -I $aclocaldir"
713     unset libtool_found gettext_found
714     unset extra_includes aclocaldir
715     ;;
716 esac
717
718
719 ## ---------------------------------------------------------------- ##
720 ##  Create and set up of the temporary directory used by the test.  ##
721 ##  Set up of the exit trap for cleanup of said directory.          ##
722 ## ---------------------------------------------------------------- ##
723
724 # This might be used in testcases checking distribution-related features.
725 # Test scripts are free to override this if they need to.
726 distdir=$me-1.0
727
728 # The subdirectory where the current test script will run and write its
729 # temporary/data files.  This will be created shortly, and will be removed
730 # by the cleanup trap below if the test passes.  If the test doesn't pass,
731 # this directory will be kept, to facilitate debugging.
732 testSubDir=$me.dir
733
734 test ! -d $testSubDir || {
735   find $testSubDir -type d ! -perm -700 -exec chmod u+rwx {} ";"
736   rm -rf $testSubDir
737 }
738 mkdir $testSubDir
739
740 cd ./$testSubDir
741
742 if test "$sh_errexit_works" = yes; then
743   trap 'exit_status=$?
744     set +e
745     cd "$testbuilddir"
746     # This is to ensure that a test script does give a SKIP outcome just
747     # because a command in it happens to exit with status 77.  This
748     # behaviour, while from time to time useful to developers, is not
749     # meant to be enabled by default, as it could cause spurious failures
750     # in the wild.  Thus it will be enabled only when the variable
751     # "am_explicit_skips" is set to a "true" value.
752     case $am_explicit_skips in
753       [yY]|[yY]es|1)
754         if test $exit_status -eq 77 && test $am__test_skipped != yes; then
755           exit_status=78
756         fi
757         ;;
758     esac
759     case $exit_status,$keep_testdirs in
760     0,)
761       find $testSubDir -type d ! -perm -700 -exec chmod u+rwx {} ";"
762       rm -rf $testSubDir
763       ;;
764     esac
765     test "$signal" != 0 && echo "$me: caught signal $signal"
766     echo "$me: exit $exit_status"
767     exit $exit_status
768   ' 0
769   for signal in 1 2 13 15; do
770     trap 'signal='$signal'; { Exit 99; }' $signal
771   done
772   signal=0
773 fi
774
775 # Copy in some files we need.
776 for file in install-sh missing depcomp; do
777    cp "$top_testsrcdir/lib/$file" . || Exit 99
778 done
779
780 # Build appropriate environment in test directory.  Eg create
781 # configure.in, touch all necessary files, etc.
782 # Don't use AC_OUTPUT, but AC_CONFIG_FILES so that appending
783 # still produces a valid configure.ac.  But then, tests running
784 # config.status really need to append AC_OUTPUT.
785 {
786   echo "AC_INIT([$me], [1.0])"
787   if test x"$parallel_tests" = x"yes"; then
788     echo "AM_INIT_AUTOMAKE([parallel-tests])"
789   else
790     echo "AM_INIT_AUTOMAKE"
791   fi
792   echo "AC_CONFIG_FILES([Makefile])"
793 } >configure.in
794
795 ## ---------------- ##
796 ##  Ready to go...  ##
797 ## ---------------- ##
798
799 set -x
800 set -e
801
802 pwd