1#!/bin/sh
2nfig
3# Copyright (C) 2008-2021 Free Software Foundation, Inc.
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 2, or (at your option)
8# any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program.  If not, see <https://www.gnu.org/licenses/>.
17
18# Ensure an error with inconsistent state of conditionals in configure.ac.
19# This shouldn't happen with user input, as _AM_COND_* are not documented,
20# but better to be safe.
21
22. test-init.sh
23
24cat >>configure.ac <<'END'
25AM_CONDITIONAL([COND], [:])
26# The next line is needed so that cond-if.m4 is pulled in.
27AM_COND_IF([COND])
28_AM_COND_IF([COND])
29AC_OUTPUT
30END
31
32edit_configure_ac ()
33{
34  sed "$@" < configure.ac >configure.tmp
35  mv -f configure.tmp configure.ac
36  rm -rf autom4te*.cache
37}
38
39: >Makefile.am
40
41$ACLOCAL
42AUTOMAKE_fails
43grep '^configure\.ac:8:.* condition stack' stderr
44
45edit_configure_ac 's/_AM_COND_IF/_AM_COND_ELSE/'
46AUTOMAKE_fails
47grep '^configure\.ac:7:.* else without if' stderr
48
49edit_configure_ac 's/_AM_COND_ELSE/_AM_COND_ENDIF/'
50AUTOMAKE_fails
51grep '^configure\.ac:7:.* endif without if' stderr
52
53edit_configure_ac 's/\(_AM_COND_ENDIF\).*/_AM_COND_IF\
54_AM_COND_ENDIF/'
55AUTOMAKE_fails
56grep '^configure\.ac:7:.* not enough arguments.* _AM_COND_IF' stderr
57grep '^configure\.ac:8:.* not enough arguments.* _AM_COND_ENDIF' stderr
58test 2 -eq $($FGREP -c 'not enough arguments' stderr)
59
60:
61