summaryrefslogtreecommitdiff
path: root/tests/defs.in
blob: 2154accf060656720adcd4ab6b62dcfdb4509333 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
# -*- shell-script -*-
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
# Free Software Foundation, Inc.
#
# This file is part of GNU Automake.
#
# GNU Automake 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, or (at your option)
# any later version.
#
# GNU Automake 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 autoconf; see the file COPYING.  If not, write to
# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.

# Defines for Automake testing environment.
# Tom Tromey <tromey@cygnus.com>

# Be Bourne compatible.
# (Snippet copied from configure's initialization in Autoconf 2.57.)
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
  emulate sh
  NULLCMD=:
  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
  # is contrary to our usage.  Disable this feature.
  alias -g '${1+"$@"}'='"$@"'
elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
  set -o posix
fi

# Ensure we are running from the right directory.
test -f ./defs || {
   echo "defs: not found in current directory" 1>&2
   exit 1
}

# If srcdir is not set, then we are not running from `make check', be verbose.
if test -z "$srcdir"; then
   test -z "$VERBOSE" && VERBOSE=x
   # compute $srcdir.
   srcdir=`echo "$0" | sed -e 's,/[^\\/]*$,,'`
   test $srcdir = $0 && srcdir=.
fi

# Ensure $srcdir is set correctly.
test -f $srcdir/defs.in || {
   echo "$srcdir/defs.in not found, check \$srcdir" 1>&2
   exit 1
}

me=`echo "$0" | sed -e 's,.*[\\/],,;s/\.test$//'`

# See how redirections should work.  User can set VERBOSE to see all
# output.
test -z "$VERBOSE" && {
   exec > /dev/null 2>&1
}

SHELL='@SHELL@'
# User can override various tools used.
test -z "$PERL" && PERL='@PERL@'
test -z "$MAKE" && MAKE=make
test -z "$AUTOCONF" && AUTOCONF="@AUTOCONF@"
test -z "$AUTOHEADER" && AUTOHEADER="@AUTOHEADER@"
test -z "$AUTOUPDATE" && AUTOUPDATE=autoupdate

if test -n "$required"
then
  for tool in $required
  do
    # Check that each required tool is present.
    case $tool in
      bison)
	# Since bison is required, we pick YACC for ./configure.
	YACC='bison -y'
	export YACC
	echo "$me: running bison --version"
	( bison --version ) || exit 77
	;;
      etags)
	# Exuberant Ctags will create a TAGS file even
	# when asked for --help or --version.  (Emacs's etags
	# does not have such problem.)  Use -o /dev/null
	# to make sure we do not pollute the tests/ directory.
	echo "$me: running etags --version -o /dev/null"
	( etags --version -o /dev/null ) || exit 77
	;;
      GNUmake)
	# Use --version and -v, because SGI Make doesn't fail on --version.
	echo "$me: running $MAKE --version -v"
	( $MAKE --version -v ) || exit 77
	;;
      gcc)
        # When gcc is required, export `CC=gcc' so that ./configure
        # always use it.  This is important only when the user
        # has defined CC in his environment, otherwise ./configure will
        # prefer gcc to other compilers.
        CC=gcc
	export CC
	echo "$me: running $CC --version"
	( $CC --version ) || exit 77
	;;
      g++)
        CXX=g++
	export CXX
	echo "$me: running $CXX --version"
	( $CXX --version ) || exit 77
	;;
      icc)
        CC=icc
	export CC
	# There is no way to ask *only* the compiler's version.
	# This tool always want to do something (by default
	# it will try link *nothing* and complain it cannot find
	# main(); funny).  -dryrun is a workaround.
	echo "$me: running $CC -V -dryrun"
	( $CC -V -dryrun ) || exit 77
	;;
      makedepend)
	echo "$me: running makedepend -f-"
	( makedepend -f- ) || exit 77
	;;
      makeinfo-html)
	# Make sure makeinfo understands --html.
	echo "$me: running makeinfo --html --version"
	( makeinfo --html --version ) || exit 77
	;;
      non-root)
	# Skip this test case if the user is root.
	# We try to append to a read-only file to detect this.
	priv_check_temp=priv-check.$$
	touch $priv_check_temp || exit 1
	chmod a-w $priv_check_temp || exit 1
	(echo foo >> $priv_check_temp) >/dev/null 2>&1
	overwrite_status=$?
	rm -f $priv_check_temp
	test $overwrite_status = 0 && exit 77
	;;
      python)
	# Python doesn't support --version, it has -V
	echo "$me: running python -V"
	( python -V ) || exit 77
	;;
      ro-dir)
	# Skip this test case if read-only directories aren't supported
	# (e.g., under DOS.)
	ro_dir_temp=ro_dir.$$
	mkdir $ro_dir_temp || exit 1
	chmod a-w $ro_dir_temp || exit 1
	(: > $ro_dir_temp/probe) >/dev/null 2>/dev/null
	create_status=$?
	rm -rf $ro_dir_temp
	test $create_status = 0 && exit 77
	;;
      runtest)
	# DejaGnu's runtest program.
	echo "$me: running runtest --version"
	(runtest --version) || exit 77
	;;
      tex)
        # No all versions of Tex support `--version', so we use
        # a configure check.
        test -n "@TEX@" || exit 77
	;;
      texi2dvi-o)
        # Texi2dvi supports `-o' since Texinfo 4.1.
	echo "$me: running texi2dvi -o /dev/null --version"
	( texi2dvi -o /dev/null --version ) || exit 77
	;;
      # Generic case: the tool must support --version.
      *)
	echo "$me: running $tool --version"
	( $tool --version ) || exit 77
	;;
    esac
    # Additional variables to define if some $tool is required.
    case $tool in
      gcc)
	;;
    esac
  done
fi

# Always use an absolute srcdir.  Otherwise symlinks made in subdirs
# of the test dir just won't work.
case "$srcdir" in
 [\\/]* | ?:[\\/]*)
    ;;

 *)
    srcdir=`CDPATH=: && cd "$srcdir" && pwd`
    ;;
esac

chmod -R a+rwx testSubDir > /dev/null 2>&1
rm -rf testSubDir > /dev/null 2>&1
mkdir testSubDir

# Copy in some files we need.
for file in install-sh mkinstalldirs missing depcomp; do
   cp $srcdir/../lib/$file testSubDir/$file || exit 1
done

cd ./testSubDir

# Build appropriate environment in test directory.  Eg create
# configure.in, touch all necessary files, etc.
# Don't use AC_OUTPUT, but AC_CONFIG_FILES so that appending
# still produces a valid configure.ac.  But then, tests running
# config.status really need to append AC_OUTPUT.
cat > configure.in << END
AC_INIT([$me], [1.0])
AM_INIT_AUTOMAKE
AC_CONFIG_FILES([Makefile])
END

# Unset some MAKE... variables that may cause $MAKE to act like a
# recursively invoked sub-make.  Any $MAKE invocation in a test is
# conceptually an independent invocation, not part of the main
# 'automake' build.
unset MFLAGS
unset MAKEFLAGS
unset MAKELEVEL
unset DESTDIR

echo "=== Running test $0"

# See how Automake should be run.  We put --foreign as the default
# strictness to avoid having to create lots and lots of files.  A test
# can override this by specifying a different strictness.
if test -z "$AUTOMAKE"; then
   perllibdir=`pwd`/../../lib:$srcdir/../lib
   export perllibdir
   # Use -Wall -Werror by default.  Tests for which this is inappropriate
   # (e.g. when testing that a warning is enabled by a specific switch)
   # should use -Wnone or/and -Wno-error
   AUTOMAKE="$PERL `pwd`/../../automake --libdir=$srcdir/../lib --foreign -Werror -Wall"
fi

# See how aclocal should be run.
if test -z "$ACLOCAL"; then
   perllibdir=`pwd`/../../lib:$srcdir/../lib
   export perllibdir
   # Most of the files are in $srcdir/../m4.  However amversion.m4 is
   # generated in ../m4, so we include that directory in the search
   # path too.
   ACLOCAL="$PERL `pwd`/../../aclocal -I `pwd`/../../m4 --acdir=$srcdir/../m4"
fi

# We might need extra macros, e.g., from Libtool or Gettext.
# Find them on the system.
# Use `-I $srcdir/../m4' in addition to `--acdir=$srcdir/../m4', because the
# other `-I' directories added for libtool and gettext might contain
# files from an old version of Automake that we don't want to use.
aclocaldir='@prefix@/share/aclocal'
extra_includes=""
if [ -f $aclocaldir/dirlist ] ; then
   extra_includes=`(tmp_inc=""
   while read LINE ; do
      tmp_inc="$tmp_inc -I $LINE"
   done
   echo $tmp_inc) < $aclocaldir/dirlist`
fi
case $required in
  *libtool* )
    libtool_found=no
    for d in $extra_includes $aclocaldir ; do
       if [ "x$d" != "x-I" ] && [ -f "$d/libtool.m4" ] ; then
          libtool_found=yes
       fi
    done
    test "x$libtool_found" = "xyes" || exit 77
    ACLOCAL="$ACLOCAL -I $srcdir/../m4 $extra_includes -I $aclocaldir"
    ;;
  *gettext* )
    gettext_found=no
    for d in $extra_includes $aclocaldir ; do
       if [ "x$d" != "x-I" ] && [ -f "$d/gettext.m4" ] ; then
          gettext_found=yes
       fi
    done
    test "x$gettext_found" = "xyes" || exit 77
    ACLOCAL="$ACLOCAL -I $srcdir/../m4 $extra_includes -I $aclocaldir"
    ;;
esac

# Export AUTOMAKE and ACLOCAL so that rebuild rules in Makefiles
# generated for the tests do not use the installed tools.
export AUTOMAKE ACLOCAL

# POSIX no longer requires 'egrep' and 'fgrep',
# but some hosts lack 'grep -E' and 'grep -F'.
EGREP='@EGREP@'
FGREP='@FGREP@'

# The amount we should wait after modifying files depends on the platform.
# For instance, Windows '95, '98 and ME have 2-second granularity
# and can be up to 3 seconds in the future w.r.t. the system clock.
sleep='sleep @MODIFICATION_DELAY@'

# The tests call `make -e' but we do not want $srcdir from the evironment
# to override the definition from the Makefile.
testsrcdir=$srcdir
unset srcdir

# AUTOMAKE_run status [options...]
# --------------------------------
# Run Automake with OPTIONS, and fail if automake
# does not exit with STATUS.
AUTOMAKE_run ()
{
  expected_exitcode=$1
  shift
  exitcode=0
  $AUTOMAKE ${1+"$@"} 2>stderr >stdout || exitcode=$?
  cat stderr
  cat stdout
  test $exitcode = $expected_exitcode || exit 1
}

# AUTOMAKE_fails [options...]
# ---------------------------
# Run Automake with OPTIONS, and fail if automake
# does not exit with STATUS.
AUTOMAKE_fails ()
{
  AUTOMAKE_run 1 ${1+"$@"}
}

# Turn on shell traces when VERBOSE=x.
if test "x$VERBOSE" = xx; then
  set -x
else
  :
fi
pwd