news: describe recently-fixed bug in vala support
[platform/upstream/automake.git] / tests / defs.in
1 # -*- shell-script -*-
2 # @configure_input@
3 #
4 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
5 # 2005, 2006, 2007, 2008, 2009, 2011 Free Software Foundation, 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 # Defines for Automake testing environment.
21 # Tom Tromey <tromey@cygnus.com>
22
23 # Be more Bourne compatible.
24 # (Snippet copied from configure's initialization in Autoconf 2.64)
25 DUALCASE=1; export DUALCASE # for MKS sh
26 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
27   emulate sh
28   NULLCMD=:
29   # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
30   # is contrary to our usage.  Disable this feature.
31   alias -g '${1+"$@"}'='"$@"'
32   setopt NO_GLOB_SUBST
33 else
34   case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
35 fi
36
37 # A single whitespace character.
38 sp=' '
39 # A tabulation character.
40 tab='   '
41 # A newline character.
42 nl='
43 '
44
45 # As autoconf-generated configure scripts do, ensure that IFS
46 # is defined initially, so that saving and restoring $IFS works.
47 IFS=$sp$tab$nl
48
49 # Ensure we are running from the right directory.
50 test -f ./defs || {
51    echo "defs: not found in current directory" 1>&2
52    exit 1
53 }
54
55 if test -z "$srcdir"; then
56    # compute $srcdir.
57    srcdir=`echo "$0" | sed -e 's,/[^\\/]*$,,'`
58    test "$srcdir" = $0 && srcdir=.
59 else :; fi
60
61 # Ensure $srcdir is set correctly.
62 test -f "$srcdir/defs.in" || {
63    echo "$srcdir/defs.in not found, check \$srcdir" 1>&2
64    exit 1
65 }
66
67 # The name of the current test (without the `.test' suffix).
68 # Test scripts can override it if they need to (but this should
69 # be done carefully, and *before* including ./defs).
70 if test -z "$me"; then
71   me=`echo "$0" | sed -e 's,.*[\\/],,;s/\.test$//'`
72 elif env | grep '^me=' >/dev/null; then
73   echo "$0: variable \`me' is set in the environment: this is unsafe" >&2
74   exit 99
75 fi
76
77 # Check that the environment is properly sanitized.
78 for var in required parallel_tests; do
79   if env | grep "^$var=" >/dev/null; then
80     echo "$me: variable \`$var' is set in the environment:" \
81          "this is unsafe" >&2
82     exit 99
83   fi
84 done
85 unset var
86
87 # This might be used in testcases checking distribution-related features.
88 # Test scripts are free to override this if they need to.
89 distdir=$me-1.0
90
91 APIVERSION='@APIVERSION@'
92 PATH_SEPARATOR='@PATH_SEPARATOR@'
93
94 # Make sure we override the user shell.
95 SHELL='@SHELL@'
96 export SHELL
97 # User can override various tools used.
98 MAKE=${AM_TESTSUITE_MAKE-${MAKE-'make'}}
99 test -z "$PERL" && PERL='@PERL@'
100 test -z "$AUTOCONF" && AUTOCONF="@am_AUTOCONF@"
101 test -z "$AUTOM4TE" && AUTOM4TE="@am_AUTOM4TE@"
102 test -z "$AUTORECONF" && AUTORECONF="@am_AUTORECONF@"
103 test -z "$AUTOHEADER" && AUTOHEADER="@am_AUTOHEADER@"
104 test -z "$AUTOUPDATE" && AUTOUPDATE="@am_AUTOUPDATE@"
105 test -z "$MISSING" && MISSING=`pwd`/../lib/missing
106
107 # This is a hack to seamlessly support the infamous "autoconf wrappers",
108 # that might dispatch different autoconf versions depending on the name
109 # of the input files and/or the command-line options used.  See:
110 # <http://lists.gnu.org/archive/html/automake/2011-12/msg00039.html>
111 # FIXME: in the long run, the better fix will be to convert our testsuite
112 # to use `configure.ac' instead of `configure.in' as autoconf input.
113 AUTOCONF="$AUTOCONF -B /no/such/dir"
114 AUTOM4TE="$AUTOM4TE -B /no/such/dir"
115 AUTORECONF="$AUTORECONF -B /no/such/dir"
116
117 # Use -Werror because this also turns some Perl warnings into error.
118 # (Tests for which this is inappropriate should use -Wno-error.)
119 test -z "$ACLOCAL" && ACLOCAL="aclocal-$APIVERSION -Werror"
120
121 # See how Automake should be run.  We put --foreign as the default
122 # strictness to avoid having to create lots and lots of files.  A test
123 # can override this by specifying a different strictness.  Use -Wall
124 # -Werror by default.  Tests for which this is inappropriate
125 # (e.g. when testing that a warning is enabled by a specific switch)
126 # should use -Wnone or/and -Wno-error
127 test -z "$AUTOMAKE" && AUTOMAKE="automake-$APIVERSION --foreign -Werror -Wall"
128
129 PATH="`pwd`$PATH_SEPARATOR$PATH"
130 echo "$PATH"
131 # Some shells forget to export modified environment variables.
132 # (See note about `export' in the Autoconf manual.)
133 export PATH
134
135 # We use a trap below for cleanup.  This requires us to go through
136 # hoops to get the right exit status transported through the signal.
137 # So use `Exit STATUS' instead of `exit STATUS' inside of the tests.
138 # Turn off errexit here so that we don't trip the bug with OSF1/Tru64
139 # sh inside this function.
140 Exit ()
141 {
142   set +e
143   (exit $1)
144   exit $1
145 }
146
147 # Print warnings (e.g., about skipped and failed tests) to this file
148 # number.  Override by putting, say:
149 #   stderr_fileno_=9; export stderr_fileno_; exec 9>&2;
150 # in the definition of AM_TESTS_ENVIRONMENT.
151 # This is useful when using automake's parallel tests mode, to print the
152 # reason for skip/failure to console, rather than to the *.log files.
153 : ${stderr_fileno_=2}
154
155 # Copied from Gnulib's `tests/init.sh'.
156 warn_ () { echo "$@" 1>&$stderr_fileno_; }
157 fail_ () { warn_ "$me: failed test: $@"; Exit 1; }
158 skip_ () { warn_ "$me: skipped test: $@"; Exit 77; }
159 fatal_ () { warn_ "$me: hard error: $@"; Exit 99; }
160 framework_failure_ () { warn_ "$me: set-up failure: $@"; Exit 99; }
161
162 # cross_compiling
163 # ---------------
164 # Tell whether we are cross-compiling.  This is especially useful to skip
165 # tests (or portions of them) that requires a native compiler.
166 cross_compiling ()
167 {
168   test x"$host_alias" != x
169 }
170
171 # So that we can force the use of correct gcc, g++ etc., consistently
172 # with cross-compilation settings.
173 if cross_compiling; then
174   am__tool_prefix="$host_alias-"
175 else
176   am__tool_prefix=
177 fi
178
179 for tool in : $required
180 do
181   # Check that each required tool is present.
182   case $tool in
183     :) ;;
184     bison|yacc)
185       # Since bison is required, we pick YACC for ./configure.
186       YACC='bison -y'
187       export YACC
188       echo "$me: running bison --version"
189       ( bison --version ) || exit 77
190       ;;
191     flex|lex)
192       # Since flex is required, we pick LEX for ./configure.
193       LEX=flex
194       export LEX
195       echo "$me: running flex --version"
196       flex --version || exit 77
197       ;;
198     cc|c++|fortran|fortran77)
199       echo "$me: dummy requirement '$tool', no check done"
200       ;;
201     bzip2)
202       # Do not use --version, bzip2 still tries to compress stdin.
203       echo "$me: running bzip2 --help"
204       ( bzip2 --help ) || exit 77
205       ;;
206     etags)
207       # Exuberant Ctags will create a TAGS file even
208       # when asked for --help or --version.  (Emacs's etags
209       # does not have such problem.)  Use -o /dev/null
210       # to make sure we do not pollute the tests/ directory.
211       echo "$me: running etags --version -o /dev/null"
212       ( etags --version -o /dev/null ) || exit 77
213       ;;
214     GNUmake)
215       # Use --version AND -v, because SGI Make doesn't fail on --version.
216       # Also grep for GNU because newer versions of FreeBSD make do
217       # not complain about `--version' (they seem to silently ignore it).
218       echo "$me: running $MAKE --version -v | grep GNU"
219       ( $MAKE --version -v | grep GNU ) || exit 77
220       ;;
221     gcc)
222       # When gcc is required, export `CC=gcc' so that ./configure
223       # always use it.  This is important only when the user
224       # has defined CC in his environment, otherwise ./configure will
225       # prefer gcc to other compilers.
226       CC=${am__tool_prefix}gcc
227       export CC
228       echo "$me: running $CC --version"
229       ( $CC --version ) || exit 77
230       ;;
231     gcj)
232       GCJ=${am__tool_prefix}gcj
233       export GCJ
234       echo "$me: running $GCJ --version"
235       ( $GCJ --version ) || exit 77
236       ( $GCJ -v ) || exit 77
237       ;;
238     g++)
239       CXX=${am__tool_prefix}g++
240       export CXX
241       echo "$me: running $CXX --version"
242       ( $CXX --version ) || exit 77
243       ;;
244     gfortran)
245       FC=${am__tool_prefix}gfortran
246       export FC
247       echo "$me: running $FC --version"
248       $FC --version || skip_ "GNU Fortran compiler not available"
249       echo "$me: running $FC -v"
250       $FC -v || skip_ "botched installation for GNU Fortran compiler"
251       case " $required " in
252         *\ g77\ *) ;;
253         *) F77=$FC; export F77;;
254       esac
255       ;;
256     g77)
257       F77=${am__tool_prefix}g77
258       export F77
259       echo "$me: running $F77 --version"
260       $F77 --version || skip_ "GNU Fortran 77 compiler not available"
261       echo "$me: running $F77 -v"
262       $F77 -v || skip_ "botched installation for GNU Fortran 77 compiler"
263       case " $required " in
264         *\ gfortran\ *) ;;
265         *) FC=$F77; export FC;;
266       esac
267       ;;
268     icc)
269       CC=icc
270       export CC
271       # There is no way to ask *only* the compiler's version.
272       # This tool always wants to do something (by default
273       # it will try link *nothing* and complain it cannot find
274       # main(); funny).  Use -help so it does not try linking anything.
275       echo "$me: running $CC -V -help"
276       ( $CC -V -help ) || exit 77
277       ;;
278     javac)
279       # The Java compiler from JDK 1.5 (and presumably earlier versions)
280       # cannot handle the `-version' option by itself: it bails out
281       # telling that source files are missing.  Adding also the `-help'
282       # option seems to solve the problem.
283       echo "$me: running javac -version -help"
284       javac -version -help || exit 77
285       ;;
286     makedepend)
287       echo "$me: running makedepend -f-"
288       ( makedepend -f- ) || exit 77
289       ;;
290     makeinfo-html)
291       # Make sure makeinfo understands --html.
292       echo "$me: running makeinfo --html --version"
293       ( makeinfo --html --version ) || exit 77
294       ;;
295     non-root)
296       # Skip this test case if the user is root.
297       # We try to append to a read-only file to detect this.
298       priv_check_temp=priv-check.$$
299       touch $priv_check_temp || exit 1
300       chmod a-w $priv_check_temp || exit 1
301       (echo foo >> $priv_check_temp) >/dev/null 2>&1
302       overwrite_status=$?
303       rm -f $priv_check_temp
304       test $overwrite_status = 0 && exit 77
305       ;;
306     native)
307       cross_compiling && skip_ "doesn't work in cross-compile mode"
308       ;;
309     python)
310       # Python doesn't support --version, it has -V
311       echo "$me: running python -V"
312       ( python -V ) || exit 77
313       ;;
314     ro-dir)
315       # Skip this test case if read-only directories aren't supported
316       # (e.g., under DOS.)
317       ro_dir_temp=ro_dir.$$
318       mkdir $ro_dir_temp || exit 1
319       chmod a-w $ro_dir_temp || exit 1
320       (: > $ro_dir_temp/probe) >/dev/null 2>/dev/null
321       create_status=$?
322       rm -rf $ro_dir_temp
323       test $create_status = 0 && exit 77
324       ;;
325     rst2html)
326       # Try the variants that are tried in check.am.
327       while :; do
328         for r2h in $RST2HTML rst2html rst2html.py; do
329           echo "$me: running $r2h --version"
330           $r2h --version && break 2
331         done
332         exit 77
333       done
334       ;;
335     runtest)
336       # DejaGnu's runtest program. We rely on being able to specify
337       # the program on the runtest command-line. This requires
338       # DejaGnu 1.4.3 or later.
339       echo "$me: running runtest --version"
340       (runtest SOMEPROGRAM=someprogram --version) || exit 77
341       ;;
342     tex)
343       # No all versions of Tex support `--version', so we use
344       # a configure check.
345       test -n "@TEX@" || exit 77
346       ;;
347     texi2dvi-o)
348       # Texi2dvi supports `-o' since Texinfo 4.1.
349       echo "$me: running texi2dvi -o /dev/null --version"
350       ( texi2dvi -o /dev/null --version ) || exit 77
351       ;;
352     # Generic case: the tool must support --version.
353     *)
354       echo "$me: running $tool --version"
355       ( $tool --version ) || exit 77
356       ;;
357   esac
358 done
359
360
361 # Always use an absolute srcdir.  Otherwise symlinks made in subdirs
362 # of the test dir just won't work.
363 case "$srcdir" in
364  [\\/]* | ?:[\\/]*)
365     ;;
366
367  *)
368     srcdir=`CDPATH=: && cd "$srcdir" && pwd`
369     ;;
370 esac
371
372 curdir=`pwd`
373 testSubDir=$me.dir
374 test ! -d $testSubDir || {
375   find $testSubDir -type d ! -perm -700 -exec chmod u+rwx {} ";"
376   rm -rf $testSubDir
377 }
378 mkdir $testSubDir
379
380 sh_errexit_works=@sh_errexit_works@
381 if test "$sh_errexit_works" = yes; then
382   trap 'exit_status=$?
383     set +e
384     cd "$curdir"
385     case $exit_status,$keep_testdirs in
386     0,)
387       find $testSubDir -type d ! -perm -700 -exec chmod u+rwx {} ";"
388       rm -rf $testSubDir
389       ;;
390     esac
391     test "$signal" != 0 &&
392       echo "$me: caught signal $signal"
393     echo "$me: exit $exit_status"
394     exit $exit_status
395   ' 0
396   for signal in 1 2 13 15; do
397     trap 'signal='$signal'; { Exit 1; }' $signal
398   done
399 fi
400 signal=0
401
402 # Copy in some files we need.
403 for file in install-sh missing depcomp; do
404    cp "$srcdir/../lib/$file" "$testSubDir/$file" || Exit 1
405 done
406
407 cd ./$testSubDir
408
409 # Build appropriate environment in test directory.  Eg create
410 # configure.in, touch all necessary files, etc.
411 # Don't use AC_OUTPUT, but AC_CONFIG_FILES so that appending
412 # still produces a valid configure.ac.  But then, tests running
413 # config.status really need to append AC_OUTPUT.
414 {
415   echo "AC_INIT([$me], [1.0])"
416   if test x"$parallel_tests" = x"yes"; then
417     echo "AM_INIT_AUTOMAKE([parallel-tests])"
418   else
419     echo "AM_INIT_AUTOMAKE"
420   fi
421   echo "AC_CONFIG_FILES([Makefile])"
422 } >configure.in
423
424 # Unset some make-related variables that may cause $MAKE to act like
425 # a recursively invoked sub-make.  Any $MAKE invocation in a test is
426 # conceptually an independent invocation, not part of the main
427 # 'automake' build.
428 unset MFLAGS MAKEFLAGS AM_MAKEFLAGS MAKELEVEL
429 unset __MKLVL__ MAKE_JOBS_FIFO                     # For BSD make.
430 unset DMAKE_CHILD DMAKE_DEF_PRINTED DMAKE_MAX_JOBS # For Solaris dmake.
431 # Unset verbosity flag.
432 unset V
433 # Also unset variables that will let `make -e install' divert
434 # files into unwanted directories.
435 unset DESTDIR
436 unset prefix exec_prefix bindir datarootdir datadir docdir dvidir
437 unset htmldir includedir infodir libdir libexecdir localedir mandir
438 unset oldincludedir pdfdir psdir sbindir sharedstatedir sysconfdir
439 # Unset variables that might change the "make distcheck" behaviour.
440 unset DISTCHECK_CONFIGURE_FLAGS AM_DISTCHECK_CONFIGURE_FLAGS
441 # Also unset variables that control our test driver.  While not
442 # conceptually independent, they cause some changed semantics we
443 # need to control (and test for) in some of the tests to ensure
444 # backward-compatible behavior.
445 unset TESTS_ENVIRONMENT AM_TESTS_ENVIRONMENT
446 unset DISABLE_HARD_ERRORS
447 unset AM_COLOR_TESTS
448 unset TESTS
449 unset TEST_LOG_COMPILER
450 unset TEST_LOGS
451 unset RECHECK_LOGS
452 unset VERBOSE
453
454 echo "=== Running test $0"
455
456 # We might need extra macros, e.g., from Libtool or Gettext.
457 case " $required " in *\ libtool*) . ../libtool-macros.dir/get.sh;; esac
458 case " $required " in *\ gettext*) . ../gettext-macros.dir/get.sh;; esac
459
460 testaclocaldir='@abs_top_srcdir@/m4'
461
462 # POSIX no longer requires 'egrep' and 'fgrep',
463 # but some hosts lack 'grep -E' and 'grep -F'.
464 EGREP='@EGREP@'
465 FGREP='@FGREP@'
466
467 # The amount we should wait after modifying files depends on the platform.
468 # For instance, Windows '95, '98 and ME have 2-second granularity
469 # and can be up to 3 seconds in the future w.r.t. the system clock.
470 sleep='sleep @MODIFICATION_DELAY@'
471
472 # The tests call `make -e' but we do not want $srcdir from the environment
473 # to override the definition from the Makefile.
474 testsrcdir=$srcdir
475 unset srcdir
476
477 # An old timestamp that can be given to a file, in "touch -t" format.
478 # The time stamp should be portable to all file systems of interest.
479 # Just for fun, choose the exact time of the announcement of the GNU project
480 # in UTC; see <http://www.gnu.org/gnu/initial-announcement.html>.
481 old_timestamp=198309271735.59
482
483 # is_newest FILE FILES
484 # --------------------
485 # Return false if any file in FILES is newer than FILE.
486 # Resolve ties in favor of FILE.
487 is_newest ()
488 {
489   is_newest_files=`find "$@" -prune -newer "$1"`
490   test -z "$is_newest_files"
491 }
492
493 # using_gmake
494 # -----------
495 # Return success if $MAKE is GNU make, return failure otherwise.
496 # Caches the result for speed reasons.
497 using_gmake ()
498 {
499   case $am__using_gmake in
500     yes)
501       return 0;;
502     no)
503       return 1;;
504     '')
505       # Use --version AND -v, because SGI Make doesn't fail on --version.
506       # Also grep for GNU because newer versions of FreeBSD make do
507       # not complain about `--version' (they seem to silently ignore it).
508       if $MAKE --version -v | grep GNU; then
509         am__using_gmake=yes
510         return 0
511       else
512         am__using_gmake=no
513         return 1
514       fi;;
515     *)
516       fatal_ "invalid value for \$am__using_gmake: '$am__using_gmake'";;
517   esac
518 }
519 am__using_gmake="" # Avoid interferences from the environment.
520
521 # AUTOMAKE_run status [options...]
522 # --------------------------------
523 # Run Automake with OPTIONS, and fail if automake
524 # does not exit with STATUS.
525 AUTOMAKE_run ()
526 {
527   expected_exitcode=$1
528   shift
529   exitcode=0
530   $AUTOMAKE ${1+"$@"} >stdout 2>stderr || exitcode=$?
531   cat stderr >&2
532   cat stdout
533   test $exitcode = $expected_exitcode || Exit 1
534 }
535
536 # AUTOMAKE_fails [options...]
537 # ---------------------------
538 # Run Automake with OPTIONS, and fail if automake
539 # does not exit with STATUS.
540 AUTOMAKE_fails ()
541 {
542   AUTOMAKE_run 1 ${1+"$@"}
543 }
544
545 commented_sed_unindent_prog='
546   /^$/b                    # Nothing to do for empty lines.
547   x                        # Get x<indent> into pattern space.
548   /^$/{                    # No prior x<indent>, go prepare it.
549     g                      # Copy this 1st non-blank line into pattern space.
550     s/^\(['"$tab"' ]*\).*/x\1/   # Prepare x<indent> in pattern space.
551   }                        # Now: x<indent> in pattern and <line> in hold.
552   G                        # Build x<indent>\n<line> in pattern space, and
553   h                        # duplicate it into hold space.
554   s/\n.*$//                # Restore x<indent> in pattern space, and
555   x                        # exchange with the above duplicate in hold space.
556   s/^x\(.*\)\n\1//         # Remove leading <indent> from <line>.
557   s/^x.*\n//               # Restore <line> when there is no leading <indent>.
558 '
559
560 # unindent [input files...]
561 # -------------------------
562 # Remove the "proper" amount of leading whitespace from the given files,
563 # and output the result on stdout.  That amount is determined by looking
564 # at the leading whitespace of the first non-blank line in the input
565 # files.  If no input file is specified, standard input is implied.
566 unindent ()
567 {
568   if test x"$sed_unindent_prog" = x; then
569     sed_unindent_prog=`printf '%s\n' "$commented_sed_unindent_prog" | sed -e "s/  *# .*//"`
570   fi
571   sed "$sed_unindent_prog" ${1+"$@"}
572 }
573 sed_unindent_prog="" # Avoid interferences from the environment.
574
575 # Turn on shell traces.
576 set -x
577
578 pwd