Support more C++ file extensions for MSVC in the compile script.
[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  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 # Ensure we are running from the right directory.
38 test -f ./defs || {
39    echo "defs: not found in current directory" 1>&2
40    exit 1
41 }
42
43 if test -z "$srcdir"; then
44    # compute $srcdir.
45    srcdir=`echo "$0" | sed -e 's,/[^\\/]*$,,'`
46    test "$srcdir" = $0 && srcdir=.
47 else :; fi
48
49 # Ensure $srcdir is set correctly.
50 test -f "$srcdir/defs.in" || {
51    echo "$srcdir/defs.in not found, check \$srcdir" 1>&2
52    exit 1
53 }
54
55 me=`echo "$0" | sed -e 's,.*[\\/],,;s/\.test$//'`
56
57 # Make sure we override the user shell.
58 SHELL='@SHELL@'
59 export SHELL
60 # User can override various tools used.
61 test -z "$PERL" && PERL='@PERL@'
62 test -z "$MAKE" && MAKE=make
63 test -z "$AUTOCONF" && AUTOCONF="@am_AUTOCONF@"
64 test -z "$AUTOHEADER" && AUTOHEADER="@am_AUTOHEADER@"
65 test -z "$AUTOUPDATE" && AUTOUPDATE=autoupdate
66 test -z "$MISSING" && MISSING=`pwd`/../lib/missing
67 # Use -Werror because this also turns some Perl warnings into error.
68 # (Tests for which this is inappropriate should use -Wno-error.)
69 test -z "$ACLOCAL" && ACLOCAL="aclocal-@APIVERSION@ -Werror"
70 # Extra flags to pass to aclocal before all other flags added by this script.
71 ACLOCAL_TESTSUITE_FLAGS=
72 export ACLOCAL_TESTSUITE_FLAGS
73
74 # See how Automake should be run.  We put --foreign as the default
75 # strictness to avoid having to create lots and lots of files.  A test
76 # can override this by specifying a different strictness.  Use -Wall
77 # -Werror by default.  Tests for which this is inappropriate
78 # (e.g. when testing that a warning is enabled by a specific switch)
79 # should use -Wnone or/and -Wno-error
80 test -z "$AUTOMAKE" && AUTOMAKE="automake-@APIVERSION@ --foreign -Werror -Wall"
81
82 PATH="`pwd`@PATH_SEPARATOR@$PATH"
83 echo "$PATH"
84 # Some shells forget to export modified environment variables.
85 # (See note about `export' in the Autoconf manual.)
86 export PATH
87
88 for tool in : $required
89 do
90   # Check that each required tool is present.
91   case $tool in
92     :) ;;
93     bison)
94       # Since bison is required, we pick YACC for ./configure.
95       YACC='bison -y'
96       export YACC
97       echo "$me: running bison --version"
98       ( bison --version ) || exit 77
99       ;;
100     bzip2)
101       # Do not use --version, bzip2 still tries to compress stdin.
102       echo "$me: running bzip2 --help"
103       ( bzip2 --help ) || exit 77
104       ;;
105     cl)
106       CC=cl
107       export CC
108       echo "$me: running $CC -?"
109       ( $CC -? ) || exit 77
110       ;;
111     etags)
112       # Exuberant Ctags will create a TAGS file even
113       # when asked for --help or --version.  (Emacs's etags
114       # does not have such problem.)  Use -o /dev/null
115       # to make sure we do not pollute the tests/ directory.
116       echo "$me: running etags --version -o /dev/null"
117       ( etags --version -o /dev/null ) || exit 77
118       ;;
119     GNUmake)
120       # Use --version AND -v, because SGI Make doesn't fail on --version.
121       # Also grep for GNU because newer versions of FreeBSD make do
122       # not complain about `--version' (they seem to silently ignore it).
123       echo "$me: running $MAKE --version -v | grep GNU"
124       ( $MAKE --version -v | grep GNU ) || exit 77
125       ;;
126     gcc)
127       # When gcc is required, export `CC=gcc' so that ./configure
128       # always use it.  This is important only when the user
129       # has defined CC in his environment, otherwise ./configure will
130       # prefer gcc to other compilers.
131       CC=gcc
132       export CC
133       echo "$me: running $CC --version"
134       ( $CC --version ) || exit 77
135       ;;
136     gcj)
137       GCJ=gcj
138       export GCJ
139       echo "$me: running $GCJ --version"
140       ( $GCJ --version ) || exit 77
141       ( $GCJ -v ) || exit 77
142       ;;
143     g++)
144       CXX=g++
145       export CXX
146       echo "$me: running $CXX --version"
147       ( $CXX --version ) || exit 77
148       ;;
149     icc)
150       CC=icc
151       export CC
152       # There is no way to ask *only* the compiler's version.
153       # This tool always wants to do something (by default
154       # it will try link *nothing* and complain it cannot find
155       # main(); funny).  Use -help so it does not try linking anything.
156       echo "$me: running $CC -V -help"
157       ( $CC -V -help ) || exit 77
158       ;;
159     makedepend)
160       echo "$me: running makedepend -f-"
161       ( makedepend -f- ) || exit 77
162       ;;
163     makeinfo-html)
164       # Make sure makeinfo understands --html.
165       echo "$me: running makeinfo --html --version"
166       ( makeinfo --html --version ) || exit 77
167       ;;
168     non-root)
169       # Skip this test case if the user is root.
170       # We try to append to a read-only file to detect this.
171       priv_check_temp=priv-check.$$
172       touch $priv_check_temp || exit 1
173       chmod a-w $priv_check_temp || exit 1
174       (echo foo >> $priv_check_temp) >/dev/null 2>&1
175       overwrite_status=$?
176       rm -f $priv_check_temp
177       test $overwrite_status = 0 && exit 77
178       ;;
179     python)
180       # Python doesn't support --version, it has -V
181       echo "$me: running python -V"
182       ( python -V ) || exit 77
183       ;;
184     ro-dir)
185       # Skip this test case if read-only directories aren't supported
186       # (e.g., under DOS.)
187       ro_dir_temp=ro_dir.$$
188       mkdir $ro_dir_temp || exit 1
189       chmod a-w $ro_dir_temp || exit 1
190       (: > $ro_dir_temp/probe) >/dev/null 2>/dev/null
191       create_status=$?
192       rm -rf $ro_dir_temp
193       test $create_status = 0 && exit 77
194       ;;
195     rst2html)
196       # Try the variants that are tried in check.am.
197       while :; do
198         for r2h in $RST2HTML rst2html rst2html.py; do
199           echo "$me: running $r2h --version"
200           $r2h --version && break 2
201         done
202         exit 77
203       done
204       ;;
205     runtest)
206       # DejaGnu's runtest program. We rely on being able to specify
207       # the program on the runtest command-line. This requires
208       # DejaGnu 1.4.3 or later.
209       echo "$me: running runtest --version"
210       (runtest SOMEPROGRAM=someprogram --version) || exit 77
211       ;;
212     tex)
213       # No all versions of Tex support `--version', so we use
214       # a configure check.
215       test -n "@TEX@" || exit 77
216       ;;
217     texi2dvi-o)
218       # Texi2dvi supports `-o' since Texinfo 4.1.
219       echo "$me: running texi2dvi -o /dev/null --version"
220       ( texi2dvi -o /dev/null --version ) || exit 77
221       ;;
222     # Generic case: the tool must support --version.
223     *)
224       echo "$me: running $tool --version"
225       ( $tool --version ) || exit 77
226       ;;
227   esac
228 done
229
230
231 # Always use an absolute srcdir.  Otherwise symlinks made in subdirs
232 # of the test dir just won't work.
233 case "$srcdir" in
234  [\\/]* | ?:[\\/]*)
235     ;;
236
237  *)
238     srcdir=`CDPATH=: && cd "$srcdir" && pwd`
239     ;;
240 esac
241
242 # We use a trap below for cleanup.  This requires us to go through
243 # hoops to get the right exit status transported through the signal.
244 # So use `Exit STATUS' instead of `exit STATUS' inside of the tests.
245 # Turn off errexit here so that we don't trip the bug with OSF1/Tru64
246 # sh inside this function.
247 Exit ()
248 {
249   set +e
250   (exit $1)
251   exit $1
252 }
253
254 curdir=`pwd`
255 testSubDir=$me.dir
256 test ! -d $testSubDir || {
257   find $testSubDir -type d ! -perm -200 -exec chmod u+w {} ";"
258   rm -rf $testSubDir
259 }
260 mkdir $testSubDir
261
262 sh_errexit_works=@sh_errexit_works@
263 if test "$sh_errexit_works" = yes; then
264   trap 'exit_status=$?
265     set +e
266     cd "$curdir"
267     case $exit_status,$keep_testdirs in
268     0,)
269       find $testSubDir -type d ! -perm -200 -exec chmod u+w {} ";"
270       rm -rf $testSubDir
271       ;;
272     esac
273     test "$signal" != 0 &&
274       echo "$me: caught signal $signal"
275     echo "$me: exit $exit_status"
276     exit $exit_status
277   ' 0
278   for signal in 1 2 13 15; do
279     trap 'signal='$signal'; { Exit 1; }' $signal
280   done
281 fi
282 signal=0
283
284 # Copy in some files we need.
285 for file in install-sh missing depcomp; do
286    cp "$srcdir/../lib/$file" "$testSubDir/$file" || Exit 1
287 done
288
289 cd ./$testSubDir
290
291 # Build appropriate environment in test directory.  Eg create
292 # configure.in, touch all necessary files, etc.
293 # Don't use AC_OUTPUT, but AC_CONFIG_FILES so that appending
294 # still produces a valid configure.ac.  But then, tests running
295 # config.status really need to append AC_OUTPUT.
296 {
297   echo "AC_INIT([$me], [1.0])"
298   if test x"$parallel_tests" = x"yes"; then
299     echo "AM_INIT_AUTOMAKE([parallel-tests])"
300   else
301     echo "AM_INIT_AUTOMAKE"
302   fi
303   echo "AC_CONFIG_FILES([Makefile])"
304 } >configure.in
305
306 # Unset some MAKE... variables that may cause $MAKE to act like a
307 # recursively invoked sub-make.  Any $MAKE invocation in a test is
308 # conceptually an independent invocation, not part of the main
309 # 'automake' build.
310 unset MFLAGS MAKEFLAGS AM_MAKEFLAGS MAKELEVEL __MKLVL__ MAKE_JOBS_FIFO
311 # Unset verbosity flag.
312 unset V
313 # Also unset variables that will let `make -e install' divert
314 # files into unwanted directories.
315 unset DESTDIR
316 unset prefix exec_prefix bindir datarootdir datadir docdir dvidir
317 unset htmldir includedir infodir libdir libexecdir localedir mandir
318 unset oldincludedir pdfdir psdir sbindir sharedstatedir sysconfdir
319 # Also unset variables that control our test driver.  While not
320 # conceptually independent, they cause some changed semantics we
321 # need to control (and test for) in some of the tests to ensure
322 # backward-compatible behavior.
323 unset DISABLE_HARD_ERRORS
324 unset TESTS
325 unset TEST_LOG_COMPILER
326 unset TEST_LOGS
327 unset RECHECK_LOGS
328 unset VERBOSE
329
330 echo "=== Running test $0"
331
332 # We might need extra macros, e.g., from Libtool or Gettext.
333 # Find them on the system.
334 # Use `-I $srcdir/../m4' in addition to `--acdir=$srcdir/../m4', because the
335 # other `-I' directories added for libtool and gettext might contain
336 # files from an old version of Automake that we don't want to use.
337 # Use `-Wno-syntax' because we do not want our test suite to fail because
338 # some third-party .m4 file is underquoted.
339 case $required in
340   *libtool* | *gettext* )
341     aclocaldir='@prefix@/share/aclocal'
342     extra_includes=""
343     if test -f $aclocaldir/dirlist; then
344        extra_includes=`
345        <$aclocaldir/dirlist \
346        sed  's/#.*//;s/[         ][      ]*$//g' \
347        | while read dir; do test ! -d "$dir" || echo "-I $dir"; done`
348     else :; fi
349
350     libtool_found=no
351     gettext_found=no
352     for d in $extra_includes $aclocaldir ; do
353        test "x$d" != x-I || continue
354        if test -f "$d/libtool.m4"; then
355           libtool_found=yes
356        fi
357        if test -f "$d/gettext.m4"; then
358           gettext_found=yes
359        fi
360     done
361     case $required in
362       *libtool* ) test $libtool_found = yes || Exit 77 ;;
363       *gettext* ) test $gettext_found = yes || Exit 77 ;;
364     esac
365     # Libtool cannot cope with spaces in the build tree.  Our testsuite setup
366     # cannot cope with spaces in the source tree name for Libtool and gettext
367     # tests.
368     case $srcdir,`pwd` in
369       *\ * | *\ *) Exit 77 ;;
370     esac
371     ACLOCAL="$ACLOCAL -Wno-syntax -I $srcdir/../m4 $extra_includes -I $aclocaldir"
372     ;;
373 esac
374
375 testaclocaldir='@abs_top_srcdir@/m4'
376
377 # POSIX no longer requires 'egrep' and 'fgrep',
378 # but some hosts lack 'grep -E' and 'grep -F'.
379 EGREP='@EGREP@'
380 FGREP='@FGREP@'
381
382 # The amount we should wait after modifying files depends on the platform.
383 # For instance, Windows '95, '98 and ME have 2-second granularity
384 # and can be up to 3 seconds in the future w.r.t. the system clock.
385 sleep='sleep @MODIFICATION_DELAY@'
386
387 # The tests call `make -e' but we do not want $srcdir from the environment
388 # to override the definition from the Makefile.
389 testsrcdir=$srcdir
390 unset srcdir
391
392 # An old timestamp that can be given to a file, in "touch -t" format.
393 # The time stamp should be portable to all file systems of interest.
394 # Just for fun, choose the exact time of the announcement of the GNU project
395 # in UTC; see <http://www.gnu.org/gnu/initial-announcement.html>.
396 old_timestamp=198309271735.59
397
398 # is_newest FILE FILES
399 # --------------------
400 # Return false if any file in FILES is newer than FILE.
401 # Resolve ties in favor of FILE.
402 is_newest ()
403 {
404   is_newest_files=`find "$@" -newer "$1"`
405   test -z "$is_newest_files"
406 }
407
408
409 # AUTOMAKE_run status [options...]
410 # --------------------------------
411 # Run Automake with OPTIONS, and fail if automake
412 # does not exit with STATUS.
413 AUTOMAKE_run ()
414 {
415   expected_exitcode=$1
416   shift
417   exitcode=0
418   $AUTOMAKE ${1+"$@"} >stdout 2>stderr || exitcode=$?
419   cat stderr >&2
420   cat stdout
421   test $exitcode = $expected_exitcode || Exit 1
422 }
423
424 # AUTOMAKE_fails [options...]
425 # ---------------------------
426 # Run Automake with OPTIONS, and fail if automake
427 # does not exit with STATUS.
428 AUTOMAKE_fails ()
429 {
430   AUTOMAKE_run 1 ${1+"$@"}
431 }
432
433 # Turn on shell traces.
434 set -x
435
436 pwd