+2011-05-26 Stefano Lattarini <stefano.lattarini@gmail.com>
+
+ tests: tweak and improve tests on Automake conditionals
+ The "avoid the requirement of a working compiler" we refer about
+ below is obtained by disabling automatic dependency tracking and
+ defining `CC' (and `EXEEXT', `OBJEXT', `CXX', etc., if needed) to
+ dummy values, either directly in the `Makefile.am', or by AC_SUBST
+ in `configure.in'.
+ The "cosmetic changes" we refer about below consists in, e.g.,
+ adding a trailing `:' command to a script, using proper m4 quoting
+ in `configure.in' files, adding commands that offer more debugging
+ output, explicitly declaring phony targets as such in Makefiles,
+ making use of idioms more consistent with those employed in other
+ tests, following the GNU formatting standards more closely, etc.
+ * tests/cond.test: Cosmetic changes.
+ * tests/cond3.test: Likewise.
+ * tests/cond10.test: Likewise.
+ * tests/cond14.test: Likewise.
+ * tests/cond15.test: Likewise.
+ * tests/cond17.test: Likewise.
+ * tests/cond40.test: Likewise.
+ * tests/cond13.test: Likewise, and make grepping of the generated
+ `Makefile.in' slightly stricter.
+ * tests/cond6.test: Extend by also running ./configure, make and
+ "make install". Few cosmetic changes.
+ * tests/cond8.test: Likewise.
+ * tests/cond2.test: Do few cosmetic changes. Make grepping of
+ automake stderr stricter.
+ * tests/cond20.test: Likewise.
+ * tests/cond23.test: Likewise.
+ * tests/cond24.test: Likewise.
+ * tests/cond42.test: Likewise.
+ * tests/cond46.test: Likewise.
+ * tests/cond9.test: Move more checks in the `Makefile.am' instead
+ of grepping make's output.
+ * tests/cond38.test: Likewise.
+ * tests/cond11.test: Likewise. Avoid the requirement of a working
+ C compiler.
+ * tests/cond16.test: Likewise.
+ * tests/cond22.test: Likewise.
+ * tests/cond30.test: Likewise.
+ * tests/cond31.test: Likewise.
+ * tests/cond4.test: Likewise, and drop the now-useless GNU make
+ requirement as well.
+ * tests/cond18.test: Likewise.
+ * tests/cond19.test: Likewise.
+ * tests/cond22.test: Likewise.
+ * tests/cond25.test: Add trailing `:' command.
+ * tests/cond26.test: Likewise.
+ * tests/cond27.test: Likewise.
+ * tests/cond28.test: Likewise.
+ * tests/cond29.test: Use `unindent' function for better formatting.
+ Other minor cosmetic changes. Use a `timeout' program (if it's
+ available) to determine whether the script takes too long, instead
+ of just hoping that the user will notice an abnormally long test
+ execution time.
+ * tests/cond33.test: Extend a bit. Fix heading comments. Few more
+ cosmetic changes.
+ * tests/cond37.test: Ensure verbose printing of captured make
+ output. Minor cosmetic changes.
+ * tests/cond34.test: Likewise. Avoid the requirement of a working
+ C compiler. Make grepping of make output slightly stricter.
+ * tests/cond35.test: Quote literal dots in grep regexp. Add extra
+ debugging output. Minor cosmetic changes.
+ * tests/cond36.test: Likewise.
+ * tests/cond41.test: Do not simply check that aclocal fails, but
+ also grep its stderr for the expected error message.
+ * tests/cond43.test: Likewise (but the program being automake).
+ Few cosmetic changes.
+ * tests/condd.test: Avoid the requirement of a working C compiler.
+ * tests/condman3.test: Extend by using more man pages and more
+ manpage sections.
+ * tests/condman.test: Removed, it's completely superseded by
+ `condman3.test'.
+ * tests/Makefile.am (TESTS): Update.
+
2011-05-25 Stefano Lattarini <stefano.lattarini@gmail.com>
lex tests: avoid spurious failures when LEXLIB isn't found
condinc.test \
condinc2.test \
condlib.test \
-condman.test \
condman2.test \
condman3.test \
configure.test \
condinc.test \
condinc2.test \
condlib.test \
-condman.test \
condman2.test \
condman3.test \
configure.test \
. ./defs || Exit 1
cat >> configure.in << 'END'
-AM_CONDITIONAL(TEST, true)
+AM_CONDITIONAL([TEST], [true])
AC_OUTPUT
END
grep '^TEST_TRUE' Makefile.in && Exit 1
grep '^@TEST_TRUE@VAR = true$' Makefile.in
grep '^@TEST_FALSE@VAR = false$' Makefile.in
+
+:
cat >> configure.in << 'END'
AC_PROG_CC
-AM_CONDITIONAL(USE_A,[test x = y])
-AM_CONDITIONAL(USE_B,[test x = z])
+AM_CONDITIONAL([USE_A], [test x = y])
+AM_CONDITIONAL([USE_B], [test x = z])
AC_OUTPUT
END
$ACLOCAL
$AUTOMAKE -a
grep 'USE_A_FALSE.*USE_B_FALSE.*output_c\...OBJEXT.' Makefile.in
+
+:
# This checks that, if LDADD is set from a conditional variable
# and an AC_SUBST, the _DEPENDENCIES variable is set correctly.
-required=cc
. ./defs || Exit 1
cat >> configure.in << 'END'
-AC_PROG_CC
+AC_SUBST([CC], [false])
AM_CONDITIONAL([USE_A], [test -z "$two"])
AC_SUBST([SUBSTVAR], [bar])
AC_OUTPUT
END
cat > Makefile.am << 'END'
-
if USE_A
foolibs=faz.la
else
foo_SOURCES = foo.c
LDADD = $(SUBSTVAR) $(foolibs)
-print:
- @echo BEG: $(foo_DEPENDENCIES) :END
+.PHONY: test1 test2
+test1:
+ test faz.la = $(foo_DEPENDENCIES)
+test2:
+ test -z "`echo $(foo_DEPENDENCIES)`"
END
: > config.guess
$ACLOCAL
$AUTOCONF
-$AUTOMAKE
+$AUTOMAKE --ignore-deps
./configure
-$MAKE -e print > stdout
-cat stdout
-grep 'BEG: faz.la :END' stdout
+$MAKE test1
./configure two=yes
-$MAKE -e print > stdout
-cat stdout
-grep 'BEG: :END' stdout
+$MAKE test2
+
+:
AC_PROG_CC
AC_PROG_CXX
AC_PROG_RANLIB
-AM_CONDITIONAL(COND1, true)
-AM_CONDITIONAL(COND2, true)
+AM_CONDITIONAL([COND1], [true])
+AM_CONDITIONAL([COND2], [true])
END
cat > Makefile.am << 'END'
$ACLOCAL
$AUTOMAKE
-grep 'am_libtest_a_OBJECTS = .*$' Makefile.in
+grep '^am_libtest_a_OBJECTS =' Makefile.in
+
+:
END
cat > Makefile.am << 'END'
-
if COND1
BUILD_helldl = helldl
helldl_SOURCES = dlmain.c
$ACLOCAL
$AUTOMAKE
-num=`grep 'helldl$(EXEEXT):' Makefile.in | wc -l`
-test $num -eq 2
+$FGREP helldl Makefile.in # For debugging.
+test `$FGREP -c 'helldl$(EXEEXT):' Makefile.in` -eq 2
:
END
cat > Makefile.am << 'END'
-
if COND1
if COND2
bin_SCRIPTS = helldl
$ACLOCAL
$AUTOMAKE
+$FGREP helldl Makefile.in # For debugging.
num1=`$FGREP 'helldl$(EXEEXT):' Makefile.in | wc -l`
num2=`$FGREP '@COND1_FALSE@@COND2_TRUE@helldl$(EXEEXT):' Makefile.in | wc -l`
test $num1 -eq 4
# references.
# Report from Richard Boulton
-required=cc
. ./defs || Exit 1
cat >> configure.in << 'END'
-AC_PROG_CC
AM_CONDITIONAL([COND1], [true])
AC_OUTPUT
END
: > hello.c
cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = no-dependencies
+CC = false
+OBJEXT = o
if COND1
var = foo.c
bin_PROGRAMS = hell
hell_SOURCES = $(var:=)
-echorule:
- @echo $(hell_SOURCES) $(hell_OBJECTS)
-
+.PHONY: test
+test:
+ test "`echo $(hell_SOURCES) $(hell_OBJECTS)`" = "foo.c foo.o"
END
$ACLOCAL
$AUTOCONF
$AUTOMAKE -a
-
./configure
-
-val=`$MAKE -s echorule`;
-test "x$val" = "xfoo.c foo.o"
+$MAKE test
:
. ./defs || Exit 1
-cat > configure.in << 'END'
-AC_INIT(Makefile.am)
-AM_INIT_AUTOMAKE(hello,0.23)
+cat >> configure.in << 'END'
AC_PROG_CC
AC_PROG_CXX
-AM_CONDITIONAL(COND1, true)
-AC_OUTPUT(Makefile)
+AM_CONDITIONAL([COND1], [true])
+AC_OUTPUT
END
cat > Makefile.am << 'END'
$ACLOCAL
$AUTOMAKE -a
+
+:
# Regression test for substitution references to conditional variables.
# Report from Richard Boulton
-required='cc GNUmake'
. ./defs || Exit 1
cat >> configure.in << 'END'
-AC_PROG_CC
AM_CONDITIONAL([COND1], [true])
AM_CONDITIONAL([COND2], [true])
AC_OUTPUT
END
cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = no-dependencies
+CC = false
+OBJEXT = obj
var1 = dlmain
helldl_SOURCES = $(var3)
-echorule:
- @echo $(helldl_SOURCES) $(helldl_OBJECTS)
+.PHONY: test
+test:
+ test x"`echo $(helldl_SOURCES) $(helldl_OBJECTS)`" = \
+ x"dlmain.c foo.c dlmain.obj foo.obj"
bin_PROGRAMS = helldl
END
$ACLOCAL
$AUTOCONF
$AUTOMAKE -a
-
./configure
-
-val=`$MAKE --no-print-directory echorule`;
-test "x$val" = "xdlmain.c foo.c dlmain.o foo.o"
+$MAKE test
:
# Regression test for substitution references to conditional variables.
# Report from Richard Boulton
-required='cc GNUmake'
. ./defs || Exit 1
cat >> configure.in << 'END'
-AC_PROG_CC
+AC_SUBST([CC], [false])
+AC_SUBST([OBJEXT], [o])
AM_CONDITIONAL([COND1], [test "x$CONDITION1" = "xtrue"])
AM_CONDITIONAL([COND2], [test "x$CONDITION2" = "xtrue"])
AC_OUTPUT
END
cat > Makefile.am << 'END'
+bin_PROGRAMS = helldl
var1 = dlmain
helldl_SOURCES = $(var3:.c=1.c) $(var4:.c=2.c)
-echorule:
- @echo $(helldl_SOURCES) $(helldl_OBJECTS)
+got = `echo $(helldl_SOURCES) $(helldl_OBJECTS)`
-bin_PROGRAMS = helldl
+.PHONY: test
+test:
+ test x"$(exp)" = x"$(got)"
END
$ACLOCAL
$AUTOCONF
-$AUTOMAKE -a
+$AUTOMAKE -a -i
CONDITION1=true CONDITION2=true ./configure
-vala=`$MAKE --no-print-directory echorule`;
+$MAKE test exp='dlmaina1.c dlmainb2.c dlmaina1.o dlmainb2.o'
CONDITION1=true CONDITION2=false ./configure
-valb=`$MAKE --no-print-directory echorule`;
+$MAKE test exp='dlmainb1.c dlmaina2.c dlmainb1.o dlmaina2.o'
CONDITION1=false CONDITION2=true ./configure
-valc=`$MAKE --no-print-directory echorule`;
+$MAKE test exp='dlmaina1.c dlmainb2.c dlmaina1.o dlmainb2.o'
CONDITION1=false CONDITION2=false ./configure
-vald=`$MAKE --no-print-directory echorule`;
-
-test "x$vala" = "xdlmaina1.c dlmainb2.c dlmaina1.o dlmainb2.o"
-test "x$valb" = "xdlmainb1.c dlmaina2.c dlmainb1.o dlmaina2.o"
-test "x$valc" = "xdlmaina1.c dlmainb2.c dlmaina1.o dlmainb2.o"
-test "x$vald" = "xdlmainb1.c dlmaina2.c dlmainb1.o dlmaina2.o"
+$MAKE test exp='dlmainb1.c dlmaina2.c dlmainb1.o dlmaina2.o'
:
. ./defs || Exit 1
-cat > configure.in << 'END'
-AC_INIT
-AM_INIT_AUTOMAKE(nonesuch, nonesuch)
-AM_CONDITIONAL(TEST, true)
-AC_OUTPUT(Makefile)
+cat >> configure.in << 'END'
+AM_CONDITIONAL([TEST], [true])
END
cat > Makefile.am << 'END'
$ACLOCAL
AUTOMAKE_fails
-grep 'Makefile.am:4:.*dir2.*does not exist' stderr
+grep '^Makefile\.am:4:.*dir2.*does not exist' stderr
+
+:
. ./defs || Exit 1
-cat > configure.in << 'END'
-AC_INIT(Makefile.am)
-AM_INIT_AUTOMAKE(hello,0.23)
+cat >> configure.in << 'END'
AC_PROG_CC
-AM_CONDITIONAL(COND1, true)
-AC_OUTPUT(Makefile)
+AM_CONDITIONAL([COND1], [true])
END
cat > Makefile.am << 'END'
-
var1 = $(var2)
if COND1
$ACLOCAL
$AUTOCONF
AUTOMAKE_fails -a
-grep "recursively defined" stderr
+grep "variable.*var2.*recursively defined" stderr
+
+:
# Regression test for bug when sources listed in conditional.
# Report from Richard Boulton. PR/326.
-required=cc
. ./defs || Exit 1
cat >> configure.in << 'END'
-AC_PROG_CC
-AM_CONDITIONAL(ONE, true)
-AM_CONDITIONAL(TWO, false)
-AM_CONDITIONAL(THREE, false)
+CC=false; AC_SUBST([CC])
+OBJEXT=oo; AC_SUBST([OBJEXT])
+AM_CONDITIONAL([ONE], [true])
+AM_CONDITIONAL([TWO], [false])
+AM_CONDITIONAL([THREE], [false])
AC_OUTPUT
END
targ_SOURCES = $(SONE) $(STWO) $(STHREE) $(STHREE2)
-echo:
- echo BEG: $(targ_OBJECTS) :END;
+.PHONY: test
+test:
+ test "`echo $(targ_OBJECTS)`" = "one.oo two.oo three.oo three2.oo"
END
$ACLOCAL
$AUTOCONF
-$AUTOMAKE
+$AUTOMAKE --ignore-deps
./configure
-OBJEXT=oo $MAKE -e echo > output
-cat output
-$FGREP 'BEG: one.oo two.oo three.oo three2.oo :END' output
+$MAKE test
+
+:
$ACLOCAL
AUTOMAKE_fails
-grep 'libdir was already defined' stderr
+grep '^Makefile\.am:2:.* libdir was already defined' stderr
+
+:
cat >>configure.in <<EOF
AC_SUBST([foo], [bar])
AM_CONDITIONAL([COND], [true])
-AC_OUTPUT
EOF
cat >Makefile.am <<EOF
if COND
+## A dummy comment to change line numer.
foo = baz
endif
EOF
$ACLOCAL
AUTOMAKE_fails
-grep 'foo was already defined' stderr
+grep '^Makefile\.am:3:.* foo was already defined' stderr
+grep '^configure\.in:4:.*foo.* previously defined here' stderr
+
+:
AUTOMAKE_fails
grep ' USE_FOO' stderr && Exit 1
grep '!USE_FOO' stderr
+
+:
# possible combinations of conditionals (it would do this five times,
# to define a01_DEPENDENCIES, a02_DEPENDENCIES, a03_OBJECTS,
# a04_OBJECTS, and to rewrite bin_PROGRAM), eating all memory, swap,
-# or cpu time it can found. Although this test won't print `FAIL' if
-# it fails, it will take long enough so it can't go unnoticed.
+# or cpu time it can found.
. ./defs || Exit 1
+timeout 10s true || skip_ "timeout command not found"
+
echo AC_PROG_CC >>configure.in
cat >Makefile.am <<EOF
EOF
for i in 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22; do
-cat >>Makefile.am <<EOF
-if C$i
-bin_PROGRAMS += a$i
-a01_LDADD = foo${i}.o
-a02_LDADD += bar${i}.o
-a03_SOURCES += baz${i}.c
-a04_SOURCES = quux${i}.c
-endif C$i
+ unindent >>Makefile.am <<EOF
+ if C$i
+ bin_PROGRAMS += a$i
+ a01_LDADD = foo${i}.o
+ a02_LDADD += bar${i}.o
+ a03_SOURCES += baz${i}.c
+ a04_SOURCES = quux${i}.c
+ endif C$i
EOF
-echo "AM_CONDITIONAL([C$i], [:])" >>configure.in
+ echo "AM_CONDITIONAL([C$i], [:])" >>configure.in
done
$ACLOCAL
-$AUTOMAKE
+# Be lax w.r.t. the timeout for low-priority processes on heavily
+# loaded systems.
+niceness=`nice || echo 0`
+case $niceness in [0-9]*);; *) niceness=0;; esac
+timeout `expr 60 '+' $niceness '*' 20`s $AUTOMAKE
+
+:
. ./defs || Exit 1
-cat > configure.in << 'END'
-AC_INIT
-AM_INIT_AUTOMAKE(nonesuch, nonesuch)
+cat >> configure.in << 'END'
AC_PROG_CC
-AM_CONDITIONAL(ONE, true)
-AM_CONDITIONAL(TWO, false)
-AM_CONDITIONAL(THREE, maybe)
-AC_OUTPUT(Makefile)
+AM_CONDITIONAL([ONE], [true])
+AM_CONDITIONAL([TWO], [false])
+AM_CONDITIONAL([THREE], [maybe])
+AC_OUTPUT
END
cat > Makefile.am << 'END'
EOF
diff expected produced
+
+:
# For PR/352: make sure we support bin_PROGRAMS being defined conditionally.
-required=cc
. ./defs || Exit 1
cat >>configure.in <<'EOF'
-AC_PROG_CC
-AM_CONDITIONAL(C1, [test -z "$two"])
-AM_CONDITIONAL(C2, [test -n "$two"])
+AM_CONDITIONAL([C1], [test -z "$two"])
+AM_CONDITIONAL([C2], [test -n "$two"])
AC_OUTPUT
EOF
-cat >>Makefile.am <<'EOF'
+cat > Makefile.am <<'EOF'
+AUTOMAKE_OPTIONS = no-dependencies
+CC = false
+EXEEXT = .foo
+
if C1
bin_PROGRAMS = a
endif
bin_PROGRAMS = b $(undefined)
endif
-print:
- @echo 'BEG: $(bin_PROGRAMS) :END'
+.PHONY: test-a test-b
+test-a:
+ test a.foo = $(bin_PROGRAMS)
+test-b:
+ test b.foo = $(bin_PROGRAMS)
EOF
$ACLOCAL
$AUTOCONF
$AUTOMAKE
+$FGREP 'a_SOURCES = a.c' Makefile.in
+$FGREP 'b_SOURCES = b.c' Makefile.in
+
./configure
-EXEEXT=.foo $MAKE -e print > stdout
-cat stdout
-grep 'BEG: a.foo :END' stdout
+$MAKE test-a
./configure two=yes
-EXEEXT=.foo $MAKE -e print > stdout
-cat stdout
-grep 'BEG: b.foo :END' stdout
+$MAKE test-b
-grep 'a_SOURCES = a.c' Makefile.in
-grep 'b_SOURCES = b.c' Makefile.in
+:
. ./defs || Exit 1
cat >>configure.in <<'EOF'
-AC_PROG_CC
-AM_CONDITIONAL(C1, [test -z "$two"])
-AM_CONDITIONAL(C2, [test -n "$two"])
+AC_SUBST([CC], [false])
+AC_SUBST([OBJEXT], [o])
+AM_CONDITIONAL([C1], [test -z "$two"])
+AM_CONDITIONAL([C2], [test -n "$two"])
AC_OUTPUT
EOF
-cat >>Makefile.am <<'EOF'
+cat > Makefile.am <<'EOF'
bin_PROGRAMS = a
a_LDADD = c0.o -L/some/where
if C1
if C2
a_LDADD += c2.o -dlopen c3.la
endif
-print:
- @echo BEG: $(a_DEPENDENCIES) :END
+
+.PHONY: test1 test2
+test1:
+ test "`echo $(a_DEPENDENCIES)`" = "c0.o c1.o"
+test2:
+ test "`echo $(a_DEPENDENCIES)`" = "c0.o c2.o c3.la"
EOF
$ACLOCAL
$AUTOCONF
-$AUTOMAKE
+$AUTOMAKE --ignore-deps
./configure
-$MAKE -e print > stdout
-cat stdout
-grep 'BEG: c0.o c1.o :END' stdout
+$MAKE test1
./configure two=yes
-$MAKE -e print > stdout
-cat stdout
-grep 'BEG: c0.o c2.o c3.la :END' stdout
+$MAKE test2
+
+:
# Make sure the user can override a conditional _DEPENDENCIES.
-required=cc
. ./defs || Exit 1
cat >>configure.in <<'EOF'
-AC_PROG_CC
-AM_CONDITIONAL(C1, [test -z "$two"])
-AM_CONDITIONAL(C2, [test -n "$two"])
-AM_CONDITIONAL(C3, [test -z "$three"])
-AC_SUBST([MYSUB], [foo.o])
+AM_CONDITIONAL([C1], [test -z "$two"])
+AM_CONDITIONAL([C2], [test -n "$two"])
+AM_CONDITIONAL([C3], [test -z "$three"])
+# We define CC in Makefile.am, but OBJEXT here.
+OBJEXT=o; AC_SUBST([OBJEXT])
+AC_SUBST([MYSUB], ["foo.$OBJEXT"])
AC_OUTPUT
EOF
cat >>Makefile.am <<'EOF'
+AUTOMAKE_OPTIONS = no-dependencies
+CC = :
+
bin_PROGRAMS = a
+
if C1
a_LDADD = $(MYSUB)
a_DEPENDENCIES = $(MYSUB) nonsense.a
# Note that `nonsense.a' is there just to make sure Automake insn't
# using some self computed a_DEPENDENCIES variable.
endif
+
if C2
if C3
BAR = bar.o
endif
a_LDADD = $(BAR)
endif
-print:
- @echo BEG: $(a_DEPENDENCIES) :END
+
+got = `echo $(a_DEPENDENCIES)`
+test:
+ test "$(exp)" = "$(got)"
+.PHONY: test
EOF
$ACLOCAL
$AUTOMAKE
./configure
-$MAKE -e print > stdout
-cat stdout
-grep 'BEG: foo.o nonsense.a :END' stdout
+$MAKE test exp='foo.o nonsense.a'
./configure two=yes three=
-$MAKE -e print > stdout
-cat stdout
-grep 'BEG: bar.o :END' stdout
+$MAKE test exp='bar.o'
./configure two=yes three=yes
-$MAKE -e print > stdout
-cat stdout
-grep 'BEG: baz.o :END' stdout
+$MAKE test exp='baz.o'
+
+:
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-# Check for conditional library with a conditional directory.
+# Check that $(mkdir_p) handles well conditionally-defined install
+# directories.
# Report from Ralf Corsepius
. ./defs || Exit 1
AC_OUTPUT
EOF
-cat >>Makefile.am <<'EOF'
+cat > Makefile.am <<'EOF'
if INC
include_foodir = $(includedir)/foo
include_foo_HEADERS = foo.h
foo.h x.sh:
:>$@
+
+.PHONY: distdircheck
distdircheck: distdir
test -f $(distdir)/foo.h
test -f $(distdir)/x.sh
$AUTOCONF
$AUTOMAKE
+cwd=`pwd` || Exit 99
mkdir nowhere
chmod a-w nowhere
-./configure "--prefix=`pwd`/nowhere" "--bindir=`pwd`/bin" "--includedir=`pwd`/inc"
+
+./configure --prefix="$cwd"/nowhere --bindir="$cwd"/bin \
+ --includedir="$cwd"/inc
$MAKE installdirs
test ! -d bin
test -d inc/foo
$MAKE install
test ! -d bin
test -f inc/foo/foo.h
+$MAKE distdircheck
+
rm -rf inc
-./configure two=two \
- "--prefix=`pwd`/nowhere" "--bindir=`pwd`/bin" "--includedir=`pwd`/inc"
+
+./configure two=two --prefix="$cwd"/nowhere --bindir="$cwd"/bin \
+ --includedir="$cwd"/inc
$MAKE install
test ! -d inc
test -f bin/x.sh
+rm -rf inc
$MAKE installdirs
test ! -d inc
test -d bin
$MAKE distdircheck
+
+:
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-# Check for _DEPDENDENCIES definition with conditional _LDADD.
+# Check for _DEPENDENCIES definition with conditional _LDADD.
# Report from Elena A. Vengerova
-required=cc
. ./defs || Exit 1
cat >>configure.in <<'EOF'
-AM_CONDITIONAL([TWO], test -n "$two")
-AC_PROG_CC
+AM_CONDITIONAL([TWO], [test -n "$two"])
AC_OUTPUT
EOF
-cat >>Makefile.am <<'EOF'
+cat > Makefile.am <<'EOF'
OBJEXT=z
+CC=false
+AUTOMAKE_OPTIONS=no-dependencies
bin_PROGRAMS = test1 test2
test1_DEPENDENCIES = $(test1_LDADD) somethingelse.a
+.PHONY: dep-test1 dep-test2
dep-test1:
echo BEG: $(test1_DEPENDENCIES) :END
dep-test2:
echo BEG: $(test2_DEPENDENCIES) :END
-
EOF
-:> test.c
-
$ACLOCAL
$AUTOCONF
$AUTOMAKE
./configure
-$MAKE dep-test1 >out
-grep 'BEG: one.z somethingelse.a :END' out
-$MAKE dep-test2 >out
-grep 'BEG: three.z :END' out
+
+$MAKE dep-test1 >stdout || { cat stdout; Exit 1; }
+cat stdout
+$FGREP 'BEG: one.z somethingelse.a :END' stdout
+
+$MAKE dep-test2 >stdout || { cat stdout; Exit 1; }
+cat stdout
+$FGREP 'BEG: three.z :END' stdout
./configure two=2
-$MAKE dep-test1 >out
-grep 'BEG: two.z somethingelse.a :END' out
-$MAKE dep-test2 >out
-grep 'BEG: two.z somethingelse.a :END' out
+
+$MAKE dep-test1 >stdout || { cat stdout; Exit 1; }
+cat stdout
+$FGREP 'BEG: two.z somethingelse.a :END' stdout
+
+$MAKE dep-test2 >stdout || { cat stdout; Exit 1; }
+cat stdout
+$FGREP 'BEG: two.z somethingelse.a :END' stdout
+
+:
AC_OUTPUT
EOF
-cat >>Makefile.am <<'EOF'
+cat > Makefile.am <<'EOF'
AM_YFLAGS = -d
BUILT_SOURCES = tparse.h
$AUTOCONF
$AUTOMAKE --add-missing
-test `grep tparse.h: Makefile.in | wc -l` = 1
+$FGREP 'tparse.h' Makefile.in # For debugging.
+test `$FGREP -c 'tparse.h:' Makefile.in` = 1
cat > tscan.l << 'END'
%%
. ./defs || Exit 1
cat >>configure.in <<'EOF'
-AM_CONDITIONAL([CASE_A], test -z "$case_B")
+AM_CONDITIONAL([CASE_A], [test -z "$case_B"])
AC_PROG_CC
AM_PROG_LEX
AC_PROG_YACC
AC_OUTPUT
EOF
-cat >>Makefile.am <<'EOF'
+cat > Makefile.am <<'EOF'
AM_YFLAGS = -d
BUILT_SOURCES = tparse.h
# Presently Automake doesn't fully support partially overriden rules
# and should complain.
AUTOMAKE_fails --add-missing
-grep 'tparse.h.*already defined' stderr
+grep 'tparse\.h.*already defined' stderr
$AUTOMAKE -Wno-error
# Still and all, it should generate two rules.
-test `grep tparse.h: Makefile.in | wc -l` = 2
-grep '@CASE_A_TRUE@tparse.h:' Makefile.in
-grep '@CASE_A_FALSE@tparse.h:' Makefile.in
+$FGREP 'tparse.h' Makefile.in # For debugging.
+test `$FGREP -c 'tparse.h:' Makefile.in` = 2
+$FGREP '@CASE_A_TRUE@tparse.h:' Makefile.in
+$FGREP '@CASE_A_FALSE@tparse.h:' Makefile.in
:
. ./defs || Exit 1
cat >>configure.in <<'EOF'
-AM_CONDITIONAL([CASE_A], test -n "$case_A")
+AM_CONDITIONAL([CASE_A], [test -n "$case_A"])
AC_OUTPUT
EOF
-cat >>Makefile.am <<'EOF'
+cat > Makefile.am <<'EOF'
if CASE_A
check-local:
@echo GrepMe1
$AUTOMAKE
./configure
-$MAKE check >stdout
+$MAKE check >stdout || { cat stdout; Exit 1; }
cat stdout
grep GrepMe1 stdout && Exit 1
-$MAKE install >stdout
+$MAKE install >stdout || { cat stdout; Exit 1; }
cat stdout
grep GrepMe2 stdout
./configure case_A=1
-$MAKE check >stdout
+$MAKE check >stdout || { cat stdout; Exit 1; }
cat stdout
grep GrepMe1 stdout
-$MAKE install >stdout
+$MAKE install >stdout || { cat stdout; Exit 1; }
cat stdout
grep GrepMe2 stdout && Exit 1
AC_OUTPUT
EOF
-cat >>Makefile.am <<'EOF'
+cat > Makefile.am <<'EOF'
SUBDIRS = a
if CASE_A
SUBDIRS += b
SUBDIRS += iXYZ
SUBDIRS += jZYX
endif
-print:
- @echo BEG: $(SUBDIRS) :END
+
+.PHONY: test
+test:
+ test "`echo $(SUBDIRS)`" = 'a b c d e f g h iXYZ jZYX'
EOF
mkdir a b c d e f g h iXYZ jZYX
$AUTOMAKE
./configure
-$MAKE print >stdout
-cat stdout
-# Check good ordering
-grep 'BEG: a b c d e f g h iXYZ jZYX :END' stdout
# Make sure no extra variable was created for the last 3 items.
grep 'append.*=.* h iXYZ jZYX' Makefile
+# Check good ordering.
+$MAKE test
+
+:
# Another sources-in-conditional test. Report from Tim Goodwin.
-required='cc GNUmake'
. ./defs || Exit 1
cat >> configure.in << 'END'
-AC_PROG_CC
+AC_SUBST([CC], [false])
+AC_SUBST([OBJEXT], [o])
AM_CONDITIONAL([ONE], [test "x$CONDITION1" = "xtrue"])
AM_CONDITIONAL([TWO], [test "x$CONDITION2" = "xtrue"])
AC_OUTPUT
targ_SOURCES = main.c $(OPT1) $(OPT2)
-echo-objects:
- @echo $(targ_OBJECTS)
+got = `echo $(targ_OBJECTS)`
+
+.PHONY: test
+test:
+ test x"$(exp)" = x"$(got)"
END
$ACLOCAL
-$AUTOMAKE
+$AUTOMAKE -i
# We should not output useless definitions.
-test "`grep '^@TWO_FALSE@' Makefile.in | wc -l`" -eq 0
+grep '^@ONE_FALSE@' Makefile.in && Exit 1
+grep '^@TWO_FALSE@' Makefile.in && Exit 1
$AUTOCONF
CONDITION1=true CONDITION2=true ./configure
-msgtt=`$MAKE --no-print-directory echo-objects`
+$MAKE test exp='main.o one.o two.o'
CONDITION1=true CONDITION2=false ./configure
-msgtf=`$MAKE --no-print-directory echo-objects`
+$MAKE test exp='main.o one.o'
CONDITION1=false CONDITION2=true ./configure
-msgft=`$MAKE --no-print-directory echo-objects`
+$MAKE test exp='main.o two.o'
CONDITION1=false CONDITION2=false ./configure
-msgff=`$MAKE --no-print-directory echo-objects`
-
-: msgtt = $msgtt
-: msgtf = $msgtf
-: msgft = $msgft
-: msgff = $msgff
-
-test x"$msgtt" = x"main.o one.o two.o"
-test x"$msgtf" = x"main.o one.o"
-test x"$msgft" = x"main.o two.o"
-test x"$msgff" = x"main.o"
+$MAKE test exp='main.o'
:
# Test AM_COND_IF.
. ./defs || Exit 1
+
cat >>configure.in <<'END'
AC_DEFUN([FOO],
[AC_CONFIG_FILES([$1])])
test ! -f file1
test -f file2
test ! -f file3
+
:
# AM_COND_IF with an undefined condition should fail.
. ./defs || Exit 1
+
cat >>configure.in <<'END'
-AM_COND_IF([COND],
+AM_COND_IF([BAD_COND],
[AC_CONFIG_FILES([file1])])
AC_OUTPUT
END
-$ACLOCAL && Exit 1
+$ACLOCAL 2>stderr && { cat stderr >&2; Exit 1; }
+cat stderr >&2
+grep '^configure\.in:4:.*AM_COND_IF.* no such condition.*BAD_COND' stderr
+
:
# but better to be safe.
. ./defs || Exit 1
+
cat >>configure.in <<'END'
AM_CONDITIONAL([COND], [:])
-# next line needed so that cond-if.m4 is pulled in.
+# The next line is needed so that cond-if.m4 is pulled in.
AM_COND_IF([COND])
_AM_COND_IF([COND])
AC_OUTPUT
END
+
+edit_configure_in ()
+{
+ sed "$@" < configure.in >configure.int
+ mv -f configure.int configure.in
+ rm -rf autom4te*.cache
+}
+
: >Makefile.am
$ACLOCAL
AUTOMAKE_fails
-grep 'condition stack' stderr
+grep '^configure\.in:8:.* condition stack' stderr
-sed 's/_AM_COND_IF/_AM_COND_ELSE/' < configure.in >configure.int
-mv -f configure.int configure.in
-rm -rf autom4te*.cache
+edit_configure_in 's/_AM_COND_IF/_AM_COND_ELSE/'
AUTOMAKE_fails
-grep 'else without if' stderr
+grep '^configure\.in:7:.* else without if' stderr
-sed 's/_AM_COND_ELSE/_AM_COND_ENDIF/' < configure.in >configure.int
-mv -f configure.int configure.in
-rm -rf autom4te*.cache
+edit_configure_in 's/_AM_COND_ELSE/_AM_COND_ENDIF/'
AUTOMAKE_fails
-grep 'endif without if' stderr
+grep '^configure\.in:7:.* endif without if' stderr
-sed 's/\(_AM_COND_ENDIF\).*/_AM_COND_IF\
-_AM_COND_ENDIF/' < configure.in >configure.int
-mv -f configure.int configure.in
-rm -rf autom4te*.cache
+edit_configure_in 's/\(_AM_COND_ENDIF\).*/_AM_COND_IF\
+_AM_COND_ENDIF/'
AUTOMAKE_fails
+grep '^configure\.in:7:.* not enough arguments.* _AM_COND_IF' stderr
+grep '^configure\.in:8:.* not enough arguments.* _AM_COND_ENDIF' stderr
test 2 = `grep -c 'not enough arguments' stderr`
+
:
# Ensure an error with underquoted usage of AM_COND_IF in configure.ac.
. ./defs || Exit 1
+
cat >>configure.in <<'END'
AM_CONDITIONAL([COND1], [:])
AM_CONDITIONAL([COND2], [:])
)
AC_OUTPUT
END
+
: >Makefile.am
$ACLOCAL
AUTOMAKE_fails
+$EGREP '^configure\.in:7:.* missing m4 quoting.*macro depth 2( |$)' stderr
sed '/.AM_COND_IF/{
s/^/[/
mv -f configure.int configure.in
rm -rf autom4te*.cache
$AUTOMAKE
+
+:
. ./defs || Exit 1
cat >> configure.in << 'END'
-AM_CONDITIONAL([USE_A],[test x = y])
-AM_CONDITIONAL([USE_B],[test x = z])
+AM_CONDITIONAL([USE_A], [test x = y])
+AM_CONDITIONAL([USE_B], [test x = z])
AC_OUTPUT
END
+notcompat="incompatible with current conditional"
+
$ACLOCAL
cat > Makefile.am << 'END'
END
AUTOMAKE_fails
-grep 'endif.*incompatible with current conditional' stderr
+grep "^Makefile\\.am:2:.*endif.*!USE_A.*$notcompat.*[^!]USE_A" stderr
cat > Makefile.am << 'END'
if USE_A
END
AUTOMAKE_fails
-grep 'endif.*incompatible with current conditional' stderr
+grep "^Makefile\\.am:2:.*endif.*[^!]USE_B.*$notcompat.*[^!]USE_A" stderr
cat > Makefile.am << 'END'
if USE_A
END
AUTOMAKE_fails
-grep 'endif.*incompatible with current conditional' stderr
+grep "^Makefile\\.am:3:.*endif.*[^!]USE_A.*$notcompat.*USE_A" stderr
cat > Makefile.am << 'END'
if USE_A
END
AUTOMAKE_fails
-grep 'endif.*incompatible with current conditional' stderr
+grep "^Makefile\\.am:4:.*endif.*!USE_A.*$notcompat.*USE_B" stderr
cat > Makefile.am << 'END'
if USE_A
END
AUTOMAKE_fails
-grep 'else.*incompatible with current conditional' stderr
+grep "^Makefile\\.am:2:.*else.*[^!]USE_A.*$notcompat.*[^!]USE_A" stderr
cat > Makefile.am << 'END'
if USE_A
-else USE_B
+else !USE_A
endif
END
-AUTOMAKE_fails
-grep 'else.*incompatible with current conditional' stderr
+$AUTOMAKE
cat > Makefile.am << 'END'
if USE_A
-if USE_B
-else USE_A
-endif
+else USE_B
endif
END
AUTOMAKE_fails
-grep 'else.*incompatible with current conditional' stderr
+grep "^Makefile\\.am:2:.*else.*[^!]USE_B.*$notcompat.*[^!]USE_A" stderr
cat > Makefile.am << 'END'
if USE_A
-else !USE_A
+if USE_B
+else USE_A
+endif
endif
END
-$AUTOMAKE
+AUTOMAKE_fails
+grep "^Makefile\\.am:3:.*else.*[^!]USE_A.*$notcompat.*[^!]USE_B" stderr
+
+:
. ./defs || Exit 1
-echo 'AM_CONDITIONAL(FOO, true)' >> configure.in
+echo 'AM_CONDITIONAL([FOO], [true])' >> configure.in
cat > Makefile.am << 'END'
-
if FOO
helpdir = $(prefix)/Help
help_DATA = foo
endif
+
+a b c d e f g h:
+ touch $@
+
+.PHONY: print-data
+print-data:
+ echo BEG: $(help_DATA) :END
END
+
+# Older versions of this test checked that automake could process the above
+# Makefile.am even with no AC_OUTPUT in configure. So continue to do this
+# check, for completeness.
$ACLOCAL
$AUTOMAKE
+
+rm -rf autom4te*.cache
+
+echo AC_OUTPUT >> configure.in
+$AUTOCONF
+$AUTOMAKE Makefile
+
+./configure --prefix="`pwd`/_inst"
+
+$MAKE print-data >stdout || { cat stdout; Exit 1; }
+cat stdout
+grep '^BEG: a b c d e f g h :END$' stdout
+
+$MAKE install
+for x in a b c d e f g h; do
+ test -f _inst/Help/$x
+done
+
+:
cat >> configure.in << 'END'
AC_PROG_CC
-AM_CONDITIONAL(X, false)
+AM_CONDITIONAL([X], [test "$x" = yes])
+AC_OUTPUT
END
cat > Makefile.am << 'END'
else
noinst_PROGRAMS = x y
endif
+
+.PHONY: get-built get-install not-install
+get-built:
+ test -f x.$(OBJEXT)
+ test -f y.$(OBJEXT)
+ test -f x$(EXEEXT)
+ test -f y$(EXEEXT)
+get-installed:
+ test -f $(bindir)/x$(EXEEXT)
+ test -f $(bindir)/y$(EXEEXT)
+not-installed:
+ if find $(prefix) -type f | grep .; then exit 1; else :; fi
END
$ACLOCAL
$AUTOMAKE
+$AUTOCONF
+
+cat > x.c <<'END'
+int main (void)
+{
+ return 0;
+}
+END
+
+cp x.c y.c
+
+instdir=`pwd`/_inst || Exit 99
+
+# Skip the rest of the test in case of e.g. missing C compiler.
+./configure --prefix="$instdir" x=yes || Exit $?
+$MAKE install
+$MAKE get-built
+$MAKE get-installed
+
+$MAKE distclean
+rm -rf _inst
+
+./configure --prefix="$instdir" x=no
+$MAKE install
+$MAKE get-built
+$MAKE not-installed
+
+:
. ./defs || Exit 1
cat >> configure.in << 'END'
-AM_CONDITIONAL(WRONG, [test x = y])
+AM_CONDITIONAL([WRONG], [test x = y])
AC_OUTPUT
END
this=is_something_interesting
endif
-echo-something:
- echo '$(this)'
+.PHONY: test-this
+test-this:
+ test '$(this)' = is_something_interesting
END
$ACLOCAL
$AUTOCONF
$AUTOMAKE -a
./configure
-$MAKE echo-something | grep interesting > /dev/null
+$MAKE test-this
+
+:
# Test for bug in conditionals.
-required=cc
. ./defs || Exit 1
cat >> configure.in << 'END'
-AC_PROG_CC
dnl Define a macro with the same name as the conditional to exhibit
dnl any underquoted bug.
AC_DEFUN([COND1], ["some'meaningless;characters`])
-AM_CONDITIONAL([COND1], false)
+AM_CONDITIONAL([COND1], [false])
AC_CONFIG_FILES([foo/Makefile])
AC_CONFIG_FILES([bar/Makefile])
AC_OUTPUT
END
cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = no-dependencies
+CC = false
+
SUBDIRS = foo
if COND1
SUBDIRS += bar
hello_SOURCES += hello-generic.c
endif
+.PHONY: test
test: distdir
test -f $(distdir)/foo/Makefile.am
test -f $(distdir)/bar/Makefile.am
+++ /dev/null
-#! /bin/sh
-# Copyright (C) 1998, 2001, 2002, 2010, 2011 Free Software Foundation,
-# Inc.
-#
-# This program 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.
-#
-# This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
-
-# Make sure conditionals work with man pages.
-
-. ./defs || Exit 1
-
-cat >> configure.in << 'END'
-AM_CONDITIONAL([FRED], [true])
-END
-
-cat > Makefile.am << 'END'
-if FRED
-man_MANS = foo.1
-else
-man_MANS = joe.1
-endif
-END
-
-$ACLOCAL
-$AUTOMAKE
-
-:
cat > Makefile.am << 'END'
if COND
man_MANS = foo.1
+man4_MANS = 6.man
else
-man_MANS = bar.2
+man_MANS = bar.2 baz.1
+man5_MANS = zap.5
endif
.PHONY: test1 test2
test1:
+ find $(mandir) ;: For debugging.
test -f $(mandir)/man1/foo.1
+ test -f $(mandir)/man4/6.4
test ! -f $(mandir)/man2/bar.2
+ test ! -f $(mandir)/man1/baz.1
+ test ! -f $(mandir)/man5/zap.5
test2:
- test ! -f $(mandir)/man1/foo.1
+ find $(mandir) ;: For debugging.
test -f $(mandir)/man2/bar.2
+ test -f $(mandir)/man1/baz.1
+ test -f $(mandir)/man5/zap.5
+ test ! -f $(mandir)/man1/foo.1
+ test ! -f $(mandir)/man4/6.4
+ test ! -f $(mandir)/man4/6.man
END
$ACLOCAL
$AUTOMAKE
$AUTOCONF
-mkdir dir1
-cd dir1
+$EGREP 'MANS|\.([123456789]|man)' Makefile.in # For debugging.
+
+mkdir build
+cd build
../configure FOO=true --prefix="`pwd`/_inst"
-sed -n '/man_MANS/p' Makefile # useful for debugging
-: > foo.1
+$EGREP 'MANS|\.([123456789]|man)' Makefile # For debugging.
+touch foo.1 6.man
$MAKE install
$MAKE test1
cd ..
-mkdir dir2
-cd dir2
-../configure FOO=false --prefix="`pwd`/_inst"
-sed -n '/man_MANS/p' Makefile # useful for debugging
-: > bar.2
+./configure FOO=false --prefix="`pwd`/_inst"
+$EGREP 'MANS|\.([123456789]|man)' Makefile # For debugging.
+touch bar.2 baz.1 zap.5
$MAKE install
$MAKE test2