summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rw-r--r--t/CheckListOfTests.am68
-rw-r--r--t/Makefile.am194
-rw-r--r--t/README299
-rwxr-xr-xt/ac-output-old.tap180
-rwxr-xr-xt/acloca10.sh100
-rwxr-xr-xt/acloca11.sh45
-rwxr-xr-xt/acloca12.sh46
-rwxr-xr-xt/acloca13.sh69
-rwxr-xr-xt/acloca14.sh118
-rwxr-xr-xt/acloca15.sh47
-rwxr-xr-xt/acloca16.sh36
-rwxr-xr-xt/acloca17.sh41
-rwxr-xr-xt/acloca18.sh137
-rwxr-xr-xt/acloca19.sh49
-rwxr-xr-xt/acloca20.sh41
-rwxr-xr-xt/acloca21.sh31
-rwxr-xr-xt/acloca22.sh53
-rwxr-xr-xt/acloca23.sh37
-rwxr-xr-xt/aclocal-acdir.sh95
-rwxr-xr-xt/aclocal-install-absdir.sh33
-rwxr-xr-xt/aclocal-install-fail.sh65
-rwxr-xr-xt/aclocal-install-mkdir.sh72
-rwxr-xr-xt/aclocal-no-install-no-mkdir.sh39
-rwxr-xr-xt/aclocal-path-install-serial.sh86
-rwxr-xr-xt/aclocal-path-install.sh53
-rwxr-xr-xt/aclocal-path-nonexistent.sh34
-rwxr-xr-xt/aclocal-path-precedence.sh91
-rwxr-xr-xt/aclocal-path.sh56
-rwxr-xr-xt/aclocal-print-acdir.sh34
-rwxr-xr-xt/aclocal-verbose-install.sh54
-rwxr-xr-xt/aclocal.sh44
-rwxr-xr-xt/aclocal3.sh41
-rwxr-xr-xt/aclocal4.sh75
-rwxr-xr-xt/aclocal5.sh69
-rwxr-xr-xt/aclocal6.sh74
-rwxr-xr-xt/aclocal7.sh116
-rwxr-xr-xt/aclocal8.sh42
-rwxr-xr-xt/aclocal9.sh49
-rwxr-xr-xt/acsilent.sh37
-rwxr-xr-xt/acsubst.sh31
-rwxr-xr-xt/acsubst2.sh32
-rwxr-xr-xt/add-missing.tap391
-rwxr-xr-xt/all.sh33
-rwxr-xr-xt/all2.sh32
-rwxr-xr-xt/alloca.sh40
-rwxr-xr-xt/alloca2.sh40
-rwxr-xr-xt/alpha.sh70
-rwxr-xr-xt/alpha2.sh59
-rwxr-xr-xt/am-tests-environment.sh91
-rwxr-xr-xt/amassign.sh28
-rwxr-xr-xt/amhello-binpkg.sh51
-rwxr-xr-xt/amhello-cflags.sh50
-rwxr-xr-xt/amhello-cross-compile.sh53
-rwxr-xr-xt/ammissing.sh25
-rwxr-xr-xt/amopt.sh38
-rwxr-xr-xt/amopts-location.sh83
-rwxr-xr-xt/amopts-variable-expansion.sh52
-rwxr-xr-xt/amsubst.sh39
-rwxr-xr-xt/ansi2knr-no-more.sh56
-rwxr-xr-xt/ar-lib.sh113
-rwxr-xr-xt/ar-lib2.sh38
-rwxr-xr-xt/ar-lib3.sh44
-rwxr-xr-xt/ar-lib4.sh55
-rwxr-xr-xt/ar-lib5a.sh71
-rwxr-xr-xt/ar-lib5b.sh97
-rwxr-xr-xt/ar-lib6a.sh37
-rwxr-xr-xt/ar-lib6b.sh37
-rwxr-xr-xt/ar-lib7.sh34
-rwxr-xr-xt/ar.sh44
-rwxr-xr-xt/ar2.sh38
-rwxr-xr-xt/ar3.sh41
-rwxr-xr-xt/ar4.sh37
-rwxr-xr-xt/ar5.sh40
-rwxr-xr-xt/asm.sh100
-rwxr-xr-xt/asm2.sh116
-rwxr-xr-xt/asm3.sh116
-rwxr-xr-xt/autodist-acconfig-no-subdir.sh56
-rwxr-xr-xt/autodist-acconfig.sh44
-rwxr-xr-xt/autodist-aclocal-m4.sh53
-rwxr-xr-xt/autodist-config-headers.sh59
-rwxr-xr-xt/autodist-configure-no-subdir.sh70
-rwxr-xr-xt/autodist-no-duplicate.sh50
-rwxr-xr-xt/autodist-stamp-vti.sh58
-rwxr-xr-xt/autodist-subdir.sh120
-rwxr-xr-xt/autodist.sh103
-rwxr-xr-xt/autohdr.sh30
-rwxr-xr-xt/autohdr2.sh30
-rwxr-xr-xt/autohdr3.sh53
-rwxr-xr-xt/autohdr4.sh82
-rwxr-xr-xt/autohdrdry.sh42
-rwxr-xr-xt/automake-cmdline.tap63
-rwxr-xr-xt/auxdir-autodetect.sh130
-rwxr-xr-xt/auxdir-computed.tap39
-rwxr-xr-xt/auxdir-misplaced.sh31
-rwxr-xr-xt/auxdir-nonexistent.sh34
-rwxr-xr-xt/auxdir-unportable.tap51
-rwxr-xr-xt/auxdir.sh42
-rwxr-xr-xt/auxdir6.sh50
-rwxr-xr-xt/auxdir7.sh47
-rwxr-xr-xt/auxdir8.sh46
-rw-r--r--t/ax/depcomp.sh420
-rw-r--r--t/ax/distcheck-hook-m4.am30
-rw-r--r--t/ax/extract-testsuite-summary.pl30
-rwxr-xr-xt/ax/is54
-rw-r--r--t/ax/plain-functions.sh40
-rw-r--r--t/ax/tap-functions.sh239
-rw-r--r--t/ax/tap-setup.sh47
-rw-r--r--t/ax/tap-summary-aux.sh359
-rw-r--r--t/ax/testsuite-summary-checks.sh106
-rw-r--r--t/ax/trivial-test-driver102
-rwxr-xr-xt/backcompat.sh64
-rwxr-xr-xt/backcompat2.sh73
-rwxr-xr-xt/backcompat3.sh152
-rwxr-xr-xt/backcompat4.sh66
-rwxr-xr-xt/backcompat5.sh125
-rwxr-xr-xt/backcompat6.sh104
-rwxr-xr-xt/backsl.sh34
-rwxr-xr-xt/backsl2.sh30
-rwxr-xr-xt/backsl3.sh29
-rwxr-xr-xt/backsl4.sh45
-rwxr-xr-xt/badline.sh33
-rwxr-xr-xt/badopt.sh25
-rwxr-xr-xt/badprog.sh32
-rwxr-xr-xt/block.sh34
-rwxr-xr-xt/bsource.sh32
-rwxr-xr-xt/candist.sh32
-rwxr-xr-xt/canon-name.sh38
-rwxr-xr-xt/canon.sh35
-rwxr-xr-xt/canon2.sh35
-rwxr-xr-xt/canon3.sh36
-rwxr-xr-xt/canon4.sh40
-rwxr-xr-xt/canon5.sh58
-rwxr-xr-xt/canon6.sh42
-rwxr-xr-xt/canon7.sh101
-rwxr-xr-xt/canon8.sh37
-rwxr-xr-xt/ccnoco.sh83
-rwxr-xr-xt/ccnoco2.sh55
-rwxr-xr-xt/ccnoco3.sh77
-rwxr-xr-xt/check-concurrency-bug9245.sh62
-rwxr-xr-xt/check-exported-srcdir.sh63
-rwxr-xr-xt/check-fd-redirect.sh110
-rwxr-xr-xt/check-no-test-driver.sh35
-rwxr-xr-xt/check-subst-prog.sh81
-rwxr-xr-xt/check-subst.sh87
-rwxr-xr-xt/check-tests-in-builddir.sh92
-rwxr-xr-xt/check.sh42
-rwxr-xr-xt/check10.sh85
-rwxr-xr-xt/check11.sh60
-rwxr-xr-xt/check12.sh214
-rwxr-xr-xt/check2.sh70
-rwxr-xr-xt/check3.sh79
-rwxr-xr-xt/check4.sh83
-rwxr-xr-xt/check5.sh61
-rwxr-xr-xt/check6.sh53
-rwxr-xr-xt/check7.sh68
-rwxr-xr-xt/check8.sh99
-rwxr-xr-xt/checkall.sh31
-rwxr-xr-xt/clean.sh26
-rwxr-xr-xt/clean2.sh68
-rwxr-xr-xt/colneq.sh32
-rwxr-xr-xt/colneq2.sh40
-rwxr-xr-xt/colneq3.sh44
-rwxr-xr-xt/colon.sh46
-rwxr-xr-xt/colon2.sh79
-rwxr-xr-xt/colon3.sh91
-rwxr-xr-xt/colon4.sh39
-rwxr-xr-xt/colon5.sh71
-rwxr-xr-xt/colon6.sh103
-rwxr-xr-xt/colon7.sh54
-rwxr-xr-xt/color.sh157
-rwxr-xr-xt/color2.sh194
-rwxr-xr-xt/commen10.sh32
-rwxr-xr-xt/commen11.sh41
-rwxr-xr-xt/comment.sh27
-rwxr-xr-xt/comment2.sh34
-rwxr-xr-xt/comment3.sh31
-rwxr-xr-xt/comment4.sh39
-rwxr-xr-xt/comment5.sh85
-rwxr-xr-xt/comment6.sh68
-rwxr-xr-xt/comment7.sh53
-rwxr-xr-xt/comment8.sh48
-rwxr-xr-xt/comment9.sh53
-rwxr-xr-xt/comments-in-var-def.sh56
-rwxr-xr-xt/compile.sh45
-rwxr-xr-xt/compile2.sh84
-rwxr-xr-xt/compile3.sh58
-rwxr-xr-xt/compile4.sh93
-rwxr-xr-xt/compile5.sh85
-rwxr-xr-xt/compile6.sh105
-rwxr-xr-xt/compile_f90_c_cxx.sh43
-rwxr-xr-xt/compile_f_c_cxx.sh46
-rwxr-xr-xt/cond-basic.sh42
-rwxr-xr-xt/cond.sh42
-rwxr-xr-xt/cond10.sh47
-rwxr-xr-xt/cond11.sh62
-rwxr-xr-xt/cond13.sh58
-rwxr-xr-xt/cond14.sh51
-rwxr-xr-xt/cond15.sh61
-rwxr-xr-xt/cond16.sh55
-rwxr-xr-xt/cond17.sh42
-rwxr-xr-xt/cond18.sh63
-rwxr-xr-xt/cond19.sh69
-rwxr-xr-xt/cond2.sh40
-rwxr-xr-xt/cond20.sh46
-rwxr-xr-xt/cond21.sh76
-rwxr-xr-xt/cond22.sh69
-rwxr-xr-xt/cond23.sh37
-rwxr-xr-xt/cond24.sh39
-rwxr-xr-xt/cond25.sh39
-rwxr-xr-xt/cond26.sh38
-rwxr-xr-xt/cond27.sh38
-rwxr-xr-xt/cond28.sh38
-rwxr-xr-xt/cond29.sh63
-rwxr-xr-xt/cond3.sh79
-rwxr-xr-xt/cond30.sh59
-rwxr-xr-xt/cond31.sh56
-rwxr-xr-xt/cond32.sh71
-rwxr-xr-xt/cond33.sh79
-rwxr-xr-xt/cond34.sh75
-rwxr-xr-xt/cond35.sh100
-rwxr-xr-xt/cond36.sh61
-rwxr-xr-xt/cond37.sh57
-rwxr-xr-xt/cond38.sh67
-rwxr-xr-xt/cond39.sh107
-rwxr-xr-xt/cond4.sh65
-rwxr-xr-xt/cond40.sh83
-rwxr-xr-xt/cond41.sh30
-rwxr-xr-xt/cond42.sh59
-rwxr-xr-xt/cond43.sh44
-rwxr-xr-xt/cond44.sh38
-rwxr-xr-xt/cond45.sh39
-rwxr-xr-xt/cond46.sh112
-rwxr-xr-xt/cond5.sh69
-rwxr-xr-xt/cond6.sh69
-rwxr-xr-xt/cond7.sh39
-rwxr-xr-xt/cond8.sh77
-rwxr-xr-xt/cond9.sh44
-rwxr-xr-xt/condd.sh73
-rwxr-xr-xt/condhook.sh48
-rwxr-xr-xt/condhook2.sh47
-rwxr-xr-xt/condinc.sh42
-rwxr-xr-xt/condinc2.sh59
-rwxr-xr-xt/condlib.sh44
-rwxr-xr-xt/condman2.sh33
-rwxr-xr-xt/condman3.sh74
-rwxr-xr-xt/confdeps.sh37
-rwxr-xr-xt/conff.sh94
-rwxr-xr-xt/conff2.sh36
-rwxr-xr-xt/conffile-leading-dot.sh61
-rwxr-xr-xt/confh.sh63
-rwxr-xr-xt/confh4.sh47
-rwxr-xr-xt/confh5.sh59
-rwxr-xr-xt/confh6.sh45
-rwxr-xr-xt/confh7.sh44
-rwxr-xr-xt/confh8.sh66
-rwxr-xr-xt/configure.sh54
-rwxr-xr-xt/confincl.sh36
-rwxr-xr-xt/conflnk.sh70
-rwxr-xr-xt/conflnk2.sh57
-rwxr-xr-xt/conflnk3.sh86
-rwxr-xr-xt/conflnk4.sh93
-rwxr-xr-xt/confsub.sh58
-rwxr-xr-xt/confvar.sh32
-rwxr-xr-xt/confvar2.sh34
-rwxr-xr-xt/copy.sh101
-rwxr-xr-xt/cscope.tap168
-rwxr-xr-xt/cscope2.sh34
-rwxr-xr-xt/cscope3.sh39
-rwxr-xr-xt/cxx.sh34
-rwxr-xr-xt/cxx2.sh30
-rwxr-xr-xt/cxxcpp.sh30
-rwxr-xr-xt/cxxlibobj.sh40
-rwxr-xr-xt/cxxlink.sh39
-rwxr-xr-xt/cxxnoc.sh37
-rwxr-xr-xt/cxxo.sh34
-rwxr-xr-xt/cygnus-check-without-all.sh50
-rwxr-xr-xt/cygnus-dependency-tracking.sh73
-rwxr-xr-xt/cygnus-imply-foreign.sh60
-rwxr-xr-xt/cygnus-no-dist.sh84
-rwxr-xr-xt/cygnus-no-installinfo.sh53
-rwxr-xr-xt/cygnus-requires-maintainer-mode.sh53
-rwxr-xr-xt/cygwin32.sh38
-rwxr-xr-xt/dash.sh29
-rw-r--r--t/defs1102
-rw-r--r--t/defs-static.in246
-rwxr-xr-xt/defun.sh35
-rwxr-xr-xt/defun2.sh40
-rwxr-xr-xt/dejagnu-absolute-builddir.sh60
-rwxr-xr-xt/dejagnu-relative-srcdir.sh84
-rwxr-xr-xt/dejagnu-siteexp-append.sh70
-rwxr-xr-xt/dejagnu-siteexp-extend.sh159
-rwxr-xr-xt/dejagnu-siteexp-useredit.sh67
-rwxr-xr-xt/dejagnu.sh35
-rwxr-xr-xt/dejagnu2.sh46
-rwxr-xr-xt/dejagnu3.sh70
-rwxr-xr-xt/dejagnu4.sh102
-rwxr-xr-xt/dejagnu5.sh63
-rwxr-xr-xt/dejagnu6.sh58
-rwxr-xr-xt/dejagnu7.sh62
-rwxr-xr-xt/deleted-am.sh59
-rwxr-xr-xt/deleted-m4.sh65
-rwxr-xr-xt/depacl2.sh27
-rwxr-xr-xt/depcomp.sh48
-rwxr-xr-xt/depcomp2.sh50
-rwxr-xr-xt/depcomp8a.sh82
-rwxr-xr-xt/depcomp8b.sh76
-rwxr-xr-xt/depdist.sh74
-rwxr-xr-xt/depend.sh34
-rwxr-xr-xt/depend3.sh46
-rwxr-xr-xt/depend4.sh36
-rwxr-xr-xt/depend5.sh78
-rwxr-xr-xt/depend6.sh46
-rwxr-xr-xt/deprecated-acinit.sh52
-rwxr-xr-xt/destdir.sh50
-rwxr-xr-xt/dirlist-abspath.sh42
-rwxr-xr-xt/dirlist.sh57
-rwxr-xr-xt/dirlist2.sh60
-rwxr-xr-xt/discover.sh43
-rwxr-xr-xt/dist-auxdir-many-subdirs.sh140
-rwxr-xr-xt/dist-auxfile-2.sh60
-rwxr-xr-xt/dist-auxfile.sh95
-rwxr-xr-xt/dist-formats.tap451
-rwxr-xr-xt/dist-included-parent-dir.sh49
-rwxr-xr-xt/dist-missing-am.sh66
-rwxr-xr-xt/dist-missing-included-m4.sh68
-rwxr-xr-xt/dist-missing-m4.sh70
-rwxr-xr-xt/dist-pr109765.sh42
-rwxr-xr-xt/dist-readonly.sh60
-rwxr-xr-xt/dist-repeated.sh102
-rwxr-xr-xt/distcheck-configure-flags-am.sh68
-rwxr-xr-xt/distcheck-configure-flags-subpkg.sh81
-rwxr-xr-xt/distcheck-configure-flags.sh54
-rwxr-xr-xt/distcheck-hook.sh51
-rwxr-xr-xt/distcheck-hook2.sh79
-rwxr-xr-xt/distcheck-missing-m4.sh118
-rwxr-xr-xt/distcheck-outdated-m4.sh137
-rwxr-xr-xt/distcheck-override-infodir.sh61
-rwxr-xr-xt/distcheck-pr10470.sh59
-rwxr-xr-xt/distcheck-pr9579.sh96
-rwxr-xr-xt/distcheck-writable-srcdir.sh48
-rwxr-xr-xt/distcleancheck.sh71
-rwxr-xr-xt/distcom-subdir.sh75
-rwxr-xr-xt/distcom2.sh82
-rwxr-xr-xt/distcom3.sh57
-rwxr-xr-xt/distcom4.sh77
-rwxr-xr-xt/distcom5.sh84
-rwxr-xr-xt/distdir.sh82
-rwxr-xr-xt/disthook.sh89
-rwxr-xr-xt/distlinks.sh72
-rwxr-xr-xt/distlinksbrk.sh68
-rwxr-xr-xt/distname.sh47
-rwxr-xr-xt/dmalloc.sh59
-rwxr-xr-xt/doc-parsing-buglets-colneq-subst.sh37
-rwxr-xr-xt/doc-parsing-buglets-tabs.sh59
-rwxr-xr-xt/dollar.sh44
-rwxr-xr-xt/dollarvar.sh63
-rwxr-xr-xt/dollarvar2.sh91
-rwxr-xr-xt/double.sh29
-rwxr-xr-xt/dup2.sh29
-rwxr-xr-xt/else.sh38
-rwxr-xr-xt/empty.sh29
-rwxr-xr-xt/empty2.sh35
-rwxr-xr-xt/empty3.sh32
-rwxr-xr-xt/empty4.sh38
-rwxr-xr-xt/exdir.sh30
-rwxr-xr-xt/exdir2.sh29
-rwxr-xr-xt/exdir3.sh35
-rwxr-xr-xt/exeext.sh88
-rwxr-xr-xt/exeext2.sh43
-rwxr-xr-xt/exeext3.sh41
-rwxr-xr-xt/exeext4.sh69
-rwxr-xr-xt/exsource.sh37
-rwxr-xr-xt/ext.sh45
-rwxr-xr-xt/ext2.sh66
-rwxr-xr-xt/ext3.sh39
-rwxr-xr-xt/extra-portability.sh96
-rwxr-xr-xt/extra-portability2.sh50
-rwxr-xr-xt/extra-portability3.sh60
-rwxr-xr-xt/extra-programs-empty.sh53
-rwxr-xr-xt/extra.sh40
-rwxr-xr-xt/extra10.sh50
-rwxr-xr-xt/extra11.sh93
-rwxr-xr-xt/extra12.sh51
-rwxr-xr-xt/extra2.sh33
-rwxr-xr-xt/extra3.sh28
-rwxr-xr-xt/extra4.sh29
-rwxr-xr-xt/extra5.sh38
-rwxr-xr-xt/extra6.sh55
-rwxr-xr-xt/extra7.sh64
-rwxr-xr-xt/extra8.sh36
-rwxr-xr-xt/extra9.sh43
-rwxr-xr-xt/extradep.sh107
-rwxr-xr-xt/extradep2.sh88
-rwxr-xr-xt/f90only.sh34
-rwxr-xr-xt/flavor.sh59
-rwxr-xr-xt/flibs.sh54
-rwxr-xr-xt/fn99.sh51
-rwxr-xr-xt/fn99subdir.sh81
-rwxr-xr-xt/fnoc.sh39
-rwxr-xr-xt/fo.sh36
-rwxr-xr-xt/fonly.sh34
-rwxr-xr-xt/forcemiss.sh34
-rwxr-xr-xt/forcemiss2.sh40
-rwxr-xr-xt/fort1.sh30
-rwxr-xr-xt/fort2.sh62
-rwxr-xr-xt/fort4.sh92
-rwxr-xr-xt/fort5.sh105
-rwxr-xr-xt/fortdep.sh39
-rwxr-xr-xt/gcj.sh36
-rwxr-xr-xt/gcj2.sh33
-rwxr-xr-xt/gcj3.sh37
-rwxr-xr-xt/gcj4.sh49
-rwxr-xr-xt/gcj5.sh32
-rwxr-xr-xt/gcj6.sh51
-rwxr-xr-xt/gen-testsuite-part414
-rwxr-xr-xt/get-sysconf.sh62
-rwxr-xr-xt/gettext-macros.sh94
-rwxr-xr-xt/gettext.sh87
-rwxr-xr-xt/gettext2.sh61
-rwxr-xr-xt/gettext3.sh47
-rwxr-xr-xt/gnits.sh42
-rwxr-xr-xt/gnits2.sh114
-rwxr-xr-xt/gnits3.sh104
-rwxr-xr-xt/gnumake.sh43
-rwxr-xr-xt/gnuwarn.sh54
-rwxr-xr-xt/gnuwarn2.sh42
-rwxr-xr-xt/hdr-vars-defined-once.sh50
-rwxr-xr-xt/header.sh45
-rwxr-xr-xt/help-depend.sh37
-rwxr-xr-xt/help-depend2.sh38
-rwxr-xr-xt/help-dmalloc.sh32
-rwxr-xr-xt/help-init.sh37
-rwxr-xr-xt/help-lispdir.sh37
-rwxr-xr-xt/help-multilib.sh34
-rwxr-xr-xt/help-python.sh32
-rwxr-xr-xt/help-silent.sh43
-rwxr-xr-xt/help-upc.sh33
-rwxr-xr-xt/help.sh46
-rwxr-xr-xt/help2.sh52
-rwxr-xr-xt/help3.sh60
-rwxr-xr-xt/help4.sh54
-rwxr-xr-xt/hfs.sh33
-rwxr-xr-xt/implicit.sh35
-rwxr-xr-xt/info.sh44
-rwxr-xr-xt/init.sh38
-rwxr-xr-xt/init2.sh30
-rwxr-xr-xt/insh2.sh40
-rwxr-xr-xt/install-info-dir.sh176
-rwxr-xr-xt/install2.sh50
-rwxr-xr-xt/installdir.sh64
-rwxr-xr-xt/instdat.sh32
-rwxr-xr-xt/instdat2.sh89
-rw-r--r--t/instdir-cond.sh48
-rw-r--r--t/instdir-cond2.sh51
-rwxr-xr-xt/instdir-java.sh59
-rwxr-xr-xt/instdir-lisp.sh57
-rwxr-xr-xt/instdir-ltlib.sh87
-rwxr-xr-xt/instdir-no-empty.sh123
-rwxr-xr-xt/instdir-prog.sh86
-rwxr-xr-xt/instdir-python.sh61
-rwxr-xr-xt/instdir-texi.sh71
-rwxr-xr-xt/instdir.sh70
-rwxr-xr-xt/instdir2.sh92
-rwxr-xr-xt/instexec.sh27
-rwxr-xr-xt/instfail-info.sh63
-rwxr-xr-xt/instfail-java.sh57
-rwxr-xr-xt/instfail-libtool.sh81
-rwxr-xr-xt/instfail.sh95
-rwxr-xr-xt/insthook.sh77
-rwxr-xr-xt/instman.sh34
-rwxr-xr-xt/instman2.sh33
-rwxr-xr-xt/instmany-mans.sh141
-rwxr-xr-xt/instmany-python.sh130
-rwxr-xr-xt/instmany.sh185
-rwxr-xr-xt/instsh.sh39
-rwxr-xr-xt/instsh2.sh118
-rwxr-xr-xt/instsh3.sh43
-rwxr-xr-xt/instspc.tap335
-rwxr-xr-xt/interp.sh38
-rwxr-xr-xt/interp2.sh37
-rwxr-xr-xt/java-check.sh64
-rwxr-xr-xt/java-clean.sh66
-rwxr-xr-xt/java-compile-install.sh97
-rwxr-xr-xt/java-compile-run-flat.sh241
-rwxr-xr-xt/java-compile-run-nested.sh251
-rwxr-xr-xt/java-empty-classpath.sh88
-rwxr-xr-xt/java-extra.sh73
-rwxr-xr-xt/java-mix.sh68
-rwxr-xr-xt/java-no-duplicate.sh45
-rwxr-xr-xt/java-nobase.sh65
-rwxr-xr-xt/java-noinst.sh55
-rwxr-xr-xt/java-rebuild.sh124
-rwxr-xr-xt/java-sources.sh65
-rwxr-xr-xt/java-uninstall.sh97
-rwxr-xr-xt/java.sh52
-rwxr-xr-xt/java2.sh47
-rwxr-xr-xt/java3.sh57
-rwxr-xr-xt/javadir-undefined.sh35
-rwxr-xr-xt/javaflags.sh60
-rwxr-xr-xt/javaprim.sh36
-rwxr-xr-xt/javasubst.sh36
-rwxr-xr-xt/ldadd.sh46
-rwxr-xr-xt/ldflags.sh50
-rwxr-xr-xt/lex-clean-cxx.sh127
-rwxr-xr-xt/lex-clean.sh114
-rwxr-xr-xt/lex-depend-cxx.sh96
-rwxr-xr-xt/lex-depend-grep.sh46
-rwxr-xr-xt/lex-depend.sh89
-rwxr-xr-xt/lex-lib-external.sh79
-rwxr-xr-xt/lex-lib.sh72
-rwxr-xr-xt/lex-libobj.sh78
-rwxr-xr-xt/lex-line.sh123
-rwxr-xr-xt/lex-nodist.sh90
-rwxr-xr-xt/lex-noyywrap.sh75
-rwxr-xr-xt/lex-pr204.sh89
-rwxr-xr-xt/lex-subobj-nodep.sh74
-rwxr-xr-xt/lex.sh40
-rwxr-xr-xt/lex2.sh35
-rwxr-xr-xt/lex3.sh91
-rwxr-xr-xt/lex5.sh98
-rwxr-xr-xt/lexcpp.sh44
-rwxr-xr-xt/lexvpath.sh128
-rwxr-xr-xt/lflags.sh73
-rwxr-xr-xt/lflags2.sh72
-rwxr-xr-xt/libexec.sh35
-rwxr-xr-xt/libobj-basic.sh112
-rwxr-xr-xt/libobj10.sh56
-rwxr-xr-xt/libobj12.sh77
-rwxr-xr-xt/libobj13.sh51
-rwxr-xr-xt/libobj14.sh44
-rwxr-xr-xt/libobj15a.sh40
-rwxr-xr-xt/libobj15b.sh43
-rwxr-xr-xt/libobj15c.sh50
-rwxr-xr-xt/libobj16a.sh139
-rwxr-xr-xt/libobj16b.sh140
-rwxr-xr-xt/libobj17.sh72
-rwxr-xr-xt/libobj18.sh45
-rwxr-xr-xt/libobj19.sh96
-rwxr-xr-xt/libobj2.sh68
-rwxr-xr-xt/libobj20a.sh45
-rwxr-xr-xt/libobj20b.sh57
-rwxr-xr-xt/libobj20c.sh54
-rwxr-xr-xt/libobj3.sh39
-rwxr-xr-xt/libobj4.sh34
-rwxr-xr-xt/libobj5.sh39
-rwxr-xr-xt/libobj7.sh72
-rwxr-xr-xt/library.sh38
-rwxr-xr-xt/library2.sh31
-rwxr-xr-xt/library3.sh52
-rwxr-xr-xt/libtoo10.sh60
-rwxr-xr-xt/libtoo11.sh38
-rwxr-xr-xt/libtool-macros.sh60
-rwxr-xr-xt/libtool.sh41
-rwxr-xr-xt/libtool2.sh49
-rwxr-xr-xt/libtool3.sh90
-rwxr-xr-xt/libtool4.sh37
-rwxr-xr-xt/libtool5.sh44
-rwxr-xr-xt/libtool6.sh45
-rwxr-xr-xt/libtool7.sh108
-rwxr-xr-xt/libtool8.sh53
-rwxr-xr-xt/libtool9.sh102
-rwxr-xr-xt/license.sh61
-rwxr-xr-xt/license2.sh39
-rwxr-xr-xt/link_c_cxx.sh45
-rwxr-xr-xt/link_cond.sh90
-rwxr-xr-xt/link_dist.sh47
-rwxr-xr-xt/link_f90_only.sh44
-rwxr-xr-xt/link_f_only.sh44
-rwxr-xr-xt/link_fc.sh46
-rwxr-xr-xt/link_fccxx.sh46
-rwxr-xr-xt/link_fcxx.sh45
-rwxr-xr-xt/link_override.sh44
-rwxr-xr-xt/lisp2.sh75
-rwxr-xr-xt/lisp3.sh94
-rwxr-xr-xt/lisp4.sh80
-rwxr-xr-xt/lisp5.sh79
-rwxr-xr-xt/lisp6.sh105
-rwxr-xr-xt/lisp7.sh51
-rwxr-xr-xt/lisp8.sh63
-rwxr-xr-xt/lispdry.sh58
-rw-r--r--t/list-of-tests.mk1274
-rwxr-xr-xt/listval.sh46
-rwxr-xr-xt/location.sh97
-rwxr-xr-xt/longlin2.sh48
-rwxr-xr-xt/longline.sh30
-rwxr-xr-xt/ltcond.sh105
-rwxr-xr-xt/ltcond2.sh97
-rwxr-xr-xt/ltconv.sh156
-rwxr-xr-xt/ltdeps.sh61
-rwxr-xr-xt/ltinit.sh67
-rwxr-xr-xt/ltinstloc.sh68
-rwxr-xr-xt/ltlibobjs.sh43
-rwxr-xr-xt/ltlibsrc.sh74
-rwxr-xr-xt/ltorder.sh62
-rwxr-xr-xt/lzma.sh41
-rwxr-xr-xt/m4-inclusion.sh56
-rwxr-xr-xt/maintclean-vpath.sh104
-rwxr-xr-xt/maintclean.sh96
-rwxr-xr-xt/maintmode-configure-msg.sh73
-rwxr-xr-xt/make-dryrun.tap125
-rwxr-xr-xt/make.sh52
-rwxr-xr-xt/makefile-deps.sh29
-rwxr-xr-xt/makej.sh53
-rwxr-xr-xt/makej2.sh44
-rwxr-xr-xt/maken.sh62
-rwxr-xr-xt/maken3.sh190
-rwxr-xr-xt/makevars.sh33
-rwxr-xr-xt/man.sh33
-rwxr-xr-xt/man2.sh53
-rwxr-xr-xt/man3.sh44
-rwxr-xr-xt/man4.sh105
-rwxr-xr-xt/man5.sh67
-rwxr-xr-xt/man6.sh101
-rwxr-xr-xt/man7.sh59
-rwxr-xr-xt/man8.sh61
-rwxr-xr-xt/mdate.sh37
-rwxr-xr-xt/mdate2.sh40
-rwxr-xr-xt/mdate3.sh49
-rwxr-xr-xt/mdate4.sh46
-rwxr-xr-xt/mdate5.sh45
-rwxr-xr-xt/mdate6.sh36
-rwxr-xr-xt/missing-auxfile-stops-makefiles-creation.sh65
-rwxr-xr-xt/missing.sh66
-rwxr-xr-xt/missing2.sh58
-rwxr-xr-xt/missing3.sh53
-rwxr-xr-xt/missing4.sh47
-rwxr-xr-xt/missing5.sh64
-rwxr-xr-xt/missing6.sh51
-rwxr-xr-xt/mkinst2.sh36
-rwxr-xr-xt/mkinst3.sh65
-rwxr-xr-xt/mkinstall.sh31
-rwxr-xr-xt/mmode.sh64
-rwxr-xr-xt/mmodely.sh93
-rwxr-xr-xt/multlib.sh162
-rwxr-xr-xt/no-extra-makefile-code.sh36
-rwxr-xr-xt/no-outdir-option.sh29
-rwxr-xr-xt/nobase-libtool.sh95
-rwxr-xr-xt/nobase-nodist.sh60
-rwxr-xr-xt/nobase-python.sh79
-rwxr-xr-xt/nobase.sh147
-rwxr-xr-xt/nodef.sh58
-rwxr-xr-xt/nodef2.sh54
-rwxr-xr-xt/nodep.sh40
-rwxr-xr-xt/nodep2.sh44
-rwxr-xr-xt/nodepcomp.sh26
-rwxr-xr-xt/nodist.sh40
-rwxr-xr-xt/nodist2.sh38
-rwxr-xr-xt/nodist3.sh37
-rwxr-xr-xt/noinst.sh32
-rwxr-xr-xt/noinstdir.sh49
-rwxr-xr-xt/nolink.sh36
-rwxr-xr-xt/nostdinc.sh56
-rwxr-xr-xt/notrans.sh131
-rwxr-xr-xt/number.sh37
-rwxr-xr-xt/objc.sh36
-rwxr-xr-xt/objc2.sh31
-rwxr-xr-xt/objext-pr10128.sh58
-rwxr-xr-xt/obsolete.sh57
-rwxr-xr-xt/oldvars.sh35
-rwxr-xr-xt/order.sh32
-rwxr-xr-xt/output-order.sh53
-rwxr-xr-xt/output.sh35
-rwxr-xr-xt/output10.sh61
-rwxr-xr-xt/output11.sh63
-rwxr-xr-xt/output12.sh60
-rwxr-xr-xt/output13.sh50
-rwxr-xr-xt/output2.sh38
-rwxr-xr-xt/output3.sh38
-rwxr-xr-xt/output4.sh35
-rwxr-xr-xt/output5.sh31
-rwxr-xr-xt/output6.sh72
-rwxr-xr-xt/output7.sh72
-rwxr-xr-xt/output8.sh52
-rwxr-xr-xt/output9.sh52
-rwxr-xr-xt/override-conditional-1.sh53
-rwxr-xr-xt/override-conditional-2.sh39
-rwxr-xr-xt/override-html.sh33
-rwxr-xr-xt/override-suggest-local.sh44
-rwxr-xr-xt/parallel-am.sh103
-rwxr-xr-xt/parallel-am2.sh77
-rwxr-xr-xt/parallel-am3.sh74
-rwxr-xr-xt/parallel-tests-cmdline-override.sh84
-rwxr-xr-xt/parallel-tests-console-output.sh104
-rwxr-xr-xt/parallel-tests-driver-install.sh93
-rwxr-xr-xt/parallel-tests-dry-run-1.sh93
-rwxr-xr-xt/parallel-tests-dry-run-2.sh113
-rwxr-xr-xt/parallel-tests-empty-testlogs.sh95
-rwxr-xr-xt/parallel-tests-exeext.sh67
-rwxr-xr-xt/parallel-tests-exit-statuses.sh102
-rwxr-xr-xt/parallel-tests-extra-programs.sh182
-rwxr-xr-xt/parallel-tests-fd-redirect-exeext.sh118
-rwxr-xr-xt/parallel-tests-fd-redirect.sh70
-rwxr-xr-xt/parallel-tests-fork-bomb.sh144
-rwxr-xr-xt/parallel-tests-harderror.sh96
-rwxr-xr-xt/parallel-tests-interrupt.tap117
-rwxr-xr-xt/parallel-tests-log-compiler-1.sh126
-rwxr-xr-xt/parallel-tests-log-compiler-2.sh96
-rwxr-xr-xt/parallel-tests-log-compiler-example.sh69
-rwxr-xr-xt/parallel-tests-log-override-1.sh110
-rwxr-xr-xt/parallel-tests-log-override-2.sh85
-rwxr-xr-xt/parallel-tests-log-override-recheck.sh99
-rwxr-xr-xt/parallel-tests-many.sh190
-rwxr-xr-xt/parallel-tests-no-color-in-log.sh63
-rwxr-xr-xt/parallel-tests-no-spurious-summary.sh68
-rwxr-xr-xt/parallel-tests-once.sh48
-rwxr-xr-xt/parallel-tests-reset-term.sh89
-rwxr-xr-xt/parallel-tests-subdir.sh51
-rwxr-xr-xt/parallel-tests-suffix-prog.sh77
-rwxr-xr-xt/parallel-tests-suffix.sh63
-rwxr-xr-xt/parallel-tests-trailing-bslash.sh114
-rwxr-xr-xt/parallel-tests-unreadable.sh76
-rwxr-xr-xt/parallel-tests.sh152
-rwxr-xr-xt/parallel-tests10.sh47
-rwxr-xr-xt/parallel-tests2.sh149
-rwxr-xr-xt/parallel-tests3.sh116
-rwxr-xr-xt/parallel-tests5.sh66
-rwxr-xr-xt/parallel-tests6.sh43
-rwxr-xr-xt/parallel-tests8.sh75
-rwxr-xr-xt/parallel-tests9.sh80
-rwxr-xr-xt/parse.sh36
-rwxr-xr-xt/percent.sh36
-rwxr-xr-xt/percent2.sh39
-rwxr-xr-xt/phony.sh29
-rwxr-xr-xt/pluseq.sh30
-rwxr-xr-xt/pluseq10.sh55
-rwxr-xr-xt/pluseq11.sh52
-rwxr-xr-xt/pluseq2.sh46
-rwxr-xr-xt/pluseq3.sh50
-rwxr-xr-xt/pluseq4.sh34
-rwxr-xr-xt/pluseq5.sh60
-rwxr-xr-xt/pluseq6.sh38
-rwxr-xr-xt/pluseq7.sh38
-rwxr-xr-xt/pluseq8.sh43
-rwxr-xr-xt/pluseq9.sh71
-rw-r--r--t/pm/Cond2.pl22
-rw-r--r--t/pm/Cond3.pl22
-rw-r--r--t/pm/Condition-t.pl327
-rw-r--r--t/pm/Condition.pl277
-rw-r--r--t/pm/DisjCon2.pl24
-rw-r--r--t/pm/DisjCon3.pl23
-rw-r--r--t/pm/DisjConditions-t.pl461
-rw-r--r--t/pm/DisjConditions.pl404
-rw-r--r--t/pm/Version.pl129
-rw-r--r--t/pm/Version2.pl20
-rw-r--r--t/pm/Version3.pl20
-rw-r--r--t/pm/Wrap.pl112
-rwxr-xr-xt/posixsubst-data.sh74
-rwxr-xr-xt/posixsubst-extradist.sh54
-rwxr-xr-xt/posixsubst-ldadd.sh78
-rwxr-xr-xt/posixsubst-libraries.sh65
-rwxr-xr-xt/posixsubst-ltlibraries.sh66
-rwxr-xr-xt/posixsubst-programs.sh63
-rwxr-xr-xt/posixsubst-scripts.sh99
-rwxr-xr-xt/posixsubst-sources.sh81
-rwxr-xr-xt/posixsubst-tests.sh68
-rwxr-xr-xt/postproc.sh48
-rwxr-xr-xt/ppf77.sh34
-rwxr-xr-xt/pr2.sh51
-rwxr-xr-xt/pr211.sh51
-rwxr-xr-xt/pr220.sh58
-rwxr-xr-xt/pr224.sh64
-rwxr-xr-xt/pr229.sh35
-rwxr-xr-xt/pr243.sh57
-rwxr-xr-xt/pr266.sh46
-rwxr-xr-xt/pr279-2.sh51
-rwxr-xr-xt/pr279.sh50
-rwxr-xr-xt/pr287.sh48
-rwxr-xr-xt/pr300-lib.sh76
-rwxr-xr-xt/pr300-ltlib.sh84
-rwxr-xr-xt/pr300-prog.sh72
-rwxr-xr-xt/pr307.sh93
-rwxr-xr-xt/pr401.sh189
-rwxr-xr-xt/pr401b.sh189
-rwxr-xr-xt/pr401c.sh192
-rwxr-xr-xt/pr72.sh44
-rwxr-xr-xt/pr8365-remake-timing.sh107
-rwxr-xr-xt/pr87.sh71
-rwxr-xr-xt/pr9.sh58
-rwxr-xr-xt/prefix.sh33
-rwxr-xr-xt/primary-prefix-couples-documented-valid.sh87
-rwxr-xr-xt/primary-prefix-couples-force-valid.sh87
-rwxr-xr-xt/primary-prefix-invalid-couples.tap194
-rwxr-xr-xt/primary-prefix-valid-couples.sh88
-rwxr-xr-xt/primary.sh30
-rwxr-xr-xt/primary2.sh32
-rwxr-xr-xt/primary3.sh43
-rwxr-xr-xt/print-libdir.sh46
-rwxr-xr-xt/proginst.sh29
-rwxr-xr-xt/programs-primary-rewritten.sh61
-rwxr-xr-xt/py-compile-basedir.sh50
-rwxr-xr-xt/py-compile-basic.sh63
-rwxr-xr-xt/py-compile-basic2.sh70
-rwxr-xr-xt/py-compile-destdir.sh43
-rwxr-xr-xt/py-compile-env.sh59
-rwxr-xr-xt/py-compile-option-terminate.sh43
-rwxr-xr-xt/py-compile-usage.sh75
-rwxr-xr-xt/python-dist.sh78
-rwxr-xr-xt/python-pr10995.sh60
-rwxr-xr-xt/python-vars.sh107
-rwxr-xr-xt/python-virtualenv.sh187
-rwxr-xr-xt/python.sh60
-rwxr-xr-xt/python10.sh85
-rwxr-xr-xt/python11.sh55
-rwxr-xr-xt/python12.sh56
-rwxr-xr-xt/python2.sh106
-rwxr-xr-xt/python3.sh49
-rwxr-xr-xt/python4.sh43
-rwxr-xr-xt/python5.sh45
-rwxr-xr-xt/python5b.sh53
-rwxr-xr-xt/python6.sh38
-rwxr-xr-xt/python7.sh38
-rwxr-xr-xt/python8.sh37
-rwxr-xr-xt/python9.sh38
-rwxr-xr-xt/recurs.sh36
-rwxr-xr-xt/recurs2.sh29
-rwxr-xr-xt/remake-all-1.sh67
-rwxr-xr-xt/remake-all-2.sh75
-rwxr-xr-xt/remake-am-pr10111.sh62
-rwxr-xr-xt/remake-deleted-am-2.sh75
-rwxr-xr-xt/remake-deleted-am-subdir.sh77
-rwxr-xr-xt/remake-deleted-am.sh67
-rwxr-xr-xt/remake-deleted-m4-file.sh74
-rwxr-xr-xt/remake-gnulib-add-acsubst.sh133
-rwxr-xr-xt/remake-gnulib-add-header.sh109
-rwxr-xr-xt/remake-gnulib-remove-header.sh136
-rwxr-xr-xt/remake-m4-pr10111.sh60
-rwxr-xr-xt/remake-moved-m4-file.sh76
-rwxr-xr-xt/remake-renamed-am.sh58
-rwxr-xr-xt/remake-renamed-m4-file.sh83
-rwxr-xr-xt/remake-renamed-m4-macro-and-file.sh86
-rwxr-xr-xt/remake-renamed-m4-macro.sh72
-rwxr-xr-xt/remake-subdir-from-subdir.sh56
-rwxr-xr-xt/remake-subdir-gnu.sh80
-rwxr-xr-xt/remake-subdir-long-time.sh114
-rwxr-xr-xt/remake-subdir.sh81
-rwxr-xr-xt/remake-subdir2.sh82
-rwxr-xr-xt/remake.sh38
-rwxr-xr-xt/remake10a.sh111
-rwxr-xr-xt/remake10b.sh110
-rwxr-xr-xt/remake10c.sh114
-rwxr-xr-xt/remake11.sh81
-rwxr-xr-xt/remake12.sh146
-rwxr-xr-xt/remake1a.sh55
-rwxr-xr-xt/remake2.sh38
-rwxr-xr-xt/remake3.sh38
-rwxr-xr-xt/remake3a.sh73
-rwxr-xr-xt/remake4.sh56
-rwxr-xr-xt/remake5.sh80
-rwxr-xr-xt/remake6.sh64
-rwxr-xr-xt/remake7.sh69
-rwxr-xr-xt/remake8a.sh190
-rwxr-xr-xt/remake8b.sh192
-rwxr-xr-xt/remake9a.sh109
-rwxr-xr-xt/remake9b.sh111
-rwxr-xr-xt/remake9c.sh112
-rwxr-xr-xt/remake9d.sh112
-rwxr-xr-xt/repeated-options.sh82
-rwxr-xr-xt/req.sh39
-rwxr-xr-xt/reqd.sh45
-rwxr-xr-xt/reqd2.sh57
-rwxr-xr-xt/rst-formatting.sh93
-rwxr-xr-xt/rulepat.sh30
-rwxr-xr-xt/sanity.sh43
-rwxr-xr-xt/scripts.sh27
-rwxr-xr-xt/seenc.sh43
-rwxr-xr-xt/self-check-cleanup.tap179
-rwxr-xr-xt/self-check-configure-help.sh274
-rwxr-xr-xt/self-check-dir.tap73
-rwxr-xr-xt/self-check-env-sanitize.tap57
-rwxr-xr-xt/self-check-exit.tap108
-rwxr-xr-xt/self-check-explicit-skips.sh54
-rwxr-xr-xt/self-check-is-blocked-signal.tap29
-rwxr-xr-xt/self-check-is_newest.tap80
-rwxr-xr-xt/self-check-me.tap73
-rwxr-xr-xt/self-check-reexec.tap205
-rwxr-xr-xt/self-check-report.sh54
-rwxr-xr-xt/self-check-sanity.sh72
-rwxr-xr-xt/self-check-seq.tap75
-rwxr-xr-xt/self-check-tap.sh43
-rwxr-xr-xt/self-check-unindent.tap255
-rwxr-xr-xt/serial-tests.sh86
-rwxr-xr-xt/silent-amopts.sh28
-rwxr-xr-xt/silent-configsite.sh84
-rwxr-xr-xt/silent-lex.sh139
-rwxr-xr-xt/silent-many-gcc.sh241
-rwxr-xr-xt/silent-many-generic.sh266
-rwxr-xr-xt/silent-nested-vars.sh147
-rwxr-xr-xt/silent-nowarn.sh44
-rwxr-xr-xt/silent-yacc-headers.sh173
-rwxr-xr-xt/silent-yacc.sh136
-rwxr-xr-xt/silent.sh83
-rwxr-xr-xt/silent2.sh84
-rwxr-xr-xt/silent3.sh87
-rwxr-xr-xt/silent4.sh88
-rwxr-xr-xt/silent6.sh107
-rwxr-xr-xt/silent7.sh92
-rwxr-xr-xt/silent8.sh66
-rwxr-xr-xt/silent9.sh87
-rwxr-xr-xt/silentcxx-gcc.sh109
-rwxr-xr-xt/silentcxx.sh110
-rwxr-xr-xt/silentf77.sh92
-rwxr-xr-xt/silentf90.sh92
-rwxr-xr-xt/space.sh29
-rwxr-xr-xt/specflg-dummy.sh247
-rwxr-xr-xt/specflg.sh51
-rwxr-xr-xt/specflg10.sh87
-rwxr-xr-xt/specflg2.sh59
-rwxr-xr-xt/specflg3.sh43
-rwxr-xr-xt/specflg6.sh56
-rwxr-xr-xt/specflg7.sh65
-rwxr-xr-xt/specflg8.sh64
-rwxr-xr-xt/specflg9.sh45
-rwxr-xr-xt/spell.sh29
-rwxr-xr-xt/spell2.sh31
-rwxr-xr-xt/spell3.sh31
-rwxr-xr-xt/spelling.sh30
-rwxr-xr-xt/spy-rm.tap48
-rwxr-xr-xt/spy.sh106
-rwxr-xr-xt/srcsub.sh33
-rwxr-xr-xt/srcsub2.sh36
-rwxr-xr-xt/stamph2.sh69
-rwxr-xr-xt/stdinc.sh62
-rwxr-xr-xt/stdlib.sh52
-rwxr-xr-xt/stdlib2.sh94
-rwxr-xr-xt/strictness-override.sh123
-rwxr-xr-xt/strictness-precedence.sh77
-rwxr-xr-xt/strip.sh50
-rwxr-xr-xt/strip2.sh53
-rwxr-xr-xt/strip3.sh53
-rwxr-xr-xt/subcond.sh42
-rwxr-xr-xt/subcond2.sh89
-rwxr-xr-xt/subcond3.sh90
-rwxr-xr-xt/subdir.sh40
-rwxr-xr-xt/subdir10.sh37
-rwxr-xr-xt/subdir2.sh52
-rwxr-xr-xt/subdir3.sh36
-rwxr-xr-xt/subdir4.sh70
-rwxr-xr-xt/subdir5.sh95
-rwxr-xr-xt/subdir6.sh40
-rwxr-xr-xt/subdir7.sh45
-rwxr-xr-xt/subdir8.sh97
-rwxr-xr-xt/subdir9.sh55
-rwxr-xr-xt/subdirbuiltsources.sh71
-rwxr-xr-xt/subobj.sh45
-rwxr-xr-xt/subobj10.sh55
-rwxr-xr-xt/subobj11a.sh81
-rwxr-xr-xt/subobj11b.sh85
-rwxr-xr-xt/subobj11c.sh51
-rwxr-xr-xt/subobj2.sh38
-rwxr-xr-xt/subobj4.sh52
-rwxr-xr-xt/subobj5.sh70
-rwxr-xr-xt/subobj6.sh85
-rwxr-xr-xt/subobj7.sh38
-rwxr-xr-xt/subobj8.sh47
-rwxr-xr-xt/subobj9.sh89
-rwxr-xr-xt/subobjname.sh72
-rwxr-xr-xt/subpkg-yacc.sh129
-rwxr-xr-xt/subpkg.sh113
-rwxr-xr-xt/subpkg2.sh66
-rwxr-xr-xt/subpkg3.sh55
-rwxr-xr-xt/subpkg4.sh71
-rwxr-xr-xt/subst-no-trailing-empty-line.sh97
-rwxr-xr-xt/subst.sh39
-rwxr-xr-xt/subst3.sh177
-rwxr-xr-xt/subst4.sh44
-rwxr-xr-xt/subst5.sh40
-rwxr-xr-xt/substre2.sh50
-rwxr-xr-xt/substref.sh54
-rwxr-xr-xt/substtarg.sh50
-rwxr-xr-xt/suffix-chain.tap64
-rwxr-xr-xt/suffix.sh57
-rwxr-xr-xt/suffix10.tap71
-rwxr-xr-xt/suffix11.tap82
-rwxr-xr-xt/suffix12.sh59
-rwxr-xr-xt/suffix13.sh72
-rwxr-xr-xt/suffix2.sh54
-rwxr-xr-xt/suffix3.tap82
-rwxr-xr-xt/suffix4.sh39
-rwxr-xr-xt/suffix5.sh66
-rwxr-xr-xt/suffix6.sh63
-rwxr-xr-xt/suffix6b.sh75
-rwxr-xr-xt/suffix6c.sh92
-rwxr-xr-xt/suffix7.sh37
-rwxr-xr-xt/suffix8.tap94
-rwxr-xr-xt/suffix9.sh64
-rwxr-xr-xt/symlink.sh40
-rwxr-xr-xt/symlink2.sh32
-rwxr-xr-xt/syntax.sh31
-rwxr-xr-xt/tags.sh29
-rwxr-xr-xt/tags2.sh42
-rwxr-xr-xt/tagsub.sh46
-rwxr-xr-xt/tap-ambiguous-directive.sh56
-rwxr-xr-xt/tap-autonumber.sh75
-rwxr-xr-xt/tap-bad-prog.tap113
-rwxr-xr-xt/tap-bailout-and-logging.sh49
-rwxr-xr-xt/tap-bailout-leading-space.sh72
-rwxr-xr-xt/tap-bailout-suppress-badexit.sh65
-rwxr-xr-xt/tap-bailout-suppress-later-diagnostic.sh45
-rwxr-xr-xt/tap-bailout-suppress-later-errors.sh74
-rwxr-xr-xt/tap-bailout.sh138
-rwxr-xr-xt/tap-basic.sh175
-rwxr-xr-xt/tap-color.sh173
-rwxr-xr-xt/tap-common-setup.sh43
-rwxr-xr-xt/tap-deps.sh87
-rwxr-xr-xt/tap-diagnostic-custom.sh94
-rwxr-xr-xt/tap-diagnostic.sh124
-rwxr-xr-xt/tap-doc.sh98
-rwxr-xr-xt/tap-doc2.sh140
-rwxr-xr-xt/tap-driver-stderr.sh50
-rwxr-xr-xt/tap-empty-diagnostic.sh41
-rwxr-xr-xt/tap-empty.sh55
-rwxr-xr-xt/tap-escape-directive-2.sh55
-rwxr-xr-xt/tap-escape-directive.sh39
-rwxr-xr-xt/tap-exit.sh54
-rwxr-xr-xt/tap-fancy.sh133
-rwxr-xr-xt/tap-fancy2.sh138
-rwxr-xr-xt/tap-global-log.sh122
-rwxr-xr-xt/tap-global-result.sh187
-rwxr-xr-xt/tap-log.sh164
-rwxr-xr-xt/tap-merge-stdout-stderr.sh72
-rwxr-xr-xt/tap-missing-plan-and-bad-exit.sh43
-rwxr-xr-xt/tap-more.sh162
-rwxr-xr-xt/tap-more2.sh91
-rwxr-xr-xt/tap-msg0-bailout.sh38
-rwxr-xr-xt/tap-msg0-directive.sh41
-rwxr-xr-xt/tap-msg0-misc.sh82
-rwxr-xr-xt/tap-msg0-planskip.sh37
-rwxr-xr-xt/tap-msg0-result.sh63
-rwxr-xr-xt/tap-negative-numbers.sh58
-rwxr-xr-xt/tap-no-disable-hard-error.sh50
-rwxr-xr-xt/tap-no-merge-stdout-stderr.sh53
-rwxr-xr-xt/tap-no-spurious-numbers.sh99
-rwxr-xr-xt/tap-no-spurious-summary.sh47
-rwxr-xr-xt/tap-no-spurious.sh114
-rwxr-xr-xt/tap-not-ok-skip.sh39
-rwxr-xr-xt/tap-number-wordboundary.sh112
-rwxr-xr-xt/tap-numbers-leading-zero.sh109
-rwxr-xr-xt/tap-numeric-description.sh69
-rwxr-xr-xt/tap-out-of-order.sh81
-rwxr-xr-xt/tap-passthrough-exit.sh59
-rwxr-xr-xt/tap-passthrough.sh166
-rwxr-xr-xt/tap-plan-corner.sh198
-rwxr-xr-xt/tap-plan-errors.sh114
-rwxr-xr-xt/tap-plan-leading-zero.sh57
-rwxr-xr-xt/tap-plan-malformed.sh60
-rwxr-xr-xt/tap-plan-middle.sh83
-rwxr-xr-xt/tap-plan-whitespace.sh41
-rwxr-xr-xt/tap-plan.sh52
-rwxr-xr-xt/tap-planskip-and-logging.sh74
-rwxr-xr-xt/tap-planskip-badexit.sh52
-rwxr-xr-xt/tap-planskip-bailout.sh36
-rwxr-xr-xt/tap-planskip-case-insensitive.sh46
-rwxr-xr-xt/tap-planskip-late.sh44
-rwxr-xr-xt/tap-planskip-later-errors.sh40
-rwxr-xr-xt/tap-planskip-unplanned-corner.sh48
-rwxr-xr-xt/tap-planskip-unplanned.sh73
-rwxr-xr-xt/tap-planskip-whitespace.sh48
-rwxr-xr-xt/tap-planskip.sh78
-rwxr-xr-xt/tap-realtime.sh126
-rwxr-xr-xt/tap-recheck-logs.sh119
-rwxr-xr-xt/tap-recheck.sh215
-rwxr-xr-xt/tap-result-comment.sh54
-rwxr-xr-xt/tap-signal.tap140
-rwxr-xr-xt/tap-summary-color.sh23
-rwxr-xr-xt/tap-summary.sh23
-rwxr-xr-xt/tap-test-number-0.sh86
-rwxr-xr-xt/tap-todo-skip-together.sh40
-rwxr-xr-xt/tap-todo-skip-whitespace.sh100
-rwxr-xr-xt/tap-todo-skip.sh91
-rwxr-xr-xt/tap-unplanned.sh159
-rwxr-xr-xt/tap-whitespace-normalization.sh165
-rwxr-xr-xt/tap-with-and-without-number.sh50
-rwxr-xr-xt/tap-xfail-tests.sh68
-rwxr-xr-xt/tar-override.sh65
-rwxr-xr-xt/tar.sh40
-rwxr-xr-xt/tar2.sh40
-rwxr-xr-xt/tar3.sh52
-rwxr-xr-xt/target-cflags.sh76
-rwxr-xr-xt/targetclash.sh33
-rwxr-xr-xt/test-driver-acsubst.sh88
-rwxr-xr-xt/test-driver-cond.sh119
-rwxr-xr-xt/test-driver-create-log-dir.sh83
-rwxr-xr-xt/test-driver-custom-multitest-recheck.sh214
-rwxr-xr-xt/test-driver-custom-multitest-recheck2.sh188
-rwxr-xr-xt/test-driver-custom-multitest.sh172
-rwxr-xr-xt/test-driver-custom-no-extra-driver.sh64
-rwxr-xr-xt/test-driver-custom-xfail-tests.sh166
-rwxr-xr-xt/test-driver-custom.sh144
-rwxr-xr-xt/test-driver-fail.sh65
-rwxr-xr-xt/test-driver-is-distributed.sh94
-rwxr-xr-xt/test-driver-strip-vpath.sh98
-rwxr-xr-xt/test-driver-trs-suffix-registered.sh58
-rwxr-xr-xt/test-extensions-cond.sh70
-rwxr-xr-xt/test-extensions.sh72
-rwxr-xr-xt/test-harness-vpath-rewrite.sh58
-rwxr-xr-xt/test-log.sh178
-rwxr-xr-xt/test-logs-repeated.sh45
-rwxr-xr-xt/test-metadata-global-log.sh147
-rwxr-xr-xt/test-metadata-global-result.sh196
-rwxr-xr-xt/test-metadata-recheck.sh164
-rwxr-xr-xt/test-metadata-results.sh176
-rwxr-xr-xt/test-missing.sh72
-rwxr-xr-xt/test-missing2.sh54
-rwxr-xr-xt/test-trs-basic.sh158
-rwxr-xr-xt/test-trs-recover.sh167
-rwxr-xr-xt/test-trs-recover2.sh133
-rwxr-xr-xt/tests-environment-and-log-compiler.sh75
-rwxr-xr-xt/tests-environment-backcompat.sh59
-rwxr-xr-xt/tests-environment-fd-redirect.sh94
-rwxr-xr-xt/tests-environment.sh45
-rwxr-xr-xt/testsuite-summary-color.sh199
-rwxr-xr-xt/testsuite-summary-count-many.sh105
-rwxr-xr-xt/testsuite-summary-count.sh161
-rwxr-xr-xt/testsuite-summary-reference-log.sh88
-rwxr-xr-xt/transform.sh65
-rwxr-xr-xt/transform2.sh95
-rwxr-xr-xt/transform3.sh87
-rwxr-xr-xt/txinfo-no-clutter.sh102
-rwxr-xr-xt/txinfo-unrecognized-extension.sh38
-rwxr-xr-xt/txinfo.sh47
-rwxr-xr-xt/txinfo10.sh39
-rwxr-xr-xt/txinfo13.sh65
-rwxr-xr-xt/txinfo16.sh91
-rwxr-xr-xt/txinfo17.sh39
-rwxr-xr-xt/txinfo19.sh70
-rwxr-xr-xt/txinfo2.sh45
-rwxr-xr-xt/txinfo20.sh76
-rwxr-xr-xt/txinfo21.sh176
-rwxr-xr-xt/txinfo22.sh68
-rwxr-xr-xt/txinfo23.sh66
-rwxr-xr-xt/txinfo24.sh83
-rwxr-xr-xt/txinfo25.sh111
-rwxr-xr-xt/txinfo26.sh67
-rwxr-xr-xt/txinfo27.sh46
-rwxr-xr-xt/txinfo28.sh89
-rwxr-xr-xt/txinfo29.sh62
-rwxr-xr-xt/txinfo3.sh53
-rwxr-xr-xt/txinfo30.sh63
-rwxr-xr-xt/txinfo31.sh29
-rwxr-xr-xt/txinfo32.sh40
-rwxr-xr-xt/txinfo33.sh126
-rwxr-xr-xt/txinfo4.sh32
-rwxr-xr-xt/txinfo5.sh38
-rwxr-xr-xt/txinfo5b.sh41
-rwxr-xr-xt/txinfo6.sh33
-rwxr-xr-xt/txinfo7.sh33
-rwxr-xr-xt/txinfo8.sh62
-rwxr-xr-xt/txinfo9.sh41
-rwxr-xr-xt/uninstall-fail.sh96
-rwxr-xr-xt/uninstall-pr9578.sh67
-rwxr-xr-xt/unused.sh35
-rwxr-xr-xt/upc.sh50
-rwxr-xr-xt/upc2.sh31
-rwxr-xr-xt/upc3.sh65
-rwxr-xr-xt/vala-mix.sh115
-rwxr-xr-xt/vala-mix2.sh119
-rwxr-xr-xt/vala-vpath.sh70
-rwxr-xr-xt/vala.sh86
-rwxr-xr-xt/vala1.sh52
-rwxr-xr-xt/vala2.sh87
-rwxr-xr-xt/vala3.sh96
-rwxr-xr-xt/vala4.sh61
-rwxr-xr-xt/vala5.sh83
-rwxr-xr-xt/vars.sh36
-rwxr-xr-xt/vars3.sh72
-rwxr-xr-xt/vartar.sh39
-rwxr-xr-xt/vartypo2.sh70
-rwxr-xr-xt/vartypos.sh89
-rwxr-xr-xt/version.sh41
-rwxr-xr-xt/version2.sh41
-rwxr-xr-xt/version3.sh27
-rwxr-xr-xt/version4.sh26
-rwxr-xr-xt/version6.sh36
-rwxr-xr-xt/version7.sh67
-rwxr-xr-xt/version8.sh24
-rwxr-xr-xt/vpath.sh33
-rwxr-xr-xt/vtexi.sh62
-rwxr-xr-xt/vtexi2.sh42
-rwxr-xr-xt/vtexi3.sh124
-rwxr-xr-xt/vtexi4.sh113
-rwxr-xr-xt/warning-groups-win-over-strictness.sh64
-rwxr-xr-xt/warnings-override.sh111
-rwxr-xr-xt/warnings-precedence.sh77
-rwxr-xr-xt/warnings-strictness-interactions.sh59
-rwxr-xr-xt/warnings-unknown.sh48
-rwxr-xr-xt/warnings-win-over-strictness.sh90
-rwxr-xr-xt/warnopts.sh73
-rwxr-xr-xt/werror.sh26
-rwxr-xr-xt/werror2.sh48
-rwxr-xr-xt/werror3.sh48
-rwxr-xr-xt/werror4.sh66
-rwxr-xr-xt/whoami.sh27
-rw-r--r--t/wrap/aclocal.in32
-rw-r--r--t/wrap/automake.in30
-rwxr-xr-xt/xsource.sh38
-rwxr-xr-xt/yacc-auxdir.sh56
-rwxr-xr-xt/yacc-basic.sh109
-rwxr-xr-xt/yacc-bison-skeleton-cxx.sh98
-rwxr-xr-xt/yacc-bison-skeleton.sh72
-rwxr-xr-xt/yacc-clean-cxx.sh163
-rwxr-xr-xt/yacc-clean.sh147
-rwxr-xr-xt/yacc-cxx.sh137
-rwxr-xr-xt/yacc-d-basic.sh154
-rwxr-xr-xt/yacc-d-cxx.sh231
-rwxr-xr-xt/yacc-d-vpath.sh108
-rwxr-xr-xt/yacc-deleted-headers.sh163
-rwxr-xr-xt/yacc-depend.sh82
-rwxr-xr-xt/yacc-depend2.sh86
-rwxr-xr-xt/yacc-dist-nobuild-subdir.sh93
-rwxr-xr-xt/yacc-dist-nobuild.sh90
-rwxr-xr-xt/yacc-line.sh113
-rwxr-xr-xt/yacc-mix-c-cxx.sh206
-rwxr-xr-xt/yacc-nodist.sh104
-rwxr-xr-xt/yacc-pr204.sh84
-rwxr-xr-xt/yacc-weirdnames.sh54
-rwxr-xr-xt/yacc.sh37
-rwxr-xr-xt/yacc2.sh72
-rwxr-xr-xt/yacc4.sh86
-rwxr-xr-xt/yacc5.sh80
-rwxr-xr-xt/yacc7.sh89
-rwxr-xr-xt/yacc8.sh109
-rwxr-xr-xt/yaccdry.sh58
-rwxr-xr-xt/yaccpp.sh81
-rwxr-xr-xt/yaccvpath.sh97
-rwxr-xr-xt/yflags-cmdline-override.sh88
-rwxr-xr-xt/yflags-conditional.sh143
-rwxr-xr-xt/yflags-d-false-positives.sh41
-rwxr-xr-xt/yflags-force-conditional.sh85
-rwxr-xr-xt/yflags-force-override.sh62
-rwxr-xr-xt/yflags-var-expand.sh61
-rwxr-xr-xt/yflags.sh70
-rwxr-xr-xt/yflags2.sh70
1232 files changed, 91604 insertions, 0 deletions
diff --git a/t/CheckListOfTests.am b/t/CheckListOfTests.am
new file mode 100644
index 000000000..a3913f2cd
--- /dev/null
+++ b/t/CheckListOfTests.am
@@ -0,0 +1,68 @@
+## -*- Automake -*-
+##
+## Copyright (C) 2011-2012 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/>.
+##
+
+## Temporary files used in the 'check-list-of-tests' recipe.
+am__tmk = tests-in-makefile-list.tmp
+am__tfs = tests-on-filesystem-list.tmp
+am__tdf = diff-in-tests-lists.tmp
+
+## Check that the list of tests given in the Makefile is equal to the
+## list of all test scripts in the Automake testsuite.
+.PHONY: maintainer-check-list-of-tests
+maintainer-check-list-of-tests:
+## Prefer unified diffs over plain diffs, for readability.
+ @if diff -u /dev/null /dev/null >/dev/null 2>&1; then \
+ diff='diff -u'; \
+ else \
+ diff='diff'; \
+ fi; \
+## List of tests in Makefile.
+ lst='$(expected_list_of_tests)'; \
+ test -n "$$lst" || lst='$(TESTS)'; \
+ for t in $$lst; do \
+ echo "$$t"; \
+ done | sort >$(am__tmk); \
+## List of subdirs where to look for tests.
+ dirs='$(test_subdirs)'; \
+ test -n "$$dirs" || dirs=.; \
+## List of tests on filesystem. Be careful to cater for VPATH builds too.
+ test_extensions='$(TEST_EXTENSIONS)'; \
+ for ext in $$test_extensions; do \
+ for dir in $$dirs; do \
+ ls $$dir/*$$ext 2>/dev/null; \
+ if test $(srcdir) != $(builddir); then \
+ ($(am__cd) $(srcdir) && ls $$dir/*$$ext 2>/dev/null); \
+ fi; \
+ done; \
+ done | sed 's,^\./,,' | sort | uniq >$(am__tfs); \
+## Compare the two lists, complain if they differ.
+ if $$diff $(am__tmk) $(am__tfs) >$(am__tdf); then \
+ result=0; \
+ else \
+ echo '$@: list of tests in Makefile an on filesystem differ' >&2; \
+ echo "+ $$diff in-makefile on-filesystem" >&2; \
+ cat $(am__tdf) >&2; \
+ result=1; \
+ fi; \
+ rm -f $(am__tmk) $(am__tfs) $(am__tdf); \
+ exit $$result;
+
+.PHONY: clean-maintcheck-testslist-tmp
+clean-local: clean-maintcheck-testslist-tmp
+clean-maintcheck-testslist-tmp:
+ rm -f $(am__tmk) $(am__tfs) $(am__tdf)
diff --git a/t/Makefile.am b/t/Makefile.am
new file mode 100644
index 000000000..ca00f3735
--- /dev/null
+++ b/t/Makefile.am
@@ -0,0 +1,194 @@
+## Process this file with automake to create Makefile.in
+
+# Copyright (C) 1996-2012 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/>.
+
+# Run the tests with the shell detected at configure time.
+LOG_COMPILER = $(SHELL)
+
+TEST_EXTENSIONS = .pl .sh .tap
+SH_LOG_COMPILER = $(LOG_COMPILER)
+TAP_LOG_COMPILER = $(LOG_COMPILER)
+PL_LOG_COMPILER = $(PERL)
+AM_PL_LOG_FLAGS = -Mstrict -I $(top_builddir)/lib -I $(top_srcdir)/lib -w
+
+TAP_LOG_DRIVER = AM_TAP_AWK='$(AWK)' $(SHELL) $(top_srcdir)/lib/tap-driver.sh
+
+AM_TAP_LOG_DRIVER_FLAGS = --merge
+
+EXTRA_DIST = ax/is
+
+TESTS = ## Will be updated later.
+
+# Some testsuite-influential variables should be overridable from the
+# test scripts, but not from the environment.
+AM_TESTS_ENVIRONMENT = \
+ for v in \
+ me \
+ required \
+ am_using_tap \
+ am_parallel_tests \
+ am_test_prefer_config_shell \
+ am_original_AUTOMAKE \
+ am_original_ACLOCAL \
+ ; do \
+ eval test x"\$${$$v}" = x || unset $$v; \
+ done;
+# The 'AM_TESTS_REEXEC=no' setting tells the tests not to needlessly
+# re-execute themselves with the shell detected at configure time, since
+# we are already running them under it explicitly in our setup (see e.g.
+# the definition of TEST_LOG_COMPILER above).
+AM_TESTS_ENVIRONMENT += AM_TESTS_REEXEC=no; export AM_TESTS_REEXEC;
+# We want warning messages and explanations for skipped tests to go to
+# the console if possible, so set up 'stderr_fileno_' properly.
+AM_TESTS_FD_REDIRECT = 9>&2
+AM_TESTS_ENVIRONMENT += stderr_fileno_=9; export stderr_fileno_;
+
+# Hand-written tests.
+
+include $(srcdir)/list-of-tests.mk
+
+TESTS += $(handwritten_TESTS)
+EXTRA_DIST += $(handwritten_TESTS)
+
+# Automatically-generated tests wrapping hand-written ones.
+# Also, automatically-computed dependencies for tests.
+
+include $(srcdir)/testsuite-part.am
+
+TESTS += $(generated_TESTS)
+EXTRA_DIST += $(generated_TESTS)
+
+$(srcdir)/testsuite-part.am:
+ $(AM_V_at)rm -f testsuite-part.tmp $@
+ $(AM_V_GEN)$(PERL) $(srcdir)/gen-testsuite-part \
+ --srcdir $(srcdir) > testsuite-part.tmp
+ $(AM_V_at)chmod a-w testsuite-part.tmp
+ $(AM_V_at)mv -f testsuite-part.tmp $@
+EXTRA_DIST += gen-testsuite-part
+
+$(generated_TESTS) $(srcdir)/testsuite-part.am: \
+ gen-testsuite-part list-of-tests.mk Makefile.am $(handwritten_TESTS)
+
+# Static dependencies valid for each test case.
+check_SCRIPTS = wrap/aclocal-$(APIVERSION) wrap/automake-$(APIVERSION)
+check_DATA = defs defs-static
+dist_check_DATA = ax/plain-functions.sh ax/tap-functions.sh
+
+# Few more static dependencies.
+distcheck-missing-m4.log: ax/distcheck-hook-m4.am
+distcheck-outdated-m4.log: ax/distcheck-hook-m4.am
+EXTRA_DIST += ax/distcheck-hook-m4.am
+
+# Keep in sync with AC_SUBST'd stuff in defs-static.in.
+do_subst = sed \
+ -e 's|@abs_srcdir[@]|$(abs_srcdir)|g' \
+ -e 's|@abs_top_srcdir[@]|$(abs_top_srcdir)|g' \
+ -e 's|@abs_builddir[@]|$(abs_builddir)|g' \
+ -e 's|@abs_top_builddir[@]|$(abs_top_builddir)|g' \
+ -e 's|@prefix[@]|$(prefix)|g' \
+ -e 's|@amdir[@]|$(amdir)|g' \
+ -e 's|@bindir[@]|$(bindir)|g' \
+ -e 's|@datadir[@]|$(datadir)|g' \
+ -e 's|@docdir[@]|$(docdir)|g' \
+ -e 's|@automake_acdir[@]|$(automake_acdir)|g' \
+ -e 's|@system_acdir[@]|$(system_acdir)|g' \
+ -e 's|@scriptdir[@]|$(scriptdir)|g' \
+ -e 's|@pkgvdatadir[@]|$(pkgvdatadir)|g' \
+ -e 's|@host_alias[@]|$(host_alias)|g' \
+ -e 's|@build_alias[@]|$(build_alias)|g' \
+ -e 's|@APIVERSION[@]|$(APIVERSION)|g' \
+ -e 's|@PATH_SEPARATOR[@]|$(PATH_SEPARATOR)|g' \
+ -e 's|@SHELL[@]|$(SHELL)|g' \
+ -e 's|@AWK[@]|$(AWK)|g' \
+ -e 's|@PERL[@]|$(PERL)|g' \
+ -e 's|@EGREP[@]|$(EGREP)|g' \
+ -e 's|@FGREP[@]|$(FGREP)|g' \
+ -e 's|@CPPFLAGS[@]|$(CPPFLAGS)|g' \
+ -e 's|@CC[@]|$(CC)|g' \
+ -e 's|@CFLAGS[@]|$(CFLAGS)|g' \
+ -e 's|@CXX[@]|$(CXX)|g' \
+ -e 's|@CXXFLAGS[@]|$(CXXFLAGS)|g' \
+ -e 's|@F77[@]|$(F77)|g' \
+ -e 's|@FFLAGS[@]|$(FFLAGS)|g' \
+ -e 's|@FC[@]|$(FC)|g' \
+ -e 's|@FCFLAGS[@]|$(FCFLAGS)|g' \
+ -e 's|@GNU_CC[@]|$(GNU_CC)|g' \
+ -e 's|@GNU_CFLAGS[@]|$(GNU_CFLAGS)|g' \
+ -e 's|@GNU_CXX[@]|$(GNU_CXX)|g' \
+ -e 's|@GNU_CXXFLAGS[@]|$(GNU_CXXFLAGS)|g' \
+ -e 's|@GNU_F77[@]|$(GNU_F77)|g' \
+ -e 's|@GNU_FFLAGS[@]|$(GNU_FFLAGS)|g' \
+ -e 's|@GNU_FC[@]|$(GNU_FC)|g' \
+ -e 's|@GNU_FCFLAGS[@]|$(GNU_FCFLAGS)|g' \
+ -e 's|@GNU_GCJ[@]|$(GNU_GCJ)|g' \
+ -e 's|@GNU_GCJFLAGS[@]|$(GNU_GCJFLAGS)|g' \
+ -e 's|@YACC[@]|$(YACC)|g' \
+ -e 's|@LEX[@]|$(LEX)|g' \
+ -e 's|@TEX[@]|$(TEX)|g' \
+ -e 's|@MODIFICATION_DELAY[@]|$(MODIFICATION_DELAY)|g' \
+ -e 's|@am_AUTOCONF[@]|$(am_AUTOCONF)|g' \
+ -e 's|@am_AUTOM4TE[@]|$(am_AUTOM4TE)|g' \
+ -e 's|@am_AUTORECONF[@]|$(am_AUTORECONF)|g' \
+ -e 's|@am_AUTOHEADER[@]|$(am_AUTOHEADER)|g' \
+ -e 's|@am_AUTOUPDATE[@]|$(am_AUTOUPDATE)|g' \
+ -e 's|@sh_errexit_works[@]|$(sh_errexit_works)|g' \
+ -e 's|@configure_input[@]|Generated from $@.in. DO NOT EDIT BY HAND!|'
+
+defs-static: defs-static.in
+ $(AM_V_at)rm -f $@ $@-t
+ $(AM_V_GEN)$(do_subst) $(srcdir)/defs-static.in >$@-t
+ $(AM_V_at) : Sanity check on the substitutions; \
+ if LC_ALL=C grep '@[a-zA-Z0-9_][a-zA-Z0-9_]*@' $@-t; then \
+ echo "$@ contains unexpanded substitution (see lines above)"; \
+ exit 1; \
+ fi
+ $(AM_V_at)chmod a-w $@-t && mv -f $@-t $@
+EXTRA_DIST += defs-static.in
+CLEANFILES = defs-static
+
+# If two test scripts have the same basename, they will end up sharing
+# the same log file, leading to all sort of undefined and undesired
+# behaviours.
+check-no-repeated-test-name:
+ @LC_ALL=C; export LC_ALL; \
+ lst='$(TEST_LOGS)'; for log in $$lst; do echo $$log; done \
+ | sort | uniq -c | awk '($$1 > 1) { print }' \
+ | sed 's/\.log$$//' | grep . >&2 \
+ && { \
+ echo $@: test names listed above are duplicated >&2; \
+ exit 1; \
+ }; :
+check-local: check-no-repeated-test-name
+.PHONY: check-no-repeated-test-name
+
+## Checking the list of tests.
+test_subdirs = . pm
+include $(srcdir)/CheckListOfTests.am
+
+# Run the testsuite with the installed aclocal and automake.
+installcheck-local:
+ am_running_installcheck=yes $(MAKE) $(AM_MAKEFLAGS) check
+
+clean-local: clean-local-check
+.PHONY: clean-local-check
+clean-local-check:
+ -set x *.dir; shift; \
+ if test "$$#,$$1" = "1,*.dir"; then \
+ : there is no test directory to clean; \
+ else \
+ find "$$@" -type d ! -perm -700 -exec chmod u+rwx {} ';'; \
+ rm -rf "$$@"; \
+ fi;
diff --git a/t/README b/t/README
new file mode 100644
index 000000000..33a653c71
--- /dev/null
+++ b/t/README
@@ -0,0 +1,299 @@
+ The Automake test suite
+
+
+User interface
+==============
+
+
+Running the tests
+-----------------
+
+ To run all tests:
+
+ make -k check
+
+ You can use '-jN' for faster completion (it even helps on a
+ uniprocessor system, due to unavoidable sleep delays, as
+ noted below).
+
+ To rerun only failed tests:
+
+ make -k recheck
+
+ To run only tests that are newer than their last results:
+
+ make -k check RECHECK_LOGS=
+
+ To run only selected tests:
+
+ make -k check TESTS="foo.test bar.test" (GNU make)
+ env TESTS="foo.test bar.test" make -e -k check (non-GNU make)
+
+ To run the tests in cross-compilation mode, you should first configure
+ the automake source tree to a cross-compilation setup. For example, to
+ run with a Linux-to-MinGW cross compiler, you will need something like
+ this:
+
+ ./configure --host i586-mingw32msvc --build i686-pc-linux-gnu
+
+ To avoid possible spurious error, you really have to *explicitly* specify
+ '--build' in addition to '--host'; the 'lib/config.guess' script can help
+ determine the correct value to pass to '--build'.
+ Then you can just run the testsuite in the usual way, and the test cases
+ using a compiler should automatically use a cross-compilation setup.
+
+
+Interpretation
+--------------
+
+ Successes:
+ PASS - success
+ XFAIL - expected failure
+
+ Failures:
+ FAIL - failure
+ XPASS - unexpected success
+
+ Other:
+ SKIP - skipped tests (third party tools not available)
+ ERROR - some unexpected error condition
+
+
+Getting details from failures
+-----------------------------
+
+ By default, verbose output of a test 'foo.test' or 'foo.tap' is
+ retained in the log file 'foo.log'. A summary log is created in
+ the file 'test-suite.log'.
+
+ You can limit the set of files using the TESTS variable, and enable
+ detailed test output at the end of the test run with the VERBOSE
+ variable:
+
+ env VERBOSE=x TESTS='first.test second.test ...' make -e check
+
+ You can also run the tests by hand, as explained in the next subsection.
+
+
+About the tests
+---------------
+
+ There are two kinds of tests in the Automake testsuite (both implemented
+ as shell scripts). The scripts with the '.test' suffix are "simple"
+ tests, their outcome completely determined by their exit status. Those
+ with the '.tap' suffix use the TAP protocol. If you want to run a test
+ by hand, you can do so directly if it is a simple test:
+
+ ./nogzip.test
+
+ (it will be verbose by default), while if it is a TAP test you can pass
+ it to your preferred TAP runner, as in e.g.:
+
+ prove --verbose --merge ./add-missing.tap
+
+ The tests can also be run directly in a VPATH build, as with:
+
+ /path/to/srcdir/tests/nogzip.test
+ prove --verbose --merge /path/to/srcdir/tests/add-missing.tap
+
+
+Supported shells
+----------------
+
+ By default, the tests are run by the $SHELL detected at configure
+ time. They also take care to re-execute themselves with that shell,
+ unless told not to. So, to run the tests with a different shell, say
+ '/path/to/another/sh', the user must use:
+
+ AM_TESTS_REEXEC=no /path/to/another/sh ./foo.test
+ AM_TESTS_REEXEC=no prove -v -e /path/to/another/sh ./bar.tap
+
+ to run a test directly, and:
+
+ make check LOG_COMPILER=/path/to/sh (GNU make)
+ LOG_COMPILER=/path/to/sh make -e check (non-GNU make)
+
+ to run the test(s) through the makefile test driver.
+
+ The test scripts are written with portability in mind, so that they
+ should run with any decent Bourne-compatible shell.
+
+ However, some care must be used with Zsh, since, when not directly
+ started in Bourne-compatibility mode, it has some incompatibilities
+ in the handling of $0 which conflict with our usage. Our testsuite
+ can automatically work around these incompatibilities when a version
+ 4.3 or later of Zsh is used, but unfortunately not when an older
+ version of Zsh is used. Thus, if you want to run a test script, say
+ foo.test, with Zsh 4.2, you *can't* simply do "zsh foo.test", but
+ you *must* resort to:
+
+ AM_TESTS_REEXEC=no zsh -o no_function_argzero foo.test
+
+ Note that this problem does not occur if Zsh is executed through
+ a symlink with a basename of 'sh', since in that case Zsh starts
+ in Bourne compatibility mode. So you should be perfectly safe
+ when /bin/sh is Zsh, even a it's version < 4.3.
+
+
+Reporting failures
+------------------
+
+ Send verbose output, i.e., the contents of test-suite.log, of failing
+ tests to <bug-automake@gnu.org>, along with the usual version numbers
+ (which Automake, which Autoconf, which operating system, which make
+ version, which shell, etc.)
+
+
+
+Writing test cases
+==================
+
+
+Do
+--
+
+ If you plan to fix a bug, write the test case first. This way you'll
+ make sure the test catches the bug, and that it succeeds once you have
+ fixed the bug.
+
+ Add a copyright/license paragraph.
+
+ Explain what the test does.
+
+ Cite the PR number (if any), and the original reporter (if any), so
+ we can find or ask for information if needed.
+
+ If a test checks examples or idioms given in the documentation, make
+ sure the documentation reference them appropriately in comments, as in:
+ @c Keep in sync with autodist-config-headers.test.
+ @example
+ ...
+ @end example
+
+ Use "required=..." for required tools. Do not explicitly require
+ tools which can be taken for granted because they're listed in the
+ GNU Coding Standards (for example, 'gzip').
+
+ Include ./defs in every test script (see existing tests for examples
+ of how to do this).
+
+ Use the 'skip_' function to skip tests, with a meaningful message if
+ possible. Where convenient, use the 'warn_' function to print generic
+ warnings, the 'fail_' function for test failures, and the 'fatal_'
+ function for hard errors. In case a hard error is due to a failed
+ set-up of a test scenario, you can use the 'framework_fail_' function
+ instead.
+
+ For tests that use the 'parallel-tests' Automake option, set the shell
+ variable 'am_parallel_tests' to "yes" before including ./defs. For
+ tests that are *not* meant to work with the 'parallel-tests' Automake
+ option (these should be very very few), set the shell variable
+ 'am_parallel_tests' to "no" before including ./defs.
+
+ Some tests in the Automake testsuite are auto-generated; those tests
+ might have custom extensions, but their basename (that is, with such
+ extension stripped) is expected to end with "-w" string, optionally
+ followed by decimal digits. For example, the name of a valid
+ auto-generated test can be 'color-w.test' or 'tap-signal-w09.tap'.
+ Please don't name hand-written tests in a way that could cause them
+ to be confused with auto-generated tests; for example, 'u-v-w.test'
+ or 'option-w0.tap' are *not* valid name for hand-written tests.
+
+ ./defs brings in some commonly required files, and sets a skeleton
+ configure.ac. If possible, append to this file. In some cases
+ you'll have to overwrite it, but this should be the exception. Note
+ that configure.ac registers Makefile.in but do not output anything by
+ default. If you need ./configure to create Makefile, append AC_OUTPUT
+ to configure.ac. In case you don't want ./defs to pre-populate your
+ test directory (which is a rare occurrence), set the 'am_create_testdir'
+ shell variable to "empty" before sourcing ./defs.
+
+ By default, the testcases are run with the errexit shell flag on,
+ to make it easier to catch failures you might not have thought of.
+ If this is undesirable in some testcase, you can use "set +e" to
+ disable the errexit flag (but please do so only if you have a very
+ good reason).
+
+ End the test script with a ":" or "Exit 0". Otherwise, when somebody
+ changes the test by adding a failing command after the last command,
+ the test will spuriously fail because $? is nonzero at the end. Note
+ that this is relevant even if the errexit shell flag is on, in case
+ the test contains commands like "grep ... Makefile.in && Exit 1" (and
+ there are indeed a lot of such tests).
+
+ Use $ACLOCAL, $AUTOMAKE, $AUTOCONF, $AUTOUPDATE, $AUTOHEADER,
+ $PERL, $MAKE, $EGREP, and $FGREP, instead of the corresponding
+ commands.
+
+ Use $sleep when you have to make sure that some file is newer
+ than another.
+
+ Use cat or grep or similar commands to display (part of) files that
+ may be interesting for debugging, so that when a user send a verbose
+ output we don't have to ask him for more details. Display stderr
+ output on the stderr file descriptor. If some redirected command is
+ likely to fail, display its output even in the failure case, before
+ exiting.
+
+ Use 'Exit' rather than 'exit' to abort for leave early from a test
+ case.
+
+ Use '$PATH_SEPARATOR', not hard-coded ':', as the separator of
+ PATH's entries.
+
+ It's more important to make sure that a feature works, than make
+ sure that Automake's output looks correct. It might look correct
+ and still fail to work. In other words, prefer running 'make' over
+ grepping Makefile.in (or do both).
+
+ If you run $ACLOCAL, $AUTOMAKE or $AUTOCONF several times in the
+ same test and change configure.ac by the meantime, do
+ rm -rf autom4te*.cache
+ before the following runs. On fast machines the new configure.ac
+ could otherwise have the same timestamp as the old autom4te.cache.
+
+ Use filenames with two consecutive spaces when testing that some
+ code preserves filenames with spaces. This will catch errors like
+ `echo $filename | ...`.
+
+ Make sure your test script can be used to faithfully check an
+ installed version of automake (as with "make installcheck"). For
+ example, if you need to copy or grep an automake-provided script,
+ do not assume that they can be found in the '$top_srcdir/lib'
+ directory, but use '$am_scriptdir' instead. The complete list of
+ such "$am_...dir" variables can be found in tests/defs-static.in.
+
+ When writing input for lex, include the following in the definitions
+ section:
+ %{
+ #define YY_NO_UNISTD_H 1
+ %}
+ to accomodate non-ANSI systems, since GNU flex generates code that
+ includes unistd.h otherwise. Also add:
+ %option never-interactive
+ to the definitions section if the generated code is to be compiled
+ by a C++ compiler, for similar reasons (i.e., the isatty(3) function
+ from that same unistd.h header would be required otherwise).
+
+ Before commit: make sure the test is executable, add the tests to
+ TESTS in Makefile.am, add it to XFAIL_TESTS in addition if needed,
+ write a ChangeLog entry, send the diff to <automake-patches@gnu.org>.
+
+
+Do not
+------
+
+ Do not test an Automake error with "$AUTOMAKE && Exit 1", or in three
+ years we'll discover that this test failed for some other bogus reason.
+ This happened many times. Better use something like
+ AUTOMAKE_fails
+ grep 'expected diagnostic' stderr
+ (Note this doesn't prevent the test from failing for another reason,
+ but at least it makes sure the original error is still here).
+
+ Do not override Makefile variables using make arguments, as in e.g.:
+ $MAKE prefix=/opt install
+ This is not portable for recursive targets (targets that call a
+ sub-make may not pass "prefix=/opt" along). Use the following
+ instead:
+ prefix=/opt $MAKE -e install
diff --git a/t/ac-output-old.tap b/t/ac-output-old.tap
new file mode 100755
index 000000000..5c906a2f0
--- /dev/null
+++ b/t/ac-output-old.tap
@@ -0,0 +1,180 @@
+#!/bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test for various older bugs related to quoting, escaping and
+# line breaking in the use of AC_OUTPUT. Synthesised by a bunch
+# of older tests (referenced below).
+
+. ./defs || Exit 1
+
+plan_ 22
+
+rm -f configure.ac depcomp # Not required.
+
+# -----------------------------------------------------------------------
+
+# Test for bug reported by François Pinard.
+# If \ is in AC_OUTPUT, automake barfs.
+# This was the old test 'acoutbs.test'.
+
+# Also test for bug reported by David A. Swierczek.
+# Another bug with \ in AC_OUTPUT (this time with whitespace).
+# This was the old test 'acoutbs2.test'.
+
+acoutbs_check ()
+{
+ dir=acoutbs$1
+ mkdir $dir
+ cd $dir
+ cat > configure.ac
+ touch Makefile.am zot.in
+ command_ok_ "aclocal groks '\\' in AC_OUTPUT ($dir)" $ACLOCAL
+ command_ok_ "automake groks '\\' in AC_OUTPUT ($dir)" $AUTOMAKE
+ command_ok_ "autoconf groks '\\' in AC_OUTPUT ($dir)" $AUTOCONF
+ command_ok_ "can ./configure in $dir" ./configure
+ command_ok_ "zot created in $dir" test -f zot
+ ls -a > lst || bailout_ "cannot get file listing in $dir"
+ command_ok_ "'\\' not leaked in filenames in $dir" not grep '\\' lst
+ cd ..
+}
+
+acoutbs_check 1 << 'END'
+AC_INIT
+AM_INIT_AUTOMAKE(nonesuch, nonesuch)
+AC_OUTPUT(Makefile \
+zot)
+END
+
+acoutbs_check 2 << 'END'
+AC_INIT
+AM_INIT_AUTOMAKE(nonesuch, nonesuch)
+AC_ARG_PROGRAM
+AC_PROG_INSTALL
+AC_PROG_MAKE_SET
+AC_OUTPUT(\
+ Makefile \
+ zot
+)
+END
+
+# -----------------------------------------------------------------------
+
+# Test for bug reported by Jerome Santini.
+# If I put this line in my configure.ac:
+# AC_OUTPUT(Makefile src/Makefile tests/Makefile, echo timestamp > stamp-h)dnl
+# automake is not happy:
+# [ ... ]
+# This was the old test 'acoutnoq.test'.
+
+mkdir acoutnoq
+cd acoutnoq
+
+cat > configure.ac << 'END'
+AC_INIT
+AM_INIT_AUTOMAKE(nonesuch, nonesuch)
+AC_OUTPUT(Makefile, [true])
+END
+
+: > Makefile.am
+
+command_ok_ "aclocal and quoted AC_OUTPUT second argument" $ACLOCAL
+command_ok_ "automake and quoted AC_OUTPUT second argument" $AUTOMAKE
+
+cd ..
+
+# -----------------------------------------------------------------------
+
+# Test for bug when AC_OUTPUT has 2 args on the same line, eg:
+# AC_OUTPUT([Makefile automake tests/Makefile],[chmod +x automake])
+# This was the old test 'acoutpt.test'.
+
+mkdir acoutpt
+cd acoutpt
+
+cat > configure.ac << 'END'
+AC_INIT
+AM_INIT_AUTOMAKE(nonesuch, nonesuch)
+AC_OUTPUT([Makefile], [true])
+END
+
+: > Makefile.am
+
+command_ok_ "aclocal and two AC_OUTPUT arguments on same line" $ACLOCAL
+command_ok_ "automake and two AC_OUTPUT arguments on same line" $AUTOMAKE
+
+cd ..
+
+# -----------------------------------------------------------------------
+
+# Test for bug reported by Eric Magnien.
+# This was the old test 'acoutpt2.test'.
+
+mkdir acoutpt2
+cd acoutpt2
+
+# Name of the current "subtest".
+cur=acoutput2
+
+cat > configure.ac <<END
+AC_INIT([$cur], [1.0])
+AM_INIT_AUTOMAKE
+AC_OUTPUT([subdir/Makefile subdir/foo Makefile foo], [true])
+END
+
+mkdir subdir
+
+: > Makefile.am
+: > subdir/Makefile.am
+: > foo.in
+: > subdir/foo.in
+
+command_ok_ "aclocal and AC_OUTPUT ($cur)" $ACLOCAL
+command_ok_ "automake and AC_OUTPUT ($cur)" $AUTOMAKE
+command_ok_ "foo.in mentioned two times in Makefile.in ($cur)" \
+ test `$FGREP foo.in Makefile.in | wc -l` -eq 2
+
+# This ought to work as well.
+command_ok_ "'automake -a -f' and AC_OUTPUT ($cur)" \
+ $AUTOMAKE --add-missing --force-missing
+
+cd ..
+
+# -----------------------------------------------------------------------
+
+# Test for bug reported by François Pinard.
+# This was the old test 'acoutqnl.test'.
+
+mkdir acoutqnl
+cd acoutqnl
+
+cat > configure.ac << 'END'
+AC_INIT
+AM_INIT_AUTOMAKE(nonesuch, nonesuch)
+AC_OUTPUT([Makefile],
+[echo zardoz has spoken])
+END
+
+: > Makefile.am
+
+command_ok_ "aclocal and two AC_OUTPUT arguments on two lines" $ACLOCAL
+command_ok_ "automake and two AC_OUTPUT arguments on two lines" $AUTOMAKE
+
+cd ..
+
+# -----------------------------------------------------------------------
+
+# And we're done.
+Exit 0
diff --git a/t/acloca10.sh b/t/acloca10.sh
new file mode 100755
index 000000000..05db9b9ab
--- /dev/null
+++ b/t/acloca10.sh
@@ -0,0 +1,100 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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 aclocal define macros in the same order as -I's.
+# This is the same as aclocal9.test, with the macro calls reversed.
+# (It did make a difference.)
+#
+# Also check for --install.
+
+# TODO: write a sister test that doesn't use a 'dirlist' file, but
+# TODO: puts third-party macros directly into 'acdir'.
+
+am_create_testdir=empty
+. ./defs || Exit 1
+
+cat > configure.ac << 'END'
+AC_INIT
+MACRO1
+MACRO2
+MACRO3
+END
+
+ACLOCAL="$ACLOCAL --system-acdir acdir"
+
+mkdir m4_1 m4_2 acdir acdir2
+echo ./acdir2 > acdir/dirlist
+
+cat >m4_1/somedefs.m4 <<EOF
+AC_DEFUN([MACRO1], [:macro11:])
+AC_DEFUN([MACRO2], [:macro21:])
+EOF
+
+cat >m4_2/somedefs.m4 <<EOF
+AC_DEFUN([MACRO1], [:macro12:])
+EOF
+
+cat >acdir2/macro.m4 <<EOF
+AC_DEFUN([MACRO3], [:macro33:])
+EOF
+
+$ACLOCAL -I m4_1 -I m4_2
+$AUTOCONF
+$FGREP ':macro11:' configure
+$FGREP ':macro21:' configure
+$FGREP ':macro33:' configure
+grep MACRO3 aclocal.m4
+test ! -f m4_1/macro.m4
+test ! -f m4_2/macro.m4
+
+$sleep
+
+$ACLOCAL -I m4_2 -I m4_1
+$AUTOCONF
+$FGREP ':macro12:' configure
+$FGREP ':macro21:' configure
+$FGREP ':macro33:' configure
+grep MACRO3 aclocal.m4
+test ! -f m4_1/macro.m4
+test ! -f m4_2/macro.m4
+
+$sleep
+
+$ACLOCAL -I m4_1 -I m4_2 --install
+$AUTOCONF
+$FGREP ':macro11:' configure
+$FGREP ':macro21:' configure
+$FGREP ':macro33:' configure
+grep MACRO3 aclocal.m4 && Exit 1
+test -f m4_1/macro.m4
+test ! -f m4_2/macro.m4
+cp aclocal.m4 copy.m4
+
+$sleep
+
+echo '#GREPME' >>acdir2/macro.m4
+$ACLOCAL -I m4_1 -I m4_2 --install
+$AUTOCONF
+$FGREP ':macro11:' configure
+$FGREP ':macro21:' configure
+$FGREP ':macro33:' configure
+grep MACRO3 aclocal.m4 && Exit 1
+grep GREPME m4_1/macro.m4 && Exit 1
+test -f m4_1/macro.m4
+test ! -f m4_2/macro.m4
+diff aclocal.m4 copy.m4
+
+:
diff --git a/t/acloca11.sh b/t/acloca11.sh
new file mode 100755
index 000000000..7a1cff609
--- /dev/null
+++ b/t/acloca11.sh
@@ -0,0 +1,45 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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 that when two files define the same macro in the same
+# directory, the macro from the lexically greatest file is used.
+
+am_create_testdir=empty
+. ./defs || Exit 1
+
+cat > configure.ac << 'END'
+AC_INIT
+MACRO2
+MACRO1
+END
+
+mkdir m4
+
+cat >m4/version1.m4 <<EOF
+AC_DEFUN([MACRO1], [:macro11:])
+AC_DEFUN([MACRO2], [:macro21:])
+EOF
+
+cat >m4/version2.m4 <<EOF
+AC_DEFUN([MACRO1], [:macro12:])
+EOF
+
+$ACLOCAL -I m4
+$AUTOCONF
+$FGREP ':macro12:' configure
+$FGREP ':macro21:' configure
+
+:
diff --git a/t/acloca12.sh b/t/acloca12.sh
new file mode 100755
index 000000000..958238e1b
--- /dev/null
+++ b/t/acloca12.sh
@@ -0,0 +1,46 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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 that when two files define the same macro in the same
+# directory, the macro from the lexically greatest file is used.
+# Same as acloca11.test, but without calling MACRO2.
+
+am_create_testdir=empty
+. ./defs || Exit 1
+
+cat > configure.ac <<END
+AC_INIT([$me], [1.0])
+MACRO1
+END
+
+mkdir m4
+
+cat >m4/version1.m4 <<EOF
+AC_DEFUN([MACRO1], [:macro11:])
+AC_DEFUN([MACRO2], [:macro21:])
+EOF
+
+cat >m4/version2.m4 <<EOF
+AC_DEFUN([MACRO1], [:macro12:])
+EOF
+
+$ACLOCAL --verbose -I m4
+$AUTOCONF
+$FGREP ':macro11:' configure && Exit 1
+$FGREP ':macro21:' configure && Exit 1
+$FGREP ':macro12:' configure
+
+:
diff --git a/t/acloca13.sh b/t/acloca13.sh
new file mode 100755
index 000000000..e91a534ed
--- /dev/null
+++ b/t/acloca13.sh
@@ -0,0 +1,69 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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 changes to m4_included files also cause aclocal.m4 to change.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+m4_include([somefile.m4])
+AC_OUTPUT
+END
+
+cat >Makefile.am <<'EOF'
+check-local:
+ test -f "$(srcdir)/somefile.m4"
+ test -f "$(srcdir)/m4/version1.m4"
+ test -f "$(srcdir)/m4/otherfile.m4"
+EOF
+
+mkdir m4
+
+echo MACRO1 >somefile.m4
+echo 'AC_PREREQ([2.58])' >m4/otherfile.m4
+
+cat >m4/version1.m4 <<EOF
+AC_DEFUN([MACRO1])
+AC_DEFUN([MACRO2])
+m4_sinclude(m4/otherfile.m4)
+EOF
+
+cat >m4/version2.m4 <<EOF
+AC_DEFUN([MACRO1])
+EOF
+
+$ACLOCAL -I m4
+grep version2 aclocal.m4
+grep version1 aclocal.m4 && Exit 1
+
+$sleep
+echo MACRO2 >somefile.m4
+
+$ACLOCAL -I m4
+grep version2 aclocal.m4 && Exit 1
+grep version1 aclocal.m4
+
+$sleep
+# aclocal.m4 should change if we touch otherfile.m4
+touch m4/otherfile.m4
+$sleep
+$ACLOCAL -I m4
+test `ls -1t aclocal.m4 m4/otherfile.m4 | sed 1q` = aclocal.m4
+
+$AUTOCONF
+$AUTOMAKE
+./configure
+$MAKE distcheck
diff --git a/t/acloca14.sh b/t/acloca14.sh
new file mode 100755
index 000000000..ba1f07228
--- /dev/null
+++ b/t/acloca14.sh
@@ -0,0 +1,118 @@
+#! /bin/sh
+# Copyright (C) 2004-2012 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 m4_included files are also scanned for definitions.
+# Report from Phil Edwards.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AM_PROG_LIBTOOL
+AC_OUTPUT
+END
+
+echo 'm4_include([a.m4])' > acinclude.m4
+echo 'm4_include([b.m4])' > a.m4
+
+cat >b.m4 <<EOF
+m4_include([c.m4])
+AC_DEFUN([AM_PROG_LIBTOOL],
+[AC_REQUIRE([SOMETHING])dnl
+AC_REQUIRE([SOMETHING_ELSE])dnl
+])
+
+AC_DEFUN([SOMETHING])
+EOF
+
+echo 'm4_include([d.m4])' > c.m4
+echo 'AC_DEFUN([SOMETHING_ELSE])' >d.m4
+
+mkdir defs
+echo 'AC_DEFUN([SOMETHING_ELSE])' >defs/e.m4
+echo 'AC_DEFUN([ANOTHER_MACRO])' >defs/f.m4
+
+cat >>Makefile.am<<\EOF
+ACLOCAL_AMFLAGS = -I defs
+testdist1: distdir
+ test -f $(distdir)/acinclude.m4
+ test -f $(distdir)/a.m4
+ test -f $(distdir)/b.m4
+ test -f $(distdir)/c.m4
+ test -f $(distdir)/d.m4
+ test ! -d $(distdir)/defs
+testdist2: distdir
+ test -f $(distdir)/acinclude.m4
+ test -f $(distdir)/a.m4
+ test -f $(distdir)/b.m4
+ test -f $(distdir)/c.m4
+ test -f $(distdir)/d.m4
+ test ! -f $(distdir)/defs/e.m4
+ test -f $(distdir)/defs/f.m4
+EOF
+
+$ACLOCAL -I defs
+
+$FGREP acinclude.m4 aclocal.m4
+# None of the following macro should be included. acinclude.m4
+# includes the first four, and the last two are not needed at all.
+$FGREP a.m4 aclocal.m4 && Exit 1
+$FGREP b.m4 aclocal.m4 && Exit 1
+$FGREP c.m4 aclocal.m4 && Exit 1
+$FGREP d.m4 aclocal.m4 && Exit 1
+$FGREP defs/e.m4 aclocal.m4 && Exit 1
+$FGREP defs/f.m4 aclocal.m4 && Exit 1
+
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+$MAKE testdist1
+
+cp aclocal.m4 stamp
+$sleep
+
+cat >>c.m4 <<\EOF
+AC_DEFUN([FOO], [ANOTHER_MACRO])
+EOF
+
+$MAKE
+
+# Because c.m4 has changed, aclocal.m4 must have been rebuilt.
+test `ls -1t aclocal.m4 stamp | sed 1q` = aclocal.m4
+# However, since FOO is not used, f.m4 should not be included
+# and the contents of aclocal.m4 should remain the same
+diff aclocal.m4 stamp
+
+# If FOO where to be used, that would be another story, of course.
+cat >>configure.ac <<EOF
+FOO
+EOF
+
+cp aclocal.m4 stamp
+$sleep
+
+$MAKE
+
+$FGREP defs/f.m4 aclocal.m4
+$MAKE testdist2
+
+# Make sure aclocal diagnose missing included files with correct 'file:line:'.
+rm -f b.m4
+$ACLOCAL 2>stderr && { cat stderr >&2; Exit 1; }
+cat stderr >&2
+grep 'a\.m4:1: .*b\.m4.*does not exist' stderr
+
+:
diff --git a/t/acloca15.sh b/t/acloca15.sh
new file mode 100755
index 000000000..690c06c67
--- /dev/null
+++ b/t/acloca15.sh
@@ -0,0 +1,47 @@
+#! /bin/sh
+# Copyright (C) 2004-2012 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 aclocal scans configure.ac for macro definitions.
+# PR/319.
+
+am_create_testdir=empty
+. ./defs || Exit 1
+
+# Start macros with AM_ because that causes aclocal to complain if it
+# cannot find them.
+
+cat > configure.ac << 'END'
+AC_INIT
+m4_include([somedef.m4])
+AC_DEFUN([AM_SOME_MACRO])
+AC_DEFUN([AM_SOME_OTHER_MACRO])
+AM_SOME_MACRO
+AM_SOME_OTHER_MACRO
+AM_MORE_MACRO
+END
+
+mkdir m4
+echo 'AC_DEFUN([AM_SOME_MACRO])' > m4/some.m4
+echo 'AC_DEFUN([AM_SOME_DEF])' > somedef.m4
+echo 'AC_DEFUN([AM_MORE_MACRO], [AC_REQUIRE([AM_SOME_DEF])])' > m4/more.m4
+
+$ACLOCAL -I m4
+$FGREP AM_SOME_MACRO aclocal.m4 && Exit 1
+$FGREP AM_MORE_MACRO aclocal.m4 && Exit 1
+$FGREP 'm4_include([m4/more.m4])' aclocal.m4
+test 1 = `grep m4_include aclocal.m4 | wc -l`
+
+:
diff --git a/t/acloca16.sh b/t/acloca16.sh
new file mode 100755
index 000000000..ab894c739
--- /dev/null
+++ b/t/acloca16.sh
@@ -0,0 +1,36 @@
+#! /bin/sh
+# Copyright (C) 2004-2012 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 aclocal does not include definitions that are not actually
+# evaluated.
+
+am_create_testdir=empty
+. ./defs || Exit 1
+
+cat > configure.ac << 'END'
+AC_SUBST([POM])
+END
+
+mkdir m4
+cat >m4/some.m4 <<'EOF'
+AC_DEFUN([AM_SOME_MACRO],
+[AC_DEFUN([AC_SUBST], [GREPME])])
+EOF
+
+$ACLOCAL -I m4
+grep m4/some.m4 aclocal.m4 && Exit 1
+
+:
diff --git a/t/acloca17.sh b/t/acloca17.sh
new file mode 100755
index 000000000..e6098f0a6
--- /dev/null
+++ b/t/acloca17.sh
@@ -0,0 +1,41 @@
+#! /bin/sh
+# Copyright (C) 2004-2012 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 aclocal report unused required macros.
+
+am_create_testdir=empty
+. ./defs || Exit 1
+
+cat > configure.ac << 'END'
+AC_INIT
+SOME_DEFS
+END
+
+mkdir m4
+cat >m4/somedefs.m4 <<EOF
+AC_DEFUN([SOME_DEFS], [
+ AC_REQUIRE([UNDEFINED_MACRO])
+])
+EOF
+
+# FIXME: We want autom4te's 'undefined required macro' warning to be fatal,
+# but have no means to say so to aclocal. We use WARNINGS=error instead.
+
+WARNINGS=error $ACLOCAL -I m4 2>stderr && { cat stderr >&2; Exit 1; }
+cat stderr >&2
+grep '^configure\.ac:2:.*UNDEFINED_MACRO' stderr
+
+:
diff --git a/t/acloca18.sh b/t/acloca18.sh
new file mode 100755
index 000000000..c0510e10d
--- /dev/null
+++ b/t/acloca18.sh
@@ -0,0 +1,137 @@
+#! /bin/sh
+# Copyright (C) 2005-2012 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/>.
+
+# Test for --install with #serial numbers.
+
+am_create_testdir=empty
+. ./defs || Exit 1
+
+cat > configure.ac << 'END'
+AC_INIT
+AM_MACRO1
+AM_MACRO2
+END
+
+mkdir 1 2 3 4 5 6
+
+cat >1/m1.m4 <<EOF
+#serial 1.8.1230.9
+AC_DEFUN([AM_MACRO1], [:macro11:])
+AC_DEFUN([AM_MACRO2], [:macro21:])
+EOF
+
+cat >2/m1.m4 <<EOF
+#serial 1.8.1231.9
+AC_DEFUN([AM_MACRO1], [:macro12:])
+EOF
+
+cat >3/m2.m4 <<EOF
+#serial 13
+AC_DEFUN([AM_MACRO2], [:macro23:])
+EOF
+
+cat >3/m1.m4 <<EOF
+#serial 1.8.1230.1
+AC_DEFUN([AM_MACRO1], [:macro13:])
+EOF
+
+cat >4/mumble.m4 <<EOF
+#serial 0
+AC_DEFUN([AM_MACRO1], [:macro14:])
+EOF
+
+cat >5/ill-formed.m4 <<EOF
+#serial bla
+#serial .2
+#serial
+AC_DEFUN([AM_MACRO1], [:macro15:])
+EOF
+
+cat >6/after-def.m4 <<EOF
+AC_DEFUN([AM_MACRO1], [:macro16:])
+#serial 1
+EOF
+
+clean_stale ()
+{
+ rm -rf aclocal.m4 configure autom4te*.cache
+}
+
+$ACLOCAL -I 1 -I 2 -I 3 -I 4
+$AUTOCONF
+$FGREP ':macro11:' configure
+$FGREP ':macro21:' configure
+
+clean_stale
+$ACLOCAL -I 1 -I 2 -I 3 -I 4 --install
+$AUTOCONF
+$FGREP ':macro12:' configure
+$FGREP ':macro23:' configure
+
+cp -f aclocal.m4 aclocal-m4.sav
+clean_stale
+mv -f aclocal-m4.sav aclocal.m4
+$ACLOCAL -I 4 -I 1 -I 2 -I 3 --install --dry-run
+$AUTOCONF
+$FGREP ':macro12:' configure
+$FGREP ':macro23:' configure
+
+clean_stale
+$ACLOCAL -I 4 -I 1 -I 2 -I 3 --install
+$AUTOCONF
+$FGREP ':macro14:' configure
+$FGREP ':macro23:' configure
+
+clean_stale
+$ACLOCAL -I 4 -I 1 -I 2 --install 2>stderr && { cat stderr >&2; Exit 1; }
+cat stderr >&2
+grep 'macro.*AM_MACRO2.*not found' stderr
+
+clean_stale
+$ACLOCAL -I 4 -I 1 --install
+$AUTOCONF
+$FGREP ':macro14:' configure
+$FGREP ':macro21:' configure
+
+mkdir acdir
+ACLOCAL="$ACLOCAL --system-acdir acdir"
+
+cat >acdir/m1.m4 <<EOF
+#serial 456
+AC_DEFUN([AM_MACRO1], [:macro1d:])
+AC_DEFUN([AM_MACRO2], [:macro2d:])
+EOF
+clean_stale
+$ACLOCAL -I 4 -I 1 --diff=diff >stdout 2>stderr || {
+ cat stderr >&2
+ cat stdout
+ Exit 1
+}
+cat stderr >&2
+cat stdout
+grep '#serial 456' stdout
+test ! -f 4/m1.m4
+grep 'installing.*4/m1\.m4' stderr
+
+$ACLOCAL -I 5 2>stderr && { cat stderr >&2; Exit 1; }
+cat stderr >&2
+test `grep -c 'ill-formed serial' stderr` -eq 3
+
+$ACLOCAL -I 6 2>stderr && { cat stderr >&2; Exit 1; }
+cat stderr >&2
+grep 'serial.*before any macro definition' stderr
+
+:
diff --git a/t/acloca19.sh b/t/acloca19.sh
new file mode 100755
index 000000000..60e8afe49
--- /dev/null
+++ b/t/acloca19.sh
@@ -0,0 +1,49 @@
+#! /bin/sh
+# Copyright (C) 2005-2012 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 aclocal does not fail on configure.ac inclusions that do
+# more than just variable definitions.
+# Report from Peter Breitenlohner (PR/450).
+
+. ./defs || Exit 1
+
+cat >configure.ac <<'END'
+AC_INIT([acloca19], [1.0])
+m4_include([aconfig.ac])
+FOO
+AC_OUTPUT
+END
+
+cat >aconfig.ac <<'END'
+AM_INIT_AUTOMAKE
+AC_DEFUN([FOO], [echo GREPME])
+sinclude([bconfig.ac])
+END
+
+cat >bconfig.ac <<'END'
+AC_ARG_WITH([grepme], [string])
+END
+
+$ACLOCAL
+$AUTOCONF
+./configure >stdout || { cat stdout; Exit 1; }
+cat stdout
+grep GREPME stdout
+grep 'aconfig\.ac' aclocal.m4 && Exit 1
+grep 'bconfig\.ac' aclocal.m4 && Exit 1
+grep with-grepme configure
+
+:
diff --git a/t/acloca20.sh b/t/acloca20.sh
new file mode 100755
index 000000000..030506639
--- /dev/null
+++ b/t/acloca20.sh
@@ -0,0 +1,41 @@
+#! /bin/sh
+# Copyright (C) 2006-2012 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 aclocal does not write into symlinked aclocal.m4.
+
+am_create_testdir=empty
+. ./defs || Exit 1
+
+echo 'm4_define([FOO], [wrong foo])' > foo.m4
+echo 'm4_define([FOO], [right foo])' > acinclude.m4
+echo 'AC_INIT FOO' > configure.ac
+
+chmod a-w foo.m4
+
+# Setup.
+ln -s foo.m4 aclocal.m4 && test -h aclocal.m4 \
+ || skip_ "cannot create symlinks to files"
+
+# Sanity check.
+grep 'wrong foo' aclocal.m4 \
+ || fatal_ "weird error symlinking aclocal.m4 -> foo.m4"
+
+$ACLOCAL
+$AUTOCONF
+grep 'right foo' configure
+grep 'wrong foo' foo.m4
+
+:
diff --git a/t/acloca21.sh b/t/acloca21.sh
new file mode 100755
index 000000000..d9b47afc2
--- /dev/null
+++ b/t/acloca21.sh
@@ -0,0 +1,31 @@
+#! /bin/sh
+# Copyright (C) 2006-2012 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 aclocal ignores include() commands in comments.
+# Report from Mike Frysinger.
+# Also make sure aclocal does not think 'include' is
+# an Autoconf macro.
+
+am_create_testdir=empty
+. ./defs || Exit 1
+
+cat >>configure.ac <<EOF
+dnl m4_include(__some_really_bogus_nonexistent_file__.m4)
+ # m4_include(__some_really_bogus_nonexistent_file__.m4)
+## m4_include(__some_really_bogus_nonexistent_file__.m4)
+echo 'include(foobar)' is OK
+EOF
+$ACLOCAL
diff --git a/t/acloca22.sh b/t/acloca22.sh
new file mode 100755
index 000000000..85ef29b4a
--- /dev/null
+++ b/t/acloca22.sh
@@ -0,0 +1,53 @@
+#! /bin/sh
+# Copyright (C) 2007-2012 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 the "deleted header file" issue is fixed w.r.t. aclocal.m4
+# dependencies. See also related the tests 'remake-deleted-m4-file.test'
+# and 'remake-renamed-m4-macro-and-file.test'.
+
+. ./defs || Exit 1
+
+cat >>configure.ac <<EOF
+FOO
+AC_OUTPUT
+EOF
+cat >foo.m4 <<EOF
+AC_DEFUN([FOO], [AC_SUBST([GREPFOO])])
+EOF
+cat >bar.m4 <<EOF
+AC_DEFUN([BAR], [AC_SUBST([GREPBAR])])
+EOF
+cat >Makefile.am <<EOF
+ACLOCAL_AMFLAGS = -I .
+EOF
+
+$ACLOCAL -I .
+$AUTOMAKE
+$AUTOCONF
+
+./configure
+$MAKE
+grep GREPFOO Makefile
+grep GREPBAR Makefile && Exit 1
+
+sed 's/FOO/BAR/' < configure.ac > t
+mv -f t configure.ac
+rm -f foo.m4
+$MAKE
+grep GREPFOO Makefile && Exit 1
+grep GREPBAR Makefile
+
+:
diff --git a/t/acloca23.sh b/t/acloca23.sh
new file mode 100755
index 000000000..b5f66e4ce
--- /dev/null
+++ b/t/acloca23.sh
@@ -0,0 +1,37 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Ensure we diagnose underquoted AC_DEFUN's.
+
+am_create_testdir=empty
+. ./defs || Exit 1
+
+cat > configure.ac << 'END'
+AC_INIT
+FOO
+END
+
+mkdir m4
+cat >m4/foo.m4 <<EOF
+AC_DEFUN(FOO, [echo foo])
+EOF
+
+$ACLOCAL -I m4 2>stderr && { cat stderr >&2; Exit 1; }
+cat stderr >&2
+grep 'underquoted definition.*FOO' stderr
+grep 'warning.*warning' stderr && Exit 1
+
+:
diff --git a/t/aclocal-acdir.sh b/t/aclocal-acdir.sh
new file mode 100755
index 000000000..88caef62f
--- /dev/null
+++ b/t/aclocal-acdir.sh
@@ -0,0 +1,95 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Test aclocal's '--acdir', '--automake-acdir' and '--system-acdir'
+# options. Also check that stuff in the automake acdir takes precedence
+# over stuff in the system acdir.
+
+. ./defs || Exit 1
+
+mkdir am sys
+
+cat >> configure.ac <<'END'
+MY_MACRO
+END
+
+cat > am/foo.m4 <<'END'
+AC_DEFUN([AM_INIT_AUTOMAKE], [fake--init--automake])
+END
+
+cat > sys/foo.m4 <<'END'
+AC_DEFUN([MY_MACRO], [my--macro])
+END
+
+$ACLOCAL --automake-acdir am
+$AUTOCONF --force
+$FGREP 'fake--init--automake' configure
+$FGREP 'MY_MACRO' configure
+
+rm -rf autom4te*.cache
+
+$ACLOCAL --system-acdir sys
+$AUTOCONF --force
+$FGREP 'am__api_version' configure
+$FGREP 'my--macro' configure
+
+rm -rf autom4te*.cache
+
+$ACLOCAL --automake-acdir am --system-acdir sys
+$AUTOCONF --force
+$FGREP 'fake--init--automake' configure
+$FGREP 'my--macro' configure
+
+rm -rf autom4te*.cache
+
+$ACLOCAL --system-acdir sys --automake-acdir am
+$AUTOCONF --force
+$FGREP 'fake--init--automake' configure
+$FGREP 'my--macro' configure
+
+rm -rf autom4te*.cache
+
+# Stuff in automake acdir takes precedence over stuff in system acdir.
+cat > am/bar.m4 <<'END'
+AC_DEFUN([MY_MACRO], [am--macro])
+END
+$ACLOCAL --automake-acdir am --system-acdir sys
+$AUTOCONF --force
+$FGREP 'fake--init--automake' configure
+$FGREP 'am--macro' configure
+$FGREP 'my--macro' configure && Exit 1 # Just to be sure.
+
+rm -rf autom4te*.cache
+
+# Obsolescent '--acdir' option.
+$ACLOCAL -Wobsolete --acdir am 2>stderr && { cat stderr >&2; Exit 1; }
+cat stderr >&2
+grep '.*--acdir.*deprecated' stderr
+
+rm -rf autom4te*.cache
+
+$ACLOCAL -Wno-obsolete --acdir am
+$AUTOCONF --force
+$FGREP 'fake--init--automake' configure
+$FGREP 'am--macro' configure
+
+rm -rf autom4te*.cache
+
+$ACLOCAL -Wno-obsolete --acdir sys 2>stderr && { cat stderr >&2; Exit 1; }
+cat stderr >&2
+grep 'macro .*AM_INIT_AUTOMAKE.* not found' stderr
+
+:
diff --git a/t/aclocal-install-absdir.sh b/t/aclocal-install-absdir.sh
new file mode 100755
index 000000000..b07f7fac9
--- /dev/null
+++ b/t/aclocal-install-absdir.sh
@@ -0,0 +1,33 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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 "aclocal --install" install files also in directories
+# passed to '-I' as absolute paths. Now that we support the
+# ACLOCAL_PATH variable, it is clear that this is the right thing
+# to do. See also automake bug#8407.
+
+. ./defs || Exit 1
+
+mkdir loc sys
+
+echo 'AM_DUMMY_MACRO' >> configure.ac
+echo 'AC_DEFUN([AM_DUMMY_MACRO], [:])' >> sys/foo.m4
+
+cwd=`pwd` || fatal_ "cannot get current working directory"
+env ACLOCAL_PATH="$cwd/sys" $ACLOCAL --verbose --install -I "$cwd/loc"
+diff sys/foo.m4 loc/foo.m4
+
+:
diff --git a/t/aclocal-install-fail.sh b/t/aclocal-install-fail.sh
new file mode 100755
index 000000000..c458239a5
--- /dev/null
+++ b/t/aclocal-install-fail.sh
@@ -0,0 +1,65 @@
+#! /bin/sh
+# Copyright (C) 2012 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/>.
+
+# Check that "aclocal --install" fails when it should.
+# FIXME: this is a good candidate for a conversion to TAP.
+
+am_create_testdir=empty
+required=ro-dir
+. ./defs || Exit 1
+
+set -e
+
+cat > configure.ac <<END
+AC_INIT([$me], [1.0])
+MY_MACRO
+END
+
+mkdir sys-acdir
+cat > sys-acdir/my-defs.m4 <<END
+AC_DEFUN([MY_MACRO], [:])
+END
+
+ACLOCAL="$ACLOCAL -Wnone --system-acdir=sys-acdir"
+
+: > a-regular-file
+mkdir unwritable-dir
+chmod a-w unwritable-dir
+
+$ACLOCAL -I a-regular-file --install 2>stderr \
+ && { cat stderr >&2; Exit 1; }
+cat stderr >&2
+$EGREP '(mkdir:|directory ).*a-regular-file' stderr
+test ! -f aclocal.m4
+
+$ACLOCAL --install -I unwritable-dir/sub 2>stderr \
+ && { cat stderr >&2; Exit 1; }
+cat stderr >&2
+$EGREP '(mkdir:|directory ).*unwritable-dir/sub' stderr
+test ! -f aclocal.m4
+
+$ACLOCAL -I unwritable-dir --install 2>stderr \
+ && { cat stderr >&2; Exit 1; }
+cat stderr >&2
+$EGREP '(cp:|copy ).*unwritable-dir' stderr
+test ! -f aclocal.m4
+
+# Sanity check.
+mkdir m4
+$ACLOCAL -I m4 --install && test -f aclocal.m4 \
+ || fatal_ "aclocal failed also when expected to succeed"
+
+:
diff --git a/t/aclocal-install-mkdir.sh b/t/aclocal-install-mkdir.sh
new file mode 100755
index 000000000..71d09affe
--- /dev/null
+++ b/t/aclocal-install-mkdir.sh
@@ -0,0 +1,72 @@
+#! /bin/sh
+# Copyright (C) 2012 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/>.
+
+# Check that "aclocal --install" creates the local m4 directory if
+# necessary.
+# FIXME: this is a good candidate for a conversion to TAP.
+
+am_create_testdir=empty
+. ./defs || Exit 1
+
+set -e
+
+cat > configure.ac <<END
+AC_INIT([$me], [1.0])
+MY_MACRO
+END
+
+mkdir sys-acdir
+cat > sys-acdir/my-defs.m4 <<END
+AC_DEFUN([MY_MACRO], [:])
+END
+
+ACLOCAL="$ACLOCAL --system-acdir=sys-acdir"
+
+$ACLOCAL -I foo --install
+test -f foo/my-defs.m4
+
+$ACLOCAL --install -I "`pwd`/bar"
+test -f bar/my-defs.m4
+
+$ACLOCAL --install -I baz/sub/sub2
+test -f baz/sub/sub2/my-defs.m4
+
+# What should happen:
+# * zardoz1 should be created, and required m4 files copied into there.
+# * zardoz2 shouldn't be preferred to quux, even if the former exists
+# while the latter does not.
+mkdir zardoz2
+$ACLOCAL --install -I zardoz1 -I zardoz2
+test -d zardoz1
+grep MY_MACRO zardoz1/my-defs.m4
+ls zardoz2 | grep . && Exit 1
+
+# Directories in ACLOCAL_PATH should never be created if they don't
+# exist.
+ACLOCAL_PATH="`pwd`/none:`pwd`/none2" $ACLOCAL --install && Exit 1
+test ! -d none
+test ! -d none2
+ACLOCAL_PATH="`pwd`/none:`pwd`/none2" $ACLOCAL --install -I x
+test -f x/my-defs.m4
+test ! -d none
+test ! -d none2
+
+# It's better if aclocal doesn't create the first include dir on failure.
+$ACLOCAL --install -I none -I none2 && Exit 1
+test ! -d none
+test ! -d none2
+
+:
diff --git a/t/aclocal-no-install-no-mkdir.sh b/t/aclocal-no-install-no-mkdir.sh
new file mode 100755
index 000000000..728e70a05
--- /dev/null
+++ b/t/aclocal-no-install-no-mkdir.sh
@@ -0,0 +1,39 @@
+#! /bin/sh
+# Copyright (C) 2012 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/>.
+
+# Check that aclocal does not create a non-existent local m4 directory
+# if the '--install' option is not given.
+
+am_create_testdir=empty
+. ./defs || Exit 1
+
+set -e
+
+cat > configure.ac <<END
+AC_INIT([$me], [1.0])
+MY_MACRO
+END
+
+mkdir sys-acdir
+cat > sys-acdir/my-defs.m4 <<END
+AC_DEFUN([MY_MACRO], [:])
+END
+
+$ACLOCAL -I foo --system-acdir=sys-acdir && Exit 1
+test ! -d foo
+test ! -r foo
+
+:
diff --git a/t/aclocal-path-install-serial.sh b/t/aclocal-path-install-serial.sh
new file mode 100755
index 000000000..8a2b22c59
--- /dev/null
+++ b/t/aclocal-path-install-serial.sh
@@ -0,0 +1,86 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# ACLOCAL_PATH, acdir and '--install' interactions when serial number
+# are involved.
+
+am_create_testdir=empty
+. ./defs || Exit 1
+
+cat > configure.ac << 'END'
+AC_INIT
+AM_FOO
+END
+
+set_serial ()
+{
+ serial=$1 file=$2
+ sed '/^# serial/d' $file > t
+ case $serial in
+ none) mv -f t $file;;
+ *) (echo "# serial $serial" && cat t) > $file; rm -f t;;
+ esac
+ cat $file # For debugging.
+}
+
+win ()
+{
+ case $1 in
+ sdir) ok=sdir ko=pdir;;
+ pdir) ok=pdir ko=sdir;;
+ *) fatal_ "win(): invalid argument '$1'";;
+ esac
+ # This is required on fast machine, to avoid caching and timestamp
+ # issues with the autotools (already happened in practice).
+ rm -rf configure aclocal.m4 autom4te*.cache m4/*
+ $ACLOCAL -I m4 --install
+ test -f m4/foo.m4 # Sanity check.
+ $AUTOCONF
+ $FGREP "::$ok:" m4/foo.m4
+ $FGREP "::$ok::" configure
+ $FGREP "::$ko::" m4/foo.m4 configure && Exit 1
+ :
+}
+
+mkdir sdir pdir m4
+
+ACLOCAL="$ACLOCAL --system-acdir=`pwd`/sdir"
+ACLOCAL_PATH=./pdir; export ACLOCAL_PATH
+
+cat > sdir/foo.m4 << 'END'
+AC_DEFUN([AM_FOO], [::sdir::])
+END
+cat > pdir/foo.m4 << 'END'
+AC_DEFUN([AM_FOO], [::pdir::])
+END
+
+set_serial 2 sdir/foo.m4
+set_serial 1 pdir/foo.m4
+win sdir
+
+set_serial 3.3 sdir/foo.m4
+set_serial 5.7 pdir/foo.m4
+win pdir
+
+set_serial 0 sdir/foo.m4
+set_serial none pdir/foo.m4
+win sdir
+
+set_serial none sdir/foo.m4
+set_serial 1.2.3 pdir/foo.m4
+win pdir
+
+:
diff --git a/t/aclocal-path-install.sh b/t/aclocal-path-install.sh
new file mode 100755
index 000000000..a9a8b97c6
--- /dev/null
+++ b/t/aclocal-path-install.sh
@@ -0,0 +1,53 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# ACLOCAL_PATH and '--install' interactions.
+
+am_create_testdir=empty
+. ./defs || Exit 1
+
+cat > configure.ac << 'END'
+AC_INIT
+AM_FOO
+END
+
+mkdir acdir pdir ldir
+
+ACLOCAL="$ACLOCAL --system-acdir=`pwd`/acdir"
+ACLOCAL_PATH=./pdir; export ACLOCAL_PATH
+
+cat > acdir/foo.m4 << 'END'
+AC_DEFUN([AM_FOO], [:])
+END
+
+cat > pdir/bar.m4 << 'END'
+AC_DEFUN([AM_BAR], [:])
+END
+
+# The '--install' option should never cause anything to be installed
+# in a directory specified in ACLOCAL_PATH.
+$ACLOCAL --install 2>stderr && { cat stderr >&2; Exit 1; }
+cat stderr >&2
+grep ' no -I was supplied' stderr
+test ! -f pdir/foo.m4
+
+# The '--install' option should cause a required macro found in a
+# directory specified in ACLOCAL_PATH to be installed locally.
+echo AM_BAR >> configure.ac
+$ACLOCAL --install -I ldir
+diff pdir/bar.m4 ldir/bar.m4
+
+:
diff --git a/t/aclocal-path-nonexistent.sh b/t/aclocal-path-nonexistent.sh
new file mode 100755
index 000000000..8c42ddc65
--- /dev/null
+++ b/t/aclocal-path-nonexistent.sh
@@ -0,0 +1,34 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Non-existent directories in ACLOCAL_PATH are ok.
+
+am_create_testdir=empty
+. ./defs || Exit 1
+
+cat > configure.ac << 'END'
+AC_INIT
+AM_FOO
+END
+
+mkdir mdir
+echo 'AC_DEFUN([AM_FOO], [am--foo])' > mdir/foo.m4
+
+ACLOCAL_PATH=./nonesuch:./mdir:`pwd`/nonesuch2:nonesuch3 $ACLOCAL
+$AUTOCONF
+$FGREP 'am--foo' configure
+
+:
diff --git a/t/aclocal-path-precedence.sh b/t/aclocal-path-precedence.sh
new file mode 100755
index 000000000..91d9a424c
--- /dev/null
+++ b/t/aclocal-path-precedence.sh
@@ -0,0 +1,91 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check precedence rules for ACLOCAL_PATH.
+
+am_create_testdir=empty
+. ./defs || Exit 1
+
+cat > configure.ac << 'END'
+AC_INIT([foo], [1.0])
+AM_INIT_AUTOMAKE([parallel-tests])
+FOO_MACRO
+BAR_MACRO
+AC_PROG_LIBTOOL
+AM_GNU_GETTEXT
+END
+
+mkdir mdir1 mdir2 mdir3 sysdir extradir
+
+cat > mdir1/foo1.m4 << 'END'
+AC_DEFUN([FOO_MACRO], [::pass-foo::])
+END
+
+cat > mdir2/foo2.m4 << 'END'
+AC_DEFUN([FOO_MACRO], [::fail-foo::])
+END
+
+cat > mdir1/baz.m4 << 'END'
+AC_DEFUN([BAR_MACRO], [::fail-bar::])
+END
+
+cat > mdir3/bar.m4 << 'END'
+AC_DEFUN([BAR_MACRO], [::pass-bar::])
+END
+
+cat > mdir2/quux.m4 << 'END'
+AC_DEFUN([AM_INIT_AUTOMAKE], [::fail-init::])
+AC_DEFUN([AC_PROG_LIBTOOL], [::pass-libtool::])
+AC_DEFUN([AM_GNU_GETTEXT], [::pass-gettext::])
+END
+
+cat > sysdir/libtool.m4 << 'END'
+AC_DEFUN([AC_PROG_LIBTOOL], [::fail-libtool::])
+END
+
+cat > extradir/gettext.m4 << 'END'
+AC_DEFUN([AM_GNU_GETTEXT], [::fail-gettext::])
+END
+
+echo ./extradir > sysdir/dirlist
+
+ACLOCAL_PATH=mdir1:mdir2 $ACLOCAL -I mdir3 --system-acdir sysdir
+$AUTOCONF
+
+$FGREP '::' configure # For debugging.
+
+# Directories coming first in ACLOCAL_PATH should take precedence
+# over those coming later.
+$FGREP '::pass-foo::' configure
+
+# Directories from '-I' options should take precedence over directories
+# in ACLOCAL_PATH.
+$FGREP '::pass-bar::' configure
+
+# Directories in ACLOCAL_PATH should take precedence over system acdir
+# (typically '${prefix}/share/aclocal'), and any directory added through
+# the 'dirlist' special file.
+$FGREP '::pass-gettext::' configure
+$FGREP '::pass-libtool::' configure
+
+# Directories in ACLOCAL_PATH shouldn't take precedence over the internal
+# automake acdir (typically '${prefix}/share/aclocal-${APIVERSION}').
+$FGREP 'am__api_version' configure
+
+# A final sanity check.
+$FGREP '::fail' configure && Exit 1
+
+:
diff --git a/t/aclocal-path.sh b/t/aclocal-path.sh
new file mode 100755
index 000000000..d1279f021
--- /dev/null
+++ b/t/aclocal-path.sh
@@ -0,0 +1,56 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check basic ACLOCAL_PATH support.
+
+am_create_testdir=empty
+. ./defs || Exit 1
+
+cat > configure.ac << 'END'
+AC_INIT
+AM_FOO_MACRO
+AM_BAR_MACRO
+AM_BAZ_MACRO
+END
+
+mkdir mdir1 mdir2 mdir3
+
+cat > mdir1/foo.m4 << 'END'
+AC_DEFUN([AM_FOO_MACRO], [am--foo])
+END
+
+cat > mdir2/bar.m4 << 'END'
+AC_DEFUN([AM_BAR_MACRO], [am--bar])
+END
+
+cat > mdir3/baz.m4 << 'END'
+AC_DEFUN([AM_BAZ_MACRO], [am--baz])
+END
+
+ACLOCAL_PATH=mdir1:./mdir2:`pwd`/mdir3 $ACLOCAL
+$AUTOCONF
+
+# there should be no m4_include in aclocal.m4, even though ACLOCAL_PATH
+# contains 'mdir1' and './mdir2' as relative directories. Only -I
+# directories should be subject to file inclusion.
+$FGREP m4_include aclocal.m4 && Exit 1
+
+$EGREP 'AM_(FOO|BAR|BAZ)_MACRO' configure && Exit 1
+$FGREP 'am--foo' configure
+$FGREP 'am--bar' configure
+$FGREP 'am--baz' configure
+
+:
diff --git a/t/aclocal-print-acdir.sh b/t/aclocal-print-acdir.sh
new file mode 100755
index 000000000..3d8bf4e7d
--- /dev/null
+++ b/t/aclocal-print-acdir.sh
@@ -0,0 +1,34 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Test on aclocal's '--print-ac-dir' option.
+
+am_create_testdir=empty
+. ./defs || Exit 1
+
+$ACLOCAL --print-ac-dir
+test "`$ACLOCAL --print-ac-dir`" = "$am_system_acdir"
+
+$ACLOCAL -Wno-obsolete --acdir foo --print-ac-dir
+test "`$ACLOCAL -Wno-obsolete --acdir foo --print-ac-dir`" = foo
+
+$ACLOCAL --system-acdir /bar --print-ac-dir
+test "`$ACLOCAL --system-acdir /bar --print-ac-dir`" = /bar
+
+$ACLOCAL --automake-acdir /bar --print-ac-dir
+test "`$ACLOCAL --automake-acdir /bar --print-ac-dir`" = "$am_system_acdir"
+
+:
diff --git a/t/aclocal-verbose-install.sh b/t/aclocal-verbose-install.sh
new file mode 100755
index 000000000..d854719c8
--- /dev/null
+++ b/t/aclocal-verbose-install.sh
@@ -0,0 +1,54 @@
+#! /bin/sh
+# Copyright (C) 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/>.
+
+# Check verbose messages by `aclocal --install'.
+
+am_create_testdir=empty
+. ./defs || Exit 1
+
+set -e
+
+cat > configure.ac <<END
+AC_INIT([$me], [1.0])
+MY_MACRO_BAR
+MY_MACRO_QUUX
+END
+
+mkdir sys-acdir
+cat > sys-acdir/bar.m4 <<END
+AC_DEFUN([MY_MACRO_BAR], [:])
+END
+cat > sys-acdir/quux.m4 <<END
+AC_DEFUN([MY_MACRO_QUUX], [:])
+END
+
+mkdir foodir
+: > foodir/bar.m4
+
+$ACLOCAL --system-acdir=sys-acdir --install --verbose -I foodir 2>stderr \
+ || { cat stderr >&2; Exit 1; }
+cat stderr >&2
+grep ' installing .*sys-acdir/bar\.m4.* to .*foodir/bar\.m4' stderr
+grep ' installing .*sys-acdir/quux\.m4.* to .*foodir/quux\.m4' stderr
+grep ' overwriting .*foodir/bar\.m4.* with .*sys-acdir/bar\.m4' stderr
+grep ' installing .*foodir/quux\.m4.* from .*sys-acdir/quux\.m4' stderr
+
+# Sanity checks.
+ls -l foodir
+grep MY_MACRO_BAR foodir/bar.m4
+grep MY_MACRO_QUUX foodir/quux.m4
+
+:
diff --git a/t/aclocal.sh b/t/aclocal.sh
new file mode 100755
index 000000000..4030b1372
--- /dev/null
+++ b/t/aclocal.sh
@@ -0,0 +1,44 @@
+#! /bin/sh
+# Copyright (C) 1998-2012 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/>.
+
+# Test on some aclocal options. Report from Alexandre Oliva.
+
+am_create_testdir=empty
+. ./defs || Exit 1
+
+echo "AC_INIT([$me], [0]) AM_INIT_AUTOMAKE" > configure.ac
+
+$ACLOCAL --output=fred
+test -f fred
+
+$ACLOCAL --output 2>stderr && { cat stderr >&2; Exit 1; }
+cat stderr >&2
+grep 'option.*--output.*requires an argument' stderr
+grep '[Tt]ry.*--help.*for more information' stderr
+
+$ACLOCAL --unknown-option 2>stderr && { cat stderr >&2; Exit 1; }
+cat stderr >&2
+grep 'unrecognized option.*--unknown-option' stderr
+grep '[Tt]ry.*--help.*for more information' stderr
+
+$ACLOCAL --ver 2>stderr && { cat stderr >&2; Exit 1; }
+cat stderr >&2
+grep 'unrecognized option.*--ver' stderr
+grep '[Tt]ry.*--help.*for more information' stderr
+
+$ACLOCAL --versi
+
+:
diff --git a/t/aclocal3.sh b/t/aclocal3.sh
new file mode 100755
index 000000000..b2d2ab967
--- /dev/null
+++ b/t/aclocal3.sh
@@ -0,0 +1,41 @@
+#! /bin/sh
+# Copyright (C) 1998-2012 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/>.
+
+# Test to make sure include of include detects missing macros
+
+am_create_testdir=empty
+. ./defs || Exit 1
+
+cat >> configure.ac <<END
+AC_INIT([$me], [1.0])
+GNOME_X_CHECKS
+END
+
+mkdir macros
+
+cat > macros/gnome.m4 << 'END'
+AC_DEFUN([GNOME_X_CHECKS], [
+# Use a macro that cannot be installed in a third-party system-wide m4
+# file; otherwise, this test might fail under "make installcheck".
+ AM__PATH__GTK(0.99.5,,AC_MSG_ERROR(GTK not installed, or gtk-config not in path))
+])
+END
+
+$ACLOCAL -I macros 2>stderr && { cat stderr >&2; Exit 1; }
+cat stderr
+grep '^macros/gnome\.m4:4:.*AM__PATH__GTK.*not found' stderr
+
+:
diff --git a/t/aclocal4.sh b/t/aclocal4.sh
new file mode 100755
index 000000000..bc80f64cd
--- /dev/null
+++ b/t/aclocal4.sh
@@ -0,0 +1,75 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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 dependencies on aclocal.m4 are set correctly.
+# Report from Jim Meyering.
+
+required=cc
+. ./defs || Exit 1
+
+cat >>configure.ac <<EOF
+AC_PROG_RANLIB
+AM_PROG_AR
+AC_PROG_CC
+MY_MACRO
+AC_CONFIG_FILES([lib/Makefile])
+AC_OUTPUT
+EOF
+
+mkdir m4
+cat >m4/mymacro.m4 <<EOF
+AC_DEFUN([MY_MACRO], [])
+EOF
+
+mkdir lib
+: > lib/foo.c
+: > lib/bar.c
+cat >lib/Makefile.am <<'EOF'
+noinst_LIBRARIES = liberi.a
+liberi_a_SOURCES = bar.c
+liberi_a_LIBADD = $(LIBOBJS)
+EOF
+
+cat >Makefile.am <<'EOF'
+SUBDIRS = lib
+EXTRA_DIST = m4/mymacro.m4
+ACLOCAL_AMFLAGS = -I m4
+check-foo: distdir
+ test -f $(distdir)/lib/foo.c
+ test -f $(distdir)/lib/bar.c
+
+check-not-foo: distdir
+ test ! -f $(distdir)/lib/foo.c
+ test -f $(distdir)/lib/bar.c
+EOF
+
+$ACLOCAL -I m4
+$AUTOCONF
+$AUTOMAKE --add-missing
+./configure
+$MAKE check-not-foo
+
+# Update one of the macros. This should cause ./configure, Makefile.in,
+# Makefile, lib/Makefile.in, and lib/Makefile to be updated.
+
+cat >m4/mymacro.m4 <<'EOF'
+AC_DEFUN([MY_MACRO], [AC_LIBOBJ([foo])])
+EOF
+
+using_gmake || $MAKE
+$MAKE check-foo
+
+:
diff --git a/t/aclocal5.sh b/t/aclocal5.sh
new file mode 100755
index 000000000..23a7e5e55
--- /dev/null
+++ b/t/aclocal5.sh
@@ -0,0 +1,69 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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/>.
+
+# Test to make sure that aclocal.m4's dependencies are honored in
+# sub-directories. See also related tests 'remake-subdir*.test'.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AM_TEST([GREPME])
+AC_CONFIG_FILES([sub/Makefile])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+SUBDIRS = sub
+ACLOCAL_AMFLAGS = -I m4
+END
+
+mkdir sub
+: > sub/Makefile.am
+
+mkdir m4
+echo 'AC_DEFUN([AM_TEST], [echo $@])' > m4/moredefs.m4
+
+$ACLOCAL -I m4
+$AUTOCONF
+$AUTOMAKE --copy --add-missing
+./configure
+$MAKE
+
+# Update an aclocal.m4 dependency, then make sure all Makefiles are
+# updated, even from a sub-directory. Check that AU_ALIAS is
+# recognized. Change the definition of AM_TEST to check that its new
+# definition is used.
+$sleep # Modified configure dependencies must be newer than config.status.
+echo 'AU_ALIAS([AM_TEST], [AC_SUBST])' > m4/moredefs.m4
+cd sub
+$MAKE
+cd ..
+grep GREPME Makefile
+grep GREPME sub/Makefile
+
+# Make sure configure dependencies are distributed.
+$MAKE distdir
+test -f $me-1.0/m4/moredefs.m4
+
+# Change the definition of AM_TEST to check that its new definition is
+# used. Check that AC_DEFUN_ONCE is caught.
+$sleep # Modified configure dependencies must be newer than config.status.
+echo 'AC_DEFUN_ONCE([AM_TEST], [AC_SUBST(__$1__)])' > m4/moredefs.m4
+$MAKE
+grep 'm4/moredefs\.m4' aclocal.m4
+grep '__GREPME__' configure
+
+:
diff --git a/t/aclocal6.sh b/t/aclocal6.sh
new file mode 100755
index 000000000..8923851cd
--- /dev/null
+++ b/t/aclocal6.sh
@@ -0,0 +1,74 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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 aclocal.m4 is rebuilt whenever a configure
+# dependency changes. Test for acinclude.m4 and VPATH too.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+SOME_DEFS
+AC_CONFIG_FILES([sub/Makefile])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+SUBDIRS = sub
+ACLOCAL_AMFLAGS = -I m4
+END
+
+mkdir sub
+: > sub/Makefile.am
+
+mkdir m4
+echo 'AC_DEFUN([SOME_DEFS], [])' > m4/somedefs.m4
+echo 'AC_DEFUN([MORE_DEFS], [AC_SUBST([GREPME])])' > m4/moredefs.m4
+
+$ACLOCAL -I m4
+$AUTOCONF
+$AUTOMAKE --copy --add-missing
+
+mkdir build
+cd build
+
+../configure
+$MAKE
+
+# Modified configure dependencies must be newer than config.status.
+$sleep
+# Update an aclocal.m4 dependency, then make sure all Makefiles
+# are updated, even from a sub-directory.
+echo 'AC_DEFUN([SOME_DEFS], [MORE_DEFS])' > ../m4/somedefs.m4
+# Because aclocal will run again, it should also pick up acinclude.m4.
+echo 'AC_SUBST([METOO])' > ../acinclude.m4
+
+cd sub
+$MAKE
+cd ..
+grep GREPME Makefile
+grep GREPME sub/Makefile
+grep GREPME sub/Makefile
+grep METOO Makefile
+grep METOO sub/Makefile
+grep METOO sub/Makefile
+
+# Make sure configure dependencies are distributed.
+$MAKE distdir
+test -f $me-1.0/m4/moredefs.m4
+test -f $me-1.0/m4/somedefs.m4
+test -f $me-1.0/acinclude.m4
+
+:
diff --git a/t/aclocal7.sh b/t/aclocal7.sh
new file mode 100755
index 000000000..548d89017
--- /dev/null
+++ b/t/aclocal7.sh
@@ -0,0 +1,116 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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 aclocal does not overwrite aclocal.m4 needlessly.
+# Also make sure automake --no-force does not overwrite Makefile.in needlessly.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+SOME_DEFS
+AC_CONFIG_FILES([sub/Makefile])
+END
+
+mkdir sub
+: > sub/Makefile.am
+
+cat >> Makefile.am << 'END'
+SUBDIRS = sub
+include fragment.inc
+END
+
+: > fragment.inc
+
+mkdir m4
+echo 'AC_DEFUN([SOME_DEFS], [])' > m4/somedefs.m4
+
+$sleep
+
+$ACLOCAL -I m4
+
+# Automake will take aclocal.m4 to be newer if it has the same timestamp
+# as Makefile.in. Avoid the confusing by sleeping.
+$sleep
+
+$AUTOMAKE --no-force
+
+$sleep
+
+touch foo
+$ACLOCAL -I m4
+$AUTOMAKE --no-force
+
+# aclocal.m4 and Makefile.in should not have been updated, so 'foo'
+# should be younger
+test `ls -1t aclocal.m4 Makefile.in sub/Makefile.in foo | sed 1q` = foo
+
+$sleep
+$ACLOCAL -I m4 --force
+test `ls -1t aclocal.m4 foo | sed 1q` = aclocal.m4
+# We still use --no-force for automake, but since aclocal.m4 has
+# changed all Makefile.ins should be updated.
+$sleep
+$AUTOMAKE --no-force
+test `ls -1t Makefile.in foo | sed 1q` = Makefile.in
+test `ls -1t sub/Makefile.in foo | sed 1q` = sub/Makefile.in
+
+touch m4/somedefs.m4
+$sleep
+touch foo
+$sleep
+$ACLOCAL -I m4
+$sleep
+$AUTOMAKE --no-force
+
+# aclocal.m4 should have been updated, although its contents haven't changed.
+test `ls -1t aclocal.m4 foo | sed 1q` = aclocal.m4
+test `ls -1t Makefile.in foo | sed 1q` = Makefile.in
+test `ls -1t sub/Makefile.in foo | sed 1q` = sub/Makefile.in
+
+touch fragment.inc
+$sleep
+touch foo
+$sleep
+$ACLOCAL -I m4
+$AUTOMAKE --no-force
+# Only ./Makefile.in should change.
+test `ls -1t aclocal.m4 foo | sed 1q` = foo
+test `ls -1t Makefile.in foo | sed 1q` = Makefile.in
+test `ls -1t sub/Makefile.in foo | sed 1q` = foo
+
+grep README Makefile.in && Exit 1
+
+: > README
+$sleep
+touch foo
+$sleep
+$AUTOMAKE --no-force
+# Even if no dependency change, the content changed.
+test `ls -1t Makefile.in foo | sed 1q` = Makefile.in
+test `ls -1t sub/Makefile.in foo | sed 1q` = foo
+
+grep README Makefile.in
+
+: > sub/Makefile.in
+$sleep
+touch foo
+$sleep
+$ACLOCAL -I m4
+$AUTOMAKE --no-force
+# Only sub/Makefile.in should change.
+test `ls -1t aclocal.m4 foo | sed 1q` = foo
+test `ls -1t Makefile.in foo | sed 1q` = foo
+test `ls -1t sub/Makefile.in foo | sed 1q` = sub/Makefile.in
diff --git a/t/aclocal8.sh b/t/aclocal8.sh
new file mode 100755
index 000000000..8df0835bc
--- /dev/null
+++ b/t/aclocal8.sh
@@ -0,0 +1,42 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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 aclocal does not require unused macros.
+
+am_create_testdir=empty
+. ./defs || Exit 1
+
+cat > configure.ac << 'END'
+AC_INIT
+SOME_DEFS
+END
+
+mkdir m4
+cat >m4/somedefs.m4 <<EOF
+AC_DEFUN([SOME_DEFS], [
+ m4_if([a], [a], [MACRO1], [MACRO2])
+])
+EOF
+
+echo 'AC_DEFUN([MACRO1],)' >m4/macro1.m4
+echo 'AC_DEFUN([MACRO2], [AC_REQUIRE([AM_UNUSED_MACRO])])' >m4/macro2.m4
+
+$ACLOCAL -I m4 >output 2>&1 || { cat output; Exit 1; }
+test 0 = `wc -l <output`
+grep macro1.m4 aclocal.m4
+grep macro2.m4 aclocal.m4 && Exit 1
+
+:
diff --git a/t/aclocal9.sh b/t/aclocal9.sh
new file mode 100755
index 000000000..c7ce7514e
--- /dev/null
+++ b/t/aclocal9.sh
@@ -0,0 +1,49 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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 aclocal define macros in the same order as -I's.
+
+am_create_testdir=empty
+. ./defs || Exit 1
+
+cat > configure.ac << 'END'
+AC_INIT
+MACRO1
+MACRO2
+END
+
+mkdir m4_1 m4_2
+
+cat >m4_1/somedefs.m4 <<EOF
+AC_DEFUN([MACRO1], [:macro11:])
+AC_DEFUN([MACRO2], [:macro21:])
+EOF
+
+cat >m4_2/somedefs.m4 <<EOF
+AC_DEFUN([MACRO1], [:macro12:])
+EOF
+
+$ACLOCAL -I m4_1 -I m4_2
+$AUTOCONF
+$FGREP ':macro11:' configure
+$FGREP ':macro21:' configure
+
+$ACLOCAL --force -I m4_2 -I m4_1
+$AUTOCONF --force
+$FGREP ':macro12:' configure
+$FGREP ':macro21:' configure
+
+:
diff --git a/t/acsilent.sh b/t/acsilent.sh
new file mode 100755
index 000000000..0f9c1cbb0
--- /dev/null
+++ b/t/acsilent.sh
@@ -0,0 +1,37 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test to make sure there are no spurious acinclude warnings.
+
+. ./defs || Exit 1
+
+cat >configure.ac <<EOF
+AC_INIT
+AM_INIT_GUILE_MODULE
+EOF
+
+cat > acinclude.m4 << 'END'
+AC_DEFUN([AM_INIT_GUILE_MODULE],[
+. $srcdir/../GUILE-VERSION
+AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
+AC_CONFIG_AUX_DIR(..)
+module=[$1]
+AC_SUBST(module)])
+END
+
+$ACLOCAL >output 2>&1 || { cat output; Exit 1; }
+cat output
+test ! -s output
diff --git a/t/acsubst.sh b/t/acsubst.sh
new file mode 100755
index 000000000..9390944c3
--- /dev/null
+++ b/t/acsubst.sh
@@ -0,0 +1,31 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_SUBST([FOOBAR_LDFLAGS],[blablabla])
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = mumble
+mumble_SOURCES = a.c b.c d.h
+mumble_LDFLAGS = $(FOOBAR_LDFLAGS)
+END
+
+$ACLOCAL
+$AUTOMAKE -a
diff --git a/t/acsubst2.sh b/t/acsubst2.sh
new file mode 100755
index 000000000..e8c866359
--- /dev/null
+++ b/t/acsubst2.sh
@@ -0,0 +1,32 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_SUBST([FOOBAR_CFLAGS],[blablabla])
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = mumble
+mumble_SOURCES = a.c b.c d.h
+mumble_CFLAGS = $(FOOBAR_CFLAGS)
+END
+
+$ACLOCAL
+$AUTOMAKE -a
diff --git a/t/add-missing.tap b/t/add-missing.tap
new file mode 100755
index 000000000..39b7ae7f6
--- /dev/null
+++ b/t/add-missing.tap
@@ -0,0 +1,391 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Test that automake complains when required auxiliary files are not
+# found, and that 'automake --add-missing' installs the files (and only
+# the files) it's supposed to, and that these files are symlinked by
+# default, but copied if the '--copy' option is used.
+
+am_create_testdir=empty
+. ./defs || Exit 1
+
+plan_ "later"
+
+build_aux=build-aux
+ocwd=`pwd` || fatal_ "cannot get current working directory"
+
+# Try to improve readability of displayed diffs.
+if diff -u /dev/null /dev/null; then
+ am_diff='diff -u'
+elif diff -c /dev/null /dev/null; then
+ am_diff='diff -c'
+else
+ am_diff=diff
+fi
+
+# MinGW/MSYS lacks real symlinks, so we'll have to skip some checks
+# on that system. More details below.
+echo dummy > foo
+if ln -s foo bar && test -h bar; then
+ have_true_symlinks=yes
+else
+ have_true_symlinks=no
+fi
+rm -f foo bar
+
+cat > configure.stub << END
+AC_INIT([$me], [1.0])
+AC_CONFIG_AUX_DIR([$build_aux])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([Makefile])
+END
+
+# Pre-compute aclocal.m4, in order to save several aclocal invocations.
+cat configure.stub - > configure.ac <<'END'
+AC_PROG_CC
+AC_CANONICAL_BUILD
+AC_CANONICAL_HOST
+AC_CANONICAL_TARGET
+AC_CANONICAL_SYSTEM
+AM_PATH_LISPDIR
+AM_PATH_PYTHON
+END
+$ACLOCAL || framework_failure_ "cannot pre-compute aclocal.m4"
+
+rm -rf configure.ac autom4te*.cache
+mv aclocal.m4 aclocal.stub
+
+# For debugging.
+cat configure.stub
+cat aclocal.stub
+
+check_count=0
+
+# This is hacky and ugly and complex, but allow us to organize our tests
+# below in a more "declarative fashion". All in all, a good trade-off.
+check_ ()
+{
+ set +x # Temporary disable shell traces to remove noise from log files.
+ incr_ check_count
+ echo check count: $check_count
+ override=no
+ run_aclocal=no
+ fetch_file=
+ while test $# -gt 0; do
+ case $1 in
+ --override) override=yes;;
+ --run-aclocal) run_aclocal=yes;;
+ --fetch-file) fetch_file=$2; shift;;
+ *) framework_failure_ "check_: invalid argument '$1'";;
+ esac
+ shift
+ done
+ mkdir testdir-$check_count
+ cd testdir-$check_count
+ # Directory for common data files (specific to the current test, but
+ # shared by its "subtests").
+ mkdir generic
+ cd generic
+ # Use 'echo > ...', not ': > ...', here and below, as Solaris 10 /bin/sh
+ # might not execute the latter (the Autoconf manual gives more details).
+ echo > Makefile.am
+ if test $override = yes; then
+ echo > configure.ac
+ else
+ cp "$ocwd"/configure.stub configure.ac
+ fi
+ test -z "$fetch_file" || cp "$ocwd/$fetch_file" .
+ # Read description of "test scenario" from standard input.
+ what= line= name= files=
+ while read line; do
+ case $line in
+ '== Name ==') what=NAME;;
+ '== Makefile.am ==') what=Makefile.am;;
+ '== configure.ac ==') what=configure.ac;;
+ '== Files ==') what=LIST;;
+ '==*') framework_failure_ "invalid input line: $line";;
+ ''|'#%'*) : Empty line or ad-hoc comment, ignore. ;;
+ *)
+ if test $what = LIST; then
+ files="$files $line"
+ elif test $what = NAME; then
+ name=$line
+ else
+ printf '%s\n' "$line" >> "$what"
+ fi
+ ;;
+ esac
+ done
+ test -n "$name" || fatal_ "name of a test case not specified"
+ if test $run_aclocal = yes; then
+ if $ACLOCAL; then
+ ok_ "[$name] aclocal.m4 rebuilt"
+ echo == aclocal.m4 ==
+ cat aclocal.m4
+ else
+ not_ok_ "[$name] aclocal failure, aclocal.m4 not rebuilt"
+ fi
+ else
+ cp "$ocwd"/aclocal.stub aclocal.m4
+ fi
+ echo == Makefile.am ==
+ cat Makefile.am
+ echo == configure.ac ==
+ cat configure.ac
+ echo Expected files: $files
+ mkdir "$build_aux"
+ cd ..
+ # End of "test scenario" setup.
+ set -x # Re-enable shell traces.
+ pwd
+ ls -l generic
+ # Test once with '--copy', once without.
+ for action in link copy; do
+ case $action in
+ link) opts='--add-missing';;
+ copy) opts='-a --copy';;
+ *) fatal_ "invalid value '$action' for \$action";;
+ esac
+ pfx="[$action $name]"
+ cp -R generic $action
+ cd $action
+ # If the required auxiliary files are missing, and automake is
+ # not told to install them, it should complain and error out,
+ # and also give a useful suggestion.
+ AUTOMAKE_fails -d "$pfx missing files, automake fails"
+ for f in $files; do
+ command_ok_ \
+ "$pfx warn about missing file $f" \
+ grep "required file ['\`]$build_aux/$f' not found" stderr
+ # Suggest the user to use '--add-missing'.
+ command_ok_ \
+ "$pfx suggest --add-missing for $f" \
+ grep ".*--add-missing.* install .*$f" stderr
+ done
+ # No files should be automatically installed by automake if it
+ # is not told to.
+ if ls "$build_aux" | grep .; then r='not ok'; else r=ok; fi
+ result_ "$r" "$pfx no extra files installed"
+ AUTOMAKE_run -d "$pfx automake run successfully" -- $opts
+ ls -l . $build_aux
+ # The expected files should get installed correctly (e.g., no
+ # broken symlinks).
+ for f in $files; do
+ command_ok_ \
+ "$pfx file $f installed" \
+ test -f $build_aux/$f
+ done
+ # Automake should inform about which files it's installing.
+ for f in $files; do
+ command_ok_ \
+ "$pfx report installation of $f" \
+ grep ": installing ['\`]$build_aux/$f'$" stderr
+ done
+ # Only the expected files should be installed. But automake always
+ # require 'missing' and 'install-sh', so account for them.
+ all_files="install-sh missing $files"
+ for f in $all_files; do echo $f; done | sort | uniq > files.exp
+ (cd $build_aux && ls) | sort > files.got
+ cat files.exp
+ cat files.got
+ command_ok_ \
+ "$pfx all and only expected files installed" \
+ $am_diff files.exp files.got
+ # The files should be copied by '--copy' and symlinked otherwise.
+ # But these checks make no sense on systems like MSYS/MinGW where
+ # there are no true symlinks ('ln -s' behaves like 'cp -p'), so be
+ # ready to skip the checks in that case. See automake bug#10441.
+ for f in $files; do
+ if test $have_true_symlinks = no; then
+ skip_ -r "system lacks true symlinks" "$pfx $f is a symlink or not"
+ else
+ if test -h $build_aux/$f; then
+ is_symlink=yes
+ else
+ is_symlink=no
+ fi
+ case $action,$is_symlink in
+ link,yes) ok_ "$pfx $f has been symlinked" ;;
+ link,no) not_ok_ "$pfx $f has not been symlinked" ;;
+ copy,yes) not_ok_ "$pfx $f has been symlinked" ;;
+ copy,no) ok_ "$pfx $f has not been symlinked" ;;
+ *) fatal_ "invalid condition in case" ;;
+ esac
+ fi
+ done
+ # Now that the required auxiliary files have been installed, automake
+ # should not complain anymore even if the '--add-missing' option is
+ # not used.
+ AUTOMAKE_run -d "$pfx automake finds all added files"
+ cd ..
+ done # for action in link copy
+ cd "$ocwd" || fatal_ "cannot chdir back to top-level test directory"
+}
+
+# Automake should always and unconditionally require the 'missing'
+# and 'install-sh' scripts.
+check_ <<'END'
+== Name ==
+minimal
+== Files ==
+install-sh missing
+END
+
+check_ <<'END'
+== Name ==
+depcomp/C
+== Files ==
+depcomp
+== configure.ac ==
+AC_PROG_CC
+== Makefile.am ==
+bin_PROGRAMS = foo
+END
+
+check_ <<'END'
+== Name ==
+depcomp/C++
+== Files ==
+depcomp
+== configure.ac ==
+AC_PROG_CXX
+== Makefile.am ==
+bin_PROGRAMS = foo
+foo_SOURCES = foo.cc
+END
+
+check_ --run-aclocal <<'END'
+== Name ==
+compile
+== Files ==
+compile
+== configure.ac ==
+# Using AM_PROG_CC_C_O in configure.ac should be enough. No need to
+# use AC_PROG_CC too, nor to define xxx_PROGRAMS in Makefile.am.
+AM_PROG_CC_C_O
+END
+
+# For config.guess and config.sub.
+for mach in build host target system; do
+ MACH=`echo "$mach" | LC_ALL=C tr '[a-z]' '[A-Z]'`
+ check_ <<END
+== Name ==
+cfg-$mach
+== Files ==
+config.sub
+config.guess
+== configure.ac ==
+AC_CANONICAL_$MACH
+END
+done
+
+check_ <<'END'
+== Name ==
+ylwrap/Lex
+== Files ==
+ylwrap
+== configure.ac ==
+AC_PROG_CC
+AC_PROG_LEX
+== Makefile.am ==
+AUTOMAKE_OPTIONS = no-dependencies
+bin_PROGRAMS = foo
+foo_SOURCES = foo.l
+END
+
+check_ <<'END'
+== Name ==
+ylwrap/Yacc
+== Files ==
+ylwrap
+== configure.ac ==
+AC_PROG_CC
+AC_PROG_YACC
+== Makefile.am ==
+AUTOMAKE_OPTIONS = no-dependencies
+bin_PROGRAMS = foo
+foo_SOURCES = foo.y
+END
+
+echo '@setfilename foo.info' > foo.texi
+check_ --fetch-file foo.texi <<'END'
+== Name ==
+Texinfo
+== Files ==
+texinfo.tex
+== Makefile.am ==
+info_TEXINFOS = foo.texi
+END
+
+echo '@include version.texi' >> foo.texi
+check_ --fetch-file foo.texi <<'END'
+== Name ==
+Texinfo/mdate-sh
+== Files ==
+mdate-sh
+texinfo.tex
+== Makefile.am ==
+info_TEXINFOS = foo.texi
+END
+
+rm -f foo.texi
+
+check_ <<'END'
+== Name ==
+elisp-comp
+== Files ==
+elisp-comp
+== configure.ac ==
+AM_PATH_LISPDIR
+== Makefile.am ==
+lisp_LISP = foo.el
+END
+
+check_ <<'END'
+== Name ==
+py-compile
+== Files ==
+py-compile
+== configure.ac ==
+AM_PATH_PYTHON
+== Makefile.am ==
+python_PYTHON = foo.py
+END
+
+# Try few unrelated auxiliary scripts together.
+check_ <<'END'
+== Name ==
+misc
+== Files ==
+py-compile
+depcomp
+ylwrap
+config.sub
+config.guess
+== configure.ac ==
+AC_CANONICAL_BUILD
+AC_CANONICAL_HOST
+AC_PROG_CXX
+== Makefile.am ==
+PYTHON = python
+pythondir = $(prefix)/py
+YACC = bison -y
+bin_PROGRAMS = foo
+foo_SOURCES = bar.yxx baz.c++
+python_PYTHON = zardoz.py
+END
+
+:
diff --git a/t/all.sh b/t/all.sh
new file mode 100755
index 000000000..0baf9da24
--- /dev/null
+++ b/t/all.sh
@@ -0,0 +1,33 @@
+#! /bin/sh
+# Copyright (C) 1999-2012 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/>.
+
+# Test to make sure several *-local's in a single rule work.
+
+. ./defs || Exit 1
+
+targets='all install-exec install-data uninstall'
+echo "$targets:" | sed -e 's/[ :]/-local&/g' > Makefile.am
+cat Makefile.am # For debugging.
+
+$ACLOCAL
+$AUTOMAKE
+
+for target in $targets; do
+ grep "${target}-local" Makefile.in # For debugging.
+ grep "${target}-am:.*${target}-local" Makefile.in
+done
+
+:
diff --git a/t/all2.sh b/t/all2.sh
new file mode 100755
index 000000000..da22e68d5
--- /dev/null
+++ b/t/all2.sh
@@ -0,0 +1,32 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Test to make sure all-local and other -local targets work correctly.
+
+. ./defs || Exit 1
+
+$ACLOCAL
+
+targets='all install-exec install-data uninstall'
+for target in $targets; do
+ : Doing $target
+ echo "${target}-local:" > Makefile.am
+ $AUTOMAKE
+ grep "${target}-local ${target}-local" Makefile.in && Exit 1
+ grep "${target}-am:.*${target}-local" Makefile.in
+done
+
+:
diff --git a/t/alloca.sh b/t/alloca.sh
new file mode 100755
index 000000000..c87904b3d
--- /dev/null
+++ b/t/alloca.sh
@@ -0,0 +1,40 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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 we complain if @ALLOCA@ is used without being set in configure.ac
+
+. ./defs || Exit 1
+
+cat >> configure.ac <<'END'
+AM_PROG_AR
+AC_PROG_CC
+END
+
+cat > Makefile.am << 'END'
+noinst_LIBRARIES = libtu.a
+libtu_a_SOURCES =
+libtu_a_LIBADD = @ALLOCA@
+END
+
+: > alloca.c
+: > ar-lib
+
+$ACLOCAL
+AUTOMAKE_fails
+grep '^Makefile\.am:1:.*define .*RANLIB.* add .*AC_PROG_RANLIB' stderr
+grep '^Makefile\.am:3:.*define .*ALLOCA.* add .*AC_FUNC_ALLOCA' stderr
+
+:
diff --git a/t/alloca2.sh b/t/alloca2.sh
new file mode 100755
index 000000000..08fad97dd
--- /dev/null
+++ b/t/alloca2.sh
@@ -0,0 +1,40 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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 we complain if @LTALLOCA@ is used without being set in configure.ac
+
+. ./defs || Exit 1
+
+cat >> configure.ac <<'END'
+AC_PROG_CC
+AM_PROG_AR
+END
+
+cat > Makefile.am << 'END'
+noinst_LTLIBRARIES = libtu.la
+libtu_la_SOURCES =
+libtu_la_LIBADD = @LTALLOCA@
+END
+
+: > alloca.c
+: > ar-lib
+
+$ACLOCAL
+AUTOMAKE_fails
+grep '^Makefile\.am:1:.*define.*LIBTOOL.* add .*LT_INIT' stderr
+grep '^Makefile\.am:3:.*LTALLOCA' stderr
+
+:
diff --git a/t/alpha.sh b/t/alpha.sh
new file mode 100755
index 000000000..90f2cc267
--- /dev/null
+++ b/t/alpha.sh
@@ -0,0 +1,70 @@
+#! /bin/sh
+# Copyright (C) 1998-2012 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 README-alpha is distributed when appropriate. Report from
+# Jim Meyering.
+. ./defs || Exit 1
+
+cat > configure.ac << 'END'
+AC_INIT([alpha], [1.0a])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([Makefile])
+AC_CONFIG_FILES([sub/Makefile])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = gnits
+SUBDIRS = sub
+check-local: distdir
+ test -f $(distdir)/README-alpha
+ test -f $(distdir)/sub/README
+ test ! -f $(distdir)/sub/README-alpha
+ : > works
+END
+
+mkdir sub
+cat > sub/Makefile.am << 'END'
+AUTOMAKE_OPTIONS = gnits
+END
+
+: > README-alpha
+: > sub/README-alpha
+: > sub/README
+
+# Gnits stuff.
+: > INSTALL
+: > NEWS
+: > README
+: > COPYING
+: > AUTHORS
+: > ChangeLog
+: > THANKS
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+
+# "make distdir" should fail because NEWS does not mention 1.0a
+$MAKE check 2>stderr && { cat stderr >&2; Exit 1; }
+cat stderr >&2
+grep 'NEWS not updated' stderr
+test ! -f works
+
+echo 'alpha 1.0a released' > NEWS
+$MAKE check
+test -f works
diff --git a/t/alpha2.sh b/t/alpha2.sh
new file mode 100755
index 000000000..6d5207f61
--- /dev/null
+++ b/t/alpha2.sh
@@ -0,0 +1,59 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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/>.
+
+# Another check for README-alpha support. This time it is requested
+# from configure.ac. Report from Akim Demaille.
+
+. ./defs || Exit 1
+
+cat > configure.ac << 'END'
+AC_INIT([alpha], [1.0b])
+AM_INIT_AUTOMAKE([readme-alpha])
+AC_CONFIG_FILES([Makefile sub/Makefile])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+SUBDIRS = sub
+check-local: distdir
+ test -f $(distdir)/README-alpha
+ test -f $(distdir)/sub/README
+ test ! -f $(distdir)/sub/README-alpha
+ : > works
+END
+
+mkdir sub
+: > sub/Makefile.am
+
+: > README-alpha
+: > sub/README-alpha
+: > sub/README
+
+# Gnits stuff.
+: > INSTALL
+: > NEWS
+: > README
+: > COPYING
+: > AUTHORS
+: > ChangeLog
+: > THANKS
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+$MAKE check
+test -f works
diff --git a/t/am-tests-environment.sh b/t/am-tests-environment.sh
new file mode 100755
index 000000000..3a6e75532
--- /dev/null
+++ b/t/am-tests-environment.sh
@@ -0,0 +1,91 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# parallel-tests: check AM_TESTS_ENVIRONMENT support, and its
+# interactions with TESTS_ENVIRONMENT.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_MKDIR_P
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TEST_EXTENSIONS = .sh .test
+TESTS = foo.test bar.sh
+SH_LOG_COMPILER = sh
+AM_TESTS_ENVIRONMENT = \
+ $(MKDIR_P) quux.dir; \
+ if test -f $(srcdir)/test-env.sh; then \
+ . $(srcdir)/test-env.sh; \
+ fi; \
+ FOO=1; export FOO;
+EXTRA_DIST = $(TESTS) test-env.sh
+END
+
+cat > foo.test << 'END'
+#! /bin/sh
+ls -l && test -d quux.dir
+END
+chmod a+x foo.test
+
+cat > bar.sh << 'END'
+echo "FOO='$FOO'"
+echo "BAR='$BAR'"
+test x"$FOO" = x"$BAR"
+END
+
+debug_info ()
+{
+ cat test-suite.log
+ cat foo.log
+ cat bar.log
+}
+
+minicheck ()
+{
+ debug_info
+ test -d quux.dir
+}
+
+miniclean ()
+{
+ rmdir quux.dir
+ rm -f foo.log bar.log test-suite.log
+}
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+TESTS_ENVIRONMENT='BAR=1' $MAKE check || { debug_info; Exit 1; }
+minicheck
+miniclean
+
+TESTS_ENVIRONMENT='BAR=2' $MAKE check && { debug_info; Exit 1; }
+minicheck
+miniclean
+
+echo 'BAR=1 && export BAR' > test-env.sh
+$MAKE check || { debug_info; Exit 1; }
+minicheck
+$MAKE distcheck
+
+:
diff --git a/t/amassign.sh b/t/amassign.sh
new file mode 100755
index 000000000..1649dd080
--- /dev/null
+++ b/t/amassign.sh
@@ -0,0 +1,28 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test to see if AM_ name can be assigned to in configure.ac.
+# Report from Steve Robbins.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AM_CFLAGS=foo
+AC_SUBST(AM_BAR)
+AC_SUBST([AM_ZARDOZ])
+END
+
+$ACLOCAL
diff --git a/t/amhello-binpkg.sh b/t/amhello-binpkg.sh
new file mode 100755
index 000000000..4b3e0e21b
--- /dev/null
+++ b/t/amhello-binpkg.sh
@@ -0,0 +1,51 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Test an example from the manual about the 'amhello' package:
+# using DESTDIR to build simple, no-frills binary packages.
+
+am_create_testdir=empty
+. ./defs || Exit 1
+
+cp "$am_docdir"/amhello-1.0.tar.gz . \
+ || fatal_ "cannot get amhello tarball"
+
+gzip -dc amhello-1.0.tar.gz | tar xf -
+cd amhello-1.0
+
+./configure --prefix /usr
+$MAKE
+$MAKE DESTDIR="`pwd`/inst" install
+cd inst
+find . -type f -print > ../files.lst
+tar cvf amhello-1.0-i686.tar.gz `cat ../files.lst` > tar.got 2>&1
+
+EXEEXT=`sed -n -e 's/^EXEEXT *= *//p' < ../Makefile`
+
+if tar --version </dev/null | grep GNU; then
+ LC_ALL=C sort tar.got > t
+ mv -f t tar.got
+ diff - tar.got <<END
+./usr/bin/hello$EXEEXT
+./usr/share/doc/amhello/README
+END
+else
+ : Be laxer with other tar implementations, to avoid spurious failures.
+ $EGREP '(^| )\./usr/bin/hello'$EXEEXT'( |$)' tar.got
+ $EGREP '(^| )\./usr/share/doc/amhello/README( |$)' tar.got
+fi
+
+:
diff --git a/t/amhello-cflags.sh b/t/amhello-cflags.sh
new file mode 100755
index 000000000..4132bc177
--- /dev/null
+++ b/t/amhello-cflags.sh
@@ -0,0 +1,50 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Test an example from the manual about the 'amhello' package:
+# using VPATH builds to configure the same package with different
+# options.
+
+am_create_testdir=empty
+required=gcc
+. ./defs || Exit 1
+
+cp "$am_docdir"/amhello-1.0.tar.gz . \
+ || fatal_ "cannot get amhello tarball"
+
+gzip -dc amhello-1.0.tar.gz | tar xf -
+cd amhello-1.0
+
+mkdir debug optim
+cd debug
+../configure CFLAGS='-g -O0'
+$MAKE
+ls -l . src # For debugging.
+cd ../optim
+../configure CFLAGS='-O3 -fomit-frame-pointer'
+$MAKE
+ls -l . src # For debugging.
+cd ..
+
+# Check that we have really compiled the objects with two different
+# configurations.
+for exeext in '' .exe :; do
+ test -f optim/src/hello$exeext && break
+ test "$exeext" = : && fatal_ "cannot determine extension of executables"
+done
+cmp optim/src/hello$exeext debug/src/hello$exeext && Exit 1
+
+:
diff --git a/t/amhello-cross-compile.sh b/t/amhello-cross-compile.sh
new file mode 100755
index 000000000..b138d87c8
--- /dev/null
+++ b/t/amhello-cross-compile.sh
@@ -0,0 +1,53 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Test an example from the manual about the 'amhello' package:
+# cross-compiling a package from Linux/Unix to MinGW.
+
+am_create_testdir=empty
+required=i586-mingw32msvc-gcc
+. ./defs || Exit 1
+
+cp "$am_docdir"/amhello-1.0.tar.gz . \
+ || fatal_ "cannot get amhello tarball"
+
+host=i586-mingw32msvc
+build=`"$am_scriptdir"/config.guess` && test -n "$build" \
+ || fatal_ "cannot guess build platform"
+case $build in *mingw*) skip_ "build system is MinGW too";; esac
+
+gzip -dc amhello-1.0.tar.gz | tar xf -
+cd amhello-1.0
+
+./configure --build "$build" --host "$host" > stdout \
+ || { cat stdout ; Exit 1; }
+cat stdout
+grep '^checking for i586-mingw32msvc-strip\.\.\.' stdout
+grep '^checking for i586-mingw32msvc-gcc\.\.\.' stdout
+grep '^checking for suffix of executables\.\.\. \.exe *$' stdout
+grep '^checking for suffix of object files\.\.\. o *$' stdout
+grep '^checking whether i586-mingw32msvc-gcc accepts -g\.\.\. yes' stdout
+
+$MAKE
+
+cd src
+file hello.exe > whatis
+cat whatis
+$EGREP 'DOS|Win' whatis
+grep 'executable' whatis
+grep 'ELF' whatis && Exit 1
+
+:
diff --git a/t/ammissing.sh b/t/ammissing.sh
new file mode 100755
index 000000000..aa281267c
--- /dev/null
+++ b/t/ammissing.sh
@@ -0,0 +1,25 @@
+#! /bin/sh
+# Copyright (C) 1997-2012 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/>.
+
+# Test to see if aclocal correctly reports missing AM_ macro.
+
+. ./defs || Exit 1
+
+echo AM_ZARDOZ >> configure.ac
+
+$ACLOCAL 2>stderr && { cat stderr >&2; Exit 1; }
+cat stderr
+grep 'configure.ac:.*AM_ZARDOZ.*not found' stderr
diff --git a/t/amopt.sh b/t/amopt.sh
new file mode 100755
index 000000000..786118410
--- /dev/null
+++ b/t/amopt.sh
@@ -0,0 +1,38 @@
+#! /bin/sh
+# Copyright (C) 2006-2012 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 Automake diagnose a conditional AUTOMAKE_OPTIONS.
+# Report from Bas Wijnen.
+
+. ./defs || Exit 1
+
+cat >>configure.ac <<END
+AM_CONDITIONAL([COND], [true])
+END
+
+mkdir sub
+
+cat >Makefile.am <<END
+if COND
+AUTOMAKE_OPTIONS = -Wall
+endif
+END
+
+$ACLOCAL
+AUTOMAKE_fails
+grep '^Makefile\.am:2.*AUTOMAKE_OPTIONS.*conditional' stderr
+
+:
diff --git a/t/amopts-location.sh b/t/amopts-location.sh
new file mode 100755
index 000000000..0219f1854
--- /dev/null
+++ b/t/amopts-location.sh
@@ -0,0 +1,83 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that errors about AUTOMAKE_OPTIONS refers to correct
+# locations.
+
+. ./defs || Exit 1
+
+cat > Makefile.am <<'END'
+# comment \
+# continued
+include Makefile0.am
+END
+
+cat > Makefile0.am <<'END'
+#1
+#2
+#3
+include Makefile1.am
+END
+
+cat > Makefile1.am <<'END'
+AUTOMAKE_OPTIONS = tar-pax
+# comment
+END
+
+cat > Makefile2.am <<'END'
+## automake comment
+bar:
+ :
+line = \
+continued
+AUTOMAKE_OPTIONS = tar-ustar
+END
+
+cat > Makefile3.am <<'END'
+quux = a
+AUTOMAKE_OPTIONS =
+quux += b
+AUTOMAKE_OPTIONS += tar-v7
+zardoz = 1
+END
+
+cat >>configure.ac <<'END'
+AC_CONFIG_FILES([Makefile2 Makefile3])
+END
+
+$ACLOCAL
+# Automake options 'tar-v7', 'tar-ustar' and 'tar-pax' can only be used
+# as argument to AM_INIT_AUTOMAKE, and not in AUTOMAKE_OPTIONS.
+AUTOMAKE_fails
+
+# Check that all the expected line numbers are correctly reported
+# in automake warning/error messages.
+grep '^Makefile1\.am:1:.*tar-pax' stderr
+grep '^Makefile2\.am:6:.*tar-ustar' stderr
+grep '^Makefile3\.am:2:.*tar-v7' stderr
+grep '^Makefile\.am:3:.*Makefile0\.am.*included from here' stderr
+grep '^Makefile0\.am:4:.*Makefile1\.am.*included from here' stderr
+
+# And also check that no botched line number is reported.
+cat stderr \
+ | grep -v '^Makefile\.am:3:' \
+ | grep -v '^Makefile0\.am:4:' \
+ | grep -v '^Makefile1\.am:1:' \
+ | grep -v '^Makefile2\.am:6:' \
+ | grep -v '^Makefile3\.am:2:' \
+ | grep . && Exit 1
+
+:
diff --git a/t/amopts-variable-expansion.sh b/t/amopts-variable-expansion.sh
new file mode 100755
index 000000000..8a035d126
--- /dev/null
+++ b/t/amopts-variable-expansion.sh
@@ -0,0 +1,52 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that AUTOMAKE_OPTIONS support variable expansion.
+
+. ./defs || Exit 1
+
+# We want complete control over automake options.
+AUTOMAKE=$am_original_AUTOMAKE
+
+cat > configure.ac <<END
+AC_INIT([$me], [1.0])
+AM_INIT_AUTOMAKE([-Wall -Werror gnu])
+AC_CONFIG_FILES([Makefile])
+END
+
+cat > Makefile.am <<'END'
+# The following should expand to '-Wnone -Wno-error foreign -Wportability'.
+AUTOMAKE_OPTIONS = $(foo) foreign
+AUTOMAKE_OPTIONS += ${bar}
+foo = $(foo1)
+foo1 = ${foo2}
+foo2 = -Wnone
+foo2 += $(foo3)
+foo3 = -Wno-error
+bar = -Wportability
+# This will give a warning with '-Wportability'.
+zardoz :=
+# This would give a warning with '-Woverride'.
+install:
+END
+
+$ACLOCAL
+AUTOMAKE_run
+grep '^Makefile\.am:.*:=.*not portable' stderr
+grep README stderr && Exit 1
+$EGREP '(install|override)' stderr && Exit 1
+
+:
diff --git a/t/amsubst.sh b/t/amsubst.sh
new file mode 100755
index 000000000..b655ce472
--- /dev/null
+++ b/t/amsubst.sh
@@ -0,0 +1,39 @@
+#! /bin/sh
+# Copyright (C) 2006-2012 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/>.
+
+# Check for _AM_SUBST_NOTMAKE.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_SUBST([backslash], "\\")
+_AM_SUBST_NOTMAKE([backslash])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+test:
+ @echo $(backslash) @backslash@$$
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+
+# If _AM_SUBST_NOTMAKE is not honored, the backslash
+# variable will not be empty.
+$MAKE test | grep '^[$]$'
diff --git a/t/ansi2knr-no-more.sh b/t/ansi2knr-no-more.sh
new file mode 100755
index 000000000..fb2e2a546
--- /dev/null
+++ b/t/ansi2knr-no-more.sh
@@ -0,0 +1,56 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that any attempt to use the obsolete de-ANSI-fication support
+# is diagnosed.
+
+. ./defs || Exit 1
+
+warn_rx='automatic de-ANSI-fication.*removed'
+
+echo AC_PROG_CC >> configure.ac
+$ACLOCAL
+mv aclocal.m4 aclocal.sav
+cp configure.ac configure.sav
+
+echo AM_C_PROTOTYPES >> configure.ac
+
+$ACLOCAL -Wnone 2>stderr && { cat stderr >&2; Exit 1; }
+cat stderr >&2
+grep "^configure\\.ac:5:.*$warn_rx" stderr
+
+cat aclocal.sav "$am_automake_acdir"/protos.m4 > aclocal.m4
+$AUTOCONF -Wnone 2>stderr && { cat stderr >&2; Exit 1; }
+cat stderr >&2
+grep "^configure\\.ac:5:.*$warn_rx" stderr
+
+for opt in ansi2knr lib/ansi2knr; do
+ # ansi2knr option in Makefile.am
+ cp configure.sav configure.ac
+ echo "AUTOMAKE_OPTIONS = $opt" > Makefile.am
+ rm -rf autom4te*.cache
+ AUTOMAKE_fails -Wnone
+ grep "^Makefile\.am:1:.*$warn_rx" stderr
+ # ansi2knr option in configure.ac
+ echo > Makefile.am # `echo', not `:', for Solaris /bin/sh.
+ sed "s|^\\(AM_INIT_AUTOMAKE\\).*|\1([$opt])|" configure.sav >configure.ac
+ cat configure.ac # For debugging.
+ rm -rf autom4te*.cache
+ AUTOMAKE_fails -Wnone
+ grep "^configure\\.ac:2:.*$warn_rx" stderr
+done
+
+:
diff --git a/t/ar-lib.sh b/t/ar-lib.sh
new file mode 100755
index 000000000..1ddec64d8
--- /dev/null
+++ b/t/ar-lib.sh
@@ -0,0 +1,113 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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 'ar-lib' wraps the Microsoft Library Manager (lib) correctly.
+
+am_create_testdir=empty
+required=xsi-lib-shell
+. ./defs || Exit 1
+
+get_shell_script ar-lib
+
+# Use a dummy lib, since lib isn't readily available on all systems.
+cat >lib <<'END'
+#! /bin/sh
+if test x"$2" = x-LIST && test x"$3" = xfake.lib; then
+ echo fake.obj
+elif test x"$2" = x-LIST && test x"$3" = xfake2.lib; then
+ printf "%s\n" "dir\\fake2.obj"
+else
+ printf "%s\n" "lib $*"
+fi
+END
+
+chmod +x ./lib
+
+# Check if ar-lib can create an archive with "cr".
+opts=`./ar-lib ./lib cr foo.lib foo.obj`
+test x"$opts" = x"lib -NOLOGO -OUT:foo.lib foo.obj"
+
+# Check if ar-lib can update an existing archive with "r".
+touch foo.lib
+opts=`./ar-lib ./lib r foo.lib foo.obj`
+test x"$opts" = x"lib -NOLOGO -OUT:foo.lib foo.lib foo.obj"
+
+# Check if ar-lib can update an existing archive with "q".
+opts=`./ar-lib ./lib q foo.lib foo.obj`
+test x"$opts" = x"lib -NOLOGO -OUT:foo.lib foo.lib foo.obj"
+
+# Check if ar-lib accepts "u" as a modifier.
+# NOTE: "u" should have an effect, but currently doesn't.
+opts=`./ar-lib ./lib ru foo.lib foo.obj`
+test x"$opts" = x"lib -NOLOGO -OUT:foo.lib foo.lib foo.obj"
+
+# Check if ar-lib accepts "s" as a modifier.
+opts=`./ar-lib ./lib rs foo.lib foo.obj`
+test x"$opts" = x"lib -NOLOGO -OUT:foo.lib foo.lib foo.obj"
+
+# Check if ar-lib accepts "S" as a modifier.
+opts=`./ar-lib ./lib rS foo.lib foo.obj`
+test x"$opts" = x"lib -NOLOGO -OUT:foo.lib foo.lib foo.obj"
+
+# Check if ar-lib passes on @FILE with "r"
+opts=`./ar-lib ./lib r foo.lib @list`
+test x"$opts" = x"lib -NOLOGO -OUT:foo.lib foo.lib @list"
+
+# Check if ar-lib can delete a member from an archive with "d".
+opts=`./ar-lib ./lib d foo.lib foo.obj`
+test x"$opts" = x"lib -NOLOGO -REMOVE:foo.obj foo.lib"
+
+# Check if ar-lib can delete members in an @FILE.
+echo foo.obj > foolist
+opts=`./ar-lib ./lib d foo.lib @foolist`
+test x"$opts" = x"lib -NOLOGO -REMOVE:foo.obj foo.lib"
+
+# Check if ar-lib can list archive members with "t".
+opts=`./ar-lib ./lib t foo.lib`
+test x"$opts" = x"lib -NOLOGO -LIST foo.lib"
+
+# Check if ar-lib accepts "v" as a modifier.
+# NOTE: "v" should have an effect, but currently doesn't.
+opts=`./ar-lib ./lib tv foo.lib`
+test x"$opts" = x"lib -NOLOGO -LIST foo.lib"
+
+# Check if ar-lib can extract archive members with "x".
+touch fake.lib
+opts=`./ar-lib ./lib x fake.lib`
+test x"$opts" = x"lib -NOLOGO -EXTRACT:fake.obj fake.lib"
+
+# Check if ar-lib can extract specified archive members with "x".
+opts=`./ar-lib ./lib x foo.lib foo.obj`
+test x"$opts" = x"lib -NOLOGO -EXTRACT:foo.obj foo.lib"
+
+# Check if ar-lib can extract members in an @FILE.
+opts=`./ar-lib ./lib x foo.lib @foolist`
+test x"$opts" = x"lib -NOLOGO -EXTRACT:foo.obj foo.lib"
+
+# Check if ar-lib passes -lib and -LTCG through to the wrappee.
+opts=`./ar-lib ./lib -lib -LTCG x foo.lib foo.obj`
+test x"$opts" = x"lib -lib -LTCG -NOLOGO -EXTRACT:foo.obj foo.lib"
+
+# Check if ar-lib can extract backslashed members.
+touch fake2.lib
+opts=`./ar-lib ./lib x fake2.lib`
+test x"$opts" = x"lib -NOLOGO -EXTRACT:dir\\fake2.obj fake2.lib"
+
+# Check if ar-lib accepts "s" as an action.
+opts=`./ar-lib ./lib s foo.lib`
+test x"$opts" = x
+
+:
diff --git a/t/ar-lib2.sh b/t/ar-lib2.sh
new file mode 100755
index 000000000..7d7e9b588
--- /dev/null
+++ b/t/ar-lib2.sh
@@ -0,0 +1,38 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Test if AM_PROG_AR installs ar-lib.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_AR
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = wish
+wish_SOURCES = a.c
+END
+
+$ACLOCAL
+$AUTOMAKE --add-missing 2>stderr || { cat stderr >&2; Exit 1; }
+cat stderr >&2
+# Make sure ar-lib is installed, and that Automake says so.
+grep '^configure\.ac:.*install.*ar-lib' stderr
+test -f ar-lib
+
+:
diff --git a/t/ar-lib3.sh b/t/ar-lib3.sh
new file mode 100755
index 000000000..02696f62d
--- /dev/null
+++ b/t/ar-lib3.sh
@@ -0,0 +1,44 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Test if lib_LIBRARIES requests AM_PROG_AR.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_PROG_RANLIB
+END
+
+cat > Makefile.am << 'END'
+lib_LIBRARIES = libfoo.a
+libfoo_a_SOURCES = foo.c
+END
+
+$ACLOCAL
+AUTOMAKE_fails
+
+grep 'requires.*AM_PROG_AR' stderr
+
+cat >> configure.ac << 'END'
+AM_PROG_AR
+END
+
+rm -rf autom4te*.cache
+$ACLOCAL
+$AUTOMAKE --add-missing
+
+:
diff --git a/t/ar-lib4.sh b/t/ar-lib4.sh
new file mode 100755
index 000000000..d1be2eb41
--- /dev/null
+++ b/t/ar-lib4.sh
@@ -0,0 +1,55 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Test if lib_LTLIBRARIES requests AM_PROG_AR.
+
+required=libtoolize
+. ./defs || Exit 1
+
+cp configure.ac X
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_PROG_RANLIB
+AC_PROG_LIBTOOL
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+lib_LTLIBRARIES = libfoo.la
+libfoo_la_SOURCES = foo.c
+END
+
+libtoolize
+$ACLOCAL
+AUTOMAKE_fails
+
+grep 'requires.*AM_PROG_AR' stderr
+
+cp X configure.ac
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_RANLIB
+AC_PROG_LIBTOOL
+AC_OUTPUT
+END
+
+$ACLOCAL
+$AUTOMAKE --add-missing
+
+:
diff --git a/t/ar-lib5a.sh b/t/ar-lib5a.sh
new file mode 100755
index 000000000..1987936b9
--- /dev/null
+++ b/t/ar-lib5a.sh
@@ -0,0 +1,71 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Test if AM_PROG_AR triggers the use of the ar-lib script.
+# This test requires Microsoft lib.
+# Keep this test in sync with sister test 'ar-lib5b.test'.
+
+required=lib
+. ./defs || Exit 1
+
+cat > configure.ac << END
+AC_INIT([$me], [1.0])
+AC_CONFIG_AUX_DIR([auxdir])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([Makefile])
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_RANLIB
+# We want to test the content of am_cv_ar_interface in the Makefile.
+AC_SUBST([am_cv_ar_interface])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+lib_LIBRARIES = libwish.a
+libwish_a_SOURCES = wish.c
+
+check-local:
+ test x'$(am_cv_ar_interface)' = x'lib'
+ test -f ar-lib-worked
+ test -f libwish.a
+MOSTLYCLEANFILES = ar-lib-worked
+END
+
+cat > wish.c << 'END'
+int wish(void) { return 0; }
+END
+
+mkdir auxdir
+cat - "$am_scriptdir/ar-lib" > auxdir/ar-lib << 'END'
+#! /bin/sh
+:> ar-lib-worked
+END
+chmod +x auxdir/ar-lib
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+# Sanity check: test that it is ok to use 'am_cv_ar_interface' as we do.
+$FGREP 'am_cv_ar_interface=' configure
+
+./configure AR=lib RANLIB=:
+
+$MAKE check
+$MAKE distcheck DISTCHECK_CONFIGURE_FLAGS='AR=lib RANLIB=:'
+
+:
diff --git a/t/ar-lib5b.sh b/t/ar-lib5b.sh
new file mode 100755
index 000000000..2fb0cf43e
--- /dev/null
+++ b/t/ar-lib5b.sh
@@ -0,0 +1,97 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Test if AM_PROG_AR triggers the use of the ar-lib script.
+# This test does not require Microsoft lib.
+# Keep this test in sync with sister test 'ar-lib5a.test'.
+
+. ./defs || Exit 1
+
+cat > configure.ac << END
+AC_INIT([$me], [1.0])
+AC_CONFIG_AUX_DIR([auxdir])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([Makefile])
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_RANLIB
+# We want to test the content of am_cv_ar_interface in the Makefile.
+AC_SUBST([am_cv_ar_interface])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+lib_LIBRARIES = libwish.a
+libwish_a_SOURCES = wish.c
+
+check-local:
+ test x'$(am_cv_ar_interface)' = x'lib'
+ test -f ar-lib-worked
+MOSTLYCLEANFILES = ar-lib-worked
+END
+
+cat > wish.c << 'END'
+int wish(void) { return 0; }
+END
+
+mkdir auxdir
+cat > auxdir/ar-lib << 'END'
+#! /bin/sh
+:> ar-lib-worked
+END
+chmod +x auxdir/ar-lib
+
+# Let's fake microsoft lib.
+mkdir bin
+cat > bin/lib << 'END'
+#! /bin/sh
+echo lib command line: $* >&2 # For debugging.
+case " $* " in
+ # The '-OUT:' option is used by tests in configure. So don't create
+ # the 'ar-lib-worked' file here, as that might cause spurious passes
+ # of this test; but don't fail either, as that would confuse said
+ # configure tests.
+ *' -OUT:'*) exit 0;;
+ # This means that $* looks like a command-line for 'ar'. We have to
+ # exit with failure here, to accommodate the two following ortoghonal
+ # scenarios:
+ # 1. when 'lib' is tested by configure, this will tell that it does
+ # not use the ar(1) interface, so that the 'ar-lib' script will
+ # get involved;
+ # 2. when 'lib' is called by the Makefile, an ar-style command line
+ # passed to it would mean that the 'ar-lib' script has failed to
+ # properly munge the command line, or hasn't been invoked to do so.
+ *\ c*) exit 1;;
+ # Assume everything else is OK.
+ *) : > ar-lib-worked;;
+esac
+END
+chmod +x bin/lib
+PATH=`pwd`/bin$PATH_SEPARATOR$PATH; export PATH
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+# Sanity check: test that it is ok to use 'am_cv_ar_interface' as we do.
+$FGREP 'am_cv_ar_interface=' configure
+
+./configure AR=lib RANLIB=:
+
+$MAKE check
+$MAKE distcheck DISTCHECK_CONFIGURE_FLAGS="AR=lib RANLIB=:"
+
+:
diff --git a/t/ar-lib6a.sh b/t/ar-lib6a.sh
new file mode 100755
index 000000000..be6afcd3f
--- /dev/null
+++ b/t/ar-lib6a.sh
@@ -0,0 +1,37 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Test AM_PROG_AR ordering requirements
+# Keep this test in sync with sister test 'ar-lib6b.test'.
+
+required=libtoolize
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_PROG_RANLIB
+m4_ifdef([LT_INIT], [LT_INIT], [AC_PROG_LIBTOOL])
+AM_PROG_AR
+END
+
+libtoolize
+$ACLOCAL
+$AUTOCONF 2>stderr || { cat stderr >&2; Exit 1; }
+cat stderr >&2
+
+$EGREP '(AC_PROG_LIBTOOL|LT_INIT).*before.*AM_PROG_AR' stderr
+
+:
diff --git a/t/ar-lib6b.sh b/t/ar-lib6b.sh
new file mode 100755
index 000000000..54c02225e
--- /dev/null
+++ b/t/ar-lib6b.sh
@@ -0,0 +1,37 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Test AM_PROG_AR ordering requirements for older Libtools
+# Keep this test in sync with sister test 'ar-lib6a.test'.
+
+required=libtoolize
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_PROG_RANLIB
+AC_PROG_LIBTOOL
+AM_PROG_AR
+END
+
+libtoolize
+$ACLOCAL
+$AUTOCONF 2>stderr || { cat stderr >&2; Exit 1; }
+cat stderr >&2
+
+$EGREP 'AC_PROG_LIBTOOL.*before.*AM_PROG_AR' stderr
+
+:
diff --git a/t/ar-lib7.sh b/t/ar-lib7.sh
new file mode 100755
index 000000000..34e6c6e53
--- /dev/null
+++ b/t/ar-lib7.sh
@@ -0,0 +1,34 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Test if automake warns if ar-lib is missing when AM_PROG_AR is used.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AM_PROG_AR
+END
+
+:> Makefile.am
+
+$ACLOCAL
+AUTOMAKE_fails
+
+grep '^configure\.ac:.*ar-lib.*not found' stderr
+
+$AUTOMAKE --add-missing
+
+:
diff --git a/t/ar.sh b/t/ar.sh
new file mode 100755
index 000000000..b8d9901a0
--- /dev/null
+++ b/t/ar.sh
@@ -0,0 +1,44 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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 that AR, ARFLAGS, and RANLIB can be substituted from configure.ac.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AM_PROG_AR
+AC_SUBST([AR], ['echo it works'])
+AC_SUBST([ARFLAGS], ['>'])
+AC_SUBST([RANLIB], ['echo really works >>'])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+lib_LIBRARIES = libfoo.a
+libfoo_a_SOURCES =
+END
+
+:> ar-lib
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+$MAKE
+grep 'it works' libfoo.a
+grep 'really works' libfoo.a
+
+:
diff --git a/t/ar2.sh b/t/ar2.sh
new file mode 100755
index 000000000..c71afea09
--- /dev/null
+++ b/t/ar2.sh
@@ -0,0 +1,38 @@
+#! /bin/sh
+# Copyright (C) 2004-2012 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 AR and ARFLAGS are defined for EXTRA_LIBRARIES.
+# Report from Kevin Ryde.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_PROG_RANLIB
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+EXTRA_LIBRARIES = libfoo.a
+libfoo_a_SOURCES = foo.c
+END
+
+$ACLOCAL
+$AUTOMAKE -Wno-extra-portability
+grep '^ARFLAGS =' Makefile.in
+grep '^AR =' Makefile.in
+
+:
diff --git a/t/ar3.sh b/t/ar3.sh
new file mode 100755
index 000000000..ba0b4b737
--- /dev/null
+++ b/t/ar3.sh
@@ -0,0 +1,41 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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 that AR, ARFLAGS, etc. works also when the macro AM_PROG_AR
+# is used.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_RANLIB
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+EXTRA_LIBRARIES = libfoo.a
+libfoo_a_SOURCES = foo.c
+END
+
+: > ar-lib
+
+$ACLOCAL
+$AUTOMAKE
+$EGREP '^ARFLAGS =' Makefile.in
+$EGREP '^AR =' Makefile.in
+
+:
diff --git a/t/ar4.sh b/t/ar4.sh
new file mode 100755
index 000000000..424a77675
--- /dev/null
+++ b/t/ar4.sh
@@ -0,0 +1,37 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Test if configure bails out if $AR does not work and AM_PROG_AR is used.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AM_PROG_AR
+END
+
+$ACLOCAL
+$AUTOCONF
+
+st=0; ./configure AR=/bin/false >stdout 2>stderr || st=$?
+cat stdout
+cat stderr >&2
+test $st -eq 1
+
+grep '^checking.* archiver .*interface.*\.\.\. unknown' stdout
+grep '^configure: error: could not determine /bin/false interface' stderr
+ls *conftest* && Exit 1
+
+:
diff --git a/t/ar5.sh b/t/ar5.sh
new file mode 100755
index 000000000..711fad6a1
--- /dev/null
+++ b/t/ar5.sh
@@ -0,0 +1,40 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Test the optional argument of AM_PROG_AR.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AM_PROG_AR([
+ echo spy > bad-archiver-interface-detected
+ AC_MSG_CHECKING([for something else])
+ AC_MSG_RESULT([found it])
+ echo Grep This
+])
+END
+
+$ACLOCAL
+$AUTOCONF
+
+./configure AR=/bin/false >stdout || { cat stdout; Exit 1; }
+cat stdout
+grep '^checking.* archiver .*interface.*\.\.\. unknown$' stdout
+grep '^checking for something else\.\.\. found it$' stdout
+grep '^Grep This$' stdout
+test -f bad-archiver-interface-detected
+
+:
diff --git a/t/asm.sh b/t/asm.sh
new file mode 100755
index 000000000..b9a958d1a
--- /dev/null
+++ b/t/asm.sh
@@ -0,0 +1,100 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test of basic assembly functionality.
+# Keep this in sync with sister tests asm2.test and asm3.test.
+
+. ./defs || Exit 1
+
+mv configure.ac configure.stub
+
+cat > Makefile.am << 'END'
+noinst_PROGRAMS = maude
+maude_SOURCES = maude.s
+END
+
+echo '*** Try 1 -- should fail because we need CC and CCAS ***'
+cat configure.stub - > configure.ac << 'END'
+AC_SUBST([CCASFLAGS])
+AC_OUTPUT
+END
+
+$ACLOCAL
+AUTOMAKE_fails
+grep '[Aa]ssembler source.*CCAS.* undefined' stderr
+grep 'define .*CCAS.* add .*AM_PROG_AS' stderr
+
+# On fast machines the autom4te.cache created during the above run of
+# $AUTOMAKE is likely to have the same time stamp as the configure.ac
+# created below; thus causing traces for the old configure.ac to be
+# used. We could do '$sleep', but it's faster to erase the
+# directory. (Erase autom4te*.cache, not autom4te.cache, because some
+# bogus installations of Autoconf use a versioned cache.)
+rm -rf autom4te*.cache
+
+echo '*** Try 2 -- we still need CCAS ***'
+cat configure.stub - > configure.ac << 'END'
+AC_PROG_CC
+AC_SUBST([CCASFLAGS])
+AC_OUTPUT
+END
+
+$ACLOCAL
+AUTOMAKE_fails
+grep '[Aa]ssembler source.*CCAS.* undefined' stderr
+grep 'define .*CCAS.* add .*AM_PROG_AS' stderr
+
+rm -rf autom4te*.cache
+
+echo '*** Try 3 -- we need CCASFLAGS ***'
+cat configure.stub - > configure.ac << 'END'
+CCAS='$(CC)'
+AC_SUBST([CCAS])
+AC_PROG_CC
+AC_OUTPUT
+END
+
+$ACLOCAL
+AUTOMAKE_fails
+grep '[Aa]ssembler source.*CCASFLAGS.* undefined' stderr
+grep 'define .*CCASFLAGS.* add .*AM_PROG_AS' stderr
+
+rm -rf autom4te*.cache
+
+echo '*** Try 4 -- we have everything needed, expect success ***'
+cat configure.stub - > configure.ac << 'END'
+CCAS='$(CC)'
+AC_SUBST([CCAS])
+AC_PROG_CC
+AC_SUBST([CCASFLAGS])
+AC_OUTPUT
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+rm -rf autom4te*.cache
+
+echo '*** Try 5 -- we have everything needed, expect success ***'
+cat configure.stub - > configure.ac << 'END'
+AM_PROG_AS
+AC_OUTPUT
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+:
diff --git a/t/asm2.sh b/t/asm2.sh
new file mode 100755
index 000000000..737d46d4f
--- /dev/null
+++ b/t/asm2.sh
@@ -0,0 +1,116 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test of basic preprocessed assembly functionality.
+# Keep this in sync with sister tests asm.test and asm3.test.
+
+. ./defs || Exit 1
+
+mv configure.ac configure.stub
+
+cat > Makefile.am << 'END'
+noinst_PROGRAMS = maude
+maude_SOURCES = maude.S
+END
+
+echo '*** Try 1 -- should fail because we need CC and CCAS ***'
+cat configure.stub - > configure.ac << 'END'
+AC_SUBST([CCASFLAGS])
+AC_OUTPUT
+END
+
+$ACLOCAL
+AUTOMAKE_fails
+grep '[Aa]ssembler source.*CCAS.* undefined' stderr
+grep 'define .*CCAS.* add .*AM_PROG_AS' stderr
+
+# On fast machines the autom4te.cache created during the above run of
+# $AUTOMAKE is likely to have the same time stamp as the configure.ac
+# created below; thus causing traces for the old configure.ac to be
+# used. We could do '$sleep', but it's faster to erase the
+# directory. (Erase autom4te*.cache, not autom4te.cache, because some
+# bogus installations of Autoconf use a versioned cache.)
+rm -rf autom4te*.cache
+
+echo '*** Try 2 -- we still need CCAS ***'
+cat configure.stub - > configure.ac << 'END'
+AC_PROG_CC
+AC_SUBST([CCASFLAGS])
+AC_OUTPUT
+END
+
+$ACLOCAL
+AUTOMAKE_fails
+grep '[Aa]ssembler source.*CCAS.* undefined' stderr
+grep 'define .*CCAS.* add .*AM_PROG_AS' stderr
+
+rm -rf autom4te*.cache
+
+echo '*** Try 3 -- we need CCASFLAGS ***'
+cat configure.stub - > configure.ac << 'END'
+CCAS='$(CC)'
+AC_SUBST([CCAS])
+AC_PROG_CC
+AC_OUTPUT
+END
+
+$ACLOCAL
+AUTOMAKE_fails
+grep '[Aa]ssembler source.*CCASFLAGS.* undefined' stderr
+grep 'define .*CCASFLAGS.* add .*AM_PROG_AS' stderr
+
+rm -rf autom4te*.cache
+
+echo '*** Try 4 -- we need dependency tracking. ***'
+cat configure.stub - > configure.ac << 'END'
+CCAS='$(CC)'
+AC_SUBST([CCAS])
+AC_PROG_CC
+AC_SUBST([CCASFLAGS])
+AC_OUTPUT
+END
+
+$ACLOCAL
+AUTOMAKE_fails
+grep ' add .*AM_PROG_AS' stderr
+
+rm -rf autom4te*.cache
+
+echo '*** Try 5 -- we have everything needed, expect success. ***'
+cat configure.stub - > configure.ac << 'END'
+CCAS='$(CC)'
+AC_SUBST([CCAS])
+AC_PROG_CC
+_AM_DEPENDENCIES([CCAS])
+AC_SUBST([CCASFLAGS])
+AC_OUTPUT
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+rm -rf autom4te*.cache
+
+echo '*** Try 6 -- we have everything needed, expect success. ***'
+cat configure.stub - > configure.ac << 'END'
+AM_PROG_AS
+AC_OUTPUT
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+:
diff --git a/t/asm3.sh b/t/asm3.sh
new file mode 100755
index 000000000..f7f835a1f
--- /dev/null
+++ b/t/asm3.sh
@@ -0,0 +1,116 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test of basic preprocessed assembly functionality with extension .sx.
+# Keep this in sync with sister tests asm.test and asm2.test.
+
+. ./defs || Exit 1
+
+mv configure.ac configure.stub
+
+cat > Makefile.am << 'END'
+noinst_PROGRAMS = maude
+maude_SOURCES = maude.sx
+END
+
+echo '*** Try 1 -- should fail because we need CC and CCAS ***'
+cat configure.stub - > configure.ac << 'END'
+AC_SUBST([CCASFLAGS])
+AC_OUTPUT
+END
+
+$ACLOCAL
+AUTOMAKE_fails
+grep '[Aa]ssembler source.*CCAS.* undefined' stderr
+grep 'define .*CCAS.* add .*AM_PROG_AS' stderr
+
+# On fast machines the autom4te.cache created during the above run of
+# $AUTOMAKE is likely to have the same time stamp as the configure.ac
+# created below; thus causing traces for the old configure.ac to be
+# used. We could do '$sleep', but it's faster to erase the
+# directory. (Erase autom4te*.cache, not autom4te.cache, because some
+# bogus installations of Autoconf use a versioned cache.)
+rm -rf autom4te*.cache
+
+echo '*** Try 2 -- we still need CCAS ***'
+cat configure.stub - > configure.ac << 'END'
+AC_PROG_CC
+AC_SUBST([CCASFLAGS])
+AC_OUTPUT
+END
+
+$ACLOCAL
+AUTOMAKE_fails
+grep '[Aa]ssembler source.*CCAS.* undefined' stderr
+grep 'define .*CCAS.* add .*AM_PROG_AS' stderr
+
+rm -rf autom4te*.cache
+
+echo '*** Try 3 -- we need CCASFLAGS ***'
+cat configure.stub - > configure.ac << 'END'
+CCAS='$(CC)'
+AC_SUBST([CCAS])
+AC_PROG_CC
+AC_OUTPUT
+END
+
+$ACLOCAL
+AUTOMAKE_fails
+grep '[Aa]ssembler source.*CCASFLAGS.* undefined' stderr
+grep 'define .*CCASFLAGS.* add .*AM_PROG_AS' stderr
+
+rm -rf autom4te*.cache
+
+echo '*** Try 4 -- we need dependency tracking. ***'
+cat configure.stub - > configure.ac << 'END'
+CCAS='$(CC)'
+AC_SUBST([CCAS])
+AC_PROG_CC
+AC_SUBST([CCASFLAGS])
+AC_OUTPUT
+END
+
+$ACLOCAL
+AUTOMAKE_fails
+grep ' add .*AM_PROG_AS' stderr
+
+rm -rf autom4te*.cache
+
+echo '*** Try 5 -- we have everything needed, expect success. ***'
+cat configure.stub - > configure.ac << 'END'
+CCAS='$(CC)'
+AC_SUBST([CCAS])
+AC_PROG_CC
+_AM_DEPENDENCIES([CCAS])
+AC_SUBST([CCASFLAGS])
+AC_OUTPUT
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+rm -rf autom4te*.cache
+
+echo '*** Try 6 -- we have everything needed, expect success. ***'
+cat configure.stub - > configure.ac << 'END'
+AM_PROG_AS
+AC_OUTPUT
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+:
diff --git a/t/autodist-acconfig-no-subdir.sh b/t/autodist-acconfig-no-subdir.sh
new file mode 100755
index 000000000..d4ad1d960
--- /dev/null
+++ b/t/autodist-acconfig-no-subdir.sh
@@ -0,0 +1,56 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that 'acconfig.h' is *not* automatically distributed when
+# placed in a subdirectory.
+# Related to automake bug#7819.
+
+. ./defs || Exit 1
+
+cat >> configure.ac <<END
+AC_CONFIG_FILES([sub/Makefile])
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+SUBDIRS = sub
+sub/acconfig.h:
+ echo target $@ should not be built >&2; exit 1
+check-local: distdir
+ ls -l $(distdir)/sub
+ test ! -f $(distdir)/sub/acconfig.h
+END
+
+mkdir sub
+
+cat > sub/Makefile.am <<'END'
+acconfig.h:
+ echo target $@ should not be built >&2; exit 1
+check-local:
+ echo $(DISTFILES) | grep 'acconfig\.h' && exit 1; :
+ echo $(DIST_COMMON) | grep 'acconfig\.h' && exit 1; :
+END
+
+: > sub/acconfig.h
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+
+./configure
+$MAKE check
+
+:
diff --git a/t/autodist-acconfig.sh b/t/autodist-acconfig.sh
new file mode 100755
index 000000000..18b280c3c
--- /dev/null
+++ b/t/autodist-acconfig.sh
@@ -0,0 +1,44 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that 'acconfig.h' is automatically distributed if it exists
+# (at automake runtime).
+# Related to automake bug#7819.
+
+. ./defs || Exit 1
+
+cat >> configure.ac <<END
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+.PHONY: test
+test: distdir
+ ls -l $(distdir)
+ echo ' ' $(DIST_COMMON) ' ' | grep '[ /]acconfig\.h '
+ test -f $(distdir)/acconfig.h
+END
+
+: > acconfig.h
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+
+./configure
+$MAKE test
+
+:
diff --git a/t/autodist-aclocal-m4.sh b/t/autodist-aclocal-m4.sh
new file mode 100755
index 000000000..6108f5743
--- /dev/null
+++ b/t/autodist-aclocal-m4.sh
@@ -0,0 +1,53 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that 'aclocal.m4' is not automatically distributed if not
+# required to build 'configure'. This is *really* a corner-case
+# check, and the behaviour it checks is not documented either, so
+# if that behaviour is deliberately changed in the future, just
+# remove this test.
+# Related to automake bug#7819.
+
+. ./defs || Exit 1
+
+{ echo 'm4_include([defs.m4])'
+ cat configure.ac
+ echo 'AC_OUTPUT'
+} > t
+mv -f t configure.ac
+
+cat > Makefile.am <<'END'
+.PHONY: test
+test: distdir
+ ls -l $(distdir)
+ test ! -f $(distdir)/aclocal.m4
+ echo $(DISTFILES) | grep 'aclocal\.m4' && exit 1; :
+ echo $(DIST_COMMON) | grep 'aclocal\.m4' && exit 1; :
+check-local: test
+END
+
+: > defs.m4
+$ACLOCAL
+mv -f aclocal.m4 defs.m4
+
+$AUTOMAKE
+$AUTOCONF
+
+./configure
+$MAKE test
+$MAKE distcheck
+
+:
diff --git a/t/autodist-config-headers.sh b/t/autodist-config-headers.sh
new file mode 100755
index 000000000..65888f813
--- /dev/null
+++ b/t/autodist-config-headers.sh
@@ -0,0 +1,59 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that config.h.bot and config.h.top are automatically
+# distributed if the AC_CONFIG_HADERS macro is used and they
+# exist at automake runtime.
+# Related to automake bug#7819.
+
+. ./defs || Exit 1
+
+cat >> configure.ac <<END
+AC_CONFIG_HEADERS([config.h sub/config.h cfg2.h:conf2.hin])
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+.PHONY: test
+test: distdir
+ ls -l $(distdir) $(distdir)/sub
+ echo ' ' $(DIST_COMMON) ' ' | grep '[ /]config\.h\.bot '
+ echo ' ' $(DIST_COMMON) ' ' | grep '[ /]config\.h\.top '
+ echo ' ' $(DIST_COMMON) ' ' | grep '[ /]cfg2\.h\.bot '
+ echo ' ' $(DIST_COMMON) ' ' | grep '[ /]cfg2\.h\.top '
+ echo ' ' $(DIST_COMMON) ' ' | grep '[ /]sub/config\.h\.bot '
+ echo ' ' $(DIST_COMMON) ' ' | grep '[ /]sub/config\.h\.top '
+ test -f $(distdir)/config.h.bot
+ test -f $(distdir)/config.h.top
+ test -f $(distdir)/cfg2.h.bot
+ test -f $(distdir)/cfg2.h.top
+ test -f $(distdir)/sub/config.h.bot
+ test -f $(distdir)/sub/config.h.top
+END
+
+mkdir sub
+touch config.h.in config.h.top config.h.bot \
+ conf2.hin cfg2.h.top cfg2.h.bot \
+ sub/config.h.in sub/config.h.top sub/config.h.bot
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+
+./configure
+$MAKE test
+
+:
diff --git a/t/autodist-configure-no-subdir.sh b/t/autodist-configure-no-subdir.sh
new file mode 100755
index 000000000..cc53cafcc
--- /dev/null
+++ b/t/autodist-configure-no-subdir.sh
@@ -0,0 +1,70 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that 'configure', 'configure.ac' and 'configure.in' are *not*
+# automatically distributed when placed in a subdirectory.
+# Related to automake bug#7819.
+
+. ./defs || Exit 1
+
+cat >> configure.ac <<END
+AC_CONFIG_FILES([sub/Makefile])
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+SUBDIRS = sub
+dontbuild = echo target $@ should not be built >&2; exit 1
+sub/configure:
+ $(dontbuild)
+sub/configure.ac:
+ $(dontbuild)
+sub/configure.in:
+ $(dontbuild)
+check-local: distdir
+ ls -l $(distdir)/sub
+ test ! -f $(distdir)/sub/configure
+ test ! -f $(distdir)/sub/configure.in
+ test ! -f $(distdir)/sub/configure.ac
+END
+
+mkdir sub
+
+cat > sub/Makefile.am <<'END'
+dontbuild = echo target $@ should not be built >&2; exit 1
+configure:
+ $(dontbuild)
+configure.ac:
+ $(dontbuild)
+configure.in:
+ $(dontbuild)
+check-local:
+ echo $(DISTFILES) | grep 'configure' && exit 1; :
+ echo $(DIST_COMMON) | grep 'configure' && exit 1; :
+END
+
+: > sub/configure.ac
+: > sub/configure.in
+: > sub/configure
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+
+./configure
+$MAKE check
+
+:
diff --git a/t/autodist-no-duplicate.sh b/t/autodist-no-duplicate.sh
new file mode 100755
index 000000000..90a2c7dfc
--- /dev/null
+++ b/t/autodist-no-duplicate.sh
@@ -0,0 +1,50 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that there are no duplicates in the list of files automatically
+# distributed by automake.
+
+. ./defs || Exit 1
+
+re='Files .*automatically distributed.*if found'
+
+# The automake manual states that the list of automatically-distributed
+# files should be given by 'automake --help'.
+
+list1=`$AUTOMAKE --help \
+ | sed -n "/^$re.*always/,/^ *$/p" \
+ | sed 1d`
+list1=`echo $list1`
+
+list2=`$AUTOMAKE --help \
+ | sed -n "/^$re.*under certain conditions/,/^ *$/p" \
+ | sed 1d`
+list2=`echo $list2`
+
+test -n "$list1"
+test -n "$list2"
+
+st=0
+for i in 1 2; do
+ eval list=\${list$i}
+ for f in $list; do echo $f; done | sort > files$i.lst
+ uniq files$i.lst > files$i.uniq
+ cat files$i.lst
+ cat files$i.uniq
+ diff files$i.lst files$i.uniq || st=1
+done
+
+Exit $st
diff --git a/t/autodist-stamp-vti.sh b/t/autodist-stamp-vti.sh
new file mode 100755
index 000000000..4db1f141e
--- /dev/null
+++ b/t/autodist-stamp-vti.sh
@@ -0,0 +1,58 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that 'stamp-vti' is automatically distributed when info_TEXINFOS
+# and version.texi are involved.
+# Related to automake bug#7819.
+
+required=makeinfo
+. ./defs || Exit 1
+
+cat >> configure.ac << END
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+info_TEXINFOS = foo.texi
+.PHONY: test
+test: all distdir
+ ls -l $(distdir)
+ echo ' ' $(DIST_COMMON) ' ' | grep '[ /]stamp-vti '
+ test -f $(distdir)/stamp-vti
+END
+
+cat > foo.texi << 'END'
+\input texinfo
+@setfilename foo.info
+@settitle Zardoz
+@node Top
+@include version.texi
+bar baz quux
+@bye
+END
+
+# Required when using Texinfo.
+: > texinfo.tex
+cp "$am_scriptdir"/mdate-sh .
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+$MAKE test
+
+:
diff --git a/t/autodist-subdir.sh b/t/autodist-subdir.sh
new file mode 100755
index 000000000..5e1f044e9
--- /dev/null
+++ b/t/autodist-subdir.sh
@@ -0,0 +1,120 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that automake really automatically distributes all the files
+# it advertises to do, even when in subdirectories.
+#
+# This behavior might be suboptimal, but it has been in place for quite
+# a long time, and it would be risky to change it now. See also the
+# discussion of automake bug#7819:
+# <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=7819>
+#
+# Keep this test in sync with sister test 'autodist.test'.
+
+. ./defs || Exit 1
+
+cat >> configure.ac <<'END'
+AC_CONFIG_FILES([sub/Makefile])
+AC_OUTPUT
+END
+
+$ACLOCAL
+$AUTOCONF
+
+# The automake manual states that the list of automatically-distributed
+# files should be given by 'automake --help'.
+list=`$AUTOMAKE --help \
+ | sed -n '/^Files.*automatically distributed.*if found.*always/,/^ *$/p' \
+ | sed 1d`
+# Normalize whitespace, just in case.
+list=`echo $list`
+
+test -n "$list"
+
+cat > Makefile.am <<'END'
+SUBDIRS = sub
+check-local:
+## For debugging.
+ @echo DIST_COMMON:
+ @for f in $(DIST_COMMON); do echo " $$f"; done
+ @echo DISTDIR:
+ @ls -l $(distdir) | sed 's/^/ /'
+## Now the checks.
+ @for f in $(autodist_list); do \
+ echo "file: sub/$$f"; \
+ test -f $(distdir)/sub/$$f \
+ || { echo $$f: distdir fail >&2; exit 1; }; \
+ done
+END
+
+mkdir sub
+
+cat > sub/Makefile.am <<'END'
+include distfiles.am
+check-local:
+## For debugging.
+ @echo DIST_COMMON:
+ @for f in $(DIST_COMMON); do echo " $$f"; done
+ @echo DISTDIR:
+ @ls -l $(distdir) | sed 's/^/ /'
+## Now the checks.
+ @for f in $(autodist_list); do \
+ echo "file: $$f"; \
+## Some filenames might contain dots, but this won't cause spurious
+## failures, and "spurious successes" are so unlikely that they're
+## not worth worrying about.
+ echo ' ' $(DIST_COMMON) ' ' | grep "[ /]$$f " >/dev/null \
+ || { echo $$f: distcom fail >&2; exit 1; }; \
+ done
+END
+
+: First try listing the automatically-distributed files in proper
+: targets in Makefile.am
+
+echo "MAINTAINERCLEANFILES = $list" > sub/distfiles.am
+for f in $list; do echo "$f :; touch $f"; done >> sub/distfiles.am
+
+cat sub/distfiles.am # For debugging.
+
+$AUTOMAKE -a
+
+./configure
+
+$MAKE distdir
+autodist_list="$list" $MAKE check
+
+$MAKE maintainer-clean
+test ! -f sub/README # Sanity check.
+rm -rf $me-1.0 # Remove $(distdir).
+
+: Now try creating the automatically-distributed files before
+: running automake.
+
+: > sub/distfiles.am
+for f in $list; do
+ echo dummy > sub/$f
+done
+
+ls -l # For debugging.
+
+$AUTOMAKE
+
+./configure
+
+$MAKE distdir
+autodist_list="$list" $MAKE check
+
+:
diff --git a/t/autodist.sh b/t/autodist.sh
new file mode 100755
index 000000000..e6435c54c
--- /dev/null
+++ b/t/autodist.sh
@@ -0,0 +1,103 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that automake really automatically distributes all the files
+# it advertises to do.
+# Related to automake bug#7819.
+# Keep this test in sync with sister test 'autodist-subdir.test'.
+
+am_create_testdir=empty
+. ./defs || Exit 1
+
+cat > configure.ac <<END
+AC_INIT([$me], [1.0])
+AC_CONFIG_AUX_DIR([.])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+END
+
+$ACLOCAL
+$AUTOCONF
+
+# The automake manual states that the list of automatically-distributed
+# files should be given by 'automake --help'.
+list=`$AUTOMAKE --help \
+ | sed -n '/^Files.*automatically distributed.*if found.*always/,/^ *$/p' \
+ | sed 1d`
+# Normalize whitespace, just in case.
+list=`echo $list`
+
+test -n "$list"
+
+cat > Makefile.am <<'END'
+include distfiles.am
+check-local:
+## For debugging.
+ @echo DIST_COMMON:
+ @for f in $(DIST_COMMON); do echo " $$f"; done
+ @echo DISTDIR:
+ @ls -l $(distdir) | sed 's/^/ /'
+## Now the checks.
+ @for f in $(autodist_list); do \
+ echo "file: $$f"; \
+ test -f $(distdir)/$$f \
+ || { echo $$f: distdir fail >&2; exit 1; }; \
+## Some filenames might contain dots, but this won't cause spurious
+## failures, and "spurious successes" are so unlikely that they're
+## not worth worrying about.
+ echo ' ' $(DIST_COMMON) ' ' | grep "[ /]$$f " >/dev/null \
+ || { echo $$f: distcom fail >&2; exit 1; }; \
+ done
+END
+
+: First try listing the automatically-distributed files in proper
+: targets in Makefile.am
+
+echo "MAINTAINERCLEANFILES = $list" > distfiles.am
+for f in $list; do echo "$f :; touch $f"; done >> distfiles.am
+
+cat distfiles.am # For debugging.
+
+$AUTOMAKE -a
+
+./configure
+
+$MAKE distdir
+autodist_list="$list" $MAKE check
+
+$MAKE maintainer-clean
+test ! -f README # Sanity check.
+rm -rf $me-1.0 # Remove $(distdir).
+
+: Now try creating the automatically-distributed files before
+: running automake.
+
+: > distfiles.am
+for f in $list; do
+ echo dummy > $f
+done
+
+ls -l # For debugging.
+
+$AUTOMAKE
+
+./configure
+
+$MAKE distdir
+autodist_list="$list" $MAKE check
+
+:
diff --git a/t/autohdr.sh b/t/autohdr.sh
new file mode 100755
index 000000000..bef7027fe
--- /dev/null
+++ b/t/autohdr.sh
@@ -0,0 +1,30 @@
+#!/bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Check that autoheaders works, despite our AC_CONFIG_HEADERS hack.
+
+. ./defs || Exit 1
+
+cat >>configure.ac <<EOF
+AC_CONFIG_HEADERS([thisfile.h])
+EOF
+
+: > Makefile.am
+
+$ACLOCAL
+$AUTOHEADER
+
+test -f thisfile.h.in
diff --git a/t/autohdr2.sh b/t/autohdr2.sh
new file mode 100755
index 000000000..6f5415e00
--- /dev/null
+++ b/t/autohdr2.sh
@@ -0,0 +1,30 @@
+#!/bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Check that autoheaders works, despite our AC_CONFIG_HEADERS hack.
+
+. ./defs || Exit 1
+
+cat >>configure.ac <<EOF
+AM_CONFIG_HEADER([thisfile.h])
+EOF
+
+: > Makefile.am
+
+$ACLOCAL
+$AUTOHEADER
+
+test -f thisfile.h.in
diff --git a/t/autohdr3.sh b/t/autohdr3.sh
new file mode 100755
index 000000000..ad5513059
--- /dev/null
+++ b/t/autohdr3.sh
@@ -0,0 +1,53 @@
+#!/bin/sh
+# Copyright (C) 2003-2012 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/>.
+
+# Check rebuild rules for autoheader.
+
+. ./defs || Exit 1
+
+cat >>configure.ac <<EOF
+m4_include([foo.m4])
+AC_CONFIG_HEADERS([config.h:config.hin])
+AC_OUTPUT
+EOF
+
+: > foo.m4
+
+cat > Makefile.am <<'END'
+.PHONY: test
+check-local: test
+test: all
+ cat $(srcdir)/config.hin ;: For debugging.
+ cat config.h ;: Likewise.
+ grep '#.*GREPME' $(srcdir)/config.hin
+ grep '#.*define.*GREPME' config.h
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOHEADER
+$AUTOMAKE
+
+./configure
+$MAKE
+
+$sleep
+echo 'AC_DEFINE([GREPME], 1, [Doc for GREPME])' > foo.m4
+
+$MAKE test
+$MAKE distcheck
+
+:
diff --git a/t/autohdr4.sh b/t/autohdr4.sh
new file mode 100755
index 000000000..9acbab135
--- /dev/null
+++ b/t/autohdr4.sh
@@ -0,0 +1,82 @@
+#!/bin/sh
+# Copyright (C) 2003-2012 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/>.
+
+# Check rebuild rules for AC_CONFIG_HEADERS.
+# (This should also work without GNU Make.)
+
+required=cc
+. ./defs || Exit 1
+
+cat >>configure.ac <<'EOF'
+AC_PROG_CC
+AC_SUBST([BOT], [bot])
+AC_CONFIG_HEADERS([defs.h config.h:sub1/config.top:sub2/config.${BOT}],,
+ [BOT=$BOT])
+AC_CONFIG_FILES([sub3/Makefile])
+AC_OUTPUT
+EOF
+
+mkdir sub1 sub2 sub3
+
+: > sub1/config.top
+echo '#define NAME "grepme1"' >sub2/config.bot
+
+cat > Makefile.am <<'END'
+SUBDIRS = sub3
+.PHONY: test-prog-updated
+test-prog-updated:
+ stat older sub3/run$(EXEEXT) || : For debugging.
+ test `ls -t older sub3/run$(EXEEXT) | sed 1q` = sub3/run$(EXEEXT)
+END
+
+cat > sub3/Makefile.am <<'END'
+noinst_PROGRAMS = run
+END
+
+cat >sub3/run.c <<'EOF'
+#include <defs.h>
+#include <config.h>
+#include <stdio.h>
+
+int main (void)
+{
+ puts (NAME); /* from config.h */
+ puts (PACKAGE); /* from defs.h */
+}
+EOF
+
+
+$ACLOCAL
+$AUTOCONF
+$AUTOHEADER
+$AUTOMAKE
+
+# Do not reject slow dependency extractors: we need dependency tracking.
+./configure --enable-dependency-tracking
+$MAKE
+# Sanity check.
+cross_compiling || { sub3/run | grep grepme1; }
+
+: > older
+$sleep
+echo '#define NAME "grepme2"' > sub2/config.bot
+$MAKE
+cross_compiling || { sub3/run | grep grepme2; }
+$MAKE test-prog-updated
+
+$MAKE distcheck
+
+:
diff --git a/t/autohdrdry.sh b/t/autohdrdry.sh
new file mode 100755
index 000000000..9df36f1e4
--- /dev/null
+++ b/t/autohdrdry.sh
@@ -0,0 +1,42 @@
+#!/bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Removal recovery rules for AC_CONFIG_HEADERS should not remove files
+# with 'make -n'.
+
+. ./defs || Exit 1
+
+cat >>configure.ac <<'EOF'
+AC_CONFIG_HEADERS([config.h])
+AC_OUTPUT
+EOF
+
+: >Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOHEADER
+$AUTOMAKE
+
+./configure
+$MAKE
+
+rm -f config.h
+$MAKE -n
+test -f stamp-h1
+test ! -f config.h
+
+:
diff --git a/t/automake-cmdline.tap b/t/automake-cmdline.tap
new file mode 100755
index 000000000..72c559a4b
--- /dev/null
+++ b/t/automake-cmdline.tap
@@ -0,0 +1,63 @@
+#! /bin/sh
+# Copyright (C) 2004-2012 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/>.
+
+# Test Automake's command-line options.
+
+. ./defs || Exit 1
+
+plan_ 17
+
+# Usage: bad_cmdline DESCRIPTION REGEX-FOR-STDERR [ARGS-FOR-AUTOMAKE...]
+do_check ()
+{
+ test $# -ge 3 || fatal_ "do_check: invalid usage"
+ desc=$1; shift
+ regex=$1; shift
+ AUTOMAKE_fails -d "$desc (run)" -- "$@"
+ command_ok_ "$desc (stderr)" grep "$regex" stderr
+}
+
+do_check 'invalid long option' 'unrecognized option.*--voo' --voo
+
+# Older perl has a buggy Getopt::Long which makes this fail.
+if $PERL -e 'require 5.8.2;'; then
+ do_check "list of options terminated by '--'" \
+ 'input file.*--voo' -- --voo
+else
+ skip_row_ 2 -r "older perl with buggy Getopt::Long"
+fi
+
+do_check "empty argument" \
+ 'empty argument' ''
+
+do_check "missing argument for long option" \
+ 'option.*-W.*requires an argument' -W
+
+do_check "missing argument for short option" \
+ 'option.*--warnings.*requires an argument' --warnings
+
+do_check "'--help' as option argument" \
+ 'unknown warning.*--help' --warnings --help
+
+do_check "'--help' as option argument" \
+ 'unknown warning.*--help' --warnings --help
+
+do_check "ambiguous incomplete option" \
+ 'unrecognized option.*--ver' --ver
+
+command_ok_ "unambiguous incomplete long option" $AUTOMAKE --vers
+
+:
diff --git a/t/auxdir-autodetect.sh b/t/auxdir-autodetect.sh
new file mode 100755
index 000000000..790d1b152
--- /dev/null
+++ b/t/auxdir-autodetect.sh
@@ -0,0 +1,130 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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 that, if AC_CONFIG_AUX_DIR is not specified, Automake tries
+# to use '.', '..' and '../..', in precisely that order.
+
+. ./defs || Exit 1
+
+nil=__no_such_program
+
+unset NONESUCH || :
+
+cat >>configure.ac << END
+AM_MISSING_PROG([NONESUCH],[$nil])
+AC_OUTPUT
+END
+
+mkdir d3
+mkdir d3/d2
+mkdir d3/d2/d1
+mkdir d3/d2/d1/d0
+
+echo 'echo %%d3%% $*' > d3/missing
+chmod +x d3/missing
+echo 'echo %%d2%% $*' > d3/d2/missing
+chmod +x d3/d2/missing
+echo 'echo %%d1%% $*' > d3/d2/d1/missing
+chmod +x d3/d2/d1/missing
+echo 'echo %%d0%% $*' > d3/d2/d1/d0/missing
+chmod +x d3/d2/d1/d0/missing
+
+mv configure.ac d3/d2/d1/d0/
+
+cd d3/d2/d1/d0
+
+cat > Makefile.am << 'EOF'
+.PHONY: test
+test:
+ $(NONESUCH) >$(out)
+EOF
+
+$ACLOCAL
+$AUTOCONF
+
+# ------------------------------------------- #
+: We must end up with AC_CONFIG_AUX_DIR = . #
+# ------------------------------------------- #
+
+: > install-sh
+$AUTOMAKE
+./configure
+out=out0 $MAKE test
+cat out0
+grep "%%d0%%.*$nil" out0
+grep '%%d[123]' out0 && Exit 1
+
+rm -f missing install-sh
+
+# -------------------------------------------- #
+: We must end up with AC_CONFIG_AUX_DIR = .. #
+# -------------------------------------------- #
+
+# Automake finds 'install-sh' in '.', so it assumes that auxdir is '.';
+# but it won't find 'missing' in '.', so it will fail.
+: > install-sh
+AUTOMAKE_fails
+grep 'required file.*[^.]\./missing.*not found' stderr
+rm -f install-sh
+
+# Now things should work.
+: > ../install-sh
+$AUTOMAKE
+./configure
+out=out1 $MAKE test
+cat out1
+grep "%%d1%%.*$nil" out1
+grep '%%d[023]' out1 && Exit 1
+
+rm -f ../missing ../install-sh
+
+# ----------------------------------------------- #
+: We must end up with AC_CONFIG_AUX_DIR = ../.. #
+# ----------------------------------------------- #
+
+# Automake finds 'install-sh' in '.', so it assumes that auxdir is '.';
+# but it won't find 'missing' in '.', so it will fail.
+: > install-sh
+AUTOMAKE_fails
+grep 'required file.*[^.]\./missing.*not found' stderr
+rm -f install-sh
+
+# Automake finds 'install-sh' in '..', so it assumes that auxdir is '..';
+# but it won't find 'missing' in '.', so it will fail.
+: > ../install-sh
+AUTOMAKE_fails
+grep 'required file.*[^.]\.\./missing.*not found' stderr
+rm -f ../install-sh
+
+# Now things should work.
+: > ../../install-sh
+$AUTOMAKE
+./configure
+out=out2 $MAKE test
+cat out2
+grep "%%d2%%.*$nil" out2
+grep '%%d[013]' out2 && Exit 1
+
+rm -f ../../missing ../../install-sh
+
+# --------------------------------------------------------- #
+: AC_CONFIG_AUX_DIR will not be found: automake must fail #
+# --------------------------------------------------------- #
+
+AUTOMAKE_fails
+grep 'required file.*missing.*not found' stderr
+
+:
diff --git a/t/auxdir-computed.tap b/t/auxdir-computed.tap
new file mode 100755
index 000000000..487958df7
--- /dev/null
+++ b/t/auxdir-computed.tap
@@ -0,0 +1,39 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# It should be possible to use a computed auxdir. This might seem
+# bizarre, but it is actually used in multilib builds.
+
+. ./defs || Exit 1
+
+plan_ 3
+
+cat > configure.ac <<END
+AC_INIT([$me], [1.0])
+AC_CONFIG_AUX_DIR([\$foo])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([Makefile])
+END
+
+: > Makefile.am
+
+command_ok_ "aclocal" $ACLOCAL
+# Both these two invocations are meant.
+# They exercise both code paths concerning auxiliary files.
+command_ok_ "automake -a" -D TODO -r "long-standing limitation" $AUTOMAKE -a
+command_ok_ "automake" -D TODO -r "long-standing limitation" $AUTOMAKE
+
+:
diff --git a/t/auxdir-misplaced.sh b/t/auxdir-misplaced.sh
new file mode 100755
index 000000000..33f5db061
--- /dev/null
+++ b/t/auxdir-misplaced.sh
@@ -0,0 +1,31 @@
+#! /bin/sh
+# Copyright (C) 2004-2012 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/>.
+
+# Test to make sure we diagnose misplaced AC_CONFIG_AUX_DIR.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_CONFIG_AUX_DIR([.]) dnl this will appear after AM_INIT_AUTOMAKE
+END
+
+: > Makefile.am
+
+$ACLOCAL
+AUTOMAKE_fails
+grep 'AC_CONFIG_AUX_DIR.*AM_INIT_AUTOMAKE' stderr
+
+:
diff --git a/t/auxdir-nonexistent.sh b/t/auxdir-nonexistent.sh
new file mode 100755
index 000000000..5575b284d
--- /dev/null
+++ b/t/auxdir-nonexistent.sh
@@ -0,0 +1,34 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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 we diagnose non-existent AC_CONFIG_AUX_DIR names.
+
+. ./defs || Exit 1
+
+cat > configure.ac <<END
+AC_INIT([$me], [1.0])
+AC_CONFIG_AUX_DIR([nonesuch])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([Makefile])
+END
+
+: > Makefile.am
+
+$ACLOCAL
+AUTOMAKE_fails
+grep '^configure\.ac:2:.*nonesuch.* not exist' stderr
+
+:
diff --git a/t/auxdir-unportable.tap b/t/auxdir-unportable.tap
new file mode 100755
index 000000000..d04b38c89
--- /dev/null
+++ b/t/auxdir-unportable.tap
@@ -0,0 +1,51 @@
+#! /bin/sh
+# Copyright (C) 2004-2012 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 we diagnose unportable AC_CONFIG_AUX_DIR names.
+
+. ./defs || Exit 1
+
+plan_ 4
+
+cat >configure.ac <<END
+AC_INIT([$me], [1.0])
+AC_CONFIG_AUX_DIR([aux])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([Makefile])
+END
+
+: > Makefile.am
+
+am_warn_unportable_auxdir ()
+{
+ details=$1
+ AUTOMAKE_fails
+ command_ok_ \
+ "warn about $details unportable auxdir name" \
+ grep '^configure\.ac:2:.*aux.*W32' stderr
+}
+
+$ACLOCAL || fatal_ "aclocal failed"
+
+am_warn_unportable_auxdir "non-existent"
+
+if mkdir aux; then
+ am_warn_unportable_auxdir "existent"
+else
+ skip_row_ 2 -r "cannot create directory named 'aux'"
+fi
+
+:
diff --git a/t/auxdir.sh b/t/auxdir.sh
new file mode 100755
index 000000000..c4860f4d2
--- /dev/null
+++ b/t/auxdir.sh
@@ -0,0 +1,42 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test to make sure AC_CONFIG_AUX_DIR works correctly.
+
+. ./defs || Exit 1
+
+# The "./." is here so we don't have to mess with subdirs.
+cat > configure.ac <<END
+AC_INIT([$me], [1.0])
+AC_CONFIG_AUX_DIR([./.])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([Makefile])
+END
+
+cat > Makefile.am << 'END'
+pkgdata_DATA =
+END
+
+cp "$am_scriptdir/mkinstalldirs" .
+
+# The "././" prefix confuses Automake into thinking it is doing a
+# subdir build. Yes, this is hacky.
+$ACLOCAL
+$AUTOMAKE ././Makefile
+
+grep '/\./\./mkinstalldirs' Makefile.in
+
+:
diff --git a/t/auxdir6.sh b/t/auxdir6.sh
new file mode 100755
index 000000000..08de2415a
--- /dev/null
+++ b/t/auxdir6.sh
@@ -0,0 +1,50 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Test to make sure AC_CONFIG_AUX_DIR works correctly.
+# This test calls AC_CONFIG_AUX_DIR with an explicit literal argument,
+# thus explicitly making the directory named by that argument the
+# config auxdir.
+# Keep this in sync with sister tests auxdir7.test and auxdir8.test.
+
+. ./defs || Exit 1
+
+cat > configure.ac <<END
+AC_INIT([$me], [1.0])
+AC_CONFIG_AUX_DIR([auxdir])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([Makefile subdir/Makefile])
+END
+
+mkdir subdir auxdir
+
+cat > Makefile.am << 'END'
+pkgdata_DATA =
+END
+
+cp Makefile.am subdir/Makefile.am
+
+: > auxdir/mkinstalldirs
+: > auxdir/install-sh
+: > auxdir/missing
+
+$ACLOCAL
+$AUTOMAKE
+
+$FGREP '$(top_srcdir)/auxdir/mkinstalldirs' Makefile.in
+$FGREP '$(top_srcdir)/auxdir/mkinstalldirs' subdir/Makefile.in
+
+:
diff --git a/t/auxdir7.sh b/t/auxdir7.sh
new file mode 100755
index 000000000..9a32bcbb8
--- /dev/null
+++ b/t/auxdir7.sh
@@ -0,0 +1,47 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Test to make sure AC_CONFIG_AUX_DIR works correctly.
+# This test calls AC_CONFIG_AUX_DIR with a '.' argument, thus explicitly
+# making the top-level directory the config auxdir.
+# Keep this in sync with sister tests auxdir6.test and auxdir8.test.
+
+. ./defs || Exit 1
+
+cat > configure.ac <<END
+AC_INIT([$me], [1.0])
+AC_CONFIG_AUX_DIR([.])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([Makefile subdir/Makefile])
+END
+
+mkdir subdir
+
+cat > Makefile.am << 'END'
+pkgdata_DATA =
+END
+
+cp Makefile.am subdir/Makefile.am
+
+: > mkinstalldirs
+
+$ACLOCAL
+$AUTOMAKE
+
+$FGREP '$(top_srcdir)/mkinstalldirs' Makefile.in
+$FGREP '$(top_srcdir)/mkinstalldirs' subdir/Makefile.in
+
+:
diff --git a/t/auxdir8.sh b/t/auxdir8.sh
new file mode 100755
index 000000000..4dd083549
--- /dev/null
+++ b/t/auxdir8.sh
@@ -0,0 +1,46 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test to make sure AC_CONFIG_AUX_DIR works correctly.
+# This test tries without an explicit call to AC_CONFIG_AUX_DIR;
+# the config auxdir should be implicitly defined to '.' since
+# the install-sh, mkinstalldirs, etc., scripts are in the top-level
+# directory.
+# Keep this in sync with sister tests auxdir6.test and auxdir7.test.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_CONFIG_FILES([subdir/Makefile])
+END
+
+mkdir subdir
+
+cat > Makefile.am << 'END'
+pkgdata_DATA =
+END
+
+cp Makefile.am subdir/Makefile.am
+
+: > mkinstalldirs
+
+$ACLOCAL
+$AUTOMAKE
+
+$FGREP '$(top_srcdir)/mkinstalldirs' Makefile.in
+$FGREP '$(top_srcdir)/mkinstalldirs' subdir/Makefile.in
+
+:
diff --git a/t/ax/depcomp.sh b/t/ax/depcomp.sh
new file mode 100644
index 000000000..a9180e937
--- /dev/null
+++ b/t/ax/depcomp.sh
@@ -0,0 +1,420 @@
+#! /bin/sh
+# Copyright (C) 2012 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/>.
+
+# Check dependency tracking in various flavours.
+# Contains both libtool and non-libtool case.
+# Sourced by the various (autogenerated) 'depcomp*.tap' tests.
+# Examples of reported failures that motivated those test are
+# listed below.
+
+# -------------------------------------------------------------------------
+
+# <http://lists.gnu.org/archive/html/automake-patches/2011-04/msg00028.html>
+#
+# Here's the bug: makedepend will prefix VPATH to the object file name,
+# thus the second make will invoke depcomp with object='../../src/foo.o',
+# causing errors such as:
+#
+# touch: cannot touch '../../src/.deps/foo.TPo': No such file or directory
+# makedepend: error: cannot open "../../src/.deps/foo.TPo"
+# ../../depcomp: line 560: ../../src/.deps/foo.TPo: No such file or directory
+
+# -------------------------------------------------------------------------
+
+# <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=8473>
+# <http://lists.gnu.org/archive/html/automake-patches/2011-04/msg00079.html>
+#
+# Here's the bug: hp depmode will prefix VPATH to the object file name,
+# thus the second gmake will invoke depcomp with object='../../src/foo.o',
+# causing errors such as (broken on multiple lines for clarity):
+#
+# cpp: "", line 0: error 4066: Cannot create
+# "../../gllib/.deps/nonblocking.TPo" file for
+# "-M../../gllib/.deps/nonblocking.TPo" option.
+# (No such file or directory[errno=2])
+#
+
+# -------------------------------------------------------------------------
+
+# <http://lists.gnu.org/archive/html/automake-patches/2011-04/msg00140.html>
+# <http://lists.gnu.org/archive/html/automake-patches/2011-05/msg00019.html>
+#
+# A partial failure of an earlier version of this test; some bad
+# post-processing of the '*.Po' files led to the following broken
+# contents of 'src/sub/.deps/subfoo.Po':
+#
+# > sub/subfoo.o: ../../depmod-data.dir/src/sub/subfoo.c \
+# > ../../depmod-data.dir/src/foo.h
+# > ../../depmod-data.dir/src/sub/subfoo.c \:
+# > ../../depmod-data.dir/src/foo.h:
+#
+# which caused make to die with an error like:
+#
+# "sub/.deps/subfoo.Po:3: *** missing separator. Stop."
+
+# -------------------------------------------------------------------------
+
+# This expects ./defs has already been included has already been included..
+
+ocwd=`pwd` || fatal_ "cannot get current working directory"
+longpath=this-is/a-path/which-has/quite-a/definitely/truly/long_long_name
+cachevar=am_cv_CC_dependencies_compiler_type
+
+srctree=depmod-1.0
+mkdir $srctree
+cd $srctree
+
+cd_top ()
+{
+ cd "$ocwd" || fatal_ "cannot chdir back to top directory"
+}
+
+delete ()
+{
+ test -f "$1" || fatal_ "$1: file does not exist"
+ rm -f "$1" || fatal_ "$1: couldn't remove"
+}
+
+edit ()
+{
+ file=$1; shift
+ sed "$@" <"$file" > t && mv -f t "$file" \
+ || fatal_ "$file: editing of file failed"
+}
+
+rewrite ()
+{
+ file=$1; shift
+ "$@" > "$file" || fatal_ "$file: couldn't rewrite"
+}
+
+setup_srcdir ()
+{
+ srcdir=$1 # This is intended to be global.
+ mkdir -p "$srcdir" \
+ || fatal_ "couldn't create source directory '$srcdir'"
+ cp -pR "$ocwd/$srctree"/* "$srcdir"/ \
+ || fatal_ "couldn't populate source directory '$srcdir'"
+}
+
+
+check_no_depfiles ()
+{
+ find . -name '*.Plo' -o -name '*.Po' | grep . && return 1
+ return 0
+}
+
+check_distclean ()
+{
+ # "make distcleancheck" can only run from a VPATH build.
+ if test $vpath = no; then
+ make_ok distclean && check_no_depfiles
+ else
+ $MAKE distcleancheck
+ fi
+}
+
+cat > configure.ac <<END
+AC_INIT([$me], [1.0])
+AC_CONFIG_AUX_DIR([build-aux])
+AM_INIT_AUTOMAKE
+AC_PROG_CC
+AM_PROG_CC_C_O
+AM_PROG_AR
+`if test $depcomp_with_libtool = yes; then
+ echo AC_PROG_LIBTOOL
+else
+ echo AC_PROG_RANLIB
+fi`
+AC_CONFIG_FILES([Makefile src/Makefile])
+AC_OUTPUT
+END
+
+mkdir build-aux sub src src/sub2
+
+case $depcomp_with_libtool in
+ yes)
+ po=Plo objext=lo a=la
+ normalized_target=libfoo_la
+ # On platforms requiring that no undefined symbols exist in order
+ # to build shared libraries (e.g. Windows DLLs), you have to
+ # explicitly declare that the libtool library you are building
+ # does not actually have any undefined symbols, for libtool to
+ # even try to build it as a shared library. Without that
+ # explicit declaration, libtool falls back to a static library
+ # only, regardless of any --enable-shared flags etc.
+ LIBPRIMARY=LTLIBRARIES LINKADD=LIBADD NOUNDEF=-no-undefined
+ libbaz_ldflags="libbaz_${a}_LDFLAGS = $NOUNDEF"
+ echo lib_LTLIBRARIES = libfoo.la >> Makefile.am
+ make_ok ()
+ {
+ $MAKE ${1+"$@"} >output 2>&1 || { cat output; return 1; }
+ cat output
+ $FGREP 'unknown directive' output && return 1
+ rm -f output
+ # Checks for stray files possibly left around by less common
+ # depmodes.
+ find . -name '*.[ud]' | grep . && return 1
+ return 0
+ }
+ ;;
+ no)
+ po=Po objext='$(OBJEXT)' a=a
+ normalized_target=foo
+ LIBPRIMARY=LIBRARIES LINKADD=LDADD NOUNDEF=
+ libbaz_ldflags=
+ echo bin_PROGRAMS = foo >> Makefile.am
+ make_ok ()
+ {
+ $MAKE ${1+"$@"}
+ }
+ ;;
+ *)
+ fatal_ "invalid value '$depcomp_with_libtool' for variable" \
+ "\$depcomp_with_libtool"
+ ;;
+esac
+
+cat >> Makefile.am <<END
+SUBDIRS = src
+# We include subfoo only to be sure that the munging in depcomp
+# doesn't remove too much from the object file name.
+${normalized_target}_SOURCES = foo.c sub/subfoo.c foo.h sub/subfoo.h
+${normalized_target}_LDFLAGS = $NOUNDEF
+${normalized_target}_${LINKADD} = src/libbaz.$a
+
+.PHONY: grep-test
+grep-test:
+## For debugging.
+ cat \$(DEPDIR)/foo.$po || :
+ cat \$(DEPDIR)/subfoo.$po || :
+ cat src/\$(DEPDIR)/baz.$po || :
+ cat src/sub2/\$(DEPDIR)/sub2foo.$po || :
+## Checks done here.
+ grep '^foo.$objext.*:' \$(DEPDIR)/foo.$po
+ grep '^subfoo\.$objext.*:' \$(DEPDIR)/subfoo.$po
+ grep '^baz\.$objext.*:' src/\$(DEPDIR)/baz.$po
+ grep '^sub2/sub2foo\.$objext.*:' src/sub2/\$(DEPDIR)/sub2foo.$po
+END
+
+cat > src/Makefile.am <<END
+AUTOMAKE_OPTIONS = subdir-objects
+noinst_${LIBPRIMARY} = libbaz.$a
+# We include sub2foo only to be sure that the munging in depcomp
+# doesn't remove too much from the object file name.
+libbaz_${a}_SOURCES = baz.c sub2/sub2foo.c baz.h sub2/sub2foo.h
+$libbaz_ldflags
+END
+
+cat > foo.c <<'END'
+#include "foo.h"
+#include "src/baz.h"
+#include <stdlib.h>
+int main (void)
+{
+ printf ("foo bar\n");
+ exit (EXIT_SUCCESS + subfoo () + baz ());
+}
+END
+
+cat > foo.h <<'END'
+#include <stdio.h>
+#include "sub/subfoo.h"
+END
+
+cat > sub/subfoo.c <<'END'
+#include "sub/subfoo.h"
+int subfoo (void) { return 0; }
+END
+
+echo '/* empty */' > src/sub2/sub2foo.h
+
+cat > sub/subfoo.h <<'END'
+#include <stdio.h>
+extern int subfoo (void);
+END
+
+cat > src/baz.c <<'END'
+#include "baz.h"
+int baz (void) { return 0; }
+END
+
+cat > src/baz.h <<'END'
+extern int baz (void);
+END
+
+cat > src/sub2/sub2foo.c <<'END'
+#include "sub2foo.h"
+int sub2foo (void) { return 0; }
+END
+
+test $depcomp_with_libtool = no || libtoolize \
+ || fatal_ "libtoolize failed"
+$ACLOCAL && $AUTOCONF && $AUTOMAKE -a \
+ || fatal_ "autotools failed"
+test -f build-aux/depcomp \
+ || fatal_ "depcomp script not installed"
+
+# To offer extra coverage for the depmodes (like "aix" of "hp2") where the
+# name of the compiler-generated depfiles can depend on whether libtool is
+# in use *and* on which kind of libraries libtool is building (static,
+# shared, or both), we would like to run the libtool-oriented tests thrice:
+# once after having run configure with the '--disable-shared' option, once
+# after having run it with the '--enable-shared' options, and once by
+# leaving it to configure to automatically select which kind of library (or
+# libraries) to build.
+#
+# But doing such three-fold checks unconditionally for all the depmodes
+# would slow down the already too slow libtool tests unacceptably (up to a
+# 150-200% factor), with no real gain in coverage for most of the depmodes.
+# So, since the depmodes that would benefit from the extra tests are never
+# forced to configure in out tests below, but can only be automatically
+# selected by '--enable-dependency-tracking', we make this threefold check
+# only in this later case.
+
+if test $depmode,$depcomp_with_libtool = auto,yes; then
+ do_all_tests ()
+ {
+ do_test default
+ do_test noshared --disable-shared
+ do_test nostatic --disable-static
+ }
+else
+ do_all_tests () { do_test; }
+fi
+
+case $depmode in
+ auto)
+ displayed_depmode='..*' # At least one character long.
+ cfg_deptrack=--enable-dependency-tracking ;;
+ disabled)
+ displayed_depmode=none
+ cfg_deptrack=--disable-dependency-tracking ;;
+ *)
+ displayed_depmode="(cached) $depmode"
+ cfg_deptrack="$cachevar=$depmode"
+ # Sanity check: ensure the cache variable we force is truly
+ # used by configure.
+ $FGREP $cachevar configure \
+ || fatal_ "configure lacks required cache variable '$cachevar'";;
+esac
+
+cd_top
+
+do_test ()
+{
+ cd_top
+ if test $vpath = no; then
+ pfx="in-tree build"
+ else
+ pfx="$vpath VPATH"
+ fi
+ if test $# -gt 0; then
+ subdir=$1; shift
+ pfx="$pfx, $subdir"
+ test -d $subdir || mkdir $subdir || fatal_ "creating directory $subdir"
+ cd $subdir
+ fi
+ pfx="[$pfx]"
+ case $vpath in
+ simple)
+ mkdir -p vpath-simple/build
+ cd vpath-simple/build
+ setup_srcdir ..
+ ;;
+ long)
+ mkdir -p vpath-long/src vpath-long/wrk
+ cd vpath-long/wrk
+ setup_srcdir ../src/$longpath
+ ;;
+ absolute)
+ mkdir -p vpath-abs/build
+ cd vpath-abs/build
+ absdir="`(cd .. && pwd)`" || fatal_ "getting absolute directory"
+ setup_srcdir "$absdir/vpath-abs"
+ unset absdir
+ ;;
+ no)
+ mkdir intree
+ cd intree
+ setup_srcdir .
+ ;;
+ *)
+ fatal_ "invalid value '$vpath' for variable \$vpath"
+ ;;
+ esac
+
+ command_ok_ \
+ "$pfx configure" \
+ "$srcdir/configure" $cfg_deptrack ${1+"$@"} >stdout
+ cat stdout
+
+ command_ok_ \
+ "$pfx right depmode selected" \
+ grep "^checking dependency style .*\.\.\. $displayed_depmode$" stdout
+ rm -f stdout
+
+ command_ok_ "$pfx simple make" make_ok
+ # Some bugs in VPATH builds only kick in during a rebuild.
+ command_ok_ "$pfx clean & rebuild" eval '$MAKE clean && make_ok'
+
+ if test $depmode = disabled; then
+ command_ok_ "$pfx no dependency files generated" check_no_depfiles
+ r=ok \
+ && grep "[ $tab]depmode=none" Makefile \
+ && rewrite "$srcdir"/src/sub2/sub2foo.h echo 'choke me' \
+ && delete "$srcdir"/sub/subfoo.h \
+ && make_ok \
+ || r='not ok'
+ result_ "$r" "$pfx dependency tracking is truly disabled"
+ elif grep "[ $tab]depmode=none" Makefile; then
+ skip_row_ 2 -r "automatic dependency tracking couldn't be activated"
+ else
+ command_ok_ "$pfx generated $po files look correct" $MAKE grep-test
+ r=ok \
+ && : "Some checks in the subdir." \
+ && $sleep \
+ && : "Ensure rebuild rules really kick in." \
+ && rewrite "$srcdir"/src/sub2/sub2foo.h echo 'choke me' \
+ && cd src \
+ && not $MAKE \
+ && cd .. \
+ && : "Ensure the deleted header bug is fixed." \
+ && delete "$srcdir"/src/sub2/sub2foo.h \
+ && edit "$srcdir"/src/sub2/sub2foo.c -e 1d \
+ && cd src \
+ && make_ok \
+ && : "Now do similar checks for the parent directory." \
+ && cd .. \
+ && rewrite "$srcdir"/sub/subfoo.h echo 'choke me' \
+ && not $MAKE \
+ && delete "$srcdir"/sub/subfoo.h \
+ && edit "$srcdir"/sub/subfoo.c -e 1d \
+ && edit "$srcdir"/foo.h -e 2d \
+ && make_ok \
+ || r='not ok'
+ result_ "$r" "$pfx dependency tracking works"
+ fi
+
+ command_ok_ "$pfx make distclean" check_distclean
+ cd_top
+}
+
+for vpath in no simple long absolute; do
+ do_all_tests
+done
+
+:
diff --git a/t/ax/distcheck-hook-m4.am b/t/ax/distcheck-hook-m4.am
new file mode 100644
index 000000000..5d36102c6
--- /dev/null
+++ b/t/ax/distcheck-hook-m4.am
@@ -0,0 +1,30 @@
+## Data files for some tests. Not used in the automake build system.
+##
+## Copyright (C) 2011-2012 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/>.
+
+distcheck-hook:
+ @fatal () { echo "$@: $$*" >&2; exit 1; }; \
+ $(am__cd) $(distdir) && chmod u+w . && mkdir _m4 \
+ || fatal "cannot setup distdir"; \
+ $(ACLOCAL) -I _m4 $(ACLOCAL_AMFLAGS) --install --output=_am.m4 \
+ || fatal "cannot regenerate aclocal.m4"; \
+ lst=`ls _m4 | tr '\012\015' ' '`; \
+ if test -n "$$lst"; then \
+ fatal "required m4 files not distributed or outdated: $$lst"; \
+ fi; \
+ $(AUTOCONF) -o /dev/null || fatal "can't remake configure"; \
+ rm -rf _m4 _am.m4 autom4te.cache && chmod a-w . \
+ || fatal "cannot reset distdir"
diff --git a/t/ax/extract-testsuite-summary.pl b/t/ax/extract-testsuite-summary.pl
new file mode 100644
index 000000000..28a9c3560
--- /dev/null
+++ b/t/ax/extract-testsuite-summary.pl
@@ -0,0 +1,30 @@
+#! /usr/bin/env perl
+# Extract the testsuite summary generated by the parallel-tests harness
+# from the output of "make check".
+
+# Copyright (C) 2012 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/>.
+
+use warnings FATAL => 'all';
+use strict;
+
+my $br = '=' x 76;
+my @sections = ('');
+while (<>)
+ {
+ push @sections, $_, '' if /$br/;
+ $sections[-1] .= $_ if !/$br/;
+ }
+print @sections[1..$#sections-1];
diff --git a/t/ax/is b/t/ax/is
new file mode 100755
index 000000000..1e1c0ce48
--- /dev/null
+++ b/t/ax/is
@@ -0,0 +1,54 @@
+#! /bin/sh
+# Copyright (C) 2012 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/>.
+
+# Test that two whitespace-separated lists are equal.
+# Assumes the two lists are passed on the command line separated by
+# a '==' string.
+# This script is useful to test equality of lists in makefile rules,
+# in the face of variables defined through line-continuations,
+# automake rewrites and expansions of empty variables.
+
+set -e
+set -u
+
+# Initialize before unsetting, for shells (like older bash or Solaris
+# ksh) that fail to unset variables that are already unset.
+exp= got=; unset exp got
+seen_eqeq=no
+while test $# -gt 0; do
+ if test x"$1" = x"=="; then
+ if test $seen_eqeq = no; then
+ seen_eqeq=yes
+ else
+ echo "$0: more than one '==' argument seen on command line" >&2
+ exit 2
+ fi
+ else
+ if test $seen_eqeq = no; then
+ got=${got+"$got "}$1
+ else
+ exp=${exp+"$exp "}$1
+ fi
+ fi
+ shift
+done
+
+if test $seen_eqeq = no; then
+ echo "$0: no '==' argument seen on command line" >&2
+ exit 2
+fi
+
+test x"${exp-}" = x"${got-}"
diff --git a/t/ax/plain-functions.sh b/t/ax/plain-functions.sh
new file mode 100644
index 000000000..e6483dc0f
--- /dev/null
+++ b/t/ax/plain-functions.sh
@@ -0,0 +1,40 @@
+# -*- shell-script -*-
+#
+# Copyright (C) 2011-2012 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/>.
+
+# Helper functions used by "plain" tests of the Automake testsuite
+# (i.e., tests that don't use any test protocol).
+
+# Print warnings (e.g., about skipped and failed tests) to this file
+# number. Override by putting, say:
+# AM_TESTS_ENVIRONMENT = stderr_fileno_=9; export stderr_fileno_;
+# AM_TESTS_FD_REDIRECT = 9>&2
+# in your Makefile.am.
+# This is useful when using automake's parallel tests mode, to print the
+# reason for skip/failure to console, rather than to the *.log files.
+: ${stderr_fileno_=2}
+
+# Copied from Gnulib's 'tests/init.sh'.
+warn_ () { echo "$@" 1>&$stderr_fileno_; }
+fail_ () { warn_ "$me: failed test: $@"; Exit 1; }
+skip_ () { warn_ "$me: skipped test: $@"; Exit 77; }
+fatal_ () { warn_ "$me: hard error: $@"; Exit 99; }
+framework_failure_ () { warn_ "$me: set-up failure: $@"; Exit 99; }
+
+# For compatibility with TAP functions.
+skip_all_ () { skip_ "$@"; }
+
+:
diff --git a/t/ax/tap-functions.sh b/t/ax/tap-functions.sh
new file mode 100644
index 000000000..3a5db0309
--- /dev/null
+++ b/t/ax/tap-functions.sh
@@ -0,0 +1,239 @@
+# -*- shell-script -*-
+#
+# Copyright (C) 2011-2012 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/>.
+
+# Helper functions used by TAP-producing tests of the Automake testsuite.
+
+#
+# IMPORTANT: All the functions defined in this file can *not* be used
+# from within a subshell, unless explicitly noted otherwise.
+#
+
+# The counts of the TAP test results seen so far: total count and
+# per-result counts.
+tap_count_=0
+tap_pass_count_=0
+tap_skip_count_=0
+tap_fail_count_=0
+tap_xfail_count_=0
+tap_xpass_count_=0
+
+# The first "test -n" tries to avoid extra forks when possible.
+if test -n "${ZSH_VERSION}${BASH_VERSION}" \
+ || (eval 'test $((1 + 1)) = 2') >/dev/null 2>&1
+then
+ # Outer use of 'eval' needed to protect dumber shells from parsing
+ # errors.
+ eval 'incr_ () { eval "$1=\$((\${$1} + 1))"; }'
+else
+ incr_ () { eval "$1=\`expr \${$1} + 1\`"; }
+fi
+
+# not COMMAND [ARGS...]
+# ---------------------
+# Run the given command and invert its exit status.
+not ()
+{
+ if "$@"; then return 1; else return 0; fi
+}
+
+# plan_ [unknown|later|lazy|now|NUMBER-OF-PLANNED-TESTS]
+# ------------------------------------------------------
+# Print a TAP plan for the given number of tests. This must be called
+# before reporting any test result. If called with the special argument
+# "unknown" or "later", it will do nothing, expecting the calling script
+# to declare the plan later. If called with the special argument "lazy"
+# or "now", it will print a TAP plan that accounts for the number of tests
+# seen so far.
+plan_ ()
+{
+ if test $# -eq 0; then
+ bailout_ "plan_: missing argument"
+ elif test $# -ge 2; then
+ bailout_ "plan_: too many arguments"
+ elif test x"$planned_" != x"none" && test x"$planned_" != x"later"; then
+ bailout_ "plan_: called to many times"
+ elif test x"$1" = x"unknown" || test x"$1" = x"later"; then
+ # This means we want to get back later to declaring the TAP plan.
+ planned_=later
+ return 0
+ elif test x"$1" = x"lazy" || test x"$1" = x"now"; then
+ planned_=$tap_count_ # Number of test results seen so far.
+ elif test $1 -ge 0; then
+ planned_=$1
+ else
+ bailout_ "plan_: invalid argument '$1'"
+ fi
+ echo "1..$planned_"
+}
+planned_=none
+
+# diag_ [EXPLANATION]
+# ------------------
+# Report the given text as TAP diagnostic. Assumes the string denoting
+# TAP diagnostic lines is stored in the '$diag_string_' variable; this is
+# done to allow better interplay with TAP drivers that allow such a string
+# to be configured.
+diag_ ()
+{
+ test $# -eq 0 || echo "$diag_string_ $*"
+}
+
+# Used by the 'diag_' function above. User-overridable.
+diag_string_="#"
+
+# warn_ [EXPLANATION]
+# ------------------
+# Give a warning (using TAP diagnostic).
+warn_ ()
+{
+ case $# in
+ 0) diag_ "WARNING: (unknown warning)";;
+ *) diag_ "WARNING: $*";;
+ esac
+}
+
+# result_ RESULT [-D DIRECTIVE] [-r REASON] [--] [DESCRIPTION...]
+# ---------------------------------------------------------------
+# Report a test case with the given RESULT (valid values are "ok" and
+# "not ok") and the given DESCRIPTION (if any). If DIRECTIVE is given
+# and non-empty (valid values being "TODO" and "SKIP"), it will be
+# reported too, with the REASON (if given) appended.
+result_ ()
+{
+ set +x # Don't pollute the log files.
+ test $# -gt 0 || bailout_ "result_: missing argument"
+ tap_result_=$1; shift
+ case $tap_result_ in
+ "ok"|"not ok") ;;
+ *) bailout_ "result_: invalid result '$tap_result'" ;;
+ esac
+ tap_directive_= tap_reason_=
+ while test $# -gt 0; do
+ case $1 in
+ -D|--directive) tap_directive_=$2; shift;;
+ -r|--reason) tap_reason_=$2; shift;;
+ --) shift; break;;
+ -*) bailout_ "result_: invalid option '$1'";;
+ *) break;;
+ esac
+ shift
+ done
+ case $tap_directive_ in
+ ""|TODO|SKIP) ;;
+ *) bailout_ "result_: invalid directive '$directive_'" ;;
+ esac
+ incr_ tap_count_
+ case $tap_result_,$tap_directive_ in
+ ok,) incr_ tap_pass_count_;; # Passed.
+ not\ ok,TODO) incr_ tap_xfail_count_;; # Expected failure.
+ not\ ok,*) incr_ tap_fail_count_ ;; # Failed.
+ ok,TODO) incr_ tap_xpass_count_ ;; # Unexpected pass.
+ ok,SKIP) incr_ tap_skip_count_ ;; # Skipped.
+ *) bailout_ "internal error in 'result_'";; # Can't happen.
+ esac
+ tap_text_="$tap_result_ $tap_count_"
+ if test x"$*" != x; then
+ tap_text_="$tap_text_ - $*"
+ fi
+ if test x"$tap_directive_" != x; then
+ tap_text_="$tap_text_ # $tap_directive_"${tap_reason_:+" $tap_reason_"}
+ fi
+ printf '%s\n' "$tap_text_"
+ set -x # Restore shell xtraces.
+}
+
+# Shorthands for common usages of 'result_'.
+ok_ () { result_ 'ok' ${1+"$@"}; }
+not_ok_ () { result_ 'not ok' ${1+"$@"}; }
+skip_ () { result_ 'ok' -D SKIP ${1+"$@"}; }
+
+# skip_row_ COUNT [-r REASON] [--] [DESCRIPTION...]
+# -------------------------------------------------
+# Report a COUNT of skipped test, with the given reason and descriptions
+# (if any). Useful to avoid cascade failures in case a fair number of
+# tests depend on an earlier one that failed.
+skip_row_ ()
+{
+ skip_count_=$1; shift
+ for i_ in `seq_ $skip_count_`; do skip_ ${1+"$@"}; done
+}
+
+# skip_all_ [REASON ...]
+# ----------------------
+# Skip all the tests in a test script. Must be used before calling 'plan_'
+# or reporting any test result. Can't be used from within a subshell.
+skip_all_ ()
+{
+ echo "1..0 # SKIP" ${1+"$@"}
+ planned_=0
+ Exit 0
+}
+
+# bailout_ [REASON ...]
+# ---------------------
+# Stop the execution of the current test suite right now, due to an
+# unrecoverable error. Can be called at any point, but cannot be used
+# from within a subshell.
+bailout_ ()
+{
+ echo 'Bail out!' ${1+"$@"}
+ Exit 99
+}
+
+# fatal_ [REASON ...]
+# -------------------
+# Same as 'bailout_'; for compatibility with 'plain-functions.sh'.
+fatal_ ()
+{
+ bailout_ ${1+"$@"}
+}
+
+# framework_failure_ [REASON ...]
+# -------------------------------
+# Stop the execution of the current test suite right now, due to an
+# unrecoverable error in the set-up of the test case. Can be called
+# at any point, but cannot be used from within a subshell.
+framework_failure_ ()
+{
+ bailout_ "set-up failure"${1+": $*"}
+}
+
+# command_ok_ TEST-DESCRIPTION [OPTIONS..] [--] CMD [ARGS...]
+# -----------------------------------------------------------
+# Helper subroutine for when a TAP result must be determined by the
+# outcome of a command.
+command_ok_ ()
+{
+ tap_directive_= tap_reason_=
+ test $# -gt 0 || bailout_ "command_ok_: missing argument"
+ tap_description_=$1; shift
+ while test $# -gt 0; do
+ case $1 in
+ -D|--directive) tap_directive_=$2; shift;;
+ -r|--reason) tap_reason_=$2; shift;;
+ --) shift; break;;
+ -*) bailout_ "command_ok_: invalid option '$1'";;
+ *) break;;
+ esac
+ shift
+ done
+ tap_result_="ok"; "$@" || tap_result_="not ok"
+ result_ "$tap_result_" -D "$tap_directive_" -r "$tap_reason_" \
+ -- "$tap_description_"
+}
+
+:
diff --git a/t/ax/tap-setup.sh b/t/ax/tap-setup.sh
new file mode 100644
index 000000000..ab155057a
--- /dev/null
+++ b/t/ax/tap-setup.sh
@@ -0,0 +1,47 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Auxiliary shell script that copies the common data and files used by
+# many tests on TAP support into the current directory. It should be
+# sourced by client test scripts, and assumes the auxiliary test
+# 'tap-common-setup.test' has been run beforehand (it will error out
+# if this is not the case).
+
+# Check that we are running from a proper directory: last thing we want
+# is to overwrite some random user files.
+test -f ../defs-static && test -f ../defs \
+ || fatal_ "running from a wrong directory"
+
+test ! -f Makefile.am || mv Makefile.am Makefile.am~ \
+ || fatal_ "failed to save Makefile.am"
+
+test -d ../tap-common-setup.dir && cp -fpR ../tap-common-setup.dir/* . \
+ || fatal_ "couldn't get precomputed data files"
+
+fetch_tap_driver
+
+if test -f Makefile.am~; then
+ mv -f Makefile.am~ Makefile.am \
+ || fatal_ "failed to restore Makefile.am"
+ echo 'TEST_LOG_DRIVER = $(PERL) $(srcdir)/tap-driver' >> Makefile.am \
+ || fatal_ "failed to update Makefile.am"
+ $AUTOMAKE Makefile \
+ || fatal_ "failed to remake Makefile.in"
+ ./config.status Makefile \
+ || fatal_ "failed to remake Makefile"
+fi
+
+:
diff --git a/t/ax/tap-summary-aux.sh b/t/ax/tap-summary-aux.sh
new file mode 100644
index 000000000..6965281bc
--- /dev/null
+++ b/t/ax/tap-summary-aux.sh
@@ -0,0 +1,359 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Auxiliary script for tests on TAP support: checking testsuite summary.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+br='============================================================================'
+
+case $use_colors in
+ yes|no) ;;
+ *) fatal_ "invalid \$use_colors value '$use_colors'"
+esac
+
+fetch_tap_driver
+
+cat > configure.ac <<END
+AC_INIT([GNU AutoTAP], [5.12], [bug-automake@gnu.org])
+AM_INIT_AUTOMAKE([parallel-tests])
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TEST_LOG_DRIVER = $(srcdir)/tap-driver
+TEST_LOG_COMPILER = cat
+TESTS = all.test
+END
+
+# The following shell variables are influential for this function:
+# - expect_failure
+# - use_colors
+do_check ()
+{
+ case $#,$1 in
+ 1,--pass) expect_failure=no;;
+ 1,--fail) expect_failure=yes;;
+ *) fatal_ "invalid usage of 'do_check'";;
+ esac
+ shift
+ cat > summary.exp
+ cat all.test
+ st=0
+ if test $use_colors = yes; then
+ make_cmd="env AM_COLOR_TESTS=always $MAKE -e"
+ else
+ make_cmd=$MAKE
+ fi
+ $make_cmd check > stdout || st=$?
+ cat stdout
+ if test $expect_failure = yes; then
+ test $st -gt 0 || Exit 1
+ else
+ test $st -eq 0 || Exit 1
+ fi
+ $PERL "$am_testauxdir"/extract-testsuite-summary.pl stdout >summary.got \
+ || fatal_ "cannot extract testsuite summary"
+ cat summary.exp
+ cat summary.got
+ if test $use_colors = yes; then
+ # Use cmp, not diff, because the files might contain binary data.
+ compare=cmp
+ else
+ compare=diff
+ fi
+ $compare summary.exp summary.got || Exit 1
+}
+
+if test $use_colors = yes; then
+ red=''
+ grn=''
+ lgn=''
+ blu=''
+ mgn=''
+ brg=''
+ std=''
+ echo AUTOMAKE_OPTIONS = color-tests >> Makefile.am
+else
+ red= grn= lgn= blu= mgn= brg= std=
+fi
+
+ success_header="\
+${grn}${br}${std}
+${grn}Testsuite summary for GNU AutoTAP 5.12${std}
+${grn}${br}${std}"
+
+ success_footer=${grn}${br}${std}
+
+ failure_header="\
+${red}${br}${std}
+${red}Testsuite summary for GNU AutoTAP 5.12${std}
+${red}${br}${std}"
+
+ failure_footer="\
+${red}${br}${std}
+${red}See ./test-suite.log${std}
+${red}Please report to bug-automake@gnu.org${std}
+${red}${br}${std}"
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+./configure
+
+# 1 pass.
+{ echo 1..1 && echo ok; } > all.test
+do_check --pass <<END
+$success_header
+${brg}# TOTAL: 1${std}
+${grn}# PASS: 1${std}
+# SKIP: 0
+# XFAIL: 0
+# FAIL: 0
+# XPASS: 0
+# ERROR: 0
+$success_footer
+END
+
+# 1 skip.
+{ echo 1..1 && echo 'ok # SKIP'; } > all.test
+do_check --pass <<END
+$success_header
+${brg}# TOTAL: 1${std}
+# PASS: 0
+${blu}# SKIP: 1${std}
+# XFAIL: 0
+# FAIL: 0
+# XPASS: 0
+# ERROR: 0
+$success_footer
+END
+
+# 1 xfail.
+{ echo 1..1 && echo 'not ok # TODO'; } > all.test
+do_check --pass <<END
+$success_header
+${brg}# TOTAL: 1${std}
+# PASS: 0
+# SKIP: 0
+${lgn}# XFAIL: 1${std}
+# FAIL: 0
+# XPASS: 0
+# ERROR: 0
+$success_footer
+END
+
+# 1 fail.
+{ echo 1..1 && echo not ok; } > all.test
+do_check --fail <<END
+$failure_header
+${brg}# TOTAL: 1${std}
+# PASS: 0
+# SKIP: 0
+# XFAIL: 0
+${red}# FAIL: 1${std}
+# XPASS: 0
+# ERROR: 0
+$failure_footer
+END
+
+# 1 xpass.
+{ echo 1..1 && echo 'ok # TODO'; } > all.test
+do_check --fail <<END
+$failure_header
+${brg}# TOTAL: 1${std}
+# PASS: 0
+# SKIP: 0
+# XFAIL: 0
+# FAIL: 0
+${red}# XPASS: 1${std}
+# ERROR: 0
+$failure_footer
+END
+
+# 1 hard error.
+{ echo 1..1 && echo 'Bail out!'; } > all.test
+do_check --fail <<END
+$failure_header
+${brg}# TOTAL: 1${std}
+# PASS: 0
+# SKIP: 0
+# XFAIL: 0
+# FAIL: 0
+# XPASS: 0
+${mgn}# ERROR: 1${std}
+$failure_footer
+END
+
+# 3 non-failing results.
+cat > all.test <<END
+1..3
+ok
+not ok # TODO
+ok # SKIP
+END
+do_check --pass <<END
+$success_header
+${brg}# TOTAL: 3${std}
+${grn}# PASS: 1${std}
+${blu}# SKIP: 1${std}
+${lgn}# XFAIL: 1${std}
+# FAIL: 0
+# XPASS: 0
+# ERROR: 0
+$success_footer
+END
+
+# 1 pass, 1 skip, 1 fail.
+cat > all.test <<END
+1..3
+ok
+ok # SKIP
+not ok
+END
+do_check --fail <<END
+$failure_header
+${brg}# TOTAL: 3${std}
+${grn}# PASS: 1${std}
+${blu}# SKIP: 1${std}
+# XFAIL: 0
+${red}# FAIL: 1${std}
+# XPASS: 0
+# ERROR: 0
+$failure_footer
+END
+
+# 1 pass, 1 xfail, 1 xpass.
+cat > all.test <<END
+1..3
+ok
+ok # TODO
+not ok # TODO
+END
+do_check --fail <<END
+$failure_header
+${brg}# TOTAL: 3${std}
+${grn}# PASS: 1${std}
+# SKIP: 0
+${lgn}# XFAIL: 1${std}
+# FAIL: 0
+${red}# XPASS: 1${std}
+# ERROR: 0
+$failure_footer
+END
+
+# 1 skip, 1 xfail, 1 error.
+cat > all.test <<END
+1..3
+ok # SKIP
+not ok # TODO
+Bail out!
+END
+do_check --fail <<END
+$failure_header
+${brg}# TOTAL: 3${std}
+# PASS: 0
+${blu}# SKIP: 1${std}
+${lgn}# XFAIL: 1${std}
+# FAIL: 0
+# XPASS: 0
+${mgn}# ERROR: 1${std}
+$failure_footer
+END
+
+# 1 of each kind
+cat > all.test <<END
+1..6
+ok
+not ok
+ok # TODO
+not ok # TODO
+ok # SKIP
+Bail out!
+END
+do_check --fail <<END
+$failure_header
+${brg}# TOTAL: 6${std}
+${grn}# PASS: 1${std}
+${blu}# SKIP: 1${std}
+${lgn}# XFAIL: 1${std}
+${red}# FAIL: 1${std}
+${red}# XPASS: 1${std}
+${mgn}# ERROR: 1${std}
+$failure_footer
+END
+
+# Prepare some common data for later.
+for i in 0 1 2 3 4 5 6 7 8 9; do
+ for j in 0 1 2 3 4 5 6 7 8 9; do
+ echo "ok"
+ echo "not ok # TODO"
+ echo "ok # SKIP"
+ done
+done > tap
+
+# Lots of non-failures (300 per kind).
+(cat tap && cat tap && cat tap) > all.test
+test `wc -l <all.test` -eq 900 || Exit 99 # Sanity check.
+echo 1..900 >> all.test # Test plan.
+do_check --pass <<END
+$success_header
+${brg}# TOTAL: 900${std}
+${grn}# PASS: 300${std}
+${blu}# SKIP: 300${std}
+${lgn}# XFAIL: 300${std}
+# FAIL: 0
+# XPASS: 0
+# ERROR: 0
+$success_footer
+END
+
+# 1 failure and lots of non-failures means failure.
+(cat tap && echo "not ok" && cat tap) > all.test
+test `wc -l <all.test` -eq 601 || Exit 99 # Sanity check.
+echo 1..601 >> all.test # Test plan.
+do_check --fail <<END
+$failure_header
+${brg}# TOTAL: 601${std}
+${grn}# PASS: 200${std}
+${blu}# SKIP: 200${std}
+${lgn}# XFAIL: 200${std}
+${red}# FAIL: 1${std}
+# XPASS: 0
+# ERROR: 0
+$failure_footer
+END
+
+# 1 error and lots of non-failures means failure.
+(cat tap && sed 30q tap && echo 'Bail out!') > all.test
+test `wc -l <all.test` -eq 331 || Exit 99 # Sanity check.
+echo 1..331 >> all.test # Test plan.
+do_check --fail <<END
+$failure_header
+${brg}# TOTAL: 331${std}
+${grn}# PASS: 110${std}
+${blu}# SKIP: 110${std}
+${lgn}# XFAIL: 110${std}
+# FAIL: 0
+# XPASS: 0
+${mgn}# ERROR: 1${std}
+$failure_footer
+END
+
+:
diff --git a/t/ax/testsuite-summary-checks.sh b/t/ax/testsuite-summary-checks.sh
new file mode 100644
index 000000000..309d47345
--- /dev/null
+++ b/t/ax/testsuite-summary-checks.sh
@@ -0,0 +1,106 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check the testsuite summary with the parallel-tests harness. This
+# script is meant to be sourced by other test script, so that it can
+# be used to check different scenarios (colorized and non-colorized
+# testsuite output, packages with and without bug-report addresses,
+# testsuites in subdirectories, ...)
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+case $use_colors in
+ yes)
+ AM_COLOR_TESTS=always; export AM_COLOR_TESTS
+ TERM=ansi; export TERM
+ am_opts='parallel-tests color-tests'
+ ;;
+ no)
+ am_opts='parallel-tests'
+ ;;
+ *)
+ fatal_ "invalid use_colors='$use_colors'";;
+esac
+
+cat > configure.ac <<END
+AC_INIT([GNU AutoFoo], [7.1], [bug-automake@gnu.org])
+AM_INIT_AUTOMAKE([$am_opts])
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+TEST_EXTENSIONS = .t
+T_LOG_COMPILER = $(SHELL) $(srcdir)/log-compiler
+## Will be defined at runtime.
+TESTS =
+$(TESTS):
+END
+
+cat > log-compiler <<'END'
+#!/bin/sh
+case "$1" in
+ pass*|*/pass*|xpass*|*/xpass*) exit 0;;
+ fail*|*/fail*|xfail*|*/xfail*) exit 1;;
+ skip*|*/skip*) exit 77;;
+ error*|/error*) exit 99;;
+ copy*|*/copy*) cat "$1";;
+ *) exit 99;;
+esac
+END
+
+# Quite complexish, but allow the tests in client scripts to be written
+# in a "data-driven fashion".
+do_check ()
+{
+ cat > summary.exp
+ expect_failure=false
+ xfail_tests=''
+ tests="TESTS='$*'"
+ for t in $*; do
+ case $t in fail*|xpass*|error*) expect_failure=:;; esac
+ case $t in xfail*|xpass*) xfail_tests="$xfail_tests $t";; esac
+ done
+ test -z "$xfail_tests" || xfail_tests="XFAIL_TESTS='$xfail_tests'"
+ st=0
+ eval "env $tests $xfail_tests \$MAKE -e check > stdout || st=\$?"
+ cat stdout
+ if $expect_failure; then
+ test $st -gt 0 || Exit 1
+ else
+ test $st -eq 0 || Exit 1
+ fi
+ $PERL "$am_testauxdir"/extract-testsuite-summary.pl stdout >summary.got \
+ || fatal_ "cannot extract testsuite summary"
+ cat summary.exp
+ cat summary.got
+ if test $use_colors = yes; then
+ # Use cmp, not diff, because the files might contain binary data.
+ compare=cmp
+ else
+ compare=diff
+ fi
+ $compare summary.exp summary.got || Exit 1
+}
+
+br='============================================================================'
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+:
diff --git a/t/ax/trivial-test-driver b/t/ax/trivial-test-driver
new file mode 100644
index 000000000..3968acbf4
--- /dev/null
+++ b/t/ax/trivial-test-driver
@@ -0,0 +1,102 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+#
+# Test driver for a very simple test protocol used by the Automake
+# testsuite to check support for custom test drivers allowing for more
+# test results per test script.
+#
+# The exit status of the wrapped script is ignored. Lines in its stdout
+# and stderr beginning with 'PASS', 'FAIL', 'XFAIL', 'XPASS', 'SKIP' or
+# 'ERROR' count as a test case result with the obviously-corresponding
+# outcome. Every other line is ignored for what concerns the testsuite
+# outcome.
+#
+# This script is used at least by the 'driver-custom-multitest*.test'
+# tests.
+#
+
+# Help to avoid typo-related bugs.
+set -u
+
+## Option parsing.
+
+test_name=INVALID.NAME
+log_file=BAD.LOG
+trs_file=BAD.TRS
+while test $# -gt 0; do
+ case $1 in
+ --test-name) test_name=$2; shift;;
+ --log-file) log_file=$2; shift;;
+ --trs-file) trs_file=$2; shift;;
+ # Ignored.
+ --expect-failure) shift;;
+ --color-tests) shift;;
+ --enable-hard-errors) shift;;
+ # Explicitly terminate option list.
+ --) shift; break;;
+ # Shouldn't happen
+ *) echo "$0: invalid option/argument: '$1'" >&2; exit 2;;
+ esac
+ shift
+done
+
+## Log file header.
+{
+ echo "RUN: $test_name"
+ echo "RUN: $test_name" | sed 's/./=/g'
+ echo
+} > $log_file
+
+## Run the test script, get test cases results, display them on console.
+
+"$@" 2>&1 | tee -a $log_file | (
+ i=0 st=0
+ exec 5> $trs_file
+ while read line; do
+ result=
+ case $line in
+ PASS:*) result=PASS ;;
+ FAIL:*) result=FAIL ;;
+ XPASS:*) result=XPASS ;;
+ XFAIL:*) result=XFAIL ;;
+ SKIP:*) result=SKIP ;;
+ ERROR:*) result=ERROR ;;
+ esac
+ if test -n "$result"; then
+ case $result in FAIL|XPASS|ERROR) st=1;; esac
+ # Output testcase result to console.
+ echo "$result: $test_name"
+ # Register testcase outcome for the log file.
+ echo ":test-result: $line" >&5
+ echo >&5
+ fi
+ done
+ if test $st -eq 0; then
+ recheck=no
+ copy_in_global_log=no
+ else
+ recheck=yes
+ copy_in_global_log=yes
+ fi
+ echo ":recheck: $recheck" >&5
+ echo ":copy-in-global-log: $copy_in_global_log" >&5
+ exec 5>&-
+) | awk '{ print $0 ", testcase " NR }'
+
+## And we're done.
+
+exit 0
diff --git a/t/backcompat.sh b/t/backcompat.sh
new file mode 100755
index 000000000..ec8292c12
--- /dev/null
+++ b/t/backcompat.sh
@@ -0,0 +1,64 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Test usage of AM_INIT_AUTOMAKE with two or three arguments, for
+# backward-compatibility.
+
+. ./defs || Exit 1
+
+cat > Makefile.am <<'END'
+.PHONY: test display
+
+## Might be useful for debugging.
+display:
+## The following should be substituted by AM_INIT_AUTOMAKE.
+ @echo PACKAGE = $(PACKAGE)
+ @echo VERSION = $(VERSION)
+## The following should not be substituted, as we used the
+## old form of AC_INIT.
+ @echo PACKAGE_NAME = $(PACKAGE_NAME)
+ @echo PACKAGE_VERSION = $(PACKAGE_VERSION)
+ @echo PACKAGE_TARNAME = $(PACKAGE_TARNAME)
+ @echo PACKAGE_STRING = $(PACKAGE_STRING)
+
+test: display
+ test x'$(PACKAGE)' = x'FooBar'
+ test x'$(VERSION)' = x'0.7.1'
+ test x'$(PACKAGE_NAME)' = x
+ test x'$(PACKAGE_VERSION)' = x
+ test x'$(PACKAGE_TARNAME)' = x
+ test x'$(PACKAGE_STRING)' = x
+END
+
+for ac_init in 'AC_INIT' 'AC_INIT([Makefile.am])'; do
+ for am_extra_args in '' ', []' ', [:]' ', [false]'; do
+ rm -rf autom4te*.cache config* Makefile.in Makefile
+ unindent > configure.in <<END
+ $ac_init
+ AM_INIT_AUTOMAKE([FooBar], [0.7.1]$am_extra_args)
+ AC_CONFIG_FILES([Makefile])
+ AC_OUTPUT
+END
+ cat configure.in # For debugging.
+ $ACLOCAL
+ $AUTOCONF
+ $AUTOMAKE
+ ./configure
+ $MAKE test
+ done
+done
+
+:
diff --git a/t/backcompat2.sh b/t/backcompat2.sh
new file mode 100755
index 000000000..ba9ec3b93
--- /dev/null
+++ b/t/backcompat2.sh
@@ -0,0 +1,73 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Backward-compatibility test: check that AM_INIT_AUTOMAKE with two or
+# three arguments does AC_DEFINE the symbols PACKAGE and VERSION iff the
+# third argument is empty or non-existent.
+
+am_create_testdir=empty
+. ./defs || Exit 1
+
+# A trick to make the test run muuuch faster, by avoiding repeated
+# runs of aclocal (one order of magnitude improvement in speed!).
+echo 'AC_INIT(x,0) AM_INIT_AUTOMAKE' > configure.in
+$ACLOCAL
+rm -rf configure.in autom4te.*
+
+touch install-sh missing
+
+cat > config.h.in <<'END'
+#undef PACKAGE
+#undef VERSION
+END
+
+for am_arg3 in ':' 'false' '#' ' '; do
+ unindent > configure.in <<END
+ AC_INIT
+ AC_CONFIG_HEADERS([config.h])
+ AM_INIT_AUTOMAKE([pkgname], [pkgversion], [$am_arg3])
+ AC_OUTPUT
+END
+ cat configure.in # For debugging.
+ $AUTOCONF
+ ./configure
+ cat config.h # For debugging.
+ # The non-empty third argument should prevent PACKAGE and VERSION
+ # from being AC_DEFINE'd.
+ $EGREP 'pkg(name|version)' config.h && Exit 1
+ # This is required because even relatively-recent versions of the
+ # BSD shell wrongly exit when the 'errexit' shell flag is active if
+ # the last command of a compound statement fails, even if it should
+ # be protected by the use of "&&".
+ :
+done
+
+for am_extra_args in '' ',' ', []'; do
+ unindent > configure.in <<END
+ AC_INIT
+ AC_CONFIG_HEADERS([config.h])
+ AM_INIT_AUTOMAKE([pkgname], [pkgversion]$am_extra_args)
+ AC_OUTPUT
+END
+ cat configure.in # For debugging.
+ $AUTOCONF
+ ./configure
+ cat config.h # For debugging.
+ grep '^ *# *define *PACKAGE *"pkgname" *$' config.h
+ grep '^ *# *define *VERSION *"pkgversion" *$' config.h
+done
+
+:
diff --git a/t/backcompat3.sh b/t/backcompat3.sh
new file mode 100755
index 000000000..2377e8876
--- /dev/null
+++ b/t/backcompat3.sh
@@ -0,0 +1,152 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Backward-compatibility test: check what happens when AC_INIT and
+# AM_INIT_AUTOMAKE are both given two or more arguments.
+
+am_create_testdir=empty
+. ./defs || Exit 1
+
+empty=''
+
+cat > Makefile.am <<'END'
+## Leading ':;' here required to work around bugs of (at least) bash 3.2
+got: Makefile
+ @:; { \
+ echo 'PACKAGE = $(PACKAGE)'; \
+ echo 'VERSION = $(VERSION)'; \
+ echo 'PACKAGE_NAME = $(PACKAGE_NAME)'; \
+ echo 'PACKAGE_VERSION = $(PACKAGE_VERSION)'; \
+ echo 'PACKAGE_STRING = $(PACKAGE_STRING)'; \
+ echo 'PACKAGE_TARNAME = $(PACKAGE_TARNAME)'; \
+ echo 'PACKAGE_BUGREPORT = $(PACKAGE_BUGREPORT)'; \
+ echo 'PACKAGE_URL = $(PACKAGE_URL)'; \
+ } >$@
+END
+
+
+### Run 1 ###
+
+cat > configure.in <<END
+AC_INIT([ac_name], [ac_version])
+AM_INIT_AUTOMAKE([am_name], [am_version])
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+END
+
+cat configure.in
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+cat >exp <<END
+PACKAGE = am_name
+VERSION = am_version
+PACKAGE_NAME = ac_name
+PACKAGE_VERSION = ac_version
+PACKAGE_STRING = ac_name ac_version
+PACKAGE_TARNAME = ac_name
+PACKAGE_BUGREPORT = $empty
+PACKAGE_URL = $empty
+END
+
+$MAKE got
+
+diff exp got
+
+
+### Run 2 ###
+
+cat > configure.in <<'END'
+dnl: 'AC_INIT' in Autoconf <= 2.63 doesn't have an URL argument.
+dnl: Luckily, 'AC_AUTOCONF_VERSION' and 'm4_version_prereq' are
+dnl: both present in autoconf 2.62, which we require; so that we
+dnl: can at least use the following workaround.
+m4_version_prereq([2.64],
+ [AC_INIT([ac_name], [ac_version], [ac_bugreport], [ac_tarname],
+ [ac_url])],
+ [AC_INIT([ac_name], [ac_version], [ac_bugreport], [ac_tarname])
+ AC_SUBST([PACKAGE_URL], [ac_url])])
+AM_INIT_AUTOMAKE([am_name], [am_version])
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+END
+
+cat configure.in
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+
+cat >exp <<END
+PACKAGE = am_name
+VERSION = am_version
+PACKAGE_NAME = ac_name
+PACKAGE_VERSION = ac_version
+PACKAGE_STRING = ac_name ac_version
+PACKAGE_TARNAME = ac_tarname
+PACKAGE_BUGREPORT = ac_bugreport
+PACKAGE_URL = ac_url
+END
+
+$MAKE got
+
+diff exp got
+
+
+### Run 3 ###
+
+cat > configure.in <<END
+AC_INIT([ac_name], [ac_version])
+AM_INIT_AUTOMAKE([am_name], [am_version], [am_foo_quux])
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+END
+
+cat configure.in
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+
+cat >exp <<END
+PACKAGE = am_name
+VERSION = am_version
+PACKAGE_NAME = ac_name
+PACKAGE_VERSION = ac_version
+PACKAGE_STRING = ac_name ac_version
+PACKAGE_TARNAME = ac_name
+PACKAGE_BUGREPORT = $empty
+PACKAGE_URL = $empty
+END
+
+$MAKE got
+
+diff exp got
+
+$FGREP am_foo_quux Makefile.in Makefile configure config.status && Exit 1
+
+
+### Done ###
+
+:
diff --git a/t/backcompat4.sh b/t/backcompat4.sh
new file mode 100755
index 000000000..9088aae1f
--- /dev/null
+++ b/t/backcompat4.sh
@@ -0,0 +1,66 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Backward-compatibility: AC_OUTPUT with arguments.
+
+. ./defs || Exit 1
+
+mkdir sub
+: > Makefile.am
+: > zardoz
+: > foo.in
+: > foo1.in
+: > foo2.in
+: > foo3.in
+: > sub/bar.in
+
+ls -l # For debugging.
+
+for args in \
+ 'foo' \
+ 'foo:foo1.in' \
+ 'foo:zardoz' \
+ 'foo:sub/bar.in' \
+ 'foo:foo1.in:foo2.in' \
+ 'foo:zardoz:zardoz' \
+ 'foo:foo1.in:foo2.in:foo3.in' \
+ 'foo:foo1.in:foo2.in:sub/bar.in:foo3.in' \
+; do
+ rm -rf autom4te*.cache aclocal.m4
+ unindent >configure.ac <<END
+ AC_INIT([$me], [1.0])
+ AM_INIT_AUTOMAKE
+ AC_CONFIG_FILES([$args])
+ AC_OUTPUT
+END
+ cat configure.ac # For debugging.
+ $ACLOCAL
+ $AUTOMAKE Makefile
+ mv -f Makefile.in Makefile.acf
+ rm -rf autom4te*.cache aclocal.m4
+ unindent >configure.ac <<END
+ AC_INIT([$me], [1.0])
+ AM_INIT_AUTOMAKE
+ AC_OUTPUT([$args])
+END
+ cat configure.ac # For debugging.
+ $ACLOCAL
+ $AUTOMAKE Makefile
+ mv -f Makefile.in Makefile.aco
+ diff Makefile.acf Makefile.aco
+done
+
+:
diff --git a/t/backcompat5.sh b/t/backcompat5.sh
new file mode 100755
index 000000000..3aa90679e
--- /dev/null
+++ b/t/backcompat5.sh
@@ -0,0 +1,125 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Backward-compatibility test: try to build and distribute a package
+# using obsoleted forms of AC_INIT, AM_INIT_AUTOMAKE and AC_OUTPUT.
+# This script can also serve as mild stress-testing for Automake.
+# See also the similar test 'backcompat6.test'.
+
+am_parallel_tests=no
+am_create_testdir=empty
+. ./defs || Exit 1
+
+makefiles='hacky/Makefile src/Makefile data/Makefile tests/Makefile'
+
+# Yuck!
+cat > configure.in <<END
+dnl: Everything here is *deliberately* underquoted!
+AC_INIT(src/foo.input)
+AM_INIT_AUTOMAKE(foo, 1.0)
+AC_CONFIG_FILES(Makefile:mkfile.in)
+AC_OUTPUT($makefiles)
+END
+
+distdir=foo-1.0
+
+cat > mkfile.am <<'END'
+SUBDIRS = src data tests hacky
+installcheck-local:
+ grep DataDataData $(DESTDIR)$(prefix)/data/$(PACKAGE)-$(VERSION)/bar
+END
+
+mkdir hacky src tests data
+
+echo 'This is a dummy package' > README
+
+cat > src/foo.input <<'END'
+#!sh
+echo Zardoz
+END
+
+cat > tests/a.test <<'END'
+#!/bin/sh
+"$srcdir/../src/foo" | grep Zardoz
+END
+chmod a+x tests/a.test
+
+cat > data/bar <<'END'
+line1
+line2
+line3
+END
+
+cat >hacky/Makefile.am <<'END'
+dist-hook:
+ find $(top_distdir) -print
+ chmod a+rx $(top_distdir)/tests/*.test
+END
+
+cat > src/Makefile.am <<'END'
+dist_bin_SCRIPTS = foo
+foo: foo.input
+ sed '1s,^#!.*$$,#!/bin/sh,' $(srcdir)/foo.input >$@
+ chmod a+x $@
+EXTRA_DIST = foo.input
+DISTCLEANFILES = foo
+END
+
+cat > data/Makefile.am <<'END'
+nodist_data_DATA = bar
+datadir = $(prefix)/data/$(PACKAGE)-$(VERSION)
+bar:
+ echo DataDataData >$@
+distclean-local:
+ rm -f bar
+END
+
+cat > tests/Makefile.am <<'END'
+TESTS = a.test
+EXTRA_DIST = $(TESTS)
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+test -f install-sh
+for f in $makefiles; do mv -f $f.in $f.sav; done
+$AUTOMAKE
+for f in $makefiles; do diff $f.sav $f.in; done
+
+./configure
+ls -l . hacky src data tests # For debugging.
+test ! -f mkfile
+$MAKE
+$MAKE distdir
+test ! -f $distdir/Makefile.in
+test ! -f $distdir/data/bar
+test -f $distdir/src/foo
+diff README $distdir/README
+diff mkfile.in $distdir/mkfile.in
+diff tests/a.test $distdir/tests/a.test
+diff src/foo.input $distdir/src/foo.input
+
+$MAKE check
+$MAKE distcheck
+
+test -f $distdir.tar.gz
+
+chmod a-x tests/a.test
+# dist-hook should take care of making test files executables.
+$MAKE distcheck
+
+:
diff --git a/t/backcompat6.sh b/t/backcompat6.sh
new file mode 100755
index 000000000..fde118b1c
--- /dev/null
+++ b/t/backcompat6.sh
@@ -0,0 +1,104 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Backward-compatibility test: try to build and distribute a package
+# using obsoleted forms of AC_INIT, AM_INIT_AUTOMAKE and AC_OUTPUT.
+# This script can also serve as mild stress-testing for Automake.
+# See also the similar test 'backcompat5.test'.
+
+required=cc
+am_create_testdir=empty
+. ./defs || Exit 1
+
+# Anyone doing something like this in a real-life package probably
+# deserves to be killed.
+cat > configure.in <<'END'
+dnl: Everything here is *deliberately* underquoted!
+AC_INIT(quux.c)
+PACKAGE=nonesuch-zardoz
+VERSION=nonesuch-0.1
+AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
+AC_SUBST(one,1)
+two=2
+AC_SUBST(two, $two)
+three=3
+AC_SUBST(three)
+AC_PROG_CC
+AC_CONFIG_HEADERS(config.h:config.hin)
+AM_CONDITIONAL(CROSS_COMPILING, test "$cross_compiling" = yes)
+AC_OUTPUT(Makefile foo.got:foo1.in:foo2.in:foo3.in)
+END
+
+echo @one@ > foo1.in
+echo @two@ > foo2.in
+echo @three@ > foo3.in
+
+cat >config.hin <<'END'
+#undef PACKAGE
+#undef VERSION
+END
+
+cat >> Makefile.am <<'END'
+bin_PROGRAMS = foo
+foo_SOURCES = quux.c
+check-local:
+ test x'$(PACKAGE)' = x'nonesuch-zardoz'
+ test x'$(VERSION)' = x'nonesuch-0.1'
+if ! CROSS_COMPILING
+ ./foo
+## Do not anchor the regexps w.r.t. the end of line, because on
+## MinGW/MSYS, grep may assume LF line endings only, while our
+## 'foo' program may generate CRLF line endings.
+ ./foo | grep '^PACKAGE = nonesuch-zardoz!'
+ ./foo | echo '^VERSION = nonesuch-0\.1!'
+endif
+END
+
+cat > quux.c <<'END'
+#include <config.h>
+#include <stdio.h>
+int main (void)
+{
+ printf("PACKAGE = %s!\nVERSION = %s!\n", PACKAGE, VERSION);
+ return 0;
+}
+END
+
+$ACLOCAL
+$AUTOMAKE --add-missing
+$AUTOCONF
+
+./configure
+
+cat >foo.exp <<'END'
+1
+2
+3
+END
+
+diff foo.exp foo.got
+
+$MAKE
+$MAKE check
+
+distdir=nonesuch-zardoz-nonesuch-0.1
+$MAKE distdir
+test -f $distdir/quux.c
+test ! -f $distdir/foo.got
+
+$MAKE distcheck
+
+:
diff --git a/t/backsl.sh b/t/backsl.sh
new file mode 100755
index 000000000..48d70c719
--- /dev/null
+++ b/t/backsl.sh
@@ -0,0 +1,34 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test for "\" problems. Bug report from Joerg-Martin Schwarz.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = \
+ frob
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+grep '^_SOURCE' Makefile.in && Exit 1
+Exit 0
diff --git a/t/backsl2.sh b/t/backsl2.sh
new file mode 100755
index 000000000..82e2f084e
--- /dev/null
+++ b/t/backsl2.sh
@@ -0,0 +1,30 @@
+#! /bin/sh
+# Copyright (C) 1999-2012 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/>.
+
+# We must skip the backslash, not complain about './\' not existing.
+# Reported by Rick Scott <rwscott@omnisig.com>
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+SUBDIRS = \
+ .
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+:
diff --git a/t/backsl3.sh b/t/backsl3.sh
new file mode 100755
index 000000000..36fab7f32
--- /dev/null
+++ b/t/backsl3.sh
@@ -0,0 +1,29 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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 we diagnose trailing backslash at the end of a file.
+# Report from Akim Demaile <akim@epita.fr>.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+foo = \
+END
+
+$ACLOCAL
+AUTOMAKE_fails
+cat stderr
+grep 'trailing backslash' stderr
diff --git a/t/backsl4.sh b/t/backsl4.sh
new file mode 100755
index 000000000..c11d20d47
--- /dev/null
+++ b/t/backsl4.sh
@@ -0,0 +1,45 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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 we diagnose and fix white spaces following backslash.
+# Report from Peter Muir.
+
+. ./defs || Exit 1
+
+echo AC_OUTPUT >>configure.ac
+
+# Note: trailing whitespace used during the test should not appear as
+# trailing whitespace in this file, or it will get stripped by any
+# reasonable editor.
+
+echo 'bin_SCRIPTS = foo \ ' >Makefile.am
+cat >>Makefile.am <<'END'
+bar
+ok:
+ :
+END
+echo 'data_DATA = baz \ ' >>Makefile.am
+echo ' fum' >>Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+AUTOMAKE_fails
+grep ':1:.*whitespace' stderr
+grep ':5:.*whitespace' stderr
+$AUTOMAKE -Wno-error
+./configure
+# Older versions of Automake used to produce invalid Makefiles such input.
+$MAKE ok
diff --git a/t/badline.sh b/t/badline.sh
new file mode 100755
index 000000000..3f548f75d
--- /dev/null
+++ b/t/badline.sh
@@ -0,0 +1,33 @@
+#! /bin/sh
+# Copyright (C) 1998-2012 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/>.
+
+# Test to make sure that line number and file name in error message
+# referring to variable is always correct.
+
+. ./defs || Exit 1
+
+cat > configure.ac << END
+AC_INIT([$me], [1.0])
+AM_INIT_AUTOMAKE
+AC_SUBST(TEXINFOS)
+AC_CONFIG_FILES([Makefile])
+END
+
+: > Makefile.am
+
+$ACLOCAL || Exit 1
+AUTOMAKE_fails
+grep 'configure.ac:3:.*info_TEXINFOS' stderr
diff --git a/t/badopt.sh b/t/badopt.sh
new file mode 100755
index 000000000..b06657f27
--- /dev/null
+++ b/t/badopt.sh
@@ -0,0 +1,25 @@
+#! /bin/sh
+# Copyright (C) 1998-2012 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/>.
+
+# Test to make sure bad options cause error.
+
+. ./defs || Exit 1
+
+echo 'AUTOMAKE_OPTIONS = zardoz' > Makefile.am
+
+$ACLOCAL
+AUTOMAKE_fails
+grep zardoz stderr
diff --git a/t/badprog.sh b/t/badprog.sh
new file mode 100755
index 000000000..81ff5b76c
--- /dev/null
+++ b/t/badprog.sh
@@ -0,0 +1,32 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test to make sure that programs with bad names are properly
+# transformed.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = a,b
+a_b_SOURCES = ab.c
+END
+
+$ACLOCAL
+$AUTOMAKE
diff --git a/t/block.sh b/t/block.sh
new file mode 100755
index 000000000..a6e9e3255
--- /dev/null
+++ b/t/block.sh
@@ -0,0 +1,34 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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 block comments are not double-spaced.
+# Report from François Pinard.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+#START
+#a
+#b
+#c
+#END
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+(sed -e '/^#START/,/^#END/ !d' Makefile.in | grep -v '^#') && Exit 1
+Exit 0
diff --git a/t/bsource.sh b/t/bsource.sh
new file mode 100755
index 000000000..482015f3e
--- /dev/null
+++ b/t/bsource.sh
@@ -0,0 +1,32 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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/>.
+
+# Regression test for install-recursive appearing in a non recursive Makefile.
+# Report from Bruno Haible.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+noinst_SCRIPTS = hostname
+include_HEADERS = gettext-po.h
+BUILT_SOURCES = po-hash-gen.c
+END
+
+$ACLOCAL
+$AUTOMAKE
+grep 'install-recursive' Makefile.in && Exit 1
+
+:
diff --git a/t/candist.sh b/t/candist.sh
new file mode 100755
index 000000000..88d8854fd
--- /dev/null
+++ b/t/candist.sh
@@ -0,0 +1,32 @@
+#! /bin/sh
+# Copyright (C) 2009-2012 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 3 of the License, 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/>.
+
+# Test to make sure things that cannot be dist_'ed are diagnosed.
+
+. ./defs || Exit 1
+
+echo AC_OUTPUT >>configure.ac
+
+cat > Makefile.am << 'END'
+dist_bin_PROGRAMS = foo
+dist_lib_LIBRARIES = libfoo.a
+END
+
+$ACLOCAL
+AUTOMAKE_fails
+test 2 -eq `grep -c 'dist.*forbidden' stderr`
+
+Exit 0
diff --git a/t/canon-name.sh b/t/canon-name.sh
new file mode 100755
index 000000000..3e8de0888
--- /dev/null
+++ b/t/canon-name.sh
@@ -0,0 +1,38 @@
+#! /bin/sh
+# Copyright (C) 2007-2012 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/>.
+
+# PR 511: Make sure we warn about e.g. AC_CONFIG_FILES([./gmakefile]),
+# as not all make implementations treat 'file' and './file' equally.
+
+. ./defs || Exit 1
+
+cat > configure.ac <<END
+AC_INIT([$me], [1.0])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([./gmakefile ./sub/gmakefile])
+AC_OUTPUT
+END
+
+mkdir sub
+echo 'SUBDIRS = sub' >gmakefile.am
+: >sub/gmakefile.am
+
+$ACLOCAL
+AUTOMAKE_fails
+grep 'leading.*\./.*\./gmakefile' stderr
+grep 'leading.*\./.*\./sub/gmakefile' stderr
+
+:
diff --git a/t/canon.sh b/t/canon.sh
new file mode 100755
index 000000000..b5038a535
--- /dev/null
+++ b/t/canon.sh
@@ -0,0 +1,35 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test to make sure that name canonicalization error works.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = sniff-glue
+sniff-glue_SOURCES = sg.c
+END
+
+$ACLOCAL
+AUTOMAKE_fails
+grep 'Makefile\.am:2:.* bad .*variable.*sniff-glue_SOURCES' stderr
+grep 'Makefile\.am:2:.* use .*sniff_glue_SOURCES' stderr
+
+:
diff --git a/t/canon2.sh b/t/canon2.sh
new file mode 100755
index 000000000..4d39a7e42
--- /dev/null
+++ b/t/canon2.sh
@@ -0,0 +1,35 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test to make sure name canonicalization happens for texinfo.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+info_TEXINFOS = zar-doz.texi
+zar_doz_TEXINFOS = frob.texi
+END
+
+: > texinfo.tex
+echo '@setfilename zar-doz.info' > zar-doz.texi
+echo '@setfilename frob' > frob.texi
+
+$ACLOCAL
+$AUTOMAKE
+
+grep zar-doz_TEXINFOS Makefile.in && Exit 1
+
+:
diff --git a/t/canon3.sh b/t/canon3.sh
new file mode 100755
index 000000000..25a8e71df
--- /dev/null
+++ b/t/canon3.sh
@@ -0,0 +1,36 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Yet another canonicalization test.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = perm-number
+END
+
+: > perm-number.c
+
+$ACLOCAL
+$AUTOMAKE
+
+$FGREP 'perm_number.c' Makefile.in && Exit 1
+
+:
diff --git a/t/canon4.sh b/t/canon4.sh
new file mode 100755
index 000000000..6cdfd41a7
--- /dev/null
+++ b/t/canon4.sh
@@ -0,0 +1,40 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test to make sure name canonicalization happens for static libraries.
+# Keep this in sync with sister test 'canon6.test'.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_RANLIB
+END
+
+cat > Makefile.am << 'END'
+noinst_LIBRARIES = libx-y.a
+libx_y_a_SOURCES = xy.c
+END
+
+: > ar-lib
+
+$ACLOCAL
+$AUTOMAKE
+
+grep '^ *libx-y.*=' Makefile.in && Exit 1
+
+:
diff --git a/t/canon5.sh b/t/canon5.sh
new file mode 100755
index 000000000..0d71d8328
--- /dev/null
+++ b/t/canon5.sh
@@ -0,0 +1,58 @@
+#! /bin/sh
+# Copyright (C) 1999-2012 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/>.
+
+# Test to make sure that we allow variable names starting in
+# non-letters. Whatever that might mean.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+END
+
+$ACLOCAL
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = 123test
+123test_SOURCES = 123.c
+END
+
+$AUTOMAKE
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = _foo
+_foo_SOURCES = foo.c
+END
+
+$AUTOMAKE
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = ,foo
+,foo_SOURCES = foo.c
+END
+
+AUTOMAKE_fails
+grep 'Makefile\.am:2:.* bad .*variable.*,foo_SOURCES' stderr
+grep 'Makefile\.am:2:.* use .*_foo_SOURCES' stderr
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = ,foo
+_foo_SOURCES = foo.c
+END
+
+$AUTOMAKE -Wno-portability
+
+:
diff --git a/t/canon6.sh b/t/canon6.sh
new file mode 100755
index 000000000..64f946c9e
--- /dev/null
+++ b/t/canon6.sh
@@ -0,0 +1,42 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test to make sure name canonicalization happens for libtool libraries.
+# Keep this in sync with sister test 'canon4.test'.
+
+required='libtoolize'
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_LIBTOOL
+END
+
+cat > Makefile.am << 'END'
+noinst_LTLIBRARIES = libx-y.la
+libx_y_la_SOURCES = xy.c
+END
+
+: > ltmain.sh
+: > ar-lib
+
+$ACLOCAL
+$AUTOMAKE -a
+
+grep '^ *libx-y.*=' Makefile.in && Exit 1
+
+:
diff --git a/t/canon7.sh b/t/canon7.sh
new file mode 100755
index 000000000..d9d22c218
--- /dev/null
+++ b/t/canon7.sh
@@ -0,0 +1,101 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Stress test on canonicalization.
+
+required='cc libtool libtoolize'
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_RANLIB dnl: for static libraries
+AC_PROG_LIBTOOL dnl: for libtool libraries
+AM_CONDITIONAL([CROSS_COMPILING], [test "$cross_compiling" = yes])
+AC_OUTPUT
+END
+
+if touch ,foo-bar libb.az+baz lib~zardoz,,; then
+ rm -f ,foo-bar libb.az+baz lib~zardoz,,
+else
+ skip_ "cannot create regular files with \"tricky\" names"
+fi
+
+cat > Makefile.am << 'END'
+noinst_PROGRAMS = dummy_static dummy_dynamic ,foo-bar
+noinst_LIBRARIES = libb.az+baz.a
+noinst_LTLIBRARIES = lib~zardoz,,.la
+
+dummy_static_SOURCES = dummy.c lib.h
+dummy_dynamic_SOURCES = $(dummy_static_SOURCES)
+
+dummy_static_LDADD = $(noinst_LIBRARIES)
+dummy_dynamic_LDADD = $(noinst_LTLIBRARIES)
+
+_foo_bar_SOURCES = foobar.c
+libb_az_baz_a_SOURCES = libs.c
+lib_zardoz___la_SOURCES = libd.c
+
+check-local:
+ ls -l
+if CROSS_COMPILING
+ test -f ./,foo-bar$(EXEEXT)
+ test -f ./dummy_static$(EXEEXT)
+ test -f ./dummy_dynamic$(EXEEXT)
+else !CROSS_COMPILING
+ ./,foo-bar
+ ./dummy_static
+ ./dummy_dynamic
+ ./,foo-bar | grep 'Hello, FooBar!'
+ ./dummy_static | grep 'Hello from Static!'
+ ./dummy_dynamic | grep 'Hello from Dynamic!'
+endif !CROSS_COMPILING
+END
+
+cat > foobar.c << 'END'
+#include <stdio.h>
+int main(void)
+{
+ printf("Hello, FooBar!\n");
+ return 0;
+}
+END
+
+cat > dummy.c << 'END'
+#include <stdio.h>
+#include "lib.h"
+int main(void)
+{
+ printf("Hello from %s!\n", dummy_func());
+ return 0;
+}
+END
+
+echo 'const char *dummy_func(void);' > lib.h
+echo 'const char *dummy_func(void) { return "Dynamic"; }' > libd.c
+echo 'const char *dummy_func(void) { return "Static"; }' > libs.c
+
+libtoolize
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+$MAKE check
+$MAKE distcheck
+
+:
diff --git a/t/canon8.sh b/t/canon8.sh
new file mode 100755
index 000000000..180e33351
--- /dev/null
+++ b/t/canon8.sh
@@ -0,0 +1,37 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Check that canonicalization does not transliterate the '@' charactrer.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = foob@rquux
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+# The first grep is here mostly for debugging.
+grep foob.rquux Makefile.in
+grep foob@rquux Makefile.in
+grep 'foob[^@]rquux' Makefile.in && Exit 1
+
+:
diff --git a/t/ccnoco.sh b/t/ccnoco.sh
new file mode 100755
index 000000000..1df950da8
--- /dev/null
+++ b/t/ccnoco.sh
@@ -0,0 +1,83 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test to make sure we can compile when the compiler doesn't
+# understand '-c -o'.
+
+required=gcc
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_CC_C_O
+# Make sure that $CC can be used after AM_PROG_CC_C_O.
+$CC -v || exit 1
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = wish
+wish_SOURCES = a.c
+# Make sure we need something strange.
+wish_CFLAGS = -g
+END
+
+cat > a.c << 'END'
+#include <stdio.h>
+
+int main ()
+{
+ printf ("hi\n");
+}
+END
+
+cat > Mycomp << END
+#!/bin/sh
+
+case " \$* " in
+ *\ -c*\ -o* | *\ -o*\ -c*)
+ exit 1
+ ;;
+esac
+
+# Use '$CC', not 'gcc', to honour the compiler chosen by 't/defs'.
+exec $CC "\$@"
+END
+
+chmod +x Mycomp
+
+# Make sure the compiler doesn't understand '-c -o'
+CC=`pwd`/Mycomp
+export CC
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --copy --add-missing
+
+for vpath in : false; do
+ if $vpath; then
+ srcdir=..
+ mkdir build
+ cd build
+ else
+ srcdir=.
+ fi
+ $srcdir/configure
+ $MAKE
+ cd $srcdir
+done
+
+:
diff --git a/t/ccnoco2.sh b/t/ccnoco2.sh
new file mode 100755
index 000000000..e6c9c6428
--- /dev/null
+++ b/t/ccnoco2.sh
@@ -0,0 +1,55 @@
+#! /bin/sh
+# Copyright (C) 2006-2012 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 Automake requires AM_PROG_CC_C_O when either per-targets
+# flags or subdir-objects are used.
+
+. ./defs || Exit 1
+
+cat >>configure.ac <<EOF
+AC_PROG_CC
+AC_OUTPUT
+EOF
+
+cat >Makefile.am <<EOF
+bin_PROGRAMS = wish
+wish_SOURCES = a.c
+wish_CPPFLAGS = -DWHATEVER
+EOF
+
+touch a.c
+
+$ACLOCAL
+$AUTOCONF
+AUTOMAKE_fails --copy --add-missing
+grep '^Makefile\.am:2:.*per-target.*AM_PROG_CC_C_O' stderr
+
+
+cat >Makefile.am <<EOF
+bin_PROGRAMS = wish
+wish_SOURCES = sub/a.c
+EOF
+
+mkdir sub
+mv a.c sub
+
+$AUTOMAKE --copy --add-missing
+
+echo 'AUTOMAKE_OPTIONS = subdir-objects' >> Makefile.am
+AUTOMAKE_fails --copy --add-missing
+grep '^Makefile\.am:2:.*subdir.*AM_PROG_CC_C_O' stderr
+
+:
diff --git a/t/ccnoco3.sh b/t/ccnoco3.sh
new file mode 100755
index 000000000..eb291ecd5
--- /dev/null
+++ b/t/ccnoco3.sh
@@ -0,0 +1,77 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test to make sure 'compile' doesn't call 'mv SRC SRC'.
+
+required=gcc
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_CC_C_O
+$CC --version; $CC -v; # For debugging.
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = subdir-objects
+bin_PROGRAMS = wish
+wish_SOURCES = a.c
+END
+
+mkdir sub
+
+cat > a.c << 'END'
+#include <stdio.h>
+
+int main ()
+{
+ printf ("hi\n");
+}
+END
+
+cat > Mycomp << END
+#!/bin/sh
+
+case " \$* " in
+ *\ -c*\ -o* | *\ -o*\ -c*)
+ exit 1
+ ;;
+esac
+
+# Use '$CC', not 'gcc', to honour the compiler chosen by 't/defs'.
+exec $CC "\$@"
+END
+
+chmod +x Mycomp
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --copy --add-missing
+
+mkdir build
+cd build
+
+# Make sure the compiler doesn't understand '-c -o'
+CC=`pwd`/../Mycomp
+export CC
+
+../configure
+$MAKE 2>stderr || { cat stderr >&2; Exit 1; }
+cat stderr >&2
+grep 'mv.*the same file' stderr && Exit 1
+
+:
diff --git a/t/check-concurrency-bug9245.sh b/t/check-concurrency-bug9245.sh
new file mode 100755
index 000000000..064dce26f
--- /dev/null
+++ b/t/check-concurrency-bug9245.sh
@@ -0,0 +1,62 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Look for a bug where FreeBSD make in concurrent mode reported success
+# even when the Automake-generated parallel testsuite harness failed.
+# See automake bug#9245.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TESTS = foo.test bar.test
+END
+
+cat > foo.test <<'END'
+#!/bin/sh
+exit 1
+END
+chmod a+x foo.test
+
+cp foo.test bar.test
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+# Some make implementations don't grok the '-j' option.
+$MAKE -j1 || Exit 77
+
+for j in '' -j1 -j2; do
+ $MAKE $j check && Exit 1
+ TESTS=foo.test $MAKE $j -e check && Exit 1
+ if test x"$am_parallel_tests" = x"yes"; then
+ $MAKE $j recheck && Exit 1
+ TEST_LOGS=foo.log $MAKE $j -e check && Exit 1
+ rm -f test-suite.log
+ $MAKE $j test-suite.log && Exit 1
+ test -f test-suite.log || Exit 1
+ else
+ : # For shells with buggy 'set -e'.
+ fi
+done
+
+:
diff --git a/t/check-exported-srcdir.sh b/t/check-exported-srcdir.sh
new file mode 100755
index 000000000..124269bc3
--- /dev/null
+++ b/t/check-exported-srcdir.sh
@@ -0,0 +1,63 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that the testsuite driver (either with or without the
+# parallel-tests option enabled) exports the 'srcdir' value in the
+# environment of the tests. This is documented in the manual.
+
+. ./defs || Exit 1
+
+show_info ()
+{
+ if test x"$am_parallel_tests" = x"yes"; then
+ cat foo.log
+ cat test-suite.log
+ else
+ :
+ fi
+}
+
+mkdir SrcDir
+mv [!S]* SrcDir
+mkdir BuildDir
+cd SrcDir
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TESTS = foo.test
+END
+
+cat > foo.test <<'END'
+#!/bin/sh
+echo "foo.test: srcdir='$srcdir'"
+test x"$srcdir" = x"../SrcDir"
+END
+chmod a+x foo.test
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+cd ../BuildDir
+../SrcDir/configure
+
+$MAKE check || { show_info; Exit 1; }
+show_info
+
+:
diff --git a/t/check-fd-redirect.sh b/t/check-fd-redirect.sh
new file mode 100755
index 000000000..5a64c229a
--- /dev/null
+++ b/t/check-fd-redirect.sh
@@ -0,0 +1,110 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Simple Tests support: redirection of file descriptors with
+# AM_TESTS_FD_REDIRECT.
+# See also related test 'parallel-tests-fd-redirect.test'.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+TESTS = foo.test
+AM_TESTS_FD_REDIRECT = 3<three 4>four 5>>five 7<&0 8>&1 9>&2
+END
+
+echo '3333' > three
+chmod a-w three
+
+: > foo.test
+chmod a+x foo.test
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+./configure
+
+do_check ()
+{
+ cat foo.test # For debugging.
+ echo 'this line will be removed' > four
+ echo 'this line will not be removed' > five
+ st=0
+ echo 'ok ok ok' | $MAKE check >stdout 2>stderr || st=1
+ cat stdout
+ cat stderr >&2
+ cat four
+ test x"$am_parallel_tests" != x"yes" || cat foo.log
+ test $st -eq 0
+ grep '[ /]foo\.test: foofoofoo$' stdout
+ grep '[ /]foo\.test: barbarbar$' stderr
+ grep 'this line' four && Exit 1
+ grep '^3333$' four
+ grep '^this line will not be removed$' five
+ grep '^ok ok ok$' five
+ $EGREP '(foofoofoo|barbarbar|3333|ok ok ok|this line)' foo.log && Exit 1
+ :
+}
+
+# Try using both shell script and a perl script as the test, for
+# better coverage.
+
+cat > foo.test <<'END'
+#! /bin/sh
+set -e
+
+read FOO <&3
+test 3333 -eq "$FOO"
+echo "$FOO" >&4
+
+grep '^ok ok ok$' <&7 >&5
+
+echo " " $0: foofoofoo >&8
+echo " " $0: barbarbar >&9
+END
+
+do_check
+
+echo "#! $PERL -w" > foo.test
+cat >> foo.test <<'END'
+use warnings FATAL => 'all';
+use strict;
+
+open (FD3, "<&=3") or die "opening FD3: $!";
+open (FD4, ">&=4") or die "opening FD4: $!";
+open (FD5, ">&=5") or die "opening FD5: $!";
+open (FD7, "<&=7") or die "opening FD7: $!";
+open (FD8, ">&=8") or die "opening FD8: $!";
+open (FD9, ">&=9") or die "opening FD9: $!";
+
+chomp (my $FOO = <FD3>);
+die "$FOO != 3333" if not $FOO eq "3333";
+print FD4 "$FOO\n";
+
+chomp ($_ = <FD7>);
+die "$_ != 'ok ok ok'" if not $_ eq 'ok ok ok';
+print FD5 "$_\n";
+
+print FD8 " $0: foofoofoo\n";
+print FD9 " $0: barbarbar\n";
+END
+
+do_check
+
+:
diff --git a/t/check-no-test-driver.sh b/t/check-no-test-driver.sh
new file mode 100755
index 000000000..cccc0ed57
--- /dev/null
+++ b/t/check-no-test-driver.sh
@@ -0,0 +1,35 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that auxiliary script 'test-driver' doesn't get needlessly
+# installed or referenced when the 'parallel-tests' option is not
+# used.
+
+am_parallel_tests=no
+. ./defs || Exit 1
+
+echo 'TESTS = foo.test' > Makefile.am
+
+$ACLOCAL
+
+for opts in '' '-a' '--add-missing --copy'; do
+ $AUTOMAKE $opts
+ $FGREP 'test-driver' Makefile.in && Exit 1
+ find . | $FGREP 'test-driver' && Exit 1
+ : For shells with busted 'set -e'.
+done
+
+:
diff --git a/t/check-subst-prog.sh b/t/check-subst-prog.sh
new file mode 100755
index 000000000..30e87632f
--- /dev/null
+++ b/t/check-subst-prog.sh
@@ -0,0 +1,81 @@
+#! /bin/sh
+# Copyright (C) 2008-2012 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/>.
+
+# Check @substituted@ TESTS, some of which are also PROGRAMS.
+# See also sister test 'check-subst.test'.
+
+required='cc native'
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_SUBST([script_tests],
+ ['subst-pass-script.test subst-xfail-script.test'])
+AC_SUBST([prog_tests],
+ ['subst-pass-prog.test$(EXEEXT) subst-xfail-prog.test$(EXEEXT)'])
+AC_SUBST([xfail_tests],
+ ['xfail-script.test subst-xfail-script.test]dnl
+ [ xfail-prog$(EXEEXT) subst-xfail-prog.test$(EXEEXT)'])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TESTS = pass-script.test xfail-script.test @script_tests@ $(check_PROGRAMS)
+XFAIL_TESTS = @xfail_tests@
+check_PROGRAMS = pass-prog xfail-prog @prog_tests@
+EXTRA_PROGRAMS = subst-pass-prog.test subst-xfail-prog.test
+END
+
+cat > pass-script.test <<'END'
+#! /bin/sh
+exit 0
+END
+cat > xfail-script.test <<'END'
+#! /bin/sh
+exit 1
+END
+chmod a+x pass-script.test xfail-script.test
+cp pass-script.test subst-pass-script.test
+cp xfail-script.test subst-xfail-script.test
+
+cat > pass-prog.c <<'END'
+int main (void) { return 0; }
+END
+cat > xfail-prog.c <<'END'
+#include <stdlib.h>
+int main (void) { return EXIT_FAILURE; }
+END
+# The .test extension is removed for the default source file name:
+cp pass-prog.c subst-pass-prog.c
+cp xfail-prog.c subst-xfail-prog.c
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+$MAKE all
+$MAKE check
+$MAKE distclean
+
+mkdir build
+cd build
+../configure
+$MAKE all
+$MAKE check
+$MAKE distclean
+
+:
diff --git a/t/check-subst.sh b/t/check-subst.sh
new file mode 100755
index 000000000..79d7526a0
--- /dev/null
+++ b/t/check-subst.sh
@@ -0,0 +1,87 @@
+#! /bin/sh
+# Copyright (C) 2008-2012 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/>.
+
+# Check @substituted@ TESTS.
+# Note that in this test, we rely on the .test extension for the
+# substituted names: this is necessary for parallel-tests.
+# See also sister test 'check-subst-prog.test'.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_SUBST([script_tests], ['subst-pass-script.sh subst-xfail-script.sh'])
+AC_SUBST([xfail_tests], ['xfail-script.test subst-xfail-script.sh'])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TESTS = pass-script.test xfail-script.test @script_tests@
+XFAIL_TESTS = @xfail_tests@
+END
+
+if test "$am_parallel_tests" = yes; then
+ unindent >> Makefile.am <<'END'
+ TEST_EXTENSIONS = .sh .test
+ SH_LOG_COMPILER = $(SHELL)
+END
+fi
+
+cat > pass-script.test <<'END'
+#! /bin/sh
+exit 0
+END
+cat > xfail-script.test <<'END'
+#! /bin/sh
+exit 1
+END
+cp pass-script.test subst-pass-script.sh
+cp xfail-script.test subst-xfail-script.sh
+chmod a+x pass-script.test xfail-script.test
+
+if test "$am_parallel_tests" != yes; then
+ chmod a+x subst-pass-script.sh subst-xfail-script.sh
+fi
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+for vpath in false : ; do
+
+ if $vpath; then
+ mkdir build
+ cd build
+ srcdir=..
+ else
+ srcdir=.
+ fi
+
+ $srcdir/configure
+ $MAKE all
+ $MAKE check
+ if test "$am_parallel_tests" = yes; then
+ ls -l
+ test -f pass-script.log
+ test -f xfail-script.log
+ test -f subst-pass-script.log
+ test -f subst-xfail-script.log
+ fi
+ $MAKE distclean
+ cd $srcdir
+
+done
+
+:
diff --git a/t/check-tests-in-builddir.sh b/t/check-tests-in-builddir.sh
new file mode 100755
index 000000000..9f1fe4a6b
--- /dev/null
+++ b/t/check-tests-in-builddir.sh
@@ -0,0 +1,92 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that the testsuite driver can find test in the srcdir as
+# well as in builddir, and that is prefers those in the builddir.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TESTS = foo.test bar.test
+EXTRA_DIST = $(TESTS)
+END
+
+cat > foo.test << 'END'
+#! /bin/sh
+exit ${FOO_EXIT_STATUS-0}
+END
+chmod a+x foo.test
+
+unset FOO_EXIT_STATUS || :
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+mkdir build
+cd build
+
+../configure
+
+cat > bar.test << 'END'
+#! /bin/sh
+exit 0
+END
+chmod a+x bar.test
+
+$MAKE check >out 2>&1 || { cat out; Exit1; }
+cat out
+# The simple-tests driver does not strip VPATH components from
+# the name of the test, but the parallel-tests driver should.
+if test x"$am_parallel_tests" = x"yes"; then
+ grep '\.\./foo' out && Exit 1
+ grep '^PASS: foo.test *$' out
+else
+ grep '^PASS: .*foo.test *$' out
+fi
+grep '^PASS: bar.test *$' out
+
+rm -f test-suite.log foo.log bar.log
+
+FOO_EXIT_STATUS=1 $MAKE check >out 2>&1 && { cat out; Exit1; }
+cat out
+# See comments above.
+if test x"$am_parallel_tests" = x"yes"; then
+ grep '\.\./foo' out && Exit 1
+ grep '^FAIL: foo.test *$' out
+else
+ grep '^FAIL: .*foo.test *$' out
+fi
+grep '^PASS: bar.test *$' out
+
+rm -f test-suite.log foo.log bar.log
+
+# Check that if the same test is present in srcdir and builddir,
+# the one in builddir is preferred.
+cp bar.test foo.test
+FOO_EXIT_STATUS=1 $MAKE check >out 2>&1 || { cat out; Exit1; }
+cat out
+grep '^PASS: foo.test *$' out
+grep '^PASS: bar.test *$' out
+
+# The tests in the builddir must be preferred also by "make dist".
+FOO_EXIT_STATUS=1 $MAKE distcheck
+
+:
diff --git a/t/check.sh b/t/check.sh
new file mode 100755
index 000000000..c9ab0fa0f
--- /dev/null
+++ b/t/check.sh
@@ -0,0 +1,42 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test Automake style tests.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+TESTS = frob.test
+END
+
+test x"$am_parallel_tests" != x"yes" || : > test-driver
+
+: > frob.test
+
+$ACLOCAL
+$AUTOMAKE
+
+grep 'check-TESTS.*:' Makefile.in
+grep 'check-DEJAGNU' Makefile.in && Exit 1
+
+# 'check-TESTS' is phony.
+sed -n '/^\.PHONY:/,/^$/p' Makefile.in | $EGREP '(^| )check-TESTS($| )'
+
+# 'check' should depend directly on 'check-am' (similar tests are
+# in check2.test and check3.test).
+$EGREP '^check:.* check-am( |$)' Makefile.in
+
+:
diff --git a/t/check10.sh b/t/check10.sh
new file mode 100755
index 000000000..3b3ee8bdf
--- /dev/null
+++ b/t/check10.sh
@@ -0,0 +1,85 @@
+#! /bin/sh
+# Copyright (C) 2008-2012 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/>.
+
+# Check singular and plural in test summaries.
+
+# This test only makes sense for the older serial testsuite driver.
+am_parallel_tests=no
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TESTS = fail pass skip xfail xpass fail2 pass2 skip2 xfail2 xpass2
+XFAIL_TESTS = xfail xpass xfail2 xpass2
+END
+
+cat > pass <<'END'
+#! /bin/sh
+exit 0
+END
+cat > fail <<'END'
+#! /bin/sh
+exit 1
+END
+cat > skip <<'END'
+#! /bin/sh
+exit 77
+END
+chmod a+x pass fail skip
+cp pass pass2
+cp pass xpass
+cp xpass xpass2
+cp fail xfail
+cp fail fail2
+cp xfail xfail2
+cp skip skip2
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+(
+ # Do not check for failure in this subshell
+ set +e
+ env TESTS=pass $MAKE -e check
+ env TESTS=fail $MAKE -e check
+ env TESTS=skip $MAKE -e check
+ env TESTS=xfail $MAKE -e check
+ env TESTS=xpass $MAKE -e check
+ env TESTS="pass pass2" $MAKE -e check
+ env TESTS="fail fail2" $MAKE -e check
+ env TESTS="skip skip2" $MAKE -e check
+ env TESTS="xfail xfail2" $MAKE -e check
+ env TESTS="xpass xpass2" $MAKE -e check
+ env TESTS='pass skip xfail' $MAKE -e check
+ $MAKE check
+ :
+) >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+grep '1 [tT]ests' stdout && Exit 1
+grep '[02-9] [tT]est ' stdout && Exit 1
+grep '1 .* were ' stdout && Exit 1
+grep '[02-9].* was .*run' stdout && Exit 1
+grep 'All 1 ' stdout && Exit 1
+$EGREP '1 (un)?expected (failures|passes)' stdout && Exit 1
+$EGREP '[^1] (un)?expected (failure|pass)\)' stdout && Exit 1
+
+:
diff --git a/t/check11.sh b/t/check11.sh
new file mode 100755
index 000000000..e78da0f16
--- /dev/null
+++ b/t/check11.sh
@@ -0,0 +1,60 @@
+#! /bin/sh
+# Copyright (C) 2009-2012 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/>.
+
+# Check skip summary.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TESTS = skip skip2
+END
+
+cat > skip <<'END'
+#! /bin/sh
+exit 77
+END
+chmod a+x skip
+cp skip skip2
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+env TESTS=skip $MAKE -e check >stdout || { cat stdout; Exit 1; }
+cat stdout
+if test x"$am_parallel_tests" = x"yes"; then
+ count_test_results total=1 pass=0 fail=0 skip=1 xfail=0 xpass=0 error=0
+else
+ grep '1.*passed' stdout && Exit 1
+ : For shells with buggy 'set -e'.
+fi
+
+env TESTS="skip skip2" $MAKE -e check >stdout || { cat stdout; Exit 1; }
+cat stdout
+if test x"$am_parallel_tests" = x"yes"; then
+ count_test_results total=2 pass=0 fail=0 skip=2 xfail=0 xpass=0 error=0
+else
+ grep '2.*passed' stdout && Exit 1
+ : For shells with buggy 'set -e'.
+fi
+
+:
diff --git a/t/check12.sh b/t/check12.sh
new file mode 100755
index 000000000..a21c6daff
--- /dev/null
+++ b/t/check12.sh
@@ -0,0 +1,214 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Test to make sure dejagnu tests, automake-style tests, and check-local
+# target can coexist.
+
+required=runtest
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS =
+EXTRA_DIST =
+CLEANFILES =
+END
+
+## Simple tests.
+
+cat > a.test << 'END'
+#!/bin/sh
+echo a.test: exit status: ${A_EXIT_STATUS-0}
+exit ${A_EXIT_STATUS-0}
+END
+cat > b.test << 'END'
+#!/bin/sh
+echo b.test: exit status: ${B_EXIT_STATUS-0}
+exit ${B_EXIT_STATUS-0}
+END
+chmod +x a.test b.test
+
+cat >> Makefile.am << 'END'
+TESTS = a.test b.test
+EXTRA_DIST += $(TESTS)
+END
+
+A_EXIT_STATUS=0; export A_EXIT_STATUS
+B_EXIT_STATUS=0; export B_EXIT_STATUS
+
+## DejaGnu tests.
+
+cat >> Makefile.am << 'END'
+AUTOMAKE_OPTIONS += dejagnu
+DEJATOOL = hammer spanner
+AM_RUNTESTFLAGS = HAMMER=$(srcdir)/hammer SPANNER=$(srcdir)/spanner
+EXTRA_DIST += hammer.test/hammer.exp
+EXTRA_DIST += spanner.test/spanner.exp
+END
+
+cat > hammer << 'END'
+#! /bin/sh
+echo "Everything looks like a ${NAIL-nail} to me!"
+END
+
+NAIL=nail; export NAIL
+
+cat > spanner << 'END'
+#! /bin/sh
+echo "I'm a right spanner!"
+END
+chmod +x hammer spanner
+
+mkdir hammer.test spanner.test
+
+cat > hammer.test/hammer.exp << 'END'
+set test test_hammer
+spawn $HAMMER
+expect {
+ "Everything looks like a nail to me!" { pass "$test" }
+ default { fail "$test" }
+}
+END
+
+cat > spanner.test/spanner.exp << 'END'
+set test test_spanner
+spawn $SPANNER
+expect {
+ "I'm a right spanner!" { pass "$test" }
+ default { fail "$test" }
+}
+END
+
+## User-defined extra tests.
+
+cat >> Makefile.am <<'END'
+check-local:
+ case $$CHECKLOCAL_EXIT_STATUS in \
+ 0) echo 'check-local succeeded :-)';; \
+ *) echo 'check-local failed :-(';; \
+ esac >local.log
+ exit $$CHECKLOCAL_EXIT_STATUS
+CLEANFILES += local.log
+END
+CHECKLOCAL_EXIT_STATUS=0; export CHECKLOCAL_EXIT_STATUS
+
+## Go with the testcase execution.
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+for vpath in : false; do
+
+ if $vpath; then
+ srcdir=..
+ mkdir build_
+ cd build_
+ else
+ srcdir=.
+ fi
+
+ if test -f config.status; then
+ $MAKE distclean
+ fi
+
+ $srcdir/configure
+
+ $MAKE check
+ test -f hammer.log
+ test -f hammer.sum
+ test -f spanner.log
+ test -f spanner.sum
+ # This checks will be run only by the autogenerated 'check12-p.test'.
+ if test x"$am_parallel_tests" = x"yes"; then
+ test -f test-suite.log
+ test -f a.log
+ test -f b.log
+ else :; fi
+ grep 'check-local succeeded :-)' local.log
+
+ cp -f config.status config-status.sav
+
+ $MAKE distclean
+ test ! -r hammer.log
+ test ! -r hammer.sum
+ test ! -r spanner.log
+ test ! -r spanner.sum
+ test ! -r test-suite.log
+ test ! -r a.log
+ test ! -r b.log
+ test ! -r local.log
+
+ mv -f config-status.sav config.status
+ ./config.status
+
+ NAIL=screw $MAKE check && Exit 1
+ test -f hammer.log
+ test -f hammer.sum
+ test -f spanner.log
+ test -f spanner.sum
+ grep 'FAIL: test_hammer' hammer.sum
+ grep 'FAIL:' spanner.sum && Exit 1
+
+ B_EXIT_STATUS=1 $MAKE check && Exit 1
+ # This checks will be run only by the autogenerated 'check12-p.test'.
+ if test x"$am_parallel_tests" = x"yes"; then
+ cat test-suite.log
+ cat a.log
+ cat b.log
+ grep '^a\.test: exit status: 0$' a.log
+ grep '^b\.test: exit status: 1$' b.log
+ grep '^FAIL: b$' test-suite.log
+ grep '^b\.test: exit status: 1$' test-suite.log
+ grep '^a\.test' test-suite.log && Exit 1
+ : For shells with busted 'set -e'.
+ else :; fi
+
+ CHECKLOCAL_EXIT_STATUS=1 $MAKE check && Exit 1
+ grep 'check-local failed :-(' local.log
+
+ # Do not trust the exit status of 'make -k'.
+ NAIL=screw B_EXIT_STATUS=23 CHECKLOCAL_EXIT_STATUS=1 $MAKE -k check || :
+ test -f hammer.log
+ test -f hammer.sum
+ test -f spanner.log
+ test -f spanner.sum
+ grep 'FAIL: test_hammer' hammer.sum
+ grep 'FAIL:' spanner.sum && Exit 1
+ # This checks will be run only by the autogenerated 'check12-p.test'.
+ if test x"$am_parallel_tests" = x"yes"; then
+ cat test-suite.log
+ cat a.log
+ cat b.log
+ grep '^a\.test: exit status: 0$' a.log
+ grep '^b\.test: exit status: 23$' b.log
+ grep '^FAIL: b$' test-suite.log
+ grep '^b\.test: exit status: 23$' test-suite.log
+ grep '^a\.test' test-suite.log && Exit 1
+ : For shells with busted 'set -e'.
+ else :; fi
+ grep 'check-local failed :-(' local.log
+
+ cd $srcdir
+
+done
+
+$MAKE distcheck
+
+:
diff --git a/t/check2.sh b/t/check2.sh
new file mode 100755
index 000000000..8a05c9cc8
--- /dev/null
+++ b/t/check2.sh
@@ -0,0 +1,70 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Test Automake style tests.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_CONFIG_FILES([dir/Makefile])
+AC_OUTPUT
+END
+
+mkdir dir
+
+cat > Makefile.am << 'END'
+SUBDIRS = dir
+TESTS = \
+ subrun.sh
+subrun.sh:
+ (echo '#! /bin/sh'; echo 'dir/echo.sh') > $@
+ chmod +x $@
+CLEANFILES = subrun.sh
+END
+
+cat > dir/Makefile.am << 'END'
+check_SCRIPTS = echo.sh
+echo.sh:
+ (echo '#! /bin/sh'; echo 'echo Hello') > $@
+ chmod +x $@
+CLEANFILES = echo.sh
+END
+
+if test x"$am_parallel_tests" = x"yes"; then
+ cp "$am_scriptdir/test-driver" .
+fi
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+
+$MAKE check >stdout || { cat stdout; Exit 1; }
+cat stdout
+grep '^PASS: subrun\.sh *$' stdout
+grep 'PASS.*echo\.sh' stdout && Exit 1
+
+# 'check' should depend directly on 'check-am' (similar tests are
+# in check.test and check3.test).
+$EGREP '^check:.* check-recursive( |$)' Makefile.in
+$EGREP '^check:.* check-am( |$)' dir/Makefile.in
+
+# Make sure subrun.sh is still on its line as above. This means Automake
+# hasn't rewritten the TESTS line unnecessarily (we can tell, because all
+# Automake variables are reformatted by VAR_PRETTY).
+grep '^ subrun\.sh$' Makefile.in
+
+:
diff --git a/t/check3.sh b/t/check3.sh
new file mode 100755
index 000000000..3edfd9872
--- /dev/null
+++ b/t/check3.sh
@@ -0,0 +1,79 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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 'check:' and 'install:' honor $(BUILT_SOURCES).
+# PR/359.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_CONFIG_FILES([dir/Makefile])
+AC_OUTPUT
+END
+
+mkdir dir
+
+cat > Makefile.am << 'END'
+BUILT_SOURCES = command1.inc
+SUBDIRS = dir
+TESTS = subrun.sh
+subrun.sh:
+ (echo '#! /bin/sh'; cat command1.inc) > $@
+ chmod +x $@
+command1.inc:
+ echo 'dir/echo.sh' > $@
+CLEANFILES = subrun.sh command1.inc
+END
+
+cat > dir/Makefile.am << 'END'
+BUILT_SOURCES = command2.inc
+check_SCRIPTS = echo.sh
+echo.sh:
+## The next line ensures that command1.inc has been built before
+## recurring into the subdir.
+ test -f ../command1.inc
+ (echo '#! /bin/sh'; cat command2.inc) > $@
+ chmod +x $@
+command2.inc:
+ echo 'echo Hello' > $@
+CLEANFILES = echo.sh command2.inc
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+./configure --prefix "`pwd`/inst"
+
+$MAKE check >stdout || { cat stdout; Exit 1; }
+cat stdout
+grep '^PASS: subrun\.sh *$' stdout
+grep 'PASS.*echo\.sh' stdout && Exit 1
+
+# check should depend directly on $(BUILT_SOURCES) (similar tests
+# are in check.test and check2.test).
+$EGREP '^check:.* \$\(BUILT_SOURCES\)( |$)' Makefile.in
+$EGREP '^check:.* \$\(BUILT_SOURCES\)( |$)' dir/Makefile.in
+
+$MAKE clean
+# Sanity checks
+test ! -f command1.inc
+test ! -f dir/command2.inc
+# Now make sure these two files are rebuilt during make install.
+$MAKE install
+test -f command1.inc
+test -f dir/command2.inc
+
+:
diff --git a/t/check4.sh b/t/check4.sh
new file mode 100755
index 000000000..26548b3db
--- /dev/null
+++ b/t/check4.sh
@@ -0,0 +1,83 @@
+#! /bin/sh
+# Copyright (C) 2005-2012 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 'make -k check' processes all directories.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_CONFIG_FILES([dir/Makefile])
+AC_OUTPUT
+END
+
+mkdir dir
+
+cat > Makefile.am <<'END'
+SUBDIRS = dir
+TESTS = ok.sh
+END
+
+echo TESTS = fail.sh >dir/Makefile.am
+
+cat >ok.sh <<'END'
+#!/bin/sh
+:
+END
+
+cat >dir/fail.sh <<'END'
+#!/bin/sh
+exit 1
+END
+
+chmod +x ok.sh dir/fail.sh
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+./configure --prefix "`pwd`/inst"
+
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+grep '^FAIL: fail\.sh *$' stdout
+grep '^PASS: ok\.sh *$' stdout && Exit 1
+
+# The exit status of 'make -k' can be anything
+# (depending on the Make implementation)
+$MAKE -k check >stdout || :
+cat stdout
+grep '^FAIL: fail\.sh *$' stdout
+grep '^PASS: ok\.sh *$' stdout
+
+# Should also works when -k is not in first position.
+$MAKE -s -k check >stdout || :
+cat stdout
+grep '^FAIL: fail\.sh *' stdout
+grep '^PASS: ok\.sh *' stdout
+
+# The rest of the test is for GNU Make.
+
+if using_gmake; then
+ # Try with a long-option that do not have a short option equivalent
+ # (here, --no-print-directory). That should cause all options to
+ # appear verbatim in MAKEFLAGS.
+ $MAKE --no-print-directory -k check >stdout || :
+ cat stdout
+ grep '^FAIL: fail\.sh *$' stdout
+ grep '^PASS: ok\.sh *$' stdout
+fi
+
+:
diff --git a/t/check5.sh b/t/check5.sh
new file mode 100755
index 000000000..31790f8af
--- /dev/null
+++ b/t/check5.sh
@@ -0,0 +1,61 @@
+#! /bin/sh
+# Copyright (C) 2006-2012 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/>.
+
+# Test TESTS = $(check_PROGRAMS)
+
+required='cc native'
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+check_PROGRAMS = one two
+TESTS = $(check_PROGRAMS)
+check-local:
+ test -f one$(EXEEXT)
+ test -f two$(EXEEXT)
+ touch ok
+.PHONY: print-tests
+print-tests:
+ echo BEG: $(TESTS) :END
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+cat > one.c << 'END'
+int main (void)
+{
+ return 0;
+}
+END
+cp one.c two.c
+
+./configure
+$MAKE check
+test -f ok
+EXEEXT=.bin $MAKE -e print-tests >stdout || { cat stdout; Exit 1; }
+cat stdout
+$FGREP 'BEG: one.bin two.bin :END' stdout
+# No am__EXEEXT_* variable is needed.
+grep '_EXEEXT_[1-9]' Makefile.in && Exit 1
+$FGREP 'TESTS = $(check_PROGRAMS)' Makefile.in
+
+:
diff --git a/t/check6.sh b/t/check6.sh
new file mode 100755
index 000000000..b6f6a670b
--- /dev/null
+++ b/t/check6.sh
@@ -0,0 +1,53 @@
+#! /bin/sh
+# Copyright (C) 2006-2012 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/>.
+
+# Test for PR 400: XFAIL_TESTS delimited by TABs.
+# Also test that Solaris make VPATH rewriting is honored
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TESTS = $(XFAIL_TESTS)
+XFAIL_TESTS = a b c
+END
+
+cat >>a <<'END'
+#! /bin/sh
+exit 1
+END
+
+cp a b
+cp a c
+
+chmod a+x a b c
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+$MAKE check
+$MAKE distclean
+mkdir build
+cd build
+../configure
+$MAKE check
+
+:
diff --git a/t/check7.sh b/t/check7.sh
new file mode 100755
index 000000000..574569b90
--- /dev/null
+++ b/t/check7.sh
@@ -0,0 +1,68 @@
+#! /bin/sh
+# Copyright (C) 2007-2012 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/>.
+
+# Check EXEEXT extension for XFAIL_TESTS.
+
+required=cc
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TESTS = $(XFAIL_TESTS)
+XFAIL_TESTS = a b c d
+check_PROGRAMS = a c d
+check_SCRIPTS = b
+EXTRA_DIST = $(check_SCRIPTS)
+
+.PHONY: print-xfail-tests
+print-xfail-tests:
+ @echo BEG: $(XFAIL_TESTS) :END
+END
+
+cat > b <<'END'
+#! /bin/sh
+exit 1
+END
+chmod a+x b
+
+cat > a.c <<'END'
+#include <stdlib.h>
+int main (void)
+{
+ return EXIT_FAILURE;
+}
+END
+
+cp a.c c.c
+cp a.c d.c
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+$MAKE check
+EXEEXT=.bin $MAKE -e print-xfail-tests >stdout || { cat stdout; Exit 1; }
+cat stdout
+$FGREP 'BEG: a.bin b c.bin d.bin :END' stdout
+
+$MAKE distcheck
+
+:
diff --git a/t/check8.sh b/t/check8.sh
new file mode 100755
index 000000000..75a4bef63
--- /dev/null
+++ b/t/check8.sh
@@ -0,0 +1,99 @@
+#! /bin/sh
+# Copyright (C) 2008-2012 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/>.
+
+# Check subdir TESTS.
+
+required='cc native'
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = subdir-objects
+TESTS = foo sub/foo $(check_PROGRAMS)
+XFAIL_TESTS = foo sub/baz
+check_PROGRAMS = bar sub/bar baz sub/baz
+END
+
+mkdir sub
+
+cat > foo <<'END'
+#! /bin/sh
+test -f "$srcdir/Makefile.am"
+END
+cat > sub/foo <<'END'
+#! /bin/sh
+test -f "$srcdir/Makefile.am"
+END
+chmod a+x foo sub/foo
+
+cat > bar.c <<'END'
+int main (void) { return 0; }
+END
+cat > sub/bar.c <<'END'
+int main (void) { return 0; }
+END
+cat > baz.c <<'END'
+#include <stdlib.h>
+int main (void) { return EXIT_FAILURE; }
+END
+cat > sub/baz.c <<'END'
+#include <stdlib.h>
+int main (void) { return EXIT_FAILURE; }
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+AM_COLOR_TESTS=always $MAKE check >stdout 2>stderr &&
+ { cat stdout; cat stderr >&2; Exit 1; }
+cat stdout
+cat stderr >&2
+grep 'XPASS.* foo$' stdout
+grep '^[^X]*PASS.* sub/foo$' stdout
+grep '^[^X]*PASS.* bar' stdout
+grep '^[^X]*PASS.* sub/bar' stdout
+grep '^[^X]*FAIL.* baz' stdout
+grep 'XFAIL.* sub/baz' stdout
+# 'parallel-tests' should not add circular dependencies.
+# Look for known warnings from a couple of 'make' implementations.
+grep -i 'circular.*dependency' stderr && Exit 1
+grep -i 'graph cycles' stderr && Exit 1
+
+$MAKE distclean
+
+mkdir build
+cd build
+../configure
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+# Note: we are not grepping for the space in the lines from the 'foo'
+# tests, due to the Solaris make VPATH rewriting (if we fix that, we
+# can still write a separate test for it).
+grep 'XPASS.*foo$' stdout
+grep '^[^X]*PASS.*sub/foo$' stdout
+grep '^[^X]*PASS.* bar' stdout
+grep '^[^X]*PASS.* sub/bar' stdout
+grep '^[^X]*FAIL.* baz' stdout
+grep 'XFAIL.* sub/baz' stdout
+
+:
diff --git a/t/checkall.sh b/t/checkall.sh
new file mode 100755
index 000000000..3b04d568a
--- /dev/null
+++ b/t/checkall.sh
@@ -0,0 +1,31 @@
+#!/bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test for bug where check target doesn't depend on all.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+bin_SCRIPTS = derived
+check-local:
+ true
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+grep '^check-am:.*all-am' Makefile.in
+grep 'MAKE.*check-local' Makefile.in
diff --git a/t/clean.sh b/t/clean.sh
new file mode 100755
index 000000000..279e162f3
--- /dev/null
+++ b/t/clean.sh
@@ -0,0 +1,26 @@
+#! /bin/sh
+# Copyright (C) 1998-2012 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/>.
+
+# Test to make sure a clean target depends on previous one.
+
+. ./defs || Exit 1
+
+: > Makefile.am
+
+$ACLOCAL
+$AUTOMAKE
+
+grep '^clean-am:.*mostlyclean-am' Makefile.in
diff --git a/t/clean2.sh b/t/clean2.sh
new file mode 100755
index 000000000..2599e97cb
--- /dev/null
+++ b/t/clean2.sh
@@ -0,0 +1,68 @@
+#! /bin/sh
+# Copyright (C) 2004-2012 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 distclean works in cygnus mode.
+# Report from Daniel Jacobowitz.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AM_MAINTAINER_MODE
+AC_CONFIG_FILES([sub/Makefile])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+SUBDIRS = sub
+
+data_DATA = bar
+
+bar:
+ touch $@
+
+DISTCLEANFILES = bar
+END
+
+mkdir sub
+
+cat > sub/Makefile.am << 'END'
+data_DATA = foo
+
+foo:
+ touch $@
+
+CLEANFILES = $(data_DATA)
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --cygnus
+
+./configure
+$MAKE
+ls -l
+test -f bar
+test -f sub/foo
+$MAKE distclean
+ls -l
+test ! -r bar
+test ! -r sub/foo
+test ! -r Makefile
+test ! -r config.status
+test -f Makefile.in
+test -f configure
+
+:
diff --git a/t/colneq.sh b/t/colneq.sh
new file mode 100755
index 000000000..0b5bbcd9b
--- /dev/null
+++ b/t/colneq.sh
@@ -0,0 +1,32 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test that := definitions produce warnings, but otherwise work.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+ICONS := $(wildcard *.xbm)
+END
+
+$ACLOCAL
+AUTOMAKE_fails
+grep ':=.*not portable' stderr
+
+$AUTOMAKE -Wno-portability
+grep '^ICONS *:= *\$(wildcard \*\.xbm) *$' Makefile.in
+
+:
diff --git a/t/colneq2.sh b/t/colneq2.sh
new file mode 100755
index 000000000..b313441af
--- /dev/null
+++ b/t/colneq2.sh
@@ -0,0 +1,40 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test that := in var substitutions works.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+t = a b c
+EXTRA_DIST = $(t:=.test)
+.PHONY: test
+test:
+ is $(EXTRA_DIST) == a.test b.test c.test
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+$MAKE test
+
+:
diff --git a/t/colneq3.sh b/t/colneq3.sh
new file mode 100755
index 000000000..728cc3299
--- /dev/null
+++ b/t/colneq3.sh
@@ -0,0 +1,44 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Test that := definitions work as expected at make time.
+
+required=GNUmake
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+BAR := $(FOO)
+BAZ = $(FOO)
+FOO := foo
+.PHONY: test
+test:
+ test x'$(FOO)' = x'foo'
+ test x'$(BAZ)' = x'foo'
+ test x'$(BAR)' = x
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -Wno-portability
+
+./configure
+$MAKE test
+
+:
diff --git a/t/colon.sh b/t/colon.sh
new file mode 100755
index 000000000..f5cb4e0f3
--- /dev/null
+++ b/t/colon.sh
@@ -0,0 +1,46 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test for bug reported by Nyul Laszlo. When using the ":" syntax in
+# AC_OUTPUT, Automake fails to find the correct file.
+
+. ./defs || Exit 1
+
+cat >> configure.ac <<'END'
+AC_CONFIG_FILES([foo.h:foo.hin])
+AC_OUTPUT
+END
+
+: > foo.hin
+
+cat > Makefile.am <<'END'
+.PHONY: test
+test: distdir
+ ls -l . $(distdir)
+ test -f foo.h
+ test -f $(distdir)/foo.hin
+END
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+
+./configure
+
+$MAKE test
+$MAKE distcheck
+
+:
diff --git a/t/colon2.sh b/t/colon2.sh
new file mode 100755
index 000000000..2b06151d2
--- /dev/null
+++ b/t/colon2.sh
@@ -0,0 +1,79 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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 ":" works with files automake generates.
+# See also sister test 'colon3.test'.
+
+. ./defs || Exit 1
+
+cat > configure.ac <<END
+AC_INIT([$me], [1.0])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([Makefile:zardoz.in])
+AC_OUTPUT
+END
+
+cat > zardoz.am <<END
+.PHONY: dummy
+dummy:
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+# Automake should have created zardoz.in.
+test -f zardoz.in
+
+# The generated file should refer to zardoz.in and zardoz.am, but
+# never just "zardoz".
+$FGREP 'zardoz.am' zardoz.in
+$FGREP 'zardoz.in' zardoz.in
+sed -e 's|zardoz\.am|zrdz.am|g' \
+ -e 's|zardoz\.in|zrdz.in|g' \
+ <zardoz.in | $FGREP 'zardoz' && Exit 1
+
+# The configure-generated Makefile should depend on zardoz.in, two.in and
+# three.in. The automake-generated zardoz.in should depend on zardoz.am.
+# Let's do this check the right way by running configure and make.
+
+str='%% ZaR DoZ %%'
+
+$AUTOCONF
+./configure
+test -f Makefile # Sanity check.
+
+$MAKE dummy
+# Again, make sure that the generated Makefile do not unduly
+# refer to 'zardoz' .
+$MAKE -n zardoz && Exit 1
+
+$sleep
+cat >> zardoz.am <<END
+check-local: testam testin testmk
+.PHONY: testam testin testmk
+testam:
+ grep '$str' \$(srcdir)/zardoz.am
+testin:
+ grep '$str' \$(srcdir)/zardoz.in
+testmk:
+ grep '$str' Makefile
+END
+$MAKE Makefile # For non-GNU make.
+$MAKE testam testin testmk
+
+$MAKE distcheck
+
+:
diff --git a/t/colon3.sh b/t/colon3.sh
new file mode 100755
index 000000000..5d7b3b22b
--- /dev/null
+++ b/t/colon3.sh
@@ -0,0 +1,91 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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 ":" works with files automake generates.
+# This test is for multiple ":"s.
+# See also sister test 'colon2.test'.
+
+. ./defs || Exit 1
+
+cat > configure.ac <<END
+AC_INIT([$me], [1.0])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([Makefile:zardoz.in:two.in:three.in])
+AC_OUTPUT
+END
+
+cat > zardoz.am <<END
+.PHONY: dummy
+dummy:
+END
+
+: > two.in
+: > three.in
+
+$ACLOCAL
+$AUTOMAKE
+
+# Automake should have created zardoz.in.
+test -f zardoz.in
+
+# The generated file should refer to zardoz.in and zardoz.am, but
+# never just "zardoz".
+$FGREP 'zardoz.am' zardoz.in
+$FGREP 'zardoz.in' zardoz.in
+sed -e 's|zardoz\.am|zrdz.am|g' \
+ -e 's|zardoz\.in|zrdz.in|g' \
+ <zardoz.in | $FGREP 'zardoz' && Exit 1
+
+# The configure-generated Makefile should depend on zardoz.in, two.in and
+# three.in. The automake-generated zardoz.in should depend on zardoz.am.
+# Let's do this check the right way by running configure and make.
+
+str='%% ZaR DoZ %%'
+str2='// 2_TwO_2 //'
+str3='== @thr33@ =='
+
+$AUTOCONF
+./configure
+test -f Makefile # Sanity check.
+
+$MAKE dummy
+# Again, make sure that the generated Makefile do not unduly
+# refer to 'zardoz' .
+$MAKE -n zardoz && Exit 1
+
+$sleep
+cat >> zardoz.am <<END
+check-local: testam testin testmk test2 test3
+.PHONY: testam testin test2 testmk test3
+testam:
+ grep '$str' \$(srcdir)/zardoz.am
+testin:
+ grep '$str' \$(srcdir)/zardoz.in
+testmk:
+ grep '$str' Makefile
+test2:
+ grep '$str2' \$(srcdir)/two.in
+test3:
+ grep '$str3' \$(srcdir)/three.in
+END
+echo "# $str2" >> two.in
+echo "# $str3" >> three.in
+$MAKE Makefile # For non-GNU make.
+$MAKE testam testin testmk test2 test3
+
+$MAKE distcheck
+
+:
diff --git a/t/colon4.sh b/t/colon4.sh
new file mode 100755
index 000000000..6dad3ab85
--- /dev/null
+++ b/t/colon4.sh
@@ -0,0 +1,39 @@
+#! /bin/sh
+# Copyright (C) 1998-2012 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 multiple ":"s in AC_CONFIG_FILES do not generate broken
+# rebuild rules.
+# Test from Maciej W. Rozycki.
+
+. ./defs || Exit 1
+
+cat >> configure.ac <<END
+AC_CONFIG_FILES([zardoz:one:two:three])
+AC_OUTPUT
+END
+
+: > Makefile.am
+: > one
+: > two
+: > three
+
+$ACLOCAL
+$AUTOMAKE
+
+# The rule should regenerate the file "zardoz", not a meaningless
+# file "'zardoz:one:two".
+$FGREP 'zardoz:one:two' Makefile.in && Exit 1
+Exit 0
diff --git a/t/colon5.sh b/t/colon5.sh
new file mode 100755
index 000000000..5a0ef379b
--- /dev/null
+++ b/t/colon5.sh
@@ -0,0 +1,71 @@
+#! /bin/sh
+# Copyright (C) 1998-2012 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/>.
+
+# Another multi-":" test, this time from Doug Evans.
+
+. ./defs || Exit 1
+
+cat > configure.ac <<END
+AC_INIT([$me], [1.0])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([Makefile:Makefile.in:Makefile.dep])
+AC_OUTPUT
+END
+
+: > Makefile.dep
+
+cat > Makefile.am <<'END'
+.PHONY: test-fs-layout test-grep test-distcommon test-distdir
+check-local: test-fs-layout test-grep test-distcommon test-distdir
+test-fs-layout:
+ test x'$(srcdir)' = '.' || test ! -r Makefile.dep
+test-grep:
+## The use of $(empty) prevents spurious matches.
+ grep '=GrEp$(empty)Me_am=' $(srcdir)/Makefile.in
+ grep '=GrEp$(empty)Me_dep=' $(srcdir)/Makefile.dep
+ grep '=GrEp$(empty)Me_am=' Makefile
+ grep '=GrEp$(empty)Me_dep=' Makefile
+test-distcommon:
+ echo ' ' $(DIST_COMMON) ' ' | grep '[ /]Makefile.dep '
+test-distdir: distdir
+ test -f $(distdir)/Makefile.dep
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+
+grep '=GrEpMe_am=' Makefile && Exit 1 # Sanity check.
+grep '=GrEpMe_dep=' Makefile && Exit 1 # Likewise.
+
+$MAKE test-distcommon
+$MAKE test-distdir
+
+$sleep
+
+echo '# =GrEpMe_am=' >> Makefile.am
+echo '# =GrEpMe_dep=' >> Makefile.dep
+
+$MAKE Makefile # For non-GNU make.
+$MAKE test-grep
+$MAKE test-distcommon
+$MAKE test-distdir
+
+$MAKE distcheck
+
+:
diff --git a/t/colon6.sh b/t/colon6.sh
new file mode 100755
index 000000000..9f14d2a09
--- /dev/null
+++ b/t/colon6.sh
@@ -0,0 +1,103 @@
+#! /bin/sh
+# Copyright (C) 1998-2012 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/>.
+
+# Yet another multi-":" test, this time from Ken Pizzini.
+
+. ./defs || Exit 1
+
+cat > configure.ac <<END
+AC_INIT([$me], [1.0])
+AM_INIT_AUTOMAKE
+# With this, version.good should depend on version.gin, while
+# Makefile should not depend on either of them.
+AC_CONFIG_FILES([demo/Makefile demo/version.good:demo/version.gin])
+AC_OUTPUT
+END
+
+mkdir demo
+: > demo/version.gin
+: > demo/Makefile.am
+
+$ACLOCAL
+$AUTOMAKE
+
+# These are older "grepping checks", kept mostly for backward-compatibility.
+# They might (unlikely, but possibly) require updating when automake
+# internals are changed. Just relax or remove if they become too fragile.
+$EGREP 'Makefile:.*(demo|version)' demo/Makefile.in && Exit 1
+grep 'version\.good:.*version\.gin' demo/Makefile.in
+
+$AUTOCONF
+
+for vpath in : false; do
+
+ if $vpath; then
+ srcdir=..
+ mkdir build
+ cd build
+ else
+ srcdir=.
+ fi
+
+ $srcdir/configure
+
+ test -f demo/version.good # Sanity check.
+ test ! -s demo/version.good # Likewise.
+
+ cd demo
+
+ $sleep
+ # HP-UX make considers targets with exact time stamps as one of their
+ # prerequisites out of date. Ensure Makefile is newer than config.status to
+ # avoid triggering the am--refresh rule in the (here-nonexistent) toplevel
+ # Makefile.
+ touch Makefile
+
+ # version.good should depend on version.gin.
+ echo "Rebuilt (srcdir=$srcdir)" > ../$srcdir/demo/version.gin
+ $MAKE version.good
+ $FGREP "Rebuilt (srcdir=$srcdir)" version.good
+
+ # Makefile should not depend on version.good.
+ rm -f version.good
+ $MAKE Makefile
+ test ! -r version.good
+
+ # version.good should be rebuilt from version.gin.
+ $MAKE version.good
+ test -f version.good
+
+ # Makefile should not depend on version.gin.
+ rm -f ../$srcdir/demo/version.gin
+ $MAKE Makefile
+ test ! -r ../$srcdir/demo/version.gin # Sanity check.
+
+ # version.good should depend on version.gin.
+ rm -f version.good
+ $MAKE version.good >output 2>&1 && { cat output; Exit 1; }
+ cat output
+ # Try to verify that we errored out for the right reason.
+ $FGREP version.gin output
+
+ cd .. # Back in top builddir.
+ cd $srcdir
+
+ # Re-create it for the next pass (if any).
+ : > demo/version.gin
+
+done
+
+:
diff --git a/t/colon7.sh b/t/colon7.sh
new file mode 100755
index 000000000..1b84d8046
--- /dev/null
+++ b/t/colon7.sh
@@ -0,0 +1,54 @@
+#! /bin/sh
+# Copyright (C) 1998-2012 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/>.
+
+# Another test for a failing ":" in AC_OUTPUT.
+# Report from Maciej Stachowiak.
+
+. ./defs || Exit 1
+
+cat > configure.ac << 'END'
+AC_INIT([colon7], [1.0])
+AM_INIT_AUTOMAKE
+dnl: Please do not add proper m4 quoting here.
+AC_OUTPUT(subdir/bar:subdir/foo \
+ Makefile \
+ subdir/Makefile
+)
+END
+
+mkdir subdir
+: > Makefile.am
+: > subdir/foo
+cat > subdir/Makefile.am << 'END'
+# DIST_COMMON should contain 'foo', not 'subdir/foo'.
+test:
+ case '$(DIST_COMMON)' in *subdir/foo*) exit 1;; *) exit 0;; esac
+ echo ' ' $(DIST_COMMON) ' ' | grep '[ /]foo '
+.PHONY: test
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+# Should nowhere refer to 'bar.in'.
+$FGREP 'bar.in' Makefile.in subdir/Makefile.in && Exit 1
+
+$AUTOCONF
+./configure
+cd subdir
+$MAKE test
+
+:
diff --git a/t/color.sh b/t/color.sh
new file mode 100755
index 000000000..6db445428
--- /dev/null
+++ b/t/color.sh
@@ -0,0 +1,157 @@
+#! /bin/sh
+# Copyright (C) 2007-2012 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/>.
+
+# Test Automake TESTS color output, by forcing it.
+# Keep this in sync with the sister test 'color2.test'.
+
+. ./defs || Exit 1
+
+TERM=ansi
+export TERM
+
+esc=''
+# Escape '[' for grep, below.
+red="$esc\[0;31m"
+grn="$esc\[0;32m"
+lgn="$esc\[1;32m"
+blu="$esc\[1;34m"
+mgn="$esc\[0;35m"
+std="$esc\[m"
+
+# Check that grep can parse nonprinting characters.
+# BSD 'grep' works from a pipe, but not a seekable file.
+# GNU or BSD 'grep -a' works on files, but is not portable.
+case `echo "$std" | grep .` in
+ "$std") ;;
+ *) skip_ "grep can't parse nonprinting characters";;
+esac
+
+cat >>configure.ac <<END
+AC_OUTPUT
+END
+
+cat >Makefile.am <<'END'
+AUTOMAKE_OPTIONS = color-tests
+TESTS = $(check_SCRIPTS)
+check_SCRIPTS = pass fail skip xpass xfail error
+XFAIL_TESTS = xpass xfail
+END
+
+cat >pass <<END
+#! /bin/sh
+exit 0
+END
+
+cat >fail <<END
+#! /bin/sh
+exit 1
+END
+
+cat >skip <<END
+#! /bin/sh
+exit 77
+END
+
+cat >error <<END
+#! /bin/sh
+exit 99
+END
+
+cp fail xfail
+cp pass xpass
+chmod +x pass fail skip xpass xfail error
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+test_color ()
+{
+ # Not a useless use of cat; see above comments about grep.
+ cat stdout | grep "^${grn}PASS${std}: .*pass"
+ cat stdout | grep "^${red}FAIL${std}: .*fail"
+ cat stdout | grep "^${blu}SKIP${std}: .*skip"
+ cat stdout | grep "^${lgn}XFAIL${std}: .*xfail"
+ cat stdout | grep "^${red}XPASS${std}: .*xpass"
+ # The old serial testsuite driver doesn't distinguish between failures
+ # and hard errors.
+ if test x"$am_parallel_tests" = x"yes"; then
+ cat stdout | grep "^${mgn}ERROR${std}: .*error"
+ else
+ cat stdout | grep "^${red}FAIL${std}: .*error"
+ fi
+ :
+}
+
+test_no_color ()
+{
+ # With make implementations that, like Solaris make, in case of errors
+ # print the whole failing recipe on standard output, we should content
+ # ourselves with a laxer check, to avoid false positives.
+ # Keep this in sync with lib/am/check.am:$(am__color_tests).
+ if $FGREP '= Xalways || test -t 1 ' stdout; then
+ # Extra verbose make, resort to laxer checks.
+ # Note that we also want to check that the testsuite summary is
+ # not unduly colorized.
+ (
+ set +e # In case some grepped regex below isn't matched.
+ # Not a useless use of cat; see above comments about grep.
+ cat stdout | grep "TOTAL.*:"
+ cat stdout | grep "PASS.*:"
+ cat stdout | grep "FAIL.*:"
+ cat stdout | grep "SKIP.*:"
+ cat stdout | grep "XFAIL.*:"
+ cat stdout | grep "XPASS.*:"
+ cat stdout | grep "ERROR.*:"
+ cat stdout | grep 'test.*expected'
+ cat stdout | grep 'test.*not run'
+ cat stdout | grep '===='
+ cat stdout | grep '[Ss]ee .*test-suite\.log'
+ cat stdout | grep '[Tt]estsuite summary'
+ ) | grep "$esc" && Exit 1
+ : For shells with broken 'set -e'
+ else
+ cat stdout | grep "$esc" && Exit 1
+ : For shells with broken 'set -e'
+ fi
+}
+
+for vpath in false :; do
+
+ if $vpath; then
+ mkdir build
+ cd build
+ srcdir=..
+ else
+ srcdir=.
+ fi
+
+ $srcdir/configure
+
+ AM_COLOR_TESTS=always $MAKE -e check >stdout && { cat stdout; Exit 1; }
+ cat stdout
+ test_color
+
+ $MAKE -e check >stdout && { cat stdout; Exit 1; }
+ cat stdout
+ test_no_color
+
+ $MAKE distclean
+ cd $srcdir
+
+done
+
+:
diff --git a/t/color2.sh b/t/color2.sh
new file mode 100755
index 000000000..b1c8830ee
--- /dev/null
+++ b/t/color2.sh
@@ -0,0 +1,194 @@
+#! /bin/sh
+# Copyright (C) 2007-2012 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/>.
+
+# Test Automake TESTS color output, using the expect(1) program.
+# Keep this in sync with the sister test 'color.test'.
+
+. ./defs || Exit 1
+
+TERM=ansi
+export TERM
+
+esc=''
+# Escape '[' for grep, below.
+red="$esc\[0;31m"
+grn="$esc\[0;32m"
+lgn="$esc\[1;32m"
+blu="$esc\[1;34m"
+mgn="$esc\[0;35m"
+std="$esc\[m"
+
+# Check that grep can parse nonprinting characters.
+# BSD 'grep' works from a pipe, but not a seekable file.
+# GNU or BSD 'grep -a' works on files, but is not portable.
+case `echo "$std" | grep .` in
+ "$std") ;;
+ *) skip_ "grep can't parse nonprinting characters";;
+esac
+
+# This test requires a working a working 'expect' program.
+# Creative quoting required to avoid spurious maintainer-check failure.
+(set +e; expect -c 'exit ''77'; test $? -eq 77) \
+ || skip_ "requires a working expect program"
+
+# Also, if the $MAKE program fails to consider the standard output as a
+# tty (this happens with e.g., BSD make and Solaris dmake when they're
+# run in parallel mode; see the autoconf manual), there is little point
+# in proceeding.
+cat > Makefile <<'END'
+all:
+## Creative quoting in the 'echo' below to avoid risk of spurious output
+## matches by 'expect', below.
+ @test -t 1 && echo "stdout" "is" "a" "tty"
+END
+
+cat > expect-check <<'END'
+eval spawn $env(MAKE)
+expect {
+ "stdout is a tty" { exit 0 }
+ default { exit 1 }
+}
+exit 1
+END
+MAKE=$MAKE expect -f expect-check \
+ || skip_ "make spawned by expect should have a tty stdout"
+rm -f expect-check Makefile
+
+# Do the tests.
+
+cat >>configure.ac <<END
+AC_OUTPUT
+END
+
+cat >Makefile.am <<'END'
+AUTOMAKE_OPTIONS = color-tests
+TESTS = $(check_SCRIPTS)
+check_SCRIPTS = pass fail skip xpass xfail error
+XFAIL_TESTS = xpass xfail
+END
+
+cat >pass <<END
+#! /bin/sh
+exit 0
+END
+
+cat >fail <<END
+#! /bin/sh
+exit 1
+END
+
+cat >skip <<END
+#! /bin/sh
+exit 77
+END
+
+cat >error <<END
+#! /bin/sh
+exit 99
+END
+
+cp fail xfail
+cp pass xpass
+chmod +x pass fail skip xpass xfail error
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+test_color ()
+{
+ # Not a useless use of cat; see above comments about grep.
+ cat stdout | grep "^${grn}PASS${std}: .*pass"
+ cat stdout | grep "^${red}FAIL${std}: .*fail"
+ cat stdout | grep "^${blu}SKIP${std}: .*skip"
+ cat stdout | grep "^${lgn}XFAIL${std}: .*xfail"
+ cat stdout | grep "^${red}XPASS${std}: .*xpass"
+ # The old serial testsuite driver doesn't distinguish between failures
+ # and hard errors.
+ if test x"$am_parallel_tests" = x"yes"; then
+ cat stdout | grep "^${mgn}ERROR${std}: .*error"
+ else
+ cat stdout | grep "^${red}FAIL${std}: .*error"
+ fi
+ :
+}
+
+test_no_color ()
+{
+ # With make implementations that, like Solaris make, in case of errors
+ # print the whole failing recipe on standard output, we should content
+ # ourselves with a laxer check, to avoid false positives.
+ # Keep this in sync with lib/am/check.am:$(am__color_tests).
+ if $FGREP '= Xalways || test -t 1 ' stdout; then
+ # Extra verbose make, resort to laxer checks.
+ # Note that we also want to check that the testsuite summary is
+ # not unduly colorized.
+ (
+ set +e # In case some grepped regex below isn't matched.
+ # Not a useless use of cat; see above comments about grep.
+ cat stdout | grep "TOTAL.*:"
+ cat stdout | grep "PASS.*:"
+ cat stdout | grep "FAIL.*:"
+ cat stdout | grep "SKIP.*:"
+ cat stdout | grep "XFAIL.*:"
+ cat stdout | grep "XPASS.*:"
+ cat stdout | grep "ERROR.*:"
+ cat stdout | grep 'test.*expected'
+ cat stdout | grep 'test.*not run'
+ cat stdout | grep '===='
+ cat stdout | grep '[Ss]ee .*test-suite\.log'
+ cat stdout | grep '[Tt]estsuite summary'
+ ) | grep "$esc" && Exit 1
+ : For shells with broken 'set -e'
+ else
+ cat stdout | grep "$esc" && Exit 1
+ : For shells with broken 'set -e'
+ fi
+}
+
+cat >expect-make <<'END'
+eval spawn $env(MAKE) -e check
+expect eof
+END
+
+for vpath in false :; do
+
+ if $vpath; then
+ mkdir build
+ cd build
+ srcdir=..
+ else
+ srcdir=.
+ fi
+
+ $srcdir/configure
+
+ MAKE=$MAKE expect -f $srcdir/expect-make >stdout \
+ || { cat stdout; Exit 1; }
+ cat stdout
+ test_color
+
+ AM_COLOR_TESTS=no MAKE=$MAKE expect -f $srcdir/expect-make >stdout \
+ || { cat stdout; Exit 1; }
+ cat stdout
+ test_no_color
+
+ $MAKE distclean
+ cd $srcdir
+
+done
+
+:
diff --git a/t/commen10.sh b/t/commen10.sh
new file mode 100755
index 000000000..d0c246abd
--- /dev/null
+++ b/t/commen10.sh
@@ -0,0 +1,32 @@
+#! /bin/sh
+# Copyright (C) 2005-2012 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 comments following trailing backslashes are diagnosed.
+# Report from Harald Dunkel.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+SUBDIRS = foo \
+# bar
+
+END
+
+mkdir foo
+
+$ACLOCAL
+AUTOMAKE_fails
+grep backslash stderr
diff --git a/t/commen11.sh b/t/commen11.sh
new file mode 100755
index 000000000..d4b264a48
--- /dev/null
+++ b/t/commen11.sh
@@ -0,0 +1,41 @@
+#! /bin/sh
+# Copyright (C) 2005-2012 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 backslash-newline-hash combinations are diagnosed as
+# comments following a trailing backslash, even when the combination
+# follows a variable assignment that is preceded by a comment.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+# initial comment
+variable = value-before-comment \
+#
+
+# comment
+SUBDIRS = foo \
+# bar
+
+END
+
+mkdir foo
+
+$ACLOCAL
+AUTOMAKE_fails
+grep '^Makefile\.am:3:.*backslash' stderr
+grep '^Makefile\.am:7:.*backslash' stderr
+
+:
diff --git a/t/comment.sh b/t/comment.sh
new file mode 100755
index 000000000..6ca98ba13
--- /dev/null
+++ b/t/comment.sh
@@ -0,0 +1,27 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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 that '#' as start of word in AUTOMAKE_OPTIONS means
+# comment.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = #no such option
+END
+
+$ACLOCAL
+$AUTOMAKE
diff --git a/t/comment2.sh b/t/comment2.sh
new file mode 100755
index 000000000..a63075c92
--- /dev/null
+++ b/t/comment2.sh
@@ -0,0 +1,34 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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 comment recognition works in PROGRAMS. Report from Mark
+# Galassi.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = sim_products receive_th receive_pos # image_proc
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+grep '^image_proc' Makefile.in && Exit 1
+Exit 0
diff --git a/t/comment3.sh b/t/comment3.sh
new file mode 100755
index 000000000..8f80945c2
--- /dev/null
+++ b/t/comment3.sh
@@ -0,0 +1,31 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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 that '#' after a tab is a failure.
+# The Tru64 Unix V5.1 system make will pass these to the
+# shell, which in turn can't find '#' as a command.
+# Sigh. Some vendors must be destroyed.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+install-data-local:
+ # Tru64 Unix must die
+END
+
+$ACLOCAL
+AUTOMAKE_fails
+grep 'Makefile.am:2:.*#' stderr
diff --git a/t/comment4.sh b/t/comment4.sh
new file mode 100755
index 000000000..42e7bf9ad
--- /dev/null
+++ b/t/comment4.sh
@@ -0,0 +1,39 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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 commented variables are output near their comments.
+
+. ./defs || Exit 1
+
+cat >> configure.ac <<'EOF'
+AC_OUTPUT
+EOF
+
+cat > Makefile.am << 'EOF'
+# UnIqUe_COPYRIGHT_BOILERPLATE
+
+# UnIqUe_MUMBLE_COMMENT
+mumble = UnIqUe_MUMBLE_VALUE
+EOF
+
+$ACLOCAL
+$AUTOMAKE
+# UnIqUe_COPYRIGHT_BOILERPLATE should appear near the top of the file
+test `sed -n -e '1,/UnIqUe_COPYRIGHT_BOILERPLATE/p' Makefile.in \
+ | wc -l` -le 30
+# UnIqUe_MUMBLE_COMMENT should appear right before the mumble declaration.
+test `sed -n -e '/UnIqUe_MUMBLE_COMMENT/,/UnIqUe_MUMBLE_VALUE/p' Makefile.in \
+ | wc -l` -eq 2
diff --git a/t/comment5.sh b/t/comment5.sh
new file mode 100755
index 000000000..0c2a4d601
--- /dev/null
+++ b/t/comment5.sh
@@ -0,0 +1,85 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Test for PR/280.
+# (Automake should complain about trailing backslashes in comments.)
+
+. ./defs || Exit 1
+
+cat >> configure.ac <<'EOF'
+AC_OUTPUT
+EOF
+
+cat > Makefile.am << 'EOF'
+all-local:
+ @echo ${var}
+
+# a comment with backslash \
+
+
+var = foo
+EOF
+
+$ACLOCAL
+AUTOMAKE_fails
+grep '^Makefile.am:5: error: blank line following trailing backslash' stderr
+
+
+## Here is a second test because head comments are
+## handled differently in Automake 1.5.
+
+cat > Makefile.am << 'EOF'
+# a comment with backslash \
+
+
+all-local:
+ @echo ${var}
+
+var = foo
+EOF
+
+AUTOMAKE_fails
+grep '^Makefile.am:2: error: blank line following trailing backslash' stderr
+
+
+## Make sure we print an 'included' stack on errors.
+
+echo 'include Makefile.inc'> Makefile.am
+cat > Makefile.inc << 'EOF'
+# a comment with backslash \
+
+EOF
+
+AUTOMAKE_fails
+grep '^Makefile.inc:2: error: blank line following trailing backslash' stderr
+grep '^Makefile.am:1: .*included from here' stderr
+grep -v '^Makefile.am:1: .*error:' stderr
+
+
+## Make sure backslashes are still allowed within a comment.
+## This usually happens when commenting out a Makefile rule.
+
+cat > Makefile.am << 'EOF'
+all-local:
+ @echo ${var}
+
+# a comment with backslash \
+# but terminated by a line without backslash
+
+var = foo
+EOF
+
+$AUTOMAKE
diff --git a/t/comment6.sh b/t/comment6.sh
new file mode 100755
index 000000000..9fd8d1069
--- /dev/null
+++ b/t/comment6.sh
@@ -0,0 +1,68 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Test for PR/322.
+# Automake 1.6.1 seems to have a problem parsing comments that use
+# '\' to span multiple lines.
+
+. ./defs || Exit 1
+
+cat >> configure.ac <<'EOF'
+AC_OUTPUT
+EOF
+
+## There are two tests: one with backslashed comments at the top
+## of the file, and one with a rule first. This is because
+## Comments at the top of the file are handled specially
+## since Automake 1.5.
+
+cat > Makefile.am << 'EOF'
+# SOME_FILES = \
+ file1 \
+ file2 \
+ file3
+
+all-local:
+ @echo Good
+
+EOF
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+$MAKE
+
+grep '# SOME_FILES' Makefile
+grep '# *file3' Makefile
+
+cat > Makefile.am << 'EOF'
+all-local:
+ @echo Good
+
+# SOME_FILES = \
+ file1 \
+ file2 \
+ file3
+EOF
+
+$AUTOMAKE
+./configure
+$MAKE
+grep '# SOME_FILES' Makefile
+grep '# *file3' Makefile
+
+:
diff --git a/t/comment7.sh b/t/comment7.sh
new file mode 100755
index 000000000..5637fb7b6
--- /dev/null
+++ b/t/comment7.sh
@@ -0,0 +1,53 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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 comment for conditional variables are output near the
+# corresponding conditional definitions.
+
+. ./defs || Exit 1
+
+cat >> configure.ac <<'EOF'
+AM_CONDITIONAL([COND], [true])
+EOF
+
+cat > Makefile.am << 'EOF'
+if COND
+# Comment for VAR in COND_TRUE.
+VAR = foo
+else
+# Comment for VAR in COND_FALSE.
+VAR = bar
+endif
+EOF
+
+$ACLOCAL
+$AUTOMAKE
+
+# The VAR definition appears once for each condition.
+test `grep '@COND_TRUE@VAR' Makefile.in | wc -l` = 1
+test `grep '@COND_FALSE@VAR' Makefile.in | wc -l` = 1
+
+# Make sure the right definition follows each comment.
+sed -n '/^#.*VAR.*COND_TRUE/ {
+ n
+ p
+ }' Makefile.in |
+ grep '@COND_TRUE@VAR = foo'
+sed -n '/^#.*VAR.*COND_FALSE/ {
+ n
+ p
+ }' Makefile.in |
+ grep '@COND_FALSE@VAR = bar'
diff --git a/t/comment8.sh b/t/comment8.sh
new file mode 100755
index 000000000..3ed31e7c7
--- /dev/null
+++ b/t/comment8.sh
@@ -0,0 +1,48 @@
+#! /bin/sh
+# Copyright (C) 2004-2012 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 += does not append to a comment.
+# Report from Stepan Kasal.
+
+. ./defs || Exit 1
+
+cat >> configure.ac <<'EOF'
+AM_CONDITIONAL([COND1], [true])
+AM_CONDITIONAL([COND2], [true])
+AC_OUTPUT
+EOF
+
+cat > Makefile.am << 'EOF'
+VAR = valA# comA ## com C
+VAR += valB # comB
+if COND1
+ VAR += val1 # com1
+endif COND1
+VAR += valC
+if COND2
+ VAR += val2 # com2
+endif COND2
+
+.PHONY: test
+test:
+ is $(VAR) == valA valB val1 valC val2
+EOF
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+$MAKE test
diff --git a/t/comment9.sh b/t/comment9.sh
new file mode 100755
index 000000000..a75fafc41
--- /dev/null
+++ b/t/comment9.sh
@@ -0,0 +1,53 @@
+#! /bin/sh
+# Copyright (C) 2005-2012 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 ##-comments are ignored in variable definitions.
+# Report from Julien Sopena.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'EOF'
+TESTS = \
+ 1.test \
+ 2.test \
+ 3.test \
+## 4.test \
+ 5.test \
+ 6.test \
+ 7.test
+EOF
+
+: > test-driver
+
+$ACLOCAL
+$AUTOMAKE
+
+sed -n -e '/^TESTS =.*\\$/ {
+ :loop
+ p
+ n
+ t clear
+ :clear
+ s/\\$/\\/
+ t loop
+ p
+ n
+ }' -e '/^TESTS =/ p' Makefile.in > tests
+
+grep '3\.test' tests
+grep '##' tests && Exit 1
+grep '4\.test' tests && Exit 1
+grep '5\.test' tests
diff --git a/t/comments-in-var-def.sh b/t/comments-in-var-def.sh
new file mode 100755
index 000000000..5c01d76c1
--- /dev/null
+++ b/t/comments-in-var-def.sh
@@ -0,0 +1,56 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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 Automake ignores in-line comments when using variables,
+# but preserve them in the output.
+
+. ./defs || Exit 1
+
+cat >> configure.ac <<'END'
+AC_OUTPUT
+END
+
+# Use a slash in the comment, because automake takes the dirname
+# of TEXINFO_TEX to compute $(am__TEXINFO_TEX_DIR).
+cat > Makefile.am << 'END'
+TEXINFO_TEX = tex/texinfo.tex # some comment w/ a slash
+info_TEXINFOS = main.texi
+.PHONY: test
+test:
+ test tex/texinfo.tex = $(TEXINFO_TEX)
+ test -d '$(am__TEXINFO_TEX_DIR)'
+ case '$(am__TEXINFO_TEX_DIR)' in tex|./tex) :;; *) exit 1;; esac
+END
+
+cat > main.texi << 'END'
+\input texinfo
+@setfilename main.info
+END
+
+mkdir tex
+: > tex/texinfo.tex
+
+$ACLOCAL
+$AUTOMAKE
+
+grep TEX Makefile.in # For debugging.
+grep '^TEXINFO_TEX *= *tex/texinfo\.tex *# some comment w/ a slash *$' Makefile.in
+
+$AUTOCONF
+./configure
+$MAKE test
+
+:
diff --git a/t/compile.sh b/t/compile.sh
new file mode 100755
index 000000000..638a0d724
--- /dev/null
+++ b/t/compile.sh
@@ -0,0 +1,45 @@
+#! /bin/sh
+# Copyright (C) 2004-2012 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 'compile' preserves spaces in its arguments.
+
+am_create_testdir=empty
+. ./defs || Exit 1
+
+get_shell_script compile
+
+# -o 'a c' should not be stripped because 'a c' is not an object
+# (it does not matter whether touch creates ./-- or not)
+./compile touch a.o -- -o 'a c' a.c
+test -f 'a c'
+test -f ./-o
+test -f a.o
+test -f a.c
+
+rm -f 'a c' ./-o a.o a.c
+
+./compile touch a.o -- -o 'a c.o' a.c
+test -f 'a c.o'
+test ! -f ./-o
+test ! -f a.o
+test -f a.c
+
+# Make sure 'compile' works for .obj too.
+./compile touch a.obj -- -o ac.obj a.c
+test ! -f a.obj
+test ac.obj
+
+:
diff --git a/t/compile2.sh b/t/compile2.sh
new file mode 100755
index 000000000..f808607bd
--- /dev/null
+++ b/t/compile2.sh
@@ -0,0 +1,84 @@
+#! /bin/sh
+# Copyright (C) 2009-2012 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 'compile' deals correctly with Windows-style paths.
+
+am_create_testdir=empty
+. ./defs || Exit 1
+
+get_shell_script compile
+
+cat >mycc <<'END'
+source_seen=no
+for arg
+do
+ test "X$arg" = X-o && exit 1
+ test "X$arg" = "X$amtest_source" && source_seen=yes
+done
+if test "$source_seen" != yes; then
+ echo "$0: no source file seen" >&2
+ exit 1
+fi
+if test ! -f "$amtest_source"; then
+ echo "$0: $amtest_source not readable" >&2
+ exit 1
+fi
+if test ! -d "$amtest_lock"; then
+ echo "$0: no lockdir $amtest_lock" >&2
+ exit 1
+fi
+touch "$amtest_obj"
+END
+
+chmod +x ./mycc
+
+# In case this test runs on a system with backslash directory separators:
+mkdir libltdl libltdl/libltdl
+
+# Backslashes in the input and the output name should be accepted.
+# Since this test might run on non-w32 systems, we need to be careful not
+# to use any backslash sequences which might be interpreted by 'echo'.
+amtest_source='libltdl\libltdl\slist.c'
+amtest_object='libltdl\libltdl\libltdl_libltdl_la-slist.obj'
+amtest_obj='slist.o'
+amtest_lock='slist_o.d'
+export amtest_source amtest_object amtest_obj amtest_lock
+
+: > "$amtest_source"
+./compile ./mycc -c "$amtest_source" -o "$amtest_object"
+test -f "$amtest_object"
+
+# Absolute Windows paths should be accepted.
+# Do not actually run this test on anything that could be Windows.
+if test -d 'C:\'; then
+ skip_ "this test shouldn't run on a Windows-like system"
+fi
+case $PATH_SEPARATOR in
+ ';'|':');;
+ *) skip_ "unrecognized PATH separator '$PATH_SEPARATOR'"
+esac
+
+amtest_source='C:\libltdl\libltdl\slist.c'
+amtest_object='C:\libltdl\libltdl\libltdl_libltdl_la-slist.obj'
+amtest_obj='slist.o'
+amtest_lock='slist_o.d'
+export amtest_source amtest_object amtest_obj amtest_lock
+
+: > "$amtest_source"
+./compile ./mycc -c "$amtest_source" -o "$amtest_object"
+test -f "$amtest_object"
+
+:
diff --git a/t/compile3.sh b/t/compile3.sh
new file mode 100755
index 000000000..009de7023
--- /dev/null
+++ b/t/compile3.sh
@@ -0,0 +1,58 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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 'compile' wraps the Microsoft C/C++ compiler (cl) correctly
+
+am_create_testdir=empty
+required=xsi-lib-shell
+. ./defs || Exit 1
+
+get_shell_script compile
+
+# Use a dummy cl, since cl isn't readily available on all systems
+cat >cl <<'END'
+#! /bin/sh
+echo "$@"
+END
+
+chmod +x ./cl
+
+# POSIX mandates that the compiler accepts a space between the -I,
+# -l and -L options and their respective arguments. Traditionally,
+# this should work also without a space. Try both usages.
+for sp in '' ' '; do
+ # Check if compile handles "-o foo", -I, -l, -L, -Xlinker -Wl,
+ opts=`LIB= ./compile ./cl foo.c -o foo -l${sp}bar -L${sp}gazonk -I${sp}baz -Xlinker foobar -Wl,-foo,bar`
+ test x"$opts" = x"foo.c -Fefoo bar.lib -Ibaz -link -LIBPATH:gazonk foobar -foo bar"
+
+ # Check if compile handles "-o foo.obj"
+ opts=`./compile ./cl -c foo.c -o foo.obj -I${sp}baz`
+ test x"$opts" = x"-c foo.c -Fofoo.obj -Ibaz"
+
+ # Check if compile handles "-o foo.o"
+ opts=`./compile ./cl -c foo.c -o foo.o -I${sp}baz`
+ test x"$opts" = x"-c foo.c -Fofoo.o -Ibaz"
+
+ # Check if compile handles "foo.cc" as C++.
+ opts=`./compile ./cl -c foo.cc -o foo.o -I${sp}baz`
+ test x"$opts" = x"-c -Tpfoo.cc -Fofoo.o -Ibaz"
+
+ # Check if compile clears the "eat" variable properly.
+ opts=`eat=1 ./compile ./cl -c foo.c -o foo.obj -I${sp}baz`
+ test x"$opts" = x"-c foo.c -Fofoo.obj -Ibaz"
+done
+
+:
diff --git a/t/compile4.sh b/t/compile4.sh
new file mode 100755
index 000000000..bb9f6719c
--- /dev/null
+++ b/t/compile4.sh
@@ -0,0 +1,93 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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 'compile' wraps the Microsoft C/C++ compiler (cl) correctly
+# with respect to absolute paths.
+
+required='cl'
+. ./defs || Exit 1
+
+get_shell_script compile
+
+mkdir sub
+
+cat >sub/foo.c <<'EOF'
+int
+foo ()
+{
+ return 0;
+}
+EOF
+
+cat >main.c <<'EOF'
+extern int foo ();
+int
+main ()
+{
+ return foo ();
+}
+EOF
+
+absfoodir=`pwd`/sub
+absmainc=`pwd`/main.c
+absmainobj=`pwd`/main.obj
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_CC_C_O
+AM_PROG_AR
+AC_PROG_RANLIB
+AC_CONFIG_FILES([sub/Makefile])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+SUBDIRS = sub
+END
+
+cat > sub/Makefile.am << 'END'
+lib_LIBRARIES = libfoo.a
+libfoo_a_SOURCES = foo.c
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+./configure
+$MAKE
+
+./compile cl $CPPFLAGS $CFLAGS -c -o "$absmainobj" "$absmainc"
+
+# cl expects archives to be named foo.lib, not libfoo.a so
+# make a simple copy here if needed. This is a severe case
+# of badness, but ignore that since this is not what is
+# being tested here...
+if test -f sub/libfoo.a; then
+ cp sub/libfoo.a sub/foo.lib
+fi
+
+# POSIX mandates that the compiler accepts a space between the -I,
+# -l and -L options and their respective arguments. Traditionally,
+# this should work also without a space. Try both usages.
+for sp in '' ' '; do
+ rm -f main
+
+ ./compile cl $CFLAGS $LDFLAGS -L${sp}"$absfoodir" "$absmainobj" -o main -l${sp}foo
+
+ ./main
+done
+
+:
diff --git a/t/compile5.sh b/t/compile5.sh
new file mode 100755
index 000000000..02afca3fd
--- /dev/null
+++ b/t/compile5.sh
@@ -0,0 +1,85 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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 the file name translation in the 'compile' script works
+# correctly
+
+. ./defs || Exit 1
+
+get_shell_script compile
+
+# Use a dummy cl, since cl isn't readily available on all systems
+cat >cl <<'END'
+#! /bin/sh
+echo "$@"
+END
+
+chmod +x ./cl
+
+cat >>configure.ac << 'END'
+AC_CANONICAL_HOST
+AC_CONFIG_FILES([check_host], [chmod +x check_host])
+AC_OUTPUT
+END
+
+: >Makefile.am
+
+# This will be sourced, nor executed.
+cat >check_host.in << 'END'
+case '@host_os@' in
+ mingw*)
+ ;;
+ *)
+ skip_ "target OS is not MinGW"
+ ;;
+esac
+case @build_os@ in
+ mingw* | cygwin*)
+ ;;
+ *)
+ winepath -w / \
+ || skip_ "not on MinGW or Cygwin, and winepath not available"
+ ;;
+esac
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+./configure
+. ./check_host
+
+pwd=`pwd`
+
+# POSIX mandates that the compiler accepts a space between the -I,
+# -l and -L options and their respective arguments. Traditionally,
+# this should work also without a space. Try both usages.
+for sp in '' ' '; do
+ # Check if "compile cl" transforms absolute file names to
+ # host format (e.g /somewhere -> c:/msys/1.0/somewhere).
+
+ res=`./compile ./cl -L${sp}"$pwd" | sed -e 's/-link -LIBPATH://'`
+
+ case $res in
+ ?:[\\/]*)
+ ;;
+ *)
+ Exit 1
+ ;;
+ esac
+done
+
+:
diff --git a/t/compile6.sh b/t/compile6.sh
new file mode 100755
index 000000000..9db337328
--- /dev/null
+++ b/t/compile6.sh
@@ -0,0 +1,105 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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 'compile' searches libraries correctly
+
+am_create_testdir=empty
+required=xsi-lib-shell
+. ./defs || Exit 1
+
+get_shell_script compile
+
+# Use a dummy cl, since cl isn't readily available on all systems
+cat >cl <<'END'
+#! /bin/sh
+echo "$@"
+END
+
+chmod +x ./cl
+
+# POSIX mandates that the compiler accepts a space between the -I,
+# -l and -L options and their respective arguments. Traditionally,
+# this should work also without a space. Try both usages.
+for sp in '' ' '; do
+ rm -rf lib lib2 syslib "sys lib2"
+
+ mkdir syslib
+ :> syslib/foo.lib
+
+ syslib=`pwd`/syslib
+ LIB=$syslib
+ export LIB
+
+ mkdir lib
+ :> lib/bar.lib
+ :> lib/bar.dll.lib
+
+ # Check if compile library search correctly
+ opts=`./compile ./cl foo.c -o foo -L${sp}lib -l${sp}bar -l${sp}foo`
+ test x"$opts" = x"foo.c -Fefoo lib/bar.dll.lib $syslib/foo.lib -link -LIBPATH:lib"
+
+ # Check if -static makes compile avoid bar.dll.lib
+ opts=`./compile ./cl foo.c -o foo -L${sp}lib -static -l${sp}bar -l${sp}foo`
+ test x"$opts" = x"foo.c -Fefoo lib/bar.lib $syslib/foo.lib -link -LIBPATH:lib"
+
+ :> syslib/bar.lib
+ :> syslib/bar.dll.lib
+
+ # Check if compile finds bar.dll.lib in syslib
+ opts=`./compile ./cl foo.c -o foo -l${sp}bar -l${sp}foo`
+ test x"$opts" = x"foo.c -Fefoo $syslib/bar.dll.lib $syslib/foo.lib"
+
+ # Check if compile prefers -L over $LIB
+ opts=`./compile ./cl foo.c -o foo -L${sp}lib -l${sp}bar -l${sp}foo`
+ test x"$opts" = x"foo.c -Fefoo lib/bar.dll.lib $syslib/foo.lib -link -LIBPATH:lib"
+
+ mkdir lib2
+ :> lib2/bar.dll.lib
+
+ # Check if compile avoids bar.dll.lib in lib2 when -static
+ opts=`./compile ./cl foo.c -o foo -L${sp}lib2 -static -l${sp}bar -l${sp}foo`
+ test x"$opts" = x"foo.c -Fefoo $syslib/bar.lib $syslib/foo.lib -link -LIBPATH:lib2"
+
+ # Check if compile gets two different bar libraries when -static
+ # is added in the middle
+ opts=`./compile ./cl foo.c -o foo -L${sp}lib2 -L${sp}lib -l${sp}bar -static -l${sp}bar`
+ test x"$opts" = x"foo.c -Fefoo lib2/bar.dll.lib lib/bar.lib -link -LIBPATH:lib2 -LIBPATH:lib"
+
+ # Check if compile gets the correct bar.dll.lib
+ opts=`./compile ./cl foo.c -o foo -L${sp}lib -L${sp}lib2 -l${sp}bar -l${sp}foo`
+ test x"$opts" = x"foo.c -Fefoo lib/bar.dll.lib $syslib/foo.lib -link -LIBPATH:lib -LIBPATH:lib2"
+
+ # Check if compile gets the correct bar.dll.lib
+ opts=`./compile ./cl foo.c -o foo -L${sp}lib2 -L${sp}lib -l${sp}bar -l${sp}foo`
+ test x"$opts" = x"foo.c -Fefoo lib2/bar.dll.lib $syslib/foo.lib -link -LIBPATH:lib2 -LIBPATH:lib"
+
+ mkdir "sys lib2"
+ :> "sys lib2/foo.dll.lib"
+
+ syslib2="`pwd`/sys lib2"
+ LIB="$syslib2;$LIB"
+
+ # Check if compile handles spaces in $LIB and that it prefers the order
+ # in a multi-component $LIB.
+ opts=`./compile ./cl foo.c -o foo -l${sp}foo`
+ test x"$opts" = x"foo.c -Fefoo $syslib2/foo.dll.lib"
+
+ # Check if compile handles the 2nd directory in a multi-component $LIB.
+ opts=`./compile ./cl foo.c -o foo -static -l${sp}foo`
+ test x"$opts" = x"foo.c -Fefoo $syslib/foo.lib"
+done
+
+:
diff --git a/t/compile_f90_c_cxx.sh b/t/compile_f90_c_cxx.sh
new file mode 100755
index 000000000..806c59f92
--- /dev/null
+++ b/t/compile_f90_c_cxx.sh
@@ -0,0 +1,43 @@
+#! /bin/sh
+# Copyright (C) 1998-2012 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/>.
+
+# Test to make sure rules to invoke all compilers are selected with
+# mixed source objects.
+# (copied from compile_f_c_cxx.test) Mike Nolta <mrnolta@princeton.edu>
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_PROG_CXX
+AC_PROG_FC
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = foo
+foo_SOURCES = foo.f90 bar.c baz.cc
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+# Look for the macros at the beginning of rules.
+tab=
+$FGREP "$tab\$(COMPILE)" Makefile.in
+$FGREP "$tab\$(CXXCOMPILE)" Makefile.in
+$FGREP "$tab\$(FCCOMPILE)" Makefile.in
+
+:
diff --git a/t/compile_f_c_cxx.sh b/t/compile_f_c_cxx.sh
new file mode 100755
index 000000000..99893d8c3
--- /dev/null
+++ b/t/compile_f_c_cxx.sh
@@ -0,0 +1,46 @@
+#! /bin/sh
+# Copyright (C) 1998-2012 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/>.
+
+# Test to make sure rules to invoke all compilers are selected with
+# mixed source objects.
+# Matthew D. Langston <langston@SLAC.Stanford.EDU>
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_PROG_CXX
+AC_PROG_F77
+AC_F77_LIBRARY_LDFLAGS
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = foo
+foo_SOURCES = foo.f bar.c baz.cc
+END
+
+: > config.guess
+: > config.sub
+
+$ACLOCAL
+$AUTOMAKE
+
+# Look for the macros at the beginning of rules.
+$FGREP "$tab\$(COMPILE)" Makefile.in
+$FGREP "$tab\$(CXXCOMPILE)" Makefile.in
+$FGREP "$tab\$(F77COMPILE)" Makefile.in
+
+:
diff --git a/t/cond-basic.sh b/t/cond-basic.sh
new file mode 100755
index 000000000..5d18b5c5f
--- /dev/null
+++ b/t/cond-basic.sh
@@ -0,0 +1,42 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Check basic use of conditionals.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AM_CONDITIONAL([TEST], [true])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+if TEST
+target: true
+ action
+else
+target: false
+endif
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+grep '^@TEST_TRUE@target: true' Makefile.in
+grep "^@TEST_TRUE@${tab}action" Makefile.in
+grep '^@TEST_FALSE@target: false' Makefile.in
+
+:
diff --git a/t/cond.sh b/t/cond.sh
new file mode 100755
index 000000000..f7f0a8c1a
--- /dev/null
+++ b/t/cond.sh
@@ -0,0 +1,42 @@
+#! /bin/sh
+# Copyright (C) 1997-2012 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/>.
+
+# Check basic use of conditionals.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AM_CONDITIONAL([TEST], [true])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+if TEST
+VAR = true
+else
+VAR = false
+endif
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+grep '^TEST_FALSE' Makefile.in && Exit 1
+grep '^TEST_TRUE' Makefile.in && Exit 1
+grep '^@TEST_TRUE@VAR = true$' Makefile.in
+grep '^@TEST_FALSE@VAR = false$' Makefile.in
+
+:
diff --git a/t/cond10.sh b/t/cond10.sh
new file mode 100755
index 000000000..56a9083cd
--- /dev/null
+++ b/t/cond10.sh
@@ -0,0 +1,47 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test for bug in conditionals. From Raja R Harinath.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_CONDITIONAL([USE_A], [test x = y])
+AM_CONDITIONAL([USE_B], [test x = z])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+if USE_A
+out=output_a.c
+else
+if USE_B
+out=output_b.c
+else
+out=output_c.c
+endif
+endif
+
+noinst_PROGRAMS=foo
+foo_SOURCES=foo.c $(out)
+END
+
+$ACLOCAL
+$AUTOMAKE -a
+grep 'USE_A_FALSE.*USE_B_FALSE.*output_c\...OBJEXT.' Makefile.in
+
+:
diff --git a/t/cond11.sh b/t/cond11.sh
new file mode 100755
index 000000000..b53cb70e9
--- /dev/null
+++ b/t/cond11.sh
@@ -0,0 +1,62 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test for bug in conditionals. From Richard Boulton.
+# This checks that, if LDADD is set from a conditional variable
+# and an AC_SUBST, the _DEPENDENCIES variable is set correctly.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+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
+foolibs=
+endif
+
+noinst_PROGRAMS = foo
+foo_SOURCES = foo.c
+LDADD = $(SUBSTVAR) $(foolibs)
+
+.PHONY: test1 test2
+test1:
+ is faz.la == $(foo_DEPENDENCIES)
+test2:
+ is "" == $(foo_DEPENDENCIES)
+END
+
+: > config.guess
+: > config.sub
+: > compile
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --ignore-deps
+
+./configure
+$MAKE test1
+
+./configure two=yes
+$MAKE test2
+
+:
diff --git a/t/cond13.sh b/t/cond13.sh
new file mode 100755
index 000000000..1ab328d7b
--- /dev/null
+++ b/t/cond13.sh
@@ -0,0 +1,58 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test for bug in conditionals.
+# Report from Lars J. Aas.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_PROG_CXX
+AM_PROG_AR
+AC_PROG_RANLIB
+AM_CONDITIONAL([COND1], [true])
+AM_CONDITIONAL([COND2], [true])
+END
+
+cat > Makefile.am << 'END'
+noinst_LIBRARIES = libtest.a
+
+if COND1
+SOURCEVAR1 =
+SOURCEVAR2 = habla.cpp espanol.cpp
+else
+SOURCEVAR1 = dummy.cpp
+SOURCEVAR2 =
+endif
+
+if COND2
+TESTSOURCES = $(SOURCEVAR1)
+else
+TESTSOURCES = $(SOURCEVAR2)
+endif
+
+libtest_a_SOURCES = $(TESTSOURCES)
+END
+
+: > ar-lib
+
+$ACLOCAL
+$AUTOMAKE
+
+grep '^am_libtest_a_OBJECTS =' Makefile.in
+
+:
diff --git a/t/cond14.sh b/t/cond14.sh
new file mode 100755
index 000000000..f3725c3af
--- /dev/null
+++ b/t/cond14.sh
@@ -0,0 +1,51 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test for bug in conditionals.
+# Report from Robert Boehne.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_CONDITIONAL([COND1], [true])
+END
+
+cat > Makefile.am << 'END'
+if COND1
+BUILD_helldl = helldl
+helldl_SOURCES = dlmain.c
+helldl_DEPENDENCIES = libhello.la
+else
+BUILD_helldl =
+bin_SCRIPTS = helldl
+helldl$(EXEEXT):
+ rm -f $@
+ echo '#! /bin/sh' > $@
+ echo '-dlopen is unsupported' >> $@
+ chmod +x $@
+endif
+
+bin_PROGRAMS = $(BUILD_helldl)
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+$FGREP helldl Makefile.in # For debugging.
+test `$FGREP -c 'helldl$(EXEEXT):' Makefile.in` -eq 2
+
+:
diff --git a/t/cond15.sh b/t/cond15.sh
new file mode 100755
index 000000000..68f70fd47
--- /dev/null
+++ b/t/cond15.sh
@@ -0,0 +1,61 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Regression test for conditionally defined overriding of automatic rules.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_CONDITIONAL([COND1], [true])
+AM_CONDITIONAL([COND2], [true])
+END
+
+cat > Makefile.am << 'END'
+if COND1
+if COND2
+bin_SCRIPTS = helldl
+helldl$(EXEEXT):
+ rm -f $@
+ echo '#! /bin/sh' > $@
+ echo '-dlopen is unsupported' >> $@
+ chmod +x $@
+endif
+else
+if COND2
+else
+bin_SCRIPTS = helldl
+helldl$(EXEEXT):
+ rm -f $@
+ echo '#! /bin/sh' > $@
+ echo '-dlopen is unsupported' >> $@
+ chmod +x $@
+endif
+endif
+
+bin_PROGRAMS = helldl
+END
+
+$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
+test $num2 -eq 1
+
+:
diff --git a/t/cond16.sh b/t/cond16.sh
new file mode 100755
index 000000000..11a4f68d2
--- /dev/null
+++ b/t/cond16.sh
@@ -0,0 +1,55 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test for bug in conditionals in SOURCES with variable substitution
+# references.
+# Report from Richard Boulton.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+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
+else
+var = foo.c
+endif
+
+bin_PROGRAMS = hell
+hell_SOURCES = $(var:=)
+
+.PHONY: test
+test:
+ is $(hell_SOURCES) $(hell_OBJECTS) == foo.c foo.o
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+./configure
+$MAKE test
+
+:
diff --git a/t/cond17.sh b/t/cond17.sh
new file mode 100755
index 000000000..37a0793ba
--- /dev/null
+++ b/t/cond17.sh
@@ -0,0 +1,42 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test for being able to define an object to be generated in different ways
+# according to a conditional.
+# Report from Richard Boulton.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_PROG_CXX
+AM_CONDITIONAL([COND1], [true])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = helldl
+if COND1
+helldl_SOURCES = foo.cc
+else
+helldl_SOURCES = foo.c
+endif
+END
+
+$ACLOCAL
+$AUTOMAKE -a
+
+:
diff --git a/t/cond18.sh b/t/cond18.sh
new file mode 100755
index 000000000..32c0ab2b9
--- /dev/null
+++ b/t/cond18.sh
@@ -0,0 +1,63 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Regression test for substitution references to conditional variables.
+# Report from Richard Boulton.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+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
+
+if COND1
+var2 = $(var1:=.c) foo.cc
+else
+var2 = $(var1:=.c)
+endif
+
+if COND2
+var3 = $(var2:.cc=.c)
+else
+var3 = $(var2:.cc=.c)
+endif
+
+helldl_SOURCES = $(var3)
+
+.PHONY: test
+test:
+ is $(helldl_SOURCES) $(helldl_OBJECTS) == \
+ dlmain.c foo.c dlmain.obj foo.obj
+
+bin_PROGRAMS = helldl
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+./configure
+$MAKE test
+
+:
diff --git a/t/cond19.sh b/t/cond19.sh
new file mode 100755
index 000000000..86f677e6f
--- /dev/null
+++ b/t/cond19.sh
@@ -0,0 +1,69 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Regression test for substitution references to conditional variables.
+# Report from Richard Boulton.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+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
+
+if COND1
+var2 = $(var1:=.c)
+else
+var2 = $(var1:=.c)
+endif
+
+if COND2
+var3 = $(var2:.c=a.c)
+var4 = $(var2:.c=b.c)
+else
+var3 = $(var2:.c=b.c)
+var4 = $(var2:.c=a.c)
+endif
+
+helldl_SOURCES = $(var3:.c=1.c) $(var4:.c=2.c)
+
+.PHONY: test
+test:
+ is $(exp) == $(helldl_SOURCES) $(helldl_OBJECTS)
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a -i
+
+CONDITION1=true CONDITION2=true ./configure
+$MAKE test exp='dlmaina1.c dlmainb2.c dlmaina1.o dlmainb2.o'
+CONDITION1=true CONDITION2=false ./configure
+$MAKE test exp='dlmainb1.c dlmaina2.c dlmainb1.o dlmaina2.o'
+CONDITION1=false CONDITION2=true ./configure
+$MAKE test exp='dlmaina1.c dlmainb2.c dlmaina1.o dlmainb2.o'
+CONDITION1=false CONDITION2=false ./configure
+$MAKE test exp='dlmainb1.c dlmaina2.c dlmainb1.o dlmaina2.o'
+
+:
diff --git a/t/cond2.sh b/t/cond2.sh
new file mode 100755
index 000000000..1b5fceaee
--- /dev/null
+++ b/t/cond2.sh
@@ -0,0 +1,40 @@
+#! /bin/sh
+# Copyright (C) 1997-2012 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/>.
+
+# Check SUBDIRS set based on conditionals.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AM_CONDITIONAL([TEST], [true])
+END
+
+cat > Makefile.am << 'END'
+if TEST
+DIR = dir1
+else
+DIR = dir2
+endif
+SUBDIRS = $(DIR)
+END
+
+mkdir dir1
+
+$ACLOCAL
+AUTOMAKE_fails
+grep '^Makefile\.am:4:.*dir2.*does not exist' stderr
+
+:
diff --git a/t/cond20.sh b/t/cond20.sh
new file mode 100755
index 000000000..40e41f1fe
--- /dev/null
+++ b/t/cond20.sh
@@ -0,0 +1,46 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Regression test for recursion handling in substitution references to
+# conditional variables.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_CONDITIONAL([COND1], [true])
+END
+
+cat > Makefile.am << 'END'
+var1 = $(var2)
+
+if COND1
+var2 = $(var1:=.c) foo.c
+else
+var2 = $(var1:=.c)
+endif
+
+helldl_SOURCES = $(var2)
+
+bin_PROGRAMS = helldl
+END
+
+$ACLOCAL
+$AUTOCONF
+AUTOMAKE_fails -a
+grep "variable.*var2.*recursively defined" stderr
+
+:
diff --git a/t/cond21.sh b/t/cond21.sh
new file mode 100755
index 000000000..7719c835d
--- /dev/null
+++ b/t/cond21.sh
@@ -0,0 +1,76 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Check for use of = and += in different conditions.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AM_CONDITIONAL([COND1], [true])
+AM_CONDITIONAL([COND2], [true])
+AM_CONDITIONAL([COND3], [true])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+
+FOO = foo
+if COND1
+ FOO += foo1
+else
+ FOO += foon1
+endif
+if COND2
+ FOO += foo2
+else
+ FOO += foon2
+endif
+if COND1
+ FOO += foo1b
+else
+ FOO += foon1b
+endif
+
+if COND1
+if COND2
+ BAR = bar12
+else
+ BAR = bar1n2
+endif
+else
+ BAR = barn1
+endif
+
+BAR += bar
+
+if COND3
+ BAR += bar3
+endif
+
+.PHONY: test
+test:
+ @echo BAR: $(BAR) :BAR
+ @echo FOO: $(FOO) :FOO
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+./configure
+$MAKE test | $FGREP 'BAR: bar12 bar bar3 :BAR'
+$MAKE test | $FGREP 'FOO: foo foo1 foo2 foo1b :FOO'
+
+:
diff --git a/t/cond22.sh b/t/cond22.sh
new file mode 100755
index 000000000..7a58c2418
--- /dev/null
+++ b/t/cond22.sh
@@ -0,0 +1,69 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Regression test for bug when sources listed in conditional.
+# Report from Richard Boulton. PR/326.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+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
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = targ
+
+if ONE
+SONE = one.c
+endif
+
+if TWO
+STWO =
+else
+STWO = two.c
+endif
+
+if THREE
+STHREE =
+else
+STHREE = three.c
+endif
+
+if THREE
+STHREE2 =
+else
+STHREE2 = three2.c
+endif
+
+targ_SOURCES = $(SONE) $(STWO) $(STHREE) $(STHREE2)
+
+.PHONY: test
+test:
+ is $(targ_OBJECTS) == one.oo two.oo three.oo three2.oo
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --ignore-deps
+./configure
+$MAKE test
+
+:
diff --git a/t/cond23.sh b/t/cond23.sh
new file mode 100755
index 000000000..d6c2bdfe3
--- /dev/null
+++ b/t/cond23.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Check that conditional redefinitions of AC_SUBST'ed variables are detected.
+# Report from Patrik Weiskircher.
+
+. ./defs || Exit 1
+
+cat >>configure.ac <<EOF
+AM_CONDITIONAL([COND], [true])
+AC_OUTPUT
+EOF
+
+cat >Makefile.am <<EOF
+if COND
+libdir = mumble
+endif
+EOF
+
+$ACLOCAL
+AUTOMAKE_fails
+grep '^Makefile\.am:2:.* libdir was already defined' stderr
+
+:
diff --git a/t/cond24.sh b/t/cond24.sh
new file mode 100755
index 000000000..b7038cc6b
--- /dev/null
+++ b/t/cond24.sh
@@ -0,0 +1,39 @@
+#!/bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Check that conditional redefinitions of AC_SUBST'ed variables are detected.
+# Report from Patrik Weiskircher.
+
+. ./defs || Exit 1
+
+cat >>configure.ac <<EOF
+AC_SUBST([foo], [bar])
+AM_CONDITIONAL([COND], [true])
+EOF
+
+cat >Makefile.am <<EOF
+if COND
+## A dummy comment to change line numer.
+foo = baz
+endif
+EOF
+
+$ACLOCAL
+AUTOMAKE_fails
+grep '^Makefile\.am:3:.* foo was already defined' stderr
+grep '^configure\.ac:4:.*foo.* previously defined here' stderr
+
+:
diff --git a/t/cond25.sh b/t/cond25.sh
new file mode 100755
index 000000000..c42703356
--- /dev/null
+++ b/t/cond25.sh
@@ -0,0 +1,39 @@
+#!/bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Check that conditional primaries can use non-conditional directories.
+# From Pavel Roskin.
+
+. ./defs || Exit 1
+
+cat >>configure.ac << 'EOF'
+AM_CONDITIONAL([USE_FOO], [true])
+AC_PROG_CC
+EOF
+
+cat >Makefile.am << 'EOF'
+if USE_FOO
+foo_PROGRAMS = foo
+endif
+
+foodir = $(libdir)/foo
+foo_SOURCES = foo.c
+EOF
+
+$ACLOCAL
+$AUTOMAKE
+
+:
diff --git a/t/cond26.sh b/t/cond26.sh
new file mode 100755
index 000000000..f0aac9638
--- /dev/null
+++ b/t/cond26.sh
@@ -0,0 +1,38 @@
+#!/bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Check that non-conditional primaries can use conditional directories.
+# Reported by Juergen Keil.
+
+. ./defs || Exit 1
+
+cat >>configure.ac << 'EOF'
+AM_CONDITIONAL([USE_FOO], [true])
+EOF
+
+cat >Makefile.am << 'EOF'
+if USE_FOO
+mydir = /foo
+else
+mydir = /bar
+endif
+my_DATA = foo
+EOF
+
+$ACLOCAL
+$AUTOMAKE
+
+:
diff --git a/t/cond27.sh b/t/cond27.sh
new file mode 100755
index 000000000..0a8263d01
--- /dev/null
+++ b/t/cond27.sh
@@ -0,0 +1,38 @@
+#!/bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Check that non-conditional primaries cannot use directories defined
+# in some conditions (but not others).
+
+. ./defs || Exit 1
+
+cat >>configure.ac << 'EOF'
+AM_CONDITIONAL([USE_FOO], [true])
+EOF
+
+cat >Makefile.am << 'EOF'
+if USE_FOO
+mydir = /foo
+endif
+my_DATA = foo
+EOF
+
+$ACLOCAL
+AUTOMAKE_fails
+grep ' USE_FOO' stderr && Exit 1
+grep '!USE_FOO' stderr
+
+:
diff --git a/t/cond28.sh b/t/cond28.sh
new file mode 100755
index 000000000..7a6bcff84
--- /dev/null
+++ b/t/cond28.sh
@@ -0,0 +1,38 @@
+#!/bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Check that conditional primaries can use directories defined
+# in the same conditions (but not others).
+
+. ./defs || Exit 1
+
+cat >>configure.ac << 'EOF'
+AM_CONDITIONAL([USE_FOO], [true])
+EOF
+
+cat >Makefile.am << 'EOF'
+if USE_FOO
+mydir = /foo
+endif
+if USE_FOO
+my_DATA = foo
+endif
+EOF
+
+$ACLOCAL
+$AUTOMAKE
+
+:
diff --git a/t/cond29.sh b/t/cond29.sh
new file mode 100755
index 000000000..ee9bf9b76
--- /dev/null
+++ b/t/cond29.sh
@@ -0,0 +1,63 @@
+#!/bin/sh
+# Copyright (C) 2003-2012 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/>.
+
+# Check that many conditions do not lead to combinatorial explosion.
+# (This is related to PR/352.)
+
+. ./defs || Exit 1
+
+echo AC_PROG_CC >>configure.ac
+
+cat >Makefile.am <<EOF
+bin_PROGRAMS = a
+a02_LDADD =
+a03_SOURCES =
+EOF
+
+# On this test, Automake 1.7.x would compute all 2**24 = 16777216
+# 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.
+# Limit memory available to spawned processes to ~ 150 MB. Considering
+# that 70 MB is enough for x86_64 Fedora 16, that gives tools and
+# libraries plenty of room to grow. Suggested by Jim Meyering in
+# automake bug#10374.
+(ulimit -v 1; sh -c ":") && skip_ "no adequate 'ulimit' builtin found"
+(ulimit -v 150000; sh -c ":") || skip_ "no adequate 'ulimit' builtin found"
+ulimit -v 150000
+
+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 23 24
+do
+ 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.ac
+done
+
+$ACLOCAL
+$AUTOMAKE
+
+:
diff --git a/t/cond3.sh b/t/cond3.sh
new file mode 100755
index 000000000..2bcb8c1db
--- /dev/null
+++ b/t/cond3.sh
@@ -0,0 +1,79 @@
+#! /bin/sh
+# Copyright (C) 1997-2012 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/>.
+
+# Test sources listed in conditional.
+# Report from Rob Savoye <rob@cygnus.com>, and Lars J. Aas.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_CONDITIONAL([ONE], [true])
+AM_CONDITIONAL([TWO], [false])
+AM_CONDITIONAL([THREE], [maybe])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = targ
+
+if ONE
+SONE = one.c
+else
+SONE =
+endif
+
+if TWO
+STWO = two.c
+else
+STWO =
+endif
+
+if THREE
+STHREE = three.c
+else
+STHREE =
+endif
+
+targ_SOURCES = $(SONE) $(STWO) $(STHREE)
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+# 'b top' so that
+sed -n '
+/[oO][bB][jJ][eE][cC][tT].* =/ {
+ : loop
+ /\\$/ {
+ p
+ n
+ b loop
+ }
+ p
+}' Makefile.in >produced
+
+cat >expected << 'EOF'
+@ONE_TRUE@am__objects_1 = one.$(OBJEXT)
+@TWO_TRUE@am__objects_2 = two.$(OBJEXT)
+@THREE_TRUE@am__objects_3 = three.$(OBJEXT)
+am_targ_OBJECTS = $(am__objects_1) $(am__objects_2) $(am__objects_3)
+targ_OBJECTS = $(am_targ_OBJECTS)
+EOF
+
+diff expected produced
+
+:
diff --git a/t/cond30.sh b/t/cond30.sh
new file mode 100755
index 000000000..6c2b39626
--- /dev/null
+++ b/t/cond30.sh
@@ -0,0 +1,59 @@
+#!/bin/sh
+# Copyright (C) 2003-2012 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/>.
+
+# For PR/352: make sure we support bin_PROGRAMS being defined conditionally.
+
+. ./defs || Exit 1
+
+cat >>configure.ac <<'EOF'
+AM_CONDITIONAL([C1], [test -z "$two"])
+AM_CONDITIONAL([C2], [test -n "$two"])
+AC_OUTPUT
+EOF
+
+cat > Makefile.am <<'EOF'
+AUTOMAKE_OPTIONS = no-dependencies
+CC = false
+EXEEXT = .foo
+
+if C1
+bin_PROGRAMS = a
+endif
+if C2
+bin_PROGRAMS = b $(undefined)
+endif
+
+.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
+$MAKE test-a
+
+./configure two=yes
+$MAKE test-b
+
+:
diff --git a/t/cond31.sh b/t/cond31.sh
new file mode 100755
index 000000000..d6006cb0d
--- /dev/null
+++ b/t/cond31.sh
@@ -0,0 +1,56 @@
+#!/bin/sh
+# Copyright (C) 2003-2012 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 we define conditional _DEPENDENCIES correctly.
+
+. ./defs || Exit 1
+
+cat >>configure.ac <<'EOF'
+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'
+bin_PROGRAMS = a
+a_LDADD = c0.o -L/some/where
+if C1
+a_LDADD += c1.o -llibfoo.a
+endif
+if C2
+a_LDADD += c2.o -dlopen c3.la
+endif
+
+.PHONY: test1 test2
+test1:
+ is $(a_DEPENDENCIES) == c0.o c1.o
+test2:
+ is $(a_DEPENDENCIES) == c0.o c2.o c3.la
+EOF
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --ignore-deps
+
+./configure
+$MAKE test1
+
+./configure two=yes
+$MAKE test2
+
+:
diff --git a/t/cond32.sh b/t/cond32.sh
new file mode 100755
index 000000000..7ff1a4142
--- /dev/null
+++ b/t/cond32.sh
@@ -0,0 +1,71 @@
+#!/bin/sh
+# Copyright (C) 2003-2012 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 the user can override a conditional _DEPENDENCIES.
+
+. ./defs || Exit 1
+
+cat >>configure.ac <<'EOF'
+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
+else
+BAR = baz.o
+endif
+a_LDADD = $(BAR)
+endif
+
+test:
+ is $(exp) == $(a_DEPENDENCIES)
+.PHONY: test
+EOF
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+$MAKE test exp='foo.o nonsense.a'
+
+./configure two=yes three=
+$MAKE test exp='bar.o'
+
+./configure two=yes three=yes
+$MAKE test exp='baz.o'
+
+:
diff --git a/t/cond33.sh b/t/cond33.sh
new file mode 100755
index 000000000..9655d3b1e
--- /dev/null
+++ b/t/cond33.sh
@@ -0,0 +1,79 @@
+#!/bin/sh
+# Copyright (C) 2004-2012 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/>.
+
+# Check that conditionally-defined install directories are handled
+# correctly.
+# Report from Ralf Corsepius.
+
+. ./defs || Exit 1
+
+cat >>configure.ac <<'EOF'
+AM_CONDITIONAL([INC], [test -z "$two"])
+AC_OUTPUT
+EOF
+
+cat > Makefile.am <<'EOF'
+if INC
+include_foodir = $(includedir)/foo
+include_foo_HEADERS = foo.h
+else
+bardir = $(bindir)
+dist_bar_SCRIPTS = x.sh
+endif
+
+foo.h x.sh:
+ :>$@
+
+.PHONY: distdircheck
+distdircheck: distdir
+ test -f $(distdir)/foo.h
+ test -f $(distdir)/x.sh
+EOF
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+cwd=`pwd` || fatal_ "cannot get current directory"
+mkdir nowhere
+chmod a-w nowhere
+
+./configure --prefix="$cwd"/nowhere --bindir="$cwd"/bin \
+ --includedir="$cwd"/inc
+$MAKE installdirs
+test ! -d bin
+test -d inc/foo
+test ! -f inc/foo/foo.h
+rm -rf inc
+$MAKE install
+test ! -d bin
+test -f inc/foo/foo.h
+$MAKE distdircheck
+
+rm -rf 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
+
+:
diff --git a/t/cond34.sh b/t/cond34.sh
new file mode 100755
index 000000000..8349406a2
--- /dev/null
+++ b/t/cond34.sh
@@ -0,0 +1,75 @@
+#!/bin/sh
+# Copyright (C) 2004-2012 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/>.
+
+# Check for _DEPENDENCIES definition with conditional _LDADD.
+# Report from Elena A. Vengerova.
+
+. ./defs || Exit 1
+
+cat >>configure.ac <<'EOF'
+AM_CONDITIONAL([TWO], [test -n "$two"])
+AC_OUTPUT
+EOF
+
+cat > Makefile.am <<'EOF'
+OBJEXT=z
+CC=false
+AUTOMAKE_OPTIONS=no-dependencies
+
+bin_PROGRAMS = test1 test2
+
+if TWO
+ test1_LDADD = two.$(OBJEXT)
+ test2_LDADD = two.$(OBJEXT)
+ test2_DEPENDENCIES = $(test2_LDADD) somethingelse.a
+else !TWO
+ test1_LDADD = one.$(OBJEXT)
+ test2_LDADD = three.$(OBJEXT)
+endif !TWO
+
+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
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+
+$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 >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
+
+:
diff --git a/t/cond35.sh b/t/cond35.sh
new file mode 100755
index 000000000..043b3b059
--- /dev/null
+++ b/t/cond35.sh
@@ -0,0 +1,100 @@
+#!/bin/sh
+# Copyright (C) 2004-2012 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/>.
+
+# Check rules output for parser defined conditionally.
+# Report from Roman Fietze.
+
+required='cc lex yacc'
+. ./defs || Exit 1
+
+cat >>configure.ac <<'EOF'
+AM_CONDITIONAL([CASE_A], [test -z "$case_B"])
+AC_PROG_CC
+AM_PROG_LEX
+AC_PROG_YACC
+AC_OUTPUT
+EOF
+
+cat > Makefile.am <<'EOF'
+AM_YFLAGS = -d
+
+BUILT_SOURCES = tparse.h
+
+if CASE_A
+bin_PROGRAMS = ta
+ta_SOURCES = ta.c tparse.h tscan.l tparse.y
+ta_LDADD = $(LEXLIB)
+else
+bin_PROGRAMS = tb
+tb_SOURCES = tb.c tparse.h tscan.l tparse.y
+tb_LDADD = $(LEXLIB)
+endif
+
+
+test-ta:
+ test -f ta$(EXEEXT)
+test-tb:
+ test -f tb$(EXEEXT)
+EOF
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+$FGREP 'tparse.h' Makefile.in # For debugging.
+test `$FGREP -c 'tparse.h:' Makefile.in` = 1
+
+cat > tscan.l << 'END'
+%{
+#define YY_NO_UNISTD_H 1
+%}
+%%
+"END" return EOF;
+%%
+/* Avoid possible link errors. */
+int yywrap (void)
+{
+ return 1;
+}
+END
+
+cat > tparse.y << 'END'
+%{
+void yyerror (char *s) {}
+%}
+%token EOF
+%%
+foobar : 'f' 'o' 'o' 'b' 'a' 'r' EOF {};
+END
+
+cat > ta.c << 'END'
+int main (void)
+{
+ return 0;
+}
+END
+
+cp ta.c tb.c
+
+./configure
+$MAKE
+$MAKE test-ta
+
+./configure case_B=yes
+$MAKE
+$MAKE test-tb
+
+:
diff --git a/t/cond36.sh b/t/cond36.sh
new file mode 100755
index 000000000..82200cca9
--- /dev/null
+++ b/t/cond36.sh
@@ -0,0 +1,61 @@
+#!/bin/sh
+# Copyright (C) 2004-2012 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/>.
+
+# Check rules output for parser defined conditionally.
+
+. ./defs || Exit 1
+
+cat >>configure.ac <<'EOF'
+AM_CONDITIONAL([CASE_A], [test -z "$case_B"])
+AC_PROG_CC
+AM_PROG_LEX
+AC_PROG_YACC
+AC_OUTPUT
+EOF
+
+cat > Makefile.am <<'EOF'
+AM_YFLAGS = -d
+
+BUILT_SOURCES = tparse.h
+
+if CASE_A
+bin_PROGRAMS = ta
+ta_SOURCES = ta.c tparse.h tscan.l tparse.y
+ta_LDADD = $(LEXLIB)
+else
+bin_PROGRAMS = tb
+tb_SOURCES = tb.c tparse.h tscan.l tparse.y
+tb_LDADD = $(LEXLIB)
+tparse.h: tparce.c
+ echo whatever
+endif
+EOF
+
+$ACLOCAL
+
+# Presently Automake doesn't fully support partially overriden rules
+# and should complain.
+AUTOMAKE_fails --add-missing
+grep 'tparse\.h.*already defined' stderr
+$AUTOMAKE -Wno-error
+
+# Still and all, it should generate two rules.
+$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
+
+:
diff --git a/t/cond37.sh b/t/cond37.sh
new file mode 100755
index 000000000..6423d391b
--- /dev/null
+++ b/t/cond37.sh
@@ -0,0 +1,57 @@
+#!/bin/sh
+# Copyright (C) 2004-2012 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/>.
+
+# Check conditional local rules.
+# Report from Simon Josefsson.
+
+. ./defs || Exit 1
+
+cat >>configure.ac <<'EOF'
+AM_CONDITIONAL([CASE_A], [test -n "$case_A"])
+AC_OUTPUT
+EOF
+
+cat > Makefile.am <<'EOF'
+if CASE_A
+check-local:
+ @echo GrepMe1
+else
+install-data-local:
+ @echo GrepMe2
+endif
+EOF
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+$MAKE check >stdout || { cat stdout; Exit 1; }
+cat stdout
+grep GrepMe1 stdout && Exit 1
+$MAKE install >stdout || { cat stdout; Exit 1; }
+cat stdout
+grep GrepMe2 stdout
+
+./configure case_A=1
+$MAKE check >stdout || { cat stdout; Exit 1; }
+cat stdout
+grep GrepMe1 stdout
+$MAKE install >stdout || { cat stdout; Exit 1; }
+cat stdout
+grep GrepMe2 stdout && Exit 1
+
+:
diff --git a/t/cond38.sh b/t/cond38.sh
new file mode 100755
index 000000000..71ae69a0c
--- /dev/null
+++ b/t/cond38.sh
@@ -0,0 +1,67 @@
+#!/bin/sh
+# Copyright (C) 2005-2012 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/>.
+
+# Check conditional variable ordering.
+# Report from Ed Hartnett.
+
+. ./defs || Exit 1
+
+cat >>configure.ac <<'EOF'
+AM_CONDITIONAL([CASE_A], :)
+AM_CONDITIONAL([CASE_B], :)
+AC_OUTPUT
+EOF
+
+cat > Makefile.am <<'EOF'
+SUBDIRS = a
+if CASE_A
+SUBDIRS += b
+endif
+SUBDIRS += c
+if CASE_A
+SUBDIRS += d
+if CASE_B
+SUBDIRS += e
+endif
+SUBDIRS += f
+endif
+SUBDIRS += g
+if CASE_B
+SUBDIRS += h
+endif
+if CASE_B
+SUBDIRS += iXYZ
+SUBDIRS += jZYX
+endif
+
+.PHONY: test
+test:
+ is $(SUBDIRS) == a b c d e f g h iXYZ jZYX
+EOF
+
+mkdir a b c d e f g h iXYZ jZYX
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+# Make sure no extra variable was created for the last 3 items.
+grep 'append.*=.* h iXYZ jZYX' Makefile
+# Check good ordering.
+$MAKE test
+
+:
diff --git a/t/cond39.sh b/t/cond39.sh
new file mode 100755
index 000000000..840b8b804
--- /dev/null
+++ b/t/cond39.sh
@@ -0,0 +1,107 @@
+#!/bin/sh
+# Copyright (C) 2008-2012 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/>.
+
+# Build either as CONFIG_FILE or as PROGRAM.
+
+required=cc
+. ./defs || Exit 1
+
+mkdir sub
+
+cat >>configure.ac <<'END'
+AC_PROG_CC
+AM_CONDITIONAL([COND], [test "$COND" = true])
+AM_COND_IF([COND], [],
+ [AC_CONFIG_FILES([prog1], [chmod 755 prog1])
+ AC_CONFIG_FILES([sub/prog2], [chmod 755 sub/prog2])])
+AC_CONFIG_FILES([sub/Makefile])
+AC_OUTPUT
+END
+
+cat >Makefile.am <<'END'
+SUBDIRS = sub
+if COND
+bin_PROGRAMS = prog1
+prog1_SOURCES = prog.c
+else
+bin_SCRIPTS = prog1
+CLEANFILES = prog1
+endif
+
+sure-exist:
+ test -f prog1 || test -f prog1$(EXEEXT)
+ test -f sub/prog2 || test -f sub/prog2$(EXEEXT)
+
+sure-not-exist:
+ test ! -f prog1 && test ! -f prog1$(EXEEXT)
+ test ! -f sub/prog2 && test ! -f sub/prog2$(EXEEXT)
+END
+
+cat >sub/Makefile.am <<'END'
+if COND
+bin_PROGRAMS = prog2
+prog2_SOURCES = prog.c
+else
+bin_SCRIPTS = prog2
+CLEANFILES = prog2
+endif
+END
+
+cat >prog.c <<'END'
+int main () { return 42; }
+END
+
+cat >prog1.in <<'END'
+#! /bin/sh
+bindir='@bindir@'
+echo "hi, this is $0, and bindir is $bindir"
+END
+
+cp prog.c sub
+cp prog1.in sub/prog2.in
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+./configure COND=true
+$MAKE 2>stderr || { cat stderr >&2; Exit 1; }
+cat stderr >&2
+grep 'overriding commands' stderr && Exit 1
+$MAKE sure-exist
+./prog1 && Exit 1
+./sub/prog2 && Exit 1
+$MAKE clean
+$MAKE sure-not-exist
+$MAKE
+$MAKE sure-exist
+./prog1 && Exit 1
+./sub/prog2 && Exit 1
+$MAKE distclean
+
+./configure COND=false
+$MAKE 2>stderr || { cat stderr >&2; Exit 1; }
+cat stderr >&2
+grep 'overriding commands' stderr && Exit 1
+./prog1
+./sub/prog2
+$MAKE clean
+$MAKE sure-not-exist
+$MAKE
+./prog1
+./sub/prog2
+
+:
diff --git a/t/cond4.sh b/t/cond4.sh
new file mode 100755
index 000000000..9bd0cc6fd
--- /dev/null
+++ b/t/cond4.sh
@@ -0,0 +1,65 @@
+#! /bin/sh
+# Copyright (C) 1998-2012 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/>.
+
+# Another sources-in-conditional test. Report from Tim Goodwin.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_SUBST([CC], [false])
+AC_SUBST([OBJEXT], [o])
+AM_CONDITIONAL([ONE], [test "x$CONDITION1" = "xtrue"])
+AM_CONDITIONAL([TWO], [test "x$CONDITION2" = "xtrue"])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = targ
+
+if ONE
+OPT1 = one.c
+endif
+
+if TWO
+OPT2 = two.c
+endif
+
+targ_SOURCES = main.c $(OPT1) $(OPT2)
+
+.PHONY: test
+test:
+ is $(exp) == $(targ_OBJECTS)
+END
+
+$ACLOCAL
+$AUTOMAKE -i
+
+# We should not output useless definitions.
+grep '^@ONE_FALSE@' Makefile.in && Exit 1
+grep '^@TWO_FALSE@' Makefile.in && Exit 1
+
+$AUTOCONF
+
+CONDITION1=true CONDITION2=true ./configure
+$MAKE test exp='main.o one.o two.o'
+CONDITION1=true CONDITION2=false ./configure
+$MAKE test exp='main.o one.o'
+CONDITION1=false CONDITION2=true ./configure
+$MAKE test exp='main.o two.o'
+CONDITION1=false CONDITION2=false ./configure
+$MAKE test exp='main.o'
+
+:
diff --git a/t/cond40.sh b/t/cond40.sh
new file mode 100755
index 000000000..7dadfc171
--- /dev/null
+++ b/t/cond40.sh
@@ -0,0 +1,83 @@
+#! /bin/sh
+# Copyright (C) 2008-2012 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/>.
+
+# Test AM_COND_IF.
+
+. ./defs || Exit 1
+
+cat >>configure.ac <<'END'
+AC_DEFUN([FOO],
+ [AC_CONFIG_FILES([$1])])
+
+AM_CONDITIONAL([COND], [test "$cond" = yes])
+# Next lines should not cause a shell syntax error.
+AM_COND_IF([COND])
+AM_COND_IF([COND],
+ [AC_SUBST([BAR])])
+AM_COND_IF([COND],
+ [AC_CONFIG_FILES([file1])])
+
+# Things should work even at a time when the shell expressions
+# for the conditional are not valid any more.
+ok=$cond1
+AM_CONDITIONAL([COND1], [test "$ok" = yes])
+ok=$cond2
+AM_CONDITIONAL([COND2], [test "$ok" = yes])
+ok=$cond3
+AM_CONDITIONAL([COND3], [test "$ok" = yes])
+
+AM_COND_IF([COND1],
+ [AM_COND_IF([COND2], [FOO([file2])],
+ [AM_COND_IF([COND3],
+ [FOO([file3])])])])
+
+AC_OUTPUT
+END
+
+: >Makefile.am
+: >file1.in
+: >file2.in
+: >file3.in
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure cond=yes cond1=yes cond2=no cond3=yes
+test -f file1
+test ! -f file2
+test -f file3
+rm -f file1 file3
+$MAKE file1 file3
+$MAKE file2 && Exit 1
+test -f file1
+test ! -f file2
+test -f file3
+$MAKE distclean
+
+./configure cond=no cond1=yes cond2=yes
+test ! -f file1
+test -f file2
+test ! -f file3
+rm -f file2
+$MAKE file1 && Exit 1
+$MAKE file2
+$MAKE file3 && Exit 1
+test ! -f file1
+test -f file2
+test ! -f file3
+
+:
diff --git a/t/cond41.sh b/t/cond41.sh
new file mode 100755
index 000000000..7c59a0a68
--- /dev/null
+++ b/t/cond41.sh
@@ -0,0 +1,30 @@
+#!/bin/sh
+# Copyright (C) 2008-2012 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/>.
+
+# AM_COND_IF with an undefined condition should fail.
+
+. ./defs || Exit 1
+
+cat >>configure.ac <<'END'
+AM_COND_IF([BAD_COND], [AC_CONFIG_FILES([file1])])
+AC_OUTPUT
+END
+
+$ACLOCAL 2>stderr && { cat stderr >&2; Exit 1; }
+cat stderr >&2
+grep '^configure\.ac:4:.*AM_COND_IF.* no such condition.*BAD_COND' stderr
+
+:
diff --git a/t/cond42.sh b/t/cond42.sh
new file mode 100755
index 000000000..d4eee0104
--- /dev/null
+++ b/t/cond42.sh
@@ -0,0 +1,59 @@
+#!/bin/sh
+# Copyright (C) 2008-2012 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/>.
+
+# Ensure an error with inconsistent state of conditionals in configure.ac.
+# This shouldn't happen with user input, as _AM_COND_* are not documented,
+# but better to be safe.
+
+. ./defs || Exit 1
+
+cat >>configure.ac <<'END'
+AM_CONDITIONAL([COND], [:])
+# 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.ac >configure.int
+ mv -f configure.int configure.ac
+ rm -rf autom4te*.cache
+}
+
+: >Makefile.am
+
+$ACLOCAL
+AUTOMAKE_fails
+grep '^configure\.ac:8:.* condition stack' stderr
+
+edit_configure_in 's/_AM_COND_IF/_AM_COND_ELSE/'
+AUTOMAKE_fails
+grep '^configure\.ac:7:.* else without if' stderr
+
+edit_configure_in 's/_AM_COND_ELSE/_AM_COND_ENDIF/'
+AUTOMAKE_fails
+grep '^configure\.ac:7:.* endif without if' stderr
+
+edit_configure_in 's/\(_AM_COND_ENDIF\).*/_AM_COND_IF\
+_AM_COND_ENDIF/'
+AUTOMAKE_fails
+grep '^configure\.ac:7:.* not enough arguments.* _AM_COND_IF' stderr
+grep '^configure\.ac:8:.* not enough arguments.* _AM_COND_ENDIF' stderr
+test 2 = `grep -c 'not enough arguments' stderr`
+
+:
diff --git a/t/cond43.sh b/t/cond43.sh
new file mode 100755
index 000000000..028168ec2
--- /dev/null
+++ b/t/cond43.sh
@@ -0,0 +1,44 @@
+#!/bin/sh
+# Copyright (C) 2008-2012 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/>.
+
+# Ensure an error with underquoted usage of AM_COND_IF in configure.ac.
+
+. ./defs || Exit 1
+
+cat >>configure.ac <<'END'
+AM_CONDITIONAL([COND1], [:])
+AM_CONDITIONAL([COND2], [:])
+AM_COND_IF([COND1],
+ AM_COND_IF([COND2], [:])
+)
+AC_OUTPUT
+END
+
+: >Makefile.am
+
+$ACLOCAL
+AUTOMAKE_fails
+$EGREP '^configure\.ac:7:.* missing m4 quoting.*macro depth 2( |$)' stderr
+
+sed '/.AM_COND_IF/{
+ s/^/[/
+ s/$/]/
+ }' < configure.ac > configure.int
+mv -f configure.int configure.ac
+rm -rf autom4te*.cache
+$AUTOMAKE
+
+:
diff --git a/t/cond44.sh b/t/cond44.sh
new file mode 100755
index 000000000..8cc2c2e91
--- /dev/null
+++ b/t/cond44.sh
@@ -0,0 +1,38 @@
+#!/bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Check that redefinitions of AC_SUBST'ed AM_SUBST_NOTMAKE'd variables
+# are not diagnosed. See cond23.test.
+
+. ./defs || Exit 1
+
+cat >>configure.ac <<EOF
+AM_CONDITIONAL([COND], [true])
+AM_SUBST_NOTMAKE([libdir])
+AC_OUTPUT
+EOF
+
+cat >Makefile.am <<EOF
+if COND
+libdir = mumble
+endif
+EOF
+
+$ACLOCAL
+AUTOMAKE_run
+grep 'libdir was already defined' stderr && Exit 1
+grep '^libdir = ' Makefile.in && Exit 1
+Exit 0
diff --git a/t/cond45.sh b/t/cond45.sh
new file mode 100755
index 000000000..1296cd188
--- /dev/null
+++ b/t/cond45.sh
@@ -0,0 +1,39 @@
+#!/bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Check that redefinitions of AC_SUBST'ed AM_SUBST_NOTMAKE'd variables
+# are not diagnosed. See cond24.test.
+
+. ./defs || Exit 1
+
+cat >>configure.ac <<EOF
+AC_SUBST([foo], [bar])
+AM_SUBST_NOTMAKE([foo])
+AM_CONDITIONAL([COND], [true])
+AC_OUTPUT
+EOF
+
+cat >Makefile.am <<EOF
+if COND
+foo = baz
+endif
+EOF
+
+$ACLOCAL
+AUTOMAKE_run
+grep 'foo was already defined' stderr && Exit 1
+grep '^foo =' Makefile.in && Exit 1
+Exit 0
diff --git a/t/cond46.sh b/t/cond46.sh
new file mode 100755
index 000000000..c89caf997
--- /dev/null
+++ b/t/cond46.sh
@@ -0,0 +1,112 @@
+#! /bin/sh
+# Copyright (C) 2009-2012 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 3 of the License, 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/>.
+
+# Ensure the right condition is listed after 'else' and 'endif'.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+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'
+if USE_A
+endif !USE_A
+END
+
+AUTOMAKE_fails
+grep "^Makefile\\.am:2:.*endif.*!USE_A.*$notcompat.*[^!]USE_A" stderr
+
+cat > Makefile.am << 'END'
+if USE_A
+endif USE_B
+END
+
+AUTOMAKE_fails
+grep "^Makefile\\.am:2:.*endif.*[^!]USE_B.*$notcompat.*[^!]USE_A" stderr
+
+cat > Makefile.am << 'END'
+if USE_A
+else
+endif USE_A
+END
+
+AUTOMAKE_fails
+grep "^Makefile\\.am:3:.*endif.*[^!]USE_A.*$notcompat.*USE_A" stderr
+
+cat > Makefile.am << 'END'
+if USE_A
+else
+endif !USE_A
+END
+
+$AUTOMAKE
+
+cat > Makefile.am << 'END'
+if USE_A
+if USE_B
+else
+endif !USE_A
+endif
+END
+
+AUTOMAKE_fails
+grep "^Makefile\\.am:4:.*endif.*!USE_A.*$notcompat.*USE_B" stderr
+
+cat > Makefile.am << 'END'
+if USE_A
+else USE_A
+endif
+END
+
+AUTOMAKE_fails
+grep "^Makefile\\.am:2:.*else.*[^!]USE_A.*$notcompat.*[^!]USE_A" stderr
+
+cat > Makefile.am << 'END'
+if USE_A
+else !USE_A
+endif
+END
+
+$AUTOMAKE
+
+cat > Makefile.am << 'END'
+if USE_A
+else USE_B
+endif
+END
+
+AUTOMAKE_fails
+grep "^Makefile\\.am:2:.*else.*[^!]USE_B.*$notcompat.*[^!]USE_A" stderr
+
+cat > Makefile.am << 'END'
+if USE_A
+if USE_B
+else USE_A
+endif
+endif
+END
+
+AUTOMAKE_fails
+grep "^Makefile\\.am:3:.*else.*[^!]USE_A.*$notcompat.*[^!]USE_B" stderr
+
+:
diff --git a/t/cond5.sh b/t/cond5.sh
new file mode 100755
index 000000000..dd45678e9
--- /dev/null
+++ b/t/cond5.sh
@@ -0,0 +1,69 @@
+#! /bin/sh
+# Copyright (C) 1998-2012 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/>.
+
+# Yet another sources-in-conditional test. Report from Tim Goodwin.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_CONDITIONAL([ONE], [true])
+AM_CONDITIONAL([TWO], [false])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = targ
+
+if ONE
+OPT_SRC = one.c
+endif
+
+if TWO
+OPT_SRC = $(OPT_SRC) two.c
+endif
+
+targ_SOURCES = main.c $(OPT_SRC)
+END
+
+# The bug is that automake hangs. So we give it an appropriate grace
+# time, then kill it if necessary.
+$ACLOCAL
+$AUTOMAKE 2>stderr &
+pid=$!
+
+# MSYS bash seems to have a bug in kill, so don't try to kill too soon;
+# and avoid maintainer-check test.
+sleep '2'
+
+# Make at most 30 tries, one every 10 seconds (= 300 seconds = 5 min).
+try=1
+while test $try -le 30; do
+ if kill -0 $pid; then
+ : process $pid is still alive, wait and retry
+ sleep '10'
+ try=`expr $try + 1`
+ else
+ cat stderr >&2
+ # Automake must fail with a proper error message.
+ grep 'variable.*OPT_SRC.*recursively defined' stderr
+ Exit 0
+ fi
+done
+# The automake process probably hung. Kill it, and exit with failure.
+echo "$me: automake process $pid hung"
+kill $pid
+Exit 1
diff --git a/t/cond6.sh b/t/cond6.sh
new file mode 100755
index 000000000..f6a499d1c
--- /dev/null
+++ b/t/cond6.sh
@@ -0,0 +1,69 @@
+#! /bin/sh
+# Copyright (C) 1998-2012 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/>.
+
+# Test for an odd conditional bug. Report from Matt Leach.
+
+. ./defs || Exit 1
+
+echo 'AM_CONDITIONAL([FOO], [true])' >> configure.ac
+
+cat > Makefile.am << 'END'
+if FOO
+
+helpdir = $(prefix)/Help
+# The continuation line below must start with a Tab to see the bug.
+help_DATA = a b c d e \
+ f g h
+
+else
+
+helpdir = $(prefix)/help
+help_DATA = foo
+
+endif
+
+a b c d e f g h:
+ touch $@
+
+.PHONY: test
+test:
+ is $(help_DATA) == a b c d e f g h
+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.ac
+touch aclocal.m4 # Avoid unnecessary firing the remake rules.
+$AUTOCONF
+$AUTOMAKE Makefile
+
+./configure --prefix="`pwd`/_inst"
+
+$MAKE test
+
+$MAKE install
+for x in a b c d e f g h; do
+ test -f _inst/Help/$x
+done
+
+:
diff --git a/t/cond7.sh b/t/cond7.sh
new file mode 100755
index 000000000..1651ac981
--- /dev/null
+++ b/t/cond7.sh
@@ -0,0 +1,39 @@
+#! /bin/sh
+# Copyright (C) 1998-2012 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/>.
+
+# Test for an odd conditional bug. Report from Pavel Roskin.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+compat=yes
+AM_CONDITIONAL([Compatible], [test x$compat = xyes])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+if Compatible
+abdir = none
+ab_HEADERS = \
+ minus.h
+endif
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+grep '^[^#].*002' Makefile.in && Exit 1
+Exit 0
diff --git a/t/cond8.sh b/t/cond8.sh
new file mode 100755
index 000000000..f21aacba9
--- /dev/null
+++ b/t/cond8.sh
@@ -0,0 +1,77 @@
+#! /bin/sh
+# Copyright (C) 1999-2012 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/>.
+
+# Test to make sure _PROGRAMS conditionals can be written in a useful
+# way.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_CONDITIONAL([X], [test "$x" = yes])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+if X
+bin_PROGRAMS = x y
+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 || fatal_ "cannot get current directory"
+
+# 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
+
+:
diff --git a/t/cond9.sh b/t/cond9.sh
new file mode 100755
index 000000000..b9addabeb
--- /dev/null
+++ b/t/cond9.sh
@@ -0,0 +1,44 @@
+#! /bin/sh
+# Copyright (C) 1999-2012 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/>.
+
+# Test for bug in conditionals. From Raja R Harinath.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AM_CONDITIONAL([WRONG], [test x = y])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+if WRONG
+this=
+else
+this=is_something_interesting
+endif
+
+.PHONY: test-this
+test-this:
+ test '$(this)' = is_something_interesting
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+./configure
+$MAKE test-this
+
+:
diff --git a/t/condd.sh b/t/condd.sh
new file mode 100755
index 000000000..be32b7d1d
--- /dev/null
+++ b/t/condd.sh
@@ -0,0 +1,73 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test for bug in conditionals.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+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])
+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
+endif
+
+# Small example from the manual.
+bin_PROGRAMS = hello
+hello_SOURCES = hello-common.c
+if COND1
+hello_SOURCES += hello-cond1.c
+else
+hello_SOURCES += hello-generic.c
+endif
+
+.PHONY: test
+test: distdir
+ test -f $(distdir)/foo/Makefile.am
+ test -f $(distdir)/bar/Makefile.am
+ test -f $(distdir)/hello-common.c
+ test -f $(distdir)/hello-cond1.c
+ test -f $(distdir)/hello-generic.c
+END
+
+mkdir foo bar
+
+: > foo/Makefile.am
+: > bar/Makefile.am
+: > hello-common.c
+: > hello-cond1.c
+: > hello-generic.c
+
+$ACLOCAL
+$AUTOCONF
+grep "meaningless;characters" configure && Exit 1
+$AUTOMAKE
+./configure
+$MAKE test
+
+:
diff --git a/t/condhook.sh b/t/condhook.sh
new file mode 100755
index 000000000..3b0f89c2a
--- /dev/null
+++ b/t/condhook.sh
@@ -0,0 +1,48 @@
+#!/bin/sh
+# Copyright (C) 2004-2012 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/>.
+
+# Test install when a conditional install-*-hook is not defined.
+# Keep this in sync with sister test condhook2.test.
+# Report by Nik A. Melchior (PR/428).
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AM_CONDITIONAL([TEST], [false])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+sysconf_DATA = mumble
+if TEST
+install-data-hook:
+ : > $(top_srcdir)/bad
+endif
+END
+
+: > mumble
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure --prefix "`pwd`/inst"
+
+$MAKE install
+test -f inst/etc/mumble
+test ! -f bad
+
+:
diff --git a/t/condhook2.sh b/t/condhook2.sh
new file mode 100755
index 000000000..a853e37a2
--- /dev/null
+++ b/t/condhook2.sh
@@ -0,0 +1,47 @@
+#!/bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Test install when a conditional install-*-hook is defined.
+# Keep this in sync with sister test condhook.test.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AM_CONDITIONAL([TEST], [true])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+sysconf_DATA = mumble
+if TEST
+install-data-hook:
+ : > $(top_srcdir)/good
+endif
+END
+
+: > mumble
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure --prefix "`pwd`/inst"
+
+$MAKE install
+test -f inst/etc/mumble
+test -f good
+
+:
diff --git a/t/condinc.sh b/t/condinc.sh
new file mode 100755
index 000000000..b7011e76d
--- /dev/null
+++ b/t/condinc.sh
@@ -0,0 +1,42 @@
+#! /bin/sh
+# Copyright (C) 1999-2012 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 a conditional include statement is handled properly.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AM_CONDITIONAL([TOBE], [false])
+END
+
+cat > Makefile.am << 'END'
+if TOBE
+include adjunct
+endif
+END
+
+cat > adjunct << 'END'
+target: dependency
+ rule
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+grep '^target:' Makefile.in && Exit 1
+grep '^@TOBE_TRUE@target:' Makefile.in
+
+:
diff --git a/t/condinc2.sh b/t/condinc2.sh
new file mode 100755
index 000000000..e88b0d276
--- /dev/null
+++ b/t/condinc2.sh
@@ -0,0 +1,59 @@
+#! /bin/sh
+# Copyright (C) 1999-2012 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/>.
+
+# Another test of conditional include statements.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AM_CONDITIONAL([TOBE], [false])
+END
+
+cat > Makefile.am << 'END'
+if TOBE
+include adjunct
+endif
+END
+
+cat > adjunct << 'END'
+target: dependency
+ rule
+endif
+END
+
+$ACLOCAL
+AUTOMAKE_fails
+grep 'adjunct:3: error: too many conditionals closed' stderr
+
+cat > adjunct << 'END'
+if TOBE
+target: dependency
+ rule
+END
+
+AUTOMAKE_fails
+grep 'unterminated conditionals' stderr
+
+cat > adjunct << 'END'
+if TOBE
+target: dependency
+ rule
+endif
+END
+
+$AUTOMAKE
+
+:
diff --git a/t/condlib.sh b/t/condlib.sh
new file mode 100755
index 000000000..fae04bff6
--- /dev/null
+++ b/t/condlib.sh
@@ -0,0 +1,44 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test for bug with conditional library.
+# From Harlan Stenn.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_RANLIB
+AM_MAINTAINER_MODE
+AM_PROG_AR
+AC_PROG_CC
+END
+
+cat > Makefile.am << 'END'
+noinst_LIBRARIES = @LIBRSAREF@
+EXTRA_LIBRARIES = librsaref.a
+
+nodist_librsaref_a_SOURCES = desc.c digit.c
+
+BUILT_SOURCES = $(nodist_librsaref_a_SOURCES)
+END
+
+: > ar-lib
+
+$ACLOCAL
+$AUTOMAKE
+
+$FGREP librsaref.a.c Makefile.in && Exit 1
+Exit 0
diff --git a/t/condman2.sh b/t/condman2.sh
new file mode 100755
index 000000000..fbb3844b0
--- /dev/null
+++ b/t/condman2.sh
@@ -0,0 +1,33 @@
+#! /bin/sh
+# Copyright (C) 1998-2012 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 appropriate man install targets generated in all cases.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+man_MANS = foo.1 foo.2
+man5_MANS = foo.5
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+grep '^install-man1:' Makefile.in
+grep '^install-man2:' Makefile.in
+grep '^install-man5:' Makefile.in
+
+:
diff --git a/t/condman3.sh b/t/condman3.sh
new file mode 100755
index 000000000..9f2714ffe
--- /dev/null
+++ b/t/condman3.sh
@@ -0,0 +1,74 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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.ac << 'END'
+AM_CONDITIONAL([COND], [test x"$FOO" = x"true"])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+if COND
+man_MANS = foo.1
+man4_MANS = 6.man
+else
+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:
+ 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
+
+$EGREP 'MANS|\.([123456789]|man)' Makefile.in # For debugging.
+
+mkdir build
+cd build
+../configure FOO=true --prefix="`pwd`/_inst"
+$EGREP 'MANS|\.([123456789]|man)' Makefile # For debugging.
+touch foo.1 6.man
+$MAKE install
+$MAKE test1
+
+cd ..
+./configure FOO=false --prefix="`pwd`/_inst"
+$EGREP 'MANS|\.([123456789]|man)' Makefile # For debugging.
+touch bar.2 baz.1 zap.5
+$MAKE install
+$MAKE test2
+
+:
diff --git a/t/confdeps.sh b/t/confdeps.sh
new file mode 100755
index 000000000..f508d45f2
--- /dev/null
+++ b/t/confdeps.sh
@@ -0,0 +1,37 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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 that config* files are properly regenerated.
+
+. ./defs || Exit 1
+
+echo "FOO = foo" > Makefile.am
+
+$ACLOCAL
+
+echo "$me: Generated by aclocal ..."
+$AUTOMAKE
+grep '^\$(ACLOCAL_M4):' Makefile.in
+
+echo "$me: Not generated by aclocal ..."
+# Pretend it is not from aclocal (remove the signature),
+# but keep it correct, i.e., with AM_INIT_AUTOMAKE etc.
+sed -n '3,$p' aclocal.m4 >aclocal.m4t
+mv -f aclocal.m4t aclocal.m4
+$AUTOMAKE
+grep '^\$(ACLOCAL_M4):' Makefile.in && Exit 1
+
+:
diff --git a/t/conff.sh b/t/conff.sh
new file mode 100755
index 000000000..d9696608e
--- /dev/null
+++ b/t/conff.sh
@@ -0,0 +1,94 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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 rebuild rules work even when AC_CONFIG_FILES uses colons.
+# Report from Alexander Turbov.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_CONFIG_FILES([bar/Makefile:bar/Makefile.in:Makefile.bot])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+SUBDIRS = bar
+EXTRA_DIST = Makefile.bot
+END
+
+mkdir bar
+cat > bar/Makefile.am << 'END'
+top-rule:
+ @echo 'top rule'
+END
+
+cat > Makefile.bot << 'END'
+bot-rule:
+ @echo 'bot rule'
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+$MAKE
+
+cd bar
+$MAKE top-rule >stdout || { cat stdout; Exit 1; }
+cat stdout
+grep 'top rule' stdout
+$MAKE bot-rule >stdout || { cat stdout; Exit 1; }
+cat stdout
+grep 'bot rule' stdout
+cd ..
+
+$sleep
+
+cat > bar/Makefile.am << 'END'
+top-rule:
+ @echo 'top2 rule'
+END
+$MAKE
+
+cd bar
+$MAKE top-rule >stdout || { cat stdout; Exit 1; }
+cat stdout
+grep 'top2 rule' stdout
+$MAKE bot-rule >stdout || { cat stdout; Exit 1; }
+cat stdout
+grep 'bot rule' stdout
+cd ..
+
+$sleep
+
+cat > Makefile.bot << 'END'
+bot-rule:
+ @echo 'bot2 rule'
+END
+$MAKE
+
+cd bar
+$MAKE top-rule >stdout || { cat stdout; Exit 1; }
+cat stdout
+grep 'top2 rule' stdout
+$MAKE bot-rule >stdout || { cat stdout; Exit 1; }
+cat stdout
+grep 'bot2 rule' stdout
+cd ..
+
+$MAKE distcheck
+
+:
diff --git a/t/conff2.sh b/t/conff2.sh
new file mode 100755
index 000000000..2c42f29bc
--- /dev/null
+++ b/t/conff2.sh
@@ -0,0 +1,36 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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 empty calls to AC_CONFIG_FILES or AC_CONFIG_HEADERS are diagnosed.
+
+. ./defs || Exit 1
+
+# We avoid using configure.ac stub initialized by ./defs, since we need
+# to keep track of line numbers (to grep for error messages).
+cat > configure.ac << END
+AC_INIT([$me], [1.0])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES ([oops])
+AC_CONFIG_HEADERS
+AC_OUTPUT
+END
+
+$ACLOCAL
+AUTOMAKE_fails
+grep 'configure\.ac:3:.* arguments .*AC_CONFIG_FILES' stderr
+grep 'configure\.ac:4:.* arguments .*AC_CONFIG_HEADERS' stderr
+
+:
diff --git a/t/conffile-leading-dot.sh b/t/conffile-leading-dot.sh
new file mode 100755
index 000000000..9c4cb4fff
--- /dev/null
+++ b/t/conffile-leading-dot.sh
@@ -0,0 +1,61 @@
+#! /bin/sh
+# Copyright (C) 2012 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/>.
+
+# Automake must complain if AC_CONFIG_FILES is passed something starting
+# with a dot (like "./Makefile"), since the remake rules might be subtly
+# broken in that case.
+
+required=GNUmake
+. ./defs || Exit 1
+
+cat > configure.ac << END
+AC_INIT([$me], [1.0])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([./Makefile])
+AC_CONFIG_FILES([./foo:a.in:b.in:c.in])
+AC_OUTPUT
+END
+
+touch a.in b.in c.in Makefile.am
+
+$ACLOCAL
+
+AUTOMAKE_fails -Wnone -Wunsupported
+grep "^configure\.ac:3:.*'\\./Makefile'" stderr
+grep "^configure\.ac:3:.* omit leading '\\./'" stderr
+grep "^configure\.ac:3:.*remake rules might be subtly broken" stderr
+grep "^configure\.ac:4:.*'\\./foo'" stderr
+grep "^configure\.ac:4:.* omit leading '\\./'" stderr
+grep "^configure\.ac:4:.*remake rules might be subtly broken" stderr
+
+# Check that our warning was actually justified.
+sed 's/^AM_INIT_AUTOMAKE/&([-Wall -Wno-unsupported])/' <configure.ac >t
+mv -f t configure.ac
+rm -rf autom4te*.cache
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -Wall -Wno-unsupported
+./configure
+$MAKE
+$sleep
+touch Makefile.am
+# Check that remake rules do truly break -- otherwise automake is
+# giving a bogus warning.
+$MAKE 2>stderr && { cat stderr >&2; Exit 1; }
+cat stderr >&2
+grep "config\\.status:.*invalid argument.*Makefile" stderr
+
+:
diff --git a/t/confh.sh b/t/confh.sh
new file mode 100755
index 000000000..475961998
--- /dev/null
+++ b/t/confh.sh
@@ -0,0 +1,63 @@
+#! /bin/sh
+# Copyright (C) 1999-2012 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/>.
+
+# Test to make sure config.h works in a subdir.
+# Report from Alexandre Oliva.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AM_CONFIG_HEADER([include/config.h])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+.PHONY: test1 test2
+test1:
+ @echo DIST_COMMON = $(DIST_COMMON)
+ echo ' ' $(DIST_COMMON) ' ' | grep '[ /]acconfig\.h '
+test2: distdir
+ ls -l $(distdir)/*
+ test -f $(distdir)/acconfig.h
+check-local: test1 test2
+END
+
+mkdir include
+: > include/config.h.in
+: > acconfig.h
+
+# The test used to fail if 'include/Makefile.am' was created (!)
+: > include/Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOHEADER
+$AUTOMAKE
+
+./configure
+
+$MAKE test1
+$MAKE test2
+$MAKE distcheck
+
+# Make sure re-running automake in a different way generates same
+# Makefile.in.
+mv Makefile.in Makefile.sav
+$ACLOCAL
+$AUTOMAKE Makefile
+diff Makefile.sav Makefile.in
+
+:
diff --git a/t/confh4.sh b/t/confh4.sh
new file mode 100755
index 000000000..ea6a9ffc2
--- /dev/null
+++ b/t/confh4.sh
@@ -0,0 +1,47 @@
+#! /bin/sh
+# Copyright (C) 1999-2012 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/>.
+
+# Test for PR 34.
+# > Description:
+# Automake fails to add -I option to include configuration
+# header indicated like AM_CONFIG_HEADER(magick/config.h)
+# > How-To-Repeat:
+# Use AM_CONFIG_HEADER(subdir/config.h) to place configuration
+# header in subdirectory and observe that it is not included.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_CONFIG_FILES([include/Makefile])
+AM_CONFIG_HEADER([include/config.h])
+AC_PROG_CC
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = foo
+foo_SOURCES = foo.c
+END
+
+mkdir include
+: > include/Makefile.am
+: > include/config.h.in
+
+$ACLOCAL
+$AUTOMAKE
+
+grep '^ *DEFAULT_INCLUDES *=.* -I\$(top_builddir)/include' Makefile.in
+
+:
diff --git a/t/confh5.sh b/t/confh5.sh
new file mode 100755
index 000000000..c35c3e847
--- /dev/null
+++ b/t/confh5.sh
@@ -0,0 +1,59 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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 we do not distribute header sources when they are built.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_SUBST([FOO], [NameToBeGrepped])
+AC_CONFIG_FILES([include/config.h.in])
+AC_CONFIG_HEADERS([config.h])
+AC_CONFIG_HEADERS([include/config.h])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+.PHONY: test
+test: distdir
+ test -f $(distdir)/config.h.in
+ test -f $(distdir)/include/config.h.in.in
+ : # Solaris Sh does not support 'test -e'.
+ test ! -f $(distdir)/include/config.h.in
+ test ! -r $(distdir)/include/config.h.in
+END
+
+mkdir include
+: > include/config.h.in.in
+
+$ACLOCAL
+$AUTOCONF
+$AUTOHEADER
+$AUTOMAKE
+
+./configure
+$MAKE
+
+$sleep
+echo '#undef @FOO@' > include/config.h.in.in
+$MAKE include/config.h
+# Don't try to be too strict in this grepping, since the substitution
+# is done by config.status, and we don't have too much control on it.
+grep '/\*.*#undef.*NameToBeGrepped' include/config.h
+$MAKE test
+$MAKE distcheck
+
+:
diff --git a/t/confh6.sh b/t/confh6.sh
new file mode 100755
index 000000000..c5e7d7e58
--- /dev/null
+++ b/t/confh6.sh
@@ -0,0 +1,45 @@
+#! /bin/sh
+# Copyright (C) 1998-2012 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/>.
+
+# Test to make sure config.h rule made even if it is in a subdir. The
+# idea is that if config.h is in a subdir, and there is no Makefile in
+# that subdir, then we want to build config.h as the top level.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AM_CONFIG_HEADER([subdir/config.h])
+AC_OUTPUT
+END
+
+: > Makefile.am
+mkdir subdir
+: > subdir/config.h.in
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+$MAKE
+
+$sleep
+echo '#define gRePmE' > subdir/config.h.in
+$MAKE subdir/config.h
+$FGREP gRePmE subdir/config.h
+
+$MAKE distcheck
+
+:
diff --git a/t/confh7.sh b/t/confh7.sh
new file mode 100755
index 000000000..408077978
--- /dev/null
+++ b/t/confh7.sh
@@ -0,0 +1,44 @@
+#! /bin/sh
+# Copyright (C) 1997-2012 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/>.
+
+# Test to make sure several config headers are allowed.
+# See also sister "semantic" test 'confh8.test'.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AM_CONFIG_HEADER([config.h two.h])
+END
+
+: > Makefile.am
+
+: > config.h.in
+: > two.h.in
+
+$ACLOCAL
+$AUTOMAKE
+
+# Try again with more macros.
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_OUTPUT
+END
+
+$ACLOCAL --force
+$AUTOMAKE
+
+:
diff --git a/t/confh8.sh b/t/confh8.sh
new file mode 100755
index 000000000..c3a27d10f
--- /dev/null
+++ b/t/confh8.sh
@@ -0,0 +1,66 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Test to make sure several config headers are allowed.
+# See also sister "minimalistic" test 'confh7.test'.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AM_CONFIG_HEADER([one.h two.h])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+.PHONY: test0 test1 test2
+test0:
+ @echo DIST_COMMON = $(DIST_COMMON)
+ echo ' ' $(DIST_COMMON) ' ' | grep '[ /]one\.h\.in '
+ echo ' ' $(DIST_COMMON) ' ' | grep '[ /]two\.h\.in '
+ : Processed header files should not be distributed.
+ if echo ' ' $(DIST_COMMON) ' ' | grep '\.h '; then \
+ exit 1; \
+ else \
+ exit 0; \
+ fi
+test1: all
+ test -f one.h
+ test -f two.h
+test2: distdir
+ ls -l $(distdir)/*
+ test -f $(distdir)/one.h.in
+ test -f $(distdir)/two.h.in
+ : Processed header files should not be distributed.
+ test ! -r $(distdir)/one.h
+ test ! -r $(distdir)/two.h
+check-local: test0 test1 test2
+END
+
+: > one.h.in
+: > two.h.in
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+
+$MAKE test0
+$MAKE test1
+$MAKE test2
+$MAKE distcheck
+
+:
diff --git a/t/configure.sh b/t/configure.sh
new file mode 100755
index 000000000..cedba5505
--- /dev/null
+++ b/t/configure.sh
@@ -0,0 +1,54 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Diagnose if both configure.in and configure.ac are present, prefer
+# configure.ac.
+
+. ./defs || Exit 1
+
+cat >configure.ac <<EOF
+AC_INIT([$me], [1.0])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([Makefile])
+EOF
+
+cat >configure.in <<EOF
+AC_INIT([$me], [1.0])
+AM_INIT_AUTOMAKE([an-invalid-automake-option])
+AC_CONFIG_FILES([Makefile])
+EOF
+
+: >Makefile.am
+
+$ACLOCAL 2>stderr && { cat stderr >&2; Exit 1; }
+cat stderr >&2
+grep 'configure\.ac.*configure\.in.*both present' stderr
+
+$ACLOCAL -Wno-error 2>stderr || { cat stderr >&2; Exit 1; }
+cat stderr >&2
+grep 'configure\.ac.*configure\.in.*both present' stderr
+grep 'proceeding.*configure\.ac' stderr
+
+# Ensure we really proceed with configure.ac.
+AUTOMAKE_fails -Werror
+grep 'configure\.ac.*configure\.in.*both present' stderr
+grep 'proceeding.*configure\.ac' stderr
+
+AUTOMAKE_run -Wno-error
+grep 'configure\.ac.*configure\.in.*both present' stderr
+grep 'proceeding.*configure\.ac' stderr
+
+:
diff --git a/t/confincl.sh b/t/confincl.sh
new file mode 100755
index 000000000..dfc755106
--- /dev/null
+++ b/t/confincl.sh
@@ -0,0 +1,36 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# This tests for a bug reported by Gord Matzigkeit.
+# If config.h is not used, @CONFIG_INCLUDE_SPEC@ should not appear
+# in Makefile.in.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = fred
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+$FGREP '@CONFIG_INCLUDE_SPEC@' Makefile.in && Exit 1
+
+:
diff --git a/t/conflnk.sh b/t/conflnk.sh
new file mode 100755
index 000000000..93851ca8c
--- /dev/null
+++ b/t/conflnk.sh
@@ -0,0 +1,70 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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/>.
+
+# Test to make sure links created by AC_CONFIG_LINKS get removed with
+# 'make distclean'
+
+. ./defs || Exit 1
+
+echo 'SUBDIRS = sdir' > Makefile.am
+: > src
+mkdir sdir
+: > sdir/Makefile.am
+: > sdir/src2
+mkdir sdir-no-make
+
+cat >>configure.ac << 'EOF'
+AC_CONFIG_FILES([sdir/Makefile])
+AC_CONFIG_LINKS([dest:src])
+AC_CONFIG_LINKS([dest2:src])
+AC_CONFIG_LINKS([sdir/dest3:src])
+AC_CONFIG_LINKS([dest4:sdir/src2])
+AC_CONFIG_LINKS([sdir/dest5:sdir/src2 sdir-no-make/dest6:src])
+AC_OUTPUT
+EOF
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+./configure
+
+# Make sure nothing is deleted by 'make clean'
+$MAKE clean
+
+test -r dest
+test -r dest2
+test -r sdir/dest3
+test -r dest4
+test -r sdir/dest5
+test -r sdir-no-make/dest6
+test -f src
+test -f sdir/src2
+
+# Make sure the links are deleted by 'make distclean' and the original files
+# are not.
+$MAKE distclean
+
+test -f src
+test -f sdir/src2
+
+test -r dest && Exit 1
+test -r dest2 && Exit 1
+test -r sdir/dest3 && Exit 1
+test -r dest4 && Exit 1
+test -r sdir/dest5 && Exit 1
+test -r sdir-no-make/dest6 && Exit 1
+
+:
diff --git a/t/conflnk2.sh b/t/conflnk2.sh
new file mode 100755
index 000000000..4a1478b29
--- /dev/null
+++ b/t/conflnk2.sh
@@ -0,0 +1,57 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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/>.
+
+# Test to make sure that sources for links created by AC_CONFIG_LINKS
+# are distributed.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+SUBDIRS = sdir
+.PHONY: test
+test: distdir
+ test -f $(distdir)/src
+ test -f $(distdir)/src2
+ test -f $(distdir)/sdir/src3
+ test -f $(distdir)/sdir-no-make/src4
+ test 2 -gt `find $(distdir)/sdir -type d | wc -l`
+ test 2 -gt `find $(distdir)/sdir-no-make -type d | wc -l`
+ test 4 -gt `find $(distdir) -type d | wc -l`
+END
+
+: > src
+: > src2
+mkdir sdir
+: > sdir/Makefile.am
+: > sdir/src3
+mkdir sdir-no-make
+: > sdir-no-make/src4
+
+cat >>configure.ac << 'EOF'
+AC_CONFIG_FILES([sdir/Makefile])
+AC_CONFIG_LINKS([dest:src])
+AC_CONFIG_LINKS([sdir/dest2:src2 sdir-no-make/dest3:sdir/src3])
+AC_CONFIG_LINKS([sdir/dest4:sdir-no-make/src4])
+AC_OUTPUT
+EOF
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+./configure
+$MAKE test
+
+:
diff --git a/t/conflnk3.sh b/t/conflnk3.sh
new file mode 100755
index 000000000..ffb0d98c3
--- /dev/null
+++ b/t/conflnk3.sh
@@ -0,0 +1,86 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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/>.
+
+# Test to make sure that AC_CONFIG_LINKS using a variable source
+# is not broken.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+SUBDIRS = sdir
+.PHONY: test
+test: distdir
+ test ! -r $(distdir)/sdir/dest3
+ test ! -r $(distdir)/sdir/dest2
+ test ! -r $(distdir)/dest3
+ test ! -r $(distdir)/dest2
+ test -f $(distdir)/src2
+## src3 cannot be distributed, Automake knows nothing about it.
+ test ! -r $(distdir)/sdir/src3
+ test ! -r $(distdir)/src3
+END
+
+: > src
+: > src2
+mkdir sdir
+: > sdir/Makefile.am
+: > sdir/src3
+
+cat >>configure.ac << 'EOF'
+AC_CONFIG_FILES([sdir/Makefile])
+my_src_dir=sdir
+my_dest=dest
+AC_CONFIG_LINKS([sdir/dest2:src2 sdir/dest3:$my_src_dir/src3])
+AC_CONFIG_LINKS([$my_dest:src])
+# The following is a link whose source is itself a link.
+AC_CONFIG_LINKS([dest4:sdir/dest2])
+# Some package prefer to compute links.
+cmplink='dest5:src';
+AC_CONFIG_LINKS([$cmplink])
+AC_OUTPUT
+EOF
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+# $my_src_dir and $my_dest are variables local to configure, they should
+# not appear in Makefile.
+grep my_src_dir Makefile.in && Exit 1
+grep my_dest Makefile.in && Exit 1
+
+./configure
+test -r sdir/dest2
+test -r sdir/dest3
+test -r dest
+test -r dest4
+test -r dest5
+$MAKE test
+
+$MAKE distclean
+test ! -r sdir/dest2
+test ! -r sdir/dest3
+test -r dest # Should still exist, Automake knows nothing about it.
+test -r dest5 # Ditto.
+rm -f dest dest5
+test ! -r dest4
+
+mkdir build
+cd build
+../configure
+$MAKE test
+
+:
diff --git a/t/conflnk4.sh b/t/conflnk4.sh
new file mode 100755
index 000000000..a1f2f0e5a
--- /dev/null
+++ b/t/conflnk4.sh
@@ -0,0 +1,93 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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/>.
+
+# Test to make sure links to _identical files_ created by AC_CONFIG_LINKS get
+# removed with 'make distclean' only if doing a VPATH build.
+
+. ./defs || Exit 1
+
+mkdir nonmk-subdir sdir sdir/mk-subdir
+: > src
+: > sdir/Makefile.am
+: > sdir/src2
+: > nonmk-subdir/src3
+: > sdir/mk-subdir/src4
+
+cat >> Makefile.am <<'EOF'
+SUBDIRS = sdir
+.PHONY: test
+test: distdir
+ test -f $(distdir)/src
+ test -f $(distdir)/sdir/src2
+ test -f $(distdir)/nonmk-subdir/src3
+ test -f $(distdir)/sdir/mk-subdir/src4
+EOF
+
+cat >>configure.ac << 'EOF'
+AC_CONFIG_FILES([sdir/Makefile])
+AC_CONFIG_LINKS([src:src])
+AC_CONFIG_LINKS([sdir/src2:sdir/src2])
+AC_CONFIG_LINKS([nonmk-subdir/src3:nonmk-subdir/src3])
+AC_CONFIG_LINKS([sdir/mk-subdir/src4:sdir/mk-subdir/src4])
+AC_OUTPUT
+EOF
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+
+mkdir build
+cd build
+../configure
+
+$MAKE test
+
+# Make sure nothing is deleted by 'make clean'
+$MAKE clean
+
+test -f ../src
+test -f ../sdir/src2
+test -f ../nonmk-subdir/src3
+test -f ../sdir/mk-subdir/src4
+
+# Make sure the links are deleted by 'make distclean' and the original files
+# are not.
+$MAKE distclean
+
+test -f ../src
+test -f ../sdir/src2
+test -f ../nonmk-subdir/src3
+test -f ../sdir/mk-subdir/src4
+
+test -r src && Exit 1
+test -r sdir/src2 && Exit 1
+test -r nonmk-subdir/src3 && Exit 1
+test -r sdir/mk-subdir/src4 && Exit 1
+
+cd ..
+./configure
+
+$MAKE test
+
+# Make sure nothing is deleted by 'make distclean'
+$MAKE distclean
+
+test -f src
+test -f sdir/src2
+test -f nonmk-subdir/src3
+test -f sdir/mk-subdir/src4
+
+:
diff --git a/t/confsub.sh b/t/confsub.sh
new file mode 100755
index 000000000..188704678
--- /dev/null
+++ b/t/confsub.sh
@@ -0,0 +1,58 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test to make sure config.h can be in subdir.
+# Also, make sure config.h is properly rebuilt.
+
+. ./defs || Exit 1
+
+cat > configure.ac << 'END'
+AC_INIT
+AM_INIT_AUTOMAKE(nonesuch, nonesuch)
+AM_CONFIG_HEADER(subdir/config.h:subdir/config.hin)
+AC_OUTPUT(Makefile subdir/Makefile)
+END
+
+cat > Makefile.am << 'END'
+SUBDIRS = subdir
+END
+
+mkdir subdir
+cat > subdir/Makefile.am << 'END'
+END
+
+echo 'Before.' > subdir/config.hin
+
+$ACLOCAL
+$AUTOMAKE
+
+# Make sure subdir Makefile.in doesn't itself look in the subdir.
+# One line is allowed though:
+#
+# cd $(top_builddir) && $(SHELL) ./config.status subdir/config.h
+($FGREP 'subdir/config.h' subdir/Makefile.in |
+ $FGREP -v 'cd $(top_builddir)') && Exit 1
+
+$AUTOCONF
+./configure
+$FGREP 'Before.' subdir/config.h
+
+$sleep
+echo 'After.' > subdir/config.hin
+$MAKE
+$FGREP 'After.' subdir/config.h
+
+:
diff --git a/t/confvar.sh b/t/confvar.sh
new file mode 100755
index 000000000..e77563ee1
--- /dev/null
+++ b/t/confvar.sh
@@ -0,0 +1,32 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test to make sure configure_vars stuff works.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_SUBST([QBERT])
+END
+
+: > Makefile.am
+
+$ACLOCAL
+$AUTOMAKE
+
+grep '^QBERT =' Makefile.in
+
+:
diff --git a/t/confvar2.sh b/t/confvar2.sh
new file mode 100755
index 000000000..bc6ffcae7
--- /dev/null
+++ b/t/confvar2.sh
@@ -0,0 +1,34 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test for bug reported by Jim Meyering.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_SUBST([OTHER_SCRIPTS])
+END
+
+cat > Makefile.am << 'END'
+bin_SCRIPTS = foo
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+grep '^OTHER_SCRIPTS =' Makefile.in
+
+:
diff --git a/t/copy.sh b/t/copy.sh
new file mode 100755
index 000000000..a9f0f5616
--- /dev/null
+++ b/t/copy.sh
@@ -0,0 +1,101 @@
+#! /bin/sh
+# Copyright (C) 1999-2012 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/>.
+
+# Test to make sure '-c' works. Report from Andris Pavenis.
+# See also the much more in-depth test 'add-missing'.
+
+. ./defs || Exit 1
+
+# We'll have to cater to systems like MSYS/MinGW where there are no
+# true symlinks ('ln -s' behaves like 'cp -p'); see automake bug#10441.
+
+echo dummy > foo
+if ln -s foo bar && test -h bar; then
+ is_symlink () { test -h "$1"; }
+ is_not_symlink () { test ! -h "$1"; }
+else
+ is_symlink () { return 0; } # Avoid spurious failures.
+ is_not_symlink () { return 0; }
+fi
+rm -f foo bar
+
+# First a simple test, where the auxdir is automatically determined
+# by automake.
+
+: > Makefile.am
+rm -f install-sh
+
+$ACLOCAL
+$AUTOMAKE -c -a
+ls -l # For debugging.
+
+test -f install-sh
+is_not_symlink install-sh
+
+# Let's do a couple of more elaborated tests, this time with the auxdir
+# explicitly defined in configure.ac.
+
+mkdir sub
+cd sub
+
+cat > configure.ac <<END
+AC_INIT([$me], [1.0])
+AC_CONFIG_AUX_DIR([auxdir])
+AM_INIT_AUTOMAKE
+AC_PROG_CC
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+END
+
+cat > Makefile.am <<END
+bin_PROGRAMS = foo
+END
+
+$ACLOCAL
+
+# 'automake -a' called without '-c' should create symlinks by default,
+# even when there is already a non-symlinked required auxiliary file.
+
+mkdir auxdir
+echo FAKE-DEPCOMP > auxdir/depcomp
+$AUTOMAKE -a
+ls -l auxdir # For debugging.
+test -f auxdir/install-sh
+is_symlink auxdir/install-sh
+test -f auxdir/depcomp
+is_not_symlink auxdir/depcomp
+test FAKE-DEPCOMP = `cat auxdir/depcomp`
+
+# 'automake -a -c' should not create symlinks, even when there are
+# already symlinked required auxiliary files.
+
+rm -rf auxdir
+mkdir auxdir
+cd auxdir
+ln -s "$am_scriptdir/missing" "$am_scriptdir/install-sh" .
+cd ..
+
+$AUTOMAKE -a -c
+ls -l auxdir # For debugging.
+test -f auxdir/install-sh
+is_symlink auxdir/install-sh
+test -f auxdir/missing
+is_symlink auxdir/missing
+test -f auxdir/depcomp
+is_not_symlink auxdir/depcomp
+diff "$am_scriptdir"/depcomp auxdir/depcomp
+
+:
diff --git a/t/cscope.tap b/t/cscope.tap
new file mode 100755
index 000000000..c39feedd7
--- /dev/null
+++ b/t/cscope.tap
@@ -0,0 +1,168 @@
+#! /bin/sh
+# Copyright (C) 2009-2012 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/>.
+
+# Test cscope functionality.
+
+. ./defs || Exit 1
+
+plan_ 18
+
+ocwd=`pwd` || fatal_ "getting top-level directory"
+
+cat >> configure.ac << 'END'
+AC_CONFIG_FILES([sub/Makefile])
+AC_SUBST([CC], [who-cares])
+AC_SUBST([CXX], [who-cares])
+AC_SUBST([FC], [who-cares])
+AC_SUBST([GCJ], [who-cares])
+AM_PATH_LISPDIR
+AC_OUTPUT
+END
+
+mkdir sub sub/subsub
+
+cat > Makefile.am <<'END'
+SUBDIRS = sub
+bin_PROGRAMS = foo
+foo_SOURCES = foo.c bar.cpp baz.f90
+lisp_LISP = foo.el
+EXTRA_DIST = foo.el
+END
+
+cat > sub/Makefile.am <<'END'
+bin_PROGRAMS = bar
+bar_SOURCES = subsub/dist.c
+nodist_bar_SOURCES = subsub/gen.c
+subsub/gen.c:
+ $(MKDIR_P) subsub
+ echo 'int generated_subsub () { return 0; }' > $@
+CLEANFILES = subsub/gen.c
+END
+
+echo 'int foo_func () { return 0; }' > foo.c
+echo 'int main () { return 0; }' > bar.cpp
+cat > baz.f90 <<'END'
+ subroutine baz
+ end
+END
+: > foo.el
+echo 'int main () { return 0; }' > sub/subsub/dist.c
+
+$ACLOCAL || fatal_ "aclocal failed"
+$AUTOCONF || fatal_ "autoconf failed"
+$AUTOMAKE -i -a || fatal_ "automake -i -a failed"
+
+# Sun cscope is interactive without redirection.
+if cscope --version </dev/null; then
+ have_cscope=yes
+else
+ have_cscope=no
+fi
+
+test_cleanup ()
+{
+ r=ok
+ if test -f configure; then
+ # In-tree build.
+ $MAKE distclean
+ else
+ # VPATH build.
+ $MAKE distcleancheck
+ fi \
+ && test ! -f cscope.files \
+ && test ! -f cscope.out \
+ && test ! -f cscope.in.out \
+ && test ! -f cscope.po.out \
+ || r='not ok'
+ result_ "$r" "[$pfx] make distcheck"
+}
+
+test_cscope ()
+{
+ r=ok
+ $MAKE -n cscope || r='not ok'
+ result_ "$r" "[$pfx] make -n cscope"
+
+ if test $have_cscope = no; then
+ # For later tests.
+ touch cscope.files cscope.out cscope.in.out cscope.po.out
+ skip_row_ 3 -r "no cscope program avaiable"
+ return 0
+ fi
+
+ r=ok
+ $MAKE cscope 2>stderr || r='not ok'
+ cat stderr >&2
+ grep 'cannot find file' stderr && r='not ok'
+ rm -f stderr
+ result_ "$r" "[$pfx] make cscope"
+
+ r=ok
+ test -f cscope.files \
+ && $FGREP foo.c cscope.files \
+ && $FGREP bar.cpp cscope.files \
+ && $FGREP sub/subsub/dist.c cscope.files \
+ && $FGREP sub/subsub/gen.c cscope.files \
+ || r='not ok'
+ result_ "$r" "[$pfx] cscope.files looks correct"
+
+ r=ok
+ # cscope.files might not exist of the earlier "make cscope" failed.
+ cp cscope.files cscope.files1 \
+ && $MAKE cscope \
+ && diff cscope.files cscope.files1 \
+ || r='not ok'
+ rm -f cscope.files1
+ result_ "$r" "[$pfx] second \"make cscope\" is consistent"
+}
+
+my_configure ()
+{
+ command_ok_ "[$pfx] configure" \
+ "$1"/configure EMACS=no --with-lispdir=/who/cares
+}
+
+if using_gmake; then
+
+ cd "$ocwd"
+ pfx="relative VPATH"
+ mkdir build
+ cd build
+ my_configure ..
+ test_cscope
+ test_cleanup
+
+ cd "$ocwd"
+ pfx="absolute VPATH"
+ mkdir build2
+ cd build2
+ my_configure "$ocwd"
+ test_cscope
+ test_cleanup
+
+else
+
+ skip_row_ 12 -r "cscope in VPATH required GNU make"
+
+fi
+
+cd "$ocwd"
+pfx="in-tree build"
+my_configure .
+test_cscope
+test_cleanup
+
+:
diff --git a/t/cscope2.sh b/t/cscope2.sh
new file mode 100755
index 000000000..f72bb6a32
--- /dev/null
+++ b/t/cscope2.sh
@@ -0,0 +1,34 @@
+#! /bin/sh
+# Copyright (C) 2009-2012 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/>.
+
+# The 'cscope' target should not fail if there are no sources.
+
+required=
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+: >Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+$MAKE cscope
+
+:
diff --git a/t/cscope3.sh b/t/cscope3.sh
new file mode 100755
index 000000000..47bcd4d3a
--- /dev/null
+++ b/t/cscope3.sh
@@ -0,0 +1,39 @@
+#! /bin/sh
+# Copyright (C) 2009-2012 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/>.
+
+# The 'cscope' target should not fail if there are no sources in a subdir.
+# In practice this means 'cscope' should not be invoked if cscope.files
+# is empty.
+
+required=cscope
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_CONFIG_FILES([sub/Makefile])
+AC_OUTPUT
+END
+mkdir sub
+echo 'SUBDIRS = sub' >Makefile.am
+: >sub/Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+$MAKE cscope
+
+:
diff --git a/t/cxx.sh b/t/cxx.sh
new file mode 100755
index 000000000..63e55b87a
--- /dev/null
+++ b/t/cxx.sh
@@ -0,0 +1,34 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test that '.c++' extension works.
+# From Ralf Corsepius.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CXX
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = hello
+hello_SOURCES = hello.c++
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+grep '^\.SUFFIXES:.*c[+][+]' Makefile.in
diff --git a/t/cxx2.sh b/t/cxx2.sh
new file mode 100755
index 000000000..243e607d0
--- /dev/null
+++ b/t/cxx2.sh
@@ -0,0 +1,30 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Test that Automake suggests using AC_PROG_CXX if C++ sources are used.
+
+. ./defs || Exit 1
+
+echo AC_PROG_CC >>configure.ac
+
+cat >Makefile.am <<'END'
+bin_PROGRAMS = hello
+hello_SOURCES = hello.cpp
+END
+
+$ACLOCAL
+AUTOMAKE_fails
+grep AC_PROG_CXX stderr
diff --git a/t/cxxcpp.sh b/t/cxxcpp.sh
new file mode 100755
index 000000000..cc69163ca
--- /dev/null
+++ b/t/cxxcpp.sh
@@ -0,0 +1,30 @@
+#! /bin/sh
+# Copyright (C) 1998-2012 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 automake sees AC_PROG_CXXCPP. From Garth Corral.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CXXCPP
+END
+
+: > Makefile.am
+
+$ACLOCAL
+$AUTOMAKE
+
+grep '^CXXCPP' Makefile.in
diff --git a/t/cxxlibobj.sh b/t/cxxlibobj.sh
new file mode 100755
index 000000000..6f4ce2ea1
--- /dev/null
+++ b/t/cxxlibobj.sh
@@ -0,0 +1,40 @@
+#! /bin/sh
+# Copyright (C) 1997-2012 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/>.
+
+# Test to make sure LIBOBJS and C++ sources work right.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CXX
+AC_PROG_CC
+AC_REPLACE_FUNCS(strdup)
+END
+
+cat > Makefile.am << 'END'
+sbin_PROGRAMS = anonymous
+anonymous_SOURCES = doe.C jane.C
+anonymous_LDADD = @LIBOBJS@
+END
+
+: > strdup.c
+: > doe.C
+: > jane.C
+
+$ACLOCAL
+$AUTOMAKE
+
+grep CC Makefile.in
diff --git a/t/cxxlink.sh b/t/cxxlink.sh
new file mode 100755
index 000000000..5ce3beb6f
--- /dev/null
+++ b/t/cxxlink.sh
@@ -0,0 +1,39 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test to make sure C++ linker is used when appropriate.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_PROG_CXX
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = lavalamp
+lavalamp_SOURCES = lava.c lamp.cxx
+END
+
+: > lava.c
+: > lamp.cxx
+
+$ACLOCAL
+$AUTOMAKE
+
+# Look for this macro not at the beginning of any line; that will have
+# to be good enough for now.
+grep '.CXXLINK' Makefile.in
diff --git a/t/cxxnoc.sh b/t/cxxnoc.sh
new file mode 100755
index 000000000..66d0b0df2
--- /dev/null
+++ b/t/cxxnoc.sh
@@ -0,0 +1,37 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test to make sure pure C++ sources don't include C-specific code.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CXX
+END
+
+cat > Makefile.am << 'END'
+sbin_PROGRAMS = anonymous
+anonymous_SOURCES = doe.C jane.C
+END
+
+: > doe.C
+: > jane.C
+
+$ACLOCAL
+$AUTOMAKE
+
+$FGREP '(CC)' Makefile.in && Exit 1
+Exit 0
diff --git a/t/cxxo.sh b/t/cxxo.sh
new file mode 100755
index 000000000..a754701d7
--- /dev/null
+++ b/t/cxxo.sh
@@ -0,0 +1,34 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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 C++ files are rewritten to ".o" and not just "o".
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CXX
+END
+
+cat > Makefile.am << 'END'
+sbin_PROGRAMS = anonymous
+anonymous_SOURCES = doe.C
+END
+
+: > doe.C
+
+$ACLOCAL
+$AUTOMAKE
+
+$FGREP 'doe.$(OBJEXT)' Makefile.in
diff --git a/t/cygnus-check-without-all.sh b/t/cygnus-check-without-all.sh
new file mode 100755
index 000000000..f428e9533
--- /dev/null
+++ b/t/cygnus-check-without-all.sh
@@ -0,0 +1,50 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Check that, in cygnus mode, target "check" does not depend target
+# "all".
+
+. ./defs || Exit 1
+
+cat >> configure.ac <<'END'
+AM_MAINTAINER_MODE
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+all-local:
+ : > all-target-has-failed
+ exit 1
+check-local:
+ touch check-target-has-run
+END
+
+$ACLOCAL
+$AUTOMAKE --cygnus
+
+$EGREP '(^| )all.*(:|:.* )check' Makefile.in && Exit 1
+
+$AUTOCONF
+./configure
+
+$MAKE check
+test -f check-target-has-run
+test ! -r all-target-has-failed
+# Sanity checks.
+$MAKE && Exit 1
+test -f all-target-has-failed
+
+:
diff --git a/t/cygnus-dependency-tracking.sh b/t/cygnus-dependency-tracking.sh
new file mode 100755
index 000000000..f07c6fc51
--- /dev/null
+++ b/t/cygnus-dependency-tracking.sh
@@ -0,0 +1,73 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Check that cygnus mode disables automatic dependency tracking.
+# And check that this *cannot* be overridden.
+
+required=cc
+. ./defs || Exit 1
+
+cat >> configure.ac <<'END'
+AM_MAINTAINER_MODE
+AC_PROG_CC
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+bin_PROGRAMS = foo
+foo_SOURCES = foo.c
+.PHONY: test-nodeps
+test-nodeps:
+ test ! -d .deps
+ test ! -d _deps
+ test ! -d '$(DEPDIR)'
+END
+
+cat > foo.c <<'END'
+#include "bar.h"
+int main ()
+{
+ GIVE_BACK 0;
+}
+END
+
+cat > bar.sav <<'END'
+#define GIVE_BACK return
+END
+
+cp bar.sav bar.h
+
+$ACLOCAL
+$AUTOMAKE --include-deps --cygnus --include-deps
+$AUTOCONF
+
+# Unknown options should cause just warnings from configure.
+./configure --enable-dependency-tracking
+$MAKE
+$MAKE test-nodeps
+
+: > bar.h
+$MAKE
+$MAKE test-nodeps
+
+# Sanity check.
+$MAKE clean
+$MAKE >out 2>&1 && { cat out; Exit 1; }
+cat out
+# Not all compilers mention the undefined symbol in the error message.
+grep GIVE_BACK out || grep main out
+
+:
diff --git a/t/cygnus-imply-foreign.sh b/t/cygnus-imply-foreign.sh
new file mode 100755
index 000000000..3dcf6715a
--- /dev/null
+++ b/t/cygnus-imply-foreign.sh
@@ -0,0 +1,60 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Check that 'cygnus' mode imply 'foreign' mode.
+
+. ./defs || Exit 1
+
+cat >> configure.ac <<'END'
+# This is *required* in cygnus mode
+AM_MAINTAINER_MODE
+END
+
+$ACLOCAL
+
+: > Makefile.am
+
+# We want complete control automake flags, while honouring the
+# user overrides for $AUTOMAKE.
+AUTOMAKE=$am_original_AUTOMAKE
+
+# Sanity check: gnu mode must complain about missing files and
+# portability problems.
+AUTOMAKE_fails
+grep 'required file.*README' stderr
+
+# But cygnus mode should imply foreign mode, so no complaints.
+# And cygnus mode should by able to override gnu and gnits modes.
+$AUTOMAKE --cygnus -Werror
+$AUTOMAKE --gnu --cygnus -Werror
+$AUTOMAKE --gnits --cygnus -Werror
+
+# Try again, this time enabling cygnus mode from Makefile.am.
+cp Makefile.am Makefile.sav
+echo 'AUTOMAKE_OPTIONS = gnu cygnus' >> Makefile.am
+$AUTOMAKE -Werror
+mv -f Makefile.sav Makefile.am
+
+# Try again, this time enabling cygnus mode from configure.ac.
+cp configure.ac configure.sav
+sed 's/^AM_INIT_AUTOMAKE$/&([gnits cygnus])/' configure.sav >configure.ac
+cmp configure.ac configure.sav && fatal_ 'failed to edit configure.ac'
+
+$ACLOCAL --force
+$AUTOMAKE -Werror
+mv -f configure.sav configure.ac
+
+:
diff --git a/t/cygnus-no-dist.sh b/t/cygnus-no-dist.sh
new file mode 100755
index 000000000..519f0c2b8
--- /dev/null
+++ b/t/cygnus-no-dist.sh
@@ -0,0 +1,84 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Check that cygnus mode forbids creation of distribution tarball.
+
+. ./defs || Exit 1
+
+echo AM_MAINTAINER_MODE >> configure.ac
+mv -f configure.ac configure.stub
+
+cat configure.stub - > configure.ac <<'END'
+AC_OUTPUT
+END
+
+: > Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --cygnus
+
+./configure
+$MAKE
+
+for target in dist distdir distcheck dist-all dist-gzip; do
+ $MAKE -n $target >out 2>&1 && { cat out; Exit 1; }
+ cat out
+ grep $target out
+done
+
+# Now check that cygnus mode in a subdirectory disables
+# distribution-building in that subdirectory.
+
+cat > Makefile.am <<'END'
+SUBDIRS = sub1 sub2
+END
+
+mkdir sub1 sub2
+: > sub1/Makefile.am
+cat > sub2/Makefile.am <<'END'
+# The '-Wall' after 'cygnus' should ensure no warning gets
+# unintentionally disabled. We are particularly interested
+# in override warnings, for when (below) we add the 'distdir'
+# target.
+AUTOMAKE_OPTIONS = cygnus -Wall
+END
+
+cat configure.stub - > configure.ac <<'END'
+AC_CONFIG_FILES([sub1/Makefile sub2/Makefile])
+AC_OUTPUT
+END
+
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+$MAKE
+cd sub2
+$MAKE -n distdir >out 2>&1 && { cat out; Exit 1; }
+grep distdir out
+cd ..
+
+cat >> sub2/Makefile.am <<'END'
+distdir:
+END
+$AUTOMAKE sub2/Makefile
+./config.status sub2/Makefile
+
+$MAKE distdir
+$MAKE dist
+
+:
diff --git a/t/cygnus-no-installinfo.sh b/t/cygnus-no-installinfo.sh
new file mode 100755
index 000000000..6f3f322ff
--- /dev/null
+++ b/t/cygnus-no-installinfo.sh
@@ -0,0 +1,53 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Check that cygnus mode enables the 'no-installinfo' option.
+
+required=makeinfo
+. ./defs || Exit 1
+
+cat >> configure.ac <<'END'
+AM_MAINTAINER_MODE
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+info_TEXINFOS = foo.texi
+END
+
+cat > foo.texi <<'END'
+@setfilename foo.info
+END
+
+$ACLOCAL
+# FIXME: -Wno-override works around a buglet in definition of $(MAKEINFO)
+# in cygnus mode; see also xfailing test 'txinfo5.test'.
+$AUTOMAKE --cygnus -Wno-override
+$AUTOCONF
+
+cwd=`pwd` || Exit 1
+./configure --prefix="$cwd"/_inst
+$MAKE
+$MAKE install
+test ! -d _inst
+test ! -r foo.info
+test ! -d _inst/share/info
+$MAKE install-info
+ls -l _inst
+test -f foo.info
+test -f _inst/share/info/foo.info
+
+:
diff --git a/t/cygnus-requires-maintainer-mode.sh b/t/cygnus-requires-maintainer-mode.sh
new file mode 100755
index 000000000..b01dfbcb8
--- /dev/null
+++ b/t/cygnus-requires-maintainer-mode.sh
@@ -0,0 +1,53 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Check that, in cygnus mode, maintainer mode is required.
+
+. ./defs || Exit 1
+
+: > Makefile.am
+
+$ACLOCAL
+AUTOMAKE_fails --cygnus
+grep '^configure\.ac:.*AM_MAINTAINER_MODE.*required.*cygnus' stderr
+
+cat >> configure.ac <<'END'
+AC_CONFIG_FILES([sub/Makefile])
+END
+
+cat > Makefile.am <<'END'
+SUBDIRS = sub
+END
+
+mkdir sub
+cat > sub/Makefile.am <<'END'
+AUTOMAKE_OPTIONS = cygnus
+END
+
+rm -rf autom4te.cache
+$ACLOCAL
+AUTOMAKE_fails
+grep '^configure\.ac:.*AM_MAINTAINER_MODE.*required.*cygnus' stderr
+
+cat >> configure.ac <<'END'
+AM_MAINTAINER_MODE
+END
+
+rm -rf autom4te.cache
+$ACLOCAL
+$AUTOMAKE --cygnus
+
+:
diff --git a/t/cygwin32.sh b/t/cygwin32.sh
new file mode 100755
index 000000000..9415fb64c
--- /dev/null
+++ b/t/cygwin32.sh
@@ -0,0 +1,38 @@
+#! /bin/sh
+# Copyright (C) 1997-2012 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/>.
+
+# Test basic Cygwin32 functionality.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = www
+www_SOURCES = www.c
+EXTRA_www_SOURCES = xtra.c
+www_LDADD = @extra_stuff@
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+grep '^CYGWIN' Makefile.in && Exit 1
+grep 'EXEEXT' Makefile.in
+
+:
diff --git a/t/dash.sh b/t/dash.sh
new file mode 100755
index 000000000..992bf6228
--- /dev/null
+++ b/t/dash.sh
@@ -0,0 +1,29 @@
+#! /bin/sh
+# Copyright (C) 1999-2012 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/>.
+
+# Test to make sure '-' can be used in path.
+# Report from Matthew D. Langston.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+include Make-lang
+END
+
+: > Make-lang
+
+$ACLOCAL
+$AUTOMAKE
diff --git a/t/defs b/t/defs
new file mode 100644
index 000000000..fb1370898
--- /dev/null
+++ b/t/defs
@@ -0,0 +1,1102 @@
+# -*- shell-script -*-
+#
+# Copyright (C) 1996-2012 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/>.
+
+########################################################
+### IMPORTANT NOTE: keep this file 'set -e' clean. ###
+########################################################
+
+# NOTE: This file should execute correctly with any system's /bin/sh
+# shell, and not only with configure-time detected $CONFIG_SHELL,
+# *until differently and explicitly specified*.
+
+## -------------------------------------------------------- ##
+## Source static setup and definitions for the testsuite. ##
+## -------------------------------------------------------- ##
+
+# Ensure we are running from the right directory.
+test -f ./defs-static || {
+ echo "$0: ./defs-static: not found in current directory" >&2
+ exit 99
+}
+
+# Source the shell sanitization and variables' definitions.
+. ./defs-static || exit 99
+
+# Enable the errexit shell flag early.
+set -e
+
+# The name of the current test (without the '.sh' or '.tap' suffix).
+# Test scripts can override it if they need to (but this should
+# be done carefully, and *before* including ./defs).
+if test -z "$me"; then
+ # Guard against failure to spawn sed (seen on MSYS), or empty $argv0.
+ me=`echo "$argv0" | sed -e 's,.*[\\/],,;s/\.sh$//;s/\.tap$//;'` \
+ && test -n "$me" \
+ || { echo "$argv0: failed to define \$me" >&2; exit 99; }
+fi
+
+## ---------------------- ##
+## Early sanity checks. ##
+## ---------------------- ##
+
+# A single whitespace character.
+sp=' '
+# A tabulation character.
+tab=' '
+# A newline character.
+nl='
+'
+
+# As autoconf-generated configure scripts do, ensure that IFS
+# is defined initially, so that saving and restoring $IFS works.
+IFS=$sp$tab$nl
+
+# Ensure $testsrcdir is set correctly.
+test -f "$testsrcdir/defs-static.in" || {
+ echo "$me: $testsrcdir/defs-static.in not found, check \$testsrcdir" >&2
+ exit 99
+}
+
+# Ensure $testbuilddir is set correctly.
+test -f "$testbuilddir/defs-static" || {
+ echo "$me: $testbuilddir/defs-static not found, check \$testbuilddir" >&2
+ exit 99
+}
+
+
+## ------------------------------------ ##
+## Ensure we run with a proper shell. ##
+## ------------------------------------ ##
+
+# Make sure we run with the shell detected at configure time (unless
+# the user forbids it).
+case ${AM_TESTS_REEXEC-yes} in
+ n|no|false|0)
+ ;;
+ *)
+ # Ensure we can find ourselves.
+ if test ! -f "$0"; then
+ echo "$me: unable to find myself: $0" >&2
+ exit 99
+ fi
+ AM_TESTS_REEXEC=no; export AM_TESTS_REEXEC
+ # Cannot simply do "opts=$-", since the content of $- is not
+ # portable among different shells. So try to propagate only
+ # the portable and interesting options.
+ case $- in
+ *x*v*|*v*x) opts=-vx;;
+ *v*) opts=-v;;
+ *x*) opts=-x;;
+ *) opts=;;
+ esac
+ echo $me: exec $SHELL $opts "$0" "$*"
+ exec $SHELL $opts "$0" ${1+"$@"} || {
+ echo "$me: failed to re-execute with $SHELL" >&2
+ exit 99
+ }
+ ;;
+esac
+
+# NOTE: From this point on, we can assume this file is being executed
+# by the configure-time detected $CONFIG_SHELL.
+
+
+## ----------------------- ##
+## Early debugging info. ##
+## ----------------------- ##
+
+echo "Running from installcheck: $am_running_installcheck"
+echo "Using TAP: $am_using_tap"
+echo "PATH = $PATH"
+
+
+## ---------------------- ##
+## Environment cleanup. ##
+## ---------------------- ##
+
+# Temporarily disable this, since some shells (e.g., older version
+# of Bash) can return a non-zero exit status upon the when a non-set
+# variable is unset.
+set +e
+
+# Unset some make-related 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 MAKEFLAGS AM_MAKEFLAGS MAKELEVEL
+unset __MKLVL__ MAKE_JOBS_FIFO # For BSD make.
+unset DMAKE_CHILD DMAKE_DEF_PRINTED DMAKE_MAX_JOBS # For Solaris dmake.
+# Unset verbosity flag.
+unset V
+# Also unset variables that will let "make -e install" divert
+# files into unwanted directories.
+unset DESTDIR
+unset prefix exec_prefix bindir datarootdir datadir docdir dvidir
+unset htmldir includedir infodir libdir libexecdir localedir mandir
+unset oldincludedir pdfdir psdir sbindir sharedstatedir sysconfdir
+# Unset variables that might change the "make distcheck" behaviour.
+unset DISTCHECK_CONFIGURE_FLAGS AM_DISTCHECK_CONFIGURE_FLAGS
+# The tests call "make -e" but we do not want $srcdir from the environment
+# to override the definition from the Makefile.
+unset srcdir
+# Also unset variables that control our test driver. While not
+# conceptually independent, they cause some changed semantics we
+# need to control (and test for) in some of the tests to ensure
+# backward-compatible behavior.
+unset TESTS_ENVIRONMENT AM_TESTS_ENVIRONMENT
+unset DISABLE_HARD_ERRORS
+unset AM_COLOR_TESTS
+unset TESTS
+unset XFAIL_TESTS
+unset TEST_LOGS
+unset TEST_SUITE_LOG
+unset RECHECK_LOGS
+unset VERBOSE
+for pfx in TEST_ TAP_ ''; do
+ unset ${pfx}LOG_COMPILER
+ unset ${pfx}LOG_COMPILE # Not a typo!
+ unset ${pfx}LOG_FLAGS
+ unset AM_${pfx}LOG_FLAGS
+ unset ${pfx}LOG_DRIVER
+ unset ${pfx}LOG_DRIVER_FLAGS
+ unset AM_${pfx}LOG_DRIVER_FLAGS
+done
+unset pfx
+
+# Re-enable, it had been temporarily disabled above.
+set -e
+
+## ---------------------------- ##
+## Auxiliary shell functions. ##
+## ---------------------------- ##
+
+# Tell whether we should keep the test directories around, even in
+# case of success. By default, we don't.
+am_keeping_testdirs ()
+{
+ case $keep_testdirs in
+ ""|n|no|NO) return 1;;
+ *) return 0;;
+ esac
+}
+
+# This is used in 'Exit' and in the exit trap. See comments in the latter
+# for more information,
+am__test_skipped=no
+
+# We use a trap below for cleanup. This requires us to go through
+# hoops to get the right exit status transported through the signal.
+# So use "Exit STATUS" instead of "exit STATUS" inside of the tests.
+# Turn off errexit here so that we don't trip the bug with OSF1/Tru64
+# sh inside this function.
+Exit ()
+{
+ set +e
+ # See comments in the exit trap for the reason we do this.
+ test 77 = $1 && am__test_skipped=yes
+ (exit $1); exit $1
+}
+
+if test $am_using_tap = yes; then
+ am_funcs_file=tap-functions.sh
+else
+ am_funcs_file=plain-functions.sh
+fi
+
+if test -f "$am_testauxdir/$am_funcs_file"; then
+ . "$am_testauxdir/$am_funcs_file" || {
+ echo "$me: error sourcing $testsrcdir/$am_funcs_file" >&2
+ Exit 99
+ }
+else
+ echo "$me: $am_testauxdir/$am_funcs_file not found" >&2
+ Exit 99
+fi
+unset am_funcs_file
+
+# cross_compiling
+# ---------------
+# Tell whether we are cross-compiling. This is especially useful to skip
+# tests (or portions of them) that requires a native compiler.
+cross_compiling ()
+{
+ # Quoting from the autoconf manual:
+ # ... [$host_alias and $build both] default to the result of running
+ # config.guess, unless you specify either --build or --host. In
+ # this case, the default becomes the system type you specified.
+ # If you specify both, *and they're different*, configure enters
+ # cross compilation mode (so it doesn't run any tests that require
+ # execution).
+ test x"$host_alias" != x && test x"$build_alias" != x"$host_alias"
+}
+
+# is_newest FILE FILES
+# --------------------
+# Return false if any file in FILES is newer than FILE.
+# Resolve ties in favor of FILE.
+is_newest ()
+{
+ is_newest_files=`find "$@" -prune -newer "$1"`
+ test -z "$is_newest_files"
+}
+
+# is_blocked_signal SIGNAL-NUMBER
+# --------------------------------
+# Return success if the given signal number is blocked in the shell,
+# return a non-zero exit status and print a proper diagnostic otherwise.
+is_blocked_signal ()
+{
+ # Use perl, since trying to do this portably in the shell can be
+ # very tricky, if not downright impossible. For reference, see:
+ # <http://lists.gnu.org/archive/html/bug-autoconf/2011-09/msg00004.html>
+ if $PERL -w -e '
+ use strict;
+ use warnings FATAL => "all";
+ use POSIX;
+ my %oldsigaction = ();
+ sigaction('"$1"', 0, \%oldsigaction);
+ exit ($oldsigaction{"HANDLER"} eq "IGNORE" ? 0 : 77);
+ '; then
+ return 0
+ elif test $? -eq 77; then
+ return 1
+ else
+ fatal_ "couldn't determine whether signal $1 is blocked"
+ fi
+}
+
+# AUTOMAKE_run [-e STATUS] [-d DESCRIPTION] [--] [AUTOMAKE-ARGS...]
+# -----------------------------------------------------------------
+# Run automake with AUTOMAKE-ARGS, and fail if it doesn't exit with
+# STATUS. Should be polymorphic for TAP and "plain" tests. The
+# DESCRIPTION, when provided, is used for console reporting, only if
+# the TAP protocol is in use in the current test script.
+AUTOMAKE_run ()
+{
+ am__desc=
+ am__exp_rc=0
+ while test $# -gt 0; do
+ case $1 in
+ -d) am__desc=$2; shift;;
+ -e) am__exp_rc=$2; shift;;
+ --) shift; break;;
+ # Don't fail on unknown option: assume they (and the rest of the
+ # command line) are to be passed verbatim to automake (so stop our
+ # own option parsing).
+ *) break;;
+ esac
+ shift
+ done
+ am__got_rc=0
+ $AUTOMAKE ${1+"$@"} >stdout 2>stderr || am__got_rc=$?
+ cat stderr >&2
+ cat stdout
+ if test $am_using_tap != yes; then
+ test $am__got_rc -eq $am__exp_rc || Exit 1
+ return
+ fi
+ if test -z "$am__desc"; then
+ if test $am__got_rc -eq $am__exp_rc; then
+ am__desc="automake exited $am__got_rc"
+ else
+ am__desc="automake exited $am__got_rc, expecting $am__exp_rc"
+ fi
+ fi
+ command_ok_ "$am__desc" test $am__got_rc -eq $am__exp_rc
+}
+
+# AUTOMAKE_fails [-d DESCRIPTION] [OPTIONS...]
+# --------------------------------------------
+# Run automake with OPTIONS, and fail if doesn't exit with status 1.
+# Should be polymorphic for TAP and "plain" tests. The DESCRIPTION,
+# when provided, is used for console reporting, only if the TAP
+# protocol is in use in the current test script.
+AUTOMAKE_fails ()
+{
+ AUTOMAKE_run -e 1 ${1+"$@"}
+}
+
+# extract_configure_help { --OPTION | VARIABLE-NAME } [FILES]
+# -----------------------------------------------------------
+# Use this to extract from the output of "./configure --help" (or similar)
+# the description or help message associated to the given --OPTION or
+# VARIABLE-NAME.
+extract_configure_help ()
+{
+ am__opt_re='' am__var_re=''
+ case $1 in
+ --*'=') am__opt_re="^ $1";;
+ --*'[=]') am__opt_re='^ '`printf '%s\n' "$1" | sed 's/...$//'`'\[=';;
+ --*) am__opt_re="^ $1( .*|$)";;
+ *) am__var_re="^ $1( .*|$)";;
+ esac
+ shift
+ if test x"$am__opt_re" != x; then
+ LC_ALL=C awk '
+ /'"$am__opt_re"'/ { print; do_print = 1; next; }
+ /^$/ { do_print = 0; next }
+ /^ --/ { do_print = 0; next }
+ (do_print == 1) { print }
+ ' ${1+"$@"}
+ else
+ LC_ALL=C awk '
+ /'"$am__var_re"'/ { print; do_print = 1; next; }
+ /^$/ { do_print = 0; next }
+ /^ [A-Z][A-Z0-9_]* / { do_print = 0; next }
+ /^ [A-Z][A-Z0-9_]*$/ { do_print = 0; next }
+ (do_print == 1) { print }
+ ' ${1+"$@"}
+ fi
+}
+
+# grep_configure_help { --OPTION | VARIABLE-NAME } REGEXP
+# -------------------------------------------------------
+# Grep the section of "./configure --help" output associated with either
+# --OPTION or VARIABLE-NAME for the given *extended* regular expression.
+grep_configure_help ()
+{
+ ./configure --help > am--all-help \
+ || { cat am--all-help; Exit 1; }
+ cat am--all-help
+ extract_configure_help "$1" am--all-help > am--our-help \
+ || { cat am--our-help; Exit 1; }
+ cat am--our-help
+ $EGREP "$2" am--our-help || Exit 1
+}
+
+# using_gmake
+# -----------
+# Return success if $MAKE is GNU make, return failure otherwise.
+# Caches the result for speed reasons.
+using_gmake ()
+{
+ case $am__using_gmake in
+ yes)
+ return 0;;
+ no)
+ return 1;;
+ '')
+ # Use --version AND -v, because SGI Make doesn't fail on --version.
+ # Also grep for GNU because newer versions of FreeBSD make do
+ # not complain about --version (they seem to silently ignore it).
+ if $MAKE --version -v | grep GNU; then
+ am__using_gmake=yes
+ return 0
+ else
+ am__using_gmake=no
+ return 1
+ fi;;
+ *)
+ fatal_ "invalid value for \$am__using_gmake: '$am__using_gmake'";;
+ esac
+}
+am__using_gmake="" # Avoid interferences from the environment.
+
+# make_can_chain_suffix_rules
+# ---------------------------
+# Return 0 if $MAKE is a make implementation that can chain suffix rules
+# automatically, return 1 otherwise. Caches the result for speed reasons.
+make_can_chain_suffix_rules ()
+{
+ if test -z "$am__can_chain_suffix_rules"; then
+ if using_gmake; then
+ am__can_chain_suffix_rules=yes
+ return 0
+ else
+ mkdir am__chain.dir$$
+ cd am__chain.dir$$
+ unindent > Makefile << 'END'
+ .SUFFIXES: .u .v .w
+ .u.v: ; cp $< $@
+ .v.w: ; cp $< $@
+END
+ echo make can chain suffix rules > foo.u
+ if $MAKE foo.w && diff foo.u foo.w; then
+ am__can_chain_suffix_rules=yes
+ else
+ am__can_chain_suffix_rules=no
+ fi
+ cd ..
+ rm -rf am__chain.dir$$
+ fi
+ fi
+ case $am__can_chain_suffix_rules in
+ yes) return 0;;
+ no) return 1;;
+ *) fatal_ "make_can_chain_suffix_rules: internal error";;
+ esac
+}
+am__can_chain_suffix_rules="" # Avoid interferences from the environment.
+
+# useless_vpath_rebuild
+# ---------------------
+# Tell whether $MAKE suffers of the bug triggering automake bug#7884.
+# For example, this happens with FreeBSD make, since in a VPATH build
+# it tends to rebuilt files for which there is an explicit or even just
+# a suffix rule, even if said files are already available in the VPATH
+# directory.
+useless_vpath_rebuild ()
+{
+ if test -z "$am__useless_vpath_rebuild"; then
+ if using_gmake; then
+ am__useless_vpath_rebuild=no
+ return 1
+ fi
+ mkdir am__vpath.dir$$
+ cd am__vpath.dir$$
+ touch foo.a foo.b bar baz
+ mkdir build
+ cd build
+ unindent > Makefile << 'END'
+ .SUFFIXES: .a .b
+ VPATH = ..
+ all: foo.b baz
+ .PHONY: all
+ .a.b: ; cp $< $@
+ baz: bar ; cp ../baz bar
+END
+ if $MAKE all && test ! -f foo.b && test ! -f bar; then
+ am__useless_vpath_rebuild=no
+ else
+ am__useless_vpath_rebuild=yes
+ fi
+ cd ../..
+ rm -rf am__vpath.dir$$
+ fi
+ case $am__useless_vpath_rebuild in
+ yes) return 0;;
+ no) return 1;;
+ "") ;;
+ *) fatal_ "no_useless_builddir_remake: internal error";;
+ esac
+}
+am__useless_vpath_rebuild=""
+
+yl_distcheck () { useless_vpath_rebuild || $MAKE distcheck ${1+"$@"}; }
+
+# seq_ - print a sequence of numbers
+# ----------------------------------
+# This function simulates GNU seq(1) portably. Valid usages:
+# - seq LAST
+# - seq FIRST LAST
+# - seq FIRST INCREMENT LAST
+seq_ ()
+{
+ case $# in
+ 0) fatal_ "seq_: missing argument";;
+ 1) seq_first=1 seq_incr=1 seq_last=$1;;
+ 2) seq_first=$1 seq_incr=1 seq_last=$2;;
+ 3) seq_first=$1 seq_incr=$2 seq_last=$3;;
+ *) fatal_ "seq_: too many arguments";;
+ esac
+ # Try to avoid forks if possible.
+ case "$BASH_VERSION" in
+ ""|[12].*)
+ : Not bash, or a too old bash version. ;;
+ *)
+ # Use eval to protect dumber shells from parsing errors.
+ eval 'for ((i = seq_first; i <= seq_last; i += seq_incr)); do
+ echo $i
+ done'
+ return 0;;
+ esac
+ # Else, use GNU seq if available.
+ seq "$@" && return 0
+ # Otherwise revert to a slower loop using expr(1).
+ i=$seq_first
+ while test $i -le $seq_last; do
+ echo $i
+ i=`expr $i + $seq_incr`
+ done
+}
+
+# rm_rf_ [FILES OR DIRECTORIES ...]
+# ---------------------------------
+# Recursively remove the given files or directory, also handling the case
+# of non-writable subdirectories.
+rm_rf_ ()
+{
+ test $# -gt 0 || return 0
+ # Ignore failures in find, we are only interested in failures of the
+ # final rm.
+ find "$@" -type d ! -perm -700 -exec chmod u+rwx {} \; || :
+ rm -rf "$@"
+}
+
+# count_test_results total=N pass=N fail=N xpass=N xfail=N skip=N error=N
+# -----------------------------------------------------------------------
+# Check that a testsuite run driven by the parallel-tests harness has
+# had the specified numbers of test results (specified by kind).
+# This function assumes that the output of "make check" or "make recheck"
+# has been saved in the 'stdout' file in the current directory, and its
+# log in the 'test-suite.log' file.
+count_test_results ()
+{
+ # Use a subshell so that we won't pollute the script namespace.
+ (
+ # TODO: Do proper checks on the arguments?
+ total=ERR pass=ERR fail=ERR xpass=ERR xfail=ERR skip=ERR error=ERR
+ eval "$@"
+ # For debugging.
+ $EGREP -i '(total|x?pass|x?fail|skip|error)' stdout || :
+ rc=0
+ # Avoid spurious failures with shells with "overly sensible"
+ # errexit shell flag, such as e.g., Solaris /bin/sh.
+ set +e
+ test `grep -c '^PASS:' stdout` -eq $pass || rc=1
+ test `grep -c '^XFAIL:' stdout` -eq $xfail || rc=1
+ test `grep -c '^SKIP:' stdout` -eq $skip || rc=1
+ test `grep -c '^FAIL:' stdout` -eq $fail || rc=1
+ test `grep -c '^XPASS:' stdout` -eq $xpass || rc=1
+ test `grep -c '^ERROR:' stdout` -eq $error || rc=1
+ grep "^# TOTAL: *$total$" stdout || rc=1
+ grep "^# PASS: *$pass$" stdout || rc=1
+ grep "^# XFAIL: *$xfail$" stdout || rc=1
+ grep "^# SKIP: *$skip$" stdout || rc=1
+ grep "^# FAIL: *$fail$" stdout || rc=1
+ grep "^# XPASS: *$xpass$" stdout || rc=1
+ grep "^# ERROR: *$error$" stdout || rc=1
+ test $rc -eq 0
+ )
+}
+
+commented_sed_unindent_prog='
+ /^$/b # Nothing to do for empty lines.
+ x # Get x<indent> into pattern space.
+ /^$/{ # No prior x<indent>, go prepare it.
+ g # Copy this 1st non-blank line into pattern space.
+ s/^\(['"$tab"' ]*\).*/x\1/ # Prepare x<indent> in pattern space.
+ } # Now: x<indent> in pattern and <line> in hold.
+ G # Build x<indent>\n<line> in pattern space, and
+ h # duplicate it into hold space.
+ s/\n.*$// # Restore x<indent> in pattern space, and
+ x # exchange with the above duplicate in hold space.
+ s/^x\(.*\)\n\1// # Remove leading <indent> from <line>.
+ s/^x.*\n// # Restore <line> when there is no leading <indent>.
+'
+
+# unindent [input files...]
+# -------------------------
+# Remove the "proper" amount of leading whitespace from the given files,
+# and output the result on stdout. That amount is determined by looking
+# at the leading whitespace of the first non-blank line in the input
+# files. If no input file is specified, standard input is implied.
+unindent ()
+{
+ if test x"$sed_unindent_prog" = x; then
+ sed_unindent_prog=`printf '%s\n' "$commented_sed_unindent_prog" | sed -e "s/ *# .*//"`
+ fi
+ sed "$sed_unindent_prog" ${1+"$@"}
+}
+sed_unindent_prog="" # Avoid interferences from the environment.
+
+# get_shell_script SCRIPT-NAME
+# -----------------------------
+# Fetch an Automake-provided shell script from the 'lib/' directory into
+# the current directory, and, if the '$am_test_prefer_config_shell'
+# variable is set to "yes", modify its shebang line to use $SHELL instead
+# of /bin/sh.
+get_shell_script ()
+{
+ test ! -f "$1" || rm -f "$1" || return 99
+ if test x"$am_test_prefer_config_shell" = x"yes"; then
+ sed "1s|#!.*|#! $SHELL|" "$am_scriptdir/$1" > "$1" \
+ && chmod a+x "$1" \
+ || return 99
+ else
+ cp -f "$am_scriptdir/$1" . || return 99
+ fi
+ sed 10q "$1" # For debugging.
+}
+
+# require_xsi SHELL
+# -----------------
+# Skip the test if the given shell fails to support common XSI constructs.
+require_xsi ()
+{
+ test $# -eq 1 || fatal_ "require_xsi needs exactly one argument"
+ echo "$me: trying some XSI constructs with $1"
+ $1 -c "$xsi_shell_code" || skip_all_ "$1 lacks XSI features"
+}
+# Shell code supposed to work only with XSI shells. Keep this in sync
+# with libtool.m4:_LT_CHECK_SHELL_FEATURES.
+xsi_shell_code='
+ _lt_dummy="a/b/c"
+ test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \
+ = c,a/b,b/c, \
+ && eval '\''test $(( 1 + 1 )) -eq 2 \
+ && test "${#_lt_dummy}" -eq 5'\'
+
+# fetch_tap_driver
+# ----------------
+# Fetch the Automake-provided TAP driver from the 'lib/' directory into
+# the current directory, and edit its shebang line so that it will be
+# run with the perl interpreter determined at configure time.
+fetch_tap_driver ()
+{
+ # TODO: we should devise a way to make the shell TAP driver tested also
+ # TODO: with /bin/sh, for better coverage.
+ case $am_tap_implementation in
+ perl)
+ $PERL -MTAP::Parser -e 1 \
+ || skip_all_ "cannot import TAP::Parser perl module"
+ sed "1s|#!.*|#! $PERL -w|" "$am_scriptdir"/tap-driver.pl >tap-driver
+ ;;
+ shell)
+ AM_TAP_AWK=$AWK; export AM_TAP_AWK
+ sed "1s|#!.*|#! $SHELL|" "$am_scriptdir"/tap-driver.sh >tap-driver
+ ;;
+ *)
+ fatal_ "invalid \$am_tap_implementation '$am_tap_implementation'" ;;
+ esac \
+ && chmod a+x tap-driver \
+ || framework_failure_ "couldn't fetch $am_tap_implementation TAP driver"
+ sed 10q tap-driver # For debugging.
+}
+# The shell/awk implementation of the TAP driver is still mostly dummy, so
+# use the perl implementation by default for the moment.
+am_tap_implementation=${am_tap_implementation-shell}
+
+# Usage: require_compiler_ {cc|c++|fortran|fortran77}
+require_compiler_ ()
+{
+ case $# in
+ 0) fatal_ "require_compiler_: missing argument";;
+ 1) ;;
+ *) fatal_ "require_compiler_: too many arguments";;
+ esac
+ case $1 in
+ cc)
+ am__comp_lang="C"
+ am__comp_var=CC
+ am__comp_flag_vars='CFLAGS CPPFLAGS'
+ ;;
+ c++)
+ am__comp_lang="C++"
+ am__comp_var=CXX
+ am__comp_flag_vars='CXXFLAGS CPPFLAGS'
+ ;;
+ fortran)
+ am__comp_lang="Fortran"
+ am__comp_var=FC
+ am__comp_flag_vars='FCFLAGS'
+ ;;
+ fortran77)
+ am__comp_lang="Fortran 77"
+ am__comp_var=F77
+ am__comp_flag_vars='FFLAGS'
+ ;;
+ esac
+ shift
+ eval "am__comp_prog=\${$am__comp_var}" \
+ || fatal_ "expanding \${$am__comp_var} in require_compiler_"
+ case $am__comp_prog in
+ "")
+ fatal_ "botched configuration: \$$am__comp_var is empty";;
+ false)
+ skip_all_ "no $am__comp_lang compiler available";;
+ autodetect|autodetected)
+ # Let the ./configure commands in the test script try to determine
+ # these automatically.
+ unset $am__comp_var $am__comp_flag_vars;;
+ *)
+ # Pre-set these for the ./configure commands in the test script.
+ export $am__comp_var $am__comp_flag_vars;;
+ esac
+ # Delete private variables.
+ unset am__comp_lang am__comp_prog am__comp_var am__comp_flag_vars
+}
+
+## ----------------------------------------------------------- ##
+## Checks for required tools, and additional setups (if any) ##
+## required by them. ##
+## ----------------------------------------------------------- ##
+
+# Look for (and maybe set up) required tools and/or system features; skip
+# the current test if they are not found.
+for tool in : $required
+do
+ # Check that each required tool is present.
+ case $tool in
+ :) ;;
+ cc|c++|fortran|fortran77)
+ require_compiler_ $tool;;
+ xsi-lib-shell)
+ if test x"$am_test_prefer_config_shell" = x"yes"; then
+ require_xsi "$SHELL"
+ else
+ require_xsi "/bin/sh"
+ fi
+ ;;
+ bzip2)
+ # Do not use --version, older versions bzip2 still tries to compress
+ # stdin.
+ echo "$me: running bzip2 --help"
+ bzip2 --help \
+ || skip_all_ "required program 'bzip2' not available"
+ ;;
+ cl)
+ CC=cl
+ # Don't export CFLAGS, as that could have been initialized to only
+ # work with the C compiler detected at configure time. If the user
+ # wants CFLAGS to also influence 'cl', he can still export CFLAGS
+ # in the environment "by hand" before calling the testsuite.
+ export CC CPPFLAGS
+ echo "$me: running $CC -?"
+ $CC -? || skip_all_ "Microsoft C compiler '$CC' not available"
+ ;;
+ 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 build directory.
+ echo "$me: running etags --version -o /dev/null"
+ etags --version -o /dev/null \
+ || skip_all_ "required program 'etags' not available"
+ ;;
+ GNUmake)
+ for make_ in "$MAKE" gmake gnumake :; do
+ MAKE=$make_ am__using_gmake=''
+ test "$MAKE" = : && break
+ echo "$me: determine whether $MAKE is GNU make"
+ # Don't use "&&" here, or a bug of 'set -e' present in some
+ # versions of the BSD shell will be triggered. We add the
+ # dummy "else" branch for extra safety.
+ if using_gmake; then break; else :; fi
+ done
+ test "$MAKE" = : && skip_all_ "this test requires GNU make"
+ export MAKE
+ unset make_
+ ;;
+ gcj)
+ GCJ=$GNU_GCJ GCJFLAGS=$GNU_GCJFLAGS; export GCJ GCJFLAGS
+ test "$GCJ" = false && skip_all_ "GNU Java compiler unavailable"
+ : For shells with busted 'set -e'.
+ ;;
+ gcc)
+ CC=$GNU_CC CFLAGS=$GNU_CFLAGS; export CC CFLAGS CPPFLAGS
+ test "$CC" = false && skip_all_ "GNU C compiler unavailable"
+ : For shells with busted 'set -e'.
+ ;;
+ g++)
+ CXX=$GNU_CXX CXXFLAGS=$GNU_CXXFLAGS; export CXX CXXFLAGS CPPFLAGS
+ test "$CXX" = false && skip_all_ "GNU C++ compiler unavailable"
+ : For shells with busted 'set -e'.
+ ;;
+ gfortran)
+ FC=$GNU_FC FCFLAGS=$GNU_FCFLAGS; export FC FCFLAGS
+ test "$FC" = false && skip_all_ "GNU Fortran compiler unavailable"
+ case " $required " in
+ *\ g77\ *) ;;
+ *) F77=$FC FFLAGS=$FCFLAGS; export F77 FFLAGS;;
+ esac
+ ;;
+ g77)
+ F77=$GNU_F77 FFLAGS=$GNU_FFLAGS; export F77 FFLAGS
+ test "$F77" = false && skip_all_ "GNU Fortran 77 compiler unavailable"
+ case " $required " in
+ *\ gfortran\ *) ;;
+ *) FC=$F77 FCFLAGS=$FFLAGS; export FC FCFLAGS;;
+ esac
+ ;;
+ javac)
+ # The Java compiler from JDK 1.5 (and presumably earlier versions)
+ # cannot handle the '-version' option by itself: it bails out
+ # telling that source files are missing. Adding also the '-help'
+ # option seems to solve the problem.
+ echo "$me: running javac -version -help"
+ javac -version -help || skip_all_ "Sun Java compiler not available"
+ ;;
+ java)
+ # See the comments above about 'javac' for why we use also '-help'.
+ echo "$me: running java -version -help"
+ java -version -help || skip_all_ "Sun Java interpreter not found"
+ ;;
+ lib)
+ AR=lib
+ export AR
+ # Attempting to create an empty archive will actually not
+ # create the archive, but lib will output its version.
+ echo "$me: running $AR -out:defstest.lib"
+ $AR -out:defstest.lib \
+ || skip_all_ "Microsoft 'lib' utility not available"
+ ;;
+ makedepend)
+ echo "$me: running makedepend -f-"
+ makedepend -f- \
+ || skip_all_ "required program 'makedepend' not available"
+ ;;
+ makeinfo-html)
+ # Make sure we have makeinfo, and it understands '--html'.
+ echo "$me: running makeinfo --html --version"
+ makeinfo --html --version \
+ || skip_all_ "cannot find a makeinfo program that groks" \
+ "the '--html' option"
+ ;;
+ mingw)
+ uname_s=`uname -s || echo UNKNOWN`
+ echo "$me: system name: $uname_s"
+ case $uname_s in
+ MINGW*) ;;
+ *) skip_all_ "this test requires MSYS in MinGW mode" ;;
+ esac
+ ;;
+ 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 && chmod a-w $priv_check_temp \
+ || framework_failure_ "creating unwritable file $priv_check_temp"
+ # Not a useless use of subshell: lesser shells like Solaris /bin/sh
+ # can exit if a builtin fails.
+ overwrite_status=0
+ (echo foo >> $priv_check_temp) || overwrite_status=$?
+ rm -f $priv_check_temp
+ if test $overwrite_status -eq 0; then
+ skip_all_ "cannot drop file write permissions"
+ fi
+ unset priv_check_temp overwrite_status
+ ;;
+ perl-threads)
+ if test "$WANT_NO_THREADS" = "yes"; then
+ skip_all_ "Devel::Cover cannot cope with threads"
+ fi
+ ;;
+ native)
+ # Don't use "&&" here, to avoid a bug of 'set -e' present in
+ # some (even relatively recent) versions of the BSD shell.
+ # We add the dummy "else" branch for extra safety.
+ if cross_compiling; then
+ skip_all_ "doesn't work in cross-compile mode"
+ else :; fi
+ ;;
+ python)
+ # Python doesn't support --version, it has -V
+ echo "$me: running python -V"
+ python -V || skip_all_ "python interpreter not available"
+ ;;
+ 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 && chmod a-w $ro_dir_temp \
+ || framework_failure_ "creating unwritable directory $ro_dir_temp"
+ # Not a useless use of subshell: lesser shells like Solaris /bin/sh
+ # can exit if a builtin fails.
+ create_status=0
+ (: > $ro_dir_temp/probe) || create_status=$?
+ rm -rf $ro_dir_temp
+ if test $create_status -eq 0; then
+ skip_all_ "cannot drop directory write permissions"
+ fi
+ unset ro_dir_temp create_status
+ ;;
+ runtest)
+ # DejaGnu's runtest program. We rely on being able to specify
+ # the program on the runtest command-line. This requires
+ # DejaGnu 1.4.3 or later.
+ echo "$me: running runtest SOMEPROGRAM=someprogram --version"
+ runtest SOMEPROGRAM=someprogram --version \
+ || skip_all_ "DejaGnu is not available"
+ ;;
+ tex)
+ # No all versions of Tex support '--version', so we use
+ # a configure check.
+ if test -z "$TEX"; then
+ skip_all_ "TeX is required, but it wasn't found by configure"
+ fi
+ ;;
+ texi2dvi-o)
+ # Texi2dvi supports '-o' since Texinfo 4.1.
+ echo "$me: running texi2dvi -o /dev/null --version"
+ texi2dvi -o /dev/null --version \
+ || skip_all_ "required program 'texi2dvi' not available"
+ ;;
+ lex)
+ test x"$LEX" = x"false" && skip_all_ "lex not found or disabled"
+ export LEX
+ ;;
+ yacc)
+ test x"$YACC" = x"false" && skip_all_ "yacc not found or disabled"
+ export YACC
+ ;;
+ flex)
+ LEX=flex; export LEX
+ echo "$me: running flex --version"
+ flex --version || skip_all_ "required program 'flex' not available"
+ ;;
+ bison)
+ YACC='bison -y'; export YACC
+ echo "$me: running bison --version"
+ bison --version || skip_all_ "required program 'bison' not available"
+ ;;
+ *)
+ # Generic case: the tool must support --version.
+ echo "$me: running $tool --version"
+ # It is not likely but possible that $tool is a special builtin,
+ # in which case the shell is allowed to exit after an error. So
+ # we need the subshell here. Also, some tools, like Sun cscope,
+ # can be interactive without redirection.
+ ($tool --version) </dev/null \
+ || skip_all_ "required program '$tool' not available"
+ ;;
+ esac
+done
+
+# Using just $testbuilddir for the check here is ok, since the
+# further temporary subdirectory where the test will be run is
+# ensured not to contain any whitespace character.
+case $testbuilddir in
+ *\ *|*\ *)
+ case " $required " in
+ *' libtool '* | *' libtoolize '* )
+ skip_all_ "libtool has problems with spaces in builddir name";;
+ esac
+ ;;
+esac
+
+# This test is necessary, although Automake's configure script bails out
+# when $srcdir contains spaces. This is because $testsrcdir is in not
+# configure-time $srcdir, but is instead configure-time $abs_srcdir, and
+# that is allowed to contain spaces.
+case $testsrcdir in
+ *\ * |*\ *)
+ case " $required " in
+ *' libtool '* | *' libtoolize '* | *' gettext '* )
+ skip_all_ "spaces in srcdir name: libtool/gettext tests won't work";;
+ esac
+ ;;
+esac
+
+# We might need extra macros, e.g., from Libtool or Gettext.
+case " $required " in *\ libtool*) . ./libtool-macros.dir/get.sh;; esac
+case " $required " in *\ gettext*) . ./gettext-macros.dir/get.sh;; esac
+
+
+## ---------------------------------------------------------------- ##
+## Create and set up of the temporary directory used by the test. ##
+## Set up of the exit trap for cleanup of said directory. ##
+## ---------------------------------------------------------------- ##
+
+# This might be used in testcases checking distribution-related features.
+# Test scripts are free to override this if they need to.
+distdir=$me-1.0
+
+# Set up the exit trap.
+if test "$sh_errexit_works" = yes; then
+ trap 'exit_status=$?
+ set +e
+ cd "$testbuilddir"
+ if test $am_using_tap = yes; then
+ if test "$planned_" = later && test $exit_status -eq 0; then
+ plan_ "now"
+ fi
+ test $exit_status -eq 0 && test $tap_pass_count_ -eq $tap_count_ \
+ || keep_testdirs=yes
+ else
+ # This is to ensure that a test script does give a SKIP outcome just
+ # because a command in it happens to exit with status 77. This
+ # behaviour, while from time to time useful to developers, is not
+ # meant to be enabled by default, as it could cause spurious failures
+ # in the wild. Thus it will be enabled only when the variable
+ # "am_explicit_skips" is set to a "true" value.
+ case $am_explicit_skips in
+ [yY]|[yY]es|1)
+ if test $exit_status -eq 77 && test $am__test_skipped != yes; then
+ echo "$me: implicit skip turned into failure"
+ exit_status=78
+ fi;;
+ esac
+ test $exit_status -eq 0 || keep_testdirs=yes
+ fi
+ am_keeping_testdirs || rm_rf_ $testSubDir
+ set +x
+ echo "$me: exit $exit_status"
+ exit $exit_status
+ ' 0
+ trap "fatal_ 'caught signal SIGHUP'" 1
+ trap "fatal_ 'caught signal SIGINT'" 2
+ trap "fatal_ 'caught signal SIGTERM'" 15
+ # Various shells seems to just ignore SIGQUIT under some circumstances,
+ # even if the signal is not blocked; however, if the signal it trapped,
+ # the trap gets correctly executed. So we also trap SIGQUIT.
+ # Here is a list of some shells that have been verified to exhibit the
+ # problematic behavior with SIGQUIT:
+ # - zsh 4.3.12 on Debian GNU/Linux
+ # - /bin/ksh and /usr/xpg4/bin/sh on Solaris 10
+ # - Bash 3.2.51 on Solaris 10 and bash 4.1.5 on Debian GNU/Linux
+ # - AT&T ksh on Debian Gnu/Linux (deb package ksh, version 93u-1)
+ # OTOH, at least these shells that do *not* exhibit that behaviour:
+ # - modern version of the Almquist Shell (at least 0.5.5.1), on
+ # both Solaris and GNU/Linux
+ # - Solaris 10 /bin/sh
+ # - public domain Korn Shell, version 5.2.14, on Debian GNU/Linux
+ trap "fatal_ 'caught signal SIGQUIT'" 3
+ # Ignore further SIGPIPE in the trap code. This is required to avoid
+ # a very weird issue with some shells, at least when the execution of
+ # the automake testsuite is driven by the 'prove' utility: if prove
+ # (or the make process that has spawned it) gets interrupted with
+ # Ctrl-C, the shell might go in a loop, continually getting a SIGPIPE,
+ # sometimes finally dumping core, other times hanging indefinitely.
+ # See also Test::Harness bug [rt.cpan.org #70855], archived at
+ # <https://rt.cpan.org/Ticket/Display.html?id=70855>
+ trap "trap '' 13; fatal_ 'caught signal SIGPIPE'" 13
+fi
+
+# Create and populate the temporary directory, if and as required.
+if test x"$am_create_testdir" = x"no"; then
+ testSubDir=
+else
+ # The subdirectory where the current test script will run and write its
+ # temporary/data files. This will be created shortly, and will be removed
+ # by the cleanup trap below if the test passes. If the test doesn't pass,
+ # this directory will be kept, to facilitate debugging.
+ testSubDir=$me.dir
+ test ! -d $testSubDir || rm_rf_ $testSubDir \
+ || framework_failure_ "removing old test subdirectory"
+ mkdir $testSubDir \
+ || framework_failure_ "creating test subdirectory"
+ cd ./$testSubDir \
+ || framework_failure_ "cannot chdir into test subdirectory"
+ if test x"$am_create_testdir" != x"empty"; then
+ cp "$am_scriptdir"/install-sh "$am_scriptdir"/missing \
+ "$am_scriptdir"/depcomp . \
+ || framework_failure_ "fetching common files from $am_scriptdir"
+ # Build appropriate environment in test directory. E.g., create
+ # configure.ac, 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.
+ {
+ echo "AC_INIT([$me], [1.0])"
+ if test x"$am_parallel_tests" = x"yes"; then
+ echo "AM_INIT_AUTOMAKE([parallel-tests])"
+ else
+ echo "AM_INIT_AUTOMAKE"
+ fi
+ echo "AC_CONFIG_FILES([Makefile])"
+ } >configure.ac || framework_failure_ "creating configure.ac skeleton"
+ fi
+fi
+
+
+## ---------------- ##
+## Ready to go... ##
+## ---------------- ##
+
+set -x
+pwd
diff --git a/t/defs-static.in b/t/defs-static.in
new file mode 100644
index 000000000..c1500cdb6
--- /dev/null
+++ b/t/defs-static.in
@@ -0,0 +1,246 @@
+# -*- shell-script -*-
+# @configure_input@
+#
+# Copyright (C) 1996-2012 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/>.
+
+# Defines and minimal setup for Automake testing environment.
+
+# IMPORTANT NOTES AND REQUIREMENTS
+# - Multiple inclusions of this file should be idempotent.
+# - This code has to be 'set -e' clean.
+# - This file should execute correctly with any system's /bin/sh
+# shell, not only with configure-time detected $CONFIG_SHELL.
+
+# Be more Bourne compatible.
+# (Snippet inspired to configure's initialization in Autoconf 2.64)
+DUALCASE=1; export DUALCASE # for MKS sh
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+ emulate sh
+ NULLCMD=:
+ # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '${1+"$@"}'='"$@"'
+ setopt NO_GLOB_SUBST
+ # If Zsh is not started directly in Bourne-compatibility mode, it has
+ # some incompatibilities in the handling of $0 that conflict with
+ # our usage: i.e., $0 inside a file sourced with the '.' builtin is
+ # temporarily set to the name of the sourced file.
+ # Work around this when possible, otherwise abort the script.
+ # Note that a bug in some versions of Zsh prevents us from resetting $0
+ # in a sourced script, so the use of $argv0. For more info see:
+ # <http://www.zsh.org/mla/workers/2009/msg01140.html>
+ # Note: the apparently useless 'eval' below are needed by at least
+ # dash 0.5.2, to prevent it from bailing out with an error like
+ # "Syntax error: Bad substitution"
+ if eval '[[ "$0" = *."test" ]]'; then
+ # Good, FUNCTION_ARGZERO option was already off when this file was
+ # sourced. Thus we've nothing to do.
+ argv0=$0
+ elif eval 'test -n "${functrace[-1]}"'; then
+ # FUNCTION_ARGZERO option was on, but we have a easy workaround.
+ eval 'argv0=${functrace[-1]%:*}'
+ else
+ # Give up.
+ echo "$0: cannot determine the path of running test script" >&2
+ echo "$0: test was running with Zsh version $ZSH_VERSION" >&2
+ echo "$0: did you enable the NO_FUNCTION_ARGZERO option?" >&2
+ exit 99
+ fi
+else
+ argv0=$0
+ # Avoid command substitution failure, for Tru64 sh -e and instspc*.test.
+ case `(set -o) 2>/dev/null || :` in *posix*) set -o posix;; esac
+fi
+
+# Check that the environment is properly sanitized.
+# Having variables exported to the empty string is OK, since our code
+# treats such variables as if they were unset.
+for var in \
+ me \
+ required \
+ am_using_tap \
+ am_parallel_tests \
+ am_create_testdir \
+ am_tap_implementation \
+ am_test_prefer_config_shell \
+ am_original_AUTOMAKE \
+ am_original_ACLOCAL \
+; do
+ if eval "test x\"\$$var\" != x" && env | grep "^$var=" >/dev/null; then
+ echo "$argv0: variable '$var' is set in the environment:" \
+ "this is unsafe" >&2
+ exit 99
+ fi
+done
+unset var
+
+# See whether the current test script is expected to use TAP or not.
+# Use a sensible default, while allowing the scripts to override this
+# check.
+if test -z "$am_using_tap"; then
+ case $argv0 in *.tap) am_using_tap=yes;; *) am_using_tap=no;; esac
+fi
+
+testsrcdir='@abs_srcdir@'
+top_testsrcdir='@abs_top_srcdir@'
+testbuilddir='@abs_builddir@'
+top_testbuilddir='@abs_top_builddir@'
+testprefix='@prefix@'
+
+# Where testsuite-related helper scripts, data files and shell libraries
+# are placed.
+am_testauxdir=$testsrcdir/ax
+
+# Support for the "installcheck" target.
+case ${am_running_installcheck:=no} in
+ yes)
+ am_amdir='@amdir@'
+ am_automake_acdir='@automake_acdir@'
+ am_bindir='@bindir@'
+ am_datadir='@datadir@'
+ am_docdir='@docdir@'
+ am_pkgvdatadir='@pkgvdatadir@'
+ am_scriptdir='@scriptdir@'
+ am_system_acdir='@system_acdir@'
+ ;;
+ no)
+ am_amdir=$top_testsrcdir/lib/am
+ am_automake_acdir=$top_testsrcdir/m4
+ am_bindir=$testbuilddir/wrap
+ am_datadir=$top_testsrcdir
+ am_docdir=$top_testsrcdir/doc
+ am_pkgvdatadir=$top_testsrcdir/lib
+ am_scriptdir=$top_testsrcdir/lib
+ am_system_acdir=$top_testsrcdir/m4/acdir
+ ;;
+ *)
+ echo "$argv0: variable 'am_running_installcheck' has invalid"
+ "value '$am_running_installcheck'" >&2
+ exit 99
+ ;;
+esac
+
+APIVERSION='@APIVERSION@'
+PATH_SEPARATOR='@PATH_SEPARATOR@'
+
+host_alias=${host_alias-'@host_alias@'}; export host_alias
+build_alias=${build_alias-'@build_alias@'}; export build_alias
+
+# Make sure we override the user shell. And do not read the value of
+# $SHELL from the environment (think to the non-uncommon situation where
+# e.g., $SHELL=/bin/tcsh).
+SHELL=${AM_TESTSUITE_SHELL-'@SHELL@'}; export SHELL
+
+# User can override various tools used. Prefer overriding specific for
+# that automake testsuite, if they are available.
+AWK=${AM_TESTSUITE_AWK-${AWK-'@AWK@'}}
+PERL=${AM_TESTSUITE_PERL-${PERL-'@PERL@'}}
+MAKE=${AM_TESTSUITE_MAKE-${MAKE-'make'}}
+YACC=${AM_TESTSUITE_YACC-${YACC-'@YACC@'}}
+LEX=${AM_TESTSUITE_LEX-${LEX-'@LEX@'}}
+AUTOCONF=${AM_TESTSUITE_AUTOCONF-${AUTOCONF-'@am_AUTOCONF@'}}
+AUTOM4TE=${AM_TESTSUITE_AUTOM4TE-${AUTOM4TE-'@am_AUTOM4TE@'}}
+AUTORECONF=${AM_TESTSUITE_AUTORECONF-${AUTORECONF-'@am_AUTORECONF@'}}
+AUTOHEADER=${AM_TESTSUITE_AUTOHEADER-${AUTOHEADER-'@am_AUTOHEADER@'}}
+AUTOUPDATE=${AM_TESTSUITE_AUTOUPDATE-${AUTOUPDATE-'@am_AUTOUPDATE@'}}
+
+# Tests who want complete control over aclocal or automake command-line
+# options should use $am_original_ACLOCAL or $am_original_AUTOMAKE. The
+# "test -z" tests take care not to re-initialize them if defs-static
+# is re-sourced, as we want defs-static to remain really idempotent.
+if test -z "$am_original_AUTOMAKE"; then
+ am_original_AUTOMAKE=${AM_TESTSUITE_AUTOMAKE-${AUTOMAKE-"automake-$APIVERSION"}}
+fi
+if test -z "$am_original_ACLOCAL"; then
+ am_original_ACLOCAL=${AM_TESTSUITE_ACLOCAL-${ACLOCAL-"aclocal-$APIVERSION"}}
+fi
+
+# Use -Werror because this also turns some Perl warnings into error.
+# Tests for which this is inappropriate should use -Wno-error.
+# Tests who want complete control over aclocal command-line options
+# should use $am_original_ACLOCAL instead.
+ACLOCAL="$am_original_ACLOCAL -Werror"
+
+# 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. 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.
+# Tests who want complete control over automake command-line options
+# should use $am_original_AUTOMAKE instead.
+AUTOMAKE="$am_original_AUTOMAKE --foreign -Werror -Wall"
+
+# POSIX no longer requires 'egrep' and 'fgrep',
+# but some hosts lack 'grep -E' and 'grep -F'.
+EGREP=${AM_TESTSUITE_EGREP-'@EGREP@'}
+FGREP=${AM_TESTSUITE_FGREP-'@FGREP@'}
+
+# Compilers and their flags. These can point to non-GNU compilers (and
+# on non-Linux and non-BSD systems, they probably will).
+CC=${AM_TESTSUITE_CC-${CC-'@CC@'}}
+CXX=${AM_TESTSUITE_CXX-${CXX-'@CXX@'}}
+F77=${AM_TESTSUITE_F77-${F77-'@F77@'}}
+FC=${AM_TESTSUITE_FC-${FC-'@FC@'}}
+CFLAGS=${AM_TESTSUITE_CFLAGS-${CFLAGS-'@CFLAGS@'}}
+CXXFLAGS=${AM_TESTSUITE_CXXFLAGS-${CXXFLAGS-'@CXXFLAGS@'}}
+FCFLAGS=${AM_TESTSUITE_FCFLAGS-${FCFLAGS-'@FCFLAGS@'}}
+FFLAGS=${AM_TESTSUITE_FFLAGS-${FFLAGS-'@FFLAGS@'}}
+CPPFLAGS=${AM_TESTSUITE_CPPFLAGS-${CPPFLAGS-'@CPPFLAGS@'}}
+
+# GNU compilers and their flags.
+GNU_CC=${AM_TESTSUITE_GNU_CC-${GNU_CC-'@GNU_CC@'}}
+GNU_CXX=${AM_TESTSUITE_GNU_CXX-${GNU_CXX-'@GNU_CXX@'}}
+GNU_F77=${AM_TESTSUITE_GNU_F77-${GNU_F77-'@GNU_F77@'}}
+GNU_FC=${AM_TESTSUITE_GNU_FC-${GNU_FC-'@GNU_FC@'}}
+GNU_FFLAGS=${AM_TESTSUITE_GNU_FFLAGS-${GNU_FFLAGS-'@GNU_FFLAGS@'}}
+GNU_FCFLAGS=${AM_TESTSUITE_GNU_FCFLAGS-${GNU_FCFLAGS-'@GNU_FCFLAGS@'}}
+GNU_CXXFLAGS=${AM_TESTSUITE_GNU_CXXFLAGS-${GNU_CXXFLAGS-'@GNU_CXXFLAGS@'}}
+GNU_CFLAGS=${AM_TESTSUITE_GNU_CFLAGS-${GNU_CFLAGS-'@GNU_CFLAGS@'}}
+GNU_GCJ=${AM_TESTSUITE_GNU_GCJ-${GNU_GCJ-'@GNU_GCJ@'}}
+GNU_GCJFLAGS=${AM_TESTSUITE_GNU_GCJFLAGS-${GNU_GCJFLAGS-'@GNU_GCJFLAGS@'}}
+
+# No all versions of Tex support '--version', so we use a configure
+# check to decide if tex is available. This decision is embodied in
+# this variable.
+TEX=${AM_TESTSUITE_TEX-'@TEX@'}
+
+# Whether $SHELL has working 'set -e' with exit trap.
+sh_errexit_works='@sh_errexit_works@'
+
+# 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@'
+
+# An old timestamp that can be given to a file, in "touch -t" format.
+# The time stamp should be portable to all file systems of interest.
+# Just for fun, choose the exact time of the announcement of the GNU project
+# in UTC; see <http://www.gnu.org/gnu/initial-announcement.html>.
+old_timestamp=198309271735.59
+
+# Make our wrapper script (or installed scripts, if running under
+# "installcheck") accessible by default. And avoid to uselessly
+# extend $PATH multiple times if this file is sourced multiple times.
+case $PATH in
+ $am_bindir$PATH_SEPARATOR*) ;;
+ *) PATH=$am_bindir$PATH_SEPARATOR$PATH;;
+esac
+
+# Make our helper script accessible by default.
+PATH=$testsrcdir/ax$PATH_SEPARATOR$PATH
+
+export PATH
diff --git a/t/defun.sh b/t/defun.sh
new file mode 100755
index 000000000..9b66a56f3
--- /dev/null
+++ b/t/defun.sh
@@ -0,0 +1,35 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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 aclocal picks up on all macro definitions.
+
+. ./defs || Exit 1
+
+cat > acinclude.m4 << 'END'
+AC_DEFUN([AM_FUNC_THREE])
+AC_DEFUN([AM_FUNC_TWO], [@!GrepThisString!@AM_FUNC_THREE])
+AC_DEFUN([AM_FUNC_ONE], [AC_REQUIRE([AM_FUNC_TWO])])
+END
+
+cat >>configure.ac << 'END'
+AM_FUNC_ONE
+END
+
+$ACLOCAL
+$AUTOCONF
+grep '^@!GrepThisString!@$' configure
+
+:
diff --git a/t/defun2.sh b/t/defun2.sh
new file mode 100755
index 000000000..0b3f96b6d
--- /dev/null
+++ b/t/defun2.sh
@@ -0,0 +1,40 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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 we don't mistake a macro definition for an invocation.
+# From Jim Meyering.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+dnl if buggy this will require getloadavg.c
+AC_PROG_CC
+AC_DEFUN([AC_FUNC_GETLOADAVG])
+dnl need this to avoid LIBOBJS used but not defined.
+AC_FUNC_MEMCMP
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = foo
+foo_LDADD = @LIBOBJS@
+END
+
+: > memcmp.c
+
+$ACLOCAL
+$AUTOMAKE
+
+:
diff --git a/t/dejagnu-absolute-builddir.sh b/t/dejagnu-absolute-builddir.sh
new file mode 100755
index 000000000..8cdc3a1d7
--- /dev/null
+++ b/t/dejagnu-absolute-builddir.sh
@@ -0,0 +1,60 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that DejaGnu testsuites have 'objdir' defined (as a TCL variable)
+# to an absolute path.
+
+required=runtest
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = dejagnu
+DEJATOOL = tcl env
+EXTRA_DIST = tcl.test/tcl.exp
+END
+
+mkdir tcl.test
+
+cat > tcl.test/tcl.exp << 'END'
+send_user "tcl_objdir: $objdir\n"
+if { [ regexp "^/" $objdir ] } {
+ pass "test_tcl_objdir"
+} else {
+ fail "test_tcl_objdir"
+}
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+./configure
+
+$MAKE check
+
+# Sanity check: all tests have run.
+test -f env.log
+test -f env.sum
+test -f tcl.log
+test -f tcl.sum
+
+$MAKE distcheck
+
+:
diff --git a/t/dejagnu-relative-srcdir.sh b/t/dejagnu-relative-srcdir.sh
new file mode 100755
index 000000000..05ae2005e
--- /dev/null
+++ b/t/dejagnu-relative-srcdir.sh
@@ -0,0 +1,84 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that DejaGnu testsuites have 'srcdir' defined to a relative path
+# (both as TCL variable and as environment variable).
+
+required=runtest
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = dejagnu
+DEJATOOL = tcl env
+EXTRA_DIST = env.test/env.exp tcl.test/tcl.exp lib/tcl.exp
+END
+
+mkdir env.test tcl.test lib
+
+# DejaGnu can change $srcdir behind our backs, so we have to
+# save its original value. Thanks to Ian Lance Taylor for the
+# suggestion.
+cat > lib/tcl.exp << 'END'
+send_user "tcl_lib_srcdir: $srcdir\n"
+set orig_srcdir $srcdir
+END
+
+cat > env.test/env.exp << 'END'
+set env_srcdir $env(srcdir)
+send_user "env_srcdir: $env_srcdir\n"
+if { [ regexp "^\.\.?$" $env_srcdir ] } {
+ pass "test_env_src"
+} else {
+ fail "test_env_src"
+}
+END
+
+cat > tcl.test/tcl.exp << 'END'
+send_user "tcl_srcdir: $srcdir\n"
+if { [ regexp "^\.\.?$" $srcdir ] } {
+ pass "test_tcl_src"
+} else {
+ fail "test_tcl_src"
+}
+send_user "tcl_orig_srcdir: $orig_srcdir\n"
+if { [ regexp "^\.\.?$" $orig_srcdir ] } {
+ pass "test_tcl_orig_src"
+} else {
+ fail "test_tcl_orig_src"
+}
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+./configure --srcdir=.
+
+$MAKE check
+
+# Sanity check: all tests have run.
+test -f env.log
+test -f env.sum
+test -f tcl.log
+test -f tcl.sum
+
+$MAKE distcheck
+
+:
diff --git a/t/dejagnu-siteexp-append.sh b/t/dejagnu-siteexp-append.sh
new file mode 100755
index 000000000..c3bfff6af
--- /dev/null
+++ b/t/dejagnu-siteexp-append.sh
@@ -0,0 +1,70 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that the files in $(EXTRA_DEJAGNU_SITE_CONFIG) get appended to
+# site.exp in the same order in which they're listed in that variable.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = dejagnu
+DEJATOOL = tool
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+./configure
+
+$MAKE site.exp
+sed '/^##.*##$/d' site.exp > expected
+
+cat > foo.exp << 'END'
+foo1
+foo2
+foo3
+END
+
+cat foo.exp - >> expected << 'END'
+BAR 1
+# foo
+BAR 2
+END
+
+cat >> Makefile.am << 'END'
+EXTRA_DEJAGNU_SITE_CONFIG = foo.exp bar.exp
+bar.exp:
+ @(echo 'BAR 1' && echo '# foo' && echo 'BAR 2') > $@
+END
+
+$AUTOMAKE Makefile
+./config.status Makefile
+
+rm -f site.exp
+$MAKE site.exp
+sed '/^##.*##$/d' site.exp > obtained
+
+cat expected
+cat site.exp
+
+diff expected obtained
+
+:
diff --git a/t/dejagnu-siteexp-extend.sh b/t/dejagnu-siteexp-extend.sh
new file mode 100755
index 000000000..f0f61942a
--- /dev/null
+++ b/t/dejagnu-siteexp-extend.sh
@@ -0,0 +1,159 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that the developer can extend the site.exp generated by the
+# automake-generated Makefile.
+
+required=runtest
+. ./defs || Exit 1
+
+write_check_for ()
+{
+ echo "send_user \"$1: \$$1\\n\""
+ unindent << END
+ if { \$$1 == "/$1/" } {
+ pass "test_$1"
+ } else {
+ fail "test_$1"
+ }
+END
+}
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = dejagnu
+DEJATOOL = tool
+
+EXTRA_DIST = tool.test/tool.exp
+
+EXTRA_DEJAGNU_SITE_CONFIG = foo.exp
+EXTRA_DIST += foo.exp
+END
+
+echo 'set foo "/foo/"' > foo.exp
+
+mkdir tool.test
+write_check_for foo > tool.test/tool.exp
+cat tool.test/tool.exp
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+./configure
+
+$MAKE check
+cat foo.exp
+cat site.exp
+grep 'PASS: test_foo' tool.sum
+
+write_check_for bar >> tool.test/tool.exp
+write_check_for baz >> tool.test/tool.exp
+cat tool.test/tool.exp
+
+# Ensure that foo.exp will be newer than site.exp, which will
+# thus have to be remade.
+$sleep
+# With this, below we'll also check that settings in files coming later in
+# $(EXTRA_DEJAGNU_SITE_CONFIG) override those in files coming earlier.
+cat >> foo.exp <<'END'
+set bar "/foo/"
+set baz "/foo/"
+set qux "/foo/"
+END
+
+$MAKE check && { cat site.exp; Exit 1; }
+grep 'PASS: test_foo' tool.sum
+grep 'FAIL: test_bar' tool.sum
+grep 'FAIL: test_baz' tool.sum
+
+cat >> Makefile.am << 'END'
+EXTRA_DEJAGNU_SITE_CONFIG += bar bar.dir/bar
+EXTRA_DIST += bar
+DISTCLEANFILES = bar.dir/bar
+bar.dir/bar:
+ test -d bar.dir || mkdir bar.dir
+ echo 'set baz "/baz/"' > $@
+END
+
+echo 'set bar "/bar/"' > bar
+# This will allow us to check one more time that settings in files
+# coming later in $(EXTRA_DEJAGNU_SITE_CONFIG) override those in
+# files coming earlier.
+echo 'set baz "/xyz/"' >> bar
+
+# Ensure that the Makefile will be newer than site.exp, which will
+# thus have to be remade.
+$sleep
+$AUTOMAKE Makefile
+./config.status Makefile
+
+$MAKE check || { cat site.exp; Exit 1; }
+cat site.exp
+cat bar.dir/bar
+$FGREP '/bar/' site.exp
+$FGREP '/baz/' site.exp
+grep 'PASS: test_foo' tool.sum
+grep 'PASS: test_bar' tool.sum
+grep 'PASS: test_baz' tool.sum
+
+# Check that the features we're testing behave well in VPATH builds.
+$MAKE distcheck
+
+# Check that the user can edit the site.exp file, and that his edits
+# are retained.
+write_check_for zardoz >> tool.test/tool.exp
+cat tool.test/tool.exp
+echo 'set zardoz "/zardoz/"' >> site.exp
+
+$MAKE check
+cat site.exp
+grep 'PASS: test_zardoz' tool.sum
+
+cat >> Makefile.am << 'END'
+EXTRA_DEJAGNU_SITE_CONFIG += quux.exp
+quux.exp:
+ echo 'set zardoz "/quux/"' > $@
+END
+
+# Ensure that the Makefile will be newer than on site.exp, which will
+# thus have to be remade.
+$sleep
+$AUTOMAKE Makefile
+./config.status Makefile
+grep 'zardoz.*/quux/' Makefile
+
+$MAKE site.exp
+cat site.exp
+cat quux.exp
+grep 'zardoz.*/quux/' site.exp
+
+$MAKE check
+grep 'PASS: test_zardoz' tool.sum
+grep 'zardoz: /zardoz/' tool.log
+grep 'zardoz.*quux' tool.log && Exit 1
+
+# Check that files in $(EXTRA_DEJAGNU_SITE_CONFIG) are not distributed
+# by default.
+$MAKE distdir
+ls -l $distdir
+test ! -r $distdir/bar.dir/bar
+test ! -r $distdir/quux.exp
+
+:
diff --git a/t/dejagnu-siteexp-useredit.sh b/t/dejagnu-siteexp-useredit.sh
new file mode 100755
index 000000000..9be5eba90
--- /dev/null
+++ b/t/dejagnu-siteexp-useredit.sh
@@ -0,0 +1,67 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that the user can edit the Makefile-generated site.exp, and
+# have its edits survive to the remaking of that file.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = dejagnu
+DEJATOOL = foo
+END
+
+# Deliberately select a variable defined automatically by
+# the Makefile-generated site.exp.
+mkdir foo.test
+cat > foo.test/foo.exp << 'END'
+send_user "objdir: $objdir\n"
+set pipe "|"
+if { $objdir == "${pipe}objdir${pipe}" } {
+ pass "test_obj"
+} else {
+ fail "test_obj"
+}
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+./configure
+
+$MAKE site.exp
+echo 'set objdir "|objdir|"' >> site.exp
+cat site.exp
+$sleep
+touch Makefile
+$MAKE site.exp
+cat site.exp
+is_newest site.exp Makefile # Sanity check.
+grep '|objdir|' site.exp
+test `grep -c '|objdir|' site.exp` -eq 1
+
+# We can do a "more semantic" check if DejaGnu is available.
+if runtest SOMEPROGRAM=someprogram --version; then
+ $MAKE check
+ grep 'PASS: test_obj' foo.sum
+fi
+
+:
diff --git a/t/dejagnu.sh b/t/dejagnu.sh
new file mode 100755
index 000000000..14b118c8a
--- /dev/null
+++ b/t/dejagnu.sh
@@ -0,0 +1,35 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Superficial test to check that dejagnu tests and automake-style
+# tests can coexist. See also related deeper test 'check12.test'.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = dejagnu
+TESTS = frob.test
+END
+
+test x"$am_parallel_tests" != x"yes" || : > test-driver
+
+$ACLOCAL
+$AUTOMAKE
+
+grep '^check-TESTS' Makefile.in
+grep '^check-DEJAGNU' Makefile.in
+
+:
diff --git a/t/dejagnu2.sh b/t/dejagnu2.sh
new file mode 100755
index 000000000..0a0d0910f
--- /dev/null
+++ b/t/dejagnu2.sh
@@ -0,0 +1,46 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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 we don't override the user's site.exp rule.
+
+. ./defs || Exit 1
+
+cat >> configure.ac <<'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = dejagnu
+
+site.exp:
+ echo :GREP:ME: > $@
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -Wno-override
+
+grep 'site\.exp' Makefile.in
+test `grep -c '^site\.exp:' Makefile.in` -eq 1
+
+./configure
+$MAKE site.exp
+grep ':GREP:ME:' site.exp
+
+AUTOMAKE_fails
+grep '^Makefile\.am:3:.*site\.exp' stderr
+
+:
diff --git a/t/dejagnu3.sh b/t/dejagnu3.sh
new file mode 100755
index 000000000..7d15bc941
--- /dev/null
+++ b/t/dejagnu3.sh
@@ -0,0 +1,70 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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/>.
+
+# Check that the DejaGnu rules work for a simple program and test case.
+
+required=runtest
+. ./defs || Exit 1
+
+cat > hammer << 'END'
+#! /bin/sh
+echo "Everything looks like a nail to me!"
+END
+
+chmod +x hammer
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = dejagnu
+DEJATOOL = hammer
+AM_RUNTESTFLAGS = HAMMER=$(srcdir)/hammer
+EXTRA_DIST = hammer hammer.test/hammer.exp
+END
+
+mkdir hammer.test
+
+cat > hammer.test/hammer.exp << 'END'
+set test test
+spawn $HAMMER
+expect {
+ "Everything looks like a nail to me!" { pass "$test" }
+ default { fail "$test" }
+}
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+./configure
+
+$MAKE check
+test -f hammer.log
+test -f hammer.sum
+
+$MAKE distcheck
+
+# Ensure that the envvar RUNTESTFLAGS is used.
+# Report from Mark Mitchell.
+RUNTESTFLAGS=--unknown-runtest-option $MAKE check >output 2>&1 \
+ && { cat output; Exit 1; }
+cat output
+$FGREP 'unknown-runtest-option' output
+
+:
diff --git a/t/dejagnu4.sh b/t/dejagnu4.sh
new file mode 100755
index 000000000..44904dfbf
--- /dev/null
+++ b/t/dejagnu4.sh
@@ -0,0 +1,102 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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/>.
+
+# Check that the DejaGnu rules work for a simple program and test case.
+# Also check PR 488: Failure of the first of several tools tested.
+# From the original bug report:
+# ``If you use dejagnu for testing and have multiple tools (i.e.,
+# multiple entries in the DEJATOOL variable) then the success/failure
+# of "make check" is only dependent on the success/failure of the
+# tests on the final tool. Thus there may be failures in the tests on
+# previous tools, but at first glance "make check" has passed.''
+
+required=runtest
+. ./defs || Exit 1
+
+cat > hammer << 'END'
+#! /bin/sh
+echo "Everything looks like a nail to me!"
+END
+chmod +x hammer
+
+cat > spanner << 'END'
+#! /bin/sh
+echo "I'm a right spanner!"
+END
+chmod +x spanner
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = dejagnu
+
+DEJATOOL = hammer spanner
+
+AM_RUNTESTFLAGS = HAMMER=$(srcdir)/hammer SPANNER=$(srcdir)/spanner
+
+EXTRA_DIST = hammer hammer.test/hammer.exp
+EXTRA_DIST += spanner spanner.test/spanner.exp
+END
+
+mkdir hammer.test spanner.test
+
+cat > hammer.test/hammer.exp << 'END'
+set test test
+spawn $HAMMER
+expect {
+ "Everything looks like a nail to me!" { pass "$test" }
+ default { fail "$test" }
+}
+END
+
+cat > spanner.test/spanner.exp << 'END'
+set test test
+spawn $SPANNER
+expect {
+ "I'm a right spanner!" { pass "$test" }
+ default { fail "$test" }
+}
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+./configure
+
+$MAKE check
+test -f hammer.log
+test -f hammer.sum
+test -f spanner.log
+test -f spanner.sum
+
+$MAKE distcheck
+
+# Test for PR 488.
+sed 's/E\(verything\)/Not e\1/' hammer > thammer
+mv -f thammer hammer
+chmod +x hammer
+
+rm -f hammer.log hammer.sum spanner.log spanner.sum
+$MAKE check && Exit 1
+test -f hammer.log
+test -f hammer.sum
+test -f spanner.log
+test -f spanner.sum
+
+:
diff --git a/t/dejagnu5.sh b/t/dejagnu5.sh
new file mode 100755
index 000000000..26eaa6096
--- /dev/null
+++ b/t/dejagnu5.sh
@@ -0,0 +1,63 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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/>.
+
+# Check that the DejaGnu rules do look for a testsuite named after
+# the package by default.
+
+required=runtest
+. ./defs || Exit 1
+
+package=$me
+
+cat > $package << 'END'
+#! /bin/sh
+echo "Ah, we have been expecting you, Mr. Blond."
+END
+chmod +x $package
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << END
+AUTOMAKE_OPTIONS = dejagnu
+EXTRA_DIST = $package $package.test/$package.exp
+AM_RUNTESTFLAGS = PACKAGE=\$(srcdir)/$package
+END
+
+mkdir $package.test
+cat > $package.test/$package.exp << 'END'
+set test "a_dejagnu_test"
+spawn $PACKAGE
+expect {
+ "Ah, we have been expecting you, Mr. Blond." { pass "$test" }
+ default { fail "$test" }
+}
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+./configure
+
+$MAKE check
+test -f $package.log
+test -f $package.sum
+
+$MAKE distcheck
+
+:
diff --git a/t/dejagnu6.sh b/t/dejagnu6.sh
new file mode 100755
index 000000000..38255f6f8
--- /dev/null
+++ b/t/dejagnu6.sh
@@ -0,0 +1,58 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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/>.
+
+# Check that "make check" fails, when a DejaGnu test fails.
+
+required=runtest
+. ./defs || Exit 1
+
+cat > faildeja << 'END'
+#! /bin/sh
+echo whatever
+END
+chmod +x faildeja
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = dejagnu
+DEJATOOL = faildeja
+AM_RUNTESTFLAGS = FAILDEJA=$(srcdir)/faildeja
+END
+
+mkdir faildeja.test
+cat > faildeja.test/faildeja.exp << 'END'
+set test failing_deja_test
+spawn $FAILDEJA
+expect {
+ default { fail "$test" }
+}
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+./configure
+
+$MAKE check && Exit 1
+test -f faildeja.log
+test -f faildeja.sum
+$FGREP 'FAIL: failing_deja_test' faildeja.sum
+
+:
diff --git a/t/dejagnu7.sh b/t/dejagnu7.sh
new file mode 100755
index 000000000..a926955f6
--- /dev/null
+++ b/t/dejagnu7.sh
@@ -0,0 +1,62 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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/>.
+
+# Check that "make check" fails, when we invoke DejaGnu tests with --status
+# (to detect TCL errors) on a file with TCL errors.
+
+required=runtest
+. ./defs || Exit 1
+
+runtest --help | grep '.*--status' \
+ || skip_ "dejagnu lacks support for '--status'"
+
+cat > failtcl << 'END'
+#! /bin/sh
+echo whatever
+END
+chmod +x failtcl
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = dejagnu
+DEJATOOL = failtcl
+AM_RUNTESTFLAGS = --status FAILTCL=$(srcdir)/failtcl
+END
+
+mkdir failtcl.test
+cat > failtcl.test/failtcl.exp << 'END'
+set test test
+spawn $FAILTCL
+expect {
+ default { pass "$test" }
+# Oops, no closing brace.
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+./configure
+
+$MAKE check && Exit 1
+test -f failtcl.log
+test -f failtcl.sum
+$FGREP 'missing close-brace' failtcl.sum
+
+:
diff --git a/t/deleted-am.sh b/t/deleted-am.sh
new file mode 100755
index 000000000..636286cf9
--- /dev/null
+++ b/t/deleted-am.sh
@@ -0,0 +1,59 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# The stub rules emitted to work around the "deleted header problem"
+# for '.am' files shouldn't prevent the remake rules from correctly
+# erroring out when a still-required file is missing.
+# See also discussion about automake bug#9768.
+
+. ./defs || Exit 1
+
+echo AC_OUTPUT >> configure.ac
+
+echo 'include $(top_srcdir)/foobar.am' > Makefile.am
+echo 'include zardoz.am' > foobar.am
+: > zardoz.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+$MAKE
+
+rm -f zardoz.am
+$sleep # Required to avoid racy failures with FreeBSD make.
+$MAKE >output 2>&1 && { cat output; Exit 1; }
+cat output
+# This error will come from automake, not make, so we can be stricter
+# in our grepping of it.
+grep 'cannot open.*zardoz\.am' output
+grep 'foobar\.am' output && Exit 1 # No spurious error, please.
+
+# Try with one less indirection.
+: > foobar.am
+$AUTOMAKE Makefile
+./config.status Makefile
+$MAKE # Sanity check.
+rm -f foobar.am
+$sleep # Required to avoid racy failures with FreeBSD make.
+$MAKE >output 2>&1 && { cat output; Exit 1; }
+cat output
+# This error will come from automake, not make, so we can be stricter
+# in our grepping of it.
+grep 'cannot open.*foobar\.am' output
+
+:
diff --git a/t/deleted-m4.sh b/t/deleted-m4.sh
new file mode 100755
index 000000000..e1bbfce4a
--- /dev/null
+++ b/t/deleted-m4.sh
@@ -0,0 +1,65 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# The stub rules emitted to work around the "deleted header problem"
+# for '.m4' files shouldn't prevent the remake rules from correctly
+# erroring out when a still-required file is missing.
+# See also discussion about automake bug#9768.
+
+. ./defs || Exit 1
+
+cat >> configure.ac <<'END'
+m4_include([foobar.m4])
+AC_OUTPUT
+END
+
+: > Makefile.am
+
+echo 'm4_include([zardoz.m4])' > foobar.m4
+: > zardoz.m4
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+$MAKE
+
+rm -f zardoz.m4
+$MAKE >output 2>&1 && { cat output; Exit 1; }
+cat output
+# This error will come from aclocal, not make, so we can be stricter
+# in our grepping of it.
+grep ' foobar\.m4:1:.*zardoz\.m4.*does not exist' output
+# No spurious errors, please.
+$FGREP -v ' foobar.m4:1:' output | $FGREP 'foobar.m4' && Exit 1
+
+# Try with one less indirection.
+: > foobar.m4
+$ACLOCAL --force
+$AUTOCONF
+./configure
+$MAKE # Sanity check.
+rm -f foobar.m4
+$MAKE >output 2>&1 && { cat output; Exit 1; }
+cat output
+# This error will come from aclocal, not make, so we can be stricter
+# in our grepping of it.
+grep 'foobar\.m4.*does not exist' output
+# No spurious errors, please (ok, this is really paranoid).
+$FGREP 'zardoz.m4' output && Exit 1
+
+:
diff --git a/t/depacl2.sh b/t/depacl2.sh
new file mode 100755
index 000000000..378a1a2a2
--- /dev/null
+++ b/t/depacl2.sh
@@ -0,0 +1,27 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test to make sure dependencies work when required macro is part of
+# autoconf.
+
+. ./defs || Exit 1
+
+echo 'AM_FOO' >> configure.ac
+echo 'AC_DEFUN([AM_FOO], [AC_REQUIRE([AC_HEADER_STDC])])' > AM_FOO.m4
+
+$ACLOCAL -I .
+
+:
diff --git a/t/depcomp.sh b/t/depcomp.sh
new file mode 100755
index 000000000..f2e0370e5
--- /dev/null
+++ b/t/depcomp.sh
@@ -0,0 +1,48 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test to make sure depcomp is installed and found properly
+# when required for multiple directories.
+
+. ./defs || Exit 1
+
+cat > configure.ac << END
+AC_INIT([$me], [1.0])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([subdir/Makefile subdir2/Makefile])
+AC_PROG_CC
+AC_OUTPUT
+END
+
+rm -f depcomp
+mkdir subdir
+mkdir subdir2
+
+cat > subdir/Makefile.am << 'END'
+noinst_PROGRAMS = foo
+foo_SOURCES = foo.c
+END
+
+cp subdir/Makefile.am subdir2/Makefile.am
+
+$ACLOCAL
+$AUTOMAKE --add-missing
+
+# There used to be a bug where this was created in the first subdir with C
+# sources in it instead of in $top_srcdir or $ac_auxdir.
+test -f depcomp
+
+:
diff --git a/t/depcomp2.sh b/t/depcomp2.sh
new file mode 100755
index 000000000..624dee6f0
--- /dev/null
+++ b/t/depcomp2.sh
@@ -0,0 +1,50 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test to make sure that depcomp is not used when it's not installed
+# From Pavel Roskin.
+
+required=cc
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_CONFIG_FILES([subdir/Makefile])
+AC_PROG_CC
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+SUBDIRS = subdir
+END
+
+rm -f depcomp
+mkdir subdir
+
+cat > subdir/Makefile.in << 'END'
+foo:
+ $(CC) -o foo foo.c
+END
+
+: > subdir/foo.c
+
+$ACLOCAL
+$AUTOMAKE --add-missing
+$AUTOCONF
+./configure 2>stderr || { cat stderr >&2; Exit 1; }
+cat stderr >&2
+test ! -s stderr
+
+:
diff --git a/t/depcomp8a.sh b/t/depcomp8a.sh
new file mode 100755
index 000000000..01a2403c2
--- /dev/null
+++ b/t/depcomp8a.sh
@@ -0,0 +1,82 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Test for regressions in computation of names of .Po files for
+# automatic dependency tracking.
+# Keep this in sync with sister test 'depcomp8b.test', which checks the
+# same thing for libtool objects.
+
+required=cc
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+#x AM_PROG_CC_C_O
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = zardoz
+zardoz_SOURCES = foo.c sub/bar.c
+END
+
+mkdir sub
+cat > foo.c << 'END'
+int main (void)
+{
+ extern int bar;
+ return bar;
+}
+END
+cat > sub/bar.c << 'END'
+extern int bar = 0;
+END
+
+$ACLOCAL
+$AUTOMAKE -a
+grep include Makefile.in # For debugging.
+grep 'include.*\./\$(DEPDIR)/foo\.P' Makefile.in
+grep 'include.*\./\$(DEPDIR)/bar\.P' Makefile.in
+grep 'include.*/\./\$(DEPDIR)' Makefile.in && Exit 1
+
+$AUTOCONF
+# Don't reject slower dependency extractors, for better coverage.
+./configure --enable-dependency-tracking
+$MAKE
+cross_compiling || ./zardoz
+DISTCHECK_CONFIGURE_FLAGS='--enable-dependency-tracking' $MAKE distcheck
+
+# Try again with subdir-objects option.
+
+sed 's/#x //' configure.ac >configure.int
+mv -f configure.int configure.ac
+echo AUTOMAKE_OPTIONS = subdir-objects >> Makefile.am
+
+$ACLOCAL
+$AUTOMAKE -a
+grep include Makefile.in # For debugging.
+grep 'include.*\./\$(DEPDIR)/foo\.P' Makefile.in
+grep 'include.*[^a-zA-Z0-9_/]sub/\$(DEPDIR)/bar\.P' Makefile.in
+$EGREP 'include.*/(\.|sub)/\$\(DEPDIR\)' Makefile.in && Exit 1
+
+$AUTOCONF
+# Don't reject slower dependency extractors, for better coverage.
+./configure --enable-dependency-tracking
+$MAKE
+cross_compiling || ./zardoz
+DISTCHECK_CONFIGURE_FLAGS='--enable-dependency-tracking' $MAKE distcheck
+
+:
diff --git a/t/depcomp8b.sh b/t/depcomp8b.sh
new file mode 100755
index 000000000..b5f7371cd
--- /dev/null
+++ b/t/depcomp8b.sh
@@ -0,0 +1,76 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Test for regressions in computation of names of .Plo files for
+# automatic dependency tracking.
+# Keep this in sync with sister test 'depcomp8a.test', which checks the
+# same thing for non-libtool objects.
+
+required='cc libtoolize'
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+#x AM_PROG_CC_C_O
+AM_PROG_AR
+AC_PROG_LIBTOOL
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+lib_LTLIBRARIES = libzardoz.la
+libzardoz_la_SOURCES = foo.c sub/bar.c
+END
+
+mkdir sub
+echo 'extern int foo = 0;' > foo.c
+echo 'extern int bar = 0;' > sub/bar.c
+
+libtoolize
+
+$ACLOCAL
+$AUTOMAKE -a
+grep include Makefile.in # For debugging.
+grep 'include.*\./\$(DEPDIR)/foo\.P' Makefile.in
+grep 'include.*\./\$(DEPDIR)/bar\.P' Makefile.in
+grep 'include.*/\./\$(DEPDIR)' Makefile.in && Exit 1
+
+$AUTOCONF
+# Don't reject slower dependency extractors, for better coverage.
+./configure --enable-dependency-tracking
+$MAKE
+DISTCHECK_CONFIGURE_FLAGS='--enable-dependency-tracking' $MAKE distcheck
+
+# Try again with subdir-objects option.
+
+sed 's/#x //' configure.ac >configure.int
+mv -f configure.int configure.ac
+echo AUTOMAKE_OPTIONS = subdir-objects >> Makefile.am
+
+$ACLOCAL
+$AUTOMAKE -a
+grep include Makefile.in # For debugging.
+grep 'include.*\./\$(DEPDIR)/foo\.P' Makefile.in
+grep 'include.*[^a-zA-Z0-9_/]sub/\$(DEPDIR)/bar\.P' Makefile.in
+$EGREP 'include.*/(\.|sub)/\$\(DEPDIR\)' Makefile.in && Exit 1
+
+$AUTOCONF
+# Don't reject slower dependency extractors, for better coverage.
+./configure --enable-dependency-tracking
+$MAKE
+DISTCHECK_CONFIGURE_FLAGS='--enable-dependency-tracking' $MAKE distcheck
+
+:
diff --git a/t/depdist.sh b/t/depdist.sh
new file mode 100755
index 000000000..e81e09783
--- /dev/null
+++ b/t/depdist.sh
@@ -0,0 +1,74 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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 depcomp is found for the distribution.
+# From Eric Magnien.
+
+required=cc
+. ./defs || Exit 1
+
+rm -f configure.ac
+
+mkdir config
+for i in *; do
+ if test "$i" != "config"; then
+ mv -f "$i" config
+ fi
+done
+
+cat > configure.ac << END
+AC_INIT([$me], [1.0])
+AC_CONFIG_AUX_DIR([config])
+AM_INIT_AUTOMAKE
+AC_PROG_CC
+AC_CONFIG_FILES([subdir/Makefile Makefile])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+SUBDIRS = subdir
+check-local: test1 test2
+.PHONY: test1 test2
+test1:
+ echo ' ' $(DIST_COMMON) ' ' | grep '[ /]config/depcomp '
+test2: distdir
+ ls -l $(distdir)/*
+ test -f $(distdir)/config/depcomp
+END
+
+mkdir subdir
+cat > subdir/foo.c << 'END'
+int main(void)
+{
+ return 0;
+}
+END
+
+cat > subdir/Makefile.am << 'END'
+bin_PROGRAMS = foo
+foo_SOURCES = foo.c
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+./configure
+
+$MAKE check
+$MAKE distcheck
+
+:
diff --git a/t/depend.sh b/t/depend.sh
new file mode 100755
index 000000000..a2e3bd866
--- /dev/null
+++ b/t/depend.sh
@@ -0,0 +1,34 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# This tests for a bug reported by Henrik Frystyk Nielsen <frystyk@w3.org>
+# In some cases the auto-dependency can get confused and try
+# to '-include' a directory (if a backslash-newline appears in _SOURCES).
+
+. ./defs || Exit 1
+
+echo AC_PROG_CC >> configure.ac
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = fred
+fred_SOURCES = \
+ fred.c
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+test 1 = `grep '^@AMDEP_TRUE@@am__include@' Makefile.in | wc -l`
diff --git a/t/depend3.sh b/t/depend3.sh
new file mode 100755
index 000000000..8f8431afa
--- /dev/null
+++ b/t/depend3.sh
@@ -0,0 +1,46 @@
+#! /bin/sh
+# Copyright (C) 1997-2012 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/>.
+
+# Test _DEPENDENCIES variable. From Lee Iverson.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_SUBST(DEPS)
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = TerraVision
+
+TerraVision_SOURCES = \
+ AboutDialog.c Clock.c Dialogs.c DrawModel.c \
+ TsmWidget.c Gats.c GATSDialogs.c Model.c ModelAnim.c \
+ ScannedMap.c \
+ TerraVision.c TerraVisionAvs.c TerraVisionCAVE.c \
+ Texture.c ThreeDControl.c ThreeDPanel.c \
+ ThreeDWidget.c ThreeDWidget1.c TileManager.c \
+ TileRequester.c TwoDWidget.c \
+ Visible.c RequestGenerator.c X11FrameGrab.c \
+ matrix.c pixmaps.c xpmhash.c xpmread.c xcolor.c xv24to8.c
+
+DEPS = @DEPS@
+
+TerraVision_DEPENDENCIES = $(DEPS)
+END
+
+$ACLOCAL
+$AUTOMAKE
diff --git a/t/depend4.sh b/t/depend4.sh
new file mode 100755
index 000000000..d9896f860
--- /dev/null
+++ b/t/depend4.sh
@@ -0,0 +1,36 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Check that dependencies are included when there are many header files.
+
+. ./defs || Exit 1
+
+echo AC_PROG_CC >> configure.ac
+
+$ACLOCAL
+
+headers=
+for header in one.h two.h three.h four.h five.h six.h; do
+ headers="$headers $header"
+ unindent > Makefile.am << END
+ bin_PROGRAMS = fred
+ fred_SOURCES = fred1.c $headers
+END
+ $AUTOMAKE
+ test 1 = `grep '^@AMDEP_TRUE@@am__include@' Makefile.in | wc -l`
+done
+
+:
diff --git a/t/depend5.sh b/t/depend5.sh
new file mode 100755
index 000000000..ca900f0fc
--- /dev/null
+++ b/t/depend5.sh
@@ -0,0 +1,78 @@
+#! /bin/sh
+# Copyright (C) 2008-2012 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/>.
+
+# Check that _AM_OUTPUT_DEPENDENCY_COMMANDS works with eval-style
+# quoting in $CONFIG_FILES, done by newer Autoconf.
+
+required=cc
+. ./defs || Exit 1
+
+cat >>configure.ac << END
+AC_PROG_CC
+AC_OUTPUT
+END
+
+cat > Makefile.am << END
+bin_PROGRAMS = foo
+foo_SOURCES = foo.c foo.h
+END
+
+cat >foo.c << END
+#include "foo.h"
+END
+: >foo.h
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+./configure --enable-dependency-tracking
+if test -d .deps; then
+ depdir=.deps
+elif test -d _deps; then
+ depdir=_deps
+else
+ depdir=
+fi
+
+# For the fun of it, we should also cope with makefile
+# names that contain weird characters, with Autoconf 2.62
+# and newer.
+# Pick the first name that the file system will accept.
+for name in \
+ 'weird name with $ `#() &! characters"' \
+ 'weird name with $ `#() characters"' \
+ 'weird name with characters'
+do
+ cp Makefile.in "$name.in" && break || :
+done
+
+for arg in Makefile \
+ --file=Makefile \
+ "--file=$name"
+do
+ rm -rf .deps _deps
+ ./config.status "$arg" depfiles >stdout 2>stderr ||
+ { cat stdout; cat stderr >&2; Exit 1; }
+ cat stdout
+ cat stderr >&2
+ grep '[Nn]o such file' stderr && Exit 1
+
+ if test -n "$depdir"; then
+ test -d $depdir || Exit 1
+ fi
+done
+
+:
diff --git a/t/depend6.sh b/t/depend6.sh
new file mode 100755
index 000000000..fb4c14003
--- /dev/null
+++ b/t/depend6.sh
@@ -0,0 +1,46 @@
+#! /bin/sh
+# Copyright (C) 2008-2012 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/>.
+
+# Check for _AM_OUTPUT_DEPENDENCY_COMMANDS grouping bug,
+# reported by Markus Duft.
+
+. ./defs || Exit 1
+
+cat >>configure.ac << END
+AC_PROG_CC
+AC_OUTPUT
+END
+
+cat > Makefile.am << END
+bin_PROGRAMS = foo
+foo_SOURCES = foo.c foo.h
+END
+
+cat >foo.c << END
+#include "foo.h"
+END
+: >foo.h
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+./configure --disable-dependency-tracking 2>stderr || {
+ stat=$?; cat stderr >&2; Exit $stat;
+}
+cat stderr >&2
+grep shift stderr && Exit 1
+
+:
diff --git a/t/deprecated-acinit.sh b/t/deprecated-acinit.sh
new file mode 100755
index 000000000..d130f9c44
--- /dev/null
+++ b/t/deprecated-acinit.sh
@@ -0,0 +1,52 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that automake and autoconf complain about an old-style AC_INIT
+# call used with a new-style AM_AUTOMAKE_INIT call.
+
+. ./defs || Exit 1
+
+: > Makefile.am
+
+# We'll need a proper aclocal.m4, but aclocal is expected to fail
+# later, so get and store it now.
+$ACLOCAL
+mv aclocal.m4 aclocal-m4.sav
+
+errmsg='AC_INIT should be called with package and version argument'
+
+for ac_init in AC_INIT 'AC_INIT([Makefile.am])'; do
+ for am_init_automake in AM_INIT_AUTOMAKE 'AM_INIT_AUTOMAKE([1.11])'; do
+ rm -rf autom4te*.cache aclocal.m4
+ unindent > configure.ac <<END
+ $ac_init
+ $am_init_automake
+ AC_CONFIG_FILES([Makefile])
+END
+ cat configure.ac # For debugging.
+ $ACLOCAL 2>stderr && { cat stderr >&2; Exit 1; }
+ cat stderr >&2
+ grep "^configure\\.ac:.* $errmsg" stderr
+ cp aclocal-m4.sav aclocal.m4
+ $AUTOCONF 2>stderr && { cat stderr >&2; Exit 1; }
+ cat stderr >&2
+ grep "^configure\\.ac:.* $errmsg" stderr
+ AUTOMAKE_fails
+ grep "^configure\\.ac:.* $errmsg" stderr
+ done
+done
+
+:
diff --git a/t/destdir.sh b/t/destdir.sh
new file mode 100755
index 000000000..22bf18406
--- /dev/null
+++ b/t/destdir.sh
@@ -0,0 +1,50 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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 that 'make distcheck' can find some $(DESTDIR) omissions.
+# PR/186.
+
+# The feature we test here relies on read-only directories.
+# It will only work for non-root users.
+required='ro-dir'
+
+. ./defs || Exit 1
+
+cat >> configure.ac <<'EOF'
+AC_OUTPUT
+EOF
+
+cat > Makefile.am <<'EOF'
+dist_data_DATA = foo
+
+# This rule is bogus because it doesn't use $(DESTDIR) on the
+# second argument of cp. distcheck is expected to catch this.
+install-data-hook:
+ cp $(DESTDIR)$(datadir)/foo $(datadir)/bar
+
+uninstall-local:
+ rm -f $(DESTDIR)$(datadir)/bar
+EOF
+
+: > foo
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+./configure
+$MAKE distcheck && Exit 1
+
+:
diff --git a/t/dirlist-abspath.sh b/t/dirlist-abspath.sh
new file mode 100755
index 000000000..78af8b1f2
--- /dev/null
+++ b/t/dirlist-abspath.sh
@@ -0,0 +1,42 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Check use of absolute paths in dirlist.
+
+am_create_testdir=empty
+. ./defs || Exit 1
+
+mkdir acdir-more sub sub/acdir
+echo "`pwd`/acdir-more" > sub/acdir/dirlist
+
+echo 'AC_DEFUN([AM_FOO], [foo-foo--foo])' > acdir-more/foo.m4
+
+cd sub
+
+cat > configure.ac <<EOF
+AC_INIT([$me], [1.0])
+AM_FOO
+EOF
+
+$ACLOCAL --system-acdir acdir
+$AUTOCONF
+
+# Only -I directories are subject to file inclusion.
+grep m4_include aclocal.m4 && Exit 1
+
+grep 'foo-foo--foo' configure
+
+:
diff --git a/t/dirlist.sh b/t/dirlist.sh
new file mode 100755
index 000000000..76daa3505
--- /dev/null
+++ b/t/dirlist.sh
@@ -0,0 +1,57 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Check dirlist support.
+
+. ./defs || Exit 1
+
+cat > configure.ac <<EOF
+AC_INIT
+AM_INIT_GUILE_MODULE
+EOF
+
+mkdir acdir dirlist-test
+echo ./dirlist-test > acdir/dirlist
+
+cat >dirlist-test/dirlist-check.m4 <<'END'
+AC_DEFUN([AM_INIT_GUILE_MODULE],[
+. $srcdir/../GUILE-VERSION
+AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
+AC_CONFIG_AUX_DIR(..)
+module=[$1]
+AC_SUBST(module)])
+END
+
+cat >dirlist-test/init.m4 <<EOF
+AC_DEFUN([AM_INIT_AUTOMAKE], [I should not be included])
+EOF
+
+$ACLOCAL --system-acdir acdir
+$AUTOCONF
+
+# There should be no m4_include in aclocal.m4, even though m4/dirlist
+# contains './dirlist-test' as a relative directory. Only -I directories
+# are subject to file inclusion.
+grep m4_include aclocal.m4 && Exit 1
+
+grep 'GUILE-VERSION' configure
+
+# This bug can occur only when we do a VPATH build of Automake
+# (because of the '-I' passed to aclocal in tests/defs/aclocal.in) but
+# it's OK because VPATH builds are done by 'make distcheck'.
+grep 'I should not be included' configure && Exit 1
+
+:
diff --git a/t/dirlist2.sh b/t/dirlist2.sh
new file mode 100755
index 000000000..f3b9c4ddc
--- /dev/null
+++ b/t/dirlist2.sh
@@ -0,0 +1,60 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Check dirlist globbing support.
+
+. ./defs || Exit 1
+
+cat > configure.ac <<EOF
+AC_INIT
+AM_INIT_GUILE_MODULE
+AM_FOO_BAR
+EOF
+
+mkdir dirlist21-test dirlist22-test
+
+cat >dirlist21-test/dirlist21-check.m4 <<'END'
+AC_DEFUN([AM_INIT_GUILE_MODULE],[
+. $srcdir/../GUILE-VERSION
+AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
+AC_CONFIG_AUX_DIR(..)
+module=[$1]
+AC_SUBST(module)])
+END
+
+cat >dirlist22-test/dirlist22-check.m4 <<'END'
+AC_DEFUN([AM_FOO_BAR],[
+: foo bar baz
+])
+END
+
+mkdir my-acdir
+cat > my-acdir/dirlist <<'END'
+dirlist2*-test
+END
+
+$ACLOCAL --system-acdir my-acdir
+$AUTOCONF
+
+# There should be no m4_include in aclocal.m4, even though m4/dirlist
+# contains './dirlist-test' as a relative directory. Only -I directories
+# are subject to file inclusion.
+grep m4_include aclocal.m4 && Exit 1
+
+grep 'GUILE-VERSION' configure
+grep 'foo bar baz' configure
+
+:
diff --git a/t/discover.sh b/t/discover.sh
new file mode 100755
index 000000000..7a01dc74d
--- /dev/null
+++ b/t/discover.sh
@@ -0,0 +1,43 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test to make sure LIBOBJS file cannot be mentioned explicitly.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_RANLIB
+AM_PROG_AR
+AC_PROG_CC
+AC_LIBOBJ([fsusage])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+noinst_LIBRARIES = libtu.a
+libtu_a_SOURCES = fsusage.c
+libtu_a_LIBADD = @LIBOBJS@
+END
+
+: > fsusage.c
+: > ar-lib
+
+$ACLOCAL
+AUTOMAKE_fails
+
+grep 'automatically discovered.*fsusage\.c.*explicitly mentioned' stderr
+
+:
diff --git a/t/dist-auxdir-many-subdirs.sh b/t/dist-auxdir-many-subdirs.sh
new file mode 100755
index 000000000..db9aa9407
--- /dev/null
+++ b/t/dist-auxdir-many-subdirs.sh
@@ -0,0 +1,140 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# It should be legitimate for many subdir Makefiles to require the
+# same config-aux files.
+
+am_create_testdir=empty
+am_parallel_tests=yes
+required=cc
+. ./defs || Exit 1
+
+count=0
+ocwd=`pwd` || fatal_ "cannot get current working directory"
+
+# Usage: do_check [--add-missing] [CONFIG-AUXDIR-PATH=.]
+do_check ()
+{
+ case $1 in
+ -a|--add-missing) add_missing=yes; shift;;
+ *) add_missing=no;;
+ esac
+ auxdir=${1-.}
+
+ count=`expr $count + 1`
+ mkdir T$count.d
+ cd T$count.d
+
+ distdir=$me-$count
+ unindent > configure.ac << END
+ AC_INIT([$me], [$count])
+ AC_CONFIG_AUX_DIR([$auxdir])
+ AM_INIT_AUTOMAKE([parallel-tests])
+ AC_PROG_CC
+ # We don't want to require python or emcas in this test, so
+ # the tricks below.
+ AM_PATH_PYTHON([2.2], [], [:])
+ EMACS=no; AM_PATH_LISPDIR
+ AC_CONFIG_FILES([Makefile])
+END
+
+ unindent > Makefile.stub <<'END'
+ ## For depcomp.
+ bin_PROGRAMS = foo
+ foo_SOURCES = foo.c
+ ## For py-compile.
+ python_PYTHON = bar.py
+ ## For elisp-comp.
+ lisp_LISP = baz.el
+ ## For test-driver.
+ TESTS =
+END
+
+ required_files='
+ install-sh
+ missing
+ depcomp
+ py-compile
+ elisp-comp
+ test-driver
+ '
+
+ echo "SUBDIRS =" > Makefile.am
+
+ suffixes='0 1 2 3 4 5 6 7 8 9'
+
+ for x in $suffixes; do
+ mkdir sub$x
+ echo "SUBDIRS += sub$x" >> Makefile.am
+ echo "AC_CONFIG_FILES([sub$x/Makefile])" >> configure.ac
+ cp Makefile.stub sub$x/Makefile.am
+ echo 'int main (void) { return 0; }' > sub$x/foo.c
+ touch sub$x/bar.py sub$x/baz.el
+ done
+ echo AC_OUTPUT >> configure.ac
+
+ $ACLOCAL
+ $AUTOCONF
+
+ "$am_scriptdir"/install-sh -d $auxdir \
+ || fatal_ "creating directory '$auxdir' with install-sh"
+ if test $add_missing = yes; then
+ $AUTOMAKE -a --copy
+ for f in $required_files; do
+ test -f $auxdir/$f
+ # To ensure that if a auxiliary file is required and distributed
+ # by many Makefiles, the "dist" rule won't try to copy it multiple
+ # times in $(distdir).
+ chmod a-w $auxdir/$f
+ done
+ else
+ for f in $required_files; do
+ cp "$am_scriptdir"/$f $auxdir/$f \
+ || fatal_ "faild to fetch auxiliary script '$f'"
+ # See comments above.
+ chmod a-w $auxdir/$f
+ done
+ $AUTOMAKE
+ fi
+
+ for vpath in : false; do
+ if $vpath; then
+ mkdir build
+ cd build
+ srcdir=..
+ else
+ srcdir=.
+ fi
+ $srcdir/configure
+ $MAKE distdir
+ find $distdir # For debugging.
+ for f in $required_files; do
+ test -f $distdir/$auxdir/$f
+ done
+ cd $srcdir
+ done
+
+ cd "$ocwd" || fatal_ "cannot chdir back to '$ocwd'"
+}
+
+do_check .
+do_check --add-missing .
+do_check build-aux
+do_check --add-missing build-aux
+do_check a/b/c
+do_check --add-missing a/b/c
+
+:
diff --git a/t/dist-auxfile-2.sh b/t/dist-auxfile-2.sh
new file mode 100755
index 000000000..b7e2e2d1a
--- /dev/null
+++ b/t/dist-auxfile-2.sh
@@ -0,0 +1,60 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Files specified by AC_REQUIRE_AUX_FILE must exist, and if a Makefile
+# is present in the build-aux directory, they correctly get automatically
+# distributed.
+# Related to automake bug#9651.
+
+am_create_testdir=empty
+. ./defs || Exit 1
+
+cat > configure.ac <<END
+AC_INIT([$me], [1.0])
+AC_CONFIG_AUX_DIR([sub])
+AM_INIT_AUTOMAKE
+AC_REQUIRE_AUX_FILE([zardoz])
+AC_CONFIG_FILES([Makefile sub/Makefile])
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+SUBDIRS = sub
+test: distdir
+ ls -l $(distdir) $(distdir)/* ;: For debugging.
+ test -f $(distdir)/sub/zardoz
+.PHONY: test
+check-local: test
+END
+
+mkdir sub
+: > sub/Makefile.am
+
+echo dummy > sub/zardoz
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+test -f sub/install-sh
+# Should work also without '--add-missing'.
+$AUTOMAKE
+
+./configure
+
+$MAKE test
+$MAKE distcheck
+
+:
diff --git a/t/dist-auxfile.sh b/t/dist-auxfile.sh
new file mode 100755
index 000000000..9f7e8eee7
--- /dev/null
+++ b/t/dist-auxfile.sh
@@ -0,0 +1,95 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Files specified by AC_REQUIRE_AUX_FILE must exist, and they get
+# automatically distributed by the top-level Makefile.am.
+# Automake bug#9651 reported that this didn't happen when the build-aux
+# directory was set to '.' by AC_CONFIG_AUX_DIR.
+
+am_create_testdir=empty
+. ./defs || Exit 1
+
+i=0
+for auxdir in build-aux ''; do
+
+ echo "*** Testing with auxdir '$auxdir' ***"
+
+ i=`expr $i + 1`
+ mkdir T$i.d
+ cd T$i.d
+
+ unindent > configure.ac <<END
+ AC_INIT([$me], [1.0])
+ AC_CONFIG_AUX_DIR([${auxdir:-.}])
+ AM_INIT_AUTOMAKE
+ AC_REQUIRE_AUX_FILE([foo.txt])
+ AC_REQUIRE_AUX_FILE([bar.sh])
+ AC_REQUIRE_AUX_FILE([zardoz])
+ AC_CONFIG_FILES([Makefile subdir/Makefile])
+ AC_OUTPUT
+END
+
+ echo auxdir = ${auxdir:+"$auxdir/"} > Makefile.am
+ unindent >> Makefile.am <<'END'
+ SUBDIRS = subdir
+ test: distdir
+ ls -l $(distdir) $(distdir)/* ;: For debugging.
+ @echo DIST_COMMON = $(DIST_COMMON) ;: Likewise.
+ echo ' ' $(DIST_COMMON) ' ' | grep '[ /]$(auxdir)foo.txt '
+ echo ' ' $(DIST_COMMON) ' ' | grep '[ /]$(auxdir)bar.sh '
+ echo ' ' $(DIST_COMMON) ' ' | grep '[ /]$(auxdir)zardoz '
+ test -f $(distdir)/$(auxdir)foo.txt
+ test -f $(distdir)/$(auxdir)bar.sh
+ test -f $(distdir)/$(auxdir)zardoz
+ .PHONY: test
+ check-local: test
+END
+
+ mkdir subdir
+ echo > subdir/Makefile.am # 'echo', not ':', for Solaris /bin/sh.
+
+ test -z "$auxdir" || mkdir "$auxdir" || Exit 99
+
+ if test -z "$auxdir"; then
+ auxdir=.
+ auxdir_rx='\.'
+ else
+ auxdir_rx=$auxdir
+ fi
+
+ $ACLOCAL
+ $AUTOCONF
+
+ AUTOMAKE_fails
+ grep "^configure\\.ac:4:.* required file.*$auxdir_rx/foo\\.txt" stderr
+ grep "^configure\\.ac:5:.* required file.*$auxdir_rx/bar\\.sh" stderr
+ grep "^configure\\.ac:6:.* required file.*$auxdir_rx/zardoz" stderr
+
+ touch $auxdir/foo.txt $auxdir/bar.sh $auxdir/zardoz
+ cp "$am_scriptdir"/missing "$am_scriptdir"/install-sh $auxdir \
+ || fatal_ "fetching auxiliary scripts 'missing' and 'install-sh'"
+ $AUTOMAKE
+ ./configure
+ $MAKE test
+ $EGREP '(foo\.txt|bar\.sh|zardoz)' subdir/Makefile.in && Exit 1
+
+ $MAKE distcheck
+
+ cd ..
+
+done
+
+:
diff --git a/t/dist-formats.tap b/t/dist-formats.tap
new file mode 100755
index 000000000..8a287ff9d
--- /dev/null
+++ b/t/dist-formats.tap
@@ -0,0 +1,451 @@
+#! /bin/sh
+# Copyright (C) 2012 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/>.
+
+# Check support for different compression formats used by distribution
+# archives.
+
+am_create_testdir=empty
+. ./defs || Exit 1
+
+plan_ 70
+
+# ---------------------------------------------------- #
+# Common and/or auxiliary subroutines and variables. #
+# ---------------------------------------------------- #
+
+ocwd=`pwd` || fatal_ "obtaining current working directory"
+
+TAR='' && unset TAR
+
+# Create common aclocal.m4 file, for later tests.
+mkdir setup \
+ && cd setup \
+ && echo 'AC_INIT([x], [0]) AM_INIT_AUTOMAKE' > configure.ac \
+ && $ACLOCAL \
+ && mv aclocal.m4 .. \
+ && cd .. \
+ && rm -rf setup \
+ || fatal_ "creating common aclocal.m4 file"
+
+# Some make implementations (e.g., HP-UX) don't grok '-j', some require
+# no space between '-j' and the number of jobs (e.g., older GNU make
+# versions), and some *do* require a space between '-j' and the number
+# of jobs (e.g., Solaris dmake). We need a runtime test to see what
+# works.
+for MAKE_j4 in "$MAKE -j4" "$MAKE -j 4" false; do
+ echo all: | $MAKE_j4 -f - && break
+ : For shells with buggy 'set -e'.
+done
+
+# Set variables '$compressor' and '$suffix'.
+setup_vars_for_compression_format ()
+{
+ suffix=NONE compressor=NONE
+ case $1 in
+ gzip) suffix=tar.gz compressor=gzip ;;
+ tarZ) suffix=tar.Z compressor=compress ;;
+ lzip) suffix=tar.lz compressor=lzip ;;
+ xz) suffix=tar.xz compressor=xz ;;
+ bzip2) suffix=tar.bz2 compressor=bzip2 ;;
+ zip) suffix=zip compressor=zip ;;
+ shar) suffix=shar.gz compressor=shar ;;
+ *) fatal_ "invalid compression format '$1'";;
+ esac
+}
+
+all_compression_formats='gzip tarZ lzip xz bzip2 zip shar'
+
+all_compressors=`
+ for x in $all_compression_formats; do
+ setup_vars_for_compression_format $x
+ echo $compressor
+ done | tr "$nl" ' '`
+echo All compressors: $all_compressors
+
+missing_compressors=`
+ for c in $all_compressors; do
+ case $c in
+ # Assume gzip(1) is available on every reasonable portability target.
+ gzip)
+ continue
+ ;;
+ # On Cygwin, as of 9/2/2012, 'compress' is provided by sharutils
+ # and is just a dummy script that is not able to actually compress
+ # (it can only decompress). So, check that the 'compress' program
+ # is actually able to compress input.
+ # Note that, at least on GNU/Linux, 'compress' does (and is
+ # documented to) exit with status 2 if the output is larger than
+ # the input after (attempted) compression; so we need to pass it
+ # an input that it can actually reduce in size when compressing.
+ compress)
+ for x in 1 2 3 4 5 6 7 8; do
+ echo aaaaaaaaaaaaaaa
+ done | $c -c >/dev/null && continue
+ : For shells with busted 'set -e'.
+ ;;
+ *)
+ $c --version </dev/null >&2 && continue
+ : For shells with busted 'set -e'.
+ ;;
+ esac
+ echo $c
+ done | tr "$nl" ' '`
+echo Missing compressors: $missing_compressors
+
+have_compressor ()
+{
+ case " $missing_compressors " in *\ $1\ *) false;; *) : ;; esac
+}
+
+have_all_compressors ()
+{
+ test -z "$missing_compressors"
+}
+
+start_subtest ()
+{
+ name=$1; shift
+ test -n "$name" || fatal_ "start_subtest: no subtest name given"
+ if test $# -gt 0; then
+ eval "$@" || fatal_ "start_subtest: evaluating assignments"
+ fi
+ ac_opts=`echo $ac_opts | tr ',' ' '`
+ am_opts=`echo $am_opts | tr ',' ' '`
+ mkdir "$name"
+ cd "$name"
+ unindent > configure.ac <<END
+ AC_INIT([$name], [1.0])
+ AM_INIT_AUTOMAKE([$ac_opts])
+ AC_CONFIG_FILES([Makefile])
+ AC_OUTPUT
+END
+ echo "AUTOMAKE_OPTIONS = $am_opts" > Makefile.am
+ # It is imperative that aclocal.m4 is copied after configure.ac has
+ # been created, to avoid a spurious trigger of the automatic remake
+ # rules for configure & co.
+ cp "$ocwd"/aclocal.m4 \
+ "$am_scriptdir"/missing \
+ "$am_scriptdir"/install-sh \
+ .
+}
+
+end_subtest ()
+{
+ unset name; unset ac_opts; unset am_opts;
+ cd "$ocwd" || fatal_ "couldn't chdir back to '$ocwd'"
+}
+
+command_ok_if_have_compressor ()
+{
+ if have_compressor "$compressor"; then
+ command_ok_ "$@"
+ else
+ skip_ -r "'$compressor' not available" "$1"
+ fi
+}
+
+can_compress ()
+{
+ test $# -eq 2 || fatal_ "can_compress: bad number of arguments"
+ tarname=$1 format=$2
+ setup_vars_for_compression_format "$format"
+
+ command_ok_ "'dist-$format' target always created" $MAKE -n dist-$format
+
+ command_ok_if_have_compressor "'make dist-$format' work by default" \
+ eval '
+ rm -rf *$tarname* \
+ && make dist-$format \
+ && test -f $tarname-1.0.$suffix \
+ && ls -l *$tarname* \
+ && test "`ls *$tarname*`" = $tarname-1.0.$suffix'
+
+ unset suffix compressor format tarname
+}
+
+# ---------------------------------------- #
+# Defaults layout of the dist-* targets. #
+# ---------------------------------------- #
+
+start_subtest defaults
+
+command_ok_ "default [automake]" $AUTOMAKE
+command_ok_ "default [autoconf]" $AUTOCONF
+command_ok_ "default [configure]" ./configure
+command_ok_ "default [make distcheck]" $MAKE distcheck
+
+command_ok_ "'make dist' only builds *.tar.gz by default" \
+ test "`ls *defaults*`" = defaults-1.0.tar.gz
+
+rm -rf *defaults*
+
+for fmt in $all_compression_formats; do
+ can_compress defaults $fmt
+done
+unset fmt
+
+end_subtest
+
+# ----------------------------------------------------------- #
+# Check diagnostic for no-dist-gzip without another dist-*. #
+# ----------------------------------------------------------- #
+
+nogzip_stderr ()
+{
+ grep "$1:.*no-dist-gzip" stderr \
+ && grep "$1:.* at least one archive format must be enabled" stderr
+}
+
+nogzip_automake_failure ()
+{
+ AUTOMAKE_fails -d "no-dist-gzip ($1) without other formats is an error"
+ command_ok_ "no-dist-gzip ($1) without other formats gives diagnostic" \
+ nogzip_stderr "$2"
+}
+
+start_subtest am-nogz-only am_opts=no-dist-gzip ac_opts=
+nogzip_automake_failure 'am' 'Makefile\.am:1'
+end_subtest
+
+start_subtest ac-nogz-only am_opts= ac_opts=no-dist-gzip
+nogzip_automake_failure 'ac' 'configure\.ac:2'
+end_subtest
+
+# ------------------------------------------------- #
+# Check use of no-dist-gzip with a dist-* option. #
+# ------------------------------------------------- #
+
+append_to_opt ()
+{
+ var=$1_opts val=$2
+ eval "$var=\${$var:+\"\$$var,\"}\$val" || fatal_ "evaluating \${$var}"
+ unset var val
+}
+
+nogzip ()
+{
+ test $#,$1,$3,$5 = 6,in,and,in \
+ && case $2,$6 in ac,ac|ac,am|am,ac|am,am) :;; *) false;; esac \
+ || fatal_ "nogzip: invalid usage"
+ format=$4 where_dist_nogzip=$2 where_dist_format=$6
+ shift 6
+
+ am_opts= ac_opts=
+ append_to_opt $where_dist_format dist-$format
+ append_to_opt $where_dist_nogzip no-dist-gzip
+ setup_vars_for_compression_format "$format"
+ # Do these before the am_opts and ac_opts variable can be munged
+ # by 'start_subtest'.
+ desc=
+ test -n "$am_opts" && desc=${desc:+"$desc "}"am=$am_opts"
+ test -n "$ac_opts" && desc=${desc:+"$desc "}"ac=$ac_opts"
+
+ start_subtest nogzip-$format am_opts=$am_opts ac_opts=$ac_opts
+
+ unindent >> Makefile.am <<END
+ check-ark-name:
+ test \$(DIST_ARCHIVES) = \$(distdir).$suffix
+ check-ark-exists:
+ test -f \$(distdir).$suffix
+ check-no-tar-gz:
+ test ! -f \$(distdir).tar.gz
+END
+
+ command_ok_ "$desc [automake]" $AUTOMAKE
+ command_ok_ "$desc [autoconf]" $AUTOCONF
+ command_ok_ "$desc [configure]" ./configure
+ command_ok_ "$desc [ark-name]" $MAKE check-ark-name
+ command_ok_if_have_compressor "$desc [distcheck]" $MAKE distcheck
+ command_ok_if_have_compressor "$desc [ark-exists]" $MAKE check-ark-exists
+ command_ok_ "$desc [no .tar.gz]" $MAKE check-no-tar-gz
+
+ unset desc
+
+ end_subtest
+}
+
+# $1 $2 $3 $4 $5 $6
+nogzip in am and bzip2 in am
+nogzip in ac and xz in am
+nogzip in am and lzip in ac
+nogzip in ac and tarZ in ac
+
+
+# ----------------------------------------------------------- #
+# The 'dist-gzip' target is created also with no-dist-gzip. #
+# ----------------------------------------------------------- #
+
+start_subtest dist-gzip-persistence am_opts=no-dist-gzip,dist-xz
+command_ok_ "dist-gzip persistence [automake]" $AUTOMAKE
+command_ok_ "dist-gzip persistence [autoconf]" $AUTOCONF
+command_ok_ "dist-gzip persistence [configure]" ./configure
+can_compress dist-gzip-persistence gzip
+end_subtest
+
+
+# ----------------------- #
+# Parallel compression. #
+# ----------------------- #
+
+# We only use formats requiring 'gzip', 'bzip2' and 'compress' programs,
+# since there are the most likely to be all found on the great majority
+# of systems.
+
+start_subtest parallel-compression ac_opts=dist-bzip2 am_opts=dist-tarZ
+
+desc=gzip+bzip2+tarZ
+tarname=parallel-compression-1.0
+
+check_tarball ()
+{
+ format=$1
+ setup_vars_for_compression_format $format
+ (
+ tarball=$tarname.$suffix \
+ && test -f $tarball \
+ && mkdir check-$format \
+ && cp $tarball check-$format \
+ && cd check-$format \
+ && $compressor -d $tarball \
+ && tar xvf $tarname.tar \
+ && diff ../Makefile.in $tarname/Makefile.in \
+ && cd .. \
+ && rm -rf check-$format
+ )
+}
+
+command_ok_ "$desc [automake]" $AUTOMAKE
+
+skip_reason=
+have_compressor compress || skip_reason="'compress' not available"
+have_compressor bzip2 || skip_reason="'bzip2' not available"
+if test "$MAKE_j4" = false; then
+ test -z "$skip_reason" || skip_reason="$skip_reason and "
+ skip_reason="${skip_reason}make concurrency unavailable"
+fi
+
+if test -n "$skip_reason"; then
+ skip_row_ 6 -r "$skip_reason" "$desc"
+else
+ command_ok_ "$desc [autoconf]" $AUTOCONF
+ command_ok_ "$desc [configure]" ./configure
+ command_ok_ "$desc [make -j4 dist-all]" $MAKE_j4 dist
+ ls -l # For debugging.
+ command_ok_ "$desc [check .tar.gz tarball]" check_tarball gzip
+ command_ok_ "$desc [check .tar.bz2 tarball]" check_tarball bzip2
+ command_ok_ "$desc [check .tar.Z tarball]" check_tarball tarZ
+fi
+
+unset tarname desc skip_reason
+
+end_subtest
+
+
+# --------------------------------------------------------- #
+# The various 'dist-*' targets can happily work together. #
+# --------------------------------------------------------- #
+
+start_subtest all-together
+
+desc='all compressors together'
+tarname=all-together-1.0
+
+echo 'AM_INIT_AUTOMAKE([' > am-init.m4
+echo 'AUTOMAKE_OPTIONS =' > Makefile.am
+
+# Add half 'dist-*' options to AM_INIT_AUTOMAKE, half to AUTOMAKE_OPTIONS.
+flip=:
+for fmt in $all_compression_formats; do
+ test $fmt = gzip && continue
+ if $flip; then
+ echo " dist-$fmt" >> am-init.m4
+ flip=false
+ else
+ echo "AUTOMAKE_OPTIONS += dist-$fmt" >> Makefil.am
+ flip=:
+ fi
+done
+unset flip fmt
+
+echo '])' >> am-init.m4
+
+sed 's/AM_INIT_AUTOMAKE.*/m4_include([am-init.m4])/' configure.ac > t
+mv -f t configure.ac
+
+# For debugging.
+cat Makefil.am
+cat configure.ac
+cat am-init.m4
+
+command_ok_ "$desc [aclocal]" $ACLOCAL --force
+command_ok_ "$desc [automake]" $AUTOMAKE
+command_ok_ "$desc [autoconf]" $AUTOCONF
+command_ok_ "$desc [configure]" ./configure
+
+if have_all_compressors; then
+ command_ok_ "$desc [make distcheck, real]" $MAKE distcheck
+else
+ skip_ -r "not all compressors available" "$desc [make distcheck, real]"
+fi
+
+# We fake existence of all the compressors here, so that we don't have
+# to require any of them to run the further tests. This is especially
+# important since it's very unlikely that a non-developer has all the
+# compression tools installed on his machine at the same time.
+
+mkdir bin
+cd bin
+cat > check-distdir <<END
+#!/bin/sh
+{ ls -l '$tarname' && diff Makefile.am '$tarname'/Makefile.am; } >&2 \
+ || { echo "== distdir fail =="; exit 1; }
+END
+cat > grep-distdir-error <<'END'
+#!/bin/sh
+grep 'distdir fail' && exit 1
+:
+END
+chmod a+x check-distdir grep-distdir-error
+for prog in tar $all_compressors; do
+ case $prog in
+ tar|shar|zip) cp check-distdir $prog;;
+ *) cp grep-distdir-error $prog;;
+ esac
+done
+unset prog
+ls -l # For debugging.
+cd ..
+
+oPATH=$PATH
+PATH=`pwd`/bin$PATH_SEPARATOR$PATH; export PATH
+
+command_ok_ \
+ "$desc ['make dist-all', stubbed]" \
+ $MAKE dist-all
+
+subdesc="$desc ['make dist -j4', stubbed]"
+if test "$MAKE_j4" = false; then
+ skip_ -r "make concurrency unavailable" "$subdesc"
+else
+ command_ok_ "$subdesc" $MAKE_j4 dist
+fi
+unset subdesc
+
+PATH=$oPATH; export PATH
+
+end_subtest
+
+:
diff --git a/t/dist-included-parent-dir.sh b/t/dist-included-parent-dir.sh
new file mode 100755
index 000000000..ae135aee4
--- /dev/null
+++ b/t/dist-included-parent-dir.sh
@@ -0,0 +1,49 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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 included files in parent directory are distributed.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_CONFIG_FILES([sub/Makefile])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+SUBDIRS = sub
+test: distdir
+ test -f $(distdir)/foo
+ test -f $(distdir)/bar
+ test 2 -gt `find $(distdir)/sub -type d | wc -l`
+END
+
+: > foo
+: > bar
+
+mkdir sub
+cat > sub/Makefile.am << 'END'
+include $(top_srcdir)/foo
+include ../bar
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+# Use --srcdir with an absolute path because it's harder
+# to support in 'distdir'.
+./configure --srcdir "`pwd`"
+$MAKE test
diff --git a/t/dist-missing-am.sh b/t/dist-missing-am.sh
new file mode 100755
index 000000000..0765b0c59
--- /dev/null
+++ b/t/dist-missing-am.sh
@@ -0,0 +1,66 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# The stub rules emitted to work around the "deleted header problem"
+# for '.am' files shouldn't prevent "make" from diagnosing a missing
+# required '.am' file from a distribution tarball.
+# See discussion about automake bug#9768.
+
+. ./defs || Exit 1
+
+echo AC_OUTPUT >> configure.ac
+
+cat > Makefile.am <<'END'
+include $(srcdir)/foobar.am
+include $(srcdir)/zardoz.am
+END
+
+: > foobar.am
+: > zardoz.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+
+# A faulty distribution tarball, with a required '.am' file missing.
+# Building from it should fail, both for in-tree and VPATH builds.
+ocwd=`pwd` || fatal_ "cannot get current working directory"
+for vpath in false :; do
+ $MAKE distdir
+ test -f $distdir/zardoz.am # Sanity check.
+ rm -f $distdir/zardoz.am
+ if $vpath; then
+ # We can't just build in a subdirectory of $distdir, otherwise
+ # we'll hit automake bug#10111.
+ mkdir vpath-distcheck
+ cd vpath-distcheck
+ ../$distdir/configure
+ else
+ cd $distdir
+ ./configure
+ fi
+ $MAKE >output 2>&1 && { cat output; Exit 1; }
+ cat output
+ # This error comes from automake, not make, so we can be stricter
+ # in our grepping of it.
+ grep 'cannot open.*zardoz\.am' output
+ grep 'foobar\.am' output && Exit 1 # No spurious error, please.
+ cd "$ocwd" || fatal_ "cannot chdir back to top-level test directory"
+done
+
+:
diff --git a/t/dist-missing-included-m4.sh b/t/dist-missing-included-m4.sh
new file mode 100755
index 000000000..59600036c
--- /dev/null
+++ b/t/dist-missing-included-m4.sh
@@ -0,0 +1,68 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# The stub rules emitted to work around the "deleted header problem"
+# for '.m4' files shouldn't prevent "make" from diagnosing a missing
+# required '.m4' file from a distribution tarball.
+# See discussion about automake bug#9768.
+# See also sister test 'dist-missing-m4.test'.
+
+. ./defs || Exit 1
+
+cat >> configure.ac <<'END'
+m4_include([foobar.m4])
+m4_include([zardoz.m4])
+AC_OUTPUT
+END
+
+: > foobar.m4
+: > zardoz.m4
+
+: > Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+
+# A faulty distribution tarball, with a required '.m4' file missing.
+# Building from it should fail, both for in-tree and VPATH builds.
+ocwd=`pwd` || fatal_ "cannot get current working directory"
+for vpath in false :; do
+ $MAKE distdir
+ test -f $distdir/zardoz.m4 # Sanity check.
+ rm -f $distdir/zardoz.m4
+ if $vpath; then
+ # We can't just build in a subdirectory of $distdir, otherwise
+ # we'll hit automake bug#10111.
+ mkdir vpath-distcheck
+ cd vpath-distcheck
+ ../$distdir/configure
+ else
+ cd $distdir
+ ./configure
+ fi
+ $MAKE >output 2>&1 && { cat output; Exit 1; }
+ cat output
+ # This error will come from automake, not make, so we can be stricter
+ # in our grepping of it.
+ grep 'zardoz\.m4.*does not exist' output
+ grep 'foobar\.m4' output && Exit 1 # No spurious error, please.
+ cd "$ocwd" || fatal_ "cannot chdir back to top-level test directory"
+done
+
+:
diff --git a/t/dist-missing-m4.sh b/t/dist-missing-m4.sh
new file mode 100755
index 000000000..9a418d316
--- /dev/null
+++ b/t/dist-missing-m4.sh
@@ -0,0 +1,70 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# The stub rules emitted to work around the "deleted header problem"
+# for '.m4' files shouldn't prevent "make" from diagnosing a missing
+# required '.m4' file from a distribution tarball.
+# See discussion about automake bug#9768.
+# See also sister test 'dist-missing-included-m4.test'.
+
+. ./defs || Exit 1
+
+cat >> configure.ac <<'END'
+m4_pattern_forbid([^MY_])
+MY_FOOBAR || exit 1
+MY_ZARDOZ || exit 1
+AC_OUTPUT
+END
+
+mkdir m4
+echo 'AC_DEFUN([MY_FOOBAR], [:])' > m4/foobar.m4
+echo 'AC_DEFUN([MY_ZARDOZ], [:])' > m4/zardoz.m4
+
+echo 'ACLOCAL_AMFLAGS = -I m4' > Makefile.am
+
+$ACLOCAL -I m4
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+
+# A faulty distribution tarball, with a required '.m4' file missing.
+# Building from it should fail, both for in-tree and VPATH builds.
+ocwd=`pwd` || fatal_ "cannot get current working directory"
+for vpath in false :; do
+ $MAKE distdir
+ test -f $distdir/m4/zardoz.m4 # Sanity check.
+ rm -f $distdir/m4/zardoz.m4
+ if $vpath; then
+ # We can't just build in a subdirectory of $distdir, otherwise
+ # we'll hit automake bug#10111.
+ mkdir vpath-distcheck
+ cd vpath-distcheck
+ ../$distdir/configure
+ else
+ cd $distdir
+ ./configure
+ fi
+ $MAKE >output 2>&1 && { cat output; Exit 1; }
+ cat output
+ # This error will come from autoconf, not make, so we can be stricter
+ # in our grepping of it.
+ grep 'possibly undefined .*MY_ZARDOZ' output
+ grep 'MY_FOOBAR' output && Exit 1 # No spurious error, please.
+ cd "$ocwd" || fatal_ "cannot chdir back to top-level test directory"
+done
+
+:
diff --git a/t/dist-pr109765.sh b/t/dist-pr109765.sh
new file mode 100755
index 000000000..2e22e841d
--- /dev/null
+++ b/t/dist-pr109765.sh
@@ -0,0 +1,42 @@
+#! /bin/sh
+# Copyright (C) 2012 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/>.
+
+# Expose automake bug#10975: when several "dist-*" targets are invoked
+# on the make command line, the first one ends up removing the distdir,
+# so that the latter ones fail.
+
+required=bzip2
+. ./defs || Exit 1
+
+echo AC_OUTPUT >> configure.ac
+: > Makefile.am
+
+$ACLOCAL || fatal_ "aclocal failed"
+$AUTOCONF || fatal_ "autoconf failed"
+$AUTOMAKE || fatal_ "automake failed"
+
+./configure
+$MAKE dist-gzip dist-bzip2
+
+gzip -dc $distdir.tar.gz | tar tf - > one || { cat one; Exit 1; }
+cat one
+bzip2 -dc $distdir.tar.gz | tar tf - > two || { cat two; Exit 1; }
+cat two
+
+$FGREP "$distdir/Makefile.am" one
+diff one two
+
+:
diff --git a/t/dist-readonly.sh b/t/dist-readonly.sh
new file mode 100755
index 000000000..1aa32c804
--- /dev/null
+++ b/t/dist-readonly.sh
@@ -0,0 +1,60 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Test that a readonly files are distributed as such, and not make
+# writable while being copied in the $(distdir).
+
+required=cc
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = foo
+foo_SOURCES = foo.c
+EXTRA_DIST = bar.txt
+check-local: test
+.PHONY: test
+test:
+ test -f $(srcdir)/foo.c && test ! -w $(srcdir)/foo.c
+ if (echo x > $(srcdir)/foo.c); then exit 1; else :; fi
+ grep 'main (void)' $(srcdir)/foo.c
+ test -f $(srcdir)/bar.txt && test ! -w $(srcdir)/bar.txt
+ if (echo x > $(srcdir)/bar.txt); then exit 1; else :; fi
+ grep 'To be, or not to be' $(srcdir)/bar.txt
+END
+
+echo 'int main (void) { return 0; }' > foo.c
+echo To be, or not to be ... > bar.txt
+chmod a-w foo.c bar.txt
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+$MAKE distdir
+ls -l $distdir # For debugging.
+test -f foo.c && test ! -w foo.c || Exit 1
+(echo x > foo.c) && Exit 1
+test -f bar.txt && test ! -w bar.txt || Exit 1
+(echo x > bar.txt) && Exit 1
+$MAKE distcheck
+
+:
diff --git a/t/dist-repeated.sh b/t/dist-repeated.sh
new file mode 100755
index 000000000..6651e72c9
--- /dev/null
+++ b/t/dist-repeated.sh
@@ -0,0 +1,102 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Test that we can distribute the same file as many times as we want.
+# The distdir target should take care of not copying it more than one
+# time anyway.
+
+. ./defs || Exit 1
+
+echo AC_OUTPUT >> configure.ac
+
+cat > Makefile.am <<'END'
+bin_PROGRAMS = foo bar
+foo_SOURCES = foo.c
+bar_SOURCES = foo.c
+python_PYTHON = bar.py
+EXTRA_DIST = foo.c bar.py
+
+.PHONY: sanity-check
+sanity-check:
+ for f in $(DISTFILES); do echo " $$f "; done > dist.txt
+ cat dist.txt
+ test `grep ' foo\.c ' dist.txt | wc -l` -eq 3
+ test `grep ' bar\.py ' dist.txt | wc -l` -eq 2
+
+# So that we don't have to require a C compiler.
+AUTOMAKE_OPTIONS = no-dependencies
+CC = false
+
+# So that we don't have to require a Python interpreter.
+pythondir = ${prefix}/py
+PYTHON = false
+END
+
+ocwd=`pwd` || fatal_ "cannot get current working directory"
+
+# Help to ensure cp won't see the same file twice.
+mkdir bin
+cat > bin/cp <<END
+#!/bin/sh
+PATH='$PATH'; export PATH
+
+case " \$* " in
+ *foo.c\ *)
+ if test -f '$ocwd'/foo-c-copied; then
+ echo "\$0: we tried to copy foo.c twice" >&2
+ exit 1
+ else
+ # For a sanity check later.
+ echo ok > '$ocwd'/cp-wrapper-has-seen-foo-c
+ fi
+ ;;
+esac
+
+case " \$* " in
+ *bar.py\ *)
+ if test -f '$ocwd'/bar-py-copied; then
+ echo "\$0: we tried to copy bar.py twice" >&2
+ exit 1
+ else
+ # For a sanity check later.
+ echo ok > '$ocwd'/cp-wrapper-has-seen-bar-py
+ fi
+ ;;
+esac
+
+exec cp "\$@"
+END
+chmod a+x bin/cp
+PATH=`pwd`/bin$PATH_SEPARATOR$PATH; export PATH;
+
+: > foo.c
+: > bar.py
+: > py-compile
+
+# Help to ensure cp won't try to copy the same file twice.
+chmod a-w foo.c bar.py
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+$MAKE sanity-check || fatal_ "expected invariants not verified"
+$MAKE distdir
+test -f cp-wrapper-has-seen-foo-c && test -f cp-wrapper-has-seen-bar-py \
+ || fatal_ "our cp wrapper hasn't run correctly"
+
+:
diff --git a/t/distcheck-configure-flags-am.sh b/t/distcheck-configure-flags-am.sh
new file mode 100755
index 000000000..7dbe2ab3d
--- /dev/null
+++ b/t/distcheck-configure-flags-am.sh
@@ -0,0 +1,68 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check support for AM_DISTCHECK_CONFIGURE_FLAGS at "make distcheck"
+# time, and its interactions with DISTCHECK_CONFIGURE_FLAGS.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_ARG_ENABLE([success], [], [success=$enableval], [success=no])
+AS_IF([test $success = yes && test "$sentence" = 'it works :-)'],
+ [:],
+ [AC_MSG_ERROR([success='$success', sentence='$sentence'])])
+AC_OUTPUT
+END
+
+unset sentence || :
+
+cat > Makefile.am << 'END'
+AM_DISTCHECK_CONFIGURE_FLAGS = $(dc_flags1) $(dc_flags2)
+dc_flags1 = --enable-success sentence='it works :-)'
+dc_flags2 =
+END
+
+$ACLOCAL
+$AUTOMAKE
+$FGREP '$(DISTCHECK_CONFIGURE_FLAGS)' Makefile.in
+$FGREP '$(AM_DISTCHECK_CONFIGURE_FLAGS)' Makefile.in
+grep 'DISTCHECK_CONFIGURE_FLAGS.*AM_DISTCHECK_CONFIGURE_FLAGS' Makefile.in \
+ && Exit 1
+
+$AUTOCONF
+./configure --enable-success sentence='it works :-)'
+
+# The configure call in "make distcheck" should honour
+# $(AM_DISTCHECK_CONFIGURE_FLAGS).
+
+$MAKE distcheck
+
+# $(DISTCHECK_CONFIGURE_FLAGS) takes precedence over
+# $(AM_DISTCHECK_CONFIGURE_FLAGS)
+
+cat >> Makefile.am << 'END'
+dc_flags2 += --disable-success
+END
+$AUTOMAKE Makefile
+./config.status Makefile
+
+$MAKE distcheck >output 2>&1 && { cat output; Exit 1; }
+cat output
+grep "^configure:.* success='no', sentence='it works :-)'" output
+
+$MAKE distcheck DISTCHECK_CONFIGURE_FLAGS="--enable-success=yes"
+
+:
diff --git a/t/distcheck-configure-flags-subpkg.sh b/t/distcheck-configure-flags-subpkg.sh
new file mode 100755
index 000000000..45d0e0cb6
--- /dev/null
+++ b/t/distcheck-configure-flags-subpkg.sh
@@ -0,0 +1,81 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check AM_DISTCHECK_CONFIGURE_FLAGS and DISTCHECK_CONFIGURE_FLAGS
+# are not honored in a subpackage Makefile.am, but the flags from
+# AM_DISTCHECK_CONFIGURE_FLAGS and DISTCHECK_CONFIGURE_FLAGS are
+# passed down to the configure script of the subpackage. This is
+# explicitly documented in the manual.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_CONFIG_SUBDIRS([subpkg])
+if test $dc != ok || test $am_dc != ok; then
+ AC_MSG_ERROR([dc=$dc am_dc=$dc])
+fi
+AC_OUTPUT
+END
+
+mkdir subpkg
+
+sed <configure.ac >subpkg/configure.ac \
+ -e 's/^AC_INIT.*/AC_INIT([subpkg], [2.0])/' \
+ -e '/^AC_CONFIG_SUBDIRS/d' \
+
+cat configure.ac
+cat subpkg/configure.ac
+
+dc=KO am_dc=KO; export dc am_dc
+
+cat > Makefile.am << 'END'
+AM_DISTCHECK_CONFIGURE_FLAGS = am_dc=ok
+DISTCHECK_CONFIGURE_FLAGS = dc=ok
+END
+
+: > subpkg/Makefile.am
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+
+cd subpkg
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+cd ..
+
+# For debugging.
+$FGREP 'DISTCHECK_CONFIGURE_FLAGS' Makefile.in subpkg/Makefile.in
+
+grep '^AM_DISTCHECK_CONFIGURE_FLAGS =' Makefile.in
+grep '^DISTCHECK_CONFIGURE_FLAGS =' Makefile.in
+$EGREP '^(AM_)?DISTCHECK_CONFIGURE_FLAGS' subpkg/Makefile.in && Exit 1
+
+./configure dc=ok am_dc=ok
+
+# Flags in $(DISTCHECK_CONFIGURE_FLAGS) and $(AM_DISTCHECK_CONFIGURE_FLAGS)
+# should be passed down to the subpackage configure when "make distcheck"
+# is run from the top-level package ...
+$MAKE distcheck
+
+# ... but not when "make distcheck" is run from the subpackage.
+cd subpkg
+$MAKE distcheck >output 2>&1 && { cat output; Exit 1; }
+cat output
+grep '^configure:.* dc=KO am_dc=KO' output
+
+:
diff --git a/t/distcheck-configure-flags.sh b/t/distcheck-configure-flags.sh
new file mode 100755
index 000000000..ae9fe4015
--- /dev/null
+++ b/t/distcheck-configure-flags.sh
@@ -0,0 +1,54 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check support for DISTCHECK_CONFIGURE_FLAGS at "make distcheck" time.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_ARG_ENABLE([success], [], [success=$enableval], [success=no])
+AS_IF([test $success = yes && test "$sentence" = 'it works :-)'],
+ [:],
+ [AC_MSG_ERROR([success='$success', sentence='$sentence'])])
+AC_OUTPUT
+END
+
+unset sentence || :
+
+: > Makefile.am
+
+$ACLOCAL
+$AUTOMAKE
+$FGREP '$(DISTCHECK_CONFIGURE_FLAGS)' Makefile.in
+
+$AUTOCONF
+./configure --enable-success sentence='it works :-)'
+
+# It should be ok to define DISTCHECK_CONFIGURE_FLAGS either on the
+# make command line or in the environment.
+
+env DISTCHECK_CONFIGURE_FLAGS='--enable-success sentence=it\ works\ :-\)' \
+ $MAKE distcheck # Not 'make -e' here, deliberately.
+
+$MAKE distcheck \
+ DISTCHECK_CONFIGURE_FLAGS="--enable-success=yes sentence='it works :-)'"
+
+# Sanity check.
+$MAKE distcheck >output 2>&1 && { cat output; Exit 1; }
+cat output
+grep "^configure:.* success='no', sentence=''" output
+
+:
diff --git a/t/distcheck-hook.sh b/t/distcheck-hook.sh
new file mode 100755
index 000000000..dfc20010a
--- /dev/null
+++ b/t/distcheck-hook.sh
@@ -0,0 +1,51 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check basic support for distcheck-hook.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+distcheck-hook:
+ ls -l $(distdir)
+ chmod u+w $(distdir)
+ : > $(distdir)/dc-hook-has-run
+ chmod a-w $(distdir)
+check-local:
+ ls -l $(srcdir)
+ test -f $(srcdir)/dc-hook-has-run
+END
+
+$ACLOCAL
+$AUTOMAKE
+$FGREP 'distcheck-hook' Makefile.in
+$FGREP '$(MAKE) $(AM_MAKEFLAGS) distcheck-hook' Makefile.in
+grep '^distcheck-hook:' Makefile.in
+
+$AUTOCONF
+./configure
+
+$MAKE
+$MAKE check && Exit 1
+$MAKE distdir
+test -f $distdir/dc-hook-has-run && Exit 1
+$MAKE distcheck
+
+:
diff --git a/t/distcheck-hook2.sh b/t/distcheck-hook2.sh
new file mode 100755
index 000000000..93446b3bc
--- /dev/null
+++ b/t/distcheck-hook2.sh
@@ -0,0 +1,79 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that no 'distcheck-hook' target is created automatically by
+# Automake, and that a used-defined 'distcheck-hook' is *not* honored
+# in a subpackage Makefile.am.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_CONFIG_SUBDIRS([subpkg])
+AC_OUTPUT
+END
+
+mkdir subpkg
+
+cat > subpkg/configure.ac << 'END'
+AC_INIT([subpkg], [1.0])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+distcheck-hook:
+ ls -l $(distdir)
+ chmod u+w $(distdir)
+ : > $(distdir)/dc-hook-has-run
+ chmod a-w $(distdir)
+check-local:
+ ls -l $(srcdir)
+ test -f $(srcdir)/dc-hook-has-run
+END
+
+cat > subpkg/Makefile.am <<'END'
+check-local:
+ ls -l $(srcdir)
+ test ! -r $(srcdir)/dc-hook-has-run
+END
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+cd subpkg
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+cd ..
+
+# For debugging.
+$FGREP 'distcheck-hook' Makefile.in subpkg/Makefile.in
+
+$FGREP 'distcheck-hook' subpkg/Makefile.in && Exit 1
+$FGREP '$(MAKE) $(AM_MAKEFLAGS) distcheck-hook' Makefile.in
+grep '^distcheck-hook:' Makefile.in
+
+./configure
+
+$MAKE
+$MAKE check && Exit 1
+cd subpkg
+$MAKE check
+cd ..
+$MAKE distcheck
+
+:
diff --git a/t/distcheck-missing-m4.sh b/t/distcheck-missing-m4.sh
new file mode 100755
index 000000000..e583be12f
--- /dev/null
+++ b/t/distcheck-missing-m4.sh
@@ -0,0 +1,118 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Test that we can define a distcheck-hook to diagnose m4 files
+# missing from the dist tarball (interaction with '--install').
+# See automake bug#9037.
+
+. ./defs || Exit 1
+
+cwd=`pwd` || fatal_ "cannot get current working directory"
+
+cp "$am_testauxdir"/distcheck-hook-m4.am . \
+ || fatal_ "cannot fetch makefile fragment 'distcheck-hook-m4.am'"
+
+cat > Makefile.am << 'END'
+## The lack of '--install' here is meant.
+ACLOCAL_AMFLAGS = -I m4
+include $(srcdir)/distcheck-hook-m4.am
+END
+
+cat >> configure.ac << 'END'
+dnl We *deliberately* don't use m4_pattern_forbid here.
+AC_OUTPUT
+MY_FOO
+MY_BAR
+MY_BAZ
+MY_ZAR
+END
+
+mkdir m4 acdir acdir1 acdir2 pth
+
+cat > acdir/dirlist << END
+$cwd/acdir1
+$cwd/acdir2
+END
+
+echo 'AC_DEFUN([MY_FOO], [:])' > m4/foo.m4
+echo 'AC_DEFUN([MY_BAR], [:])' > acdir1/bar.m4
+echo 'AC_DEFUN([MY_BAZ], [:])' > acdir1/baz.m4
+echo 'AC_DEFUN([MY_QUX], [:])' > acdir2/qux.m4
+echo 'AC_DEFUN([MY_ZAR], [:])' > pth/zar.m4
+echo 'AC_DEFUN([MY_BLA], [:])' > pth/bla.m4
+
+ACLOCAL="$ACLOCAL --system-acdir=$cwd/acdir"; export ACLOCAL
+ACLOCAL_PATH=$cwd/pth; export ACLOCAL_PATH
+
+# We don't use '--install' here. Our distcheck-hook should catch this.
+$ACLOCAL -I m4
+$AUTOCONF
+$EGREP 'MY_(FOO|BAR|BAZ|ZAR)' configure && Exit 1 # Sanity check.
+$AUTOMAKE
+
+check_no_spurious_error ()
+{
+ $EGREP -i 'mkdir:|:.*(permission|denied)' output && Exit 1
+ # On failure, some make implementations (such as Solaris make) print the
+ # whole failed recipe on stdout. The first grep works around this.
+ grep -v 'rm -rf ' output | grep -i 'autom4te.*\.cache' && Exit 1
+ : To placate 'set -e'.
+}
+
+./configure
+
+$MAKE distcheck >output 2>&1 && { cat output; Exit 1; }
+cat output
+for x in bar baz zar; do
+ $EGREP "required m4 file.*not distributed.* $x.m4( |$)" output
+done
+check_no_spurious_error
+
+# Now we use '--install', and "make distcheck" should pass.
+$ACLOCAL -I m4 --install
+test -f m4/bar.m4 # Sanity check.
+test -f m4/baz.m4 # Likewise.
+test -f m4/zar.m4 # Likewise.
+using_gmake || $MAKE Makefile
+$MAKE distcheck
+
+# We start to use new "third-party" macros from new .m4 files, but forget
+# to re-run "aclocal --install" by hand, relying on automatic remake rules.
+# Our distcheck-hook should catch this too.
+cat >> configure.ac << 'END'
+MY_QUX
+MY_BLA
+END
+
+$MAKE
+$EGREP 'MY_(FOO|BAR|BAZ|QUX|ZAR|BLA)' configure && Exit 1 # Sanity check.
+
+$MAKE distcheck >output 2>&1 && { cat output; Exit 1; }
+cat output
+$EGREP "required m4 file.*not distributed.* qux.m4( |$)" output
+$EGREP "required m4 file.*not distributed.* bla.m4( |$)" output
+check_no_spurious_error
+# Check that we don't complain for files that should have been found.
+$FGREP " (bar|baz|zar).m4" output && Exit 1
+
+# Now we again use '--install', and "make distcheck" should pass.
+$ACLOCAL -I m4 --install
+test -f m4/qux.m4 # Sanity check.
+test -f m4/bla.m4 # Likewise.
+using_gmake || $MAKE Makefile
+$MAKE distcheck
+
+:
diff --git a/t/distcheck-outdated-m4.sh b/t/distcheck-outdated-m4.sh
new file mode 100755
index 000000000..71ae3dd21
--- /dev/null
+++ b/t/distcheck-outdated-m4.sh
@@ -0,0 +1,137 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Test that we can define a distcheck-hook to diagnose outdated m4
+# files in a dist tarball (interaction with '--install').
+# See automake bug#9037.
+
+. ./defs || Exit 1
+
+cwd=`pwd` || fatal_ "cannot get current working directory"
+
+cp "$am_testauxdir"/distcheck-hook-m4.am . \
+ || fatal_ "cannot fetch makefile fragment 'distcheck-hook-m4.am'"
+
+cat > Makefile.am << 'END'
+## The lack of '--install' here is meant.
+ACLOCAL_AMFLAGS = -I m4
+include $(srcdir)/distcheck-hook-m4.am
+END
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+MY_FOO
+MY_BAR
+MY_BAZ
+END
+
+mkdir m4 acdir
+echo 'AC_DEFUN([MY_FOO], [:])' > m4/foo.m4
+echo 'AC_DEFUN([MY_BAR], [:])' > acdir/bar.m4
+cat > acdir/baz.m4 << 'END'
+# serial 1
+AC_DEFUN([MY_BAZ], [:])
+END
+
+ACLOCAL="$ACLOCAL --system-acdir=$cwd/acdir"; export ACLOCAL
+
+# The use of '--install' here won't help when the installed file '.m4'
+# will become out-of-date w.r.t. the one in the system acdir.
+$ACLOCAL -I m4 --install
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+$MAKE distcheck # Sanity check.
+
+check_no_spurious_error ()
+{
+ $EGREP -i 'mkdir:|:.*(permission|denied)' output && Exit 1
+ # On failure, some make implementations (such as Solaris make) print the
+ # whole failed recipe on stdout. The first grep works around this.
+ grep -v 'rm -rf ' output | grep -i 'autom4te.*\.cache' && Exit 1
+ : To placate 'set -e'.
+}
+
+# We start to use a new "third-party" macro in a new version
+# of a pre-existing third-party m4 file, but forget to re-run
+# "aclocal --install" by hand, relying on automatic remake
+# rules. Our distcheck-hook should catch this too.
+echo MY_ZARDOZ >> configure.ac
+
+cat > acdir/baz.m4 << 'END'
+# serial 2
+AC_DEFUN([MY_BAZ], [:])
+AC_DEFUN([MY_ZARDOZ], [:])
+END
+
+$MAKE # Rebuild configure and makefiles.
+$MAKE distcheck >output 2>&1 && { cat output; Exit 1; }
+cat output
+
+$EGREP "required m4 file.* outdated.* baz.m4( |$)" output
+check_no_spurious_error
+# Check that we don't complain for files that aren't outdated.
+$EGREP " (foo|bar).m4" output && Exit 1
+
+# Now we again use '--install' explicitly, and "make distcheck"
+# should pass.
+$ACLOCAL -I m4 --install
+using_gmake || $MAKE Makefile
+$MAKE distcheck
+
+# Similar to what have been done above, but this time we:
+# - use ACLOCAL_PATH, and
+# - do not add the use of a new macro.
+
+echo MY_FNORD >> configure.ac
+
+mkdir pth
+cat > pth/fnord.m4 << 'END'
+# serial 1
+AC_DEFUN([MY_FNORD], [:])
+END
+
+ACLOCAL_PATH="$cwd/pth"; export ACLOCAL_PATH
+
+# The explicit use of '--install' here won't help when the installed file
+# '.m4' will become out-of-date w.r.t. the one in the system acdir.
+$ACLOCAL -I m4 --install
+using_gmake || $MAKE Makefile
+$MAKE distcheck
+
+# Only increase serial number, without changing the other contents; this
+# is deliberate.
+cat > pth/fnord.m4 << 'END'
+# serial 2
+AC_DEFUN([MY_FNORD], [:])
+END
+
+$MAKE # Rebuild configure and makefiles.
+$MAKE distcheck >output 2>&1 && { cat output; Exit 1; }
+cat output
+$EGREP "required m4 file.* outdated.* fnord.m4( |$)" output
+check_no_spurious_error
+# Check that we don't complain for files that aren't outdated.
+$EGREP " (foo|bar|baz).m4" output && Exit 1
+
+# Now we again use '--install' explicitly, and "make distcheck"
+# should pass.
+$ACLOCAL -I m4 --install
+using_gmake || $MAKE Makefile
+$MAKE distcheck
+
+:
diff --git a/t/distcheck-override-infodir.sh b/t/distcheck-override-infodir.sh
new file mode 100755
index 000000000..746b5f859
--- /dev/null
+++ b/t/distcheck-override-infodir.sh
@@ -0,0 +1,61 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that we can override ${infodir} while having distcheck still
+# working. Related to automake bug#9579.
+
+required='makeinfo tex texi2dvi install-info'
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+infodir = ${prefix}/blah/blah/foobar
+info_TEXINFOS = main.texi
+## Sanity check.
+installcheck-local:
+ if test x$${infodir+set} != xset; then \
+ ls -l "$(DESTDIR)$(prefix)/blah/blah/foobar/" || exit 1; \
+ test -f "$(DESTDIR)$(prefix)/blah/blah/foobar/dir" || exit 1; \
+ else \
+ ls -l "$(DESTDIR)$$infodir/" || exit 1; \
+ test -f "$(DESTDIR)$$infodir/dir" || exit 1; \
+ fi
+END
+
+cat > main.texi << 'END'
+\input texinfo
+@setfilename main.info
+@settitle main
+@node Top
+Hello walls.
+@bye
+END
+
+$ACLOCAL
+$AUTOMAKE -a
+$AUTOCONF
+
+./configure
+$MAKE
+
+$MAKE distcheck
+infodir="`pwd`"/_info $MAKE -e distcheck
+test -f _info/dir || Exit 99 # Sanity check.
+
+:
diff --git a/t/distcheck-pr10470.sh b/t/distcheck-pr10470.sh
new file mode 100755
index 000000000..1b6a3226a
--- /dev/null
+++ b/t/distcheck-pr10470.sh
@@ -0,0 +1,59 @@
+#! /bin/sh
+# Copyright (C) 2012 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/>.
+
+# Ensure "make distcheck" does not experience racy failures on
+# systems (like MinGW/MSYS) that cannot remove a directory "in use"
+# by a process (e.g., that is its "current working directory").
+# See automake bug#10470.
+
+am_parallel_tests=no
+. ./defs || Exit 1
+
+mkdir foo.d
+sh -c "cd foo.d && sleep '4'" &
+# Without this sleep, the "rm -rf foo.d" below would reliably beat
+# the "cd foo.d" in the subshell above, and the test would be always
+# skipped, even on MinGW/MSYS.
+sleep '1'
+rm -rf foo.d && skip_ 'system is able to remove "in use" directories'
+
+echo AC_OUTPUT >> configure.ac
+
+cat > Makefile.am <<END
+TESTS = foo.test
+EXTRA_DIST= foo.test
+END
+
+cat > foo.test <<END
+#!/bin/sh
+sleep '4' &
+exit 0
+END
+chmod a+x foo.test
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+
+# We can build the distribution.
+$MAKE distcheck >output 2>&1 || { cat output; Exit 1; }
+cat output
+# Sanity check: verify that our code has hit a problem removing
+# the distdir, but has recovered from it.
+grep "rm:.*$destdir" output || fatal_ "expected code path not covered"
+
+:
diff --git a/t/distcheck-pr9579.sh b/t/distcheck-pr9579.sh
new file mode 100755
index 000000000..8c789001e
--- /dev/null
+++ b/t/distcheck-pr9579.sh
@@ -0,0 +1,96 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check against automake bug#9579: distcheck does not always detect
+# incomplete uninstall as advertised.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+# NOTE: the use of 'dir' as the name of the data file installed by hand
+# is deliberate, and enhances coverage -- see definition and comments of
+# lib/am/distdir.am:$(am__distuninstallcheck_listfiles).
+
+cat > Makefile.am << 'END'
+dist_data_DATA = foo
+EXTRA_DIST = dir
+install-data-local:
+ $(MKDIR_P) '$(DESTDIR)$(datadir)'
+ cp '$(srcdir)/dir' '$(DESTDIR)$(datadir)/dir'
+END
+
+: > foo
+: > dir
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+
+./configure --prefix="`pwd`/inst"
+
+# Sanity checks.
+$MAKE install
+find inst -type f
+test -f inst/share/foo
+test -f inst/share/dir
+# We expect the uninstall target of our Makefile to be definitely broken.
+$MAKE uninstall
+test -f inst/share/dir
+rm -rf inst
+
+$MAKE distcheck >output 2>&1 && { cat output; Exit 1; }
+cat output
+
+$FGREP 'ERROR: files left after uninstall:' output
+grep '/share/dir *$' output
+
+# A few trickier corner cases.
+
+cat > Makefile.am << 'END'
+EXTRA_DIST = dir
+install-data-local:
+install-data-local:
+ $(MKDIR_P) '$(DESTDIR)$(prefix)/mu/share/info'
+ cp '$(srcdir)/dir' '$(DESTDIR)$(prefix)/mu/share/info'
+ $(MKDIR_P) '$(DESTDIR)$(infodir)/more'
+ cp '$(srcdir)/dir' '$(DESTDIR)$(infodir)/more'
+END
+
+$AUTOMAKE
+./config.status Makefile
+
+# Sanity checks, again.
+$MAKE install
+find inst -type f
+test -f inst/mu/share/info/dir
+test -f inst/share/info/more/dir
+# We expect the uninstall target of our Makefile to be definitely broken.
+$MAKE uninstall
+test -f inst/mu/share/info/dir
+test -f inst/share/info/more/dir
+rm -rf inst
+
+$MAKE distcheck >output 2>&1 && { cat output; Exit 1; }
+cat output
+
+$FGREP 'ERROR: files left after uninstall:' output
+grep '/mu/share/info/dir *$' output
+grep '/share/info/more/dir *$' output
+
+:
diff --git a/t/distcheck-writable-srcdir.sh b/t/distcheck-writable-srcdir.sh
new file mode 100755
index 000000000..bbc50f461
--- /dev/null
+++ b/t/distcheck-writable-srcdir.sh
@@ -0,0 +1,48 @@
+#! /bin/sh
+# Copyright (C) 2012 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/>.
+
+# Check that the user abuse 'distcheck-hook' to ensure his packages
+# is built by "make distcheck" with a writable srcdir. This goes
+# against the GNU Coding Standards, but some package authors might
+# not care about them too much, and it's nice to support their use
+# case too (since it doesn't cost us anything but this test).
+# See automake bug#10878.
+
+. ./defs || Exit 1
+
+echo AC_OUTPUT >> configure.ac
+
+cat > Makefile.am <<'END'
+EXTRA_DIST = old
+distcheck-hook:
+ find $(distdir) -exec chmod u+w '{}' ';'
+check-local:
+ test -f $(srcdir)/old
+ test ! -f $(srcdir)/new
+ test ! -r $(srcdir)/new
+## Don't do this in real life, or I'll kill you.
+ echo foo > $(srcdir)/old
+ echo bar > $(srcdir)/new
+END
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+./configure
+: > old
+$MAKE distcheck
+
+:
diff --git a/t/distcleancheck.sh b/t/distcleancheck.sh
new file mode 100755
index 000000000..39197d721
--- /dev/null
+++ b/t/distcleancheck.sh
@@ -0,0 +1,71 @@
+#! /bin/sh
+# Copyright (C) 2008-2012 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 the suggested 'distcleancheck_listfiles' in the manual works.
+# The example Makefile.am we use is from the FAQ entry 'distcleancheck'.
+
+required=cc
+. ./defs || Exit 1
+
+cat >>configure.ac << 'END'
+AC_PROG_CC
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+# This Makefile.am is bogus. See @node{distcleancheck} in the manual
+# for how to fix it properly.
+bin_PROGRAMS = foo
+foo_SOURCES = foo.c
+dist_man_MANS = foo.1
+
+# We write './foo.1' inside the rule on purpose, to avoid VPATH rewriting
+# done by some 'make' implementations.
+foo.1: foo$(EXEEXT)
+ echo man page for foo$(EXEEXT) > ./foo.1
+
+## Ignore warnings about overridden variables
+AUTOMAKE_OPTIONS = -Wno-override
+distcleancheck_listfiles = \
+ find . -type f -exec sh -c 'test -f $(srcdir)/$$1 || echo $$1' \
+ sh '{}' ';'
+END
+
+cat >foo.c <<'END'
+int main () { return 0; }
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+$MAKE
+$MAKE distcheck
+
+# Now ensure that we really needed the override.
+sed '/distcleancheck_listfiles/,$d' Makefile.am > t
+mv -f t Makefile.am
+$AUTOMAKE
+./configure
+$MAKE
+$MAKE distcheck 2>stderr && { cat srderr >&2; Exit 1; }
+cat stderr >&2
+
+grep 'ERROR:.*files left in build directory after distclean' stderr
+grep '^\./foo\.1$' stderr
+
+:
diff --git a/t/distcom-subdir.sh b/t/distcom-subdir.sh
new file mode 100755
index 000000000..4da74d05c
--- /dev/null
+++ b/t/distcom-subdir.sh
@@ -0,0 +1,75 @@
+#! /bin/sh
+# Copyright (C) 2004-2012 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/>.
+
+# Test to make sure that if an auxfile (here depcomp) is required
+# by a subdir Makefile.am, it is distributed by that Makefile.am.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_CONFIG_FILES([subdir/Makefile])
+AC_PROG_CC
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+SUBDIRS = subdir
+END
+
+rm -f depcomp
+mkdir subdir
+
+: > subdir/Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+test ! -f depcomp
+
+cat > subdir/Makefile.am << 'END'
+bin_PROGRAMS = foo
+END
+
+: > subdir/foo.c
+
+$AUTOMAKE -a subdir/Makefile
+test -f depcomp
+
+# FIXME: the logic of this check and other similar ones in other
+# FIXME: 'distcom*.test' files should be factored out in a common
+# FIXME: subroutine in 'defs'...
+sed -n -e "
+ /^DIST_COMMON =.*\\\\$/ {
+ :loop
+ p
+ n
+ t clear
+ :clear
+ s/\\\\$/\\\\/
+ t loop
+ s/$/ /
+ s/[$tab ][$tab ]*/ /g
+ p
+ n
+ }" subdir/Makefile.in > dc.txt
+cat dc.txt
+$FGREP ' $(top_srcdir)/depcomp ' dc.txt
+
+./configure
+$MAKE distdir
+test -f $distdir/depcomp
+
+:
diff --git a/t/distcom2.sh b/t/distcom2.sh
new file mode 100755
index 000000000..4b86f928d
--- /dev/null
+++ b/t/distcom2.sh
@@ -0,0 +1,82 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test to make sure that depcomp and compile are added to DIST_COMMON.
+# Report from Pavel Roskin. Report of problems with '--no-force' from
+# Scott James Remnant (Debian #206299)
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_CONFIG_FILES([subdir/Makefile])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+SUBDIRS = subdir
+END
+
+mkdir subdir
+: > subdir/foo.c
+
+cat > subdir/Makefile.am << 'END'
+noinst_PROGRAMS = foo
+foo_SOURCES = foo.c
+foo_CFLAGS = -DBAR
+END
+
+$ACLOCAL
+
+for opt in '' --no-force; do
+
+ $AUTOMAKE $opt --add-missing
+
+ test -f compile
+ test -f depcomp
+
+ for dir in . subdir; do
+ # FIXME: the logic of this check and other similar ones in other
+ # FIXME: 'distcom*.test' files should be factored out in a common
+ # FIXME: subroutine in 'defs'...
+ sed -n -e "
+ /^DIST_COMMON =.*\\\\$/ {
+ :loop
+ p
+ n
+ t clear
+ :clear
+ s/\\\\$/\\\\/
+ t loop
+ s/$/ /
+ s/[$tab ][$tab ]*/ /g
+ p
+ n
+ }" $dir/Makefile.in > $dir/dc.txt
+ done
+
+ cat dc.txt # For debugging.
+ cat subdir/dc.txt # Likewise.
+
+ $FGREP ' $(top_srcdir)/depcomp ' subdir/dc.txt
+ # The 'compile' script will be listed in the DIST_COMMON of the top-level
+ # Makefile because it's required in configure.ac (by AM_PROG_CC_C_O).
+ $FGREP ' $(top_srcdir)/compile ' dc.txt || $FGREP ' compile ' dc.txt
+
+done
+
+:
diff --git a/t/distcom3.sh b/t/distcom3.sh
new file mode 100755
index 000000000..34ad7096e
--- /dev/null
+++ b/t/distcom3.sh
@@ -0,0 +1,57 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test to make sure that non-existing common files are distributed
+# if they are buildable.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+README:
+ echo 'I bet you are reading me.' > README
+END
+
+# Files required by '--gnu'.
+: > NEWS
+: > AUTHORS
+: > ChangeLog
+
+$ACLOCAL
+
+# Should not warn about missing README, since it is a target.
+$AUTOMAKE --add-missing --gnu >output 2>&1 || { cat output; Exit 1; }
+cat output
+grep README output && Exit 1
+
+sed -n -e '/^DIST_COMMON =.*\\$/ {
+ :loop
+ p
+ n
+ t clear
+ :clear
+ s/\\$/\\/
+ t loop
+ p
+ n
+ }' -e '/^DIST_COMMON =/ p' Makefile.in | grep README
+
+
+# Should warn about missing README.
+: > Makefile.am
+AUTOMAKE_fails --add-missing --gnu
+grep 'required file.*README.*not found' stderr
+
+:
diff --git a/t/distcom4.sh b/t/distcom4.sh
new file mode 100755
index 000000000..dc37fcf4f
--- /dev/null
+++ b/t/distcom4.sh
@@ -0,0 +1,77 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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/>.
+
+# Test to make sure config files are distributed, and only once.
+# This tries to distribute a file from a subdirectory, without
+# Makefile in that directory. distcom5.test performs the same
+# test with a Makefile in the directory.
+# Also make sure that README appears first in DIST_COMMON.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+ AC_CONFIG_FILES([tests/autoconf:tests/wrapper.in],
+ [chmod +x tests/autoconf])
+ AC_CONFIG_FILES([tests/autoheader:tests/wrapper.in],
+ [chmod +x tests/autoheader])
+ AC_CONFIG_FILES([tests/autom4te:tests/wrapper.in],
+ [chmod +x tests/autom4te])
+ AC_CONFIG_FILES([tests/autoreconf:tests/wrapper.in],
+ [chmod +x tests/autoreconf])
+ AC_CONFIG_FILES([tests/autoscan:tests/wrapper.in],
+ [chmod +x tests/autoscan])
+ AC_CONFIG_FILES([tests/autoupdate:tests/wrapper.in],
+ [chmod +x tests/autoupdate])
+ AC_CONFIG_FILES([tests/ifnames:tests/wrapper.in],
+ [chmod +x tests/ifnames])
+ AC_OUTPUT
+END
+
+mkdir tests
+: > README
+: > tests/wrapper.in
+cat > Makefile.am << 'END'
+.PHONY: test
+test: distdir
+ test -f $(distdir)/tests/wrapper.in
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+./configure
+$MAKE test
+
+sed -n -e '/^DIST_COMMON =.*\\$/ {
+ :loop
+ p
+ n
+ t clear
+ :clear
+ s/\\$/\\/
+ t loop
+ p
+ n
+ }' -e '/^DIST_COMMON =/ p' Makefile.in > dc.txt
+
+cat dc.txt # For debugging.
+
+test 1 = `grep tests dc.txt | wc -l`
+grep configure dc.txt
+# README must come first.
+grep 'DIST_COMMON = README' Makefile.in
+
+:
diff --git a/t/distcom5.sh b/t/distcom5.sh
new file mode 100755
index 000000000..adfbe52d1
--- /dev/null
+++ b/t/distcom5.sh
@@ -0,0 +1,84 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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/>.
+
+# Test to make sure config files are distributed, and only once.
+# This tries to distribute a file from a subdirectory, with
+# a Makefile in that directory. distcom4.test performs the same
+# test without Makefile in the directory.
+
+. ./defs || Exit 1
+
+extract_distcommon ()
+{
+ sed -n -e '/^DIST_COMMON =.*\\$/ {
+ :loop
+ p
+ n
+ t clear
+ :clear
+ s/\\$/\\/
+ t loop
+ p
+ n
+ }' -e '/^DIST_COMMON =/ p' ${1+"$@"}
+}
+
+cat >> configure.ac << 'END'
+ AC_CONFIG_FILES([tests/autoconf:tests/wrapper.in],
+ [chmod +x tests/autoconf])
+ AC_CONFIG_FILES([tests/autoheader:tests/wrapper.in],
+ [chmod +x tests/autoheader])
+ AC_CONFIG_FILES([tests/autom4te:tests/wrapper.in],
+ [chmod +x tests/autom4te])
+ AC_CONFIG_FILES([tests/autoreconf:tests/wrapper.in],
+ [chmod +x tests/autoreconf])
+ AC_CONFIG_FILES([tests/autoscan:tests/wrapper.in],
+ [chmod +x tests/autoscan])
+ AC_CONFIG_FILES([tests/autoupdate:tests/wrapper.in],
+ [chmod +x tests/autoupdate])
+ AC_CONFIG_FILES([tests/ifnames:tests/wrapper.in],
+ [chmod +x tests/ifnames])
+ AC_CONFIG_FILES([tests/Makefile])
+ AC_OUTPUT
+END
+
+mkdir tests
+: > tests/wrapper.in
+: > tests/Makefile.am
+cat > Makefile.am << 'END'
+SUBDIRS = tests
+.PHONY: test
+test: distdir
+ test -f $(distdir)/tests/wrapper.in
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+./configure
+$MAKE test
+
+extract_distcommon Makefile.in > top.txt
+extract_distcommon tests/Makefile.in > inner.txt
+
+# Might be useful for debugging.
+cat top.txt
+cat inner.txt
+
+test 0 = `grep tests top.txt | wc -l`
+test 1 = `grep wrapper inner.txt | wc -l`
+
+:
diff --git a/t/distdir.sh b/t/distdir.sh
new file mode 100755
index 000000000..0657928dc
--- /dev/null
+++ b/t/distdir.sh
@@ -0,0 +1,82 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test to make sure subdirs in EXTRA_DIST work. Also tests to make
+# sure *srcdir is properly handled. Note that using './', as in
+# EXTRA_DIST = ./joe
+# does not work portably: it fails with HP-UX and Tru64 make.
+# Also test DISTFILES containing a directory and a file in it,
+# and repeated directories.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+include_HEADERS = some/file another/sub/subsub/file2 yet/another/file3
+EXTRA_DIST = foo/bar joe $(top_srcdir)/woo/doo $(srcdir)/dada \
+ some another/sub yet \
+ some another/sub yet
+
+
+all-local:
+ $(MKDIR_P) another/sub/subsub
+ touch another/sub/subsub/file2
+
+CLEANFILES = another/sub/subsub/file2
+
+check-local:
+ test -f $(srcdir)/foo/bar
+ test -f $(srcdir)/woo/doo
+ test -f $(srcdir)/joe
+ test -f $(srcdir)/dada
+ test -f $(srcdir)/some/file
+ test -f $(srcdir)/another/sub/subsub/file2 \
+ || test -f /another/sub/subsub/file2
+ test -f $(srcdir)/yet/another/file3
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+mkdir foo woo some another another/sub another/sub/subsub yet yet/another
+touch foo/bar joe woo/doo dada some/file another/sub/subsub/file2
+touch yet/another/file3
+
+mkdir build
+cd build
+../configure
+$MAKE distdir
+# Check to make sure 'foo' isn't made in build directory.
+test -d foo && Exit 1
+
+rm -rf $me-1.0
+# Remove the dot from VERSION for the next grep.
+VERSION=10 MKDIR_P='echo MKDIR_P' $MAKE -e distdir >stdout || :
+cat stdout
+
+# Make sure no './' appear in the directory names. srcdir is '..', so
+# this also checks that no directory is created in the source tree.
+grep 'MKDIR_P.*\.' stdout && Exit 1
+
+cd ..
+./configure --prefix "`pwd`"
+$MAKE distcheck
+
+:
diff --git a/t/disthook.sh b/t/disthook.sh
new file mode 100755
index 000000000..9804e9942
--- /dev/null
+++ b/t/disthook.sh
@@ -0,0 +1,89 @@
+#! /bin/sh
+# Copyright (C) 2012 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/>.
+
+# Check that 'dist-hook' works. See automake bug#10878.
+
+. ./defs || Exit 1
+
+echo AC_OUTPUT >> configure.ac
+
+cat > Makefile.am <<'END'
+EXTRA_DIST = write execute removed doc
+
+removed:
+ echo I will be deleted > $@
+DISTCLEANFILES = removed
+
+dist-hook:
+ chmod u+w $(distdir)/write $(distdir)/doc
+ chmod u+x $(distdir)/execute
+ rm -f $(distdir)/removed
+ rm -f $(distdir)/doc/HACKING
+ rm -f $(distdir)/doc/RELEASE-DATE
+ date > $(distdir)/doc/RELEASE-DATE
+ echo all is ok > $(distdir)/write
+
+check-local:
+ ls -l $(srcdir) $(srcdir)/doc
+ test "`cat $(srcdir)/write`" = "all is ok"
+ test -f $(srcdir)/doc/README
+ test -f $(srcdir)/doc/RELEASE-DATE
+ test ! -f $(srcdir)/removed
+ test ! -r $(srcdir)/removed
+ test ! -f $(srcdir)/doc/HACKING
+ test ! -r $(srcdir)/doc/HACKING
+ $(srcdir)/execute
+ $(srcdir)/execute | grep 'I run successfully'
+## Sanity check.
+ echo ok > $(srcdir)/../distcheck-run
+END
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+
+./configure
+mkdir doc
+: > doc/README
+: > doc/HACKING
+echo will be clobbered > write
+cat > execute <<'END'
+#!/bin/sh
+echo I run successfully
+END
+
+chmod a-w write
+chmod a-x execute
+
+$MAKE distdir
+ls -l $distdir $distdir/doc
+cd $distdir
+test "`cat write`" = "all is ok"
+test ! -f removed
+test ! -r removed
+test -f doc/README
+test -f doc/RELEASE-DATE
+test ! -f doc/HACING
+test ! -r doc/HACING
+./execute
+./execute | grep 'I run successfully'
+cd ..
+
+
+$MAKE distcheck
+test -f distcheck-run
+
+:
diff --git a/t/distlinks.sh b/t/distlinks.sh
new file mode 100755
index 000000000..08244c06e
--- /dev/null
+++ b/t/distlinks.sh
@@ -0,0 +1,72 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Check that distributed symlinks in the source tree will be expanded
+# as regular files in $(distdir).
+
+. ./defs || Exit 1
+
+echo text > file
+
+ln -s file lnk || skip_ "cannot create symlinks to files"
+
+mkdir A
+mkdir B
+echo aaa > A/aaa
+cd B
+ln -s ../A/aaa bbb
+cd ..
+
+echo FooBarBaz > foo
+
+ln -s foo bar1
+ln -s bar1 bar2
+ln -s bar2 bar3
+
+ln -s "`pwd`/foo" quux
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+echo "me = $me" > Makefile.am # For better failure messages.
+cat >> Makefile.am << 'END'
+EXTRA_DIST = lnk B/bbb bar1 bar2 bar3 quux
+.PHONY: test
+test: distdir
+ ls -l $(distdir) $(distdir)/B
+ fail() { echo "$(me): $$*" >&2; e=1; }; \
+ e=0; \
+ set file lnk A/aaa B/bbb foo quux foo bar1 foo bar2 foo bar3; \
+ while test $$# -ge 2; do \
+ file=$$1; shift; link=$(distdir)/$$1; shift; \
+ test -f $$link || fail "$$link is not a regular file"; \
+ test ! -h $$link || fail "$$link is a symlink"; \
+ diff $$file $$link || fail "$$link differs from $$file"; \
+ done; \
+ exit $$e;
+END
+
+ls -l . A B
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+$MAKE test
+
+:
diff --git a/t/distlinksbrk.sh b/t/distlinksbrk.sh
new file mode 100755
index 000000000..b7732ca63
--- /dev/null
+++ b/t/distlinksbrk.sh
@@ -0,0 +1,68 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Check that distributed broken symlinks cause 'make dist' to fail, and
+# to do so with (mostly) meaningful diagnostic.
+
+. ./defs || Exit 1
+
+# We need, for our broken symlinks, names that make it hard to get false
+# positives when grepping make output to look for them.
+lnk_base=BrknSymlnk
+lnk1=${lnk_base}__001
+lnk2=${lnk_base}__002
+lnka=${lnk_base}__aaa
+lnkb=${lnk_base}__bbb
+
+ln -s nonesuch $lnk1 || skip_ "cannot create broken symlinks"
+
+ln -s "`pwd`/nonesuch" $lnk2
+
+ln -s $lnk1 $lnka
+ln -s $lnka $lnkb
+
+# Sanity checks. Use 'test -r', since Solaris Sh doesn't grok 'test -e'.
+test ! -r $lnk1
+test ! -r $lnk2
+test ! -r $lnka
+test ! -r $lnkb
+test -h $lnk1
+test -h $lnk2
+test -h $lnka
+test -h $lnkb
+
+cat >> configure.ac <<'END'
+AC_OUTPUT
+END
+
+$ACLOCAL
+$AUTOCONF
+
+ls -l # For debugging.
+
+# Don't try to use "make -k", because some botched make implementations
+# (HP-UX, IRIX) might still exit on the first error in this situations.
+for lnk in $lnk1 $lnk2 $lnka $lnkb; do
+ echo "EXTRA_DIST = $lnk" > Makefile.am
+ $AUTOMAKE
+ ./configure
+ # Distribution must fail, with a decent error message.
+ $MAKE distdir >out 2>&1 && { cat out; Exit 1; }
+ cat out
+ $FGREP $lnk out
+done
+
+:
diff --git a/t/distname.sh b/t/distname.sh
new file mode 100755
index 000000000..0ef3cdb4c
--- /dev/null
+++ b/t/distname.sh
@@ -0,0 +1,47 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test of names in tar file.
+# From Rainer Orth.
+
+required=cc
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_CONFIG_SRCDIR([a.c])
+AC_PROG_CC
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = wish
+wish_SOURCES = a.c
+END
+
+: > a.c
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --include-deps --copy --add-missing
+./configure
+$MAKE dist
+
+gzip -d $me-1.0.tar.gz
+tar tf $me-1.0.tar > stdout || { cat stdout; Exit 1; }
+cat stdout
+$FGREP ./$me-1.0/a.c stdout && Exit 1
+
+:
diff --git a/t/dmalloc.sh b/t/dmalloc.sh
new file mode 100755
index 000000000..2bf6a7c49
--- /dev/null
+++ b/t/dmalloc.sh
@@ -0,0 +1,59 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Simple checks on the 'AM_WITH_DMALLOC' macro.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_CONFIG_HEADERS([config.h])
+AM_WITH_DMALLOC
+AC_SUBST([LDFLAGS])
+AC_OUTPUT
+END
+
+cat > config.h.in <<'END'
+#undef WITH_DMALLOC
+END
+
+cat > Makefile.am <<'END'
+check-with-dmalloc:
+## The AM_WITH_DMALLOC assumes that the user is a developer, so that
+## he is expected to install and make available the 'dmalloc' library
+## by his own. So we just check that proper linker and libs flags get
+## added.
+ echo ' ' $(LDFLAGS) ' ' | grep ' -g '
+ echo ' ' $(LIBS) ' ' | grep ' -ldmalloc '
+END
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+
+./configure
+cat config.h # For debugging.
+grep '^ */\* *# *undef *WITH_DMALLOC *\*/ *$' config.h
+
+./configure --without-dmalloc
+cat config.h # For debugging.
+grep '^ */\* *# *undef *WITH_DMALLOC *\*/ *$' config.h
+
+./configure --with-dmalloc
+cat config.h # For debugging.
+grep '^# *define *WITH_DMALLOC *1 *$' config.h
+$MAKE check-with-dmalloc
+
+:
diff --git a/t/doc-parsing-buglets-colneq-subst.sh b/t/doc-parsing-buglets-colneq-subst.sh
new file mode 100755
index 000000000..8ff27f1e7
--- /dev/null
+++ b/t/doc-parsing-buglets-colneq-subst.sh
@@ -0,0 +1,37 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check a documented limitation of the Automake's Makefile parser
+# w.r.t. POSIX variable substitutions used in the name of targets.
+# See Section "General Operation" in the Automake manual.
+# If you cause some parts of this test to fail, chances are that you've
+# improved the Automake parser ;-)
+# See: <http://lists.gnu.org/archive/html/automake/2010-08/msg00074.html>
+# or: <http://thread.gmane.org/gmane.comp.sysutils.automake.general/11943/focus=11962>
+
+. ./defs || Exit 1
+
+cat > Makefile.am <<'END'
+$(FOO:=x): bar
+END
+
+$ACLOCAL
+AUTOMAKE_fails
+
+grep 'bad characters.*variable name.*\$(FOO' stderr
+grep ':=.*assignments.*not portable' stderr
+
+:
diff --git a/t/doc-parsing-buglets-tabs.sh b/t/doc-parsing-buglets-tabs.sh
new file mode 100755
index 000000000..22c981c63
--- /dev/null
+++ b/t/doc-parsing-buglets-tabs.sh
@@ -0,0 +1,59 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check the documented limitation of the Automake's Makefile parser w.r.t.
+# use of TAB characters; see Section "General Operation" in the Automake
+# manual, and automake bug#8360.
+# If you cause some parts of this test to fail, chances are that you've
+# improved the Automake parser ;-)
+
+. ./defs || Exit 1
+
+cat > Makefile.am <<END
+.PHONY: test
+test: all check
+
+fail:
+${tab}@echo "'\$@ recipe executed'"; exit 1
+
+## This won't be recognized as a target+recipe by Automake.
+all-local${tab}:
+${tab}@exit 1
+
+## This won't be recognized as a target+rdependency by Automake.
+all-local${tab}: fail
+
+just_to_separate: dummy deps
+
+## This won't be recognized as a variable assignment by Automake.
+${tab}bin_PROGRAMS = foo
+END
+
+echo AC_OUTPUT >> configure.ac
+
+$ACLOCAL
+$AUTOMAKE
+
+$FGREP '$(EXEEEXT)' Makefile.in && Exit 1
+grep 'all:.*all-local' Makefile.in && Exit 1
+grep "^${tab}bin_PROGRAMS = foo" Makefile.in
+
+$AUTOCONF
+./configure
+
+$MAKE test
+
+:
diff --git a/t/dollar.sh b/t/dollar.sh
new file mode 100755
index 000000000..92ed26a94
--- /dev/null
+++ b/t/dollar.sh
@@ -0,0 +1,44 @@
+#!/bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# We should support files with '$' characters in their names.
+# Java people need this.
+# PR/317, reported by Eric Siegerman and Philip Fong.
+
+# Require GNU make for this test. SunOS Make does not support
+# '$$' in a target or a dependency (it outputs the empty string instead).
+required=GNUmake
+. ./defs || Exit 1
+
+echo AC_OUTPUT >> configure.ac
+
+cat > Makefile.am <<'EOF'
+mydir = $(prefix)/my
+dist_my_DATA = hello$$world
+
+check-dist: distdir
+ test -f '$(distdir)/hello$$world'
+EOF
+
+: > 'hello$world'
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure --prefix "`pwd`/inst"
+$MAKE install
+test -f 'inst/my/hello$world'
+$MAKE check-dist
diff --git a/t/dollarvar.sh b/t/dollarvar.sh
new file mode 100755
index 000000000..940ef23db
--- /dev/null
+++ b/t/dollarvar.sh
@@ -0,0 +1,63 @@
+#!/bin/sh
+# Copyright (C) 2009-2012 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/>.
+
+# Test to make sure that -Wportability complains about recursive
+# variable expansions and variables containing '$', '$(...)', or
+# '${...}' in the name. We support recursive variable expansions using
+# the latter two constructs for the 'silent-rules' option, and they are
+# rather widely supported in practice. OTOH variable definitions
+# containing a '$' on the left hand side of an assignment are not
+# portable in practice, even though POSIX allows them. :-/
+
+. ./defs || Exit 1
+
+cat >Makefile.am <<'EOF'
+x = 1
+foo$x = 1
+bar$(x) = 1
+baz${x} = 1
+bla = $(foo$x)
+bli = $(foo$(x))
+blo = $(foo${x})
+EOF
+
+$ACLOCAL
+AUTOMAKE_fails -Wportability
+grep 'Makefile.am:2' stderr
+grep 'Makefile.am:3' stderr
+grep 'Makefile.am:4' stderr
+grep 'Makefile.am:5' stderr
+grep 'Makefile.am:6' stderr
+grep 'Makefile.am:7' stderr
+
+# On the other hand, if we allow 'silent-rules' mode, then we need to
+# allow recursive variable expansion, too.
+
+# This should work with the AM_SILENT_RULES macro.
+$sleep
+echo 'AM_SILENT_RULES' >> configure.ac
+
+$ACLOCAL --force
+AUTOMAKE_fails -Wportability
+grep 'Makefile.am:2' stderr
+grep 'Makefile.am:3' stderr
+grep 'Makefile.am:4' stderr
+grep 'Makefile.am:5' stderr
+grep 'Makefile.am:6' stderr && Exit 1
+grep 'Makefile.am:7' stderr && Exit 1
+
+
+:
diff --git a/t/dollarvar2.sh b/t/dollarvar2.sh
new file mode 100755
index 000000000..cef85bb96
--- /dev/null
+++ b/t/dollarvar2.sh
@@ -0,0 +1,91 @@
+#!/bin/sh
+# Copyright (C) 2009-2012 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/>.
+
+# Test to make sure that -Wportability turns on portability-recursive,
+# likewise for -Wno-...
+
+. ./defs || Exit 1
+
+#
+# First, try a setup where we have a 'portability-recursive' warning,
+# but no "simple" 'portability' warning.
+#
+
+cat >Makefile.am <<'EOF'
+x = 1
+bla = $(foo$(x))
+EOF
+
+$ACLOCAL
+
+# Enabling 'portability' warnings should enable 'portability-recursive'
+# warnings.
+AUTOMAKE_fails -Wnone -Wportability
+grep 'recursive variable expansion' stderr
+# 'portability-recursive' warnings can be enabled by themselves.
+AUTOMAKE_fails -Wnone -Wportability-recursive
+grep 'recursive variable expansion' stderr
+
+# Various ways to disable 'portability-recursive'.
+$AUTOMAKE -Wno-all
+$AUTOMAKE -Wno-portability
+$AUTOMAKE -Wall -Wno-portability-recursive
+
+# '-Wno-portability-recursive' after '-Wportability' correctly disables
+# 'portability-recursive' warnings.
+$AUTOMAKE -Wportability -Wno-portability-recursive
+
+# '-Wno-portability' disables 'portability-recursive' warnings; but
+# a later '-Wportability-recursive' re-enables them. This time, we
+# use AUTOMAKE_OPTIONS to specify the warning levels.
+echo 'AUTOMAKE_OPTIONS = -Wno-portability' >> Makefile.am
+$AUTOMAKE
+echo 'AUTOMAKE_OPTIONS += -Wportability-recursive' >> Makefile.am
+AUTOMAKE_fails
+grep 'recursive variable expansion' stderr
+
+#
+# Now try a setup where we have both a 'portability' warning and
+# a 'portability-recursive' one.
+#
+
+cat >Makefile.am <<'EOF'
+x = 1
+bla = $(foo$(x))
+noinst_PROGRAMS = foo
+foo_CPPFLAGS = -Dwhatever
+EOF
+
+echo AC_PROG_CC >> configure.ac
+
+$ACLOCAL --force
+
+# Can disable both 'portability' and 'portability-recursive' warnings.
+$AUTOMAKE -Wno-portability
+
+# Disabling 'portability-recursive' warnings should not disable
+# 'portability' warnings.
+AUTOMAKE_fails -Wportability -Wno-portability-recursive
+grep AM_PROG_CC_C_O stderr
+grep 'recursive variable expansion' stderr && Exit 1
+
+# Enabling 'portability-recursive' warnings should not enable
+# all the 'portability' warning.
+AUTOMAKE_fails -Wno-portability -Wportability-recursive
+grep AM_PROG_CC_C_O stderr && Exit 1
+grep 'recursive variable expansion' stderr
+
+:
diff --git a/t/double.sh b/t/double.sh
new file mode 100755
index 000000000..7f353b799
--- /dev/null
+++ b/t/double.sh
@@ -0,0 +1,29 @@
+#! /bin/sh
+# Copyright (C) 1999-2012 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/>.
+
+# Test to make sure listing a program twice is ok.
+# Report from Manu Rouat.
+
+. ./defs || Exit 1
+
+echo AC_PROG_CC >> configure.ac
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = spice nutmeg help sconvert multidec nutmeg
+END
+
+$ACLOCAL
+$AUTOMAKE
diff --git a/t/dup2.sh b/t/dup2.sh
new file mode 100755
index 000000000..d40582839
--- /dev/null
+++ b/t/dup2.sh
@@ -0,0 +1,29 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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 aclocal only warns about definitions overridden by acinclude.m4.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AM_FUNC_STRTOD
+END
+
+cat > acinclude.m4 << 'END'
+AC_DEFUN([AM_FUNC_STRTOD])
+END
+
+$ACLOCAL
diff --git a/t/else.sh b/t/else.sh
new file mode 100755
index 000000000..74d21586b
--- /dev/null
+++ b/t/else.sh
@@ -0,0 +1,38 @@
+#! /bin/sh
+# Copyright (C) 1998-2012 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/>.
+
+# Test to make sure line numbers are correct in some error reports.
+
+. ./defs || Exit 1
+
+echo 'AM_CONDITIONAL(FOO, true)' >> configure.ac
+
+cat > Makefile.am << 'END'
+# Flag to tell us if apache dir is a source distribution.
+APACHE_DIR_IS_SRC = @APACHE_DIR_IS_SRC@
+
+# We only need to descend into the c dir if we're doing a 1.3 DSO
+# configuration.
+ifeq ("${APACHE_DIR_IS_SRC}","yes")
+SUBDIRS = java
+else
+SUBDIRS = c java
+endif
+END
+
+$ACLOCAL
+AUTOMAKE_fails
+grep '^Makefile\.am:8:.*else without if' stderr
diff --git a/t/empty.sh b/t/empty.sh
new file mode 100755
index 000000000..795f92226
--- /dev/null
+++ b/t/empty.sh
@@ -0,0 +1,29 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test for bug where if the list of installables is empty, invalid sh
+# code is generated.
+
+. ./defs || Exit 1
+
+echo AC_OUTPUT >>configure.ac
+echo 'data_DATA =' >Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure --prefix "`pwd`/inst"
+$MAKE install
diff --git a/t/empty2.sh b/t/empty2.sh
new file mode 100755
index 000000000..7d1242301
--- /dev/null
+++ b/t/empty2.sh
@@ -0,0 +1,35 @@
+#! /bin/sh
+# Copyright (C) 1999-2012 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/>.
+
+# Test to make sure empty _SOURCES suppresses assumption about default
+# name. Report from Pavel Roskin.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = pavel
+pavel_SOURCES =
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+grep 'pavel\.[co]' Makefile.in && Exit 1
+Exit 0
diff --git a/t/empty3.sh b/t/empty3.sh
new file mode 100755
index 000000000..6aabfbaa9
--- /dev/null
+++ b/t/empty3.sh
@@ -0,0 +1,32 @@
+#! /bin/sh
+# Copyright (C) 1999-2012 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/>.
+
+# A test for missing _SOURCES variable.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = pavel
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+grep 'pavel\.[co]' Makefile.in
diff --git a/t/empty4.sh b/t/empty4.sh
new file mode 100755
index 000000000..810642607
--- /dev/null
+++ b/t/empty4.sh
@@ -0,0 +1,38 @@
+#! /bin/sh
+# Copyright (C) 1999-2012 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/>.
+
+# Test to make sure empty _SOURCES works.
+# From Paul Berrevoets.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_SUBST(ZOO_OBJ)
+END
+
+cat > Makefile.am << 'END'
+noinst_PROGRAMS = zoo
+zoo_SOURCES =
+EXTRA_zoo_SOURCES = bar.c foo.c
+zoo_DEPENDENCIES = $(ZOO_OBJ)
+zoo_LDADD = $(zoo_DEPENDENCIES)
+END
+
+$ACLOCAL
+$AUTOMAKE
+$FGREP zoo. Makefile.in && Exit 1
+Exit 0
diff --git a/t/exdir.sh b/t/exdir.sh
new file mode 100755
index 000000000..6e048d23f
--- /dev/null
+++ b/t/exdir.sh
@@ -0,0 +1,30 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Check to make sure new extended directory mechanism works.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'EOF'
+htmldir = $(prefix)/html
+html_DATA = zot.html
+pkgdata_DATA = qbert
+EOF
+
+$ACLOCAL
+$AUTOMAKE
+
+grep '^DATA' Makefile.in | grep html
diff --git a/t/exdir2.sh b/t/exdir2.sh
new file mode 100755
index 000000000..ddaac5830
--- /dev/null
+++ b/t/exdir2.sh
@@ -0,0 +1,29 @@
+#! /bin/sh
+# Copyright (C) 1998-2012 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/>.
+
+# Test to make sure undefined directories are invalid.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'EOF'
+quuz_DATA = zot.html
+pkgdata_DATA = qbert
+EOF
+
+$ACLOCAL
+AUTOMAKE_fails
+grep 'pkgdatadir' stderr && Exit 1
+grep 'Makefile.am:1:.*quuzdir.*undefined' stderr
diff --git a/t/exdir3.sh b/t/exdir3.sh
new file mode 100755
index 000000000..672548c44
--- /dev/null
+++ b/t/exdir3.sh
@@ -0,0 +1,35 @@
+#! /bin/sh
+# Copyright (C) 2007-2012 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/>.
+
+# Test to make sure pkgdatadir can be overridden via AC_SUBST.
+
+. ./defs || Exit 1
+
+cat >>configure.ac <<'EOF'
+AC_SUBST([pkgdatadir], ["FOO"])
+AC_OUTPUT
+EOF
+
+cat > Makefile.am << 'EOF'
+showme:
+ @echo $(pkgdatadir)
+EOF
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+$MAKE showme | grep FOO
diff --git a/t/exeext.sh b/t/exeext.sh
new file mode 100755
index 000000000..42fa57497
--- /dev/null
+++ b/t/exeext.sh
@@ -0,0 +1,88 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test to make sure '.' in an exe name doesn't fool us.
+# Report from Robert Collins.
+# Also make sure we rewrite conditionals variables.
+# Also check for PR/352.
+# Also make sure the old definitions of bin_PROGRAMS and friend
+# aren't left around. Report from Jim Meyering.
+
+required=cc
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_CONDITIONAL([WANT_MT], [test -z "$revert"])
+AM_CONDITIONAL([WANT_RMT], [test -z "$revert"])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+## Use a different dir for each to make grep easy.
+bin_PROGRAMS = maude
+sbin_PROGRAMS = maude.static
+## We don't define this one for now. Probably it is an error.
+## noinst_PROGRAMS = maude2.exe
+check_PROGRAMS = maude3$(EXEEXT)
+
+if WANT_MT
+ bin_PROGRAMS += mt
+endif
+if WANT_RMT
+ libexec_PROGRAMS = rmt
+endif
+
+print:
+ @echo 1BEG: $(bin_PROGRAMS) :END1
+ @echo 2BEG: $(sbin_PROGRAMS) :END2
+ @echo 3BEG: $(check_PROGRAMS) :END3
+ @echo 4BEG: $(libexec_PROGRAMS) :END4
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+grep '^maude$(EXEEXT):' Makefile.in
+grep '^maude\.static$(EXEEXT):' Makefile.in
+grep '^maude3$(EXEEXT):' Makefile.in
+grep '^mt$(EXEEXT):' Makefile.in
+grep '^rmt$(EXEEXT):' Makefile.in
+test `grep '^bin_PROGRAMS =' Makefile.in | wc -l` = 1
+
+# Make sure $(EXEEXT) gets stripped before canonicalization.
+grep 'maude3__EXEEXT__OBJECTS' Makefile.in && Exit 1
+
+./configure
+
+EXEEXT=.foo $MAKE -e print > stdout
+cat stdout
+
+grep '1BEG: maude.foo mt.foo :END1' stdout
+grep '2BEG: maude.static.foo :END2' stdout
+grep '3BEG: maude3.foo :END3' stdout
+grep '4BEG: rmt.foo :END4' stdout
+
+./configure revert=yes
+
+EXEEXT=.foo $MAKE -e print > stdout
+cat stdout
+
+grep '1BEG: maude.foo :END1' stdout
+grep '2BEG: maude.static.foo :END2' stdout
+grep '3BEG: maude3.foo :END3' stdout
+grep '4BEG: :END4' stdout
diff --git a/t/exeext2.sh b/t/exeext2.sh
new file mode 100755
index 000000000..3315ad8db
--- /dev/null
+++ b/t/exeext2.sh
@@ -0,0 +1,43 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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 no-exeext option works.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = maude
+
+maude:
+ yeah
+END
+
+$ACLOCAL
+
+$AUTOMAKE -Wnone
+AUTOMAKE_fails -Wnone -Wobsolete
+grep 'deprecated.*maude' stderr
+AUTOMAKE_fails -Wall
+grep 'deprecated.*maude' stderr
+grep 'overrid.*maude' stderr
+
+echo 'AUTOMAKE_OPTIONS = no-exeext' >> Makefile.am
+
+$AUTOMAKE -Wall -Wno-override
diff --git a/t/exeext3.sh b/t/exeext3.sh
new file mode 100755
index 000000000..1bc1a1022
--- /dev/null
+++ b/t/exeext3.sh
@@ -0,0 +1,41 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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 we can override a program rule.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = maude 3dldf
+
+maude$(EXEEXT):
+ yeah
+
+3dldf$(EXEEXT):
+ yippie
+END
+
+$ACLOCAL
+$AUTOMAKE -Wno-override
+
+$FGREP 'maude$(EXEEXT):' Makefile.in
+test 1 = `grep 'maude.*:' Makefile.in | wc -l`
+$FGREP '3dldf$(EXEEXT):' Makefile.in
+test 1 = `grep '3dldf.*:' Makefile.in | wc -l`
diff --git a/t/exeext4.sh b/t/exeext4.sh
new file mode 100755
index 000000000..298879dee
--- /dev/null
+++ b/t/exeext4.sh
@@ -0,0 +1,69 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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 $(EXEEXT) is appended to programs and to tests that are
+# programs, but not to @substitutions@.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AM_CONDITIONAL([COND], [test -n "$cond"])
+AC_SUBST([programs], ['prg1$(EXEEXT) prg2$(EXEEXT)'])
+AC_SUBST([CC], [whocares])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = no-dependencies
+EXEEXT = .x
+if COND
+ BAR = bar
+ DEP = bar
+ BAZE = baz$(EXEEXT)
+ BAZ = baz $(DEP)
+endif
+bin_PROGRAMS = $(programs) @programs@ prg3 $(BAR) $(BAZE)
+EXTRA_PROGRAMS = prg1 prg2 prg3
+TESTS = prg1 prg3 prg4 $(BAZ)
+
+.PHONY: test-cond test-nocond
+test-nocond:
+ is $(bin_PROGRAMS) == prg1.x prg2.x prg1.x prg2.x prg3.x
+ is $(EXTRA_PROGRAMS) == prg1.x prg2.x prg3.x
+ is $(TESTS) == prg1.x prg3.x prg4
+test-cond:
+ is $(bin_PROGRAMS) == prg1.x prg2.x prg1.x prg2.x prg3.x bar.x baz.x
+ is $(EXTRA_PROGRAMS) == prg1.x prg2.x prg3.x
+ is $(TESTS) == prg1.x prg3.x prg4 baz.x bar.x
+ is $(BAR) $(BAZ) == bar baz bar
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing --copy
+
+./configure
+$MAKE test-nocond
+
+./configure cond=yes
+$MAKE test-cond
+
+# Only two am__EXEEXT_* variables are needed here: one for BAR, and one
+# BAZ. The latter must use the former.
+test 2 = `grep '__EXEEXT_. =' Makefile.in | wc -l`
+grep 'am__EXEEXT_2 = .*am__EXEEXT_1' Makefile.in
+
+:
diff --git a/t/exsource.sh b/t/exsource.sh
new file mode 100755
index 000000000..15b274f07
--- /dev/null
+++ b/t/exsource.sh
@@ -0,0 +1,37 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test to make sure EXTRA_..._SOURCES actually works.
+# Bug report from Henrik Frystyk Nielsen.
+
+. ./defs || Exit 1
+
+echo AC_PROG_CC >> configure.ac
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = www
+www_SOURCES = www.c
+EXTRA_www_SOURCES = xtra.c
+www_LDADD = @extra_stuff@
+END
+
+: > www.c
+: > xtra.c
+
+$ACLOCAL
+$AUTOMAKE
+
+grep '@am__include@ .*/xtra\.P' Makefile.in
diff --git a/t/ext.sh b/t/ext.sh
new file mode 100755
index 000000000..dd92e8555
--- /dev/null
+++ b/t/ext.sh
@@ -0,0 +1,45 @@
+#! /bin/sh
+# Copyright (C) 1999-2012 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/>.
+
+# Test to make sure extensions are set correctly for various languages.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_F77
+AC_PROG_FC
+AC_PROG_OBJC
+AM_PROG_UPC
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = foo
+foo_SOURCES = 1.f 2.for 3.f90 4.f95 5.F 6.F90 7.F95 8.r 9.m 10.upc
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+for ext in f for f90 f95 F F90 F95 r m upc
+do
+ # Some versions of the BSD shell wrongly exit when 'set -e' is active
+ # if the last command within a compound statement fails and is guarded
+ # by an && only. So we play safe and use the following idiom, instead
+ # of the apparently simpler 'grep ... && Exit 1'.
+ if grep "^$ext\.o:" Makefile.in; then Exit 1; else :; fi
+ grep "^\.$ext\.o:" Makefile.in
+done
+Exit 0
diff --git a/t/ext2.sh b/t/ext2.sh
new file mode 100755
index 000000000..3df028208
--- /dev/null
+++ b/t/ext2.sh
@@ -0,0 +1,66 @@
+#!/bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Regression test for a bug reported by Ladislav Strojil.
+# Using different extensions for the same language should not
+# output the build rules several times.
+
+. ./defs || Exit 1
+
+cat >>configure.ac <<EOF
+AC_PROG_CXX
+EOF
+
+cat >Makefile.am <<EOF
+bin_PROGRAMS = p q r
+p_SOURCES = a.cc b.cpp c.cxx
+q_SOURCES = sub/d.cc sub/e.cpp sub/f.cxx
+r_SOURCES = g.cc h.cpp i.cxx
+r_CXXFLAGS = -DFOO
+EOF
+
+$ACLOCAL
+$AUTOMAKE
+
+grep '\.o:' Makefile.in > rules
+cat rules
+
+# Here is an example of bogus output. The rules are output several
+# times.
+#| .cc.o:
+#| d.o: sub/d.cc
+#| e.o: sub/e.cpp
+#| f.o: sub/f.cxx
+#| r-g.o: g.cc
+#| r-h.o: h.cpp
+#| r-i.o: i.cxx
+#| .cpp.o:
+#| d.o: sub/d.cc
+#| e.o: sub/e.cpp
+#| f.o: sub/f.cxx
+#| r-g.o: g.cc
+#| r-h.o: h.cpp
+#| r-i.o: i.cxx
+#| .cxx.o:
+#| #d.o: sub/d.cc
+#| #e.o: sub/e.cpp
+#| #f.o: sub/f.cxx
+#| #r-g.o: g.cc
+#| #r-h.o: h.cpp
+#| #r-i.o: i.cxx
+
+# Bail out if we find a duplicate.
+$PERL -ne 'if (exists $a{$_}) { exit 1 } else { $a{$_} = 1 }' < rules
diff --git a/t/ext3.sh b/t/ext3.sh
new file mode 100755
index 000000000..bd5ed6dd3
--- /dev/null
+++ b/t/ext3.sh
@@ -0,0 +1,39 @@
+#! /bin/sh
+# Copyright (C) 2009-2012 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 3 of the License, 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/>.
+
+# Cover corner cases of derive_suffix wrt. file extensions:
+# - extension declared with SUFFIXES but with no suffix rule for it
+# - extension with a suffix rule but none that leads us to $(OBJEXT)
+# In both cases, we don't try to create a rule; but we shouldn't
+# fail either, because magic might be happening behind our back.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = foo bar
+foo_SOURCES = foo.goo
+SUFFIXES = .goo
+bar_SOURCES = bar.woo
+.woo.zoo: ; making a zoo $@ from a woo $<
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+Exit 0
diff --git a/t/extra-portability.sh b/t/extra-portability.sh
new file mode 100755
index 000000000..3ad637592
--- /dev/null
+++ b/t/extra-portability.sh
@@ -0,0 +1,96 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check interactions between the 'portability' and 'extra-portability'
+# warning categories:
+# 1. '-Wextra-portability' must imply '-Wportability'.
+# 2. '-Wno-portability' must imply '-Wno-extra-portability'.
+# 3. '-Wall' must imply '-Wextra-portability'.
+
+. ./defs || Exit 1
+
+# We want (almost) complete control over automake options.
+AUTOMAKE="$am_original_AUTOMAKE --foreign -Werror"
+
+cat >>configure.ac <<END
+AC_PROG_CC
+AC_PROG_RANLIB
+AC_OUTPUT
+END
+
+$ACLOCAL
+
+#
+# First, a setup where only an extra-portability warning is present
+# (no "simple" portability-warnings are).
+#
+
+cat >Makefile.am <<END
+EXTRA_LIBRARIES = libfoo.a
+libfoo_a_SOURCES = sub/foo.c
+END
+
+# Sanity check: extra-portability warnings causes the expected error.
+AUTOMAKE_fails -Wextra-portability
+grep 'requires.*AM_PROG_AR' stderr
+
+# Warnings in extra-portability category are not enabled by default.
+$AUTOMAKE
+
+# -Wall enables extra-portability.
+AUTOMAKE_fails -Wall
+grep 'requires.*AM_PROG_AR' stderr
+
+# Disabling portability disables extra-portability as well.
+$AUTOMAKE -Wextra-portability -Wno-portability
+$AUTOMAKE -Wall -Wno-portability
+
+#
+# Now, a setup where also a "simple" portability warning is present.
+#
+
+# Per-target flags require the use of AM_PROG_CC_C_O in configure.ac.
+echo libfoo_a_CPPFLAGS = -Dwhatever >> Makefile.am
+
+# Enabling extra-portability enables portability as well ...
+AUTOMAKE_fails -Wextra-portability
+grep 'requires.*AM_PROG_CC_C_O' stderr
+grep 'requires.*AM_PROG_AR' stderr
+# ... even if it had been previously disabled.
+AUTOMAKE_fails -Wno-portability -Wextra-portability
+grep 'requires.*AM_PROG_CC_C_O' stderr
+grep 'requires.*AM_PROG_AR' stderr
+
+# Disabling extra-portability leaves portability intact (1).
+AUTOMAKE_fails -Wportability -Wno-extra-portability
+grep 'requires.*AM_PROG_CC_C_O' stderr
+grep 'requires.*AM_PROG_AR' stderr && Exit 1
+# Disabling extra-portability leaves portability intact (2).
+AUTOMAKE_fails -Wall -Wno-extra-portability
+grep 'requires.*AM_PROG_CC_C_O' stderr
+grep 'requires.*AM_PROG_AR' stderr && Exit 1
+
+# Enabling portability does not enable extra-portability.
+AUTOMAKE_fails -Wportability
+grep 'requires.*AM_PROG_CC_C_O' stderr
+grep 'requires.*AM_PROG_AR' stderr && Exit 1
+
+# Disabling portability disables extra-portability.
+$AUTOMAKE -Wno-portability
+$AUTOMAKE -Wextra-portability -Wno-portability
+$AUTOMAKE -Wall -Wno-portability
+
+:
diff --git a/t/extra-portability2.sh b/t/extra-portability2.sh
new file mode 100755
index 000000000..2d33008c5
--- /dev/null
+++ b/t/extra-portability2.sh
@@ -0,0 +1,50 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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 that extra-portability warnings are not enabled by --gnits,
+# --gnu and --foreign.
+
+. ./defs || Exit 1
+
+# We want complete control over automake options.
+AUTOMAKE=$am_original_AUTOMAKE
+
+cat >>configure.ac <<END
+AC_PROG_CC
+AC_PROG_RANLIB
+AC_OUTPUT
+END
+
+cat >Makefile.am <<END
+EXTRA_LIBRARIES = libfoo.a
+libfoo_a_SOURCES = foo.c
+END
+
+$ACLOCAL
+
+# Make sure the test is useful.
+AUTOMAKE_fails -Wextra-portability \
+ || fatal_ "setup doesn't trigger 'extra-portability' warnings"
+
+$AUTOMAKE --foreign
+
+touch INSTALL NEWS README AUTHORS ChangeLog COPYING # Satisfy --gnu.
+$AUTOMAKE --gnu
+
+touch THANKS # Satisfy also --gnits.
+$AUTOMAKE --gnits
+
+:
diff --git a/t/extra-portability3.sh b/t/extra-portability3.sh
new file mode 100755
index 000000000..13d608469
--- /dev/null
+++ b/t/extra-portability3.sh
@@ -0,0 +1,60 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check interactions between the 'portability-recursive' and
+# 'extra-portability' warning categories.
+
+. ./defs || Exit 1
+
+# We want (almost) complete control over automake options.
+AUTOMAKE="$am_original_AUTOMAKE --foreign -Werror"
+
+cat >>configure.ac <<END
+AC_PROG_CC
+AC_PROG_RANLIB
+AC_OUTPUT
+END
+
+$ACLOCAL
+
+cat >Makefile.am <<'END'
+baz = $(foo$(bar))
+lib_LIBRARIES = libfoo.a
+libfoo_a_SOURCES = foo.c
+END
+
+# 'extra-portability' implies 'portability-recursive'.
+AUTOMAKE_fails -Wextra-portability
+grep 'requires.*AM_PROG_AR' stderr
+grep 'recursive variable expansion' stderr
+
+# We can disable 'extra-portability' while leaving
+# 'portability-recursive' intact.
+AUTOMAKE_fails -Wportability-recursive -Wno-extra-portability
+grep 'requires.*AM_PROG_AR' stderr && Exit 1
+grep 'recursive variable expansion' stderr
+
+# We can disable 'portability-recursive' while leaving
+# 'extra-portability' intact.
+AUTOMAKE_fails -Wextra-portability -Wno-portability-recursive
+grep 'requires.*AM_PROG_AR' stderr
+grep 'recursive variable expansion' stderr && Exit 1
+
+# Disabling 'portability' disables 'portability-recursive' and
+# 'extra-portability'.
+$AUTOMAKE -Wextra-portability -Wno-portability
+
+:
diff --git a/t/extra-programs-empty.sh b/t/extra-programs-empty.sh
new file mode 100755
index 000000000..37e1a2bc1
--- /dev/null
+++ b/t/extra-programs-empty.sh
@@ -0,0 +1,53 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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/>.
+
+# Test that EXTRA_PROGRAMS doesn't get removed because it is empty.
+# This check has been introduced in commit 'Release-1-9-254-g9d0eaef'
+# into the former test 'subst2.test'.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_CONFIG_FILES([Makefile2 Makefile3])
+AC_SUBST([prog])
+AC_PROG_CC
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+EXTRA_PROGRAMS =
+END
+
+cat > Makefile2.am <<'END'
+bin_PROGRAMS = a @prog@ b
+EXTRA_PROGRAMS =
+END
+
+cat > Makefile3.am <<'END'
+empty =
+EXTRA_PROGRAMS = $(empty)
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+grep '^EXTRA_PROGRAMS = *$' Makefile.in
+grep '^EXTRA_PROGRAMS = *$' Makefile2.in
+# Be laxer here, since EXTRA_PROGRAMS might be internally rewritten
+# by Automake when it contains references to other variables.
+grep '^EXTRA_PROGRAMS =' Makefile3.in
+
+:
diff --git a/t/extra.sh b/t/extra.sh
new file mode 100755
index 000000000..7bad9ef0a
--- /dev/null
+++ b/t/extra.sh
@@ -0,0 +1,40 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test to make sure EXTRA_ targets are generated. This test used to
+# make sure the targets were *not* generated. That is wrong; the
+# targets should always be generated. However, they should not be
+# built by default.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = @foo@
+EXTRA_PROGRAMS = zardoz
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+grep "^zardoz" Makefile.in
+
+# Can't have EXTRA clean rules.
+grep 'clean.*EXTRA' Makefile.in && Exit 1
+Exit 0
diff --git a/t/extra10.sh b/t/extra10.sh
new file mode 100755
index 000000000..8fe7133d2
--- /dev/null
+++ b/t/extra10.sh
@@ -0,0 +1,50 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Check that wildcards in EXTRA_DIST are honoured.
+# Suggested by observations from Braden McDaniel.
+# See also sister test 'extra11.test', that check a similar usage
+# with the involvement of the $(wildcard) GNU make builtin.
+
+required=GNUmake
+. ./defs || Exit 1
+
+echo AC_OUTPUT >> configure.ac
+
+cat > Makefile.am <<'END'
+EXTRA_DIST = *.foo
+.PHONY: test
+test: distdir
+ diff a.foo $(distdir)/a.foo
+ diff b.foo $(distdir)/b.foo
+ test ! -r $(distdir)/c.bar
+check-local:
+ test -f $(srcdir)/a.foo
+ test -f $(srcdir)/b.foo
+ test ! -r $(srcdir)/c.bar
+END
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+
+echo aaa > a.foo
+echo bbb > b.foo
+echo ccc > c.bar
+./configure
+$MAKE test
+
+:
diff --git a/t/extra11.sh b/t/extra11.sh
new file mode 100755
index 000000000..a645afbe4
--- /dev/null
+++ b/t/extra11.sh
@@ -0,0 +1,93 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Check for more complex usage of wildcards in EXTRA_DIST.
+# Suggested by observations from Braden McDaniel.
+
+required=GNUmake
+. ./defs || Exit 1
+
+echo AC_OUTPUT >> configure.ac
+
+cat > Makefile.am <<'END'
+AUTOMAKE_OPTIONS = -Wno-portability
+
+EXTRA_DIST = $(wildcard [!c-z].t d.t [ab].dir foo.* *zardoz*)
+
+.PHONY: prereq
+prereq:
+ echo a > a.t
+ echo b > b.t
+ echo c > c.t
+ echo d > d.t
+ echo m > m.t
+ echo z > z.t
+ mkdir a.dir b.dir c.dir
+ echo a1 > a.dir/f1
+ echo a2 > a.dir/f2
+ echo bb > b.dir/f
+ echo cc > c.dir/x
+ echo 0 > foo
+ echo 1 > foo.x
+ echo 2 > foo.bar
+ echo foo > _zardoz_
+
+.PHONY: test
+test: distdir
+ ls -l $(distdir) $(distdir)/*.dir ;: For debugging.
+ diff a.t $(distdir)/a.t
+ diff b.t $(distdir)/b.t
+ test ! -r $(distdir)/c.t
+ diff d.t $(distdir)/d.t
+ test ! -r $(distdir)/m.t
+ test ! -r $(distdir)/z.t
+ diff a.dir/f1 $(distdir)/a.dir/f1
+ diff a.dir/f2 $(distdir)/a.dir/f2
+ diff b.dir/f $(distdir)/b.dir/f
+ test ! -r $(distdir)/c.dir
+ diff foo.x $(distdir)/foo.x
+ diff foo.bar $(distdir)/foo.bar
+ test ! -r $(distdir)/foo
+ diff _zardoz_ $(distdir)/_zardoz_
+check-local:
+ ls -l . *.dir ;: For debugging.
+ test -f $(srcdir)/a.t
+ test -f $(srcdir)/b.t
+ test ! -r $(srcdir)/c.t
+ test -f $(srcdir)/d.t
+ test ! -r $(srcdir)/m.t
+ test ! -r $(srcdir)/z.t
+ test -f $(srcdir)/a.dir/f1
+ test -f $(srcdir)/a.dir/f2
+ test -f $(srcdir)/b.dir/f
+ test ! -r $(srcdir)/c.dir
+ test -f $(srcdir)/foo.x
+ test -f $(srcdir)/foo.bar
+ test ! -r $(srcdir)/foo
+ test -f $(srcdir)/_zardoz_
+END
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+
+./configure
+$MAKE prereq
+ls -l . *.dir # For debugging.
+$MAKE test
+$MAKE distcheck
+
+:
diff --git a/t/extra12.sh b/t/extra12.sh
new file mode 100755
index 000000000..979411592
--- /dev/null
+++ b/t/extra12.sh
@@ -0,0 +1,51 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Check that wildcards in elements of EXTRA_DIST are honoured when
+# $srcdir != $builddir, if properly declared.
+# Suggested by observations from Braden McDaniel.
+
+required=GNUmake
+. ./defs || Exit 1
+
+echo AC_OUTPUT >> configure.ac
+
+
+cat > Makefile.am <<'END'
+EXTRA_DIST = *.foo $(srcdir)/*.foo $(builddir)/*.bar $(srcdir)/*.bar
+
+.PHONY: test
+test: distdir
+ ls -l $(srcdir) $(builddir) $(distdir)
+ diff $(srcdir)/a.foo $(distdir)/a.foo
+ diff $(srcdir)/b.bar $(distdir)/b.bar
+ diff $(builddir)/c.foo $(distdir)/c.foo
+ diff $(builddir)/d.bar $(distdir)/d.bar
+END
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+
+echo aaa > a.foo
+echo bbb > b.bar
+mkdir build
+echo ccc > build/c.foo
+echo ddd > build/d.bar
+
+cd build
+../configure
+$MAKE test
diff --git a/t/extra2.sh b/t/extra2.sh
new file mode 100755
index 000000000..30eaeeda6
--- /dev/null
+++ b/t/extra2.sh
@@ -0,0 +1,33 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Check to make sure EXTRA_foo_SOURCES not defined unnecessarily.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = foo
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+grep EXTRA_foo_SOURCES Makefile.in && Exit 1
+Exit 0
diff --git a/t/extra3.sh b/t/extra3.sh
new file mode 100755
index 000000000..406580106
--- /dev/null
+++ b/t/extra3.sh
@@ -0,0 +1,28 @@
+#! /bin/sh
+# Copyright (C) 1998-2012 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/>.
+
+# Check to make sure EXTRA_DATA not required.
+
+. ./defs || Exit 1
+
+echo 'AC_SUBST(CODICIL)' >> configure.ac
+
+cat > Makefile.am << 'END'
+sysconf_DATA = @CODICIL@
+END
+
+$ACLOCAL
+$AUTOMAKE
diff --git a/t/extra4.sh b/t/extra4.sh
new file mode 100755
index 000000000..5b31b63ac
--- /dev/null
+++ b/t/extra4.sh
@@ -0,0 +1,29 @@
+#! /bin/sh
+# Copyright (C) 1998-2012 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/>.
+
+# Check to make sure EXTRA_DATA can be specified.
+
+. ./defs || Exit 1
+
+echo 'AC_SUBST(CODICIL)' >> configure.ac
+
+cat > Makefile.am << 'END'
+sysconf_DATA = @CODICIL@
+EXTRA_DATA = codicil.txt
+END
+
+$ACLOCAL
+$AUTOMAKE
diff --git a/t/extra5.sh b/t/extra5.sh
new file mode 100755
index 000000000..7fdd9838d
--- /dev/null
+++ b/t/extra5.sh
@@ -0,0 +1,38 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Check to make sure EXTRA_DIST can contain a directory from $buildir.
+# From Dean Povey.
+
+. ./defs || Exit 1
+
+echo AC_OUTPUT >> configure.ac
+
+cat > Makefile.am << 'END'
+EXTRA_DIST=foo
+
+foo:
+ mkdir foo
+ touch foo/bar
+END
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+mkdir build
+cd build
+../configure
+$MAKE distdir
diff --git a/t/extra6.sh b/t/extra6.sh
new file mode 100755
index 000000000..6b512114b
--- /dev/null
+++ b/t/extra6.sh
@@ -0,0 +1,55 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Check to make sure EXTRA_DIST can contain a directory or
+# a subdirectory, in $(builddir) or $(srcdir).
+
+. ./defs || Exit 1
+
+echo AC_OUTPUT >> configure.ac
+
+cat > Makefile.am << 'END'
+EXTRA_DIST=foo/bar baz foo2/bar2 baz2
+
+check: distdir
+ test -f $(distdir)/foo/bar/baz
+ test -f $(distdir)/baz/foo
+ test -f $(distdir)/foo2/bar2/baz2
+ test -f $(distdir)/baz2/foo2
+END
+
+# Create some files in $(srcdir)
+mkdir foo
+mkdir foo/bar
+touch foo/bar/baz
+mkdir baz
+touch baz/foo
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+mkdir build
+cd build
+../configure
+
+# Create some files in $(builddir)
+mkdir foo2
+mkdir foo2/bar2
+touch foo2/bar2/baz2
+mkdir baz2
+touch baz2/foo2
+
+$MAKE check
diff --git a/t/extra7.sh b/t/extra7.sh
new file mode 100755
index 000000000..4ad778959
--- /dev/null
+++ b/t/extra7.sh
@@ -0,0 +1,64 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Check to make sure that when distdir is invoked in a VPATH
+# configuration and has to distribute directory X, it actually merge
+# $(srcdir)/X and ./X, with the files from the later overriding the
+# files from the former.
+
+. ./defs || Exit 1
+
+echo AC_OUTPUT >> configure.ac
+
+cat > Makefile.am << 'END'
+EXTRA_DIST=foo/bar baz
+
+check: distdir
+ test -f $(distdir)/foo/bar/baz
+ test -f $(distdir)/foo/bar/baz2
+ test -f $(distdir)/baz/foo
+ test -f $(distdir)/baz/foo2
+ grep source $(distdir)/foo/bar/baz
+ grep build $(distdir)/foo/bar/baz2
+ grep source $(distdir)/baz/foo
+ grep build $(distdir)/baz/foo2
+END
+
+# Create some files in $(srcdir)
+mkdir foo
+mkdir foo/bar
+echo source > foo/bar/baz
+echo source > foo/bar/baz2
+mkdir baz
+echo source > baz/foo
+echo source > baz/foo2
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+mkdir build
+cd build
+../configure
+
+# Create some files in $(builddir) that will override part of the
+# files if $(srcdir) when the distribution is made.
+mkdir foo
+mkdir foo/bar
+echo build > foo/bar/baz2
+mkdir baz
+echo build > baz/foo2
+
+$MAKE check
diff --git a/t/extra8.sh b/t/extra8.sh
new file mode 100755
index 000000000..9eef189d1
--- /dev/null
+++ b/t/extra8.sh
@@ -0,0 +1,36 @@
+#!/bin/sh
+# Copyright (C) 2009-2012 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/>.
+
+# Ensure defining bin_PROGRAMS in terms of EXTRA_PROGRAMS works,
+# and that referring to the same program with inconsistent addition
+# of $(EXEEXT) works, too.
+
+. ./defs || Exit 1
+
+cat >>configure.ac <<'END'
+AC_PROG_CC
+AC_OUTPUT
+END
+cat >Makefile.am <<'END'
+EXTRA_PROGRAMS = foo bar
+bin_PROGRAMS = $(EXTRA_PROGRAMS) baz
+noinst_PROGRAMS = baz$(EXEEXT)
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+:
diff --git a/t/extra9.sh b/t/extra9.sh
new file mode 100755
index 000000000..b5a6007c1
--- /dev/null
+++ b/t/extra9.sh
@@ -0,0 +1,43 @@
+#!/bin/sh
+# Copyright (C) 2009-2012 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/>.
+
+# Ensure we warn about substitutions in bin_PROGRAMS if EXTRA_PROGRAMS
+# are missing; but only if the former is not AC_SUBSTed itself
+# (lib_LIBRARIES is in the same boat here).
+
+. ./defs || Exit 1
+
+cat >>configure.ac <<'END'
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_RANLIB
+AC_SUBST([lib_LIBRARIES])
+AC_SUBST([bins])
+AC_OUTPUT
+END
+
+cat >Makefile.am <<'END'
+bin_PROGRAMS = @bins@
+END
+
+: > ar-lib
+
+$ACLOCAL
+AUTOMAKE_fails
+grep 'bin_PROGRAMS.*contains configure substitution' stderr
+grep 'lib_LIBRARIES.*contains configure substitution' stderr && Exit 1
+
+Exit 0
diff --git a/t/extradep.sh b/t/extradep.sh
new file mode 100755
index 000000000..77b806a97
--- /dev/null
+++ b/t/extradep.sh
@@ -0,0 +1,107 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Test EXTRA_*_DEPENDENCIES. See extradep2 for libtool variant.
+
+required=cc
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_RANLIB
+AC_SUBST([deps], [bardep])
+AM_CONDITIONAL([COND], [test -n "$cond"])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+noinst_LIBRARIES = libfoo.a
+EXTRA_libfoo_a_DEPENDENCIES = libfoodep
+libfoodep:
+ @echo making $@
+ @: > $@
+CLEANFILES = libfoodep
+
+bin_PROGRAMS = foo bar
+EXTRA_foo_DEPENDENCIES = foodep
+if COND
+EXTRA_foo_DEPENDENCIES += foodep2
+endif
+bar_LDADD = libfoo.a
+EXTRA_bar_DEPENDENCIES = $(deps)
+
+EXTRA_DIST = foodep bardep
+
+.PHONY: bar-has-been-updated
+bar-has-been-updated:
+ stat older bar$(EXEEXT) libfoo.a || : For debugging.
+ test `ls -t bar$(EXEEXT) older | sed q` = bar$(EXEEXT)
+END
+
+cat >libfoo.c <<'END'
+int libfoo () { return 0; }
+END
+
+cat >foo.c <<'END'
+int main () { return 0; }
+END
+
+cat >bar.c <<'END'
+extern int libfoo ();
+int main () { return libfoo (); }
+END
+
+$ACLOCAL
+$AUTOMAKE --add-missing
+$AUTOCONF
+
+./configure cond=yes
+
+# Hypotheses:
+# - EXTRA_*_DEPENDENCIES are honored.
+# - Conditionals and substitutions are honored.
+# - *_DEPENDENCIES are not overwritten by their EXTRA_* counterparts.
+
+: >foodep
+: >foodep2
+: >bardep
+$MAKE >stdout || { cat stdout; Exit 1; }
+cat stdout
+grep 'making libfoodep' stdout
+
+rm -f foodep
+$MAKE && Exit 1
+: >foodep
+
+rm -f foodep2
+$MAKE && Exit 1
+: >foodep2
+
+rm -f bardep
+$MAKE && Exit 1
+: >bardep
+
+$MAKE
+: > older
+$sleep
+touch libfoo.a
+$MAKE
+$MAKE bar-has-been-updated
+
+$MAKE distcheck
+
+:
diff --git a/t/extradep2.sh b/t/extradep2.sh
new file mode 100755
index 000000000..91722bd0a
--- /dev/null
+++ b/t/extradep2.sh
@@ -0,0 +1,88 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Test EXTRA_*_DEPENDENCIES, libtool version; see extradep.test.
+
+required='cc libtoolize'
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_LIBTOOL
+AC_SUBST([deps], [bardep])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+noinst_LTLIBRARIES = libfoo.la
+EXTRA_libfoo_la_DEPENDENCIES = libfoodep
+libfoodep:
+ @echo making $@
+ @: > $@
+CLEANFILES = libfoodep
+
+bin_PROGRAMS = bar
+bar_LDADD = libfoo.la
+EXTRA_bar_DEPENDENCIES = $(deps)
+
+EXTRA_DIST = bardep
+
+.PHONY: bar-has-been-updated
+bar-has-been-updated:
+ stat older bar$(EXEEXT) libfoo.la || : For debugging.
+ test `ls -t bar$(EXEEXT) older | sed q` = bar$(EXEEXT)
+END
+
+cat >libfoo.c <<'END'
+int libfoo () { return 0; }
+END
+
+cat >bar.c <<'END'
+extern int libfoo ();
+int main () { return libfoo (); }
+END
+
+libtoolize
+$ACLOCAL
+$AUTOMAKE --add-missing
+$AUTOCONF
+
+./configure
+
+# Hypothesis: EXTRA_*_DEPENDENCIES are honored.
+
+: >foodep
+: >foodep2
+: >bardep
+$MAKE >stdout || { cat stdout; Exit 1; }
+cat stdout
+grep 'making libfoodep' stdout
+
+rm -f bardep
+$MAKE && Exit 1
+: >bardep
+
+$MAKE
+: > older
+$sleep
+touch libfoo.la
+$MAKE
+$MAKE bar-has-been-updated
+
+$MAKE distcheck
+
+:
diff --git a/t/f90only.sh b/t/f90only.sh
new file mode 100755
index 000000000..a65a91ecf
--- /dev/null
+++ b/t/f90only.sh
@@ -0,0 +1,34 @@
+#! /bin/sh
+# Copyright (C) 1998-2012 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 programs with only Fortran 90 source are handled properly.
+# (copied from fonly.test) Mike Nolta <mrnolta@princeton.edu>
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_FC
+END
+
+cat > Makefile.am <<'END'
+bin_PROGRAMS = zardoz
+zardoz_SOURCES = zardoz.f90
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+grep 'zardoz.f90' Makefile.in
diff --git a/t/flavor.sh b/t/flavor.sh
new file mode 100755
index 000000000..f53240690
--- /dev/null
+++ b/t/flavor.sh
@@ -0,0 +1,59 @@
+#! /bin/sh
+# Copyright (C) 2009-2012 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 flavors like 'cygnus', 'gnu', 'gnits' and command line
+# options like '--ignore-deps' and '--silent-rules' are preserved across
+# automake reruns.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AM_MAINTAINER_MODE
+AC_OUTPUT
+END
+
+: > Makefile.am
+: > NEWS
+: > README
+: > AUTHORS
+: > ChangeLog
+: > THANKS
+
+$ACLOCAL
+$AUTOCONF
+# Order flavors so that all needed files are installed early.
+for flavor in --gnits --gnu --foreign --cygnus --ignore-deps
+do
+ $AUTOMAKE --add-missing $flavor
+ ./configure --enable-maintainer-mode
+ grep " $flavor" Makefile
+ $MAKE
+
+ # Two code paths in configure.am:
+ # - either a file in $(am__configure_deps) has been updated ...
+ $sleep
+ touch aclocal.m4
+ $MAKE
+ grep " $flavor" Makefile
+
+ # - ... or not; i.e., Makefile.am or an included file has.
+ $sleep
+ touch Makefile.am
+ $MAKE
+ grep " $flavor" Makefile
+done
+
+:
diff --git a/t/flibs.sh b/t/flibs.sh
new file mode 100755
index 000000000..4f5701bd0
--- /dev/null
+++ b/t/flibs.sh
@@ -0,0 +1,54 @@
+#! /bin/sh
+# Copyright (C) 1998-2012 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 'AC_F77_LIBRARY_LDFLAGS' works properly.
+# Matthew D. Langston <langston@SLAC.Stanford.EDU>
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_F77
+AC_F77_LIBRARY_LDFLAGS
+END
+
+# Tue Aug 11 09:50:48 1998 Matthew D. Langston <langston@SLAC.Stanford.EDU>
+#
+# This test currently fails with automake v. 1.3 since automake assumes
+# that elements of 'bin_PROGRAMS' (e.g. zardoz) without a corresponding
+# '_SOURCES' (e.g. zardoz_SOURCES) should be compiled from 'zardoz.c'
+# whether or not 'zardoz.c' actually exists. For example, even if the
+# file 'zardoz.c' doesn't exist but the file 'zardoz.f' does exist, this
+# tests would still fail.
+#
+# Therefore, for now I have put in the line 'zardoz_SOURCES = zardoz.f'
+# (see below) so that automake's top-level 'make check' won't fail, but
+# this line should be removed once automake handles this situation
+# correctly.
+
+cat > Makefile.am <<'END'
+bin_PROGRAMS = zardoz
+zardoz_SOURCES = zardoz.f
+zardoz_LDADD = @FLIBS@
+END
+
+: > zardoz.f
+: > config.guess
+: > config.sub
+
+$ACLOCAL
+$AUTOMAKE
+
+grep '@FLIBS@' Makefile.in
diff --git a/t/fn99.sh b/t/fn99.sh
new file mode 100755
index 000000000..900b36bd3
--- /dev/null
+++ b/t/fn99.sh
@@ -0,0 +1,51 @@
+#! /bin/sh
+# Copyright (C) 2004-2012 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/>.
+
+# Check the filename-length-max=99 option.
+
+. ./defs || Exit 1
+
+echo AC_OUTPUT >> configure.ac
+
+cat >Makefile.am <<'END'
+AUTOMAKE_OPTIONS = filename-length-max=99
+EXTRA_DIST = 12345678
+END
+
+(for i in 1 2 3 4 5 6 7 8 9; do
+ mkdir -p 12345678 && cd 12345678 && touch x || Exit 1
+done) || skip_ "failed to create deep directory hierarchy"
+
+# AIX 5.3 'cp -R' is too buggy for 'make dist'.
+cp -R 12345678 t \
+ || skip_ "'cp -R' failed to copy deep directory hierarchy"
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+$MAKE distcheck
+
+(for i in 1 2 3 4 5 6 7 8 9 10 11; do
+ mkdir -p 12345678 && cd 12345678 && touch x || Exit 1
+done) || skip_ "failed to create deeper directory hierarchy"
+
+$MAKE dist 2>stderr && { cat stderr >&2; Exit 1; }
+cat stderr >&2
+grep 'filenames are too long' stderr
+test 2 = `grep 12345678 stderr | wc -l`
+
+:
diff --git a/t/fn99subdir.sh b/t/fn99subdir.sh
new file mode 100755
index 000000000..beb02618f
--- /dev/null
+++ b/t/fn99subdir.sh
@@ -0,0 +1,81 @@
+#! /bin/sh
+# Copyright (C) 2006-2012 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/>.
+
+# PR 507: Check the filename-length-max=99 option
+# in conjunction with AC_CONFIG_SUBDIRS.
+
+. ./defs || Exit 1
+
+# The name is so that 99 is exactly hit (including final \0).
+subdirname='cnfsubdir'
+
+cat >>configure.ac <<END
+AC_CONFIG_SUBDIRS([$subdirname])
+AC_OUTPUT
+END
+
+cat >Makefile.am <<END
+AUTOMAKE_OPTIONS = filename-length-max=99
+SUBDIRS = $subdirname
+END
+
+mkdir $subdirname
+
+cat >> $subdirname/configure.ac <<EOF
+AC_INIT([$subdirname], [1.0])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+EOF
+
+cat >$subdirname/Makefile.am <<'END'
+AUTOMAKE_OPTIONS = filename-length-max=99
+EXTRA_DIST = 12345678
+END
+
+(cd $subdirname || Exit 1
+for i in 1 2 3 4 5 6 7 8; do
+ mkdir -p 12345678 && cd 12345678 && touch x || Exit 1
+done) || skip_ "failed to create deep directory hierarchy"
+
+# AIX 5.3 'cp -R' is too buggy for 'make dist'.
+cp -R $subdirname t \
+ || skip_ "'cp -R' failed to copy deep directory hierarchy"
+
+cd $subdirname
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+cd ..
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+$MAKE distcheck
+
+(cd $subdirname || Exit 1
+for i in 1 2 3 4 5 6 7 8 9; do
+ mkdir -p 12345678 && cd 12345678 && touch x || Exit 1
+done) || skip_ "failed to create deeper directory hierarchy"
+
+$MAKE dist 2>stderr && { cat stderr >&2; Exit 1; }
+cat stderr >&2
+grep 'filenames are too long' stderr
+test 1 = `grep 12345678 stderr | wc -l`
+
+:
diff --git a/t/fnoc.sh b/t/fnoc.sh
new file mode 100755
index 000000000..fbd21352f
--- /dev/null
+++ b/t/fnoc.sh
@@ -0,0 +1,39 @@
+#! /bin/sh
+# Copyright (C) 1998-2012 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/>.
+
+# Test to make sure that pure Fortran 77 sources don't include
+# C-specific code.
+# Matthew D. Langston <langston@SLAC.Stanford.EDU>
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_F77
+END
+
+cat > Makefile.am << 'END'
+sbin_PROGRAMS = anonymous
+anonymous_SOURCES = doe.f jane.f
+END
+
+: > doe.f
+: > jane.f
+
+$ACLOCAL
+$AUTOMAKE
+
+grep '[^F]CC' Makefile.in | grep -v MKDEP && Exit 1
+Exit 0
diff --git a/t/fo.sh b/t/fo.sh
new file mode 100755
index 000000000..50b4f4a12
--- /dev/null
+++ b/t/fo.sh
@@ -0,0 +1,36 @@
+#! /bin/sh
+# Copyright (C) 1998-2012 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 Fortran 77 files are rewritten to ".o" and not just "o".
+# Matthew D. Langston <langston@SLAC.Stanford.EDU>
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_F77
+END
+
+cat > Makefile.am << 'END'
+sbin_PROGRAMS = anonymous
+anonymous_SOURCES = doe.f
+END
+
+: > doe.f
+
+$ACLOCAL
+$AUTOMAKE
+
+$FGREP 'doe.$(OBJEXT)' Makefile.in
diff --git a/t/fonly.sh b/t/fonly.sh
new file mode 100755
index 000000000..c3ae61481
--- /dev/null
+++ b/t/fonly.sh
@@ -0,0 +1,34 @@
+#! /bin/sh
+# Copyright (C) 1998-2012 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 programs with only Fortran 77 source are handled properly.
+# Matthew D. Langston <langston@SLAC.Stanford.EDU>
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_F77
+END
+
+cat > Makefile.am <<'END'
+bin_PROGRAMS = zardoz
+zardoz_SOURCES = zardoz.f
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+grep 'zardoz.f' Makefile.in
diff --git a/t/forcemiss.sh b/t/forcemiss.sh
new file mode 100755
index 000000000..d7d0800c2
--- /dev/null
+++ b/t/forcemiss.sh
@@ -0,0 +1,34 @@
+#! /bin/sh
+# Copyright (C) 2000-2012 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/>.
+
+# Test to make sure that 'automake --force-missing' works.
+
+. ./defs || Exit 1
+
+rm -f install-sh
+
+echo zot > install-sh
+
+: > Makefile.am
+
+$ACLOCAL
+$AUTOMAKE --add-missing --force-missing
+
+ls -l install-sh
+test -f install-sh
+grep zot install-sh && Exit 1
+
+:
diff --git a/t/forcemiss2.sh b/t/forcemiss2.sh
new file mode 100755
index 000000000..3c75722df
--- /dev/null
+++ b/t/forcemiss2.sh
@@ -0,0 +1,40 @@
+#! /bin/sh
+# Copyright (C) 2000-2012 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/>.
+
+# Test to make sure that 'automake --force-missing' works, even with
+# symlinked files.
+
+. ./defs || Exit 1
+
+rm -f install-sh
+
+echo zot > foo
+cp foo foo2
+
+ln -s foo2 install-sh || skip_ "cannot create symlinks to files"
+
+: > Makefile.am
+
+$ACLOCAL
+ls -l install-sh
+$AUTOMAKE --add-missing --force-missing
+ls -l install-sh
+
+test -f install-sh
+grep zot install-sh && Exit 1
+diff foo foo2
+
+:
diff --git a/t/fort1.sh b/t/fort1.sh
new file mode 100755
index 000000000..6bf58fef9
--- /dev/null
+++ b/t/fort1.sh
@@ -0,0 +1,30 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Test that Automake suggests using AC_PROG_F77/FC if Fortran sources
+# are used.
+
+. ./defs || Exit 1
+
+cat >Makefile.am <<END
+bin_PROGRAMS = hello
+hello_SOURCES = hello.f foo.f95
+END
+
+$ACLOCAL
+AUTOMAKE_fails
+grep AC_PROG_F77 stderr
+grep AC_PROG_FC stderr
diff --git a/t/fort2.sh b/t/fort2.sh
new file mode 100755
index 000000000..d345592ef
--- /dev/null
+++ b/t/fort2.sh
@@ -0,0 +1,62 @@
+#! /bin/sh
+# Copyright (C) 2006-2012 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/>.
+
+# Test that AC_FC_SRCEXT(f9x) works as intended:
+# - $(FCFLAGS_f) will be used
+
+# Cf. fort1.test and link_f90_only.test.
+
+. ./defs || Exit 1
+
+mkdir sub
+
+cat >>configure.ac <<'END'
+AC_PROG_FC
+AC_FC_SRCEXT([f90])
+AC_FC_SRCEXT([f95])
+AC_FC_SRCEXT([f03])
+AC_FC_SRCEXT([f08])
+AC_FC_SRCEXT([blabla])
+END
+
+cat >Makefile.am <<'END'
+bin_PROGRAMS = hello goodbye
+hello_SOURCES = hello.f90 foo.f95 sub/bar.f95 hi.f03 sub/howdy.f03 greets.f08 sub/bonjour.f08
+goodbye_SOURCES = bye.f95 sub/baz.f90
+goodbye_FCFLAGS =
+END
+
+$ACLOCAL
+$AUTOMAKE
+# The following tests aren't fool-proof, but they don't
+# need a Fortran compiler.
+grep '.\$(LINK)' Makefile.in && Exit 1
+grep '.\$(FCLINK)' Makefile.in
+grep '.\$(FCCOMPILE)' Makefile.in > stdout
+cat stdout
+grep -v '\$(FCFLAGS_f' stdout && Exit 1
+grep '.\$(FC.*\$(FCFLAGS_blabla' Makefile.in && Exit 1
+# Notice the TAB:
+grep '^[ ].*\$(FC.*\$(FCFLAGS_f90).*\.f90' Makefile.in
+grep '^[ ].*\$(FC.*\$(FCFLAGS_f95).*\.f95' Makefile.in
+grep '^[ ].*\$(FC.*\$(FCFLAGS_f03).*\.f03' Makefile.in
+grep '^[ ].*\$(FC.*\$(FCFLAGS_f08).*\.f08' Makefile.in
+grep '^[ ].*\$(FC.*\$(FCFLAGS_f90).*\.f95' Makefile.in && Exit 1
+grep '^[ ].*\$(FC.*\$(FCFLAGS_f95).*\.f90' Makefile.in && Exit 1
+grep '^[ ].*\$(FC.*\$(FCFLAGS_f90).*\.f03' Makefile.in && Exit 1
+grep '^[ ].*\$(FC.*\$(FCFLAGS_f08).*\.f90' Makefile.in && Exit 1
+
+:
diff --git a/t/fort4.sh b/t/fort4.sh
new file mode 100755
index 000000000..a23c9bda5
--- /dev/null
+++ b/t/fort4.sh
@@ -0,0 +1,92 @@
+#! /bin/sh
+# Copyright (C) 2006-2012 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/>.
+
+# Test mixing Fortran 77 and Fortran (FC).
+
+# For now, require the GNU compilers (to avoid some Libtool/Autoconf
+# issues).
+required='g77 gfortran'
+. ./defs || Exit 1
+
+mkdir sub
+
+cat >hello.f <<'END'
+ program hello
+ call foo
+ call bar
+ stop
+ end
+END
+
+cat >bye.f90 <<'END'
+program goodbye
+ call baz
+ stop
+end
+END
+
+cat >foo.f90 <<'END'
+ subroutine foo
+ return
+ end
+END
+
+sed s,foo,bar, foo.f90 > sub/bar.f90
+sed s,foo,baz, foo.f90 > sub/baz.f
+
+cat >>configure.ac <<'END'
+AC_PROG_F77
+AC_PROG_FC
+AC_FC_SRCEXT([f90], [],
+ [AC_MSG_FAILURE([$FC compiler cannot create executables], 77)])
+AC_FC_LIBRARY_LDFLAGS
+AC_OUTPUT
+END
+
+cat >Makefile.am <<'END'
+bin_PROGRAMS = hello goodbye
+hello_SOURCES = hello.f foo.f90 sub/bar.f90
+goodbye_SOURCES = bye.f90 sub/baz.f
+goodbye_FCFLAGS =
+LDADD = $(FCLIBS)
+END
+
+$ACLOCAL
+$AUTOMAKE -a
+# The Fortran 77 linker should be preferred:
+grep '.\$(FCLINK)' Makefile.in && Exit 1
+
+$AUTOCONF
+# ./configure may exit with status 77 if no compiler is found,
+# or if the compiler cannot compile Fortran 90 files).
+./configure
+$MAKE
+subobjs=`echo sub/*.o sub/*.obj`
+test "$subobjs" = 'sub/*.o sub/*.obj'
+$MAKE distcheck
+
+$MAKE distclean
+echo 'AUTOMAKE_OPTIONS = subdir-objects' >> Makefile.am
+$AUTOMAKE
+./configure
+$MAKE
+test ! -f bar.o
+test ! -f bar.obj
+test ! -f baz.o
+test ! -f baz.obj
+test ! -f goodbye-baz.o
+test ! -f goodbye-baz.obj
+$MAKE distcheck
diff --git a/t/fort5.sh b/t/fort5.sh
new file mode 100755
index 000000000..4614b661d
--- /dev/null
+++ b/t/fort5.sh
@@ -0,0 +1,105 @@
+#! /bin/sh
+# Copyright (C) 2006-2012 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/>.
+
+# Test mixing Fortran 77 and Fortran (FC), libtool version.
+
+# For now, require the GNU compilers (to avoid some Libtool/Autoconf
+# issues).
+required='libtoolize g77 gfortran'
+. ./defs || Exit 1
+
+mkdir sub
+
+cat >hello.f <<'END'
+ program hello
+ call foo
+ call bar
+ call goodbye
+ stop
+ end
+END
+
+cat >bye.f90 <<'END'
+subroutine goodbye
+ call baz
+ return
+end
+END
+
+cat >foo.f90 <<'END'
+ subroutine foo
+ return
+ end
+END
+
+sed s,foo,bar, foo.f90 > sub/bar.f90
+sed s,foo,baz, foo.f90 > sub/baz.f
+
+cat >>configure.ac <<'END'
+AC_PROG_F77
+AC_PROG_FC
+AC_FC_SRCEXT([f90], [],
+ [AC_MSG_FAILURE([$FC compiler cannot create executables], 77)])
+AC_FC_LIBRARY_LDFLAGS
+AM_PROG_AR
+LT_PREREQ([2.0])
+AC_PROG_LIBTOOL
+AC_OUTPUT
+END
+
+cat >Makefile.am <<'END'
+bin_PROGRAMS = hello
+lib_LTLIBRARIES = libhello.la
+noinst_LTLIBRARIES = libgoodbye.la
+hello_SOURCES = hello.f
+hello_LDADD = libhello.la
+libhello_la_SOURCES = foo.f90 sub/bar.f90
+libhello_la_LIBADD = libgoodbye.la
+libgoodbye_la_SOURCES = bye.f90 sub/baz.f
+libgoodbye_la_FCFLAGS =
+LDADD = $(FCLIBS)
+END
+
+libtoolize --force
+$ACLOCAL
+$AUTOMAKE -a
+$AUTOCONF
+
+# This test requires Libtool >= 2.0. Earlier Libtool does not
+# have the LT_PREREQ macro to cause autoconf failure.
+grep LT_PREREQ configure && skip_ "libtool is too old (probably < 2.0)"
+
+# Ensure we use --tag for f90, too.
+grep " --tag=FC" Makefile.in
+
+# ./configure may exit with status 77 if no compiler is found,
+# or if the compiler cannot compile Fortran 90 files).
+./configure
+$MAKE
+subobjs=`echo sub/*.lo`
+test "$subobjs" = 'sub/*.lo'
+$MAKE distcheck
+
+# The following will be fixed in a later patch:
+$MAKE distclean
+echo 'AUTOMAKE_OPTIONS = subdir-objects' >> Makefile.am
+$AUTOMAKE -a
+./configure
+$MAKE
+test ! -f bar.lo
+test ! -f baz.lo
+test ! -f libgoodbye_la-baz.lo
+$MAKE distcheck
diff --git a/t/fortdep.sh b/t/fortdep.sh
new file mode 100755
index 000000000..d10644d88
--- /dev/null
+++ b/t/fortdep.sh
@@ -0,0 +1,39 @@
+#! /bin/sh
+# Copyright (C) 2000-2012 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/>.
+
+# Test to make sure dependency tracking doesn't interfere with Fortran.
+# For PR 75.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_CONFIG_SRCDIR([foo.f])
+AC_PROG_F77
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS=foo
+foo_SOURCES=foo.f
+END
+
+: > foo.f
+
+$ACLOCAL
+$AUTOMAKE
+
+grep 'foo\.Po' Makefile.in && Exit 1
+Exit 0
diff --git a/t/gcj.sh b/t/gcj.sh
new file mode 100755
index 000000000..b510f1c76
--- /dev/null
+++ b/t/gcj.sh
@@ -0,0 +1,36 @@
+#! /bin/sh
+# Copyright (C) 1999-2012 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/>.
+
+# Test of compiled java.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+_AM_DEPENDENCIES([GCJ])
+AC_SUBST([GCJ])
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = convert
+convert_SOURCES = x/y/convert.java
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+grep '^x/y/convert' Makefile.in
+
+:
diff --git a/t/gcj2.sh b/t/gcj2.sh
new file mode 100755
index 000000000..2c4d60f33
--- /dev/null
+++ b/t/gcj2.sh
@@ -0,0 +1,33 @@
+#! /bin/sh
+# Copyright (C) 1999-2012 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 '..' invalid in subdir .o's.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+_AM_DEPENDENCIES(GCJ)
+AC_SUBST(GCJ)
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = convert
+convert_SOURCES = x/../convert.java
+END
+
+$ACLOCAL
+AUTOMAKE_fails
+grep 'Makefile.am:.*\.\.' stderr
diff --git a/t/gcj3.sh b/t/gcj3.sh
new file mode 100755
index 000000000..a8ec120b6
--- /dev/null
+++ b/t/gcj3.sh
@@ -0,0 +1,37 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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 dependency tracking works for java.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+_AM_DEPENDENCIES([GCJ])
+AC_SUBST([GCJ])
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = convert
+convert_SOURCES = x/y/convert.java
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+num=`grep depcomp Makefile.in | wc -l`
+test $num -gt 1
+
+:
diff --git a/t/gcj4.sh b/t/gcj4.sh
new file mode 100755
index 000000000..a860f89e2
--- /dev/null
+++ b/t/gcj4.sh
@@ -0,0 +1,49 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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 dependency tracking works for Java.
+
+required=gcj
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AM_PROG_GCJ
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = convert
+convert_SOURCES = convert.java
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure >stdout
+cat stdout
+
+# Configure must be checking the dependency style of gcj ...
+grep 'dependency style of gcj' stdout >filt
+cat filt
+
+# ... only once.
+test `wc -l < filt` = 1
+
+# Accept any outcome but 'none'
+# (at the time of writing it should be gcc or gcc3).
+grep -v none filt
+
+:
diff --git a/t/gcj5.sh b/t/gcj5.sh
new file mode 100755
index 000000000..f3c218f30
--- /dev/null
+++ b/t/gcj5.sh
@@ -0,0 +1,32 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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 Automake suggests AM_PROG_GCJ when GCJ is needed.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+_AM_DEPENDENCIES(GCJ)
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = convert
+convert_SOURCES = convert.java
+END
+
+$ACLOCAL
+AUTOMAKE_fails
+grep AM_PROG_GCJ stderr
diff --git a/t/gcj6.sh b/t/gcj6.sh
new file mode 100755
index 000000000..3fe4a31f6
--- /dev/null
+++ b/t/gcj6.sh
@@ -0,0 +1,51 @@
+#! /bin/sh
+# Copyright (C) 2009-2012 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/>.
+
+# AM_PROG_GCJ should cause OBJEXT and EXEEXT to be set.
+
+required='gcj'
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AM_PROG_GCJ
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+noinst_PROGRAMS = test
+test_SOURCES = Test.java
+test_LDFLAGS = --main=Test
+END
+
+cat >Test.java << 'END'
+public class Test {
+ public static void main(String[] argv) {
+ System.out.println("Hello, automake!");
+ }
+}
+END
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+./configure
+
+# These fail without e.g., AC_PROG_CC.
+$MAKE
+grep "OBJEXT = " Makefile
+grep "EXEEXT = " Makefile
+
+:
diff --git a/t/gen-testsuite-part b/t/gen-testsuite-part
new file mode 100755
index 000000000..f97810645
--- /dev/null
+++ b/t/gen-testsuite-part
@@ -0,0 +1,414 @@
+#! /usr/bin/env perl
+# Automatically compute some dependencies for the hand-written tests
+# of the Automake testsuite. Also, automatically generate some more
+# tests from them (for particular cases/setups only).
+
+# Copyright (C) 2011-2012 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/>.
+
+#--------------------------------------------------------------------------
+
+use warnings FATAL => "all";
+use strict;
+use File::Basename ();
+use constant TRUE => 1;
+use constant FALSE => 0;
+
+my $me = File::Basename::basename $0;
+
+# For use in VPATH builds.
+my $srcdir = ".";
+
+#--------------------------------------------------------------------------
+
+sub unindent ($)
+{
+ my $text = shift;
+ $text =~ /^(\s*)/;
+ my $indentation = $1;
+ $text =~ s/^$indentation//gm;
+ return $text;
+}
+
+sub atomic_write ($$;$)
+{
+ my ($outfile, $func) = (shift, shift);
+ my $perms = @_ > 0 ? shift : 0777;
+ my $tmpfile = "$outfile-t";
+ foreach my $f ($outfile, $tmpfile)
+ {
+ unlink $f or die "$me: cannot unlink '$f': $!\n"
+ if -e $f;
+ }
+ open (my $fh, ">$tmpfile")
+ or die "$me: can't write to '$tmpfile': $!\n";
+ $func->($fh);
+ close $fh
+ or die "$me: closing '$tmpfile': $!\n";
+ chmod ($perms & ~umask, $tmpfile)
+ or die "$me: cannot change perms for '$tmpfile': $!\n";
+ rename ($tmpfile, $outfile)
+ or die "$me: renaming '$tmpfile' -> '$outfile: $!\n'";
+}
+
+sub line_match ($$)
+{
+ my ($re, $file) = (shift, shift);
+ # Try both curdir and srcdir, with curdir first, to play nice
+ # with VPATH builds.
+ open (FH, "<$file") or open (FH, "<$srcdir/$file")
+ or die "$me: cannot open file '$file': $!\n";
+ my $ret = 0;
+ while (defined (my $line = <FH>))
+ {
+ if ($line =~ $re)
+ {
+ $ret = 1;
+ last;
+ }
+ }
+ close FH or die "$me: cannot close file '$file': $!\n";
+ return $ret;
+}
+
+sub write_wrapper_script ($$$)
+{
+ my ($file_handle, $wrapped_test, $shell_setup_code, $creator_name) = @_;
+ # FIXME: we use some creative quoting in the generated scripts,
+ # FIXME: to please maintainer-check.
+ print $file_handle unindent <<EOF;
+ #! /bin/sh
+ # This file has been automatically generated. DO NOT EDIT BY HAND!
+ . ./defs-static || exit '99';
+ $shell_setup_code
+ # In the spirit of VPATH, we prefer a test in the build tree
+ # over one in the source tree.
+ for dir in . "\$testsrcdir"; do
+ if test -f "\$dir/$wrapped_test"; then
+ echo "\$0: will source \$dir/$wrapped_test"
+ . "\$dir/$wrapped_test"; exit "\$?"
+ fi
+ done
+ echo "\$0: cannot find wrapped test '$wrapped_test'" >&2
+ exit '99'
+EOF
+}
+
+sub get_list_of_tests ()
+{
+ my $make = defined $ENV{MAKE} ? $ENV{MAKE} : "make";
+ # Unset MAKEFLAGS, for when we are called from make itself.
+ my $cmd = "MAKEFLAGS= && unset MAKEFLAGS && cd '$srcdir' && "
+ . "$make -s -f list-of-tests.mk print-list-of-tests";
+ my @tests_list = split /\s+/, `$cmd`;
+ die "$me: cannot get list of tests\n" unless $? == 0 && @tests_list;
+ my $ok = 1;
+ foreach my $test (@tests_list)
+ {
+ # Respect VPATH builds.
+ next if -f $test || -f "$srcdir/$test";
+ warn "$me: test `$test' not found\n";
+ $ok = 0;
+ }
+ die "$me: some test scripts not found\n" if !$ok;
+ return @tests_list;
+}
+
+sub parse_options (@)
+{
+ use Getopt::Long qw/GetOptions/;
+ local @ARGV = @_;
+ GetOptions ('srcdir=s' => \$srcdir) or die "$me: usage error\n";
+ die "$me: too many arguments\n" if @ARGV > 0;
+ die "$me: srcdir '$srcdir': not a directory\n" unless -d $srcdir;
+}
+
+#--------------------------------------------------------------------------
+
+# Where testsuite-related helper scripts, data files and shell libraries
+# are placed. Relative to the 't/' subdirectory.
+my $auxdir = "ax";
+
+my %deps_extractor =
+ (
+ libtool_macros =>
+ {
+ line_matcher => qr/^\s*required=.*\blibtool/,
+ nodist_prereqs => "libtool-macros.log",
+ },
+ gettext_macros =>
+ {
+ line_matcher => qr/^\s*required=.*\bgettext/,
+ nodist_prereqs => "gettext-macros.log",
+ },
+ use_trivial_test_driver =>
+ {
+ line_matcher => qr/\btrivial-test-driver\b/,
+ dist_prereqs => "$auxdir/trivial-test-driver",
+ },
+ check_testsuite_summary =>
+ {
+ line_matcher => qr/\btestsuite-summary-checks\.sh\b/,
+ dist_prereqs => "$auxdir/testsuite-summary-checks.sh",
+ },
+ extract_testsuite_summary =>
+ {
+ line_matcher => qr/\bextract-testsuite-summary\.pl\b/,
+ dist_prereqs => "$auxdir/extract-testsuite-summary.pl",
+ },
+ check_tap_testsuite_summary =>
+ {
+ line_matcher => qr/\btap-summary-aux\.sh\b/,
+ dist_prereqs => "$auxdir/tap-summary-aux.sh",
+ },
+ on_tap_with_common_setup =>
+ {
+ line_matcher => qr/\btap-setup\.sh\b/,
+ dist_prereqs => "$auxdir/tap-setup.sh",
+ nodist_prereqs => "tap-common-setup.log",
+ },
+ depcomp =>
+ {
+ line_matcher => qr/\bdepcomp\.sh\b/,
+ dist_prereqs => "$auxdir/depcomp.sh",
+ },
+ );
+
+#--------------------------------------------------------------------------
+
+my %test_generators =
+ (
+ #
+ # For each test script in the Automake testsuite that itself tests
+ # features of the TESTS automake interface, define a sibling test
+ # that does likewise, but with the option 'parallel-tests' enabled.
+ #
+ # A test is considered a candidate for sibling-generation if any
+ # Makefile.am generated by it define the TESTS variable.
+ #
+ # Individual tests can prevent the creation of such a sibling by
+ # explicitly setting the '$am_parallel_tests' variable to either "yes"
+ # or "no". The rationale for this is that if the variable is set to
+ # "yes", the test already uses the 'parallel-tests' option, so that
+ # a sibling would be just a duplicate; while if the variable is set
+ # to "no", the test doesn't support, or is not meant to run with, the
+ # 'parallel-tests' option, and forcing it to do so in the sibling
+ # would likely cause a spurious failure.
+ #
+ parallel_testsuite_harness =>
+ {
+ line_matcher =>
+ qr/(?:^|\s)TESTS\s*=/,
+ line_rejecter =>
+ qr/(?:^[^#]*\bparallel-tests\b)|\bam_parallel_tests=/,
+ shell_setup_code =>
+ 'am_parallel_tests=yes'
+ },
+ #
+ # For each test script in the Automake testsuite that tests features
+ # of one or more automake-provided shell script from the 'lib/'
+ # subdirectory by running those scripts directly (i.e., not thought
+ # make calls and automake-generated makefiles), define a sibling test
+ # that does likewise, but running the said script with the configure
+ # time $SHELL instead of the default system shell /bin/sh.
+ #
+ # A test is considered a candidate for sibling-generation if it calls
+ # the 'get_shell_script' function anywhere.
+ #
+ # Individual tests can prevent the creation of such a sibling by
+ # explicitly setting the '$am_test_prefer_config_shell' variable
+ # to either "yes" or "no".
+ # The rationale for this is that if the variable is set to "yes",
+ # the test already uses $SHELL, so that a sibling would be just a
+ # duplicate; while if the variable is set to "no", the test doesn't
+ # support, or is not meant to use, $SHELL to run the script under
+ # testing, and forcing it to do so in the sibling would likely
+ # cause a spurious failure.
+ #
+ prefer_config_shell =>
+ {
+ line_matcher =>
+ qr/(^|\s)get_shell_script\s/,
+ line_rejecter =>
+ qr/\bam_test_prefer_config_shell=/,
+ shell_setup_code =>
+ 'am_test_prefer_config_shell=yes',
+ },
+ #
+ # Tests on tap support should be run with both the perl and awk
+ # implementations of the TAP driver (they run with the awk one
+ # by default).
+ #
+ perl_tap_driver =>
+ {
+ line_matcher =>
+ qr<(?:\bfetch_tap_driver\b|[\s/]tap-setup\.sh\b)>,
+ line_rejecter =>
+ qr/\bam_tap_implementation=/,
+ shell_setup_code =>
+ 'am_tap_implementation=perl',
+ },
+ );
+
+#--------------------------------------------------------------------------
+
+parse_options @ARGV;
+
+my @all_tests = get_list_of_tests;
+my @generated_tests = (); # Will be updated later.
+
+print "## -*- Makefile -*-\n";
+print "## Generated by $me. DO NOT EDIT BY HAND!\n\n";
+
+print <<EOF;
+
+## --------------------------------------------- ##
+## Autogenerated tests and their dependencies. ##
+## --------------------------------------------- ##
+
+EOF
+
+# FIXME: the following is not really right, since cannot compose wrapping
+# of tests matching more than one condition. Still, there should be no
+# such test at the moment, so the limitation is (temporarily) acceptable.
+while (my ($k, $g) = each %test_generators)
+ {
+ my @wrapped_tests = grep {
+ line_match ($g->{line_matcher}, $_)
+ && !line_match ($g->{line_rejecter}, $_)
+ } @all_tests;
+ foreach my $wrapped_test (@wrapped_tests)
+ {
+ (my $base = $wrapped_test) =~ s/\.([^.]*)$//;
+ my $suf = $1 or die "$me: test '$wrapped_test' lacks a suffix\n";
+ my $wrapper_test = "$base-w.$suf";
+ # Register wrapper test as "autogenerated".
+ push @generated_tests, $wrapper_test;
+ # Create wrapper test.
+ atomic_write $wrapper_test,
+ sub { write_wrapper_script $_[0], $wrapped_test,
+ $g->{shell_setup_code} },
+ 0555;
+ # The generated test works by sourcing the original test, so that
+ # it has to be re-run every time that changes ...
+ print "$base-w.log: $wrapped_test\n";
+ # ... but also every time the prerequisites of the wrapped test
+ # changes. The simpler (although suboptimal) way to do so is to
+ # ensure that the wrapped tests runs before the wrappee one (in
+ # case it needs to be re-run *at all*.
+ # FIXME: we could maybe refactor the script to find a more
+ # granular way to express such implicit dependencies.
+ print "$base-w.log: $base.log\n";
+ }
+ }
+
+print <<EOF;
+
+## ---------------------------------------------------- ##
+## Ad-hoc autogenerated tests and their dependencies. ##
+## ---------------------------------------------------- ##
+
+EOF
+
+print "## Tests on automatic dependency tracking (see 'depcomp.sh').\n";
+
+# Key: depmode, value: list of required programs.
+my %depmodes =
+ (
+ auto => ["cc"],
+ disabled => ["cc"],
+ makedepend => ["cc", "makedepend"],
+ dashmstdout => ["gcc"],
+ cpp => ["gcc"],
+# This is for older (pre-3.x) GCC versions. Newer versions
+# have depmode "gcc3".
+ gcc => ["gcc"],
+# This is for older (pre-7) msvc versions. Newer versions
+# have depmodes "msvc7" and "msvc7msys".
+ msvisualcpp => ["cl", "cygpath"],
+ msvcmsys => ["cl", "mingw"],
+ );
+
+foreach my $lt (TRUE, FALSE)
+ {
+ foreach my $m (keys %depmodes)
+ {
+ my $planned = ($lt && $m eq "auto") ? 84 : 28;
+ my @required =
+ (
+ @{$depmodes{$m}},
+ $lt ? ("libtoolize",) : (),
+ );
+ my @vars_init =
+ (
+ "am_create_testdir=empty",
+ "depmode=$m",
+ "depcomp_with_libtool=" . ($lt ? "yes" : "no"),
+ );
+ my $base = "depcomp" . ($lt ? "-lt-" : "-") . $m;
+ # Register wrapper test as "autogenerated" ...
+ push @generated_tests, "$base.tap";
+ atomic_write ("$base.tap", sub
+ {
+ my $file_handle = shift;
+ print $file_handle unindent <<EOF;
+ #! /bin/sh
+ # Automatically generated test. DO NOT EDIT BY HAND!
+ @vars_init
+ required="@required"
+ . ./defs || Exit 1
+ plan_ $planned
+ . "\$am_testauxdir/depcomp.sh"; exit "\$?"
+EOF
+ },
+ 0555);
+ }
+ }
+
+# Update generated makefile fragment to account for all the generated tests.
+print "generated_TESTS =\n";
+map { print "generated_TESTS += $_\n" } @generated_tests;
+
+# The test scripts are scanned for automatic dependency generation *after*
+# the generated tests have been created, so they too can be scanned. To
+# do so correctly, we need to update the list in '@all_tests' to make it
+# comprise also the freshly-generated tests.
+
+push @all_tests, @generated_tests;
+
+print <<EOF;
+
+## ----------------------------- ##
+## Autogenerated dependencies. ##
+## ----------------------------- ##
+
+EOF
+
+while (my ($k, $x) = each %deps_extractor)
+ {
+ my $dist_prereqs = $x->{dist_prereqs} || "";
+ my $nodist_prereqs = $x->{nodist_prereqs} || "";
+ my @tests = grep { line_match $x->{line_matcher}, $_ } @all_tests;
+ map { s/\.[^.]*$//; s/$/\.log/; } (my @logs = @tests);
+ print "## Added by deps-extracting key '$k'.\n";
+ ## The list of all tests which have a dependency detected by the
+ ## current key.
+ print join(" \\\n ", "${k}_TESTS =", @tests) . "\n";
+ print "EXTRA_DIST += $dist_prereqs\n";
+ map { print "$_: $dist_prereqs $nodist_prereqs\n" } @logs;
+ print "\n";
+ }
+
+__END__
diff --git a/t/get-sysconf.sh b/t/get-sysconf.sh
new file mode 100755
index 000000000..ae3310e5d
--- /dev/null
+++ b/t/get-sysconf.sh
@@ -0,0 +1,62 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Dummy test case, aimed at reporting useful system information in the
+# final 'test-suite.log'. This way, if a user experiences a failure in
+# the Automake test suite and then only sends us the 'test-suite.log',
+# we won't have to ask him for more information to start analyzing the
+# failure (that had happened too many times in the past!).
+
+. ./defs || Exit 1
+
+st=0
+if test -d "$top_testsrcdir"/.git; then
+ # We are running from a git checkout.
+ (cd "$top_testsrcdir" && git log -1) || st=1
+elif test -f "$top_testsrcdir"/ChangeLog; then
+ # We are probably running from a distribution tarball.
+ awk '
+ BEGIN { first = 1 }
+ (first == 1) { print; first = 0; next; }
+ /^[^\t]/ { exit(0); }
+ { print }
+ ' "$top_testsrcdir"/ChangeLog || st=1
+else
+ # Some non-common but possibly valid setup (see for example the Homebrew
+ # problem reported in automake bug#10866); so just give an harmless
+ # warning instead of failing.
+ warn_ "no .git directory nor ChangeLog file found, some info won't" \
+ "be available"
+fi
+$PERL -V || st=1
+# It's OK for the user not to have the TAP::Parser module; this can
+# happen with older perl installation, or on MinGW/MSYS.
+$PERL -e 'use TAP::Parser; print $TAP::Parser::VERSION, "\n"' || :
+
+cat "$top_testbuilddir/config.log" || st=1
+cat "$testbuilddir/wrap/aclocal-$APIVERSION" || st=1
+cat "$testbuilddir/wrap/automake-$APIVERSION" || st=1
+
+if test $st -eq 0; then
+ # This test SKIPs, so that all the information it has gathered and
+ # printed will get unconditionally copied into the 'test-suite.log'
+ # file.
+ Exit 77
+fi
+
+# Some unexpected error occurred; this must be reported as an hard
+# error by the testsuite driver.
+Exit 99
diff --git a/t/gettext-macros.sh b/t/gettext-macros.sh
new file mode 100755
index 000000000..38749d36c
--- /dev/null
+++ b/t/gettext-macros.sh
@@ -0,0 +1,94 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Try to find the gettext '.m4' files and make them easily accessed
+# to the test cases requiring them.
+# See also automake bug#9807.
+
+. ./defs || Exit 1
+
+extract_program_version ()
+{
+ "$1" --version | sed 1q | $PERL -ne '/(\d(?:\.\d+)+)/ and print "$1\n"'
+}
+
+echo "# Automatically generated by $me." > get.sh
+echo : >> get.sh
+
+# The 'gettextize' and 'autopoint' scripts will look into Makefile.am.
+echo ACLOCAL_AMFLAGS = -I m4 > Makefile.am
+
+# Prefer autopoint to gettextize, since the more modern versions of the
+# latter might unconditionally require user interaction to complete;
+# yes, this means confirmation from /dev/tty (!) -- see:
+# <http://lists.gnu.org/archive/html/bug-gettext/2011-12/msg00000.html>
+# Since this "forced interaction" behaviour of gettextize wasn't present
+# before the introduction of autopoint, we should be able to safely
+# fall back to calling gettextize non-interactively if autopoint is not
+# present.
+if autopoint --version; then
+ am_gettextize_command=autopoint
+else
+ am_gettextize_command=gettextize
+fi
+
+# We will need to specify the correct autopoint (or gettextize) version
+# in the AM_GNU_GETTEXT_VERSION call in configure.ac if we want autopoint
+# (or gettextize) to setup the correct infrastructure -- in particular,
+# for what concerns us, to bring in all the required .m4 files.
+autopoint_version=`extract_program_version $am_gettextize_command` \
+ && test -n "$autopoint_version" \
+ || autopoint_version=0.10.35
+
+cat > configure.ac <<END
+AC_INIT([foo], [1.0])
+AC_PROG_CC
+# Both required by autopoint.
+AM_GNU_GETTEXT
+AM_GNU_GETTEXT_VERSION([$autopoint_version])
+END
+
+if $am_gettextize_command --force && test -f m4/gettext.m4; then
+ echo "ACLOCAL_PATH='`pwd`/m4':\$ACLOCAL_PATH" >> get.sh
+ echo "export ACLOCAL_PATH" >> get.sh
+else
+ # Older versions of gettext might not have a gettextize program
+ # available, but this doesn't mean the user hasn't made the gettext
+ # macros available, e.g., by properly setting ACLOCAL_PATH.
+ rm -rf m4
+ mkdir m4
+ # See below for an explanation about the use the of '-Wno-syntax'.
+ if $ACLOCAL -Wno-syntax -I m4 --install && test -f m4/gettext.m4; then
+ : # Gettext macros already accessible by default.
+ else
+ echo "skip_all_ \"couldn't find or get gettext macros\"" >> get.sh
+ fi
+fi
+
+. ./get.sh
+
+$ACLOCAL --force -I m4 || cat >> get.sh <<'END'
+# We need to use '-Wno-syntax', since we do not want our test suite
+# to fail merely because some third-party '.m4' file is underquoted.
+ACLOCAL="$ACLOCAL -Wno-syntax"
+END
+
+# The file gettextize or autopoint might have copied in the 'm4'
+# subdirectory of the test directory are going to be needed by
+# other tests, so we must not remove the test directory.
+keep_testdirs=yes
+
+:
diff --git a/t/gettext.sh b/t/gettext.sh
new file mode 100755
index 000000000..a9181e48d
--- /dev/null
+++ b/t/gettext.sh
@@ -0,0 +1,87 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Check gettext support.
+
+required='gettext'
+. ./defs || Exit 1
+
+cat >>configure.ac <<END
+AM_GNU_GETTEXT
+AM_GNU_GETTEXT_VERSION([0.14.3])
+AC_OUTPUT
+END
+
+: >Makefile.am
+mkdir po intl
+
+# config.rpath is required by versions >= 0.14.3. We try to verify
+# this requirement, but only when we find we have a working and recent
+# gettext installation.
+
+# If aclocal fails here, it may be that gettext is too old to
+# provide AM_GNU_GETTEXT_VERSION.
+if $ACLOCAL; then
+
+ # autopoint will fail if it's from an older version.
+ # If gettext is too old to provide autopoint, this will
+ # fail as well, so we're safe here.
+ if autopoint -n; then
+ AUTOMAKE_fails --add-missing
+ grep 'required.*config.rpath' stderr
+ fi
+fi
+
+: >config.rpath
+sed '/AM_GNU_GETTEXT_VERSION/d' configure.ac >configure.int
+mv -f configure.int configure.ac
+
+$ACLOCAL
+
+# po/ and intl/ are required.
+
+AUTOMAKE_fails --add-missing
+grep 'AM_GNU_GETTEXT.*SUBDIRS' stderr
+
+echo 'SUBDIRS = po' >Makefile.am
+AUTOMAKE_fails --add-missing
+grep 'AM_GNU_GETTEXT.*intl' stderr
+
+echo 'SUBDIRS = intl' >Makefile.am
+AUTOMAKE_fails --add-missing
+grep 'AM_GNU_GETTEXT.*po' stderr
+
+# Ok.
+
+echo 'SUBDIRS = po intl' >Makefile.am
+$AUTOMAKE --add-missing
+
+# Make sure distcheck runs './configure --with-included-gettext'.
+grep 'with-included-gettext' Makefile.in
+
+# 'SUBDIRS = po intl' isn't required if po/ doesn't exist.
+# PR/381.
+
+rmdir po
+mkdir sub
+echo 'SUBDIRS = sub' >Makefile.am
+$AUTOMAKE
+
+# Still, SUBDIRS must be defined.
+
+: >Makefile.am
+AUTOMAKE_fails --add-missing
+grep 'AM_GNU_GETTEXT.*SUBDIRS' stderr
diff --git a/t/gettext2.sh b/t/gettext2.sh
new file mode 100755
index 000000000..8b8a06284
--- /dev/null
+++ b/t/gettext2.sh
@@ -0,0 +1,61 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Check gettext 'external' support.
+# PR/338, reported by Charles Wilson.
+
+required='gettext'
+. ./defs || Exit 1
+
+cat >>configure.ac <<END
+AM_GNU_GETTEXT([external])
+AC_OUTPUT
+END
+
+: >Makefile.am
+mkdir foo po
+
+$ACLOCAL
+
+# config.rpath is required.
+: >config.rpath
+
+# po/ is required, but intl/ isn't.
+
+AUTOMAKE_fails --add-missing
+grep 'AM_GNU_GETTEXT.*SUBDIRS' stderr
+
+echo 'SUBDIRS = foo' >Makefile.am
+AUTOMAKE_fails --add-missing
+grep 'AM_GNU_GETTEXT.*po' stderr
+
+# Ok.
+
+echo 'SUBDIRS = po' >Makefile.am
+$AUTOMAKE --add-missing
+
+# Don't try running ./configure --with-included-gettext if the
+# user is using AM_GNU_GETTEXT([external]).
+grep 'with-included-gettext' Makefile.in && Exit 1
+
+# intl/ isn't wanted with AM_GNU_GETTEXT([external]).
+
+mkdir intl
+echo 'SUBDIRS = po intl' >Makefile.am
+AUTOMAKE_fails --add-missing
+grep 'intl.*AM_GNU_GETTEXT' stderr
+
+:
diff --git a/t/gettext3.sh b/t/gettext3.sh
new file mode 100755
index 000000000..9a39af2ae
--- /dev/null
+++ b/t/gettext3.sh
@@ -0,0 +1,47 @@
+#! /bin/sh
+# Copyright (C) 2006-2012 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/>.
+
+# Check gettext 'AM_GNU_GETTEXT_INTL_SUBDIR' support.
+
+required='gettext'
+. ./defs || Exit 1
+
+cat >>configure.ac <<END
+AM_GNU_GETTEXT([external])
+AM_GNU_GETTEXT_INTL_SUBDIR
+AC_OUTPUT
+END
+
+echo 'SUBDIRS = po' >Makefile.am
+mkdir po
+
+# If aclocal fails, assume the gettext macros are too old and do not
+# define AM_GNU_GETTEXT_INTL_SUBDIR.
+$ACLOCAL || skip_ "your gettext macros are probably too old"
+
+# config.rpath is required.
+: >config.rpath
+
+# intl/ is required.
+AUTOMAKE_fails --add-missing
+grep 'AM_GNU_GETTEXT.*intl.*SUBDIRS' stderr
+
+mkdir intl
+AUTOMAKE_fails --add-missing
+grep 'AM_GNU_GETTEXT.*intl.*SUBDIRS' stderr
+
+echo 'SUBDIRS = po intl' > Makefile.am
+$AUTOMAKE --add-missing
diff --git a/t/gnits.sh b/t/gnits.sh
new file mode 100755
index 000000000..badb8b0c3
--- /dev/null
+++ b/t/gnits.sh
@@ -0,0 +1,42 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test to ensure --gnits version checking is correct.
+
+. ./defs || Exit 1
+
+cat > configure.ac << END
+AC_INIT([$me], [3.5.3.2])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES(Makefile)
+END
+
+cat > Makefile.am << 'END'
+pkgdata_DATA =
+END
+
+# Files required by Gnits.
+: > INSTALL
+: > NEWS
+: > README
+: > COPYING
+: > AUTHORS
+: > ChangeLog
+: > THANKS
+
+$ACLOCAL
+AUTOMAKE_fails --gnits
+grep 'configure.ac:.*3\.5\.3\.2' stderr
diff --git a/t/gnits2.sh b/t/gnits2.sh
new file mode 100755
index 000000000..ef7078cc2
--- /dev/null
+++ b/t/gnits2.sh
@@ -0,0 +1,114 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Test to ensure std-options checking is correct.
+
+required='cc native'
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = gnits
+noinst_PROGRAMS = fubar2
+bin_PROGRAMS = fubar sub/fine
+nobase_bin_PROGRAMS = sub/fubar3
+fubar_SOURCES = fubar.c
+fubar2_SOURCES = fubar.c
+sub_fubar3_SOURCES = fubar.c
+sub_fine_SOURCES = fine.c
+bin_SCRIPTS = sub/scriptok.sh sub/scriptnok.sh
+
+grep-stderr:
+ grep 'pfubar$(EXEEXT) does not support' stderr
+ grep 'pfubar3$(EXEEXT) does not support' stderr
+ grep 'pscriptnok\.sh does not support' stderr
+## Only three failures please.
+ test `grep 'does not support --help' stderr | wc -l` = 3
+ test `grep 'does not support --version' stderr | wc -l` = 3
+
+test-install: install
+ test -f ../inst-dir/bin/pfine$(EXEEXT)
+ test ! -f ../inst-dir/bin/fine$(EXEEXT)
+END
+
+cat > fubar.c <<'END'
+int main (void)
+{
+ return 0;
+}
+END
+
+cat > fine.c << 'END'
+#include <stdio.h>
+int main (void)
+{
+ puts ("Which version? Which usage?");
+ return 0;
+}
+END
+
+mkdir sub
+
+cat >sub/scriptok.sh <<EOF
+#!/bin/sh
+echo "Which version? Which usage?"
+EOF
+
+# Not only does this script not support --help/--version, but
+# it will also hang when run without input.
+cat >sub/scriptnok.sh <<EOF
+#!/bin/sh
+cat
+EOF
+
+chmod +x sub/scriptok.sh
+chmod +x sub/scriptnok.sh
+
+# Files required by Gnits.
+: > INSTALL
+: > NEWS
+: > README
+: > COPYING
+: > AUTHORS
+: > ChangeLog
+: > THANKS
+
+# The following file should not be distributed.
+# (alpha.test checks the case where it must be distributed.)
+: > README-alpha
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+grep README-alpha Makefile.in && Exit 1
+
+mkdir build
+cd build
+
+# Use --program-prefix to make sure the std-options check honors it.
+../configure "--prefix=`pwd`/../inst-dir" --program-prefix=p
+$MAKE all
+$MAKE test-install
+$MAKE -k installcheck 2>stderr || : # Never trust the exit status of make -k.
+cat stderr >&2
+$MAKE grep-stderr
+
+:
diff --git a/t/gnits3.sh b/t/gnits3.sh
new file mode 100755
index 000000000..f4797629d
--- /dev/null
+++ b/t/gnits3.sh
@@ -0,0 +1,104 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Check that AM_INSTALLCHECK_STD_OPTIONS_EXEMPT works.
+
+required=cc
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_OUTPUT
+END
+
+# We use the same basename for all targets on purpose. This way
+# we make sure that 'AM_INSTALLCHECK_STD_OPTIONS_EXEMPT = nok'
+# will not match anything containing 'nok'.
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = gnits
+
+nobase_bin_PROGRAMS = nok sub/nok
+nok_SOURCES = nok.c
+sub_nok_SOURCES = nok.c
+
+nobase_bin_SCRIPTS = nok.sh sub/nok.sh
+
+AM_INSTALLCHECK_STD_OPTIONS_EXEMPT = nok$(EXEEXT) nok.sh
+
+grep-stderr:
+ grep 'sub/pnok$(EXEEXT) does not support' stderr
+ grep 'sub/pnok\.sh does not support' stderr
+## Only two failures please.
+ test `grep 'does not support --help' stderr | wc -l` = 2
+ test `grep 'does not support --version' stderr | wc -l` = 2
+END
+
+cat > nok.c <<'END'
+int main (void)
+{
+ return 0;
+}
+END
+
+mkdir sub
+
+cat >nok.sh <<EOF
+#!/bin/sh
+echo "Which version? Which usage?"
+exit 1
+EOF
+
+cp nok.sh sub/nok.sh
+
+chmod +x nok.sh
+chmod +x sub/nok.sh
+
+# Files required by Gnits.
+: > INSTALL
+: > NEWS
+: > README
+: > COPYING
+: > AUTHORS
+: > ChangeLog
+: > THANKS
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+mkdir build
+cd build
+
+# Use --program-prefix to make sure the std-options check honors it.
+../configure "--prefix=`pwd`/../inst-dir" --program-prefix=p
+$MAKE
+$MAKE install
+$MAKE installcheck && Exit 1
+$MAKE -k installcheck 2>stderr || : # Never trust the exit status of make -k.
+cat stderr >&2
+$MAKE grep-stderr
+
+# Make sure there is no more error when all targets are exempted.
+cd ..
+cat >> Makefile.am <<'END'
+AM_INSTALLCHECK_STD_OPTIONS_EXEMPT += sub/nok$(EXEEXT) sub/nok.sh
+END
+$AUTOMAKE
+cd build
+./config.status # Don't rely on the rebuild rules (they need GNU make).
+$MAKE installcheck
+
+:
diff --git a/t/gnumake.sh b/t/gnumake.sh
new file mode 100755
index 000000000..b1ea0002f
--- /dev/null
+++ b/t/gnumake.sh
@@ -0,0 +1,43 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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/>.
+
+# Automake should not assume that make files are called Makefile.
+# Report from Braden McDaniel.
+
+required=GNUmake
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_CONFIG_FILES([sub/GNUmakefile])
+AC_OUTPUT
+END
+
+mkdir sub
+
+echo SUBDIRS = sub > Makefile.am
+
+cat > sub/GNUmakefile.am <<'EOF'
+# In this project, the Makefile is an installed data file.
+dist_data_DATA = Makefile
+EOF
+
+echo 'this should not cause any problem' > sub/Makefile
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+$MAKE distcheck
diff --git a/t/gnuwarn.sh b/t/gnuwarn.sh
new file mode 100755
index 000000000..5aac432b7
--- /dev/null
+++ b/t/gnuwarn.sh
@@ -0,0 +1,54 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Check that Automake warns about user variables being overridden.
+
+. ./defs || Exit 1
+
+# We need (almost) complete control over automake options.
+AUTOMAKE="$am_original_AUTOMAKE -Werror"
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_OUTPUT
+END
+
+# Needed by --gnu.
+: > NEWS
+: > README
+: > AUTHORS
+: > ChangeLog
+
+cat > Makefile.am << 'END'
+CFLAGS += -I..
+LDFLAGS = -lfoo
+CXXFLAGS = -Wall
+bin_PROGRAMS = bar
+END
+
+$ACLOCAL
+# Don't warn in foreign mode
+$AUTOMAKE --add-missing --foreign
+# Warn in gnu mode
+AUTOMAKE_fails --add-missing --gnu
+grep '^Makefile\.am:1:.*CFLAGS' stderr
+grep '^Makefile\.am:2:.*LDFLAGS' stderr
+# No reason to warn about CXXFLAGS since it's not used.
+grep CXXFLAGS stderr && Exit 1
+# Don't warn if -Wno-gnu.
+$AUTOMAKE --gnu -Wno-gnu
+
+:
diff --git a/t/gnuwarn2.sh b/t/gnuwarn2.sh
new file mode 100755
index 000000000..6a68d6580
--- /dev/null
+++ b/t/gnuwarn2.sh
@@ -0,0 +1,42 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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/>.
+
+# Check diagnostics about no-installman being disallowed in 'gnu'.
+
+. ./defs || Exit 1
+
+cat > configure.ac << 'END'
+AC_INIT([gnuwarn2], [1.0])
+AM_INIT_AUTOMAKE([no-installman])
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+END
+
+# --gnu files
+: > NEWS
+: > README
+: > AUTHORS
+: > ChangeLog
+: > COPYING
+: > INSTALL
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = gnu
+END
+
+$ACLOCAL
+AUTOMAKE_fails
+grep 'configure.ac:2:.*no-installman' stderr
diff --git a/t/hdr-vars-defined-once.sh b/t/hdr-vars-defined-once.sh
new file mode 100755
index 000000000..1e31cd201
--- /dev/null
+++ b/t/hdr-vars-defined-once.sh
@@ -0,0 +1,50 @@
+#! /bin/sh
+# Copyright (C) 1999-2012 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/>.
+
+# Test to make sure header vars defined only once when including.
+# Report from Marcus G. Daniels.
+
+. ./defs || Exit 1
+
+cat >> configure.ac <<END
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+include Will_Be_Included_In_Makefile
+END
+
+: > Will_Be_Included_In_Makefile
+
+$ACLOCAL
+$AUTOMAKE
+len=`grep '^srcdir' Makefile.in | wc -l`
+test $len -eq 1
+
+# Also make sure include file is distributed.
+sed -n -e '/^DIST_COMMON =.*\\$/ {
+ :loop
+ p
+ n
+ t clear
+ :clear
+ s/\\$/\\/
+ t loop
+ p
+ n
+ }' -e '/^DIST_COMMON =/ p' Makefile.in | grep Will_Be_Included_In_Makefile
+
+:
diff --git a/t/header.sh b/t/header.sh
new file mode 100755
index 000000000..dc93ac87a
--- /dev/null
+++ b/t/header.sh
@@ -0,0 +1,45 @@
+#! /bin/sh
+# Copyright (C) 2000-2012 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/>.
+
+# Test for PR 68.
+#
+# == Report ==
+# If an autoconf substitution variable of the form "*_HEADERS" --
+# for example "MY_HEADERS" -- is used in an "include_" variable
+# in conjunction with EXTRA_HEADERS, $(MY_HEADERS) gets included
+# in the HEADERS variable for *all* generated Makefile.ins in the
+# project.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_SUBST([MY_HEADERS])
+AC_PROG_CC
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = zoo
+zoo_SOURCES = joe.c
+END
+
+: > joe.c
+: > qq.h
+
+$ACLOCAL
+$AUTOMAKE
+
+grep '[^@]MY_HEADERS' Makefile.in && Exit 1
+Exit 0
diff --git a/t/help-depend.sh b/t/help-depend.sh
new file mode 100755
index 000000000..c69d564d8
--- /dev/null
+++ b/t/help-depend.sh
@@ -0,0 +1,37 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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 that our private macro 'AM_DEP_TRACK' adds proper text to
+# the configure help screen.
+# Keep this in sync with sister test 'help-depend2.test'
+
+. ./defs || Exit 1
+
+cat > configure.ac <<END
+AC_INIT([$me], [1.0])
+AM_DEP_TRACK
+END
+
+$ACLOCAL
+$AUTOCONF
+
+grep_configure_help --enable-dependency-tracking \
+ ' not reject slow dependency extract'
+
+grep_configure_help --disable-dependency-tracking \
+ ' speeds up one-time build'
+
+:
diff --git a/t/help-depend2.sh b/t/help-depend2.sh
new file mode 100755
index 000000000..58a8342a8
--- /dev/null
+++ b/t/help-depend2.sh
@@ -0,0 +1,38 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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 that when automake automatically activates support for
+# dependency tracking, it adds proper text to the configure help screen.
+# Keep this in sync with sister test 'help-depend.test'
+
+. ./defs || Exit 1
+
+cat > configure.ac <<END
+AC_INIT([$me], [1.0])
+AM_INIT_AUTOMAKE
+AC_PROG_CC
+END
+
+$ACLOCAL
+$AUTOCONF
+
+grep_configure_help --enable-dependency-tracking \
+ ' not reject slow dependency extract'
+
+grep_configure_help --disable-dependency-tracking \
+ ' speeds up one-time build'
+
+:
diff --git a/t/help-dmalloc.sh b/t/help-dmalloc.sh
new file mode 100755
index 000000000..a9ab69f60
--- /dev/null
+++ b/t/help-dmalloc.sh
@@ -0,0 +1,32 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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 that our macro 'AM_WITH_DMALLOC' adds proper text to
+# the configure help screen.
+
+. ./defs || Exit 1
+
+cat > configure.ac <<END
+AC_INIT([$me], [1.0])
+AM_WITH_DMALLOC
+END
+
+$ACLOCAL
+$AUTOCONF
+
+grep_configure_help --with-dmalloc ' use dmalloc.*http://www\.dmalloc\.com'
+
+:
diff --git a/t/help-init.sh b/t/help-init.sh
new file mode 100755
index 000000000..d1cff1cd0
--- /dev/null
+++ b/t/help-init.sh
@@ -0,0 +1,37 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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 that our grand macro 'AM_INIT_AUTOMAKE' add proper text
+# to the configure help screen.
+
+. ./defs || Exit 1
+
+cat > configure.ac <<END
+AC_INIT([$me], [1.0])
+AM_INIT_AUTOMAKE
+END
+
+$ACLOCAL
+$AUTOCONF
+
+./configure --help >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+grep '^ --program-prefix[= ]' stdout
+grep '^ --program-suffix[= ]' stdout
+grep '^ --program-transform-name[= ]' stdout
+
+:
diff --git a/t/help-lispdir.sh b/t/help-lispdir.sh
new file mode 100755
index 000000000..ca1ddfc30
--- /dev/null
+++ b/t/help-lispdir.sh
@@ -0,0 +1,37 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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 that our macro 'AM_PATH_LISPDIR' adds proper text to
+# the configure help screen.
+
+. ./defs || Exit 1
+
+cat > configure.ac <<END
+AC_INIT([$me], [1.0])
+AM_PATH_LISPDIR
+END
+
+$ACLOCAL
+$AUTOCONF
+
+./configure --help >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+grep_configure_help --with-lispdir ' override.*lisp directory'
+grep_configure_help EMACS ' [eE]macs editor'
+grep_configure_help EMACSLOADPATH ' [eE]macs library search path'
+
+:
diff --git a/t/help-multilib.sh b/t/help-multilib.sh
new file mode 100755
index 000000000..3fb455fc8
--- /dev/null
+++ b/t/help-multilib.sh
@@ -0,0 +1,34 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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 that our macro 'AM_ENABLE_MULTILIB' adds proper text to
+# the configure help screen.
+# FIXME: the features tested by this script has been moved in contrib.
+# FIXME: We should move this script accordingly.
+
+. ./defs || Exit 1
+
+cat > configure.ac <<END
+AC_INIT([$me], [1.0])
+AM_ENABLE_MULTILIB
+END
+
+cat "$top_testsrcdir"/contrib/multilib/multi.m4 > aclocal.m4
+$AUTOCONF
+
+grep_configure_help --enable-multilib ' many library versions \(default\)'
+
+:
diff --git a/t/help-python.sh b/t/help-python.sh
new file mode 100755
index 000000000..501b545d8
--- /dev/null
+++ b/t/help-python.sh
@@ -0,0 +1,32 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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 that macro 'AM_PATH_PYTHON' adds proper text to the
+# configure help screen.
+
+. ./defs || Exit 1
+
+cat > configure.ac <<END
+AC_INIT([$me], [1.0])
+AM_PATH_PYTHON
+END
+
+$ACLOCAL
+$AUTOCONF
+
+grep_configure_help PYTHON 'the Python interpreter'
+
+:
diff --git a/t/help-silent.sh b/t/help-silent.sh
new file mode 100755
index 000000000..d5fc34225
--- /dev/null
+++ b/t/help-silent.sh
@@ -0,0 +1,43 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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 that our macro 'AM_SILENT_RULES' adds proper text to
+# the configure help screen.
+
+. ./defs || Exit 1
+
+cat > configure.ac <<END
+AC_INIT([$me], [1.0])
+AM_SILENT_RULES
+END
+
+$ACLOCAL
+
+mv -f configure.ac configure.tmpl
+
+q="[\`'\"]"
+
+for args in '' '([])' '([yes])' '([no])'; do
+ sed "s/AM_SILENT_RULES.*/&$args/" configure.tmpl >configure.ac
+ cat configure.ac
+ $AUTOCONF --force
+ grep_configure_help --enable-silent-rules \
+ " less verbose build.*\\(undo.*${q}make V=1${q}"
+ grep_configure_help --disable-silent-rules \
+ " verbose build.*\\(undo.*${q}make V=0${q}"
+done
+
+:
diff --git a/t/help-upc.sh b/t/help-upc.sh
new file mode 100755
index 000000000..b81b3879a
--- /dev/null
+++ b/t/help-upc.sh
@@ -0,0 +1,33 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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 that our macro 'AM_PROG_UPC' adds proper text to
+# the configure help screen.
+
+. ./defs || Exit 1
+
+cat > configure.ac <<END
+AC_INIT([$me], [1.0])
+AM_PROG_UPC
+END
+
+$ACLOCAL
+$AUTOCONF
+
+grep_configure_help UPC '[Uu]nified Parallel C compiler command'
+grep_configure_help UPCFLAGS '[Uu]nified Parallel C compiler flags'
+
+:
diff --git a/t/help.sh b/t/help.sh
new file mode 100755
index 000000000..2f7c2d1ba
--- /dev/null
+++ b/t/help.sh
@@ -0,0 +1,46 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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 --help and --version work, even when no configure.ac nor
+# configure.in is in the current directory.
+
+. ./defs || Exit 1
+
+# Ensure we run in an empty directory.
+mkdir emptydir
+cd emptydir
+
+# Honour user overrides for $ACLOCAL and $AUTOMAKE, but without
+# adding extra options.
+ACLOCAL=$am_original_ACLOCAL
+AUTOMAKE=$am_original_AUTOMAKE
+
+$ACLOCAL --version
+$ACLOCAL --help
+$AUTOMAKE --version
+$AUTOMAKE --help
+
+# Sanity checks: aclocal and automake cannot work without configure.ac
+# nor configure.in.
+$ACLOCAL 2>stderr && { cat stderr >&2; Exit 1; }
+cat stderr >&2
+$FGREP configure.ac stderr
+$FGREP configure.in stderr
+AUTOMAKE_fails
+$FGREP configure.ac stderr
+$FGREP configure.in stderr
+
+:
diff --git a/t/help2.sh b/t/help2.sh
new file mode 100755
index 000000000..0d433f462
--- /dev/null
+++ b/t/help2.sh
@@ -0,0 +1,52 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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 --help and --version work, even when the current directory
+# contains a broken configure.ac and a broken acinclude.m4.
+. ./defs || Exit 1
+
+# Ensure we run in a new, clean directory.
+mkdir cleandir
+cd cleandir
+
+# Honour user overrides for $ACLOCAL and $AUTOMAKE, but without
+# adding extra options.
+ACLOCAL=$am_original_ACLOCAL
+AUTOMAKE=$am_original_AUTOMAKE
+
+echo '[' > configure.ac
+echo '[' > acinclude.m4
+
+$AUTOMAKE --version
+$AUTOMAKE --help
+$ACLOCAL --version
+$ACLOCAL --help
+
+# Sanity check: aclocal cannot work with broken acinclude.m4.
+$ACLOCAL 2>stderr && { cat stderr >&2; Exit 1; }
+cat stderr >&2
+$FGREP acinclude.m4 stderr
+
+rm -f acinclude.m4
+
+# Sanity checks: aclocal and automake cannot work with broken configure.ac.
+$ACLOCAL 2>stderr && { cat stderr >&2; Exit 1; }
+cat stderr >&2
+$FGREP configure.ac stderr
+AUTOMAKE_fails
+$FGREP configure.ac stderr
+
+:
diff --git a/t/help3.sh b/t/help3.sh
new file mode 100755
index 000000000..54e06d57c
--- /dev/null
+++ b/t/help3.sh
@@ -0,0 +1,60 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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 --help and --version takes precedence over other options.
+
+. ./defs || Exit 1
+
+# We must have full control over the content of the current directory.
+mkdir cleandir
+cd cleandir
+
+# Honour user overrides for $ACLOCAL and $AUTOMAKE, but without
+# adding extra options.
+ACLOCAL=$am_original_ACLOCAL
+AUTOMAKE=$am_original_AUTOMAKE
+
+cat > configure.ac <<END
+AC_INIT([$me], [1.0])
+AC_CONFIG_AUX_DIR([.]) dnl prevent automake from looking into '..'
+AM_INIT_AUTOMAKE([foreign])
+AC_CONFIG_FILES([Makefile])
+END
+
+cat > Makefile.am <<END
+# So that install-sh will be required.
+pkgdata_DATA =
+END
+
+$ACLOCAL --force --help --output=foo.m4
+test ! -r foo.m4
+$ACLOCAL --output=foo.m4 --version --force
+test ! -r foo.m4
+# Sanity check.
+$ACLOCAL --output=foo.m4 --force
+test -f foo.m4
+
+mv -f foo.m4 aclocal.m4 # autoconf will need aclocal.m4
+
+$AUTOMAKE --add-missing --help --copy
+test ! -r install-sh
+$AUTOMAKE --copy --version --add-mising
+test ! -r install-sh
+# Sanity check.
+$AUTOMAKE --add-missing --copy
+test -f install-sh
+
+:
diff --git a/t/help4.sh b/t/help4.sh
new file mode 100755
index 000000000..9747968b1
--- /dev/null
+++ b/t/help4.sh
@@ -0,0 +1,54 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Check that the first among --help and --version to be specified on
+# the command line takes precedence over the following one.
+
+. ./defs || Exit 1
+
+# Ensure we run in an empty directory.
+mkdir emptydir
+cd emptydir
+
+# Honour user overrides for $ACLOCAL and $AUTOMAKE, but without
+# adding extra options.
+ACLOCAL=$am_original_ACLOCAL
+AUTOMAKE=$am_original_AUTOMAKE
+
+escape_dots () { sed 's/\./\\./g'; } # Avoid issues with "\" in backquotes.
+apiversion_rx=`echo "$APIVERSION" | escape_dots`
+
+$ACLOCAL --version --help >stdout || { cat stdout; Exit 1; }
+cat stdout
+grep "^aclocal.*$apiversion_rx" stdout
+grep "^Usage" stdout && Exit 1
+
+$ACLOCAL --help --version >stdout || { cat stdout; Exit 1; }
+cat stdout
+grep "^Usage" stdout
+grep "^aclocal.*$apiversion_rx" stdout && Exit 1
+
+$AUTOMAKE --version --help >stdout || { cat stdout; Exit 1; }
+cat stdout
+grep "^automake.*$apiversion_rx" stdout
+grep "^Usage" stdout && Exit 1
+
+$AUTOMAKE --help --version >stdout || { cat stdout; Exit 1; }
+cat stdout
+grep "^Usage" stdout
+grep "^automake.*$apiversion_rx" stdout && Exit 1
+
+:
diff --git a/t/hfs.sh b/t/hfs.sh
new file mode 100755
index 000000000..60000406f
--- /dev/null
+++ b/t/hfs.sh
@@ -0,0 +1,33 @@
+#! /bin/sh
+# Copyright (C) 2004-2012 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/>.
+
+
+# Automake should not think that ChangeLog == CHANGELOG on
+# case-preserving case-insensitive filesystems (such as HFS+, on
+# Darwin).
+# Report from Peter O'Gorman.
+
+. ./defs || Exit 1
+echo AC_OUTPUT >>configure.ac
+
+: >CHANGELOG
+echo 'EXTRA_DIST = CHANGELOG' >Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+$MAKE distcheck
diff --git a/t/implicit.sh b/t/implicit.sh
new file mode 100755
index 000000000..a9a068b9b
--- /dev/null
+++ b/t/implicit.sh
@@ -0,0 +1,35 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test to make sure implicit .o's are listed as appropriate. Report
+# from Henrik Frystyk Nielsen.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+END
+
+cat > Makefile.am << 'END'
+noinst_PROGRAMS = libapp_1
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+grep '^libapp_1_OBJECTS' Makefile.in | $FGREP '.$(OBJEXT)'
+
+:
diff --git a/t/info.sh b/t/info.sh
new file mode 100755
index 000000000..738ddfd1c
--- /dev/null
+++ b/t/info.sh
@@ -0,0 +1,44 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test to make sure info files are distributed correctly.
+# FIXME: This test is probably obsoleted, or wrong. The generated
+# Makefile.in seems not to define any 'INFOS' variable!
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+info_TEXINFOS = foo.texi
+END
+
+echo '@setfilename foo.info' > foo.texi
+: > texinfo.tex
+
+$ACLOCAL
+$AUTOMAKE
+
+for i in `grep '^INFOS =' Makefile.in | sed -e 's/^INFOS = //'`; do
+ echo $i
+ case "$i" in
+ foo*)
+ ;;
+ *)
+ Exit 1
+ ;;
+ esac
+done
+
+:
diff --git a/t/init.sh b/t/init.sh
new file mode 100755
index 000000000..d57681489
--- /dev/null
+++ b/t/init.sh
@@ -0,0 +1,38 @@
+#! /bin/sh
+# Copyright (C) 2006-2012 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 we give a sensible error message when AC_INIT and
+# AM_INIT_AUTOMAKE are both given less than two arguments.
+
+. ./defs || Exit 1
+
+for ac_init_args in '' '([x])'; do
+ for am_init_args in '' '([1.10])'; do
+ rm -rf aclocal.m4 autom4te*.cache
+ unindent >configure.ac <<END
+ AC_INIT$ac_init_args
+ AM_INIT_AUTOMAKE$am_init_args
+END
+ cat configure.ac # For debugging.
+ # The error message should mention AC_INIT, not AC_PACKAGE_VERSION.
+ ($ACLOCAL && $AUTOCONF) 2>stderr && { cat stderr >&2; Exit 1; }
+ cat stderr >&2
+ $FGREP AC_PACKAGE_VERSION stderr && Exit 1
+ grep 'configure\.ac:.* AC_INIT .*arguments' stderr
+ done
+done
+
+:
diff --git a/t/init2.sh b/t/init2.sh
new file mode 100755
index 000000000..44e79cb9c
--- /dev/null
+++ b/t/init2.sh
@@ -0,0 +1,30 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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 3 of the License, 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 we give a sensible error message when AM_INIT_AUTOMAKE
+# contains junk.
+
+. ./defs || Exit 1
+
+cat >configure.ac <<END
+AC_INIT([init2], [1.0])
+AM_INIT_AUTOMAKE([nosuchoption])
+END
+
+$ACLOCAL
+AUTOMAKE_fails
+grep 'nosuchoption.*recognized' stderr
+Exit 0
diff --git a/t/insh2.sh b/t/insh2.sh
new file mode 100755
index 000000000..cd74f82a5
--- /dev/null
+++ b/t/insh2.sh
@@ -0,0 +1,40 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test for bug where install-sh not included in distribution.
+
+. ./defs || Exit 1
+
+echo AC_OUTPUT >> configure.ac
+
+cat > Makefile.am << 'END'
+pkgdata_DATA =
+.PHONY: test
+test: distdir
+ find $(distdir) ;: For debugging.
+ echo ' ' $(DISTFILES) ' ' | grep '[ /]install-sh '
+ echo ' ' $(DIST_COMMON) ' ' | grep '[ /]install-sh '
+ test -f $(distdir)/install-sh
+END
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+
+./configure
+$MAKE test
+
+:
diff --git a/t/install-info-dir.sh b/t/install-info-dir.sh
new file mode 100755
index 000000000..c76f424ad
--- /dev/null
+++ b/t/install-info-dir.sh
@@ -0,0 +1,176 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Checks on the 'install-info' target.
+# Details about the individual checks' purposes and motivations are
+# inlined, below.
+
+# FIXME: this test is a good candidate for a conversion to TAP,
+# FIXME: and could be merged with 'txinfo27.test'.
+
+required=makeinfo
+. ./defs || Exit 1
+
+cwd=`pwd` || fatal_ "cannot get current working directory"
+
+mkdir bin
+saved_PATH=$PATH; export saved_PATH
+PATH=$cwd/bin$PATH_SEPARATOR$PATH; export PATH
+
+cat >> configure.ac <<'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+info_TEXINFOS = foo.texi
+END
+
+cat > foo.texi << 'END'
+\input texinfo
+@setfilename foo.info
+@c All the following directives might be required to allow older
+@c versions of the 'install-info' program (e.g., version 4.8) to
+@c create the 'dir' index file in ${infodir}. Don't remove them.
+@settitle foo
+@dircategory Dummy utilities
+@direntry
+* Foo: (foo). Does nothing at all, but has a nice name.
+@end direntry
+@node Top
+Hello world!
+@bye
+END
+
+$ACLOCAL
+$AUTOMAKE -a
+$AUTOCONF
+
+instdir=_inst
+destdir=_dest
+
+./configure --prefix="$cwd/$instdir" --infodir="$cwd/$instdir/info"
+
+$MAKE info
+test -f foo.info
+
+if install-info --version; then
+ have_installinfo=yes
+else
+ have_installinfo=no
+fi
+
+# The 'install-info' target updates the '${infodir}/dir' file
+# by default (if the 'install-info' program is available).
+# This should happen in a normal as well as in a DESTDIR installation.
+if test $have_installinfo = yes; then
+
+ $MAKE install-info
+ test -f $instdir/info/foo.info
+ test -f $instdir/info/dir
+ $FGREP 'Does nothing at all, but has a nice name' $instdir/info/dir
+
+ $MAKE uninstall
+ test ! -f $instdir/info/foo.info
+ $FGREP 'but has a nice name' $instdir/info/dir && Exit 1
+
+ dir="$destdir/$cwd/$instdir/info"
+
+ $MAKE DESTDIR="$cwd/$destdir" install-info
+ test -f "$dir"/foo.info
+ test -f "$dir"/dir
+ $FGREP 'Does nothing at all, but has a nice name' "$dir"/dir
+ $MAKE DESTDIR="$cwd/$destdir" uninstall
+ test ! -f "$dir"/foo.info
+ $FGREP 'but has a nice name' "$dir"/dir && Exit 1
+
+ unset dir
+
+fi
+
+rm -rf $instdir $destdir
+
+# The 'install-info' target doesn't fail if the 'install-info'
+# program is not available.
+cat > bin/install-info <<'END'
+#!/bin/sh
+echo error from install-info >&2
+exit 127
+END
+chmod a+x bin/install-info
+$MAKE install-info >output 2>&1 || { cat output; Exit 1; }
+cat output
+test -f $instdir/info/foo.info
+test ! -f $instdir/info/dir
+grep 'error from install-info' output && Exit 1
+
+rm -rf $instdir output
+
+if test $have_installinfo = yes; then
+ # The 'install-info' target doesn't try to guess whether the 'install-info'
+ # is the GNU or debian version.
+ unindent > bin/install-info <<'END'
+ #!/bin/sh
+ set -e; set -u;
+ for fd in 1 2; do
+ for str in dpkg debian Debian; do
+ eval "echo This is $str install-info >&$fd"
+ done
+ done
+ PATH=$saved_PATH; export PATH
+ exec install-info ${1+"$@"}
+END
+ $MAKE install-info
+ test -f $instdir/info/foo.info
+ test -f $instdir/info/dir
+ $MAKE uninstall
+ test ! -f $instdir/info/foo.info
+ test -f $instdir/info/dir
+ $FGREP 'but has a nice name' $instdir/info/dir && Exit 1
+ : For shells with busted 'set -e'.
+fi
+
+rm -rf $instdir bin/install-info
+
+# The 'AM_UPDATE_INFO_DIR' environment variable can be used to
+# prevent the creation or update of the '${infodir}/dir' file,
+# if set to a "no" value.
+for val in no NO n; do
+ rm -rf $instdir
+ env AM_UPDATE_INFO_DIR="$val" $MAKE install-info
+ test -f $instdir/info/foo.info
+ test ! -f $instdir/info/dir
+done
+
+$MAKE install-info
+chmod a-w $instdir/info/dir
+for val in no NO n; do
+ env AM_UPDATE_INFO_DIR="$val" $MAKE uninstall
+ $FGREP 'Does nothing at all, but has a nice name' $instdir/info/dir
+done
+
+if test $have_installinfo = yes; then
+ for val in 'yes' 'who cares!'; do
+ rm -rf $instdir
+ env AM_UPDATE_INFO_DIR="$val" $MAKE install-info
+ test -f $instdir/info/foo.info
+ test -f $instdir/info/dir
+ env AM_UPDATE_INFO_DIR="$val" $MAKE uninstall
+ test ! -f $instdir/info/foo.info
+ $FGREP 'but has a nice name' $instdir/info/dir && Exit 1
+ done
+fi
+
+:
diff --git a/t/install2.sh b/t/install2.sh
new file mode 100755
index 000000000..f1992e8b1
--- /dev/null
+++ b/t/install2.sh
@@ -0,0 +1,50 @@
+#! /bin/sh
+# Copyright (C) 1999-2012 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/>.
+
+# Test for bug in 'make dist'
+# From Pavel Roskin.
+
+. ./defs || Exit 1
+
+cat > configure.ac << 'END'
+AC_INIT
+dnl Prevent automake from looking in .. and ../..
+AC_CONFIG_AUX_DIR(.)
+AM_INIT_AUTOMAKE(foo, 0.1)
+AC_OUTPUT(Makefile)
+END
+
+cat > Makefile.am << 'END'
+SUBDIRS = .
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+chmod 000 Makefile.am
+
+# On some systems (like DOS and Windows), files are always readable.
+test ! -r Makefile.am || skip_ "cannot drop file read permissions"
+
+./configure
+
+# 'dist' should fail because we can't copy Makefile.am.
+if $MAKE dist; then
+ Exit 1
+else
+ Exit 0
+fi
diff --git a/t/installdir.sh b/t/installdir.sh
new file mode 100755
index 000000000..dc83ee36d
--- /dev/null
+++ b/t/installdir.sh
@@ -0,0 +1,64 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test for PR 203.
+# See also automake bug#11030.
+#
+# == Original Report for PR/203 ==
+# Some standard targets are missing '-local' hooks. For instance,
+# installdirs is missing this. Ideally this would be an automatic
+# feature of any exported target.
+
+. ./defs || Exit 1
+
+echo AC_OUTPUT >> configure.ac
+
+cat > Makefile.am << 'END'
+foodir = $(datadir)/$(distdir)
+installdirs-local:
+ $(MKDIR_P) $(DESTDIR)$(foodir)
+install-data-hook: installdirs-local
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+test `grep installdirs-local Makefile.in | wc -l` -eq 4
+
+cwd=`pwd` || fatal_ "getting current working directory"
+
+$AUTOCONF
+./configure --prefix="$cwd/inst"
+
+$MAKE installdirs
+test -d inst/share/$me-1.0
+rm -rf inst
+
+$MAKE install
+test -d inst/share/$me-1.0
+rm -rf inst
+
+./configure --prefix=/foo
+
+$MAKE installdirs DESTDIR="$cwd/dest"
+test -d dest/foo/share/$me-1.0
+rm -rf dest
+
+$MAKE install DESTDIR="$cwd/dest"
+test -d dest/foo/share/$me-1.0
+rm -rf dest
+
+:
diff --git a/t/instdat.sh b/t/instdat.sh
new file mode 100755
index 000000000..0754a0941
--- /dev/null
+++ b/t/instdat.sh
@@ -0,0 +1,32 @@
+#! /bin/sh
+# Copyright (C) 1998-2012 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/>.
+
+# Test to see if defining INSTALL_DATA causes problems. From EGCS
+# list.
+
+. ./defs || Exit 1
+
+cat >> configure.ac <<END
+AC_SUBST([INSTALL_DATA])
+END
+
+: > Makefile.am
+
+$ACLOCAL
+$AUTOMAKE
+
+grep '^DATA =' Makefile.in | grep 'INSTALL_DATA' && Exit 1
+Exit 0
diff --git a/t/instdat2.sh b/t/instdat2.sh
new file mode 100755
index 000000000..8773fc369
--- /dev/null
+++ b/t/instdat2.sh
@@ -0,0 +1,89 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test that installing under $exec_prefix is handled by install-exec.
+# Testing with headers for instance.
+
+. ./defs || Exit 1
+
+cat >Makefile.am << 'EOF'
+# User directories.
+inclexecdir = $(exec_prefix)/include
+inclexec_HEADERS = my-config.h
+
+incldatadir = $(prefix)/include
+incldata_HEADERS = my-data.h
+
+## Standard directories: _DATA
+## Commented out are invalid combinations.
+##bin_DATA = data
+##sbin_DATA = data
+##libexec_DATA = data
+data_DATA = data
+sysconf_DATA = data
+localstate_DATA = data
+##lib_DATA = data
+##info_DATA = data
+##man_DATA = data
+##include_DATA = data
+##oldinclude_DATA = data
+pkgdata_DATA = data
+##pkglib_DATA = data
+##pkginclude_DATA = data
+
+## Standard directories: _SCRIPTS
+## Commented out are invalid combinations.
+bin_SCRIPTS = script
+sbin_SCRIPTS = script
+libexec_SCRIPTS = script
+##data_SCRIPTS = script
+##sysconf_SCRIPTS = script
+##localstate_SCRIPTS = script
+##lib_SCRIPTS = script
+##info_SCRIPTS = script
+##man_SCRIPTS = script
+##include_SCRIPTS = script
+##oldinclude_SCRIPTS = script
+pkgdata_SCRIPTS = script
+##pkglib_SCRIPTS = script
+##pkginclude_SCRIPTS = script
+EOF
+
+$ACLOCAL || Exit 1
+$AUTOMAKE
+
+# install-SCRIPTS targets.
+sed -n '/^install-data-am/,/^ /p' Makefile.in > produced
+
+cat > expected <<'EOF'
+install-data-am: install-dataDATA install-incldataHEADERS \
+ install-pkgdataDATA install-pkgdataSCRIPTS
+EOF
+
+diff expected produced
+
+
+# install-exec targets.
+sed -n '/^install-exec-am/,/^ /p' Makefile.in > produced
+
+cat > expected <<'EOF'
+install-exec-am: install-binSCRIPTS install-inclexecHEADERS \
+ install-libexecSCRIPTS install-localstateDATA \
+EOF
+
+diff expected produced
+
+Exit 0
diff --git a/t/instdir-cond.sh b/t/instdir-cond.sh
new file mode 100644
index 000000000..2965ff19d
--- /dev/null
+++ b/t/instdir-cond.sh
@@ -0,0 +1,48 @@
+#! /bin/sh
+# Copyright (C) 2012 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/>.
+
+# Check against automake bug#10997: directories holding only
+# conditionally-installed files should not be created unconditionally.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AM_CONDITIONAL([ENABLE_FOO], [false])
+AC_OUTPUT
+END
+
+: > foo
+: > bar
+
+cat > Makefile.am << 'END'
+pkglibexec_SCRIPTS =
+if ENABLE_FOO
+pkgdata_DATA = foo
+pkglibexec_SCRIPTS += bar
+endif
+END
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+
+./configure --prefix="`pwd`/inst"
+
+$MAKE install
+test ! -d inst/share/instdir-cond
+test ! -d inst/libexec/instdir-cond
+
+:
diff --git a/t/instdir-cond2.sh b/t/instdir-cond2.sh
new file mode 100644
index 000000000..1fc24b70d
--- /dev/null
+++ b/t/instdir-cond2.sh
@@ -0,0 +1,51 @@
+#! /bin/sh
+# Copyright (C) 2012 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/>.
+
+# Check against automake bug#10997: directories holding only
+# conditionally-installed files should not be created unconditionally.
+# FIXME: this test tries to check that the above also hold for the
+# FIXME: "installdirs" target, but that doesn't currently work :-(
+# FIXME: So this test is still xfailing.
+# See sister test 'instdir-cond.test' for the succeeding part.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AM_CONDITIONAL([ENABLE_FOO], [false])
+AC_OUTPUT
+END
+
+: > foo
+: > bar
+
+cat > Makefile.am << 'END'
+pkglibexec_SCRIPTS =
+if ENABLE_FOO
+pkgdata_DATA = foo
+pkglibexec_SCRIPTS += bar
+endif
+END
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+
+./configure --prefix="`pwd`/inst"
+
+$MAKE installdirs
+test ! -d inst || { find inst; Exit 1; }
+
+:
diff --git a/t/instdir-java.sh b/t/instdir-java.sh
new file mode 100755
index 000000000..4d47d19a8
--- /dev/null
+++ b/t/instdir-java.sh
@@ -0,0 +1,59 @@
+#! /bin/sh
+# Copyright (C) 2009-2012 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/>.
+
+# If $(javadir) is the empty string, then nothing should be installed there.
+
+required=javac
+. ./defs || Exit 1
+
+cat >>configure.ac <<'END'
+AC_OUTPUT
+END
+
+cat >Makefile.am <<'END'
+javadir = $(datarootdir)/java
+java_JAVA = foo.java
+END
+
+cat >foo.java <<'END'
+class foo {
+}
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+instdir=`pwd`/inst
+destdir=`pwd`/dest
+mkdir build
+cd build
+../configure --prefix="$instdir"
+$MAKE
+
+javadir=
+export javadir
+$MAKE -e install
+test ! -d "$instdir"
+$MAKE -e install DESTDIR="$destdir"
+test ! -d "$instdir"
+test ! -d "$destdir"
+$MAKE -e uninstall > stdout || { cat stdout; Exit 1; }
+cat stdout
+grep 'rm -f' stdout && Exit 1
+$MAKE -e uninstall DESTDIR="$destdir"
+
+:
diff --git a/t/instdir-lisp.sh b/t/instdir-lisp.sh
new file mode 100755
index 000000000..f019504d2
--- /dev/null
+++ b/t/instdir-lisp.sh
@@ -0,0 +1,57 @@
+#! /bin/sh
+# Copyright (C) 2009-2012 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/>.
+
+# If $(lispdir) is the empty string, then nothing should be installed there.
+
+required=emacs
+. ./defs || Exit 1
+
+cat >>configure.ac <<'END'
+AM_PATH_LISPDIR
+AC_OUTPUT
+END
+
+cat >Makefile.am <<'END'
+lisp_LISP = l.el
+END
+
+: >l.el
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+instdir=`pwd`/inst
+destdir=`pwd`/dest
+mkdir build
+cd build
+../configure --prefix="$instdir"
+$MAKE
+
+lispdir=
+export lispdir
+
+$MAKE -e install
+test ! -d "$instdir"
+$MAKE -e install DESTDIR="$destdir"
+test ! -d "$instdir"
+test ! -d "$destdir"
+$MAKE -e uninstall > stdout || { cat stdout; Exit 1; }
+cat stdout
+grep 'rm -f' stdout && Exit 1
+$MAKE -e uninstall DESTDIR="$destdir"
+
+:
diff --git a/t/instdir-ltlib.sh b/t/instdir-ltlib.sh
new file mode 100755
index 000000000..ded16cd5b
--- /dev/null
+++ b/t/instdir-ltlib.sh
@@ -0,0 +1,87 @@
+#! /bin/sh
+# Copyright (C) 2009-2012 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/>.
+
+# If $(libdir) or $(pyexecdir) is the empty string, then nothing should
+# be installed there.
+# This test exercises the libtool code paths.
+
+required='cc libtoolize'
+. ./defs || Exit 1
+
+cat >>configure.ac <<'END'
+AC_PROG_CC
+AM_PROG_CC_C_O
+AM_PROG_AR
+AC_PROG_LIBTOOL
+AM_PATH_PYTHON
+AC_OUTPUT
+END
+
+mkdir sub
+
+cat >Makefile.am <<'END'
+AUTOMAKE_OPTIONS = subdir-objects
+bin_PROGRAMS = p
+nobase_bin_PROGRAMS = np sub/np
+lib_LTIBRARIES = libfoo.la
+nobase_lib_LTLIBRARIES = libnfoo.la sub/libnfoo.la
+pyexec_LTIBRARIES = libpy.la
+nobase_pyexec_LTLIBRARIES = libnpy.la sub/libnpy.la
+END
+
+cat >p.c <<'END'
+int main () { return 0; }
+END
+cp p.c np.c
+cp p.c sub/np.c
+cp p.c libfoo.c
+cp p.c libnfoo.c
+cp p.c sub/libnfoo.c
+cp p.c libpy.c
+cp p.c libnpy.c
+cp p.c sub/libnpy.c
+
+libtoolize
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+instdir=`pwd`/inst
+destdir=`pwd`/dest
+mkdir build
+cd build
+../configure --prefix="$instdir" PYTHON="echo" \
+ am_cv_python_pythondir="$instdir/python" \
+ am_cv_python_pyexecdir="$instdir/pyexec"
+$MAKE
+
+bindir= libdir= pyexecdir=
+export bindir libdir pyexecdir
+$MAKE -e install
+test ! -d "$instdir"
+$MAKE -e install DESTDIR="$destdir"
+test ! -d "$instdir"
+test ! -d "$destdir"
+$MAKE -e uninstall > stdout || { cat stdout; Exit 1; }
+cat stdout
+# Creative quoting below to please maintainer-check.
+grep 'rm'' ' stdout && Exit 1
+$MAKE -e uninstall DESTDIR="$destdir" > stdout || { cat stdout; Exit 1; }
+cat stdout
+# Creative quoting below to please maintainer-check.
+grep 'rm'' ' stdout && Exit 1
+
+:
diff --git a/t/instdir-no-empty.sh b/t/instdir-no-empty.sh
new file mode 100755
index 000000000..6f105c025
--- /dev/null
+++ b/t/instdir-no-empty.sh
@@ -0,0 +1,123 @@
+#! /bin/sh
+# Copyright (C) 2012 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/>.
+
+# An empty "foo_PRIMARY" declaration should *not* cause "make install"
+# to create directory $(foodir). See automake bug#10997 and bug#11030.
+
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.ac <<'END'
+AC_SUBST([CC], [whatever])
+AC_SUBST([JAVAC], [whatever])
+AM_PATH_PYTHON(,,:)
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = no-dependencies
+mydir = $(prefix)/my
+myexecdir = $(prefix)/myexec
+javadir = $(prefix)/java
+END
+
+# Write Makefile.am.
+{
+
+ for dir in sbin bin libexec pkglibexec myexec; do
+ for dst in '' dist_ nodist_; do
+ echo "${dst}${dir}_SCRIPTS ="
+ done
+ echo "${dir}_PROGRAMS ="
+ done
+
+ for dir in lib pkglib myexec my; do
+ echo "${dir}_LIBRARIES ="
+ echo "${dir}_LTLIBRARIES ="
+ done
+
+ for p1 in '' notrans_; do
+ for p2 in '' dist_ nodist_; do
+ for s in '' 1 2 3 4 5 6 7 8 9; do
+ echo "${p1}${p2}man${s}_MANS ="
+ done
+ done
+ done
+
+ for dst in '' dist_ nodist_; do
+ for dir in dataroot data pkgdata doc lisp my; do
+ echo "${dst}${dir}_DATA ="
+ done
+ for dir in include pkginclude oldinclude my; do
+ echo "${dst}${dir}_HEADERS ="
+ done
+ for dir in python my; do
+ echo "${dst}${dir}_PYTHON ="
+ done
+ for dir in info my; do
+ echo "${dst}${dir}_TEXINFOS ="
+ done
+ for dir in java my; do
+ echo "${dst}${dir}_JAVA ="
+ done
+ for dir in lisp my; do
+ echo "${dst}${dir}_LISP ="
+ done
+ done
+
+} > t
+
+cat t >> Makefile.am
+sed 's/^/nobase_/' t >> Makefile.am
+rm -f t
+
+cat Makefile.am # For debugging.
+
+# Sanity check.
+grep '^oldinclude_HEADERS =' Makefile.am \
+ && grep '^nodist_my_PYTHON =' Makefile.am \
+ && grep '^notrans_dist_man5_MANS =' Makefile.am \
+ || fatal_ "creating Makefile.am"
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+cwd=`pwd` || fatal_ "getting current working directory"
+
+doinst ()
+{
+ $MAKE install install-pdf install-ps install-dvi ${1+"$@"}
+}
+
+: > foo.sh
+
+./configure --prefix="$cwd/inst"
+doinst
+test ! -d inst || { find inst; Exit 1; }
+$MAKE uninstall
+doinst bin_SCRIPTS=foo.sh AM_MAKEFLAGS='bin_SCRIPTS=foo.sh'
+test -f inst/bin/foo.sh
+
+./configure
+doinst DESTDIR="$cwd/dest"
+test ! -d dest || { find dest; Exit 1; }
+$MAKE uninstall
+doinst DESTDIR="$cwd/dest" bin_SCRIPTS=foo.sh AM_MAKEFLAGS='bin_SCRIPTS=foo.sh'
+test -f dest/usr/local/bin/foo.sh
+
+:
diff --git a/t/instdir-prog.sh b/t/instdir-prog.sh
new file mode 100755
index 000000000..e0948c088
--- /dev/null
+++ b/t/instdir-prog.sh
@@ -0,0 +1,86 @@
+#! /bin/sh
+# Copyright (C) 2009-2012 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/>.
+
+# If $(bindir), $(libdir) or $(pyexecdir) is the empty string, then
+# nothing should be installed there.
+# This test exercises the prog and libs code paths.
+
+required=cc
+. ./defs || Exit 1
+
+cat >>configure.ac <<'END'
+AC_PROG_CC
+AM_PROG_CC_C_O
+AM_PROG_AR
+AC_PROG_RANLIB
+AM_PATH_PYTHON
+AC_OUTPUT
+END
+
+mkdir sub
+
+cat >Makefile.am <<'END'
+AUTOMAKE_OPTIONS = subdir-objects
+bin_PROGRAMS = p
+nobase_bin_PROGRAMS = np sub/np
+lib_LIBRARIES = libfoo.a
+nobase_lib_LIBRARIES = libnfoo.a sub/libnfoo.a
+pyexec_PROGRAMS = py
+nobase_pyexec_PROGRAMS = npy sub/npy
+END
+
+cat >p.c <<'END'
+int main () { return 0; }
+END
+cp p.c np.c
+cp p.c sub/np.c
+cp p.c libfoo.c
+cp p.c libnfoo.c
+cp p.c sub/libnfoo.c
+cp p.c py.c
+cp p.c npy.c
+cp p.c sub/npy.c
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+instdir=`pwd`/inst
+destdir=`pwd`/dest
+mkdir build
+cd build
+../configure --prefix="$instdir" PYTHON="echo" \
+ am_cv_python_pythondir="$instdir/python" \
+ am_cv_python_pyexecdir="$instdir/pyexec"
+$MAKE
+
+bindir= libdir= pyexecdir=
+export bindir libdir pyexecdir
+$MAKE -e install
+test ! -d "$instdir"
+$MAKE -e install DESTDIR="$destdir"
+test ! -d "$instdir"
+test ! -d "$destdir"
+$MAKE -e uninstall > stdout || { cat stdout; Exit 1; }
+cat stdout
+# Creative quoting below to please maintainer-check.
+grep 'rm'' ' stdout && Exit 1
+$MAKE -e uninstall DESTDIR="$destdir" > stdout || { cat stdout; Exit 1; }
+cat stdout
+# Creative quoting below to please maintainer-check.
+grep 'rm'' ' stdout && Exit 1
+
+:
diff --git a/t/instdir-python.sh b/t/instdir-python.sh
new file mode 100755
index 000000000..f48353deb
--- /dev/null
+++ b/t/instdir-python.sh
@@ -0,0 +1,61 @@
+#! /bin/sh
+# Copyright (C) 2009-2012 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/>.
+
+# If $(pythondir) is the empty string, then nothing should be installed there.
+
+required=python
+. ./defs || Exit 1
+
+cat >>configure.ac <<'END'
+AM_PATH_PYTHON
+AC_OUTPUT
+END
+
+mkdir sub
+
+cat >Makefile.am <<'END'
+python_PYTHON = one.py
+END
+
+cat >one.py <<'END'
+def one(): return 1
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+instdir=`pwd`/inst
+destdir=`pwd`/dest
+mkdir build
+cd build
+../configure --prefix="$instdir"
+$MAKE
+
+pythondir=
+export pythondir
+
+$MAKE -e install
+test ! -d "$instdir"
+$MAKE -e install DESTDIR="$destdir"
+test ! -d "$instdir"
+test ! -d "$destdir"
+$MAKE -e uninstall > stdout || { cat stdout; Exit 1; }
+cat stdout
+grep 'rm -f' stdout && Exit 1
+$MAKE -e uninstall DESTDIR="$destdir"
+
+:
diff --git a/t/instdir-texi.sh b/t/instdir-texi.sh
new file mode 100755
index 000000000..4e4887a7a
--- /dev/null
+++ b/t/instdir-texi.sh
@@ -0,0 +1,71 @@
+#! /bin/sh
+# Copyright (C) 2009-2012 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/>.
+
+# If $(infodir) is the empty string, then nothing should be installed there.
+# Likewise for the other install-* targets used for texinfo files.
+
+required='makeinfo-html tex texi2dvi'
+. ./defs || Exit 1
+
+dvips --help \
+ || skip_ "dvips is missing"
+pdfetex --version || pdftex --version \
+ || skip_ "pdeftex and pdftex are both missing"
+
+cat >>configure.ac <<'END'
+AC_OUTPUT
+END
+
+cat >Makefile.am <<'END'
+info_TEXINFOS = foo.texi
+END
+
+cat >foo.texi << 'END'
+\input texinfo
+@setfilename foo.info
+@settitle foo
+@node Top
+Hello walls.
+@include version.texi
+@bye
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+instdir=`pwd`/inst
+destdir=`pwd`/dest
+mkdir build
+cd build
+../configure --prefix="$instdir"
+$MAKE all dvi ps pdf html
+ls -l
+
+infodir= htmldir= dvidir= psdir= pdfdir=
+export infodir htmldir dvidir psdir pdfdir
+
+$MAKE -e install install-html install-dvi install-ps install-pdf
+test ! -d "$instdir"
+$MAKE -e install install-html install-dvi install-ps install-pdf DESTDIR="$destdir"
+test ! -d "$instdir"
+test ! -d "$destdir"
+$MAKE -e uninstall > stdout || { cat stdout; Exit 1; }
+cat stdout
+grep 'rm -f' stdout && Exit 1
+$MAKE -e uninstall DESTDIR="$destdir"
+
+:
diff --git a/t/instdir.sh b/t/instdir.sh
new file mode 100755
index 000000000..f09fdfa7c
--- /dev/null
+++ b/t/instdir.sh
@@ -0,0 +1,70 @@
+#! /bin/sh
+# Copyright (C) 2009-2012 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/>.
+
+# If $(foodir) is the empty string, then nothing should be installed there.
+# This test only ensures this if $(foo_PRIMARY) is also empty, see
+# instdir2.test and siblings instdir-*.test for nonempty contents.
+
+. ./defs || Exit 1
+
+cat >>configure.ac <<'END'
+AC_SUBST([foodir], ['${datadir}'/foo])
+AC_OUTPUT
+END
+
+cat >Makefile.am <<'END'
+bin_SCRIPTS =
+nobase_bin_SCRIPTS =
+data_DATA =
+nobase_data_DATA =
+include_HEADERS =
+nobase_include_HEADERS =
+foo_DATA =
+nobase_foo_DATA =
+bardir = $(datadir)/bar
+bar_DATA =
+nobase_bar_DATA =
+man1_MANS =
+man_MANS =
+notrans_man1_MANS =
+notrans_man_MANS =
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+instdir=`pwd`/inst
+destdir=`pwd`/dest
+mkdir build
+cd build
+../configure --prefix="$instdir"
+$MAKE
+
+bindir= datadir= includedir= foodir= bardir= man1dir= man2dir=
+export bindir datadir includedir foodir bardir man1dir man2dir
+
+$MAKE -e install
+test ! -d "$instdir"
+$MAKE -e install DESTDIR="$destdir"
+test ! -d "$instdir"
+test ! -d "$destdir"
+$MAKE -e uninstall > stdout || { cat stdout; Exit 1; }
+cat stdout
+grep 'rm -f' stdout && Exit 1
+$MAKE -e uninstall DESTDIR="$destdir"
+
+:
diff --git a/t/instdir2.sh b/t/instdir2.sh
new file mode 100755
index 000000000..bdfa80999
--- /dev/null
+++ b/t/instdir2.sh
@@ -0,0 +1,92 @@
+#! /bin/sh
+# Copyright (C) 2009-2012 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/>.
+
+# If $(foodir) is the empty string, then nothing should be installed there.
+# This test ensures this also if $(foo_PRIMARY) is nonempty, see
+# instdir.test.
+
+. ./defs || Exit 1
+
+cat >>configure.ac <<'END'
+AC_SUBST([foodir], ['${datadir}'/foo])
+AC_OUTPUT
+END
+
+mkdir sub
+
+cat >Makefile.am <<'END'
+bin_SCRIPTS = s
+nobase_bin_SCRIPTS = ns sub/ns
+data_DATA = d
+nobase_data_DATA = nd sub/nd
+include_HEADERS = h
+nobase_include_HEADERS = nh sub/nh
+foo_DATA = f
+nobase_foo_DATA = nf sub/nf
+bardir = $(datadir)/bar
+bar_DATA = b
+nobase_bar_DATA = nb sub/nb
+man1_MANS = m1.1
+man_MANS = m.2
+notrans_man1_MANS = nm1.1
+notrans_man_MANS = nm.2
+END
+
+: >s
+: >ns
+: >sub/ns
+: >d
+: >nd
+: >sub/nd
+: >h
+: >nh
+: >sub/nh
+: >f
+: >nf
+: >sub/nf
+: >b
+: >nb
+: >sub/nb
+: >m1.1
+: >m.2
+: >nm1.1
+: >nm.2
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+instdir=`pwd`/inst
+destdir=`pwd`/dest
+mkdir build
+cd build
+../configure --prefix="$instdir"
+$MAKE
+
+bindir= datadir= includedir= foodir= bardir= man1dir= man2dir=
+export bindir datadir includedir foodir bardir man1dir man2dir
+
+$MAKE -e install
+test ! -d "$instdir"
+$MAKE -e install DESTDIR="$destdir"
+test ! -d "$instdir"
+test ! -d "$destdir"
+$MAKE -e uninstall > stdout || { cat stdout; Exit 1; }
+cat stdout
+grep 'rm -f' stdout && Exit 1
+$MAKE -e uninstall DESTDIR="$destdir"
+
+:
diff --git a/t/instexec.sh b/t/instexec.sh
new file mode 100755
index 000000000..c033ecd37
--- /dev/null
+++ b/t/instexec.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test for this bug: when a Makefile.am builds nothing, no
+# install-exec target is generated.
+
+. ./defs || Exit 1
+
+: > Makefile.am
+
+$ACLOCAL
+$AUTOMAKE
+
+grep '^install-exec:' Makefile.in
diff --git a/t/instfail-info.sh b/t/instfail-info.sh
new file mode 100755
index 000000000..58aef975c
--- /dev/null
+++ b/t/instfail-info.sh
@@ -0,0 +1,63 @@
+#! /bin/sh
+# Copyright (C) 2008-2012 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/>.
+
+# The install rule should honor failures of the install program.
+# Some of these are already caught by instmany.test.
+
+# This test has a few sister tests, for java, info, libtool.
+
+required='makeinfo'
+. ./defs || Exit 1
+
+cat >>configure.ac <<END
+AC_OUTPUT
+END
+
+cat >Makefile.am <<'END'
+info_TEXINFOS = info1.texi info2.texi info3.texi
+END
+
+for n in 1 2 3; do
+ cat >info$n.texi <<END
+\input texinfo
+@setfilename info$n.info
+@settitle main
+@node Top
+Hello walls.
+@bye
+END
+done
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+instdir=`pwd`/inst
+./configure --prefix="$instdir"
+$MAKE
+
+$MAKE install
+$MAKE uninstall
+
+for file in info1.info
+do
+ chmod a-r $file
+ test ! -r $file || skip_ "cannot drop file read permissions"
+ $MAKE install-data && Exit 1
+ chmod u+r $file
+done
+
+:
diff --git a/t/instfail-java.sh b/t/instfail-java.sh
new file mode 100755
index 000000000..0ae80f58e
--- /dev/null
+++ b/t/instfail-java.sh
@@ -0,0 +1,57 @@
+#! /bin/sh
+# Copyright (C) 2008-2012 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/>.
+
+# The install rule should honor failures of the install program.
+# Some of these are already caught by instmany.test.
+
+# This is the java sister test of instfail.test.
+
+required=javac
+. ./defs || Exit 1
+
+cat >>configure.ac <<'END'
+AC_OUTPUT
+END
+
+cat >Makefile.am <<'END'
+javadir = $(datadir)/java
+java_JAVA = java1.java java2.java java3.java
+END
+
+for n in 1 2 3; do
+ echo "class java$n { }" >java$n.java
+done
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+instdir=`pwd`/inst
+./configure --prefix="$instdir"
+$MAKE
+
+$MAKE install
+$MAKE uninstall
+
+for file in java1.class
+do
+ chmod a-r $file
+ test ! -r $file || skip_ "cannot drop file read permissions"
+ $MAKE install-data && Exit 1
+ chmod u+r $file
+done
+
+:
diff --git a/t/instfail-libtool.sh b/t/instfail-libtool.sh
new file mode 100755
index 000000000..0acfd2c5a
--- /dev/null
+++ b/t/instfail-libtool.sh
@@ -0,0 +1,81 @@
+#! /bin/sh
+# Copyright (C) 2008-2012 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/>.
+
+# The install rule should honor failures of the install program.
+# Some of these are already caught by instmany.test.
+
+# This is the libtool sister test of instfail.test
+
+required='cc libtool libtoolize'
+. ./defs || Exit 1
+
+cat >>configure.ac <<END
+AM_PROG_AR
+AC_PROG_LIBTOOL
+AC_OUTPUT
+END
+
+cat >Makefile.am <<'END'
+bin_PROGRAMS = prog1 prog2 prog3
+nobase_bin_PROGRAMS = progn1 progn2 progn3
+lib_LTLIBRARIES = liblt1.la liblt2.la liblt3.la
+nobase_lib_LTLIBRARIES = libltn1.la libltn2.la libltn3.la
+unreadable-prog:
+ chmod a-r prog1$(EXEEXT)
+readable-prog:
+ chmod a+r prog1$(EXEEXT)
+unreadable-progn:
+ chmod a-r progn1$(EXEEXT)
+readable-progn:
+ chmod a+r progn1$(EXEEXT)
+END
+
+for n in 1 2 3; do
+ echo "int main () { return 0; }" > prog$n.c
+ echo "int main () { return 0; }" > progn$n.c
+ echo "int foolt$n () { return 0; }" > liblt$n.c
+ echo "int fooltn$n () { return 0; }" > libltn$n.c
+done
+
+libtoolize
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+instdir=`pwd`/inst
+./configure --prefix="$instdir"
+$MAKE
+
+$MAKE install
+$MAKE uninstall
+
+for file in liblt1.la libltn1.la
+do
+ chmod a-r $file
+ test ! -r $file || skip_ "cannot drop file read permissions"
+ $MAKE install-exec && Exit 1
+ chmod u+r $file
+done
+
+$MAKE unreadable-prog
+$MAKE install-exec && Exit 1
+$MAKE readable-prog
+
+$MAKE unreadable-progn
+$MAKE install-exec && Exit 1
+$MAKE readable-progn
+
+:
diff --git a/t/instfail.sh b/t/instfail.sh
new file mode 100755
index 000000000..1e5a340f7
--- /dev/null
+++ b/t/instfail.sh
@@ -0,0 +1,95 @@
+#! /bin/sh
+# Copyright (C) 2008-2012 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/>.
+
+# The install rule should honor failures of the install program.
+# Some of these are already caught by instmany.test.
+
+# This test has a few sister tests, for java, info, libtool.
+
+required=cc
+. ./defs || Exit 1
+
+cat >>configure.ac <<END
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_RANLIB
+AM_PATH_LISPDIR
+AC_OUTPUT
+END
+
+cat >Makefile.am <<'END'
+bin_PROGRAMS = prog1 prog2 prog3
+nobase_bin_PROGRAMS = progn1 progn2 progn3
+lisp_LISP = lisp1.el lisp2.el lisp3.el
+nobase_lisp_LISP = lispn1.el lispn2.el lispn3.el
+lib_LIBRARIES = lib1.a lib2.a lib3.a
+nobase_lib_LIBRARIES = libn1.a libn2.a libn3.a
+unreadable-prog:
+ chmod a-r prog1$(EXEEXT)
+readable-prog:
+ chmod a+r prog1$(EXEEXT)
+unreadable-progn:
+ chmod a-r progn1$(EXEEXT)
+readable-progn:
+ chmod a+r progn1$(EXEEXT)
+END
+
+for n in 1 2 3; do
+ echo "int main () { return 0; }" > prog$n.c
+ echo "int main () { return 0; }" > progn$n.c
+ echo "int foo$n () { return 0; }" > lib$n.c
+ echo "int foon$n () { return 0; }" > libn$n.c
+ echo >lisp$n.el
+ echo >lispn$n.el
+done
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+instdir=`pwd`/inst
+./configure --prefix="$instdir"
+$MAKE
+
+$MAKE install
+$MAKE uninstall
+
+for file in lib1.a libn1.a
+do
+ chmod a-r $file
+ test ! -r $file || skip_ "cannot drop file read permissions"
+ $MAKE install-exec && Exit 1
+ chmod u+r $file
+done
+
+$MAKE unreadable-prog
+$MAKE install-exec && Exit 1
+$MAKE readable-prog
+
+$MAKE unreadable-progn
+$MAKE install-exec && Exit 1
+$MAKE readable-progn
+
+if grep "^EMACS = no" Makefile; then :; else
+ for file in lisp1.el lisp1.elc
+ do
+ chmod a-r $file
+ $MAKE install-data && Exit 1
+ chmod u+r $file
+ done
+fi
+
+:
diff --git a/t/insthook.sh b/t/insthook.sh
new file mode 100755
index 000000000..23bc4e03e
--- /dev/null
+++ b/t/insthook.sh
@@ -0,0 +1,77 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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 the install-exec-hook example we give in the manual works.
+
+. ./defs || Exit 1
+
+cat >>configure.ac <<'EOF'
+AC_PROG_LN_S
+AC_OUTPUT
+EOF
+
+cat >Makefile.am <<'END'
+dist_bin_SCRIPTS = foo
+
+install-exec-hook:
+ cd "$(DESTDIR)$(bindir)" && \
+ mv -f foo foo-$(VERSION) && \
+ $(LN_S) foo-$(VERSION) foo
+
+installcheck-local:
+ test -f "$(bindir)/foo"
+ test -f "$(bindir)/foo-$(VERSION)"
+ : > $(top_srcdir)/../ok
+
+uninstall-hook:
+ rm -f $(DESTDIR)$(bindir)/foo-$(VERSION)
+END
+
+echo 1 > foo
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+$MAKE distcheck
+# Sanity check to make sure installcheck-local was run.
+test -f ok
+
+# Make sure that installing a second version doesn't erase the first
+# one. (This is error prone since 'foo' symlinks to 'foo-1.0' and the
+# second version will overwrite 'foo'. Hopefully 'install' and 'install-sh'
+# are smart enough to erase the 'foo' symlink before installing the new
+# version.)
+./configure "--bindir=`pwd`/bin"
+$MAKE install
+echo 2 > foo
+VERSION=2.0 $MAKE -e install
+grep 1 bin/foo-1.0
+grep 2 bin/foo-2.0
+grep 2 bin/foo
+
+# install-hook is an error.
+cat >>Makefile.am <<EOF
+install-hook:
+ echo test
+EOF
+
+AUTOMAKE_fails
+grep install-data-hook stderr
+grep install-exec-hook stderr
+
+:
diff --git a/t/instman.sh b/t/instman.sh
new file mode 100755
index 000000000..787104592
--- /dev/null
+++ b/t/instman.sh
@@ -0,0 +1,34 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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 the MKDIR_P invocation is correct in install-man
+# target. Bug reported by Gordon Irlam <gordoni@cygnus.com>.
+
+. ./defs || Exit 1
+
+echo AC_OUTPUT >> configure.ac
+
+cat > Makefile.am << 'EOF'
+man_MANS = frob.8
+EOF
+
+: > frob.8
+
+$ACLOCAL
+$AUTOMAKE
+
+grep '[^(/]MKDIR_P' Makefile.in > out
+test `wc -l < out` -eq 1
diff --git a/t/instman2.sh b/t/instman2.sh
new file mode 100755
index 000000000..04663dbef
--- /dev/null
+++ b/t/instman2.sh
@@ -0,0 +1,33 @@
+#! /bin/sh
+# Copyright (C) 2000-2012 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/>.
+
+# Test to make sure mkinstalldirs invocation correct in install-man
+# target. Bug reported by Gordon Irlam <gordoni@cygnus.com>.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'EOF'
+man8_MANS = frob.8
+EOF
+
+: > frob.8
+
+$ACLOCAL
+$AUTOMAKE
+
+grep '^install-man' Makefile.in
+
+:
diff --git a/t/instmany-mans.sh b/t/instmany-mans.sh
new file mode 100755
index 000000000..ceb3a9e0f
--- /dev/null
+++ b/t/instmany-mans.sh
@@ -0,0 +1,141 @@
+#! /bin/sh
+# Copyright (C) 2008-2012 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/>.
+
+# Installing many files should not exceed the command line length limit.
+
+# This is the mans sister test of instmany.test, see there for details.
+
+. ./defs || Exit 1
+
+# In order to have a useful test on modern systems (which have a high
+# limit, if any), use a fake install program that errors out for more
+# than 2K characters in a command line. The POSIX limit is 4096, but
+# that may include space taken up by the environment.
+
+limit=2500
+subdir=long_subdir_name_with_many_characters
+nfiles=81
+list=`seq_ 1 $nfiles`
+
+sed "s|@limit@|$limit|g" >myinstall.in <<'END'
+#! /bin/sh
+# Fake install script. This doesn't really install
+# (the INSTALL path below would be wrong outside this directory).
+limit=@limit@
+INSTALL='@INSTALL@'
+len=`expr "$INSTALL $*" : ".*" 2>/dev/null || echo $limit`
+if test $len -ge $limit; then
+ echo "$0: safe command line limit of $limit characters exceeded" >&2
+ exit 1
+fi
+exit 0
+END
+
+# Creative quoting in the next line to please maintainer-check.
+sed "s|@limit@|$limit|g" >'rm' <<'END'
+#! /bin/sh
+limit=@limit@
+PATH=$save_PATH
+export PATH
+RM='rm -f'
+len=`expr "$RM $*" : ".*" 2>/dev/null || echo $limit`
+if test $len -ge $limit; then
+ echo "$0: safe command line limit of $limit characters exceeded" >&2
+ exit 1
+fi
+exec $RM "$@"
+exit 1
+END
+
+chmod +x rm
+
+cat >>configure.ac <<END
+AC_CONFIG_FILES([myinstall], [chmod +x ./myinstall])
+AC_CONFIG_FILES([$subdir/Makefile])
+AC_OUTPUT
+END
+
+cat >Makefile.am <<END
+SUBDIRS = $subdir
+END
+
+mkdir $subdir
+cd $subdir
+
+cat >Makefile.am <<'END'
+man_MANS =
+man3_MANS =
+notrans_man_MANS =
+notrans_man3_MANS =
+END
+
+for n in $list; do
+ unindent >>Makefile.am <<END
+ man_MANS += page$n.1
+ man3_MANS += page$n.man
+ notrans_man_MANS += npage$n.1
+ notrans_man3_MANS += npage$n.man
+END
+ echo >page$n.1
+ echo >page$n.man
+ echo >npage$n.1
+ echo >npage$n.man
+done
+
+cd ..
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+instdir=`pwd`/inst
+mkdir build
+cd build
+../configure --prefix="$instdir"
+$MAKE
+# Try whether native install (or install-sh) works.
+$MAKE install
+# Multiple uninstall should work, too.
+$MAKE uninstall
+$MAKE uninstall
+test `find "$instdir" -type f -print | wc -l` = 0
+
+# Try whether we don't exceed the low limit.
+INSTALL='$(SHELL) $(top_builddir)/myinstall' $MAKE -e install
+env save_PATH="$PATH" PATH="`pwd`/..$PATH_SEPARATOR$PATH" $MAKE uninstall
+
+cd $subdir
+srcdir=../../$subdir
+
+# Ensure 'make install' fails when 'install' fails.
+
+# We cheat here, for efficiency, knowing the internal rule names.
+# For correctness, one should '$MAKE install' here always, or at
+# least use install-exec or install-data.
+
+for file in page3.1 page$nfiles.1 npage3.1 npage$nfiles.1; do
+ chmod a-r $srcdir/$file
+ test ! -r $srcdir/$file || skip_ "cannot drop file read permissions"
+ $MAKE install-man1 && Exit 1
+ chmod u+r $srcdir/$file
+done
+
+for file in page3.man page$nfiles.man npage3.man npage$nfiles.man; do
+ chmod a-r $srcdir/$file
+ $MAKE install-man3 && Exit 1
+ chmod u+r $srcdir/$file
+done
+
+:
diff --git a/t/instmany-python.sh b/t/instmany-python.sh
new file mode 100755
index 000000000..d0c5b1a95
--- /dev/null
+++ b/t/instmany-python.sh
@@ -0,0 +1,130 @@
+#! /bin/sh
+# Copyright (C) 2008-2012 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/>.
+
+# Installing many files should not exceed the command line length limit.
+
+# This is the python sister test of instmany.test, see there for details.
+
+required='python'
+. ./defs || Exit 1
+
+limit=2500
+subdir=long_subdir_name_with_many_characters
+nfiles=81
+list=`seq_ 1 $nfiles`
+
+sed "s|@limit@|$limit|g" >myinstall.in <<'END'
+#! /bin/sh
+# Fake install script. This doesn't really install
+# (the INSTALL path below would be wrong outside this directory).
+limit=@limit@
+INSTALL='@INSTALL@'
+len=`expr "$INSTALL $*" : ".*" 2>/dev/null || echo $limit`
+if test $len -ge $limit; then
+ echo "$0: safe command line limit of $limit characters exceeded" >&2
+ exit 1
+fi
+exit 0
+END
+
+# Creative quoting in the next line to please maintainer-check.
+sed "s|@limit@|$limit|g" >'rm' <<'END'
+#! /bin/sh
+limit=@limit@
+PATH=$save_PATH
+export PATH
+RM='rm -f'
+len=`expr "$RM $*" : ".*" 2>/dev/null || echo $limit`
+if test $len -ge $limit; then
+ echo "$0: safe command line limit of $limit characters exceeded" >&2
+ exit 1
+fi
+exec $RM "$@"
+exit 1
+END
+
+chmod +x rm
+
+cat >>configure.ac <<END
+AM_PATH_PYTHON
+AC_CONFIG_FILES([myinstall], [chmod +x ./myinstall])
+AC_CONFIG_FILES([$subdir/Makefile])
+AC_OUTPUT
+END
+
+cat >Makefile.am <<END
+SUBDIRS = $subdir
+END
+
+mkdir $subdir
+cd $subdir
+
+cat >Makefile.am <<'END'
+python_PYTHON =
+nobase_python_PYTHON =
+END
+
+for n in $list; do
+ unindent >>Makefile.am <<END
+ python_PYTHON += python$n.py
+ nobase_python_PYTHON += npython$n.py
+END
+ echo >python$n.py
+ echo >npython$n.py
+done
+
+cd ..
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+instdir=`pwd`/inst
+mkdir build
+cd build
+../configure --prefix="$instdir"
+$MAKE
+# Try whether native install (or install-sh) works.
+$MAKE install
+# Multiple uninstall should work, too.
+$MAKE uninstall
+$MAKE uninstall
+test `find "$instdir" -type f -print | wc -l` = 0
+
+# Try whether we don't exceed the low limit.
+INSTALL='$(SHELL) $(top_builddir)/myinstall' $MAKE -e install
+env save_PATH="$PATH" PATH="`pwd`/..$PATH_SEPARATOR$PATH" $MAKE uninstall
+
+cd $subdir
+srcdir=../../$subdir
+
+# Ensure 'make install' fails when 'install' fails.
+
+for file in python3.py python$nfiles.py
+do
+ chmod a-r $srcdir/$file
+ test ! -r $srcdir/$file || skip_ "cannot drop file read permissions"
+ $MAKE install && Exit 1
+ chmod u+r $srcdir/$file
+done
+
+for file in npython3.py npython$nfiles.py
+do
+ chmod a-r $srcdir/$file
+ $MAKE install && Exit 1
+ chmod u+r $srcdir/$file
+done
+
+:
diff --git a/t/instmany.sh b/t/instmany.sh
new file mode 100755
index 000000000..d334ebef1
--- /dev/null
+++ b/t/instmany.sh
@@ -0,0 +1,185 @@
+#! /bin/sh
+# Copyright (C) 2008-2012 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/>.
+
+# Installing many files should not exceed the command line length limit.
+# Here, the main issue is that we may prepend '$(srcdir)/' to each file,
+# which may cause much longer command lines. The list of files must
+# anyway remain below the limit, otherwise 'make' won't be able to even
+# fork the command.
+#
+# Further, the install rule should honor failures of the install program.
+
+# Python is done in the sister test.
+# For texinfos, we expand names using $(srcdir) in the first place.
+# Let's hope nobody uses many texinfos.
+
+. ./defs || Exit 1
+
+# In order to have a useful test on modern systems (which have a high
+# limit, if any), use a fake install program that errors out for more
+# than 2K characters in a command line. The POSIX limit is 4096, but
+# that may include space taken up by the environment.
+
+limit=2500
+subdir=long_subdir_name_with_many_characters
+nfiles=81
+list=`seq_ 1 $nfiles`
+
+sed "s|@limit@|$limit|g" >myinstall.in <<'END'
+#! /bin/sh
+# Fake install script. This doesn't really install
+# (the INSTALL path below would be wrong outside this directory).
+limit=@limit@
+INSTALL='@INSTALL@'
+len=`expr "$INSTALL $*" : ".*" 2>/dev/null || echo $limit`
+if test $len -ge $limit; then
+ echo "$0: safe command line limit of $limit characters exceeded" >&2
+ exit 1
+fi
+exit 0
+END
+
+# Creative quoting in the next line to please maintainer-check.
+sed "s|@limit@|$limit|g" >'rm' <<'END'
+#! /bin/sh
+limit=@limit@
+PATH=$save_PATH
+export PATH
+RM='rm -f'
+len=`expr "$RM $*" : ".*" 2>/dev/null || echo $limit`
+if test $len -ge $limit; then
+ echo "$0: safe command line limit of $limit characters exceeded" >&2
+ exit 1
+fi
+exec $RM "$@"
+exit 1
+END
+
+chmod +x rm
+
+cat >>configure.ac <<END
+AC_CONFIG_FILES([myinstall], [chmod +x ./myinstall])
+AC_CONFIG_FILES([$subdir/Makefile])
+AC_OUTPUT
+END
+
+cat >Makefile.am <<END
+SUBDIRS = $subdir
+END
+
+mkdir $subdir
+cd $subdir
+
+cat >Makefile.am <<'END'
+bin_SCRIPTS =
+nobase_bin_SCRIPTS =
+data_DATA =
+nobase_data_DATA =
+include_HEADERS =
+nobase_include_HEADERS =
+END
+
+for n in $list; do
+ unindent >>Makefile.am <<END
+ bin_SCRIPTS += script$n
+ nobase_bin_SCRIPTS += nscript$n
+ data_DATA += data$n
+ nobase_data_DATA += ndata$n
+ include_HEADERS += header$n.h
+ nobase_include_HEADERS += nheader$n.h
+END
+ echo >script$n
+ echo >nscript$n
+ echo >data$n
+ echo >ndata$n
+ echo >header$n.h
+ echo >nheader$n.h
+done
+
+cd ..
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+instdir=`pwd`/inst
+mkdir build
+cd build
+../configure --prefix="$instdir"
+$MAKE
+# Try whether native install (or install-sh) works.
+$MAKE install
+# Multiple uninstall should work, too.
+$MAKE uninstall
+$MAKE uninstall
+test `find "$instdir" -type f -print | wc -l` = 0
+
+# Try whether we don't exceed the low limit.
+INSTALL='$(SHELL) $(top_builddir)/myinstall' $MAKE -e install
+env save_PATH="$PATH" PATH="`pwd`/..$PATH_SEPARATOR$PATH" $MAKE uninstall
+
+cd $subdir
+srcdir=../../$subdir
+
+# Ensure 'make install' fails when 'install' fails.
+
+# We cheat here, for efficiency, knowing the internal rule names.
+# For correctness, one should '$MAKE install' here always, or at
+# least use install-exec or install-data.
+
+for file in script3 script$nfiles
+do
+ chmod a-r $srcdir/$file
+ test ! -r $srcdir/$file || skip_ "cannot drop file read permissions"
+ $MAKE install-binSCRIPTS && Exit 1
+ chmod u+r $srcdir/$file
+done
+
+for file in nscript3 nscript$nfiles
+do
+ chmod a-r $srcdir/$file
+ $MAKE install-nobase_binSCRIPTS && Exit 1
+ chmod u+r $srcdir/$file
+done
+
+for file in data3 data$nfiles
+do
+ chmod a-r $srcdir/$file
+ $MAKE install-dataDATA && Exit 1
+ chmod u+r $srcdir/$file
+done
+
+for file in ndata3 ndata$nfiles
+do
+ chmod a-r $srcdir/$file
+ $MAKE install-nobase_dataDATA && Exit 1
+ chmod u+r $srcdir/$file
+done
+
+for file in header3.h header$nfiles.h
+do
+ chmod a-r $srcdir/$file
+ $MAKE install-includeHEADERS && Exit 1
+ chmod u+r $srcdir/$file
+done
+
+for file in nheader3.h nheader$nfiles.h
+do
+ chmod a-r $srcdir/$file
+ $MAKE install-nobase_includeHEADERS && Exit 1
+ chmod u+r $srcdir/$file
+done
+
+:
diff --git a/t/instsh.sh b/t/instsh.sh
new file mode 100755
index 000000000..1fd1b3b30
--- /dev/null
+++ b/t/instsh.sh
@@ -0,0 +1,39 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test for this bug:
+# automake: Makefile.am: required file "../../install-sh" not found; installing
+# This also makes sure that install-sh is created in the correct directory.
+
+. ./defs || Exit 1
+
+: > Makefile.am
+rm -f install-sh
+
+# Since the default path includes '../..', we must run this test in
+# yet another subdir.
+mkdir frob
+mv Makefile.am configure.ac frob/
+cd frob
+
+$ACLOCAL
+$AUTOMAKE --add-missing > output 2>&1
+
+# Only one '/' should appear in the output.
+cat output
+grep '/.*/' output && Exit 1
+
+test -f install-sh
diff --git a/t/instsh2.sh b/t/instsh2.sh
new file mode 100755
index 000000000..054beb9eb
--- /dev/null
+++ b/t/instsh2.sh
@@ -0,0 +1,118 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Various install-sh checks.
+
+am_create_testdir=empty
+. ./defs || Exit 1
+
+get_shell_script install-sh
+
+# Basic errors.
+./install-sh && Exit 1
+./install-sh -m 644 dest && Exit 1
+
+# Directories.
+
+# It should be OK to create no directory. We sometimes need
+# this when directory are conditionally defined.
+./install-sh -d
+# One directory.
+./install-sh -d d0
+test -d d0
+# Multiple directories (for make installdirs).
+./install-sh -d d1 d2 d3 d4
+test -d d1
+test -d d2
+test -d d3
+test -d d4
+# Subdirectories.
+./install-sh -d p1/p2/p3 p4//p5//p6//
+test -d p1/p2/p3
+test -d p4/p5/p6
+
+# Files.
+: > x
+./install-sh -c -m 644 x y
+test -f x
+test -f y
+./install-sh -m 644 y z
+test -f y
+test -f z
+# Multiple files.
+./install-sh -m 644 -c x z d1
+test -f x
+test -f z
+test -f d1/x
+test -f d1/z
+./install-sh -m 644 x z d2//
+test -f x
+test -f z
+test -f d2/x
+test -f d2/z
+./install-sh -t d3 -m 644 x z
+test -f x
+test -f z
+test -f d3/x
+test -f d3/z
+./install-sh -t d4// -m 644 x z
+test -f x
+test -f z
+test -f d4/x
+test -f d4/z
+./install-sh -T x d3/y
+test -f x
+test -f d3/y
+./install-sh -T x d3 && Exit 1
+./install-sh -T x d4// && Exit 1
+
+# Ensure that install-sh works with names that include spaces.
+touch 'a b'
+mkdir 'x y'
+./install-sh 'a b' 'x y'
+test -f x\ \ y/a\ \ b
+test -f 'a b'
+
+# Ensure we do not run into 'test' operator precedence bugs with Tru64 sh.
+for c in = '(' ')' '!'; do
+ ./install-sh $c 2>stderr && { cat stderr >&2; Exit 1; }
+ cat stderr >&2
+ grep 'test: ' stderr && Exit 1
+ # Skip tests if the file system is not capable.
+ mkdir ./$c || continue
+ rmdir ./$c
+ ./install-sh -d $c/$c/$c
+ rm -rf ./$c
+ ./install-sh -d $c d5/$c/$c
+ test -d ./$c
+ test -d d5/$c/$c
+ ./install-sh x $c
+ test -f ./$c/x
+ rm -f ./$c/x
+ ./install-sh -t $c x
+ test -f ./$c/x
+ rm -rf ./$c
+ ( : > ./$c ) || continue
+ ./install-sh $c x d5/$c/$c
+ test -f d5/$c/$c/x
+ test -f d5/$c/$c/$c
+ rm -f d5/$c/$c/?
+ ./install-sh -t d5/$c/$c $c x
+ test -f d5/$c/$c/x
+ test -f d5/$c/$c/$c
+done
+
+:
diff --git a/t/instsh3.sh b/t/instsh3.sh
new file mode 100755
index 000000000..3a527cb59
--- /dev/null
+++ b/t/instsh3.sh
@@ -0,0 +1,43 @@
+#! /bin/sh
+# Copyright (C) 2006-2012 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/>.
+
+# More install-sh checks: check -C.
+
+am_create_testdir=empty
+required=non-root
+. ./defs || Exit 1
+
+# Solaris /usr/ucb/touch does not accept -t.
+touch -t $old_timestamp foo \
+ || skip_ "touch utility doesn't accept '-t' option"
+
+get_shell_script install-sh
+
+./install-sh -d d1
+
+# Do not change the timestamps when using -C.
+echo foo >file
+./install-sh -C file d1
+TZ=UTC0 touch -t $old_timestamp d1/file
+./install-sh -C file d1
+is_newest file d1/file
+echo foo1 >file
+./install-sh -C file d1
+diff file d1/file
+# Rights must be updated.
+./install-sh -C -m 444 file d1
+test -r d1/file
+test ! -w d1/file
diff --git a/t/instspc.tap b/t/instspc.tap
new file mode 100755
index 000000000..cbe0fdfdd
--- /dev/null
+++ b/t/instspc.tap
@@ -0,0 +1,335 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Check that building from, or installing to, directories with shell
+# metacharacters succeed.
+# Original report from James Amundson about file names with spaces.
+# Other characters added by Paul Eggert.
+
+. ./defs || Exit 99
+
+# Usage: is_in_list ITEM [LIST...]
+is_in_list ()
+{
+ item=$1; shift;
+ case " $* " in
+ *[\ \ ]"$item"[\ \ ]*) return 0;;
+ *) return 1;;
+ esac
+}
+
+# Helper subroutine for test data definition.
+# Usage: define_problematic_string NAME STRING
+define_problematic_string ()
+{
+ tst=$1; shift
+ eval "instspc__$tst=\$1" \
+ || fatal_ "define_problematic_string: bad argument: '$tst'"
+ shift
+ all_test_names_list="$all_test_names_list $tst"
+ # Some of the "problematic" characters cannot be used in the name of
+ # a build or install directory on a POSIX host. These lists should
+ # be empty, but are not due to limitations in Autoconf, Automake, Make,
+ # M4, or the shell.
+ if is_in_list fail-builddir "$@"; then
+ builddir_xfails="$builddir_xfails $tst"
+ fi
+ if is_in_list fail-destdir "$@"; then
+ destdir_xfails="$destdir_xfails $tst"
+ fi
+}
+
+# Be sure to avoid interferences from the environment.
+all_test_names_list=''
+builddir_xfails=''
+destdir_xfails=''
+
+expected_to_fail ()
+{
+ case $1 in
+ build) is_in_list "$2" $builddir_xfails;;
+ dest) is_in_list "$2" $destdir_xfails;;
+ *) fatal_ "incorrect 'expected_to_fail' usage";;
+ esac
+}
+
+# Helper subroutines for creation of input data files.
+create_input_data ()
+{
+ mkdir sub
+
+ unindent >> configure.ac << 'EOF'
+ AC_PROG_CC
+ AM_PROG_AR
+ AC_PROG_RANLIB
+ AC_OUTPUT
+EOF
+
+ : > sub/base.h
+ : > sub/nobase.h
+ : > sub/base.dat
+ : > sub/nobase.dat
+ : > sub/base.sh
+ : > sub/nobase.sh
+
+ unindent > source.c << 'EOF'
+ int
+ main (int argc, char **argv)
+ {
+ return 0;
+ }
+EOF
+
+ unindent > Makefile.am << 'EOF'
+ foodir = $(prefix)/foo
+ fooexecdir = $(prefix)/foo
+
+ foo_HEADERS = sub/base.h
+ nobase_foo_HEADERS = sub/nobase.h
+
+ dist_foo_DATA = sub/base.dat
+ nobase_dist_foo_DATA = sub/nobase.dat
+
+ dist_fooexec_SCRIPTS = sub/base.sh
+ nobase_dist_fooexec_SCRIPTS = sub/nobase.sh
+
+ fooexec_PROGRAMS = sub/base
+ nobase_fooexec_PROGRAMS = sub/nobase
+ sub_base_SOURCES = source.c
+ sub_nobase_SOURCES = source.c
+
+ fooexec_LIBRARIES = sub/libbase.a
+ nobase_fooexec_LIBRARIES = sub/libnobase.a
+ sub_libbase_a_SOURCES = source.c
+ sub_libnobase_a_SOURCES = source.c
+
+ .PHONY: test-inst
+ test-inst: install
+ test -f '$(DESTDIR)/$(file)-prefix/foo/sub/nobase.h'
+ test ! -f '$(DESTDIR)/$(file)-prefix/foo/nobase.h'
+ test -f '$(DESTDIR)/$(file)-prefix/foo/base.h'
+ test -f '$(DESTDIR)/$(file)-prefix/foo/sub/nobase.dat'
+ test ! -f '$(DESTDIR)/$(file)-prefix/foo/nobase.dat'
+ test -f '$(DESTDIR)/$(file)-prefix/foo/base.dat'
+ test -f '$(DESTDIR)/$(file)-prefix/foo/sub/nobase.sh'
+ test ! -f '$(DESTDIR)/$(file)-prefix/foo/nobase.sh'
+ test -f '$(DESTDIR)/$(file)-prefix/foo/base.sh'
+ test -f '$(DESTDIR)/$(file)-prefix/foo/sub/nobase$(EXEEXT)'
+ test ! -f '$(DESTDIR)/$(file)-prefix/foo/nobase$(EXEEXT)'
+ test -f '$(DESTDIR)/$(file)-prefix/foo/base$(EXEEXT)'
+ test -f '$(DESTDIR)/$(file)-prefix/foo/sub/libnobase.a'
+ test ! -f '$(DESTDIR)/$(file)-prefix/foo/libnobase.a'
+ test -f '$(DESTDIR)/$(file)-prefix/foo/libbase.a'
+EOF
+
+ $ACLOCAL || framework_failure_ "aclocal failed"
+ $AUTOCONF || framework_failure_ "autoconf failed"
+ $AUTOMAKE -a || framework_failure_ "automake failed"
+}
+
+# ================= #
+# Test data begin #
+# ----------------- #
+
+# Some control characters that are white space.
+bs='' # back space
+cr=' ' # carriage return
+ff=' ' # form feed
+ht=' ' # horizontal tab
+lf='
+' # line feed (aka newline)
+
+# Hack to save typing and make code visually clearer.
+def=define_problematic_string
+
+$def squote \' fail-builddir fail-destdir
+$def dquote '"' fail-builddir fail-destdir
+$def bquote '`' fail-builddir fail-destdir
+$def sharp '#' fail-builddir fail-destdir
+$def dollar '$' fail-builddir fail-destdir
+$def bang '!'
+$def bslash '\' fail-builddir
+$def ampersand '&' fail-builddir
+$def percent '%'
+$def leftpar '('
+$def rightpar ')'
+$def pipe '|'
+$def caret '^'
+$def tilde '~'
+$def qmark '?'
+$def star '*'
+$def plus '+'
+$def minus '-'
+$def comma ','
+$def colon ':'
+$def semicol ';'
+$def equal '='
+$def less '<'
+$def more '>'
+$def at '@'
+$def lqbrack '['
+$def rqbrack ']'
+$def lcbrack '{'
+$def rcbrack '}'
+$def space ' '
+$def tab "$ht"
+$def linefeed "$lf" fail-builddir fail-destdir
+$def backspace "$bs"
+$def formfeed "$ff"
+$def carriageret "$cr"
+$def quadrigraph0 '@&t@' fail-builddir
+$def quadrigraph1 '@<:@'
+$def quadrigraph2 '@:>@'
+$def quadrigraph3 '@S|@'
+$def quadrigraph4 '@%:@'
+$def a_b 'a b'
+$def a__b 'a b'
+$def a_lf_b "a${lf}b" fail-builddir fail-destdir
+$def dotdotdot '...'
+$def dosdrive 'a:'
+$def miscglob1 '?[a-z]*'
+$def miscglob2 '.*?[0-9]'
+
+unset def
+
+# --------------- #
+# Test data end #
+# =============== #
+
+# Allow the user to select a subset of the tests.
+if test $# -gt 0; then
+ test_names_list=$*
+ for test_name in $test_names_list; do
+ case " $all_test_names_list " in
+ *" $test_name "*);;
+ *) fatal_ "invalid user-specified test_name '$test_name'"
+ esac
+ done
+ # We need to determine the TAP plan adaptively.
+ n=`for t in $test_names_list; do echo $t; done | wc -l`
+ plan_ `expr $n '*' 2` # Two tests per "problematic string".
+ unset n
+else
+ test_names_list=$all_test_names_list
+ # Prefer static TAP plan if possible, it minimizes the chance of errors.
+ plan_ 94
+fi
+
+ocwd=`pwd` || fatal_ "cannot get current working directory"
+
+create_input_data
+
+for test_name in $test_names_list; do
+
+ eval "test_string=\${instspc__$test_name}" \
+ || fatal_ "invalid test name: '$test_name'"
+
+ if test x"$test_string" = x; then
+ if test x"$test_name" != xcarriageret; then
+ fatal_ "invalid test name: '$test_name'"
+ else
+ # MSYS version 1.0.17 still mishandles carriage returns; see
+ # automake bug#7849.
+ skip_ -r "carriage-return treated as null char" "$test_name in builddir"
+ skip_ -r "carriage-return treated as null char" "$test_name in destdir"
+ continue
+ fi
+ fi
+
+ # Skip the next checks if this system doesn't support the required
+ # characters in file names.
+
+ mkdir "./$test_string" || {
+ skip_ -r "mkdir failed" "$test_name in builddir"
+ skip_ -r "mkdir failed" "$test_name in destdir"
+ continue
+ }
+
+ case $test_string in
+ *:*)
+ # On MSYS 1.0.17, "mkdir ./a:" creates ./a, and "cd ./a:" takes you
+ # to a strange directory with pwd equal to "a". But only for
+ # interactive shells. Or something? In this script, "cd ./a:" fails
+ # on MSYS. Marvelous.
+ ( cd "./$test_string" ) || {
+ rmdir "./$test_string" || fatal_ "removing directory"
+ skip_ -r "cd failed" "$test_name in builddir"
+ skip_ -r "cd failed" "$test_name in destdir"
+ continue
+ }
+ ;;
+ esac
+
+ # Where are the "weird" characters going to be used, in $(builddir)
+ # or in $(DESTDIR)? They are always going to be used in $(prefix)
+ # though; should we maybe separate this into a dedicated check?
+ for where in build dest; do
+
+ case $where in
+ build)
+ build=./$test_string
+ dest=$ocwd/dest-$test_name
+ ;;
+ dest)
+ build=build-$test_name
+ dest=$ocwd/$test_string
+ mkdir "$build" || fatal_ "cannot create '$build'"
+ ;;
+ *)
+ fatal_ "invalid where '$where'"
+ ;;
+ esac
+
+ cd "$build" || fatal_ "cannot chdir into '$build'"
+
+ # Some make implementations eliminate leading and trailing whitespace
+ # from macros passed on the command line, and some eliminate leading
+ # whitespace from macros set from environment variables, so prepend
+ # './' and use the latter here.
+ r=ok
+ ../configure --prefix "/$test_string-prefix" \
+ && $MAKE all \
+ && DESTDIR="$dest" file="./$test_string" $MAKE -e test-inst \
+ || r='not ok'
+
+ description="$test_name in ${where}dir"
+ if expected_to_fail "$where" "$test_name"; then
+ directive=TODO
+ reason="long-standing limitation"
+ else
+ directive=
+ reason=
+ fi
+ # Test case outcome is here.
+ result_ "$r" -D "$directive" -r "$reason" -- "$description"
+
+ cd "$ocwd" || fatal_ "cannot chdir back to test directory"
+
+ # Remove subdirectories for tests that have passed, to avoid ending up
+ # with a too big test directory. This is especially important since
+ # some tests in this tests are expected to fail, and this will cause
+ # the test directory not to be removed when the script terminates.
+ if not am_keeping_testdirs && test "$r" = ok; then
+ rm_rf_ "$build" "$dest" || fatal_ "removing temporary subdirectory"
+ else
+ : For lesser shells with broken 'set -e'.
+ fi
+
+ done # $instspc_action
+
+done # $test_name
+
+:
diff --git a/t/interp.sh b/t/interp.sh
new file mode 100755
index 000000000..b45d44932
--- /dev/null
+++ b/t/interp.sh
@@ -0,0 +1,38 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test to make sure variable interpolation works.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = foo
+xs = a.c b.c
+foo_SOURCES = c.c $(xs)
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+$FGREP ' a.$(OBJEXT)' Makefile.in
+$FGREP ' b.$(OBJEXT)' Makefile.in
+$FGREP ' c.$(OBJEXT)' Makefile.in
+
+:
diff --git a/t/interp2.sh b/t/interp2.sh
new file mode 100755
index 000000000..3ce33e253
--- /dev/null
+++ b/t/interp2.sh
@@ -0,0 +1,37 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test to make sure variable interpolation doesn't break other
+# features. Report from Joel N. Weber, II.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_PATH_X
+AC_PATH_XTRA
+END
+
+cat > Makefile.am << 'END'
+noinst_PROGRAMS = x
+x_SOURCES = x.c
+x_LDADD = $(X_EXTRA_LIBS)
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+:
diff --git a/t/java-check.sh b/t/java-check.sh
new file mode 100755
index 000000000..230fb96f1
--- /dev/null
+++ b/t/java-check.sh
@@ -0,0 +1,64 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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 that check_JAVA causes *.class files to be built only with
+# "make check", and not also with "make all".
+# See automake bug#8234.
+
+required=javac
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+check_JAVA = One.java Two.java
+END
+
+cat > One.java <<'END'
+class One { }
+END
+
+cat > Two.java <<'END'
+class Two { // Deliberately missing closing bracket.
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+inst=`pwd`/_inst
+
+./configure --prefix="$inst"
+
+$MAKE
+ls | $EGREP '\.(class|stamp)$' && Exit 1
+
+# Make Two.java compilable.
+echo '}' >> Two.java
+
+# "make check" should compile files in $(check_JAVA) ...
+$MAKE check
+ls -l # For debugging.
+test -f One.class
+test -f Two.class
+# ... but should *not* install them.
+$FGREP checkdir Makefile && Exit 1
+$MAKE install
+test -d _inst && Exit 1
+
+:
diff --git a/t/java-clean.sh b/t/java-clean.sh
new file mode 100755
index 000000000..239920172
--- /dev/null
+++ b/t/java-clean.sh
@@ -0,0 +1,66 @@
+#! /bin/sh
+# Copyright (C) 1998-2012 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/>.
+
+# Test cleaning of Java class files and timestamps.
+
+required=javac
+. ./defs || Exit 1
+
+cat >> configure.ac <<'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+javadir = $(datadir)/java
+
+java_JAVA = Class.java
+dist_java_JAVA = ClassDist.java
+nodist_java_JAVA = ClassNodist.java
+
+nobase_java_JAVA = ClassNobase.java
+nobase_dist_java_JAVA = ClassNobaseDist.java
+nobase_nodist_java_JAVA = ClassNobaseNodist.java
+END
+
+for base in '' Nobase; do
+ for dist in '' Dist Nodist; do
+ echo "class Class$base$dist {}" > Class$base$dist.java
+ done
+done
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+$MAKE
+ls -l
+test -f classjava.stamp
+for base in '' Nobase; do
+ for dist in '' Dist Nodist; do
+ test -f Class$base$dist.class
+ done
+done
+$MAKE clean
+find . -name '*.class' -o -name '*.stamp' | grep . && Exit 1
+# We should not remove unrelated stamp files.
+echo timestamp > classjava2.stamp
+echo timestamp > classdist_java.stamp
+$MAKE clean
+test -f classjava2.stamp
+test -f classdist_java.stamp
+
+:
diff --git a/t/java-compile-install.sh b/t/java-compile-install.sh
new file mode 100755
index 000000000..f3340ffa3
--- /dev/null
+++ b/t/java-compile-install.sh
@@ -0,0 +1,97 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Test on compilation and installation of Java class files.
+
+required=javac
+. ./defs || Exit 1
+
+cat >>configure.ac <<'EOF'
+AC_OUTPUT
+EOF
+
+cat > Makefile.am << 'END'
+javadir = $(datadir)/java
+java_JAVA = Foo.java
+nobase_java_JAVA = Foo2.java
+nobase_dist_java_JAVA = Bar.java
+nodist_java_JAVA = Baz.java
+
+# Java files are not distributed by default, so we distribute
+# one "by hand" ...
+EXTRA_DIST = Foo.java
+# ... and make the other one generated.
+Foo2.java:
+ rm -f $@ $@-t
+ echo 'class bClass {}' > $@-t
+ chmod a-w $@-t && mv -f $@-t $@
+
+# Explicitly declared as 'nodist_', so generate it.
+Baz.java:
+ rm -f $@ $@-t
+ echo 'class Baz {}' > $@-t
+ echo 'class Baz2 {}' >> $@-t
+ chmod a-w $@-t && mv -f $@-t $@
+
+test:
+ ls -l $(srcdir) . ;: For debugging.
+ test -f $(srcdir)/Foo.java
+ test -f $(srcdir)/Bar.java
+ test -f Foo2.java
+ test -f Baz.java
+ test -f aClass.class
+ test -f bClass.class
+ test -f Zardoz.class
+ test -f Baz.class
+ test -f Baz2.class
+ test ! -r Foo.class
+ test ! -r Bar.class
+ test -f classjava.stamp
+
+test-install:
+ ls -l $(javadir) ;: For debugging.
+ test -f '$(javadir)/bClass.class'
+ test -f '$(javadir)/aClass.class'
+ test -f '$(javadir)/Zardoz.class'
+ test -f '$(javadir)/Baz.class'
+ test -f '$(javadir)/Baz2.class'
+ test ! -r '$(javadir)/Foo.class'
+ test ! -r '$(javadir)/Bar.class'
+ if find $(prefix) | grep '\.stamp$$'; then exit 1; else :; fi
+
+check-local: test
+installcheck-local: test-install
+
+.PHONY: test test-install
+
+DISTCLEANFILES = Baz.java Foo2.java
+END
+
+echo 'class aClass {}' > Foo.java
+echo 'class Zardoz {}' > Bar.java
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure --prefix="`pwd`"/_inst
+$MAKE
+$MAKE test
+$MAKE install
+$MAKE test-install
+$MAKE distcheck
+
+:
diff --git a/t/java-compile-run-flat.sh b/t/java-compile-run-flat.sh
new file mode 100755
index 000000000..79083af0b
--- /dev/null
+++ b/t/java-compile-run-flat.sh
@@ -0,0 +1,241 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Test on compilation and execution of Java class files.
+# Also meddle with wrapper scripts, as would be probably seen in a real
+# "UNIX-style" use case.
+# This test uses a "flat" setup for the source tree (i.e., everything in
+# the top-level directory), and forces the use of the old, non-parallel
+# testsuite driver. The sister test 'java-compile-run-nested.test' do
+# similar checks with a more usual, "nested" setup, and using the newer
+# 'parallel-tests' driver.
+
+required='java javac'
+am_parallel_tests=no
+. ./defs || Exit 1
+
+echo "AC_SUBST([PATH_SEPARATOR], ['$PATH_SEPARATOR'])" >> configure.ac
+
+cat >> configure.ac <<'END'
+AC_SUBST([JAVA], [java])
+AC_CONFIG_SRCDIR([PkgLocation.jin])
+AC_CONFIG_FILES([PkgLocation.java:PkgLocation.jin])
+AC_OUTPUT
+END
+
+## TOP-LEVEL SETUP AND TARGETS ##
+
+cat > Makefile.am <<'END'
+EXTRA_DIST = # Will be updated later.
+
+test-built:
+ ls -l $(srcdir) ;: For debugging.
+ test $(srcdir) = . || ls -l . ;: Likewise.
+ test -f $(srcdir)/Main.java
+ test -f $(srcdir)/HelloStream.java
+ test -f $(srcdir)/PkgLocation.jin
+ test -f PkgLocation.java
+ test -f HelloStream.class
+ test -f PkgLocation.class
+ test -f Main.class
+ test -f classjava.stamp
+
+test-installed:
+ ls -l $(javadir) ;: For debugging.
+ test -f $(javadir)/HelloStream.class
+ test -f $(javadir)/PkgLocation.class
+ test -f $(javadir)/Main.class
+ if find $(prefix) | grep '\.stamp$$'; then exit 1; else :; fi
+
+run-installed:
+ jprog_doing_installcheck=yes $(MAKE) $(AM_MAKEFLAGS) check
+
+check-local: test-built
+installcheck-local: test-installed run-installed
+
+.PHONY: test-built test-installed run-installed
+END
+
+## WRAPPER SCRIPT ##
+
+cat >> Makefile.am <<'END'
+bin_SCRIPTS = jprog
+
+edit_script = sed -e 's|[@]JAVA@|$(JAVA)|g' \
+ -e 's|[@]javadir@|$(javadir)|g' \
+ -e 's|[@]SHELL@|$(SHELL)|g' \
+ -e 's|[@]PATH_SEPARATOR@|$(PATH_SEPARATOR)|g'
+
+jprog: jprog.sh
+ rm -f $@ $@-t
+ $(edit_script) `test -f '$@.sh' || echo $(srcdir)/`$@.sh >$@-t
+ chmod a-w $@-t && chmod a+x $@-t && mv -f $@-t $@
+ sed 's/^/ | /' $@ ;: for debugging.
+
+EXTRA_DIST += jprog.sh
+CLEANFILES = jprog
+END
+
+cat > jprog.sh <<'END'
+#!@SHELL@
+CLASSPATH=${jprog_classpath-'@javadir@'}${CLASSPATH+"@PATH_SEPARATOR@$CLASSPATH"}
+export CLASSPATH
+case $# in
+ 0) exec @JAVA@ Main;;
+ *) exec @JAVA@ Main "$@";;
+esac
+END
+
+## JAVA SOURCES ##
+
+cat >> Makefile.am <<'END'
+javadir = $(pkgdatadir)/java
+
+dist_java_JAVA = Main.java HelloStream.java
+nodist_java_JAVA = PkgLocation.java
+END
+
+cat > PkgLocation.jin <<'END'
+public class PkgLocation {
+ public static String prefix() {
+ return new String("@prefix@");
+ }
+}
+END
+
+cat > Main.java <<'END'
+public class Main {
+ public static void main(String[] args) {
+ for (int i = 0; i < args.length; i++) {
+ if (args[i].equals("--print-prefix")) {
+ System.out.println(PkgLocation.prefix());
+ } else if (args[i].equals("--hello-stdout")) {
+ HelloStream.to(System.out);
+ } else if (args[i].equals("--hello-stderr")) {
+ HelloStream.to(System.err);
+ } else {
+ System.err.println("jprog: invalid option '" + args[i] +
+ "'");
+ System.exit(2);
+ }
+ }
+ System.exit(0);
+ }
+}
+END
+
+cat > HelloStream.java <<'END'
+import java.io.PrintStream;
+class HelloStream {
+ public static void to(PrintStream stream) {
+ stream.println("Hello, Stream!");
+ }
+}
+END
+
+## TESTS ##
+
+cat >> Makefile.am <<'END'
+## We must use 'TESTS_ENVIRONMENT', not 'AM_TESTS_ENVIRONMENT',
+## because the latter is not hnoured by the old serial test
+## harness.
+TESTS_ENVIRONMENT = \
+ if test x"$$jprog_doing_installcheck" != x"yes"; then \
+ jprog_classpath='$(abs_top_builddir):$(abs_top_srcdir)'; \
+ export jprog_classpath; \
+ PATH='$(abs_top_builddir)$(PATH_SEPARATOR)'$$PATH; \
+ export PATH; \
+ else \
+ unset jprog_classpath || :; \
+ PATH='$(prefix)/bin$(PATH_SEPARATOR)'$$PATH; \
+ export PATH; \
+ fi; \
+ config_time_prefix='@prefix@'; export config_time_prefix;
+
+TESTS = \
+ simple.test \
+ prefix.test \
+ stdout.test \
+ stderr.test \
+ badarg.test
+
+XFAIL_TESTS = badarg.test
+
+EXTRA_DIST += $(TESTS)
+END
+
+cat > simple.test <<'END'
+#!/bin/sh
+jprog
+END
+
+cat > prefix.test <<'END'
+#!/bin/sh
+jprefix=`jprog --print-prefix` || exit 1
+echo "$0: exp prefix: $config_time_prefix"
+echo "$0: got prefix: $jprefix"
+test x"$jprefix" = x"$config_time_prefix"
+END
+
+cat > stdout.test <<'END'
+#!/bin/sh
+rc=0
+jprog --hello-stdout >stdout.out 2>stdout.err || { echo \$?=$?; rc=1; }
+sed 's/^/out:/' <stdout.out # For debugging.
+sed 's/^/err:/' <stdout.err >&2 # Likewise.
+test -s stdout.err && rc=1
+test "`cat stdout.out`" = 'Hello, Stream!' || rc=1
+rm -f stdout.out stdout.err || rc=1
+exit $rc
+END
+
+cat > stderr.test <<'END'
+#!/bin/sh
+rc=0
+jprog --hello-stderr >stderr.out 2>stderr.err || { echo \$?=$?; rc=1; }
+sed 's/^/out:/' <stderr.out # For debugging.
+sed 's/^/err:/' <stderr.err >&2 # Likewise.
+test -s stderr.out && rc=1
+test "`cat stderr.err`" = 'Hello, Stream!' || rc=1
+rm -f stderr.out stderr.err || rc=1
+exit $rc
+END
+
+cat > badarg.test <<'END'
+#!/bin/sh
+jprog --bad-argument
+END
+
+chmod a+x *.test
+
+## DO CHECKS ##
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+# To have the parallel testsuite more verbose.
+VERBOSE=yes; export VERBOSE
+
+./configure --prefix="`pwd`/_inst"
+cat PkgLocation.java # For debugging.
+$MAKE check
+$MAKE install
+$MAKE test-installed
+$MAKE run-installed
+$MAKE distcheck
+
+:
diff --git a/t/java-compile-run-nested.sh b/t/java-compile-run-nested.sh
new file mode 100755
index 000000000..d4a780023
--- /dev/null
+++ b/t/java-compile-run-nested.sh
@@ -0,0 +1,251 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Test on compilation and execution of Java class files.
+# Also meddle with wrapper scripts, as would be probably seen in a real
+# "UNIX-style" use case.
+# This test uses a typical "nested" source tree setup (i.e., different
+# components/aspects are separated into different subdirectories),
+# and uses the 'parallel-tests' testsuite driver. The sister test
+# 'java-compile-run-flat.test' do similar checks with a "flat" setup
+# (i.e., everything in the top-level directory), and forcing the use
+# of the older non-parallel 'simple-tests' driver.
+
+required='java javac'
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+echo "AC_SUBST([PATH_SEPARATOR], ['$PATH_SEPARATOR'])" >> configure.ac
+
+cat >> configure.ac <<'END'
+AC_SUBST([JAVA], [java])
+AC_CONFIG_SRCDIR([jprog/PkgLocation.jin])
+AC_SUBST([jprogdatadir], ['${pkgdatadir}'])
+AC_SUBST([jprogclassdir], ['${jprogdatadir}/jprog'])
+AC_CONFIG_FILES([jprog/PkgLocation.java:jprog/PkgLocation.jin])
+AC_CONFIG_FILES([jprog/Makefile bin/Makefile tests/Makefile])
+AC_OUTPUT
+END
+
+## TOP-LEVEL SETUP AND TARGETS ##
+
+cat > Makefile.am <<'END'
+SUBDIRS = bin jprog tests
+
+test-built:
+ ls -l $(srcdir)/* ;: For debugging.
+ test $(srcdir) = . || ls -l * ;: Likewise.
+ test -f $(srcdir)/jprog/Main.java
+ test -f $(srcdir)/jprog/HelloStream.java
+ test -f $(srcdir)/jprog/PkgLocation.jin
+ test -f jprog/PkgLocation.java
+ test -f jprog/HelloStream.class
+ test -f jprog/Main.class
+ test -f jprog/PkgLocation.class
+ test -f jprog/classjprogclass.stamp
+
+test-installed:
+ ls -l $(jprogclassdir) ;: For debugging.
+ test -f $(jprogclassdir)/HelloStream.class
+ test -f $(jprogclassdir)/Main.class
+ test -f $(jprogclassdir)/PkgLocation.class
+ if find $(prefix) | grep '\.stamp$$'; then exit 1; else :; fi
+
+run-installed:
+ jprog_doing_installcheck=yes $(MAKE) $(AM_MAKEFLAGS) check
+
+check-local: test-built
+installcheck-local: test-installed run-installed
+
+.PHONY: test-built test-installed run-installed
+END
+
+## WRAPPER SCRIPT ##
+
+mkdir bin
+
+cat > bin/Makefile.am <<'END'
+bin_SCRIPTS = jprog
+
+edit_script = sed -e 's|[@]JAVA@|$(JAVA)|g' \
+ -e 's|[@]jprogdatadir@|$(jprogdatadir)|g' \
+ -e 's|[@]SHELL@|$(SHELL)|g' \
+ -e 's|[@]PATH_SEPARATOR@|$(PATH_SEPARATOR)|g'
+
+jprog: jprog.sh
+ rm -f $@ $@-t
+ $(edit_script) `test -f '$@.sh' || echo $(srcdir)/`$@.sh >$@-t
+ chmod a-w $@-t && chmod a+x $@-t && mv -f $@-t $@
+ sed 's/^/ | /' $@ ;: for debugging.
+
+EXTRA_DIST = jprog.sh
+CLEANFILES = jprog
+END
+
+cat > bin/jprog.sh <<'END'
+#!@SHELL@
+CLASSPATH=${jprog_classpath-'@jprogdatadir@'}${CLASSPATH+"@PATH_SEPARATOR@$CLASSPATH"}
+export CLASSPATH
+case $# in
+ 0) exec @JAVA@ jprog.Main;;
+ *) exec @JAVA@ jprog.Main "$@";;
+esac
+END
+
+## JAVA SOURCES ##
+
+mkdir jprog
+
+cat > jprog/Makefile.am <<'END'
+dist_jprogclass_JAVA = Main.java HelloStream.java
+nodist_jprogclass_JAVA = PkgLocation.java
+END
+
+cat > jprog/PkgLocation.jin <<'END'
+package jprog;
+public class PkgLocation {
+ public static String prefix() {
+ return new String("@prefix@");
+ }
+}
+END
+
+cat > jprog/Main.java <<'END'
+package jprog;
+import jprog.PkgLocation;
+import jprog.HelloStream;
+public class Main {
+ public static void main(String[] args) {
+ for (int i = 0; i < args.length; i++) {
+ if (args[i].equals("--print-prefix")) {
+ System.out.println(PkgLocation.prefix());
+ } else if (args[i].equals("--hello-stdout")) {
+ HelloStream.to(System.out);
+ } else if (args[i].equals("--hello-stderr")) {
+ HelloStream.to(System.err);
+ } else {
+ System.err.println("jprog: invalid option '" + args[i] +
+ "'");
+ System.exit(2);
+ }
+ }
+ System.exit(0);
+ }
+}
+END
+
+cat > jprog/HelloStream.java <<'END'
+package jprog;
+import java.io.PrintStream;
+class HelloStream {
+ public static void to(PrintStream stream) {
+ stream.println("Hello, Stream!");
+ }
+}
+END
+
+## TESTS ##
+
+mkdir tests
+
+cat > tests/Makefile.am <<'END'
+AM_TESTS_ENVIRONMENT = \
+ if test x"$$jprog_doing_installcheck" != x"yes"; then \
+ jprog_classpath='$(abs_top_builddir):$(abs_top_srcdir)'; \
+ export jprog_classpath; \
+ PATH='$(abs_top_builddir)/bin$(PATH_SEPARATOR)'$$PATH; \
+ export PATH; \
+ else \
+ unset jprog_classpath || :; \
+ PATH='$(prefix)/bin$(PATH_SEPARATOR)'$$PATH; \
+ export PATH; \
+ fi; \
+ config_time_prefix='@prefix@'; export config_time_prefix;
+
+TESTS = \
+ simple.test \
+ prefix.test \
+ stdout.test \
+ stderr.test \
+ badarg.test
+
+XFAIL_TESTS = badarg.test
+
+EXTRA_DIST = $(TESTS)
+END
+
+cat > tests/simple.test <<'END'
+#!/bin/sh
+jprog
+END
+
+cat > tests/prefix.test <<'END'
+#!/bin/sh
+jprefix=`jprog --print-prefix` || exit 1
+echo "$0: exp prefix: $config_time_prefix"
+echo "$0: got prefix: $jprefix"
+test x"$jprefix" = x"$config_time_prefix"
+END
+
+cat > tests/stdout.test <<'END'
+#!/bin/sh
+rc=0
+jprog --hello-stdout >stdout.out 2>stdout.err || { echo \$?=$?; rc=1; }
+sed 's/^/out:/' <stdout.out # For debugging.
+sed 's/^/err:/' <stdout.err >&2 # Likewise.
+test -s stdout.err && rc=1
+test "`cat stdout.out`" = 'Hello, Stream!' || rc=1
+rm -f stdout.out stdout.err || rc=1
+exit $rc
+END
+
+cat > tests/stderr.test <<'END'
+#!/bin/sh
+rc=0
+jprog --hello-stderr >stderr.out 2>stderr.err || { echo \$?=$?; rc=1; }
+sed 's/^/out:/' <stderr.out # For debugging.
+sed 's/^/err:/' <stderr.err >&2 # Likewise.
+test -s stderr.out && rc=1
+test "`cat stderr.err`" = 'Hello, Stream!' || rc=1
+rm -f stderr.out stderr.err || rc=1
+exit $rc
+END
+
+cat > tests/badarg.test <<'END'
+#!/bin/sh
+jprog --bad-argument
+END
+
+chmod a+x tests/*.test
+
+## DO CHECKS ##
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+# To have the parallel testsuite more verbose.
+VERBOSE=yes; export VERBOSE
+
+./configure --prefix="`pwd`/_inst"
+cat jprog/PkgLocation.java # For debugging.
+$MAKE check
+$MAKE install
+$MAKE test-installed
+$MAKE run-installed
+$MAKE distcheck
+
+:
diff --git a/t/java-empty-classpath.sh b/t/java-empty-classpath.sh
new file mode 100755
index 000000000..9ec48b28b
--- /dev/null
+++ b/t/java-empty-classpath.sh
@@ -0,0 +1,88 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Java compilation works also when CLASSPATH is unset or empty at
+# compilation time. See automake bug#9306.
+
+required=javac
+. ./defs || Exit 1
+
+cat >> configure.ac <<'END'
+AC_CONFIG_SRCDIR([org/gnu/bug/Library.java])
+AC_CONFIG_FILES([
+ org/Makefile
+ org/gnu/Makefile
+ org/gnu/bug/Makefile
+])
+AC_OUTPUT
+END
+
+mkdir org org/gnu org/gnu/bug
+cat > Makefile.am <<END
+CLEANFILES = *.class
+SUBDIRS = org
+END
+echo SUBDIRS = gnu > org/Makefile.am
+echo SUBDIRS = bug > org/gnu/Makefile.am
+cat > org/gnu/bug/Makefile.am <<'END'
+JAVAROOT = ../../..
+dist_noinst_JAVA = Library.java Application.java
+END
+
+cat > org/gnu/bug/Library.java <<'END'
+package org.gnu.bug;
+public class Library
+{
+ public Library ()
+ {
+ // Nothing to do.
+ }
+ public static void doSomethingUseful (String arg)
+ {
+ System.out.println (arg);
+ }
+}
+END
+
+cat > org/gnu/bug/Application.java <<'END'
+import org.gnu.bug.*;
+public class Application
+{
+ public static void main (String args[])
+ {
+ Library lib = new Library ();
+ lib.doSomethingUseful ("PLUGH");
+ }
+}
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+
+unset CLASSPATH || :
+$MAKE
+$MAKE clean
+
+CLASSPATH=''; export CLASSPATH
+$MAKE
+$MAKE clean
+
+unset CLASSPATH || :
+$MAKE distcheck
+
+:
diff --git a/t/java-extra.sh b/t/java-extra.sh
new file mode 100755
index 000000000..f2fc76d31
--- /dev/null
+++ b/t/java-extra.sh
@@ -0,0 +1,73 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check use of EXTRA with the JAVA primary. Also test interaction
+# of JAVA with conditionals (it's natural to test it here, since
+# EXTRA_JAVA exists mostly for ensuring interoperation with Automake
+# conditionals).
+
+required=javac
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AM_CONDITIONAL([COND], [test x"$cond" = x"yes"])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+javadir = $(pkgdatadir)/java
+
+EXTRA_JAVA = Class1.java Class2.java Class3.java
+
+java_JAVA = Class1.java
+
+if COND
+java_JAVA += Class2.java
+else !COND
+java_JAVA += Class3.java
+endif !COND
+
+Class3.java: Makefile
+ echo 'class Class3 {}' > $@
+CLEANFILES = Class3.java
+END
+
+echo "class Class1 {}" > Class1.java
+echo "class Class2 {}" > Class2.java
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure cond=yes
+$MAKE
+ls -l
+test -f Class1.class
+test -f Class2.class
+test ! -f Class3.class
+test ! -f Class3.java
+
+$MAKE distclean
+
+./configure cond=no
+$MAKE
+ls -l
+test -f Class1.class
+test ! -f Class2.class
+test -f Class3.class
+test -f Class3.java
+
+:
diff --git a/t/java-mix.sh b/t/java-mix.sh
new file mode 100755
index 000000000..6ec91855f
--- /dev/null
+++ b/t/java-mix.sh
@@ -0,0 +1,68 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that the JAVA primary can be used freely in the same Makefile.am
+# with proper combinations of the 'dist_', 'nodist_' and 'nobase_'
+# modifiers. Also check that '.java' files are not distributed by
+# default.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+# This test does not require compilation of *.java files.
+JAVAC = false
+javadir = $(prefix)
+
+java_JAVA = Class.java
+dist_java_JAVA = ClassDist.java
+nodist_java_JAVA = ClassNodist.java
+
+nobase_java_JAVA = ClassNobase.java
+nobase_dist_java_JAVA = ClassNobaseDist.java
+nobase_nodist_java_JAVA = ClassNobaseNodist.java
+
+Class.java ClassNodist.java ClassNobase.java ClassNobaseNodist.java:
+ @echo '$@ should not be generated!' >&2; exit 1
+END
+
+: > ClassDist.java
+: > ClassNobaseDist.java
+
+$ACLOCAL
+$AUTOCONF
+# Automake used to display non-fatal warnings with this test, but
+# they were unexpected, so we want to consider them as failures in
+# this test.
+$AUTOMAKE 2>stderr || { cat stderr >&2; Exit 1; }
+cat stderr >&2
+test ! -s stderr
+
+./configure
+
+$MAKE distdir
+ls -l $distdir # For debugging.
+test ! -f $distdir/Class.java
+test -f $distdir/ClassDist.java
+test ! -f $distdir/ClassNobase.java
+test -f $distdir/ClassNobaseDist.java
+test ! -f $distdir/ClassNodist.java
+test ! -f $distdir/ClassNobaseNodist.java
+
+:
diff --git a/t/java-no-duplicate.sh b/t/java-no-duplicate.sh
new file mode 100755
index 000000000..416fdb9c7
--- /dev/null
+++ b/t/java-no-duplicate.sh
@@ -0,0 +1,45 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Test that some Java-related variables and rules are not repeatedly
+# defined.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+javadir = $(datadir)/java
+java_JAVA = a.java
+dist_java_JAVA = b.java
+nodist_java_JAVA = c.java
+nobase_java_JAVA = d.java
+nobase_dist_java_JAVA = e.java
+nobase_nodist_java_JAVA = f.java
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+$EGREP -i '\.stamp|\.class|java|classpath' Makefile.in # For debugging.
+
+for var in JAVAC JAVAROOT CLASSPATH_ENV am__java_sources; do
+ grep "^$var =" Makefile.in
+ test `grep -c "^[$sp$tab]*$var[$sp$tab]*=" Makefile.in` = 1
+done
+
+grep '^classjava\.stamp:' Makefile.in
+test `grep -c "class.*java.*\.stamp.*:" Makefile.in` = 1
+
+:
diff --git a/t/java-nobase.sh b/t/java-nobase.sh
new file mode 100755
index 000000000..ff72a1338
--- /dev/null
+++ b/t/java-nobase.sh
@@ -0,0 +1,65 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Test support of 'nobase_' with the 'JAVA' primary.
+
+required=javac
+. ./defs || Exit 1
+
+cat >>configure.ac <<'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+javadir = $(datadir)/java
+nobase_java_JAVA = sub/subsub/Foo.java
+nobase_dist_java_JAVA = sub/Bar.java
+nobase_nodist_java_JAVA = sub2/Baz.java
+
+# Java files are not distributed by default.
+EXTRA_DIST = sub/subsub/Foo.java
+
+sub2/Baz.java:
+ rm -f $@ $@-t
+ test -d sub2 || mkdir sub2
+ echo 'class Baz {}' > $@-t
+ chmod a-w $@-t && mv -f $@-t $@
+
+.PHONY: test-install
+test-install:
+ find $(prefix) ;: For debugging.
+ test -f $(javadir)/sub/subsub/Foo.class
+ test -f $(javadir)/sub/Bar.class
+ test -f $(javadir)/sub2/Baz.class
+installcheck-local: test-install
+DISTCLEANFILES = sub2/Baz.java
+END
+
+mkdir sub sub/subsub
+echo 'class Foo {}' > sub/subsub/Foo.java
+echo 'class Bar {}' > sub/Bar.java
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure --prefix="`pwd`"/_inst
+$MAKE check
+$MAKE install
+$MAKE test-install
+$MAKE distcheck
+
+:
diff --git a/t/java-noinst.sh b/t/java-noinst.sh
new file mode 100755
index 000000000..b11e6a000
--- /dev/null
+++ b/t/java-noinst.sh
@@ -0,0 +1,55 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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 that noinst_JAVA causes generated *.class files not to
+# be installed.
+
+required=javac
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+noinst_JAVA = 1.java
+dist_noinst_JAVA = 2.java
+nodist_noinst_JAVA = 3.java
+nobase_noinst_JAVA = 4.java
+nobase_dist_noinst_JAVA = 5.java
+nobase_nodist_noinst_JAVA = 6.java
+END
+
+for i in 1 2 3 4 5 6; do
+ echo "class Class$i {}" > $i.java
+done
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+
+./configure --prefix="`pwd`/_inst"
+
+$MAKE
+ls -l
+for i in 1 2 3 4 5 6; do
+ test -f Class$i.class
+done
+
+$MAKE install
+test -d _inst && { ls -l _inst; Exit 1; }
+
+:
diff --git a/t/java-rebuild.sh b/t/java-rebuild.sh
new file mode 100755
index 000000000..7672943a3
--- /dev/null
+++ b/t/java-rebuild.sh
@@ -0,0 +1,124 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Test rebuild rules for Java class files.
+
+required='javac'
+. ./defs || Exit 1
+
+cat >> configure.ac <<'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+AM_JAVACFLAGS = -verbose
+foodir = $(datadir)/java
+foo_JAVA = a.java
+dist_foo_JAVA = d.java
+nodist_foo_JAVA = n.java
+nobase_foo_JAVA = Nobase.java
+nobase_dist_foo_JAVA = NobaseDist.java
+nobase_nodist_foo_JAVA = NobaseNoDist.java
+END
+
+echo 'class _x {}' > a.java
+echo 'class x_ {}' > d.java
+echo 'class a {} class d {}' > n.java
+echo 'class Nobase_Foo {} class Nobase_Bar {}' > Nobase.java
+echo 'class NobaseDist {}' > NobaseDist.java
+echo 'class NobaseNoDist {}' > NobaseNoDist.java
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+all_classes='_x x_ a d Nobase_Foo Nobase_Bar NobaseDist NobaseNoDist'
+
+for vpath in : false; do
+
+ if $vpath; then
+ srcdir=..
+ mkdir build
+ cd build
+ else
+ srcdir=.
+ fi
+
+ $srcdir/configure
+ $MAKE
+ ls -l # For debugging.
+
+ # Sanity check.
+ test -f classfoo.stamp
+ for cls in $all_classes; do
+ test -f $cls.class
+ done
+
+ # When the stampfile is removed, all the *.class files should
+ # be considered out-of-date.
+ echo timestamp > older
+ $sleep
+ rm -f classfoo.stamp
+ $MAKE
+ for cls in $all_classes; do
+ is_newest $cls.class older
+ done
+
+ # When only a java file is modified, only the *.class files derived from
+ # it should be updated.
+ # The strings we loop on here have the following format:
+ # "JAVA-FILES-TO-BE-TOUCHED -- CLASSES-THAT-SHOULD-BE-UPDATED"
+ for args in \
+ 'a -- _x' \
+ 'd -- x_' \
+ 'n -- a d' \
+ 'a d Nobase -- _x x_ Nobase_Foo Nobase_Bar' \
+ 'n NobaseDist -- a d NobaseDist' \
+ 'd NobaseNoDist -- x_ NobaseNoDist' \
+ "a d n Nobase NobaseDist NobaseNoDist -- $all_classes" \
+ ; do
+ set $args
+ touched_javas=
+ while test $# -gt 0; do
+ if test x"$1" = x"--"; then
+ shift
+ break
+ else
+ touched_javas="$touched_javas $1"
+ shift
+ fi
+ done
+ updated_classes=$*
+ echo timestamp > older
+ $sleep
+ for j in $touched_javas; do
+ touch $srcdir/$j.java
+ done
+ $MAKE
+ is_newest classfoo.stamp older
+ for cls in $all_classes; do
+ case " $updated_classes " in
+ *" $cls "*) is_newest $cls.class older;;
+ *) is_newest older $cls.class;;
+ esac
+ done
+ done # $args ...
+
+ cd $srcdir
+
+done # $vpath ...
+
+:
diff --git a/t/java-sources.sh b/t/java-sources.sh
new file mode 100755
index 000000000..2de968391
--- /dev/null
+++ b/t/java-sources.sh
@@ -0,0 +1,65 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Test definition of automake-generated private Makefile variable
+# '$(am__java_sources)'.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+foodir = $(prefix)
+
+foo_JAVA = a.java
+dist_foo_JAVA = b.java
+nodist_foo_JAVA = c.java
+nobase_foo_JAVA = d.java
+nobase_dist_foo_JAVA = e.java
+nobase_nodist_foo_JAVA = f.java
+
+.PHONY: debug
+debug:
+ @echo 'am__java_sources: "$(am__java_sources)"'
+got:
+ @lst='$(am__java_sources)'; \
+ for f in $$lst; do echo $$f; done | sort > $@
+END
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+
+cat > exp << 'END'
+a.java
+b.java
+c.java
+d.java
+e.java
+f.java
+END
+
+./configure
+$MAKE debug
+$MAKE got
+
+cat got
+cat exp
+diff exp got
+
+:
diff --git a/t/java-uninstall.sh b/t/java-uninstall.sh
new file mode 100755
index 000000000..fb6bfa1be
--- /dev/null
+++ b/t/java-uninstall.sh
@@ -0,0 +1,97 @@
+#! /bin/sh
+# Copyright (C) 1998-2012 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/>.
+
+# Check uninstallation of Java class files.
+
+required=javac
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+javadir = $(prefix)/java
+java_JAVA = Foo.java
+nobase_java_JAVA = Foo2.java
+nobase_dist_java_JAVA = Bar.java
+nodist_java_JAVA = Baz.java
+
+# Java files are not distributed by default, so we distribute
+# one "by hand" ...
+EXTRA_DIST = Foo.java
+# ... and make the other one generated.
+Foo2.java:
+ rm -f $@ $@-t
+ echo 'class bClass {}' > $@-t
+ chmod a-w $@-t && mv -f $@-t $@
+
+# Explicitly declared as 'nodist_', so generate it.
+Baz.java:
+ rm -f $@ $@-t
+ echo 'class Baz {}' > $@-t
+ echo 'class Baz2 {}' >> $@-t
+ chmod a-w $@-t && mv -f $@-t $@
+
+DISTCLEANFILES = Baz.java Foo2.java
+END
+
+echo 'class aClass {}' > Foo.java
+echo 'class Zardoz {}' > Bar.java
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure --prefix="`pwd`"/_inst
+javadir=_inst/java
+
+check_uninstallation()
+{
+ test ! -r $javadir/aClass.class
+ test ! -r $javadir/bClass.class
+ test ! -r $javadir/Zardoz.class
+ test ! -r $javadir/Baz.class
+ test ! -r $javadir/Baz2.class
+ test -f $javadir/Foo.class
+ test -f $javadir/Bar.class
+ test -f $javadir/xClass.class
+}
+
+$MAKE
+ls -l
+$MAKE install
+: > $javadir/Foo.class
+: > $javadir/Bar.class
+: > $javadir/xClass.class
+ls -l $javadir
+$MAKE uninstall
+ls -l $javadir
+check_uninstallation
+
+# FIXME: "make uninstall" should continue to work also after "make clean",
+# but currently this doesn't happen. See automake bug#8540.
+$MAKE install
+ls -l $javadir
+$MAKE clean
+ls -l
+$MAKE uninstall
+ls -l $javadir
+#check_uninstallation
+
+$MAKE distcheck
+
+:
diff --git a/t/java.sh b/t/java.sh
new file mode 100755
index 000000000..16b125038
--- /dev/null
+++ b/t/java.sh
@@ -0,0 +1,52 @@
+#! /bin/sh
+# Copyright (C) 1998-2012 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/>.
+
+# Minimal test of Java functionality.
+
+required=javac
+. ./defs || Exit 1
+
+cat >>configure.ac <<'EOF'
+AC_OUTPUT
+EOF
+
+cat > Makefile.am << 'END'
+javadir = $(datadir)/java
+dist_java_JAVA = a.java b.java
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+$EGREP '\.stamp|class' Makefile.in # For debugging.
+grep '^all[-a-z]*:.*classjava\.stamp' Makefile.in
+test `grep -c '^all[-a-z]*:.*classjava\.stamp' Makefile.in` -eq 1
+
+cat >a.java <<EOF
+class a
+{
+}
+EOF
+
+cat >b.java <<EOF
+class b
+{
+}
+EOF
+
+./configure --prefix "`pwd`"
+$MAKE distcheck
diff --git a/t/java2.sh b/t/java2.sh
new file mode 100755
index 000000000..c0b9f957d
--- /dev/null
+++ b/t/java2.sh
@@ -0,0 +1,47 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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 that Java rules doesn't attempt to run javac when there is
+# no classes to compile.
+# Report from Braden McDaniel.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AM_CONDITIONAL(WITH_JDK, false)
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+JAVAC = false
+JAVAROOT = $(top_builddir)/java
+
+JAVA_FILES = MyClass1.java
+
+if WITH_JDK
+noinst_JAVA = $(JAVA_FILES)
+endif
+
+EXTRA_DIST = $(JAVA_FILES)
+END
+
+: >MyClass1.java
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+$MAKE
diff --git a/t/java3.sh b/t/java3.sh
new file mode 100755
index 000000000..7d9463599
--- /dev/null
+++ b/t/java3.sh
@@ -0,0 +1,57 @@
+#! /bin/sh
+# Copyright (C) 2004-2012 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 that Java rules don't attempt to compile or install
+# *.java files when there are none.
+# Report from Johannes Nicolai (PR/441).
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AM_CONDITIONAL([WHO_CARES], [false])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+if WHO_CARES
+JAVA_FILES = MyClass1.java
+endif
+
+javadir = $(prefix)/java
+java_JAVA = $(JAVA_FILES)
+END
+
+cat > MyClass1.java << 'END'
+class MyClass1 { // Deliberately missing right curly bracket.
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+cwd=`pwd` || Exit 1
+./configure --prefix="$cwd/_inst"
+$MAKE
+$MAKE install
+ls -l .
+find . -name '*.class' | grep . && Exit 1
+# If we have nothing to install, we shouldn't create any installation
+# directory. Related to automake bug#11030.
+test ! -d _inst
+$MAKE uninstall
+$MAKE distcheck
+
+:
diff --git a/t/javadir-undefined.sh b/t/javadir-undefined.sh
new file mode 100755
index 000000000..e2ed7f659
--- /dev/null
+++ b/t/javadir-undefined.sh
@@ -0,0 +1,35 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Use of JAVA primary should not allow the use of the 'java_' prefix
+# when $(javadir) is undefined. Otherwise, we could silently end up
+# with a broken Makefile.in (where "make install" doesn't install
+# the *.class files).
+# See automake bug#8461.
+
+. ./defs || Exit 1
+
+$ACLOCAL
+
+echo java_JAVA = a.java > Makefile.am
+AUTOMAKE_fails
+grep '^Makefile\.am:1:.*java_JAVA.*javadir.* undefined' stderr
+$EGREP '(uninitialized|line) ' stderr && Exit 1
+
+echo javadir = a-dummy-value >> Makefile.am
+$AUTOMAKE
+
+:
diff --git a/t/javaflags.sh b/t/javaflags.sh
new file mode 100755
index 000000000..364b21fe8
--- /dev/null
+++ b/t/javaflags.sh
@@ -0,0 +1,60 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check support for $(JAVACFLAGS) and $(AM_JAVACFLAGS).
+
+. ./defs || Exit 1
+
+cat > fake-javac <<'END'
+#!/bin/sh
+echo "$*" > javaflags.list
+END
+chmod a+x fake-javac
+
+# Remove JAVAC from the environment, so that it won't interfere
+# with 'make -e' below.
+unset JAVAC || :
+
+cat >> configure.ac <<'END'
+AC_PROG_CC
+# Simulate presence of the java compiler using our fake-javac script.
+AC_SUBST([JAVAC], ['$(abs_top_srcdir)'/fake-javac])
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+foodir = $(prefix)
+foo_JAVA = bar.java
+AM_JAVACFLAGS = __am_flags__
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+grep '\$(JAVACFLAGS).*\$(AM_JAVACFLAGS)' Makefile.in && Exit 1
+
+: > bar.java
+
+$AUTOCONF
+./configure
+env JAVACFLAGS=__user_flags__ $MAKE -e
+
+ls -l
+
+cat javaflags.list
+grep '__am_flags__.*__user_flags__' javaflags.list
+
+:
diff --git a/t/javaprim.sh b/t/javaprim.sh
new file mode 100755
index 000000000..fe5553572
--- /dev/null
+++ b/t/javaprim.sh
@@ -0,0 +1,36 @@
+#! /bin/sh
+# Copyright (C) 1998-2012 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/>.
+
+# Test to make sure JAVA variable can be defined by AC_SUBST.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_SUBST([JAVA])
+END
+
+cat > Makefile.am << 'END'
+javadir = $(datadir)/java
+java_JAVA = a.java b.java c.java
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+grep -i java Makefile.in # For debugging.
+grep '^JAVA = *@JAVA@ *$' Makefile.in
+
+:
diff --git a/t/javasubst.sh b/t/javasubst.sh
new file mode 100755
index 000000000..455b8c653
--- /dev/null
+++ b/t/javasubst.sh
@@ -0,0 +1,36 @@
+#! /bin/sh
+# Copyright (C) 1998-2012 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/>.
+
+# Test to make sure redefining JAVAC with AC_SUBST works.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_SUBST([JAVAC])
+END
+
+cat > Makefile.am << 'END'
+javadir = $(datadir)/java
+java_JAVA = a.java b.java c.java
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+grep -i java Makefile.in # For debugging.
+grep '^JAVAC = *@JAVAC@ *$' Makefile.in
+
+:
diff --git a/t/ldadd.sh b/t/ldadd.sh
new file mode 100755
index 000000000..8e16fb34b
--- /dev/null
+++ b/t/ldadd.sh
@@ -0,0 +1,46 @@
+#! /bin/sh
+# Copyright (C) 1997-2012 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/>.
+
+# Check to make sure incorrect LDADD usage is diagnosed.
+
+required=libtool
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_PROG_LIBTOOL
+AC_SUBST([LTLIBOBJS], [q.lo])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+lib_LTLIBRARIES = libtu.la
+libtu_la_SOURCES = foo.c
+libtu_la_LDADD = @LTLIBOBJS@
+END
+
+: > ltconfig
+: > ltmain.sh
+: > config.guess
+: > config.sub
+: > q.c
+
+$ACLOCAL || Exit 1
+AUTOMAKE_fails -Wno-extra-portability
+grep "libtu_la_LDADD" stderr
+grep " use 'libtu_la_LIBADD'" stderr
+
+:
diff --git a/t/ldflags.sh b/t/ldflags.sh
new file mode 100755
index 000000000..269af345e
--- /dev/null
+++ b/t/ldflags.sh
@@ -0,0 +1,50 @@
+#! /bin/sh
+# Copyright (C) 2000-2012 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/>.
+
+# Check for LDFLAGS in conditional.
+# PR 77.
+
+required=libtool
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_LIBTOOL
+AC_SUBST([LTLIBOBJS], [q.o])
+AM_CONDITIONAL([USE_SWIG], [:])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+if USE_SWIG
+lib_LTLIBRARIES = libtu.la
+libtu_la_SOURCES = foo.c
+libtu_la_LDFLAGS = -module
+endif
+END
+
+: > ltconfig
+: > ltmain.sh
+: > ar-lib
+: > config.guess
+: > config.sub
+: > q.c
+
+$ACLOCAL
+$AUTOMAKE
+
+:
diff --git a/t/lex-clean-cxx.sh b/t/lex-clean-cxx.sh
new file mode 100755
index 000000000..9ff2dbc00
--- /dev/null
+++ b/t/lex-clean-cxx.sh
@@ -0,0 +1,127 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that C++ source and header files derived from non-distributed
+# Yacc sources are cleaned by "make clean", while C++ source and
+# header files derived from distributed Yacc sources are cleaned by
+# "make maintainer-clean".
+# See also sister test 'lex-clean.test'.
+
+required=lex
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CXX
+AC_PROG_LEX
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = foo bar baz qux
+
+foo_SOURCES = mainfoo.cc parsefoo.lxx
+
+bar_SOURCES = mainbar.cpp parsebar.ll
+bar_LFLAGS = $(AM_LFLAGS)
+
+baz_SOURCES = mainbaz.c++
+nodist_baz_SOURCES = parsebaz.l++
+
+qux_SOURCES = mainqux.cxx
+nodist_qux_SOURCES = parsequx.lpp
+qux_LFLAGS = $(AM_LFLAGS)
+
+parsebaz.l++ parsequx.lpp:
+ cp $(srcdir)/parsefoo.lxx $@
+
+CLEANFILES = parsebaz.l++ parsequx.lpp
+
+LDADD = $(LEXLIB)
+END
+
+cat > parsefoo.lxx << 'END'
+%{
+#define YY_NO_UNISTD_H 1
+%}
+%option never-interactive
+%%
+"GOOD" return EOF;
+.
+%%
+int yywrap (void)
+{
+ return 1;
+}
+END
+cp parsefoo.lxx parsebar.ll
+
+cat > mainfoo.cc << 'END'
+// This file should contain valid C++ but invalid C.
+using namespace std;
+int main (int argc, char **argv)
+{
+ extern int yylex (void);
+ return yylex ();
+}
+END
+cp mainfoo.cc mainbar.cpp
+cp mainfoo.cc mainbaz.c++
+cp mainfoo.cc mainqux.cxx
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+cp config.status config.sav
+
+$MAKE
+ls -l
+# Sanity checks.
+test -f parsefoo.cxx
+test -f bar-parsebar.cc
+test -f parsebaz.l++
+test -f parsebaz.c++
+test -f parsequx.lpp
+test -f qux-parsequx.cpp
+
+for target in clean distclean; do
+ $MAKE $target
+ ls -l
+ test -f parsefoo.cxx
+ test -f bar-parsebar.cc
+ test ! -r parsebaz.l++
+ test ! -r parsebaz.c++
+ test ! -r parsequx.lpp
+ test ! -r qux-parsequx.cpp
+done
+
+cp config.sav config.status
+./config.status # re-create Makefile
+
+$MAKE maintainer-clean
+ls -l
+test -f parsefoo.lxx
+test -f parsebar.ll
+test ! -r parsefoo.cxx
+test ! -r bar-parsebar.cc
+test -f parsefoo.lxx
+test -f parsebar.ll
+test ! -r parsefoo.cxx
+test ! -r bar-parsebar.cc
+
+:
diff --git a/t/lex-clean.sh b/t/lex-clean.sh
new file mode 100755
index 000000000..9b23f0104
--- /dev/null
+++ b/t/lex-clean.sh
@@ -0,0 +1,114 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that .c files derived from non-distributed .l sources
+# are cleaned by "make clean", while .c files derived from
+# distributed .l sources are cleaned by "make maintainer-clean".
+# See also sister test 'lex-clean-cxx.test'.
+
+required=yacc
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_PROG_LEX
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = foo bar baz qux
+
+foo_SOURCES = main.c lexer.l
+
+bar_SOURCES = main.c lexer.l
+bar_LFLAGS = $(AM_LFLAGS)
+
+baz_SOURCES = main.c
+nodist_baz_SOURCES = baz.l
+
+qux_SOURCES = main.c
+nodist_qux_SOURCES = baz.l
+qux_LFLAGS = $(AM_LFLAGS)
+
+baz.l:
+ cp $(srcdir)/lexer.l $@
+
+CLEANFILES = baz.l
+
+LDADD = $(LEXLIB)
+END
+
+cat > lexer.l << 'END'
+%{
+#define YY_NO_UNISTD_H 1
+%}
+%%
+"GOOD" return EOF;
+.
+END
+
+cat > main.c << 'END'
+int main (void)
+{
+ return yylex ();
+}
+
+/* Avoid possible link errors. */
+int yywrap (void)
+{
+ return 1;
+}
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+cp config.status config.sav
+
+$MAKE
+ls -l
+# Sanity checks.
+test -f lexer.l
+test -f lexer.c
+test -f bar-lexer.c
+test -f baz.l
+test -f baz.c
+test -f qux-baz.c
+
+for target in clean distclean; do
+ $MAKE $target
+ ls -l
+ test -f lexer.l
+ test -f lexer.c
+ test -f bar-lexer.c
+ test ! -r baz.l
+ test ! -r baz.c
+ test ! -r qux-baz.c
+done
+
+cp config.sav config.status
+./config.status # re-create Makefile
+
+$MAKE maintainer-clean
+ls -l
+test -f lexer.l
+test ! -r lexer.c
+test ! -r bar-lexer.c
+
+:
diff --git a/t/lex-depend-cxx.sh b/t/lex-depend-cxx.sh
new file mode 100755
index 000000000..52491022b
--- /dev/null
+++ b/t/lex-depend-cxx.sh
@@ -0,0 +1,96 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Test to make sure dependencies work with Lex/C++.
+# Test synthesized from PR automake/6.
+
+required=lex
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CXX
+AM_PROG_LEX
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+noinst_PROGRAMS = joe moe
+joe_SOURCES = joe.ll
+moe_SOURCES = moe.l++
+LDADD = $(LEXLIB)
+
+.PHONY: test-deps-exist
+test-deps-exist:
+ ls -l $(DEPDIR) ;: For debugging.
+ test -f $(DEPDIR)/joe.Po
+ test -f $(DEPDIR)/moe.Po
+
+.PHONY: test-obj-updated
+test-obj-updated: joe.$(OBJEXT) moe.$(OBJEXT)
+ stat older my-hdr.hxx joe.$(OBJEXT) moe.$(OBJEXT) || :
+ test `ls -t older joe.$(OBJEXT) | sed 1q` = joe.$(OBJEXT)
+ test `ls -t older moe.$(OBJEXT) | sed 1q` = moe.$(OBJEXT)
+END
+
+cat > joe.ll << 'END'
+%{
+#define YY_NO_UNISTD_H 1
+%}
+%option never-interactive
+%%
+"foo" return EOF;
+.
+%%
+#include "my-hdr.hxx"
+int yywrap (void)
+{
+ return 1;
+}
+int main (int argc, char **argv)
+{
+ printf("Hello, World!\n");
+ return 0;
+}
+END
+
+cp joe.ll moe.l++
+
+cat > my-hdr.hxx <<'END'
+// This header contains deliberetly invalid C (but valid C++)
+#include <cstdio>
+using namespace std;
+END
+
+$ACLOCAL
+$AUTOMAKE -a
+
+$FGREP joe.Po Makefile.in
+$FGREP moe.Po Makefile.in
+
+$AUTOCONF
+# Try to enable dependency tracking if possible, even if that means
+# using slow dependency extractors.
+./configure --enable-dependency-tracking
+
+$MAKE test-deps-exist
+$MAKE
+
+: > older
+$sleep
+touch my-hdr.hxx
+$MAKE test-obj-updated
+
+:
diff --git a/t/lex-depend-grep.sh b/t/lex-depend-grep.sh
new file mode 100755
index 000000000..0fe32ed0c
--- /dev/null
+++ b/t/lex-depend-grep.sh
@@ -0,0 +1,46 @@
+#! /bin/sh
+# Copyright (C) 1999-2012 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/>.
+
+# Test to make sure dependencies for Lex and C/C++ does not break
+# in obvious ways. See PR automake/6, and related semantic tests
+# 'lex-depend.test' and 'lex-depend-cxx.test'.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_PROG_CXX
+AM_PROG_LEX
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = zoo foo
+zoo_SOURCES = joe.ll
+foo_SOURCES = moe.l
+noinst_PROGRAMS = zardoz
+zardoz_SOURCES = _0.l _1.ll _2.lxx _3.l++ _4.lpp
+END
+
+$ACLOCAL
+$AUTOMAKE -a
+
+$EGREP '([mj]oe|_[01234]|include|\.P)' Makefile.in # For debugging.
+
+for x in joe moe _0 _1 _2 _3 _4; do
+ grep "include.*$x\.Po" Makefile.in
+done
+
+:
diff --git a/t/lex-depend.sh b/t/lex-depend.sh
new file mode 100755
index 000000000..9487f4a5c
--- /dev/null
+++ b/t/lex-depend.sh
@@ -0,0 +1,89 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Test to make sure automatic dependency tracking work with Lex/C.
+# Test suggested by PR automake/6.
+
+required=lex
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_LEX
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = zoo
+zoo_SOURCES = joe.l
+LDADD = $(LEXLIB)
+
+.PHONY: test-deps-exist
+test-deps-exist:
+ ls -l $(DEPDIR) ;: For debugging.
+ test -f $(DEPDIR)/joe.Po
+
+.PHONY: test-obj-updated
+test-obj-updated: joe.$(OBJEXT)
+ stat older my-hdr.h joe.$(OBJEXT) || : For debugging.
+ test `ls -t older joe.$(OBJEXT) | sed 1q` = joe.$(OBJEXT)
+END
+
+cat > joe.l << 'END'
+%{
+#define YY_NO_UNISTD_H 1
+%}
+%%
+"foo" return EOF;
+.
+%%
+#include "my-hdr.h"
+int main (void)
+{
+ printf("%s\n", MESSAGE);
+ return 0;
+}
+/* Avoid possible link errors. */
+int yywrap (void)
+{
+ return 1;
+}
+END
+
+cat > my-hdr.h <<'END'
+#include <stdio.h>
+#define MESSAGE "Hello, World!"
+END
+
+$ACLOCAL
+$AUTOMAKE -a
+
+$FGREP joe.Po Makefile.in
+
+$AUTOCONF
+# Try to enable dependency tracking if possible, even if that means
+# using slow dependency extractors.
+./configure --enable-dependency-tracking
+
+$MAKE test-deps-exist
+$MAKE
+
+: > older
+$sleep
+touch my-hdr.h
+$MAKE test-obj-updated
+
+:
diff --git a/t/lex-lib-external.sh b/t/lex-lib-external.sh
new file mode 100755
index 000000000..21802c5d2
--- /dev/null
+++ b/t/lex-lib-external.sh
@@ -0,0 +1,79 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that we can get use the 'yywrap' function from a system-wide
+# library, if that's available.
+
+required='cc lex'
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_PROG_RANLIB
+AC_PROG_LEX
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = lexer
+lexer_SOURCES = foo.l
+lexer_LDADD = $(LEXLIB)
+
+.PHONY: have-lexlib
+have-lexlib:
+ test x'$(LEXLIB)' != x
+ echo 'int main (void) { return yywrap (); }' > x.c
+ $(CC) -c x.c
+ $(CC) x.$(OBJEXT) $(LEXLIB)
+ rm -f x.c *.$(OBJEXT) *.o *.out *.exe
+END
+
+cat > foo.l <<'END'
+%{
+#define YY_NO_UNISTD_H 1
+%}
+%%
+"GOOD" return EOF;
+.
+%%
+int main (void)
+{
+ /* We don't use a 'while' loop here (like a real lexer would do)
+ to avoid possible hangs. */
+ if (yylex () == EOF)
+ return 0;
+ else
+ return 1;
+}
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+$MAKE have-lexlib || skip_ "no system-wide lex library found"
+
+# Program should build and run and distribute.
+$MAKE all
+if cross_compiling; then :; else
+ echo GOOD | ./lexer
+ echo BAD | ./lexer && Exit 1
+ : For shells with busted 'set -e'.
+fi
+yl_distcheck
+
+:
diff --git a/t/lex-lib.sh b/t/lex-lib.sh
new file mode 100755
index 000000000..0320f759c
--- /dev/null
+++ b/t/lex-lib.sh
@@ -0,0 +1,72 @@
+#! /bin/sh
+# Copyright (C) 1999-2012 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/>.
+
+# Check that we can provide a personal 'yywrap' function in a custom
+# library.
+# See also test 'lex-lib-external.test'.
+
+required='cc lex'
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_RANLIB
+LEXLIB=libmylex.a
+AC_PROG_LEX
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = lexer
+lexer_SOURCES = foo.l
+lexer_LDADD = $(LEXLIB)
+EXTRA_lexer_DEPENDENCIES = $(LEXLIB)
+noinst_LIBRARIES = libmylex.a
+libmylex_a_SOURCES = mu.c
+END
+
+cat > mu.c << 'END'
+int yywrap (void)
+{
+ return 1;
+}
+END
+
+cat > foo.l <<'END'
+%{
+#define YY_NO_UNISTD_H 1
+%}
+%%
+"END" return EOF;
+.
+%%
+int main (void)
+{
+ return 0;
+}
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+$MAKE
+test -f foo.c
+test -f libmylex.a
+
+:
diff --git a/t/lex-libobj.sh b/t/lex-libobj.sh
new file mode 100755
index 000000000..3bc29814b
--- /dev/null
+++ b/t/lex-libobj.sh
@@ -0,0 +1,78 @@
+#! /bin/sh
+# Copyright (C) 1999-2012 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/>.
+
+# Check that we can provide a personal 'yywrap' function through the
+# LIBOBJ machinery.
+
+required='cc lex'
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_PROG_RANLIB
+AC_PROG_LEX
+save_LIBS=$LIBS
+LIBS="$LEXLIB $LIBS"
+AC_REPLACE_FUNCS([yywrap])
+LIBS=$save_LIBS
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+noinst_PROGRAMS = foo
+foo_SOURCES = foo.l
+foo_LDADD = $(LEXLIB) $(LIBOBJS)
+END
+
+cat > yywrap.c << 'END'
+int yywrap (void)
+{
+ return 1;
+}
+END
+
+cat > foo.l <<'END'
+%{
+#define YY_NO_UNISTD_H 1
+%}
+%%
+"END" return EOF;
+.
+%%
+int main (void)
+{
+ return 0;
+}
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+grep LIBOBJS Makefile # For debugging.
+$MAKE
+$MAKE distclean
+
+# Force "no system lex library".
+./configure LEXLIB='-L /lib'
+grep LIBOBJS Makefile # For debugging.
+grep '^LIBOBJS *=.*yywrap.*\.o' Makefile # Sanity check.
+$MAKE
+
+yl_distcheck
+
+:
diff --git a/t/lex-line.sh b/t/lex-line.sh
new file mode 100755
index 000000000..05b6f9999
--- /dev/null
+++ b/t/lex-line.sh
@@ -0,0 +1,123 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that automake lex support ensures that lex-generated C
+# files use correct "#line" directives. Try also with the
+# 'subdir-object' option enabled.
+# See also sister test 'yacc-line.test'.
+
+required=lex
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_CONFIG_FILES([sub/Makefile])
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_PROG_LEX
+AC_OUTPUT
+END
+
+mkdir dir sub sub/dir
+
+cat > Makefile.am << 'END'
+SUBDIRS = sub
+bin_PROGRAMS = foo bar
+LDADD = $(LEXLIB)
+bar_LFLAGS = -v
+foo_SOURCES = zardoz.l
+bar_SOURCES = dir/quux.l
+## Avoid spurious failures with Solaris make.
+zardoz.@OBJEXT@: zardoz.c
+bar-quux.@OBJEXT@: bar-quux.c
+END
+
+cat > sub/Makefile.am << 'END'
+AUTOMAKE_OPTIONS = subdir-objects
+noinst_PROGRAMS = foo bar
+## We already used $(LEXLIB) above, so try @LEXLIB@ now.
+LDADD = @LEXLIB@
+foo_LFLAGS = -v
+foo_SOURCES = zardoz.l
+bar_SOURCES = dir/quux.l
+## Avoid spurious failures with Solaris make.
+foo-zardoz.@OBJEXT@: foo-zardoz.c
+dir/quux.@OBJEXT@: dir/quux.c
+END
+
+cat > zardoz.l << 'END'
+%{
+#define YY_NO_UNISTD_H 1
+%}
+%%
+"END" return EOF;
+.
+%%
+int main ()
+{
+ while (yylex () != EOF)
+ ;
+ return 0;
+}
+
+/* Avoid possible link errors. */
+int yywrap (void)
+{
+ return 1;
+}
+END
+
+cp zardoz.l dir/quux.l
+cp zardoz.l sub/zardoz.l
+cp zardoz.l sub/dir/quux.l
+
+c_outputs='zardoz.c bar-quux.c sub/foo-zardoz.c sub/dir/quux.c'
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+for vpath in : false; do
+
+ if $vpath; then
+ srcdir=..
+ mkdir build
+ cd build
+ else
+ srcdir=.
+ fi
+
+ $srcdir/configure
+ $MAKE
+
+ # For debugging,
+ ls -l . sub sub/dir
+ $FGREP '.l' $c_outputs
+
+ # Adjusted "#line" should not contain reference to the builddir.
+ $EGREP '#.*line.*(build|\.\.).*\.l' $c_outputs && Exit 1
+ # Adjusted "#line" should not contain reference to the default
+ # output file names, e.g., 'lex.yy.c'.
+ $EGREP '#.*line.*lex\.yy' $c_outputs && Exit 1
+ # Don't be excessively strict in grepping, to avoid spurious failures.
+ grep '#.*line.*zardoz\.l' zardoz.c
+ grep '#.*line.*quux\.l' bar-quux.c
+ grep '#.*line.*zardoz\.l' sub/foo-zardoz.c
+ grep '#.*line.*quux\.l' sub/dir/quux.c
+ cd $srcdir
+
+done
+
+:
diff --git a/t/lex-nodist.sh b/t/lex-nodist.sh
new file mode 100755
index 000000000..99e6b7b56
--- /dev/null
+++ b/t/lex-nodist.sh
@@ -0,0 +1,90 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Checks for .c files derived from non-distributed .l sources.
+# The test 'lex-pr204.test' does similar check with AM_MAINTAINER_MODE
+# enabled.
+# The tests 'yacc-nodist.test' and 'yacc-pr204.test' does similar checks
+# for yacc-generated .c and .h files.
+
+required=lex
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+dnl Sister test 'lex-pr204.test' should use 'AC_PROG_LEX' instead.
+AM_PROG_LEX
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+.PHONY: test-build test-dist
+test-build: all
+ ls -l
+ test -f lexer.l
+ test -f lexer.c
+test-dist: distdir
+ ls -l $(distdir)
+ test ! -r $(distdir)/lexer.l
+ test ! -r $(distdir)/lexer.c
+check-local: test-build test-dist
+
+lexer.l:
+ rm -f $@ $@-t
+ :; { : \
+ && echo '%{' \
+ && echo '#define YY_NO_UNISTD_H 1' \
+ && echo '%}' \
+ && echo '%%' \
+ && echo '"GOOD" return EOF;' \
+ && echo '.'; \
+ } > $@-t
+ chmod a-w $@-t && mv -f $@-t $@
+
+bin_PROGRAMS = prog
+prog_SOURCES = main.c
+nodist_prog_SOURCES = lexer.l
+prog_LDADD = $(LEXLIB)
+CLEANFILES = $(nodist_prog_SOURCES)
+END
+
+cat > main.c << 'END'
+int main ()
+{
+ return yylex ();
+}
+
+/* Avoid possible link errors. */
+int yywrap (void)
+{
+ return 1;
+}
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+$MAKE
+$MAKE test-build
+$MAKE test-dist
+
+# But the distribution must work correctly, assuming the user has
+# the proper tools to process yacc files.
+$MAKE distcheck
+
+:
diff --git a/t/lex-noyywrap.sh b/t/lex-noyywrap.sh
new file mode 100755
index 000000000..1c4a13b19
--- /dev/null
+++ b/t/lex-noyywrap.sh
@@ -0,0 +1,75 @@
+#! /bin/sh
+# Copyright (C) 1999-2012 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/>.
+
+# Check Lex support with flex using the '%noyywrap' option.
+
+required='cc flex'
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_LEX
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = foo
+foo_SOURCES = foo.l
+
+.PHONY: test-no-lexlib
+check-local: test-no-lexlib
+test-no-lexlib:
+ test x'$(LEXLIB)' = x'none needed'
+END
+
+cat > foo.l << 'END'
+%option noyywrap
+%{
+#define YY_NO_UNISTD_H 1
+%}
+%%
+"GOOD" return EOF;
+.
+%%
+int main (void)
+{
+ /* We don't use a 'while' loop here (like a real lexer would do)
+ to avoid possible hangs. */
+ if (yylex () == EOF)
+ return 0;
+ else
+ return 1;
+}
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure LEXLIB="none needed"
+
+# Program should build and run.
+$MAKE
+if cross_compiling; then :; else
+ echo GOOD | ./foo
+ echo BAD | ./foo && Exit 1
+ : For shells with busted 'set -e'.
+fi
+
+# Sanity check on distribution.
+yl_distcheck DISTCHECK_CONFIGURE_FLAGS='LEXLIB="none needed"'
+
+:
diff --git a/t/lex-pr204.sh b/t/lex-pr204.sh
new file mode 100755
index 000000000..2e1b4e3f6
--- /dev/null
+++ b/t/lex-pr204.sh
@@ -0,0 +1,89 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Related to PR 204.
+# C sources derived from nodist_ lex sources should not be distributed.
+# See also related test 'lex-nodist.test'.
+# The tests 'yacc-nodist.test' and 'yacc-pr204.test' does similar checks
+# for yacc-generated .c and .h files.
+
+required=lex
+. ./defs || Exit 1
+
+cat >> configure.ac <<'EOF'
+AM_MAINTAINER_MODE
+AC_PROG_CC
+dnl We use AC_PROG_LEX deliberately.
+dnl Sister 'lex-nodist.test' should use 'AM_PROG_LEX' instead.
+AC_PROG_LEX
+AC_OUTPUT
+EOF
+
+# The LEXER2 intermediate variable is there to make sure Automake
+# matches 'nodist_' against the right variable name...
+cat > Makefile.am << 'EOF'
+EXTRA_PROGRAMS = foo
+LEXER2 = lexer2.l
+nodist_foo_SOURCES = lexer.l $(LEXER2)
+
+distdirtest: distdir
+ test ! -f $(distdir)/lexer.c
+ test ! -f $(distdir)/lexer.l
+ test ! -f $(distdir)/lexer.h
+ test ! -f $(distdir)/lexer2.c
+ test ! -f $(distdir)/lexer2.l
+ test ! -f $(distdir)/lexer2.h
+EOF
+
+cat > lexer.l << 'END'
+%{
+#define YY_NO_UNISTD_H 1
+%}
+%%
+"GOOD" return EOF;
+.
+%%
+int main (void)
+{
+ return yylex ();
+}
+END
+
+cp lexer.l lexer2.l
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+$MAKE distdirtest
+
+# Make sure lexer.c and lexer2.c are still targets.
+$MAKE lexer.c lexer2.c
+test -f lexer.c
+test -f lexer2.c
+
+# Ensure the rebuild rule works despite AM_MAINTAINER_MODE, because
+# it's a nodist_ lexer.
+$sleep
+touch lexer.l lexer2.l
+$sleep
+$MAKE lexer.c lexer2.c
+stat lexer.c lexer.l lexer2.c lexer2.l || : # For debugging.
+test `ls -t lexer.c lexer.l | sed 1q` = lexer.c
+test `ls -t lexer2.c lexer2.l | sed 1q` = lexer2.c
+
+:
diff --git a/t/lex-subobj-nodep.sh b/t/lex-subobj-nodep.sh
new file mode 100755
index 000000000..44c977635
--- /dev/null
+++ b/t/lex-subobj-nodep.sh
@@ -0,0 +1,74 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Ensure subdirs for subdir scanners are generated when subdir-objects
+# are used, even when dependency tracking is disabled.
+
+required='cc lex'
+. ./defs || Exit 1
+
+cat >>configure.ac <<\END
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_PROG_LEX
+AC_OUTPUT
+END
+
+cat >Makefile.am <<\END
+AUTOMAKE_OPTIONS = subdir-objects
+bin_PROGRAMS = p1 p2
+p1_SOURCES = sub1/s1.l
+p2_SOURCES = sub2/s2.l
+p2_CPPFLAGS = -DWHATEVER
+END
+
+mkdir sub1 sub2
+
+cat >sub1/s1.l <<\END
+%{
+#define YY_NO_UNISTD_H 1
+%}
+%%
+"END" return EOF;
+.
+%%
+int main (void)
+{
+ while (yylex () != EOF)
+ ;
+ return 0;
+}
+
+int yywrap(void)
+{
+ return 1;
+}
+END
+
+cp sub1/s1.l sub2/s2.l
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+mkdir build
+cd build
+../configure --disable-dependency-tracking
+$MAKE sub1/s1.c
+$MAKE sub2/s2.c
+rm -rf sub1 sub2
+$MAKE
+
+:
diff --git a/t/lex.sh b/t/lex.sh
new file mode 100755
index 000000000..d3d256a98
--- /dev/null
+++ b/t/lex.sh
@@ -0,0 +1,40 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_LEX
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = zot
+zot_SOURCES = joe.l
+LDADD = @LEXLIB@
+END
+
+$ACLOCAL
+$AUTOMAKE -a
+
+# Test to make sure that lex source generates correct target.
+$FGREP '$(LEX)' Makefile.in
+
+# Test to make sure that lex source generates correct clean rule.
+# From Ralf Corsepius.
+$FGREP joel Makefile.in && Exit 1
+
+:
diff --git a/t/lex2.sh b/t/lex2.sh
new file mode 100755
index 000000000..4b20d14f7
--- /dev/null
+++ b/t/lex2.sh
@@ -0,0 +1,35 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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 that Automake suggest using AM_PROG_LEX when a lexer is used.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = zot
+zot_SOURCES = joe.l
+END
+
+$ACLOCAL
+AUTOMAKE_fails -a
+grep 'LEX.* undefined' stderr
+grep 'add .*AM_PROG_LEX' stderr
+
+:
diff --git a/t/lex3.sh b/t/lex3.sh
new file mode 100755
index 000000000..125152b44
--- /dev/null
+++ b/t/lex3.sh
@@ -0,0 +1,91 @@
+#! /bin/sh
+# Copyright (C) 1999-2012 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/>.
+
+# Basic semantic checks on Lex support.
+# Test associated with PR 19.
+# From Matthew D. Langston.
+
+required='cc lex'
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_LEX
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+noinst_PROGRAMS = foo
+foo_SOURCES = foo.l
+END
+
+cat > foo.l << 'END'
+%{
+#define YY_NO_UNISTD_H 1
+%}
+%%
+"GOOD" return EOF;
+.
+%%
+
+int main (void)
+{
+ /* We don't use a 'while' loop here (like a real lexer would do)
+ to avoid possible hangs. */
+ if (yylex () == EOF)
+ return 0;
+ else
+ return 1;
+}
+
+/* Avoid possible link errors. */
+int yywrap (void)
+{
+ return 1;
+}
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+# Program should build and run.
+$MAKE
+if cross_compiling; then :; else
+ echo GOOD | ./foo
+ echo BAD | ./foo && Exit 1
+ : For shells with busted 'set -e'.
+fi
+
+# The generated file 'foo.c' must be shipped.
+$MAKE distdir
+test -f $distdir/foo.c
+
+# Sanity check on distribution.
+yl_distcheck
+
+# While we are at it, make sure that foo.c is erased by
+# maintainer-clean, and not by distclean.
+test -f foo.c
+$MAKE distclean
+test -f foo.c
+./configure # Re-create 'Makefile'.
+$MAKE maintainer-clean
+test ! -f foo.c
+
+:
diff --git a/t/lex5.sh b/t/lex5.sh
new file mode 100755
index 000000000..4b0663de0
--- /dev/null
+++ b/t/lex5.sh
@@ -0,0 +1,98 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Test for subdir lexers.
+
+required='cc lex'
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_CC_C_O
+AM_PROG_LEX
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = subdir-objects
+LDADD = @LEXLIB@
+
+bin_PROGRAMS = foo/foo
+foo_foo_SOURCES = foo/foo.l
+END
+
+mkdir foo
+
+cat > foo/foo.l << 'END'
+%{
+#define YY_NO_UNISTD_H 1
+%}
+%%
+"END" return EOF;
+.
+%%
+int
+main ()
+{
+ while (yylex () != EOF)
+ ;
+
+ return 0;
+}
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+# We expect ylwrap to be used and distributed even if there is
+# only one lexer.
+test -f ylwrap
+
+mkdir sub
+cd sub
+../configure
+$MAKE foo/foo.o
+ls -l # For debugging.
+
+test -f foo/foo.c
+test -f foo/foo.o
+
+# Now, adds another lexer to test ylwrap.
+
+cd ..
+cp foo/foo.l foo/foo2.l
+cat >> Makefile.am << 'END'
+EXTRA_foo_foo_SOURCES = foo/foo2.l
+END
+
+# Make sure Makefile.in has a new time stamp: the rebuild rules are
+# used below. We do this after updating Makefile.am, that way we can
+# ensure that automake, even with --no-force, is not confused if the
+# new Makefile.am has the same time stamp as the older one (since the
+# output will change, --no-force should have no effect).
+$sleep
+
+$AUTOMAKE -a --no-force
+
+cd sub
+using_gmake || $MAKE Makefile
+$MAKE foo/foo2.o
+ls -l # For debugging.
+test -f foo/foo2.c
+test -f foo/foo2.o
+
+:
diff --git a/t/lexcpp.sh b/t/lexcpp.sh
new file mode 100755
index 000000000..717be0e03
--- /dev/null
+++ b/t/lexcpp.sh
@@ -0,0 +1,44 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Test to make sure Lex + C++ is supported.
+# Please keep this is sync with sister test yaccpp.test.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CXX
+AC_PROG_LEX
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = foo bar baz qux
+foo_SOURCES = foo.l++
+bar_SOURCES = bar.lpp
+baz_SOURCES = baz.ll
+qux_SOURCES = qux.lxx
+END
+
+$ACLOCAL
+$AUTOMAKE -a
+
+sed -e 's/^/ /' -e 's/$/ /' Makefile.in >mk
+$FGREP ' foo.c++ ' mk
+$FGREP ' bar.cpp ' mk
+$FGREP ' baz.cc ' mk
+$FGREP ' qux.cxx ' mk
+
+:
diff --git a/t/lexvpath.sh b/t/lexvpath.sh
new file mode 100755
index 000000000..c7316929f
--- /dev/null
+++ b/t/lexvpath.sh
@@ -0,0 +1,128 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# This test checks that dependent files are updated before including
+# in the distribution. 'lexer.c' depends on 'lexer.l'. The latter is
+# updated so that 'lexer.c' should be rebuild. Then we are running
+# 'make' and 'make distdir' and check whether the version of 'lexer.c'
+# to be distributed is up to date.
+
+# Please keep this in sync with sister test 'yaccvapth.test'.
+
+required='cc lex'
+. ./defs || Exit 1
+
+cat > lexoutroot.in << 'END'
+LEX_OUTPUT_ROOT='@LEX_OUTPUT_ROOT@'
+END
+
+cat >> configure.ac << 'END'
+AC_CONFIG_FILES([lexoutroot])
+AC_PROG_CC
+AC_PROG_LEX
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = foo
+foo_SOURCES = lexer.l foo.c
+LDADD = $(LEXLIB)
+END
+
+# Original lexer, with a "foobar" comment
+cat > lexer.l << 'END'
+%{
+#define YY_NO_UNISTD_H 1
+%}
+%%
+"END" return EOF;
+.
+%%
+/*foobar*/
+END
+
+cat > foo.c << 'END'
+int main (void)
+{
+ return 0;
+}
+/* Avoid possible link errors. */
+int yywrap (void)
+{
+ return 1;
+}
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+mkdir sub
+
+# We must run configure early, to find out why $LEX_OUTPUT_ROOT is.
+cd sub
+../configure
+. ./lexoutroot
+test -n "$LEX_OUTPUT_ROOT" # Sanity check.
+cd ..
+
+$LEX lexer.l
+mv "$LEX_OUTPUT_ROOT".c lexer.c
+
+cd sub
+
+# Ensure that lexer.l will be newer than lexer.c.
+$sleep
+
+# New lexer, with 'fubar' comment.
+cat > ../lexer.l << 'END'
+%{
+#define YY_NO_UNISTD_H 1
+%}
+%%
+"END" return EOF;
+.
+%%
+/*fubar*/
+END
+
+$MAKE
+$MAKE distdir
+$FGREP '/*fubar*/' $distdir/lexer.c
+
+#
+# Now check to make sure that 'make dist' will rebuilt the parser.
+#
+
+# Ensure that lexer.l will be newer than lexer.c.
+$sleep
+
+# New lexer, with 'maude' comment.
+cat > ../lexer.l << 'END'
+%{
+#define YY_NO_UNISTD_H 1
+%}
+%%
+"END" return EOF;
+.
+%%
+/*maude*/
+END
+
+$MAKE distdir
+$FGREP '/*maude*/' $distdir/lexer.c
+
+:
diff --git a/t/lflags.sh b/t/lflags.sh
new file mode 100755
index 000000000..bb939a785
--- /dev/null
+++ b/t/lflags.sh
@@ -0,0 +1,73 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Check that $(LFLAGS) takes precedence over both $(AM_LFLAGS) and
+# $(foo_LFLAGS).
+# Please keep this in sync with the sister tests lflags2.test, yflags.test
+# and yflags2.test.
+
+required=cc
+. ./defs || Exit 1
+
+cat >fake-lex <<'END'
+#!/bin/sh
+echo '/*' "$*" '*/' >lex.yy.c
+echo 'extern int dummy;' >> lex.yy.c
+END
+chmod a+x fake-lex
+
+# Remove Lex from the environment, so that it won't interfere
+# with 'make -e' below.
+unset LEX || :
+
+cat >> configure.ac <<'END'
+AC_SUBST([CC], [false])
+# Simulate presence of Lex using our fake-lex script.
+AC_SUBST([LEX], ['$(abs_top_srcdir)'/fake-lex])
+AC_SUBST([LEX_OUTPUT_ROOT], [lex.yy])
+AC_SUBST([LEXLIB], [''])
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+AUTOMAKE_OPTIONS = no-dependencies
+bin_PROGRAMS = foo bar
+foo_SOURCES = main.c foo.l
+bar_SOURCES = main.c bar.l
+AM_LFLAGS = __am_flags__
+bar_LFLAGS = __bar_flags__
+END
+
+$ACLOCAL
+$AUTOMAKE -a
+
+grep '\$(LFLAGS).*\$(bar_LFLAGS)' Makefile.in && Exit 1
+grep '\$(LFLAGS).*\$(AM_LFLAGS)' Makefile.in && Exit 1
+
+: > foo.l
+: > bar.l
+
+$AUTOCONF
+./configure
+env LFLAGS=__user_flags__ $MAKE -e foo.c bar-bar.c
+
+cat foo.c
+cat bar-bar.c
+
+grep '__am_flags__.*__user_flags__' foo.c
+grep '__bar_flags__.*__user_flags__' bar-bar.c
+
+:
diff --git a/t/lflags2.sh b/t/lflags2.sh
new file mode 100755
index 000000000..57b7b6715
--- /dev/null
+++ b/t/lflags2.sh
@@ -0,0 +1,72 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Check that $(LFLAGS) takes precedence over both $(AM_LFLAGS) and
+# $(foo_LFLAGS).
+# Please keep this in sync with the sister tests lflags.test, yflags.test
+# and yflags2.test.
+
+. ./defs || Exit 1
+
+cat >fake-lex <<'END'
+#!/bin/sh
+echo '/*' "$*" '*/' >lex.yy.c
+echo 'extern int dummy;' >> lex.yy.c
+END
+chmod a+x fake-lex
+
+# Remove Lex from the environment, so that it won't interfere
+# with 'make -e' below.
+unset LEX || :
+
+cat >> configure.ac <<'END'
+AC_SUBST([CXX], [false])
+# Simulate presence of Lex using our fake-lex script.
+AC_SUBST([LEX], ['$(abs_top_srcdir)'/fake-lex])
+AC_SUBST([LEX_OUTPUT_ROOT], [lex.yy])
+AC_SUBST([LEXLIB], [''])
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+AUTOMAKE_OPTIONS = no-dependencies
+bin_PROGRAMS = foo bar
+foo_SOURCES = main.cc foo.ll
+bar_SOURCES = main.cc bar.l++
+AM_LFLAGS = __am_flags__
+bar_LFLAGS = __bar_flags__
+END
+
+$ACLOCAL
+$AUTOMAKE -a
+
+grep '\$(LFLAGS).*\$(bar_LFLAGS)' Makefile.in && Exit 1
+grep '\$(LFLAGS).*\$(AM_LFLAGS)' Makefile.in && Exit 1
+
+: > foo.ll
+: > bar.l++
+
+$AUTOCONF
+./configure
+env LFLAGS=__user_flags__ $MAKE -e foo.cc bar-bar.c++
+
+cat foo.cc
+cat bar-bar.c++
+
+grep '__am_flags__.*__user_flags__' foo.cc
+grep '__bar_flags__.*__user_flags__' bar-bar.c++
+
+:
diff --git a/t/libexec.sh b/t/libexec.sh
new file mode 100755
index 000000000..24a934da3
--- /dev/null
+++ b/t/libexec.sh
@@ -0,0 +1,35 @@
+#! /bin/sh
+# Copyright (C) 2006-2012 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/>.
+
+# PROGRAMS and LIBRARIES can be installed in (pkg)libexecdir.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+libexec_PROGRAMS = foo
+pkglibexec_PROGRAMS = bar
+END
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_OUTPUT
+END
+
+: > foo.c
+: > bar.c
+
+$ACLOCAL
+$AUTOMAKE
diff --git a/t/libobj-basic.sh b/t/libobj-basic.sh
new file mode 100755
index 000000000..1165f1ecc
--- /dev/null
+++ b/t/libobj-basic.sh
@@ -0,0 +1,112 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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 AC_LIBSOURCE and AC_LIBSOURCES work.
+
+required=cc
+. ./defs || Exit 1
+
+mv configure.ac configure.proto
+cat >> configure.proto << 'END'
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_RANLIB
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+noinst_LIBRARIES = libtu.a
+libtu_a_SOURCES = foo.c
+libtu_a_LIBADD = $(LIBOBJS)
+
+include extra-checks.am
+.PHONY: $(extra_checks) pre-test
+
+pre-test: distdir
+ ls -l $(srcdir) $(builddir) $(distdir)
+ $(AR) tv libtu.a
+$(extra_checks): pre-test
+check-local: $(extra_checks)
+
+maude-src:
+ grep dummy_maude $(srcdir)/maude.c
+maude-dist:
+ grep dummy_maude $(distdir)/maude.c
+liver-src:
+ grep dummy_liver $(srcdir)/liver.c
+liver-dist:
+ grep dummy_liver $(distdir)/liver.c
+liver-not-dist:
+ test -d $(distdir)
+ test ! -r $(distdir)/liver.c
+maude-not-dist:
+ test -d $(distdir)
+ test ! -r $(distdir)/maude.c
+END
+
+cat > foo.c << 'END'
+extern int dummy_foo;
+END
+
+cat > maude.c << 'END'
+extern int dummy_maude;
+END
+
+cat > liver.c << 'END'
+extern int dummy_liver;
+END
+
+# AC_LIBSOURCE should work also if called after AC_OUTPUT.
+cat configure.proto - > configure.ac <<END
+AC_LIBSOURCE([maude.c])
+END
+
+cat > extra-checks.am << 'END'
+extra_checks = maude-src maude-dist liver-not-dist
+END
+
+cp "$am_scriptdir/ar-lib" . || fatal_ "fetching auxiliary script 'ar-lib'"
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+
+$MAKE check
+$MAKE distcheck
+
+$MAKE distclean
+# Avoid timestamp-related differences.
+rm -rf autom4te*.cache
+
+cat > extra-checks.am << 'END'
+extra_checks = maude-src maude-dist liver-src liver-dist
+END
+
+# AC_LIBSOURCES should work also if called after AC_OUTPUT.
+cat configure.proto - > configure.ac <<END
+AC_LIBSOURCES([maude.c, liver.c])
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+
+$MAKE check
+$MAKE distcheck
+
+:
diff --git a/t/libobj10.sh b/t/libobj10.sh
new file mode 100755
index 000000000..f19de7492
--- /dev/null
+++ b/t/libobj10.sh
@@ -0,0 +1,56 @@
+#! /bin/sh
+# Copyright (C) 1999-2012 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/>.
+
+# Do not complain about the nonexistence of a source for LIBOBJS if
+# it's in BUILT_SOURCES. Reported by Erez Zadok.
+
+required=cc
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_RANLIB
+AC_LIBOBJ([foo])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+noinst_LIBRARIES = libfoo.a
+libfoo_a_SOURCES =
+libfoo_a_LIBADD = $(LIBOBJS)
+BUILT_SOURCES = foo.c
+CLEANFILES = foo.c
+foo.c:
+ echo 'extern int dummy;' > $@
+.PHONY: debugging
+debugging:
+ $(AR) t libfoo.a
+END
+
+cp "$am_scriptdir/ar-lib" . || fatal_ "fetching auxiliary script 'ar-lib'"
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+
+$MAKE
+$MAKE debugging
+$MAKE distcheck
+
+:
diff --git a/t/libobj12.sh b/t/libobj12.sh
new file mode 100755
index 000000000..c3c005707
--- /dev/null
+++ b/t/libobj12.sh
@@ -0,0 +1,77 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Test if a file can be mentioned in LIBOBJS and explicitly.
+# (See libobj13.test for the LTLIBRARIES check.)
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_RANLIB
+AC_LIBOBJ([foo])
+AC_LIBOBJ([bar])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+noinst_LIBRARIES = libfoo.a libbar.a
+noinst_PROGRAMS = p1 p2
+
+libfoo_a_SOURCES =
+libfoo_a_LIBADD = @LIBOBJS@
+
+libbar_a_SOURCES = foo.c
+
+p1_SOURCES =
+p1_LDADD = @LIBOBJS@
+
+p2_SOURCES = bar.c
+END
+
+: > ar-lib
+: > foo.c
+: > bar.c
+
+$ACLOCAL
+
+# This however should be diagnosed, since foo.c and bar.c are in @LIBOBJS@.
+cat >> Makefile.am << 'END'
+libfoo_a_SOURCES += foo.c
+p1_SOURCES += bar.c
+END
+
+AUTOMAKE_fails
+grep 'foo\.c.*explicitly mentioned' stderr
+grep 'bar\.c.*explicitly mentioned' stderr
+
+# Global 'LDADD' can also come into play.
+cat > Makefile.am << 'END'
+noinst_PROGRAMS = a b
+LDADD = @LIBOBJS@
+END
+
+$AUTOMAKE
+grep 'a_DEPENDENCIES.*LIBOBJS' Makefile.in
+
+cat >> Makefile.am << 'END'
+a_SOURCES = foo.c
+END
+AUTOMAKE_fails
+grep 'foo\.c.*explicitly mentioned' stderr
+
+:
diff --git a/t/libobj13.sh b/t/libobj13.sh
new file mode 100755
index 000000000..ef63d8b0d
--- /dev/null
+++ b/t/libobj13.sh
@@ -0,0 +1,51 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Test if a file can be mentioned in LTLIBOBJS and explicitly.
+# (Like libobj12.test, but for Libtool libraries.)
+
+required='libtoolize'
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_LIBTOOL
+AC_LIBOBJ([foo])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+noinst_LTLIBRARIES = libfoo.la libbar.la
+
+libfoo_la_SOURCES =
+libfoo_la_LIBADD = @LTLIBOBJS@
+
+libbar_la_SOURCES = foo.c
+END
+
+: > foo.c
+
+$ACLOCAL
+: > ltmain.sh
+$AUTOMAKE --add-missing
+
+# This however should be diagnosed, since foo.c is in @LIBOBJS@.
+echo 'libfoo_la_SOURCES += foo.c' >> Makefile.am
+AUTOMAKE_fails
+grep 'foo\.c.*explicitly mentioned' stderr
+
+:
diff --git a/t/libobj14.sh b/t/libobj14.sh
new file mode 100755
index 000000000..50554de49
--- /dev/null
+++ b/t/libobj14.sh
@@ -0,0 +1,44 @@
+#!/bin/sh
+# Copyright (C) 2004-2012 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/>.
+
+# Regression test for an internal error when @LIBOBJS@ is used in
+# a variable that is not defined in the same conditions as the _LDADD
+# that uses it.
+# Report from Bill Davidson.
+
+. ./defs || Exit 1
+
+cat >>configure.ac <<'EOF'
+AC_PROG_CC
+AC_LIBSOURCE([bar.c])
+AM_CONDITIONAL([CASE], [:])
+AC_OUTPUT
+EOF
+
+: >bar.c
+
+cat >>Makefile.am <<'EOF'
+COMMON_LIBS = @LIBOBJS@
+bin_PROGRAMS = foo
+if ! CASE
+foo_LDADD = $(COMMON_LIBS)
+endif
+EOF
+
+$ACLOCAL
+$AUTOMAKE
+
+:
diff --git a/t/libobj15a.sh b/t/libobj15a.sh
new file mode 100755
index 000000000..d306b7157
--- /dev/null
+++ b/t/libobj15a.sh
@@ -0,0 +1,40 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Nonexistent sources for AC_LIBOBJ should cause an Automake failure.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_RANLIB
+AC_LIBOBJ([foobar])
+END
+
+cat > Makefile.am << 'END'
+noinst_LIBRARIES = libtu.a
+libtu_a_SOURCES =
+libtu_a_LIBADD = $(LIBOBJS)
+END
+
+: > ar-lib
+
+$ACLOCAL
+AUTOMAKE_fails
+grep 'configure\.ac:.*required file.*foobar\.c.*' stderr
+
+:
diff --git a/t/libobj15b.sh b/t/libobj15b.sh
new file mode 100755
index 000000000..f0466fd54
--- /dev/null
+++ b/t/libobj15b.sh
@@ -0,0 +1,43 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Nonexistent source for AC_LIBSOURCE should cause Automake to fail.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_RANLIB
+AC_LIBSOURCE([foobar.c])
+# NOTE: this call to AC_OUTPUT is really needed; see Automake bug #7635
+# <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=7635>
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+noinst_LIBRARIES = libtu.a
+libtu_a_SOURCES =
+libtu_a_LIBADD = $(LIBOBJS)
+END
+
+: > ar-lib
+
+$ACLOCAL
+AUTOMAKE_fails
+grep 'configure\.ac:.*required file.*foobar\.c.*' stderr
+
+:
diff --git a/t/libobj15c.sh b/t/libobj15c.sh
new file mode 100755
index 000000000..8fe521d9c
--- /dev/null
+++ b/t/libobj15c.sh
@@ -0,0 +1,50 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Nonexistent sources for AC_LIBSOURCES should cause Automake to fail.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_PROG_RANLIB
+AC_LIBSOURCES([foobar.c, bazquux.c])
+# NOTE: this call to AC_OUTPUT is really needed; see Automake bug #7635
+# <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=7635>
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+noinst_LIBRARIES = libtu.a
+libtu_a_SOURCES =
+libtu_a_LIBADD = $(LIBOBJS)
+END
+
+# Don't trip on errors due to missing 'AM_PROG_AR'.
+AUTOMAKE="$AUTOMAKE -Wno-extra-portability"
+
+$ACLOCAL
+
+AUTOMAKE_fails
+grep 'configure\.ac:.*required file.*foobar\.c.*' stderr
+grep 'configure\.ac:.*required file.*bazquux\.c.*' stderr
+
+: > foobar.c
+AUTOMAKE_fails
+grep 'configure\.ac:.*required file.*bazquux\.c.*' stderr
+grep 'foobar\.c' stderr && Exit 1
+
+:
diff --git a/t/libobj16a.sh b/t/libobj16a.sh
new file mode 100755
index 000000000..2e1da263b
--- /dev/null
+++ b/t/libobj16a.sh
@@ -0,0 +1,139 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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 AC_LIBOBJ and friends work.
+# Please keep this in sync with sister test 'libobj16b.test'.
+
+required=cc
+. ./defs || Exit 1
+
+mv configure.ac configure.proto
+cat >> configure.proto << 'END'
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_RANLIB
+%LIBOBJ-STUFF% # Will be activated later.
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+noinst_LIBRARIES = libtu.a
+libtu_a_SOURCES =
+libtu_a_LIBADD = $(LIBOBJS)
+
+include extra-checks.am
+.PHONY: $(extra_checks) pre-test
+
+pre-test: distdir
+ ls -l $(srcdir) $(builddir) $(distdir)
+ $(AR) tv libtu.a
+$(extra_checks): pre-test
+check-local: $(extra_checks)
+
+maude-src:
+ grep dummy_maude $(srcdir)/maude.c
+maude-dist:
+ grep dummy_maude $(distdir)/maude.c
+liver-src:
+ grep dummy_liver $(srcdir)/liver.c
+liver-dist:
+ grep dummy_liver $(distdir)/liver.c
+liver-not-dist: distdir
+ test ! -r $(distdir)/liver.c
+maude-not-dist: distdir
+ test ! -r $(distdir)/maude.c
+maude-lib:
+ $(AR) t libtu.a | grep maude
+maude-not-lib:
+ $(AR) t libtu.a | grep maude && exit 1; exit 0
+liver-lib:
+ $(AR) t libtu.a | grep liver
+liver-not-lib:
+ $(AR) t libtu.a | grep liver && exit 1; exit 0
+END
+
+cat > maude.c << 'END'
+extern int dummy_maude;
+END
+
+cat > liver.c << 'END'
+extern int dummy_liver;
+END
+
+sed '/%LIBOBJ-STUFF%/{
+s/.*//
+i\
+AC_LIBOBJ([maude])
+}' configure.proto > configure.ac
+cat configure.ac # For debugging.
+
+cat > extra-checks.am << 'END'
+extra_checks = maude-src maude-dist maude-lib liver-not-dist
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+./configure
+
+$MAKE
+$MAKE check
+$MAKE distcheck
+$MAKE distclean
+
+# Avoid timestamp-related differences.
+rm -rf autom4te*.cache
+
+cat > extra-checks.am << 'END'
+extra_checks = maude-src maude-dist liver-src liver-dist
+if MAUDE_COND
+extra_checks += maude-lib liver-not-lib
+else
+extra_checks += maude-not-lib liver-lib
+endif
+END
+
+sed '/%LIBOBJ-STUFF%/{
+s/.*//
+i\
+AM_CONDITIONAL([MAUDE_COND], [test x"$MAUDE" = x"yes"])\
+if test x"$MAUDE" = x"yes"; then\
+ AC_LIBOBJ([maude])\
+else\
+ AC_LIBOBJ([liver])\
+fi\
+AC_LIBSOURCES([maude.c, liver.c])
+}' configure.proto > configure.ac
+cat configure.ac # For debugging.
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure MAUDE=yes
+$MAKE
+$MAKE check
+$MAKE distcheck
+$MAKE distclean
+
+./configure MAUDE=no
+$MAKE
+$MAKE check
+$MAKE distcheck
+$MAKE distclean
+
+:
diff --git a/t/libobj16b.sh b/t/libobj16b.sh
new file mode 100755
index 000000000..110ba1959
--- /dev/null
+++ b/t/libobj16b.sh
@@ -0,0 +1,140 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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 AC_LIBOBJ and friends work.
+# Please keep this in sync with sister test 'libobj16a.test'.
+
+required=cc
+. ./defs || Exit 1
+
+mv configure.ac configure.proto
+cat >> configure.proto << 'END'
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_RANLIB
+%LIBOBJ-STUFF% # Will be activated later.
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+noinst_LIBRARIES = libtu.a
+libtu_a_SOURCES =
+libtu_a_LIBADD = @LIBOBJS@
+
+include extra-checks.am
+.PHONY: $(extra_checks) pre-test
+
+pre-test: distdir
+ ls -l $(srcdir) $(builddir) $(distdir)
+ $(AR) tv libtu.a
+$(extra_checks): pre-test
+check-local: $(extra_checks)
+
+maude-src:
+ grep dummy_maude $(srcdir)/maude.c
+maude-dist:
+ grep dummy_maude $(distdir)/maude.c
+liver-src:
+ grep dummy_liver $(srcdir)/liver.c
+liver-dist:
+ grep dummy_liver $(distdir)/liver.c
+liver-not-dist: distdir
+ test ! -r $(distdir)/liver.c
+maude-not-dist: distdir
+ test ! -r $(distdir)/maude.c
+maude-lib:
+ $(AR) t libtu.a | grep maude
+maude-not-lib:
+ $(AR) t libtu.a | grep maude && exit 1; exit 0
+liver-lib:
+ $(AR) t libtu.a | grep liver
+liver-not-lib:
+ $(AR) t libtu.a | grep liver && exit 1; exit 0
+END
+
+cat > maude.c << 'END'
+extern int dummy_maude;
+END
+
+cat > liver.c << 'END'
+extern int dummy_liver;
+END
+
+sed '/%LIBOBJ-STUFF%/{
+s/.*//
+i\
+AC_LIBOBJ(maude) dnl: do not quote this!
+}' configure.proto > configure.ac
+cat configure.ac # For debugging.
+
+cat > extra-checks.am << 'END'
+extra_checks = maude-src maude-dist maude-lib liver-not-dist
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+./configure
+
+$MAKE
+$MAKE check
+$MAKE distcheck
+$MAKE distclean
+
+# Avoid timestamp-related differences.
+rm -rf autom4te*.cache
+
+cat > extra-checks.am << 'END'
+extra_checks = maude-src maude-dist liver-src liver-dist
+if MAUDE_COND
+extra_checks += maude-lib liver-not-lib
+else
+extra_checks += maude-not-lib liver-lib
+endif
+END
+
+sed '/%LIBOBJ-STUFF%/{
+s/.*//
+i\
+AM_CONDITIONAL([MAUDE_COND], [test x"$MAUDE" = x"yes"])\
+if test x"$MAUDE" = x"yes"; then\
+ AC_LIBOBJ(maude) dnl: do not quote this!\
+else\
+ AC_LIBOBJ(liver) dnl: do not quote this!\
+fi\
+AC_LIBSOURCE(maude.c) dnl: do not quote this!\
+AC_LIBSOURCE(liver.c) dnl: do not quote this!
+}' configure.proto > configure.ac
+cat configure.ac # For debugging.
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure MAUDE=yes
+$MAKE
+$MAKE check
+$MAKE distcheck
+$MAKE distclean
+
+./configure MAUDE=no
+$MAKE
+$MAKE check
+$MAKE distcheck
+$MAKE distclean
+
+:
diff --git a/t/libobj17.sh b/t/libobj17.sh
new file mode 100755
index 000000000..6c54a284e
--- /dev/null
+++ b/t/libobj17.sh
@@ -0,0 +1,72 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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 AC_LIBOBJ accept non-literal arguments.
+
+required=cc
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_PROG_RANLIB
+AM_PROG_AR
+foo=${FOO-oops}
+AC_LIBSOURCES([quux.c, zardoz.c])
+AC_LIBOBJ([$foo])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+noinst_LIBRARIES = libtu.a
+libtu_a_SOURCES =
+libtu_a_LIBADD = $(LIBOBJS)
+.PHONY: check-quux check-zardoz
+check-quux:
+ $(AR) t libtu.a | grep quux
+ $(AR) t libtu.a | grep zardoz && exit 1; exit 0
+check-zardoz:
+ $(AR) t libtu.a | grep zardoz
+ $(AR) t libtu.a | grep quux && exit 1; exit 0
+END
+
+cat > quux.c <<'END'
+extern int dummy;
+END
+
+cat > zardoz.c <<'END'
+extern int dummy;
+END
+
+# These might print warnings, but should not error out.
+$ACLOCAL
+$AUTOMAKE -a
+$AUTOCONF
+
+./configure FOO=quux
+$MAKE
+ls -l # For debugging.
+test -f libtu.a
+$MAKE check-quux
+
+$MAKE distclean
+
+./configure FOO=zardoz
+$MAKE
+ls -l # For debugging.
+test -f libtu.a
+$MAKE check-zardoz
+
+:
diff --git a/t/libobj18.sh b/t/libobj18.sh
new file mode 100755
index 000000000..0ac743859
--- /dev/null
+++ b/t/libobj18.sh
@@ -0,0 +1,45 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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 AC_LIBSOURCE and AC_LIBSOURCES use arguments literally.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_RANLIB
+foo=dummy bar=dummy baz=dummy
+AC_LIBSOURCE([$foo.c])
+AC_LIBSOURCES([$bar.c, $baz.c])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+noinst_LIBRARIES = libtu.a
+libtu_a_SOURCES =
+libtu_a_LIBADD = $(LIBOBJS)
+END
+
+: > dummy.c
+
+$ACLOCAL
+AUTOMAKE_fails
+grep 'configure\.ac:.*required file.*\$foo\.c.*not found' stderr
+grep 'configure\.ac:.*required file.*\$bar\.c.*not found' stderr
+grep 'configure\.ac:.*required file.*\$baz\.c.*not found' stderr
+
+:
diff --git a/t/libobj19.sh b/t/libobj19.sh
new file mode 100755
index 000000000..4d9e2835d
--- /dev/null
+++ b/t/libobj19.sh
@@ -0,0 +1,96 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Test support for AC_CONFIG_LIBOBJ_DIR.
+
+required=cc
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_CONFIG_LIBOBJ_DIR([libobj-dir])
+AC_PROG_CC
+AM_PROG_CC_C_O
+AM_PROG_AR
+AC_PROG_RANLIB
+AC_LIBOBJ([foobar])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = subdir-objects
+noinst_LIBRARIES = libtu.a
+libtu_a_SOURCES =
+libtu_a_LIBADD = $(LIBOBJS)
+## Hack with this variable ans with extra make recursion in the check-local
+## rule are required for when we move this Makefile in a subdir, later.
+my_distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)
+check-local:
+ (cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) distdir)
+ ls -l $(top_srcdir)/* $(top_builddir)/* $(my_distdir)/*
+ test -f libtu.a
+ test ! -r $(top_srcdir)/foobar.c
+ test -f $(top_srcdir)/libobj-dir/foobar.c
+ test ! -r $(my_distdir)/foobar.c
+ test -f $(my_distdir)/libobj-dir/foobar.c
+ $(AR) t libtu.a
+ $(AR) t libtu.a | grep foobar
+END
+
+mkdir libobj-dir
+cat > libobj-dir/foobar.c << 'END'
+extern int dummy;
+END
+
+cp "$am_scriptdir/ar-lib" . || fatal_ "fetching auxiliary script 'ar-lib'"
+cp "$am_scriptdir/compile" . || fatal_ "fetching auxiliary script 'compile'"
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+
+$MAKE
+$MAKE check
+$MAKE distcheck
+
+# Same check, but with the Makefile.am using $(LIBOBJS) not being
+# the top-level one.
+
+$MAKE distclean
+rm -rf autom4te*.cache aclocal.m4 configure
+
+mkdir sub
+mv -f Makefile.am sub
+echo SUBDIRS = sub > Makefile.am
+
+sed '/^AC_OUTPUT/i\
+AC_CONFIG_FILES([sub/Makefile])
+' configure.ac > t
+mv -f t configure.ac
+cat configure.ac # For debugging.
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+
+$MAKE
+$MAKE check
+$MAKE distcheck
+
+:
diff --git a/t/libobj2.sh b/t/libobj2.sh
new file mode 100755
index 000000000..ce655c232
--- /dev/null
+++ b/t/libobj2.sh
@@ -0,0 +1,68 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test to make sure LIBOBJS works in subdirs.
+# Bug from Josh MacDonald.
+
+required=cc
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_CONFIG_FILES([subdir/Makefile])
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_RANLIB
+AC_CHECK_TOOLS([AR], [ar])
+AC_LIBOBJ([fsusage])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+SUBDIRS = subdir
+check-local: distdir
+ ls -l $(srcdir) $(srcdir)/subdir
+ ls -l $(distdir) $(distdir)/subdir
+ ls -l $(builddir) $(builddir)/subdir
+ test -f $(srcdir)/subdir/fsusage.c
+ test -f $(distdir)/subdir/fsusage.c
+ $(AR) tv $(builddir)/subdir/libtu.a
+END
+
+mkdir subdir
+
+cat > subdir/Makefile.am << 'END'
+noinst_LIBRARIES = libtu.a
+libtu_a_SOURCES =
+libtu_a_LIBADD = @LIBOBJS@
+END
+
+cat > subdir/fsusage.c << 'END'
+extern int dummy;
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+# Older grepping check, kept "just to be sure".
+$FGREP 'fsusage.c' subdir/Makefile.in
+
+./configure
+
+$MAKE check
+$MAKE distcheck
+
+:
diff --git a/t/libobj20a.sh b/t/libobj20a.sh
new file mode 100755
index 000000000..d56be31da
--- /dev/null
+++ b/t/libobj20a.sh
@@ -0,0 +1,45 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Test error reporting for AC_CONFIG_LIBOBJ_DIR.
+# See also sister tests 'libobj20b.test' and 'libobj20c.test' .
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_CONFIG_LIBOBJ_DIR([libobj-dir])
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_RANLIB
+AC_LIBOBJ([foo])
+END
+
+cat > Makefile.am << 'END'
+noinst_LIBRARIES = libtu.a
+libtu_a_SOURCES =
+libtu_a_LIBADD = $(LIBOBJS)
+END
+
+mkdir libobj-dir
+: > libobj-dir/foo.c
+: > ar-lib
+
+$ACLOCAL
+AUTOMAKE_fails
+grep 'LIBOBJS.*used outside.*libobj-dir' stderr
+grep 'subdir-objects.*not set' stderr
+
+:
diff --git a/t/libobj20b.sh b/t/libobj20b.sh
new file mode 100755
index 000000000..f8ca60019
--- /dev/null
+++ b/t/libobj20b.sh
@@ -0,0 +1,57 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Test error reporting for AC_CONFIG_LIBOBJ_DIR.
+# See also sister tests 'libobj20a.test' and 'libobj20c.test' .
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_CONFIG_LIBOBJ_DIR([libobj-dir])
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_RANLIB
+AC_LIBSOURCE([foobar.c])
+# NOTE: this call to AC_OUTPUT is really needed; see Automake bug #7635
+# <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=7635>
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = subdir-objects
+noinst_LIBRARIES = libtu.a
+libtu_a_SOURCES =
+libtu_a_LIBADD = $(LIBOBJS)
+END
+
+: > ar-lib
+
+$ACLOCAL
+
+AUTOMAKE_fails
+grep 'configure\.ac:.*required directory.*libobj-dir' stderr
+
+mkdir libobj-dir
+: > foobar.c # Oops, it should be in libobj-dir!
+AUTOMAKE_fails
+grep 'configure\.ac:.*required file.*libobj-dir/foobar.c.*' stderr
+
+rm -f foobar.c
+
+: > libobj-dir/foobar.c
+$AUTOMAKE # Now we should succeed.
+
+:
diff --git a/t/libobj20c.sh b/t/libobj20c.sh
new file mode 100755
index 000000000..7ae51bf21
--- /dev/null
+++ b/t/libobj20c.sh
@@ -0,0 +1,54 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Test error reporting for AC_CONFIG_LIBOBJ_DIR.
+# See also sister tests 'libobj20a.test' and 'libobj20b.test' .
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_CONFIG_LIBOBJ_DIR([libobj-dir])
+AC_PROG_CC
+AC_PROG_RANLIB
+AC_LIBOBJ([foobar])
+END
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = subdir-objects
+noinst_LIBRARIES = libtu.a
+libtu_a_SOURCES =
+libtu_a_LIBADD = $(LIBOBJS)
+END
+
+$ACLOCAL
+
+# Don't trip on errors due to missing 'AM_PROG_AR'.
+AUTOMAKE="$AUTOMAKE -Wno-extra-portability"
+
+AUTOMAKE_fails
+grep 'configure\.ac:.*required directory.*\./libobj-dir' stderr
+
+mkdir libobj-dir
+: > foobar.c # Oops, it should be in libobj-dir!
+AUTOMAKE_fails
+grep 'configure\.ac:.*required file.*libobj-dir/foobar.c.*' stderr
+
+rm -f foobar.c
+
+: > libobj-dir/foobar.c
+$AUTOMAKE # Now we should succeed.
+
+:
diff --git a/t/libobj3.sh b/t/libobj3.sh
new file mode 100755
index 000000000..37ec6bf77
--- /dev/null
+++ b/t/libobj3.sh
@@ -0,0 +1,39 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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 we complain if @LIBOBJS@ is used without being set in
+# configure.ac.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_RANLIB
+AM_PROG_AR
+END
+
+cat > Makefile.am << 'END'
+noinst_LIBRARIES = libtu.a
+libtu_a_SOURCES =
+libtu_a_LIBADD = @LIBOBJS@
+END
+
+: > ar-lib
+
+$ACLOCAL
+AUTOMAKE_fails
+grep 'Makefile\.am:3:.*LIBOBJS' stderr
+
+:
diff --git a/t/libobj4.sh b/t/libobj4.sh
new file mode 100755
index 000000000..68711afc8
--- /dev/null
+++ b/t/libobj4.sh
@@ -0,0 +1,34 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test to make sure LIBOBJS error only occurs if LIBOBJS seen. Report
+# from Jim Meyering.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = foo
+END
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_REPLACE_FUNCS([foo])
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+:
diff --git a/t/libobj5.sh b/t/libobj5.sh
new file mode 100755
index 000000000..036ae561d
--- /dev/null
+++ b/t/libobj5.sh
@@ -0,0 +1,39 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test to make sure AC_REPLACE_FUNCS works across lines. Report from
+# Jim Meyering.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = joe
+LDADD = @LIBOBJS@
+END
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_REPLACE_FUNCS(\
+ foo_bar_quux)
+END
+
+: > foo_bar_quux.c
+
+$ACLOCAL
+$AUTOMAKE
+$FGREP foo_bar_quux.c Makefile.in
+
+:
diff --git a/t/libobj7.sh b/t/libobj7.sh
new file mode 100755
index 000000000..46f0f9841
--- /dev/null
+++ b/t/libobj7.sh
@@ -0,0 +1,72 @@
+#! /bin/sh
+# Copyright (C) 1997-2012 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/>.
+
+# Test for multiple replacement functions.
+
+required=cc
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_RANLIB
+# 'am__dummy_function' is there to ensure that at least one function is
+# replaced, to avoid creating an empty archive which can cause problems
+# with e.g. Solaris ar.
+AC_REPLACE_FUNCS([basename dirname am__dummy_function])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+noinst_LIBRARIES = libtu.a
+libtu_a_SOURCES =
+libtu_a_LIBADD = @LIBOBJS@
+check-local: test1 test2 test3
+.PHONY: test1 test2 test3
+test1: all
+ $(AR) tv libtu.a
+test2:
+ @echo DIST_COMMON = $(DIST_COMMON)
+ echo ' ' $(DIST_COMMON) ' ' | grep '[ /]basename\.c '
+ echo ' ' $(DIST_COMMON) ' ' | grep '[ /]dirname\.c '
+ echo ' ' $(DIST_COMMON) ' ' | grep '[ /]am__dummy_function\.c '
+test3: distdir
+ test -f $(distdir)/basename.c
+ test -f $(distdir)/dirname.c
+ test -f $(distdir)/am__dummy_function.c
+END
+
+cat > basename.c <<'END'
+extern int dummy1;
+END
+cat > dirname.c <<'END'
+extern int dummy2;
+END
+cat > am__dummy_function.c <<'END'
+extern int dummy3;
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+./configure
+
+$MAKE
+$MAKE check
+$MAKE distcheck
+
+:
diff --git a/t/library.sh b/t/library.sh
new file mode 100755
index 000000000..dffe658cb
--- /dev/null
+++ b/t/library.sh
@@ -0,0 +1,38 @@
+#! /bin/sh
+# Copyright (C) 1998-2012 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/>.
+
+# Test for _DEPENDENCIES with libraries.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_RANLIB
+AM_MAINTAINER_MODE
+AC_PROG_CC
+AM_PROG_AR
+END
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = dejagnu cygnus
+lib_LIBRARIES = libfoo.a
+libfoo_a_DEPENDENCIES = libzot.a
+END
+
+: > ar-lib
+$ACLOCAL
+$AUTOMAKE
+
+:
diff --git a/t/library2.sh b/t/library2.sh
new file mode 100755
index 000000000..dfa87584c
--- /dev/null
+++ b/t/library2.sh
@@ -0,0 +1,31 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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 Automake suggest using AC_PROG_RANLIB when *_LIBRARIES is used.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+END
+
+cat > Makefile.am << 'END'
+EXTRA_LIBRARIES = libfoo.a
+END
+
+$ACLOCAL
+AUTOMAKE_fails -Wno-portability
+grep AC_PROG_RANLIB stderr
diff --git a/t/library3.sh b/t/library3.sh
new file mode 100755
index 000000000..27a2b156f
--- /dev/null
+++ b/t/library3.sh
@@ -0,0 +1,52 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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 Automake simplify conditions in diagnostics.
+
+. ./defs || Exit 1
+
+cat >>configure.ac <<EOF
+AC_PROG_CC
+AM_CONDITIONAL([A], [:])
+AM_CONDITIONAL([B], [:])
+AM_CONDITIONAL([C], [:])
+AM_CONDITIONAL([D], [:])
+EOF
+
+cat > Makefile.am << 'END'
+if A
+if !B
+ RANLIB = anb
+else
+ RANLIB = ab
+endif
+endif
+if C
+ RANLIB = c
+endif
+if !C
+if D
+ RANLIB = ncd
+endif
+endif
+EXTRA_LIBRARIES = libfoo.a
+END
+
+$ACLOCAL
+AUTOMAKE_fails
+grep '^Makefile.am:.*: !A and !C and !D$' stderr
+# Is there only one missing condition?
+test `grep ': !' stderr | wc -l` = 1 || Exit 1
diff --git a/t/libtoo10.sh b/t/libtoo10.sh
new file mode 100755
index 000000000..0218ef32c
--- /dev/null
+++ b/t/libtoo10.sh
@@ -0,0 +1,60 @@
+#! /bin/sh
+# Copyright (C) 2007-2012 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 .libs directories are removed for _PROGRAMS.
+# Report from Guillermo Ontañón.
+
+required='cc libtoolize'
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AM_PROG_AR
+AC_PROG_LIBTOOL
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+lib_LTLIBRARIES = lib/libfoo.la
+lib_libfoo_la_SOURCES = foo.c
+bin_PROGRAMS = src/main
+check_PROGRAMS = check/test
+src_main_SOURCES = main.c
+check_test_SOURCES = main.c
+LDADD = lib/libfoo.la
+END
+
+mkdir lib src check
+cat > foo.c << 'END'
+int foo () { return 0; }
+END
+
+cat > main.c << 'END'
+extern int foo ();
+int main () { return foo (); }
+END
+
+libtoolize
+$ACLOCAL
+$AUTOMAKE --add-missing
+$AUTOCONF
+./configure
+$MAKE all check
+$MAKE clean
+test ! -d src/.libs
+test ! -d src/_libs
+test ! -d check/.libs
+test ! -d check/_libs
+$MAKE distcheck
diff --git a/t/libtoo11.sh b/t/libtoo11.sh
new file mode 100755
index 000000000..cd55cc014
--- /dev/null
+++ b/t/libtoo11.sh
@@ -0,0 +1,38 @@
+#! /bin/sh
+# Copyright (C) 2008-2012 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 config.lt is removed with Libtool 2.2.x's LT_OUTPUT.
+# Report by Charles Wilson.
+
+required='cc libtoolize'
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_LIBTOOL
+m4_ifdef([LT_OUTPUT], [LT_OUTPUT])
+AC_OUTPUT
+END
+
+: > Makefile.am
+
+libtoolize
+$ACLOCAL
+$AUTOMAKE --add-missing
+$AUTOCONF
+./configure
+$MAKE distcheck
+
+:
diff --git a/t/libtool-macros.sh b/t/libtool-macros.sh
new file mode 100755
index 000000000..e5c77ac1d
--- /dev/null
+++ b/t/libtool-macros.sh
@@ -0,0 +1,60 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Try to find the libtool '.m4' files and make them easily accessed
+# to the test cases requiring them.
+# See also automake bug#9807.
+
+. ./defs || Exit 1
+
+echo "# Automatically generated by $me." > get.sh
+echo : >> get.sh
+
+# The 'libtoolize' script will look into Makefile.am.
+echo ACLOCAL_AMFLAGS = -I m4 > Makefile.am
+
+if libtoolize --copy --install && test -f m4/libtool.m4; then
+ echo "ACLOCAL_PATH='`pwd`/m4':\$ACLOCAL_PATH" >> get.sh
+ echo "export ACLOCAL_PATH" >> get.sh
+else
+ # Libtoolize from libtool < 2.0 didn't support the '--install' option,
+ # but this doesn't mean the user hasn't made the libtool macros
+ # available, e.g., by properly setting ACLOCAL_PATH.
+ rm -rf m4
+ mkdir m4
+ echo AC_PROG_LIBTOOL >> configure.ac
+ # See below for an explanation about the use the of '-Wno-syntax'.
+ if $ACLOCAL -Wno-syntax -I m4 --install && test -f m4/libtool.m4; then
+ : # Libtool macros already accessible by default.
+ else
+ echo "skip_all_ \"couldn't find or get libtool macros\"" >> get.sh
+ fi
+fi
+
+. ./get.sh
+
+$ACLOCAL --force -I m4 || cat >> get.sh <<'END'
+# We need to use '-Wno-syntax', since we do not want our test suite
+# to fail merely because some third-party '.m4' file is underquoted.
+ACLOCAL="$ACLOCAL -Wno-syntax"
+END
+
+# The file libtoolize might have just copied in the 'm4' subdirectory of
+# the test directory are going to be needed by other tests, so we must
+# not remove the test directory.
+keep_testdirs=yes
+
+:
diff --git a/t/libtool.sh b/t/libtool.sh
new file mode 100755
index 000000000..7b267a714
--- /dev/null
+++ b/t/libtool.sh
@@ -0,0 +1,41 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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 libtool is removed.
+# Report from Kevin Dalley.
+
+required=libtool
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_LIBTOOL_DLOPEN
+AC_DISABLE_SHARED
+AC_PROG_LIBTOOL
+AC_SUBST([LIBTOOL_DEPS])
+END
+
+: > Makefile.am
+
+: > ltmain.sh
+: > config.guess
+: > config.sub
+
+$ACLOCAL
+$AUTOMAKE
+
+grep 'rm -f libtool' Makefile.in
+
+:
diff --git a/t/libtool2.sh b/t/libtool2.sh
new file mode 100755
index 000000000..3b8a78b60
--- /dev/null
+++ b/t/libtool2.sh
@@ -0,0 +1,49 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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 libtool clean targets exist.
+# Report from Eric Magnien.
+
+required=libtoolize
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_LIBTOOL
+AC_CONFIG_FILES([sub/Makefile])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+SUBDIR = subdir
+lib_LTLIBRARIES = libfoo.la
+libfoo_la_SOURCES = foo.c
+END
+
+mkdir sub
+cat > sub/Makefile.am << 'END'
+lib_LTLIBRARIES = libfoo.la
+libfoo_la_SOURCES = foo.c
+END
+
+$ACLOCAL
+: > ltmain.sh
+$AUTOMAKE -a
+
+grep 'rm -f .*\.lo' sub/Makefile.in
+
+:
diff --git a/t/libtool3.sh b/t/libtool3.sh
new file mode 100755
index 000000000..dbcd519d9
--- /dev/null
+++ b/t/libtool3.sh
@@ -0,0 +1,90 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Try to build and package a program linked to a Libtool library.
+# Also make sure we do not bloat the Makefile with unneeded rules.
+
+required='cc libtoolize'
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_AR
+AM_PROG_LIBTOOL
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+lib_LTLIBRARIES = lib0.la liba/liba.la
+lib0_la_SOURCES = 0.c
+liba_liba_la_SOURCES = liba/a.c
+
+bin_PROGRAMS = 1
+1_SOURCES = sub/1.c
+1_LDADD = lib0.la liba/liba.la
+END
+
+mkdir liba sub
+
+cat > 0.c << 'END'
+int
+zero (void)
+{
+ return 0;
+}
+END
+
+cat > sub/1.c << 'END'
+int zero ();
+
+int
+main (void)
+{
+ return zero ();
+}
+END
+
+cat > liba/a.c << 'END'
+int
+a (void)
+{
+ return 'a';
+}
+END
+
+# Use --copy to workaround a bug in Cygwin's 'cp -p' during distcheck.
+# (This bug is already exhibited by subobj9.test.) In brief: Cygwin's
+# 'cp -p' tries to preserve group and owner of the source and fails
+# to do so under normal accounts. With --copy we ensure we own all files.
+
+libtoolize --force --copy
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing --copy
+
+# We need explicit rules to build 1.o and a.lo. Make sure
+# Automake did not output additional rules for 1.lo and and a.lo.
+$FGREP '1.o:' Makefile.in
+$FGREP '1.lo:' Makefile.in && Exit 1
+$FGREP 'a.o:' Makefile.in && Exit 1
+$FGREP 'a.lo:' Makefile.in
+
+./configure
+
+$MAKE
+$MAKE distcheck
+
+:
diff --git a/t/libtool4.sh b/t/libtool4.sh
new file mode 100755
index 000000000..2ce92dd29
--- /dev/null
+++ b/t/libtool4.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+# Copyright (C) 2002-2012 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 Automake suggests AC_PROG_LIBTOOL when *_LTLIBRARIES is used.
+
+. ./defs || Exit 1
+
+cat >> configure.ac <<'END'
+AC_PROG_CC
+AM_PROG_AR
+END
+
+cat > Makefile.am << 'END'
+EXTRA_LTLIBRARIES = liblib.la
+END
+
+: > ar-lib
+
+$ACLOCAL
+AUTOMAKE_fails
+grep '[Ll]ibtool library .*LIBTOOL.* undefined' stderr
+grep 'define .*LIBTOOL.* add .*LT_INIT' stderr
+
+:
diff --git a/t/libtool5.sh b/t/libtool5.sh
new file mode 100755
index 000000000..b9e778b36
--- /dev/null
+++ b/t/libtool5.sh
@@ -0,0 +1,44 @@
+#!/bin/sh
+# Copyright (C) 2002-2012 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 it's ok to install a library under different conditions
+# in the same directory.
+# Report from Harlan Stenn.
+
+required='libtoolize'
+. ./defs || Exit 1
+
+cat >>configure.ac <<'END'
+AM_CONDITIONAL([COND1], [true])
+AM_CONDITIONAL([COND2], [false])
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_LIBTOOL
+AC_OUTPUT
+END
+
+cat >Makefile.am <<'END'
+if COND1
+ lib_LTLIBRARIES = liba.la
+endif
+if COND2
+ lib_LTLIBRARIES = liba.la
+endif
+END
+
+libtoolize
+$ACLOCAL
+$AUTOMAKE --add-missing
diff --git a/t/libtool6.sh b/t/libtool6.sh
new file mode 100755
index 000000000..13dbc738e
--- /dev/null
+++ b/t/libtool6.sh
@@ -0,0 +1,45 @@
+#!/bin/sh
+# Copyright (C) 2002-2012 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 it's OK to install a library under different conditions
+# in different directories. PR/285.
+
+required='libtoolize'
+. ./defs || Exit 1
+
+cat >>configure.ac <<'END'
+AM_CONDITIONAL([COND1], [true])
+AM_CONDITIONAL([COND2], [false])
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_LIBTOOL
+AC_OUTPUT
+END
+
+cat >Makefile.am <<'END'
+if COND1
+ lib_LTLIBRARIES = liba.la
+endif
+if COND2
+ pkglib_LTLIBRARIES = liba.la
+endif
+END
+
+libtoolize
+$ACLOCAL
+$AUTOMAKE --add-missing
+# am_liba_la_rpath is defined twice, and used once
+test 3 = `grep 'am_liba_la_rpath' Makefile.in | wc -l`
diff --git a/t/libtool7.sh b/t/libtool7.sh
new file mode 100755
index 000000000..bc8eacae3
--- /dev/null
+++ b/t/libtool7.sh
@@ -0,0 +1,108 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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 we allow Libtool's -dlopen/-dlpreopen
+# Also check basic support for AM_LIBTOOLFLAGS/LIBTOOLFLAGS
+
+required='cc libtoolize'
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_AR
+AC_LIBTOOL_DLOPEN
+AM_PROG_LIBTOOL
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = subdir-objects
+AM_LIBTOOLFLAGS = --silent
+lib_LTLIBRARIES = libmod1.la mod2.la
+libmod1_la_SOURCES = sub/mod1.c
+libmod1_la_LDFLAGS = -module
+libmod1_la_LIBADD = -dlopen mod2.la
+mod2_la_SOURCES = mod2.c
+mod2_la_LDFLAGS = -module
+mod2_la_LIBTOOLFLAGS =
+
+bin_PROGRAMS = prg
+prg_SOURCES = prg.c
+prg_LDADD = -dlopen libmod1.la -dlpreopen mod2.la
+
+.PHONY: print
+print:
+ @echo 1BEG: $(prg_DEPENDENCIES) :END1
+ @echo 2BEG: $(libmod1_la_DEPENDENCIES) :END2
+ @echo 3BEG: $(LTCOMPILE) :END3
+END
+
+mkdir sub liba
+
+cat > sub/mod1.c << 'END'
+int mod1 (void)
+{
+ return 1;
+}
+END
+
+cat > mod2.c << 'END'
+int mod2 (void)
+{
+ return 2;
+}
+END
+
+cat > prg.c << 'END'
+int main (void)
+{
+ return 0;
+}
+END
+
+libtoolize --force --copy
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing --copy
+
+./configure "--prefix=`pwd`/_inst"
+env LIBTOOLFLAGS=--silent $MAKE print >output 2>&1 || {
+ cat output
+ Exit 1
+}
+cat output
+grep '1BEG: libmod1.la mod2.la :END1' output
+grep '2BEG: mod2.la :END2' output
+grep '3BEG: .*silent.*silent.* :END3' output
+test 2 -le `grep mod2_la_LIBTOOLFLAGS Makefile | wc -l`
+$MAKE
+
+env LIBTOOLFLAGS=--silent $MAKE install >output 2>&1 || {
+ cat output
+ Exit 1
+}
+cat output
+grep 'silent.*silent.*prg' output
+grep 'silent.*silent.*libmod1' output
+
+env LIBTOOLFLAGS=--silent $MAKE uninstall >output 2>&1 || {
+ cat output
+ Exit 1
+}
+cat output
+grep 'silent.*silent.*libmod1' output
+
+:
diff --git a/t/libtool8.sh b/t/libtool8.sh
new file mode 100755
index 000000000..9182c278e
--- /dev/null
+++ b/t/libtool8.sh
@@ -0,0 +1,53 @@
+#!/bin/sh
+# Copyright (C) 2004-2012 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 Automake diagnoses conflicting installations.
+
+required='libtoolize'
+. ./defs || Exit 1
+
+cat >>configure.ac <<'END'
+AM_CONDITIONAL([COND1], [true])
+AM_CONDITIONAL([COND2], [false])
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_LIBTOOL
+AC_OUTPUT
+END
+
+cat >Makefile.am <<'END'
+if COND1
+ lib_LTLIBRARIES = liba.la
+ EXTRA_LTLIBRARIES = libc.la libc.la libb.la
+else
+ lib_LTLIBRARIES = libb.la
+endif
+if COND2
+if COND1
+ pkglib_LTLIBRARIES = liba.la
+endif
+LIBTOOLFLAGS = ouch
+endif
+END
+
+libtoolize
+$ACLOCAL
+AUTOMAKE_fails --add-missing
+grep libb stderr && Exit 1
+grep 'Makefile.am:3:.*libc.la.*multiply defined' stderr
+grep "Makefile.am:9:.*'pkglib" stderr
+grep "Makefile.am:2:.*'lib" stderr
+grep 'Makefile.am:11:.*AM_LIBTOOLFLAGS' stderr
diff --git a/t/libtool9.sh b/t/libtool9.sh
new file mode 100755
index 000000000..b4d7baa87
--- /dev/null
+++ b/t/libtool9.sh
@@ -0,0 +1,102 @@
+#! /bin/sh
+# Copyright (C) 2005-2012 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 xxx_LINK is defined for each target that requires specific
+# flags.
+# Quite similar to libtool7.test, using AM_LDFLAGS in addition to
+# xxx_LDFLAGS.
+
+required='cc libtoolize'
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_CC_C_O
+AM_PROG_AR
+AC_LIBTOOL_DLOPEN
+AM_PROG_LIBTOOL
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+AM_LDFLAGS = -module
+lib_LTLIBRARIES = libmod1.la mod2.la
+libmod1_la_SOURCES = mod1.c
+libmod1_la_LDFLAGS =
+libmod1_la_LIBADD = -dlopen mod2.la
+mod2_la_SOURCES = mod2.c
+
+bin_PROGRAMS = prg prg2
+prg_SOURCES = prg.c
+prg_LDADD = -dlopen libmod1.la -dlpreopen mod2.la
+prg_CPPFLAGS = -DXYZ=1
+prg2_SOURCES = prg.c
+prg2_CFLAGS =
+
+print:
+ @echo 1BEG: $(prg_DEPENDENCIES) :END1
+ @echo 2BEG: $(libmod1_la_DEPENDENCIES) :END2
+ @echo 3BEG: $(libmod1_la_LINK) :END3
+ @echo 4BEG: $(mod2_la_LINK) :END4
+ @echo 5BEG: $(prg_LINK) :END5
+ @echo 6BEG: $(prg2_LINK) :END6
+
+END
+
+mkdir liba
+
+cat > mod1.c << 'END'
+int mod1 (void)
+{
+ return 1;
+}
+END
+
+cat > mod2.c << 'END'
+int mod2 (void)
+{
+ return 2;
+}
+END
+
+cat > prg.c << 'END'
+int main (void)
+{
+ return 0;
+}
+END
+
+libtoolize --force --copy
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing --copy
+
+./configure
+env LDFLAGS=ldflags AM_LDFLAGS=am_ldflags libmod1_la_LDFLAGS=lm1_la_ldflags \
+ CFLAGS=cflags AM_CFLAGS=am_cflags prg2_CFLAGS=prg2_cflags \
+ $MAKE -e print >output 2>&1 || { cat output; Exit 1; }
+cat output
+grep '1BEG: libmod1.la mod2.la :END1' output
+grep '2BEG: mod2.la :END2' output
+grep '3BEG:.* am_cflags cflags .*lm1_la_ldflags ldflags.* :END3' output
+grep '3BEG: .*am_ldflags.* :END3' output && Exit 1
+grep '4BEG: :END4' output
+grep '5BEG: :END5' output
+grep '6BEG:.* prg2_cflags cflags .*am_ldflags ldflags.* :END6' output
+grep '6BEG: .*am_cflags.* :END6' output && Exit 1
+$MAKE
+
+:
diff --git a/t/license.sh b/t/license.sh
new file mode 100755
index 000000000..c3dad694e
--- /dev/null
+++ b/t/license.sh
@@ -0,0 +1,61 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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 COPYING is not overwritten, even with -a -f.
+
+. ./defs || Exit 1
+
+echo AC_OUTPUT >>configure.ac
+
+cat >Makefile.am <<\EOF
+test1: distdir
+ grep 'GNU GENERAL PUBLIC LICENSE' $(distdir)/COPYING
+test2: distdir
+ grep 'MY-OWN-LICENSE' $(distdir)/COPYING
+test3: distdir
+ test ! -f $(distdir)/COPYING
+ grep 'MY-OWN-LICENSE' $(distdir)/COPYING.LIB
+EOF
+
+:> NEWS
+:> AUTHORS
+:> ChangeLog
+:> README
+
+test ! -f COPYING
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --gnu --add-missing
+
+./configure
+$MAKE test1
+
+# Use 'rm' before 'echo', because COPYING is likely to be a symlink to
+# the real COPYING...
+rm -f COPYING
+echo 'MY-OWN-LICENSE' >COPYING
+$MAKE test2
+
+$AUTOMAKE --gnu --add-missing --force-missing
+./configure
+$MAKE test2
+
+rm -f COPYING
+echo 'MY-OWN-LICENSE' >COPYING.LIB
+$AUTOMAKE --gnu --add-missing --force-missing
+./configure
+$MAKE test3
diff --git a/t/license2.sh b/t/license2.sh
new file mode 100755
index 000000000..d447eba2f
--- /dev/null
+++ b/t/license2.sh
@@ -0,0 +1,39 @@
+#! /bin/sh
+# Copyright (C) 2008-2012 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/>.
+
+# Check that installing 'COPYING' outputs a warning.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = gnu
+END
+
+: >AUTHORS
+: >NEWS
+: >README
+: >ChangeLog
+: >INSTALL
+
+$ACLOCAL
+AUTOMAKE_fails
+grep 'COPYING' stderr
+
+AUTOMAKE_run --add-missing
+grep 'COPYING' stderr
+grep 'GNU General Public License' stderr
+grep 'Consider adding.*version control' stderr
+test -f COPYING
diff --git a/t/link_c_cxx.sh b/t/link_c_cxx.sh
new file mode 100755
index 000000000..a3dac1b5b
--- /dev/null
+++ b/t/link_c_cxx.sh
@@ -0,0 +1,45 @@
+#! /bin/sh
+# Copyright (C) 1998-2012 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/>.
+
+# Test to make sure the C++ linker is used when appropriate.
+# Matthew D. Langston <langston@SLAC.Stanford.EDU>
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_PROG_CXX
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = lavalamp
+lavalamp_SOURCES = lava.c lamp.cxx
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+# We should only see the C++ linker in the rules of 'Makefile.in'.
+
+# Look for this macro not at the beginning of any line; that will have
+# to be good enough for now.
+grep '.\$(CXXLINK)' Makefile.in
+
+# We should not see these patterns:
+grep '.\$(FLINK)' Makefile.in && Exit 1
+grep '.\$(LINK)' Makefile.in && Exit 1
+
+Exit 0
diff --git a/t/link_cond.sh b/t/link_cond.sh
new file mode 100755
index 000000000..7b9fd5a3c
--- /dev/null
+++ b/t/link_cond.sh
@@ -0,0 +1,90 @@
+#! /bin/sh
+# Copyright (C) 2012 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/>.
+
+# Test that automatic determination of the linker works well with
+# conditional use of languages in a single program.
+# This currently doesn't truly work, but we have an easy workaround
+# at least, that is tested here.
+# See automake bug#11089.
+
+required='cc c++'
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_PROG_CXX
+AM_CONDITIONAL([HAVE_CXX], [test $have_cxx = yes])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = foo
+if HAVE_CXX
+foo_SOURCES = more.c++
+else
+foo_SOURCES = less.c
+endif
+## FIXME: ideally, this workaround shouldn't be needed.
+if HAVE_CXX
+foo_LINK = $(CXXLINK)
+else
+foo_LINK = $(LINK)
+endif
+END
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+
+rm -f *.c++
+cat > less.c <<'END'
+/* Valid C but deliberately invalid C++ */
+main ()
+{
+ int new = 0;
+ return new;
+}
+END
+
+./configure have_cxx=no
+CXX=false $MAKE -e
+
+# Sanity check.
+rm -f foo foo.exe
+CC=false $MAKE -e && Exit 99
+
+$MAKE distclean
+
+rm -f *.c
+cat > more.c++ <<'END'
+/* Valid C++ but deliberately invalid C */
+using namespace std;
+int main (void)
+{
+ return 0;
+}
+END
+
+./configure have_cxx=yes
+CC=false $MAKE -e
+
+# Sanity check.
+rm -f foo foo.exe
+CXX=false $MAKE -e && Exit 99
+
+:
diff --git a/t/link_dist.sh b/t/link_dist.sh
new file mode 100755
index 000000000..8ba05dfd4
--- /dev/null
+++ b/t/link_dist.sh
@@ -0,0 +1,47 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test to make sure the linker for a dist_*_SOURCES can override that for
+# *_SOURCES
+# Richard Boulton <richard@tartarus.org>
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_PROG_CXX
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = lavalamp
+lavalamp_SOURCES = lava.c
+dist_lavalamp_SOURCES = lamp.cxx
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+# We should only see the C++ linker in the rules of 'Makefile.in'.
+
+# Look for this macro not at the beginning of any line; that will have
+# to be good enough for now.
+grep '.\$(CXXLINK)' Makefile.in
+
+# We should not see these patterns:
+grep '.\$(FLINK)' Makefile.in && Exit 1
+grep '.\$(LINK)' Makefile.in && Exit 1
+
+Exit 0
diff --git a/t/link_f90_only.sh b/t/link_f90_only.sh
new file mode 100755
index 000000000..a34d6c6d2
--- /dev/null
+++ b/t/link_f90_only.sh
@@ -0,0 +1,44 @@
+#! /bin/sh
+# Copyright (C) 1998-2012 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/>.
+
+# Test to make sure the Fortran 90 linker is used when appropriate.
+# (copied from link_f_only.test) Mike Nolta <mrnolta@princeton.edu>
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_FC
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = lavalamp
+lavalamp_SOURCES = lamp.f90
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+# We should only see the Fortran linker in the rules of 'Makefile.in'.
+
+# Look for this macro not at the beginning of any line; that will have
+# to be good enough for now.
+grep '.\$(FCLINK)' Makefile.in
+
+# We should not see these patterns:
+grep '.\$(CXXLINK)' Makefile.in && Exit 1
+grep '.\$(LINK)' Makefile.in && Exit 1
+
+Exit 0
diff --git a/t/link_f_only.sh b/t/link_f_only.sh
new file mode 100755
index 000000000..25f3ef93e
--- /dev/null
+++ b/t/link_f_only.sh
@@ -0,0 +1,44 @@
+#! /bin/sh
+# Copyright (C) 1998-2012 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/>.
+
+# Test to make sure the Fortran 77 linker is used when appropriate.
+# Matthew D. Langston <langston@SLAC.Stanford.EDU>
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_F77
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = lavalamp
+lavalamp_SOURCES = lamp.f
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+# We should only see the Fortran linker in the rules of 'Makefile.in'.
+
+# Look for this macro not at the beginning of any line; that will have
+# to be good enough for now.
+grep '.\$(F77LINK)' Makefile.in
+
+# We should not see these patterns:
+grep '.\$(CXXLINK)' Makefile.in && Exit 1
+grep '.\$(LINK)' Makefile.in && Exit 1
+
+Exit 0
diff --git a/t/link_fc.sh b/t/link_fc.sh
new file mode 100755
index 000000000..6cf8b8bd2
--- /dev/null
+++ b/t/link_fc.sh
@@ -0,0 +1,46 @@
+#! /bin/sh
+# Copyright (C) 1998-2012 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/>.
+
+# Test to make sure the Fortran 77 linker is used when appropriate.
+# Matthew D. Langston <langston@SLAC.Stanford.EDU>
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_PROG_F77
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = lavalamp
+lavalamp_SOURCES = lava.c lamp.f
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+# We should only see the Fortran 77 linker in the rules of
+# 'Makefile.in'.
+
+# Look for this macro not at the beginning of any line; that will have
+# to be good enough for now.
+grep '.\$(F77LINK)' Makefile.in
+
+# We should not see these patterns:
+grep '.\$(LINK)' Makefile.in && Exit 1
+grep '.\$(CXXLINK)' Makefile.in && Exit 1
+
+Exit 0
diff --git a/t/link_fccxx.sh b/t/link_fccxx.sh
new file mode 100755
index 000000000..ede7b5a59
--- /dev/null
+++ b/t/link_fccxx.sh
@@ -0,0 +1,46 @@
+#! /bin/sh
+# Copyright (C) 1998-2012 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/>.
+
+# Test to make sure the C++ linker is used when appropriate.
+# Matthew D. Langston <langston@SLAC.Stanford.EDU>
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_PROG_CXX
+AC_PROG_F77
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = lavalamp
+lavalamp_SOURCES = lava.c lamp.cxx lamp2.f
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+# We should only see the C++ linker in the rules of 'Makefile.in'.
+
+# Look for this macro not at the beginning of any line; that will have
+# to be good enough for now.
+grep '.\$(CXXLINK)' Makefile.in
+
+# We should not see these patterns:
+grep '.\$(F77LINK)' Makefile.in && Exit 1
+grep '.\$(LINK)' Makefile.in && Exit 1
+
+Exit 0
diff --git a/t/link_fcxx.sh b/t/link_fcxx.sh
new file mode 100755
index 000000000..545f6a675
--- /dev/null
+++ b/t/link_fcxx.sh
@@ -0,0 +1,45 @@
+#! /bin/sh
+# Copyright (C) 1998-2012 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/>.
+
+# Test to make sure the C++ linker is used when appropriate.
+# Matthew D. Langston <langston@SLAC.Stanford.EDU>
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CXX
+AC_PROG_F77
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = lavalamp
+lavalamp_SOURCES = lava.cxx lamp.f
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+# We should only see the C++ linker in the rules of 'Makefile.in'.
+
+# Look for this macro not at the beginning of any line; that will have
+# to be good enough for now.
+grep '.\$(CXXLINK)' Makefile.in
+
+# We should not see these patterns:
+grep '.\$(F77LINK)' Makefile.in && Exit 1
+grep '.\$(LINK)' Makefile.in && Exit 1
+
+Exit 0
diff --git a/t/link_override.sh b/t/link_override.sh
new file mode 100755
index 000000000..48d32a26a
--- /dev/null
+++ b/t/link_override.sh
@@ -0,0 +1,44 @@
+#! /bin/sh
+# Copyright (C) 2009-2012 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 3 of the License, 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/>.
+
+# Test to make sure _LINK variables are detected and used as documented.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = foo bar baz boo
+foo_LINK = $(LINK)
+bar_LINK = $(LINK)
+bar_LDFLAGS = $(AM_LDFLAGS)
+END
+
+$ACLOCAL
+$AUTOMAKE -a
+
+# We should use foo_LINK not LINK.
+grep '.\$(foo_LINK)' Makefile.in
+grep '.\$(LINK).*foo' Makefile.in && Exit 1
+
+# We should not override the user definition of bar_LINK.
+# IOW, bar_LDFLAGS is useless unless bar_LINK refers to it.
+grep '^ *bar_LINK *=.*bar_LDFLAGS' Makefile.in && Exit 1
+grep '.\$(bar_LINK).*bar' Makefile.in
+
+Exit 0
diff --git a/t/lisp2.sh b/t/lisp2.sh
new file mode 100755
index 000000000..25d174f71
--- /dev/null
+++ b/t/lisp2.sh
@@ -0,0 +1,75 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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 that Automake suggest using AM_PATH_LISPDIR to define lispdir.
+
+. ./defs || Exit 1
+
+
+: TRY 1 -- We lack both EMACS and lispdir.
+
+cat > Makefile.am << 'END'
+lisp_LISP = foo.el
+END
+
+$ACLOCAL
+AUTOMAKE_fails
+grep AM_PATH_LISPDIR stderr
+grep '[Ll]isp source.*EMACS.* undefined' stderr
+grep '[Ll]isp source.*lispdir.* undefined' stderr
+grep ' add .*AM_PATH_LISPDIR' stderr
+
+
+: TRY 2 -- Setting lispdir should not be enough.
+
+cat > Makefile.am << 'END'
+lispdir = /usr/share/emacs/site-lisp
+lisp_LISP = foo.el
+END
+
+$ACLOCAL
+AUTOMAKE_fails
+grep 'lispdir.*undefined' stderr && Exit 1
+grep '[Ll]isp source.*EMACS.* undefined' stderr
+grep 'define .*EMACS.* add .*AM_PATH_LISPDIR' stderr
+
+
+: TRY 3 -- Setting EMACS should not be enough.
+
+cat > Makefile.am << 'END'
+EMACS = emacs
+lisp_LISP = foo.el
+END
+
+$ACLOCAL
+AUTOMAKE_fails
+grep 'EMACS.*undefined' stderr && Exit 1
+grep '[Ll]isp source.*lispdir.* undefined' stderr
+grep 'define .*lispdir.* add .*AM_PATH_LISPDIR' stderr
+
+
+: TRY 4 -- Setting both EMACS and lispdir is OK.
+
+cat > Makefile.am << 'END'
+lispdir = /usr/share/emacs/site-lisp
+EMACS = emacs
+lisp_LISP = foo.el
+END
+
+$ACLOCAL
+$AUTOMAKE -a
+
+:
diff --git a/t/lisp3.sh b/t/lisp3.sh
new file mode 100755
index 000000000..a1531d355
--- /dev/null
+++ b/t/lisp3.sh
@@ -0,0 +1,94 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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/>.
+
+# Test that compiling interdependent elisp files works.
+
+required=emacs
+. ./defs || Exit 1
+
+cat > Makefile.am << 'EOF'
+lisp_LISP = am-one.el am-two.el am-three.el
+EXTRA_DIST = am-one.el am-two.el
+am-three.el:
+ echo "(provide 'am-three)" > $@
+CLEANFILES = am-three.el
+EOF
+
+cat >> configure.ac << 'EOF'
+AM_PATH_LISPDIR
+AC_OUTPUT
+EOF
+
+echo "(require 'am-two)" > am-one.el
+echo "(require 'am-three) (provide 'am-two)" > am-two.el
+# am-three.el is a built source
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+./configure --prefix="`pwd`/_inst"
+
+$MAKE
+
+test -f am-one.elc
+test -f am-two.elc
+test -f am-three.elc
+test -f elc-stamp
+
+# Make sure we can recover from a deletion.
+rm -f am-one.elc
+$MAKE
+test -f am-one.elc
+
+# Test installation/deinstallation.
+
+$MAKE install
+
+find _inst # For debugging.
+
+# Keep thin in sync with m4/lispdir.m4.
+for dir in lib/emacs lib/xemacs share/emacs share/xemacs :; do
+ if test $dir = :; then
+ Exit 1
+ elif test -d _inst/$dir/site-lisp; then
+ break
+ fi
+done
+
+test -f _inst/$dir/site-lisp/am-one.el
+test -f _inst/$dir/site-lisp/am-one.elc
+test -f _inst/$dir/site-lisp/am-two.el
+test -f _inst/$dir/site-lisp/am-two.elc
+test -f _inst/$dir/site-lisp/am-three.el
+test -f _inst/$dir/site-lisp/am-three.elc
+
+$MAKE uninstall
+find _inst | $EGREP '\.elc?$' && Exit 1
+
+# Make sure we build all files when any of them change.
+# (We grep a message to make sure the compilation happens.)
+unique=0a3346e2af8a689b85002b53df09142a
+$sleep
+echo "(message \"$unique\")(provide 'am-three)" > am-three.el
+$MAKE >output 2>&1 || { cat output; Exit 1; }
+cat output
+grep $unique output
+
+# It should also work for VPATH-builds.
+$MAKE distcheck
+
+:
diff --git a/t/lisp4.sh b/t/lisp4.sh
new file mode 100755
index 000000000..8d2de591a
--- /dev/null
+++ b/t/lisp4.sh
@@ -0,0 +1,80 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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 setting ELCFILES= disable byte-compilation as documented.
+# Report from Simon Josefsson.
+
+required=emacs
+. ./defs || Exit 1
+
+cat > Makefile.am << 'EOF'
+lisp_LISP = am-one.el am-two.el am-three.el
+EXTRA_DIST = am-one.el am-two.el
+ELCFILES=
+am-three.el:
+ echo "(provide 'am-three)" > $@
+CLEANFILES = am-three.el
+
+test:
+ test ! -f am-one.elc
+ test ! -f am-two.elc
+ test ! -f am-three.elc
+ test ! -f elc-stamp
+
+install-test: install
+ test -f "$(lispdir)/am-one.el"
+ test -f "$(lispdir)/am-two.el"
+ test -f "$(lispdir)/am-three.el"
+ test ! -f "$(lispdir)/am-one.elc"
+ test ! -f "$(lispdir)/am-two.elc"
+ test ! -f "$(lispdir)/am-three.elc"
+
+not-installed:
+ find "$(lispdir)" | grep '\.el$$' && exit 1; :
+ find "$(lispdir)" | grep '\.elc$$' && exit 1; :
+EOF
+
+cat >> configure.ac << 'EOF'
+AM_PATH_LISPDIR
+AC_OUTPUT
+EOF
+
+echo "(require 'am-two)" > am-one.el
+echo "(require 'am-three) (provide 'am-two)" > am-two.el
+# am-tree.el is a built source
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+./configure --prefix "`pwd`"
+$MAKE
+$MAKE test
+$MAKE install-test
+$MAKE uninstall
+$MAKE not-installed
+
+# Fake the absence of emacs.
+# *.el files should not be installed, but "make install" and
+# "make uninstall" should continue to work.
+./configure EMACS=no --prefix "`pwd`"
+$MAKE
+$MAKE test
+$MAKE install
+$MAKE not-installed
+$MAKE uninstall
+
+:
diff --git a/t/lisp5.sh b/t/lisp5.sh
new file mode 100755
index 000000000..997a56e73
--- /dev/null
+++ b/t/lisp5.sh
@@ -0,0 +1,79 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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/>.
+
+# Same as lisp4.test, but using the now-recommended way to install
+# non-bytecompiled *.el files.
+
+required=emacs
+. ./defs || Exit 1
+
+cat > Makefile.am << 'EOF'
+lisp_DATA = am-one.el am-two.el am-three.el
+EXTRA_DIST = am-one.el am-two.el
+am-three.el:
+ echo "(provide 'am-three)" > $@
+CLEANFILES = am-three.el
+
+test:
+ test ! -f am-one.elc
+ test ! -f am-two.elc
+ test ! -f am-three.elc
+ test ! -f elc-stamp
+
+install-test: install
+ test -f "$(lispdir)/am-one.el"
+ test -f "$(lispdir)/am-two.el"
+ test -f "$(lispdir)/am-three.el"
+ test ! -f "$(lispdir)/am-one.elc"
+ test ! -f "$(lispdir)/am-two.elc"
+ test ! -f "$(lispdir)/am-three.elc"
+
+not-installed:
+ find "$(lispdir)" | grep '\.el$$' && exit 1; :
+ find "$(lispdir)" | grep '\.elc$$' && exit 1; :
+EOF
+
+cat >> configure.ac << 'EOF'
+AM_PATH_LISPDIR
+AC_OUTPUT
+EOF
+
+echo "(require 'am-two)" > am-one.el
+echo "(require 'am-three) (provide 'am-two)" > am-two.el
+# am-tree.el is a built source
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+./configure --prefix "`pwd`"
+$MAKE
+$MAKE test
+$MAKE install-test
+$MAKE uninstall
+$MAKE not-installed
+
+# Fake the absence of emacs.
+# *.el files SHOULD be installed by "make install" (and uninstalled
+# by "make uninstall").
+./configure EMACS=no --prefix "`pwd`"
+$MAKE
+$MAKE test
+$MAKE install-test
+$MAKE uninstall
+$MAKE not-installed
+
+:
diff --git a/t/lisp6.sh b/t/lisp6.sh
new file mode 100755
index 000000000..9635ea275
--- /dev/null
+++ b/t/lisp6.sh
@@ -0,0 +1,105 @@
+#! /bin/sh
+# Copyright (C) 2004-2012 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/>.
+
+# Test for conditional _LISP.
+
+required=emacs
+. ./defs || Exit 1
+
+cat > Makefile.am << 'EOF'
+dist_lisp_LISP = am-one.el
+if WANT_TWO
+ dist_lisp_LISP += am-two.el
+endif
+dist_noinst_LISP = am-three.el
+
+dist-test: distdir
+ test -f $(distdir)/am-one.el
+ test -f $(distdir)/am-two.el
+ test -f $(distdir)/am-three.el
+EOF
+
+cat >> configure.ac << 'EOF'
+AM_CONDITIONAL([WANT_TWO], [test -n "$want_two"])
+AM_PATH_LISPDIR
+AC_OUTPUT
+EOF
+
+echo "(provide 'am-one)" > am-one.el
+echo "(require 'am-one)" > am-two.el
+echo "(require 'am-one)" > am-three.el
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+./configure "--with-lispdir=`pwd`/lisp"
+
+$MAKE
+test -f am-one.elc
+test ! -f am-two.elc
+test -f am-three.elc
+test -f elc-stamp
+
+$MAKE install
+test -f lisp/am-one.el
+test -f lisp/am-one.elc
+test ! -f lisp/am-two.el
+test ! -f lisp/am-two.elc
+test ! -f lisp/am-three.el
+test ! -f lisp/am-three.elc
+
+$MAKE dist-test
+
+$MAKE distclean
+test ! -f am-one.elc
+test ! -f am-two.elc
+test ! -f am-three.elc
+test ! -f elc-stamp
+
+./configure "--with-lispdir=`pwd`/lisp" want_two=1
+
+$MAKE
+test -f am-one.elc
+test -f am-two.elc
+test -f am-three.elc
+test -f elc-stamp
+
+# Let's mutilate the source tree, to check the recover rule.
+rm -f am-*.elc
+$MAKE
+test -f am-one.elc
+test -f am-two.elc
+test -f am-three.elc
+test -f elc-stamp
+
+$MAKE install
+test -f lisp/am-one.el
+test -f lisp/am-one.elc
+test -f lisp/am-two.el
+test -f lisp/am-two.elc
+test ! -f lisp/am-three.el
+test ! -f lisp/am-three.elc
+
+$MAKE dist-test
+
+$MAKE distclean
+test ! -f am-one.elc
+test ! -f am-two.elc
+test ! -f am-three.elc
+test ! -f elc-stamp
+
+:
diff --git a/t/lisp7.sh b/t/lisp7.sh
new file mode 100755
index 000000000..79799d160
--- /dev/null
+++ b/t/lisp7.sh
@@ -0,0 +1,51 @@
+#! /bin/sh
+# Copyright (C) 2005-2012 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 that lisp_LISP also works when emacs is not installed.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'EOF'
+dist_lisp_LISP = am-one.el am-two.el am-three.el
+EOF
+
+cat >> configure.ac << 'EOF'
+AM_PATH_LISPDIR
+EMACS=no # Simulate no emacs.
+AC_OUTPUT
+EOF
+
+echo "(require 'am-two)" > am-one.el
+echo "(require 'am-three) (provide 'am-two)" > am-two.el
+echo "(provide 'am-three)" > am-three.el
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+./configure
+
+$MAKE >stdout || { cat stdout; Exit 1; }
+cat stdout
+test 1 -eq `grep 'Warnings can be ignored' stdout | wc -l`
+
+test ! -f am-one.elc
+test ! -f am-two.elc
+test ! -f am-three.elc
+test -f elc-stamp
+
+$MAKE distcheck
+
+:
diff --git a/t/lisp8.sh b/t/lisp8.sh
new file mode 100755
index 000000000..299ecd0a4
--- /dev/null
+++ b/t/lisp8.sh
@@ -0,0 +1,63 @@
+#! /bin/sh
+# Copyright (C) 2005-2012 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/>.
+
+# Check the recover rule of lisp_LISP with parallel make.
+
+required='GNUmake emacs'
+. ./defs || Exit 1
+
+cat > Makefile.am << 'EOF'
+dist_lisp_LISP = am-one.el am-two.el am-three.el
+EOF
+
+cat >> configure.ac << 'EOF'
+AM_PATH_LISPDIR
+AC_OUTPUT
+EOF
+
+echo "(require 'am-two)" > am-one.el
+echo "(require 'am-three) (provide 'am-two)" > am-two.el
+echo "(provide 'am-three)" > am-three.el
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+./configure
+
+: >stdout
+$MAKE -j >>stdout || { cat stdout; Exit 1; }
+
+cat stdout
+test 1 -eq `grep 'Warnings can be ignored' stdout | wc -l`
+
+test -f am-one.elc
+test -f am-two.elc
+test -f am-three.elc
+test -f elc-stamp
+
+rm -f am-*.elc
+
+: >stdout
+$MAKE -j >>stdout || { cat stdout; Exit 1; }
+
+cat stdout
+test 1 -eq `grep 'Warnings can be ignored' stdout | wc -l`
+test -f am-one.elc
+test -f am-two.elc
+test -f am-three.elc
+test -f elc-stamp
+
+:
diff --git a/t/lispdry.sh b/t/lispdry.sh
new file mode 100755
index 000000000..a89ffe171
--- /dev/null
+++ b/t/lispdry.sh
@@ -0,0 +1,58 @@
+#! /bin/sh
+# Copyright (C) 2005-2012 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/>.
+
+# Check that 'make -n' works with the lisp_LISP recover rule.
+
+required='emacs non-root'
+. ./defs || Exit 1
+
+cat > Makefile.am << 'EOF'
+dist_lisp_LISP = am-one.el am-two.el am-three.el
+EOF
+
+cat >> configure.ac << 'EOF'
+AM_PATH_LISPDIR
+AC_OUTPUT
+EOF
+
+echo "(require 'am-two)" > am-one.el
+echo "(require 'am-three) (provide 'am-two)" > am-two.el
+echo "(provide 'am-three)" > am-three.el
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+./configure
+
+$MAKE
+
+test -f am-one.elc
+test -f am-two.elc
+test -f am-three.elc
+test -f elc-stamp
+
+rm -f am-*.elc elc-stamp
+
+chmod a-w .
+
+$MAKE -n
+
+test ! -f am-one.elc
+test ! -f am-two.elc
+test ! -f am-three.elc
+test ! -f elc-stamp
+
+:
diff --git a/t/list-of-tests.mk b/t/list-of-tests.mk
new file mode 100644
index 000000000..32e8c1765
--- /dev/null
+++ b/t/list-of-tests.mk
@@ -0,0 +1,1274 @@
+## Makefile fragment that holds the list of test scripts of the automake
+## testsuite. This fragment is meant to be included by the Makefile.am,
+## but also to be executed directly by make when bootstrapping automake.
+
+## Copyright (C) 2011-2012 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/>.
+
+# FIXME: this "expected failures" are in truth an hack used to
+# FIXME: to verify that some incorrect usages of our perl libraries
+# FIXME: raise an error. We should find a cleaner way to check that.
+perl_fake_XFAIL_TESTS = \
+pm/Cond2.pl \
+pm/Cond3.pl \
+pm/DisjCon2.pl \
+pm/DisjCon3.pl \
+pm/Version2.pl \
+pm/Version3.pl
+
+XFAIL_TESTS = \
+all.sh \
+yacc-bison-skeleton-cxx.sh \
+yacc-bison-skeleton.sh \
+cond17.sh \
+gcj6.sh \
+override-conditional-2.sh \
+dist-pr109765.sh \
+instdir-cond2.sh \
+java-nobase.sh \
+objext-pr10128.sh \
+parallel-tests-many.sh \
+pr8365-remake-timing.sh \
+lex-subobj-nodep.sh \
+remake-am-pr10111.sh \
+remake-m4-pr10111.sh \
+txinfo5.sh \
+$(perl_fake_XFAIL_TESTS)
+
+perl_TESTS = \
+pm/Cond2.pl \
+pm/Cond3.pl \
+pm/Condition.pl \
+pm/Condition-t.pl \
+pm/DisjCon2.pl \
+pm/DisjCon3.pl \
+pm/DisjConditions.pl \
+pm/DisjConditions-t.pl \
+pm/Version.pl \
+pm/Version2.pl \
+pm/Version3.pl \
+pm/Wrap.pl
+
+# The order here is mostly alphabetical, with the deliberate exception
+# that tests having a high runtime (especially TAP tests that run various
+# checks sequentially) are listed early; this improves performance on
+# concurrent testsuite runs.
+handwritten_TESTS = \
+get-sysconf.sh \
+$(perl_TESTS) \
+instspc.tap \
+aclocal.sh \
+aclocal3.sh \
+aclocal4.sh \
+aclocal5.sh \
+aclocal6.sh \
+aclocal7.sh \
+aclocal8.sh \
+aclocal9.sh \
+acloca10.sh \
+acloca11.sh \
+acloca12.sh \
+acloca13.sh \
+acloca14.sh \
+acloca15.sh \
+acloca16.sh \
+acloca17.sh \
+acloca18.sh \
+acloca19.sh \
+acloca20.sh \
+acloca21.sh \
+acloca22.sh \
+acloca23.sh \
+aclocal-acdir.sh \
+aclocal-install-absdir.sh \
+aclocal-print-acdir.sh \
+aclocal-path.sh \
+aclocal-path-install.sh \
+aclocal-path-install-serial.sh \
+aclocal-path-nonexistent.sh \
+aclocal-path-precedence.sh \
+aclocal-install-fail.sh \
+aclocal-install-mkdir.sh \
+aclocal-no-install-no-mkdir.sh \
+aclocal-verbose-install.sh \
+ac-output-old.tap \
+acsilent.sh \
+acsubst.sh \
+acsubst2.sh \
+add-missing.tap \
+all.sh \
+all2.sh \
+alloca.sh \
+alloca2.sh \
+alpha.sh \
+alpha2.sh \
+amhello-cflags.sh \
+amhello-cross-compile.sh \
+amhello-binpkg.sh \
+amassign.sh \
+ammissing.sh \
+amopt.sh \
+amopts-location.sh \
+amopts-variable-expansion.sh \
+amsubst.sh \
+ansi2knr-no-more.sh \
+ar-lib.sh \
+ar-lib2.sh \
+ar-lib3.sh \
+ar-lib4.sh \
+ar-lib5a.sh \
+ar-lib5b.sh \
+ar-lib6a.sh \
+ar-lib6b.sh \
+ar-lib7.sh \
+ar.sh \
+ar2.sh \
+ar3.sh \
+ar4.sh \
+ar5.sh \
+asm.sh \
+asm2.sh \
+asm3.sh \
+autodist.sh \
+autodist-subdir.sh \
+autodist-acconfig.sh \
+autodist-acconfig-no-subdir.sh \
+autodist-aclocal-m4.sh \
+autodist-config-headers.sh \
+autodist-configure-no-subdir.sh \
+autodist-no-duplicate.sh \
+autodist-stamp-vti.sh \
+autohdr.sh \
+autohdr2.sh \
+autohdr3.sh \
+autohdr4.sh \
+autohdrdry.sh \
+automake-cmdline.tap \
+auxdir.sh \
+auxdir6.sh \
+auxdir7.sh \
+auxdir8.sh \
+auxdir-autodetect.sh \
+auxdir-computed.tap \
+auxdir-misplaced.sh \
+auxdir-nonexistent.sh \
+auxdir-unportable.tap \
+backcompat.sh \
+backcompat2.sh \
+backcompat3.sh \
+backcompat4.sh \
+backcompat5.sh \
+backcompat6.sh \
+backsl.sh \
+backsl2.sh \
+backsl3.sh \
+backsl4.sh \
+badline.sh \
+badopt.sh \
+badprog.sh \
+block.sh \
+bsource.sh \
+candist.sh \
+canon.sh \
+canon2.sh \
+canon3.sh \
+canon4.sh \
+canon5.sh \
+canon6.sh \
+canon7.sh \
+canon8.sh \
+canon-name.sh \
+ccnoco.sh \
+ccnoco2.sh \
+ccnoco3.sh \
+check.sh \
+check2.sh \
+check3.sh \
+check4.sh \
+check5.sh \
+check6.sh \
+check7.sh \
+check8.sh \
+check10.sh \
+check11.sh \
+check12.sh \
+check-subst.sh \
+check-subst-prog.sh \
+check-exported-srcdir.sh \
+check-fd-redirect.sh \
+check-tests-in-builddir.sh \
+check-no-test-driver.sh \
+check-concurrency-bug9245.sh \
+checkall.sh \
+clean.sh \
+clean2.sh \
+colneq.sh \
+colneq2.sh \
+colneq3.sh \
+colon.sh \
+colon2.sh \
+colon3.sh \
+colon4.sh \
+colon5.sh \
+colon6.sh \
+colon7.sh \
+color.sh \
+color2.sh \
+comment.sh \
+comment2.sh \
+comment3.sh \
+comment4.sh \
+comment5.sh \
+comment6.sh \
+comment7.sh \
+comment8.sh \
+comment9.sh \
+commen10.sh \
+commen11.sh \
+comments-in-var-def.sh \
+compile.sh \
+compile2.sh \
+compile3.sh \
+compile4.sh \
+compile5.sh \
+compile6.sh \
+compile_f90_c_cxx.sh \
+compile_f_c_cxx.sh \
+cond-basic.sh \
+cond.sh \
+cond2.sh \
+cond3.sh \
+cond4.sh \
+cond5.sh \
+cond6.sh \
+cond7.sh \
+cond8.sh \
+cond9.sh \
+cond10.sh \
+cond11.sh \
+cond13.sh \
+cond14.sh \
+cond15.sh \
+cond16.sh \
+cond17.sh \
+cond18.sh \
+cond19.sh \
+cond20.sh \
+cond21.sh \
+cond22.sh \
+cond23.sh \
+cond24.sh \
+cond25.sh \
+cond26.sh \
+cond27.sh \
+cond28.sh \
+cond29.sh \
+cond30.sh \
+cond31.sh \
+cond32.sh \
+cond33.sh \
+cond34.sh \
+cond35.sh \
+cond36.sh \
+cond37.sh \
+cond38.sh \
+cond39.sh \
+cond40.sh \
+cond41.sh \
+cond42.sh \
+cond43.sh \
+cond44.sh \
+cond45.sh \
+cond46.sh \
+condd.sh \
+condhook.sh \
+condhook2.sh \
+condinc.sh \
+condinc2.sh \
+condlib.sh \
+condman2.sh \
+condman3.sh \
+configure.sh \
+confdeps.sh \
+conff.sh \
+conff2.sh \
+conffile-leading-dot.sh \
+confh.sh \
+confh4.sh \
+confh5.sh \
+confh6.sh \
+confh7.sh \
+confh8.sh \
+confincl.sh \
+conflnk.sh \
+conflnk2.sh \
+conflnk3.sh \
+conflnk4.sh \
+confsub.sh \
+confvar.sh \
+confvar2.sh \
+copy.sh \
+cscope.tap \
+cscope2.sh \
+cscope3.sh \
+cxx.sh \
+cxx2.sh \
+cxxcpp.sh \
+cxxlibobj.sh \
+cxxlink.sh \
+cxxnoc.sh \
+cxxo.sh \
+cygnus-check-without-all.sh \
+cygnus-dependency-tracking.sh \
+cygnus-imply-foreign.sh \
+cygnus-no-dist.sh \
+cygnus-no-installinfo.sh \
+cygnus-requires-maintainer-mode.sh \
+cygwin32.sh \
+dash.sh \
+defun.sh \
+defun2.sh \
+dejagnu.sh \
+dejagnu2.sh \
+dejagnu3.sh \
+dejagnu4.sh \
+dejagnu5.sh \
+dejagnu6.sh \
+dejagnu7.sh \
+dejagnu-absolute-builddir.sh \
+dejagnu-relative-srcdir.sh \
+dejagnu-siteexp-extend.sh \
+dejagnu-siteexp-append.sh \
+dejagnu-siteexp-useredit.sh \
+deleted-am.sh \
+deleted-m4.sh \
+depacl2.sh \
+depcomp.sh \
+depcomp2.sh \
+depcomp8a.sh \
+depcomp8b.sh \
+depdist.sh \
+depend.sh \
+depend3.sh \
+depend4.sh \
+depend5.sh \
+depend6.sh \
+deprecated-acinit.sh \
+destdir.sh \
+dirlist.sh \
+dirlist2.sh \
+dirlist-abspath.sh \
+discover.sh \
+dist-formats.tap \
+dist-auxdir-many-subdirs.sh \
+dist-auxfile-2.sh \
+dist-auxfile.sh \
+dist-included-parent-dir.sh \
+dist-missing-am.sh \
+dist-missing-included-m4.sh \
+dist-missing-m4.sh \
+dist-readonly.sh \
+dist-repeated.sh \
+dist-pr109765.sh \
+distcleancheck.sh \
+distcom2.sh \
+distcom3.sh \
+distcom4.sh \
+distcom5.sh \
+distcom-subdir.sh \
+distdir.sh \
+disthook.sh \
+distlinks.sh \
+distlinksbrk.sh \
+distname.sh \
+distcheck-configure-flags.sh \
+distcheck-configure-flags-am.sh \
+distcheck-configure-flags-subpkg.sh \
+distcheck-hook.sh \
+distcheck-hook2.sh \
+distcheck-writable-srcdir.sh \
+distcheck-missing-m4.sh \
+distcheck-outdated-m4.sh \
+distcheck-override-infodir.sh \
+distcheck-pr9579.sh \
+distcheck-pr10470.sh \
+dmalloc.sh \
+doc-parsing-buglets-colneq-subst.sh \
+doc-parsing-buglets-tabs.sh \
+dollar.sh \
+dollarvar.sh \
+dollarvar2.sh \
+double.sh \
+dup2.sh \
+else.sh \
+empty.sh \
+empty2.sh \
+empty3.sh \
+empty4.sh \
+exdir.sh \
+exdir2.sh \
+exdir3.sh \
+exeext.sh \
+exeext2.sh \
+exeext3.sh \
+exeext4.sh \
+exsource.sh \
+ext.sh \
+ext2.sh \
+ext3.sh \
+extra.sh \
+extra2.sh \
+extra3.sh \
+extra4.sh \
+extra5.sh \
+extra6.sh \
+extra7.sh \
+extra8.sh \
+extra9.sh \
+extra10.sh \
+extra11.sh \
+extra12.sh \
+extra-programs-empty.sh \
+extra-portability.sh \
+extra-portability2.sh \
+extra-portability3.sh \
+extradep.sh \
+extradep2.sh \
+f90only.sh \
+flavor.sh \
+flibs.sh \
+fn99.sh \
+fn99subdir.sh \
+fnoc.sh \
+fo.sh \
+forcemiss.sh \
+forcemiss2.sh \
+fort1.sh \
+fort2.sh \
+fort4.sh \
+fort5.sh \
+fonly.sh \
+fortdep.sh \
+gcj.sh \
+gcj2.sh \
+gcj3.sh \
+gcj4.sh \
+gcj5.sh \
+gcj6.sh \
+gettext.sh \
+gettext2.sh \
+gettext3.sh \
+gnumake.sh \
+gnuwarn.sh \
+gnuwarn2.sh \
+gnits.sh \
+gnits2.sh \
+gnits3.sh \
+hdr-vars-defined-once.sh \
+header.sh \
+help.sh \
+help2.sh \
+help3.sh \
+help4.sh \
+help-depend.sh \
+help-depend2.sh \
+help-dmalloc.sh \
+help-init.sh \
+help-lispdir.sh \
+help-multilib.sh \
+help-python.sh \
+help-silent.sh \
+help-upc.sh \
+hfs.sh \
+implicit.sh \
+info.sh \
+init.sh \
+init2.sh \
+insh2.sh \
+install2.sh \
+installdir.sh \
+instsh.sh \
+instsh2.sh \
+instsh3.sh \
+instdat.sh \
+instdat2.sh \
+instdir.sh \
+instdir2.sh \
+instdir-cond.sh \
+instdir-cond2.sh \
+instdir-no-empty.sh \
+instdir-java.sh \
+instdir-lisp.sh \
+instdir-ltlib.sh \
+instdir-prog.sh \
+instdir-python.sh \
+instdir-texi.sh \
+instexec.sh \
+instfail.sh \
+instfail-info.sh \
+instfail-java.sh \
+instfail-libtool.sh \
+insthook.sh \
+instman.sh \
+instman2.sh \
+instmany.sh \
+instmany-mans.sh \
+instmany-python.sh \
+install-info-dir.sh \
+interp.sh \
+interp2.sh \
+java.sh \
+java2.sh \
+java3.sh \
+javadir-undefined.sh \
+javaflags.sh \
+java-check.sh \
+java-clean.sh \
+java-compile-install.sh \
+java-compile-run-flat.sh \
+java-compile-run-nested.sh \
+java-empty-classpath.sh \
+javaprim.sh \
+javasubst.sh \
+java-extra.sh \
+java-mix.sh \
+java-no-duplicate.sh \
+java-nobase.sh \
+java-noinst.sh \
+java-rebuild.sh \
+java-sources.sh \
+java-uninstall.sh \
+ldadd.sh \
+ldflags.sh \
+lex.sh \
+lex2.sh \
+lex3.sh \
+lex5.sh \
+lexcpp.sh \
+lexvpath.sh \
+lex-subobj-nodep.sh \
+lex-lib.sh \
+lex-lib-external.sh \
+lex-libobj.sh \
+lex-noyywrap.sh \
+lex-clean-cxx.sh \
+lex-clean.sh \
+lex-depend-cxx.sh \
+lex-depend-grep.sh \
+lex-depend.sh \
+lex-line.sh \
+lex-nodist.sh \
+lex-pr204.sh \
+lflags.sh \
+lflags2.sh \
+libexec.sh \
+libobj-basic.sh \
+libobj2.sh \
+libobj3.sh \
+libobj4.sh \
+libobj5.sh \
+libobj7.sh \
+libobj10.sh \
+libobj12.sh \
+libobj13.sh \
+libobj14.sh \
+libobj15a.sh \
+libobj15b.sh \
+libobj15c.sh \
+libobj16a.sh \
+libobj16b.sh \
+libobj17.sh \
+libobj18.sh \
+libobj19.sh \
+libobj20a.sh \
+libobj20b.sh \
+libobj20c.sh \
+library.sh \
+library2.sh \
+library3.sh \
+libtool.sh \
+libtool2.sh \
+libtool3.sh \
+libtool4.sh \
+libtool5.sh \
+libtool6.sh \
+libtool7.sh \
+libtool8.sh \
+libtool9.sh \
+libtoo10.sh \
+libtoo11.sh \
+license.sh \
+license2.sh \
+link_c_cxx.sh \
+link_cond.sh \
+link_dist.sh \
+link_f90_only.sh \
+link_fc.sh \
+link_fccxx.sh \
+link_fcxx.sh \
+link_f_only.sh \
+link_override.sh \
+lisp2.sh \
+lisp3.sh \
+lisp4.sh \
+lisp5.sh \
+lisp6.sh \
+lisp7.sh \
+lisp8.sh \
+lispdry.sh \
+listval.sh \
+location.sh \
+longline.sh \
+longlin2.sh \
+ltcond.sh \
+ltcond2.sh \
+ltconv.sh \
+ltdeps.sh \
+ltinit.sh \
+ltinstloc.sh \
+ltlibobjs.sh \
+ltlibsrc.sh \
+ltorder.sh \
+lzma.sh \
+m4-inclusion.sh \
+maintclean.sh \
+maintclean-vpath.sh \
+maintmode-configure-msg.sh \
+make.sh \
+makefile-deps.sh \
+makej.sh \
+makej2.sh \
+maken.sh \
+maken3.sh \
+make-dryrun.tap \
+makevars.sh \
+man.sh \
+man2.sh \
+man3.sh \
+man4.sh \
+man5.sh \
+man6.sh \
+man7.sh \
+man8.sh \
+mdate.sh \
+mdate2.sh \
+mdate3.sh \
+mdate4.sh \
+mdate5.sh \
+mdate6.sh \
+missing.sh \
+missing2.sh \
+missing3.sh \
+missing4.sh \
+missing5.sh \
+missing6.sh \
+missing-auxfile-stops-makefiles-creation.sh \
+mkinstall.sh \
+mkinst2.sh \
+mkinst3.sh \
+mmode.sh \
+mmodely.sh \
+multlib.sh \
+no-extra-makefile-code.sh \
+no-outdir-option.sh \
+nobase.sh \
+nobase-libtool.sh \
+nobase-python.sh \
+nobase-nodist.sh \
+nodef.sh \
+nodef2.sh \
+nodep.sh \
+nodep2.sh \
+nodepcomp.sh \
+nodist.sh \
+nodist2.sh \
+nodist3.sh \
+noinst.sh \
+noinstdir.sh \
+nolink.sh \
+nostdinc.sh \
+notrans.sh \
+number.sh \
+objc.sh \
+objc2.sh \
+objext-pr10128.sh \
+obsolete.sh \
+oldvars.sh \
+order.sh \
+output.sh \
+output2.sh \
+output3.sh \
+output4.sh \
+output5.sh \
+output6.sh \
+output7.sh \
+output8.sh \
+output9.sh \
+output10.sh \
+output11.sh \
+output12.sh \
+output13.sh \
+output-order.sh \
+override-conditional-1.sh \
+override-conditional-2.sh \
+override-html.sh \
+override-suggest-local.sh \
+parallel-am.sh \
+parallel-am2.sh \
+parallel-am3.sh \
+serial-tests.sh \
+parallel-tests.sh \
+parallel-tests2.sh \
+parallel-tests3.sh \
+parallel-tests5.sh \
+parallel-tests6.sh \
+parallel-tests8.sh \
+parallel-tests9.sh \
+parallel-tests10.sh \
+parallel-tests-exeext.sh \
+parallel-tests-suffix.sh \
+parallel-tests-suffix-prog.sh \
+parallel-tests-log-compiler-1.sh \
+parallel-tests-log-compiler-2.sh \
+parallel-tests-dry-run-1.sh \
+parallel-tests-dry-run-2.sh \
+parallel-tests-fd-redirect.sh \
+parallel-tests-fd-redirect-exeext.sh \
+parallel-tests-extra-programs.sh \
+parallel-tests-unreadable.sh \
+parallel-tests-subdir.sh \
+parallel-tests-interrupt.tap \
+parallel-tests-reset-term.sh \
+parallel-tests-harderror.sh \
+parallel-tests-log-override-1.sh \
+parallel-tests-log-override-2.sh \
+parallel-tests-log-override-recheck.sh \
+parallel-tests-log-compiler-example.sh \
+parallel-tests-cmdline-override.sh \
+parallel-tests-fork-bomb.sh \
+parallel-tests-empty-testlogs.sh \
+parallel-tests-driver-install.sh \
+parallel-tests-no-color-in-log.sh \
+parallel-tests-no-spurious-summary.sh \
+parallel-tests-exit-statuses.sh \
+parallel-tests-console-output.sh \
+parallel-tests-once.sh \
+parallel-tests-trailing-bslash.sh \
+parallel-tests-many.sh \
+tests-environment.sh \
+am-tests-environment.sh \
+tests-environment-backcompat.sh \
+testsuite-summary-color.sh \
+testsuite-summary-count.sh \
+testsuite-summary-count-many.sh \
+testsuite-summary-reference-log.sh \
+test-driver-acsubst.sh \
+test-driver-cond.sh \
+test-driver-custom-no-extra-driver.sh \
+test-driver-custom.sh \
+test-driver-custom-xfail-tests.sh \
+test-driver-custom-multitest.sh \
+test-driver-custom-multitest-recheck.sh \
+test-driver-custom-multitest-recheck2.sh \
+test-driver-create-log-dir.sh \
+test-driver-strip-vpath.sh \
+test-driver-trs-suffix-registered.sh \
+test-driver-fail.sh \
+test-driver-is-distributed.sh \
+test-harness-vpath-rewrite.sh \
+test-log.sh \
+test-logs-repeated.sh \
+test-metadata-global-log.sh \
+test-metadata-global-result.sh \
+test-metadata-recheck.sh \
+test-metadata-results.sh \
+test-missing.sh \
+test-missing2.sh \
+test-trs-basic.sh \
+test-trs-recover.sh \
+test-trs-recover2.sh \
+test-extensions.sh \
+test-extensions-cond.sh \
+parse.sh \
+percent.sh \
+percent2.sh \
+phony.sh \
+pluseq.sh \
+pluseq2.sh \
+pluseq3.sh \
+pluseq4.sh \
+pluseq5.sh \
+pluseq6.sh \
+pluseq7.sh \
+pluseq8.sh \
+pluseq9.sh \
+pluseq10.sh \
+pluseq11.sh \
+posixsubst-data.sh \
+posixsubst-extradist.sh \
+posixsubst-ldadd.sh \
+posixsubst-libraries.sh \
+posixsubst-ltlibraries.sh \
+posixsubst-programs.sh \
+posixsubst-scripts.sh \
+posixsubst-sources.sh \
+posixsubst-tests.sh \
+postproc.sh \
+ppf77.sh \
+pr2.sh \
+pr9.sh \
+pr72.sh \
+pr87.sh \
+pr211.sh \
+pr220.sh \
+pr224.sh \
+pr229.sh \
+pr243.sh \
+pr266.sh \
+pr279.sh \
+pr279-2.sh \
+pr287.sh \
+pr300-lib.sh \
+pr300-ltlib.sh \
+pr300-prog.sh \
+pr307.sh \
+pr401.sh \
+pr401b.sh \
+pr401c.sh \
+prefix.sh \
+primary.sh \
+primary2.sh \
+primary3.sh \
+primary-prefix-invalid-couples.tap \
+primary-prefix-valid-couples.sh \
+primary-prefix-couples-force-valid.sh \
+primary-prefix-couples-documented-valid.sh \
+print-libdir.sh \
+proginst.sh \
+programs-primary-rewritten.sh \
+py-compile-basic.sh \
+py-compile-basic2.sh \
+py-compile-basedir.sh \
+py-compile-destdir.sh \
+py-compile-env.sh \
+py-compile-option-terminate.sh \
+py-compile-usage.sh \
+python.sh \
+python2.sh \
+python3.sh \
+python4.sh \
+python5.sh \
+python5b.sh \
+python6.sh \
+python7.sh \
+python8.sh \
+python9.sh \
+python10.sh \
+python11.sh \
+python12.sh \
+python-dist.sh \
+python-vars.sh \
+python-virtualenv.sh \
+python-pr10995.sh \
+recurs.sh \
+recurs2.sh \
+remake.sh \
+remake1a.sh \
+remake2.sh \
+remake3.sh \
+remake3a.sh \
+remake4.sh \
+remake5.sh \
+remake6.sh \
+remake7.sh \
+remake8a.sh \
+remake8b.sh \
+remake9a.sh \
+remake9b.sh \
+remake9c.sh \
+remake9d.sh \
+remake10a.sh \
+remake10b.sh \
+remake10c.sh \
+remake11.sh \
+remake12.sh \
+remake-all-1.sh \
+remake-all-2.sh \
+remake-subdir-from-subdir.sh \
+remake-subdir-gnu.sh \
+remake-subdir.sh \
+remake-subdir2.sh \
+remake-subdir-long-time.sh \
+remake-gnulib-add-acsubst.sh \
+remake-gnulib-add-header.sh \
+remake-gnulib-remove-header.sh \
+remake-moved-m4-file.sh \
+remake-deleted-m4-file.sh \
+remake-renamed-m4-file.sh \
+remake-renamed-m4-macro-and-file.sh \
+remake-renamed-m4-macro.sh \
+remake-am-pr10111.sh \
+remake-m4-pr10111.sh \
+remake-deleted-am-2.sh \
+remake-deleted-am-subdir.sh \
+remake-deleted-am.sh \
+remake-renamed-am.sh \
+pr8365-remake-timing.sh \
+req.sh \
+reqd.sh \
+reqd2.sh \
+repeated-options.sh \
+rst-formatting.sh \
+rulepat.sh \
+self-check-cleanup.tap \
+self-check-configure-help.sh \
+self-check-dir.tap \
+self-check-env-sanitize.tap \
+self-check-exit.tap \
+self-check-explicit-skips.sh \
+self-check-is_newest.tap \
+self-check-me.tap \
+self-check-reexec.tap \
+self-check-report.sh \
+self-check-sanity.sh \
+self-check-seq.tap \
+self-check-is-blocked-signal.tap \
+self-check-tap.sh \
+self-check-unindent.tap \
+sanity.sh \
+scripts.sh \
+seenc.sh \
+silent.sh \
+silent2.sh \
+silent3.sh \
+silent4.sh \
+silent6.sh \
+silent7.sh \
+silent8.sh \
+silent9.sh \
+silentcxx.sh \
+silentcxx-gcc.sh \
+silentf77.sh \
+silentf90.sh \
+silent-amopts.sh \
+silent-many-gcc.sh \
+silent-many-generic.sh \
+silent-nowarn.sh \
+silent-configsite.sh \
+silent-nested-vars.sh \
+silent-lex.sh \
+silent-yacc.sh \
+silent-yacc-headers.sh \
+srcsub.sh \
+srcsub2.sh \
+space.sh \
+specflg.sh \
+specflg2.sh \
+specflg3.sh \
+specflg6.sh \
+specflg7.sh \
+specflg8.sh \
+specflg9.sh \
+specflg10.sh \
+specflg-dummy.sh \
+spell.sh \
+spell2.sh \
+spell3.sh \
+spelling.sh \
+spy.sh \
+spy-rm.tap \
+stdinc.sh \
+stamph2.sh \
+stdlib.sh \
+stdlib2.sh \
+strictness-override.sh \
+strictness-precedence.sh \
+strip.sh \
+strip2.sh \
+strip3.sh \
+subdir.sh \
+subdir2.sh \
+subdir3.sh \
+subdir4.sh \
+subdir5.sh \
+subdir6.sh \
+subdir7.sh \
+subdir8.sh \
+subdir9.sh \
+subdir10.sh \
+subdirbuiltsources.sh \
+subcond.sh \
+subcond2.sh \
+subcond3.sh \
+subobj.sh \
+subobj2.sh \
+subobj4.sh \
+subobj5.sh \
+subobj6.sh \
+subobj7.sh \
+subobj8.sh \
+subobj9.sh \
+subobj10.sh \
+subobj11a.sh \
+subobj11b.sh \
+subobj11c.sh \
+subobjname.sh \
+subpkg.sh \
+subpkg2.sh \
+subpkg3.sh \
+subpkg4.sh \
+subpkg-yacc.sh \
+subst.sh \
+subst3.sh \
+subst4.sh \
+subst5.sh \
+subst-no-trailing-empty-line.sh \
+substref.sh \
+substre2.sh \
+substtarg.sh \
+suffix.sh \
+suffix2.sh \
+suffix3.tap \
+suffix4.sh \
+suffix5.sh \
+suffix6.sh \
+suffix6b.sh \
+suffix6c.sh \
+suffix7.sh \
+suffix8.tap \
+suffix9.sh \
+suffix10.tap \
+suffix11.tap \
+suffix12.sh \
+suffix13.sh \
+suffix-chain.tap \
+symlink.sh \
+symlink2.sh \
+syntax.sh \
+tap-ambiguous-directive.sh \
+tap-autonumber.sh \
+tap-bailout.sh \
+tap-bailout-leading-space.sh \
+tap-bailout-and-logging.sh \
+tap-bailout-suppress-badexit.sh \
+tap-bailout-suppress-later-diagnostic.sh \
+tap-bailout-suppress-later-errors.sh \
+tap-color.sh \
+tap-deps.sh \
+tap-diagnostic.sh \
+tap-empty-diagnostic.sh \
+tap-empty.sh \
+tap-escape-directive.sh \
+tap-escape-directive-2.sh \
+tap-exit.sh \
+tap-signal.tap \
+tap-fancy.sh \
+tap-fancy2.sh \
+tap-global-log.sh \
+tap-global-result.sh \
+tap-log.sh \
+tap-msg0-result.sh \
+tap-msg0-directive.sh \
+tap-msg0-planskip.sh \
+tap-msg0-bailout.sh \
+tap-msg0-misc.sh \
+tap-merge-stdout-stderr.sh \
+tap-no-merge-stdout-stderr.sh \
+tap-no-disable-hard-error.sh \
+tap-no-spurious-summary.sh \
+tap-no-spurious-numbers.sh \
+tap-no-spurious.sh \
+tap-not-ok-skip.sh \
+tap-number-wordboundary.sh \
+tap-numeric-description.sh \
+tap-negative-numbers.sh \
+tap-numbers-leading-zero.sh \
+tap-out-of-order.sh \
+tap-passthrough.sh \
+tap-passthrough-exit.sh \
+tap-plan.sh \
+tap-plan-corner.sh \
+tap-plan-errors.sh \
+tap-plan-middle.sh \
+tap-plan-whitespace.sh \
+tap-plan-leading-zero.sh \
+tap-plan-malformed.sh \
+tap-missing-plan-and-bad-exit.sh \
+tap-planskip.sh \
+tap-planskip-late.sh \
+tap-planskip-and-logging.sh \
+tap-planskip-unplanned.sh \
+tap-planskip-unplanned-corner.sh \
+tap-planskip-case-insensitive.sh \
+tap-planskip-whitespace.sh \
+tap-planskip-badexit.sh \
+tap-planskip-bailout.sh \
+tap-planskip-later-errors.sh \
+tap-realtime.sh \
+tap-test-number-0.sh \
+tap-recheck-logs.sh \
+tap-result-comment.sh \
+tap-todo-skip-together.sh \
+tap-todo-skip-whitespace.sh \
+tap-todo-skip.sh \
+tap-unplanned.sh \
+tap-whitespace-normalization.sh \
+tap-with-and-without-number.sh \
+tap-xfail-tests.sh \
+tap-common-setup.sh \
+tap-bad-prog.tap \
+tap-basic.sh \
+tap-diagnostic-custom.sh \
+tap-driver-stderr.sh \
+tap-doc.sh \
+tap-doc2.sh \
+tap-more.sh \
+tap-more2.sh \
+tap-recheck.sh \
+tap-summary.sh \
+tap-summary-color.sh \
+tags.sh \
+tags2.sh \
+tagsub.sh \
+tar.sh \
+tar2.sh \
+tar3.sh \
+tar-override.sh \
+target-cflags.sh \
+targetclash.sh \
+tests-environment-fd-redirect.sh \
+tests-environment-and-log-compiler.sh \
+txinfo.sh \
+txinfo2.sh \
+txinfo3.sh \
+txinfo4.sh \
+txinfo5.sh \
+txinfo5b.sh \
+txinfo6.sh \
+txinfo7.sh \
+txinfo8.sh \
+txinfo9.sh \
+txinfo10.sh \
+txinfo13.sh \
+txinfo16.sh \
+txinfo17.sh \
+txinfo19.sh \
+txinfo20.sh \
+txinfo21.sh \
+txinfo22.sh \
+txinfo23.sh \
+txinfo24.sh \
+txinfo25.sh \
+txinfo26.sh \
+txinfo27.sh \
+txinfo28.sh \
+txinfo29.sh \
+txinfo30.sh \
+txinfo31.sh \
+txinfo32.sh \
+txinfo33.sh \
+txinfo-no-clutter.sh \
+txinfo-unrecognized-extension.sh \
+transform.sh \
+transform2.sh \
+transform3.sh \
+uninstall-fail.sh \
+uninstall-pr9578.sh \
+unused.sh \
+upc.sh \
+upc2.sh \
+upc3.sh \
+vala.sh \
+vala1.sh \
+vala2.sh \
+vala3.sh \
+vala4.sh \
+vala5.sh \
+vala-vpath.sh \
+vala-mix.sh \
+vala-mix2.sh \
+vars.sh \
+vars3.sh \
+vartar.sh \
+vartypos.sh \
+vartypo2.sh \
+version.sh \
+version2.sh \
+version3.sh \
+version4.sh \
+version6.sh \
+version7.sh \
+version8.sh \
+vpath.sh \
+vtexi.sh \
+vtexi2.sh \
+vtexi3.sh \
+vtexi4.sh \
+warnings-override.sh \
+warnings-precedence.sh \
+warnings-strictness-interactions.sh \
+warnings-unknown.sh \
+warnopts.sh \
+warnings-win-over-strictness.sh \
+warning-groups-win-over-strictness.sh \
+werror.sh \
+werror2.sh \
+werror3.sh \
+werror4.sh \
+whoami.sh \
+xsource.sh \
+yacc.sh \
+yacc2.sh \
+yacc4.sh \
+yacc5.sh \
+yacc7.sh \
+yacc8.sh \
+yaccdry.sh \
+yaccpp.sh \
+yaccvpath.sh \
+yacc-auxdir.sh \
+yacc-basic.sh \
+yacc-cxx.sh \
+yacc-bison-skeleton-cxx.sh \
+yacc-bison-skeleton.sh \
+yacc-clean.sh \
+yacc-clean-cxx.sh \
+yacc-d-basic.sh \
+yacc-d-cxx.sh \
+yacc-d-vpath.sh \
+yacc-deleted-headers.sh \
+yacc-depend.sh \
+yacc-depend2.sh \
+yacc-dist-nobuild-subdir.sh \
+yacc-dist-nobuild.sh \
+yacc-line.sh \
+yacc-mix-c-cxx.sh \
+yacc-nodist.sh \
+yacc-pr204.sh \
+yacc-weirdnames.sh \
+yflags.sh \
+yflags2.sh \
+yflags-cmdline-override.sh \
+yflags-conditional.sh \
+yflags-d-false-positives.sh \
+yflags-force-conditional.sh \
+yflags-force-override.sh \
+yflags-var-expand.sh \
+libtool-macros.sh \
+gettext-macros.sh
+
+print-list-of-tests:
+ @echo $(handwritten_TESTS)
+.PHONY: print-list-of-tests
diff --git a/t/listval.sh b/t/listval.sh
new file mode 100755
index 000000000..5e2f9a64c
--- /dev/null
+++ b/t/listval.sh
@@ -0,0 +1,46 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test to make sure variable is expanded properly.
+# From Adam J. Richter.
+
+required=libtool
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_SUBST([LTLIBOBJS])
+AM_PROG_AR
+AC_PROG_LIBTOOL
+END
+
+cat > Makefile.am << 'END'
+lib_LTLIBRARIES = libpanel_applet.la
+libpanel_applet_la_SOURCES = \
+ applet-widget.c
+libpanel_applet_la_LDFLAGS = -version-info 0:1:0 -rpath $(libdir)
+libpanel_applet_la_LIBADD = -lm
+END
+
+: > ltconfig
+: > ltmain.sh
+: > ar-lib
+: > config.guess
+: > config.sub
+
+$ACLOCAL
+$AUTOMAKE
+
+:
diff --git a/t/location.sh b/t/location.sh
new file mode 100755
index 000000000..e496ca6b6
--- /dev/null
+++ b/t/location.sh
@@ -0,0 +1,97 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Test for locations in error messages.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AM_CONDITIONAL([COND1], [true])
+AM_CONDITIONAL([COND2], [true])
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_RANLIB
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = libfoo.a
+if COND2
+ lib_LIBRARIES = libfoo.a
+endif
+if COND1
+ bin_PROGRAMS += ctags
+endif
+VAR = 1 \
+ 2 \
+ 3
+
+VAR = 1 \
+ 2 \
+ 3
+END
+
+: > ar-lib
+
+# Smash the useless difference of lib file locations.
+smash_useless_diffs ()
+{
+ # FIXME: we could get rid of the second 's|||' once we improve our
+ # wrapper scripts ...
+ sed -e "s|^$am_amdir/\\([a-z]*\.am\\)|\\1|" \
+ -e "s|^automake-$APIVERSION:|automake:|" ${1+"$@"};
+}
+
+$ACLOCAL
+AUTOMAKE_fails -Wno-error
+
+smash_useless_diffs stderr >observed
+
+cat >expected <<\EOF
+Makefile.am:12: warning: VAR multiply defined in condition TRUE ...
+Makefile.am:8: ... 'VAR' previously defined here
+automake: error: libfoo_a_OBJECTS should not be defined
+Makefile.am:3: while processing library 'libfoo.a'
+automake: error: use 'libfoo_a_LDADD', not 'libfoo_a_LIBADD'
+Makefile.am:3: while processing library 'libfoo.a'
+library.am: warning: deprecated feature: target 'libfoo.a' overrides 'libfoo.a$(EXEEXT)'
+library.am: change your target to read 'libfoo.a$(EXEEXT)'
+Makefile.am:3: while processing library 'libfoo.a'
+program.am: target 'libfoo.a$(EXEEXT)' was defined here
+Makefile.am:1: while processing program 'libfoo.a'
+program.am: warning: redefinition of 'libfoo.a$(EXEEXT)' ...
+Makefile.am:1: while processing program 'libfoo.a'
+library.am: ... 'libfoo.a' previously defined here
+Makefile.am:3: while processing library 'libfoo.a'
+tags.am: warning: redefinition of 'ctags' ...
+program.am: ... 'ctags$(EXEEXT)' previously defined here
+Makefile.am:6: while processing program 'ctags'
+EOF
+
+cat expected
+cat observed
+diff expected observed || Exit 1
+
+AUTOMAKE_fails -Werror
+smash_useless_diffs stderr >observed
+(echo 'automake: warnings are treated as errors' && cat expected) > t
+mv -f t expected
+
+cat expected
+cat observed
+
+diff expected observed || Exit 1
+
+:
diff --git a/t/longlin2.sh b/t/longlin2.sh
new file mode 100755
index 000000000..1ba8072f3
--- /dev/null
+++ b/t/longlin2.sh
@@ -0,0 +1,48 @@
+#! /bin/sh
+# Copyright (C) 2005-2012 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/>.
+
+# Long lines should be wrapped.
+# Report from Albert Chin.
+
+. ./defs || Exit 1
+
+n=1
+files=
+match=
+while test $n -le 100
+do
+ files="$files filename$n"
+ match="..........$match"
+ n=`expr $n + 1`
+done
+files2=`echo "$files" | sed s/filename/filenameb/g`
+
+cat >Makefile.am <<EOF
+FOO = $files $files2 \
+ grepme
+EOF
+
+# The 'FOO = ...' line is 2293-byte long. More than what a POSIX
+# conformant system is expected to support. So do not use grep
+# on the non-text file.
+
+# grep $match Makefile.am
+
+$ACLOCAL
+$AUTOMAKE
+
+grep $match Makefile.in && Exit 1
+grep 'filenameb100 grepme' Makefile.in
diff --git a/t/longline.sh b/t/longline.sh
new file mode 100755
index 000000000..dd5664d31
--- /dev/null
+++ b/t/longline.sh
@@ -0,0 +1,30 @@
+#! /bin/sh
+# Copyright (C) 2004-2012 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/>.
+
+# Long lines of += should be wrapped.
+# Report from Simon Josefsson.
+
+. ./defs || Exit 1
+
+(echo DUMMY = some_long_filename_1;
+for i in 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20;
+do
+ echo DUMMY += some_long_filename_$i
+done) > Makefile.am
+
+$ACLOCAL
+$AUTOMAKE
+test 80 -ge `grep DUMMY Makefile.in | wc -c`
diff --git a/t/ltcond.sh b/t/ltcond.sh
new file mode 100755
index 000000000..d5098ea9b
--- /dev/null
+++ b/t/ltcond.sh
@@ -0,0 +1,105 @@
+#!/bin/sh
+# Copyright (C) 2003-2012 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/>.
+
+# Test for conditional libtool libraries.
+# This combines two examples from the manual.
+
+required='cc libtoolize'
+. ./defs || Exit 1
+
+cat >>configure.ac <<'END'
+AM_CONDITIONAL([WANT_LIBFOO], [true])
+AM_CONDITIONAL([WANT_LIBBAR], [false])
+AC_SUBST([WANTEDLIBS], ['lib1foo.la lib1bar.la'])
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_LIBTOOL
+AC_OUTPUT
+END
+
+cat >Makefile.am <<'END'
+EXTRA_LTLIBRARIES = lib1foo.la lib1bar.la lib3bar.la
+lib_LTLIBRARIES = $(WANTEDLIBS)
+lib1foo_la_SOURCES = foo.c
+lib1foo_la_LDFLAGS = -rpath '$(libdir)'
+lib1bar_la_SOURCES = bar.c
+lib1bar_la_LDFLAGS = -rpath '$(libdir)'
+lib3bar_la_SOURCES = bar.c
+
+if WANT_LIBFOO
+lib_LTLIBRARIES += lib2foo.la
+check_LTLIBRARIES = lib3foo.la
+endif
+if WANT_LIBBAR
+lib_LTLIBRARIES += lib2bar.la
+endif
+lib2foo_la_SOURCES = foo.c
+lib2bar_la_SOURCES = bar.c
+lib3foo_la_SOURCES = foo.c
+END
+
+echo 'int one () { return 1; }' >foo.c
+echo 'int two () { return 2; }' >bar.c
+
+mkdir empty
+
+libtoolize
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+# Install libraries in lib/, and the rest in empty/.
+# (in fact there is no "rest", so as the name imply empty/ is
+# expected to remain empty).
+./configure "--prefix=`pwd`/empty" "--libdir=`pwd`/lib"
+
+$MAKE
+test -f lib1foo.la
+test -f lib1bar.la
+test -f lib2foo.la
+test ! -f lib2bar.la
+test ! -f lib3foo.la
+test ! -f lib3bar.la
+
+$MAKE check
+test ! -f lib2bar.la
+test -f lib3foo.la
+test ! -f lib3bar.la
+
+$MAKE install
+test -f lib/lib1foo.la
+test -f lib/lib1bar.la
+test -f lib/lib2foo.la
+test ! -f lib/lib3foo.la
+find empty -type f -print > empty.lst
+cat empty.lst
+test 0 = `wc -l < empty.lst`
+
+$MAKE uninstall
+find lib -type f -print > lib.lst
+test 0 = `wc -l < lib.lst`
+test -f lib1foo.la
+test -f lib1bar.la
+test -f lib2foo.la
+test -f lib3foo.la
+
+$MAKE clean
+test ! -f lib1foo.la
+test ! -f lib1bar.la
+test ! -f lib2foo.la
+test ! -f lib3foo.la
+
+:
diff --git a/t/ltcond2.sh b/t/ltcond2.sh
new file mode 100755
index 000000000..4a7239483
--- /dev/null
+++ b/t/ltcond2.sh
@@ -0,0 +1,97 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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/>.
+
+# Test for bug in conditionals.
+
+required='cc native libtoolize'
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_LIBTOOL
+AC_SUBST([HELLO_SYSTEM], [hello-generic.lo])
+AM_CONDITIONAL([LINUX], [true])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+lib_LTLIBRARIES = libhello.la
+libhello_la_SOURCES = hello-common.c
+EXTRA_libhello_la_SOURCES = hello-linux.c hello-generic.c
+libhello_la_LIBADD = $(HELLO_SYSTEM)
+libhello_la_DEPENDENCIES = $(HELLO_SYSTEM)
+
+lib_LTLIBRARIES += libhello2.la
+libhello2_la_SOURCES = hello-common.c
+if LINUX
+libhello2_la_SOURCES += hello-linux.c
+else
+libhello2_la_SOURCES += hello-generic.c
+endif
+
+bin_PROGRAMS = hello hello2
+hello_SOURCES = main.c
+hello_LDADD = libhello.la
+hello2_SOURCES = main.c
+hello2_LDADD = libhello2.la
+
+check-local:
+ ./hello$(EXEEXT) | grep hello-generic
+ ./hello2$(EXEEXT) | grep hello-linux
+ : > check-ok
+END
+
+cat > hello-linux.c <<'END'
+const char* str (void)
+{
+ return "hello-linux";
+}
+END
+
+cat > hello-generic.c <<'END'
+const char* str (void)
+{
+ return "hello-generic";
+}
+END
+
+cat > hello-common.c <<'END'
+#include <stdio.h>
+const char* str (void);
+void print (void)
+{
+ puts (str ());
+}
+END
+
+cat > main.c <<'END'
+int main (void)
+{
+ print();
+ return 0;
+}
+END
+
+libtoolize
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+./configure
+$MAKE check
+test -f check-ok
+
+:
diff --git a/t/ltconv.sh b/t/ltconv.sh
new file mode 100755
index 000000000..19ed8b34b
--- /dev/null
+++ b/t/ltconv.sh
@@ -0,0 +1,156 @@
+#!/bin/sh
+# Copyright (C) 2003-2012 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/>.
+
+# Test for libtool convenience libraries.
+# This example is taken from the manual.
+
+required='cc native libtoolize'
+. ./defs || Exit 1
+
+cat >>configure.ac <<'END'
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_LIBTOOL
+AC_CONFIG_FILES([sub1/Makefile
+ sub2/Makefile
+ sub2/sub21/Makefile
+ sub2/sub22/Makefile])
+AC_OUTPUT
+END
+
+mkdir sub1
+mkdir sub2
+mkdir sub2/sub21
+mkdir sub2/sub22
+mkdir empty
+
+cat >Makefile.am <<'END'
+SUBDIRS = sub1 sub2
+lib_LTLIBRARIES = libtop.la
+libtop_la_SOURCES =
+libtop_la_LIBADD = \
+ sub1/libsub1.la \
+ sub2/libsub2.la
+
+bin_PROGRAMS = ltconvtest
+ltconvtest_SOURCES = test.c
+ltconvtest_LDADD = libtop.la
+
+check-local:
+ ./ltconvtest$(EXEEXT)
+ : > check-ok
+installcheck-local:
+ $(bindir)/ltconvtest$(EXEEXT)
+ : > installcheck-ok
+END
+
+cat >sub1/Makefile.am <<'END'
+noinst_LTLIBRARIES = libsub1.la
+libsub1_la_SOURCES = sub1.c
+END
+
+echo 'int sub1 () { return 1; }' > sub1/sub1.c
+
+cat >sub2/Makefile.am <<'END'
+SUBDIRS = sub21 sub22
+noinst_LTLIBRARIES = libsub2.la
+libsub2_la_SOURCES = sub2.c
+libsub2_la_LIBADD = \
+ sub21/libsub21.la \
+ sub22/libsub22.la
+END
+
+echo 'int sub2 () { return 2; }' > sub2/sub2.c
+
+cat >sub2/sub21/Makefile.am <<'END'
+noinst_LTLIBRARIES = libsub21.la
+libsub21_la_SOURCES = sub21.c
+END
+
+echo 'int sub21 () { return 21; }' > sub2/sub21/sub21.c
+
+cat >sub2/sub22/Makefile.am <<'END'
+noinst_LTLIBRARIES = libsub22.la
+libsub22_la_SOURCES = sub22.c
+END
+
+echo 'int sub22 () { return 22; }' > sub2/sub22/sub22.c
+
+cat >test.c <<'EOF'
+#include <stdio.h>
+int main ()
+{
+ if (1 != sub1 ())
+ return 1;
+ if (2 != sub2 ())
+ return 2;
+ if (21 != sub21 ())
+ return 3;
+ if (22 != sub22 ())
+ return 4;
+ return 0;
+}
+EOF
+
+libtoolize
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+# Install libraries in lib/, programs in bin/, and the rest in empty/.
+# (in fact there is no "rest", so as the name imply empty/ is
+# expected to remain empty).
+./configure "--prefix=`pwd`/empty" "--libdir=`pwd`/lib" "--bindir=`pwd`/bin"
+
+$MAKE
+test -f libtop.la
+test -f sub1/libsub1.la
+test -f sub2/libsub2.la
+test -f sub2/sub21/libsub21.la
+test -f sub2/sub22/libsub22.la
+$MAKE check
+test -f check-ok
+rm -f check-ok
+
+$MAKE install
+test -f lib/libtop.la
+$MAKE installcheck
+test -f installcheck-ok
+rm -f installcheck-ok
+
+find empty -type f -print > empty.lst
+cat empty.lst
+test 0 = `wc -l < empty.lst`
+
+$MAKE clean
+test ! -f libtop.la
+test ! -f sub1/libsub1.la
+test ! -f sub2/libsub2.la
+test ! -f sub2/sub21/libsub21.la
+test ! -f sub2/sub22/libsub22.la
+test ! -f ltconvtest
+
+$MAKE installcheck
+test -f installcheck-ok
+rm -f installcheck-ok
+
+$MAKE uninstall
+find lib -type f -print > lib.lst
+test 0 = `wc -l < lib.lst`
+find bin -type f -print > bin.lst
+test 0 = `wc -l < bin.lst`
+
+:
diff --git a/t/ltdeps.sh b/t/ltdeps.sh
new file mode 100755
index 000000000..100d045e9
--- /dev/null
+++ b/t/ltdeps.sh
@@ -0,0 +1,61 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test to make sure libtool library dependencies are correct.
+# Report from Lars J. Aas.
+required=libtool
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AM_PROG_AR
+AC_PROG_LIBTOOL
+AC_PROG_CXX
+AM_CONDITIONAL(HACKING_COMPACT_BUILD, whatever)
+END
+
+cat > Makefile.am << 'END'
+RegularSources = \
+ SbBSPTree.cpp \
+ SbBox2f.cpp \
+ SbBox2s.cpp
+
+LinkHackSources = \
+ all.cpp
+
+if HACKING_COMPACT_BUILD
+BuildSources = $(LinkHackSources)
+else
+BuildSources = $(RegularSources)
+endif
+
+noinst_LTLIBRARIES = libbase.la
+libbase_la_SOURCES = $(BuildSources)
+
+EXTRA_libbase_la_SOURCES = \
+ $(RegularSources) $(LinkHackSources)
+END
+
+: > ltconfig
+: > ltmain.sh
+: > ar-lib
+: > config.guess
+: > config.sub
+
+$ACLOCAL
+$AUTOMAKE
+
+grep 'OBJECTS =$' Makefile.in && Exit 1
+Exit 0
diff --git a/t/ltinit.sh b/t/ltinit.sh
new file mode 100755
index 000000000..49ddbe0f8
--- /dev/null
+++ b/t/ltinit.sh
@@ -0,0 +1,67 @@
+#!/bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Test that libtool support works correctly when "newer" libtool
+# interface (with LT_INIT etc.) is used (this interface has been
+# present since libtool 1.9b, circa 2004).
+
+required='cc libtoolize'
+. ./defs || Exit 1
+
+cat >>configure.ac <<'END'
+AC_PROG_CC
+AM_PROG_AR
+dnl Older libtool versions don't define LT_PREREQ :-(
+m4_ifdef([LT_PREREQ],
+ [LT_PREREQ([2.0])],
+ [m4_fatal([Libtool version too old], [63])])
+LT_INIT([dlopen])
+AC_OUTPUT
+END
+
+cat >Makefile.am <<'END'
+lib_LTLIBRARIES = libfoo.la
+END
+
+cat > libfoo.c <<'END'
+int foo (void)
+{
+ return 1;
+}
+END
+
+libtoolize
+# Skip if older libtool (pre-2.0) is used.
+{ $ACLOCAL && $AUTOCONF; } || {
+ if test $? -eq 63; then
+ skip_ "libtool is too old (probably < 2.0)"
+ else
+ Exit 1
+ fi
+}
+$EGREP 'LT_(INIT|PREREQ)' configure && Exit 1 # Sanity check.
+$AUTOMAKE -a
+
+cwd=`pwd`
+./configure --prefix="$cwd/inst" >stdout || { cat stdout; Exit 1; }
+cat stdout
+grep '^checking.*dlfcn\.h.* no$' stdout || grep '^checking.*dlopen' stdout
+
+$MAKE
+$MAKE install
+$MAKE distcheck
+
+:
diff --git a/t/ltinstloc.sh b/t/ltinstloc.sh
new file mode 100755
index 000000000..690699449
--- /dev/null
+++ b/t/ltinstloc.sh
@@ -0,0 +1,68 @@
+#!/bin/sh
+# Copyright (C) 2008-2012 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/>.
+
+# Test for libtool errors for multiple install locations, esp. with nobase.
+
+
+required='libtoolize'
+. ./defs || Exit 1
+
+cat >>configure.ac <<'END'
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_LIBTOOL
+AM_CONDITIONAL([COND], [:])
+AC_OUTPUT
+END
+
+cat >Makefile.am <<'END'
+if COND
+lib_LTLIBRARIES = liba1.la sub/liba2.la
+#else
+pkglib_LTLIBRARIES = liba1.la
+nobase_lib_LTLIBRARIES = sub/liba2.la
+endif
+END
+
+libtoolize
+$ACLOCAL
+$AUTOCONF
+AUTOMAKE_fails --add-missing
+
+# libtoolize might have installed config.guess and config.sub already,
+# and autom4te might warn about bugs in Libtool macro files, so filter
+# out warnings about Makefile.am only. We don't care in this test
+# whether automake installs config.guess, config.sub and ar-lib.
+
+cat >expected <<'END'
+Makefile.am:5: error: sub/liba2.la multiply defined in condition COND
+Makefile.am:5: 'sub/liba2.la' should be installed below 'lib' in condition COND ...
+Makefile.am:2: ... and should also be installed in 'lib' in condition COND.
+Makefile.am:4: error: liba1.la multiply defined in condition COND
+Makefile.am:4: 'liba1.la' should be installed in 'pkglib' in condition COND ...
+Makefile.am:2: ... and should also be installed in 'lib' in condition COND.
+Makefile.am:2: Libtool libraries can be built for only one destination
+END
+
+grep '^Makefile.am' stderr | diff - expected
+
+sed 's/#//' < Makefile.am > t
+mv -f t Makefile.am
+
+$AUTOMAKE
+grep ' -rpath \$(libdir)/sub' Makefile.in
+
+:
diff --git a/t/ltlibobjs.sh b/t/ltlibobjs.sh
new file mode 100755
index 000000000..5cdccf09b
--- /dev/null
+++ b/t/ltlibobjs.sh
@@ -0,0 +1,43 @@
+#! /bin/sh
+# Copyright (C) 1999-2012 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/>.
+
+# Test to make sure LTLIBOBJS alone works ok.
+# Report from Vadim Zeitlin.
+required=libtool
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_SUBST([LTLIBOBJS])
+AM_PROG_AR
+AC_PROG_LIBTOOL
+END
+
+cat > Makefile.am << 'END'
+lib_LTLIBRARIES = libtu.la
+libtu_la_SOURCES = foo.c
+libtu_la_LIBADD = @LTLIBOBJS@
+END
+
+: > ltconfig
+: > ltmain.sh
+: > ar-lib
+: > config.guess
+: > config.sub
+
+$ACLOCAL
+$AUTOMAKE
+
+:
diff --git a/t/ltlibsrc.sh b/t/ltlibsrc.sh
new file mode 100755
index 000000000..11e2a1d56
--- /dev/null
+++ b/t/ltlibsrc.sh
@@ -0,0 +1,74 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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/>.
+
+# Test to make sure a sensible default source for libraries is used.
+
+required='cc libtool'
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_LIBTOOL
+AC_OUTPUT
+END
+
+mkdir zoo.d
+
+cat > Makefile.am << 'END'
+AM_LDFLAGS = -module
+pkglib_LTLIBRARIES = zoo.d/bar.la old.la
+noinst_LTLIBRARIES = foo.la zoo.d/old2.la
+
+$(srcdir)/zoo_d_old2_la.c: $(srcdir)/old_la.c
+ cp $(srcdir)/old_la.c $@
+END
+
+cat > foo.c << 'END'
+int foo (void)
+{
+ return 0;
+}
+END
+
+cp foo.c zoo.d/bar.c
+cp foo.c old_la.c
+
+libtoolize
+$ACLOCAL
+$AUTOCONF
+AUTOMAKE_fails -a
+grep '^Makefile\.am:2:.*old_la\.c' stderr
+grep '^Makefile\.am:2:.*old\.c' stderr
+grep '^Makefile\.am:3:.*zoo_d_old2_la\.c' stderr
+grep '^Makefile\.am:3:.*zoo\.d/old2\.c' stderr
+
+$AUTOMAKE -Wno-obsolete
+
+mkdir sub
+cd sub
+
+../configure
+$MAKE
+
+test -f foo.la
+test -f zoo.d/bar.la
+test -f old.la
+test -f zoo.d/old2.la
+
+$MAKE distcheck
+
+:
diff --git a/t/ltorder.sh b/t/ltorder.sh
new file mode 100755
index 000000000..358e620fe
--- /dev/null
+++ b/t/ltorder.sh
@@ -0,0 +1,62 @@
+#!/bin/sh
+# Copyright (C) 2008-2012 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/>.
+
+# Test for correct installation order of nobase libtool libraries.
+
+required='cc libtoolize'
+. ./defs || Exit 1
+
+cat >>configure.ac <<'END'
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_LIBTOOL
+AC_OUTPUT
+END
+
+cat >Makefile.am <<'END'
+nobase_lib_LTLIBRARIES = liba1.la sub/liba2.la sub/liba3.la liba4.la liba5.la
+sub_liba2_la_LIBADD = liba1.la
+sub_liba3_la_LIBADD = sub/liba2.la
+liba4_la_LIBADD = sub/liba3.la
+liba5_la_LIBADD = liba4.la
+bin_PROGRAMS = p
+p_LDADD = liba5.la
+END
+
+mkdir sub
+echo 'int a1 () { return 1; }' >liba1.c
+echo 'extern int a1 (); int a2 () { return a1 (); }' >sub/liba2.c
+echo 'extern int a2 (); int a3 () { return a2 (); }' >sub/liba3.c
+echo 'extern int a3 (); int a4 () { return a3 (); }' >liba4.c
+echo 'extern int a4 (); int a5 () { return a4 (); }' >liba5.c
+echo 'extern int a5 (); int main () { return a5 (); }' >p.c
+
+libtoolize
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+./configure "--prefix=`pwd`/inst"
+
+$MAKE
+$MAKE install 2>stderr || { cat stderr >&2; Exit 1; }
+cat stderr >&2
+grep 'has not been installed' stderr && Exit 1
+
+$MAKE uninstall
+test `find inst -type f -print | wc -l` -eq 0
+
+:
diff --git a/t/lzma.sh b/t/lzma.sh
new file mode 100755
index 000000000..8e78f8683
--- /dev/null
+++ b/t/lzma.sh
@@ -0,0 +1,41 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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/>.
+
+# Check support for no-dist-gzip with lzma.
+
+. ./defs || Exit 1
+
+errmsg='support for lzma.*removed'
+
+echo AUTOMAKE_OPTIONS = dist-lzma > Makefile.am
+$ACLOCAL --force
+AUTOMAKE_fails -Wnone -Wno-error
+grep "^Makefile\\.am:1:.*$errmsg" stderr
+
+cat > configure.ac << 'END'
+AC_INIT([lzma], [1.0])
+AM_INIT_AUTOMAKE([no-dist-gzip dist-lzma])
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+END
+: > Makefile.am
+
+rm -rf autom4te*.cache
+$ACLOCAL
+AUTOMAKE_fails -Wnone -Wno-error
+grep "^configure\\.ac:2:.*$errmsg" stderr
+
+:
diff --git a/t/m4-inclusion.sh b/t/m4-inclusion.sh
new file mode 100755
index 000000000..52dae22a0
--- /dev/null
+++ b/t/m4-inclusion.sh
@@ -0,0 +1,56 @@
+#! /bin/sh
+# Copyright (C) 1998-2012 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/>.
+
+# Test to see if 'm4_sinclude' and 'm4_include' works.
+
+. ./defs || Exit 1
+
+cat >> configure.ac <<'EOF'
+sinclude([doesntexist.m4])
+EOF
+
+mkdir sub
+
+cat > sub/p.m4 << 'END'
+AC_SUBST([MAGICALPIG])
+END
+
+cat > sub/h.m4 << 'END'
+AC_SUBST([MAGICALHOG])
+END
+
+cat > sub/g.m4 << 'END'
+AC_SUBST([GREPME])
+END
+
+: > Makefile.am
+
+echo 'sinclude([sub/g.m4])' >> acinclude.m4
+echo 'm4_sinclude([sub/doesntexist.m4])' >> acinclude.m4
+
+$ACLOCAL
+
+echo 'm4_sinclude([sub/p.m4])' >> aclocal.m4
+echo 'm4_include([sub/h.m4])' >> aclocal.m4
+
+$AUTOMAKE
+
+grep doesntexist Makefile.in && Exit 1
+grep MAGICALPIG Makefile.in
+grep MAGICALHOG Makefile.in
+grep GREPME Makefile.in
+
+:
diff --git a/t/maintclean-vpath.sh b/t/maintclean-vpath.sh
new file mode 100755
index 000000000..11e97a69f
--- /dev/null
+++ b/t/maintclean-vpath.sh
@@ -0,0 +1,104 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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 distclean and maintainer-clean erase the right files.
+# This test is for VPATH builds; see sister test 'maintclean.test'
+# for in-tree builds.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_CONFIG_FILES([bar sub/Makefile])
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+SUBDIRS = sub
+noinst_DATA = foo.c
+foo.c:
+ touch foo.c
+MAINTAINERCLEANFILES = foo.c
+END
+
+mkdir sub
+cat > sub/Makefile.am <<'END'
+noinst_SCRIPTS = zap
+zap: zap.sh
+ cp $(srcdir)/zap.sh $@ && chmod a+x $@
+MAINTAINERCLEANFILES = zap
+END
+
+: > bar.in
+: > sub/zap.sh
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+# Users can disable autom4te.cache.
+if test -d autom4te.cache; then
+ test_cache='test -d ../autom4te.cache'
+else
+ test_cache=:
+fi
+
+mkdir build
+
+chmod a-w . sub
+
+cd build
+
+../configure
+test -f bar
+
+$MAKE
+test -f foo.c
+test -f sub/zap
+$test_cache
+
+$MAKE distclean
+test ! -f bar
+test ! -f Makefile
+test ! -f sub/Makefile
+test ! -f config.status
+test -f foo.c
+test -f sub/zap
+test -f ../sub/zap.sh
+$test_cache
+
+../configure
+test -f bar
+
+$MAKE foo.c
+test -f foo.c
+cd sub
+$MAKE zap
+test -f zap
+cd ..
+
+chmod u+w ..
+
+$MAKE maintainer-clean
+test -f ../sub/zap.sh
+test ! -f bar
+test ! -f foo.c
+test ! -f sub/zap
+test ! -f Makefile
+test ! -f sub/Makefile
+test ! -f config.status
+test ! -d ../autom4te.cache
+
+:
diff --git a/t/maintclean.sh b/t/maintclean.sh
new file mode 100755
index 000000000..c5d3d0ef7
--- /dev/null
+++ b/t/maintclean.sh
@@ -0,0 +1,96 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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 distclean and maintainer-clean erase the right files.
+# This test is for in-tree builds; see sister test 'maintclean-vpath.test'
+# for VPATH builds.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_CONFIG_FILES([bar sub/Makefile])
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+SUBDIRS = sub
+noinst_DATA = foo.c
+foo.c:
+ touch foo.c
+MAINTAINERCLEANFILES = foo.c
+END
+
+mkdir sub
+cat > sub/Makefile.am <<'END'
+noinst_SCRIPTS = zap
+zap: zap.sh
+ cp $(srcdir)/zap.sh $@ && chmod a+x $@
+MAINTAINERCLEANFILES = zap
+END
+
+: > bar.in
+: > sub/zap.sh
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+# Users can disable autom4te.cache.
+if test -d autom4te.cache; then
+ test_cache='test -d autom4te.cache'
+else
+ test_cache=:
+fi
+
+./configure
+test -f bar
+
+$MAKE
+test -f foo.c
+test -f sub/zap
+$test_cache
+
+$MAKE distclean
+test ! -f bar
+test ! -f Makefile
+test ! -f sub/Makefile
+test ! -f config.status
+test -f foo.c
+test -f sub/zap
+test -f sub/zap.sh
+$test_cache
+
+./configure
+test -f bar
+
+$MAKE foo.c
+test -f foo.c
+cd sub
+$MAKE zap
+test -f zap
+cd ..
+
+$MAKE maintainer-clean
+test -f sub/zap.sh
+test ! -f bar
+test ! -f foo.c
+test ! -f sub/zap
+test ! -f Makefile
+test ! -f sub/Makefile
+test ! -f config.status
+test ! -d autom4te.cache
+
+:
diff --git a/t/maintmode-configure-msg.sh b/t/maintmode-configure-msg.sh
new file mode 100755
index 000000000..8a7c45104
--- /dev/null
+++ b/t/maintmode-configure-msg.sh
@@ -0,0 +1,73 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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 that our macro 'AM_MAINTAINER_MODE' adds proper text to
+# the configure help screen. Also make sure the "checking ..." messages
+# related to the enabling/disabling of maintainer mode are correct (see
+# automake bug#9890).
+
+. ./defs || Exit 1
+
+set_maintmode ()
+{
+ rm -rf autom4te*.cache # Just to be sure not to use a stale cache.
+ echo "AC_INIT([$me], [1.0])" > configure.ac
+ case $1 in
+ DEFAULT) echo AM_MAINTAINER_MODE;;
+ *) echo "AM_MAINTAINER_MODE([$*])";;
+ esac >> configure.ac
+}
+
+check_configure_message_with ()
+{
+ answer=$1; shift
+ ./configure ${1+"$@"} >stdout || { cat stdout; Exit 1; }
+ cat stdout
+ grep "^checking whether to enable maintainer-specific.*\\.\\.\\. $answer$" stdout
+ test `grep -c 'checking.*maint' stdout` -eq 1
+ :
+}
+
+set_maintmode "DEFAULT"
+
+$ACLOCAL
+
+$AUTOCONF --force
+
+grep_configure_help --enable-maintainer-mode 'enable make rules'
+
+check_configure_message_with "no"
+check_configure_message_with "yes" --enable-maintainer-mode
+
+set_maintmode "disable"
+
+$AUTOCONF --force
+grep_configure_help --enable-maintainer-mode 'enable make rules'
+
+check_configure_message_with "no"
+check_configure_message_with "yes" --enable-maintainer-mode
+
+set_maintmode "enable"
+
+$AUTOCONF --force
+./configure --help >stdout || { cat stdout; Exit 1; }
+cat stdout
+grep_configure_help --disable-maintainer-mode 'disable make rules'
+
+check_configure_message_with "yes"
+check_configure_message_with "no" --disable-maintainer-mode
+
+:
diff --git a/t/make-dryrun.tap b/t/make-dryrun.tap
new file mode 100755
index 000000000..37692059b
--- /dev/null
+++ b/t/make-dryrun.tap
@@ -0,0 +1,125 @@
+#! /bin/sh
+# Copyright (C) 2012 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/>.
+
+# Check that $(am__make_dryrun) works as expected.
+
+am_parallel_tests=yes # Avoid generation of a useless wrapper test.
+. ./defs || Exit 1
+
+plan_ 14
+
+if echo "all: ; @+printf %sbb%s aa cc" | $MAKE -n -f - | grep aabbcc; then
+ make_plus_silence () { return 0; }
+else
+ make_plus_silence () { return 1; }
+fi
+
+mkdir sub
+
+echo AC_OUTPUT >> configure.ac
+
+cat > Makefile.am <<'END'
+all:
+ : Dummy, nothing to do.
+foo:
+ $(MAKE) all
+notdry:
+ @echo ":: $$MAKEFLAGS ::"; : For debugging.
+ $(am__make_dryrun) && exit 1; exit 0
+dry:
+ +@echo ":: $$MAKEFLAGS ::"; : For debugging.
+ +$(am__make_dryrun) || exit 1; echo ok > from-dry-mode
+END
+
+$ACLOCAL || fatal_ "aclocal failed"
+$AUTOCONF || fatal_ "autoconf failed"
+$AUTOMAKE || fatal_ "automake failed"
+./configure || fatal_ "configure failed"
+
+# ----------------------------------------------------------------------
+
+check_no_dryrun ()
+{
+ command_ok_ "dry-run ($cnt)" $MAKE notdry ${1+"$@"}
+ cnt=`expr $cnt + 1`
+}
+cnt=1
+
+check_no_dryrun
+
+# Test against a known regression. This was especially heinous, since
+# make running in normal mode was sometimes mistaken for make running
+# in dry mode.
+check_no_dryrun TESTS="n1.test n2.test"
+check_no_dryrun TESTS="n1 n2" AM_MAKEFLAGS="TESTS='n1 n2'"
+check_no_dryrun TESTS="n1 n2" AM_MAKEFLAGS='TESTS="n1 n2"'
+check_no_dryrun FOOFLAGS="-n -n -knf2 n --none -n"
+check_no_dryrun MYFLAGS="-n --dryrun -n --dry-run -n"
+
+# ----------------------------------------------------------------------
+
+check_dryrun ()
+{
+ r=ok directive=
+ case $1 in
+ -C) condition=$2 reason=$3; shift; shift; shift;;
+ *) condition=: reason=;;
+ esac
+ if $condition; then
+ $MAKE dry ${1+"$@"} || r='not ok'
+ test -f from-dry-mode || r='not ok'
+ rm -f from-dry-mode || fatal_ "cleaning up"
+ else
+ directive=SKIP
+ fi
+ result_ "$r" -D "$directive" -r "$reason" "not dry-run ($cnt)"
+ unset r directive reason
+ cnt=`expr $cnt + 1`
+}
+cnt=1
+
+check_dryrun -C make_plus_silence 'recipe prefix "+" unsupported' -n
+check_dryrun -C using_gmake "\$MAKE is not GNU make" --dry-run -k
+
+# ----------------------------------------------------------------------
+
+# Test for when shell metacharacters or backslashes are in $(MAKEFLAGS).
+
+check_metachars ()
+{
+ r=ok
+ $MAKE notdry ${1+"$@"} || r='not ok'
+ if test -f bad; then
+ r='not ok'
+ else
+ rm -f bad || fatal_ "cleaning up"
+ fi
+ result_ "$r" "dry-run, with shell metachars ($cnt)"
+ unset r
+ cnt=`expr $cnt + 1`
+}
+cnt=1
+
+check_metachars MYFLAGS="-n \"n\" '-n' --none -n"
+check_metachars MYFLAGS='-knf2\ n\ \\n'
+check_metachars MYFLAGS="(&) | ; \" \` '"
+check_metachars MYFLAGS=" ' # ' "
+check_metachars MYFLAGS='$(foo)'
+check_metachars MYFLAGS='`touch bad`'
+
+# ----------------------------------------------------------------------
+
+:
diff --git a/t/make.sh b/t/make.sh
new file mode 100755
index 000000000..e292e38c7
--- /dev/null
+++ b/t/make.sh
@@ -0,0 +1,52 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test to make sure 'make' check works.
+# From Ralf Corsepius.
+
+required=GNUmake
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AM_MAKE_INCLUDE
+AC_OUTPUT
+END
+
+: > Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+export ACLOCAL
+export AUTOCONF
+export AUTOMAKE
+
+# Do the test twice -- once with make and once with make -w.
+# This tests for a bug reported by Rainer Orth (see PR 175).
+
+save="$MAKE"
+for flag in '' -w; do
+ MAKE="$save $flag" ./configure
+ $FGREP 'am__include = include' Makefile
+ $sleep
+ touch configure.ac
+ $MAKE $flag
+ $FGREP 'am__include = include' Makefile
+ rm -f config.cache
+done
+
+Exit 0
diff --git a/t/makefile-deps.sh b/t/makefile-deps.sh
new file mode 100755
index 000000000..83f3caeef
--- /dev/null
+++ b/t/makefile-deps.sh
@@ -0,0 +1,29 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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 we don't emit a rule with empty target if list of
+# automatically-computed dependencies for Makefile.in is empty.
+
+. ./defs || Exit 1
+
+: > Makefile.am
+
+$ACLOCAL
+$AUTOMAKE
+
+grep "^ *:" Makefile.in && Exit 1
+
+:
diff --git a/t/makej.sh b/t/makej.sh
new file mode 100755
index 000000000..64c5f28a9
--- /dev/null
+++ b/t/makej.sh
@@ -0,0 +1,53 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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 -j' used to fail with Autoconf < 2.58, because tools like
+# autoconf and automake can try to update autom4te's cache in parallel.
+#
+# Note that failures might not be reproducible systematically as they
+# depend on the time at which autoconf and automake update the cache
+# via autom4te.
+
+required=GNUmake
+. ./defs || Exit 1
+
+cat >configure.ac <<END
+m4_include([version.m4])
+AC_INIT([$me], [THE_VERSION])
+AM_INIT_AUTOMAKE
+AC_CONFIG_HEADER([config.h])
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+END
+
+echo 'm4_define([THE_VERSION], [2.718])' > version.m4
+
+: > Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOHEADER
+$AUTOMAKE --add-missing
+./configure --version | grep '2\.718'
+./configure
+$MAKE
+
+$sleep
+echo 'm4_define([THE_VERSION], [3.141])' > version.m4
+$MAKE -j
+./configure --version | grep '3\.141'
+
+:
diff --git a/t/makej2.sh b/t/makej2.sh
new file mode 100755
index 000000000..8183887a4
--- /dev/null
+++ b/t/makej2.sh
@@ -0,0 +1,44 @@
+#! /bin/sh
+# Copyright (C) 2009-2012 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/>.
+
+# Test to make sure known BSD 'make -jN' issues are fixed:
+# without -B, it may reuse the same shell for separate commands in a
+# rule, which can lead to interesting results.
+
+. ./defs || Exit 1
+
+cat >>configure.ac <<'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+test-distdir-removed:
+ test ! -d $(distdir)
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+mkdir build
+cd build
+../configure "--prefix=`pwd`/inst"
+
+$MAKE -j2 || skip_ "$MAKE failed to run with two parallel jobs"
+$MAKE -j2 distcheck
+$MAKE test-distdir-removed
+
+Exit 0
diff --git a/t/maken.sh b/t/maken.sh
new file mode 100755
index 000000000..bb6444461
--- /dev/null
+++ b/t/maken.sh
@@ -0,0 +1,62 @@
+#! /bin/sh
+# Copyright (C) 2009-2012 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/>.
+
+# Ensure that 'make -n dist' and 'make -n distcheck' do not change files
+# on disk, due to GNU make executing rules containing '$(MAKE)'.
+# Also, ensure that 'make -n dist' and 'make -n distcheck' show what
+# would happen, at least when using GNU make.
+
+. ./defs || Exit 1
+
+mkdir sub
+
+cat >> configure.ac << 'END'
+AC_CONFIG_FILES([sub/Makefile])
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+SUBDIRS = sub
+distcheck-hook:
+ @: > stamp-distcheck-hook
+test-no-distdir:
+ test ! -d $(distdir)
+ test ! -f stamp-distcheck-hook
+ test ! -f sub/stamp-sub-dist-hook
+END
+cat >sub/Makefile.am <<'END'
+dist-hook:
+ @: > stamp-sub-dist-hook
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+
+$sleep
+echo stamp > stampfile
+$sleep
+for target in dist distcheck; do
+ $MAKE -n $target
+ if using_gmake; then
+ $MAKE -n $target | grep stamp-sub-dist-hook || Exit 1
+ fi
+ $MAKE test-no-distdir
+ test `ls -1t | sed 1q` = stampfile
+done
+
+Exit 0
diff --git a/t/maken3.sh b/t/maken3.sh
new file mode 100755
index 000000000..2018549e5
--- /dev/null
+++ b/t/maken3.sh
@@ -0,0 +1,190 @@
+#! /bin/sh
+# Copyright (C) 2009-2012 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/>.
+
+# Test 'make -n' for various targets, to ensure that:
+#
+# 1. no files or directories are created or removed, and
+#
+# 2. if using GNU make or a make implementation supporting the .MAKE
+# special target, the output from make is sufficiently complete.
+#
+# This test exercises the GCS-mandated targets (except for dist)
+# as well as tags, TAGS.
+
+. ./defs || Exit 1
+
+# Does $MAKE support the '.MAKE' special target?
+have_dotmake=false
+if using_gmake; then
+ have_dotmake=: # GNU make must support it.
+else
+ unindent > mk.tmp << 'END'
+ targ.tmp:
+ : > $@
+ .MAKE: targ.tmp
+END
+ if $MAKE -n -f mk.tmp targ.tmp && test -f targ.tmp; then
+ have_dotmake=:
+ fi
+fi
+
+mkdir sub sub2
+
+cat >> configure.ac << 'END'
+AC_CONFIG_FILES([sub/Makefile sub2/Makefile])
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+TESTS = foo.test
+SUBDIRS = sub sub2
+##BUILT_SOURCES = foo
+foo:
+foo.test:
+all-local:
+ @: > stamp-all
+install-data-local:
+ @: > stamp-install
+uninstall-local:
+ @: > stamp-uninstall
+clean-local:
+ @: > stamp-clean
+distclean-local:
+ @: > stamp-distclean
+info-local:
+ @: > stamp-info
+html-local:
+ @: > stamp-html
+dvi-local:
+ @: > stamp-dvi
+ps-local:
+ @: > stamp-ps
+pdf-local:
+ @: > stamp-pdf
+check-local:
+ @: > stamp-check
+installcheck-local:
+ @: > stamp-installcheck
+mostlyclean-local:
+ @: > stamp-mostlyclean
+maintainer-clean-local:
+ @: > stamp-maintainer-clean
+END
+cat >sub/Makefile.am <<'END'
+all-local:
+ @: > stamp-all-sub
+install-data-local:
+ @: > stamp-install-sub
+uninstall-local:
+ @: > stamp-uninstall-sub
+clean-local:
+ @: > stamp-clean-sub
+distclean-local:
+ @: > stamp-distclean-sub
+info-local:
+ @: > stamp-info-sub
+html-local:
+ @: > stamp-html-sub
+dvi-local:
+ @: > stamp-dvi-sub
+ps-local:
+ @: > stamp-ps-sub
+pdf-local:
+ @: > stamp-pdf-sub
+check-local:
+ @: > stamp-check-sub
+installcheck-local:
+ @: > stamp-installcheck-sub
+tags:
+ @: > stamp-tags-sub
+TAGS:
+ @: > stamp-TAGS-sub
+mostlyclean-local:
+ @: > stamp-mostlyclean-sub
+maintainer-clean-local:
+ @: > stamp-maintainer-clean-sub
+END
+cat >sub2/Makefile.am <<'END'
+all install uninstall clean check:
+ @: > sub2-$@-should-not-be-executed
+info dvi pdf ps:
+ @: > sub2-$@-should-not-be-executed
+html:
+ @: > sub2-$@-should-not-be-executed
+install-info install-html install-dvi install-pdf install-ps:
+ @: > sub2-$@-should-not-be-executed
+installcheck installdirs tags TAGS mostlyclean:
+ @: > sub2-$@-should-not-be-executed
+## These targets cannot be overridden like this:
+## install-strip distclean maintainer-clean
+END
+
+$ACLOCAL
+$AUTOCONF
+
+check_targets ()
+{
+ for target in \
+ all install install-strip uninstall clean distclean check \
+ info html dvi pdf ps \
+ install-info install-html install-dvi install-pdf install-ps \
+ installcheck installdirs tags TAGS mostlyclean maintainer-clean
+ do
+ $MAKE -n $target >stdout || { cat stdout; Exit 1; }
+ cat stdout
+ case $target in
+ install-* | installdirs | tags | TAGS ) ;;
+ *)
+ if $have_dotmake; then
+ grep "stamp-$target$" stdout || Exit 1
+ fi
+ test ! -f "stamp-$target$" || Exit 1
+ ;;
+ esac
+ case $target in
+ install-* | installdirs ) ;;
+ *)
+ if $have_dotmake; then
+ grep "stamp-$target-sub" stdout || Exit 1
+ fi
+ test ! -f "sub/stamp-$target-sub" || Exit 1
+ ;;
+ esac
+ case $target in
+ distclean | maintainer-clean ) ;;
+ *)
+ if $have_dotmake; then
+ grep "should-not-be-executed" stdout || Exit 1
+ fi
+ test ! -f "sub2/sub2-$target-should-not-be-executed" || Exit 1
+ ;;
+ esac
+ done
+}
+
+$AUTOMAKE -a -Wno-override
+./configure
+check_targets || Exit 1
+
+# Now, introduce BUILT_SOURCES into the toplevel Makefile
+# TODO: add BUILT_SOURCES to sub2, fix fallout.
+sed 's/##//' < Makefile.am > t
+mv -f t Makefile.am
+$AUTOMAKE -Wno-override --force Makefile
+./configure
+check_targets || Exit 1
+
+Exit 0
diff --git a/t/makevars.sh b/t/makevars.sh
new file mode 100755
index 000000000..ad18830a2
--- /dev/null
+++ b/t/makevars.sh
@@ -0,0 +1,33 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test to make sure that automake includes the needed variables,
+# but not too many.
+
+. ./defs || Exit 1
+
+# Find the macros wanted by Automake.
+$ACLOCAL
+
+# Create some dummy Makefile.in.
+: > Makefile.am
+
+$AUTOMAKE
+
+# We are definitely not needing a compiler or preprocessor.
+$EGREP '^ *(CC|CPP|CXX|CXXCPP) *=' Makefile.in && Exit 1
+
+:
diff --git a/t/man.sh b/t/man.sh
new file mode 100755
index 000000000..d2e5dd66a
--- /dev/null
+++ b/t/man.sh
@@ -0,0 +1,33 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test to make sure 'dist' prefix works with man pages.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+dist_man_MANS = foo.1
+nodist_man1_MANS = bar.man
+END
+
+: > foo.1
+: > bar.man
+
+$ACLOCAL
+$AUTOMAKE
+grep '^MANS *=' Makefile.in
+
+:
diff --git a/t/man2.sh b/t/man2.sh
new file mode 100755
index 000000000..38c399288
--- /dev/null
+++ b/t/man2.sh
@@ -0,0 +1,53 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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 that man pages listed in man_MANS are installed and
+# renamed as documented.
+
+. ./defs || Exit 1
+
+cat >> configure.ac <<'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+man_MANS = foo.2
+man4_MANS = foo.4 bar.man
+END
+
+: > foo.2
+: > foo.4
+: > bar.man
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+# Let's play with $DESTDIR too, it shouldn't hurt.
+./configure --prefix='' --mandir=/man
+$MAKE DESTDIR="`pwd`/_inst" install
+
+test -f ./_inst/man/man2/foo.2
+test -f ./_inst/man/man4/foo.4
+test -f ./_inst/man/man4/bar.4
+
+$MAKE DESTDIR="`pwd`/_inst" uninstall
+
+test ! -f ./_inst/man/man2/foo.2
+test ! -f ./_inst/man/man4/foo.4
+test ! -f ./_inst/man/man4/bar.4
+
+:
diff --git a/t/man3.sh b/t/man3.sh
new file mode 100755
index 000000000..a842d38a9
--- /dev/null
+++ b/t/man3.sh
@@ -0,0 +1,44 @@
+#! /bin/sh
+# Copyright (C) 2008-2012 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/>.
+
+# PR 516: Prefer generated manpages to distributed ones.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+dist_man_MANS = foo.1
+installcheck-local:
+ grep bar "$(mandir)/man1/foo.1"
+END
+
+cat >>configure.ac <<'END'
+: ${foo=foo}
+AC_SUBST([foo])
+AC_CONFIG_FILES([foo.1])
+AC_OUTPUT
+END
+
+cat > foo.1.in <<'END'
+@foo@
+END
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+./configure
+DISTCHECK_CONFIGURE_FLAGS=foo=bar $MAKE -e distcheck
+
+:
diff --git a/t/man4.sh b/t/man4.sh
new file mode 100755
index 000000000..c7333b9c2
--- /dev/null
+++ b/t/man4.sh
@@ -0,0 +1,105 @@
+#! /bin/sh
+# Copyright (C) 2008-2012 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/>.
+
+# Ensure 'make dist' fails when help2man replacement man pages are created.
+#
+# The assumption here is the following: if the developer uses help2man to
+# generate man pages from --help output, then these man pages may not be
+# stored in VCS. However, they should be distributed, so that the end user
+# that receives the tarball doesn't have to install help2man. If they are
+# not distributed, then the developer should make help2man a prerequisite
+# to building the package from a tarball, e.g., with a configure check for
+# help2man that errors out if it is unavailable. In both cases it is
+# sufficient to check only distributed man pages.
+#
+# Idea of this whole shenanigan is to allow somebody to check out sources from
+# a VCS and build and install them without needing help2man installed. The
+# installed man pages will be bogus in this case. Typically, this happens
+# when developers ask users to try out a fix from VCS; the developers themselves
+# will usually have help2man installed (or should install it).
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+dist_man_MANS = $(srcdir)/foo.1 bar.1
+dist_bin_SCRIPTS = foo bar
+$(srcdir)/foo.1:
+ $(HELP2MAN) --output=$@ $(srcdir)/foo
+bar.1:
+ $(HELP2MAN) --output=$(srcdir)/bar.1 $(srcdir)/bar
+END
+
+cat >>configure.ac <<'END'
+AM_MISSING_PROG([HELP2MAN], [help2man])
+AC_OUTPUT
+END
+
+cat > foo <<'END'
+#! /bin/sh
+while test $# -gt 0; do
+ case $1 in
+ -h | --help) echo "usage: $0 [OPTIONS]..."; exit 0;;
+ -v | --version) echo "$0 1.0"; exit 0;;
+ esac
+ shift
+done
+END
+cp foo bar
+chmod +x foo bar
+
+mkdir bin
+cat > bin/help2man <<'END'
+#! /bin/sh
+# Fake help2man script that lets 'missing' think it is not installed.
+exit 127
+END
+chmod +x bin/help2man
+PATH=`pwd`/bin$PATH_SEPARATOR$PATH
+
+grep_error_messages()
+{
+ grep ' man pages contain.*missing help2man.* replacement text' stderr \
+ && grep 'install help2man' stderr \
+ && grep 'regenerate the man pages' stderr \
+ || Exit 1
+}
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+
+./configure
+$MAKE
+$MAKE dist 2>stderr && { cat stderr >&2; Exit 1; }
+cat stderr >&2
+grep_error_messages
+$MAKE distcheck 2>stderr && { cat stderr >&2; Exit 1; }
+cat stderr >&2
+grep_error_messages
+$MAKE distclean
+
+mkdir build
+cd build
+../configure
+$MAKE
+$MAKE dist 2>stderr && { cat stderr >&2; Exit 1; }
+cat stderr >&2
+grep_error_messages
+$MAKE distcheck 2>stderr && { cat stderr >&2; Exit 1; }
+cat stderr >&2
+grep_error_messages
+
+:
diff --git a/t/man5.sh b/t/man5.sh
new file mode 100755
index 000000000..674ea03c1
--- /dev/null
+++ b/t/man5.sh
@@ -0,0 +1,67 @@
+#! /bin/sh
+# Copyright (C) 2009-2012 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 to extract the correct mansection from files in man_MANS.
+
+. ./defs || Exit 1
+
+cat >> configure.ac <<'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+man_MANS = foo-1.4.5/foo.2 foo-1.4.5/bar.3 baz-1.4.2
+notrans_man_MANS = foo-1.4.5/nfoo.2 foo-1.4.5/nbar.3 nbaz-1.4.2
+END
+
+mkdir foo-1.4.5
+
+: > foo-1.4.5/foo.2
+: > foo-1.4.5/nfoo.2
+: > foo-1.4.5/bar.3
+: > foo-1.4.5/nbar.3
+: > baz-1.4.2
+: > nbaz-1.4.2
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+# Let's play with $DESTDIR too, it shouldn't hurt.
+./configure --mandir=/man
+$MAKE DESTDIR="`pwd`/_inst" install
+
+test -f ./_inst/man/man2/foo.2
+test -f ./_inst/man/man2/nfoo.2
+test -f ./_inst/man/man2/baz-1.4.2
+test -f ./_inst/man/man2/nbaz-1.4.2
+test -f ./_inst/man/man3/bar.3
+test -f ./_inst/man/man3/nbar.3
+
+test ! -d ./_inst/man/man1
+test ! -d ./_inst/man/man4
+test ! -d ./_inst/man/man5
+
+$MAKE DESTDIR="`pwd`/_inst" uninstall
+
+test ! -f ./_inst/man/man2/foo.2
+test ! -f ./_inst/man/man2/nfoo.2
+test ! -f ./_inst/man/man2/baz-1.4.2
+test ! -f ./_inst/man/man2/nbaz-1.4.2
+test ! -f ./_inst/man/man3/bar.3
+test ! -f ./_inst/man/man3/nbar.3
+
+:
diff --git a/t/man6.sh b/t/man6.sh
new file mode 100755
index 000000000..1a7b26751
--- /dev/null
+++ b/t/man6.sh
@@ -0,0 +1,101 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Ensure 'make distcheck' passes when help2man generates man pages,
+# even if the 'missing' script is involved.
+
+required=help2man
+. ./defs || Exit 1
+
+# Avoid a spurious failure due to a known FreeBSD make incompatibility.
+useless_vpath_rebuild \
+ && skip_ "VPATH useless rebuild detected (see bug#7884)"
+
+cat > Makefile.am << 'END'
+dist_man_MANS = $(srcdir)/foobar.1 bazquux.1 zardoz.1
+dist_bin_SCRIPTS = foobar bazquux zardoz
+$(srcdir)/foobar.1:
+ $(HELP2MAN) --output=$@ $(srcdir)/foobar
+bazquux.1:
+ $(HELP2MAN) --output=$@ $(srcdir)/bazquux
+zardoz.1:
+ $(HELP2MAN) --output=$(srcdir)/zardoz.1 $(srcdir)/zardoz
+END
+
+cat >> configure.ac <<'END'
+AM_MISSING_PROG([HELP2MAN], [help2man])
+AC_OUTPUT
+END
+
+cat > foobar <<'END'
+#! /bin/sh
+while test $# -gt 0; do
+ case $1 in
+ -h | --help) echo "usage: $0 [OPTIONS]..."; exit 0;;
+ -v | --version) echo "$0 1.0"; exit 0;;
+ esac
+ shift
+done
+END
+
+cp foobar bazquux
+cp foobar zardoz
+
+chmod +x foobar bazquux zardoz
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+
+mkdir build
+cd build
+
+../configure
+# Sanity check.
+grep '^HELP2MAN *=.*/missing --run help2man' Makefile
+
+$MAKE
+$FGREP foobar ../foobar.1
+$FGREP bazquux ./bazquux.1
+$FGREP zardoz ../zardoz.1
+
+$MAKE distdir
+$FGREP foobar $me-1.0/foobar.1
+$FGREP bazquux $me-1.0/bazquux.1
+$FGREP zardoz $me-1.0/zardoz.1
+
+$MAKE distcheck
+
+cd ..
+rm -f *.1 # Remove leftover generated manpages.
+
+./configure
+# Sanity check.
+grep '^HELP2MAN *=.*/missing --run help2man' Makefile
+
+$MAKE
+$FGREP foobar foobar.1
+$FGREP bazquux bazquux.1
+$FGREP zardoz zardoz.1
+
+$MAKE distdir
+$FGREP foobar $me-1.0/foobar.1
+$FGREP bazquux $me-1.0/bazquux.1
+$FGREP zardoz $me-1.0/zardoz.1
+
+$MAKE distcheck
+
+:
diff --git a/t/man7.sh b/t/man7.sh
new file mode 100755
index 000000000..37bec90ca
--- /dev/null
+++ b/t/man7.sh
@@ -0,0 +1,59 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Check for a bug in maintainer-clean w.r.t. generated manpages.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+dist_man_MANS = $(srcdir)/foo.1 bar.1
+$(srcdir)/foo.1 bar.1:
+ : > $@
+MAINTAINERCLEANFILES = $(dist_man_MANS)
+END
+
+cat >> configure.ac <<'END'
+AC_OUTPUT
+END
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+
+mkdir build
+cd build
+../configure
+
+$MAKE
+test -f bar.1
+test -f ../foo.1
+
+$MAKE maintainer-clean
+test ! -f bar.1
+test ! -f ../foo.1
+
+cd ..
+./configure
+
+$MAKE
+test -f bar.1
+test -f foo.1
+
+$MAKE maintainer-clean
+test ! -f bar.1
+test ! -f foo.1
+
+:
diff --git a/t/man8.sh b/t/man8.sh
new file mode 100755
index 000000000..14c190b0f
--- /dev/null
+++ b/t/man8.sh
@@ -0,0 +1,61 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Check for a bug in distcheck w.r.t. generated manpages.
+
+. ./defs || Exit 1
+
+# Avoid a spurious failure due to a known FreeBSD make incompatibility.
+useless_vpath_rebuild \
+ && skip_ "VPATH useless rebuild detected (see bug#7884)"
+
+cat > Makefile.am << 'END'
+dist_man_MANS = foo.1
+foo.1:
+## This 'rm' command will fail if $(srcdir) is unwritable.
+ rm -f $(srcdir)/$@
+ : > $(srcdir)/$@
+END
+
+cat >> configure.ac <<'END'
+AC_OUTPUT
+END
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+
+mkdir build
+cd build
+../configure
+
+$MAKE
+test -f ../foo.1
+$MAKE distdir
+test -f $me-1.0/foo.1
+$MAKE distcheck
+
+cd ..
+rm -f foo.1
+./configure
+
+$MAKE
+test -f foo.1
+$MAKE distdir
+test -f $me-1.0/foo.1
+$MAKE distcheck
+
+:
diff --git a/t/mdate.sh b/t/mdate.sh
new file mode 100755
index 000000000..b33bf638b
--- /dev/null
+++ b/t/mdate.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test that mdate-sh is required when Texinfo used and version.texi needed.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+info_TEXINFOS = textutils.texi
+END
+
+cat > textutils.texi << 'END'
+@include version.texi
+@setfilename textutils.info
+END
+
+# Required when using Texinfo.
+: > texinfo.tex
+
+$ACLOCAL
+AUTOMAKE_fails
+grep 'required file.*mdate-sh.*not found' stderr
+
+:
diff --git a/t/mdate2.sh b/t/mdate2.sh
new file mode 100755
index 000000000..093de5ea9
--- /dev/null
+++ b/t/mdate2.sh
@@ -0,0 +1,40 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test to make sure mdate-sh is included in distribution.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+info_TEXINFOS = textutils.texi
+END
+
+cat > textutils.texi << 'END'
+@include version.texi
+END
+
+# Required when using Texinfo.
+: > texinfo.tex
+: > mdate-sh
+echo '@setfilename textutils' > textutils.texi
+
+# Use "././" to confuse Automake into thinking this is a subdir build.
+$ACLOCAL
+$AUTOMAKE ././Makefile
+
+grep 'mdate-sh' Makefile.in | grep -v SHELL
+
+:
diff --git a/t/mdate3.sh b/t/mdate3.sh
new file mode 100755
index 000000000..a37e60b79
--- /dev/null
+++ b/t/mdate3.sh
@@ -0,0 +1,49 @@
+#! /bin/sh
+# Copyright (C) 1999-2012 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/>.
+
+# Test to make sure mdate-sh run correctly.
+
+. ./defs || Exit 1
+
+cat > configure.ac << END
+AC_INIT([$me], [1.0])
+AC_CONFIG_AUX_DIR([foo])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([Makefile])
+END
+
+cat > Makefile.am << 'END'
+info_TEXINFOS = textutils.texi
+END
+
+cat > textutils.texi << 'END'
+@include version.texi
+@setfilename textutils.info
+END
+
+mkdir foo
+
+# Required when using Texinfo.
+: > foo/texinfo.tex
+: > foo/mdate-sh
+mv install-sh foo
+mv missing foo
+
+$ACLOCAL
+$AUTOMAKE
+
+grep '[^/]mdate-sh' Makefile.in && Exit 1
+Exit 0
diff --git a/t/mdate4.sh b/t/mdate4.sh
new file mode 100755
index 000000000..ac1be3a38
--- /dev/null
+++ b/t/mdate4.sh
@@ -0,0 +1,46 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test to make sure that mdate-sh is added to the right directory.
+# Report from Kevin Dalley.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_CONFIG_FILES([sub/Makefile])
+END
+
+cat > Makefile.am << 'END'
+SUBDIRS = sub
+END
+
+mkdir sub
+
+cat > sub/Makefile.am << 'END'
+info_TEXINFOS = textutils.texi
+END
+
+cat > sub/textutils.texi << 'END'
+@include version.texi
+@setfilename textutils.info
+END
+
+$ACLOCAL
+$AUTOMAKE -a
+ls -l sub
+test -f sub/mdate-sh
+
+:
diff --git a/t/mdate5.sh b/t/mdate5.sh
new file mode 100755
index 000000000..4cef9526d
--- /dev/null
+++ b/t/mdate5.sh
@@ -0,0 +1,45 @@
+#! /bin/sh
+# Copyright (C) 1999-2012 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/>.
+
+# Test to make sure mdate-sh works correctly.
+
+am_create_testdir=empty
+. ./defs || Exit 1
+
+get_shell_script mdate-sh
+
+set x `./mdate-sh mdate-sh`
+shift
+echo "$*" # For debugging.
+
+# Check that mdate output looks like a date:
+test $# = 3
+case $1$3 in *[!0-9]*) Exit 1;; esac
+test $1 -lt 32
+# Hopefully automake will be obsolete in 80 years ;-)
+case $3 in 20[0-9][0-9]) :;; *) Exit 1;; esac
+case $2 in
+ January|February|March|April|May|June|July|August) ;;
+ September|October|November|December) ;;
+ *) Exit 1
+esac
+
+# Stricter checks on the year required a POSIX date(1) command.
+if year=`date +%Y` && test $year -gt 2010; then
+ test $year = $3 || Exit 1
+fi
+
+:
diff --git a/t/mdate6.sh b/t/mdate6.sh
new file mode 100755
index 000000000..ca3ca21ea
--- /dev/null
+++ b/t/mdate6.sh
@@ -0,0 +1,36 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# mdate-sh can work with weird file names, doesn't eval too much.
+
+am_create_testdir=empty
+. ./defs || Exit 1
+
+a=
+file='file name $a'
+( : > "$file" ) \
+ || skip_ "file name with spaces and metacharacters not accepted"
+
+get_shell_script mdate-sh
+
+./mdate-sh "$file" >stdout 2>stderr ||
+ { cat stdout; cat stderr >&2; Exit 1; }
+cat stdout
+cat stderr >&2
+grep '[12][0-9]\{3\}' stdout
+test ! -s stderr
+
+:
diff --git a/t/missing-auxfile-stops-makefiles-creation.sh b/t/missing-auxfile-stops-makefiles-creation.sh
new file mode 100755
index 000000000..d7080818d
--- /dev/null
+++ b/t/missing-auxfile-stops-makefiles-creation.sh
@@ -0,0 +1,65 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Automake should stop the creation of Makefile.in files at the first
+# encountered error due to a required auxiliary file not found.
+
+. ./defs || Exit 1
+
+cat >> configure.ac <<END
+AM_PATH_PYTHON
+END
+
+echo SUBDIRS = > Makefile.am
+
+for i in 1 2 3 4 5; do
+ echo "AC_CONFIG_FILES([sub$i/Makefile])" >> configure.ac
+ echo "SUBDIRS += sub$i" >> Makefile.am
+ mkdir sub$i
+ echo python_PYTHON = foo.py > sub$i/Makefile.am
+done
+
+: > sub1/Makefile.am
+
+$ACLOCAL
+
+unset AUTOMAKE_JOBS || :
+
+AUTOMAKE_fails
+ls -l Makefile.in */Makefile.in || : # For debugging.
+# Top-level Makefile.in might be created or not, we don't want to set
+# too strict semantics here, so don't check for it. But the later
+# files shouldn't exist.
+test -f sub1/Makefile.in
+test ! -f sub2/Makefile.in
+test ! -f sub3/Makefile.in
+test ! -f sub4/Makefile.in
+test ! -f sub5/Makefile.in
+
+rm -f Makefile.in */Makefile.in
+
+: > sub2/Makefile.am
+: > sub3/Makefile.am
+
+AUTOMAKE_fails
+ls -l Makefile.in */Makefile.in || : # For debugging.
+test -f sub1/Makefile.in
+test -f sub2/Makefile.in
+test -f sub3/Makefile.in
+test ! -f sub4/Makefile.in
+test ! -f sub5/Makefile.in
+
+:
diff --git a/t/missing.sh b/t/missing.sh
new file mode 100755
index 000000000..473d0412c
--- /dev/null
+++ b/t/missing.sh
@@ -0,0 +1,66 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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/>.
+
+# Test missing with version mismatches.
+
+. ./defs || Exit 1
+
+cat >>configure.ac <<'EOF'
+AC_OUTPUT
+EOF
+
+: > Makefile.am
+
+get_shell_script missing
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+# Make sure we do use missing, even if the user exported AUTOCONF.
+# (We cannot export this new value, because it would be used by Automake
+# when tracing, and missing is no good for this.)
+MYAUTOCONF="./missing --run $AUTOCONF"
+unset AUTOCONF
+
+./configure AUTOCONF="$MYAUTOCONF"
+$MAKE
+$sleep
+# Hopefully the install version of Autoconf cannot compete with this one...
+echo 'AC_PREREQ(9999)' >> aclocal.m4
+$MAKE distdir
+
+# Try version number suffixes if we can add them safely.
+case $MYAUTOCONF in *autoconf)
+ ./configure AUTOCONF="${MYAUTOCONF}6789"
+ $MAKE
+ $sleep
+ # Hopefully the install version of Autoconf cannot compete with this one...
+ echo 'AC_PREREQ(9999)' >> aclocal.m4
+ $MAKE distdir
+esac
+
+# Run again, but without missing, to ensure that timestamps were updated.
+export AUTOMAKE ACLOCAL
+./configure AUTOCONF="$MYAUTOCONF"
+$MAKE
+
+# Make sure $MAKE fails when timestamps aren't updated and missing is not used.
+$sleep
+touch aclocal.m4
+$MAKE && Exit 1
+
+:
diff --git a/t/missing2.sh b/t/missing2.sh
new file mode 100755
index 000000000..89e9a5daf
--- /dev/null
+++ b/t/missing2.sh
@@ -0,0 +1,58 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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/>.
+
+# Test missing with version mismatches.
+
+. ./defs || Exit 1
+
+cat >>configure.ac <<'EOF'
+m4_include([v.m4])
+AC_OUTPUT
+EOF
+
+: > v.m4
+
+: > Makefile.am
+
+get_shell_script missing
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+# See missing.test for explanations about this.
+MYAUTOCONF="./missing --run $AUTOCONF"
+unset AUTOCONF
+
+./configure AUTOCONF="$MYAUTOCONF"
+
+$MAKE
+$sleep
+# Hopefully the install version of Autoconf cannot compete with this one...
+echo 'AC_PREREQ(9999)' > v.m4
+$MAKE distdir
+
+# Run again, but without missing, to ensure that timestamps were updated.
+export AUTOMAKE ACLOCAL
+./configure AUTOCONF="$MYAUTOCONF"
+$MAKE
+
+# Make sure $MAKE fail when timestamps aren't updated and missing is not used.
+$sleep
+touch v.m4
+$MAKE && Exit 1
+
+:
diff --git a/t/missing3.sh b/t/missing3.sh
new file mode 100755
index 000000000..a26f954c9
--- /dev/null
+++ b/t/missing3.sh
@@ -0,0 +1,53 @@
+#! /bin/sh
+# Copyright (C) 2004-2012 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/>.
+
+# Test missing when running a tool's --version.
+
+am_create_testdir=empty
+. ./defs || Exit 1
+
+get_shell_script missing
+
+# b7cb8259 assumed not to exist.
+
+./missing b7cb8259 --version 2>stderr && { cat stderr >&2; Exit 1; }
+cat stderr >&2
+grep . stderr && Exit 1
+./missing b7cb8259 --grep 2>stderr && { cat stderr >&2; Exit 1; }
+cat stderr >&2
+grep WARNING stderr
+
+./missing --run b7cb8259 --version && Exit 1
+./missing --run b7cb8259 --grep 2>stderr && { cat stderr >&2; Exit 1; }
+cat stderr >&2
+grep WARNING stderr
+
+# missing itself it known to exist :)
+
+./missing ./missing --version 2>stderr && { cat stderr >&2; Exit 1; }
+cat stderr >&2
+grep . stderr && Exit 1
+./missing ./missing --grep 2>stderr && { cat stderr >&2; Exit 1; }
+cat stderr >&2
+grep WARNING stderr
+
+./missing --run ./missing --version 2>stderr || { cat stderr >&2; Exit 1; }
+cat stderr >&2
+grep . stderr && Exit 1
+./missing --run ./missing --grep 2>stderr && { cat stderr >&2; Exit 1; }
+cat stderr >&2
+grep WARNING stderr && Exit 1
+grep Unknown stderr
diff --git a/t/missing4.sh b/t/missing4.sh
new file mode 100755
index 000000000..01321c349
--- /dev/null
+++ b/t/missing4.sh
@@ -0,0 +1,47 @@
+#! /bin/sh
+# Copyright (C) 2006-2012 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/>.
+
+# See how well the rebuild rule handles an aclocal.m4 that was
+# generated for another version of autoconf.
+
+. ./defs || Exit 1
+
+echo AC_OUTPUT >>configure.ac
+
+touch Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+$MAKE
+
+sed '1,20 s/m4_defn(\[AC_AUTOCONF_VERSION\]),/9999,/' < aclocal.m4 > aclocal.tmp
+cmp aclocal.m4 aclocal.tmp && Exit 1
+
+mv aclocal.tmp aclocal.m4
+
+$MAKE 2>stderr || { cat cat stderr >&2; Exit 1; }
+cat stderr >&2
+grep 'You have another version of autoconf' stderr
+grep 'aclocal.m4:.*this file was generated for' stderr
+
+$MAKE 2>stderr || { cat cat stderr >&2; Exit 1; }
+cat stderr >&2
+grep 'You have another version of autoconf' stderr && Exit 1
+grep 'aclocal.m4:.*this file was generated for' stderr && Exit 1
+
+:
diff --git a/t/missing5.sh b/t/missing5.sh
new file mode 100755
index 000000000..80bba3691
--- /dev/null
+++ b/t/missing5.sh
@@ -0,0 +1,64 @@
+#! /bin/sh
+# Copyright (C) 2006-2012 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/>.
+
+# Test how well 'missing' finds output file names of various tools.
+# PR automake/483.
+
+am_create_testdir=empty
+. ./defs || Exit 1
+
+get_shell_script missing
+
+# These programs may be invoked by 'missing'.
+needed_tools='chmod find sed test touch'
+needed_tools_csep=`echo $needed_tools | sed 's/ /, /g'`
+
+cat >configure.ac <<EOF
+AC_INIT([missing4], [1.0])
+m4_foreach([tool], [$needed_tools_csep],
+ [AC_PATH_PROG(tool, tool, [false])
+ AC_CONFIG_FILES(tool, chmod +x tool)
+ ])
+AC_OUTPUT
+EOF
+
+for tool in $needed_tools; do
+ unindent >$tool.in <<EOF
+ #! /bin/sh
+ exec @$tool@ "\$@"
+EOF
+done
+
+$AUTOCONF
+./configure
+
+echo output-file > output-file
+cp output-file my--output--file-o
+
+save_PATH=$PATH
+PATH=.
+export PATH
+missing --help
+missing --version
+for tool in autom4te help2man makeinfo; do
+ missing --run $tool -o my--output--file-o input
+ missing --run $tool --output my--output--file-o input
+done
+PATH=$save_PATH
+export PATH
+diff output-file my--output--file-o
+test ! -f ./--file-o
+test ! -f input
diff --git a/t/missing6.sh b/t/missing6.sh
new file mode 100755
index 000000000..8173f818a
--- /dev/null
+++ b/t/missing6.sh
@@ -0,0 +1,51 @@
+#! /bin/sh
+# Copyright (C) 2008-2012 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 autoconf version checks in aclocal.m4 are robust.
+
+am_create_testdirs=empty
+. ./defs || Exit 1
+
+cat > configure.ac <<END
+m4_define([AC_AUTOCONF_VERSION], [9999a])
+dnl!! m4_define([a], [oops])
+AC_INIT([$me], [1.0])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+END
+
+: > Makefile.am
+
+$ACLOCAL
+$AUTOCONF 2>stderr || { cat stderr >&2; Exit 1; }
+cat stderr >&2
+grep 'You have another version of autoconf' stderr
+grep 'aclocal.m4:.*this file was generated for' stderr
+$AUTOMAKE -a
+./configure
+$MAKE
+
+sed 's/^dnl!! //' < configure.ac > configure.tmp
+cmp configure.ac configure.tmp && fatal_ 'failed to edit configure.ac'
+mv -f configure.tmp configure.ac
+
+$MAKE 2>stderr || { cat stderr >&2; Exit 1; }
+cat stderr >&2
+grep 'You have another version of autoconf' stderr
+grep 'aclocal.m4:.*this file was generated for autoconf 9999a' stderr
+
+:
diff --git a/t/mkinst2.sh b/t/mkinst2.sh
new file mode 100755
index 000000000..658283600
--- /dev/null
+++ b/t/mkinst2.sh
@@ -0,0 +1,36 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test to make sure no-installman suppresses man dir creation.
+
+. ./defs || Exit 1
+
+echo AC_OUTPUT >> configure.ac
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = no-installman
+man_MANS = foo.1
+END
+
+: > foo.1
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure --prefix "`pwd`/sub"
+
+$MAKE installdirs
+test ! -d sub/man
diff --git a/t/mkinst3.sh b/t/mkinst3.sh
new file mode 100755
index 000000000..fbe01c652
--- /dev/null
+++ b/t/mkinst3.sh
@@ -0,0 +1,65 @@
+#! /bin/sh
+# Copyright (C) 2005-2012 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/>.
+
+# Test mkinstalldirs with spaces in directory names.
+
+am_create_testdir=empty
+. ./defs || Exit 1
+
+# Make sure the directory we will create can be created...
+mkdir '~a b' && mkdir '~a b/-x y' \
+ || skip_ "directory names with spaces and metacharacters not accepted"
+rm -rf '~a b'
+
+get_shell_script mkinstalldirs
+
+# Test mkinstalldirs with the installed mkdir.
+
+./mkinstalldirs '~a b/-x y'
+test -d '~a b/-x y'
+rm -rf '~a b'
+
+# Trick mkinstalldirs into thinking mkdir does not support -p.
+
+mkdir bin
+cat >bin/mkdir <<'EOF'
+#!/bin/sh
+for arg
+do
+ case $arg in
+ -p) exit 1;;
+ esac
+done
+PATH=$AM_PATH
+export PATH
+exec mkdir "$@"
+EOF
+
+chmod +x bin/mkdir
+AM_PATH=$PATH
+export AM_PATH
+PATH=`pwd`/bin$PATH_SEPARATOR$PATH
+export PATH
+
+# Test mkinstalldirs without mkdir -p.
+
+./mkinstalldirs '~a b/-x y'
+test -d '~a b/-x y'
+rm -rf '~a b'
+
+./mkinstalldirs "`pwd`///~a b//-x y"
+test -d "`pwd`/~a b/-x y"
+rm -rf '~a b'
diff --git a/t/mkinstall.sh b/t/mkinstall.sh
new file mode 100755
index 000000000..e6b3bc22a
--- /dev/null
+++ b/t/mkinstall.sh
@@ -0,0 +1,31 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test for bug where mkinstalldirs variable can be set incorrectly.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+pkgdata_DATA =
+END
+
+# The "././" prefix confuses Automake into thinking it is doing a
+# subdir build. Yes, this is hacky.
+$ACLOCAL
+$AUTOMAKE ././Makefile
+
+grep ' /mkinstalldirs' Makefile.in && Exit 1
+Exit 0
diff --git a/t/mmode.sh b/t/mmode.sh
new file mode 100755
index 000000000..6c8039955
--- /dev/null
+++ b/t/mmode.sh
@@ -0,0 +1,64 @@
+#! /bin/sh
+# Copyright (C) 2008-2012 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/>.
+
+# Check for AM_MAINTAINER_MODE defaults.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AM_MAINTAINER_MODE
+AC_OUTPUT
+END
+
+: >Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+grep '^MAINT.*#' Makefile
+
+./configure --disable-maintainer-mode
+grep '^MAINT.*#' Makefile
+
+./configure --enable-maintainer-mode
+grep '^MAINT.*#' Makefile && Exit 1
+
+sed 's/\(AM_MAINTAINER_MODE\).*/\1([disable])/' configure.ac > configure.int
+mv -f configure.int configure.ac
+mv configure configure1
+$AUTOCONF --force
+diff configure configure1
+
+sed 's/\(AM_MAINTAINER_MODE\).*/\1([enable])/' configure.ac > configure.int
+mv -f configure.int configure.ac
+$AUTOCONF --force
+
+./configure
+grep '^MAINT.*#' Makefile && Exit 1
+
+./configure --enable-maintainer-mode
+grep '^MAINT.*#' Makefile && Exit 1
+
+./configure --disable-maintainer-mode
+grep '^MAINT.*#' Makefile
+
+sed 's/\(AM_MAINTAINER_MODE\).*/\1([foo])/' configure.ac > configure.int
+mv -f configure.int configure.ac
+$AUTOCONF --force -Werror && Exit 1
+
+:
diff --git a/t/mmodely.sh b/t/mmodely.sh
new file mode 100755
index 000000000..6c6191520
--- /dev/null
+++ b/t/mmodely.sh
@@ -0,0 +1,93 @@
+#! /bin/sh
+# Copyright (C) 2004-2012 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/>.
+
+# Verify that intermediate files are only built from Yacc and Lex
+# sources in maintainer mode.
+# From Derek R. Price.
+
+required=cc
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AM_MAINTAINER_MODE
+AC_PROG_CC
+AM_PROG_LEX
+AC_PROG_YACC
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+YACC = false
+LEX = false
+bin_PROGRAMS = zardoz
+zardoz_SOURCES = zardoz.y joe.l
+LDADD = @LEXLIB@
+END
+
+# The point of this test is that it is not dependent on a working lex
+# or yacc.
+cat > joe.c <<EOF
+int joe (int arg)
+{
+ return arg * 2;
+}
+EOF
+# On systems which link in libraries non-lazily and whose linkers
+# complain about unresolved symbols by default, such as Solaris, an
+# yylex function needs to be defined to avoid an error due to an
+# unresolved symbol.
+cat > zardoz.c <<EOF
+int joe (int arg);
+int yylex (void)
+{
+ return 0;
+}
+int main (int argc, char **argv)
+{
+ return joe (argc);
+}
+EOF
+
+# Ensure a later timestamp for our Lex & Yacc sources.
+$sleep
+: > joe.l
+: > zardoz.y
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+$MAKE
+
+cat >myyacc.sh <<'END'
+#! /bin/sh
+echo "$@" >y.tab.c
+END
+cat >mylex.sh <<'END'
+echo "$@" >lex.yy.c
+END
+chmod +x myyacc.sh mylex.sh
+PATH="`pwd`$PATH_SEPARATOR$PATH"
+
+# "make maintainer-clean; ./configure; make" should always work,
+# per GNU Standard.
+$MAKE maintainer-clean
+./configure
+YACC="myyacc.sh" LEX="mylex.sh" \
+ LEX_OUTPUT_ROOT='lex.yy' $MAKE -e zardoz.c joe.c
+grep zardoz.y zardoz.c
+grep joe.l joe.c
diff --git a/t/multlib.sh b/t/multlib.sh
new file mode 100755
index 000000000..b7ddf200e
--- /dev/null
+++ b/t/multlib.sh
@@ -0,0 +1,162 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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/>.
+
+# Check multilib support.
+# Based on a test case from Ralf Corsepius.
+# FIXME: the features tested by this script has been moved in contrib.
+# FIXME: We should move this script accordingly.
+
+required='gcc GNUmake'
+. ./defs || Exit 1
+
+mldir=$top_testsrcdir/contrib/multilib
+mkdir m4
+cp "$mldir"/config-ml.in "$mldir"/symlink-tree .
+cp "$mldir"/multi.m4 m4
+
+ACLOCAL_PATH=${ACLOCAL_PATH+"$ACLOCAL_PATH:"}`pwd`/m4
+export ACLOCAL_PATH
+
+cat >configure.ac <<'END'
+AC_INIT([multlib], [1.0])
+AC_CONFIG_SRCDIR(libfoo/foo.c)
+AC_CONFIG_AUX_DIR(.)
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([Makefile])
+AC_CONFIG_SUBDIRS(libfoo)
+AC_CONFIG_SUBDIRS(libbar)
+AC_OUTPUT
+END
+
+cat >mycc <<'END'
+#! /bin/sh
+case ${1+"$@"} in
+ *-print-multi-lib*)
+ echo ".;"
+ echo "debug;@g"
+ exit 0 ;;
+esac
+gcc ${1+"$@"}
+END
+
+chmod +x mycc
+PATH=`pwd`$PATH_SEPARATOR$PATH
+
+cat >Makefile.am <<'EOF'
+SUBDIRS = @subdirs@
+EXTRA_DIST = config-ml.in symlink-tree
+check-all:
+ test -f debug/libfoo/libfoo.a
+ test -f debug/libbar/libbar.a
+ test -f libfoo/libfoo.a
+ test -f libbar/libbar.a
+EOF
+
+# libfoo tests multilib supports when there are no subdirectories
+# libbar tests multilib supports when there are subdirectories
+
+mkdir libfoo
+cp "$mldir"/multilib.am libfoo/
+
+cat >libfoo/configure.ac <<'END'
+AC_PREREQ(2.57)
+AC_INIT(libfoo, 0.1, nobody@localhost)
+AC_CONFIG_SRCDIR(foo.c)
+# Apparently it doesn't work to have auxdir=.. when
+# multilib uses symlinked trees.
+AC_CONFIG_AUX_DIR(.)
+AM_INIT_AUTOMAKE
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_RANLIB
+AM_ENABLE_MULTILIB(Makefile,[..])
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+END
+
+cat >libfoo/Makefile.am <<'END'
+noinst_LIBRARIES = libfoo.a
+libfoo_a_SOURCES = foo.c
+include $(top_srcdir)/multilib.am
+END
+
+: > libfoo/foo.c
+
+mkdir libbar
+cp "$mldir"/multilib.am libbar/
+
+cat >libbar/configure.ac <<'END'
+AC_PREREQ(2.57)
+AC_INIT(libbar, 0.1, nobody@localhost)
+# Apparently it doesn't work to have auxdir=.. when
+# multilib uses symlinked trees.
+AC_CONFIG_AUX_DIR(.)
+AM_INIT_AUTOMAKE
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_RANLIB
+AM_ENABLE_MULTILIB(Makefile,[..])
+AC_CONFIG_FILES([Makefile sub/Makefile])
+AC_OUTPUT
+END
+
+cat >libbar/Makefile.am <<'END'
+SUBDIRS = sub
+noinst_LIBRARIES = libbar.a
+libbar_a_SOURCES = bar.c
+include $(top_srcdir)/multilib.am
+END
+
+mkdir libbar/sub
+echo 'include $(top_srcdir)/multilib.am' >libbar/sub/Makefile.am
+: > libbar/bar.c
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+cd libfoo
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+cd ..
+
+cd libbar
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+cd ..
+
+# Check VPATH builds
+mkdir build
+cd build
+../configure --enable-multilib CC=mycc
+$MAKE
+test -f debug/libfoo/libfoo.a
+test -f debug/libbar/libbar.a
+test -f libfoo/libfoo.a
+test -f libbar/libbar.a
+$MAKE install
+$MAKE distcleancheck
+
+# Check standard builds.
+cd ..
+# Why to I have to specify --with-target-subdir?
+./configure --enable-multilib --with-target-subdir=. CC=mycc
+$MAKE check
+DISTCHECK_CONFIGURE_FLAGS='--enable-multilib CC=mycc' $MAKE distcheck
+
+:
diff --git a/t/no-extra-makefile-code.sh b/t/no-extra-makefile-code.sh
new file mode 100755
index 000000000..1742dc433
--- /dev/null
+++ b/t/no-extra-makefile-code.sh
@@ -0,0 +1,36 @@
+#!/bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Check that we don't emit harmless but useless code in the generated
+# Makefile.in when the project does not use compiled languages. Motivated
+# by a regression caused by removal of automatic de-ANSI-fication support:
+# <http://lists.gnu.org/archive/html/automake-patches/2011-08/msg00200.html>
+
+. ./defs || Exit 1
+
+echo AC_OUTPUT >> configure.ac
+
+: > Makefile.am
+
+rm -f depcomp compile
+
+$ACLOCAL
+$AUTOMAKE
+
+$EGREP 'DEFAULT_INCLUDES|@am__isrc@|-compile|\$\(OBJEXT\)|tab\.[ch]' \
+ Makefile.in && Exit 1
+
+:
diff --git a/t/no-outdir-option.sh b/t/no-outdir-option.sh
new file mode 100755
index 000000000..621253479
--- /dev/null
+++ b/t/no-outdir-option.sh
@@ -0,0 +1,29 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Check that the '-o' aka '--output-dir' option is not recognized anymore.
+
+. ./defs || Exit 1
+
+: > Makefile.am
+
+AUTOMAKE_fails -Wno-error --output-dir=foo
+grep 'unrecognized option.*--output-dir' stderr
+
+AUTOMAKE_fails -Wno-error -o foo
+grep 'unrecognized option.*-o' stderr
+
+:
diff --git a/t/nobase-libtool.sh b/t/nobase-libtool.sh
new file mode 100755
index 000000000..38008cd0a
--- /dev/null
+++ b/t/nobase-libtool.sh
@@ -0,0 +1,95 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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 nobase_* works for libtool libraries and programs as well.
+# This is just the libtool equivalent of nobase.test, split
+# up for greater exposure of nobase.test.
+
+required='cc libtoolize'
+. ./defs || Exit 1
+
+cat >> configure.ac <<'EOF'
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_LIBTOOL
+AC_OUTPUT
+EOF
+
+cat > Makefile.am << 'EOF'
+fooexecdir = $(prefix)/foo
+fooexec_LTLIBRARIES = sub/libbase.la
+nobase_fooexec_LTLIBRARIES = sub/libnobase.la
+fooexec_PROGRAMS = sub/base
+nobase_fooexec_PROGRAMS = sub/nobase
+sub_libbase_la_SOURCES = source2.c
+sub_libnobase_la_SOURCES = source2.c
+sub_base_SOURCES = source.c
+sub_nobase_SOURCES = source.c
+
+test-install-data: install-data
+ test ! -f inst/foo/sub/libnobase.la
+ test ! -f inst/foo/libbase.la
+
+test-install-exec: install-exec
+ test -f inst/foo/sub/libnobase.la
+ test ! -f inst/foo/libnobase.la
+ test -f inst/foo/libbase.la
+
+.PHONY: test-install-exec test-install-data
+EOF
+
+mkdir sub
+
+cat >source.c <<'EOF'
+int
+main (int argc, char *argv[])
+{
+ return 0;
+}
+EOF
+cp source.c source2.c
+
+rm -f install-sh
+
+libtoolize
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a --copy
+./configure --prefix "`pwd`/inst" --program-prefix=p
+
+$MAKE
+$MAKE test-install-data
+$MAKE test-install-exec
+$MAKE uninstall
+
+test `find inst/foo -type f -print | wc -l` = 0
+
+$MAKE install-strip
+
+# Likewise, in a VPATH build.
+
+$MAKE uninstall
+$MAKE distclean
+mkdir build
+cd build
+../configure --prefix "`pwd`/inst" --program-prefix=p
+$MAKE
+$MAKE test-install-data
+$MAKE test-install-exec
+$MAKE uninstall
+test `find inst/foo -type f -print | wc -l` = 0
+
+:
diff --git a/t/nobase-nodist.sh b/t/nobase-nodist.sh
new file mode 100755
index 000000000..54b940b9b
--- /dev/null
+++ b/t/nobase-nodist.sh
@@ -0,0 +1,60 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Interaction of 'nobase_' and 'nodist_' prefixes.
+
+. ./defs || Exit 1
+
+# Simulate no emacs and no python (it shouldn't be needed in this test).
+EMACS="no" PYTHON=":"; export EMCAS PYTHON
+
+cat >> configure.ac << 'END'
+AM_PATH_LISPDIR
+AM_PATH_PYTHON([], [], [:])
+# Simulate no javac (it shouldn't be needed in this test).
+AC_SUBST([JAVAC], [false])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+nobase_nodist_noinst_PYTHON = baz1.py sub/baz2.py
+# Lisp and Java sources are not distributed by default, so try both
+# with and without the 'nodist_' prefix, for more coverage.
+nobase_noinst_LISP = foo1.el sub/foo2.el
+nobase_nodist_noinst_LISP = foo3.el sub/foo4.el
+nobase_noinst_JAVA = bar1.java sub/bar2.java
+nobase_nodist_noinst_JAVA = bar3.java sub/bar4.java
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+./configure
+$MAKE distdir
+
+ls -l $distdir $distdir/* # For debugging.
+test ! -f $distdir/foo1.el
+test ! -f $distdir/sub/foo2.el
+test ! -f $distdir/foo3.el
+test ! -f $distdir/sub/foo4.el
+test ! -f $distdir/bar1.java
+test ! -f $distdir/sub/bar2.java
+test ! -f $distdir/bar3.java
+test ! -f $distdir/sub/bar4.java
+test ! -f $distdir/baz1.py
+test ! -f $distdir/sub/baz2.py
+
+:
diff --git a/t/nobase-python.sh b/t/nobase-python.sh
new file mode 100755
index 000000000..28509018b
--- /dev/null
+++ b/t/nobase-python.sh
@@ -0,0 +1,79 @@
+#! /bin/sh
+# Copyright (C) 2008-2012 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 nobase_* works for python files.
+
+required=python
+. ./defs || Exit 1
+
+cat >>configure.ac <<EOF
+AM_PATH_PYTHON
+AC_OUTPUT
+EOF
+
+cat > Makefile.am <<'END'
+mydir=$(prefix)/my
+my_PYTHON = one.py sub/base.py
+nobase_my_PYTHON = two.py sub/nobase.py
+
+test-install-data: install-data
+ find inst -print; : For debugging.
+ test -f inst/my/one.py
+ test -f inst/my/one.pyc
+ test -f inst/my/two.py
+ test -f inst/my/two.pyc
+ test -f inst/my/base.py
+ test -f inst/my/base.pyc
+ test -f inst/my/sub/nobase.py
+ test -f inst/my/sub/nobase.pyc
+ test ! -f inst/my/nobase.py
+ test ! -f inst/my/nobase.pyc
+END
+
+mkdir sub
+
+for file in one.py sub/base.py two.py sub/nobase.py
+do
+ echo 'def one(): return 1' >$file
+done
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+./configure --prefix "`pwd`/inst" --program-prefix=p
+
+$MAKE
+$MAKE test-install-data
+$MAKE uninstall
+
+find inst/my -type f -print | grep . && Exit 1
+
+$MAKE install-strip
+
+# Likewise, in a VPATH build.
+
+$MAKE uninstall
+$MAKE distclean
+mkdir build
+cd build
+../configure --prefix "`pwd`/inst" --program-prefix=p
+$MAKE
+$MAKE test-install-data
+$MAKE uninstall
+find inst/my -type f -print | grep . && Exit 1
+
+:
diff --git a/t/nobase.sh b/t/nobase.sh
new file mode 100755
index 000000000..e7661c09a
--- /dev/null
+++ b/t/nobase.sh
@@ -0,0 +1,147 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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 nobase_* works.
+
+required=cc
+. ./defs || Exit 1
+
+cat >> configure.ac <<'EOF'
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_RANLIB
+AC_OUTPUT
+EOF
+
+cat > Makefile.am << 'EOF'
+foodir = $(prefix)/foo
+fooexecdir = $(prefix)/foo
+
+foo_HEADERS = sub/base.h sub/base-gen.h
+nobase_foo_HEADERS = sub/nobase.h sub/nobase-gen.h
+
+dist_foo_DATA = sub/base.dat sub/base-gen.dat
+nobase_dist_foo_DATA = sub/nobase.dat sub/nobase-gen.dat
+
+dist_fooexec_SCRIPTS = sub/base.sh sub/base-gen.sh
+nobase_dist_fooexec_SCRIPTS = sub/nobase.sh sub/nobase-gen.sh
+
+fooexec_PROGRAMS = sub/base
+nobase_fooexec_PROGRAMS = sub/nobase
+sub_base_SOURCES = source.c
+sub_nobase_SOURCES = source.c
+
+fooexec_LIBRARIES = sub/libbase.a
+nobase_fooexec_LIBRARIES = sub/libnobase.a
+sub_libbase_a_SOURCES = source.c
+sub_libnobase_a_SOURCES = source.c
+
+generated_files = sub/base-gen.h sub/nobase-gen.h sub/base-gen.dat \
+sub/nobase-gen.dat sub/base-gen.sh sub/nobase-gen.sh
+
+$(generated_files):
+ $(MKDIR_P) sub
+ echo "generated file $@" > $@
+
+CLEANFILES = $(generated_files)
+
+test-install-data: install-data
+ test -f inst/foo/sub/nobase.h
+ test ! -f inst/foo/nobase.h
+ test -f inst/foo/sub/nobase-gen.h
+ test ! -f inst/foo/nobase-gen.h
+ test -f inst/foo/base.h
+ test -f inst/foo/base-gen.h
+ test -f inst/foo/sub/nobase.dat
+ test ! -f inst/foo/nobase.dat
+ test -f inst/foo/sub/nobase-gen.dat
+ test ! -f inst/foo/nobase-gen.dat
+ test -f inst/foo/base.dat
+ test -f inst/foo/base-gen.dat
+ test ! -f inst/foo/sub/pnobase.sh
+ test ! -f inst/foo/sub/pnobase-gen.sh
+ test ! -f inst/foo/pbase.sh
+ test ! -f inst/foo/pbase-gen.sh
+ test ! -f inst/foo/sub/pnobase$(EXEEXT)
+ test ! -f inst/foo/pbase$(EXEEXT)
+ test ! -f inst/foo/sub/libnobase.a
+ test ! -f inst/foo/libbase.a
+
+test-install-exec: install-exec
+ test -f inst/foo/sub/pnobase.sh
+ test ! -f inst/foo/pnobase.sh
+ test -f inst/foo/sub/pnobase-gen.sh
+ test ! -f inst/foo/pnobase-gen.sh
+ test -f inst/foo/pbase.sh
+ test -f inst/foo/pbase-gen.sh
+ test -f inst/foo/sub/pnobase$(EXEEXT)
+ test ! -f inst/foo/pnobase$(EXEEXT)
+ test -f inst/foo/pbase$(EXEEXT)
+ test -f inst/foo/sub/libnobase.a
+ test ! -f inst/foo/libnobase.a
+ test -f inst/foo/libbase.a
+
+.PHONY: test-install-exec test-install-data
+EOF
+
+mkdir sub
+
+: > sub/base.h
+: > sub/nobase.h
+: > sub/base.dat
+: > sub/nobase.dat
+: > sub/base.sh
+: > sub/nobase.sh
+
+cat >source.c <<'EOF'
+int
+main (int argc, char *argv[])
+{
+ return 0;
+}
+EOF
+cp source.c source2.c
+
+rm -f install-sh
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a --copy
+./configure --prefix "`pwd`/inst" --program-prefix=p
+
+$MAKE
+$MAKE test-install-data
+$MAKE test-install-exec
+$MAKE uninstall
+
+test `find inst/foo -type f -print | wc -l` = 0
+
+$MAKE install-strip
+
+# Likewise, in a VPATH build.
+
+$MAKE uninstall
+$MAKE distclean
+mkdir build
+cd build
+../configure --prefix "`pwd`/inst" --program-prefix=p
+$MAKE
+$MAKE test-install-data
+$MAKE test-install-exec
+$MAKE uninstall
+test `find inst/foo -type f -print | wc -l` = 0
+
+:
diff --git a/t/nodef.sh b/t/nodef.sh
new file mode 100755
index 000000000..3c55745b3
--- /dev/null
+++ b/t/nodef.sh
@@ -0,0 +1,58 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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 that PACKAGE and VERSION are AC_DEFINEd when requested.
+
+. ./defs || Exit 1
+
+# -------------------------------------------------------------------
+# Do not upgrade this file to use the modern AC_INIT/AM_INIT_AUTOMAKE
+# forms. The day these obsolete AC_INIT and AM_INIT_AUTOMAKE forms
+# are dropped, just erase the file.
+# nodef2.test contains the modern version of this test.
+# -------------------------------------------------------------------
+
+# First, check that PACKAGE and VERSION are output by default.
+
+cat > configure.ac << 'END'
+AC_INIT
+AM_INIT_AUTOMAKE([UnIqUe_PaCkAgE], [UnIqUe_VeRsIoN])
+AC_OUTPUT(output)
+END
+
+echo 'DEFS = @DEFS@' > output.in
+
+$ACLOCAL
+$AUTOCONF
+./configure
+
+grep 'DEFS.*-DVERSION=\\"UnIqUe' output
+
+# Then, check that PACKAGE and VERSION are not output if requested.
+
+cat > configure.ac << 'END'
+AC_INIT
+AM_INIT_AUTOMAKE([UnIqUe_PaCkAgE], [UnIqUe_VeRsIoN], [no])
+AC_OUTPUT(output)
+END
+
+$ACLOCAL
+$AUTOCONF
+./configure
+
+grep 'DEFS.*-DVERSION=\\"UnIqUe' output && Exit 1
+
+:
diff --git a/t/nodef2.sh b/t/nodef2.sh
new file mode 100755
index 000000000..1af7b0d36
--- /dev/null
+++ b/t/nodef2.sh
@@ -0,0 +1,54 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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 that PACKAGE and VERSION are AC_DEFINEd when requested.
+
+. ./defs || Exit 1
+
+# First, check that PACKAGE and VERSION are output by default.
+
+cat > configure.ac << 'END'
+AC_INIT([UnIqUe_PaCkAgE], [UnIqUe_VeRsIoN])
+AM_INIT_AUTOMAKE
+AC_OUTPUT(output)
+END
+
+echo 'DEFS = @DEFS@' > output.in
+
+$ACLOCAL
+$AUTOCONF
+./configure
+
+grep 'DEFS.*-DVERSION=\\"UnIqUe' output
+
+# Then, check that PACKAGE and VERSION are not output if requested.
+
+cat > configure.ac << 'END'
+AC_INIT([UnIqUe_PaCkAgE], [UnIqUe_VeRsIoN])
+AM_INIT_AUTOMAKE([no-define])
+AC_OUTPUT(output Makefile)
+END
+
+: > Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE # Dummy call to make sure Automake grok 'no-define' silently.
+./configure
+
+grep 'DEFS.*-DVERSION=\\"UnIqUe' output && Exit 1
+
+:
diff --git a/t/nodep.sh b/t/nodep.sh
new file mode 100755
index 000000000..5dcad1ce9
--- /dev/null
+++ b/t/nodep.sh
@@ -0,0 +1,40 @@
+#! /bin/sh
+# Copyright (C) 1999-2012 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/>.
+
+# Test to make sure no-dependencies option does the right thing.
+# Bug report from Greg A. Woods.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = no-dependencies
+bin_PROGRAMS = zardoz
+zardoz_SOURCES = y.c
+END
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+END
+
+mkdir x
+
+: > y.c
+
+$ACLOCAL
+$AUTOMAKE
+
+grep '%' Makefile.in && Exit 1
+Exit 0
diff --git a/t/nodep2.sh b/t/nodep2.sh
new file mode 100755
index 000000000..edf0fa9da
--- /dev/null
+++ b/t/nodep2.sh
@@ -0,0 +1,44 @@
+#! /bin/sh
+# Copyright (C) 2006-2012 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/>.
+
+# Another test to make sure no-dependencies option does the right thing.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = foo
+foo_SOURCES = a.c b.cpp c.m d.S e.java f.upc
+END
+
+cat > configure.ac << 'END'
+AC_INIT([nodep2], [1], [bug-automake@gnu.org])
+AM_INIT_AUTOMAKE([no-dependencies])
+AC_CONFIG_FILES([Makefile])
+AC_PROG_CC
+AC_PROG_CXX
+AC_PROG_OBJC
+AM_PROG_AS
+AM_PROG_GCJ
+AM_PROG_UPC
+AC_OUTPUT
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+grep DEPMODE Makefile.in && Exit 1
+
+:
diff --git a/t/nodepcomp.sh b/t/nodepcomp.sh
new file mode 100755
index 000000000..4691efa91
--- /dev/null
+++ b/t/nodepcomp.sh
@@ -0,0 +1,26 @@
+#! /bin/sh
+# Copyright (C) 2000-2012 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/>.
+
+# Test to make sure depcomp isn't always required.
+
+. ./defs || Exit 1
+
+rm -f depcomp
+
+: > Makefile.am
+
+$ACLOCAL
+$AUTOMAKE
diff --git a/t/nodist.sh b/t/nodist.sh
new file mode 100755
index 000000000..92cc2f75a
--- /dev/null
+++ b/t/nodist.sh
@@ -0,0 +1,40 @@
+#! /bin/sh
+# Copyright (C) 1999-2012 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/>.
+
+# Test to make sure dist_*_SOURCES and nodist_*_SOURCES work.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = eyeball
+
+eyeball_SOURCES = a.c
+nodist_eyeball_SOURCES = b.c
+dist_eyeball_SOURCES = c.c
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+grep '^am_eyeball_OBJECTS' Makefile.in
+grep '^DIST_SOURCES =' Makefile.in
+grep '^DIST_SOURCES =.*nodist' Makefile.in && Exit 1
+
+:
diff --git a/t/nodist2.sh b/t/nodist2.sh
new file mode 100755
index 000000000..36851be90
--- /dev/null
+++ b/t/nodist2.sh
@@ -0,0 +1,38 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test to make sure nodist_noinst_HEADERS work.
+# For PR 249.
+
+. ./defs || Exit 1
+
+cat >> configure.ac <<'EOF'
+AC_OUTPUT
+EOF
+
+cat > Makefile.am << 'EOF'
+nodist_noinst_HEADERS = baz.h
+EOF
+
+: > baz.h
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+./configure --prefix "`pwd`/install"
+$MAKE install-data
+
+:
diff --git a/t/nodist3.sh b/t/nodist3.sh
new file mode 100755
index 000000000..23becc12d
--- /dev/null
+++ b/t/nodist3.sh
@@ -0,0 +1,37 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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/>.
+
+# Test to make sure no-dist option works.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+END
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = no-dist
+bin_PROGRAMS = eyeball
+eyeball_SOURCES = a.c
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+grep '^dist:' Makefile.in && Exit 1
+grep '^DIST_SOURCES =' Makefile.in && Exit 1
+
+:
diff --git a/t/noinst.sh b/t/noinst.sh
new file mode 100755
index 000000000..887c7a73c
--- /dev/null
+++ b/t/noinst.sh
@@ -0,0 +1,32 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Check to make sure "make install" will build all in directory with
+# nothing to install.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+all-local:
+ exit 1
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+grep '^install[-a-z]*:.* all' Makefile.in
+
+:
diff --git a/t/noinstdir.sh b/t/noinstdir.sh
new file mode 100755
index 000000000..39abdc7e2
--- /dev/null
+++ b/t/noinstdir.sh
@@ -0,0 +1,49 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test to make sure that noinst_* and check_* are not installed.
+# From Pavel Roskin.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+noinst_SCRIPTS = foo.sh
+noinst_DATA = foo.xpm
+noinst_LIBRARIES = libfoo.a
+noinst_PROGRAMS = foo
+noinst_HEADERS = foo.h
+check_SCRIPTS = bar.sh
+check_DATA = bar.xpm
+check_LIBRARIES = libbar.a
+check_PROGRAMS = bar
+check_HEADERS = bar.h
+END
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_RANLIB
+END
+
+: > ar-lib
+
+$ACLOCAL
+$AUTOMAKE
+
+grep 'noinstdir' Makefile.in && Exit 1
+grep 'checkdir' Makefile.in && Exit 1
+
+:
diff --git a/t/nolink.sh b/t/nolink.sh
new file mode 100755
index 000000000..dea627127
--- /dev/null
+++ b/t/nolink.sh
@@ -0,0 +1,36 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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 Automake does not emit a link rule for unknown languages.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = no-exeext
+
+bin_PROGRAMS = meal
+meal_SOURCES = beans.veg beef.meat
+
+meal: beans.veg beef.meat
+ cat beans.veg beef.meat > meal
+END
+
+$ACLOCAL
+$AUTOMAKE -Wno-override
+
+grep '^meal.*:' Makefile.in | grep -v beef.meat && Exit 1
+
+Exit 0
diff --git a/t/nostdinc.sh b/t/nostdinc.sh
new file mode 100755
index 000000000..8b780a6e5
--- /dev/null
+++ b/t/nostdinc.sh
@@ -0,0 +1,56 @@
+#! /bin/sh
+# Copyright (C) 1999-2012 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/>.
+
+# Test to make sure nostdinc option works correctly.
+
+# We don't require a C compiler explicitly, because the first part of the
+# test (where 'Makefile.in' is grepped) does not require one. Insted, we
+# just skip the rest of the test if configure fails to find a working C
+# compiler.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = nostdinc
+bin_PROGRAMS = foo
+foo_SOURCES = foo.c
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+$EGREP '(-I *\.|-I.*srcdir|am__isrc)' Makefile.in && Exit 1
+
+# We'll test the fully-processed Makefile too.
+$AUTOCONF
+
+# Test with $builddir != $srcdir
+mkdir build
+cd build
+../configure || Exit $?
+$EGREP '.*-I *(\.|\$.srcdir.)' Makefile && Exit 1
+
+# Test with $builddir = $srcdir
+cd ..
+./configure || Exit $?
+$EGREP '.*-I *(\.|\$.srcdir.)' Makefile && Exit 1
+
+Exit 0
diff --git a/t/notrans.sh b/t/notrans.sh
new file mode 100755
index 000000000..487b66f3d
--- /dev/null
+++ b/t/notrans.sh
@@ -0,0 +1,131 @@
+#! /bin/sh
+# Copyright (C) 2008-2012 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/>.
+
+# Check all notrans_, dist_, nodist_ prefix combinations for MANS
+# primary and install-man dependencies.
+
+. ./defs || Exit 1
+
+cat >>configure.ac <<'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'EOF'
+man_MANS = foo.1 foo2.1
+dist_man_MANS = bar.2 bar2.2
+nodist_man_MANS = baz.3 baz2.3
+notrans_man_MANS = x-foo.4 x-foo2.4
+notrans_dist_man_MANS = x-bar.5 x-bar2.5
+notrans_nodist_man_MANS = x-baz.6 x-baz2.6
+man7_MANS = y-foo.man y-foo2.man
+dist_man5_MANS = y-bar.man y-bar2.man
+nodist_man4_MANS = y-baz.man y-baz2.man
+notrans_man3_MANS = z-foo.man z-foo2.man
+notrans_dist_man2_MANS = z-bar.man z-bar2.man
+notrans_nodist_man1_MANS = z-baz.man z-baz2.man
+
+# These two are ignored.
+dist_notrans_man_MANS = nosuch.8
+nodist_notrans_man9_MANS = nosuch.man
+
+y-foo.man y-foo2.man:
+ : >$@
+y-bar.man y-bar2.man:
+ : >$@
+y-baz.man y-baz2.man:
+ : >$@
+z-foo.man z-foo2.man:
+ : >$@
+z-bar.man z-bar2.man:
+ : >$@
+z-baz.man z-baz2.man:
+ : >$@
+
+test-install: install
+ test -f inst/man/man1/gnu-foo.1
+ test -f inst/man/man1/gnu-foo2.1
+ test -f inst/man/man2/gnu-bar.2
+ test -f inst/man/man2/gnu-bar2.2
+ test -f inst/man/man3/gnu-baz.3
+ test -f inst/man/man3/gnu-baz2.3
+ test -f inst/man/man4/x-foo.4
+ test -f inst/man/man4/x-foo2.4
+ test -f inst/man/man5/x-bar.5
+ test -f inst/man/man5/x-bar2.5
+ test -f inst/man/man6/x-baz.6
+ test -f inst/man/man6/x-baz2.6
+ test -f inst/man/man7/gnu-y-foo.7
+ test -f inst/man/man7/gnu-y-foo2.7
+ test -f inst/man/man5/gnu-y-bar.5
+ test -f inst/man/man5/gnu-y-bar2.5
+ test -f inst/man/man4/gnu-y-baz.4
+ test -f inst/man/man4/gnu-y-baz2.4
+ test -f inst/man/man3/z-foo.3
+ test -f inst/man/man3/z-foo2.3
+ test -f inst/man/man2/z-bar.2
+ test -f inst/man/man2/z-bar2.2
+ test -f inst/man/man1/z-baz.1
+ test -f inst/man/man1/z-baz2.1
+ if test -d inst/man/man8; then (exit 1); else :; fi
+ if test -d inst/man/man9; then (exit 1); else :; fi
+EOF
+
+: > foo.1
+: > foo2.1
+: > bar.2
+: > bar2.2
+: > baz.3
+: > baz2.3
+: > x-foo.4
+: > x-foo2.4
+: > x-bar.5
+: > x-bar2.5
+: > x-baz.6
+: > x-baz2.6
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+grep '^install-man1:' Makefile.in | grep '\$(man_MANS)'
+grep '^install-man2:' Makefile.in | grep '\$(dist_man_MANS)'
+grep '^install-man3:' Makefile.in | grep '\$(nodist_man_MANS)'
+grep '^install-man4:' Makefile.in | grep '\$(notrans_man_MANS)'
+grep '^install-man5:' Makefile.in | grep '\$(notrans_dist_man_MANS)'
+grep '^install-man6:' Makefile.in | grep '\$(notrans_nodist_man_MANS)'
+
+if grep '^install-man8:' Makefile.in; then Exit 1; else :; fi
+if grep '^install-man9:' Makefile.in; then Exit 1; else :; fi
+
+./configure --program-prefix=gnu- --prefix "`pwd`"/inst --mandir "`pwd`"/inst/man
+$MAKE
+$MAKE test-install
+test `find inst/man -type f -print | wc -l` = 24
+$MAKE uninstall
+test `find inst/man -type f -print | wc -l` = 0
+
+# Opportunistically test for installdirs.
+rm -rf inst
+$MAKE installdirs
+test -d inst/man/man1
+test -d inst/man/man2
+test -d inst/man/man3
+test -d inst/man/man4
+test -d inst/man/man5
+test -d inst/man/man6
+test -d inst/man/man7
+if test -d inst/man/man8; then Exit 1; else :; fi
+if test -d inst/man/man9; then Exit 1; else :; fi
diff --git a/t/number.sh b/t/number.sh
new file mode 100755
index 000000000..b96e1180d
--- /dev/null
+++ b/t/number.sh
@@ -0,0 +1,37 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test to make sure _OBJECTS only generated once. Bug reported by
+# Joerg-Martin Schwarz.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = zardoz
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+grep '^zardoz_OBJECTS' Makefile.in
+count=`grep -c '^zardoz_OBJECTS' Makefile.in`
+test $count -eq 1
+
+:
diff --git a/t/objc.sh b/t/objc.sh
new file mode 100755
index 000000000..f56c76d8c
--- /dev/null
+++ b/t/objc.sh
@@ -0,0 +1,36 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test that '.m' extension works.
+# From Ralf Corsepius (for C++).
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_OBJC
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = hello
+hello_SOURCES = hello.m
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+grep '^\.SUFFIXES:.*\.m' Makefile.in
+
+:
diff --git a/t/objc2.sh b/t/objc2.sh
new file mode 100755
index 000000000..290bf2642
--- /dev/null
+++ b/t/objc2.sh
@@ -0,0 +1,31 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Test that Automake suggests using AC_PROG_OBJC if Objective C sources
+# are used.
+
+. ./defs || Exit 1
+
+echo AC_PROG_CC >>configure.ac
+
+cat >Makefile.am <<'END'
+bin_PROGRAMS = hello
+hello_SOURCES = hello.m
+END
+
+$ACLOCAL
+AUTOMAKE_fails
+grep AC_PROG_OBJC stderr
diff --git a/t/objext-pr10128.sh b/t/objext-pr10128.sh
new file mode 100755
index 000000000..2fe2dfd2c
--- /dev/null
+++ b/t/objext-pr10128.sh
@@ -0,0 +1,58 @@
+#! /bin/sh
+# Copyright (C) 2012 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/>.
+
+# Test for automake bug#10128: $(OBJEXT) redefinition causes
+# $(foo_OBJECTS) to be defined as empty.
+
+. ./defs || Exit 1
+
+echo AC_OUTPUT >> configure.ac
+
+cat > Makefile.am <<'END'
+LINK = echo >$@ Linked $@ from
+OBJEXT = fasl
+EXEEXT =
+
+noinst_PROGRAMS = foo zardoz
+foo_SOURCES = foo.lisp
+zardoz_SOURCES = mu1.lisp mu2.lisp
+
+## Un-commenting this is enough to make the test pass. Weird!
+##.lisp.o:
+
+.lisp.fasl:
+ touch $@
+
+.PHONY: test
+test:
+ is $(foo_OBJECTS) == foo.fasl
+ is $(zardoz_OBJECTS) == mu1.fasl mu2.fasl
+END
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+
+./configure
+$MAKE test
+touch foo.lisp mu1.lisp mu2.lisp
+$MAKE all
+cat foo
+cat zardoz
+test "`cat foo`" = "Linked foo from foo.fasl"
+test "`cat zardoz`" = "Linked zardoz from mu1.fasl mu2.fasl"
+
+:
diff --git a/t/obsolete.sh b/t/obsolete.sh
new file mode 100755
index 000000000..c4240c200
--- /dev/null
+++ b/t/obsolete.sh
@@ -0,0 +1,57 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test to make sure obsolete macros can be autoupdated.
+
+# We need the following indirection in case someone exported e.g.
+# AUTOUPDATE='autoupdate --verbose'.
+set x ${AUTOUPDATE-autoupdate}
+required=$2
+. ./defs || Exit 1
+
+cat > configure.ac << 'END'
+AC_INIT
+END
+
+$PERL -ne '/AU_DEFUN\(\[(\w+)\]/ && print "$1\n"' \
+ "$am_automake_acdir/obsolete.m4" > obs
+cat obs >> configure.ac
+$PERL -ne 'chomp; print "grep $_ output || Exit 1\n"; ' obs > obs.1
+$PERL -ne 'chomp; print "grep $_ configure.ac && Exit 1\n"; ' obs > obs.2
+echo : >> obs.1 # Since it will be sourced, it must end with a success.
+echo : >> obs.2 # Likewise.
+
+cat configure.ac # For debugging.
+cat obs.1 # Likewise.
+cat obs.2 # Likewise.
+
+# Sanity check. Make sure we have added something to configure.ac.
+test `wc -l <configure.ac` -gt 1
+
+$ACLOCAL
+
+# Expect Autoconf to complain about each of the macros in obs.
+$AUTOCONF -Wobsolete >output 2>&1 || { cat output; Exit 1; }
+cat output
+. ./obs.1
+# Make sure Autoupdate remove each of these macros.
+$AUTOUPDATE
+. ./obs.2
+
+# Autoconf should be able to grok the updated configure.ac.
+$AUTOCONF
+
+:
diff --git a/t/oldvars.sh b/t/oldvars.sh
new file mode 100755
index 000000000..87d9cf1fa
--- /dev/null
+++ b/t/oldvars.sh
@@ -0,0 +1,35 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Use of these variables is deprecated:
+# LISP, HEADERS, DATA, SCRIPTS, LTLIBRARIES, LIBRARIES, PROGRAMS, MANS.
+
+. ./defs || Exit 1
+
+cat >Makefile.am <<\EOF
+DATA =
+HEADERS =
+LIBRARIES =
+LISP =
+LTLIBRARIES =
+MANS =
+PROGRAMS =
+SCRIPTS =
+EOF
+
+$ACLOCAL
+AUTOMAKE_fails
+test `grep -c anachronism stderr` -eq 8
diff --git a/t/order.sh b/t/order.sh
new file mode 100755
index 000000000..238340346
--- /dev/null
+++ b/t/order.sh
@@ -0,0 +1,32 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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 AC_DEFUN is handled correctly. This test isn't named very
+# well. Report from Jim Meyering.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+jm_TEST
+FOO
+END
+
+cat > acinclude.m4 << 'END'
+AC_DEFUN([jm_TEST])
+AC_DEFUN([FOO], [AC_REQUIRE([jm_TEST])])
+END
+
+$ACLOCAL
diff --git a/t/output-order.sh b/t/output-order.sh
new file mode 100755
index 000000000..879b678c3
--- /dev/null
+++ b/t/output-order.sh
@@ -0,0 +1,53 @@
+#! /bin/sh
+# Copyright (C) 2008-2012 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/>.
+
+# Test that 'automake -a' output order is stable.
+# From report by Bruno Haible.
+
+. ./defs || Exit 1
+
+cat >>configure.ac <<'END'
+AC_OUTPUT
+END
+
+: >Makefile.am
+: >AUTHORS
+: >ChangeLog
+: >NEWS
+: >README
+
+cat >.autom4te.cfg <<'END'
+begin-language: "Autoconf"
+args: --no-cache
+end-language: "Autoconf"
+begin-language: "Autoconf-without-aclocal-m4"
+args: --no-cache
+end-language: "Autoconf-without-aclocal-m4"
+END
+
+$ACLOCAL
+$AUTOCONF
+rm -f missing install-sh
+$AUTOMAKE --add-missing --copy 2>stderr || { cat stderr >&2; Exit 1; }
+cat stderr >&2
+
+for i in 1 2 3 4 5 6; do
+ rm -f missing install-sh INSTALL COPYING
+ # The grep prevents a Heisenbug with the HP-UX shell and VERBOSE=yes.
+ $AUTOMAKE --add-missing --copy 2>&1 >/dev/null |
+ grep -v /dev/null |
+ diff - stderr
+done
diff --git a/t/output.sh b/t/output.sh
new file mode 100755
index 000000000..faf877ba5
--- /dev/null
+++ b/t/output.sh
@@ -0,0 +1,35 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test to make sure files listed in AC_OUTPUT are found.
+
+. ./defs || Exit 1
+
+cat > configure.ac <<END
+AC_INIT([$me], [1.0])
+AM_INIT_AUTOMAKE
+AC_OUTPUT([Makefile frob/zardoz])
+END
+
+: > Makefile.am
+
+mkdir frob
+: > frob/zardoz.in
+
+$ACLOCAL
+$AUTOMAKE
+
+:
diff --git a/t/output10.sh b/t/output10.sh
new file mode 100755
index 000000000..92492f692
--- /dev/null
+++ b/t/output10.sh
@@ -0,0 +1,61 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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 an AC_CONFIG_FILES can have an AC_CONFIG_FILES output as input.
+# This is comparable to output9.test, but testing Makefile rules.
+# PR/411
+
+. ./defs || Exit 1
+
+cat >> configure.ac << END
+AC_SUBST([FOO], [top])
+AC_SUBST([BAR], [bot])
+AC_CONFIG_FILES([a/top])
+AC_CONFIG_FILES([a/bot])
+AC_CONFIG_FILES([b/Makefile:a/top:b/Makefile.in:a/bot])
+AC_OUTPUT
+END
+
+mkdir a
+mkdir b
+
+cat >Makefile.am <<\EOF
+SUBDIRS = b
+dist-hook:
+ test ! -f $(distdir)/a/top
+ test ! -f $(distdir)/a/bot
+EOF
+
+cat >b/Makefile.am <<\EOF
+output:
+ echo $(TOP)$(BOT) > ok
+EOF
+
+echo TOP=@FOO@ >a/top.in
+echo BOT=@BAR@ >a/bot.in
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+mkdir build
+cd build
+../configure
+cd b
+$MAKE output
+grep topbot ok
+cd ..
+$MAKE distcheck
diff --git a/t/output11.sh b/t/output11.sh
new file mode 100755
index 000000000..4413f9732
--- /dev/null
+++ b/t/output11.sh
@@ -0,0 +1,63 @@
+#! /bin/sh
+# Copyright (C) 2005-2012 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 an AC_CONFIG_FILES ignore filenames with shell variables.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << \END
+AC_SUBST([FOO], [foo])
+file1=this.in
+echo @FOO@ >$file1
+file2=that
+file3=mumble
+file4=foo
+AC_CONFIG_FILES([this:$file1],, [file1=$file1])
+AC_CONFIG_FILES([sub/this:$file1])
+AC_CONFIG_FILES([${file2}:this],, [file2=$file2])
+AC_CONFIG_FILES([$file3],, [file3=$file3])
+AC_CONFIG_FILES([$file4:foo.in],, [file4=$file4])
+AC_CONFIG_FILES([sub/Makefile])
+AC_OUTPUT
+END
+
+mkdir sub
+
+cat >Makefile.am <<\EOF
+SUBDIRS = sub
+EXTRA_DIST = mumble.in
+DISTCLEANFILES = this.in that mumble foo
+dist-hook:
+ test -f $(distdir)/foo.in
+ test ! -f $(distdir)/this
+EOF
+
+echo @FOO@ >mumble.in
+echo @FOO@ >foo.in
+: >sub/Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+$FGREP ' $file' Makefile.in sub/Makefile.in && Exit 1
+
+./configure
+$MAKE distcheck
+cd sub
+rm -f this
+$MAKE this
+grep foo this
diff --git a/t/output12.sh b/t/output12.sh
new file mode 100755
index 000000000..a3693cc29
--- /dev/null
+++ b/t/output12.sh
@@ -0,0 +1,60 @@
+#! /bin/sh
+# Copyright (C) 2005-2012 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 an AC_CONFIG_FILES process filenames with AC_SUBST variables.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << \END
+AC_SUBST([FOO], [foo])
+AC_SUBST([file1], [this.in])
+echo @FOO@ >$file1
+AC_SUBST([file2], [that])
+AC_SUBST([file3], [mumble])
+AC_SUBST([file4], [foo])
+AC_CONFIG_FILES([this:$file1],, [file1=$file1])
+AC_CONFIG_FILES([sub/this:$file1])
+AC_CONFIG_FILES([${file2}:this],, [file2=$file2])
+AC_CONFIG_FILES([${file3}],, [file3=$file3])
+AC_CONFIG_FILES([${file4}:foo.in],, [file4=$file4])
+AC_CONFIG_FILES([sub/Makefile])
+AC_OUTPUT
+END
+
+mkdir sub
+
+cat >Makefile.am <<\EOF
+SUBDIRS = sub
+DISTCLEANFILES = $(file1)
+dist-hook:
+ test -f $(distdir)/foo.in
+ test ! -f $(distdir)/this
+EOF
+
+echo @FOO@ >mumble.in
+echo @FOO@ >foo.in
+: >sub/Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+$MAKE distcheck
+cd sub
+rm -f this
+$MAKE this
+grep foo this
diff --git a/t/output13.sh b/t/output13.sh
new file mode 100755
index 000000000..065bdb5cb
--- /dev/null
+++ b/t/output13.sh
@@ -0,0 +1,50 @@
+#! /bin/sh
+# Copyright (C) 2007-2012 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 an AC_CONFIG_FILES, AC_CONFIG_LINKS, and AC_CONFIG_COMMANDS
+# are not prerequisites of 'all'.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << \END
+AC_SUBST([FOO], [foo])
+if $create; then
+ AC_CONFIG_FILES([file])
+ AC_CONFIG_LINKS([link:input])
+ AC_CONFIG_COMMANDS([stamp], [echo stamp > stamp])
+fi
+AC_OUTPUT
+END
+
+: >Makefile.am
+
+echo link > input
+echo @FOO@ >file.in
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure create=false
+$MAKE
+test ! -f file
+test ! -f link
+test ! -f stamp
+
+./configure create=:
+test -f file
+test -f link
+test -f stamp
diff --git a/t/output2.sh b/t/output2.sh
new file mode 100755
index 000000000..41c81bfe7
--- /dev/null
+++ b/t/output2.sh
@@ -0,0 +1,38 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Another AC_OUTPUT test. From report by Ulrich Drepper.
+
+. ./defs || Exit 1
+
+cat > configure.ac <<END
+AC_INIT([$me], [1.0])
+AM_INIT_AUTOMAKE
+AC_OUTPUT([Makefile intl/intlh.inst po/Makefile.in misc/gettextize])
+END
+
+: > Makefile.am
+
+mkdir intl po misc
+: > intl/intlh.inst.in
+: > po/Makefile.in.am
+: > misc/gettextize.in
+
+$ACLOCAL
+$AUTOMAKE
+
+grep '^gettextize' Makefile.in && Exit 1
+Exit 0
diff --git a/t/output3.sh b/t/output3.sh
new file mode 100755
index 000000000..dd7aaefe7
--- /dev/null
+++ b/t/output3.sh
@@ -0,0 +1,38 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Yet another AC_OUTPUT test.
+
+. ./defs || Exit 1
+
+cat > configure.ac <<END
+AC_INIT([$me], [1.0])
+AM_INIT_AUTOMAKE
+AC_OUTPUT([Makefile
+tests/Makefile tests/defs],
+[blah])
+END
+
+: > Makefile.am
+
+mkdir tests
+: > tests/Makefile.am
+: > tests/defs.in
+
+$ACLOCAL
+$AUTOMAKE
+
+:
diff --git a/t/output4.sh b/t/output4.sh
new file mode 100755
index 000000000..fa6a95ea5
--- /dev/null
+++ b/t/output4.sh
@@ -0,0 +1,35 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# It's hard to believe there are so many AC_OUTPUT-related bugs.
+
+. ./defs || Exit 1
+
+cat > configure.ac <<END
+AC_INIT([$me], [1.0])
+AM_INIT_AUTOMAKE
+AC_OUTPUT([tests/Makefile tests/defs])
+END
+
+mkdir tests
+: > tests/defs.in
+: > tests/Makefile.am
+
+$ACLOCAL
+$AUTOMAKE
+
+grep tests/defs.in tests/Makefile.in && Exit 1
+Exit 0
diff --git a/t/output5.sh b/t/output5.sh
new file mode 100755
index 000000000..8bf9403a2
--- /dev/null
+++ b/t/output5.sh
@@ -0,0 +1,31 @@
+#! /bin/sh
+# Copyright (C) 1997-2012 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 Automake complains when there is no Makefile specified.
+
+. ./defs || Exit 1
+
+cat > configure.ac << 'END'
+AC_INIT([foo], [bar], [baz])
+AM_INIT_AUTOMAKE
+AC_OUTPUT
+END
+
+: > Makefile.am
+
+$ACLOCAL
+AUTOMAKE_fails
+grep 'AC_CONFIG_FILES(.Makefile.)' stderr
diff --git a/t/output6.sh b/t/output6.sh
new file mode 100755
index 000000000..b55f5e327
--- /dev/null
+++ b/t/output6.sh
@@ -0,0 +1,72 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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/>.
+
+# Check for support for colon-separated input files in AC_CONFIG_FILES.
+
+. ./defs || Exit 1
+
+cat > configure.ac << END
+AC_INIT([$me], [1.0])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([foo:a.in:b.in:c.in:d.in])
+AC_OUTPUT
+END
+
+cat >a.in <<'EOF'
+a = A
+b = A
+c = A
+d = A
+EOF
+
+cat >b.in <<'EOF'
+b = B
+c = B
+d = B
+EOF
+
+cat >c.am <<'EOF'
+c = C
+d = C
+
+.PHONY: test1 test2
+test1:
+ test $(a)$(b)$(c)$(d) = ABCD
+test2:
+ test $(a)$(b)$(c)$(d) = GFCD
+EOF
+
+echo 'd = D' > d.in
+
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+$MAKE -f foo test1
+
+$sleep
+cat >b.in <<'EOF'
+a = G
+b = F
+c = F
+d = F
+EOF
+
+using_gmake || $MAKE -f foo
+$MAKE -f foo test2
+
+:
diff --git a/t/output7.sh b/t/output7.sh
new file mode 100755
index 000000000..0f4725fae
--- /dev/null
+++ b/t/output7.sh
@@ -0,0 +1,72 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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/>.
+
+# Check for support for colon separated input files in AC_CONFIG_FILES,
+# with sources in sub directories.
+
+. ./defs || Exit 1
+
+cat > configure.ac << END
+AC_INIT([$me], [1.0])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([
+ Makefile:mk/toplevel.in
+ sub/Makefile:mk/sub.in
+ mk/Makefile
+])
+AC_OUTPUT
+END
+
+mkdir mk sub
+cat >mk/Makefile.am <<'EOF'
+all-local:
+ @echo in--mk
+EOF
+
+cat >mk/sub.am <<'EOF'
+EXTRA_DIST = foo
+all-local:
+ @echo in--sub
+EOF
+
+cat >mk/toplevel.am <<'EOF'
+all-local:
+ @echo at--toplevel
+SUBDIRS = mk sub
+EOF
+
+# We have to distribute something in foo, because some versions
+# of tar do not archive empty directories when passed the 'o'
+# flags. (This was fixed in GNU tar 1.12, but older
+# versions are still used: NetBSD 1.6.1 ships with tar 1.11.2).
+#
+# If sub/ is missing from the archive, config.status will fail
+# to compute $ac_abs_srcdir during a VPATH build: config.status
+# is able to create sub/ in the build tree, but it assumes the
+# directory already exists in the source tree.
+echo bar > sub/foo
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+$MAKE >output
+cat output
+grep in--mk output
+grep in--sub output
+grep at--toplevel output
+
+$MAKE distcheck
diff --git a/t/output8.sh b/t/output8.sh
new file mode 100755
index 000000000..1339c67dd
--- /dev/null
+++ b/t/output8.sh
@@ -0,0 +1,52 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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/>.
+
+# Check AC_CONFIG_FILES support for files starting with '../'.
+# Report from Bruno Haible.
+
+. ./defs || Exit 1
+
+mkdir testdir
+cd testdir
+
+mv ../configure.ac .
+cat >> configure.ac << END
+AC_CONFIG_FILES([a/foo.sh:../testdir/a/foo.sh.in])
+AC_CONFIG_FILES([a/Makefile])
+AC_OUTPUT
+END
+
+mkdir a
+
+echo SUBDIRS = a >Makefile.am
+: >a/Makefile.am
+
+echo foo >a/foo.sh.in
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+./configure
+$MAKE
+test "`cat a/foo.sh`" = foo
+
+$sleep
+echo 'bar' >a/foo.sh.in
+
+cd a
+$MAKE foo.sh
+test "`cat foo.sh`" = bar
diff --git a/t/output9.sh b/t/output9.sh
new file mode 100755
index 000000000..f0759108c
--- /dev/null
+++ b/t/output9.sh
@@ -0,0 +1,52 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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 an AC_CONFIG_FILES can have an AC_CONFIG_FILES output as input.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << END
+AC_CONFIG_FILES([a/mid.in:a/input.in.in])
+AC_CONFIG_FILES([b/out:a/mid.in])
+AC_CONFIG_FILES([a/Makefile b/Makefile])
+AC_OUTPUT
+END
+
+mkdir a
+mkdir b
+
+
+cat >Makefile.am <<\EOF
+SUBDIRS = a b
+dist-hook:
+ test -f $(distdir)/a/input.in.in
+ test ! -f $(distdir)/a/mid.in
+ if test ! -f check; then :; else : > ok; fi
+EOF
+
+: >a/Makefile.am
+: >b/Makefile.am
+
+echo foo >a/input.in.in
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+./configure
+: > check
+$MAKE distcheck
+test -f ok
diff --git a/t/override-conditional-1.sh b/t/override-conditional-1.sh
new file mode 100755
index 000000000..1f66d3f47
--- /dev/null
+++ b/t/override-conditional-1.sh
@@ -0,0 +1,53 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Test for conditionally-defined overrides.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AM_CONDITIONAL([COND], [test x"$cond" = x"yes"])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+foobar:
+ : > $@
+if COND
+ps: foobar
+ :
+endif
+END
+
+$ACLOCAL
+$AUTOMAKE -Wno-override
+
+# "ps:" should be output in two conditions
+test `grep '[^-]ps:' Makefile.in | wc -l` = 2
+grep '@COND_TRUE@ps: *foobar' Makefile.in
+grep '@COND_FALSE@ps: *ps-am' Makefile.in
+
+$AUTOCONF
+
+./configure cond=no
+$MAKE ps
+test ! -r foobar
+
+./configure cond=yes
+$MAKE ps
+test -f foobar
+
+:
diff --git a/t/override-conditional-2.sh b/t/override-conditional-2.sh
new file mode 100755
index 000000000..4f0688832
--- /dev/null
+++ b/t/override-conditional-2.sh
@@ -0,0 +1,39 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Test that conditional overrides are diagnosed.
+# This test is still xfailing; see the FIXME in Automake::Rule::define.
+# Once that is fixed, the test should succeed.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AM_CONDITIONAL([COND], [:])
+END
+
+cat > Makefile.am << 'END'
+if COND
+all:
+ :
+endif
+END
+
+$ACLOCAL
+
+AUTOMAKE_fails
+grep ':.*overrides.*all' stderr
+
+:
diff --git a/t/override-html.sh b/t/override-html.sh
new file mode 100755
index 000000000..6438c998b
--- /dev/null
+++ b/t/override-html.sh
@@ -0,0 +1,33 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Test that overriding 'html' target causes only one "html:" rule to
+# be output.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+html:
+ :
+END
+
+$ACLOCAL
+$AUTOMAKE -Wno-override
+
+# Overriding 'html' should cause only one "html:" rule to be output.
+test `grep '^html:' Makefile.in | wc -l` = 1
+
+:
diff --git a/t/override-suggest-local.sh b/t/override-suggest-local.sh
new file mode 100755
index 000000000..286c8881b
--- /dev/null
+++ b/t/override-suggest-local.sh
@@ -0,0 +1,44 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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 automake -Woverride suggests using TARGET-local instead
+# of TARGET when possible.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+install:
+ :
+installcheck:
+ :
+html:
+ :
+clean-am:
+ :
+END
+
+$ACLOCAL
+$AUTOMAKE -Wno-override
+AUTOMAKE_fails
+# There is no such thing as 'install-local'.
+grep ':.*install-local' stderr && Exit 1
+grep ':.*installcheck-local' stderr
+grep ':.*html-local' stderr
+# Make sure overriding *-am targets suggest using *-local, not *-am.
+grep ':.*clean-am-local' stderr && Exit 1
+grep ':.*clean-local' stderr
+
+:
diff --git a/t/parallel-am.sh b/t/parallel-am.sh
new file mode 100755
index 000000000..db184b283
--- /dev/null
+++ b/t/parallel-am.sh
@@ -0,0 +1,103 @@
+#! /bin/sh
+# Copyright (C) 2008-2012 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/>.
+
+# Test parallel automake execution.
+
+# There are several hypotheses to be tested: Independently of the number
+# of threads used by automake,
+# 0) the generated Makefile.in files must be identical without --add-missing,
+# 1) the Makefile.in that distributes auxiliary files must be generated
+# after all other ones, so all installed aux files are caught,
+# 2) normal automake output should have identical content and be ordered
+# in the same way, when --add-missing is not passed, or when
+# --add-missing is passed but there are no concurrent file requirements
+# (i.e., two Makefile.am files call for the same needed aux file)
+# 3) normal automake output should be identical and ordered in the same way
+# with --add-missing, even with concurrent file requirements, and the
+# installation of aux files should be race-free,
+# 4) warning and normal error output should be identical, in that duplicate
+# warnings should be omitted in the same way as without threads,
+# 5) fatal error and debug messages could be identical. This is not
+# intended, though.
+#
+# This test checks (0), (1), and (2). See sister tests for further coverage.
+
+required=perl-threads
+. ./defs || Exit 1
+
+cat > configure.ac << 'END'
+AC_INIT([parallel-am], [1.0])
+AC_CONFIG_AUX_DIR([build-aux])
+AM_INIT_AUTOMAKE
+AC_PROG_CC
+AM_PATH_LISPDIR
+AM_PATH_PYTHON
+AC_CONFIG_FILES([Makefile])
+END
+
+cat > Makefile.am << 'END'
+SUBDIRS =
+END
+
+list='1 2 3 4 5 6 7 8 9'
+for i in $list; do
+ echo "AC_CONFIG_FILES([sub$i/Makefile])" >> configure.ac
+ echo "SUBDIRS += sub$i" >> Makefile.am
+ mkdir sub$i
+ echo > sub$i/Makefile.am
+done
+# Use an include chain to cause a nontrivial location object to be
+# serialized through a thread queue.
+echo 'include foo.am' >> sub7/Makefile.am
+echo 'include bar.am' > sub7/foo.am
+echo 'python_PYTHON = foo.py' > sub7/bar.am
+echo 'lisp_LISP = foo.el' >> sub8/Makefile.am
+echo 'bin_PROGRAMS = p' >> sub9/Makefile.am
+
+rm -f install-sh missing depcomp
+mkdir build-aux
+
+$ACLOCAL
+
+# This test may have to be run several times in order to expose the
+# race that, when the last Makefile.in (the toplevel one) is created
+# before the other ones have finished, not all auxiliary files may
+# be installed yet, thus some may not be distributed.
+#
+# Further, automake output should be stable.
+
+# Generate expected output using the non-threaded code.
+unset AUTOMAKE_JOBS || :
+AUTOMAKE_run --add-missing
+mv stderr expected
+Makefile_ins=`find . -name Makefile.in`
+for file in $Makefile_ins; do
+ mv $file $file.exp
+done
+
+AUTOMAKE_JOBS=5
+export AUTOMAKE_JOBS
+
+for run in 1 2 3 4 5 6 7; do
+ rm -f build-aux/* sub*/Makefile.in
+ AUTOMAKE_run --add-missing
+ diff stderr expected
+ for file in $Makefile_ins; do
+ diff $file $file.exp
+ done
+done
+
+:
diff --git a/t/parallel-am2.sh b/t/parallel-am2.sh
new file mode 100755
index 000000000..a8ee1b955
--- /dev/null
+++ b/t/parallel-am2.sh
@@ -0,0 +1,77 @@
+#! /bin/sh
+# Copyright (C) 2008-2012 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/>.
+
+# Test parallel automake execution.
+
+# This tests:
+# 4) warning and normal error output should be identical, in that duplicate
+# warnings should be omitted in the same way as without threads.
+
+required=perl-threads
+. ./defs || Exit 1
+
+mkdir sub
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = subdir-objects
+bin_PROGRAMS = main
+main_SOURCES = sub/main.c
+SUBDIRS =
+END
+
+list='1 2 3'
+for i in $list; do
+ echo "AC_CONFIG_FILES([sub$i/Makefile])" >> configure.ac
+ echo "SUBDIRS += sub$i" >> Makefile.am
+ mkdir sub$i sub$i/sub
+ unindent > sub$i/Makefile.am << END
+ AUTOMAKE_OPTIONS = subdir-objects
+ bin_PROGRAMS = sub$i
+ sub${i}_SOURCES = sub/main$i.c
+END
+done
+
+mkdir build-aux
+
+$ACLOCAL
+
+# Independently of the number of worker threads, automake output
+# should be
+# - stable (multiple runs should produce the same output),
+# - properly uniquified,
+# - complete (output from worker threads should not be lost).
+#
+# The parts output by --add-missing are unstable not only wrt. order
+# but also wrt. content: any of the Makefile.am files may cause the
+# depcomp script to be installed (or several of them).
+# Thus we install the auxiliary files in a prior step.
+
+# Generate expected output using non-threaded code.
+unset AUTOMAKE_JOBS || :
+rm -f install-sh missing depcomp
+AUTOMAKE_fails --add-missing
+mv stderr expected
+
+AUTOMAKE_JOBS=5
+export AUTOMAKE_JOBS
+
+for i in 1 2 3 4 5 6 7 8; do
+ rm -f install-sh missing depcomp
+ AUTOMAKE_fails --add-missing
+ diff expected stderr
+done
+
+:
diff --git a/t/parallel-am3.sh b/t/parallel-am3.sh
new file mode 100755
index 000000000..d6302907e
--- /dev/null
+++ b/t/parallel-am3.sh
@@ -0,0 +1,74 @@
+#! /bin/sh
+# Copyright (C) 2008-2012 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/>.
+
+# Test parallel automake execution.
+
+# This tests:
+# 3) normal automake output should be identical and ordered in the same way
+# with --add-missing, even with concurrent file requirements, and the
+# installation of aux files should be race-free.
+
+required=perl-threads
+. ./defs || Exit 1
+
+cat > configure.ac << 'END'
+AC_INIT([parallel-am], [1.0])
+AC_CONFIG_AUX_DIR([build-aux])
+AM_INIT_AUTOMAKE
+AC_PROG_CC
+AM_PATH_LISPDIR
+AM_PATH_PYTHON
+AC_CONFIG_FILES([Makefile])
+END
+
+cat > Makefile.am << 'END'
+SUBDIRS =
+END
+
+list='1 2 3'
+for i in $list; do
+ echo "AC_CONFIG_FILES([sub$i/Makefile])" >> configure.ac
+ echo "SUBDIRS += sub$i" >> Makefile.am
+ mkdir sub$i
+ unindent > sub$i/Makefile.am <<END
+ python_PYTHON = foo$i.py
+ lisp_LISP = foo$i.el
+ bin_PROGRAMS = p$i
+END
+done
+
+rm -f install-sh missing depcomp
+mkdir build-aux
+
+$ACLOCAL
+
+# Generate expected output using the non-threaded code.
+unset AUTOMAKE_JOBS || :
+AUTOMAKE_run --add-missing
+mv stderr expected
+mv Makefile.in Makefile.in.exp
+
+AUTOMAKE_JOBS=3
+export AUTOMAKE_JOBS
+
+for run in 1 2 3 4 5 6 7; do
+ rm -f build-aux/* sub*/Makefile.in
+ AUTOMAKE_run --add-missing
+ diff stderr expected
+ diff Makefile.in Makefile.in.exp
+done
+
+:
diff --git a/t/parallel-tests-cmdline-override.sh b/t/parallel-tests-cmdline-override.sh
new file mode 100755
index 000000000..86b0c94ef
--- /dev/null
+++ b/t/parallel-tests-cmdline-override.sh
@@ -0,0 +1,84 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that we can use indirections when overriding TESTS and
+# TEST_LOGS from the command line.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TEST_EXTENSIONS = .test .t
+TEST_LOG_COMPILER = cat
+T_LOG_COMPILER = cat
+TESTS = bad.test
+var1 = b.test $(var2)
+var2 = c.test
+var3 = d.d
+var4 = e
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+rm -f config.log # Do not create false positives below.
+
+cat > exp-log <<'END'
+a.log
+b.log
+c.log
+d.log
+e.log
+test-suite.log
+END
+
+cat > exp-out <<'END'
+PASS: a.t
+PASS: b.test
+PASS: c.test
+PASS: d.t
+PASS: e.test
+END
+
+do_check ()
+{
+ env "$@" $MAKE -e check >stdout || { cat stdout; Exit 1; }
+ cat stdout
+ grep '^PASS:' stdout | LC_ALL=C sort > got-out
+ cat got-out
+ ls . | grep '\.log$' | LC_ALL=C sort > got-log
+ cat got-log
+ st=0
+ diff exp-out got-out || st=1
+ diff exp-log got-log || st=1
+ return $st
+}
+
+tests='a.t $(var1) $(var3:.d=.t) $(var4:=.test)'
+test_logs='a.log $(var1:.test=.log) $(var3:.d=.log) $(var4:=.log)'
+
+touch a.t b.test c.test d.t e.test
+
+do_check TESTS="$tests"
+do_check TEST_LOGS="$test_logs"
+
+:
diff --git a/t/parallel-tests-console-output.sh b/t/parallel-tests-console-output.sh
new file mode 100755
index 000000000..ac43b2537
--- /dev/null
+++ b/t/parallel-tests-console-output.sh
@@ -0,0 +1,104 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# parallel-tests: some checks on console output about testsuite
+# progress.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+XFAIL_TESTS = sub/xpass.test xfail.test error.test
+TESTS = $(XFAIL_TESTS) fail.test pass.test a/b/skip.test sub/error2.test
+pass.log: fail.log
+error.log: pass.log
+sub/xpass.log: error.log
+sub/error2.log: xfail.log
+a/b/skip.log: sub/error2.log
+END
+
+cat > exp <<'END'
+FAIL: fail.test
+PASS: pass.test
+ERROR: error.test
+XPASS: sub/xpass.test
+XFAIL: xfail.test
+ERROR: sub/error2.test
+SKIP: a/b/skip.test
+END
+
+mkdir sub a a/b
+
+cat > pass.test << 'END'
+#!/bin/sh
+exit 0
+END
+cp pass.test sub/xpass.test
+
+cat > fail.test << 'END'
+#!/bin/sh
+exit 1
+END
+
+cat > xfail.test << 'END'
+#!/bin/sh
+# The sleep should ensure expected execution order of tests
+# even when make is run in parallel mode.
+# Creative quoting below to plase maintainer-check.
+sleep '10'
+exit 1
+END
+
+cat > error.test << 'END'
+#!/bin/sh
+exit 99
+END
+cp error.test sub/error2.test
+
+cat > a/b/skip.test << 'END'
+#!/bin/sh
+exit 77
+END
+
+chmod a+x pass.test fail.test xfail.test sub/xpass.test \
+ a/b/skip.test error.test sub/error2.test
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+for vpath in : false; do
+ if $vpath; then
+ mkdir build
+ cd build
+ srcdir=..
+ else
+ srcdir=.
+ fi
+ $srcdir/configure
+ $MAKE check >stdout && { cat stdout; Exit 1; }
+ cat stdout
+ LC_ALL=C grep '^[A-Z][A-Z]*:' stdout > got
+ cat got
+ diff $srcdir/exp got
+ cd $srcdir
+done
+
+:
diff --git a/t/parallel-tests-driver-install.sh b/t/parallel-tests-driver-install.sh
new file mode 100755
index 000000000..b538799e0
--- /dev/null
+++ b/t/parallel-tests-driver-install.sh
@@ -0,0 +1,93 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that auxiliary script 'test-driver' gets automatically installed
+# in the correct directory by 'parallel-tests' option.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+: Try first with parallel-tests defined in AM_INIT_AUTOMAKE.
+
+mkdir am-init-automake
+cd am-init-automake
+
+cat > configure.ac <<END
+AC_INIT([$me], [1.0])
+AC_CONFIG_AUX_DIR([my_aux_dir])
+AM_INIT_AUTOMAKE([parallel-tests])
+AC_CONFIG_FILES([Makefile sub/Makefile])
+AC_OUTPUT
+END
+
+mkdir sub my_aux_dir
+
+cat > Makefile.am <<END
+SUBDIRS = sub
+TESTS = foo.test
+END
+
+cat > sub/Makefile.am <<END
+TESTS = bar.test
+END
+
+$ACLOCAL
+$AUTOMAKE -a 2>stderr || { cat stderr >&2; Exit 1; }
+cat stderr >&2
+
+ls -l . sub my_aux_dir # For debugging.
+test -f my_aux_dir/test-driver
+test ! -r test-driver
+test ! -r sub/test-driver
+
+grep '^configure\.ac:3:.*installing.*my_aux_dir/test-driver' stderr
+
+cd ..
+
+: Now try with parallel-tests defined in AUTOMAKE_OPTIONS.
+
+mkdir automake-options
+cd automake-options
+
+cat > configure.ac <<END
+AC_INIT([$me], [1.0])
+AC_CONFIG_AUX_DIR([build-aux])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([dir/GNUmakefile])
+AC_OUTPUT
+END
+
+mkdir build-aux dir
+
+cat > dir/GNUmakefile.am <<END
+TESTS = foo.test
+AUTOMAKE_OPTIONS = parallel-tests
+TESTS += bar.test
+END
+
+$ACLOCAL
+$AUTOMAKE --add-missing --copy dir/GNUmakefile 2>stderr \
+ || { cat stderr >&2; Exit 1; }
+cat stderr >&2
+
+ls -l . dir build-aux # For debugging.
+test -f build-aux/test-driver
+test ! -r test-driver
+test ! -r dir/test-driver
+
+grep '^dir/GNUmakefile\.am:2:.*installing.*build-aux/test-driver' stderr
+
+:
diff --git a/t/parallel-tests-dry-run-1.sh b/t/parallel-tests-dry-run-1.sh
new file mode 100755
index 000000000..b094c1841
--- /dev/null
+++ b/t/parallel-tests-dry-run-1.sh
@@ -0,0 +1,93 @@
+#! /bin/sh
+# Copyright (C) 2012 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/>.
+
+# Check parallel-tests interactions with "make -n".
+# See also sister test 'parallel-tests-dry-run-2.test'.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+echo AC_OUTPUT >> configure.ac
+
+cat > Makefile.am <<'END'
+TESTS = foo.test bar.test
+$(TESTS):
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+# Avoid confusion with test logs.
+rm -f config.log
+
+log_files='test-suite.log foo.log bar.log'
+
+all_exist ()
+{
+ st=0
+ for i in $*; do
+ test -f $i || { echo File $i not found; st=1; }
+ done
+ test $st -eq 0
+}
+
+none_exist ()
+{
+ st=0
+ for i in $*; do
+ if test -r $i || test -f $i; then
+ echo File $i found
+ st=1
+ fi
+ done
+ test $st -eq 0
+}
+
+for targ in check recheck $log_files; do
+ $MAKE -n "$targ"
+ none_exist $log_files
+done
+
+touch $log_files
+
+$MAKE -n mostlyclean
+all_exist $log_files
+$MAKE -n clean
+all_exist $log_files
+
+cat > foo.test <<'END'
+#! /bin/sh
+exit 0
+END
+
+cat > bar.test <<'END'
+#! /bin/sh
+exit 1
+END
+
+chmod a+x foo.test bar.test
+
+$MAKE check && Exit 1
+
+for targ in recheck clean mostlyclean distclean; do
+ $MAKE -n "$targ"
+ all_exist $log_files
+done
+
+:
diff --git a/t/parallel-tests-dry-run-2.sh b/t/parallel-tests-dry-run-2.sh
new file mode 100755
index 000000000..0d13677c2
--- /dev/null
+++ b/t/parallel-tests-dry-run-2.sh
@@ -0,0 +1,113 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check parallel-tests interactions with "make -n".
+# See also sister test 'parallel-tests-dry-run-1.test'.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+TESTS = foo.test bar.test
+TEST_LOG_COMPILER = $(SHELL)
+END
+
+$ACLOCAL
+$AUTOMAKE -a
+$AUTOCONF
+
+./configure
+
+make_n_ ()
+{
+ st=0
+ $MAKE -n "$@" >output 2>&1 || { cat output; ls -l; Exit 1; }
+ cat output
+ # Look out for possible errors from common tools used by recipes.
+ $EGREP -i ' (exist|permission|denied|no .*(such|file))' output && Exit 1
+ $EGREP '(mv|cp|rm|cat|grep|sed|awk): ' output && Exit 1
+ :
+}
+
+: > output
+
+files='foo.log bar.log foo.trs bar.trs'
+
+for target in check recheck test-suite.log; do
+ test ! -f foo.log
+ test ! -f foo.trs
+ test ! -f bar.log
+ test ! -f bar.trs
+ test ! -f test-suite.log
+done
+
+# Creative quoting below to please maintainer-check.
+echo exit '0' > foo.test
+echo exit '1' > bar.test
+
+$MAKE check && Exit 1
+
+chmod a-w .
+
+make_n_ clean
+test -f foo.log
+test -f foo.trs
+test -f foo.log
+test -f bar.trs
+
+# Creative quoting below to please maintainer-check.
+cat > foo.test <<END
+echo this is bad
+exit 1
+END
+echo exit '0' > bar.test
+
+for target in check recheck test-suite.log; do
+ make_n_ $target
+ grep '^:test-result: *FAIL' bar.trs
+ grep 'this is bad' foo.log test-suite.log && Exit 1
+ : For shells with busted 'set -e'.
+done
+
+chmod a-rw $files
+if test -r foo.log; then
+ : You can still read unreadable files! Skip these checks.
+else
+ for target in check recheck test-suite.log; do
+ make_n_ $target
+ for f in $files; do
+ test -f $f && test ! -r $f || Exit 1
+ done
+ done
+fi
+chmod u+r $files
+
+chmod u+w .
+rm -f foo.log bar.trs
+chmod a-w .
+for target in check recheck test-suite.log $files; do
+ make_n_ $target
+ test ! -f foo.log
+ test -f foo.trs
+ test ! -f bar.trs
+ test -f bar.log
+done
+
+:
diff --git a/t/parallel-tests-empty-testlogs.sh b/t/parallel-tests-empty-testlogs.sh
new file mode 100755
index 000000000..0ea6db837
--- /dev/null
+++ b/t/parallel-tests-empty-testlogs.sh
@@ -0,0 +1,95 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check parallel-tests features:
+# - empty TESTS
+# - empty TEST_LOGS
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_CONFIG_FILES([sub1/Makefile sub2/Makefile])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+SUBDIRS = sub1 sub2
+END
+
+mkdir sub1 sub2
+
+cat > sub1/Makefile.am << 'END'
+TESTS =
+END
+
+# When $(TESTS) is empty, NetBSD 5.1 make ends up defining $(TESTS_LOGS)
+# to ".log" rather than to the empty string (as would be expected).
+# But our recipes are smart enough to work around such a botched-up
+# substitution, so let's not bother too much about it.
+if using_gmake; then
+ unindent >> sub1/Makefile.am << 'END'
+ check-local:
+ echo $(TEST_LOGS) | grep . && exit 1; exit 0
+END
+fi
+
+cat > sub2/Makefile.am << 'END'
+TESTS = foo.test
+END
+
+cat > sub2/foo.test <<'END'
+#! /bin/sh
+exit 0
+END
+chmod a+x sub2/foo.test
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+no_test_has_run ()
+{
+ ls -1 *.log | grep -v '^test-suite\.log$' | grep . && Exit 1
+ grep '^# TOTAL: *0$' test-suite.log
+ :
+}
+
+for vpath in : false; do
+ if $vpath; then
+ mkdir build
+ cd build
+ srcdir=..
+ else
+ srcdir=.
+ fi
+ $srcdir/configure
+ cd sub1
+ VERBOSE=yes $MAKE check
+ no_test_has_run
+ cd ../sub2
+ VERBOSE=yes TESTS='' $MAKE -e check
+ no_test_has_run
+ VERBOSE=yes TEST_LOGS='' $MAKE -e check
+ no_test_has_run
+ cd ..
+ $MAKE check
+ cat sub2/foo.log
+ $MAKE distclean
+ cd $srcdir
+done
+
+:
diff --git a/t/parallel-tests-exeext.sh b/t/parallel-tests-exeext.sh
new file mode 100755
index 000000000..e93f5f10d
--- /dev/null
+++ b/t/parallel-tests-exeext.sh
@@ -0,0 +1,67 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# parallel-tests:
+# - check2.am and interaction with $(EXEEXT)
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+dnl We need to fool the init.m4 internals a little.
+AC_DEFUN([_AM_FOO],
+ [m4_provide([_AM_COMPILER_EXEEXT])
+ AC_SUBST([CC], [false])
+ AC_SUBST([EXEEXT])])
+_AM_FOO
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TESTS = x y a.test b.test
+LOG_COMPILER = true
+TEST_LOG_COMPILER = true
+## We also need to fool the automake internals a little.
+EXTRA_PROGRAMS = y
+y_SOURCES =
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+$EGREP 'EXEEXT|\.log|\.test' Makefile.in # For debugging.
+
+./configure EXEEXT=
+touch x y a.test b.test
+$MAKE check
+
+$MAKE distclean
+rm -f x y a.test b.test *.log *.trs
+
+./configure EXEEXT=.bin
+touch x y.bin a.test b.test.bin
+$MAKE check
+ls -l # For debugging.
+test -f y.log
+test ! -r y.bin.log
+test -f b.log
+test ! -r b.test.log
+
+$EGREP '^y\.log: y(\$\(EXEEXT\)|\.bin)' Makefile
+$EGREP '^\.test(\$\(EXEEXT\)|\.bin)\.log:' Makefile
+
+:
diff --git a/t/parallel-tests-exit-statuses.sh b/t/parallel-tests-exit-statuses.sh
new file mode 100755
index 000000000..688ff8447
--- /dev/null
+++ b/t/parallel-tests-exit-statuses.sh
@@ -0,0 +1,102 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check parallel-tests features: normal and special exit statuses
+# in the test scripts.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+# $failure_statuses should be defined to the list of all integers between
+# 1 and 255 (inclusive), excluded 77 and 99.
+failure_statuses=`seq_ 1 255 | $EGREP -v '^(77|99)$' | tr "$nl" ' '`
+# For debugging.
+echo "failure_statuses: $failure_statuses"
+# Sanity check.
+test `for st in $failure_statuses; do echo $st; done | wc -l` -eq 253 \
+ || fatal_ "initializing list of exit statuses for simple failures"
+
+cat > Makefile.am <<END
+LOG_COMPILER = ./do-exit
+fail_tests = $failure_statuses
+TESTS = 0 77 99 $failure_statuses
+\$(TESTS):
+END
+
+cat > do-exit <<'END'
+#!/bin/sh
+echo "$0: $1"
+case $1 in
+ [0-9]|[0-9][0-9]|[0-9][0-9][0-9]) st=$1;;
+ */[0-9]|*/[0-9][0-9]|*/[0-9][0-9][0-9]) st=`echo x"$1" | sed 's|.*/||'`;;
+ *) st=99;;
+esac
+exit $st
+END
+chmod a+x do-exit
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+{
+ echo PASS: 0
+ echo SKIP: 77
+ echo ERROR: 99
+ for st in $failure_statuses; do
+ echo "FAIL: $st"
+ done
+} | LC_ALL=C sort > exp-fail
+
+sed 's/^FAIL:/XFAIL:/' exp-fail | LC_ALL=C sort > exp-xfail-1
+sed '/^ERROR:/d' exp-xfail-1 > exp-xfail-2
+
+sort exp-fail
+sort exp-xfail-1
+sort exp-xfail-2
+
+./configure
+
+st=1
+$MAKE check >stdout && st=0
+cat stdout
+cat test-suite.log
+test $st -gt 0 || Exit 1
+LC_ALL=C grep '^[A-Z][A-Z]*:' stdout | LC_ALL=C sort > got-fail
+diff exp-fail got-fail
+
+st=1
+XFAIL_TESTS="$failure_statuses 99" $MAKE -e check >stdout && st=0
+cat stdout
+cat test-suite.log
+test $st -gt 0 || Exit 1
+LC_ALL=C grep '^[A-Z][A-Z]*:' stdout | LC_ALL=C sort > got-xfail-1
+diff exp-xfail-1 got-xfail-1
+
+st=0
+XFAIL_TESTS="$failure_statuses" TESTS="0 77 $failure_statuses" \
+ $MAKE -e check >stdout || st=$?
+cat stdout
+cat test-suite.log
+test $st -eq 0 || Exit 1
+LC_ALL=C grep '^[A-Z][A-Z]*:' stdout | LC_ALL=C sort > got-xfail-2
+diff exp-xfail-2 got-xfail-2
+
+:
diff --git a/t/parallel-tests-extra-programs.sh b/t/parallel-tests-extra-programs.sh
new file mode 100755
index 000000000..d95d18476
--- /dev/null
+++ b/t/parallel-tests-extra-programs.sh
@@ -0,0 +1,182 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Parallel test harness: check that $(TESTS) can lazily depend on
+# (or even be) $(EXTRA_PROGRAMS).
+
+required='cc native'
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_OUTPUT
+END
+
+# Will be extended later.
+cat > Makefile.am << 'END'
+TEST_EXTENSIONS = .bin .test
+EXTRA_PROGRAMS =
+TESTS =
+END
+
+#
+# Now try various kinds of test dependencies ...
+#
+
+# 1. A program that is also a test, and whose source files
+# already exist.
+
+cat >> Makefile.am <<'END'
+EXTRA_PROGRAMS += foo.bin
+TESTS += foo.bin
+foo_bin_SOURCES = foo.c
+END
+
+cat > foo.c <<'END'
+#include <stdio.h>
+int main (void)
+{
+ printf ("foofoofoo\n");
+ return 0;
+}
+END
+
+# 2. A program that is also a test, and whose source files
+# are buildable by make.
+cat >> Makefile.am <<'END'
+EXTRA_PROGRAMS += bar.bin
+TESTS += bar.bin
+bar_bin_SOURCES = bar.c
+bar.c: foo.c
+ sed -e 's/foofoofoo/barbarbar/' foo.c > $@
+END
+
+# 3. A test script that already exists, whose execution depends
+# on a program whose source files already exist and which is
+# not itself a test.
+cat >> Makefile.am <<'END'
+EXTRA_PROGRAMS += y
+TESTS += baz.test
+baz.log: y$(EXEEXT)
+END
+
+cat > baz.test <<'END'
+#!/bin/sh
+$srcdir/y "$@" | sed 's/.*/&ep&ep&ep/'
+END
+chmod a+x baz.test
+
+cat > y.c <<'END'
+#include <stdio.h>
+int main (void)
+{
+ printf ("y\n");
+ return 0;
+}
+END
+
+# 4. A program that is also a test, but whose source files
+# do not exit and are not buildable by make.
+
+cat >> Makefile.am <<'END'
+EXTRA_PROGRAMS += none.bin
+TESTS += none.bin
+none_bin_SOURCES = none.c
+END
+
+#
+# Setup done, go with the tests.
+#
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+# What we check now:
+# 1. even if we cannot build the 'none.bin' program, all the other
+# test programs should be built, and all the other tests should
+# be run;
+# 2. still, since we cannot create the 'none.log' file, the
+# 'test-suite.log' file shouldn't be created (as it depends
+# on *all* the test logs).
+
+st=0
+$MAKE -k check >stdout 2>stderr || st=$?
+cat stdout
+cat stderr >&2
+ls -l
+if using_gmake; then
+ test $st -gt 0 || Exit 1
+else
+ # Don't trust exit status of "make -k" for non-GNU make.
+ $MAKE check && Exit 1
+ : For shells with busted 'set -e'.
+fi
+
+# Files that should have been created, with the expected content.
+cat bar.c
+grep foofoofoo foo.log
+grep barbarbar bar.log
+grep yepyepyep baz.log
+# Files that shouldn't have been created.
+test ! -f none.log
+test ! -f test-suite.log
+# Expected testsuite progress output.
+grep '^PASS: baz\.test$' stdout
+# Don't anchor the end of the next two patterns, to allow for non-empty
+# $(EXEEXT).
+grep '^PASS: foo\.bin' stdout
+grep '^PASS: bar\.bin' stdout
+# Expected error messages from make. Some make implementations (e.g.,
+# FreeBSD make) seem to print the error on stdout instead, so check for
+# it there as well.
+$EGREP 'none\.(bin|o|c)' stderr stdout
+
+# What we check now:
+# 1. if we make the last EXTRA_PROGRAM buildable, the failed tests
+# pass;
+# 2. on a lazy re-run, the passed tests are not re-run, and
+# 3. their log files are not updated or touched.
+
+: > stamp
+$sleep
+
+echo 'int main (void) { return 0; }' > none.c
+
+st=0
+RECHECK_LOGS= $MAKE -e check >stdout || st=$?
+cat stdout
+ls -l
+test $st -eq 0 || Exit 1
+
+# For debugging.
+stat stamp foo.log bar.log baz.log || :
+
+# Files that shouldn't have been updated or otherwise touched.
+is_newest stamp foo.log bar.log baz.log
+# Files that should have been created now.
+test -f none.log
+test -f test-suite.log
+# Tests that shouldn't have been re-run.
+$EGREP '(foo|bar)\.bin|baz\.test$' stdout && Exit 1
+# Tests that should have been run. Again, we don't anchor the end
+# of the next pattern, to allow for non-empty $(EXEEXT).
+grep '^PASS: none\.bin' stdout
+
+:
diff --git a/t/parallel-tests-fd-redirect-exeext.sh b/t/parallel-tests-fd-redirect-exeext.sh
new file mode 100755
index 000000000..56d7f5990
--- /dev/null
+++ b/t/parallel-tests-fd-redirect-exeext.sh
@@ -0,0 +1,118 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# parallel-tests support: redirection of file descriptors with
+# AM_TESTS_FD_REDIRECT, for tests which are binary executables
+# We use some tricks to ensure that all code paths in 'lib/am/check2.am'
+# are covered, even on platforms where $(EXEEXT) would be naturally empty.
+# See also the more generic test 'check-fd-redirect.test', and
+# sister test 'parallel-tests-fd-redirect.test'.
+
+required='cc native'
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+# Calls like "write(9, ...)" are unlikely to work for MinGW-compiled
+# programs. We must skip this test if this is the case.
+am__ok=no
+AC_LINK_IFELSE(
+ [AC_LANG_PROGRAM([[#include <unistd.h>]],
+ [[write (9, "foobar\n", 7); return 0;]])],
+ [AM_RUN_LOG([./conftest$EXEEXT 9>&1]) \
+dnl Leading ":;" required to avoid having two nested subshells starting
+dnl with '((' in the generated configure: that is unportable and could
+dnl confuse some shells (e.g., NetBSD 5.1 /bin/ksh) into thinking we are
+dnl trying to perform an arithmetic operation.
+ && AM_RUN_LOG([:; (./conftest$EXEEXT 9>&1) | grep "^foobar"]) \
+ && am__ok=yes])
+test $am__ok = yes || AS_EXIT([63])
+AM_CONDITIONAL([real_EXEEXT], [test -n "$EXEEXT"])
+test -n "$EXEEXT" || EXEEXT=.bin
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+AM_TESTS_FD_REDIRECT = 9>&1
+TESTS = $(check_PROGRAMS)
+check_PROGRAMS = baz qux.test
+qux_test_SOURCES = zardoz.c
+
+## Sanity check.
+if !real_EXEEXT
+check-local:
+ test -f baz.bin
+ test -f qux.test.bin
+endif
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+cat > baz.c <<'END'
+#include <stdio.h>
+#include <unistd.h>
+int main (void)
+{
+ ssize_t res = write (9, " bazbazbaz\n", 11);
+ if (res < 0)
+ perror("write failed");
+ return res != 11;
+}
+END
+
+cat > zardoz.c <<'END'
+#include <stdio.h>
+#include <unistd.h>
+int main (void)
+{
+ ssize_t res = write (9, " quxquxqux\n", 11);
+ if (res < 0)
+ perror("write failed");
+ return res != 11;
+}
+END
+
+st=0; ./configure || st=$?
+cat config.log # For debugging, as we do tricky checks in configure.
+if test $st -eq 63; then
+ skip_ "fd redirect in compiled program unsupported"
+elif test $st -eq 0; then
+ : Continue.
+else
+ fatal_ "unexpected error in ./configure"
+fi
+
+# Sanity checks.
+st=0
+grep '^baz\.log:.*baz\$(EXEEXT)' Makefile || st=1
+grep '^\.test\$(EXEEXT)\.log:' Makefile || st=1
+grep '^qux\.log:' Makefile && st=1
+test $st -eq 0 || fatal_ "doesn't cover expected code paths"
+
+st=0
+$MAKE check >stdout || st=1
+cat stdout
+cat baz.log
+cat qux.log
+test $st -eq 0
+grep "^ bazbazbaz$" stdout
+grep "^ quxquxqux$" stdout
+$EGREP '(bazbazbaz|quxquxqux)' *.log && Exit 1
+
+:
diff --git a/t/parallel-tests-fd-redirect.sh b/t/parallel-tests-fd-redirect.sh
new file mode 100755
index 000000000..cf7acce10
--- /dev/null
+++ b/t/parallel-tests-fd-redirect.sh
@@ -0,0 +1,70 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# parallel-tests support: redirection of file descriptors with
+# AM_TESTS_FD_REDIRECT, even when using tests without suffix.
+# The sister 'parallel-tests-fd-redirect-exeext.test' do a similar
+# check for tests that are binary executables.
+# See also the more generic test 'check-fd-redirect.test'.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+AM_TESTS_FD_REDIRECT = 9>&1
+TEST_EXTENSIONS = .test .sh
+TESTS = foo.sh bar
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+cat > foo.sh <<'END'
+#!/bin/sh
+echo " foofoofoo" >&9
+END
+chmod a+x foo.sh
+
+cat > bar <<'END'
+#!/bin/sh
+echo " barbarbar" >&9
+END
+
+chmod a+x foo.sh bar
+
+./configure
+
+# Sanity checks.
+st=0
+grep '^bar\.log:.*bar' Makefile || st=1
+grep '^foo\.log:' Makefile && st=1
+test $st -eq 0 || fatal_ "doesn't cover expected code paths"
+
+st=0; $MAKE check >stdout || st=1
+cat stdout
+cat foo.log
+cat bar.log
+test $st -eq 0
+grep "^ foofoofoo$" stdout
+grep "^ barbarbar$" stdout
+$EGREP '(foofoofoo|barbarbar)' *.log && Exit 1
+
+:
diff --git a/t/parallel-tests-fork-bomb.sh b/t/parallel-tests-fork-bomb.sh
new file mode 100755
index 000000000..2f0016bc1
--- /dev/null
+++ b/t/parallel-tests-fork-bomb.sh
@@ -0,0 +1,144 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check parallel-tests features:
+# - If $(TEST_SUITE_LOG) is in $(TEST_LOGS), we get a diagnosed
+# error, not a make hang or a system freeze.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+# The tricky part of this test is to avoid that make hangs or even
+# freezes the system in case infinite recursion (which is the bug we
+# are testing against) is encountered. The following hacky makefile
+# should minimize the probability of that happening.
+cat > Makefile.am << 'END'
+TEST_LOG_COMPILER = true
+TESTS =
+
+errmsg = ::OOPS:: Recursion too deep
+
+if IS_GNU_MAKE
+
+ is_too_deep := $(shell test $(MAKELEVEL) -lt 10 && echo no)
+
+## Indenteation here required to avoid confusing Automake.
+ ifeq ($(is_too_deep),no)
+ else
+ $(error $(errmsg), $(MAKELEVEL) levels)
+ endif
+
+else !IS_GNU_MAKE
+
+# We use mkdir to detect the level of recursion, since it is easy
+# to use and assured to be portably atomical. Also use an higher
+# number than with GNU make above, since the level used here can
+# be incremented by tow or more per recursion.
+recursion-not-too-deep:
+ @ok=no; \
+ for i in 0 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; \
+ do \
+ echo " mkdir rec-$$i.d"; \
+ if mkdir rec-$$i.d; then \
+ ok=yes; break; \
+ else :; fi; \
+ done; \
+ test $$ok = yes || { echo '$(errmsg)' >&2; exit 1; }
+.PHONY: recursion-not-too-deep
+clean-local:
+ rmdir rec-[0-9].d
+
+targets = all check recheck $(TESTS) $(TEST_LOGS) $(TEST_SUITE_LOG)
+$(targets): recursion-not-too-deep
+
+# For BSD make.
+.BEGIN: recursion-not-too-deep
+
+endif !IS_GNU_MAKE
+END
+
+if using_gmake; then
+ cond=:
+else
+ cond=false
+fi
+
+cat >> configure.ac << END
+AM_CONDITIONAL([IS_GNU_MAKE], [$cond])
+AC_OUTPUT
+END
+
+# Another helpful idiom to avoid hanging on capable systems. The subshell
+# is needed since 'ulimit' might be a special shell builtin.
+if (ulimit -t 8); then ulimit -t 8; fi
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a -Wno-portability
+
+./configure
+
+do_check ()
+{
+ st=0
+ log=$1; shift
+ env "$@" $MAKE -e check >output 2>&1 || st=$?
+ cat output
+ $FGREP '::OOPS::' output && Exit 1 # Possible infinite recursion.
+ # Check that at least we don't create a botched global log file.
+ test ! -f "$log"
+ if using_gmake; then
+ grep "[Cc]ircular.*dependency" output | $FGREP "$log"
+ test $st -gt 0
+ else
+ # Look for possible error messages about circular dependencies from
+ # either make or our own recipes. At least one such a message must
+ # be present. OTOH, some make implementations (e.g., NetBSD's), while
+ # smartly detecting the circular dependency early and diagnosing it,
+ # still exit with a successful exit status (yikes!). So don't check
+ # the exit status of non-GNU make, to avoid spurious failures.
+ # this case.
+ err_seen=no
+ for err_rx in \
+ 'circular.* depend' \
+ 'depend.* circular' \
+ 'graph cycle' \
+ 'infinite (loop|recursion)' \
+ 'depend.* on itself' \
+ ; do
+ $EGREP -i "$err_rx" output | $FGREP "$log" || continue
+ err_seen=yes
+ break
+ done
+ test $err_seen = yes || Exit 1
+ fi
+}
+
+: > test-suite.test
+do_check test-suite.log TESTS=test-suite.test
+rm -f *.log *.test
+
+: > 0.test
+: > 1.test
+: > 2.test
+: > 3.test
+: > foobar.test
+do_check foobar.log TEST_LOGS='0.log 1.log foobar.log 2.log 3.log' \
+ TEST_SUITE_LOG=foobar.log
+rm -f *.log *.test
+
+:
diff --git a/t/parallel-tests-harderror.sh b/t/parallel-tests-harderror.sh
new file mode 100755
index 000000000..7b6625190
--- /dev/null
+++ b/t/parallel-tests-harderror.sh
@@ -0,0 +1,96 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check parallel-tests features: DISABLE_HARD_ERRORS
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_CONFIG_FILES([sub/Makefile])
+AC_OUTPUT
+END
+
+mkdir sub
+
+cat > Makefile.am << 'END'
+SUBDIRS = . sub
+TESTS = foo.test
+XFAIL_TESTS = foo.test
+EXTRA_DIST = $(TESTS)
+END
+
+cat > sub/Makefile.am << 'END'
+TESTS = bar.test
+XFAIL_TESTS = $(TESTS)
+EXTRA_DIST = $(TESTS)
+END
+
+cat > foo.test <<'END'
+#! /bin/sh
+exit 99
+END
+chmod a+x foo.test
+cp foo.test sub/bar.test
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+# DISABLE_HARD_ERRORS is not defined as a make variable, so that it
+# should be possible to define either from the environment or from
+# command-line, also when recursive make invocations are involved,
+# and also without using the '-e' make flag; this should work also
+# for non-GNU make. Moreover, it shouldn't be necessary to define
+# DISABLE_HARD_ERRORS to "yes" to really disable hard errors: any
+# non-empty value should do.
+$MAKE check DISABLE_HARD_ERRORS=yes
+DISABLE_HARD_ERRORS=x $MAKE check
+
+# But an empty values for DISABLE_HARD_ERRORS means that hard errors
+# are not to be counted like normal failures.
+
+$MAKE check DISABLE_HARD_ERRORS='' && Exit 1
+cat test-suite.log
+grep '^ERROR: foo$' test-suite.log
+
+cd sub
+# The '-e' is wanted here.
+DISABLE_HARD_ERRORS='' $MAKE -e check && Exit 1
+cat test-suite.log
+grep '^ERROR: bar$' test-suite.log
+cd ..
+
+# Check the distributions.
+$MAKE DISABLE_HARD_ERRORS=y distcheck
+
+# Finally, DISABLE_HARD_ERRORS should work also when the developer
+# sets it directly in Makefile.am or Makefile. And its effects
+# should remain local to that specific Makefile, obviously.
+
+echo 'DISABLE_HARD_ERRORS = yes' >> Makefile.am
+$AUTOMAKE Makefile
+./config.status Makefile
+VERBOSE=yes $MAKE check && Exit 1
+grep '^FAIL' test-suite.log && Exit 1
+grep '^ERROR: bar$' sub/test-suite.log
+
+echo 'DISABLE_HARD_ERRORS = zardoz' >> sub/Makefile
+VERBOSE=yes $MAKE check
+
+:
diff --git a/t/parallel-tests-interrupt.tap b/t/parallel-tests-interrupt.tap
new file mode 100755
index 000000000..39a04a753
--- /dev/null
+++ b/t/parallel-tests-interrupt.tap
@@ -0,0 +1,117 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that the parallel-tests driver removed incomplete log files
+# when interrupt upon some signal. This test is definitely too hacky,
+# but we couldn't find a better way to deal with inter-processes
+# signals and the whole process-synchronization mess.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+plan_ 16
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TESTS = foo.test
+## Provide more debugging info.
+TEST_LOG_COMPILER = $(SHELL) -x
+## Required by foo.test; see below.
+AM_TESTS_FD_REDIRECT = 9>&1
+END
+
+# This is hacky and ugly, but has the great advantage of avoiding us a lot
+# of pain with background processes and related synchronization issues.
+
+cat - "$am_scriptdir"/test-driver > test-driver <<'END'
+#!/bin/sh
+echo $$ > pid
+END
+
+cat > foo.test << 'END'
+#!/bin/sh -e
+
+# We expect the test driver to be terminated by a signal, and so
+# to exit with non-zero status, thus causing "make check" to fail.
+# Exiting with status 0 from this test script is thus a good way to
+# make unexpected behaviours more evident, since this will likely
+# cause and unexpected success in "make check".
+trap 'exit 0' 0;
+stop_test () { exit 0; }
+
+# We need the "foo is starting to run" string flushed to standard output
+# ASAP, because we are soon going to grep for that string in the log file
+# where the test driver is redirecting this script's stdout. The safest
+# way force this flushing portably is to rely on perl I/O capabilities.
+$PERL -e 'BEGIN { $| = 1 }; print "foo is starting to run\n"' || stop_test
+
+ls -l >&9 || stop_test
+
+bailout ()
+{
+ # Print this to the original stdout (saved in the fd 9), so that the
+ # emitted "Bail out!" directive will be interpreted by the test driver
+ # running the Automake testsuite.
+ echo "Bail out! $*" >&9
+ stop_test
+}
+
+test $sig -gt 0 || bailout "\$sig not exported to test script"
+
+res=ok; cat foo.log >&9 || res="not ok"
+echo "$res - logfile created and readable [SIG $sig]" >&9
+
+res=ok; grep '^foo is starting to run$' foo.log >&9 || res='not ok'
+echo "$res - logfile contains output from test script [SIG $sig]" >&9
+
+cat pid >&9 || bailout "cannot get PID of test driver"
+kill -$sig `cat pid` || bailout "cannot send signal $sig to test driver"
+
+stop_test
+END
+chmod a+x foo.test
+
+$ACLOCAL || fatal_ "aclocal failed"
+$AUTOCONF || fatal_ "autoconf failed"
+$AUTOMAKE || fatal_ "automake failed"
+
+./configure || fatal_ "./configure failed"
+
+# The only signals that can be trapped portable are 1 "SIGHUP",
+# 2 "SIGINT", 13 "SIGPIPE" and 15 "SIGTERM".
+trapped_signals='1 2 13 15'
+
+for sig in $trapped_signals; do
+ if is_blocked_signal $sig; then
+ for i in 1 2 3 4; do echo "ok # SKIP signal $sig is blocked"; done
+ continue
+ fi
+ rm -f pid fail *.log
+ r=ok; env PERL="$PERL" sig="$sig" $MAKE check && r='not ok'
+ echo "$r - signal $sig to test driver causes \"make check\" to fail"
+ ls -l
+ # These files shouldn't exist, but in case they do, their content might
+ # provide helpful information about the causes of the failure(s).
+ cat foo.log || :
+ cat test-suite.log || :
+ r=ok; ls | $EGREP 'foo.*\.(log|tmp)' && r='not ok'
+ echo "$r - test driver clean up log and tmp files after signal $sig"
+done
+
+:
diff --git a/t/parallel-tests-log-compiler-1.sh b/t/parallel-tests-log-compiler-1.sh
new file mode 100755
index 000000000..77bdac406
--- /dev/null
+++ b/t/parallel-tests-log-compiler-1.sh
@@ -0,0 +1,126 @@
+#! /bin/sh
+# Copyright (C) 2009-2012 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/>.
+
+# Check parallel-tests features:
+# - per-extension "test runners" a.k.a. "log compilers" (xxx_LOG_COMPILER
+# and xxx_LOG_FLAGS), also with AC_SUBST'd stuff.
+# See also related test 'parallel-tests-log-compiler-2.test'.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_SUBST([acsubst_compiler], [t-compiler])
+AC_CONFIG_LINKS([chk-compiler:chk-compiler])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+# Note that automake should not match the '/test' part of 'sub/test'
+# as '.test' suffix.
+TESTS = foo.chk bar.test baz bla.t bli.suff sub/test
+
+TEST_EXTENSIONS = .chk .test .t
+
+CHK_LOG_COMPILER = ./chk-compiler
+TEST_LOG_COMPILER = $(SHELL) $(srcdir)/test-compiler
+T_LOG_COMPILER = @acsubst_compiler@
+LOG_COMPILER = @SHELL@ -x $(srcdir)/noext-compiler
+
+CHK_LOG_FLAGS = --chk
+
+AM_TEST_LOG_FLAGS = --am-test
+
+T_LOG_FLAGS = --t
+AM_T_LOG_FLAGS = --am-t
+
+AM_LOG_FLAGS = -a
+LOG_FLAGS = -b
+
+# 't-compiler' is deliberately not distributed; it should be available
+# in PATH also from "make distcheck".
+EXTRA_DIST = $(TESTS) chk-compiler test-compiler noext-compiler
+END
+
+mkdir sub
+
+cat > chk-compiler <<'END'
+#! /bin/sh
+test x"$1" = x"--chk" || {
+ echo "$0: invalid command line: $*" >&2
+ exit 1
+}
+shift
+exec "$@"
+exit 127
+END
+sed 's/--chk/--am-test/' chk-compiler > test-compiler
+
+mkdir bin
+PATH=`pwd`/bin$PATH_SEPARATOR$PATH; export PATH
+
+cat > bin/t-compiler <<'END'
+#! /bin/sh
+if test x"$1,$2" != x"--am-t,--t"; then
+ echo "$0: invalid command line: $*" >&2
+ exit 1
+fi
+shift; shift
+exec "$@"
+exit 127
+END
+sed 's/--am-t,--t/-a,-b/' bin/t-compiler > noext-compiler
+
+chmod a+x chk-compiler chk-compiler test-compiler bin/t-compiler noext-compiler
+
+cat >foo.chk << 'END'
+#! /bin/sh
+exit 0
+END
+chmod a+x foo.chk
+cp foo.chk bar.test
+cp foo.chk baz
+cp foo.chk bla.t
+cp foo.chk bli.suff
+cp foo.chk sub/test
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+$MAKE check || { cat test-suite.log; Exit 1; }
+ls -l . sub
+cat test-suite.log
+test -f foo.log
+test -f bar.log
+test -f baz.log
+test -f bla.log
+test -f bli.suff.log
+test -f sub/test.log
+
+T_LOG_FLAGS=--bad $MAKE -e check && Exit 1
+cat test-suite.log
+cat bla.log
+# With the above flag overridden, bla.t should fail ...
+$EGREP '(^ *|/)t-compiler:.* invalid .*--bad' bla.log
+# ... but no other test should.
+grep -v '^FAIL: bla\.t ' bla.log | grep 'FAIL:' && Exit 1
+
+# Try also with a VPATH build.
+$MAKE distcheck
+
+:
diff --git a/t/parallel-tests-log-compiler-2.sh b/t/parallel-tests-log-compiler-2.sh
new file mode 100755
index 000000000..7443e263f
--- /dev/null
+++ b/t/parallel-tests-log-compiler-2.sh
@@ -0,0 +1,96 @@
+#! /bin/sh
+# Copyright (C) 2009-2012 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/>.
+
+# Check parallel-tests features:
+# - per-extension "test runners" a.k.a. "log compilers" (xxx_LOG_COMPILER
+# and xxx_LOG_FLAGS), when some tests are PROGRAMS.
+# See also related test 'parallel-tests-log-compiler-1.test'.
+
+am_parallel_tests=yes
+required='cc native'
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+## Note that automake should not match the '/test' part
+## of 'sub/test' as '.test' suffix.
+TESTS = foo.chk bar.test $(check_PROGRAMS) sub/test
+check_PROGRAMS = baz bla.test bli.suff
+TEST_EXTENSIONS = .chk .test
+CHK_LOG_COMPILER = ./chk-compiler
+TEST_LOG_COMPILER = ./test-compiler
+LOG_COMPILER = ./noext-compiler
+AM_CHK_LOG_FLAGS = 1
+CHK_LOG_FLAGS = 2
+AM_TEST_LOG_FLAGS = 3
+TEST_LOG_FLAGS = 4
+AM_LOG_FLAGS = 5
+LOG_FLAGS = 6
+END
+
+mkdir sub
+
+cat >chk-compiler <<'END'
+#! /bin/sh
+echo $0 "$@"
+shift
+shift
+exec "$@"
+exit 127
+END
+chmod a+x chk-compiler
+cp chk-compiler test-compiler
+cp chk-compiler noext-compiler
+
+cat >foo.chk << 'END'
+#! /bin/sh
+exit 0
+END
+chmod a+x foo.chk
+cp foo.chk bar.test
+cp foo.chk sub/test
+
+cat >baz.c << 'END'
+int main (void)
+{
+ return 0;
+}
+END
+cp baz.c bla.c
+cp baz.c bli.c
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+$MAKE
+$MAKE check || { cat test-suite.log; Exit 1; }
+ls -l . sub
+cat test-suite.log
+grep 'chk-compiler *1 *2' foo.log
+grep 'test-compiler *3 *4' bar.log
+grep 'noext-compiler *5 *6' baz.log
+grep 'test-compiler *3 *4' bla.log
+grep 'noext-compiler *5 *6' bli.suff.log
+grep 'noext-compiler *5 *6' sub/test.log
+
+:
diff --git a/t/parallel-tests-log-compiler-example.sh b/t/parallel-tests-log-compiler-example.sh
new file mode 100755
index 000000000..8b4575861
--- /dev/null
+++ b/t/parallel-tests-log-compiler-example.sh
@@ -0,0 +1,69 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Test the example of usage of generic and extension-specific
+# LOG_COMPILER and LOG_FLAGS given in the manual.
+
+am_parallel_tests=yes
+required=python
+. ./defs || Exit 1
+
+cat >> configure.ac <<END
+AC_SUBST([PERL], ['$PERL'])
+AM_PATH_PYTHON
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TESTS = foo.pl bar.py baz
+TEST_EXTENSIONS = .pl .py
+PL_LOG_COMPILER = $(PERL)
+AM_PL_LOG_FLAGS = -w
+PY_LOG_COMPILER = $(PYTHON)
+AM_PY_LOG_FLAGS = -v
+LOG_COMPILER = ./wrapper-script
+AM_LOG_FLAGS = -d
+END
+
+echo 'my $a =+ 2; exit (0);' > foo.pl
+echo 'import sys; sys.exit(0);' > bar.py
+: > baz
+
+cat > wrapper-script <<'END'
+#!/bin/sh
+echo "wrapper args: $*"
+END
+chmod a+x wrapper-script
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+st=0
+$MAKE check || st=$?
+cat foo.log
+cat bar.log
+cat baz.log
+test $st -eq 0 || Exit $st
+
+# Check that the wrappers have been run with the expected flags.
+grep '[rR]eversed.*+=.*operator.*foo\.pl' foo.log
+grep '^# *[cC]lear.*sys\.argv' bar.log
+grep '^wrapper args:.* -d .*baz' baz.log
+
+:
diff --git a/t/parallel-tests-log-override-1.sh b/t/parallel-tests-log-override-1.sh
new file mode 100755
index 000000000..f76d193cc
--- /dev/null
+++ b/t/parallel-tests-log-override-1.sh
@@ -0,0 +1,110 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check parallel-tests features: runtime redefinition of $(TEST_SUITE_LOG).
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.ac <<'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+TESTS = pass.test skip.test xfail.test
+XFAIL_TESTS = xfail.test
+EXTRA_DIST = $(TESTS)
+END
+
+cat > pass.test <<'END'
+#! /bin/sh
+exit 0
+END
+
+cat > skip.test <<'END'
+#! /bin/sh
+echo "% test skipped %"
+exit 77
+END
+
+cat > xfail.test <<'END'
+#! /bin/sh
+echo "# expected failure #"
+exit 1
+END
+
+chmod a+x *.test
+
+test_log_edit ()
+{
+ sed -e "s|^ *$me 1\.0:.*$| $me 1.0: ???|" \
+ -e "s|^=====*|=======================|" $*
+}
+
+test_log_expected ()
+{
+ test_log_edit orig > exp
+ test_log_edit $1 > got
+ diff exp got || Exit 1
+ rm -f exp got
+}
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+$MAKE check
+ls -l
+cat test-suite.log
+cp test-suite.log orig
+
+$MAKE clean
+test -f test-suite.log && Exit 99 # Sanity check.
+
+# Check that we can override the testsuite log file at runtime.
+TEST_SUITE_LOG=zardoz.log $MAKE -e check
+ls -l
+test ! -f test-suite.log
+cat zardoz.log
+test_log_expected zardoz.log
+# Sanity check the distribution too (this also does minimal checks on
+# VPATH support).
+TEST_SUITE_LOG=zardoz.log $MAKE -e distcheck
+
+# Check that cleanup rules remove the correct file even when
+# user overrides are in place.
+cp orig test-suite.log
+TEST_SUITE_LOG=zardoz.log $MAKE -e clean
+ls -l
+test ! -f zardoz.log
+diff orig test-suite.log
+
+# Check that the default testsuite log doesn't get unduly modified.
+# Also check that the testsuite log file doesn't need to be named
+# accordingly to the '*.log' pattern.
+chmod a-w test-suite.log
+TEST_SUITE_LOG=TheLogFile $MAKE -e check
+ls -l
+diff orig test-suite.log
+test_log_expected TheLogFile
+TEST_SUITE_LOG=TheLogFile $MAKE -e clean
+ls -l
+test ! -f TheLogFile
+diff orig test-suite.log
+
+:
diff --git a/t/parallel-tests-log-override-2.sh b/t/parallel-tests-log-override-2.sh
new file mode 100755
index 000000000..ca0b59fbb
--- /dev/null
+++ b/t/parallel-tests-log-override-2.sh
@@ -0,0 +1,85 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check parallel-tests features: runtime redefinition of:
+# - $(TEST_SUITE_LOG) and $(TESTS)
+# - $(TEST_SUITE_LOG) and $(TEST_LOGS)
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.ac <<'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+TESTS = pass.test pass2.test skip.test skip2.test fail.test
+END
+
+cat > pass.test <<'END'
+#! /bin/sh
+exit 0
+END
+
+cp pass.test pass2.test
+
+cat > skip.test <<'END'
+#! /bin/sh
+echo "% skipped test %"
+exit 77
+END
+
+cp skip.test skip2.test
+
+cat > fail.test <<'END'
+#! /bin/sh
+exit 1
+END
+
+chmod a+x *.test
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+for test_list_override in \
+ 'TESTS=pass.test skip.test' \
+ 'TEST_LOGS=pass.log skip.log'
+do
+ env TEST_SUITE_LOG=partial.log "$test_list_override" \
+ $MAKE -e check >stdout || { cat stdout; Exit 1; }
+ cat stdout
+ ls -l
+ count_test_results total=2 pass=1 fail=0 skip=1 xfail=0 xpass=0 error=0
+ cat pass.log
+ cat skip.log
+ cat partial.log
+ test ! -f test-suite.log
+ test ! -f pass2.log
+ test ! -f skip2.log
+ test ! -f fail.log
+ grep '^PASS: pass\.test$' stdout
+ grep '^SKIP: skip\.test$' stdout
+ $FGREP 'SKIP: skip' partial.log
+ $FGREP '% skipped test %' partial.log
+ $EGREP '(pass2|skip2|fail)\.test' stdout && Exit 1
+ $EGREP '(pass2|skip2|fail)' partial.log && Exit 1
+ rm -f *.log
+done
+
+:
diff --git a/t/parallel-tests-log-override-recheck.sh b/t/parallel-tests-log-override-recheck.sh
new file mode 100755
index 000000000..c7c1b2b39
--- /dev/null
+++ b/t/parallel-tests-log-override-recheck.sh
@@ -0,0 +1,99 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check parallel-tests features: runtime redefinition of $(TEST_SUITE_LOG)
+# for the recheck target.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.ac <<'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+TESTS = foofoo.test barbar.test bazbaz.test
+END
+
+cat > foofoo.test <<'END'
+#! /bin/sh
+echo "this is $0"
+exit 0
+END
+
+cat > barbar.test <<'END'
+#! /bin/sh
+echo "this is $0"
+exit 99
+END
+
+cat > bazbaz.test <<'END'
+#! /bin/sh
+echo "this is $0"
+exit ${BAZ_EXIT_STATUS-1}
+END
+
+chmod a+x *.test
+
+unset BAZ_EXIT_STATUS || :
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+# Filter make output before grepping it, for make implementations that,
+# like Solaris' one, print the whole of the failed recipe on failure.
+filter_stdout ()
+{
+ grep -v 'bases=.*;' stdout > t && mv -f t stdout
+}
+
+./configure
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+chmod a-rw test-suite.log
+TEST_SUITE_LOG=my.log $MAKE -e recheck >stdout \
+ && { cat stdout; Exit 1; }
+cat stdout
+ls -l
+filter_stdout
+count_test_results total=2 pass=0 fail=1 skip=0 xfail=0 xpass=0 error=1
+for x in stdout my.log; do
+ $FGREP foofoo $x && Exit 1
+ $FGREP barbar $x
+ $FGREP bazbaz $x
+done
+
+chmod a-rw my.log
+BAZ_EXIT_STATUS=0 TEST_SUITE_LOG=my2.log $MAKE -e recheck >stdout \
+ && { cat stdout; Exit 1; }
+cat stdout
+ls -l
+count_test_results total=2 pass=1 fail=0 skip=0 xfail=0 xpass=0 error=1
+filter_stdout
+$FGREP foofoo stdout && Exit 1
+$FGREP barbar stdout
+$FGREP bazbaz stdout
+$FGREP foofoo my2.log && Exit 1
+$FGREP barbar my2.log
+$FGREP bazbaz my2.log && Exit 1
+
+chmod u+r test-suite.log my.log
+$FGREP bazbaz test-suite.log
+$FGREP bazbaz my.log
+
+:
diff --git a/t/parallel-tests-many.sh b/t/parallel-tests-many.sh
new file mode 100755
index 000000000..a09dbe518
--- /dev/null
+++ b/t/parallel-tests-many.sh
@@ -0,0 +1,190 @@
+#! /bin/sh
+# Copyright (C) 2012 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/>.
+
+# Check that the parallel-tests harness does not hit errors due to
+# an exceeded command line length when there are many tests.
+# For automake bug#7868. This test is currently expected to fail.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+# Sanity check that the $(TESTS) is going to exceed the system
+# command line length.
+# Extra quoting and indirections below are required to ensure the
+# various make implementations (e.g, GNU make or Sun Distributed Make)
+# will truly spawn a shell to execute this command, instead of relying
+# on optimizations that might mask the "Argument list too long" error
+# we expect.
+this-will-fail:
+ @":" && ":" $(TEST_LOGS)
+TEST_LOG_COMPILER = true
+include list-of-tests.am
+# So that we won't have to create a ton of dummy test cases.
+$(TESTS):
+END
+
+# The real instance will be dynamically created later.
+echo TESTS = foo.test > list-of-tests.am
+
+$ACLOCAL && $AUTOCONF && $AUTOMAKE -a \
+ || framework_failure_ "unexpected autotools failure"
+./configure \
+ || framework_failure_ "unexpected configure failure"
+
+# We want to hit the system command-line length limit without hitting
+# the filename length limit or the PATHMAX limit; so we use longish
+# (but not too long) names for the testcase, and place them in a nested
+# (but not too deeply) directory.
+# We also prefer to use the minimal(ish) number of test cases that can
+# make us hit the command-line length limit, since the more the test
+# cases are, the more time "automake" and "make check" will take to run
+# (especially on Cygwin and MinGW/MSYS).
+
+tname="wow-this-is-a-very-long-name-for-a-simple-dummy-test-case"
+dname="and-this-too-is-a-very-long-name-for-a-dummy-directory"
+
+deepdir=.
+depth=0
+for i in 1 2 3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 19 29 21 22 23 24; do
+ new_deepdir=$deepdir/$dname.d$i
+ mkdir $new_deepdir || break
+ tmpfile=$new_deepdir/$tname-some-more-chars-for-good-measure
+ if touch $tmpfile; then
+ rm -f $tmpfile || Exit 99
+ else
+ rmdir $new_deepdir || Exit 99
+ fi
+ deepdir=$new_deepdir
+ unset tmpfile new_deepdir
+ depth=$i
+done
+
+cat <<END
+*********************************************************************
+Our tests will be in the following directory (depth = $depth)
+*********************************************************************
+$deepdir
+*********************************************************************
+END
+
+setup_data ()
+{
+ # Use perl, not awk, to avoid errors like "awk: string too long"
+ # (seen e.g. with Solaris 10 /usr/bin/awk).
+ count=$count deepdir=$deepdir tname=$tname $PERL -e '
+ use warnings FATAL => "all";
+ use strict;
+ print "TESTS = \\\n";
+ my $i = 0;
+ while (++$i)
+ {
+ print " $ENV{deepdir}/$ENV{tname}-$i.test";
+ if ($i >= $ENV{count})
+ {
+ print "\n";
+ last;
+ }
+ else
+ {
+ print " \\\n";
+ }
+ }
+ ' > list-of-tests.am || Exit 99
+ sed 20q list-of-tests.am || Exit 99 # For debugging.
+ $AUTOMAKE Makefile \
+ || framework_failure_ "unexpected automake failure"
+ ./config.status Makefile \
+ || framework_failure_ "unexpected config.status failure"
+}
+
+for count in 1 2 4 8 12 16 20 24 28 32 48 64 96 128 E_HUGE; do
+ test $count = E_HUGE && break
+ count=`expr $count '*' 100` || Exit 99
+ setup_data
+ if $MAKE this-will-fail; then
+ continue
+ else
+ # We have managed to find a number of test cases large enough to
+ # hit the system command-line limits; we can stop. But first, for
+ # good measure, increase the number of tests of some 20%, to be
+ # "even more sure" of really tickling command line length limits.
+ count=`expr '(' $count '*' 12 ')' / 10` || Exit 99
+ setup_data
+ break
+ fi
+done
+
+if test $count = E_HUGE; then
+ framework_failure_ "system has a too-high limit on command line length"
+else
+ cat <<END
+*********************************************************************
+ Number of tests we will use: $count
+*********************************************************************
+END
+fi
+
+env TESTS=$deepdir/$tname-1.test $MAKE -e check \
+ && test -f $deepdir/$tname-1.log \
+ || framework_failure_ "\"make check\" with one single tests"
+
+rm -f $deepdir/* || Exit 99
+
+$MAKE check > stdout || { cat stdout; Exit 1; }
+cat stdout
+
+grep "^# TOTAL: $count$" stdout
+grep "^# PASS: $count$" stdout
+
+grep "^PASS: .*$tname-[0-9][0-9]*\.test" stdout > grp
+ls -1 $deepdir | grep '\.log$' > lst
+
+sed 20q lst # For debugging.
+sed 20q grp # Likewise.
+
+test `cat <grp | wc -l` -eq $count
+test `cat <lst | wc -l` -eq $count
+
+# We need to simulate a failure of two tests.
+st=0
+env TESTS="$deepdir/$tname-1.test $deepdir/$tname-2.test" \
+ TEST_LOG_COMPILER=false $MAKE -e check > stdout && st=1
+cat stdout
+test `grep -c '^FAIL:' stdout` -eq 2 || st=1
+test $st -eq 0 || fatal_ "couldn't simulate failure of two tests"
+unset st
+
+$MAKE recheck > stdout || { cat stdout; Exit 1; }
+cat stdout
+grep "^PASS: .*$tname-1\.test" stdout
+grep "^PASS: .*$tname-2\.test" stdout
+test `LC_ALL=C grep -c "^[A-Z][A-Z]*:" stdout` -eq 2
+grep "^# TOTAL: 2$" stdout
+grep "^# PASS: 2$" stdout
+
+# "make clean" might ignore some failures, so we prefer to also grep its
+# output to ensure that no "Argument list too long" error was encountered.
+$MAKE clean >output 2>&1 || { cat output; Exit 1; }
+cat output
+grep -i 'list.* too long' output && Exit 1
+ls $deepdir | grep '\.log$' && Exit 1
+
+:
diff --git a/t/parallel-tests-no-color-in-log.sh b/t/parallel-tests-no-color-in-log.sh
new file mode 100755
index 000000000..17115b943
--- /dev/null
+++ b/t/parallel-tests-no-color-in-log.sh
@@ -0,0 +1,63 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Colorized output from the testsuite report shouldn't end up in log files.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+esc=''
+
+# Check that grep can parse nonprinting characters.
+# BSD 'grep' works from a pipe, but not a seekable file.
+# GNU or BSD 'grep -a' works on files, but is not portable.
+case `echo "$esc" | $FGREP "$esc"` in
+ "$esc") ;;
+# Creative quoting below to please maintainer-check.
+ *) echo "$me: f""grep can't parse nonprinting characters" >&2; Exit 77;;
+esac
+
+TERM=ansi; export TERM
+
+cat >>configure.ac <<END
+AC_OUTPUT
+END
+
+cat >Makefile.am <<'END'
+LOG_COMPILER = $(SHELL)
+AUTOMAKE_OPTIONS = color-tests parallel-tests
+TESTS = pass fail skip xpass xfail error
+XFAIL_TESTS = xpass xfail
+END
+
+# Creative quoting to please maintainer-check.
+echo exit '0' > pass
+echo exit '0' > xpass
+echo exit '1' > fail
+echo exit '1' > xfail
+echo exit '77' > skip
+echo exit '99' > error
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+./configure
+mv config.log config-log # Avoid possible false positives below.
+AM_COLOR_TESTS=always $MAKE -e check && Exit 1
+$FGREP "$esc" *.log && Exit 1
+
+:
diff --git a/t/parallel-tests-no-spurious-summary.sh b/t/parallel-tests-no-spurious-summary.sh
new file mode 100755
index 000000000..62b4ef64c
--- /dev/null
+++ b/t/parallel-tests-no-spurious-summary.sh
@@ -0,0 +1,68 @@
+#! /bin/sh
+# Copyright (C) 2009-2012 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/>.
+
+# Check that ':test-results:' directives in test scripts' output doesn't
+# originate spurious results in the testsuite summary.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TESTS = foo.test bar.test
+END
+
+cat > foo.test <<'END'
+#! /bin/sh
+echo :test-result:XFAIL
+echo :test-result: SKIP
+echo :test-result:ERROR
+exit 0
+END
+cat > bar.test <<'END'
+#! /bin/sh
+echo :test-result: ERROR
+echo :test-result:FAIL
+echo :test-result: XPASS
+exit 0
+END
+chmod a+x foo.test bar.test
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+st=0
+$MAKE check >stdout || st=$?
+cat stdout
+cat test-suite.log
+cat foo.log
+cat bar.log
+test $st -eq 0 || Exit $st
+
+grep '^:test-result:XFAIL$' foo.log
+grep '^:test-result: SKIP$' foo.log
+grep '^:test-result:FAIL$' bar.log
+grep '^:test-result: XPASS$' bar.log
+
+count_test_results total=2 pass=2 fail=0 skip=0 xfail=0 xpass=0 error=0
+
+:
diff --git a/t/parallel-tests-once.sh b/t/parallel-tests-once.sh
new file mode 100755
index 000000000..53ee677fb
--- /dev/null
+++ b/t/parallel-tests-once.sh
@@ -0,0 +1,48 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Tests shouldn't be run multiple times by a simple "make check" in a
+# clean directory. An early implementation of the '.trs' intermediate
+# files incurred a similar problem.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TESTS = foo.test
+END
+
+cat > foo.test <<'END'
+#! /bin/sh
+test -f foo.run && Exit 1
+: > foo.run
+END
+chmod a+x foo.test
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+$MAKE check
+test -f foo.run # Sanity check.
+
+:
diff --git a/t/parallel-tests-reset-term.sh b/t/parallel-tests-reset-term.sh
new file mode 100755
index 000000000..6307f6e4b
--- /dev/null
+++ b/t/parallel-tests-reset-term.sh
@@ -0,0 +1,89 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that the parallel-tests driver correctly handle overrides of the
+# TERM variable by either TESTS_ENVIRONMENT and AM_TESTS_ENVIRONMENT.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+esc='['
+
+# Check that grep can parse nonprinting characters.
+# BSD 'grep' works from a pipe, but not a seekable file.
+# GNU or BSD 'grep -a' works on files, but is not portable.
+case `echo "$esc" | $FGREP "$esc"` in
+ "$esc") ;;
+ *) skip_ "$FGREP can't parse nonprinting characters" ;;
+esac
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+AM_COLOR_TESTS = always
+AUTOMAKE_OPTIONS = color-tests
+TESTS = foobar
+END
+
+cat > foobar << 'END'
+#!/bin/sh
+echo "TERM='$TERM'"
+echo "expected_term='$expected_term'"
+test x"$TERM" = x"$expected_term"
+END
+chmod a+x foobar
+
+mkcheck ()
+{
+ if env AM_COLOR_TESTS=always $* $MAKE check > stdout; then
+ rc=0
+ else
+ rc=1
+ fi
+ cat stdout
+ cat foobar.log
+ cat test-suite.log
+ return $rc
+}
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+./configure
+
+TERM=ansi; export TERM
+expected_term=dumb; export expected_term
+mkcheck TESTS_ENVIRONMENT='TERM=dumb'
+cat stdout | grep "PASS.*foobar" | $FGREP "$esc"
+
+TERM=dumb; export TERM
+expected_term=ansi; export expected_term
+mkcheck TESTS_ENVIRONMENT='TERM=ansi'
+cat stdout | $FGREP "$esc" && Exit 1
+
+TERM=ansi; export TERM
+expected_term=dumb; export expected_term
+mkcheck AM_TESTS_ENVIRONMENT='TERM=dumb'
+cat stdout | grep "PASS.*foobar" | $FGREP "$esc"
+
+TERM=dumb; export TERM
+expected_term=ansi; export expected_term
+mkcheck AM_TESTS_ENVIRONMENT='TERM=ansi'
+cat stdout | $FGREP "$esc" && Exit 1
+
+:
diff --git a/t/parallel-tests-subdir.sh b/t/parallel-tests-subdir.sh
new file mode 100755
index 000000000..6848edbd8
--- /dev/null
+++ b/t/parallel-tests-subdir.sh
@@ -0,0 +1,51 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that the parallel-tests driver creates parent directories for
+# the log files when needed.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TESTS = dir1/foo.test dir2/dir3/foo.test
+TEST_LOG_COMPILER = sh
+END
+
+mkdir dir1 dir2 dir2/dir3
+echo : > dir1/foo.test
+echo : > dir2/dir3/foo.test
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+mkdir build
+cd build
+../configure
+$MAKE check
+find . # For debugging.
+test -f test-suite.log
+test -f dir1/foo.log
+test -f dir1/foo.trs
+test -f dir2/dir3/foo.log
+test -f dir2/dir3/foo.trs
+
+:
diff --git a/t/parallel-tests-suffix-prog.sh b/t/parallel-tests-suffix-prog.sh
new file mode 100755
index 000000000..abd4a5c42
--- /dev/null
+++ b/t/parallel-tests-suffix-prog.sh
@@ -0,0 +1,77 @@
+#! /bin/sh
+# Copyright (C) 2009-2012 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/>.
+
+# Check parallel-tests features:
+# - suffix rules, with PROGRAMS involved
+# See also sister test 'parallel-tests-suffix.test'.
+
+am_parallel_tests=yes
+required='cc native'
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+## Note that automake should not match the '/test' part of 'sub/test' as
+## '.test' suffix, nor the '/chk' part of 'sub/chk' as '.chk' suffix.
+TESTS = $(dist_TESTS) $(check_PROGRAMS)
+dist_TESTS = foo.chk bar.test sub/test
+check_PROGRAMS = baz bla.test bli.suff sub/chk
+TEST_EXTENSIONS = .chk .test
+EXTRA_DIST = $(dist_TESTS)
+END
+
+mkdir sub
+
+cat >foo.chk << 'END'
+#! /bin/sh
+exit 0
+END
+chmod a+x foo.chk
+cp foo.chk bar.test
+cp foo.chk sub/test
+
+cat >baz.c << 'END'
+int main (void)
+{
+ return 0;
+}
+END
+cp baz.c bla.c
+cp baz.c bli.c
+cp baz.c sub/chk.c
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+$MAKE check
+ls -l . sub
+test -f foo.log
+test -f bar.log
+test -f baz.log
+test -f bla.log
+test -f bli.suff.log
+test -f sub/chk.log
+test -f sub/test.log
+
+$MAKE distcheck
+
+:
diff --git a/t/parallel-tests-suffix.sh b/t/parallel-tests-suffix.sh
new file mode 100755
index 000000000..bd72d0d57
--- /dev/null
+++ b/t/parallel-tests-suffix.sh
@@ -0,0 +1,63 @@
+#! /bin/sh
+# Copyright (C) 2009-2012 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/>.
+
+# Check parallel-tests features:
+# - suffix rules
+# See also sister test 'parallel-tests-suffix-prog.test'.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+## Note that automake should not match the '/test' part
+## of 'sub/test' as '.test' suffix.
+TESTS = foo.chk bar.test baz bli.suff sub/test
+TEST_EXTENSIONS = .chk .test
+EXTRA_DIST = $(TESTS)
+END
+
+mkdir sub
+
+cat >foo.chk << 'END'
+#! /bin/sh
+exit 0
+END
+chmod a+x foo.chk
+cp foo.chk bar.test
+cp foo.chk baz
+cp foo.chk bli.suff
+cp foo.chk sub/test
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+$MAKE check
+ls -l . sub
+test -f foo.log
+test -f bar.log
+test -f baz.log
+test -f bli.suff.log
+test -f sub/test.log
+
+$MAKE distcheck
+
+:
diff --git a/t/parallel-tests-trailing-bslash.sh b/t/parallel-tests-trailing-bslash.sh
new file mode 100755
index 000000000..4b3bdf847
--- /dev/null
+++ b/t/parallel-tests-trailing-bslash.sh
@@ -0,0 +1,114 @@
+#! /bin/sh
+# Copyright (C) 2012 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/>.
+
+# Check that the new testsuite harness do not generate recipes that can
+# have a trailing '\', since that can cause spurious syntax errors with
+# older bash versions (e.g., bash 2.05b).
+# See automake bug#10436.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+echo AC_OUTPUT >> configure.ac
+
+cat > Makefile.am <<'END'
+TESTS = foo.test
+EXTRA_DIST = $(TESTS)
+am__backslash = \\ # foo
+.PHONY: bad-recipe
+bad-recipe:
+ @printf '%s\n' $(am__backslash)
+END
+
+cat > foo.test <<'END'
+#!/bin/sh
+exit 0
+END
+chmod +x foo.test
+
+am__SHELL=$SHELL; export am__SHELL
+am__PERL=$PERL; export am__PERL
+
+cat > my-shell <<'END'
+#!/bin/sh -e
+set -u
+tab=' '
+nl='
+'
+am__shell_flags=
+am__shell_command=; unset am__shell_command
+while test $# -gt 0; do
+ case $1 in
+ # If the shell is invoked by make e.g. as "sh -ec" (seen on
+ # GNU make in POSIX mode) or "sh -ce" (seen on Solaris make).
+ -*c*)
+ flg=`echo x"$1" | sed -e 's/^x-//' -e 's/c//g'`
+ if test x"$flg" != x; then
+ am__shell_flags="$am__shell_flags -$flg"
+ fi
+ am__shell_command=$2
+ shift
+ ;;
+ -?*)
+ am__shell_flags="$am__shell_flags $1"
+ ;;
+ *)
+ break
+ ;;
+ esac
+ shift
+done
+if test x${am__shell_command+"set"} != x"set"; then
+ # Some make implementations, like *BSD's, pass the recipes to the shell
+ # through its standard input. Trying to run our extra checks in this
+ # case would be too tricky, so we just skip them.
+ exec $am__SHELL $am__shell_flags ${1+"$@"}
+else
+ am__tweaked_shell_command=`printf '%s\n' "$am__shell_command" \
+ | tr -d " $tab$nl"`
+ case ${am__tweaked_shell_command-} in
+ *\\)
+ echo "my-shell: recipe ends with backslash character" >&2
+ printf '%s\n' "=== BEGIN recipe" >&2
+ printf '%s\n' "${am__shell_command-}" >&2
+ printf '%s\n' "=== END recipe" >&2
+ exit 99
+ ;;
+ esac
+ exec $am__SHELL $am__shell_flags -c "$am__shell_command" ${1+"$@"}
+fi
+END
+chmod a+x my-shell
+
+cat my-shell
+
+CONFIG_SHELL=`pwd`/my-shell; export CONFIG_SHELL
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure CONFIG_SHELL="$CONFIG_SHELL"
+
+st=0
+$MAKE bad-recipe 2>stderr && st=1
+cat stderr >&2
+$FGREP "my-shell: recipe ends with backslash character" stderr || st=1
+test $st -eq 0 || skip_ "can't catch trailing backslashes in make recipes"
+
+$MAKE check
+
+:
diff --git a/t/parallel-tests-unreadable.sh b/t/parallel-tests-unreadable.sh
new file mode 100755
index 000000000..7ddb9db5b
--- /dev/null
+++ b/t/parallel-tests-unreadable.sh
@@ -0,0 +1,76 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that the testsuite driver copes well with unreadable '.log'
+# and '.trs' files.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+: > t
+chmod a-r t && test ! -r t || skip_ "you can still read unreadable files"
+rm -f t
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TESTS = foo.test bar.test
+END
+
+cat > foo.test << 'END'
+#! /bin/sh
+echo foofoofoo
+exit 0
+END
+
+cat > bar.test << 'END'
+#! /bin/sh
+echo barbarbar
+exit 77
+END
+
+chmod a+x foo.test bar.test
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+for files in \
+ 'foo.log bar.log' \
+ 'foo.trs bar.trs' \
+ 'foo.trs bar.log' \
+ 'foo.log bar.trs' \
+; do
+ $MAKE check
+ rm -f test-suite.log
+ chmod a-r $files
+ $MAKE test-suite.log || { ls -l; Exit 1; }
+ ls -l
+ grep '^foofoofoo$' foo.log
+ grep '^:test-result: PASS' foo.trs
+ grep '^barbarbar$' bar.log
+ grep '^:test-result: SKIP' bar.trs
+ grep '^SKIP: bar' test-suite.log
+ grep '^barbarbar$' test-suite.log
+ $EGREP ':.*foo|foofoofoo' test-suite.log && Exit 1
+ : For shells with busted 'set -e'.
+done
+
+:
diff --git a/t/parallel-tests.sh b/t/parallel-tests.sh
new file mode 100755
index 000000000..891d7bd80
--- /dev/null
+++ b/t/parallel-tests.sh
@@ -0,0 +1,152 @@
+#! /bin/sh
+# Copyright (C) 2009-2012 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/>.
+
+# Basic checks on parallel-tests support:
+# - console output
+# - log files, and what goes in 'test-suite.log'
+# - make clean
+# - dependencies between tests
+# - TESTS redefinition at runtime
+# - TEST_LOGS redefinition at runtime
+# - RECHECK_LOGS redefinition at runtime
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TESTS = foo.test bar.test baz.test
+XFAIL_TESTS = bar.test
+foo.log: bar.log
+bar.log: baz.log
+END
+
+# foo.test and bar.test sleep to ensure their logs are always strictly newer
+# than the logs of their prerequisites, for HP-UX make. The quoting pleases
+# maintainer-check.
+cat > foo.test <<'END'
+#! /bin/sh
+echo "this is $0"
+sleep '1'
+exit 0
+END
+cat > bar.test <<'END'
+#! /bin/sh
+echo "this is $0"
+sleep '1'
+exit 99
+END
+cat > baz.test <<'END'
+#! /bin/sh
+echo "this is $0"
+exit 1
+END
+chmod a+x foo.test bar.test baz.test
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+count_test_results total=3 pass=1 fail=1 skip=0 xfail=0 xpass=0 error=1
+test -f test-suite.log
+cat test-suite.log
+test `grep -c '^FAIL:' test-suite.log` -eq 1
+test `grep -c '^ERROR:' test-suite.log` -eq 1
+$EGREP '^(X?PASS|XFAIL|SKIP)' test-suite.log && Exit 1
+test -f baz.log
+test -f bar.log
+test -f foo.log
+
+$MAKE clean
+test ! -f baz.log
+test ! -f bar.log
+test ! -f foo.log
+test ! -f test-suite.log
+
+# Check dependencies: baz.test needs to run before bar.test,
+# but foo.test is not needed.
+# Note that this usage has a problem: the summary will only
+# take bar.log into account, because the $(TEST_SUITE_LOG) rule
+# does not "see" baz.log. Hmm.
+env TESTS='bar.test' $MAKE -e check >stdout && { cat stdout; Exit 1; }
+cat stdout
+grep '^FAIL: baz\.test$' stdout
+grep '^ERROR: bar\.test$' stdout
+
+test -f baz.log
+test -f bar.log
+test ! -f foo.log
+test -f test-suite.log
+
+# Upon a lazy rerun, foo.test should be run, but the others shouldn't.
+# Note that the lazy rerun still exits with a failure, due to the previous
+# test failures.
+# Note that the previous test and this one taken together expose the timing
+# issue that requires the check-TESTS rule to always remove TEST_SUITE_LOG
+# before running the tests lazily.
+env RECHECK_LOGS= $MAKE -e check > stdout && { cat stdout; Exit 1; }
+cat stdout
+test -f foo.log
+grep '^PASS: foo\.test$' stdout
+grep bar.test stdout && Exit 1
+grep baz.test stdout && Exit 1
+grep '^# PASS: *1$' stdout
+grep '^# FAIL: *1$' stdout
+grep '^# ERROR: *1$' stdout
+
+# Now, explicitly retry with all test logs already updated, and ensure
+# that the summary is still displayed.
+env RECHECK_LOGS= $MAKE -e check > stdout && { cat stdout; Exit 1; }
+cat stdout
+grep foo.test stdout && Exit 1
+grep bar.test stdout && Exit 1
+grep baz.test stdout && Exit 1
+grep '^# PASS: *1$' stdout
+grep '^# FAIL: *1$' stdout
+grep '^# ERROR: *1$' stdout
+
+# Lazily rerunning only foo should only rerun this one test.
+env RECHECK_LOGS=foo.log $MAKE -e check > stdout && { cat stdout; Exit 1; }
+cat stdout
+grep foo.test stdout
+grep bar.test stdout && Exit 1
+grep baz.test stdout && Exit 1
+grep '^# PASS: *1$' stdout
+grep '^# FAIL: *1$' stdout
+grep '^# ERROR: *1$' stdout
+
+$MAKE clean
+env TEST_LOGS=baz.log $MAKE -e check > stdout && { cat stdout; Exit 1; }
+cat stdout
+grep foo.test stdout && Exit 1
+grep bar.test stdout && Exit 1
+grep baz.test stdout
+
+$MAKE clean
+env TESTS=baz.test $MAKE -e check > stdout && { cat stdout; Exit 1; }
+cat stdout
+grep foo.test stdout && Exit 1
+grep bar.test stdout && Exit 1
+grep baz.test stdout
+
+:
diff --git a/t/parallel-tests10.sh b/t/parallel-tests10.sh
new file mode 100755
index 000000000..239648263
--- /dev/null
+++ b/t/parallel-tests10.sh
@@ -0,0 +1,47 @@
+#! /bin/sh
+# Copyright (C) 2009-2012 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/>.
+
+# Check parallel-tests features:
+# - trailing whitespace in TESTS
+# GNU make 3.80 may expand trailing white space to '.log'.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TESTS = foo $(BAR)
+BAR =
+END
+
+cat >foo <<'END'
+#! /bin/sh
+exit 0
+END
+
+chmod +x ./foo
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+$MAKE check
+
+:
diff --git a/t/parallel-tests2.sh b/t/parallel-tests2.sh
new file mode 100755
index 000000000..7b6933a5d
--- /dev/null
+++ b/t/parallel-tests2.sh
@@ -0,0 +1,149 @@
+#! /bin/sh
+# Copyright (C) 2009-2012 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/>.
+
+# Check parallel-tests features:
+# - check-html
+# - recheck-html
+# FIXME: the features tested by this script has been moved in contrib.
+# FIXME: We should move this script accordingly.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+# Try the variants that are tried in check-html.am.
+while :; do
+ for r2h in $RST2HTML rst2html rst2html.py; do
+ echo "$me: running $r2h --version"
+ # Don't use "&&" here, or a bug of 'set -e' present in some
+ # versions of the BSD shell will be triggered. We add the
+ # dummy "else" branch for extra safety.
+ if $r2h --version; then break 2; else :; fi
+ done
+ skip_all_ "no proper rst2html program found"
+done
+unset r2h
+
+cp "$top_testsrcdir"/contrib/check-html.am . \
+ || fatal_ "cannot fetch 'check-html.am' from contrib"
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TEST_SUITE_LOG = mylog.log
+TESTS = foo.test bar.test baz.test
+check_SCRIPTS = bla
+bla:
+ echo bla > $@
+CLEANFILES = bla
+include $(srcdir)/check-html.am
+END
+
+cat > foo.test <<'END'
+#! /bin/sh
+echo "this is $0"
+test -f bla || exit 1
+exit 0
+END
+
+cat > bar.test <<'END'
+#! /bin/sh
+echo "this is $0"
+exit 99
+END
+
+cat > baz.test <<'END'
+#! /bin/sh
+echo "this is $0"
+exit 1
+END
+
+chmod a+x foo.test bar.test baz.test
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+$MAKE check-html && Exit 1
+test -f mylog.html
+# check-html should cause check_SCRIPTS to be created.
+test -f bla
+
+# "make clean" should remove HTML files.
+$MAKE clean
+test ! -f mylog.html
+test ! -f bla
+
+# Always create the HTML output, even if there were no failures.
+rm -f mylog.html
+env TESTS=foo.test $MAKE -e check-html
+test -f mylog.html
+
+# Create summarizing HTML output also with recheck-html.
+rm -f mylog.html
+env TESTS=foo.test $MAKE -e recheck-html
+test -f mylog.html
+
+# Create HTML output for an individual test.
+$MAKE foo.html
+grep 'this is .*foo\.test' foo.html
+test ! -f bar.html
+test ! -f baz.html
+
+# Create HTML output for individual tests. Since the pre-existing log
+# files are expected to be used for the HTML conversion, this should
+# go smoothly even for failed tests.
+$MAKE bar.html baz.html
+grep 'this is .*bar\.test' bar.html
+grep 'this is .*baz\.test' baz.html
+
+# HTML output removed by mostlyclean.
+$MAKE mostlyclean
+test ! -f foo.html
+test ! -f bar.html
+test ! -f baz.html
+test ! -f mylog.html
+
+# check-html and recheck-html should cause check_SCRIPTS to be created,
+# and recheck-html should rerun no tests if check has not been run.
+
+$MAKE clean
+test ! -f mylog.html
+env TEST_LOGS=foo.log $MAKE -e check-html
+test -f bla
+test -f foo.log
+test ! -f bar.log
+test ! -f baz.log
+test -f mylog.html
+
+$MAKE clean
+env TESTS=foo.test $MAKE -e recheck-html
+test -f bla
+test ! -f foo.log
+test -f mylog.html
+
+$MAKE clean
+$MAKE recheck-html
+test -f bla
+test ! -f foo.log
+test ! -f bar.log
+test ! -f baz.log
+test -f mylog.html
+
+:
diff --git a/t/parallel-tests3.sh b/t/parallel-tests3.sh
new file mode 100755
index 000000000..f06d0939e
--- /dev/null
+++ b/t/parallel-tests3.sh
@@ -0,0 +1,116 @@
+#! /bin/sh
+# Copyright (C) 2009-2012 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/>.
+
+# Check parallel-tests features:
+# - concurrent parallel execution
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+case $MAKE in
+ *\ -j*) skip_ "\$MAKE contains '-j'";;
+esac
+
+if using_gmake; then
+ j=-j
+else
+ unindent > Makefile <<END
+ all: one two
+ one:
+ $sleep && test -f two
+ two:
+ echo ok > \$@
+END
+ for j in "-j" "-j " NONE; do
+ if test x"$j" = xNONE; then
+ skip_ "can't run make in parallel mode"
+ fi
+ $MAKE ${j}2 all >output 2>&1 || continue
+ $EGREP -i "(warning|error):|-j[\"\'\` ]" output && continue
+ break
+ done
+ rm -f one output Makefile
+fi
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TESTS =
+END
+
+cat > x <<'END'
+#! /bin/sh
+echo "this is $0"
+# Creative quoting below to please maintainer-check.
+sleep '1'
+exit 0
+END
+chmod a+x ./x
+
+mkdir sub
+for i in 1 2 3; do
+ echo "TESTS += foo$i.test" >> Makefile.am
+ cp x foo$i.test
+ echo "TESTS += zap$i" >> Makefile.am
+ cp x zap$i
+ echo "TESTS += sub/bar$i.test" >> Makefile.am
+ cp x sub/bar$i.test
+ echo "TESTS += sub/mu$i" >> Makefile.am
+ cp x sub/mu$i
+done
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+for build in serial parallel; do
+ mkdir $build
+ cd $build
+ ../configure
+ $MAKE
+ cd ..
+done
+
+cd serial
+$MAKE ${j}1 check &
+cd ../parallel
+$sleep
+# Use append mode here to avoid dropping output.
+# Yes, this actually happens.
+: >stdout
+$MAKE ${j}4 check >> stdout
+cd ..
+# Ensure the tests are really being run in parallel mode: if this is
+# the case, the serial run of the dummy testsuite started above should
+# still be ongoing when the parallel one has terminated.
+kill -0 $!
+cat parallel/stdout
+test `grep -c '^PASS:' parallel/stdout` -eq 12
+
+# Wait long enough so that there are no open files any more when the
+# post-test cleanup runs. But exit after we've waited for two minutes
+# or more, to avoid testsuite hangs in unusual situations (this has
+# already happened).
+i=1
+while test ! -f serial/test-suite.log && test $i -le 120; do
+ i=`expr $i + 1`
+ sleep '1' # Extra quoting to please maintainer-check.
+done
+$sleep
+
+:
diff --git a/t/parallel-tests5.sh b/t/parallel-tests5.sh
new file mode 100755
index 000000000..9f0a9669e
--- /dev/null
+++ b/t/parallel-tests5.sh
@@ -0,0 +1,66 @@
+#! /bin/sh
+# Copyright (C) 2009-2012 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/>.
+
+# Check parallel-tests features:
+# - concurrent program compilation and testing (with EXTRA_PROGRAMS)
+#
+# Actually, this test doesn't ensure that things happen concurrently.
+# It merely serves as demonstration. :-)
+
+am_parallel_tests=yes
+required='cc native GNUmake'
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TESTS = $(programs) $(scripts)
+EXTRA_PROGRAMS = $(programs)
+CLEANFILES = $(EXTRA_PROGRAMS)
+dist_noinst_SCRIPTS = $(scripts)
+programs =
+scripts =
+END
+
+for i in 1 2 3 4 5 6 7 8; do
+ echo "scripts += foo$i.test" >> Makefile.am
+ echo "programs += foo$i.prog" >> Makefile.am
+ unindent >foo$i.test <<'END'
+ #! /bin/sh
+ echo "this is $0"
+ exit 0
+END
+ cat >foo$i.c <<'END'
+ int main (void)
+ {
+ return 0;
+ }
+END
+ chmod a+x foo$i.test
+done
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+$MAKE -j4 check
+$MAKE distcheck
+
+:
diff --git a/t/parallel-tests6.sh b/t/parallel-tests6.sh
new file mode 100755
index 000000000..eee653810
--- /dev/null
+++ b/t/parallel-tests6.sh
@@ -0,0 +1,43 @@
+#! /bin/sh
+# Copyright (C) 2009-2012 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/>.
+
+# Check parallel-tests features:
+# - empty TESTS
+# BSD make will expand '$(TESTS:=.log)' to '.log' unless overridden.
+# See parallel-tests10.test for a similar issue.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TESTS =
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+$MAKE check >stdout || { cat stdout; Exit 1; }
+cat stdout
+for x in TOTAL PASS FAIL XPASS FAIL SKIP ERROR; do
+ grep "^# $x: *0$" stdout
+done
+
+Exit 0
diff --git a/t/parallel-tests8.sh b/t/parallel-tests8.sh
new file mode 100755
index 000000000..8e35b6b61
--- /dev/null
+++ b/t/parallel-tests8.sh
@@ -0,0 +1,75 @@
+#! /bin/sh
+# Copyright (C) 2009-2012 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/>.
+
+# Check parallel-tests features:
+# - generated distributed tests.
+# - listing $(srcdir)/ or $(top_srcdir)/ in TESTS doesn't work ATM,
+# and is thus diagnosed.
+
+# TODO: this test should also ensure that the 'make' implementation
+# properly adheres to rules in all cases. See the Autoconf
+# manual for the ugliness in this area, when VPATH comes into
+# play. :-/
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TESTS = foo.test
+## the next line will cause automake to error out:
+TESTS += $(srcdir)/bar.test $(top_srcdir)/baz.test
+.in.test:
+## Account for VPATH issues on weaker make implementations (e.g. IRIX 6.5)
+ cp `test -f '$<' || echo $(srcdir)/`$< $@
+ chmod +x $@
+check_SCRIPTS = $(TESTS)
+EXTRA_DIST = foo.in foo.test
+DISTCLEANFILES = foo.test
+END
+
+cat > foo.in <<'END'
+#! /bin/sh
+echo "this is $0"
+exit 0
+END
+
+$ACLOCAL
+$AUTOCONF
+AUTOMAKE_fails -a
+grep '$(srcdir).*TESTS.*bar\.test' stderr
+grep '$(top_srcdir).*TESTS.*baz\.test' stderr
+
+sed '/^TESTS +=.*srcdir/d' < Makefile.am > t
+mv -f t Makefile.am
+$AUTOMAKE -a
+
+./configure
+$MAKE check
+$MAKE distcheck
+$MAKE distclean
+
+mkdir build
+cd build
+../configure
+$MAKE check
+test ! -f ../foo.log
+$MAKE distcheck
+
+:
diff --git a/t/parallel-tests9.sh b/t/parallel-tests9.sh
new file mode 100755
index 000000000..f22be8d73
--- /dev/null
+++ b/t/parallel-tests9.sh
@@ -0,0 +1,80 @@
+#! /bin/sh
+# Copyright (C) 2009-2012 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/>.
+
+# Check parallel-tests features:
+# - recheck
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TEST_SUITE_LOG = mylog.log
+TESTS = foo.test bar.test baz.test
+check_SCRIPTS = bla
+CLEANFILES = bla
+bla:
+ echo bla > $@
+END
+
+cat > foo.test <<'END'
+#! /bin/sh
+echo "this is $0"
+test -f bla || exit 1
+exit 0
+END
+cat > bar.test <<'END'
+#! /bin/sh
+echo "this is $0"
+exit 99
+END
+cat > baz.test <<'END'
+#! /bin/sh
+echo "this is $0"
+exit 1
+END
+chmod a+x foo.test bar.test baz.test
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+count_test_results total=3 pass=1 fail=1 skip=0 xfail=0 xpass=0 error=1
+
+$MAKE recheck >stdout && { cat stdout; Exit 1; }
+cat stdout
+count_test_results total=2 pass=0 fail=1 skip=0 xfail=0 xpass=0 error=1
+grep 'foo\.test' stdout && Exit 1
+grep '^ERROR: bar\.test$' stdout
+grep '^FAIL: baz\.test$' stdout
+
+# Ensure that recheck builds check_SCRIPTS, and that
+# recheck reruns nothing if check has not been run.
+$MAKE clean
+$MAKE recheck
+test -f bla
+test ! -f foo.log
+test ! -f bar.log
+test ! -f baz.log
+test -f mylog.log
+
+:
diff --git a/t/parse.sh b/t/parse.sh
new file mode 100755
index 000000000..20ac2fedc
--- /dev/null
+++ b/t/parse.sh
@@ -0,0 +1,36 @@
+#! /bin/sh
+# Copyright (C) 1998-2012 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/>.
+
+# Test to make sure backslash-newline is treated as whitespace.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = zot
+zot_SOURCES = \
+zar.c\
+doz.c
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+$FGREP zar.cdoz Makefile.in && Exit 1
+Exit 0
diff --git a/t/percent.sh b/t/percent.sh
new file mode 100755
index 000000000..bdba44ede
--- /dev/null
+++ b/t/percent.sh
@@ -0,0 +1,36 @@
+#!/bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Test to make sure that -Wportability understands %-style pattern
+# rules.
+
+. ./defs || Exit 1
+
+cat >>configure.ac <<EOF
+AC_PROG_CC
+EOF
+
+cat >Makefile.am <<EOF
+bin_PROGRAMS = liver
+liver_SOURCES = foo.c
+
+%.o: %.c
+ echo "gnu make extension"
+EOF
+
+$ACLOCAL
+AUTOMAKE_fails -Wportability
+grep 'Makefile.am:4:.*%' stderr
diff --git a/t/percent2.sh b/t/percent2.sh
new file mode 100755
index 000000000..19af61a52
--- /dev/null
+++ b/t/percent2.sh
@@ -0,0 +1,39 @@
+#!/bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Another test for -Wportability warning about %-style rules, plus
+# make sure we don't warn about duplicate definition for
+# '${ARCH}/%.$(OBJEXT):'.
+# Report from Ralf Corsepius.
+
+. ./defs || Exit 1
+
+cat >>Makefile.am << 'EOF'
+${ARCH}/%.$(OBJEXT): %.S
+ test -d ${ARCH} || mkdir ${ARCH}
+ ${CCASCOMPILE} -o $@ -c $<
+
+${ARCH}/%.$(OBJEXT): %.c
+ test -d ${ARCH} || mkdir ${ARCH}
+ ${COMPILE} -o $@ -c $<
+EOF
+
+$ACLOCAL
+AUTOMAKE_fails
+grep '%.*pattern.*rules' stderr
+
+# No error otherwise.
+$AUTOMAKE -Wno-portability
diff --git a/t/phony.sh b/t/phony.sh
new file mode 100755
index 000000000..a818cfb70
--- /dev/null
+++ b/t/phony.sh
@@ -0,0 +1,29 @@
+#!/bin/sh
+# Copyright (C) 2002-2012 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 .PHONY can be given dependencies several times.
+# From Ralf Corsepius.
+
+. ./defs || Exit 1
+
+cat >Makefile.am << 'EOF'
+.PHONY: foo
+.PHONY: bar
+EOF
+
+$ACLOCAL
+$AUTOMAKE
+test `$FGREP .PHONY: Makefile.in | wc -l` = 3
diff --git a/t/pluseq.sh b/t/pluseq.sh
new file mode 100755
index 000000000..7a8df81da
--- /dev/null
+++ b/t/pluseq.sh
@@ -0,0 +1,30 @@
+#! /bin/sh
+# Copyright (C) 1998-2012 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/>.
+
+# Test '+=' functionality.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+data_DATA = zar
+data_DATA += doz
+END
+
+$ACLOCAL
+$AUTOMAKE
+$FGREP 'zar doz' Makefile.in
+
+:
diff --git a/t/pluseq10.sh b/t/pluseq10.sh
new file mode 100755
index 000000000..e9ce944a0
--- /dev/null
+++ b/t/pluseq10.sh
@@ -0,0 +1,55 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Test for += and backslashes.
+# Reported by Ralf Corsepius.
+
+. ./defs || Exit 1
+
+cat >>configure.ac << 'END'
+AM_CONDITIONAL([A], [true])
+AM_CONDITIONAL([B], [false])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+foo = 0.h
+if A
+foo += a0.h \
+ a1.h
+foo += a2.h \
+ a3.h
+endif
+if B
+foo += b0.h \
+ b1.h
+endif
+
+.PHONY: print
+print:
+ @echo BEG: $(foo) :END
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+$MAKE print >stdout || { cat stdout; Exit 1; }
+cat stdout
+$FGREP 'BEG: 0.h a0.h a1.h a2.h a3.h :END' stdout
+
+:
diff --git a/t/pluseq11.sh b/t/pluseq11.sh
new file mode 100755
index 000000000..4c0b8886c
--- /dev/null
+++ b/t/pluseq11.sh
@@ -0,0 +1,52 @@
+#!/bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Check for bug in variable concatenation with '+=': an extra backslash
+# is erroneously retained in the final value.
+# See also sister test pluseq11b.test.
+
+. ./defs || Exit 1
+
+cat >>configure.ac <<'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+## Use more line continuation to ensure we are robust and can (hopefully)
+## cope any number of them, and not just one
+FOO = \
+\
+\
+bar
+## Both these two variable additions are required to trigger the bug.
+FOO +=
+FOO += baz
+
+.PHONY: test
+test:
+ case '$(FOO)' in *\\*) exit 1;; *) exit 0;; esac
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+grep '^ *FOO *=.*\\.' Makefile.in && Exit 1
+
+$AUTOCONF
+./configure
+$MAKE test
+
+:
diff --git a/t/pluseq2.sh b/t/pluseq2.sh
new file mode 100755
index 000000000..102076a6d
--- /dev/null
+++ b/t/pluseq2.sh
@@ -0,0 +1,46 @@
+#! /bin/sh
+# Copyright (C) 1998-2012 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/>.
+
+# Test '+=' with conditionals.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AM_CONDITIONAL([CHECK], [true])
+END
+
+cat > Makefile.am << 'END'
+
+if CHECK
+data_DATA = zar
+else
+data_DATA =
+endif
+
+if CHECK
+data_DATA += doz
+else
+data_DATA += dog
+endif
+
+END
+
+$ACLOCAL
+$AUTOMAKE
+grep 'CHECK_TRUE.*zar doz' Makefile.in
+grep 'CHECK_FALSE.*dog' Makefile.in
+
+:
diff --git a/t/pluseq3.sh b/t/pluseq3.sh
new file mode 100755
index 000000000..fc7a496a0
--- /dev/null
+++ b/t/pluseq3.sh
@@ -0,0 +1,50 @@
+#! /bin/sh
+# Copyright (C) 1998-2012 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/>.
+
+# Another '+=' test with conditionals.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AM_CONDITIONAL([CHECK], [true])
+END
+
+cat > Makefile.am << 'END'
+
+if CHECK
+data_DATA = zarrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
+else
+data_DATA =
+endif
+
+if CHECK
+data_DATA += \
+ doz
+else
+data_DATA += dog
+endif
+
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+grep '^@CHECK_TRUE@data_DATA = zarrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr \\$' Makefile.in
+grep "^@CHECK_TRUE@${tab}doz$" Makefile.in
+
+grep '^@CHECK_FALSE@data_DATA = dog$' Makefile.in
+
+:
diff --git a/t/pluseq4.sh b/t/pluseq4.sh
new file mode 100755
index 000000000..59c82d855
--- /dev/null
+++ b/t/pluseq4.sh
@@ -0,0 +1,34 @@
+#! /bin/sh
+# Copyright (C) 1998-2012 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/>.
+
+# Yet another '+=' test.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = foo
+CC += -Dwhatever
+END
+
+$ACLOCAL
+$AUTOMAKE
+$FGREP '@CC@ -Dwhatever' Makefile.in
+
+:
diff --git a/t/pluseq5.sh b/t/pluseq5.sh
new file mode 100755
index 000000000..5db9c47b3
--- /dev/null
+++ b/t/pluseq5.sh
@@ -0,0 +1,60 @@
+#! /bin/sh
+# Copyright (C) 1999-2012 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/>.
+
+# Test for another '+=' problem. Report from Brian Jones.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AM_CONDITIONAL([CHECK], [true])
+END
+
+cat > Makefile.am << 'END'
+if CHECK
+INCLUDES = abc
+endif
+INCLUDES += def
+END
+
+$ACLOCAL
+AUTOMAKE_fails
+
+# We expect the following diagnostic:
+#
+# Makefile.am:4: cannot apply '+=' because 'INCLUDES' is not defined in
+# Makefile.am:4: the following conditions:
+# Makefile.am:4: !CHECK
+# Makefile.am:4: either define 'INCLUDES' in these conditions, or use
+# Makefile.am:4: '+=' in the same conditions as the definitions.
+
+# Is !CHECK mentioned?
+grep ':.*!CHECK$' stderr
+# Is there only one missing condition?
+test `grep ': ' stderr | wc -l` = 1
+
+# By the way, Automake should suggest using AM_CPPFLAGS,
+# because INCLUDES is an obsolete name.
+grep AM_CPPFLAGS stderr
+
+# A way to suppress the obsolete warning is to use
+# -Wno-obsolete:
+echo 'AUTOMAKE_OPTIONS = -Wno-obsolete' >> Makefile.am
+AUTOMAKE_fails
+grep AM_CPPFLAGS stderr && Exit 1
+# !CHECK should still be mentioned.
+grep ':.*!CHECK$' stderr
+
+:
diff --git a/t/pluseq6.sh b/t/pluseq6.sh
new file mode 100755
index 000000000..7a8f18706
--- /dev/null
+++ b/t/pluseq6.sh
@@ -0,0 +1,38 @@
+#! /bin/sh
+# Copyright (C) 1999-2012 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/>.
+
+# Test that '+=' works with standard header-vars.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_SUBST([ZZZ])
+END
+
+# If you do this in a real Makefile.am, I will kill you.
+cat > Makefile.am << 'END'
+mandir += foo
+zq = zzz
+END
+
+$ACLOCAL
+$AUTOMAKE
+$FGREP '@mandir@ foo' Makefile.in
+
+num=`grep '^mandir =' Makefile.in | wc -l`
+test $num -eq 1
+
+:
diff --git a/t/pluseq7.sh b/t/pluseq7.sh
new file mode 100755
index 000000000..7f5a32ec3
--- /dev/null
+++ b/t/pluseq7.sh
@@ -0,0 +1,38 @@
+#! /bin/sh
+# Copyright (C) 1999-2012 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/>.
+
+# Test that '+=' fails when required.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_PROG_RANLIB
+END
+
+# If you do this in a real Makefile.am, I will kill you.
+cat > Makefile.am << 'END'
+lib_LIBRARIES = libq.a
+libq_a_SOURCES = q.c
+AR += qq
+END
+
+$ACLOCAL
+AUTOMAKE_fails -Wno-portability
+q="[\`'\"]"
+grep "^Makefile\.am:3:.* AR .* with $q=$q before .*$q+=$q" stderr
+
+:
diff --git a/t/pluseq8.sh b/t/pluseq8.sh
new file mode 100755
index 000000000..724e4d510
--- /dev/null
+++ b/t/pluseq8.sh
@@ -0,0 +1,43 @@
+#! /bin/sh
+# Copyright (C) 1999-2012 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/>.
+
+# Another '+=' test. From Paul Berrevoets.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+VAR = \
+ one \
+ two
+VAR += three
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+sed -n -e '/^VAR =/ {
+ :loop
+ p
+ n
+ t clear
+ :clear
+ s/\\$/\\/
+ t loop
+ p
+ n
+ }' Makefile.in | grep three
+
+:
diff --git a/t/pluseq9.sh b/t/pluseq9.sh
new file mode 100755
index 000000000..f3c802158
--- /dev/null
+++ b/t/pluseq9.sh
@@ -0,0 +1,71 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Test the += diagnostics.
+
+. ./defs || Exit 1
+
+cat >>configure.ac << 'END'
+AM_CONDITIONAL([COND1], [true])
+AM_CONDITIONAL([COND2], [true])
+AM_CONDITIONAL([COND3], [true])
+END
+
+cat > Makefile.am << 'END'
+if COND1
+ C = c
+if COND2
+ A = a
+ B = aa
+ C += cc
+else
+ A = b
+ B = bb
+endif
+ A += c
+else
+ A = d
+endif
+A += e
+
+if COND3
+ A += f
+ B = cc
+endif
+B += dd
+END
+
+$ACLOCAL
+AUTOMAKE_fails
+
+# We expect the following diagnostic:
+#
+# Makefile.am:19: cannot apply '+=' because 'B' is not defined in
+# Makefile.am:19: the following conditions:
+# Makefile.am:19: !COND1 and !COND3
+# Makefile.am:19: either define 'B' in these conditions, or use
+# Makefile.am:19: '+=' in the same conditions as the definitions.
+#
+# It would be nice if Automake could print only COND3_FALSE and
+# COND1_FALSE (merging the last two conditions), so we'll support
+# this case in the check too.
+
+grep '[cC]annot apply.*+=' stderr
+grep ': !COND1 and !COND3$' stderr
+# Make sure there is exactly one missing condition.
+test `grep ': ' stderr | wc -l` = 1
+
+:
diff --git a/t/pm/Cond2.pl b/t/pm/Cond2.pl
new file mode 100644
index 000000000..2bed02826
--- /dev/null
+++ b/t/pm/Cond2.pl
@@ -0,0 +1,22 @@
+# Copyright (C) 2011-2012 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/>.
+
+# Catch common programming error:
+# A Condition passed as a string to 'new'.
+
+use Automake::Condition;
+
+my $cond = new Automake::Condition ('TRUE');
+new Automake::Condition ($cond);
diff --git a/t/pm/Cond3.pl b/t/pm/Cond3.pl
new file mode 100644
index 000000000..518eea84d
--- /dev/null
+++ b/t/pm/Cond3.pl
@@ -0,0 +1,22 @@
+# Copyright (C) 2011-2012 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/>.
+
+# Catch common programming error:
+# A Condition passed as a string to 'new'.
+
+use Automake::Condition;
+
+my $cond = new Automake::Condition ("COND1_TRUE");
+new Automake::Condition ("$cond");
diff --git a/t/pm/Condition-t.pl b/t/pm/Condition-t.pl
new file mode 100644
index 000000000..d29407add
--- /dev/null
+++ b/t/pm/Condition-t.pl
@@ -0,0 +1,327 @@
+# Copyright (C) 2001-2012 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/>.
+
+BEGIN {
+ use Config;
+ if (eval { require 5.007_002; } # for CLONE support
+ && $Config{useithreads}
+ && !$ENV{WANT_NO_THREADS})
+ {
+ require threads;
+ import threads;
+ }
+ else
+ {
+ exit 77;
+ }
+}
+use Automake::Condition qw/TRUE FALSE/;
+
+sub test_basics ()
+{
+ my @tests = (# [[Conditions], is_true?, is_false?, string, subst-string, human]
+ [[], 1, 0, 'TRUE', '', 'TRUE'],
+ [['TRUE'], 1, 0, 'TRUE', '', 'TRUE'],
+ [['FALSE'], 0, 1, 'FALSE', '#', 'FALSE'],
+ [['A_TRUE'], 0, 0, 'A_TRUE', '@A_TRUE@', 'A'],
+ [['A_TRUE', 'B_FALSE'],
+ 0, 0, 'A_TRUE B_FALSE', '@A_TRUE@@B_FALSE@', 'A and !B'],
+ [['B_TRUE', 'FALSE'], 0, 1, 'FALSE', '#', 'FALSE'],
+ [['B_TRUE', 'B_FALSE'], 0, 1, 'FALSE', '#', 'FALSE']);
+
+ for (@tests)
+ {
+ my $a = new Automake::Condition @{$_->[0]};
+ return 1
+ if threads->new(sub {
+ return 1 if $_->[1] != $a->true;
+ return 1 if $_->[1] != ($a == TRUE);
+ return 1 if $_->[2] != $a->false;
+ return 1 if $_->[2] != ($a == FALSE);
+ return 1 if $_->[3] ne $a->string;
+ return 1 if $_->[4] ne $a->subst_string;
+ return 1 if $_->[5] ne $a->human;
+ })->join;
+ }
+ return 0;
+}
+
+sub test_true_when ()
+{
+ my $failed = 0;
+
+ my @tests = (# [When,
+ # [Implied-Conditions],
+ # [Not-Implied-Conditions]]
+ [['TRUE'],
+ [['TRUE']],
+ [['A_TRUE'], ['A_TRUE', 'B_FALSE'], ['FALSE']]],
+ [['A_TRUE'],
+ [['TRUE'], ['A_TRUE']],
+ [['A_TRUE', 'B_FALSE'], ['FALSE']]],
+ [['A_TRUE', 'B_FALSE'],
+ [['TRUE'], ['A_TRUE'], ['B_FALSE'], ['A_TRUE', 'B_FALSE']],
+ [['FALSE'], ['C_FALSE'], ['C_FALSE', 'A_TRUE']]]);
+
+ for my $t (@tests)
+ {
+ my $a = new Automake::Condition @{$t->[0]};
+ return 1
+ if threads->new(sub {
+ for my $u (@{$t->[1]})
+ {
+ my $b = new Automake::Condition @$u;
+ return threads->new(sub {
+ if (! $b->true_when ($a))
+ {
+ print "`" . $b->string .
+ "' not implied by `" . $a->string . "'?\n";
+ $failed = 1;
+ }
+ })->join;
+ }
+ for my $u (@{$t->[2]})
+ {
+ my $b = new Automake::Condition @$u;
+ return threads->new(sub {
+ if ($b->true_when ($a))
+ {
+ print "`" . $b->string .
+ "' implied by `" . $a->string . "'?\n";
+ $failed = 1;
+ }
+
+ return threads->new(sub {
+ return 1 if $b->true_when ($a);
+ })->join;
+ })->join;
+ }
+ })->join;
+ }
+ return $failed;
+}
+
+sub test_reduce_and ()
+{
+ my @tests = (# If no conditions are given, TRUE should be returned
+ [[], ["TRUE"]],
+ # An empty condition is TRUE
+ [[""], ["TRUE"]],
+ # A single condition should be passed through unchanged
+ [["FOO"], ["FOO"]],
+ [["FALSE"], ["FALSE"]],
+ [["TRUE"], ["TRUE"]],
+ # TRUE and false should be discarded and overwhelm
+ # the result, respectively
+ [["FOO", "TRUE"], ["FOO"]],
+ [["FOO", "FALSE"], ["FALSE"]],
+ # Repetitions should be removed
+ [["FOO", "FOO"], ["FOO"]],
+ [["TRUE", "FOO", "FOO"], ["FOO"]],
+ [["FOO", "TRUE", "FOO"], ["FOO"]],
+ [["FOO", "FOO", "TRUE"], ["FOO"]],
+ # Two different conditions should be preserved,
+ # but TRUEs should be removed
+ [["FOO", "BAR"], ["BAR,FOO"]],
+ [["TRUE", "FOO", "BAR"], ["BAR,FOO"]],
+ [["FOO", "TRUE", "BAR"], ["BAR,FOO"]],
+ [["FOO", "BAR", "TRUE"], ["BAR,FOO"]],
+ # A condition implied by another condition should be removed.
+ [["FOO BAR", "BAR"], ["FOO BAR"]],
+ [["BAR", "FOO BAR"], ["FOO BAR"]],
+ [["TRUE", "FOO BAR", "BAR"], ["FOO BAR"]],
+ [["FOO BAR", "TRUE", "BAR"], ["FOO BAR"]],
+ [["FOO BAR", "BAR", "TRUE"], ["FOO BAR"]],
+
+ [["BAR FOO", "BAR"], ["BAR FOO"]],
+ [["BAR", "BAR FOO"], ["BAR FOO"]],
+ [["TRUE", "BAR FOO", "BAR"], ["BAR FOO"]],
+ [["BAR FOO", "TRUE", "BAR"], ["BAR FOO"]],
+ [["BAR FOO", "BAR", "TRUE"], ["BAR FOO"]],
+
+ # Check that reduction happens even when there are
+ # two conditions to remove.
+ [["FOO", "FOO BAR", "BAR"], ["FOO BAR"]],
+ [["FOO", "FOO BAR", "BAZ", "FOO BAZ"], ["FOO BAR", "FOO BAZ"]],
+ [["FOO", "FOO BAR", "BAZ", "FOO BAZ", "FOO BAZ BAR"],
+ ["FOO BAZ BAR"]],
+
+ # Duplicated conditionals should be removed.
+ [["FOO", "BAR", "BAR"], ["BAR,FOO"]],
+
+ # Equivalent conditions in different forms should be
+ # reduced: which one is left is unfortunately order
+ # dependent.
+ [["BAR FOO", "FOO BAR"], ["FOO BAR"]],
+ [["FOO BAR", "BAR FOO"], ["BAR FOO"]]);
+
+ my $failed = 0;
+ foreach (@tests)
+ {
+ my ($inref, $outref) = @$_;
+ my @inconds = map { new Automake::Condition $_ } @$inref;
+ return 1
+ if threads->new(sub {
+ my @outconds = map { (new Automake::Condition $_)->string } @$outref;
+ return threads->new(sub {
+ my @res =
+ map { $_->string } (Automake::Condition::reduce_and (@inconds));
+ return threads->new(sub {
+ my $result = join (",", sort @res);
+ my $exresult = join (",", @outconds);
+
+ if ($result ne $exresult)
+ {
+ print '"' . join(",", @$inref) . '" => "' .
+ $result . '" expected "' .
+ $exresult . '"' . "\n";
+ $failed = 1;
+ }
+ return $failed;
+ })->join;
+ })->join;
+ })->join;
+ }
+ return $failed;
+}
+
+sub test_reduce_or ()
+{
+ my @tests = (# If no conditions are given, FALSE should be returned
+ [[], ["FALSE"]],
+ # An empty condition is TRUE
+ [[""], ["TRUE"]],
+ # A single condition should be passed through unchanged
+ [["FOO"], ["FOO"]],
+ [["FALSE"], ["FALSE"]],
+ [["TRUE"], ["TRUE"]],
+ # FALSE and TRUE should be discarded and overwhelm
+ # the result, respectively
+ [["FOO", "TRUE"], ["TRUE"]],
+ [["FOO", "FALSE"], ["FOO"]],
+ # Repetitions should be removed
+ [["FOO", "FOO"], ["FOO"]],
+ [["FALSE", "FOO", "FOO"], ["FOO"]],
+ [["FOO", "FALSE", "FOO"], ["FOO"]],
+ [["FOO", "FOO", "FALSE"], ["FOO"]],
+ # Two different conditions should be preserved,
+ # but FALSEs should be removed
+ [["FOO", "BAR"], ["BAR,FOO"]],
+ [["FALSE", "FOO", "BAR"], ["BAR,FOO"]],
+ [["FOO", "FALSE", "BAR"], ["BAR,FOO"]],
+ [["FOO", "BAR", "FALSE"], ["BAR,FOO"]],
+ # A condition implying another condition should be removed.
+ [["FOO BAR", "BAR"], ["BAR"]],
+ [["BAR", "FOO BAR"], ["BAR"]],
+ [["FALSE", "FOO BAR", "BAR"], ["BAR"]],
+ [["FOO BAR", "FALSE", "BAR"], ["BAR"]],
+ [["FOO BAR", "BAR", "FALSE"], ["BAR"]],
+
+ [["BAR FOO", "BAR"], ["BAR"]],
+ [["BAR", "BAR FOO"], ["BAR"]],
+ [["FALSE", "BAR FOO", "BAR"], ["BAR"]],
+ [["BAR FOO", "FALSE", "BAR"], ["BAR"]],
+ [["BAR FOO", "BAR", "FALSE"], ["BAR"]],
+
+ # Check that reduction happens even when there are
+ # two conditions to remove.
+ [["FOO", "FOO BAR", "BAR"], ["BAR,FOO"]],
+ [["FOO", "FOO BAR", "BAZ", "FOO BAZ"], ["BAZ,FOO"]],
+ [["FOO", "FOO BAR", "BAZ", "FOO BAZ", "FOO BAZ BAR"],
+ ["BAZ,FOO"]],
+
+ # Duplicated conditionals should be removed.
+ [["FOO", "BAR", "BAR"], ["BAR,FOO"]],
+
+ # Equivalent conditions in different forms should be
+ # reduced: which one is left is unfortunately order
+ # dependent.
+ [["BAR FOO", "FOO BAR"], ["FOO BAR"]],
+ [["FOO BAR", "BAR FOO"], ["BAR FOO"]]);
+
+ my $failed = 0;
+ foreach (@tests)
+ {
+ my ($inref, $outref) = @$_;
+ my @inconds = map { new Automake::Condition $_ } @$inref;
+ return 1
+ if threads->new(sub {
+ my @outconds = map { (new Automake::Condition $_)->string } @$outref;
+ return threads->new(sub {
+ my @res =
+ map { $_->string } (Automake::Condition::reduce_or (@inconds));
+ return threads->new(sub {
+ my $result = join (",", sort @res);
+ my $exresult = join (",", @outconds);
+
+ if ($result ne $exresult)
+ {
+ print '"' . join(",", @$inref) . '" => "' .
+ $result . '" expected "' .
+ $exresult . '"' . "\n";
+ $failed = 1;
+ }
+ return $failed;
+ })->join;
+ })->join;
+ })->join;
+ }
+ return $failed;
+}
+
+sub test_merge ()
+{
+ my $cond = new Automake::Condition "COND1_TRUE", "COND2_FALSE";
+ return threads->new(sub {
+ my $other = new Automake::Condition "COND3_FALSE";
+ return threads->new(sub {
+ my $both = $cond->merge ($other);
+ return threads->new(sub {
+ my $both2 = $cond->merge_conds ("COND3_FALSE");
+ return threads->new(sub {
+ $cond = $both->strip ($other);
+ my @conds = $cond->conds;
+ return 1 if $both->string ne "COND1_TRUE COND2_FALSE COND3_FALSE";
+ return 1 if $cond->string ne "COND1_TRUE COND2_FALSE";
+ return 1 if $both != $both2;
+ })->join;
+ })->join;
+ })->join;
+ })->join;
+ return 0;
+}
+
+exit (test_basics
+ || test_true_when
+ || test_reduce_and
+ || test_reduce_or
+ || test_merge);
+
+### Setup "GNU" style for perl-mode and cperl-mode.
+## Local Variables:
+## perl-indent-level: 2
+## perl-continued-statement-offset: 2
+## perl-continued-brace-offset: 0
+## perl-brace-offset: 0
+## perl-brace-imaginary-offset: 0
+## perl-label-offset: -2
+## cperl-indent-level: 2
+## cperl-brace-offset: 0
+## cperl-continued-brace-offset: 0
+## cperl-label-offset: -2
+## cperl-extra-newline-before-brace: t
+## cperl-merge-trailing-else: nil
+## cperl-continued-statement-offset: 2
+## End:
diff --git a/t/pm/Condition.pl b/t/pm/Condition.pl
new file mode 100644
index 000000000..5041a843e
--- /dev/null
+++ b/t/pm/Condition.pl
@@ -0,0 +1,277 @@
+# Copyright (C) 2001-2012 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/>.
+
+use Automake::Condition qw/TRUE FALSE/;
+
+sub test_basics ()
+{
+ my @tests = (# [[Conditions], is_true?, is_false?, string, subst-string, human]
+ [[], 1, 0, 'TRUE', '', 'TRUE'],
+ [['TRUE'], 1, 0, 'TRUE', '', 'TRUE'],
+ [['FALSE'], 0, 1, 'FALSE', '#', 'FALSE'],
+ [['A_TRUE'], 0, 0, 'A_TRUE', '@A_TRUE@', 'A'],
+ [['A_TRUE', 'B_FALSE'],
+ 0, 0, 'A_TRUE B_FALSE', '@A_TRUE@@B_FALSE@', 'A and !B'],
+ [['B_TRUE', 'FALSE'], 0, 1, 'FALSE', '#', 'FALSE'],
+ [['B_TRUE', 'B_FALSE'], 0, 1, 'FALSE', '#', 'FALSE']);
+
+ for (@tests)
+ {
+ my $a = new Automake::Condition @{$_->[0]};
+ return 1 if $_->[1] != $a->true;
+ return 1 if $_->[1] != ($a == TRUE);
+ return 1 if $_->[2] != $a->false;
+ return 1 if $_->[2] != ($a == FALSE);
+ return 1 if $_->[3] ne $a->string;
+ return 1 if $_->[4] ne $a->subst_string;
+ return 1 if $_->[5] ne $a->human;
+ }
+ return 0;
+}
+
+sub test_true_when ()
+{
+ my $failed = 0;
+
+ my @tests = (# [When,
+ # [Implied-Conditions],
+ # [Not-Implied-Conditions]]
+ [['TRUE'],
+ [['TRUE']],
+ [['A_TRUE'], ['A_TRUE', 'B_FALSE'], ['FALSE']]],
+ [['A_TRUE'],
+ [['TRUE'], ['A_TRUE']],
+ [['A_TRUE', 'B_FALSE'], ['FALSE']]],
+ [['A_TRUE', 'B_FALSE'],
+ [['TRUE'], ['A_TRUE'], ['B_FALSE'], ['A_TRUE', 'B_FALSE']],
+ [['FALSE'], ['C_FALSE'], ['C_FALSE', 'A_TRUE']]]);
+
+ for my $t (@tests)
+ {
+ my $a = new Automake::Condition @{$t->[0]};
+ for my $u (@{$t->[1]})
+ {
+ my $b = new Automake::Condition @$u;
+ if (! $b->true_when ($a))
+ {
+ print "`" . $b->string .
+ "' not implied by `" . $a->string . "'?\n";
+ $failed = 1;
+ }
+ }
+ for my $u (@{$t->[2]})
+ {
+ my $b = new Automake::Condition @$u;
+ if ($b->true_when ($a))
+ {
+ print "`" . $b->string .
+ "' implied by `" . $a->string . "'?\n";
+ $failed = 1;
+ }
+
+ return 1 if $b->true_when ($a);
+ }
+ }
+ return $failed;
+}
+
+sub test_reduce_and ()
+{
+ my @tests = (# If no conditions are given, TRUE should be returned
+ [[], ["TRUE"]],
+ # An empty condition is TRUE
+ [[""], ["TRUE"]],
+ # A single condition should be passed through unchanged
+ [["FOO"], ["FOO"]],
+ [["FALSE"], ["FALSE"]],
+ [["TRUE"], ["TRUE"]],
+ # TRUE and false should be discarded and overwhelm
+ # the result, respectively
+ [["FOO", "TRUE"], ["FOO"]],
+ [["FOO", "FALSE"], ["FALSE"]],
+ # Repetitions should be removed
+ [["FOO", "FOO"], ["FOO"]],
+ [["TRUE", "FOO", "FOO"], ["FOO"]],
+ [["FOO", "TRUE", "FOO"], ["FOO"]],
+ [["FOO", "FOO", "TRUE"], ["FOO"]],
+ # Two different conditions should be preserved,
+ # but TRUEs should be removed
+ [["FOO", "BAR"], ["BAR,FOO"]],
+ [["TRUE", "FOO", "BAR"], ["BAR,FOO"]],
+ [["FOO", "TRUE", "BAR"], ["BAR,FOO"]],
+ [["FOO", "BAR", "TRUE"], ["BAR,FOO"]],
+ # A condition implied by another condition should be removed.
+ [["FOO BAR", "BAR"], ["FOO BAR"]],
+ [["BAR", "FOO BAR"], ["FOO BAR"]],
+ [["TRUE", "FOO BAR", "BAR"], ["FOO BAR"]],
+ [["FOO BAR", "TRUE", "BAR"], ["FOO BAR"]],
+ [["FOO BAR", "BAR", "TRUE"], ["FOO BAR"]],
+
+ [["BAR FOO", "BAR"], ["BAR FOO"]],
+ [["BAR", "BAR FOO"], ["BAR FOO"]],
+ [["TRUE", "BAR FOO", "BAR"], ["BAR FOO"]],
+ [["BAR FOO", "TRUE", "BAR"], ["BAR FOO"]],
+ [["BAR FOO", "BAR", "TRUE"], ["BAR FOO"]],
+
+ # Check that reduction happens even when there are
+ # two conditions to remove.
+ [["FOO", "FOO BAR", "BAR"], ["FOO BAR"]],
+ [["FOO", "FOO BAR", "BAZ", "FOO BAZ"], ["FOO BAR", "FOO BAZ"]],
+ [["FOO", "FOO BAR", "BAZ", "FOO BAZ", "FOO BAZ BAR"],
+ ["FOO BAZ BAR"]],
+
+ # Duplicated conditionals should be removed.
+ [["FOO", "BAR", "BAR"], ["BAR,FOO"]],
+
+ # Equivalent conditions in different forms should be
+ # reduced: which one is left is unfortunately order
+ # dependent.
+ [["BAR FOO", "FOO BAR"], ["FOO BAR"]],
+ [["FOO BAR", "BAR FOO"], ["BAR FOO"]]);
+
+ my $failed = 0;
+ foreach (@tests)
+ {
+ my ($inref, $outref) = @$_;
+ my @inconds = map { new Automake::Condition $_ } @$inref;
+ my @outconds = map { (new Automake::Condition $_)->string } @$outref;
+ my @res =
+ map { $_->string } (Automake::Condition::reduce_and (@inconds));
+ my $result = join (",", sort @res);
+ my $exresult = join (",", @outconds);
+
+ if ($result ne $exresult)
+ {
+ print '"' . join(",", @$inref) . '" => "' .
+ $result . '" expected "' .
+ $exresult . '"' . "\n";
+ $failed = 1;
+ }
+ }
+ return $failed;
+}
+
+sub test_reduce_or ()
+{
+ my @tests = (# If no conditions are given, FALSE should be returned
+ [[], ["FALSE"]],
+ # An empty condition is TRUE
+ [[""], ["TRUE"]],
+ # A single condition should be passed through unchanged
+ [["FOO"], ["FOO"]],
+ [["FALSE"], ["FALSE"]],
+ [["TRUE"], ["TRUE"]],
+ # FALSE and TRUE should be discarded and overwhelm
+ # the result, respectively
+ [["FOO", "TRUE"], ["TRUE"]],
+ [["FOO", "FALSE"], ["FOO"]],
+ # Repetitions should be removed
+ [["FOO", "FOO"], ["FOO"]],
+ [["FALSE", "FOO", "FOO"], ["FOO"]],
+ [["FOO", "FALSE", "FOO"], ["FOO"]],
+ [["FOO", "FOO", "FALSE"], ["FOO"]],
+ # Two different conditions should be preserved,
+ # but FALSEs should be removed
+ [["FOO", "BAR"], ["BAR,FOO"]],
+ [["FALSE", "FOO", "BAR"], ["BAR,FOO"]],
+ [["FOO", "FALSE", "BAR"], ["BAR,FOO"]],
+ [["FOO", "BAR", "FALSE"], ["BAR,FOO"]],
+ # A condition implying another condition should be removed.
+ [["FOO BAR", "BAR"], ["BAR"]],
+ [["BAR", "FOO BAR"], ["BAR"]],
+ [["FALSE", "FOO BAR", "BAR"], ["BAR"]],
+ [["FOO BAR", "FALSE", "BAR"], ["BAR"]],
+ [["FOO BAR", "BAR", "FALSE"], ["BAR"]],
+
+ [["BAR FOO", "BAR"], ["BAR"]],
+ [["BAR", "BAR FOO"], ["BAR"]],
+ [["FALSE", "BAR FOO", "BAR"], ["BAR"]],
+ [["BAR FOO", "FALSE", "BAR"], ["BAR"]],
+ [["BAR FOO", "BAR", "FALSE"], ["BAR"]],
+
+ # Check that reduction happens even when there are
+ # two conditions to remove.
+ [["FOO", "FOO BAR", "BAR"], ["BAR,FOO"]],
+ [["FOO", "FOO BAR", "BAZ", "FOO BAZ"], ["BAZ,FOO"]],
+ [["FOO", "FOO BAR", "BAZ", "FOO BAZ", "FOO BAZ BAR"],
+ ["BAZ,FOO"]],
+
+ # Duplicated conditionals should be removed.
+ [["FOO", "BAR", "BAR"], ["BAR,FOO"]],
+
+ # Equivalent conditions in different forms should be
+ # reduced: which one is left is unfortunately order
+ # dependent.
+ [["BAR FOO", "FOO BAR"], ["FOO BAR"]],
+ [["FOO BAR", "BAR FOO"], ["BAR FOO"]]);
+
+ my $failed = 0;
+ foreach (@tests)
+ {
+ my ($inref, $outref) = @$_;
+ my @inconds = map { new Automake::Condition $_ } @$inref;
+ my @outconds = map { (new Automake::Condition $_)->string } @$outref;
+ my @res =
+ map { $_->string } (Automake::Condition::reduce_or (@inconds));
+ my $result = join (",", sort @res);
+ my $exresult = join (",", @outconds);
+
+ if ($result ne $exresult)
+ {
+ print '"' . join(",", @$inref) . '" => "' .
+ $result . '" expected "' .
+ $exresult . '"' . "\n";
+ $failed = 1;
+ }
+ }
+ return $failed;
+}
+
+sub test_merge ()
+{
+ my $cond = new Automake::Condition "COND1_TRUE", "COND2_FALSE";
+ my $other = new Automake::Condition "COND3_FALSE";
+ my $both = $cond->merge ($other);
+ my $both2 = $cond->merge_conds ("COND3_FALSE");
+ $cond = $both->strip ($other);
+ my @conds = $cond->conds;
+ return 1 if $both->string ne "COND1_TRUE COND2_FALSE COND3_FALSE";
+ return 1 if $cond->string ne "COND1_TRUE COND2_FALSE";
+ return 1 if $both != $both2;
+ return 0;
+}
+
+exit (test_basics
+ || test_true_when
+ || test_reduce_and
+ || test_reduce_or
+ || test_merge);
+
+### Setup "GNU" style for perl-mode and cperl-mode.
+## Local Variables:
+## perl-indent-level: 2
+## perl-continued-statement-offset: 2
+## perl-continued-brace-offset: 0
+## perl-brace-offset: 0
+## perl-brace-imaginary-offset: 0
+## perl-label-offset: -2
+## cperl-indent-level: 2
+## cperl-brace-offset: 0
+## cperl-continued-brace-offset: 0
+## cperl-label-offset: -2
+## cperl-extra-newline-before-brace: t
+## cperl-merge-trailing-else: nil
+## cperl-continued-statement-offset: 2
+## End:
diff --git a/t/pm/DisjCon2.pl b/t/pm/DisjCon2.pl
new file mode 100644
index 000000000..2d287493d
--- /dev/null
+++ b/t/pm/DisjCon2.pl
@@ -0,0 +1,24 @@
+# Copyright (C) 2011-2012 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/>.
+
+# Catch common programming error:
+# A non-Condition reference passed to new.
+
+use Automake::Condition;
+use Automake::DisjConditions;
+
+my $cond = new Automake::Condition ('TRUE');
+my $cond2 = new Automake::DisjConditions ($cond);
+new Automake::DisjConditions ($cond2);
diff --git a/t/pm/DisjCon3.pl b/t/pm/DisjCon3.pl
new file mode 100644
index 000000000..ede5ab7ac
--- /dev/null
+++ b/t/pm/DisjCon3.pl
@@ -0,0 +1,23 @@
+# Copyright (C) 2011-2012 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/>.
+
+# Catch common programming error:
+# A non-reference passed to new.
+
+use Automake::Condition qw/TRUE FALSE/;
+use Automake::DisjConditions;
+
+my $cond = new Automake::Condition ("COND1_TRUE");
+new Automake::DisjConditions ("$cond");
diff --git a/t/pm/DisjConditions-t.pl b/t/pm/DisjConditions-t.pl
new file mode 100644
index 000000000..b49ae2e59
--- /dev/null
+++ b/t/pm/DisjConditions-t.pl
@@ -0,0 +1,461 @@
+# Copyright (C) 2001-2012 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/>.
+
+BEGIN {
+ use Config;
+ if (eval { require 5.007_002; } # for CLONE support
+ && $Config{useithreads}
+ && !$ENV{WANT_NO_THREADS})
+ {
+ require threads;
+ import threads;
+ }
+ else
+ {
+ exit 77;
+ }
+}
+use Automake::Condition qw/TRUE FALSE/;
+use Automake::DisjConditions;
+
+sub test_basics ()
+{
+ my $true = new Automake::DisjConditions TRUE;
+ my $false = new Automake::DisjConditions FALSE;
+ my $cond = new Automake::Condition "COND1_TRUE", "COND2_FALSE";
+ return threads->new (sub {
+ my $other = new Automake::Condition "COND3_FALSE";
+ my $another = new Automake::Condition "COND3_TRUE", "COND4_FALSE";
+ return threads->new (sub {
+ my $set1 = new Automake::DisjConditions $cond, $other;
+ return threads->new (sub {
+ my $set2 = new Automake::DisjConditions $other, $cond;
+ my $set3 = new Automake::DisjConditions FALSE, $another;
+ return 1 unless $set1 == $set2;
+ return 1 if $set1->false;
+ return 1 if $set1->true;
+ return 1 unless (new Automake::DisjConditions)->false;
+ return 1 if (new Automake::DisjConditions)->true;
+ return 1 unless $true->human eq 'TRUE';
+ return 1 unless $false->human eq 'FALSE';
+ return 1 unless $set1->human eq "(COND1 and !COND2) or (!COND3)";
+ return 1 unless $set2->human eq "(COND1 and !COND2) or (!COND3)";
+ my $one_cond_human = $set1->one_cond->human;
+ return 1 unless $one_cond_human eq "!COND3"
+ || $one_cond_human eq "COND1 and !COND2";
+ return 1 unless $set1->string eq "COND1_TRUE COND2_FALSE | COND3_FALSE";
+
+ my $merged1 = $set1->merge ($set2);
+ my $merged2 = $set1->merge ($cond);
+ my $mult1 = $set1->multiply ($set3);
+ return threads->new (sub {
+ my $mult2 = $set1->multiply ($another);
+ return threads->new (sub {
+ return 1 unless $merged1->simplify->string eq "COND1_TRUE COND2_FALSE | COND3_FALSE";
+ return 1 unless $merged2->simplify->string eq "COND1_TRUE COND2_FALSE | COND3_FALSE";
+ return 1 unless $mult1->string eq "COND1_TRUE COND2_FALSE COND3_TRUE COND4_FALSE";
+ return 1 unless $mult1 == $mult2;
+ return 0;
+ })->join;
+ })->join;
+ })->join;
+ })->join;
+ })->join;
+}
+
+sub build_set (@)
+{
+ my @conds = @_;
+ my @set = ();
+ for my $cond (@conds)
+ {
+ push @set, new Automake::Condition @$cond;
+ }
+ return new Automake::DisjConditions @set;
+}
+
+sub test_invert ()
+{
+ my @tests = ([[["FALSE"]],
+ [["TRUE"]]],
+
+ [[["TRUE"]],
+ [["FALSE"]]],
+
+ [[["COND1_TRUE", "COND2_TRUE"],
+ ["COND3_FALSE", "COND2_TRUE"]],
+ [["COND2_FALSE"],
+ ["COND1_FALSE", "COND3_TRUE"]]],
+
+ [[["COND1_TRUE", "COND2_TRUE"],
+ ["TRUE"]],
+ [["FALSE"]]],
+
+ [[["COND1_TRUE", "COND2_TRUE"],
+ ["FALSE"]],
+ [["COND1_FALSE"],
+ ["COND2_FALSE"]]],
+
+ [[["COND1_TRUE"],
+ ["COND2_FALSE"]],
+ [["COND1_FALSE", "COND2_TRUE"]]]
+ );
+
+ for my $t (@tests)
+ {
+ my $set = build_set @{$t->[0]};
+ return 1
+ if threads->new(sub {
+ my $res = build_set @{$t->[1]};
+ my $inv = $set->invert;
+ if ($inv != $res)
+ {
+ print " (I) " . $set->string . "\n\t"
+ . $inv->string . ' != ' . $res->string . "\n";
+ return 1;
+ }
+ return 0
+ })-> join;
+ }
+ return 0;
+}
+
+sub test_simplify ()
+{
+ my @tests = ([[["FOO_TRUE", "BAR_FALSE", "BAZ_FALSE"],
+ ["FOO_TRUE", "BAR_FALSE", "BAZ_TRUE"]],
+ [["FOO_TRUE", "BAR_FALSE"]]],
+
+ [[["FOO_TRUE", "BAR_FALSE", "BAZ_FALSE"],
+ ["FOO_TRUE", "BAR_FALSE", "BAZ_TRUE"],
+ ["FOO_TRUE", "BAR_TRUE"]],
+ [["FOO_TRUE"]]],
+
+ [[["FOO_TRUE", "BAR_FALSE", "BAZ_FALSE"],
+ ["FOO_TRUE", "BAR_FALSE", "BAZ_TRUE"],
+ ["FOO_TRUE", "BAR_TRUE"],
+ ["FOO_FALSE"]],
+ [["TRUE"]]],
+
+ [[["FOO_TRUE", "BAR_FALSE", "BAZ_FALSE"],
+ ["FOO_TRUE", "BAR_FALSE", "BAZ_TRUE"],
+ ["BAR_TRUE", "BAZ_TRUE"],
+ ["BAR_FALSE", "BAZ_TRUE"]],
+ [["BAZ_TRUE"], ["FOO_TRUE", "BAR_FALSE"]]],
+
+ [[["FOO_TRUE", "BAR_FALSE", "BAZ_FALSE"],
+ ["FOO_TRUE", "BAR_FALSE", "BAZ_TRUE"],
+ ["BAR_TRUE", "BAZ_TRUE"],
+ ["BAR_FALSE", "BAZ_TRUE"],
+ ["FOO_FALSE"]],
+ [["FOO_FALSE"], ["BAZ_TRUE"], ["BAR_FALSE"]]],
+
+ [[["B_TRUE"],
+ ["A_FALSE", "B_TRUE"]],
+ [["B_TRUE"]]],
+
+ [[["B_TRUE"],
+ ["A_FALSE", "B_FALSE", "C_TRUE"],
+ ["A_FALSE", "B_FALSE", "C_FALSE"]],
+ [["A_FALSE"], ["B_TRUE"]]],
+
+ [[["B_TRUE"],
+ ["A_FALSE", "B_FALSE", "C_TRUE"],
+ ["A_FALSE", "B_FALSE", "C_FALSE"],
+ ["A_TRUE", "B_FALSE"]],
+ [["TRUE"]]],
+
+ [[["A_TRUE", "B_TRUE"],
+ ["A_TRUE", "B_FALSE"],
+ ["A_TRUE", "C_FALSE", "D_FALSE"]],
+ [["A_TRUE"]]],
+
+ [[["A_FALSE", "B_FALSE", "C_FALSE", "D_TRUE", "E_FALSE"],
+ ["A_FALSE", "B_FALSE", "C_TRUE", "D_TRUE", "E_TRUE"],
+ ["A_FALSE", "B_TRUE", "C_TRUE", "D_FALSE", "E_TRUE"],
+ ["A_FALSE", "B_TRUE", "C_FALSE", "D_FALSE", "E_FALSE"],
+ ["A_TRUE", "B_TRUE", "C_FALSE", "D_FALSE", "E_FALSE"],
+ ["A_TRUE", "B_TRUE", "C_TRUE", "D_FALSE", "E_TRUE"],
+ ["A_TRUE", "B_FALSE", "C_TRUE", "D_TRUE", "E_TRUE"],
+ ["A_TRUE", "B_FALSE", "C_FALSE", "D_TRUE", "E_FALSE"]],
+ [ ["B_FALSE", "C_FALSE", "D_TRUE", "E_FALSE"],
+ ["B_FALSE", "C_TRUE", "D_TRUE", "E_TRUE"],
+ ["B_TRUE", "C_TRUE", "D_FALSE", "E_TRUE"],
+ ["B_TRUE", "C_FALSE", "D_FALSE", "E_FALSE"]]],
+
+ [[["A_FALSE", "B_FALSE", "C_FALSE", "D_TRUE", "E_FALSE"],
+ ["A_FALSE", "B_FALSE", "C_TRUE", "D_TRUE", "E_TRUE"],
+ ["A_FALSE", "B_TRUE", "C_TRUE", "D_FALSE", "E_TRUE"],
+ ["A_FALSE", "B_TRUE", "C_FALSE", "D_FALSE", "E_FALSE"],
+ ["A_TRUE", "B_TRUE", "C_FALSE", "D_FALSE", "E_FALSE"],
+ ["A_TRUE", "B_TRUE", "C_TRUE", "D_FALSE", "E_TRUE"],
+ ["A_TRUE", "B_FALSE", "C_TRUE", "D_TRUE", "E_TRUE"],
+ ["A_TRUE", "B_FALSE", "C_FALSE", "D_TRUE", "E_FALSE"],
+ ["A_FALSE", "B_FALSE", "C_FALSE", "D_FALSE", "E_FALSE"],
+ ["A_FALSE", "B_FALSE", "C_TRUE", "D_FALSE", "E_TRUE"],
+ ["A_FALSE", "B_TRUE", "C_TRUE", "D_TRUE", "E_TRUE"],
+ ["A_FALSE", "B_TRUE", "C_FALSE", "D_TRUE", "E_FALSE"],
+ ["A_TRUE", "B_TRUE", "C_FALSE", "D_TRUE", "E_FALSE"],
+ ["A_TRUE", "B_TRUE", "C_TRUE", "D_TRUE", "E_TRUE"],
+ ["A_TRUE", "B_FALSE", "C_TRUE", "D_FALSE", "E_TRUE"],
+ ["A_TRUE", "B_FALSE", "C_FALSE", "D_FALSE", "E_FALSE"]],
+ [["C_FALSE", "E_FALSE"],
+ ["C_TRUE", "E_TRUE"]]],
+
+ [[["A_FALSE"],
+ ["A_TRUE", "B_FALSE"],
+ ["A_TRUE", "B_TRUE", "C_FALSE"],
+ ["A_TRUE", "B_TRUE", "C_TRUE", "D_FALSE"],
+ ["A_TRUE", "B_TRUE", "C_TRUE", "D_TRUE", "E_FALSE"],
+ ["A_TRUE", "B_TRUE", "C_TRUE", "D_TRUE", "E_TRUE", "F_FALSE"],
+ ["A_TRUE", "B_TRUE", "C_TRUE", "D_TRUE", "E_TRUE"]],
+ [["TRUE"]]],
+
+ # Simplify should work with up to 31 variables.
+ [[["V01_TRUE", "V02_TRUE", "V03_TRUE", "V04_TRUE", "V05_TRUE",
+ "V06_TRUE", "V07_TRUE", "V08_TRUE", "V09_TRUE", "V10_TRUE",
+ "V11_TRUE", "V12_TRUE", "V13_TRUE", "V14_TRUE", "V15_TRUE",
+ "V16_TRUE", "V17_TRUE", "V18_TRUE", "V19_TRUE", "V20_TRUE",
+ "V21_TRUE", "V22_TRUE", "V23_TRUE", "V24_TRUE", "V25_TRUE",
+ "V26_TRUE", "V27_TRUE", "V28_TRUE", "V29_TRUE", "V30_TRUE",
+ "V31_TRUE"],
+ ["V01_TRUE", "V02_TRUE", "V03_TRUE", "V04_TRUE", "V05_TRUE",
+ "V06_TRUE", "V07_TRUE", "V08_TRUE", "V09_TRUE", "V10_TRUE",
+ "V11_TRUE", "V12_TRUE", "V13_TRUE", "V14_TRUE", "V15_TRUE",
+ "V16_TRUE", "V17_TRUE", "V18_TRUE", "V19_TRUE", "V20_TRUE",
+ "V21_TRUE", "V22_TRUE", "V23_TRUE", "V24_TRUE", "V25_TRUE",
+ "V26_TRUE", "V27_TRUE", "V28_TRUE", "V29_TRUE", "V30_TRUE",
+ "V31_FALSE"],
+ ["V01_FALSE","V02_TRUE", "V03_TRUE", "V04_TRUE", "V05_TRUE",
+ "V06_TRUE", "V07_TRUE", "V08_TRUE", "V09_TRUE", "V10_TRUE",
+ "V11_TRUE", "V12_TRUE", "V13_TRUE", "V14_TRUE", "V15_TRUE",
+ "V16_TRUE", "V17_TRUE", "V18_TRUE", "V19_TRUE", "V20_TRUE",
+ "V21_TRUE", "V22_TRUE", "V23_TRUE", "V24_TRUE", "V25_TRUE",
+ "V26_TRUE", "V27_TRUE", "V28_TRUE", "V29_TRUE", "V30_TRUE",
+ "V31_TRUE"],
+ ["V01_FALSE","V02_TRUE", "V03_TRUE", "V04_TRUE", "V05_TRUE",
+ "V06_TRUE", "V07_TRUE", "V08_TRUE", "V09_TRUE", "V10_TRUE",
+ "V11_TRUE", "V12_TRUE", "V13_TRUE", "V14_TRUE", "V15_TRUE",
+ "V16_TRUE", "V17_TRUE", "V18_TRUE", "V19_TRUE", "V20_TRUE",
+ "V21_TRUE", "V22_TRUE", "V23_TRUE", "V24_TRUE", "V25_TRUE",
+ "V26_TRUE", "V27_TRUE", "V28_TRUE", "V29_TRUE", "V30_TRUE",
+ "V31_FALSE"]],
+ [[ "V02_TRUE", "V03_TRUE", "V04_TRUE", "V05_TRUE",
+ "V06_TRUE", "V07_TRUE", "V08_TRUE", "V09_TRUE", "V10_TRUE",
+ "V11_TRUE", "V12_TRUE", "V13_TRUE", "V14_TRUE", "V15_TRUE",
+ "V16_TRUE", "V17_TRUE", "V18_TRUE", "V19_TRUE", "V20_TRUE",
+ "V21_TRUE", "V22_TRUE", "V23_TRUE", "V24_TRUE", "V25_TRUE",
+ "V26_TRUE", "V27_TRUE", "V28_TRUE", "V29_TRUE", "V30_TRUE"
+ ]]]);
+
+ for my $t (@tests)
+ {
+ my $set = build_set @{$t->[0]};
+ return 1
+ if threads->new(sub {
+ my $res = build_set @{$t->[1]};
+ return threads->new(sub {
+
+ # Make sure simplify() yields the expected result.
+ my $sim = $set->simplify;
+ return threads->new(sub {
+ if ($sim != $res)
+ {
+ print " (S1) " . $set->string . "\n\t"
+ . $sim->string . ' != ' . $res->string . "\n";
+ return 1;
+ }
+
+ # Make sure simplify() is idempotent.
+ my $sim2 = $sim->simplify;
+ return threads->new(sub {
+ if ($sim2 != $sim)
+ {
+ print " (S2) " . $sim->string . "\n\t"
+ . $sim2->string . ' != ' . $sim->string . "\n";
+ return 1;
+ }
+
+ # Also exercise invert() while we are at it.
+
+ my $inv1 = $set->invert->simplify;
+ return threads->new(sub {
+ my $inv2 = $sim->invert->simplify;
+ return threads->new(sub {
+ if ($inv1 != $inv2)
+ {
+ print " (S3) " . $set->string . ", " . $sim->string . "\n\t"
+ . $inv1->string . ' -= ' . $inv2->string . "\n";
+ return 1;
+ }
+ })->join;
+ })->join;
+ })->join;
+ })->join;
+ })->join;
+ })->join;
+ }
+
+ return 0;
+}
+
+sub test_sub_conditions ()
+{
+ my @tests = ([[["FOO_TRUE", "BAR_FALSE", "BAZ_FALSE"],
+ ["FOO_TRUE", "BAR_FALSE", "BAZ_TRUE"],
+ ["FOO_FALSE"]],
+ ["FOO_TRUE"],
+ [["BAR_FALSE", "BAZ_FALSE"],
+ ["BAR_FALSE", "BAZ_TRUE"]]],
+
+ [[["FOO_TRUE", "BAR_FALSE", "BAZ_FALSE"],
+ ["FOO_TRUE", "BAR_FALSE", "BAZ_TRUE"],
+ ["FOO_FALSE"]],
+ ["FOO_TRUE", "BAR_FALSE"],
+ [["BAZ_FALSE"],
+ ["BAZ_TRUE"]]],
+
+ [[["FOO_TRUE", "BAR_FALSE", "BAZ_FALSE"],
+ ["FOO_TRUE", "BAR_FALSE", "BAZ_TRUE"],
+ ["FOO_FALSE"]],
+ ["FOO_TRUE", "BAR_TRUE"],
+ [["FALSE"]]],
+
+ [[["FOO_TRUE", "BAR_FALSE", "BAZ_FALSE"],
+ ["FOO_TRUE", "BAZ_TRUE"],
+ ["FOO_FALSE"]],
+ ["FOO_TRUE", "BAR_TRUE"],
+ [["BAZ_TRUE"]]],
+
+ [[["FOO_TRUE", "BAR_FALSE"],
+ ["FOO_TRUE", "BAR_TRUE"]],
+ ["FOO_TRUE", "BAR_TRUE"],
+ [["TRUE"]]],
+
+ [[["TRUE"]],
+ ["TRUE"],
+ [["TRUE"]]],
+
+ [[["FALSE"]],
+ ["TRUE"],
+ [["FALSE"]]],
+
+ [[["FALSE"]],
+ ["FALSE"],
+ [["FALSE"]]]);
+
+ for my $t (@tests)
+ {
+ my $t1 = build_set @{$t->[0]};
+ return 1
+ if threads->new(sub {
+ my $t2 = new Automake::Condition @{$t->[1]};
+ return threads->new(sub {
+ my $t3 = build_set @{$t->[2]};
+ return threads->new(sub {
+
+ # Make sure sub_conditions() yields the expected result.
+ my $s = $t1->sub_conditions ($t2);
+ threads->new(sub {
+ if ($s != $t3)
+ {
+ print " (SC) " . $t1->string . "\n\t"
+ . $s->string . ' != ' . $t3->string . "\n";
+ return 1;
+ }
+ })->join;
+ })->join;
+ })->join;
+ })->join;
+ }
+}
+
+sub test_ambig ()
+{
+ my @tests = ([[["TRUE"]],
+ ["TRUE"],
+ "multiply defined"],
+ [[["C1_TRUE"]],
+ ["C1_TRUE"],
+ "multiply defined"],
+ [[["TRUE"]],
+ ["C1_FALSE"],
+ "which includes"],
+ [[["C1_TRUE"]],
+ ["C1_TRUE", "C2_TRUE"],
+ "which includes"],
+ [[["C1_TRUE", "C2_TRUE"]],
+ ["C2_TRUE"],
+ "which is included in"],
+ [[["C1_TRUE"]],
+ ["C2_TRUE"],
+ ''],
+ [[["C1_TRUE"],
+ ["C2_FALSE"]],
+ ["C1_FALSE", "C2_TRUE"],
+ '']);
+
+ my $failed = 0;
+ for my $t (@tests)
+ {
+ my $t1 = build_set @{$t->[0]};
+ $failed = 1
+ if threads->new(sub {
+ my $t2 = new Automake::Condition @{$t->[1]};
+ my $t3 = $t->[2];
+ return threads->new(sub {
+ my ($ans, $cond) = $t1->ambiguous_p ("FOO", $t2);
+ return threads->new(sub {
+ if ($t3 && $ans !~ /FOO.*$t3/)
+ {
+ print " (A1) " . $t1->string . " vs. " . $t2->string . "\n\t"
+ . "Error message '$ans' does not match '$t3'\n";
+ return 1;
+ }
+ if (!$t3 && $ans ne '')
+ {
+ print " (A2) " . $t1->string . " vs. " . $t2->string . "\n\t"
+ . "Unexpected error message: $ans\n";
+ return 1;
+ }
+ })->join;
+ })->join;
+ })->join;
+ }
+ return $failed;
+}
+
+exit (test_basics
+ || test_invert
+ || test_simplify
+ || test_sub_conditions
+ || test_ambig);
+
+### Setup "GNU" style for perl-mode and cperl-mode.
+## Local Variables:
+## perl-indent-level: 2
+## perl-continued-statement-offset: 2
+## perl-continued-brace-offset: 0
+## perl-brace-offset: 0
+## perl-brace-imaginary-offset: 0
+## perl-label-offset: -2
+## cperl-indent-level: 2
+## cperl-brace-offset: 0
+## cperl-continued-brace-offset: 0
+## cperl-label-offset: -2
+## cperl-extra-newline-before-brace: t
+## cperl-merge-trailing-else: nil
+## cperl-continued-statement-offset: 2
+## End:
diff --git a/t/pm/DisjConditions.pl b/t/pm/DisjConditions.pl
new file mode 100644
index 000000000..e7c977534
--- /dev/null
+++ b/t/pm/DisjConditions.pl
@@ -0,0 +1,404 @@
+# Copyright (C) 2001-2012 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/>.
+
+use Automake::Condition qw/TRUE FALSE/;
+use Automake::DisjConditions;
+
+sub test_basics ()
+{
+ my $true = new Automake::DisjConditions TRUE;
+ my $false = new Automake::DisjConditions FALSE;
+ my $cond = new Automake::Condition "COND1_TRUE", "COND2_FALSE";
+ my $other = new Automake::Condition "COND3_FALSE";
+ my $another = new Automake::Condition "COND3_TRUE", "COND4_FALSE";
+ my $set1 = new Automake::DisjConditions $cond, $other;
+ my $set2 = new Automake::DisjConditions $other, $cond;
+ my $set3 = new Automake::DisjConditions FALSE, $another;
+ return 1 unless $set1 == $set2;
+ return 1 if $set1->false;
+ return 1 if $set1->true;
+ return 1 unless (new Automake::DisjConditions)->false;
+ return 1 if (new Automake::DisjConditions)->true;
+ return 1 unless $true->human eq 'TRUE';
+ return 1 unless $false->human eq 'FALSE';
+ return 1 unless $set1->human eq "(COND1 and !COND2) or (!COND3)";
+ return 1 unless $set2->human eq "(COND1 and !COND2) or (!COND3)";
+ my $one_cond_human = $set1->one_cond->human;
+ return 1 unless $one_cond_human eq "!COND3"
+ || $one_cond_human eq "COND1 and !COND2";
+ return 1 unless $set1->string eq "COND1_TRUE COND2_FALSE | COND3_FALSE";
+
+ my $merged1 = $set1->merge ($set2);
+ my $merged2 = $set1->merge ($cond);
+ my $mult1 = $set1->multiply ($set3);
+ my $mult2 = $set1->multiply ($another);
+ return 1 unless $merged1->simplify->string eq "COND1_TRUE COND2_FALSE | COND3_FALSE";
+ return 1 unless $merged2->simplify->string eq "COND1_TRUE COND2_FALSE | COND3_FALSE";
+ return 1 unless $mult1->string eq "COND1_TRUE COND2_FALSE COND3_TRUE COND4_FALSE";
+ return 1 unless $mult1 == $mult2;
+
+ return 0;
+}
+
+sub build_set (@)
+{
+ my @conds = @_;
+ my @set = ();
+ for my $cond (@conds)
+ {
+ push @set, new Automake::Condition @$cond;
+ }
+ return new Automake::DisjConditions @set;
+}
+
+sub test_invert ()
+{
+ my @tests = ([[["FALSE"]],
+ [["TRUE"]]],
+
+ [[["TRUE"]],
+ [["FALSE"]]],
+
+ [[["COND1_TRUE", "COND2_TRUE"],
+ ["COND3_FALSE", "COND2_TRUE"]],
+ [["COND2_FALSE"],
+ ["COND1_FALSE", "COND3_TRUE"]]],
+
+ [[["COND1_TRUE", "COND2_TRUE"],
+ ["TRUE"]],
+ [["FALSE"]]],
+
+ [[["COND1_TRUE", "COND2_TRUE"],
+ ["FALSE"]],
+ [["COND1_FALSE"],
+ ["COND2_FALSE"]]],
+
+ [[["COND1_TRUE"],
+ ["COND2_FALSE"]],
+ [["COND1_FALSE", "COND2_TRUE"]]]
+ );
+
+ for my $t (@tests)
+ {
+ my $set = build_set @{$t->[0]};
+ my $res = build_set @{$t->[1]};
+ my $inv = $set->invert;
+ if ($inv != $res)
+ {
+ print " (I) " . $set->string . "\n\t"
+ . $inv->string . ' != ' . $res->string . "\n";
+ return 1;
+ }
+ }
+ return 0;
+}
+
+sub test_simplify ()
+{
+ my @tests = ([[["FOO_TRUE", "BAR_FALSE", "BAZ_FALSE"],
+ ["FOO_TRUE", "BAR_FALSE", "BAZ_TRUE"]],
+ [["FOO_TRUE", "BAR_FALSE"]]],
+
+ [[["FOO_TRUE", "BAR_FALSE", "BAZ_FALSE"],
+ ["FOO_TRUE", "BAR_FALSE", "BAZ_TRUE"],
+ ["FOO_TRUE", "BAR_TRUE"]],
+ [["FOO_TRUE"]]],
+
+ [[["FOO_TRUE", "BAR_FALSE", "BAZ_FALSE"],
+ ["FOO_TRUE", "BAR_FALSE", "BAZ_TRUE"],
+ ["FOO_TRUE", "BAR_TRUE"],
+ ["FOO_FALSE"]],
+ [["TRUE"]]],
+
+ [[["FOO_TRUE", "BAR_FALSE", "BAZ_FALSE"],
+ ["FOO_TRUE", "BAR_FALSE", "BAZ_TRUE"],
+ ["BAR_TRUE", "BAZ_TRUE"],
+ ["BAR_FALSE", "BAZ_TRUE"]],
+ [["BAZ_TRUE"], ["FOO_TRUE", "BAR_FALSE"]]],
+
+ [[["FOO_TRUE", "BAR_FALSE", "BAZ_FALSE"],
+ ["FOO_TRUE", "BAR_FALSE", "BAZ_TRUE"],
+ ["BAR_TRUE", "BAZ_TRUE"],
+ ["BAR_FALSE", "BAZ_TRUE"],
+ ["FOO_FALSE"]],
+ [["FOO_FALSE"], ["BAZ_TRUE"], ["BAR_FALSE"]]],
+
+ [[["B_TRUE"],
+ ["A_FALSE", "B_TRUE"]],
+ [["B_TRUE"]]],
+
+ [[["B_TRUE"],
+ ["A_FALSE", "B_FALSE", "C_TRUE"],
+ ["A_FALSE", "B_FALSE", "C_FALSE"]],
+ [["A_FALSE"], ["B_TRUE"]]],
+
+ [[["B_TRUE"],
+ ["A_FALSE", "B_FALSE", "C_TRUE"],
+ ["A_FALSE", "B_FALSE", "C_FALSE"],
+ ["A_TRUE", "B_FALSE"]],
+ [["TRUE"]]],
+
+ [[["A_TRUE", "B_TRUE"],
+ ["A_TRUE", "B_FALSE"],
+ ["A_TRUE", "C_FALSE", "D_FALSE"]],
+ [["A_TRUE"]]],
+
+ [[["A_FALSE", "B_FALSE", "C_FALSE", "D_TRUE", "E_FALSE"],
+ ["A_FALSE", "B_FALSE", "C_TRUE", "D_TRUE", "E_TRUE"],
+ ["A_FALSE", "B_TRUE", "C_TRUE", "D_FALSE", "E_TRUE"],
+ ["A_FALSE", "B_TRUE", "C_FALSE", "D_FALSE", "E_FALSE"],
+ ["A_TRUE", "B_TRUE", "C_FALSE", "D_FALSE", "E_FALSE"],
+ ["A_TRUE", "B_TRUE", "C_TRUE", "D_FALSE", "E_TRUE"],
+ ["A_TRUE", "B_FALSE", "C_TRUE", "D_TRUE", "E_TRUE"],
+ ["A_TRUE", "B_FALSE", "C_FALSE", "D_TRUE", "E_FALSE"]],
+ [ ["B_FALSE", "C_FALSE", "D_TRUE", "E_FALSE"],
+ ["B_FALSE", "C_TRUE", "D_TRUE", "E_TRUE"],
+ ["B_TRUE", "C_TRUE", "D_FALSE", "E_TRUE"],
+ ["B_TRUE", "C_FALSE", "D_FALSE", "E_FALSE"]]],
+
+ [[["A_FALSE", "B_FALSE", "C_FALSE", "D_TRUE", "E_FALSE"],
+ ["A_FALSE", "B_FALSE", "C_TRUE", "D_TRUE", "E_TRUE"],
+ ["A_FALSE", "B_TRUE", "C_TRUE", "D_FALSE", "E_TRUE"],
+ ["A_FALSE", "B_TRUE", "C_FALSE", "D_FALSE", "E_FALSE"],
+ ["A_TRUE", "B_TRUE", "C_FALSE", "D_FALSE", "E_FALSE"],
+ ["A_TRUE", "B_TRUE", "C_TRUE", "D_FALSE", "E_TRUE"],
+ ["A_TRUE", "B_FALSE", "C_TRUE", "D_TRUE", "E_TRUE"],
+ ["A_TRUE", "B_FALSE", "C_FALSE", "D_TRUE", "E_FALSE"],
+ ["A_FALSE", "B_FALSE", "C_FALSE", "D_FALSE", "E_FALSE"],
+ ["A_FALSE", "B_FALSE", "C_TRUE", "D_FALSE", "E_TRUE"],
+ ["A_FALSE", "B_TRUE", "C_TRUE", "D_TRUE", "E_TRUE"],
+ ["A_FALSE", "B_TRUE", "C_FALSE", "D_TRUE", "E_FALSE"],
+ ["A_TRUE", "B_TRUE", "C_FALSE", "D_TRUE", "E_FALSE"],
+ ["A_TRUE", "B_TRUE", "C_TRUE", "D_TRUE", "E_TRUE"],
+ ["A_TRUE", "B_FALSE", "C_TRUE", "D_FALSE", "E_TRUE"],
+ ["A_TRUE", "B_FALSE", "C_FALSE", "D_FALSE", "E_FALSE"]],
+ [["C_FALSE", "E_FALSE"],
+ ["C_TRUE", "E_TRUE"]]],
+
+ [[["A_FALSE"],
+ ["A_TRUE", "B_FALSE"],
+ ["A_TRUE", "B_TRUE", "C_FALSE"],
+ ["A_TRUE", "B_TRUE", "C_TRUE", "D_FALSE"],
+ ["A_TRUE", "B_TRUE", "C_TRUE", "D_TRUE", "E_FALSE"],
+ ["A_TRUE", "B_TRUE", "C_TRUE", "D_TRUE", "E_TRUE", "F_FALSE"],
+ ["A_TRUE", "B_TRUE", "C_TRUE", "D_TRUE", "E_TRUE"]],
+ [["TRUE"]]],
+
+ # Simplify should work with up to 31 variables.
+ [[["V01_TRUE", "V02_TRUE", "V03_TRUE", "V04_TRUE", "V05_TRUE",
+ "V06_TRUE", "V07_TRUE", "V08_TRUE", "V09_TRUE", "V10_TRUE",
+ "V11_TRUE", "V12_TRUE", "V13_TRUE", "V14_TRUE", "V15_TRUE",
+ "V16_TRUE", "V17_TRUE", "V18_TRUE", "V19_TRUE", "V20_TRUE",
+ "V21_TRUE", "V22_TRUE", "V23_TRUE", "V24_TRUE", "V25_TRUE",
+ "V26_TRUE", "V27_TRUE", "V28_TRUE", "V29_TRUE", "V30_TRUE",
+ "V31_TRUE"],
+ ["V01_TRUE", "V02_TRUE", "V03_TRUE", "V04_TRUE", "V05_TRUE",
+ "V06_TRUE", "V07_TRUE", "V08_TRUE", "V09_TRUE", "V10_TRUE",
+ "V11_TRUE", "V12_TRUE", "V13_TRUE", "V14_TRUE", "V15_TRUE",
+ "V16_TRUE", "V17_TRUE", "V18_TRUE", "V19_TRUE", "V20_TRUE",
+ "V21_TRUE", "V22_TRUE", "V23_TRUE", "V24_TRUE", "V25_TRUE",
+ "V26_TRUE", "V27_TRUE", "V28_TRUE", "V29_TRUE", "V30_TRUE",
+ "V31_FALSE"],
+ ["V01_FALSE","V02_TRUE", "V03_TRUE", "V04_TRUE", "V05_TRUE",
+ "V06_TRUE", "V07_TRUE", "V08_TRUE", "V09_TRUE", "V10_TRUE",
+ "V11_TRUE", "V12_TRUE", "V13_TRUE", "V14_TRUE", "V15_TRUE",
+ "V16_TRUE", "V17_TRUE", "V18_TRUE", "V19_TRUE", "V20_TRUE",
+ "V21_TRUE", "V22_TRUE", "V23_TRUE", "V24_TRUE", "V25_TRUE",
+ "V26_TRUE", "V27_TRUE", "V28_TRUE", "V29_TRUE", "V30_TRUE",
+ "V31_TRUE"],
+ ["V01_FALSE","V02_TRUE", "V03_TRUE", "V04_TRUE", "V05_TRUE",
+ "V06_TRUE", "V07_TRUE", "V08_TRUE", "V09_TRUE", "V10_TRUE",
+ "V11_TRUE", "V12_TRUE", "V13_TRUE", "V14_TRUE", "V15_TRUE",
+ "V16_TRUE", "V17_TRUE", "V18_TRUE", "V19_TRUE", "V20_TRUE",
+ "V21_TRUE", "V22_TRUE", "V23_TRUE", "V24_TRUE", "V25_TRUE",
+ "V26_TRUE", "V27_TRUE", "V28_TRUE", "V29_TRUE", "V30_TRUE",
+ "V31_FALSE"]],
+ [[ "V02_TRUE", "V03_TRUE", "V04_TRUE", "V05_TRUE",
+ "V06_TRUE", "V07_TRUE", "V08_TRUE", "V09_TRUE", "V10_TRUE",
+ "V11_TRUE", "V12_TRUE", "V13_TRUE", "V14_TRUE", "V15_TRUE",
+ "V16_TRUE", "V17_TRUE", "V18_TRUE", "V19_TRUE", "V20_TRUE",
+ "V21_TRUE", "V22_TRUE", "V23_TRUE", "V24_TRUE", "V25_TRUE",
+ "V26_TRUE", "V27_TRUE", "V28_TRUE", "V29_TRUE", "V30_TRUE"
+ ]]]);
+
+ for my $t (@tests)
+ {
+ my $set = build_set @{$t->[0]};
+ my $res = build_set @{$t->[1]};
+
+ # Make sure simplify() yields the expected result.
+ my $sim = $set->simplify;
+ if ($sim != $res)
+ {
+ print " (S1) " . $set->string . "\n\t"
+ . $sim->string . ' != ' . $res->string . "\n";
+ return 1;
+ }
+
+ # Make sure simplify() is idempotent.
+ my $sim2 = $sim->simplify;
+ if ($sim2 != $sim)
+ {
+ print " (S2) " . $sim->string . "\n\t"
+ . $sim2->string . ' != ' . $sim->string . "\n";
+ return 1;
+ }
+
+ # Also exercise invert() while we are at it.
+
+ my $inv1 = $set->invert->simplify;
+ my $inv2 = $sim->invert->simplify;
+ if ($inv1 != $inv2)
+ {
+ print " (S3) " . $set->string . ", " . $sim->string . "\n\t"
+ . $inv1->string . ' != ' . $inv2->string . "\n";
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+sub test_sub_conditions ()
+{
+ my @tests = ([[["FOO_TRUE", "BAR_FALSE", "BAZ_FALSE"],
+ ["FOO_TRUE", "BAR_FALSE", "BAZ_TRUE"],
+ ["FOO_FALSE"]],
+ ["FOO_TRUE"],
+ [["BAR_FALSE", "BAZ_FALSE"],
+ ["BAR_FALSE", "BAZ_TRUE"]]],
+
+ [[["FOO_TRUE", "BAR_FALSE", "BAZ_FALSE"],
+ ["FOO_TRUE", "BAR_FALSE", "BAZ_TRUE"],
+ ["FOO_FALSE"]],
+ ["FOO_TRUE", "BAR_FALSE"],
+ [["BAZ_FALSE"],
+ ["BAZ_TRUE"]]],
+
+ [[["FOO_TRUE", "BAR_FALSE", "BAZ_FALSE"],
+ ["FOO_TRUE", "BAR_FALSE", "BAZ_TRUE"],
+ ["FOO_FALSE"]],
+ ["FOO_TRUE", "BAR_TRUE"],
+ [["FALSE"]]],
+
+ [[["FOO_TRUE", "BAR_FALSE", "BAZ_FALSE"],
+ ["FOO_TRUE", "BAZ_TRUE"],
+ ["FOO_FALSE"]],
+ ["FOO_TRUE", "BAR_TRUE"],
+ [["BAZ_TRUE"]]],
+
+ [[["FOO_TRUE", "BAR_FALSE"],
+ ["FOO_TRUE", "BAR_TRUE"]],
+ ["FOO_TRUE", "BAR_TRUE"],
+ [["TRUE"]]],
+
+ [[["TRUE"]],
+ ["TRUE"],
+ [["TRUE"]]],
+
+ [[["FALSE"]],
+ ["TRUE"],
+ [["FALSE"]]],
+
+ [[["FALSE"]],
+ ["FALSE"],
+ [["FALSE"]]]);
+
+ for my $t (@tests)
+ {
+ my $t1 = build_set @{$t->[0]};
+ my $t2 = new Automake::Condition @{$t->[1]};
+ my $t3 = build_set @{$t->[2]};
+
+ # Make sure sub_conditions() yields the expected result.
+ my $s = $t1->sub_conditions ($t2);
+ if ($s != $t3)
+ {
+ print " (SC) " . $t1->string . "\n\t"
+ . $s->string . ' != ' . $t3->string . "\n";
+ return 1;
+ }
+ }
+}
+
+sub test_ambig ()
+{
+ my @tests = ([[["TRUE"]],
+ ["TRUE"],
+ "multiply defined"],
+ [[["C1_TRUE"]],
+ ["C1_TRUE"],
+ "multiply defined"],
+ [[["TRUE"]],
+ ["C1_FALSE"],
+ "which includes"],
+ [[["C1_TRUE"]],
+ ["C1_TRUE", "C2_TRUE"],
+ "which includes"],
+ [[["C1_TRUE", "C2_TRUE"]],
+ ["C2_TRUE"],
+ "which is included in"],
+ [[["C1_TRUE"]],
+ ["C2_TRUE"],
+ ''],
+ [[["C1_TRUE"],
+ ["C2_FALSE"]],
+ ["C1_FALSE", "C2_TRUE"],
+ '']);
+
+ for my $t (@tests)
+ {
+ my $t1 = build_set @{$t->[0]};
+ my $t2 = new Automake::Condition @{$t->[1]};
+ my $t3 = $t->[2];
+ my ($ans, $cond) = $t1->ambiguous_p ("FOO", $t2);
+ if ($t3 && $ans !~ /FOO.*$t3/)
+ {
+ print " (A1) " . $t1->string . " vs. " . $t2->string . "\n\t"
+ . "Error message '$ans' does not match '$t3'\n";
+ return 1;
+ }
+ if (!$t3 && $ans ne '')
+ {
+ print " (A2) " . $t1->string . " vs. " . $t2->string . "\n\t"
+ . "Unexpected error message: $ans\n";
+ return 1;
+ }
+ }
+ return 0;
+}
+
+exit (test_basics
+ || test_invert
+ || test_simplify
+ || test_sub_conditions
+ || test_ambig);
+
+### Setup "GNU" style for perl-mode and cperl-mode.
+## Local Variables:
+## perl-indent-level: 2
+## perl-continued-statement-offset: 2
+## perl-continued-brace-offset: 0
+## perl-brace-offset: 0
+## perl-brace-imaginary-offset: 0
+## perl-label-offset: -2
+## cperl-indent-level: 2
+## cperl-brace-offset: 0
+## cperl-continued-brace-offset: 0
+## cperl-label-offset: -2
+## cperl-extra-newline-before-brace: t
+## cperl-merge-trailing-else: nil
+## cperl-continued-statement-offset: 2
+## End:
diff --git a/t/pm/Version.pl b/t/pm/Version.pl
new file mode 100644
index 000000000..293badcd1
--- /dev/null
+++ b/t/pm/Version.pl
@@ -0,0 +1,129 @@
+# Copyright (C) 2002-2012 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/>.
+
+use Automake::Version;
+
+my $failed = 0;
+
+sub test_version_compare
+{
+ my ($left, $right, $result) = @_;
+ my @leftver = Automake::Version::split ($left);
+ my @rightver = Automake::Version::split ($right);
+ if ($#leftver == -1)
+ {
+ print "can't grok \"$left\"\n";
+ $failed = 1;
+ return;
+ }
+ if ($#rightver == -1)
+ {
+ print "can't grok \"$right\"\n";
+ $failed = 1;
+ return;
+ }
+ my $res = Automake::Version::compare (@leftver, @rightver);
+ if ($res != $result)
+ {
+ print "compare (\"$left\", \"$right\") = $res! (not $result?)\n";
+ $failed = 1;
+ }
+
+ my $check_expected = ($result == 0 || $result == 1) ? 0 : 1;
+ # Exception for 'foo' fork.
+ $check_expected = 1
+ if ($right =~ /foo/ && !($left =~ /foo/));
+
+ my $check = Automake::Version::check ($left, $right);
+ if ($check != $check_expected)
+ {
+ print "check (\"$left\", \"$right\") = $check! (not $check_expected?)\n";
+ $failed = 1;
+ }
+}
+
+sub test_bad_versions
+{
+ my ($ver) = @_;
+ my @version = Automake::Version::split ($ver);
+ if ($#version != -1)
+ {
+ print "shouldn't grok \"$ver\"\n";
+ $failed = 1;
+ }
+}
+
+my @tests = (
+# basics
+ ['1.0', '2.0', -1],
+ ['2.0', '1.0', 1],
+ ['1.2', '1.2', 0],
+ ['1.1', '1.2', -1],
+ ['1.2', '1.1', 1],
+# alphas
+ ['1.4', '1.4g', -1],
+ ['1.4g', '1.5', -1],
+ ['1.4g', '1.4', 1],
+ ['1.5', '1.4g', 1],
+ ['1.4a', '1.4g', -1],
+ ['1.5a', '1.3g', 1],
+ ['1.6a', '1.6a', 0],
+# micros
+ ['1.5.1', '1.5', 1],
+ ['1.5.0', '1.5', 0],
+ ['1.5.4', '1.6.1', -1],
+# micros and alphas
+ ['1.5a', '1.5.1', 1],
+ ['1.5a', '1.5.1a', 1],
+ ['1.5a', '1.5.1f', 1],
+ ['1.5', '1.5.1a', -1],
+ ['1.5.1a', '1.5.1f', -1],
+ ['1.5.1f', '1.5.1a', 1],
+ ['1.5.1f', '1.5.1f', 0],
+# special exceptions
+ ['1.6-p5a', '1.6.5a', 0],
+ ['1.6', '1.6-p5a', -1],
+ ['1.6-p4b', '1.6-p5a', -1],
+ ['1.6-p4b', '1.6-foo', 1],
+ ['1.6-p4b', '1.6a-foo', -1],
+ ['1.6-p5', '1.6.5', 0],
+ ['1.6a-foo', '1.6a-foo', 0],
+);
+
+my @bad_versions = (
+ '', 'a', '1', '1a', '1.2.3.4', '-1.2'
+);
+
+test_version_compare (@{$_}) foreach @tests;
+test_bad_versions ($_) foreach @bad_versions;
+
+exit $failed;
+
+### Setup "GNU" style for perl-mode and cperl-mode.
+## Local Variables:
+## perl-indent-level: 2
+## perl-continued-statement-offset: 2
+## perl-continued-brace-offset: 0
+## perl-brace-offset: 0
+## perl-brace-imaginary-offset: 0
+## perl-label-offset: -2
+## cperl-indent-level: 2
+## cperl-brace-offset: 0
+## cperl-continued-brace-offset: 0
+## cperl-label-offset: -2
+## cperl-extra-newline-before-brace: t
+## cperl-merge-trailing-else: nil
+## cperl-continued-statement-offset: 2
+## End:
diff --git a/t/pm/Version2.pl b/t/pm/Version2.pl
new file mode 100644
index 000000000..b452e475d
--- /dev/null
+++ b/t/pm/Version2.pl
@@ -0,0 +1,20 @@
+# Copyright (C) 2011-2012 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/>.
+
+# prog_error due to invalid $VERSION.
+
+use Automake::Version;
+
+Automake::Version::check ('', '1.2.3');
diff --git a/t/pm/Version3.pl b/t/pm/Version3.pl
new file mode 100644
index 000000000..2f7d41375
--- /dev/null
+++ b/t/pm/Version3.pl
@@ -0,0 +1,20 @@
+# Copyright (C) 2011-2012 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/>.
+
+# prog_error due to invalid $REQUIRED.
+
+use Automake::Version;
+
+Automake::Version::check ('1.2.3', '');
diff --git a/t/pm/Wrap.pl b/t/pm/Wrap.pl
new file mode 100644
index 000000000..a929a6a44
--- /dev/null
+++ b/t/pm/Wrap.pl
@@ -0,0 +1,112 @@
+# Copyright (C) 2003-2012 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/>.
+
+use Automake::Wrap qw/wrap makefile_wrap/;
+
+my $failed = 0;
+
+sub test_wrap
+{
+ my ($in, $exp_out) = @_;
+
+ my $out = &wrap (@$in);
+ if ($out ne $exp_out)
+ {
+ print STDERR "For: @$in\nGot:\n$out\nInstead of:\n$exp_out\n---\n";
+ ++$failed;
+ }
+}
+
+sub test_makefile_wrap
+{
+ my ($in, $exp_out) = @_;
+
+ my $out = &makefile_wrap (@$in);
+ if ($out ne $exp_out)
+ {
+ print STDERR "For: @$in\nGot:\n$out\nInstead of:\n$exp_out\n---\n";
+ ++$failed;
+ }
+}
+
+my @tests = (
+ [["HEAD:", "NEXT:", "CONT", 13, "v" ,"a", "l", "ue", "s", "values"],
+"HEAD:v aCONT
+NEXT:l ueCONT
+NEXT:sCONT
+NEXT:values
+"],
+ [["rule: ", "\t", " \\", 20, "dep1" ,"dep2", "dep3", "dep4", "dep5",
+ "dep06", "dep07", "dep08"],
+"rule: dep1 dep2 \\
+\tdep3 dep4 \\
+\tdep5 dep06 \\
+\tdep07 \\
+\tdep08
+"],
+ [["big header:", "big continuation:", " END", 5, "diag1", "diag2", "diag3"],
+"big header:diag1 END
+big continuation:diag2 END
+big continuation:diag3
+"],
+ [["big header:", "cont: ", " END", 16, "word1", "word2"],
+"big header: END
+cont: word1 END
+cont: word2
+"],
+ [["big header:", "", " END", 16, "w1", "w2 ", "w3"],
+"big header: END
+w1 w2 w3
+"]);
+
+my @makefile_tests = (
+ [["target:"],
+"target:
+"],
+ [["target:", "\t"],
+"target:
+"],
+ [["target:", "\t", "prereq1", "prereq2"],
+"target: prereq1 prereq2
+"],
+ [["target: ", "\t", "this is a long list of prerequisites ending in space",
+ "so that there is no need for another space before the backslash",
+ "unlike in the second line"],
+"target: this is a long list of prerequisites ending in space \\
+\tso that there is no need for another space before the backslash \\
+\tunlike in the second line
+"]);
+
+test_wrap (@{$_}) foreach @tests;
+test_makefile_wrap (@{$_}) foreach @makefile_tests;
+
+exit $failed;
+
+### Setup "GNU" style for perl-mode and cperl-mode.
+## Local Variables:
+## perl-indent-level: 2
+## perl-continued-statement-offset: 2
+## perl-continued-brace-offset: 0
+## perl-brace-offset: 0
+## perl-brace-imaginary-offset: 0
+## perl-label-offset: -2
+## cperl-indent-level: 2
+## cperl-brace-offset: 0
+## cperl-continued-brace-offset: 0
+## cperl-label-offset: -2
+## cperl-extra-newline-before-brace: t
+## cperl-merge-trailing-else: nil
+## cperl-continued-statement-offset: 2
+## End:
diff --git a/t/posixsubst-data.sh b/t/posixsubst-data.sh
new file mode 100755
index 000000000..c2c2d7e3e
--- /dev/null
+++ b/t/posixsubst-data.sh
@@ -0,0 +1,74 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Test that POSIX variable expansion '$(var:str=rpl)' works
+# in when used with the DATA primary.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+foodir = $(prefix)
+
+t1 = foo1 foo2
+t2 = barx
+t3 = baz.y
+
+bar.data bazzardoz:
+ : > $@
+CLEANFILES = bar.data bazzardoz
+
+# Also try an empty match suffix, to ensure that the ':=' in there is
+# not confused by the parser with an unportable assignment operator.
+dist_foo_DATA = $(t1:=.txt)
+foo_DATA = $(t2:x=.data)
+nodist_foo_DATA = $(t3:.y=zardoz)
+
+check-local: test
+.PHONY: test
+test: distdir
+ ls -l $(distdir)
+ test ! -r $(distdir)/foo.data
+ test ! -r $(distdir)/bazzardoz
+
+installcheck-local:
+ ls -l $(prefix)
+ test -f $(prefix)/foo1.txt
+ test -f $(prefix)/foo2.txt
+ test -f $(prefix)/bar.data
+ test -f $(prefix)/bazzardoz
+END
+
+: > foo1.txt
+: > foo2.txt
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+cwd=`pwd` || Exit 1
+./configure --prefix="$cwd/_inst"
+$MAKE install
+test -f bar.data
+test -f bazzardoz
+$MAKE test
+$MAKE installcheck
+$MAKE distcheck
+
+:
diff --git a/t/posixsubst-extradist.sh b/t/posixsubst-extradist.sh
new file mode 100755
index 000000000..7e3cf2f54
--- /dev/null
+++ b/t/posixsubst-extradist.sh
@@ -0,0 +1,54 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Test that POSIX variable expansion '$(var:str=rpl)' works when used
+# in EXTRA_DIST.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+t1 = foo1 foo2
+t2 = bar.x
+t3 = baz-y
+# Also try an empty match suffix, to ensure that the ':=' in there is
+# not confused by the parser with an unportable assignment operator.
+EXTRA_DIST = $(t1:=.c) $(t2:.x=.f) $(t3:-y=ar)
+bazar bar.f:
+ : > $@
+.PHONY: test
+test: distdir
+ ls -l $(distdir)
+ test -f $(distdir)/foo1.c
+ test -f $(distdir)/foo2.c
+ test -f $(distdir)/bar.f
+ test -f $(distdir)/bazar
+END
+
+: > foo1.c
+: > foo2.c
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+$MAKE test
+
+:
diff --git a/t/posixsubst-ldadd.sh b/t/posixsubst-ldadd.sh
new file mode 100755
index 000000000..f1cc55b36
--- /dev/null
+++ b/t/posixsubst-ldadd.sh
@@ -0,0 +1,78 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Test that POSIX variable expansion '$(var:str=rpl)' works
+# when used in LDADD.
+
+required=cc
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_PROG_RANLIB
+AM_PROG_AR
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+u = libquux1.lib libquux2.lib
+v = libquux1
+w = none
+
+zardozdir = $(prefix)/zardoz
+zardoz_PROGRAMS = foo bar
+
+noinst_LIBRARIES = libquux1.a libquux2.a libquux3.a
+
+# Also try an empty match suffix, to ensure that the ':=' in there is
+# not confused by the parser with an unportable assignment operator.
+LDADD = $(u:.lib=.a)
+bar_LDADD = $(v:=.a) libquux2.a $(w:none=libquux3.a)
+
+libquux1.c:
+ echo 'int quux1(void) { return 0; }' > $@
+CLEANFILES = libquux1.c # For FreeBSD make.
+END
+
+cat > foo.c <<'END'
+int main(void)
+{
+ int quux1(void), quux2(void);
+ return quux1() + quux2();
+}
+END
+
+cat > bar.c <<'END'
+int main(void)
+{
+ int quux1(void), quux2(void), quux3(void);
+ return quux1() + quux2() + quux3();
+}
+END
+
+echo 'int quux2(void) { return 0; }' > libquux2.c
+echo 'int quux3(void) { return 0; }' > libquux3.c
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+$MAKE
+test -f libquux1.c
+$MAKE distcheck
+
+:
diff --git a/t/posixsubst-libraries.sh b/t/posixsubst-libraries.sh
new file mode 100755
index 000000000..8e6b26521
--- /dev/null
+++ b/t/posixsubst-libraries.sh
@@ -0,0 +1,65 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Test that POSIX variable expansion '$(var:str=rpl)' works when used
+# with the LIBRARIES primary in a "simple" way.
+# Keep this in sync with sister test 'posixsubst-ltlibraries.test'.
+
+required=cc
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_PROG_RANLIB
+AM_PROG_AR
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+foolibs = libfoo1 libfoo2
+barlibs = libbaz
+
+# Also try an empty match suffix, to ensure that the ':=' in there is
+# not confused by the parser with an unportable assignment operator.
+lib_LIBRARIES = $(foolibs:=.a) $(barlibs:z=r.a)
+
+libbar.c:
+ echo 'int bar(void) { return 0; }' > $@
+CLEANFILES = libbar.c # For FreeBSD make.
+
+installcheck-local:
+ ls -l $(prefix)/lib
+ test -f $(prefix)/lib/libfoo1.a
+ test -f $(prefix)/lib/libfoo2.a
+ test -f $(prefix)/lib/libbar.a
+END
+
+echo 'int bar1(void) { return 0; }' > libfoo1.c
+echo 'int bar2(void) { return 0; }' > libfoo2.c
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+cwd=`pwd` || Exit 1
+./configure --prefix="$cwd/_inst"
+$MAKE
+test -f libfoo2.c
+$MAKE install
+$MAKE installcheck
+$MAKE distcheck
+
+:
diff --git a/t/posixsubst-ltlibraries.sh b/t/posixsubst-ltlibraries.sh
new file mode 100755
index 000000000..6a4cbd551
--- /dev/null
+++ b/t/posixsubst-ltlibraries.sh
@@ -0,0 +1,66 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Test that POSIX variable expansion '$(var:str=rpl)' works when used
+# with the LTLIBRARIES primary in a "simple" way.
+# Keep this in sync with sister test 'posixsubst-libraries.test'.
+
+required='cc libtool libtoolize'
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_LIBTOOL
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+foolibs = libfoo1 libfoo2
+barlibs = libbaz
+
+# Also try an empty match suffix, to ensure that the ':=' in there is
+# not confused by the parser with an unportable assignment operator.
+lib_LTLIBRARIES = $(foolibs:=.la) $(barlibs:z=r.la)
+
+libbar.c:
+ echo 'int bar(void) { return 0; }' > $@
+CLEANFILES = libbar.c # For FreeBSD make.
+
+installcheck-local:
+ ls -l $(prefix)/lib
+ test -f $(prefix)/lib/libfoo1.la
+ test -f $(prefix)/lib/libfoo2.la
+ test -f $(prefix)/lib/libbar.la
+END
+
+echo 'int bar1(void) { return 0; }' > libfoo1.c
+echo 'int bar2(void) { return 0; }' > libfoo2.c
+
+libtoolize
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+cwd=`pwd` || Exit 1
+./configure --prefix="$cwd/_inst"
+$MAKE
+test -f libfoo2.c
+$MAKE install
+$MAKE installcheck
+$MAKE distcheck
+
+:
diff --git a/t/posixsubst-programs.sh b/t/posixsubst-programs.sh
new file mode 100755
index 000000000..a02cb9209
--- /dev/null
+++ b/t/posixsubst-programs.sh
@@ -0,0 +1,63 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Test that POSIX variable expansion '$(var:str=rpl)' works when used
+# with the PROGRAMS primary.
+
+required=cc
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+t1 = foo1 foo2
+t2 = barx bar2
+
+# Also try an empty match suffix, to ensure that the ':=' in there is
+# not confused by the parser with an unportable assignment operator.
+bin_PROGRAMS = $(t1:=-p) $(t2:2=y)
+
+installcheck-local:
+ ls -l $(prefix)/bin
+ test -f $(prefix)/bin/foo1-p$(EXEEXT)
+ test -x $(prefix)/bin/foo1-p$(EXEEXT)
+ test -f $(prefix)/bin/foo2-p$(EXEEXT)
+ test -x $(prefix)/bin/foo2-p$(EXEEXT)
+ test -f $(prefix)/bin/barx$(EXEEXT)
+ test -x $(prefix)/bin/barx$(EXEEXT)
+ test -f $(prefix)/bin/bary$(EXEEXT)
+ test -x $(prefix)/bin/bary$(EXEEXT)
+END
+
+for f in foo1-p.c foo2-p.c barx.c bary.c; do
+ echo 'int main(void) { return 0; }' > $f
+done
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+cwd=`pwd` || Exit 1
+./configure --prefix="$cwd/_inst"
+$MAKE
+$MAKE install
+$MAKE installcheck
+$MAKE distcheck
+
+:
diff --git a/t/posixsubst-scripts.sh b/t/posixsubst-scripts.sh
new file mode 100755
index 000000000..934b82eb4
--- /dev/null
+++ b/t/posixsubst-scripts.sh
@@ -0,0 +1,99 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Test that POSIX variable expansion '$(var:str=rpl)' works when used
+# with the SCRIPTS primary.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+# We have to be careful with 'test -x' commands on MinGW/MSYS, because
+# the file system does not actually have execute permission information.
+# Instead, that is emulated by looking at the file content, and returning
+# 0 if the file starts with, e.g., a COFF header or with '#!'.
+# So we need to create actual scripts in the make rules and in the file
+# creation below.
+
+cat > Makefile.am << 'END'
+t1 = foo1 foo2
+t2 = bar1x bar2
+t3 = quu-baz
+
+bar1 bar2:
+ (echo '#!/bin/sh' && echo 'exit 0') > $@
+quux.pl:
+ (echo '#!/bin/perl' && echo '1;') > $@
+CLEANFILES = bar1 bar2 quux.pl
+
+# Also try an empty match suffix, to ensure that the ':=' in there is
+# not confused by the parser with an unportable assignment operator.
+dist_sbin_SCRIPTS = $(t1:=.sh)
+libexec_SCRIPTS = $(t2:x=)
+nodist_bin_SCRIPTS = $(t3:-baz=x.pl)
+
+check-local: test1 test2
+.PHONY: test1 test2
+test1:
+ ls -l
+ test -f bar1
+ test -f bar2
+ test -f quux.pl
+test2: distdir
+ ls -l $(distdir)
+## The scripts foo1.sh and foo2.sh should be distributed.
+ test -f $(distdir)/foo1.sh
+ test -f $(distdir)/foo2.sh
+## The scripts bar1, bar2 and quux.pl shouldn't be distributed.
+ test ! -r $(distdir)/bar1
+ test ! -r $(distdir)/bar2
+ test ! -r $(distdir)/quux.pl
+
+installcheck-local:
+ ls -l $(prefix)/libexec $(prefix)/bin $(prefix)/sbin
+ test -f $(prefix)/sbin/foo1.sh
+ test -x $(prefix)/sbin/foo1.sh
+ test -f $(prefix)/sbin/foo2.sh
+ test -x $(prefix)/sbin/foo2.sh
+ test -f $(prefix)/libexec/bar1
+ test -x $(prefix)/libexec/bar1
+ test -f $(prefix)/libexec/bar2
+ test -x $(prefix)/libexec/bar2
+ test -f $(prefix)/bin/quux.pl
+ test -x $(prefix)/bin/quux.pl
+END
+
+cat > foo1.sh <<'END'
+#!/bin/sh
+exit 0
+END
+cp foo1.sh foo2.sh
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+cwd=`pwd` || Exit 1
+./configure --prefix="$cwd/_inst"
+$MAKE
+$MAKE test1 test2
+$MAKE install
+$MAKE installcheck
+$MAKE distcheck
+
+:
diff --git a/t/posixsubst-sources.sh b/t/posixsubst-sources.sh
new file mode 100755
index 000000000..ccd61b9b4
--- /dev/null
+++ b/t/posixsubst-sources.sh
@@ -0,0 +1,81 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Test that POSIX variable expansion '$(var:str=rpl)' works when used
+# with the SOURCES primary.
+
+required=cc
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = foo
+
+FOO = foo.cxx
+BAR = bar__
+BAZ = baz.
+
+# Also try an empty match suffix, to ensure that the ':=' in there is
+# not confused by the parser with an unportable assignment operator.
+foo_SOURCES = main.c $(FOO:.cxx=.c)
+dist_foo_SOURCES = $(BAR:__=.c)
+nodist_foo_SOURCES = $(BAZ:=c)
+
+bar.c baz.c:
+ echo 'int $@ (void) { return 0; }' | sed 's/\.c //' > $@
+CLEANFILES = baz.c
+CLEANFILES += bar.c # For FreeBSD make.
+
+.PHONY: test test2
+check-local: test1 test2
+test1:
+ ls -l . $(srcdir)
+ test -f $(srcdir)/bar.c
+ test -f baz.c
+test2: distdir
+ ls -l $(distdir)
+## These sources should be distributed ...
+ test -f $(distdir)/bar.c
+ test -f $(distdir)/foo.c
+ test -f $(distdir)/main.c
+## ... and this shouldn't.
+ test ! -r $(distdir)/baz.c
+END
+
+cat > main.c <<'END'
+int main(void)
+{
+ int foo(void), bar(void), baz(void);
+ return foo() + bar() + baz();
+}
+END
+
+echo 'int foo(void) { return 0; }' > foo.c
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+$MAKE
+$MAKE test1 test2
+$MAKE distcheck
+
+:
diff --git a/t/posixsubst-tests.sh b/t/posixsubst-tests.sh
new file mode 100755
index 000000000..27a451dbf
--- /dev/null
+++ b/t/posixsubst-tests.sh
@@ -0,0 +1,68 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Test that POSIX variable expansion '$(var:str=rpl)' works when used
+# with the TESTS special variable.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+t1 = foo1 foo2
+t2 = barx
+t3 = bar2
+
+foo2.test barz:
+ (echo '#!/bin/sh' && echo 'exit 0') > $@ && chmod a+x $@
+CLEANFILES = foo2.test barz # For FreeBSD make.
+
+# Also try an empty match suffix, to ensure that the ':=' in there is
+# not confused by the parser with an unportable assignment operator.
+TESTS = $(t1:=.test) $(t2:x=y) $(t3:2=z)
+
+EXTRA_DIST = $(TESTS)
+MOSTLYCLEANFILES = *.out
+END
+
+cat > foo1.test <<'END'
+#!/bin/sh
+touch foo1.out
+test x"${TESTSUITE_OK-no}" = x"yes"
+END
+sed 's/foo1/bary/g' foo1.test > bary
+chmod +x foo1.test bary
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+$MAKE check >out 2>&1 && { cat out; Exit 1; }
+cat out
+ls -l
+grep '^FAIL: foo1\.test *$' out
+grep '^PASS: foo2\.test *$' out
+grep '^FAIL: bary *$' out
+grep '^PASS: barz *$' out
+test -f foo1.out
+test -f bary.out
+
+TESTSUITE_OK=yes $MAKE distcheck
+
+:
diff --git a/t/postproc.sh b/t/postproc.sh
new file mode 100755
index 000000000..7eaa4f871
--- /dev/null
+++ b/t/postproc.sh
@@ -0,0 +1,48 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Check to make sure we recognize a Makefile.in, even if post-processed
+# and renamed.
+
+required=cc
+. ./defs || Exit 1
+
+cat >configure.ac <<END
+AC_INIT([$me], [1.0])
+AM_INIT_AUTOMAKE
+AC_PROG_CC
+AC_CONFIG_FILES([myMakefile])
+AC_OUTPUT
+END
+
+cat > myMakefile.am << 'END'
+bin_PROGRAMS = fred
+fred_SOURCES = fred.c
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -- myMakefile
+
+mv myMakefile.in myMakefile.old
+echo '# Post-processed by post-processor 3.14.' > myMakefile.in
+cat myMakefile.old >> myMakefile.in
+
+./configure
+
+test -f .deps/fred.Po || test -f _deps/fred.Po || Exit 1
+
+:
diff --git a/t/ppf77.sh b/t/ppf77.sh
new file mode 100755
index 000000000..70266d639
--- /dev/null
+++ b/t/ppf77.sh
@@ -0,0 +1,34 @@
+#! /bin/sh
+# Copyright (C) 1999-2012 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/>.
+
+# Test to make sure preprocessed F77 works.
+# Report from Jochen Kuepper.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_F77
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = ppf
+ppf_SOURCES = foo.F q.r
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+:
diff --git a/t/pr2.sh b/t/pr2.sh
new file mode 100755
index 000000000..ffe4a81d7
--- /dev/null
+++ b/t/pr2.sh
@@ -0,0 +1,51 @@
+#! /bin/sh
+# Copyright (C) 1999-2012 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/>.
+
+# Test for bug reported in PR 2.
+# "make dist" fails for AC_OUTPUT(README.foo:templ/README.foo.in).
+#
+# == Report ==
+# When my AC_OUTPUT macro in configure.ac contains something
+# like the following (among the Makefiles)
+# README.foo:templ/README.foo.in
+# the generated dist target in the Makefile.in fails,
+# because DIST_COMMON will contain templ/README.foo.in
+# and the dist target will try to copy templ/README.foo.in
+# to the distribution directory before it creates a templ
+# subdirectory in the distribution directory.
+
+. ./defs || Exit 1
+
+# Please keep this underquoted and old-style.
+cat > configure.ac << 'END'
+AC_INIT
+AM_INIT_AUTOMAKE(nonesuch, nonesuch)
+AC_OUTPUT(README.foo:templ/README.foo.in Makefile)
+END
+
+: > Makefile.am
+
+mkdir templ
+: > templ/README.foo.in
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+$MAKE distdir
+test -f nonesuch-nonesuch/templ/README.foo.in
+
+:
diff --git a/t/pr211.sh b/t/pr211.sh
new file mode 100755
index 000000000..97e28ebc2
--- /dev/null
+++ b/t/pr211.sh
@@ -0,0 +1,51 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test for PR 211.
+#
+# == Description ==
+# Suppose you have a library and an ltlibrary in the same
+# directory which use the same source:
+#
+# libfoo_la_SOURCES = foo.c
+# libbar_a_SOURCES = foo.c
+#
+# In this case foo.c will be compiled twice but using different
+# compilers. This is a conflict. In this case the user should
+# rename one of the 'foo.o' files.
+
+required=libtoolize
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_PROG_LIBTOOL
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = helldl
+lib_LTLIBRARIES = libfoo.la
+helldl_SOURCES = foo.c
+libfoo_la_SOURCES = foo.c
+END
+
+libtoolize
+$ACLOCAL
+AUTOMAKE_fails -Wnone -a
+$FGREP 'foo.$(OBJEXT)' stderr
+
+:
diff --git a/t/pr220.sh b/t/pr220.sh
new file mode 100755
index 000000000..657221d2f
--- /dev/null
+++ b/t/pr220.sh
@@ -0,0 +1,58 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test for PR automake/220.
+# Test for problems when conditionals are not actually defined.
+# Check that the problems is diagnosed by configure.
+# This isn't perfect (ideally we'd like an error from autoconf),
+# but it is the best we can do. It certainly makes it easier
+# to debug the problem.
+# Note that this should be also in the documentation.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'EOF'
+if NEVER_TRUE
+NEVER_DEFINED = foo.txt
+endif
+data_DATA = $(NEVER_DEFINED)
+EOF
+
+cat >> configure.ac << 'EOF'
+AC_ARG_ENABLE([foo],
+[ --enable-foo Enable foo],
+[ if test "foo" = "bar" ; then
+ AM_CONDITIONAL([NEVER_TRUE], [true])
+ else
+ AM_CONDITIONAL([NEVER_TRUE], [false])
+ fi
+])
+AC_OUTPUT
+EOF
+
+mkdir build
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+cd build
+# configure should fail since we've done something invalid.
+../configure 2>stderr && { cat stderr >&2; Exit 1; }
+cat stderr >&2
+grep 'conditional.*NEVER_TRUE' stderr
+
+:
diff --git a/t/pr224.sh b/t/pr224.sh
new file mode 100755
index 000000000..51e3c1723
--- /dev/null
+++ b/t/pr224.sh
@@ -0,0 +1,64 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Test for PR automake/224: $(top_srcdir) w.r.t. dependencies.
+#
+# == Description ==
+# Dependency tracking data should be stored in in the relative path
+# of the source file, as opposed the object file.
+# I.e., for 'foo.c' in '$(top_srcdir)/bar', being built in
+# '$(top_srcdir)/build', the location of the '.deps' directory
+# should be '$(top_builddir)/bar/.deps'.
+
+required=cc
+. ./defs || Exit 1
+
+mkdir foo
+
+cat >foo/main.c <<'EOF'
+int main (void)
+{
+ return 0;
+}
+EOF
+
+cat >Makefile.am <<'EOF'
+AUTOMAKE_OPTIONS = subdir-objects
+bin_PROGRAMS = bar
+bar_SOURCES = foo/main.c
+EOF
+
+cat >>configure.ac <<'EOF'
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_OUTPUT
+EOF
+
+mkdir build
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+cd build
+../configure
+
+$MAKE
+test -d foo/.deps
+$MAKE distclean
+test -d foo/.deps && Exit 1
+
+:
diff --git a/t/pr229.sh b/t/pr229.sh
new file mode 100755
index 000000000..cacdb824a
--- /dev/null
+++ b/t/pr229.sh
@@ -0,0 +1,35 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Test for PR automake/229.
+# Make sure AC_CYGWIN requires config.{sub,guess}.
+# Reported by James Youngman.
+
+. ./defs || Exit 1
+
+cat >> configure.ac <<EOF
+AC_CYGWIN
+EOF
+
+: > Makefile.am
+
+$ACLOCAL
+$AUTOMAKE -a
+
+test -f config.sub
+test -f config.guess
+
+:
diff --git a/t/pr243.sh b/t/pr243.sh
new file mode 100755
index 000000000..01ba6447f
--- /dev/null
+++ b/t/pr243.sh
@@ -0,0 +1,57 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test for PR 243.
+# AM_OUTPUT_DEPENDENCY_COMMANDS doesn't handle
+# 'Makefile:Makefile.in:tail.mk' in AC_OUTPUT.
+#
+# == Report ==
+# If configure.ac has something like:
+# AC_OUTPUT(Makefile:Makefile.in:tail.mk)
+# then config.status cannot parse the Makefile to build the
+# dependency files in the .deps directory. This is because
+# the AM_OUTPUT_DEPENDENCY_COMMANDS macro cannot cope with
+# the colon in the CONFIG_FILES variable.
+
+required=cc
+. ./defs || Exit 1
+
+cat > configure.ac << END
+AC_INIT([$me], [1.0])
+AM_INIT_AUTOMAKE
+AC_PROG_CC
+AC_CONFIG_FILES([Makefile:Makefile.in:tail.mk])
+AC_OUTPUT
+END
+
+: > tail.mk
+
+cat > Makefile.am << 'END'
+include_HEADERS = 3dfx.h linutil.h
+noinst_HEADERS = fx64.h fxdll.h fximg.h fxglob.h \
+ fxos.h fxver.h glob.h
+noinst_PROGRAMS = fxmisc
+fxmisc_SOURCES = fx64.c fximg.c fxos.c linutil.c
+END
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+./configure
+
+test -f .deps/fx64.Po
+
+:
diff --git a/t/pr266.sh b/t/pr266.sh
new file mode 100755
index 000000000..ac5687894
--- /dev/null
+++ b/t/pr266.sh
@@ -0,0 +1,46 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test for PR 266.
+# Dependency tracking -vs- nonstandard Makefile names
+
+required=cc
+. ./defs || Exit 1
+
+cat > configure.ac << END
+AC_INIT([$me], [1.0])
+AM_INIT_AUTOMAKE
+AC_PROG_CC
+AC_CONFIG_FILES([Maudefile])
+AC_OUTPUT
+END
+
+cat > Maudefile.am << 'END'
+include_HEADERS = 3dfx.h linutil.h
+noinst_HEADERS = fx64.h fxdll.h fximg.h fxglob.h \
+ fxos.h fxver.h glob.h
+noinst_PROGRAMS = fxmisc
+fxmisc_SOURCES = fx64.c fximg.c fxos.c linutil.c
+END
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+./configure --enable-dependency-tracking
+
+test -f .deps/fx64.Po
+
+:
diff --git a/t/pr279-2.sh b/t/pr279-2.sh
new file mode 100755
index 000000000..5618d7625
--- /dev/null
+++ b/t/pr279-2.sh
@@ -0,0 +1,51 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Another test related to PR 279.
+# Multiple DEPENDENCIES on conditionals.
+# Please keep this in sync with sister test pr279.test.
+#
+# == Report ==
+# When defining xxx_LDADD and xxx_DEPENDENCIES variables where the
+# xxx_LDADD one contains values set in conditionals, automake will
+# fail with messages like:
+# foo_DEPENDENCIES was already defined in condition TRUE, ...
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_CONDITIONAL([FOOTEST], [false])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+if FOOTEST
+foo_LDADD = zardoz
+else
+foo_LDADD = maude
+endif
+
+bin_PROGRAMS = foo
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+grep '^@FOOTEST_TRUE@foo_DEPENDENCIES *= *zardoz$' Makefile.in
+grep '^@FOOTEST_FALSE@foo_DEPENDENCIES *= *maude$' Makefile.in
+
+:
diff --git a/t/pr279.sh b/t/pr279.sh
new file mode 100755
index 000000000..338313184
--- /dev/null
+++ b/t/pr279.sh
@@ -0,0 +1,50 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test for PR 279.
+# Multiple DEPENDENCIES on conditionals.
+# Please keep this in sync with sister test pr279-2.test.
+#
+# == Report ==
+# When defining xxx_LDADD and xxx_DEPENDENCIES variables where the
+# xxx_LDADD one contains values set in conditionals, automake will
+# fail with messages like:
+# foo_DEPENDENCIES was already defined in condition TRUE, ...
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_CONDITIONAL([FOOTEST], [false])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+if FOOTEST
+xtralib =
+else
+xtralib =
+endif
+
+bin_PROGRAMS = foo
+foo_LDADD = ${xtralib}
+foo_DEPENDENCIES =
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+:
diff --git a/t/pr287.sh b/t/pr287.sh
new file mode 100755
index 000000000..681f6d61b
--- /dev/null
+++ b/t/pr287.sh
@@ -0,0 +1,48 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Test for PR 287: empty SUBDIRS.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+SUBDIRS =
+bin_SCRIPTS = foo
+END
+
+cat > foo << 'END'
+#! /bin/sh
+echo Maude
+END
+
+chmod +x foo
+
+mkdir install
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure "--prefix=`cd install && pwd`"
+
+$MAKE
+$MAKE distdir
+
+:
diff --git a/t/pr300-lib.sh b/t/pr300-lib.sh
new file mode 100755
index 000000000..b655cf013
--- /dev/null
+++ b/t/pr300-lib.sh
@@ -0,0 +1,76 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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 that installing subdirectory libraries works.
+# PR/300
+
+required=cc
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_RANLIB
+AC_PROG_CC
+AM_PROG_AR
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+lib_LIBRARIES = subdir/liba.a
+subdir_liba_a_SOURCES = a.c
+
+nobase_lib_LIBRARIES = subdir/libb.a
+subdir_libb_a_SOURCES = a.c
+END
+
+cat > a.c << 'END'
+int i = 3;
+END
+
+## A rule in the Makefile should create subdir
+# mkdir subdir
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --copy --add-missing
+
+# We pass '--libdir' explicitly, to avoid spurious failures due to users
+# or distributions possibly overriding '${libdir}' in their $CONFIG_SITE
+# file (for example, defining it to '${prefix}/lib64' on 64-bit systems,
+# as is the case with openSUSE 12.1). See automake bug#10426.
+cwd=`pwd` || Exit 99
+./configure --prefix "$cwd/inst" --libdir "$cwd/inst/lib"
+
+$MAKE
+
+test -f subdir/liba.a
+test -f subdir/libb.a
+
+$MAKE install
+
+test -f inst/lib/liba.a
+test -f inst/lib/subdir/libb.a
+
+$MAKE uninstall
+
+test -f inst/lib/liba.a && Exit 1
+test -f inst/lib/subdir/libb.a && Exit 1
+
+$MAKE install-strip
+
+test -f inst/lib/liba.a
+test -f inst/lib/subdir/libb.a
+
+:
diff --git a/t/pr300-ltlib.sh b/t/pr300-ltlib.sh
new file mode 100755
index 000000000..8db6b0792
--- /dev/null
+++ b/t/pr300-ltlib.sh
@@ -0,0 +1,84 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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 that installing subdirectory libtool libraries works.
+# PR/300
+
+required='cc libtoolize'
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_LIBTOOL
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+lib_LTLIBRARIES = subdir/liba.la
+subdir_liba_la_SOURCES = a.c
+
+nobase_lib_LTLIBRARIES = subdir/libb.la
+subdir_libb_la_SOURCES = a.c
+END
+
+cat > a.c << 'END'
+int i = 3;
+END
+
+libtoolize
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --copy --add-missing
+
+# We pass '--libdir' explicitly, to avoid spurious failures due to users
+# or distributions possibly overriding '${libdir}' in their $CONFIG_SITE
+# file (for example, defining it to '${prefix}/lib64' on 64-bit systems,
+# as is the case with openSUSE 12.1). See automake bug#10426.
+cwd=`pwd` || Exit 99
+./configure --prefix "$cwd/inst" --libdir "$cwd/inst/lib"
+
+# A rule in the Makefile should create subdir.
+test ! -d subdir
+$MAKE >stdout || { cat stdout; Exit 1; }
+cat stdout
+test -d subdir
+
+grep 'liba.la .*-rpath .*lib' stdout
+grep 'liba.la .*-rpath .*lib/subdir' stdout && Exit 1
+grep 'libb.la .*-rpath .*lib/subdir' stdout
+
+test -f subdir/liba.la
+test -f subdir/libb.la
+
+$MAKE install 2>stderr || { cat stderr >&2; Exit 1; }
+cat stderr >&2
+grep 'remember.*--finish' stderr && Exit 1
+
+test -f inst/lib/liba.la
+test -f inst/lib/subdir/libb.la
+
+$MAKE uninstall
+
+test -f inst/lib/liba.la && Exit 1
+test -f inst/lib/subdir/libb.la && Exit 1
+
+$MAKE install-strip
+
+test -f inst/lib/liba.la
+test -f inst/lib/subdir/libb.la
+
+:
diff --git a/t/pr300-prog.sh b/t/pr300-prog.sh
new file mode 100755
index 000000000..6812231bd
--- /dev/null
+++ b/t/pr300-prog.sh
@@ -0,0 +1,72 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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 that installing subdirectory programs works.
+# PR/300
+
+required=cc
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = subdir/wish
+subdir_wish_SOURCES = a.c
+
+nobase_bin_PROGRAMS = subdir/want
+subdir_want_SOURCES = a.c
+
+test-all: all
+ test -f subdir/wish$(EXEEXT)
+ test -f subdir/want$(EXEEXT)
+test-install: install
+ test -f inst/bin/wish$(EXEEXT)
+ test -f inst/bin/subdir/want$(EXEEXT)
+test-uninstall: uninstall
+ test ! -f inst/bin/wish$(EXEEXT)
+ test ! -f inst/bin/subdir/want$(EXEEXT)
+test-install-strip: install-strip
+ test -f inst/bin/wish$(EXEEXT)
+ test -f inst/bin/subdir/want$(EXEEXT)
+END
+
+cat > a.c << 'END'
+#include <stdio.h>
+int main ()
+{
+ printf ("hi liver!\n");
+ return 0;
+}
+END
+
+## A rule in the Makefile should create subdir
+# mkdir subdir
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --copy --add-missing
+
+./configure --prefix "`pwd`/inst"
+
+$MAKE test-all
+$MAKE test-install
+$MAKE test-uninstall
+$MAKE test-install-strip
+
+:
diff --git a/t/pr307.sh b/t/pr307.sh
new file mode 100755
index 000000000..abcff807d
--- /dev/null
+++ b/t/pr307.sh
@@ -0,0 +1,93 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Test for PR 307: depcomp with depmode=dashmstdout libtool race condition
+# Report from Laurent Morichetti.
+# (Also exercises check_LTLIBRARIES.)
+#
+# == Report ==
+# The dashmstdout depmode calls libtool in parallel to generate the
+# dependencies (with -M flag) and to build the objfile (both have
+# --mode=compile and -o).
+# The process with 'libtool --mode=compile .* -M' can corrupt the objfile
+# as none is generated by the compiler. Since --mode=compile and -o are
+# set libtool assumes that a objfile should be generated and will execute
+# invalid $mv & $LN_S.
+#
+# == Fix ==
+# Now 'depcomp' never compute dependencies in the background, as this can
+# cause races with libtool. Compute the dependencies after the actual
+# compilation.
+
+required='libtoolize gcc'
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_LIBTOOL
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+check_LTLIBRARIES = librace.la
+librace_la_SOURCES = a.c b.c c.c d.c e.c f.c g.c h.c
+
+# Make sure the dependencies are updated.
+check-local:
+ for i in $(librace_la_SOURCES:.c=.Plo); do \
+ echo "checking ./$(DEPDIR)/$$i"; \
+ grep 'foo\.h' ./$(DEPDIR)/$$i >tst || exit 1; \
+ test `wc -l <tst` -eq 2 || exit 1; \
+ done
+END
+
+: >foo.h
+
+for i in a b c d e f g h; do
+ unindent >$i.c <<EOF
+ #include "foo.h"
+ int $i () { return 0; }
+EOF
+done
+
+libtoolize --force
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+# Sanity check: make sure the variable we are attempting to force
+# is indeed used by configure.
+grep am_cv_CC_dependencies_compiler_type configure
+
+./configure am_cv_CC_dependencies_compiler_type=dashmstdout
+
+$MAKE
+test -f librace.la && Exit 1
+$MAKE check
+
+# The failure we check usually occurs during the above build,
+# with an output such as:
+#
+# mv -f .libs/f.lo f.lo
+# mv: cannot stat '.libs/f.lo': No such file or directory
+#
+# (This may happen on 'f' or on some other files.)
+
+test -f librace.la
+test -f tst # A proof that check-local was run.
+
+:
diff --git a/t/pr401.sh b/t/pr401.sh
new file mode 100755
index 000000000..a14349849
--- /dev/null
+++ b/t/pr401.sh
@@ -0,0 +1,189 @@
+#! /bin/sh
+# Copyright (C) 2005-2012 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/>.
+
+# Check support for AC_CONFIG_LIBOBJ_DIR vs LIBOBJS.
+# (pr401b.test and pr401c.test do the same for LTLIBOBJS and ALLOCA)
+
+am_parallel_tests=no
+required=cc
+. ./defs || Exit 1
+
+mkdir lib src
+
+cat >lib/feep.c <<'EOF'
+const char *feep (void)
+{
+ return "feep";
+}
+EOF
+
+cat >src/main.c <<'EOF'
+#include <stdio.h>
+
+extern const char *feep (void);
+
+int main (void)
+{
+ puts (feep ());
+ return 0;
+}
+EOF
+
+cat >>configure.ac << 'EOF'
+## These lines are activated for later tests
+#: AC_CONFIG_LIBOBJ_DIR([lib])
+AC_PROG_CC
+#x AM_PROG_CC_C_O
+AC_LIBOBJ([feep])
+AC_LIBSOURCE([feep.c])
+AM_PROG_AR
+AC_PROG_RANLIB
+AC_CONFIG_FILES([lib/Makefile src/Makefile])
+AM_CONDITIONAL([CROSS_COMPILING], [test $cross_compiling = yes])
+AC_OUTPUT
+EOF
+
+## ------------------------------------------ ##
+## First a test of traditional LIBOBJS usage. ##
+## ------------------------------------------ ##
+
+cat >Makefile.am <<'EOF'
+SUBDIRS = lib src
+EOF
+
+cat >lib/Makefile.am <<'EOF'
+noinst_LIBRARIES = libfeep.a
+libfeep_a_SOURCES =
+libfeep_a_LIBADD = $(LIBOBJS)
+EOF
+
+cat >src/Makefile.am <<'EOF'
+check_PROGRAMS = main
+main_LDADD = ../lib/libfeep.a
+
+if !CROSS_COMPILING
+TESTS = main
+endif
+EOF
+
+cp "$am_scriptdir/ar-lib" . || fatal_ "fetching auxiliary script 'ar-lib'"
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+$MAKE distcheck
+
+## ------------------------------------------ ##
+## Traditional LIBOBJS with LIBOBJDIR set. ##
+## ------------------------------------------ ##
+
+# Invocation of AC_CONFIG_LIBOBJ_DIR may be necessary for reasons
+# unrelated to Automake or Makefile.am layout.
+
+sed 's/#: //' configure.ac >configure.int
+mv -f configure.int configure.ac
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+test ! -d lib/lib
+$MAKE distcheck
+
+## -------------------------------------------- ##
+## Error message with usage in wrong directory. ##
+## -------------------------------------------- ##
+
+mv -f src/Makefile.am src/t
+sed 's/LDADD = .*/LDADD = @LIBOBJS@/' src/t > src/Makefile.am
+AUTOMAKE_fails
+grep 'cannot be used outside.*lib' stderr
+mv -f src/t src/Makefile.am
+
+
+## -------------------------------------------- ##
+## Test using LIBOBJS from a sibling directory. ##
+## -------------------------------------------- ##
+
+sed 's/#x //; s/lib\/Makefile //' configure.ac >configure.int
+mv -f configure.int configure.ac
+
+cat >Makefile.am <<'EOF'
+SUBDIRS = src
+EOF
+
+cat > src/Makefile.am <<'EOF'
+AUTOMAKE_OPTIONS = subdir-objects
+
+noinst_LIBRARIES = libfeep.a
+libfeep_a_SOURCES =
+libfeep_a_LIBADD = $(LIBOBJS)
+
+check_PROGRAMS = main
+main_LDADD = libfeep.a
+
+if !CROSS_COMPILING
+TESTS = main
+endif
+EOF
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+./configure
+test ! -d src/lib
+test ! -d 'src/$(top_builddir)'
+$MAKE
+$MAKE check
+$MAKE distclean
+
+
+## ----------------------------------------- ##
+## Test using LIBOBJS from parent directory. ##
+## ----------------------------------------- ##
+
+sed 's/^.*src\/Makefile.*$//' configure.ac >configure.int
+mv -f configure.int configure.ac
+
+cat >Makefile.am <<'EOF'
+AUTOMAKE_OPTIONS = subdir-objects
+
+noinst_LIBRARIES = lib/libfeep.a
+lib_libfeep_a_SOURCES =
+lib_libfeep_a_LIBADD = $(LIBOBJS)
+
+check_PROGRAMS = src/main
+src_main_SOURCES = src/main.c
+src_main_LDADD = lib/libfeep.a
+
+if !CROSS_COMPILING
+TESTS = src/main
+endif
+
+check-local:
+ test -f src/main.$(OBJEXT)
+ test -f lib/feep.$(OBJEXT)
+ test ! -f src/$(DEPDIR)/feep.Po
+EOF
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+$MAKE distcheck
+
+:
diff --git a/t/pr401b.sh b/t/pr401b.sh
new file mode 100755
index 000000000..3d15671c2
--- /dev/null
+++ b/t/pr401b.sh
@@ -0,0 +1,189 @@
+#! /bin/sh
+# Copyright (C) 2005-2012 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/>.
+
+# Check support for AC_CONFIG_LIBOBJ_DIR vs LTLIBOBJS.
+# (pr401.test and pr401c.test do the same for LIBOBJS and ALLOCA)
+
+am_parallel_tests=no
+required='cc libtoolize'
+. ./defs || Exit 1
+
+mkdir lib src
+
+cat >lib/feep.c <<'EOF'
+const char *feep (void)
+{
+ return "feep";
+}
+EOF
+
+cat >src/main.c <<'EOF'
+#include <stdio.h>
+
+extern const char *feep (void);
+
+int main (void)
+{
+ puts (feep ());
+ return 0;
+}
+EOF
+
+cat >>configure.ac << 'EOF'
+## These lines are activated for later tests
+#: AC_CONFIG_LIBOBJ_DIR([lib])
+AC_PROG_CC
+#x AM_PROG_CC_C_O
+AC_LIBOBJ([feep])
+AC_LIBSOURCE([feep.c])
+AM_PROG_AR
+AC_PROG_LIBTOOL
+AC_CONFIG_FILES([lib/Makefile src/Makefile])
+AM_CONDITIONAL([CROSS_COMPILING], [test $cross_compiling = yes])
+AC_OUTPUT
+EOF
+
+## -------------------------------------------- ##
+## First a test of traditional LTLIBOBJS usage. ##
+## -------------------------------------------- ##
+
+cat >Makefile.am <<'EOF'
+SUBDIRS = lib src
+EOF
+
+cat >lib/Makefile.am <<'EOF'
+noinst_LTLIBRARIES = libfeep.la
+libfeep_la_SOURCES =
+libfeep_la_LIBADD = $(LTLIBOBJS)
+EOF
+
+cat >src/Makefile.am <<'EOF'
+check_PROGRAMS = main
+main_LDADD = ../lib/libfeep.la
+
+if !CROSS_COMPILING
+TESTS = main
+endif
+EOF
+
+cp "$am_scriptdir/ar-lib" . || fatal_ "fetching auxiliary script 'ar-lib'"
+
+libtoolize
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+./configure
+$MAKE distcheck
+
+## ----------------------------------------- ##
+## Traditional LTLIBOBJS with LIBOBJDIR set. ##
+## ----------------------------------------- ##
+
+# Invocation of AC_CONFIG_LIBOBJ_DIR may be necessary for reasons
+# unrelated to Automake or Makefile.am layout.
+
+sed 's/#: //' configure.ac >configure.int
+mv -f configure.int configure.ac
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+./configure
+test ! -d lib/lib
+$MAKE distcheck
+
+## -------------------------------------------- ##
+## Error message with usage in wrong directory. ##
+## -------------------------------------------- ##
+
+mv -f src/Makefile.am src/t
+sed 's/LDADD = .*/LDADD = @LTLIBOBJS@/' src/t > src/Makefile.am
+AUTOMAKE_fails
+grep 'cannot be used outside.*lib' stderr
+mv -f src/t src/Makefile.am
+
+## ---------------------------------------------- ##
+## Test using LTLIBOBJS from a sibling directory. ##
+## ---------------------------------------------- ##
+
+sed 's/#x //; s/lib\/Makefile //' configure.ac >configure.int
+mv -f configure.int configure.ac
+
+cat >Makefile.am <<'EOF'
+SUBDIRS = src
+EOF
+
+cat > src/Makefile.am <<'EOF'
+AUTOMAKE_OPTIONS = subdir-objects
+
+noinst_LTLIBRARIES = libfeep.la
+libfeep_la_SOURCES =
+libfeep_la_LIBADD = $(LTLIBOBJS)
+
+check_PROGRAMS = main
+main_LDADD = libfeep.la
+
+if !CROSS_COMPILING
+TESTS = main
+endif
+EOF
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+./configure
+test ! -d src/lib
+test ! -d 'src/$(top_builddir)'
+$MAKE
+$MAKE check
+$MAKE distclean
+
+
+## ------------------------------------------- ##
+## Test using LTLIBOBJS from parent directory. ##
+## ------------------------------------------- ##
+
+sed 's/^.*src\/Makefile.*$//' configure.ac >configure.int
+mv -f configure.int configure.ac
+
+cat >Makefile.am <<'EOF'
+AUTOMAKE_OPTIONS = subdir-objects
+
+noinst_LTLIBRARIES = lib/libfeep.la
+lib_libfeep_la_SOURCES =
+lib_libfeep_la_LIBADD = $(LTLIBOBJS)
+
+check_PROGRAMS = src/main
+src_main_SOURCES = src/main.c
+src_main_LDADD = lib/libfeep.la
+
+if !CROSS_COMPILING
+TESTS = src/main
+endif
+
+check-local:
+ test -f src/main.$(OBJEXT)
+ test -f lib/feep.lo
+ test ! -f src/$(DEPDIR)/feep.Po
+EOF
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+$MAKE distcheck
+
+:
diff --git a/t/pr401c.sh b/t/pr401c.sh
new file mode 100755
index 000000000..1f238f615
--- /dev/null
+++ b/t/pr401c.sh
@@ -0,0 +1,192 @@
+#! /bin/sh
+# Copyright (C) 2005-2012 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/>.
+
+# Check support for AC_CONFIG_LIBOBJ_DIR vs ALLOCA.
+# (pr401.test and pr401b.test do the same for LIBOBJS and LTLIBOBJS)
+
+am_parallel_tests=no
+required=cc
+. ./defs || Exit 1
+
+mkdir lib src
+
+ac_cv_func_alloca_works=no
+export ac_cv_func_alloca_works
+
+cat >lib/alloca.c <<'EOF'
+const char *feep (void)
+{
+ return "feep";
+}
+EOF
+
+cat >src/main.c <<'EOF'
+#include <stdio.h>
+
+extern const char *feep (void);
+
+int main (void)
+{
+ puts (feep ());
+ return 0;
+}
+EOF
+
+cat >>configure.ac << 'EOF'
+## These lines are activated for later tests.
+#: AC_CONFIG_LIBOBJ_DIR([lib])
+AC_PROG_CC
+#x AM_PROG_CC_C_O
+AM_PROG_AR
+AC_PROG_RANLIB
+AC_FUNC_ALLOCA
+AC_CONFIG_FILES([lib/Makefile src/Makefile])
+AM_CONDITIONAL([CROSS_COMPILING], [test $cross_compiling = yes])
+AC_OUTPUT
+EOF
+
+## ----------------------------------------- ##
+## First a test of traditional ALLOCA usage. ##
+## ----------------------------------------- ##
+
+cat >Makefile.am <<'EOF'
+SUBDIRS = lib src
+EOF
+
+cat >lib/Makefile.am <<'EOF'
+noinst_LIBRARIES = libfeep.a
+libfeep_a_SOURCES =
+libfeep_a_LIBADD = $(ALLOCA)
+EOF
+
+cat >src/Makefile.am <<'EOF'
+check_PROGRAMS = main
+main_LDADD = ../lib/libfeep.a
+
+if !CROSS_COMPILING
+TESTS = main
+endif
+EOF
+
+cp "$am_scriptdir/ar-lib" . || fatal_ "fetching auxiliary script 'ar-lib'"
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+$MAKE distcheck
+
+
+## --------------------------------------- ##
+## Traditional ALLOCA with LIBOBJDIR set. ##
+## --------------------------------------- ##
+
+# Invocation of AC_CONFIG_LIBOBJ_DIR may be necessary for reasons
+# unrelated to Automake or Makefile.am layout.
+
+sed 's/#: //' configure.ac >configure.int
+mv -f configure.int configure.ac
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+test ! -d lib/lib
+$MAKE distcheck
+
+## -------------------------------------------- ##
+## Error message with usage in wrong directory. ##
+## -------------------------------------------- ##
+
+mv -f src/Makefile.am src/t
+sed 's/LDADD = .*/LDADD = @ALLOCA@/' src/t > src/Makefile.am
+AUTOMAKE_fails
+grep 'cannot be used outside.*lib' stderr
+mv -f src/t src/Makefile.am
+
+
+## ------------------------------------------- ##
+## Test using ALLOCA from a sibling directory. ##
+## ------------------------------------------- ##
+
+sed 's/#x //; s/lib\/Makefile //' configure.ac >configure.int
+mv -f configure.int configure.ac
+
+cat >Makefile.am <<'EOF'
+SUBDIRS = src
+EOF
+
+cat > src/Makefile.am <<'EOF'
+AUTOMAKE_OPTIONS = subdir-objects
+
+noinst_LIBRARIES = libfeep.a
+libfeep_a_SOURCES =
+libfeep_a_LIBADD = $(ALLOCA) $(LIBOBJS) # Add LIBOBJS for fun.
+
+check_PROGRAMS = main
+main_LDADD = libfeep.a
+
+if !CROSS_COMPILING
+TESTS = main
+endif
+EOF
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+./configure
+$MAKE
+test ! -d src/lib
+test ! -d 'src/$(top_builddir)'
+$MAKE check
+$MAKE distclean
+
+
+## ---------------------------------------- ##
+## Test using ALLOCA from parent directory. ##
+## ---------------------------------------- ##
+
+sed 's/^.*src\/Makefile.*$//' configure.ac >configure.int
+mv -f configure.int configure.ac
+
+cat >Makefile.am <<'EOF'
+AUTOMAKE_OPTIONS = subdir-objects
+
+noinst_LIBRARIES = lib/libfeep.a
+lib_libfeep_a_SOURCES =
+lib_libfeep_a_LIBADD = $(ALLOCA)
+
+check_PROGRAMS = src/main
+src_main_SOURCES = src/main.c
+src_main_LDADD = lib/libfeep.a
+
+if !CROSS_COMPILING
+TESTS = src/main
+endif
+
+check-local:
+ test -f src/main.$(OBJEXT)
+ test -f lib/alloca.$(OBJEXT)
+ test ! -f src/$(DEPDIR)/alloca.Po
+EOF
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+$MAKE distcheck
+
+:
diff --git a/t/pr72.sh b/t/pr72.sh
new file mode 100755
index 000000000..b16e8792f
--- /dev/null
+++ b/t/pr72.sh
@@ -0,0 +1,44 @@
+#! /bin/sh
+# Copyright (C) 2000-2012 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/>.
+
+# Test for PR 72
+# Empty _SOURCES results in $(LINK) undefined.
+
+required=libtool
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_PROG_LIBTOOL
+END
+
+cat > Makefile.am << 'END'
+lib_LTLIBRARIES = libviewer.la
+libviewer_la_SOURCES =
+libviewer_la_LIBADD = libphony.la
+END
+
+: > ltconfig
+: > ltmain.sh
+: > config.guess
+: > config.sub
+
+$ACLOCAL
+$AUTOMAKE -Wno-extra-portability
+
+grep '^LINK =' Makefile.in
+
+:
diff --git a/t/pr8365-remake-timing.sh b/t/pr8365-remake-timing.sh
new file mode 100755
index 000000000..2feaf6df2
--- /dev/null
+++ b/t/pr8365-remake-timing.sh
@@ -0,0 +1,107 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Test for automake bug#8365, related to Makefile remake rules.
+# The bug is due to subtle timestamp issues and limitations in
+# make's behaviour, and is very unlikely to be triggered (we have
+# to resort to timestamp edit hacks to consistently expose it); in
+# any account, it is nigh to impossible to trigger it by running
+# make by hand. Thus, fixing it would not be worth the hassle, but
+# we prefer to keep it exposed anyway.
+
+. ./defs || Exit 1
+
+# We'll use calls to stat to get debugging information.
+if stat /dev/null; then stat=stat; else stat=:; fi
+
+cat >> configure.ac << 'END'
+FOOBAR=zardoz
+AC_OUTPUT
+END
+
+: > Makefile.am
+
+$ACLOCAL
+# Run automake *before* autoconf, because we want to ensure that
+# Makefile.in is not newer than configure.
+$AUTOMAKE
+$AUTOCONF
+
+./configure
+$MAKE Makefile
+# Sanity check.
+$EGREP 'FOOBAR|zardoz' Makefile && fatal_ 'unexpected AC_SUBST in Makefile'
+
+echo 'AC_SUBST([FOOBAR])' >> configure.ac
+
+# Modified configure dependencies must have the same timestamp of
+# config.status and Makefile in order to trigger the bug.
+# We also re-touch config.status, because "touch -r" can truncate
+# timestamps on file systems with sub-second resolutions (see the
+# autoconf manual). Finally, we also sleep before touching, to ensure
+# that the (possibly truncated) timestamps of config.status etc. are
+# strictly newer than the non-truncated configure timestamp.
+$stat config.status Makefile configure.ac
+$sleep
+touch config.status
+touch -r config.status config.status Makefile configure.ac
+$stat config.status Makefile configure.ac
+
+# Also, the race condition is triggered only when aclocal, automake
+# and aclocal run fast enough to keep the timestamp of the generated
+# aclocal.m4, Makefile.in and configure equal to the timestamp of
+# Makefile & config.status. To reproduce this race consistently, we
+# need the following hackish wrappers.
+
+cat > aclocal-wrap <<END
+#!/bin/sh
+set -ex
+# aclocal shouldn't use our autoconf wrapper when extracting
+# the races from configure.ac.
+AUTOCONF='$AUTOCONF'; export AUTOCONF
+$ACLOCAL "\$@"
+touch -r config.status aclocal.m4
+$stat aclocal.m4
+END
+
+cat > automake-wrap <<END
+#!/bin/sh
+set -ex
+# automake shouldn't use our autoconf wrapper when extracting
+# the races from configure.ac.
+AUTOCONF='$AUTOCONF'; export AUTOCONF
+$AUTOMAKE "\$@"
+touch -r config.status Makefile.in
+$stat Makefile.in
+END
+
+cat > autoconf-wrap <<END
+#!/bin/sh
+set -ex
+$AUTOCONF "\$@"
+touch -r config.status configure
+$stat configure
+END
+
+chmod a+x aclocal-wrap automake-wrap autoconf-wrap
+
+env \
+ ACLOCAL=./aclocal-wrap AUTOMAKE=./automake-wrap AUTOCONF=./autoconf-wrap \
+ $MAKE -e Makefile
+grep '^FOOBAR =' Makefile.in
+grep '^FOOBAR *= *zardoz *$' Makefile
+
+:
diff --git a/t/pr87.sh b/t/pr87.sh
new file mode 100755
index 000000000..d98b66152
--- /dev/null
+++ b/t/pr87.sh
@@ -0,0 +1,71 @@
+#! /bin/sh
+# Copyright (C) 2000-2012 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/>.
+
+# Test for PR automake/87.
+# "make distcheck" fails when two source dirs exist.
+
+required=cc
+. ./defs || Exit 1
+
+subdirs="foo bar"
+
+for i in $subdirs; do
+ mkdir $i
+ unindent >$i/$i.c <<EOF
+ int main (void)
+ {
+ return 0;
+ }
+EOF
+ unindent >$i/Makefile.am <<EOF
+ bin_PROGRAMS = $i
+ ${i}_SOURCES = $i.c
+EOF
+done
+
+echo "SUBDIRS = $subdirs" > Makefile.am
+cat >configure.ac <<EOF
+AC_INIT(`echo $subdirs | sed 's|\([a-z][a-z]*\).*|\1/\1.c|'`)
+AC_CONFIG_AUX_DIR(.)
+AM_INIT_AUTOMAKE($me, 1.0)
+AC_PROG_CC
+AC_OUTPUT(Makefile `echo $subdirs | sed 's|\([a-z][a-z]*\)|\1/Makefile|g'`)
+EOF
+
+mkdir build
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+# Regression test for bug where '.c.o:' is followed by blank line.
+(while read line; do
+ if test "$line" = ".c.o:"; then
+ read next
+ if test -z "$next"; then
+ Exit 1
+ else
+ : # For shells with broken 'set -e'.
+ fi
+ break
+ fi
+ done) < foo/Makefile.in || Exit 1
+
+cd build
+../configure
+$MAKE distcheck
+
+:
diff --git a/t/pr9.sh b/t/pr9.sh
new file mode 100755
index 000000000..36a9f7e95
--- /dev/null
+++ b/t/pr9.sh
@@ -0,0 +1,58 @@
+#! /bin/sh
+# Copyright (C) 1999-2012 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/>.
+
+# Test for bug in PR 9.
+# "make dist" incorrect when AC_CONFIG_AUX_DIR is present.
+#
+# == Report ==
+# When AC_CONFIG_AUX_DIR is set (in my case to 'support'), make dist
+# no longer automatically includes config.guess, config.sub, install-sh,
+# ltconfig, ltmain.sh, mdate-sh, missing, and mkinstalldirs. In fact,
+# the entire 'support/' directory is omitted.
+
+. ./defs || Exit 1
+
+cat > configure.ac << END
+AC_INIT([$me], [1.0])
+AC_CONFIG_AUX_DIR([support])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+END
+
+: > Makefile.am
+
+mkdir support
+
+$ACLOCAL
+
+$AUTOCONF
+$AUTOMAKE -a -c
+./configure
+$MAKE
+$MAKE distcheck
+
+gzip -d $distdir.tar.gz
+
+tar tf $distdir.tar | $FGREP support
+
+tar xf $distdir.tar
+ls -l . $distdir # For debugging.
+test -d $distdir/support
+ls -l $distdir/support # For debugging.
+test -f $distdir/support/install-sh
+
+:
diff --git a/t/prefix.sh b/t/prefix.sh
new file mode 100755
index 000000000..26c088a0e
--- /dev/null
+++ b/t/prefix.sh
@@ -0,0 +1,33 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test to make sure range of prefixes can be extended
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+END
+
+cat > Makefile.am << 'EOF'
+bnidir = $(prefix)/bni
+bni_PROGRAMS = zardoz
+EOF
+
+$ACLOCAL
+$AUTOMAKE
+
+:
diff --git a/t/primary-prefix-couples-documented-valid.sh b/t/primary-prefix-couples-documented-valid.sh
new file mode 100755
index 000000000..7b0021abb
--- /dev/null
+++ b/t/primary-prefix-couples-documented-valid.sh
@@ -0,0 +1,87 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that the "uncommon" prefix/primary combinations used in
+# examples in the Automake manual do not cause obvious errors.
+# Please keep this test in sync with the automake manual.
+
+. ./defs || Exit 1
+
+cat >> configure.ac <<'END'
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_RANLIB
+AC_PROG_LIBTOOL
+AM_PROG_GCJ
+AM_PATH_PYTHON
+END
+
+# Fake libtool availability.
+: > ltmain.sh
+cat > acinclude.m4 <<'END'
+AC_DEFUN([AC_PROG_LIBTOOL],
+ [AC_SUBST([LIBTOOL], [:])])
+END
+
+cat > Makefile.am <<'END'
+xmldir = $(datadir)/xml
+xml_DATA = file.xml
+
+data_DATA = file1 file2 file3
+data2dir = $(datadir)
+data2_DATA = file4 file5 file6
+
+aclocaldir = $(datadir)/aclocal
+aclocal_DATA = mymacro.m4 myothermacro.m4
+
+imagesdir = $(pkgdatadir)/images
+soundsdir = $(pkgdatadir)/sounds
+dist_images_DATA = images/vortex.pgm
+dist_sounds_DATA = sounds/whirl.ogg
+
+lisp_DATA = file1.el file2.el
+
+javadir = $(datadir)/java
+dist_java_JAVA = a.java b.java c.java
+
+pkgpython_PYTHON = foo.py
+
+pyexec_LTLIBRARIES = quaternion.la
+quaternion_la_SOURCES = quaternion.c support.c support.h
+quaternion_la_LDFLAGS = -avoid-version -module
+
+myexecbindir = /exec
+myexecbin_PROGRAMS = zardoz
+
+foodir = $(prefix)/foo
+barexecdir = $(prefix)/bar/binaries
+foo_SCRIPTS = foo.sh
+barexec_SCRIPTS = quux.pl
+
+my_execbindir = $(pkglibdir)
+my_doclibdir = $(docdir)
+my_execbin_PROGRAMS = foo
+my_doclib_LIBRARIES = libquux.a
+END
+
+$ACLOCAL
+
+# Both these two invocations are meant.
+# They exercise both code paths concerning auxiliary files.
+$AUTOMAKE -a
+$AUTOMAKE
+
+:
diff --git a/t/primary-prefix-couples-force-valid.sh b/t/primary-prefix-couples-force-valid.sh
new file mode 100755
index 000000000..064db2bbb
--- /dev/null
+++ b/t/primary-prefix-couples-force-valid.sh
@@ -0,0 +1,87 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that a user who wants to use an invalid prefix/primary
+# combination can do so with a proper workaround.
+# For example, this:
+# lib_PROGRAMS = foo
+# is expected to cause an automake error, but this:
+# bardir = $(libdir)
+# bar_PROGRAMS = foo
+# should work.
+
+required=cc
+. ./defs || Exit 1
+
+cat >> configure.ac <<'END'
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_RANLIB
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+my_libdir = $(libdir)
+my_lib_PROGRAMS = foo
+
+foodir = $(bindir)
+foo_LIBRARIES = libquux.a
+
+xdir = $(libexecdir)
+x_HEADERS = bar.h
+
+installcheck-local: test
+.PHONY: test
+test:
+ (cd '$(prefix)' && find .);: For debugging.
+ ls -l '$(libdir)/foo$(EXEEXT)'
+ test -f '$(libdir)/foo$(EXEEXT)'
+ test -x '$(libdir)/foo$(EXEEXT)'
+ ls -l '$(bindir)/libquux.a'
+ test -f '$(bindir)/libquux.a'
+ ls -l '$(libexecdir)/bar.h'
+ test -f '$(libexecdir)/bar.h'
+ test ! -x '$(libexecdir)/bar.h'
+END
+
+cat > foo.c <<'END'
+int main (void)
+{
+ return 0;
+}
+END
+
+cat > libquux.c <<'END'
+int quux(void)
+{
+ return 1;
+}
+END
+
+: > bar.h
+
+$ACLOCAL
+$AUTOMAKE -a
+$AUTOCONF
+
+cwd=`pwd` || fatal_ "cannot get current working directory"
+./configure --prefix="$cwd/_inst"
+
+$MAKE install
+$MAKE installcheck
+$MAKE distcheck
+
+:
diff --git a/t/primary-prefix-invalid-couples.tap b/t/primary-prefix-invalid-couples.tap
new file mode 100755
index 000000000..407c8738f
--- /dev/null
+++ b/t/primary-prefix-invalid-couples.tap
@@ -0,0 +1,194 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Not all primaries/directories combinations are valid.
+# Automake should flag them as errors.
+# Originated from PR/294, extended later (following bug #7647) to
+# cover more cases.
+# See also test 'primary-prefix-valid-couples.test'.
+
+. ./defs || Exit 1
+
+plan_ "later"
+
+oIFS=$IFS # Saved for later.
+
+: > ar-lib
+: > ltmain.sh
+: > texinfo.tex
+: > elisp-comp
+: > py-compile
+: > config.guess
+: > config.sub
+
+cat >> configure.ac <<'END'
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_RANLIB
+AC_SUBST([LIBTOOL], [:]) dnl So that we don't have to require Libtool.
+AM_PROG_GCJ
+AM_PATH_PYTHON
+AM_PATH_LISPDIR
+END
+
+$ACLOCAL || fatal_ "aclocal failure"
+
+# Please keep this list in sync with the list of "Directory Variables"
+# in the GNU Coding Standards and with the list additional directory
+# variables provided by autoconf and/or automake (pkgdatadir, pkglibdir,
+# ...). See also the hash '%standard_prefix' in the automake script.
+prefixes='bin data dataroot doc dvi exec html include info lib libexec
+ lisp locale localstate man man1 man2 man3 man4 man5 man6 man7
+ man8 man9 oldinclude pdf pkgdata pkginclude pkglib pkglibexec
+ ps sbin sharedstate sysconf'
+# Please keep this list in sync with the list of primaries documented in
+# the Automake manual (see the "The Uniform Naming Scheme" section).
+primaries='PROGRAMS LIBRARIES LTLIBRARIES LISP PYTHON JAVA SCRIPTS DATA
+ HEADERS MANS TEXINFOS'
+
+# Use files, not variables, to hold the list of all the possible
+# prefix_PRIMARY couples and the list of those couples valid for
+# automake, to avoid having unreadable very verbose traces.
+
+set +x # Don't be overly verbose.
+
+for prefix in $prefixes; do
+ for primary in $primaries; do
+ echo ${prefix} ${primary}
+ done
+done >all.list
+
+for primary in $primaries; do
+ prefixes_ok=''
+ case $primary in
+ LIBRARIES|LTLIBRARIES)
+ prefixes_ok='lib pkglib'
+ ;;
+ PROGRAMS)
+ prefixes_ok='bin sbin libexec pkglibexec'
+ ;;
+ SCRIPTS)
+ prefixes_ok='bin sbin libexec pkglibexec pkgdata'
+ ;;
+ DATA)
+ prefixes_ok='data dataroot pkgdata doc html dvi pdf ps
+ sysconf sharedstate localstate lisp'
+ ;;
+ HEADERS)
+ prefixes_ok='include oldinclude pkginclude'
+ ;;
+ LISP)
+ prefixes_ok='lisp'
+ ;;
+ PYTHON)
+ prefixes_ok='python'
+ ;;
+ JAVA)
+ prefixes_ok='java'
+ ;;
+ MANS)
+ # FIXME: Here we'd like to have:
+ # prefixes_ok='man man1 man2 man3 man4 man5 man6 man7 man8 man9'
+ # but Automake currently fails on that, as it allows the MANS
+ # primary to be coupled to any prefix.
+ # See also Automake bug#7656.
+ # We should dig out how automake had come to behave this way, and
+ # if such a behaviour can be safely changed.
+ prefixes_ok=$prefixes
+ ;;
+ TEXINFOS)
+ # FIXME: Here we'd like to have:
+ # prefixes_ok='info'
+ # but Automake currently fails on that, as it allows the use of
+ # 'foo_TEXINFOS' to declare extra Texinfo sources for the 'foo'
+ # Texinfo manual, as in e.g.:
+ # info_TEXINFOS = foo.texi
+ # foo_TEXINFOS = gpl.texi
+ # See also Automake bug#7657.
+ prefixes_ok=$prefixes
+ ;;
+ *)
+ fatal_ "unrecognized primary '$primary'"
+ ;;
+ esac
+ for prefix in $prefixes_ok; do
+ echo ${prefix}_${primary}
+ done
+done >allow.list
+
+# 'html_TEXINFOS' is not yet supported, and might never be.
+grep -v '^html TEXINFOS$' all.list | awk '{print NR, $0}' > t
+mv -f t all.list
+
+# For debugging.
+echo '=== all.list ==='
+cat all.list
+echo '=== allow.list ==='
+cat allow.list
+
+# Create the Makefile.am.
+while read lineno prefix primary; do
+ test -n "$prefix" && test -n "$primary" && test 0 -lt $lineno \
+ || fatal_ "internal error in 'all.list'"
+ pfx='' ext=''
+ case $primary in
+ LTLIBRARIES) pfx=lib ext=la;;
+ LIBRARIES) pfx=lib ext=a;;
+ MANS) ext=man;;
+ HEADERS) ext=h;;
+ JAVA) ext=java;;
+ PYTHON) ext=py;;
+ LISP) ext=el;;
+ TEXINFOS) ext=texi;;
+ esac
+ test -z "$ext" || ext=.$ext
+ if test $primary = TEXINFOS; then
+ echo @setfilename foo$lineno.info > foo$lineno.texi
+ fi
+ echo ${prefix}_${primary} = ${pfx}foo${lineno}${ext}
+done <all.list >Makefile.am
+
+# For debugging.
+echo '=== Makefile.am ==='
+cat Makefile.am
+
+set -x # Restore shell xtraces from now on.
+
+AUTOMAKE_fails \
+ -d "'automake -a' error out on mismatched prefix/primary couples" \
+ -- --add-missing
+
+while read lineno prefix primary; do
+ test -n "$prefix" && test -n "$primary" && test 0 -lt $lineno \
+ || fatal_ "internal error in 'all.list'"
+ grep "^${prefix}_${primary}$" allow.list >/dev/null && continue
+ errmsg_rx=".*${prefix}dir.* not a legitimate directory .*$primary"
+ command_ok_ \
+ "mismatched prefix/primary in ${prefix}_${primary}" \
+ grep "^Makefile\\.am:$lineno: $errmsg_rx" stderr
+done <all.list
+
+# Check that automake really failed only for the expected reason(s).
+grep -v 'dir.* not a legitimate directory' stderr && Exit 1
+
+# Check that the same failures are present without the '--add-missing'
+# option.
+mv stderr stderr.old
+AUTOMAKE_fails -d "automake error out on mismatched prefix/primary couples"
+command_ok_ "... and with the same diagnostic of 'automake -a'" \
+ diff stderr.old stderr
+
+:
diff --git a/t/primary-prefix-valid-couples.sh b/t/primary-prefix-valid-couples.sh
new file mode 100755
index 000000000..989ca4bad
--- /dev/null
+++ b/t/primary-prefix-valid-couples.sh
@@ -0,0 +1,88 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Test for valid prefix/primary combinations.
+# See also test 'primary-prefix-invalid-couples.test'.
+
+. ./defs || Exit 1
+
+cat >> configure.ac <<'END'
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_RANLIB
+AC_PROG_LIBTOOL
+AM_PATH_PYTHON
+AM_PATH_LISPDIR
+END
+
+# Fake libtool availability.
+: > ltmain.sh
+: > config.sub
+: > config.guess
+cat > acinclude.m4 <<'END'
+AC_DEFUN([AC_PROG_LIBTOOL],
+ [AC_SUBST([LIBTOOL], [:])])
+END
+
+# Other required files.
+echo '@setfilename foo' > foo.texi
+: > texinfo.tex
+: > py-compile
+: > elisp-comp
+: > ar-lib
+
+# Setup Makefile.am.
+
+: > Makefile.am
+
+for p in bin sbin libexec pkglibexec; do
+ echo "${p}_PROGRAMS = prog-$p" >> Makefile.am
+done
+
+for p in lib pkglib; do
+ echo "${p}_LIBRARIES = libs-$p.a" >> Makefile.am
+ echo "${p}_LTLIBRARIES = libd-$p.la" >> Makefile.am
+done
+
+for p in bin sbin libexec pkglibexec pkgdata; do
+ echo "${p}_SCRIPTS = $p.sh" >> Makefile.am
+done
+
+for p in data dataroot pkgdata doc html dvi pdf ps sysconf \
+ sharedstate localstate lisp; do
+ echo "${p}_DATA = $p.dat" >> Makefile.am
+done
+
+for p in include oldinclude pkginclude; do
+ echo "${p}_HEADERS = $p.h" >> Makefile.am
+done
+
+for p in man man1 man2 man3 man4 man5 man6 man7 man8 man9; do
+ echo "${p}_MANS = bar.$p"
+done
+
+echo "info_TEXINFOS = foo.texi" >> Makefile.am
+echo "lisp_LISP = foo.el" >> Makefile.am
+echo "python_PYTHON = foo.py" >> Makefile.am
+
+awk '{print NR ":" $0}' Makefile.am # For debugging.
+
+# Go with the tests.
+
+$ACLOCAL
+$AUTOMAKE
+
+:
diff --git a/t/primary.sh b/t/primary.sh
new file mode 100755
index 000000000..e1a8f444f
--- /dev/null
+++ b/t/primary.sh
@@ -0,0 +1,30 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test to make sure errors in am_install_var work.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = @programs@
+END
+
+$ACLOCAL
+AUTOMAKE_fails
+grep 'bin_PROGRAMS.*configure substitution' stderr
+grep 'EXTRA_PROGRAMS.*not defined' stderr
+
+:
diff --git a/t/primary2.sh b/t/primary2.sh
new file mode 100755
index 000000000..f9417d8f3
--- /dev/null
+++ b/t/primary2.sh
@@ -0,0 +1,32 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test to make sure errors in am_install_var work.
+
+. ./defs || Exit 1
+
+echo AC_PROG_CC >> configure.ac
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = @programs@
+EXTRA_PROGRAMS = joe @more@
+END
+
+$ACLOCAL
+AUTOMAKE_fails
+grep 'EXTRA_PROGRAMS.*configure substitution' stderr
+
+:
diff --git a/t/primary3.sh b/t/primary3.sh
new file mode 100755
index 000000000..80dab29e2
--- /dev/null
+++ b/t/primary3.sh
@@ -0,0 +1,43 @@
+#! /bin/sh
+# Copyright (C) 2004-2012 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 we can build programs ending in '.la'
+
+required=cc
+. ./defs || Exit 1
+
+cat >>configure.ac <<EOF
+AC_PROG_CC
+AC_OUTPUT
+EOF
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = foo.la
+foo_la_SOURCES = foo.c
+.PHONY: test
+test: all
+ test -f foo.la$(EXEEXT)
+END
+
+echo 'int main () { return 0; }' > foo.c
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+$MAKE test
+
+:
diff --git a/t/print-libdir.sh b/t/print-libdir.sh
new file mode 100755
index 000000000..f5764b368
--- /dev/null
+++ b/t/print-libdir.sh
@@ -0,0 +1,46 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Test on automake options '--print-data-dir' and '--print-script-dir'.
+
+am_create_testdir=empty
+. ./defs || Exit 1
+
+libdir=`$AUTOMAKE --print-libdir` || Exit 1
+case $libdir in /*);; *) Exit 1;; esac
+test -d "$libdir"
+test "$libdir" = "$am_pkgvdatadir"
+test "$libdir" = "$am_scriptdir"
+
+: > Makefile.am
+
+cat > configure.ac <<END
+AC_INIT([$me], [1.0])
+AC_CONFIG_AUX_DIR([.])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([Makefile])
+END
+
+touch ChangeLog README NEWS AUTHORS COPYING
+
+$ACLOCAL
+$AUTOMAKE --gnu --add-missing
+ls -l
+
+diff missing "$libdir"/missing
+diff INSTALL "$libdir"/INSTALL
+
+:
diff --git a/t/proginst.sh b/t/proginst.sh
new file mode 100755
index 000000000..4008b4743
--- /dev/null
+++ b/t/proginst.sh
@@ -0,0 +1,29 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test for bug where when multiple scripts are installed,
+# the check for AC_PROG_INSTALL fails.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+bin_SCRIPTS = zardoz qbert brownie
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+:
diff --git a/t/programs-primary-rewritten.sh b/t/programs-primary-rewritten.sh
new file mode 100755
index 000000000..7de6d99bf
--- /dev/null
+++ b/t/programs-primary-rewritten.sh
@@ -0,0 +1,61 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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 xxx_PROGRAMS gets properly rewritten where needed. These
+# checks have been introduced in commit 'Release-1-9-254-g9d0eaef' into
+# the former test 'subst2.test'.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_SUBST([FOO], [c])
+AC_OUTPUT
+END
+
+cat >Makefile.am <<'END'
+AUTOMAKE_OPTIONS = no-dependencies
+CC = false
+EXEEXT = .bin
+
+check_PROGRAMS = a
+bin_PROGRAMS = b @FOO@
+noinst_PROGRAMS = $(bar) $(baz:=de)
+EXTRA_PROGRAMS =
+
+bar = zardoz
+baz = mau
+
+.PHONY: test
+test:
+ is $(check_PROGRAMS) == a.bin
+ is $(bin_PROGRAMS) == b.bin c
+ is $(noinst_PROGRAMS) == zardoz.bin maude.bin
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+grep PROGRAMS Makefile.in # For debugging.
+
+# Check that no useless indirections are used.
+grep '^check_PROGRAMS = a$(EXEEXT)$' Makefile.in
+grep '^bin_PROGRAMS = b$(EXEEXT) @FOO@$' Makefile.in
+
+$AUTOCONF
+./configure
+$MAKE test
+
+:
diff --git a/t/py-compile-basedir.sh b/t/py-compile-basedir.sh
new file mode 100755
index 000000000..1504f557e
--- /dev/null
+++ b/t/py-compile-basedir.sh
@@ -0,0 +1,50 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Test the '--basedir' option of the 'py-compile' script,
+
+required=python
+. ./defs || Exit 1
+
+# We'll need to create files in '..', so we need one more subdirectory
+# level in order not to clutter up the top-level tests directory.
+mkdir sandbox
+cd sandbox
+
+cp "$am_scriptdir/py-compile" . \
+ || fatal_ "failed to fetch auxiliary script py-compile"
+
+f=__init__
+for d in foo foo/bar "`pwd`/foo" . .. ../foo ''; do
+ if test -z "$d"; then
+ d2=.
+ else
+ d2=$d
+ fi
+ ../install-sh -d "$d2" "$d2/sub" || Exit 99
+ : > "$d2/$f.py"
+ : > "$d2/sub/$f.py"
+ ./py-compile --basedir "$d" "$f.py" "sub/$f.py"
+ ls -l "$d2" "$d2/sub" # For debugging.
+ test -f "$d2/$f.pyc"
+ test -f "$d2/$f.pyo"
+ test -f "$d2/sub/$f.pyc"
+ test -f "$d2/sub/$f.pyo"
+ rm -f "$d2/$f.pyc" "$d2/$f.pyo" "$d2/sub/$f.pyc" "$d2/sub/$f.pyo"
+ find . | grep '\.py[co]$' && Exit 1
+done
+
+:
diff --git a/t/py-compile-basic.sh b/t/py-compile-basic.sh
new file mode 100755
index 000000000..5fa3bf68f
--- /dev/null
+++ b/t/py-compile-basic.sh
@@ -0,0 +1,63 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Test more basic functionalities of the 'py-compile' script,
+# with "believable" python sources. See also related test
+# 'py-compile-basic2.test'.
+
+required=python
+. ./defs || Exit 1
+
+cp "$am_scriptdir/py-compile" . \
+ || fatal_ "failed to fetch auxiliary script py-compile"
+
+cat > foo.py <<'END'
+# Try out some non-trivial syntax in here.
+
+'''Module docstring'''
+
+def foo (*args, **kwargs):
+ """Function docstring
+ with embedded newline"""
+ return 1
+
+class Foo:
+ r"""Class docstring"""
+ def __init__(self):
+ r'''Method docstring
+ with
+ embedded
+ newlines'''
+ pass
+
+bar = baz = (1, (2,), [3, 4]); zardoz = 0;
+END
+
+cat > bar.py <<'END'
+# Import of non-existent modules, or assertion of false conditions,
+# shouldn't cause problems, as it should be enough for the code to
+# be syntactically correct.
+import Automake.No.Such.Module
+assert False
+END
+
+./py-compile foo.py bar.py
+test -f foo.pyc
+test -f foo.pyo
+test -f bar.pyc
+test -f bar.pyo
+
+:
diff --git a/t/py-compile-basic2.sh b/t/py-compile-basic2.sh
new file mode 100755
index 000000000..dfa992c15
--- /dev/null
+++ b/t/py-compile-basic2.sh
@@ -0,0 +1,70 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Test more basic functionalities of the 'py-compile' script, with
+# dummy python sources, but more complex directory layouts. See also
+# related test 'py-compile-basic.test'.
+
+required=python
+. ./defs || Exit 1
+
+ocwd=`pwd` || Exit 99
+
+pyfiles="
+ foo.py
+ ./foo1.py
+ ../foo2.py
+ ../dir/foo3.py
+ $ocwd/foo4.py
+ sub/bar.py
+ sub/subsub/barbar.py
+ __init__.py
+ sub/__init__.py
+ 1.py
+ .././_.py
+"
+
+lst='
+ dir/foo
+ dir/foo1
+ foo2
+ dir/foo3
+ foo4
+ dir/sub/bar
+ dir/sub/subsub/barbar
+ dir/__init__
+ dir/sub/__init__
+ dir/1
+ _
+'
+
+mkdir dir
+cd dir
+cp "$am_scriptdir/py-compile" . \
+ || fatal_ "failed to fetch auxiliary script py-compile"
+mkdir sub sub/subsub
+touch $pyfiles
+./py-compile $pyfiles
+cd "$ocwd"
+
+for x in $lst; do echo $x.pyc; echo $x.pyo; done | sort > exp
+find . -name '*.py[co]' | sed 's|^\./||' | sort > got
+
+cat exp
+cat got
+diff exp got
+
+:
diff --git a/t/py-compile-destdir.sh b/t/py-compile-destdir.sh
new file mode 100755
index 000000000..ab3fe7779
--- /dev/null
+++ b/t/py-compile-destdir.sh
@@ -0,0 +1,43 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Test the '--destdir' option of the 'py-compile' script,
+
+required=python
+. ./defs || Exit 1
+
+cp "$am_scriptdir/py-compile" . \
+ || fatal_ "failed to fetch auxiliary script py-compile"
+
+# Should not give false positives when grepping for it, so use
+# an "uncommon" string (with ugly CamelCase).
+destdir=TheDestDir
+
+mkdir sub $destdir $destdir/sub
+echo 'def foo (): return "foo"' > $destdir/foo.py
+echo 'def bar (): return "bar"' > $destdir/sub/bar.py
+
+./py-compile --destdir $destdir foo.py sub/bar.py
+ls -l $destdir $destdir/sub # For debugging.
+ls . sub | grep '\.py[co]$' && Exit 1
+test -f $destdir/foo.pyc
+test -f $destdir/foo.pyo
+test -f $destdir/sub/bar.pyc
+test -f $destdir/sub/bar.pyo
+strings $destdir/*.py[co] $destdir/sub/*.py[co] || : # For debugging.
+$FGREP $destdir $destdir/*.py[co] $destdir/sub/*.py[co] && Exit 1
+
+:
diff --git a/t/py-compile-env.sh b/t/py-compile-env.sh
new file mode 100755
index 000000000..5dd7e5f5c
--- /dev/null
+++ b/t/py-compile-env.sh
@@ -0,0 +1,59 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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 'py-compile' honours the PYTHON environment variable.
+
+. ./defs || Exit 1
+
+cp "$am_scriptdir/py-compile" . \
+ || fatal_ "failed to fetch auxiliary script py-compile"
+
+cat > my-py <<'END'
+#!/bin/sh
+: > my-py.run
+END
+chmod a+x my-py
+
+mkdir sub1
+cd sub1
+
+PYTHON=: ../py-compile foo.py
+ls | grep . && Exit 1
+
+PYTHON=false ../py-compile foo.py && Exit 1
+ls | grep . && Exit 1
+
+PYTHON='echo GrEpMe AndMeToo' ../py-compile foo.py
+PYTHON='echo GrEpMe AndMeToo' ../py-compile foo.py | grep 'GrEpMe AndMeToo'
+ls | grep . && Exit 1
+
+cd ..
+mkdir sub2
+cd sub2
+
+PYTHON=../my-py ../py-compile foo.py
+test -f my-py.run
+ls | grep -v '^my-py\.run$' | grep . && Exit 1
+
+cd ..
+mkdir sub3
+cd sub3
+PATH=..$PATH_SEPARATOR$PATH; export PATH
+PYTHON=my-py py-compile foo.py
+test -f my-py.run
+ls | grep -v '^my-py\.run$' | grep . && Exit 1
+
+:
diff --git a/t/py-compile-option-terminate.sh b/t/py-compile-option-terminate.sh
new file mode 100755
index 000000000..f54ffc756
--- /dev/null
+++ b/t/py-compile-option-terminate.sh
@@ -0,0 +1,43 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that a non-option argument and the '--' special argument
+# explicitly terminate the option list for 'py-compile'.
+
+required=python
+. ./defs || Exit 1
+
+cp "$am_scriptdir/py-compile" . \
+ || fatal_ "failed to fetch auxiliary script py-compile"
+
+: > ./-o.py
+: > ./--foo.py
+./py-compile -- -o.py --foo.py
+test -f ./-o.pyc
+test -f ./-o.pyo
+test -f ./--foo.pyc
+test -f ./--foo.pyo
+rm -f ./-*.py[co]
+: > x.py
+./py-compile x.py -o.py --foo.py
+test -f ./x.pyc
+test -f ./x.pyo
+test -f ./-o.pyc
+test -f ./-o.pyo
+test -f ./--foo.pyc
+test -f ./--foo.pyo
+
+:
diff --git a/t/py-compile-usage.sh b/t/py-compile-usage.sh
new file mode 100755
index 000000000..19883b03d
--- /dev/null
+++ b/t/py-compile-usage.sh
@@ -0,0 +1,75 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Test 'py-compile --help', 'py-compile --version', and that 'py-compile'
+# correctly complains on wrong usage.
+
+. ./defs || Exit 1
+
+cp "$am_scriptdir/py-compile" . \
+ || fatal_ "failed to fetch auxiliary script py-compile"
+
+# --help
+
+./py-compile --help >stdout 2>stderr \
+ || { cat stdout; cat stderr >&2; Exit 1; }
+cat stdout
+test -s stderr && { cat stderr >&2; Exit 1; }
+grep '^Usage: py-compile .' stdout
+$FGREP ' [--basedir DIR]' stdout
+$FGREP ' [--destdir DIR]' stdout
+
+# --version
+
+./py-compile --version >stdout 2>stderr \
+ || { cat stdout; cat stderr >&2; Exit 1; }
+cat stdout
+test -s stderr && { cat stderr >&2; Exit 1; }
+year='20[0-9][0-9]' # Hopefully automake will be obsolete in 80 years ;-)
+month='(0[0-9]|1[012])'
+day='([012][0-9]|3[01])'
+hour='([01][0-9]|2[0123])'
+LC_ALL=C $EGREP "^py-compile $year-$month-$day\.$hour" stdout
+test `wc -l <stdout` -eq 1
+
+# Unknown option.
+
+for opt in -b -d --foo; do
+ ./py-compile $opt 2>stderr && { cat stderr >&2; Exit 1; }
+ cat stderr >&2
+ grep "^py-compile: unrecognized option ['\`]$opt'" stderr
+ grep "^Try [\`']py-compile --help' for more information" stderr
+done
+
+# Missing option argument.
+
+for opt in --basedir --destdir; do
+ ./py-compile $opt 2>stderr && { cat stderr >&2; Exit 1; }
+ cat stderr >&2
+ grep "^py-compile: option ['\`]$opt' requires an argument" stderr
+ grep "^Try [\`']py-compile --help' for more information" stderr
+done
+
+# Missing files.
+
+for args in '' '--basedir dir' '--destdir dir'; do
+ ./py-compile $args 2>stderr && { cat stderr >&2; Exit 1; }
+ cat stderr >&2
+ grep '^py-compile: no files given' stderr
+ grep "^Try [\`']py-compile --help' for more information" stderr
+done
+
+:
diff --git a/t/python-dist.sh b/t/python-dist.sh
new file mode 100755
index 000000000..25dd4fe8b
--- /dev/null
+++ b/t/python-dist.sh
@@ -0,0 +1,78 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Test distribution of *_PYTHON files.
+
+# This test does not require python.
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AM_PATH_PYTHON([], [:], [:])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+python_PYTHON = python.py
+dist_python_PYTHON = python-dist.py
+nodist_python_PYTHON = python-nodist.py
+
+pkgpython_PYTHON = pkgpython.py
+dist_pkgpython_PYTHON = pkgpython-dist.py
+nodist_pkgpython_PYTHON = pkgpython-nodist.py
+
+mydir = $(prefix)/my
+my_PYTHON = my.py
+dist_my_PYTHON = my-dist.py
+nodist_my_PYTHON = my-nodist.py
+
+my.py my-dist.py my-nodist.py:
+ : > $@
+
+.PHONY: disttest
+disttest: distdir
+ ls -l $(distdir)
+ test -f $(distdir)/python.py
+ test -f $(distdir)/python-dist.py
+ test ! -f $(distdir)/python-nodist.py
+ test -f $(distdir)/pkgpython.py
+ test -f $(distdir)/pkgpython-dist.py
+ test ! -f $(distdir)/pkgpython-nodist.py
+ test -f $(distdir)/my.py
+ test -f $(distdir)/my-dist.py
+ test ! -f $(distdir)/my-nodist.py
+END
+
+: > python.py
+: > python-dist.py
+: > python-nodist.py
+
+: > pkgpython.py
+: > pkgpython-dist.py
+: > pkgpython-nodist.py
+
+: > py-compile
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+
+$MAKE disttest
+# It's not distributed, hence it shouldn't be needlessly generated.
+test ! -f my-nodist.py
+
+:
diff --git a/t/python-pr10995.sh b/t/python-pr10995.sh
new file mode 100755
index 000000000..b21d38f0c
--- /dev/null
+++ b/t/python-pr10995.sh
@@ -0,0 +1,60 @@
+#! /bin/sh
+# Copyright (C) 2012 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/>.
+
+# Test automake bug#10995: am__py_compile doesn't get correctly defined
+# when there a 'noinst_PYTHON' declaration precedes a 'foo_PYTHON'
+# declaration.
+
+required=python
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.ac <<'EOF'
+AM_PATH_PYTHON
+AC_OUTPUT
+EOF
+
+cat > Makefile.am <<'END'
+yesinstdir = $(prefix)/py
+noinst_PYTHON = no.py
+yesinst_PYTHON = yes.py
+disttest: distdir
+ test -f $(distdir)/no.py
+ test -f $(distdir)/yes.py
+END
+
+echo 'def foo(): return 1' > yes.py
+# no.py shouldn't be byte-compiled, so lets make it syntactically invalid.
+echo 'if' > no.py
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+test -f py-compile
+
+inst=`pwd`/inst
+
+./configure --prefix="$inst"
+$MAKE install
+test -f "$inst/py/yes.py"
+test -f "$inst/py/yes.pyc"
+test ! -f "$inst/py/no.py"
+test ! -f "$inst/py/no.pyc"
+
+$MAKE disttest
+
+:
diff --git a/t/python-vars.sh b/t/python-vars.sh
new file mode 100755
index 000000000..56c2b619f
--- /dev/null
+++ b/t/python-vars.sh
@@ -0,0 +1,107 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that AM_PATH_PYTHON correctly sets all the output variables
+# advertised in the manual.
+
+required=python
+. ./defs || Exit 1
+
+# In case the user's config.site defines pythondir or pyexecdir.
+CONFIG_SITE=/dev/null; export CONFIG_SITE
+
+PYTHON=python
+
+# Update the definition below if the documentation changes.
+# Note that the value of the 'pythondir' and 'pyexecdir' variables can
+# vary among different python installations, so we need more relaxed
+# and ad-hoc checks for them. Also, more proper "functional" checks
+# on them should be done in the 'python-virtualenv.test' test.
+PYTHON_VERSION=`$PYTHON -c 'import sys; print(sys.version[:3])'` || Exit 1
+PYTHON_PLATFORM=`$PYTHON -c 'import sys; print(sys.platform)'` || Exit 1
+PYTHON_EXEC_PREFIX='${exec_prefix}'
+PYTHON_PREFIX='${prefix}'
+pkgpythondir="\${pythondir}/$me"
+pkgpyexecdir="\${pyexecdir}/$me"
+
+pyvars='PYTHON_VERSION PYTHON_PLATFORM PYTHON_PREFIX PYTHON_EXEC_PREFIX
+ pkgpythondir pkgpyexecdir'
+
+cat >> configure.ac << 'END'
+AC_CONFIG_FILES([vars-got pythondir pyexecdir])
+AM_PATH_PYTHON
+AC_OUTPUT
+END
+
+cat > my.py << 'END'
+def my():
+ return 1
+END
+
+cat > Makefile.am << 'END'
+
+python_PYTHON = my.py
+
+EXTRA_DIST = vars-exp
+
+check-local: test-in test-am
+.PHONY: test-in test-am
+
+test-in:
+ cat pythondir
+ case `cat pythondir` in '$${prefix}'/*);; *) exit 1;; esac
+ cat pyexecdir
+ case `cat pyexecdir` in '$${exec_prefix}'/*);; *) exit 1;; esac
+ cat $(srcdir)/vars-exp
+ cat $(builddir)/vars-got
+ diff $(srcdir)/vars-exp $(builddir)/vars-got
+
+## Note: this target's rules will be extended in the "for" loop below.
+test-am:
+ case '$(pythondir)' in '$(prefix)'/*);; *) exit 1;; esac
+ case '$(pyexecdir)' in '$(exec_prefix)'/*);; *) exit 1;; esac
+END
+
+echo @pythondir@ > pythondir.in
+echo @pyexecdir@ > pyexecdir.in
+
+: > vars-exp
+: > vars-got.in
+
+for var in $pyvars; do
+ eval val=\$$var
+ echo "var=$val" >> vars-exp
+ echo "var=@$var@" >> vars-got.in
+ echo "${tab}test x'\$($var)' = x'$val'" >> Makefile.am
+done
+
+cat Makefile.am
+cat vars-got.in
+
+$ACLOCAL
+$AUTOMAKE --add-missing
+
+for var in pythondir pyexecdir $pyvars; do
+ grep "^$var *=" Makefile.in
+done
+
+$AUTOCONF
+./configure PYTHON="$PYTHON"
+
+$MAKE test-in test-am
+$MAKE distcheck
+
+:
diff --git a/t/python-virtualenv.sh b/t/python-virtualenv.sh
new file mode 100755
index 000000000..c534e8da4
--- /dev/null
+++ b/t/python-virtualenv.sh
@@ -0,0 +1,187 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that python support can work well with virtualenvs.
+# This test also works as a mild stress-test on the python support.
+
+required='cc python virtualenv'
+. ./defs || Exit 1
+
+# In case the user's config.site defines pythondir or pyexecdir.
+CONFIG_SITE=/dev/null; export CONFIG_SITE
+
+# Skip the test if a proper virtualenv cannot be created.
+virtualenv --verbose virtenv && test -f virtenv/bin/activate \
+ || skip_ "coulnd't create python virtual environment"
+
+# Activate the virtualenv.
+. ./virtenv/bin/activate
+# Sanity check.
+if test -z "$VIRTUAL_ENV"; then
+ framework_failure_ "can't activate python virtual environment"
+fi
+
+cwd=`pwd`
+py_version=`python -c 'import sys; print("%u.%u" % tuple(sys.version_info[:2]))'`
+py_site=$VIRTUAL_ENV/lib/python$py_version/site-packages
+
+# We need control over the package name.
+cat > configure.ac << END
+AC_INIT([am_virtenv], [1.0])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([Makefile])
+AC_SUBST([MY_VIRTENV], ['$cwd/virtenv'])
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_RANLIB
+AM_PATH_PYTHON
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+python_PYTHON = am_foo.py
+pkgpython_PYTHON = __init__.py
+pyexec_LIBRARIES = libquux.a
+libquux_a_SOURCES = foo.c
+pkgpyexec_LIBRARIES = libzardoz.a
+libzardoz_a_SOURCES = foo.c
+
+py_site = $(MY_VIRTENV)/lib/python$(PYTHON_VERSION)/site-packages
+
+.PYTHON: debug test-run test-install test-uninstall
+debug:
+ @echo PYTHON: $(PYTHON)
+ @echo PYTHON_VERSION: $(PYTHON_VERSION)
+ @echo prefix: $(prefix)
+ @echo pythondir: $(pythondir)
+ @echo pkgpythondir: $(pkgpythondir)
+ @echo pyexecdir: $(pyexecdir)
+ @echo pkgpyexecdir: $(pkgpyexecdir)
+test-run:
+ ## In a virtualenv, the default python must be the custom
+ ## virtualenv python.
+ @: \
+ && py1=`python -c 'import sys; print(sys.executable)'` \
+ && py2=`$(PYTHON) -c 'import sys; print(sys.executable)'` \
+ && echo "py1: $$py1" \
+ && echo "py2: $$py2" \
+ && test -n "$$py1" \
+ && test -n "$$py2" \
+ && test x"$$py1" = x"$$py2"
+ ## Check that modules installed in the virtualenv are readily
+ ## available.
+ python -c 'from am_foo import foo_func; assert (foo_func () == 12345)'
+ python -c 'from am_virtenv import old_am; assert (old_am () == "AutoMake")'
+test-install:
+ test -f $(py_site)/am_foo.py
+ test -f $(py_site)/am_foo.pyc
+ test -f $(py_site)/am_foo.pyo
+ test -f $(py_site)/am_virtenv/__init__.py
+ test -f $(py_site)/am_virtenv/__init__.pyc
+ test -f $(py_site)/am_virtenv/__init__.pyo
+ test -f $(py_site)/libquux.a
+ test -f $(py_site)/am_virtenv/libzardoz.a
+test-uninstall:
+ test ! -f $(py_site)/am_foo.py
+ test ! -f $(py_site)/am_foo.pyc
+ test ! -f $(py_site)/am_foo.pyo
+ test ! -f $(py_site)/am_virtenv/__init__.py
+ test ! -f $(py_site)/am_virtenv/__init__.pyc
+ test ! -f $(py_site)/am_virtenv/__init__.pyo
+ test ! -f $(py_site)/libquux.a
+ test ! -f $(py_site)/am_virtenv/libzardoz.a
+all-local: debug
+END
+
+cat > am_foo.py << 'END'
+def foo_func ():
+ return 12345
+END
+
+cat > __init__.py << 'END'
+def old_am ():
+ return 'AutoMake'
+END
+
+cat > foo.c << 'END'
+int foo (void)
+{
+ return 0;
+}
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+# Try a VPATH build.
+mkdir build
+cd build
+../configure --prefix="$VIRTUAL_ENV"
+$MAKE install
+$MAKE test-install
+$MAKE test-run
+$MAKE uninstall
+$MAKE test-uninstall
+cd ..
+
+# Try an in-tree build.
+./configure --prefix="$VIRTUAL_ENV"
+$MAKE install
+$MAKE test-install
+$MAKE test-run
+$MAKE uninstall
+$MAKE test-uninstall
+
+$MAKE distclean
+
+# Overriding pythondir and pyexecdir with cache variables should work.
+./configure am_cv_python_pythondir="$py_site" \
+ am_cv_python_pyexecdir="$py_site"
+$MAKE install
+$MAKE test-install
+$MAKE test-run
+$MAKE uninstall
+$MAKE test-uninstall
+
+$MAKE distclean
+
+# Overriding pythondir and pyexecdir at make time should be enough.
+./configure --prefix="$cwd/bad-prefix"
+pythondir=$py_site pyexecdir=$py_site
+export pythondir pyexecdir
+$MAKE -e install
+test ! -d bad-prefix
+$MAKE -e test-install
+$MAKE test-run
+$MAKE -e uninstall
+$MAKE -e test-uninstall
+unset pythondir pyexecdir
+
+# Also check that the distribution is self-contained, for completeness.
+$MAKE distcheck
+
+# Finally, check that if we disable the virtualenv, we shouldn't be
+# able to access to the installed modules anymore.
+cd build
+$MAKE install
+python -c 'import am_foo; print(am_foo.__file__)'
+python -c 'import am_virtenv; print(am_virtenv.__file__)'
+deactivate "nondestructive"
+python -c 'import am_foo' && Exit 1
+python -c 'import am_virtenv' && Exit 1
+
+:
diff --git a/t/python.sh b/t/python.sh
new file mode 100755
index 000000000..de8c0bbfb
--- /dev/null
+++ b/t/python.sh
@@ -0,0 +1,60 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test to make sure py_compile and am__py_compile are correctly defined.
+
+. ./defs || Exit 1
+
+echo 'AM_PATH_PYTHON' >> configure.ac
+
+cat > Makefile.am << 'END'
+python_PYTHON = foo.py
+END
+
+cat > Makefile2.am << 'END'
+python_PYTHON = a.py
+nodist_python_PYTHON = b.py
+nobase_python_PYTHON = x/c.py
+mydir = ${prefix}
+my_PYTHON = d.py
+END
+
+# For automake bug#10995.
+cat > Makefile3.am << 'END'
+noinst_PYTHON = un.py
+python_PYTHON = in.py
+END
+
+$ACLOCAL
+
+AUTOMAKE_fails
+grep '^Makefile\.am:1:.* required file.*py-compile' stderr
+
+$AUTOMAKE -a
+grep '^py_compile *=' Makefile.in
+test -f py-compile
+
+$AUTOMAKE Makefile2
+$AUTOMAKE Makefile3
+
+grep "py" Makefile.in Makefile2.in Makefile3.in # For debugging.
+
+for f in Makefile.in Makefile2.in Makefile3.in; do
+ test `grep -c '^py_compile =' $f` -eq 1
+ test `grep -c '^am__py_compile =' $f` -eq 1
+done
+
+:
diff --git a/t/python10.sh b/t/python10.sh
new file mode 100755
index 000000000..b28c3a449
--- /dev/null
+++ b/t/python10.sh
@@ -0,0 +1,85 @@
+#! /bin/sh
+# Copyright (C) 2004-2012 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/>.
+
+# Test _PYTHON with conditionals.
+
+required=python
+. ./defs || Exit 1
+
+cat >>configure.ac <<'EOF'
+AM_PATH_PYTHON
+AM_CONDITIONAL([ONE], [test "x$one" = x1])
+AC_OUTPUT
+EOF
+
+cat > Makefile.am <<'END'
+if ONE
+mydir=$(prefix)/my
+my_PYTHON = one.py
+else
+yourdir=$(prefix)/your
+your_PYTHON = two.py
+endif
+
+one.py:
+ echo 'def one(): return 1' >$@
+two.py:
+ echo 'def two(): return 1' >$@
+
+.PHONY: disttest
+disttest: distdir
+ ls -l $(distdir)
+ test -f $(distdir)/one.py
+ test -f $(distdir)/two.py
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+mkdir inst
+inst=`pwd`/inst
+mkdir build
+cd build
+../configure --prefix="$inst"
+$MAKE install
+test -f "$inst/your/two.py"
+test -f "$inst/your/two.pyc"
+test -f "$inst/your/two.pyo"
+test ! -f "$inst/my/one.py"
+test ! -f "$inst/my/one.pyc"
+test ! -f "$inst/my/one.pyo"
+$MAKE uninstall
+test ! -f "$inst/your/two.py"
+test ! -f "$inst/your/two.pyc"
+test ! -f "$inst/your/two.pyo"
+
+../configure --prefix="$inst" one=1
+$MAKE install
+test ! -f "$inst/your/two.py"
+test ! -f "$inst/your/two.pyc"
+test ! -f "$inst/your/two.pyo"
+test -f "$inst/my/one.py"
+test -f "$inst/my/one.pyc"
+test -f "$inst/my/one.pyo"
+$MAKE uninstall
+test ! -f "$inst/my/one.py"
+test ! -f "$inst/my/one.pyc"
+test ! -f "$inst/my/one.pyo"
+
+$MAKE disttest
+
+:
diff --git a/t/python11.sh b/t/python11.sh
new file mode 100755
index 000000000..aff3c9c7c
--- /dev/null
+++ b/t/python11.sh
@@ -0,0 +1,55 @@
+#! /bin/sh
+# Copyright (C) 2004-2012 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/>.
+
+# Test missing python.
+
+# Python is not required for this test.
+. ./defs || Exit 1
+
+cat >>configure.ac <<'EOF'
+m4_define([_AM_PYTHON_INTERPRETER_LIST], [IShouldNotExist1 IShouldNotExist2])
+AM_PATH_PYTHON
+# The following be executed only after the first run, once a
+# third argument has been added to the previous macro.
+echo PYTHON = $PYTHON
+test "$PYTHON" = : || exit 1
+EOF
+
+: > Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+
+./configure >stdout 2>stderr && { cat stdout; cat stderr >&2; Exit 1; }
+cat stdout
+cat stderr >&2
+grep 'checking for IShouldNotExist1' stdout
+grep 'checking for IShouldNotExist2' stdout
+grep 'no suitable Python interpreter found' stderr
+
+sed 's/AM_PATH_PYTHON/AM_PATH_PYTHON(,,:)/' configure.ac >configure.int
+mv -f configure.int configure.ac
+$ACLOCAL --force
+$AUTOCONF --force
+# This one should define PYTHON as ":" and exit successfully.
+./configure
+
+# Any user setting should be used.
+./configure PYTHON=foo >stdout && { cat stdout; Exit 1; }
+cat stdout
+grep 'PYTHON = foo' stdout
+
+:
diff --git a/t/python12.sh b/t/python12.sh
new file mode 100755
index 000000000..3faeb457f
--- /dev/null
+++ b/t/python12.sh
@@ -0,0 +1,56 @@
+#! /bin/sh
+# Copyright (C) 2004-2012 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/>.
+
+# Ensure DESTDIR is not included in byte-compiled files.
+
+required=python
+. ./defs || Exit 1
+
+cat >>configure.ac <<'EOF'
+AM_PATH_PYTHON
+AC_OUTPUT
+EOF
+
+cat >Makefile.am <<'END'
+mydir = $(datadir)/my
+my_PYTHON = my.py
+
+my.py:
+ echo 'def my(): return 1' >$@
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+rm -rf inst build
+mkdir inst
+instdir=`pwd`/inst
+mkdir build
+cd build
+../configure --prefix="/usr"
+$MAKE install DESTDIR=$instdir
+
+# Perfunctory test that the files were created.
+test -f "$instdir/usr/share/my/my.py"
+test -f "$instdir/usr/share/my/my.pyc"
+test -f "$instdir/usr/share/my/my.pyo"
+
+# If DESTDIR has made it into the byte compiled files, fail the test.
+$FGREP "$instdir" "$instdir/usr/share/my/my.pyo" \
+ "$instdir/usr/share/my/my.pyc" && Exit 1
+
+:
diff --git a/t/python2.sh b/t/python2.sh
new file mode 100755
index 000000000..3b13b33f7
--- /dev/null
+++ b/t/python2.sh
@@ -0,0 +1,106 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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 that Automake suggests using AM_PATH_PYTHON.
+
+. ./defs || Exit 1
+
+$ACLOCAL
+
+echo 1. pythondir not defined
+
+cat > Makefile.am <<'END'
+PYTHON = x
+python_PYTHON = foo.py
+END
+
+AUTOMAKE_fails -a
+grep 'pythondir.*undefined' stderr
+grep AM_PATH_PYTHON stderr
+
+
+echo 2. pkgpythondir not defined
+
+cat > Makefile.am <<'END'
+PYTHON = x
+pkgpython_PYTHON = foo.py
+END
+
+AUTOMAKE_fails -a
+grep 'pkgpythondir.*undefined' stderr
+grep AM_PATH_PYTHON stderr
+
+
+echo 3. pyexecdir not defined
+
+cat > Makefile.am <<'END'
+PYTHON = x
+pyexec_PYTHON = foo.py
+END
+
+AUTOMAKE_fails -a
+grep 'pyexecdir.*undefined' stderr
+grep AM_PATH_PYTHON stderr
+
+
+echo 4. pkgpyexecdir not defined
+
+cat > Makefile.am <<'END'
+PYTHON = x
+pkgpyexec_PYTHON = foo.py
+END
+
+AUTOMAKE_fails -a
+grep 'pkgpyexecdir.*undefined' stderr
+grep AM_PATH_PYTHON stderr
+
+
+echo 5. PYTHON not defined.
+
+cat > Makefile.am <<'END'
+pkgpyexecdir = /here/we/go
+pkgpyexec_PYTHON = foo.py
+END
+
+AUTOMAKE_fails -a
+grep 'PYTHON.*undefined' stderr
+grep AM_PATH_PYTHON stderr
+
+
+echo 6. Ok.
+
+cat > Makefile.am <<'END'
+PYTHON = x
+pkgpyexecdir = /here/we/go
+pkgpyexec_PYTHON = foo.py
+END
+
+rm -f py-compile
+$AUTOMAKE -a
+test -f py-compile
+
+
+echo 7. Ok again.
+
+cat > Makefile.am <<'END'
+PYTHON = x
+fubardir = /here/we/go
+fubar_PYTHON = foo.py
+END
+
+$AUTOMAKE -a
+
+:
diff --git a/t/python3.sh b/t/python3.sh
new file mode 100755
index 000000000..72021cd86
--- /dev/null
+++ b/t/python3.sh
@@ -0,0 +1,49 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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 we install built python files.
+
+required=python
+. ./defs || Exit 1
+
+cat >>configure.ac <<EOF
+AM_PATH_PYTHON
+AC_OUTPUT
+EOF
+
+cat > Makefile.am <<'END'
+mydir=$(prefix)/my
+my_PYTHON = one.py
+
+one.py:
+ echo 'def one(): return 1' >$@
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+mkdir inst
+inst=`pwd`/inst
+mkdir build
+cd build
+../configure --prefix="$inst"
+$MAKE install
+test -f "$inst/my/one.py"
+test -f "$inst/my/one.pyc"
+test -f "$inst/my/one.pyo"
+
+:
diff --git a/t/python4.sh b/t/python4.sh
new file mode 100755
index 000000000..4294bb2ef
--- /dev/null
+++ b/t/python4.sh
@@ -0,0 +1,43 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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/>.
+
+# Test detection of missing Python.
+
+# Python is not required for this test.
+. ./defs || Exit 1
+
+cat >>configure.ac <<EOF
+AM_PATH_PYTHON
+AC_OUTPUT
+EOF
+
+: > Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+# Simulate no Python.
+./configure PYTHON=: 2>stderr && { cat stderr >&2; Exit 1; }
+cat stderr >&2
+grep 'no suitable Python interpreter found' stderr
+
+# Again, but from the environment this time.
+env PYTHON=: ./configure 2>stderr && { cat stderr >&2; Exit 1; }
+cat stderr >&2
+grep 'no suitable Python interpreter found' stderr
+
+:
diff --git a/t/python5.sh b/t/python5.sh
new file mode 100755
index 000000000..80429f9c6
--- /dev/null
+++ b/t/python5.sh
@@ -0,0 +1,45 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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/>.
+
+# Test detection of missing Python.
+# Same as python4.test, but requiring a version.
+
+# Python is not required for this test.
+. ./defs || Exit 1
+
+cat >>configure.ac <<EOF
+# Hopefully the Python team will never release such a version.
+AM_PATH_PYTHON([9999.9])
+AC_OUTPUT
+EOF
+
+: > Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+./configure >stdout 2>stderr && {
+ cat stdout
+ cat stderr >&2
+ Exit 1
+}
+cat stdout
+cat stderr >&2
+$EGREP 'checking for a Python interpreter with version >= 9999\.9\.\.\. no(ne)? *$' stdout
+grep 'no suitable Python interpreter found' stderr
+
+:
diff --git a/t/python5b.sh b/t/python5b.sh
new file mode 100755
index 000000000..b382b38f9
--- /dev/null
+++ b/t/python5b.sh
@@ -0,0 +1,53 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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/>.
+
+# Test detection of missing Python.
+# Same as python5.test, but with the user forcing the python to use.
+
+required=python
+. ./defs || Exit 1
+
+cat >>configure.ac << 'END'
+# Hopefully the Python team will never release such a version.
+AM_PATH_PYTHON([9999.9])
+AC_OUTPUT
+END
+
+mkdir bin
+cat > bin/my-python << 'END'
+#! /bin/sh
+exec python ${1+"$@"}
+END
+chmod a+x bin/my-python
+PATH=`pwd`/bin$PATH_SEPARATOR$PATH
+
+: > Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+./configure PYTHON=my-python >stdout 2>stderr && {
+ cat stdout
+ cat stderr >&2
+ Exit 1
+}
+cat stdout
+cat stderr >&2
+grep 'whether my-python version is >= 9999\.9\.\.\. no *$' stdout
+grep '[Pp]ython interpreter is too old' stderr
+
+:
diff --git a/t/python6.sh b/t/python6.sh
new file mode 100755
index 000000000..0e09a4381
--- /dev/null
+++ b/t/python6.sh
@@ -0,0 +1,38 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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/>.
+
+# Test detection of missing Python.
+# Same as python4.test, but using a custom ACTION-IF-NOT-FOUND.
+
+# Python is not required for this test.
+. ./defs || Exit 1
+
+cat >>configure.ac <<\EOF
+AM_PATH_PYTHON(,, [echo "$PYTHON" > py])
+AC_OUTPUT
+EOF
+
+: > Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+# Simulate no Python.
+./configure PYTHON=:
+test x"`cat py`" = x:
+
+:
diff --git a/t/python7.sh b/t/python7.sh
new file mode 100755
index 000000000..ec0ac070a
--- /dev/null
+++ b/t/python7.sh
@@ -0,0 +1,38 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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/>.
+
+# Test detection of missing Python.
+# Same as python6.test, but requiring a version.
+
+# Python is not required for this test.
+. ./defs || Exit 1
+
+cat >>configure.ac <<\EOF
+# Hopefully the Python team will never release such a version.
+AM_PATH_PYTHON([9999.9], [], [echo "$PYTHON" > py])
+AC_OUTPUT
+EOF
+
+: > Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+./configure
+test x"`cat py`" = x:
+
+:
diff --git a/t/python8.sh b/t/python8.sh
new file mode 100755
index 000000000..f999cb684
--- /dev/null
+++ b/t/python8.sh
@@ -0,0 +1,37 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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/>.
+
+# Test ACTION-IF-TRUE in AM_PATH_PYTHON.
+
+required=python
+. ./defs || Exit 1
+
+cat >>configure.ac <<'EOF'
+# $PYTHON is supposed to be properly set in ACTION-IF-TRUE.
+AM_PATH_PYTHON(, [$PYTHON -V >py-version 2>&1])
+AC_OUTPUT
+EOF
+
+: > Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+./configure
+grep '^Python [0-9]\.[0-9][0-9]*\.[0-9]' py-version
+
+:
diff --git a/t/python9.sh b/t/python9.sh
new file mode 100755
index 000000000..e567adcde
--- /dev/null
+++ b/t/python9.sh
@@ -0,0 +1,38 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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/>.
+
+# Test ACTION-IF-TRUE in AM_PATH_PYTHON.
+# Similar to python8.test, but requiring a version.
+
+required=python
+. ./defs || Exit 1
+
+cat >>configure.ac <<'EOF'
+# $PYTHON is supposed to be properly set in ACTION-IF-TRUE.
+AM_PATH_PYTHON([0.0], [$PYTHON -c 'print("%u:%u" % (1-1, 2**0))' > py.out])
+AC_OUTPUT
+EOF
+
+: > Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+./configure
+test x"`cat py.out`" = x0:1
+
+:
diff --git a/t/recurs.sh b/t/recurs.sh
new file mode 100755
index 000000000..5a9c16585
--- /dev/null
+++ b/t/recurs.sh
@@ -0,0 +1,36 @@
+#! /bin/sh
+# Copyright (C) 1998-2012 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/>.
+
+# Test to make sure recursive variable definitions die.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_CONDITIONAL(ONE, true)
+AM_CONDITIONAL(TWO, false)
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = $(foo)
+foo = $(bin_PROGRAMS)
+END
+
+$ACLOCAL
+AUTOMAKE_fails
+grep 'Makefile\.am:.*bin_PROGRAMS.*recursively defined' stderr
+
+:
diff --git a/t/recurs2.sh b/t/recurs2.sh
new file mode 100755
index 000000000..e2c521337
--- /dev/null
+++ b/t/recurs2.sh
@@ -0,0 +1,29 @@
+#! /bin/sh
+# Copyright (C) 1998-2012 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/>.
+
+# Test to make sure recursive variable definitions die.
+# From Jim Meyering.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+man_MANS = chgrp.1
+man_aux = $(man_MANS:.1=.x)
+EXTRA_DIST = $(man_aux) $(man_MANS)
+END
+
+$ACLOCAL
+$AUTOMAKE
diff --git a/t/remake-all-1.sh b/t/remake-all-1.sh
new file mode 100755
index 000000000..f1a85bc17
--- /dev/null
+++ b/t/remake-all-1.sh
@@ -0,0 +1,67 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Check that the "all" target triggers rebuilt of outdated Makefiles.
+# See also sister test 'remake-all-2.test'.
+
+. ./defs || Exit 1
+
+mkfile=Makefile
+
+magic1=::MagicStringOne::
+magic2=__MagicStringTwo__
+magic3=%%MagicStringThree%%
+
+cat > configure.ac <<END
+AC_INIT([$me], [1.0])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([$mkfile sub/$mkfile])
+FOO='$magic1'
+AC_OUTPUT
+END
+
+mkdir sub
+echo SUBDIRS = sub > $mkfile.am
+: > sub/$mkfile.am
+
+$ACLOCAL
+$AUTOMAKE
+
+$EGREP "^all-am:.* $mkfile( |$)" $mkfile.in sub/$mkfile.in
+
+$AUTOCONF
+./configure
+
+$FGREP "$magic1" mkfile.in && Exit 1 # Sanity check.
+
+# Two code paths in configure.am:
+
+# - either a file in $(am__configure_deps) has been updated ...
+$sleep
+echo "AC_SUBST([FOO])" >> configure.ac
+$MAKE
+$FGREP FOO $mkfile # For debugging.
+$FGREP $magic1 $mkfile
+
+# - ... or not; i.e., Makefile.am or an included file has.
+$sleep
+echo "# $magic2" >> $mkfile.am
+echo "# $magic3" >> sub/$mkfile.am
+$MAKE
+$FGREP $magic2 $mkfile
+$FGREP $magic3 sub/$mkfile
+
+:
diff --git a/t/remake-all-2.sh b/t/remake-all-2.sh
new file mode 100755
index 000000000..930653232
--- /dev/null
+++ b/t/remake-all-2.sh
@@ -0,0 +1,75 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Check that the "all" target triggers rebuilt of outdated makefiles.
+# This handle the case in which the makefiles are not called 'Makefile'.
+# See also sister test 'remake-all-1.test'.
+
+. ./defs || Exit 1
+
+mkfile=foobar
+
+magic1=::MagicStringOne::
+magic2=__MagicStringTwo__
+magic3=%%MagicStringThree%%
+
+cat > configure.ac <<END
+AC_INIT([$me], [1.0])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([$mkfile sub/$mkfile])
+FOO='$magic1'
+AC_OUTPUT
+END
+
+mkdir sub
+
+cat > $mkfile.am <<END
+SUBDIRS = sub
+AM_MAKEFLAGS = -f $mkfile
+END
+
+cat > sub/$mkfile.am <<END
+AM_MAKEFLAGS = -f $mkfile
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+$EGREP "^all-am:.* $mkfile( |$)" $mkfile.in sub/$mkfile.in
+
+$AUTOCONF
+./configure
+
+$FGREP "$magic1" mkfile.in && Exit 1 # Sanity check.
+
+# Two code paths in configure.am:
+
+# - either a file in $(am__configure_deps) has been updated ...
+$sleep
+echo "AC_SUBST([FOO])" >> configure.ac
+$MAKE -f $mkfile
+$FGREP FOO $mkfile # For debugging.
+$FGREP $magic1 $mkfile
+
+# - ... or not; i.e., Makefile.am or an included file has.
+$sleep
+echo "# $magic2" >> $mkfile.am
+echo "# $magic3" >> sub/$mkfile.am
+$MAKE -f $mkfile
+$FGREP $magic2 $mkfile
+$FGREP $magic3 sub/$mkfile
+
+:
diff --git a/t/remake-am-pr10111.sh b/t/remake-am-pr10111.sh
new file mode 100755
index 000000000..c56760842
--- /dev/null
+++ b/t/remake-am-pr10111.sh
@@ -0,0 +1,62 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that our remake rules doesn't give spurious successes in
+# some corner case situations where they should actually fail.
+# See automake bug#10111.
+# To be clear, we are speaking about *very* corner-case situations here,
+# and the fact that the remake rules might get confused in them is not a
+# big deal in practice (in fact, this test *currently fails*). Still,
+# keeping the limitation exposed is a good idea anyway.
+
+. ./defs || Exit 1
+
+cat >> configure.ac <<'END'
+AC_OUTPUT
+END
+
+: > foobar.am
+
+cat > Makefile.am <<'END'
+include $(srcdir)/foobar.am
+$(srcdir)/foobar.am:
+## Creative quoting is to avoid spurious matches in the grepping
+## of Makefile.in, later.
+ echo "mu =" foobar "was here =" > $@
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+
+# OK, so the developer wants to interactively try out how the
+# "distributed form" of his package behaves.
+$MAKE distdir
+cd $distdir
+# He's interested in trying out a VPATH build.
+mkdir build
+cd build
+../configure
+# He wants to verify that the rules he's written to rebuild a file
+# included by configure.ac works also in VPATH builds.
+rm -f ../foobar.am
+$MAKE
+grep '= foobar was here =' ../Makefile.in
+$MAKE distcheck
+
+:
diff --git a/t/remake-deleted-am-2.sh b/t/remake-deleted-am-2.sh
new file mode 100755
index 000000000..1d048be04
--- /dev/null
+++ b/t/remake-deleted-am-2.sh
@@ -0,0 +1,75 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that inclusion of '.am' fragments by automake does not suffer
+# of the "deleted header problem". This test checks deeper inclusion
+# stacks, and use VPATH builds.
+
+. ./defs || Exit 1
+
+echo AC_OUTPUT >> configure.ac
+
+$ACLOCAL
+$AUTOCONF
+
+cat > Makefile.am <<'END'
+include $(srcdir)/foo.am
+END
+
+cat > foo.am <<'END'
+# this is foo
+include sub/bar.am
+include baz.am
+END
+
+mkdir sub
+echo 'include $(top_srcdir)/sub/zardoz.am' > sub/bar.am
+echo '# this is zardoz' > sub/zardoz.am
+
+echo 'include fnord.am' > baz.am
+echo '# you are not seeing this' > fnord.am
+
+$AUTOMAKE
+# Sanity checks.
+$FGREP 'this is zardoz' Makefile.in
+$FGREP 'you are not seeing this' Makefile.in
+
+mkdir build
+cd build
+
+srcdir=..
+
+$srcdir/configure
+$MAKE
+
+$sleep
+echo '# this is baz' > $srcdir/baz.am
+rm -f $srcdir/fnord.am
+$MAKE
+# Sanity checks.
+$FGREP 'you are not seeing this' $srcdir/Makefile.in Makefile && Exit 1
+$FGREP 'this is baz' $srcdir/Makefile.in
+$FGREP 'this is baz' Makefile
+
+$sleep
+rm -rf $srcdir/sub $srcdir/foo.am $srcdir/baz.am
+echo '# no more inclusions' > $srcdir/Makefile.am
+$MAKE
+# Sanity checks.
+$EGREP 'this is (foo|bar|baz)' Makefile $srcdir/Makefile.in && Exit 1
+$FGREP 'no more inclusions' Makefile
+
+:
diff --git a/t/remake-deleted-am-subdir.sh b/t/remake-deleted-am-subdir.sh
new file mode 100755
index 000000000..3ca850730
--- /dev/null
+++ b/t/remake-deleted-am-subdir.sh
@@ -0,0 +1,77 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that inclusion of '.am' fragments by automake does not suffer
+# of the "deleted header problem". This test does the check when the
+# SUBDIRS variable is involved.
+
+. ./defs || Exit 1
+
+cat >> configure.ac <<'END'
+AC_CONFIG_FILES([sub1/Makefile sub2/Makefile])
+AC_OUTPUT
+END
+
+$ACLOCAL
+$AUTOCONF
+
+cat > Makefile.am <<'END'
+include foo.am
+SUBDIRS = sub1 sub2
+END
+
+echo '# this is foo.am' > foo.am
+
+mkdir sub1 sub2
+
+echo 'include $(srcdir)/bar.am' > sub1/Makefile.am
+echo '# this is bar.am' > sub1/bar.am
+
+echo 'include $(top_srcdir)/foo.am' > sub2/Makefile.am
+
+$AUTOMAKE
+# Sanity checks.
+$FGREP 'this is foo.am' Makefile.in
+$FGREP 'this is bar.am' sub1/Makefile.in
+$FGREP 'this is foo.am' sub2/Makefile.in
+
+./configure
+$MAKE # Should be no-op.
+
+$sleep
+echo '# this is sub1/Makefile.am' > sub1/Makefile.am
+rm -f sub1/bar.am
+$MAKE all
+# Sanity checks.
+$FGREP 'this is bar' sub1/Makefile.in sub1/Makefile && Exit 1
+$FGREP 'this is sub1/Makefile.am' sub1/Makefile.in
+$FGREP 'this is sub1/Makefile.am' sub1/Makefile
+
+$sleep
+for d in . sub2; do
+ sed "s|.*include.*foo\.am.*|# this is $d/Makefile.am|" $d/Makefile.am > t
+ mv -f t $d/Makefile.am
+done
+rm -f foo.am
+$MAKE all
+# Sanity checks.
+$FGREP 'this is foo' sub*/Makefile* Makefile* && Exit 1
+for d in . sub1 sub2; do
+ $FGREP "this is $d/Makefile.am" $d/Makefile.in
+ $FGREP "this is $d/Makefile.am" $d/Makefile
+done
+
+:
diff --git a/t/remake-deleted-am.sh b/t/remake-deleted-am.sh
new file mode 100755
index 000000000..4bd77d6fc
--- /dev/null
+++ b/t/remake-deleted-am.sh
@@ -0,0 +1,67 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that inclusion of '.am' fragments by automake does not suffer
+# of the "deleted header problem". Basic checks are done here.
+
+. ./defs || Exit 1
+
+echo AC_OUTPUT >> configure.ac
+
+$ACLOCAL
+$AUTOCONF
+
+cat > Makefile.am <<'END'
+include foo.am
+include $(srcdir)/bar.am
+include $(top_srcdir)/baz.am
+END
+
+echo '# this is foo' > foo.am
+echo '# this is bar' > bar.am
+echo '# this is baz' > baz.am
+
+$AUTOMAKE
+# Sanity checks.
+$FGREP 'this is foo' Makefile.in
+$FGREP 'this is bar' Makefile.in
+$FGREP 'this is baz' Makefile.in
+
+./configure
+$MAKE # Should be no-op.
+
+$sleep
+sed '/^include foo\.am$/d' Makefile.am > t
+mv -f t Makefile.am
+rm -f foo.am
+$MAKE Makefile
+# Sanity checks.
+$FGREP 'this is foo' Makefile.in Makefile && Exit 1
+$FGREP 'this is bar' Makefile.in
+$FGREP 'this is bar' Makefile
+$FGREP 'this is baz' Makefile.in
+$FGREP 'this is baz' Makefile
+
+$sleep
+echo '# empty empty' > Makefile.am
+rm -f bar.am baz.am
+$MAKE Makefile
+# Sanity checks.
+$FGREP 'empty empty' Makefile.in
+$FGREP 'empty empty' Makefile
+grep 'this is ba[rz]' Makefile Makefile.in && Exit 1
+
+:
diff --git a/t/remake-deleted-m4-file.sh b/t/remake-deleted-m4-file.sh
new file mode 100755
index 000000000..975d50374
--- /dev/null
+++ b/t/remake-deleted-m4-file.sh
@@ -0,0 +1,74 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Test remake rules when an m4 file gets removed and the macros it
+# defined get inlined into the caller. Try with both an indirect
+# call and a direct one. This can be seen as testing the "deleted
+# header file" issue w.r.t. aclocal.m4 dependencies. See also related
+# test 'acloca22.test'.
+
+. ./defs || Exit 1
+
+cat >> configure.ac <<'END'
+FOO_MACRO
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+ACLOCAL_AMFLAGS = -I m4
+.PHONY: test
+test:
+ test '$(the_answer)' -eq 42
+END
+
+macro_value='the_answer=42; AC_SUBST([the_answer])'
+
+mkdir m4
+
+cat > m4/foo.m4 <<'END'
+AC_DEFUN([FOO_MACRO], [BAR_MACRO])
+END
+
+cat > m4/bar.m4 <<END
+AC_DEFUN([BAR_MACRO], [$macro_value])
+END
+
+$ACLOCAL -I m4
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+$MAKE test
+
+$sleep
+
+sed -e "s|BAR_MACRO|$macro_value|" m4/foo.m4 > t
+mv -f t m4/foo.m4
+rm -f m4/bar.m4
+
+using_gmake || $MAKE Makefile
+$MAKE test
+
+$sleep
+
+sed -e "s|FOO_MACRO|$macro_value|" configure.ac > t
+mv -f t configure.ac
+rm -f m4/foo.m4
+
+using_gmake || $MAKE Makefile
+$MAKE test
+
+:
diff --git a/t/remake-gnulib-add-acsubst.sh b/t/remake-gnulib-add-acsubst.sh
new file mode 100755
index 000000000..23a02bc18
--- /dev/null
+++ b/t/remake-gnulib-add-acsubst.sh
@@ -0,0 +1,133 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Test remake rules when a new AC_SUBST'd variable is added, and C header
+# files are involved.
+# This test overlaps with others, and is not strictly necessary per se,
+# but it exercises a real use case (from gnulib, see:
+# <http://lists.gnu.org/archive/html/bug-gnulib/2011-04/msg00005.html>
+# for more info).
+
+required=cc
+. ./defs || Exit 1
+
+cat >> configure.ac <<'END'
+AC_PROG_CC
+MY_MACROS
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+ACLOCAL_AMFLAGS = -I m4
+noinst_PROGRAMS = foo
+foo_SOURCES = foo.c
+BUILT_SOURCES = foo.h
+edit_h = sed -e 's|[@]foovar@|@foovar@|g'
+foo.h: foo.in.h
+ $(edit_h) < $(srcdir)/foo.in.h > $@-t
+ cat $@-t;: For debugging.
+ mv -f $@-t $@
+EXTRA_DIST = foo.in.h
+MOSTLYCLEANFILES = foo.h foo.h-t
+END
+
+mkdir m4
+
+cat > m4/foo.m4 <<'END'
+AC_DEFUN([MY_MACROS], [
+ FOO_MACRO
+dnl: ZAP_MACRO
+])
+END
+
+cat > m4/bar.m4 <<'END'
+AC_DEFUN([FOO_MACRO], [
+ foovar=42; AC_SUBST([foovar])
+dnl: barvar=47; AC_SUBST([barvar])
+])
+END
+
+cat > foo.in.h <<'END'
+#define foo @foovar@
+END
+
+cat > foo.c <<'END'
+#include "foo.h"
+int main (void) { return 0; }
+typedef int checkfoo[1 - 2 * (foo != 42)];
+END
+
+$ACLOCAL -I m4
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+$MAKE
+
+: AC_SUBST @barvar@ and add it to foo.h.
+
+$sleep
+
+sed -e 's/^dnl:/ /' m4/bar.m4 > t
+mv -f t m4/bar.m4
+cat m4/bar.m4
+
+cat >> foo.in.h <<'END'
+#define bar @barvar@
+END
+
+cat >> foo.c <<'END'
+typedef int checkbar[1 - 2 * (bar != 47)];
+END
+
+cat >> Makefile.am <<'END'
+edit_h += -e 's|[@]barvar@|@barvar@|g'
+END
+
+using_gmake || $MAKE Makefile
+$MAKE
+
+: AC_SUBST @zapvar@ and add it to foo.h.
+# Do it in a slightly different way from how it was done for @barvar@.
+
+$sleep
+
+cat >> Makefile.am <<'END'
+edit_h += -e 's|[@]zapvar@|$(zapvar)|g'
+END
+
+cat >> foo.c <<'END'
+typedef int checkzap[1 - 2 * (zap != 163)];
+END
+
+sed -e 's/^dnl://' m4/foo.m4 > t
+mv -f t m4/foo.m4
+cat m4/foo.m4
+
+cat >> foo.in.h <<'END'
+#define zap @zapvar@
+END
+
+cat >> m4/bar.m4 <<'END'
+AC_DEFUN([ZAP_MACRO], [zapvar=163; AC_SUBST([zapvar])])
+END
+
+using_gmake || $MAKE Makefile
+$MAKE
+
+$MAKE distcheck
+
+:
diff --git a/t/remake-gnulib-add-header.sh b/t/remake-gnulib-add-header.sh
new file mode 100755
index 000000000..97f0c037e
--- /dev/null
+++ b/t/remake-gnulib-add-header.sh
@@ -0,0 +1,109 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Test remake rules when a new C header "guarded" by AC_SUBST'd
+# variables is added.
+# This test overlaps with others, and is not strictly necessary per se,
+# but it exercises a real use case (from gnulib, see:
+# <http://lists.gnu.org/archive/html/bug-gnulib/2011-04/msg00005.html>
+# for more info).
+
+required=cc
+. ./defs || Exit 1
+
+cat >> configure.ac <<'END'
+AC_CONFIG_HEADERS([config.h])
+AC_PROG_CC
+MY_MACROS
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+ACLOCAL_AMFLAGS = -I .
+noinst_PROGRAMS = foo
+foo_SOURCES = foo.c
+BUILT_SOURCES = $(STDIO_H)
+stdio.h: stdio.in.h
+ cp $(srcdir)/stdio.in.h $@
+MOSTLYCLEANFILES = stdio.h
+EXTRA_DIST = stdio.in.h
+check-local:
+ ls -l . $(srcdir)
+ if test -n '$(STDIO_H)'; then \
+ test -f stdio.h || exit 1; \
+ else \
+ test ! -f stdio.h || exit 1; \
+ fi
+END
+
+cat > macros.m4 <<'END'
+AC_DEFUN([MY_MACROS], [
+ override_stdio=false
+ if $override_stdio; then
+ STDIO_H=stdio.h
+ use_dummies=1
+ else
+ STDIO_H=
+ use_dummies=0
+ fi
+ AC_SUBST([STDIO_H])
+ AC_DEFINE_UNQUOTED([USE_DUMMIES], [$use_dummies],
+ [Whether to use dummy types.])
+])
+END
+
+cat > stdio.in.h <<'END'
+typedef struct dummyfile { void *p; } DUMMYFILE;
+END
+
+cat > foo.c <<'END'
+#include <config.h>
+#include <stdio.h>
+#if USE_DUMMIES
+DUMMYFILE *f;
+#else
+FILE *f;
+#endif
+int main () { return 0; }
+END
+
+$ACLOCAL -I .
+$AUTOHEADER
+$AUTOMAKE
+$AUTOCONF
+
+./configure
+
+$MAKE
+ls -l
+test ! -f stdio.h
+# Also try our build rules in a VPATH build.
+$MAKE distcheck
+
+# No need to sleep here: "./configure" and "make distcheck" above
+# have already slept enough.
+
+sed -e 's/^\( *override_stdio\)=.*$/\1=:/' macros.m4 > t
+mv -f t macros.m4
+
+using_gmake || $MAKE Makefile
+$MAKE
+ls -l
+test -f stdio.h
+# Also try our build rules in a VPATH build.
+$MAKE distcheck
+
+:
diff --git a/t/remake-gnulib-remove-header.sh b/t/remake-gnulib-remove-header.sh
new file mode 100755
index 000000000..04f341042
--- /dev/null
+++ b/t/remake-gnulib-remove-header.sh
@@ -0,0 +1,136 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Test remake rules when a C header "guarded" by AC_SUBST'd variables
+# is not needed anymore, or when it's needed again.
+# This test requires some user-level machinery, overlaps with other tests,
+# and is not strictly necessary per se, but it exercises a real, important
+# use case (from gnulib, see:
+# <http://lists.gnu.org/archive/html/bug-gnulib/2011-04/msg00005.html>
+# for more info).
+
+required=cc
+. ./defs || Exit 1
+
+cat >> configure.ac <<'END'
+AC_CONFIG_HEADERS([config.h])
+AC_PROG_CC
+MY_MACROS
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+ACLOCAL_AMFLAGS = -I .
+noinst_PROGRAMS = foo
+foo_SOURCES = foo.c
+BUILT_SOURCES = $(STDIO_H)
+if REPLACE_STDIO_H
+stdio.h: stdio.in.h $(top_builddir)/config.status
+ cp $(srcdir)/stdio.in.h $@
+else
+stdio.h: $(top_builddir)/config.status
+ rm -f $@
+endif
+MOSTLYCLEANFILES = stdio.h
+END
+
+cat > macros.m4 <<'END'
+AC_DEFUN([MY_MACROS], [
+ override_stdio=:
+ if $override_stdio; then
+ STDIO_H=stdio.h
+ use_dummies=1
+ else
+ STDIO_H=
+ use_dummies=0
+ fi
+ AC_SUBST([STDIO_H])
+ AC_DEFINE_UNQUOTED([USE_DUMMIES], [$use_dummies],
+ [Whether to use dummy types.])
+ AM_CONDITIONAL([REPLACE_STDIO_H], [test -n "$STDIO_H"])
+])
+END
+
+cat > stdio.in.h <<'END'
+typedef struct dummyfile { void *p; } DUMMYFILE;
+END
+
+cat > foo.c <<'END'
+#include <config.h>
+#include <stdio.h>
+#if USE_DUMMIES
+DUMMYFILE *f;
+#else
+FILE *f;
+#endif
+int main () { return 0; }
+END
+
+$ACLOCAL -I .
+$AUTOHEADER
+$AUTOMAKE
+$AUTOCONF
+
+for vpath in : false; do
+
+ if $vpath; then
+ mkdir build
+ cd build
+ srcdir=..
+ else
+ srcdir=.
+ fi
+
+ # Do not reject slow dependency extractors: we need dependency tracking.
+ $srcdir/configure --enable-dependency-tracking
+ if $FGREP 'depmode=none' Makefile; then
+ skip_ "automatic dependency tracking couldn't be activated"
+ fi
+
+ $MAKE
+ ls -l
+ test -f stdio.h
+
+ # Simulate that we don't need our custom stdio.h anymore.
+
+ $sleep
+ sed -e 's/^\( *override_stdio\)=.*$/\1=false/' $srcdir/macros.m4 > t
+ diff $srcdir/macros.m4 t && fatal_ "failed to edit macros.m4"
+ mv -f t $srcdir/macros.m4
+
+ using_gmake || $MAKE Makefile
+ $MAKE
+ ls -l
+ test ! -f stdio.h
+
+ # And now simulate that we want our custom stdio.h back.
+
+ $sleep
+ sed -e 's/^\( *override_stdio\)=.*$/\1=:/' $srcdir/macros.m4 > t
+ diff $srcdir/macros.m4 t && fatal_ "failed to edit macros.m4"
+ mv -f t $srcdir/macros.m4
+
+ using_gmake || $MAKE Makefile
+ $MAKE
+ ls -l
+ test -f stdio.h
+
+ $MAKE distclean
+ cd $srcdir
+
+done
+
+:
diff --git a/t/remake-m4-pr10111.sh b/t/remake-m4-pr10111.sh
new file mode 100755
index 000000000..09a2a4c9f
--- /dev/null
+++ b/t/remake-m4-pr10111.sh
@@ -0,0 +1,60 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that our remake rules doesn't give spurious successes in
+# some corner case situations where they should actually fail.
+# See automake bug#10111.
+# To be clear, we are speaking about *very* corner-case situations here,
+# and the fact that the remake rules might get confused in them is not a
+# big deal in practice (in fact, this test *currently fails*). Still,
+# keeping the limitation exposed is a good idea anyway.
+
+. ./defs || Exit 1
+
+cat >> configure.ac <<'END'
+m4_include([foobar.m4])
+AC_OUTPUT
+END
+
+: > foobar.m4
+
+cat > Makefile.am <<'END'
+$(srcdir)/foobar.m4:
+ echo ': foobar was here :' > $@
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+
+# OK, so the developer wants to interactively try out how the
+# "distributed form" of his package behaves.
+$MAKE distdir
+cd $distdir
+# He's interested in trying out a VPATH build.
+mkdir build
+cd build
+../configure
+# He wants to verify that the rules he's written to rebuild a file
+# included by configure.ac works also in VPATH builds.
+rm -f ../foobar.m4
+$MAKE
+grep ': foobar was here :' ../configure
+$MAKE distcheck
+
+:
diff --git a/t/remake-moved-m4-file.sh b/t/remake-moved-m4-file.sh
new file mode 100755
index 000000000..d5a12639f
--- /dev/null
+++ b/t/remake-moved-m4-file.sh
@@ -0,0 +1,76 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Test remake rules when m4 files get moved among different "include
+# dirs" (i.e. those passed to aclocal with '-I' option).
+
+. ./defs || Exit 1
+
+cat >> configure.ac <<'END'
+MY_MACRO
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+ACLOCAL_AMFLAGS = -I d1 -I d2 -I d3
+.PHONY: test
+test:
+ test '$(the_answer)' -eq 42
+END
+
+mkdir d1 d2 d3
+
+cat > d1/macros.m4 <<'END'
+AC_DEFUN([MY_MACRO], [FOO])
+END
+
+cat > d1/foo.m4 <<'END'
+AC_DEFUN([FOO], [the_answer=42; AC_SUBST([the_answer])])
+END
+
+$ACLOCAL -I d1
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+$MAKE test
+
+# Move one file.
+mv d1/foo.m4 d2/foo.m4
+using_gmake || $MAKE Makefile
+$MAKE test
+$MAKE distdir
+ls -l $distdir $distdir/*
+test -f $distdir/d2/foo.m4
+test ! -f $distdir/d1/foo.m4
+test -f $distdir/d1/macros.m4
+test ! -f $distdir/d2/macros.m4
+
+# Move both files at once.
+mv d1/macros.m4 d3/macros.m4
+mv d2/foo.m4 d3/foo.m4
+using_gmake || $MAKE Makefile
+$MAKE test
+$MAKE distdir
+ls -l $distdir $distdir/*
+test -f $distdir/d3/foo.m4
+test -f $distdir/d3/macros.m4
+test ! -f $distdir/d1/foo.m4
+test ! -f $distdir/d2/foo.m4
+test ! -f $distdir/d1/macros.m4
+test ! -f $distdir/d2/macros.m4
+
+:
diff --git a/t/remake-renamed-am.sh b/t/remake-renamed-am.sh
new file mode 100755
index 000000000..f1106f48e
--- /dev/null
+++ b/t/remake-renamed-am.sh
@@ -0,0 +1,58 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that inclusion of '.am' fragments by automake does not suffer
+# of the "deleted header problem". This test checks that we can rename
+# an included .am file without confusing the remake rules.
+
+. ./defs || Exit 1
+
+echo AC_OUTPUT >> configure.ac
+
+cat > Makefile.am <<'END'
+include foo.am
+END
+
+cat > foo.am <<'END'
+all-local:
+ echo ok > has-run-1
+END
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+
+./configure
+$MAKE
+test -f has-run-1
+
+$sleep
+rm -f has-run-1
+mv -f foo.am bar.am
+echo include bar.am > Makefile.am
+$MAKE Makefile
+$FGREP 'foo.am' Makefile Makefile.in && Exit 1
+
+$sleep
+rm -f has-run-1 bar.am
+echo 'all-local:; echo ok > has-run-2' > zardoz.am
+echo 'include $(srcdir)/zardoz.am' > Makefile.am
+using_gmake || $MAKE Makefile
+$MAKE
+test ! -f has-run-1
+test -f has-run-2
+
+:
diff --git a/t/remake-renamed-m4-file.sh b/t/remake-renamed-m4-file.sh
new file mode 100755
index 000000000..87721f55d
--- /dev/null
+++ b/t/remake-renamed-m4-file.sh
@@ -0,0 +1,83 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Test remake rules when m4 files get renamed.
+
+. ./defs || Exit 1
+
+cat >> configure.ac <<'END'
+MY_MACRO
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+ACLOCAL_AMFLAGS = -I m4
+.PHONY: test
+test:
+ test '$(the_answer)' -eq 42
+END
+
+mkdir m4
+
+cat > m4/macros.m4 <<'END'
+AC_DEFUN([MY_MACRO], [FOO])
+END
+
+cat > m4/foo.m4 <<'END'
+AC_DEFUN([FOO], [the_answer=42; AC_SUBST([the_answer])])
+END
+
+$ACLOCAL -I m4
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+$MAKE test
+
+# Rename one file at the time.
+
+mv m4/foo.m4 m4/bar.m4
+using_gmake || $MAKE Makefile
+$MAKE test
+$MAKE distdir
+ls -l $distdir $distdir/*
+test -f $distdir/m4/bar.m4
+test ! -f $distdir/m4/foo.m4
+
+mv m4/macros.m4 m4/defs.m4
+using_gmake || $MAKE Makefile
+$MAKE test
+$MAKE distdir
+ls -l $distdir $distdir/*
+test -f $distdir/m4/defs.m4
+test ! -f $distdir/m4/macros.m4
+
+# Rename both files at once.
+
+mv m4/bar.m4 m4/quux.m4
+mv m4/defs.m4 acinclude.m4
+using_gmake || $MAKE Makefile
+$MAKE test
+$MAKE distdir
+ls -l $distdir $distdir/*
+test -f $distdir/m4/quux.m4
+test -f $distdir/acinclude.m4
+test ! -f $distdir/m4/foo.m4
+test ! -f $distdir/m4/bar.m4
+test ! -f $distdir/m4/macros.m4
+test ! -f $distdir/m4/defs.m4
+
+:
diff --git a/t/remake-renamed-m4-macro-and-file.sh b/t/remake-renamed-m4-macro-and-file.sh
new file mode 100755
index 000000000..9f80b31c7
--- /dev/null
+++ b/t/remake-renamed-m4-macro-and-file.sh
@@ -0,0 +1,86 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Test remake rules when an m4 file gets renamed and *simultaneously*
+# an m4 macro in it gets renamed. Kudos to Bruno Haible for thinking
+# about this situation. See also related test 'acloca22.test'.
+
+. ./defs || Exit 1
+
+cat >> configure.ac <<'END'
+MY_MACRO
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+ACLOCAL_AMFLAGS = -I m4
+.PHONY: test
+test:
+ test '$(the_answer)' -eq 42
+END
+
+mkdir m4
+
+cat > m4/macros.m4 <<'END'
+AC_DEFUN([MY_MACRO], [FOO_MACRO])
+END
+
+cat > m4/foo.m4 <<'END'
+AC_DEFUN([FOO_MACRO], [the_answer=42; AC_SUBST([the_answer])])
+END
+
+$ACLOCAL -I m4
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+$MAKE test
+
+# Rename only one file and one macro.
+
+$sleep
+sed -e 's/FOO_MACRO/BAR_MACRO/' m4/foo.m4 > m4/bar.m4
+rm -f m4/foo.m4
+sed -e 's/FOO_MACRO/BAR_MACRO/' m4/macros.m4 > t
+mv -f t m4/macros.m4
+using_gmake || $MAKE Makefile
+$MAKE test
+$MAKE distdir
+ls -l $distdir $distdir/*
+test -f $distdir/m4/bar.m4
+test -f $distdir/m4/macros.m4
+test ! -f $distdir/m4/foo.m4
+
+# Rename both at once.
+
+$sleep
+sed -e 's/BAR_MACRO/QUUX_MACRO/' \
+ m4/bar.m4 > m4/quux.m4
+sed -e 's/BAR_MACRO/QUUX_MACRO/' -e 's/MY_MACRO/A_MACRO/' \
+ m4/macros.m4 > m4/defs.m4
+rm -f m4/macros.m4 m4/bar.m4
+sed -e 's/BAR_MACRO/QUUX_MACRO/' -e 's/MY_MACRO/A_MACRO/' configure.ac > t
+mv -f t configure.ac
+using_gmake || $MAKE Makefile
+$MAKE test
+$MAKE distdir
+ls -l $distdir $distdir/*
+test -f $distdir/m4/quux.m4
+test -f $distdir/m4/defs.m4
+test ! -f $distdir/m4/bar.m4
+test ! -f $distdir/m4/macros.m4
+
+:
diff --git a/t/remake-renamed-m4-macro.sh b/t/remake-renamed-m4-macro.sh
new file mode 100755
index 000000000..5ec71d692
--- /dev/null
+++ b/t/remake-renamed-m4-macro.sh
@@ -0,0 +1,72 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Test remake rules when the name of an m4 macro change. Try both with
+# and without indirection.
+
+. ./defs || Exit 1
+
+cat >> configure.ac <<'END'
+MY_MACRO
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+ACLOCAL_AMFLAGS = -I m4
+.PHONY: test
+test:
+ test '$(the_answer)' -eq 42
+END
+
+mkdir m4
+
+cat > m4/macros.m4 <<'END'
+AC_DEFUN([MY_MACRO], [FOO_1])
+END
+
+cat > m4/foo.m4 <<'END'
+AC_DEFUN([FOO_1], [the_answer=42
+ AC_SUBST([the_answer])])
+END
+
+$ACLOCAL -I m4
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+$MAKE test
+
+$sleep
+
+for x in macros foo; do
+ sed -e 's/FOO_1/FOO_2/' m4/$x.m4 > t
+ mv -f t m4/$x.m4
+done
+
+using_gmake || $MAKE Makefile
+$MAKE test
+
+$sleep
+
+for f in m4/macros.m4 configure.ac; do
+ sed -e 's/MY_MACRO/YOUR_MACRO/' $f > t
+ mv -f t $f
+done
+
+using_gmake || $MAKE Makefile
+$MAKE test
+
+:
diff --git a/t/remake-subdir-from-subdir.sh b/t/remake-subdir-from-subdir.sh
new file mode 100755
index 000000000..a5053e07c
--- /dev/null
+++ b/t/remake-subdir-from-subdir.sh
@@ -0,0 +1,56 @@
+#! /bin/sh
+# Copyright (C) 2009-2012 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/>.
+
+# Check that remake rules works for adding a new subdirectory from a
+# pre-existing subdirectory.
+# See also the other similar tests 'remake-subdir*.test', and the
+# related test 'aclocal5.test'.
+
+. ./defs || Exit 1
+
+cat >> configure.ac <<'END'
+m4_include([subdirs.m4])
+AC_SUBST([MAGIC], [magic])
+AC_OUTPUT
+END
+
+echo 'AC_CONFIG_FILES([sub/Makefile])' > subdirs.m4
+echo 'SUBDIRS = sub' > Makefile.am
+
+mkdir sub
+: > sub/Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+$MAKE
+
+cd sub
+$sleep
+echo 'AC_CONFIG_FILES([sub/subsub/Makefile])' >> ../subdirs.m4
+echo 'SUBDIRS = subsub' >> Makefile.am
+mkdir subsub
+cat > subsub/Makefile.am <<'END'
+all-local:
+ : > ok-it-works
+END
+using_gmake || $MAKE Makefile
+$MAKE
+test -f subsub/ok-it-works
+
+:
diff --git a/t/remake-subdir-gnu.sh b/t/remake-subdir-gnu.sh
new file mode 100755
index 000000000..116790f46
--- /dev/null
+++ b/t/remake-subdir-gnu.sh
@@ -0,0 +1,80 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that remake rules works from subdirectories, even using
+# 'GNUmakefile' as makefiles name. This obviously requires GNU
+# make.
+# See also the other similar tests 'remake-subdir*.test', and the
+# related test 'aclocal5.test'
+
+required=GNUmake
+. ./defs || Exit 1
+
+magic1='::MagicString::One::'
+magic2='__MagicString__Two__'
+
+debug_info ()
+{
+ grep -i magic configure GNUmakefile.in GNUmakefile \
+ sub/GNUmakefile.in sub/GNUmakefile
+}
+
+cat > configure.ac <<END
+AC_INIT([$me], [1.0])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([GNUmakefile sub/GNUmakefile])
+AC_SUBST([MAGIC], [magic])
+AC_OUTPUT
+END
+
+cat > GNUmakefile.am <<'END'
+SUBDIRS = sub
+END
+
+mkdir sub
+: > sub/GNUmakefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+$MAKE
+debug_info
+
+$sleep
+sed "s|magic|$magic1|" configure.ac > t
+mv -f t configure.ac
+cd sub
+$MAKE
+cd ..
+debug_info
+$FGREP $magic1 configure
+$FGREP $magic1 GNUmakefile
+$FGREP $magic1 sub/GNUmakefile
+
+$sleep
+cd sub
+echo MAGIC = $magic2 >> GNUmakefile.am
+$MAKE
+cd ..
+debug_info
+$FGREP $magic2 sub/GNUmakefile
+$FGREP $magic2 sub/GNUmakefile.in
+$FGREP $magic1 sub/GNUmakefile sub/GNUmakefile.in && Exit 1
+$FGREP $magic2 GNUmakefile GNUmakefile.in && Exit 1
+
+:
diff --git a/t/remake-subdir-long-time.sh b/t/remake-subdir-long-time.sh
new file mode 100755
index 000000000..8f3174025
--- /dev/null
+++ b/t/remake-subdir-long-time.sh
@@ -0,0 +1,114 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that remake rules from subdirectories do not hang or cycle
+# endlessly, even with build systems that takes several seconds to
+# rebuild the Makefiles.
+# This test tries to ensure a long-enough rebuild time by introducing
+# an explicit delay in the build process.
+# Suggestion by Ralf Wildenhues.
+
+. ./defs || Exit 1
+
+cat > configure.ac <<END
+AC_INIT([$me], [1.0])
+AM_INIT_AUTOMAKE([foreign -Wall -Werror])
+AC_CONFIG_FILES([Makefile sub/Makefile])
+AC_SUBST([MAGIC], [magic])
+AC_OUTPUT
+END
+
+echo SUBDIRS = sub > Makefile.am
+mkdir sub
+: > sub/Makefile.am
+
+# Both aclocal and automake are expected to run one and just one time.
+# Create and use wrappers that will verify that.
+
+ocwd=`pwd` || fatal_ "cannot get current working directory"
+
+mkdir bin
+
+cat > bin/automake <<END
+#!/bin/sh
+set -e
+PATH='$PATH'; export PATH
+sentinel='$ocwd/automake-has-run'
+if test -f "\$sentinel"; then
+ echo "Automake has been run more than one time" >&2
+ exit 1
+else
+ echo automake has run > "\$sentinel"
+fi
+$sleep; $sleep;
+exec $AUTOMAKE \${1+"\$@"}
+END
+chmod a+x bin/automake
+
+cat > bin/aclocal <<END
+#!/bin/sh
+set -e
+PATH='$PATH'; export PATH
+sentinel='$ocwd/aclocal-has-run'
+if test -f "\$sentinel"; then
+ echo "Aclocal has been run more than one time" >&2
+ exit 1
+else
+ echo aclocal has run > "\$sentinel"
+fi
+$sleep; $sleep;
+exec $ACLOCAL \${1+"\$@"}
+END
+chmod a+x bin/aclocal
+
+# Just to be sure.
+cp bin/automake bin/automake-$APIVERSION
+cp bin/aclocal bin/aclocal-$APIVERSION
+
+PATH=$ocwd/bin$PATH_SEPARATOR$PATH; export PATH
+
+AUTOMAKE=automake ACLOCAL=aclocal; export AUTOMAKE ACLOCAL
+
+$ACLOCAL # Should use or just-defined wrapper.
+$AUTOMAKE # Likewise.
+$AUTOCONF
+
+# Sanity check: the wrappers have been used.
+test -f automake-has-run
+test -f aclocal-has-run
+rm -f automake-has-run aclocal-has-run
+
+./configure
+# Sanity check: Makefile doesn't get updated uselessly.
+ACLOCAL=false AUTOMAKE=false AUTOCONF=false $MAKE -e
+
+$sleep
+sed "s|magic|magic2|" configure.ac > t
+mv -f t configure.ac
+
+cd sub
+AUTOMAKE="$AUTOMAKE" ACLOCAL="$ACLOCAL" $MAKE -e Makefile
+cd ..
+
+# For debugging.
+ls -l . sub
+grep -i magic configure Makefile.in Makefile sub/Makefile.in sub/Makefile
+# Sanity checks.
+$FGREP magic2 configure
+$FGREP magic2 Makefile
+$FGREP magic2 sub/Makefile
+
+:
diff --git a/t/remake-subdir.sh b/t/remake-subdir.sh
new file mode 100755
index 000000000..eb21f382c
--- /dev/null
+++ b/t/remake-subdir.sh
@@ -0,0 +1,81 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that remake rules works from subdirectories, even with non-GNU
+# make implementations.
+# See also the other similar tests 'remake-subdir*.test', and the
+# related test 'aclocal5.test'.
+
+. ./defs || Exit 1
+
+if using_gmake; then
+ remake=$MAKE
+else
+ remake="$MAKE Makefile"
+fi
+
+magic1='::MagicString::One::'
+magic2='__MagicString__Two__'
+
+debug_info ()
+{
+ grep -i magic configure Makefile.in Makefile sub/Makefile.in sub/Makefile
+}
+
+cat >> configure.ac <<'END'
+AC_CONFIG_FILES([sub/Makefile])
+AC_SUBST([MAGIC], [magic])
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+SUBDIRS = sub
+END
+
+mkdir sub
+: > sub/Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+$MAKE
+debug_info
+
+$sleep
+sed "s|magic|$magic1|" configure.ac > t
+mv -f t configure.ac
+cd sub
+$remake
+cd ..
+debug_info
+$FGREP $magic1 configure
+$FGREP $magic1 Makefile
+$FGREP $magic1 sub/Makefile
+
+$sleep
+cd sub
+echo MAGIC = $magic2 >> Makefile.am
+$remake
+cd ..
+debug_info
+$FGREP $magic2 sub/Makefile
+$FGREP $magic2 sub/Makefile.in
+$FGREP $magic1 sub/Makefile sub/Makefile.in && Exit 1
+$FGREP $magic2 Makefile Makefile.in && Exit 1
+
+:
diff --git a/t/remake-subdir2.sh b/t/remake-subdir2.sh
new file mode 100755
index 000000000..0a5665d97
--- /dev/null
+++ b/t/remake-subdir2.sh
@@ -0,0 +1,82 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that remake rules works from subdirectories, even when makefiles
+# are not named "Makefile".
+# See also the other similar tests 'remake-subdir*.test', and the
+# related test 'aclocal5.test'.
+
+. ./defs || Exit 1
+
+magic1='::MagicString::One::'
+magic2='__MagicString__Two__'
+
+debug_info ()
+{
+ grep -i magic configure build.in build.mk sub/build.in sub/build.mk
+}
+
+cat > configure.ac <<END
+AC_INIT([$me], [1.0])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([build.mk:build.in])
+AC_CONFIG_FILES([sub/build.mk:sub/build.in])
+AC_SUBST([MAGIC], [magic])
+AC_OUTPUT
+END
+
+cat > build.am <<'END'
+AM_MAKEFLAGS = -f build.mk
+SUBDIRS = sub
+END
+
+mkdir sub
+cat > sub/build.am <<'END'
+AM_MAKEFLAGS = -f build.mk
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+ls -l # For debugging.
+
+$MAKE -f build.mk
+debug_info
+
+$sleep
+sed "s|magic|$magic1|" configure.ac > t
+mv -f t configure.ac
+cd sub
+$MAKE -f build.mk build.mk
+cd ..
+debug_info
+$FGREP $magic1 configure
+$FGREP $magic1 build.mk
+$FGREP $magic1 sub/build.mk
+
+$sleep
+cd sub
+echo MAGIC = $magic2 >> build.am
+$MAKE -f build.mk build.mk
+cd ..
+debug_info
+$FGREP $magic2 sub/build.mk
+$FGREP $magic2 sub/build.in
+$FGREP $magic1 sub/build.in sub/build.mk && Exit 1
+$FGREP $magic2 build.in build.mk && Exit 1
+
+:
diff --git a/t/remake.sh b/t/remake.sh
new file mode 100755
index 000000000..620d5f8de
--- /dev/null
+++ b/t/remake.sh
@@ -0,0 +1,38 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Weak "grepping" test trying to ensure that remaking rules in a subdir
+# are correctly generated.
+# See also sister functional test 'remake1a.test'.
+
+. ./defs || Exit 1
+
+cat > configure.ac <<END
+AC_INIT([$me], [1.0])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([sub/Makefile])
+AC_OUTPUT
+END
+
+mkdir sub
+: > sub/Makefile.am
+
+$ACLOCAL
+$AUTOMAKE
+
+grep '^Makefile' sub/Makefile.in
+
+:
diff --git a/t/remake10a.sh b/t/remake10a.sh
new file mode 100755
index 000000000..358554f3e
--- /dev/null
+++ b/t/remake10a.sh
@@ -0,0 +1,111 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Test remake rules for m4 files included (also recursively) by
+# configure.ac.
+# Keep in sync with sister tests 'remake10b.test' and 'remake10c.test'.
+
+. ./defs || Exit 1
+
+magic1=::MagicStringOne::
+magic2=__MagicStringTwo__
+magic3=%%MagicStringThree%%
+
+if using_gmake; then
+ remake="$MAKE nil"
+else
+ remake="$MAKE Makefile"
+fi
+
+cat >> configure.ac <<END
+m4_include([foo.m4])
+AC_SUBST([FINGERPRINT], [my_fingerprint])
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+.PHONY: nil
+nil:
+## Used by "make distcheck" later.
+check-local:
+ test -f $(top_srcdir)/foo.m4
+ test ! -r $(top_srcdir)/bar.m4
+ test x'$(FINGERPRINT)' = x'DummyValue'
+END
+
+echo 'm4_define([my_fingerprint], [BadBadBad])' > foo.m4
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+for vpath in : false; do
+
+ if $vpath; then
+ mkdir build
+ cd build
+ top_srcdir=..
+ else
+ top_srcdir=.
+ fi
+
+ $top_srcdir/configure
+ $MAKE # Should be a no-op.
+
+ $sleep
+ echo "m4_define([my_fingerprint], [$magic1])" > $top_srcdir/foo.m4
+ $remake
+ $FGREP FINGERPRINT Makefile # For debugging.
+ $FGREP $magic1 Makefile
+
+ $sleep
+ echo "m4_define([my_fingerprint], [$magic2])" > $top_srcdir/foo.m4
+ $remake
+ $FGREP FINGERPRINT Makefile # For debugging.
+ $FGREP $magic1 Makefile && Exit 1
+ $FGREP $magic2 Makefile
+
+ $sleep
+ echo "m4_include([bar.m4])" > $top_srcdir/foo.m4
+ echo "m4_define([my_fingerprint], [$magic3])" > $top_srcdir/bar.m4
+ $remake
+ $FGREP FINGERPRINT Makefile # For debugging.
+ $FGREP $magic1 Makefile && Exit 1
+ $FGREP $magic2 Makefile && Exit 1
+ $FGREP $magic3 Makefile
+
+ $sleep
+ echo "m4_define([my_fingerprint], [$magic1])" > $top_srcdir/bar.m4
+ $remake
+ $FGREP $magic2 Makefile && Exit 1
+ $FGREP $magic3 Makefile && Exit 1
+ $FGREP $magic1 Makefile
+
+ $sleep
+ echo "m4_define([my_fingerprint], [DummyValue])" > $top_srcdir/foo.m4
+ using_gmake || $remake
+ $MAKE distcheck
+ $FGREP $magic1 Makefile && Exit 1 # Sanity check.
+ $FGREP $magic2 Makefile && Exit 1 # Likewise.
+ $FGREP $magic3 Makefile && Exit 1 # Likewise.
+
+ $MAKE distclean
+
+ cd $top_srcdir
+
+done
+
+:
diff --git a/t/remake10b.sh b/t/remake10b.sh
new file mode 100755
index 000000000..9eeeb9d53
--- /dev/null
+++ b/t/remake10b.sh
@@ -0,0 +1,110 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Test remake rules for am files included (also recursively) by
+# Makefile.am.
+# Keep in sync with sister tests 'remake10a.test' and 'remake10c.test'.
+
+. ./defs || Exit 1
+
+magic1=::MagicStringOne::
+magic2=__MagicStringTwo__
+magic3=%%MagicStringThree%%
+
+if using_gmake; then
+ remake="$MAKE nil"
+else
+ remake="$MAKE Makefile"
+fi
+
+cat >> configure.ac <<'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+.PHONY: nil
+nil:
+include foo.am
+## Used by "make distcheck" later.
+check-local:
+ test -f $(top_srcdir)/foo.am
+ test ! -r $(top_srcdir)/bar.am
+ test x'$(FINGERPRINT)' = x'DummyValue'
+END
+
+echo 'FINGERPRINT = BadBadBad' > foo.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+for vpath in : false; do
+
+ if $vpath; then
+ mkdir build
+ cd build
+ top_srcdir=..
+ else
+ top_srcdir=.
+ fi
+
+ $top_srcdir/configure
+ $MAKE # Should be a no-op.
+
+ $sleep
+ echo "FINGERPRINT = $magic1" > $top_srcdir/foo.am
+ $remake
+ $FGREP FINGERPRINT Makefile # For debugging.
+ $FGREP $magic1 Makefile
+
+ $sleep
+ echo "FINGERPRINT = $magic2" > $top_srcdir/foo.am
+ $remake
+ $FGREP FINGERPRINT Makefile # For debugging.
+ $FGREP $magic1 Makefile && Exit 1
+ $FGREP $magic2 Makefile
+
+ $sleep
+ echo 'include $(top_srcdir)/bar.am' > $top_srcdir/foo.am
+ echo "FINGERPRINT = $magic3" > $top_srcdir/bar.am
+ $remake
+ $FGREP FINGERPRINT Makefile # For debugging.
+ $FGREP $magic1 Makefile && Exit 1
+ $FGREP $magic2 Makefile && Exit 1
+ $FGREP $magic3 Makefile
+
+ $sleep
+ echo "FINGERPRINT = $magic1" > $top_srcdir/bar.am
+ $remake
+ $FGREP $magic2 Makefile && Exit 1
+ $FGREP $magic3 Makefile && Exit 1
+ $FGREP $magic1 Makefile
+
+ $sleep
+ echo "FINGERPRINT = DummyValue" > $top_srcdir/foo.am
+ using_gmake || $remake
+ $MAKE distcheck
+ $FGREP $magic1 Makefile && Exit 1 # Sanity check.
+ $FGREP $magic2 Makefile && Exit 1 # Likewise.
+ $FGREP $magic3 Makefile && Exit 1 # Likewise.
+
+ $MAKE distclean
+
+ cd $top_srcdir
+
+done
+
+:
diff --git a/t/remake10c.sh b/t/remake10c.sh
new file mode 100755
index 000000000..dfb43f48e
--- /dev/null
+++ b/t/remake10c.sh
@@ -0,0 +1,114 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Test remake rules for m4 files included (also recursively) by
+# aclocal.m4.
+# Keep in sync with sister tests 'remake10a.test' and 'remake10b.test'.
+
+. ./defs || Exit 1
+
+magic1=::MagicStringOne::
+magic2=__MagicStringTwo__
+magic3=%%MagicStringThree%%
+
+if using_gmake; then
+ remake="$MAKE nil"
+else
+ remake="$MAKE Makefile"
+fi
+
+cat >> configure.ac <<END
+FINGERPRINT='my_fingerprint'
+AC_SUBST([FINGERPRINT])
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+ACLOCAL_AMFLAGS = -I m4
+.PHONY: nil
+nil:
+## Used by "make distcheck" later.
+check-local:
+ test -f $(top_srcdir)/m4/foo.m4
+ test ! -r $(top_srcdir)/m4/bar.m4
+ test x'$(FINGERPRINT)' = x'DummyValue'
+END
+
+mkdir m4
+echo 'AC_DEFUN([my_fingerprint], [BadBadBad])' > m4/foo.m4
+
+$ACLOCAL -I m4
+$AUTOCONF
+$AUTOMAKE
+
+for vpath in : false; do
+
+ if $vpath; then
+ mkdir build
+ cd build
+ top_srcdir=..
+ else
+ top_srcdir=.
+ fi
+
+ $top_srcdir/configure
+ $MAKE # Should be a no-op.
+
+ $sleep
+ echo "AC_DEFUN([my_fingerprint], [$magic1])" > $top_srcdir/m4/foo.m4
+ $remake
+ $FGREP FINGERPRINT Makefile # For debugging.
+ $FGREP $magic1 Makefile
+
+ $sleep
+ echo "AC_DEFUN([my_fingerprint], [$magic2])" > $top_srcdir/m4/foo.m4
+ $remake
+ $FGREP FINGERPRINT Makefile # For debugging.
+ $FGREP $magic1 Makefile && Exit 1
+ $FGREP $magic2 Makefile
+
+ $sleep
+ echo "m4_include([m4/bar.m4])" > $top_srcdir/m4/foo.m4
+ echo "AC_DEFUN([my_fingerprint], [$magic3])" > $top_srcdir/m4/bar.m4
+ $remake
+ $FGREP FINGERPRINT Makefile # For debugging.
+ $FGREP $magic1 Makefile && Exit 1
+ $FGREP $magic2 Makefile && Exit 1
+ $FGREP $magic3 Makefile
+
+ $sleep
+ echo "AC_DEFUN([my_fingerprint], [$magic1])" > $top_srcdir/m4/bar.m4
+ $remake
+ $FGREP $magic2 Makefile && Exit 1
+ $FGREP $magic3 Makefile && Exit 1
+ $FGREP $magic1 Makefile
+
+ $sleep
+ echo "AC_DEFUN([my_fingerprint], [DummyValue])" > $top_srcdir/m4/foo.m4
+ echo "AC_DEFUN([AM_UNUSED], [NoSuchMacro])" > $top_srcdir/m4/bar.m4
+ using_gmake || $remake
+ $MAKE distcheck
+ $FGREP $magic1 Makefile && Exit 1 # Sanity check.
+ $FGREP $magic2 Makefile && Exit 1 # Likewise.
+ $FGREP $magic3 Makefile && Exit 1 # Likewise.
+
+ $MAKE distclean
+
+ cd $top_srcdir
+
+done
+
+:
diff --git a/t/remake11.sh b/t/remake11.sh
new file mode 100755
index 000000000..ec96a0829
--- /dev/null
+++ b/t/remake11.sh
@@ -0,0 +1,81 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Test remake rules in deeply nested subdirectories, and with a lot
+# of files. This is basically a mild stress test, ensuring that rebuild
+# rules don't break in obvious ways in a slightly "heavier than usual"
+# setup.
+
+. ./defs || Exit 1
+
+ocwd=`pwd` || Exit 1
+
+magic1=::MagicStringOne::
+magic2=__MagicStringTwo__
+
+echo "AC_SUBST([FOO], [$magic1])" >> configure.ac
+
+echo "@FOO@" > bar.in
+echo "AC_CONFIG_FILES([bar])" >> configure.ac
+for i in 0 1 2 3 4 5 6 7 8 9; do
+ d=${d+"$d/"}sub$i
+ echo "SUBDIRS = sub$i" > Makefile.am
+ echo "AC_CONFIG_FILES([$d/Makefile])" >> "$ocwd"/configure.ac
+ echo "AC_CONFIG_FILES([$d/bar])" >> "$ocwd"/configure.ac
+ mkdir sub$i
+ cd sub$i
+ echo "$d: @FOO@" > bar.in
+done
+echo AC_OUTPUT >> "$ocwd"/configure.ac
+: > Makefile.am
+unset d i
+bottom=`pwd`
+
+cd "$ocwd"
+
+makefiles_am_list=`find . -name Makefile.am | LC_ALL=C sort`
+makefiles_list=`echo "$makefiles_am_list" | sed 's/\.am$//'`
+bar_in_list=`find . -name bar.in | LC_ALL=C sort`
+bar_list=`echo "$bar_in_list" | sed 's/\.in$//'`
+
+cat configure.ac # For debugging.
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+
+./configure
+
+for f in configure config.status $makefiles_list $bar_list; do
+ $FGREP "$magic1" $f
+done
+
+$sleep
+sed "s/$magic1/$magic2/" configure.ac >configure.tmp
+mv -f configure.tmp configure.ac
+
+cd "$bottom"
+$MAKE
+cd "$ocwd"
+
+for f in configure config.status $makefiles_list $bar_list; do
+ $FGREP "$magic2" $f
+done
+$FGREP "$magic1" configure config.status $makefiles_list $bar_list && Exit 1
+
+$MAKE distcheck
+
+:
diff --git a/t/remake12.sh b/t/remake12.sh
new file mode 100755
index 000000000..73d85d5b8
--- /dev/null
+++ b/t/remake12.sh
@@ -0,0 +1,146 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Test basic remake rules for Makefiles with non-default names
+# and/or with multiple sources.
+
+. ./defs || Exit 1
+
+magic1=::MagicStringOne::
+magic2=__MagicStringTwo__
+magic3=%%MagicStringThree%%
+
+# See if the user's make implementation support an include directive.
+# We need it in this test.
+echo 'all:; @echo include is supported' > incl.mk
+echo 'include incl.mk' > gnu-style.mk
+echo '.include "incl.mk"' > bsd-style.mk
+if $MAKE -f gnu-style.mk | grep 'include is supported'; then
+ echo "$me: GNU make include style supported"
+ include_zardoz='include zardoz'
+elif $MAKE -f bsd-style.mk | grep 'include is supported'; then
+ echo "$me: BSD make include style supported"
+ include_zardoz='.include "zardoz"'
+else
+ skip_ "make doesn't support any \"include\" directive"
+fi
+
+cat > configure.ac <<END
+AC_INIT([$me], [1.0])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([zardoz])
+AC_CONFIG_LINKS([Makefile:Makefile])
+AC_OUTPUT
+END
+
+cat > zardoz.am <<END
+EXTRA_DIST = Makefile
+#H: $magic1
+END
+
+cat > Makefile <<END
+$include_zardoz
+nil:
+.PHONY: nil
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+
+if using_gmake; then
+ $MAKE nil
+else
+ $MAKE Makefile
+fi
+grep '^#H:' zardoz.in # For debugging.
+$FGREP $magic1 zardoz
+$FGREP $magic1 zardoz.in
+$MAKE distcheck
+$MAKE distclean # This shouldn't remove Makefile.
+ls -l
+test -f Makefile
+
+./configure
+
+$sleep
+sed "s/%MAGIC3%/$magic3/" >> Makefile <<'END'
+my-check:
+ ls -l . $(srcdir) ;: For debugging.
+ test -f $(srcdir)/quux.am
+ test -f $(srcdir)/quux.in
+ test -f $(srcdir)/bot.in
+ test -f $(srcdir)/top.in
+ test ! -r $(srcdir)/zardoz.am
+ test ! -r $(srcdir)/zardoz.in
+ grep FOO zardoz ;: For debugging.
+ test x'$(FOO)' = x'%MAGIC3%'
+test:
+ ls -l ;: For debugging.
+ test x'$(FOO)' = x'dummy'
+.PHONY: test my-check
+END
+sed "s/^#H:.*/#H: $magic2/" zardoz.am > t
+cat >> t <<'END'
+# Used by "make distcheck" below.
+check-local: my-check
+END
+mv -f t zardoz.am
+cat zardoz.am # For debugging.
+if using_gmake; then
+ $MAKE nil
+else
+ $MAKE zardoz
+fi
+$FGREP my-check zardoz # Sanity check.
+$FGREP $magic1 zardoz zardoz.in && Exit 1
+$FGREP $magic2 zardoz
+$FGREP $magic2 zardoz.in
+
+./configure
+
+$sleep
+sed 's/^\(AC_CONFIG_FILES\)(.*/\1([zardoz:top.in:quux.in:bot.in])/' \
+ <configure.ac >t
+mv -f t configure.ac
+cat configure.ac # For debugging.
+sed '/^#H:/d' zardoz.am > quux.am
+echo 'FOO = dummy' >> quux.am
+echo 'BAR = $(BAZ)' > top.in
+echo "BAZ = $magic3" > bot.in
+is_gmake || $MAKE zardoz
+$MAKE test
+$FGREP my-check zardoz # Sanity check.
+$FGREP $magic3 quux.in && Exit 1
+$FGREP $magic3 zardoz
+$FGREP $magic1 zardoz && Exit 1
+$FGREP $magic2 zardoz && Exit 1
+# After the remake above, the files 'zardoz.am' and 'zardoz.in'
+# should be no more needed.
+echo 'endif' > zardoz.am # Put in a syntax error.
+is_gmake || $MAKE zardoz
+$MAKE test
+rm -f zardoz.in zardoz.am # Get rid of them.
+is_gmake || $MAKE zardoz
+$MAKE test
+
+echo 'FOO = $(BAR)' >> quux.am
+is_gmake || $MAKE zardoz
+$MAKE distcheck
+
+:
diff --git a/t/remake1a.sh b/t/remake1a.sh
new file mode 100755
index 000000000..fede0920a
--- /dev/null
+++ b/t/remake1a.sh
@@ -0,0 +1,55 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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 remaking rules in subdir are correctly generated.
+# See also sister "grepping" test 'remake.test'.
+
+. ./defs || Exit 1
+
+fingerprint='=/FiNgErPrInT/='
+
+cat > configure.ac <<END
+AC_INIT([$me], [1.0])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([sub/Makefile])
+AC_OUTPUT
+END
+
+mkdir sub
+: > sub/Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+
+# Rebuild rules should work even if there is no top-level
+# makefiles, if we are careful enough to trigger them only
+# in proper subdirs.
+$sleep
+echo "# $fingerprint" > sub/Makefile.am
+cd sub
+$MAKE Makefile
+cd ..
+# Check that no spurious Makefile has been created in the
+# top-level directory.
+test ! -r Makefile
+# Check that the Makefile in the subdirectory has been properly
+# updated.
+$FGREP "$fingerprint" sub/Makefile
+
+:
diff --git a/t/remake2.sh b/t/remake2.sh
new file mode 100755
index 000000000..228b14f56
--- /dev/null
+++ b/t/remake2.sh
@@ -0,0 +1,38 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Weak "grepping" test trying to ensure that remaking rules in subdir
+# are correct even when there is no upper-level Makefile.
+# TODO: we should really add also functional tests for this!
+
+. ./defs || Exit 1
+
+cat > configure.ac <<END
+AC_INIT([$me], [1.0])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([sub/Makefile])
+AC_OUTPUT
+END
+
+mkdir sub
+: > sub/Makefile.am
+
+$ACLOCAL
+$AUTOMAKE
+
+grep '\$(AUTOMAKE).*sub/Makefile' sub/Makefile.in
+
+:
diff --git a/t/remake3.sh b/t/remake3.sh
new file mode 100755
index 000000000..96294fb29
--- /dev/null
+++ b/t/remake3.sh
@@ -0,0 +1,38 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Weak "grepping" test trying to ensure that remake rules work for files
+# in a subdirectory even when there is no Makefile for that subdirectory.
+# See also sister functional test 'remake3a.test'.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_CONFIG_FILES([sub/foo])
+AC_OUTPUT
+END
+
+: > Makefile.am
+
+mkdir sub
+: > sub/foo.in
+
+$ACLOCAL
+$AUTOMAKE
+
+grep '^sub/foo' Makefile.in
+
+:
diff --git a/t/remake3a.sh b/t/remake3a.sh
new file mode 100755
index 000000000..cac2abcc6
--- /dev/null
+++ b/t/remake3a.sh
@@ -0,0 +1,73 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Ensure that remake rules work for files in a subdirectory even when
+# there is no Makefile for that subdirectory.
+# See also sister "grepping" test 'remake3.test'.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_CONFIG_FILES([sub/foo])
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+all-local: sub/foo
+END
+
+mkdir sub
+: > sub/foo.in
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+# First a VPATH build.
+mkdir build
+cd build
+../configure
+$sleep
+test -f sub/foo
+test ! -s sub/foo
+echo '#GrepMe#' > ../sub/foo.in
+$MAKE
+grep '#GrepMe#' sub/foo
+
+cd ..
+
+# Now try an in-tree build.
+: > sub/foo.in # Restore its original (empty) content.
+./configure
+$sleep
+test -f sub/foo
+test ! -s sub/foo
+echo '#GrepMe#' > sub/foo.in
+$MAKE
+grep '#GrepMe#' sub/foo
+
+# Finally try to check the distribution.
+$sleep
+echo '%GrepMe%' > sub/foo.in
+cat >>Makefile.am <<END
+check-local:
+ grep '%GrepMe%' sub/foo
+END
+$MAKE
+grep "grep '%GrepMe%' sub/foo" Makefile.in # Sanity check.
+$MAKE distcheck
+
+:
diff --git a/t/remake4.sh b/t/remake4.sh
new file mode 100755
index 000000000..43f856994
--- /dev/null
+++ b/t/remake4.sh
@@ -0,0 +1,56 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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 Makefile.in are up to date after make dist.
+# This is expected to work even without GNU Make (the GNU Make
+# feature that isn't supported elsewhere is the rebuild of
+# Makefile dependencies during ordinary builds).
+#
+# If this fails, this is likely to be due to a dependency being
+# given two different name. For instance BSD Make does not know
+# that 'Makefile' is the same as './Makefile'
+#
+# Report from Akim Demaille.
+
+. ./defs || Exit 1
+
+cat >>configure.ac <<'EOF'
+# Rebuild rule are ok until make dist, but not afterwards.
+if test ! -f rebuild_ok; then
+ ACLOCAL=false
+ AUTOMAKE=false
+ AUTOCONF=false
+fi
+AC_OUTPUT
+EOF
+
+: > rebuild_ok
+: > Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+./configure
+$MAKE
+$sleep
+touch aclocal.m4
+$MAKE distdir
+cd $me-1.0
+test ! -f rebuild_ok
+./configure
+$MAKE
+
+:
diff --git a/t/remake5.sh b/t/remake5.sh
new file mode 100755
index 000000000..dba802a89
--- /dev/null
+++ b/t/remake5.sh
@@ -0,0 +1,80 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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/>.
+
+# Check that AM_MAINTAINER_MODE disable some rebuild rules,
+# but not all.
+# Report from Ralf Corsepius.
+
+. ./defs || Exit 1
+
+if using_gmake; then
+ remake="$MAKE"
+else
+ remake="$MAKE Makefile"
+fi
+
+cat >>configure.ac <<'EOF'
+AM_MAINTAINER_MODE
+m4_include([foo.m4])
+if test ! -f rebuild_ok; then
+ ACLOCAL=false
+ AUTOMAKE=false
+ AUTOCONF=false
+fi
+AC_OUTPUT
+EOF
+
+: > foo.m4
+: > Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+./configure
+$MAKE
+
+# Make sure the rules to rebuild configure/Makefile.in are not
+# triggered by default. ($MAKE will fail if they are, because the
+# tools are set to false.)
+$sleep
+touch aclocal.m4 Makefile.am configure.ac foo.m4
+$remake
+
+# Make sure the rebuild rule for Makefile is triggered.
+$sleep
+echo '# GrEpMe' >>Makefile.in
+$remake
+grep GrEpMe Makefile
+
+# Make sure the rebuild rule for config.status is triggered.
+$sleep
+grep 'AUTOCONF.*=.*false' Makefile
+: > rebuild_ok
+./configure --no-create
+$remake
+grep 'AUTOCONF.*=.*false' Makefile && Exit 1
+
+# Make sure rebuild rules do work if --enable-maintainer-mode is given.
+./configure --enable-maintainer-mode
+$sleep
+echo 'AC_SUBST([YIPPY_YIPPY_YEAH])' >foo.m4
+$remake
+grep YIPPY_YIPPY_YEAH Makefile
+
+# Try the distribution, for completeness.
+$MAKE distcheck
+
+:
diff --git a/t/remake6.sh b/t/remake6.sh
new file mode 100755
index 000000000..c48c1b882
--- /dev/null
+++ b/t/remake6.sh
@@ -0,0 +1,64 @@
+#! /bin/sh
+# Copyright (C) 2008-2012 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 remaking rules work when subdir Makefile.in has been removed.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_CONFIG_FILES([sub/Makefile])
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+SUBDIRS = sub
+END
+mkdir sub
+: > sub/Makefile.am
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+./configure
+$MAKE
+
+# Now, we are set up. Ensure that, for either missing Makefile.in,
+# or updated Makefile.am, rebuild rules are run, and run exactly once
+# only.
+
+rm -f Makefile.in
+$MAKE >stdout || { cat stdout; Exit 1; }
+cat stdout
+test `grep -c " --run " stdout` -eq 1
+
+rm -f sub/Makefile.in
+$MAKE >stdout || { cat stdout; Exit 1; }
+cat stdout
+test `grep -c " --run " stdout` -eq 1
+
+$sleep # Let touched files appear newer.
+
+touch Makefile.am
+$MAKE >stdout || { cat stdout; Exit 1; }
+cat stdout
+test `grep -c " --run " stdout` -eq 1
+
+touch sub/Makefile.am
+$MAKE >stdout || { cat stdout; Exit 1; }
+cat stdout
+test `grep -c " --run " stdout` -eq 1
+
+:
diff --git a/t/remake7.sh b/t/remake7.sh
new file mode 100755
index 000000000..fbd15e66b
--- /dev/null
+++ b/t/remake7.sh
@@ -0,0 +1,69 @@
+#! /bin/sh
+# Copyright (C) 2008-2012 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 remaking rules fail when they should.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_CONFIG_FILES([sub/Makefile])
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+SUBDIRS = sub
+END
+mkdir sub
+: > sub/Makefile.am
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+./configure
+$MAKE
+
+$sleep
+
+# Fail for broken input files.
+
+echo "if FOO" > sub/Makefile.am
+$MAKE && Exit 1
+
+: >sub/Makefile.am
+$MAKE
+
+mv Makefile.am backup
+echo "if FOO" > Makefile.am
+$MAKE && Exit 1
+
+# Fail for missing input files, with or without missing
+# Makefile.in files.
+
+cp backup Makefile.am
+mv sub/Makefile.am sub/backup
+$MAKE && Exit 1
+
+rm -f sub/Makefile.in
+$MAKE && Exit 1
+
+mv sub/backup sub/Makefile.am
+rm -f Makefile.am
+$MAKE && Exit 1
+
+rm -f Makefile.in
+$MAKE && Exit 1
+
+:
diff --git a/t/remake8a.sh b/t/remake8a.sh
new file mode 100755
index 000000000..1b32a5e93
--- /dev/null
+++ b/t/remake8a.sh
@@ -0,0 +1,190 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Test basic remake rules for Makefiles, for an *in-tree build*.
+# This testcase checks dependency of generated Makefile from Makefile.am,
+# configure.ac, acinclude.m4, aclocal.m4, and extra m4 files considered
+# by aclocal.
+# Keep this in sync with sister test 'remake8b.test', which performs the
+# same checks for a VPATH build.
+
+. ./defs || Exit 1
+
+mv -f configure.ac configure.stub
+
+cat > Makefile.am <<'END'
+all-local: foo
+foo:
+ echo '!Foo!' >$@
+check-local:
+ cat foo
+ grep '!Foo!' foo
+CLEANFILES = foo
+END
+
+cat configure.stub - > configure.ac <<'END'
+AC_OUTPUT
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+srcdir='.' # To make syncing with remake8b.test easier.
+
+$srcdir/configure
+
+$MAKE
+cat foo
+grep '!Foo!' foo
+$MAKE distcheck
+
+rm -f foo
+
+# Modify just Makefile.am.
+
+$sleep
+
+cat > $srcdir/Makefile.am <<'END'
+all-local: bar
+bar:
+ echo '!Baz!' >$@
+check-local:
+ cat bar
+ grep '!Baz!' bar
+ test ! -r $(srcdir)/foo
+ test ! -r foo
+CLEANFILES = bar
+END
+
+using_gmake || $MAKE Makefile
+$MAKE
+cat bar
+grep '!Baz!' bar
+test ! -r foo
+$MAKE distcheck
+
+rm -f bar
+
+# Modify Makefile.am and configure.ac.
+
+$sleep
+
+cat > $srcdir/Makefile.am <<'END'
+check-local:
+ cat quux
+ grep '!Zardoz!' quux
+ test ! -r $(srcdir)/bar
+ test ! -r bar
+END
+
+cat $srcdir/configure.stub - > $srcdir/configure.ac <<'END'
+AC_CONFIG_FILES([quux])
+AC_SUBST([QUUX], [Zardoz])
+AC_OUTPUT
+END
+
+cat > $srcdir/quux.in <<'END'
+!@QUUX@!
+END
+
+using_gmake || $MAKE Makefile
+$MAKE
+cat quux
+grep '!Zardoz!' quux
+test ! -r bar
+$MAKE distcheck
+
+rm -f quux
+
+# Modify Makefile.am to add a directory of extra m4 files
+# considered by aclocal.
+
+$sleep
+
+mkdir $srcdir/m4
+
+cat > $srcdir/Makefile.am <<'END'
+ACLOCAL_AMFLAGS = -I m4
+check-local:
+ cat quux
+ grep '%Foo%' quux
+ test x'$(QUUX)' = x'%Foo%'
+END
+
+$MAKE # This should place aclocal flags in Makefile.
+grep '.*-I m4' Makefile # Sanity check.
+
+# Modify configure.ac and aclocal.m4.
+
+$sleep
+
+cat $srcdir/configure.stub - > $srcdir/configure.ac <<'END'
+AC_CONFIG_FILES([quux])
+MY_CUSTOM_MACRO
+AC_OUTPUT
+END
+
+cat >> $srcdir/aclocal.m4 <<'END'
+AC_DEFUN([MY_CUSTOM_MACRO], [AC_SUBST([QUUX], [%Foo%])])
+END
+
+$MAKE
+cat quux
+grep '%Foo%' quux
+$MAKE distcheck
+
+# Modify Makefile.am, remove aclocal.m4, and add a new m4 file to
+# the directory of extra m4 files considered by aclocal. This new
+# file should now provide a macro required by configure.ac and that
+# was previously provided by aclocal.m4.
+
+$sleep
+
+sed 's/%Foo%/%Bar%/g' $srcdir/Makefile.am > t
+mv -f t $srcdir/Makefile.am
+cat $srcdir/Makefile.am
+rm -f $srcdir/aclocal.m4
+cat > $srcdir/m4/blah.m4 <<'END'
+AC_DEFUN([MY_CUSTOM_MACRO], [AC_SUBST([QUUX], [%Bar%])])
+END
+
+$MAKE
+cat quux
+grep '%Bar%' quux
+$MAKE distcheck
+
+# Modify Makefile.am, remove all the extra m4 files to considered
+# by aclocal, and add an acinclude.m4 file. This last file should
+# now provide a macro required by configure.ac, and that was
+# previously provided by the extra m4 files considered by aclocal.
+
+$sleep
+
+rm -f $srcdir/m4/*.m4
+sed 's/%Bar%/%Quux%/g' $srcdir/Makefile.am > t
+mv -f t $srcdir/Makefile.am
+cat $srcdir/Makefile.am
+cat > $srcdir/acinclude.m4 <<'END'
+AC_DEFUN([MY_CUSTOM_MACRO], [AC_SUBST([QUUX], [%Quux%])])
+END
+
+$MAKE
+cat quux
+grep '%Quux%' quux
+$MAKE distcheck
+
+:
diff --git a/t/remake8b.sh b/t/remake8b.sh
new file mode 100755
index 000000000..5f687bada
--- /dev/null
+++ b/t/remake8b.sh
@@ -0,0 +1,192 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Test basic remake rules for Makefiles, for a *VPATH build*.
+# This testcase checks dependency of generated Makefile from Makefile.am,
+# configure.ac, acinclude.m4, aclocal.m4, and extra m4 files considered
+# by aclocal.
+# Keep this in sync with sister test 'remake8a.test', which performs the
+# same checks for a in-tree build.
+
+. ./defs || Exit 1
+
+mv -f configure.ac configure.stub
+
+cat > Makefile.am <<'END'
+all-local: foo
+foo:
+ echo '!Foo!' >$@
+check-local:
+ cat foo
+ grep '!Foo!' foo
+CLEANFILES = foo
+END
+
+cat configure.stub - > configure.ac <<'END'
+AC_OUTPUT
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+mkdir build
+cd build
+srcdir='..' # To make syncing with remake8a.test easier.
+
+$srcdir/configure
+
+$MAKE
+cat foo
+grep '!Foo!' foo
+$MAKE distcheck
+
+rm -f foo
+
+# Modify just Makefile.am.
+
+$sleep
+
+cat > $srcdir/Makefile.am <<'END'
+all-local: bar
+bar:
+ echo '!Baz!' >$@
+check-local:
+ cat bar
+ grep '!Baz!' bar
+ test ! -r $(srcdir)/foo
+ test ! -r foo
+CLEANFILES = bar
+END
+
+using_gmake || $MAKE Makefile
+$MAKE
+cat bar
+grep '!Baz!' bar
+test ! -r foo
+$MAKE distcheck
+
+rm -f bar
+
+# Modify Makefile.am and configure.ac.
+
+$sleep
+
+cat > $srcdir/Makefile.am <<'END'
+check-local:
+ cat quux
+ grep '!Zardoz!' quux
+ test ! -r $(srcdir)/bar
+ test ! -r bar
+END
+
+cat $srcdir/configure.stub - > $srcdir/configure.ac <<'END'
+AC_CONFIG_FILES([quux])
+AC_SUBST([QUUX], [Zardoz])
+AC_OUTPUT
+END
+
+cat > $srcdir/quux.in <<'END'
+!@QUUX@!
+END
+
+using_gmake || $MAKE Makefile
+$MAKE
+cat quux
+grep '!Zardoz!' quux
+test ! -r bar
+$MAKE distcheck
+
+rm -f quux
+
+# Modify Makefile.am to add a directory of extra m4 files
+# considered by aclocal.
+
+$sleep
+
+mkdir $srcdir/m4
+
+cat > $srcdir/Makefile.am <<'END'
+ACLOCAL_AMFLAGS = -I m4
+check-local:
+ cat quux
+ grep '%Foo%' quux
+ test x'$(QUUX)' = x'%Foo%'
+END
+
+$MAKE # This should place aclocal flags in Makefile.
+grep '.*-I m4' Makefile # Sanity check.
+
+# Modify configure.ac and aclocal.m4.
+
+$sleep
+
+cat $srcdir/configure.stub - > $srcdir/configure.ac <<'END'
+AC_CONFIG_FILES([quux])
+MY_CUSTOM_MACRO
+AC_OUTPUT
+END
+
+cat >> $srcdir/aclocal.m4 <<'END'
+AC_DEFUN([MY_CUSTOM_MACRO], [AC_SUBST([QUUX], [%Foo%])])
+END
+
+$MAKE
+cat quux
+grep '%Foo%' quux
+$MAKE distcheck
+
+# Modify Makefile.am, remove aclocal.m4, and add a new m4 file to
+# the directory of extra m4 files considered by aclocal. This new
+# file should now provide a macro required by configure.ac and that
+# was previously provided by aclocal.m4.
+
+$sleep
+
+sed 's/%Foo%/%Bar%/g' $srcdir/Makefile.am > t
+mv -f t $srcdir/Makefile.am
+cat $srcdir/Makefile.am
+rm -f $srcdir/aclocal.m4
+cat > $srcdir/m4/blah.m4 <<'END'
+AC_DEFUN([MY_CUSTOM_MACRO], [AC_SUBST([QUUX], [%Bar%])])
+END
+
+$MAKE
+cat quux
+grep '%Bar%' quux
+$MAKE distcheck
+
+# Modify Makefile.am, remove all the extra m4 files to considered
+# by aclocal, and add an acinclude.m4 file. This last file should
+# now provide a macro required by configure.ac, and that was
+# previously provided by the extra m4 files considered by aclocal.
+
+$sleep
+
+rm -f $srcdir/m4/*.m4
+sed 's/%Bar%/%Quux%/g' $srcdir/Makefile.am > t
+mv -f t $srcdir/Makefile.am
+cat $srcdir/Makefile.am
+cat > $srcdir/acinclude.m4 <<'END'
+AC_DEFUN([MY_CUSTOM_MACRO], [AC_SUBST([QUUX], [%Quux%])])
+END
+
+$MAKE
+cat quux
+grep '%Quux%' quux
+$MAKE distcheck
+
+:
diff --git a/t/remake9a.sh b/t/remake9a.sh
new file mode 100755
index 000000000..7ee307578
--- /dev/null
+++ b/t/remake9a.sh
@@ -0,0 +1,109 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Test remake rules when configure.ac or its prerequisites change.
+# Keep in sync with the other sister tests 'remake9*.test'.
+
+. ./defs || Exit 1
+
+magic1=::MagicStringOne::
+magic2=__MagicStringTwo__
+
+if using_gmake; then
+ remake_() { $MAKE nil; }
+else
+ remake_() { $MAKE Makefile && $MAKE foo.sh; }
+fi
+
+cat >> configure.ac <<END
+FINGERPRINT=BadBadBad
+AC_SUBST([FINGERPRINT])
+AC_CONFIG_FILES([foo.sh:foo.in], [chmod a+x foo.sh])
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+nil:
+.PHONY: nil
+
+$(srcdir)/configure.ac: $(srcdir)/tweak-configure-in
+ $(SHELL) $(srcdir)/tweak-configure-in <$@ >$@-t
+ mv -f $@-t $@
+EXTRA_DIST = $(srcdir)/tweak-configure-in
+
+# Used by "make distcheck" later.
+check-local:
+ test x'$(FINGERPRINT)' = x'DummyValue'
+ test x"`./foo.sh`" = x"DummyValue"
+END
+
+cat > foo.in <<END
+#!/bin/sh
+echo '@FINGERPRINT@'
+END
+
+echo cat > tweak-configure-in # It is a no-op by default.
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+for vpath in : false; do
+
+ if $vpath; then
+ mkdir build
+ cd build
+ srcdir=..
+ else
+ srcdir=.
+ fi
+
+ $srcdir/configure
+ $MAKE # Should be a no-op.
+
+ $sleep
+ sed "s/^\\(FINGERPRINT\\)=.*/\\1=$magic1/" $srcdir/configure.ac >t
+ mv -f t $srcdir/configure.ac
+ remake_
+ $FGREP FINGERPRINT Makefile # For debugging.
+ $FGREP $magic1 Makefile
+ test x"`./foo.sh`" = x"$magic1"
+
+ $sleep
+ echo 'sed "s/^\\(FINGERPRINT\\)=.*/\\1='$magic2'/"' \
+ > $srcdir/tweak-configure-in
+ remake_
+ $FGREP FINGERPRINT Makefile # For debugging.
+ $FGREP $magic1 Makefile && Exit 1
+ $FGREP $magic2 Makefile
+ test x"`./foo.sh`" = x"$magic2"
+
+ $sleep
+ echo cat > $srcdir/tweak-configure-in # Make it a no-op again.
+ sed "s/^\\(FINGERPRINT\\)=.*/\\1=DummyValue/" $srcdir/configure.ac >t
+ mv -f t $srcdir/configure.ac
+ using_gmake || remake_
+ $MAKE distcheck
+ $FGREP $magic1 Makefile && Exit 1 # Sanity check.
+ $FGREP $magic2 Makefile && Exit 1 # Likewise.
+
+ $MAKE distclean
+
+ cd $srcdir
+
+done
+
+:
diff --git a/t/remake9b.sh b/t/remake9b.sh
new file mode 100755
index 000000000..cab606e4d
--- /dev/null
+++ b/t/remake9b.sh
@@ -0,0 +1,111 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Test remake rules when Makefile.am or its prerequisites change.
+# Keep in sync with the other sister tests 'remake9*.test'.
+
+. ./defs || Exit 1
+
+if using_gmake; then
+ remake_() { $MAKE nil; }
+else
+ remake_() { $MAKE Makefile && $MAKE foo.sh; }
+fi
+
+magic1=::MagicStringOne::
+magic2=__MagicStringTwo__
+
+cat >> configure.ac <<END
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+FINGERPRINT = BadBadBad
+
+all-local: nil
+nil: foo.sh
+.PHONY: nil
+
+$(srcdir)/Makefile.am: $(srcdir)/tweak-makefile-am
+ $(SHELL) $(srcdir)/tweak-makefile-am <$@ >$@-t
+ mv -f $@-t $@
+EXTRA_DIST = $(srcdir)/tweak-makefile-am
+
+foo.sh: Makefile
+ rm -f $@ $@-t
+ echo '#!/bin/sh' > $@-t
+ echo "echo '$(FINGERPRINT)'" >> $@-t
+ chmod a+x $@-t && mv -f $@-t $@
+CLEANFILES = foo.sh
+
+# Used by "make distcheck" later.
+check-local:
+ test x'$(FINGERPRINT)' = x'DummyValue'
+ test x"`./foo.sh`" = x"DummyValue"
+END
+
+echo cat > tweak-makefile-am # It is a no-op by default.
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+for vpath in : false; do
+
+ if $vpath; then
+ mkdir build
+ cd build
+ srcdir=..
+ else
+ srcdir=.
+ fi
+
+ $srcdir/configure
+ $MAKE # Should be a no-op.
+
+ $sleep
+ sed "s/^\\(FINGERPRINT\\) *=.*/\\1 = $magic1/" $srcdir/Makefile.am >t
+ mv -f t $srcdir/Makefile.am
+ remake_
+ $FGREP FINGERPRINT Makefile # For debugging.
+ $FGREP $magic1 Makefile
+ test x"`./foo.sh`" = x"$magic1"
+
+ $sleep
+ echo 'sed "s/^\\(FINGERPRINT\\) *=.*/\\1 = '$magic2'/"' \
+ > $srcdir/tweak-makefile-am
+ remake_
+ $FGREP FINGERPRINT Makefile # For debugging.
+ $FGREP $magic1 Makefile && Exit 1
+ $FGREP $magic2 Makefile
+ test x"`./foo.sh`" = x"$magic2"
+
+ $sleep
+ echo cat > $srcdir/tweak-makefile-am # Make it a no-op again.
+ sed "s/^\\(FINGERPRINT\\) *=.*/\\1 = DummyValue/" $srcdir/Makefile.am >t
+ mv -f t $srcdir/Makefile.am
+ using_gmake || remake_
+ $MAKE distcheck
+ $FGREP $magic1 Makefile && Exit 1 # Sanity check.
+ $FGREP $magic2 Makefile && Exit 1 # Likewise.
+
+ $MAKE distclean
+
+ cd $srcdir
+
+done
+
+:
diff --git a/t/remake9c.sh b/t/remake9c.sh
new file mode 100755
index 000000000..efbec30f0
--- /dev/null
+++ b/t/remake9c.sh
@@ -0,0 +1,112 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Test remake rules when acinclude.m4 or its prerequisites change.
+# Keep in sync with the other sister tests 'remake9*.test'.
+
+. ./defs || Exit 1
+
+magic1=::MagicStringOne::
+magic2=__MagicStringTwo__
+
+if using_gmake; then
+ remake_() { $MAKE nil; }
+else
+ remake_() { $MAKE Makefile && $MAKE foo.sh; }
+fi
+
+cat >> configure.ac <<END
+FINGERPRINT='my_fingerprint'
+AC_SUBST([FINGERPRINT])
+AC_CONFIG_FILES([foo.sh:foo.in], [chmod a+x foo.sh])
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+nil:
+.PHONY: nil
+
+# The right way to extend an autogenerated aclocal.m4 is to provide
+# an acinclude.m4 file.
+$(srcdir)/acinclude.m4: $(srcdir)/tweak-acinclude-m4
+ $(SHELL) $(srcdir)/tweak-acinclude-m4 <$@ >$@-t
+ mv -f $@-t $@
+ touch $@
+EXTRA_DIST = $(srcdir)/tweak-acinclude-m4
+
+# Used by "make distcheck" later.
+check-local:
+ test x'$(FINGERPRINT)' = x'DummyValue'
+ test x"`./foo.sh`" = x"DummyValue"
+END
+
+cat > foo.in <<END
+#!/bin/sh
+echo '@FINGERPRINT@'
+END
+
+echo "AC_DEFUN([my_fingerprint], [BadBadBad])" > acinclude.m4
+
+echo : > tweak-acinclude-m4 # It is a no-op by default.
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+for vpath in : false; do
+
+ if $vpath; then
+ mkdir build
+ cd build
+ srcdir=..
+ else
+ srcdir=.
+ fi
+
+ $srcdir/configure
+ $MAKE # Should be a no-op.
+
+ $sleep
+ echo "AC_DEFUN([my_fingerprint], [$magic1])" > $srcdir/acinclude.m4
+ remake_
+ $FGREP FINGERPRINT Makefile # For debugging.
+ $FGREP $magic1 Makefile
+ test x"`./foo.sh`" = x"$magic1"
+
+ $sleep
+ echo "echo 'AC_DEFUN([my_fingerprint], [$magic2])'" \
+ > $srcdir/tweak-acinclude-m4
+ remake_
+ $FGREP FINGERPRINT Makefile # For debugging.
+ $FGREP $magic1 Makefile && Exit 1
+ $FGREP $magic2 Makefile
+ test x"`./foo.sh`" = x"$magic2"
+
+ $sleep
+ echo : > $srcdir/tweak-acinclude-m4 # Make it a no-op again.
+ echo "AC_DEFUN([my_fingerprint], [DummyValue])" > $srcdir/acinclude.m4
+ using_gmake || remake_
+ $MAKE distcheck
+ $FGREP $magic1 Makefile && Exit 1 # Sanity check.
+ $FGREP $magic2 Makefile && Exit 1 # Likewise.
+
+ $MAKE distclean
+
+ cd $srcdir
+
+done
+
+:
diff --git a/t/remake9d.sh b/t/remake9d.sh
new file mode 100755
index 000000000..dddb08343
--- /dev/null
+++ b/t/remake9d.sh
@@ -0,0 +1,112 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Test remake rules when aclocal.m4 or its prerequisites change.
+# Keep in sync with the other sister tests 'remake9*.test'.
+
+. ./defs || Exit 1
+
+magic1=::MagicStringOne::
+magic2=__MagicStringTwo__
+
+if using_gmake; then
+ remake_() { $MAKE nil; }
+else
+ remake_() { $MAKE Makefile && $MAKE foo.sh; }
+fi
+
+cat >> configure.ac <<END
+FINGERPRINT='my_fingerprint'
+AC_SUBST([FINGERPRINT])
+AC_CONFIG_FILES([foo.sh:foo.in], [chmod a+x foo.sh])
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+nil:
+.PHONY: nil
+
+# A non-autogenerated aclocal.m4 can be extended by hand.
+$(srcdir)/aclocal.m4: $(srcdir)/tweak-aclocal-m4
+ $(SHELL) $(srcdir)/tweak-aclocal-m4 <$@ >$@-t
+ mv -f $@-t $@
+ touch $@
+EXTRA_DIST = $(srcdir)/tweak-aclocal-m4
+
+# Used by "make distcheck" later.
+check-local:
+ test x'$(FINGERPRINT)' = x'DummyValue'
+ test x"`./foo.sh`" = x"DummyValue"
+END
+
+cat > foo.in <<END
+#!/bin/sh
+echo '@FINGERPRINT@'
+END
+
+echo cat > tweak-aclocal-m4 # It is a no-op by default.
+
+$ACLOCAL
+# Cheatingly mark aclocal.m4 as non auto-generated.
+sed '/^ *#.*generated automatically/d' aclocal.m4 > t
+mv -f t aclocal.m4
+$AUTOCONF
+$AUTOMAKE
+
+for vpath in : false; do
+
+ if $vpath; then
+ mkdir build
+ cd build
+ srcdir=..
+ else
+ srcdir=.
+ fi
+
+ $srcdir/configure
+ $MAKE # Should be a no-op.
+
+ $sleep
+ echo "AC_DEFUN([my_fingerprint], [$magic1])dnl %%%" >> $srcdir/aclocal.m4
+ remake_
+ $FGREP FINGERPRINT Makefile # For debugging.
+ $FGREP $magic1 Makefile
+ test x"`./foo.sh`" = x"$magic1"
+
+ $sleep
+ echo "sed 's/.*dnl *%%%.*/AC_DEFUN([my_fingerprint], [$magic2])/'" \
+ > $srcdir/tweak-aclocal-m4
+ remake_
+ $FGREP FINGERPRINT Makefile # For debugging.
+ $FGREP $magic1 Makefile && Exit 1
+ $FGREP $magic2 Makefile
+ test x"`./foo.sh`" = x"$magic2"
+
+ $sleep
+ echo cat > $srcdir/tweak-aclocal-m4 # Make it a no-op again.
+ echo 'AC_DEFUN([my_fingerprint], [DummyValue])' >> $srcdir/aclocal.m4
+ using_gmake || remake_
+ $MAKE distcheck
+ $FGREP $magic1 Makefile && Exit 1 # Sanity check.
+ $FGREP $magic2 Makefile && Exit 1 # Likewise.
+
+ $MAKE distclean
+
+ cd $srcdir
+
+done
+
+:
diff --git a/t/repeated-options.sh b/t/repeated-options.sh
new file mode 100755
index 000000000..8ad576500
--- /dev/null
+++ b/t/repeated-options.sh
@@ -0,0 +1,82 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Check that automake does not complain on repeated options, nor
+# generate broken or incorrect makefiles.
+
+required='cc bzip2'
+. ./defs || Exit 1
+
+cat >configure.ac <<END
+AC_INIT([$me], [1.0])
+AM_INIT_AUTOMAKE([foreign dist-bzip2 no-dist-gzip no-dist-gzip dist-bzip2])
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+AUTOMAKE_OPTIONS = parallel-tests subdir-objects subdir-objects
+AUTOMAKE_OPTIONS += dist-bzip2 parallel-tests
+TESTS = foo.test
+EXTRA_DIST = $(TESTS)
+TESTS_ENVIRONMENT = EXEEXT='$(EXEEXT)'
+bin_PROGRAMS = sub/foo
+.PHONY: test-build
+test-build:
+ ls -l . sub
+ test -f sub/foo.$(OBJEXT)
+ test -f sub/foo$(EXEEXT)
+END
+
+mkdir sub
+
+cat > foo.test <<'END'
+#!/bin/sh
+test -f sub/foo$EXEEXT && test -x sub/foo$EXEEXT
+END
+chmod a+x foo.test
+
+cat > sub/foo.c <<'END'
+int main (void)
+{
+ return 0;
+}
+END
+
+cp "$am_scriptdir"/compile "$am_scriptdir"/test-driver .
+
+$ACLOCAL
+$AUTOMAKE --foreign --foreign -Wall 2>stderr || { cat stderr >&2; Exit 1; }
+test -s stderr && { cat stderr >&2; Exit 1; }
+rm -f stderr
+$AUTOCONF
+
+./configure
+$MAKE
+$MAKE test-build
+$MAKE check
+ls -l
+test -f foo.log
+test -f test-suite.log
+$MAKE clean
+$MAKE distcheck
+ls -l
+test -f $me-1.0.tar.bz2
+test ! -r $me-1.0.tar.gz
+
+:
diff --git a/t/req.sh b/t/req.sh
new file mode 100755
index 000000000..cfc3b4399
--- /dev/null
+++ b/t/req.sh
@@ -0,0 +1,39 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test to make sure macro used in m4 file is included.
+
+. ./defs || Exit 1
+
+cat > configure.ac <<EOF
+AC_INIT
+AM_INIT_GUILE_MODULE
+EOF
+
+cat > acinclude.m4 << 'END'
+AC_DEFUN([AM_INIT_GUILE_MODULE],[
+. $srcdir/../GUILE-VERSION
+AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
+AC_CONFIG_AUX_DIR(..)
+module=[$1]
+AC_SUBST(module)])
+END
+
+$ACLOCAL
+
+grep 'DEFUN.*INIT_AUTOMAKE' aclocal.m4
+
+:
diff --git a/t/reqd.sh b/t/reqd.sh
new file mode 100755
index 000000000..9e0bcc1f1
--- /dev/null
+++ b/t/reqd.sh
@@ -0,0 +1,45 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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 Automake will install several copies of required files if needed.
+# Reported by Marius Vollmer.
+
+. ./defs || Exit 1
+
+cat >> configure.ac <<EOF
+AC_CONFIG_FILES([one/Makefile two/Makefile])
+AC_OUTPUT
+EOF
+
+mkdir one
+mkdir two
+
+echo 'SUBDIRS = one two' > Makefile.am
+echo 'info_TEXINFOS = mumble.texi' > one/Makefile.am
+cat >one/mumble.texi <<'END'
+@setfilename mumble.info
+@include version.texi
+END
+
+cp one/Makefile.am one/mumble.texi two
+
+$ACLOCAL
+$AUTOMAKE --add-missing --copy
+
+test -f one/mdate-sh
+test -f one/texinfo.tex
+test -f two/mdate-sh
+test -f two/texinfo.tex
diff --git a/t/reqd2.sh b/t/reqd2.sh
new file mode 100755
index 000000000..a9442a29b
--- /dev/null
+++ b/t/reqd2.sh
@@ -0,0 +1,57 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Regression test for a bug reported by Andrew Suffield.
+# (Automake goes wild and try to rerun itself more than two time
+# to fix the Makefiles.)
+
+required='libtoolize'
+. ./defs || Exit 1
+
+cat > configure.ac << 'END'
+AC_INIT([req2], [1.0])
+AC_CONFIG_AUX_DIR([autoconf])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([Makefile])
+AC_PROG_CC
+AM_PROG_AR
+AM_PROG_LIBTOOL
+AC_CONFIG_FILES([autoconf/Makefile main/Makefile])
+AC_OUTPUT
+END
+
+mkdir autoconf
+mkdir main
+
+: > autoconf/Makefile.am
+echo 'SUBDIRS = autoconf main' >Makefile.am
+
+cat >main/Makefile.am <<'END'
+lib_LTLIBRARIES = lib0.la
+lib0_la_SOURCES = 0.c
+END
+
+: > ar-lib
+libtoolize --force --copy
+$ACLOCAL
+$AUTOCONF
+
+test -f autoconf/ltmain.sh # Sanity check.
+rm -f autoconf/ltmain.sh
+AUTOMAKE_fails --add-missing --copy
+grep '^configure\.ac:7:.* required file.*autoconf/ltmain\.sh' stderr
+
+:
diff --git a/t/rst-formatting.sh b/t/rst-formatting.sh
new file mode 100755
index 000000000..f23c28c2b
--- /dev/null
+++ b/t/rst-formatting.sh
@@ -0,0 +1,93 @@
+#! /bin/sh
+# Copyright (C) 2012 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/>.
+
+# Parallel testsuite harness: check APIs for the registering the
+# "global test result" in '*.trs' files, as documented in the automake
+# manual.
+
+am_create_testdir=empty
+. ./defs || Exit 1
+
+sed -n '/^am__rst_[a-z_][a-z_]* =/p' "$am_amdir"/check.am > Makefile \
+ || framework_failure_ "fetching definitions from check.am"
+
+cat >> Makefile << 'END'
+test:
+ printf '%s\n' "$$in" | $(am__rst_title) > title-got
+ printf '%s\n' "$$in" | $(am__rst_section) > section-got
+ cat title-exp
+ cat title-got
+ diff title-exp title-got
+ cat section-exp
+ cat section-got
+ diff section-exp section-got
+END
+
+# -------------------------------------------------------------------------
+
+cat > title-exp <<'END'
+==============
+ ab cd ef
+==============
+
+END
+
+cat > section-exp <<'END'
+ab cd ef
+========
+
+END
+
+env in='ab cd ef' $MAKE test
+
+# -------------------------------------------------------------------------
+
+cat > title-exp <<'END'
+============================================================================
+ 0123456789012345678901234567890123456789012345678901234567890123456789
+============================================================================
+
+END
+
+cat > section-exp <<'END'
+0123456789012345678901234567890123456789012345678901234567890123456789
+======================================================================
+
+END
+
+in=0123456789012345678901234567890123456789012345678901234567890123456789
+env in=$in $MAKE test
+
+# -------------------------------------------------------------------------
+
+cat > title-exp <<'END'
+=======
+ x
+=======
+
+END
+
+cat > section-exp <<'END'
+x
+=
+
+END
+
+env in=x $MAKE test
+
+# -------------------------------------------------------------------------
+
+:
diff --git a/t/rulepat.sh b/t/rulepat.sh
new file mode 100755
index 000000000..5e547a509
--- /dev/null
+++ b/t/rulepat.sh
@@ -0,0 +1,30 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test to make sure RULE_PATTERN catches strange targets.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+$(srcdir)/Makefile.am:
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+grep '^$(srcdir)/Makefile\.am' Makefile.in
+
+:
diff --git a/t/sanity.sh b/t/sanity.sh
new file mode 100755
index 000000000..d4f328c61
--- /dev/null
+++ b/t/sanity.sh
@@ -0,0 +1,43 @@
+#! /bin/sh
+# Copyright (C) 2008-2012 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/>.
+
+# Unsafe absolute directory names should be diagnosed.
+
+. ./defs || Exit 1
+
+mkdir 'unsafe$'
+cd 'unsafe$'
+
+mv ../configure.ac .
+mv ../install-sh ../missing .
+
+: > Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure 2>stderr && { cat stderr >&2; Exit 1; }
+cat stderr >&2
+grep 'unsafe absolute working directory' stderr
+
+cd ..
+mkdir build
+cd build
+../unsafe$/configure 2>stderr && { cat stderr >&2; Exit 1; }
+cat stderr >&2
+grep 'unsafe srcdir' stderr
+
+:
diff --git a/t/scripts.sh b/t/scripts.sh
new file mode 100755
index 000000000..48083586c
--- /dev/null
+++ b/t/scripts.sh
@@ -0,0 +1,27 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test for bug reported by Jim Meyering.
+# AC_PROG_INSTALL was required when only noinst_SCRIPTS was defined.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+noinst_SCRIPTS = foo
+END
+
+$ACLOCAL
+$AUTOMAKE
diff --git a/t/seenc.sh b/t/seenc.sh
new file mode 100755
index 000000000..d1bfa23a1
--- /dev/null
+++ b/t/seenc.sh
@@ -0,0 +1,43 @@
+#! /bin/sh
+# Copyright (C) 1997-2012 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/>.
+
+# Test to make sure C-but-not-CC error works.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+dnl AC_PROG_CC and AC_PROG_CXX missing on purpose
+AC_LIBOBJ([fsusage])
+AC_LIBOBJ([mountlist])
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = foo
+foo_SOURCES = x.C
+foo_LDADD = @LIBOBJS@
+END
+
+: > fsusage.c
+: > mountlist.c
+
+$ACLOCAL
+AUTOMAKE_fails
+grep ' C source.*CC.* undefined' stderr
+grep 'define .*CC.* add .*AC_PROG_CC' stderr
+grep ' C++ source.*CXX.* undefined' stderr
+grep 'define .*CXX.* add .*AC_PROG_CXX' stderr
+
+:
diff --git a/t/self-check-cleanup.tap b/t/self-check-cleanup.tap
new file mode 100755
index 000000000..f38b9055a
--- /dev/null
+++ b/t/self-check-cleanup.tap
@@ -0,0 +1,179 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Sanity check for the automake testsuite.
+# Check creation/removal of temporary test working directory by './defs'.
+
+. ./defs || Exit 1
+
+if test x"$sh_errexit_works" != x"yes"; then
+ skip_all_ "$me: no working exit trap with 'set -e'"
+fi
+
+plan_ 42
+
+# We still need a little hack to make ./defs work outside automake's
+# tree 'tests' subdirectory. Not a big deal.
+sed "s|^testbuilddir=.*|testbuilddir='`pwd`'|" ../defs-static >defs-static
+diff ../defs-static defs-static && fatal_ "failed to edit defs-static"
+cp ../defs .
+
+AM_TESTS_REEXEC=no; export AM_TESTS_REEXEC
+
+if ln -s defs foo && test -h foo; then
+ have_symlinks=yes
+else
+ have_symlinks=no
+fi
+export have_symlinks # Is used also by spawned shells.
+
+dir=dummy.dir
+
+# Don't let a failure poison all subsequent tests.
+do_clean ()
+{
+ test -d $dir || return 0
+ # Don't try to be smart and use find here, that has caused issues
+ # and extra ERROR results in the past. Be dumb and safe.
+ chmod u+rwx $dir || :
+ for d in $dir/*; do test ! -d $d || chmod u+rwx $d || :; done
+ for d in $dir/*/*; do test ! -d $d || chmod u+rwx $d || :; done
+ rm -rf $dir
+}
+
+# Check that pre-test cleanup works also with directories with
+# "null" permissions, and containing broken symlinks.
+mkdir $dir $dir/sub
+cd $dir
+touch file sub/file
+if test $have_symlinks = yes; then
+ ln -s file symlink
+ ln -s none brokenlink
+fi
+cd ..
+chmod 000 $dir/sub/* $dir/file
+test $have_symlinks = yes && chmod 000 $dir/symlink
+chmod 500 $dir/sub $dir
+command_ok_ "pre-cleanup can deal with low-perms testdir" \
+ $SHELL -c '. ./defs' dummy.sh
+command_ok_ "pre-cleanup removed low-perms testdir" \
+ eval 'test ! -f $dir && test ! -d $dir && test ! -r $dir'
+
+do_clean
+
+# Check that post-test cleanup works also with directories with
+# "null" permissions, and containing broken symlinks.
+command_ok_ "post-cleanup can deal with low-perms testdir" \
+ $SHELL -c '
+ stderr_fileno_=2
+ . ./defs || Exit 1
+ set -e
+ mkdir dir dir/sub
+ cd dir
+ touch file sub/file
+ if test $have_symlinks = yes; then
+ ln -s file symlink
+ ln -s none brokenlink
+ fi
+ cd ..
+ chmod 000 dir/sub/* dir/file
+ test $have_symlinks = yes && chmod 000 dir/symlink
+ chmod 500 dir/sub dir
+ :
+' dummy.sh
+command_ok_ "post-cleanup removed null-perms testdir" \
+ eval 'test ! -f $dir && test ! -d $dir && test ! -r $dir'
+
+do_clean
+
+# Check that pre-test cleanup does not unduly change the permissions of
+# files to which symlinks in the temporary test directory point to.
+if test $have_symlinks = yes; then
+
+ mkdir dir
+ chmod 000 dir
+ : > file
+ chmod 000 file
+
+ mkdir $dir
+ cd $dir
+ ln -s ../dir ../file .
+ cd ..
+
+ command_ok_ "pre-cleanup with testdir with zero-perms symlinks" \
+ $SHELL -c '. ./defs' dummy.sh
+ ls -l # For debugging.
+ command_ok_ "pre-cleanup chmod doesn't follow symlinks to files" \
+ eval 'ls -l file | grep "^----------.*file"'
+ command_ok_ "pre-cleanup chmod doesn't follow symlinks to dirs" \
+ eval 'ls -ld dir | grep "^d---------.*dir"'
+
+ command_ok_ "post-cleanup with testdir with zero-perms symlinks" \
+ $SHELL -c '
+ ocwd=`pwd` || exit 1
+ stderr_fileno_=2
+ . ./defs || Exit 1
+ ln -s "$ocwd/dir" "$ocwd/file" .
+ ' dummy.sh
+ ls -l # For debugging.
+ command_ok_ "post-cleanup chmod doesn't follow symlinks to files" \
+ eval 'ls -l file | grep "^----------.*file"'
+ command_ok_ "post-cleanup chmod doesn't follow symlinks to dirs" \
+ eval 'ls -ld dir | grep "^d---------.*dir"'
+
+ chmod u+rwx dir file
+ rmdir dir
+ rm -f file
+
+else # $have_symlinks = no
+ skip_row_ 6 "symlinks not supported"
+fi
+
+do_clean
+
+# Check that the cleanup trap does not remove the temporary
+# test directory in case of test failure, skip, hard-error,
+# or when receiving a signal.
+
+for st in 1 2 3 10 77 99 126 127 130 255; do
+ command_ok_ "exit trap doesn't clobber exit status $st" not $SHELL -c "
+ stderr_fileno_=2
+ . ./defs
+ : > foo
+ Exit $st
+ " dummy.sh
+ command_ok_ "testdir not removed if exiting with status $st" \
+ test -f dummy.dir/foo
+ do_clean
+done
+
+for sig in 1 2 3 9 13 15; do
+ if is_blocked_signal $sig; then
+ skip_row_ 2 -r "signal $sig seems blocked"
+ continue
+ fi
+ command_ok_ "exit trap doesn't clobber signal $sig" not $SHELL -c "
+ stderr_fileno_=2
+ . ./defs
+ : > foo
+ kill -$sig \$\$
+ " dummy.sh
+ command_ok_ "testdir not removed if getting signal $sig" \
+ test -f dummy.dir/foo
+ do_clean
+done
+
+:
diff --git a/t/self-check-configure-help.sh b/t/self-check-configure-help.sh
new file mode 100755
index 000000000..23b9dc7cb
--- /dev/null
+++ b/t/self-check-configure-help.sh
@@ -0,0 +1,274 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Sanity check on the function used by the automake testsuite to
+# analyze output of "configure --help".
+
+. ./defs || Exit 1
+
+# FIXME: this test is a good candidate for a conversion to TAP.
+
+# Prefer real-world data. This is from the help screen of the
+# configure script from GNU coreutils, with small adaptations.
+cat > help <<'END'
+'configure' configures GNU coreutils 8.14a to adapt to many kinds of systems.
+
+Usage: ./configure [OPTION]... [VAR=VALUE]...
+
+To assign environment variables (e.g., CC, CFLAGS...), specify them as
+VAR=VALUE. See below for descriptions of some of the useful variables.
+
+Defaults for the options are specified in brackets.
+
+Configuration:
+ -h, --help display this help and exit
+ --help=short display options specific to this package
+ --help=recursive display the short help of all the included packages
+ -V, --version display version information and exit
+ -q, --quiet, --silent do not print 'checking ...' messages
+ --cache-file=FILE cache test results in FILE [disabled]
+ -C, --config-cache alias for '--cache-file=config.cache'
+ -n, --no-create do not create output files
+ --srcdir=DIR find the sources in DIR [configure dir or '..']
+
+Installation directories:
+ --prefix=PREFIX install architecture-independent files in PREFIX
+ [/usr/local]
+ --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
+ [PREFIX]
+
+By default, 'make install' will install all the files in
+'/usr/local/bin', '/usr/local/lib' etc. You can specify
+an installation prefix other than '/usr/local' using '--prefix',
+for instance '--prefix=$HOME'.
+
+For better control, use the options below.
+
+Fine tuning of the installation directories:
+ --bindir=DIR user executables [EPREFIX/bin]
+ --sbindir=DIR system admin executables [EPREFIX/sbin]
+ --libexecdir=DIR program executables [EPREFIX/libexec]
+ --sysconfdir=DIR read-only single-machine data [PREFIX/etc]
+ --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
+ --localstatedir=DIR modifiable single-machine data [PREFIX/var]
+ --libdir=DIR object code libraries [EPREFIX/lib]
+ --includedir=DIR C header files [PREFIX/include]
+ --oldincludedir=DIR C header files for non-gcc [/usr/include]
+ --datarootdir=DIR read-only arch.-independent data root [PREFIX/share]
+ --datadir=DIR read-only architecture-independent data [DATAROOTDIR]
+ --infodir=DIR info documentation [DATAROOTDIR/info]
+ --localedir=DIR locale-dependent data [DATAROOTDIR/locale]
+ --mandir=DIR man documentation [DATAROOTDIR/man]
+ --docdir=DIR documentation root [DATAROOTDIR/doc/coreutils]
+ --htmldir=DIR html documentation [DOCDIR]
+ --dvidir=DIR dvi documentation [DOCDIR]
+ --pdfdir=DIR pdf documentation [DOCDIR]
+ --psdir=DIR ps documentation [DOCDIR]
+
+Program names:
+ --program-prefix=PREFIX prepend PREFIX to installed program names
+ --program-suffix=SUFFIX append SUFFIX to installed program names
+ --program-transform-name=PROGRAM run sed PROGRAM on installed program names
+
+System types:
+ --build=BUILD configure for building on BUILD [guessed]
+ --host=HOST cross-compile to build programs to run on HOST [BUILD]
+
+Optional Features:
+ --disable-option-checking ignore unrecognized --enable/--with options
+ --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
+ --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
+ --enable-silent-rules less verbose build output (undo: 'make V=1')
+ --disable-silent-rules verbose build output (undo: 'make V=0')
+ --disable-dependency-tracking speeds up one-time build
+ --enable-dependency-tracking do not reject slow dependency extractors
+ --disable-largefile omit support for large files
+ --enable-threads={posix|solaris|pth|win32}
+ specify multithreading API
+ --disable-threads build without multithread safety
+ --disable-acl do not support ACLs
+ --disable-assert turn off assertions
+ --disable-rpath do not hardcode runtime library paths
+ --disable-xattr do not support extended attributes
+ --disable-libcap disable libcap support
+ --enable-gcc-warnings turn on lots of GCC warnings (for developers)
+ --enable-install-program=PROG_LIST
+ install the programs in PROG_LIST (comma-separated,
+ default: none)
+ --enable-no-install-program=PROG_LIST
+ do NOT install the programs in PROG_LIST
+ (comma-separated, default: arch,hostname,su)
+ --disable-nls do not use Native Language Support
+
+Optional Packages:
+ --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
+ --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
+ --with-gnu-ld assume the C compiler uses GNU ld default=no
+ --with-libiconv-prefix[=DIR] search for libiconv in DIR/include and DIR/lib
+ --without-libiconv-prefix don't search for libiconv in includedir and libdir
+ --with-libpth-prefix[=DIR] search for libpth in DIR/include and DIR/lib
+ --without-libpth-prefix don't search for libpth in includedir and libdir
+ --without-included-regex
+ don't compile regex; this is the default on systems
+ with recent-enough versions of the GNU C Library
+ (use with caution on other systems).
+ --without-selinux do not use SELinux, even on systems with SELinux
+ --with-packager String identifying the packager of this software
+ --with-packager-version Packager-specific version information
+ --with-packager-bug-reports
+ Packager info for bug reports (URL/e-mail/...)
+ --with-tty-group[=NAME]
+ group used by system for TTYs, "tty" when not
+ specified (default: do not rely on any group used
+ for TTYs)
+ --without-gmp do not use the GNU MP library for arbitrary
+ precision calculation (default: use it if available)
+ --with-libintl-prefix[=DIR] search for libintl in DIR/include and DIR/lib
+ --without-libintl-prefix don't search for libintl in includedir and libdir
+
+Some influential environment variables:
+ CC C compiler command
+ CFLAGS C compiler flags
+ LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
+ nonstandard directory <lib dir>
+ LIBS libraries to pass to the linker, e.g. -l<library>
+ CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
+ you have headers in a nonstandard directory <include dir>
+ CPP C preprocessor
+ YACC The "Yet Another C Compiler" implementation to use. Defaults to
+ 'bison -y'. Values other than 'bison -y' will most likely break
+ on most systems.
+ YFLAGS YFLAGS contains the list arguments that will be passed by
+ default to Bison. This script will default YFLAGS to the empty
+ string to avoid a default value of '-d' given by some make
+ applications.
+ DEFAULT_POSIX2_VERSION
+ POSIX version to default to; see 'config.hin'.
+
+Use these variables to override the choices made by 'configure' or to help
+it to find libraries and programs with nonstandard names/locations.
+
+Report bugs to <bug-automake@gnu.org>.
+General help using GNU software: <http://www.gnu.org/gethelp/>.
+END
+
+compare_extracted_help ()
+{
+ cat > exp || Exit 99
+ extract_configure_help "$1" help > got || Exit 1
+ cat exp
+ cat got
+ diff exp got || Exit 1
+}
+
+compare_extracted_help --disable-libcap <<'END'
+ --disable-libcap disable libcap support
+END
+
+compare_extracted_help --disable-nls <<'END'
+ --disable-nls do not use Native Language Support
+END
+
+compare_extracted_help --disable-option-checking <<'END'
+ --disable-option-checking ignore unrecognized --enable/--with options
+END
+
+compare_extracted_help --build= <<'END'
+ --build=BUILD configure for building on BUILD [guessed]
+END
+
+compare_extracted_help --host= <<'END'
+ --host=HOST cross-compile to build programs to run on HOST [BUILD]
+END
+
+compare_extracted_help '--with-libintl-prefix[=]' <<'END'
+ --with-libintl-prefix[=DIR] search for libintl in DIR/include and DIR/lib
+END
+
+compare_extracted_help --without-included-regex <<'END'
+ --without-included-regex
+ don't compile regex; this is the default on systems
+ with recent-enough versions of the GNU C Library
+ (use with caution on other systems).
+END
+
+compare_extracted_help --enable-threads= <<'END'
+ --enable-threads={posix|solaris|pth|win32}
+ specify multithreading API
+END
+
+compare_extracted_help '--with-tty-group[=]' <<'END'
+ --with-tty-group[=NAME]
+ group used by system for TTYs, "tty" when not
+ specified (default: do not rely on any group used
+ for TTYs)
+END
+
+compare_extracted_help '--prefix=' <<'END'
+ --prefix=PREFIX install architecture-independent files in PREFIX
+ [/usr/local]
+END
+
+compare_extracted_help '--exec-prefix=' <<'END'
+ --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
+ [PREFIX]
+END
+
+compare_extracted_help CC <<'END'
+ CC C compiler command
+END
+
+compare_extracted_help CPP <<'END'
+ CPP C preprocessor
+END
+
+compare_extracted_help CPPFLAGS <<'END'
+ CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
+ you have headers in a nonstandard directory <include dir>
+END
+
+compare_extracted_help YACC <<'END'
+ YACC The "Yet Another C Compiler" implementation to use. Defaults to
+ 'bison -y'. Values other than 'bison -y' will most likely break
+ on most systems.
+END
+
+compare_extracted_help DEFAULT_POSIX2_VERSION <<'END'
+ DEFAULT_POSIX2_VERSION
+ POSIX version to default to; see 'config.hin'.
+END
+
+for o in \
+ '--nonesuch' \
+ '--nonesuch=' \
+ '--nonesuch[=]' \
+ '--disable-nls=' \
+ '--disable-nls[=]' \
+ '--without-included-regex=' \
+ '--without-included-regex[=]' \
+ '--prefix' \
+ '--prefix[=]' \
+ '--build' \
+ '--build[=]' \
+ '--with-tty-group' \
+ '--with-tty-group=' \
+ 'NO_SUCH_VAR' \
+ 'NOSUCHVAR' \
+; do
+ compare_extracted_help "$o" </dev/null
+done
+
+:
diff --git a/t/self-check-dir.tap b/t/self-check-dir.tap
new file mode 100755
index 000000000..b056ed3ec
--- /dev/null
+++ b/t/self-check-dir.tap
@@ -0,0 +1,73 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Sanity check for the automake testsuite.
+# Check that tests using './defs' create a proper temporary directory,
+# and run in it. Also check that we can prevent the pre-population
+# and the creation of such directory if we want.
+
+am_create_testdir=no
+. ./defs || Exit 99
+
+plan_ 5
+
+AM_TESTS_REEXEC=no; export AM_TESTS_REEXEC
+
+# This needs to be consistent with what $SHELL deems to be the
+# current working directory.
+cwd=`$SHELL -c 'pwd'` || fatal_ "can't get current working directory"
+echo "$cwd"
+
+do_check ()
+{
+ test ! -d _self.dir || rm -rf _self.dir \
+ || framework_failure_ "cleaning up _self.dir"
+ command_ok_ "$1 [$2]" $SHELL -c "
+ $2
+ . ./defs || Exit 99
+ # Don't fail if 'ls -l' fails; avoids possible racy spurious failures.
+ pwd; ls -l || : # For debugging.
+ $3
+ " _self.sh
+}
+
+do_check 'testdir has the expected path' \
+ 'unset am_create_testdir' \
+ 'case `pwd` in '"$cwd"'/_self.dir);; *) Exit 1;; esac'
+
+do_check 'fully pre-populated testdir' \
+ 'unset am_create_testdir' \
+ 'test -f install-sh || Exit 1
+ test -f configure.ac || Exit 1
+ case `pwd` in '"$cwd"'/_self.dir) : ;; *) Exit 1;; esac'
+
+do_check 'testdir has the expected path' \
+ 'am_create_testdir=empty' \
+ 'case `pwd` in '"$cwd"'/_self.dir) : ;; *) Exit 1;; esac'
+
+do_check 'do not pre-populate testdir' \
+ 'am_create_testdir=empty' \
+ 'ls -a | grep -v "^\\.\\{1,2\\}$" | grep . && Exit 1; :'
+
+do_check 'do not create nor chdir in testdir' \
+ 'am_create_testdir=no' \
+ 'test ! -d _self.dir || Exit 1
+ test ! -f _self.dir || Exit 1
+ test ! -r _self.dir || Exit 1
+ grep "self-check-dir\.tap" Makefile || Exit 1
+ case `pwd` in '"$cwd"') : ;; *) Exit 1;; esac'
+
+:
diff --git a/t/self-check-env-sanitize.tap b/t/self-check-env-sanitize.tap
new file mode 100755
index 000000000..d4e6cdb69
--- /dev/null
+++ b/t/self-check-env-sanitize.tap
@@ -0,0 +1,57 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Sanity check for the automake testsuite.
+# Make sure that the testsuite initialization code complains when
+# some testsuite-influential variables are set in the environment.
+
+am_create_testdir=no
+. ./defs || Exit 1
+
+set -x
+exec 5>&1
+
+plan_ 18 # Two times the number of variable names in $vars.
+
+vars='
+ me
+ required
+ am_parallel_tests
+ am_using_tap
+ am_create_testdir
+ am_tap_implementation
+ am_test_prefer_config_shell
+ am_original_AUTOMAKE
+ am_original_ACLOCAL
+'
+
+do_run ()
+{
+ env "$1=foo" $SHELL -c '. ./defs' foo.test
+}
+
+do_grep ()
+{
+ env "$1=foo" $SHELL -c '. ./defs' foo.test 2>&1 1>&5 \
+ | grep "foo\.test:.* variable '$1'.* in the environment.*unsafe"
+}
+
+for var in $vars; do
+ command_ok_ "$var [err status]" not do_run $var
+ command_ok_ "$var [err message]" do_grep $var
+done
+
+:
diff --git a/t/self-check-exit.tap b/t/self-check-exit.tap
new file mode 100755
index 000000000..cb655a51f
--- /dev/null
+++ b/t/self-check-exit.tap
@@ -0,0 +1,108 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Sanity check for the automake testsuite.
+# Check that, in case of failing commands, the correct exit status is
+# passed to the exit trap installed by the './defs' script.
+# Also check that the 'errexit' shell flag is active.
+
+am_create_testdir=no
+. ./defs || Exit 99
+
+plan_ 34
+
+# This test becomes more cumbersome if we keep the 'errexit' shell flag
+# set. And removing it is no big deal, as this test is a TAP-based one,
+# so that false positives remain very unlikely.
+set +e
+
+AM_TESTS_REEXEC=no; export AM_TESTS_REEXEC
+
+# It's especially important that the 'unset' is done before sourcing
+# ./defs, i.e., when 'set -e' is not active yet, for the benefit of shells
+# (like Bash 2.05 and Solaris 10 /bin/ksh) that returns a non-zero status
+# when unsetting an already-unset variable.
+init='stderr_fileno_=2; unset am_explicit_skips; . ./defs'
+
+for st in 1 2 3 4 5 77 99 126 127 128 129 130 255; do
+ for exit_cmd in "Exit $st" "sh -c 'exit $st'"; do
+ $SHELL -c "$init; $exit_cmd; :"
+ command_ok_ "$exit_cmd" test $? -eq $st
+ done
+done
+
+for sig in 1 2 13 15; do
+ if is_blocked_signal $sig; then
+ skip_ -r "signal $sig seems blocked"
+ continue
+ fi
+ if test $sig -eq 2; then
+ # Some Korn shells might otherwise get a spurious SIGINT signal when
+ # one is sent to the child $SHELL. For more details, see:
+ # <http://lists.gnu.org/archive/html/bug-autoconf/2011-09/msg00004.html>
+ trap : 2
+ fi
+ $SHELL -c "$init; kill -$sig \$\$; :"
+ rc=$?
+ if test $sig -eq 2; then
+ # Reset default SIGINT handler as portably as possible.
+ trap 2 || trap - 2
+ fi
+ if test x"$sh_errexit_works" = x"yes"; then
+ # The exit trap should turn into an hard errors any failure
+ # caused by signals.
+ command_ok_ "kill -$sig" test $rc -eq 99
+ else
+ # The exit trap is not installed, so that the shell should exit
+ # with status 128+n when receiving signal number n. But don't
+ # be too strict in the check, as POSIX only says that "The exit
+ # status of a command that terminated because it received a
+ # signal shall be reported as greater than 128".
+ command_ok_ "kill -$sig" test $rc -gt 128
+ fi
+ unset rc
+done
+
+: Non-existent program.
+# Solaris 10 /bin/sh erroneously exit with success right away when the
+# following three conditions are met at the same time:
+# 1. the 'errexit' flag is active,
+# 2. an exit trap is installed, and
+# 3. a non-existing command is issued.
+# Note that the non-existent command is issued as the last command to
+# the shell in the next line; this is deliberate.
+if $SHELL -c 'set -e; trap "exit \$?" 0; non-existent-program'; then
+ maybe_todo=TODO reason="known Solaris /bin/sh bug"
+else
+ maybe_todo="" reason=""
+fi
+$SHELL -c "$init; non-existent-program; :"
+command_ok_ "command not found" -D "$maybe_todo" -r "$reason" \
+ -- test $? -gt 0
+
+: Non-executable command.
+test -f Makefile && test ! -x Makefile || \
+ framowork_failure_ "no proper Makefile in the current directory"
+$SHELL -c "$init; ./Makefile; :"
+command_ok_ "permission denied" test $? -gt 0
+
+: Syntax errors in the test code.
+$SHELL -c "$init; if :; then"
+command_ok_ "syntax error 1" test $? -gt 0
+$SHELL -c "$init; fi"
+command_ok_ "syntax error 2" test $? -gt 0
+
+:
diff --git a/t/self-check-explicit-skips.sh b/t/self-check-explicit-skips.sh
new file mode 100755
index 000000000..602c31c3b
--- /dev/null
+++ b/t/self-check-explicit-skips.sh
@@ -0,0 +1,54 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Sanity check for the automake testsuite.
+# Check creation/removal of temporary test working directory by './defs'.
+
+am_create_testdir=empty
+. ./defs || Exit 1
+
+test x"$sh_errexit_works" = x"yes" || skip_ "no working shell exit trap"
+
+# We still need a little hack to make ./defs work outside automake's
+# tree 'tests' subdirectory. Not a big deal.
+sed "s|^testbuilddir=.*|testbuilddir='`pwd`'|" ../defs-static >defs-static
+diff ../defs-static defs-static && Exit 99
+cp ../defs .
+
+set +e
+
+unset am_explicit_skips stderr_fileno_
+AM_TESTS_REEXEC=no; export AM_TESTS_REEXEC
+
+$SHELL -c '. ./defs; (exit 77); exit 77' dummy.test
+test $? -eq 77 || Exit 1
+
+am_explicit_skips=no $SHELL -c '. ./defs; sh -c "exit 77"' dummy.test
+test $? -eq 77 || Exit 1
+
+am_explicit_skips=yes $SHELL -c '. ./defs; (exit 77); exit 77' dummy.test
+test $? -eq 78 || Exit 1
+
+am_explicit_skips=y $SHELL -c '. ./defs; sh -c "exit 77"' dummy.test
+test $? -eq 78 || Exit 1
+
+am_explicit_skips=yes $SHELL -c '. ./defs; Exit 77' dummy.test
+test $? -eq 77 || Exit 1
+
+am_explicit_skips=y $SHELL -c '. ./defs; skip_ "foo"' dummy.test
+test $? -eq 77 || Exit 1
+
+:
diff --git a/t/self-check-is-blocked-signal.tap b/t/self-check-is-blocked-signal.tap
new file mode 100755
index 000000000..5c0dded07
--- /dev/null
+++ b/t/self-check-is-blocked-signal.tap
@@ -0,0 +1,29 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Sanity check for the automake testsuite: the 'signal_is_blocked'
+# shell function.
+
+am_create_testdir=no
+. ./defs || Exit 99
+
+plan_ 2
+
+command_ok_ "unblockable signal 9" not is_blocked_signal 9
+trap "" 13
+command_ok_ "blocked signal 13" is_blocked_signal 13
+
+:
diff --git a/t/self-check-is_newest.tap b/t/self-check-is_newest.tap
new file mode 100755
index 000000000..76b69acb4
--- /dev/null
+++ b/t/self-check-is_newest.tap
@@ -0,0 +1,80 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Sanity check for the automake testsuite: the 'is_newest' subroutine.
+
+. ./defs || Exit 1
+
+plan_ 21
+
+# I'm a lazy typist.
+Y () { command_ok_ "is_newest $*" is_newest "$@"; }
+N () { command_ok_ "not is_newest $*" not is_newest "$@"; }
+
+: > a
+$sleep
+: > b
+: > c
+
+stat a b c || : # For debugging.
+
+Y c a
+Y b a
+N a b
+Y c b
+Y c c
+Y c a b c
+
+touch -r c d
+
+stat c d || : # For debugging.
+
+Y c d
+
+# Should work on directories too, both empty and not-empty. An older
+# implementation of 'is_newest' failed if the first argument was a
+# directory containing files newer than itself (see automake bug#9147).
+mkdir u x
+touch x/foo
+$sleep
+touch x/foo
+$sleep
+mkdir v y
+touch y/foo
+$sleep
+touch y/foo
+
+stat u v x y x/foo y/foo || : # For debugging.
+
+for older in u x; do
+ for newer in v y; do
+ Y $newer $older
+ N $older $newer
+ done
+done
+
+Y x/foo x
+N x x/foo
+
+touch -r x u
+Y x u
+Y u x
+
+# A couple of mild "stress" tests.
+Y y x u v
+Y y u x/foo a b c
+
+:
diff --git a/t/self-check-me.tap b/t/self-check-me.tap
new file mode 100755
index 000000000..5c83ee6d3
--- /dev/null
+++ b/t/self-check-me.tap
@@ -0,0 +1,73 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Sanity check for the automake testsuite.
+# Make sure that $me gets automatically defined by './defs', and that it
+# can be overridden by the test script.
+
+am_create_testdir=no
+. ./defs || Exit 1
+
+plan_ 14
+
+AM_TESTS_REEXEC=no; export AM_TESTS_REEXEC
+
+# This test becomes cumbersome if we keep the 'errexit' shell flag set.
+# And removing it is no big deal, as this test is a TAP-based one, so
+# that false positives remain very unlikely.
+set +e
+
+do_check ()
+{
+ $SHELL -c '. ./defs && echo me=$me' "$1" | grep "^me=$2$"
+ command_ok_ "me=$1" test $? -eq 0
+}
+
+for e in sh tap; do
+ do_check foo-bar-.$e 'foo-bar-'
+ do_check _foo__bar.$e '_foo__bar'
+ do_check 012.$e '012'
+ do_check a.b.c.$e 'a\.b\.c'
+done
+
+do_check foo.bar 'foo\.bar'
+do_check abc. 'abc\.'
+
+# If we override $me, ./defs should not modify it.
+
+s=`$SHELL -c 'me=foo.sh && . ./defs && echo me=$me' bad.sh`
+command_ok_ "override of \$me before ./defs causes no error" \
+ test $? -eq 0
+
+r='ok'
+printf '%s\n' "$s" | grep '^me=foo\.sh$' || r='not ok'
+printf '%s\n' "$s" | grep 'me=bad' && r='not ok'
+result_ "$r" "override of \$me before ./defs is honored"
+unset r
+
+# Overriding $me after sourcing ./defs-static should work.
+s=`$SHELL -c '. ./defs-static && me=zardoz &&
+ . ./defs && echo me=$me' bad.sh`
+command_ok_ "override of \$me after ./defs-static causes no error" \
+ test $? -eq 0
+
+r='ok'
+printf '%s\n' "$s" | grep '^me=zardoz$' || r='not ok'
+printf '%s\n' "$s" | grep 'me=bad' && r='not ok'
+result_ "$r" "override of \$me after ./defs-static is honored"
+unset r
+
+:
diff --git a/t/self-check-reexec.tap b/t/self-check-reexec.tap
new file mode 100755
index 000000000..48e5cfb2e
--- /dev/null
+++ b/t/self-check-reexec.tap
@@ -0,0 +1,205 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Sanity check for the automake testsuite.
+# Check that automatic re-execution of test script with the
+# configure-time $SHELL.
+
+am_create_testdir=empty
+. ./defs || Exit 1
+
+plan_ 32
+
+unset AM_TESTS_REEXEC BASH_VERSION || :
+
+cwd=`pwd` || fatal_ "cannot get current working directory"
+cp ../defs .
+
+#
+# Search for required bash and non-bash shells.
+#
+
+for bash_shell in "$SHELL" bash bash3 bash4 :; do
+ test "$bash_shell" = : && break
+ $bash_shell --version || continue
+ $bash_shell -c 'test -n "$BASH_VERSION"' || continue
+ break
+done
+
+# This might not be optimal, but it's much better than writing wrapper
+# scripts acting as "fake" shells.
+for non_bash_shell in /bin/sh /bin/ksh "$SHELL" sh ksh ash dash pdksh :; do
+ test "$non_bash_shell" = : && break
+ $non_bash_shell -c 'exit 0' || continue
+ $non_bash_shell -c 'test -n "$BASH_VERSION"' && continue
+ break
+done
+
+echo "bash_shell='$bash_shell'"
+echo "non_bash_shell='$non_bash_shell'"
+
+# This would denote an internal error.
+if test "$bash_shell" = : && test "$non_bash_shell" = :; then
+ fatal_ "we couldn't find a bash shell nor a non-bash one"
+fi
+
+#
+# Functions used throughout the test.
+#
+
+get_ddata ()
+{
+ case $1 in
+ ""|*/) dsep=;;
+ *) dsep=/;;
+ esac
+ case $1 in
+ "") dname="no dir";;
+ /*) dname="absolute dir";;
+ *) dname="dir '$1'";;
+ esac
+}
+
+get_sh ()
+{
+ case $1 in
+ bash) sh=$bash_shell;;
+ non-bash) sh=$non_bash_shell;;
+ *) fatal_ "get_sh: invalid shell type '$1'";;
+ esac
+}
+
+#
+# Check how to default, force or prevent a re-execution.
+#
+
+cat > need-bash.sh <<'END'
+#!/bin/false
+. ./defs
+# Ensure that the script gets re-executed with bash. Also ensure that
+# non-standard syntax used after the inclusion of './defs' doesn't cause
+# non-bash shells to fail.
+# Subshell required to prevent some shells (e.g., Solaris 10 /bin/sh)
+# from only complaining on stderr but then exiting with exit status 0.
+(foo=abac && test xbxc = ${foo//a/x} && test -n "$BASH_VERSION")
+END
+
+sed -e "s|^testbuilddir=.*|testbuilddir='$cwd'|" \
+ -e 's|^SHELL=.*$|SHELL=bash; export SHELL|' \
+ < ../defs-static >defs-static
+
+do_reexec ()
+{
+ command_ok_ "re-exec if AM_TESTS_REEXEC=$1" \
+ env AM_TESTS_REEXEC="$1" $non_bash_shell need-bash.sh
+}
+
+dont_reexec ()
+{
+ command_ok_ "don't re-exec if AM_TESTS_REEXEC=$1" \
+ not env AM_TESTS_REEXEC="$1" $non_bash_shell need-bash.sh
+}
+
+if test "$bash_shell" = :; then
+ skip_row_ 10 -r "no bash shell found" AM_TESTS_REEXEC
+elif test "$non_bash_shell" = :; then
+ skip_row_ 10 -r "no non-bash shell found" AM_TESTS_REEXEC
+else
+ command_ok_ "re-exec if AM_TESTS_REEXEC unset" \
+ $non_bash_shell need-bash.sh
+ do_reexec ''
+ do_reexec yes
+ do_reexec y
+ do_reexec true
+ do_reexec 1
+ dont_reexec no
+ dont_reexec n
+ dont_reexec false
+ dont_reexec 0
+fi
+
+#
+# Check message about the re-execution. Also check that arguments passed
+# to a test script are preserved by a re-exec, even in "corner" cases.
+#
+
+cat > dummy.sh <<'END'
+#!/bin/sh
+. ./defs
+:
+END
+
+cat > checkargs.sh <<'END'
+. ./defs
+test $# -eq 3 && test x"$1" = x'a' && test x"$2" = x && test x"$3" = x"-e"
+END
+
+chmod a+x dummy.sh checkargs.sh
+
+mkdir sub
+cp dummy.sh checkargs.sh defs sub
+sed -e "s|^testbuilddir=.*|testbuilddir='$cwd'|" \
+ < ../defs-static > defs-static
+sed -e "s|^testbuilddir=.*|testbuilddir='$cwd/sub'|" \
+ < ../defs-static > sub/defs-static
+
+check_preserve_args ()
+{
+ dir=$1; shift
+ get_ddata "$dir"
+ $sh "${dir}${dsep}checkargs.sh" a '' -e && r='ok' || r='not ok'
+ result_ "$r" "$sh re-exec preserving args [$dname]"
+}
+
+check_reexec_message ()
+{
+ dir=$1; shift
+ get_ddata "$dir"
+ $sh "${dir}${dsep}dummy.sh" "$@" \
+ | grep "^dummy: exec $SHELL ${dir}${dsep}dummy\\.sh $*\$" \
+ && r='ok' || r='not ok'
+ result_ "$r" "$sh display re-exec message [$dname] [args: $*]"
+}
+
+./dummy.sh a b | grep "^dummy: exec $SHELL \\./dummy\\.sh a b$" \
+ && r='ok' || r='not ok'
+result_ "$r" "direct run display re-exec message [args: a b]"
+
+./checkargs.sh a '' -e && r='ok' || r='not ok'
+result_ "$r" "direct re-exec preserving args"
+
+for sh_type in non-bash bash; do
+ get_sh $sh_type
+ if test "$sh" = :; then
+ skip_row_ 5 -r "no $sh_type shell available" "re-exec message"
+ skip_row_ 5 -r "no $sh_type shell available" "re-exec preserving args"
+ continue
+ fi
+ check_preserve_args ''
+ check_reexec_message '' a b c
+ check_preserve_args .
+ check_reexec_message . a b c
+ cd sub
+ check_preserve_args ..
+ check_reexec_message .. a b c
+ cd ..
+ check_preserve_args "$cwd"
+ check_reexec_message "$cwd" a -b c-
+ check_preserve_args sub
+ check_reexec_message sub 1 2 3 4
+done
+
+:
diff --git a/t/self-check-report.sh b/t/self-check-report.sh
new file mode 100755
index 000000000..e5998b55c
--- /dev/null
+++ b/t/self-check-report.sh
@@ -0,0 +1,54 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Sanity check for the automake testsuite.
+# Test subroutines to report warnings, and to signal failures, skips
+# and hard errors.
+
+unset stderr_fileno_ || :
+
+am_create_testdir=empty
+. ./defs || Exit 1
+
+set +e
+
+exec 5>&1
+
+(warn_ foobar) 2>&1 1>&5 | grep '^foobar$' || Exit 1
+(fail_ foo); test $? -eq 1 || Exit 1
+(fail_ foo) 2>&1 1>&5 | grep "^$me: failed test: foo" || Exit 1
+(skip_ foo); test $? -eq 77 || Exit 1
+(skip_ foo) 2>&1 1>&5 | grep "^$me: skipped test: foo" || Exit 1
+(fatal_ foo); test $? -eq 99 || Exit 1
+(fatal_ foo) 2>&1 1>&5 | grep "^$me: hard error: foo" || Exit 1
+(framework_failure_ foo); test $? -eq 99 || Exit 1
+(framework_failure_ foo) 2>&1 1>&5 \
+ | grep "^$me: set-up failure: foo" || Exit 1
+
+stderr_fileno_=6
+
+(warn_ foobar) 6>&1 1>&5 | grep '^foobar$' || Exit 1
+(fail_ foo); test $? -eq 1 || Exit 1
+(fail_ foo) 6>&1 1>&5 | grep "^$me: failed test: foo" || Exit 1
+(skip_ foo); test $? -eq 77 || Exit 1
+(skip_ foo) 6>&1 1>&5 | grep "^$me: skipped test: foo" || Exit 1
+(fatal_ foo); test $? -eq 99 || Exit 1
+(fatal_ foo) 6>&1 1>&5 | grep "^$me: hard error: foo" || Exit 1
+(framework_failure_ foo); test $? -eq 99 || Exit 1
+(framework_failure_ foo) 6>&1 1>&5 \
+ | grep "^$me: set-up failure: foo" || Exit 1
+
+:
diff --git a/t/self-check-sanity.sh b/t/self-check-sanity.sh
new file mode 100755
index 000000000..8a6b85c42
--- /dev/null
+++ b/t/self-check-sanity.sh
@@ -0,0 +1,72 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Sanity check for the automake testsuite.
+# Test the sanity checks performed by the 'defs' script. Also check
+# that we can use 'defs' elsewhere, when we duplicate some of the
+# infrastructure from the automake/tests subdirectory.
+
+am_create_testdir=empty
+. ./defs || Exit 1
+
+# Avoid to confuse traces from child processed with our own traces.
+show_stderr ()
+{
+ sed 's/^/ | /' stderr >&2
+}
+
+AM_TESTS_REEXEC=no; export AM_TESTS_REEXEC
+
+if $SHELL -c '. ../defs' dummy.test 2>stderr; then
+ show_stderr
+ Exit 1
+else
+ show_stderr
+ grep 'defs-static: not found in current directory' stderr
+fi
+
+sed 's|^testsrcdir=.*|testsrcdir=foo|' ../defs-static > defs-static
+if $SHELL -c '. ../defs' dummy.test 2>stderr; then
+ show_stderr
+ Exit 1
+else
+ show_stderr
+ grep 'foo/defs-static\.in not found.*check \$testsrcdir' stderr
+fi
+
+sed 's|^testbuilddir=.*|testbuilddir=foo|' ../defs-static > defs-static
+if $SHELL -c '. ../defs' dummy.test 2>stderr; then
+ show_stderr
+ Exit 1
+else
+ show_stderr
+ grep 'foo/defs-static not found.*check \$testbuilddir' stderr
+fi
+
+# We still need a little hack to make ./defs work outside automake's
+# tree 'tests' subdirectory. Not a big deal.
+sed "s|^testbuilddir=.*|testbuilddir='`pwd`'|" ../defs-static >defs-static
+# Redefining *srcdir and *builddir variables in the environment shouldn't
+# cause problems
+env \
+ builddir=bad-dir srcdir=bad-dir \
+ top_builddir=bad-dir top_srcdir=bad-dir \
+ abs_builddir=bad-dir abs_srcdir=bad-dir \
+ abs_top_builddir=bad-dir abs_top_srcdir=bad-dir \
+ $SHELL -c '. ../defs && echo "!OK!" > ../foo' dummy.test
+$FGREP '!OK!' foo
+
+:
diff --git a/t/self-check-seq.tap b/t/self-check-seq.tap
new file mode 100755
index 000000000..a92230ea5
--- /dev/null
+++ b/t/self-check-seq.tap
@@ -0,0 +1,75 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Sanity check for the automake testsuite.
+# Check the 'seq_' subroutine.
+
+. ./defs || Exit 1
+
+plan_ 14
+
+unset stderr_fileno_ || :
+
+check_work ()
+{
+ desc=$1 args=$2 exp=$3
+ st=0; got=`seq_ $args` || st=$?
+ command_ok_ "$desc [exit status = 0]" test $st -eq 0
+ command_ok_ "$desc [output]" test x"$exp" = x"$got"
+}
+
+check_work 'one-argument form' '5' "\
+1
+2
+3
+4
+5"
+
+check_work 'two-arguments form' '7 11' "\
+7
+8
+9
+10
+11"
+
+check_work 'three-arguments form (1)' '120 5 135' "\
+120
+125
+130
+135"
+
+check_work 'three-arguments form (1)' '13 4 23' "\
+13
+17
+21"
+
+check_err ()
+{
+ desc=$1 args=$2 err=$3
+ (seq_ $args) >output || st=$?
+ # Protect content emitted on stdout/stderr, to avoid sending to the
+ # TAP driver possible "Bail out!" directives generated by 'seq_'.
+ # Use 'grep -c' below for the same reason.
+ sed 's/^/: /' output
+ command_ok_ "$desc [exit status = 99]" test $st -eq 99
+ command_ok_ "$desc [error message]" grep -c "seq_: $err" output
+}
+
+check_err 'no argument is an error' '' 'missing argument'
+check_err 'four arguments is an error' '1 1 2 1' 'too many arguments'
+check_err 'six arguments is an error' '1 1 1 1 1 1' 'too many arguments'
+
+:
diff --git a/t/self-check-tap.sh b/t/self-check-tap.sh
new file mode 100755
index 000000000..6a2d132fd
--- /dev/null
+++ b/t/self-check-tap.sh
@@ -0,0 +1,43 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Sanity check for the automake testsuite.
+# Make sure that $am_using_tap gets automatically defined by
+# './defs-static', but can be overridden by the individual tests.
+
+. ./defs-static || exit 1
+
+set -ex
+
+$SHELL -c '. ./defs-static && test $am_using_tap = yes' foo.tap
+$SHELL -c '. ./defs-static && test $am_using_tap = no' foo.test
+$SHELL -c '. ./defs-static && test $am_using_tap = no' tap
+$SHELL -c '. ./defs-static && test $am_using_tap = no' tap.test
+$SHELL -c '. ./defs-static && test $am_using_tap = no' foo-tap
+
+$SHELL -c '
+ am_using_tap=no
+ . ./defs-static
+ test $am_using_tap = no
+' foo.tap
+
+$SHELL -c '
+ am_using_tap=yes
+ . ./defs-static
+ test $am_using_tap = yes
+' foo.test
+
+:
diff --git a/t/self-check-unindent.tap b/t/self-check-unindent.tap
new file mode 100755
index 000000000..3591656e6
--- /dev/null
+++ b/t/self-check-unindent.tap
@@ -0,0 +1,255 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Sanity check for the automake testsuite.
+# Check the 'unindent' subroutine.
+
+. ./defs || Exit 1
+
+plan_ 22
+
+#------------------------------------------------------------------
+
+will_test () { tst=$*; }
+
+do_check ()
+{
+ command_ok_ "$tst [simple, exit status]" \
+ eval 'unindent input > got'
+ command_ok_ "$tst [simple, output]" \
+ diff exp got
+ command_ok_ "$tst [parallel, exit status]" \
+ eval 'unindent input | unindent > got'
+ command_ok_ "$tst [parallel, output]" \
+ diff exp got
+}
+
+#------------------------------------------------------------------
+
+will_test 'leading spaces'
+
+cat > input <<END
+ 1
+ 2
+3
+ 4
+${tab}5
+${tab} 6
+ 6${sp}
+7${sp}
+ 8${sp}${sp}
+9${sp}${sp}
+ 10${tab}
+11${tab}
+ 12${sp}${tab}
+13${sp}${tab}
+ 14 this${tab}with${tab}multiple fields${sp}
+15 and ${tab}${tab}this too${tab}
+ 16 and also this
+${sp}${sp}
+${sp}
+${tab}
+
+last line
+END
+
+cat > exp <<END
+1
+ 2
+3
+ 4
+${tab}5
+${tab} 6
+6${sp}
+7${sp}
+8${sp}${sp}
+9${sp}${sp}
+10${tab}
+11${tab}
+12${sp}${tab}
+13${sp}${tab}
+14 this${tab}with${tab}multiple fields${sp}
+15 and ${tab}${tab}this too${tab}
+ 16 and also this
+
+${sp}
+${tab}
+
+last line
+END
+
+do_check
+
+#------------------------------------------------------------------
+
+will_test 'leading tab'
+
+cat > input <<END
+${tab}1
+${tab} 2
+3
+ 4
+ 5
+ 6
+ 7
+ ${tab}8
+${tab}${tab}9
+${tab}10${tab}
+${tab}11${sp}
+12${tab}
+13${sp}
+${tab}14 this with${tab}multiple fields${sp}
+15 and ${tab}${tab}this too${tab}
+ 16 and also this
+${tab}
+${sp}
+${sp}${tab}
+
+last line
+END
+
+cat > exp <<END
+1
+ 2
+3
+ 4
+ 5
+ 6
+ 7
+ ${tab}8
+${tab}9
+10${tab}
+11${sp}
+12${tab}
+13${sp}
+14 this with${tab}multiple fields${sp}
+15 and ${tab}${tab}this too${tab}
+ 16 and also this
+
+${sp}
+${sp}${tab}
+
+last line
+END
+
+do_check "leading tab"
+
+#------------------------------------------------------------------
+
+will_test 'no leading whitespace'
+
+cat > input <<END
+1
+ 2
+ 3
+ 4
+${tab}5
+${tab} 6
+ ${tab}7
+${tab}${tab}8
+9${sp}
+ 10${tab}
+${tab}10${sp}${sp}
+14 this with${tab}multiple fields${sp}
+ 15 and this too${tab}
+${tab}16 and also this
+${tab}
+${sp}
+
+last line
+END
+
+cp input exp
+
+do_check
+
+#------------------------------------------------------------------
+
+will_test 'leading empty lines ignored (1)'
+
+cat > input <<END
+
+
+ foo
+ bar
+ quux
+END
+
+cat > exp <<END
+
+
+foo
+bar
+ quux
+END
+
+do_check
+
+#------------------------------------------------------------------
+
+will_test 'leading empty lines ignored (2)'
+
+cat > input <<END
+
+
+foo
+bar
+ quux
+END
+
+cat > exp <<END
+
+
+foo
+bar
+ quux
+END
+
+do_check
+
+#------------------------------------------------------------------
+
+will_test 'more elaborated parallel use'
+
+cat > input <<END
+ x
+ ${tab}y
+ z
+ ${tab}a
+ ${tab} b
+${tab}c
+ ${tab}d
+ ${tab}e
+ ${tab}${tab}f
+END
+
+cat > exp <<END
+y
+z
+a
+ b
+c
+ ${tab}d
+ ${tab}e
+${tab}f
+END
+
+command_ok_ "$tst [exit status]" \
+ eval 'unindent input | sed 1d | unindent > got'
+
+command_ok_ "$tst [output]" diff exp got
+
+:
diff --git a/t/serial-tests.sh b/t/serial-tests.sh
new file mode 100755
index 000000000..680513f5b
--- /dev/null
+++ b/t/serial-tests.sh
@@ -0,0 +1,86 @@
+#! /bin/sh
+# Copyright (C) 2012 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/>.
+
+# Option 'serial-tests'.
+
+# To avoid useless generation of a sibling test.
+am_parallel_tests=yes
+am_create_testdir=empty
+. ./defs || Exit 1
+
+hasnt_parallel_tests ()
+{
+ $EGREP 'TEST_SUITE_LOG|TEST_LOGS|\.log.*:' $1 && Exit 1
+ grep 'recheck.*:' $1 && Exit 1
+ grep '^check-TESTS: \$(TESTS)$' $1
+}
+
+has_parallel_tests ()
+{
+ $EGREP '(^| )check-TESTS.*:' $1
+ $EGREP '(^| )recheck.*:' $1
+ grep '^\$(TEST_SUITE_LOG): \$(TEST_LOGS)$' $1
+ grep '^\.test\.log:$' $1
+}
+
+mkdir one two
+
+cat >> one/configure.ac <<END
+AC_INIT([$me], [1.0])
+AM_INIT_AUTOMAKE([serial-tests])
+AC_CONFIG_FILES([Makefile])
+END
+
+echo 'TESTS = foo.test bar.test' > one/Makefile.am
+
+cat >> two/configure.ac <<END
+AC_INIT([$me], [2.0])
+AC_CONFIG_AUX_DIR([config])
+AM_INIT_AUTOMAKE([parallel-tests])
+AC_CONFIG_FILES([aMakefile bMakefile])
+END
+
+cp one/Makefile.am two/aMakefile.am
+cat - one/Makefile.am > two/bMakefile.am <<END
+AUTOMAKE_OPTIONS = serial-tests
+END
+
+cd one
+touch missing install-sh
+$ACLOCAL
+$AUTOMAKE
+grep TEST Makefile.in # For debugging.
+hasnt_parallel_tests Makefile.in
+test ! -r test-driver
+cd ..
+
+cd two
+mkdir config
+$ACLOCAL
+$AUTOMAKE --add-missing
+grep TEST [ab]Makefile.in # For debugging.
+has_parallel_tests aMakefile.in
+hasnt_parallel_tests bMakefile.in
+mv aMakefile.in aMakefile.sav
+mv bMakefile.in bMakefile.sav
+test ! -r test-driver
+test -f config/test-driver
+$AUTOMAKE
+diff aMakefile.sav aMakefile.in
+diff bMakefile.sav bMakefile.in
+cd ..
+
+:
diff --git a/t/silent-amopts.sh b/t/silent-amopts.sh
new file mode 100755
index 000000000..f71ad13bb
--- /dev/null
+++ b/t/silent-amopts.sh
@@ -0,0 +1,28 @@
+#!/bin/sh
+# Copyright (C) 2012 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/>.
+
+# Check that automake complaints if the 'silent-rules' option is
+# used in AUTOMAKE_OPTIONS.
+
+. ./defs || Exit 1
+
+echo AUTOMAKE_OPTIONS = silent-rules > Makefile.am
+
+$ACLOCAL
+AUTOMAKE_fails
+grep "^Makefile\.am:1:.*'silent-rules'.*AM_INIT_AUTOMAKE" stderr
+
+:
diff --git a/t/silent-configsite.sh b/t/silent-configsite.sh
new file mode 100755
index 000000000..813753b74
--- /dev/null
+++ b/t/silent-configsite.sh
@@ -0,0 +1,84 @@
+#!/bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Check that the user can control default mode of silent-rules
+# from config.site, and that this default can be overridden from
+# either the ./configure or make command line.
+
+. ./defs || Exit 1
+
+cat >> configure.ac <<'EOF'
+AM_SILENT_RULES
+AC_OUTPUT
+EOF
+
+cat > Makefile.am <<'EOF'
+.PHONY: test-silent test-nosilent
+test-silent:
+ test x'$(AM_DEFAULT_VERBOSITY)' = x'0'
+test-nosilent:
+ test x'$(AM_DEFAULT_VERBOSITY)' = x'1'
+EOF
+
+unset enable_silent_rules || :
+
+: 'No explicit default in configure.ac, enable by default in config.site'
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+echo "enable_silent_rules=\${enable_silent_rules-yes}" > config.site
+CONFIG_SITE=./config.site ./configure
+$MAKE test-silent
+$MAKE distclean
+# Command line should win over default values in config.site.
+CONFIG_SITE=./config.site ./configure --disable-silent-rules
+$MAKE test-nosilent
+$MAKE distclean
+
+: 'Disable by default in configure.ac, enable by default in config.site'
+
+sed 's/^AM_SILENT_RULES/&([no])/' configure.ac > configure.tmp
+mv -f configure.tmp configure.ac
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+echo "enable_silent_rules=\${enable_silent_rules-yes}" > config.site
+CONFIG_SITE=./config.site ./configure
+$MAKE test-silent
+# Command line should win over default values in config.site.
+$MAKE distclean
+CONFIG_SITE=./config.site ./configure --disable-silent-rules
+$MAKE test-nosilent
+$MAKE distclean
+
+: 'Enable by default in configure.ac, disable by default in config.site'
+
+sed 's/^AM_SILENT_RULES/&([yes])/' configure.ac > configure.tmp
+mv -f configure.tmp configure.ac
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+echo "enable_silent_rules=\${enable_silent_rules-no}" > config.site
+CONFIG_SITE=./config.site ./configure
+$MAKE test-nosilent
+$MAKE distclean
+# Command line should win over default values in config.site.
+CONFIG_SITE=./config.site ./configure --enable-silent-rules
+$MAKE test-silent
+$MAKE distclean
+
+:
diff --git a/t/silent-lex.sh b/t/silent-lex.sh
new file mode 100755
index 000000000..2838d6e80
--- /dev/null
+++ b/t/silent-lex.sh
@@ -0,0 +1,139 @@
+#!/bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Check silent-rules mode for Lex.
+
+required=lex
+. ./defs || Exit 1
+
+mkdir sub
+
+cat >>configure.ac <<'EOF'
+AM_SILENT_RULES
+AM_PROG_CC_C_O
+AC_PROG_LEX
+AC_CONFIG_FILES([sub/Makefile])
+AC_OUTPUT
+EOF
+
+cat > Makefile.am <<'EOF'
+# Need generic and non-generic rules.
+bin_PROGRAMS = foo1 foo2
+foo1_SOURCES = foo.l
+foo2_SOURCES = $(foo1_SOURCES)
+foo2_LFLAGS = -n
+foo2_CFLAGS = $(AM_CFLAGS)
+SUBDIRS = sub
+LDADD = $(LEXLIB)
+EOF
+
+cat > sub/Makefile.am <<'EOF'
+AUTOMAKE_OPTIONS = subdir-objects
+# Need generic and non-generic rules.
+bin_PROGRAMS = bar1 bar2
+bar1_SOURCES = bar.l
+bar2_SOURCES = $(bar1_SOURCES)
+bar2_LFLAGS = -n
+bar2_CFLAGS = $(AM_CFLAGS)
+LDADD = $(LEXLIB)
+EOF
+
+cat > foo.l <<'EOF'
+%{
+#define YY_NO_UNISTD_H 1
+%}
+%%
+"END" return EOF;
+.
+%%
+/* Avoid possible link errors. */
+int yywrap (void) { return 1; }
+int main (void) { return 0; }
+EOF
+cp foo.l sub/bar.l
+
+$ACLOCAL
+$AUTOMAKE --add-missing
+$AUTOCONF
+
+# Ensure per-target rules are used, to ensure their coverage below.
+$FGREP 'foo2-foo.c' Makefile.in || Exit 99
+$FGREP 'bar2-bar.c' sub/Makefile.in || Exit 99
+
+./configure --enable-silent-rules
+
+$MAKE >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+$EGREP ' (-c|-o)' stdout && Exit 1
+$EGREP '(mv|ylwrap) ' stdout && Exit 1
+
+grep 'LEX .*foo\.' stdout
+grep 'LEX .*bar\.' stdout
+grep ' CC .*foo\.' stdout
+grep ' CC .*bar\.' stdout
+grep 'CCLD .*foo1' stdout
+grep 'CCLD .*bar1' stdout
+grep 'CCLD .*foo2' stdout
+grep 'CCLD .*bar2' stdout
+
+# Cleaning and then rebuilding with the same V flag (and without
+# removing the generated sources in between) shouldn't trigger a
+# different set of rules.
+$MAKE clean
+
+$MAKE >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+$EGREP ' (-c|-o)' stdout && Exit 1
+$EGREP '(mv|ylwrap) ' stdout && Exit 1
+
+# Don't look for LEX, as probably lex hasn't been re-run.
+grep ' CC .*foo\.' stdout
+grep ' CC .*bar\.' stdout
+grep 'CCLD .*foo1' stdout
+grep 'CCLD .*bar1' stdout
+grep 'CCLD .*foo2' stdout
+grep 'CCLD .*bar2' stdout
+
+# Ensure a truly clean rebuild.
+$MAKE clean
+rm -f *foo.c sub/*bar.c
+
+$MAKE V=1 >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+grep ' -c ' stdout
+grep ' -o ' stdout
+grep 'ylwrap ' stdout
+
+$EGREP '(LEX|CC|CCLD) ' stdout && Exit 1
+
+# Cleaning and then rebuilding with the same V flag (and without
+# removing the generated sources in between) shouldn't trigger a
+# different set of rules.
+$MAKE clean
+
+$MAKE V=1 >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+# Don't look for ylwrap, as probably lex hasn't been re-run.
+grep ' -c ' stdout
+grep ' -o ' stdout
+
+$EGREP '(LEX|CC|CCLD) ' stdout && Exit 1
+
+:
diff --git a/t/silent-many-gcc.sh b/t/silent-many-gcc.sh
new file mode 100755
index 000000000..8b457caaf
--- /dev/null
+++ b/t/silent-many-gcc.sh
@@ -0,0 +1,241 @@
+#!/bin/sh
+# Copyright (C) 2009-2012 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/>.
+
+# Check silent-rules mode, with gcc depmode and many languages at once.
+# This test partly overlaps with other silent*.test, but it serves as
+# a stress test by using many different languages at once -- so don't
+# remove this test script.
+# This test requires the GNU compilers; keep it in sync with sister test
+# 'silent-many-generic.test', which should work with generic compilers.
+
+required='gcc g++ gfortran lex yacc'
+. ./defs || Exit 1
+
+# Avoids too much code duplication.
+do_and_check_silent_build ()
+{
+ case $1 in
+ --rebuild) rebuild=true;;
+ *) rebuild=false;;
+ esac
+
+ $MAKE >stdout || { cat stdout; Exit 1; }
+ cat stdout
+ # Avoid spurious failures with SunStudio Fortran compilers.
+ sed '/^NOTICE:/d' stdout > t
+ mv -f t stdout
+ cat stdout
+
+ $EGREP ' (-c|-o)' stdout && Exit 1
+ $EGREP '(mv|ylwrap) ' stdout && Exit 1
+
+ grep 'CXX .*foo1\.' stdout
+ grep 'CXX .*baz1\.' stdout
+ grep 'FC .*foo2\.' stdout
+ grep 'FC .*baz2\.' stdout
+ grep 'F77 .*foo3\.' stdout
+ grep 'F77 .*baz3\.' stdout
+ grep ' CC .*foo5\.' stdout
+ grep ' CC .*baz5\.' stdout
+ grep ' CC .*foo6\.' stdout
+ grep ' CC .*baz6\.' stdout
+
+ grep 'CXXLD .*foo' stdout
+ grep 'CCLD .*bar' stdout
+ grep 'CXXLD .*baz' stdout
+ grep 'CCLD .*bla' stdout
+
+ if $rebuild; then :; else
+ grep 'YACC .*foo6\.' stdout
+ grep 'YACC .*baz6\.' stdout
+ grep 'LEX .*foo5\.' stdout
+ grep 'LEX .*baz5\.' stdout
+ fi
+
+ unset rebuild
+}
+
+# Avoids too much code duplication.
+do_and_check_verbose_build ()
+{
+ case $1 in
+ --rebuild) rebuild=true;;
+ *) rebuild=false;;
+ esac
+
+ $MAKE V=1 >stdout || { cat stdout; Exit 1; }
+ cat stdout
+
+ grep ' -c ' stdout
+ grep ' -o ' stdout
+
+ $EGREP '(CC|CXX|FC|F77|LD) ' stdout && Exit 1
+
+ if $rebuild; then :; else
+ grep 'ylwrap ' stdout
+ $EGREP '(LEX|YACC) ' stdout && Exit 1
+ fi
+
+ unset rebuild
+}
+
+mkdir sub
+
+cat >>configure.ac <<'EOF'
+AM_SILENT_RULES
+AM_PROG_CC_C_O
+AC_PROG_CXX
+AC_PROG_F77
+AC_PROG_FC
+AC_PROG_LEX
+AC_PROG_YACC
+AC_CONFIG_FILES([sub/Makefile])
+AC_OUTPUT
+EOF
+
+cat > Makefile.am <<'EOF'
+# Need generic and non-generic rules.
+bin_PROGRAMS = foo bar fo2
+bar_CFLAGS = $(AM_CFLAGS)
+foo_SOURCES = foo1.cpp foo2.f90 foo3.f foo5.l foo6.y
+fo2_SOURCES = $(foo_SOURCES)
+fo2_CPPFLAGS = $(AM_CPPFLAGS)
+fo2_FFLAGS = $(AM_FFLAGS)
+fo2_FCFLAGS = $(AM_FCFLAGS)
+fo2_YFLAGS = -v
+fo2_LFLAGS = -n
+SUBDIRS = sub
+AM_YFLAGS = -d
+LDADD = $(LEXLIB)
+BUILT_SOURCES = foo6.h
+EOF
+
+cat > sub/Makefile.am <<'EOF'
+AUTOMAKE_OPTIONS = subdir-objects
+# Need generic and non-generic rules.
+bin_PROGRAMS = baz bla ba2
+bla_CFLAGS = $(AM_CFLAGS)
+baz_SOURCES = baz1.cpp baz2.f90 baz3.f baz5.l baz6.y
+ba2_SOURCES = $(baz_SOURCES)
+ba2_CPPFLAGS = $(AM_CPPFLAGS)
+ba2_FFLAGS = $(AM_FFLAGS)
+ba2_FCFLAGS = $(AM_FCFLAGS)
+ba2_YFLAGS = -v
+ba2_LFLAGS = -n
+AM_YFLAGS = -d
+LDADD = $(LEXLIB)
+BUILT_SOURCES = baz6.h
+EOF
+
+cat > foo1.cpp <<'EOF'
+int main ()
+{
+ return 0;
+}
+EOF
+cat > foo2.f90 <<'EOF'
+ subroutine foo2
+ return
+ end
+EOF
+cat > foo3.f <<'EOF'
+ subroutine foo3
+ return
+ end
+EOF
+cat > foo5.l <<'EOF'
+%{
+#define YY_NO_UNISTD_H 1
+%}
+%%
+"END" return EOF;
+.
+%%
+/* Avoid possible link errors. */
+int yywrap (void)
+{
+ return 1;
+}
+EOF
+cat > foo6.y <<'EOF'
+%{
+void yyerror (char *s) {}
+%}
+%token EOF
+%%
+fubar : 'f' 'o' 'o' 'b' 'a' 'r' EOF {};
+EOF
+cp foo1.cpp bar.c
+cp foo1.cpp sub/baz.c
+cp foo1.cpp sub/bla.c
+cp foo1.cpp sub/baz1.cpp
+cp foo2.f90 sub/baz2.f90
+cp foo3.f sub/baz3.f
+cp foo5.l sub/baz5.l
+cp foo6.y sub/baz6.y
+
+$ACLOCAL
+$AUTOMAKE --add-missing
+$AUTOCONF
+
+# Sanity check: make sure the cache variables we force are really
+# used by configure.
+$FGREP am_cv_CC_dependencies_compiler_type configure
+$FGREP am_cv_CXX_dependencies_compiler_type configure
+# Ensure per-target rules are used, to ensure their coverage below.
+# (We do not do an exhaustive check, that wouldn't be practical).
+$FGREP 'bar-bar.o' Makefile.in
+$FGREP 'fo2-foo5.c' Makefile.in
+$FGREP 'fo2-foo6.c' Makefile.in
+
+# Force gcc ("fast") depmode.
+depmodes="am_cv_CC_dependencies_compiler_type=gcc \
+ am_cv_CXX_dependencies_compiler_type=gcc"
+# This apparently useless "for" loop is here to simplify the syncing
+# with sister test 'silent-many-generic.test'.
+for config_args in \
+ "$depmodes"
+do
+
+ ./configure $config_args --enable-silent-rules
+
+ do_and_check_silent_build
+ # Cleaning and then rebuilding with the same V flag (and without
+ # removing the generated sources in between) shouldn't trigger a
+ # different set of rules.
+ $MAKE clean
+ do_and_check_silent_build --rebuild
+
+ # Ensure a clean rebuild.
+ $MAKE clean
+ # This is required, since these files are not removed by 'make clean'
+ # (as dictated by the GNU Coding Standards).
+ rm -f *foo5.c *foo6.[ch] sub/*baz5.c sub/*baz6.[ch]
+
+ do_and_check_verbose_build
+ # Cleaning and then rebuilding with the same V flag (and without
+ # removing the generated sources in between) shouldn't trigger a
+ # different set of rules.
+ $MAKE clean
+ do_and_check_verbose_build --rebuild
+
+ # Ensure a clean reconfiguration/rebuild.
+ $MAKE clean
+ $MAKE maintainer-clean
+
+done
+
+:
diff --git a/t/silent-many-generic.sh b/t/silent-many-generic.sh
new file mode 100755
index 000000000..394900978
--- /dev/null
+++ b/t/silent-many-generic.sh
@@ -0,0 +1,266 @@
+#!/bin/sh
+# Copyright (C) 2009-2012 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/>.
+
+# Check silent-rules mode, with many languages at once.
+# This test partly overlaps with other silent*.test, but it serves as
+# a stress test by using many different languages at once -- so don't
+# remove this test script.
+# This test should work with generic compilers; keep it in sync with
+# sister test 'silent-many-gcc.test', which requires the GNU compilers
+# and forces the use of gcc depmode.
+
+required='cc c++ fortran fortran77 lex yacc'
+. ./defs || Exit 1
+
+# Avoids too much code duplication.
+do_and_check_silent_build ()
+{
+ case $1 in
+ --rebuild) rebuild=true;;
+ *) rebuild=false;;
+ esac
+
+ $MAKE >stdout || { cat stdout; Exit 1; }
+ cat stdout
+ # Avoid spurious failures with SunStudio Fortran compilers.
+ sed '/^NOTICE:/d' stdout > t
+ mv -f t stdout
+ cat stdout
+
+ $EGREP ' (-c|-o)' stdout && Exit 1
+ $EGREP '(mv|ylwrap) ' stdout && Exit 1
+
+ grep 'CXX .*foo1\.' stdout
+ grep 'CXX .*baz1\.' stdout
+ grep 'FC .*foo2\.' stdout
+ grep 'FC .*baz2\.' stdout
+ grep 'F77 .*foo3\.' stdout
+ grep 'F77 .*baz3\.' stdout
+ grep ' CC .*foo5\.' stdout
+ grep ' CC .*baz5\.' stdout
+ grep ' CC .*foo6\.' stdout
+ grep ' CC .*baz6\.' stdout
+
+ grep 'CXXLD .*foo' stdout
+ grep 'CCLD .*bar' stdout
+ grep 'CXXLD .*baz' stdout
+ grep 'CCLD .*bla' stdout
+
+ if $rebuild; then :; else
+ grep 'YACC .*foo6\.' stdout
+ grep 'YACC .*baz6\.' stdout
+ grep 'LEX .*foo5\.' stdout
+ grep 'LEX .*baz5\.' stdout
+ fi
+
+ unset rebuild
+}
+
+# Avoids too much code duplication.
+do_and_check_verbose_build ()
+{
+ case $1 in
+ --rebuild) rebuild=true;;
+ *) rebuild=false;;
+ esac
+
+ $MAKE V=1 >stdout || { cat stdout; Exit 1; }
+ cat stdout
+
+ grep ' -c ' stdout
+ grep ' -o ' stdout
+
+ $EGREP '(CC|CXX|FC|F77|LD) ' stdout && Exit 1
+
+ if $rebuild; then :; else
+ grep 'ylwrap ' stdout
+ $EGREP '(LEX|YACC) ' stdout && Exit 1
+ fi
+
+ unset rebuild
+}
+
+mkdir sub
+
+cat >>configure.ac <<'EOF'
+AM_SILENT_RULES
+AM_PROG_CC_C_O
+AC_PROG_F77
+AC_PROG_FC
+AC_PROG_LEX
+AC_PROG_YACC
+AC_PROG_CXX
+
+# FIXME: remove this hack once the requirements c++, fortran and fortran77
+# are implemented correctly.
+test -n "`echo $CXX`" || AC_MSG_ERROR([C++ compiler not found], [77])
+test -n "`echo $FC`" || AC_MSG_ERROR([Fortran compiler not found], [77])
+test -n "`echo $F77`" || AC_MSG_ERROR([Fortran 77 compiler not found], [77])
+
+# The SunStudio C++ compiler is unfortunately named 'sunCC' (or even just
+# 'CC', yuck!); similarly and the Portland group C++ compiler is named
+# 'pgCC'. This can cause problems with our grepping checks on the output
+# from make. Avoid these problems by invoking a wrapper script, as
+# filtering the make output proved too fragile.
+case " $CXX " in
+ *'CC '*)
+ AC_MSG_WARN([the C++ compiler '$CXX' name ends with 'CC'])
+ AC_MSG_WARN([it will be wrapped with the custom script 'am--cxx'])
+ echo '#!/bin/sh' > bin/am--cxx
+ echo 'PATH=$saved_PATH; export PATH' >> bin/am--cxx
+ echo "case \$# in" >> bin/am--cxx
+ echo " 0) exec $CXX ;;" >> bin/am--cxx
+ echo " *) exec $CXX \"\$@\" ;;" >> bin/am--cxx
+ echo "esac" >> bin/am--cxx
+ chmod a+x bin/am--cxx
+ CXX=am--cxx
+esac
+
+AC_CONFIG_FILES([sub/Makefile])
+AC_OUTPUT
+EOF
+
+cat > Makefile.am <<'EOF'
+# Need generic and non-generic rules.
+bin_PROGRAMS = foo bar fo2
+bar_CFLAGS = $(AM_CFLAGS)
+foo_SOURCES = foo1.cpp foo2.f90 foo3.f foo5.l foo6.y
+fo2_SOURCES = $(foo_SOURCES)
+fo2_CPPFLAGS = $(AM_CPPFLAGS)
+fo2_FFLAGS = $(AM_FFLAGS)
+fo2_FCFLAGS = $(AM_FCFLAGS)
+fo2_YFLAGS = -v
+fo2_LFLAGS = -n
+SUBDIRS = sub
+AM_YFLAGS = -d
+LDADD = $(LEXLIB)
+BUILT_SOURCES = foo6.h
+EOF
+
+cat > sub/Makefile.am <<'EOF'
+AUTOMAKE_OPTIONS = subdir-objects
+# Need generic and non-generic rules.
+bin_PROGRAMS = baz bla ba2
+bla_CFLAGS = $(AM_CFLAGS)
+baz_SOURCES = baz1.cpp baz2.f90 baz3.f baz5.l baz6.y
+ba2_SOURCES = $(baz_SOURCES)
+ba2_CPPFLAGS = $(AM_CPPFLAGS)
+ba2_FFLAGS = $(AM_FFLAGS)
+ba2_FCFLAGS = $(AM_FCFLAGS)
+ba2_YFLAGS = -v
+ba2_LFLAGS = -n
+AM_YFLAGS = -d
+LDADD = $(LEXLIB)
+BUILT_SOURCES = baz6.h
+EOF
+
+cat > foo1.cpp <<'EOF'
+int main ()
+{
+ return 0;
+}
+EOF
+cat > foo2.f90 <<'EOF'
+ subroutine foo2
+ return
+ end
+EOF
+cat > foo3.f <<'EOF'
+ subroutine foo3
+ return
+ end
+EOF
+cat > foo5.l <<'EOF'
+%{
+#define YY_NO_UNISTD_H 1
+%}
+%%
+"END" return EOF;
+.
+%%
+/* Avoid possible link errors. */
+int yywrap (void)
+{
+ return 1;
+}
+EOF
+cat > foo6.y <<'EOF'
+%{
+void yyerror (char *s) {}
+%}
+%token EOF
+%%
+fubar : 'f' 'o' 'o' 'b' 'a' 'r' EOF {};
+EOF
+cp foo1.cpp bar.c
+cp foo1.cpp sub/baz.c
+cp foo1.cpp sub/bla.c
+cp foo1.cpp sub/baz1.cpp
+cp foo2.f90 sub/baz2.f90
+cp foo3.f sub/baz3.f
+cp foo5.l sub/baz5.l
+cp foo6.y sub/baz6.y
+
+mkdir bin
+saved_PATH=$PATH; export saved_PATH
+PATH=`pwd`/bin$PATH_SEPARATOR$PATH; export PATH
+
+$ACLOCAL
+$AUTOMAKE --add-missing
+$AUTOCONF
+
+# Ensure per-target rules are used, to ensure their coverage below.
+# (We do not do an exhaustive check, that wouldn't be practical).
+$FGREP 'bar-bar.o' Makefile.in
+$FGREP 'fo2-foo5.c' Makefile.in
+$FGREP 'fo2-foo6.c' Makefile.in
+
+# Force dependency tracking explicitly, so that slow dependency
+# extractors are not rejected. Try also with dependency tracking
+# explicitly disabled.
+for config_args in \
+ --enable-dependency-tracking --disable-dependency-tracking
+do
+
+ ./configure $config_args --enable-silent-rules
+
+ do_and_check_silent_build
+ # Cleaning and then rebuilding with the same V flag (and without
+ # removing the generated sources in between) shouldn't trigger a
+ # different set of rules.
+ $MAKE clean
+ do_and_check_silent_build --rebuild
+
+ # Ensure a clean rebuild.
+ $MAKE clean
+ # This is required, since these files are not removed by 'make clean'
+ # (as dictated by the GNU Coding Standards).
+ rm -f *foo5.c *foo6.[ch] sub/*baz5.c sub/*baz6.[ch]
+
+ do_and_check_verbose_build
+ # Cleaning and then rebuilding with the same V flag (and without
+ # removing the generated sources in between) shouldn't trigger a
+ # different set of rules.
+ $MAKE clean
+ do_and_check_verbose_build --rebuild
+
+ # Ensure a clean reconfiguration/rebuild.
+ $MAKE clean
+ $MAKE maintainer-clean
+
+done
+
+:
diff --git a/t/silent-nested-vars.sh b/t/silent-nested-vars.sh
new file mode 100755
index 000000000..c579e2cd7
--- /dev/null
+++ b/t/silent-nested-vars.sh
@@ -0,0 +1,147 @@
+#!/bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check silent-rules mode, on 'make' implementations that do not
+# support nested variables (Bug#9928, Bug#10237).
+
+. ./defs || Exit 1
+
+cat >>configure.ac <<'EOF'
+AM_SILENT_RULES
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_OUTPUT
+EOF
+
+cat > Makefile.am <<'EOF'
+# Need generic and non-generic rules.
+bin_PROGRAMS = foo bar
+bar_CFLAGS = $(AM_CFLAGS)
+
+# Check that AM_V and AM_DEFAULT_V work as advertised.
+pkg_verbose = $(pkg_verbose_@AM_V@)
+pkg_verbose_ = $(pkg_verbose_@AM_DEFAULT_V@)
+pkg_verbose_0 = @echo PKG-GEN $@;
+
+bin_SCRIPTS = oop
+oop:
+ $(pkg_verbose)echo $@ >$@
+
+mostlyclean-local:
+ rm -f oop
+EOF
+
+cat > foo.c <<'EOF'
+int main ()
+{
+ return 0;
+}
+EOF
+cp foo.c bar.c
+
+cat >mymake <<'EOF'
+#! /bin/sh
+makerules=
+
+case $1 in
+ -f)
+ makefile=$2
+ case $2 in
+ -) makerules=`cat` || exit ;;
+ esac ;;
+ *)
+ for makefile in makefile Makefile; do
+ test -f $makefile && break
+ done ;;
+esac
+
+nested_var_pat='^[^#].*\$([^)]*\$'
+if
+ case $makefile in
+ -) printf '%s\n' "$makerules" | grep "$nested_var_pat";;
+ *) grep "$nested_var_pat" $makefile;;
+ esac
+then
+ echo >&2 "mymake: $makefile contains nested variables"
+ exit 1
+fi
+
+case $makefile in
+ -) printf '%s\n' "$makerules" | $mymake_MAKE "$@";;
+ *) exec $mymake_MAKE "$@";;
+esac
+EOF
+chmod a+x mymake
+mymake_MAKE=${MAKE-make}
+MAKE=./mymake
+export MAKE mymake_MAKE
+
+# As a sanity check, verify that 'mymake' rejects Makefiles that
+# use nested variables.
+cat > Makefile <<'END'
+a = $(b$(c))
+all:
+ touch bar
+END
+$MAKE && Exit 99
+mv -f Makefile foo.mk
+$MAKE -f foo.mk && Exit 99
+cat foo.mk | $MAKE -f - && Exit 99
+test -f bar && Exit 99
+sed '/a =/d' foo.mk > Makefile
+$MAKE && test -f bar || Exit 99
+rm -f bar Makefile foo.mk
+
+$ACLOCAL
+$AUTOMAKE --add-missing
+$AUTOCONF
+
+./configure --enable-silent-rules >stdout || { cat stdout; Exit 1; }
+cat stdout
+grep '^checking whether \./mymake supports nested variables\.\.\. no *$' \
+ stdout
+$EGREP 'CC|AM_V|GEN' Makefile # For debugging.
+grep '^AM_V_CC = *\$(am__v_CC_0) *$' Makefile
+grep '^AM_V_GEN = *\$(am__v_GEN_0) *$' Makefile
+$MAKE >stdout || { cat stdout; Exit 1; }
+cat stdout
+$EGREP ' (-c|-o)' stdout && Exit 1
+grep 'mv ' stdout && Exit 1
+grep 'echo .*oop' stdout && Exit 1
+grep 'CC .*foo\.' stdout
+grep 'CC .*bar\.' stdout
+grep 'CCLD .*foo' stdout
+grep 'CCLD .*bar' stdout
+grep 'PKG-GEN .*oop' stdout
+$MAKE distclean
+
+./configure --disable-silent-rules > stdout || { cat stdout; Exit 1; }
+cat stdout
+grep '^checking whether \./mymake supports nested variables\.\.\. no *$' \
+ stdout
+$EGREP 'CC|AM_V|GEN' Makefile # For debugging.
+grep '^AM_V_CC = *\$(am__v_CC_1) *$' Makefile
+grep '^AM_V_GEN = *\$(am__v_GEN_1) *$' Makefile
+
+$MAKE >stdout || { cat stdout; Exit 1; }
+cat stdout
+grep ' -c' stdout
+grep ' -o foo' stdout
+grep ' -o bar' stdout
+grep 'echo .*>oop' stdout
+$EGREP '(CC|LD) ' stdout && Exit 1
+
+:
diff --git a/t/silent-nowarn.sh b/t/silent-nowarn.sh
new file mode 100755
index 000000000..5a547bc13
--- /dev/null
+++ b/t/silent-nowarn.sh
@@ -0,0 +1,44 @@
+#!/bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that the 'silent-rules' mode suppresses the warnings for recursive
+# make variable expansions. This should happen regardless of whether and
+# where these warnings are requested.
+
+. ./defs || Exit 1
+
+cat > configure.ac <<END
+AC_INIT([$me], [1.0])
+# Yes, we repeat the warnings two times, both before and after
+# 'silent-rules'. This is deliberate.
+AM_INIT_AUTOMAKE([gnu -Wall -Wportability-recursive
+ silent-rules
+ -Wall -Wportability-recursive])
+AC_CONFIG_FILES([Makefile])
+END
+
+cat > Makefile.am <<'END'
+AUTOMAKE_OPTIONS = gnu -Wall -Wportability-recursive
+foo = $($(v)) $(x$(v)) $($(v)x) $(y$(v)z)
+END
+
+# Files required bu gnu strictness.
+touch AUTHORS ChangeLog COPYING INSTALL NEWS README THANKS
+
+$ACLOCAL
+$AUTOMAKE --gnu -Wall -Wportability-recursive
+
+:
diff --git a/t/silent-yacc-headers.sh b/t/silent-yacc-headers.sh
new file mode 100755
index 000000000..55ba24700
--- /dev/null
+++ b/t/silent-yacc-headers.sh
@@ -0,0 +1,173 @@
+#!/bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check silent-rules mode for Yacc, when yacc-generated headers are
+# involved (i.e., the '-d' option is in *YFLAGS).
+
+required=yacc
+. ./defs || Exit 1
+
+mkdir sub
+
+cat >>configure.ac <<'EOF'
+AM_SILENT_RULES
+AC_PROG_YACC
+AC_PROG_CC
+AC_OUTPUT
+EOF
+
+cat > Makefile.am <<'EOF'
+# Need generic and non-generic rules.
+AM_YFLAGS = -d
+bin_PROGRAMS = foo bar
+foo_SOURCES = parse.y
+bar_SOURCES = $(foo_SOURCES)
+bar_YFLAGS = $(AM_YFLAGS)
+EOF
+
+cat > parse.y <<'EOF'
+%{
+void yyerror (char *s) { return; }
+int yylex (void) { return 0; }
+int main (void) { return 0; }
+%}
+%token EOF
+%%
+fubar : 'f' 'o' 'o' 'b' 'a' 'r' EOF {};
+EOF
+
+$ACLOCAL
+$AUTOMAKE --add-missing
+$AUTOCONF
+
+# Check that the expected non-generic rules has been truly generated.
+# Otherwise, the coverage offered by this test will be weaker then
+# expected and planned.
+$FGREP 'bar-parse.c' Makefile.in
+$FGREP '$(bar_YFLAGS)' Makefile.in
+
+./configure --enable-silent-rules
+
+$MAKE >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+$EGREP ' (-c|-d|-o)' stdout && Exit 1
+$EGREP '(mv|ylwrap) ' stdout && Exit 1
+
+grep 'YACC *parse\.c' stdout
+grep 'updating *parse\.h' stdout
+grep 'YACC *bar-parse\.c' stdout
+grep 'updating *bar-parse\.h' stdout
+
+grep ' CC *parse\.' stdout
+grep ' CC *bar-parse\.' stdout
+grep 'CCLD *foo' stdout
+grep 'CCLD *bar' stdout
+
+# Check recovering from header removal.
+rm -f parse.h bar-parse.h
+$MAKE parse.h bar-parse.h >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+$EGREP ' (-c|-d|-o)' stdout && Exit 1
+$EGREP '(mv|ylwrap) ' stdout && Exit 1
+
+grep 'YACC *parse\.c' stdout
+grep 'updating *parse\.h' stdout
+grep 'YACC *bar-parse\.c' stdout
+grep 'updating *bar-parse\.h' stdout
+
+# Cleaning and then rebuilding with the same V flag (and without
+# removing the generated sources in between) shouldn't trigger a
+# different set of rules.
+$MAKE clean
+
+$MAKE >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+$EGREP ' (-c|-d|-o)' stdout && Exit 1
+$EGREP '(mv|ylwrap) ' stdout && Exit 1
+
+# Don't look for "YACC *.c" and "updating *.h", as yacc shouldn't
+# have been re-run.
+grep ' CC *parse\.' stdout
+grep ' CC *bar-parse\.' stdout
+grep 'CCLD *foo' stdout
+grep 'CCLD *bar' stdout
+
+# Check recovering from header removal.
+rm -f parse.h bar-parse.h
+$MAKE parse.h bar-parse.h >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+$EGREP ' (-c|-d|-o)' stdout && Exit 1
+$EGREP '(mv|ylwrap) ' stdout && Exit 1
+
+grep 'YACC *parse\.c' stdout
+grep 'updating *parse\.h' stdout
+grep 'YACC *bar-parse\.c' stdout
+grep 'updating *bar-parse\.h' stdout
+
+# Ensure a truly clean rebuild.
+$MAKE maintainer-clean
+
+./configure --enable-silent-rules
+
+$MAKE V=1 >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+grep ' -c ' stdout
+grep ' -o ' stdout
+grep ' -d ' stdout
+grep 'ylwrap ' stdout
+
+$EGREP '(YACC|CC|CCLD) ' stdout && Exit 1
+
+# Check recovering from header removal.
+rm -f parse.h bar-parse.h
+$MAKE V=1 parse.h bar-parse.h >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+grep ' -d ' stdout
+grep 'ylwrap ' stdout
+
+grep 'YACC' stdout && Exit 1
+
+# Cleaning and then rebuilding with the same V flag (and without
+# removing the generated sources in between) shouldn't trigger a
+# different set of rules.
+$MAKE clean
+
+$MAKE V=1 >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+# Don't look for ylwrap, as probably lex hasn't been re-run.
+grep ' -c ' stdout
+grep ' -o ' stdout
+
+$EGREP '(YACC|CC|CCLD) ' stdout && Exit 1
+
+# Check recovering from header removal.
+rm -f parse.h bar-parse.h
+$MAKE V=1 parse.h bar-parse.h >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+grep ' -d ' stdout
+grep 'ylwrap ' stdout
+
+grep 'YACC' stdout && Exit 1
+
+:
diff --git a/t/silent-yacc.sh b/t/silent-yacc.sh
new file mode 100755
index 000000000..35415bfb0
--- /dev/null
+++ b/t/silent-yacc.sh
@@ -0,0 +1,136 @@
+#!/bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Check silent-rules mode for Yacc.
+# Keep this in sync with sister test 'silent-yacc-gcc.test'.
+
+required=yacc
+. ./defs || Exit 1
+
+mkdir sub
+
+cat >>configure.ac <<'EOF'
+AM_SILENT_RULES
+AM_PROG_CC_C_O
+AC_PROG_YACC
+AC_CONFIG_FILES([sub/Makefile])
+AC_OUTPUT
+EOF
+
+cat > Makefile.am <<'EOF'
+# Need generic and non-generic rules.
+bin_PROGRAMS = foo1 foo2
+foo1_SOURCES = foo.y
+foo2_SOURCES = $(foo1_SOURCES)
+foo2_YFLAGS = -v
+foo2_CFLAGS = $(AM_CPPFLAGS)
+SUBDIRS = sub
+EOF
+
+cat > sub/Makefile.am <<'EOF'
+AUTOMAKE_OPTIONS = subdir-objects
+# Need generic and non-generic rules.
+bin_PROGRAMS = bar1 bar2
+bar1_SOURCES = bar.y
+bar2_SOURCES = $(bar1_SOURCES)
+bar2_YFLAGS = -v
+bar2_CFLAGS = $(AM_CPPFLAGS)
+EOF
+
+cat > foo.y <<'EOF'
+%{
+void yyerror (char *s) { return; }
+int yylex (void) { return 0; }
+int main (void) { return 0; }
+%}
+%token EOF
+%%
+fubar : 'f' 'o' 'o' 'b' 'a' 'r' EOF {};
+EOF
+cp foo.y sub/bar.y
+
+$ACLOCAL
+$AUTOMAKE --add-missing
+$AUTOCONF
+
+# Ensure per-target rules are used, to ensure their coverage below.
+$FGREP 'foo2-foo.c' Makefile.in || Exit 99
+$FGREP 'bar2-bar.c' sub/Makefile.in || Exit 99
+
+./configure --enable-silent-rules
+
+$MAKE >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+$EGREP ' (-c|-o)' stdout && Exit 1
+$EGREP '(mv|ylwrap) ' stdout && Exit 1
+
+grep 'YACC .*foo\.' stdout
+grep 'YACC .*bar\.' stdout
+grep ' CC .*foo\.' stdout
+grep ' CC .*bar\.' stdout
+grep 'CCLD .*foo1' stdout
+grep 'CCLD .*bar1' stdout
+grep 'CCLD .*foo2' stdout
+grep 'CCLD .*bar2' stdout
+
+# Cleaning and then rebuilding with the same V flag (and without
+# removing the generated sources in between) shouldn't trigger a
+# different set of rules.
+$MAKE clean
+
+$MAKE >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+$EGREP ' (-c|-o)' stdout && Exit 1
+$EGREP '(mv|ylwrap) ' stdout && Exit 1
+
+# Don't look for YACC, as probably yacc hasn't been re-run.
+grep ' CC .*foo\.' stdout
+grep ' CC .*bar\.' stdout
+grep 'CCLD .*foo1' stdout
+grep 'CCLD .*bar1' stdout
+grep 'CCLD .*foo2' stdout
+grep 'CCLD .*bar2' stdout
+
+# Ensure a truly clean rebuild.
+$MAKE clean
+rm -f *foo.[ch] sub/*bar.[ch]
+
+$MAKE V=1 >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+grep ' -c ' stdout
+grep ' -o ' stdout
+grep 'ylwrap ' stdout
+
+$EGREP '(YACC|CC|CCLD) ' stdout && Exit 1
+
+# Cleaning and then rebuilding with the same V flag (and without
+# removing the generated sources in between) shouldn't trigger a
+# different set of rules.
+$MAKE clean
+
+$MAKE V=1 >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+# Don't look for ylwrap, as probably lex hasn't been re-run.
+grep ' -c ' stdout
+grep ' -o ' stdout
+
+$EGREP '(YACC|CC|CCLD) ' stdout && Exit 1
+
+:
diff --git a/t/silent.sh b/t/silent.sh
new file mode 100755
index 000000000..f914c445c
--- /dev/null
+++ b/t/silent.sh
@@ -0,0 +1,83 @@
+#!/bin/sh
+# Copyright (C) 2009-2012 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/>.
+
+# Check silent-rules mode, without libtool, standard depmode case.
+
+# Please keep this file in sync with silent2.test.
+
+required=cc
+. ./defs || Exit 1
+
+mkdir sub
+
+cat >>configure.ac <<'EOF'
+AM_SILENT_RULES
+AC_CONFIG_FILES([sub/Makefile])
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_OUTPUT
+EOF
+
+cat > Makefile.am <<'EOF'
+# Need generic and non-generic rules.
+bin_PROGRAMS = foo bar
+bar_CFLAGS = $(AM_CFLAGS)
+SUBDIRS = sub
+EOF
+
+cat > sub/Makefile.am <<'EOF'
+AUTOMAKE_OPTIONS = subdir-objects
+# Need generic and non-generic rules.
+bin_PROGRAMS = baz bla
+bla_CFLAGS = $(AM_CFLAGS)
+EOF
+
+cat > foo.c <<'EOF'
+int main ()
+{
+ return 0;
+}
+EOF
+cp foo.c bar.c
+cp foo.c sub/baz.c
+cp foo.c sub/bla.c
+
+$ACLOCAL
+$AUTOMAKE --add-missing
+$AUTOCONF
+
+./configure --enable-silent-rules
+$MAKE >stdout || { cat stdout; Exit 1; }
+cat stdout
+$EGREP ' (-c|-o)' stdout && Exit 1
+grep 'mv ' stdout && Exit 1
+grep 'CC .*foo\.' stdout
+grep 'CC .*bar\.' stdout
+grep 'CC .*baz\.' stdout
+grep 'CC .*bla\.' stdout
+grep 'CCLD .*foo' stdout
+grep 'CCLD .*bar' stdout
+grep 'CCLD .*baz' stdout
+grep 'CCLD .*bla' stdout
+
+$MAKE clean
+$MAKE V=1 >stdout || { cat stdout; Exit 1; }
+cat stdout
+grep ' -c' stdout
+grep ' -o foo' stdout
+$EGREP '(CC|LD) ' stdout && Exit 1
+
+:
diff --git a/t/silent2.sh b/t/silent2.sh
new file mode 100755
index 000000000..6565a2701
--- /dev/null
+++ b/t/silent2.sh
@@ -0,0 +1,84 @@
+#!/bin/sh
+# Copyright (C) 2009-2012 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/>.
+
+# Check silent-rules mode, without libtool, non-fastdep case
+# (so that, with GCC, we also cover the other code paths in depend2).
+
+# Please keep this file in sync with silent.test.
+
+required=gcc
+. ./defs || Exit 1
+
+mkdir sub
+
+cat >>configure.ac <<'EOF'
+AM_SILENT_RULES
+AC_CONFIG_FILES([sub/Makefile])
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_OUTPUT
+EOF
+
+cat > Makefile.am <<'EOF'
+# Need generic and non-generic rules.
+bin_PROGRAMS = foo bar
+bar_CFLAGS = $(AM_CFLAGS)
+SUBDIRS = sub
+EOF
+
+cat > sub/Makefile.am <<'EOF'
+AUTOMAKE_OPTIONS = subdir-objects
+# Need generic and non-generic rules.
+bin_PROGRAMS = baz bla
+bla_CFLAGS = $(AM_CFLAGS)
+EOF
+
+cat > foo.c <<'EOF'
+int main ()
+{
+ return 0;
+}
+EOF
+cp foo.c bar.c
+cp foo.c sub/baz.c
+cp foo.c sub/bla.c
+
+$ACLOCAL
+$AUTOMAKE --add-missing
+$AUTOCONF
+
+./configure am_cv_CC_dependencies_compiler_type=gcc --enable-silent-rules
+$MAKE >stdout || { cat stdout; Exit 1; }
+cat stdout
+$EGREP ' (-c|-o)' stdout && Exit 1
+grep 'mv ' stdout && Exit 1
+grep 'CC .*foo\.' stdout
+grep 'CC .*bar\.' stdout
+grep 'CC .*baz\.' stdout
+grep 'CC .*bla\.' stdout
+grep 'CCLD .*foo' stdout
+grep 'CCLD .*bar' stdout
+grep 'CCLD .*baz' stdout
+grep 'CCLD .*bla' stdout
+
+$MAKE clean
+$MAKE V=1 >stdout || { cat stdout; Exit 1; }
+cat stdout
+grep ' -c' stdout
+grep ' -o foo' stdout
+$EGREP '(CC|LD) ' stdout && Exit 1
+
+:
diff --git a/t/silent3.sh b/t/silent3.sh
new file mode 100755
index 000000000..564a49001
--- /dev/null
+++ b/t/silent3.sh
@@ -0,0 +1,87 @@
+#!/bin/sh
+# Copyright (C) 2009-2012 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/>.
+
+# Check silent-rules mode, with libtool, standard depmode case.
+
+# Please keep this file in sync with silent4.test and silent9.test.
+
+required='cc libtoolize'
+. ./defs || Exit 1
+
+mkdir sub
+
+cat >>configure.ac <<'EOF'
+AM_SILENT_RULES
+AC_CONFIG_FILES([sub/Makefile])
+AC_PROG_CC
+AM_PROG_AR
+AM_PROG_CC_C_O
+AC_PROG_LIBTOOL
+AC_OUTPUT
+EOF
+
+cat > Makefile.am <<'EOF'
+# Need generic and non-generic rules.
+lib_LTLIBRARIES = libfoo.la libbar.la
+libbar_la_CFLAGS = $(AM_CFLAGS)
+SUBDIRS = sub
+EOF
+
+cat > sub/Makefile.am <<'EOF'
+AUTOMAKE_OPTIONS = subdir-objects
+# Need generic and non-generic rules.
+lib_LTLIBRARIES = libbaz.la libbla.la
+libbla_la_CFLAGS = $(AM_CFLAGS)
+EOF
+
+cat > libfoo.c <<'EOF'
+int main ()
+{
+ return 0;
+}
+EOF
+cp libfoo.c libbar.c
+cp libfoo.c sub/libbaz.c
+cp libfoo.c sub/libbla.c
+
+libtoolize
+$ACLOCAL
+$AUTOMAKE --add-missing
+$AUTOCONF
+
+./configure --enable-silent-rules
+$MAKE >stdout || { cat stdout; Exit 1; }
+cat stdout
+$EGREP ' (-c|-o)' stdout && Exit 1
+grep 'mv ' stdout && Exit 1
+grep ' CC .*foo\.' stdout
+grep ' CC .*bar\.' stdout
+grep ' CC .*baz\.' stdout
+grep ' CC .*bla\.' stdout
+grep ' CCLD .*foo' stdout
+grep ' CCLD .*bar' stdout
+grep ' CCLD .*baz' stdout
+grep ' CCLD .*bla' stdout
+
+$MAKE clean
+$MAKE V=1 >stdout || { cat stdout; Exit 1; }
+cat stdout
+grep ' -c' stdout
+grep ' -o libfoo' stdout
+# The libtool command line can contain e.g. a '--tag=CC' option.
+sed 's/--tag=[^ ]*/--tag=x/g' stdout | $EGREP '(CC|LD) ' && Exit 1
+
+:
diff --git a/t/silent4.sh b/t/silent4.sh
new file mode 100755
index 000000000..44b7eb3a0
--- /dev/null
+++ b/t/silent4.sh
@@ -0,0 +1,88 @@
+#!/bin/sh
+# Copyright (C) 2009-2012 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/>.
+
+# Check silent-rules mode, with libtool, non-fastdep case
+# (so that, with GCC, we also cover the other code paths in depend2).
+
+# Please keep this file in sync with silent3.test and silent9.test.
+
+required="libtoolize gcc"
+. ./defs || Exit 1
+
+mkdir sub
+
+cat >>configure.ac <<'EOF'
+AM_SILENT_RULES
+AC_CONFIG_FILES([sub/Makefile])
+AC_PROG_CC
+AM_PROG_AR
+AM_PROG_CC_C_O
+AC_PROG_LIBTOOL
+AC_OUTPUT
+EOF
+
+cat > Makefile.am <<'EOF'
+# Need generic and non-generic rules.
+lib_LTLIBRARIES = libfoo.la libbar.la
+libbar_la_CFLAGS = $(AM_CFLAGS)
+SUBDIRS = sub
+EOF
+
+cat > sub/Makefile.am <<'EOF'
+AUTOMAKE_OPTIONS = subdir-objects
+# Need generic and non-generic rules.
+lib_LTLIBRARIES = libbaz.la libbla.la
+libbla_la_CFLAGS = $(AM_CFLAGS)
+EOF
+
+cat > libfoo.c <<'EOF'
+int main ()
+{
+ return 0;
+}
+EOF
+cp libfoo.c libbar.c
+cp libfoo.c sub/libbaz.c
+cp libfoo.c sub/libbla.c
+
+libtoolize
+$ACLOCAL
+$AUTOMAKE --add-missing
+$AUTOCONF
+
+./configure am_cv_CC_dependencies_compiler_type=gcc --enable-silent-rules
+$MAKE >stdout || { cat stdout; Exit 1; }
+cat stdout
+$EGREP ' (-c|-o)' stdout && Exit 1
+grep 'mv ' stdout && Exit 1
+grep ' CC .*foo\.' stdout
+grep ' CC .*bar\.' stdout
+grep ' CC .*baz\.' stdout
+grep ' CC .*bla\.' stdout
+grep ' CCLD .*foo' stdout
+grep ' CCLD .*bar' stdout
+grep ' CCLD .*baz' stdout
+grep ' CCLD .*bla' stdout
+
+$MAKE clean
+$MAKE V=1 >stdout || { cat stdout; Exit 1; }
+cat stdout
+grep ' -c' stdout
+grep ' -o libfoo' stdout
+# The libtool command line can contain e.g. a '--tag=CC' option.
+sed 's/--tag=[^ ]*/--tag=x/g' stdout | $EGREP '(CC|LD) ' && Exit 1
+
+:
diff --git a/t/silent6.sh b/t/silent6.sh
new file mode 100755
index 000000000..280d25a1b
--- /dev/null
+++ b/t/silent6.sh
@@ -0,0 +1,107 @@
+#!/bin/sh
+# Copyright (C) 2009-2012 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/>.
+
+# Check user extensibility of silent-rules mode.
+
+. ./defs || Exit 1
+
+cat >>configure.ac <<'EOF'
+AM_SILENT_RULES
+AC_OUTPUT
+EOF
+
+cat > Makefile.am <<'EOF'
+my_verbose = $(my_verbose_$(V))
+my_verbose_ = $(my_verbose_$(AM_DEFAULT_VERBOSITY))
+my_verbose_0 = @echo GEN $@;
+
+all-local: foo
+
+foo: foo.in
+ $(my_verbose)cp $(srcdir)/foo.in $@
+EXTRA_DIST = foo.in
+CLEANFILES = foo
+EOF
+
+: >foo.in
+
+$ACLOCAL
+$AUTOMAKE --add-missing
+$AUTOCONF
+
+./configure --enable-silent-rules
+$MAKE >stdout || { cat stdout; Exit 1; }
+cat stdout
+grep '^ *GEN foo *$' stdout
+grep 'cp ' stdout && Exit 1
+
+$MAKE clean
+$MAKE V=1 >stdout || { cat stdout; Exit 1; }
+cat stdout
+grep 'GEN ' stdout && Exit 1
+grep 'cp \.*/foo\.in foo' stdout
+
+$MAKE distclean
+
+./configure --disable-silent-rules
+$MAKE >stdout || { cat stdout; Exit 1; }
+cat stdout
+grep 'GEN ' stdout && Exit 1
+grep 'cp \.*/foo\.in foo' stdout
+
+$MAKE clean
+$MAKE V=0 >stdout || { cat stdout; Exit 1; }
+cat stdout
+grep '^ *GEN foo *$' stdout
+grep 'cp ' stdout && Exit 1
+
+$MAKE distclean
+
+$sleep
+# Things should also work with -Wall in AM_INIT_AUTOMAKE.
+cat > configure.ac <<'END'
+AC_INIT([silent6], [1.0])
+AM_INIT_AUTOMAKE([-Wall])
+AC_CONFIG_FILES([Makefile])
+END
+
+$ACLOCAL
+AUTOMAKE_fails
+$AUTOMAKE -Wno-error
+
+# AM_SILENT_RULES should turn off the warning.
+$sleep
+echo 'AM_SILENT_RULES' >> configure.ac
+$ACLOCAL
+$AUTOMAKE
+grep 'AM_V_GEN' Makefile.in
+$AUTOMAKE --force -Wno-all -Wportability
+grep 'AM_V_GEN' Makefile.in
+
+# The 'silent-rules' option to AM_INIT_AUTOMAKE should work likewise.
+$sleep
+cat > configure.ac <<'END'
+AC_INIT([silent6], [1.0])
+AM_INIT_AUTOMAKE([silent-rules])
+AC_CONFIG_FILES([Makefile])
+END
+$ACLOCAL
+$AUTOMAKE
+grep 'AM_V_GEN' Makefile.in
+$AUTOMAKE --force -Wno-all -Wportability
+grep 'AM_V_GEN' Makefile.in
+
+:
diff --git a/t/silent7.sh b/t/silent7.sh
new file mode 100755
index 000000000..02ef287de
--- /dev/null
+++ b/t/silent7.sh
@@ -0,0 +1,92 @@
+#!/bin/sh
+# Copyright (C) 2009-2012 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/>.
+
+# Check user extensibility of silent-rules mode.
+
+. ./defs || Exit 1
+
+cat >>configure.ac <<'EOF'
+AM_SILENT_RULES
+AC_OUTPUT
+EOF
+
+cat > Makefile.am <<'EOF'
+all-local: foo
+
+## And here's how you should do it in your own code:
+foo: foo.in
+ $(AM_V_GEN)cp $(srcdir)/foo.in $@
+ $(AM_V_at)echo more >> $@
+
+EXTRA_DIST = foo.in
+CLEANFILES = foo
+EOF
+
+: >foo.in
+
+$ACLOCAL
+$AUTOMAKE --add-missing
+$AUTOCONF
+
+./configure --disable-silent-rules
+$MAKE >stdout || { cat stdout; Exit 1; }
+cat stdout
+grep 'GEN ' stdout && Exit 1
+grep 'cp ' stdout
+grep 'echo ' stdout
+
+$MAKE clean
+$MAKE V=1 >stdout || { cat stdout; Exit 1; }
+cat stdout
+grep 'GEN ' stdout && Exit 1
+grep 'cp ' stdout
+grep 'echo ' stdout
+
+$MAKE clean
+$MAKE V=0 >stdout || { cat stdout; Exit 1; }
+cat stdout
+grep 'GEN .*foo' stdout
+grep 'cp ' stdout && Exit 1
+grep 'echo ' stdout && Exit 1
+
+$MAKE distclean
+
+./configure --enable-silent-rules
+$MAKE >stdout || { cat stdout; Exit 1; }
+cat stdout
+grep 'GEN .*foo' stdout
+grep 'cp ' stdout && Exit 1
+grep 'echo ' stdout && Exit 1
+
+$MAKE clean
+$MAKE V=0 >stdout || { cat stdout; Exit 1; }
+cat stdout
+grep 'GEN .*foo' stdout
+grep 'cp ' stdout && Exit 1
+grep 'echo ' stdout && Exit 1
+
+$MAKE clean
+$MAKE V=1 >stdout || { cat stdout; Exit 1; }
+cat stdout
+grep 'GEN ' stdout && Exit 1
+grep 'cp ' stdout
+grep 'echo ' stdout
+
+# Ensure that setting 'silent-rules' in a Makefile.am produces an error.
+echo 'AUTOMAKE_OPTIONS = silent-rules' >> Makefile.am
+AUTOMAKE_fails --force
+
+:
diff --git a/t/silent8.sh b/t/silent8.sh
new file mode 100755
index 000000000..a2fdb44c1
--- /dev/null
+++ b/t/silent8.sh
@@ -0,0 +1,66 @@
+#!/bin/sh
+# Copyright (C) 2009-2012 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/>.
+
+# Check texinfo rules in silent-rules mode.
+
+required='makeinfo-html tex texi2dvi-o dvips'
+. ./defs || Exit 1
+
+cat >>configure.ac <<'EOF'
+AM_SILENT_RULES
+AC_OUTPUT
+EOF
+
+cat > Makefile.am <<'EOF'
+info_TEXINFOS = foo.texi
+EOF
+
+cat > foo.texi <<'EOF'
+\input texinfo
+@c %**start of header
+@setfilename foo.info
+@settitle foo manual
+@c %**end of header
+@bye
+EOF
+
+$ACLOCAL
+$AUTOMAKE --add-missing
+$AUTOCONF
+
+./configure --disable-silent-rules
+
+# Make sure that all labels work in silent-mode.
+$MAKE V=0 dvi html info ps pdf >stdout || { cat stdout; Exit 1; }
+cat stdout
+grep 'DVIPS foo.ps' stdout || Exit 1
+grep 'MAKEINFO foo.html' stdout || Exit 1
+# NetBSD make will print './foo.info' instead of 'foo.info'.
+grep 'MAKEINFO.*foo.info' stdout || Exit 1
+grep 'TEXI2DVI foo.dvi' stdout || Exit 1
+grep 'TEXI2PDF foo.pdf' stdout || Exit 1
+
+# Now make sure the labels don't appear in verbose mode.
+$MAKE clean || Exit 1
+$MAKE V=1 dvi html info ps pdf >stdout || { cat stdout; Exit 1; }
+cat stdout
+grep 'DVIPS foo.ps' stdout && Exit 1
+grep 'MAKEINFO foo.html' stdout && Exit 1
+grep 'MAKEINFO.*foo.info' stdout && Exit 1
+grep 'TEXI2DVI foo.dvi' stdout && Exit 1
+grep 'TEXI2PDF foo.pdf' stdout && Exit 1
+
+:
diff --git a/t/silent9.sh b/t/silent9.sh
new file mode 100755
index 000000000..70195a1a8
--- /dev/null
+++ b/t/silent9.sh
@@ -0,0 +1,87 @@
+#!/bin/sh
+# Copyright (C) 2009-2012 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/>.
+
+# Check silent-rules mode, with libtool, nodep case.
+
+# Please keep this file in sync with silent3.test and silent4.test.
+
+required='cc libtoolize'
+. ./defs || Exit 1
+
+mkdir sub
+
+cat >>configure.ac <<'EOF'
+AM_SILENT_RULES
+AC_CONFIG_FILES([sub/Makefile])
+AC_PROG_CC
+AM_PROG_CC_C_O
+AM_PROG_AR
+AC_PROG_LIBTOOL
+AC_OUTPUT
+EOF
+
+cat > Makefile.am <<'EOF'
+# Need generic and non-generic rules.
+lib_LTLIBRARIES = libfoo.la libbar.la
+libbar_la_CFLAGS = $(AM_CFLAGS)
+SUBDIRS = sub
+EOF
+
+cat > sub/Makefile.am <<'EOF'
+AUTOMAKE_OPTIONS = subdir-objects
+# Need generic and non-generic rules.
+lib_LTLIBRARIES = libbaz.la libbla.la
+libbla_la_CFLAGS = $(AM_CFLAGS)
+EOF
+
+cat > libfoo.c <<'EOF'
+int main ()
+{
+ return 0;
+}
+EOF
+cp libfoo.c libbar.c
+cp libfoo.c sub/libbaz.c
+cp libfoo.c sub/libbla.c
+
+libtoolize
+$ACLOCAL
+$AUTOMAKE --add-missing
+$AUTOCONF
+
+./configure --disable-dependency-tracking --enable-silent-rules
+$MAKE >stdout || { cat stdout; Exit 1; }
+cat stdout
+$EGREP ' (-c|-o)' stdout && Exit 1
+grep 'mv ' stdout && Exit 1
+grep ' CC .*foo\.' stdout
+grep ' CC .*bar\.' stdout
+grep ' CC .*baz\.' stdout
+grep ' CC .*bla\.' stdout
+grep ' CCLD .*foo' stdout
+grep ' CCLD .*bar' stdout
+grep ' CCLD .*baz' stdout
+grep ' CCLD .*bla' stdout
+
+$MAKE clean
+$MAKE V=1 >stdout || { cat stdout; Exit 1; }
+cat stdout
+grep ' -c' stdout
+grep ' -o libfoo' stdout
+# The libtool command line can contain e.g. a '--tag=CC' option.
+sed 's/--tag=[^ ]*/--tag=x/g' stdout | $EGREP '(CC|LD) ' && Exit 1
+
+:
diff --git a/t/silentcxx-gcc.sh b/t/silentcxx-gcc.sh
new file mode 100755
index 000000000..d99f1e9cf
--- /dev/null
+++ b/t/silentcxx-gcc.sh
@@ -0,0 +1,109 @@
+#!/bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Check silent-rules mode for C++.
+# This test requires the GNU C++ compiler; keep it in sync with sister
+# test 'silentcxx.test', which should work with generic compilers.
+
+required=g++
+. ./defs || Exit 1
+
+mkdir sub
+
+cat >>configure.ac <<'EOF'
+AM_SILENT_RULES
+AC_PROG_CXX
+AC_CONFIG_FILES([sub/Makefile])
+AC_OUTPUT
+EOF
+
+cat > Makefile.am <<'EOF'
+# Need generic and non-generic rules.
+bin_PROGRAMS = foo1 foo2
+foo1_SOURCES = foo.cpp baz.cxx quux.cc
+foo2_SOURCES = $(foo1_SOURCES)
+foo2_CXXFLAGS = $(AM_CXXFLAGS)
+SUBDIRS = sub
+EOF
+
+cat > sub/Makefile.am <<'EOF'
+AUTOMAKE_OPTIONS = subdir-objects
+# Need generic and non-generic rules.
+bin_PROGRAMS = bar1 bar2
+bar1_SOURCES = bar.cpp
+bar2_SOURCES = $(bar1_SOURCES)
+bar2_CXXFLAGS = $(AM_CXXFLAGS)
+EOF
+
+cat > foo.cpp <<'EOF'
+using namespace std; /* C compilers fail on this. */
+int main() { return 0; }
+EOF
+
+# Let's try out other extensions too.
+echo 'class Baz { public: int i; };' > baz.cxx
+echo 'class Quux { public: bool b; };' > quux.cc
+
+cp foo.cpp sub/bar.cpp
+
+$ACLOCAL
+$AUTOMAKE --add-missing
+$AUTOCONF
+
+# Sanity check: make sure the cache variable we force is really used
+# by configure.
+$FGREP am_cv_CXX_dependencies_compiler_type configure
+
+# Force gcc ("fast") depmode.
+# This apparently useless "for" loop is here to simplify the syncing
+# with sister test 'silentcxx.test'.
+for config_args in \
+ am_cv_CXX_dependencies_compiler_type=gcc
+do
+ ./configure $config_args --enable-silent-rules
+ $MAKE >stdout || { cat stdout; Exit 1; }
+ cat stdout
+
+ $EGREP ' (-c|-o)' stdout && Exit 1
+ grep 'mv ' stdout && Exit 1
+
+ grep 'CXX .*foo\.' stdout
+ grep 'CXX .*baz\.' stdout
+ grep 'CXX .*quux\.' stdout
+ grep 'CXX .*bar\.' stdout
+ grep 'CXXLD .*foo1' stdout
+ grep 'CXXLD .*bar1' stdout
+ grep 'CXXLD .*foo2' stdout
+ grep 'CXXLD .*bar2' stdout
+
+ # Ensure a clean rebuild.
+ $MAKE clean
+
+ $MAKE V=1 >stdout || { cat stdout; Exit 1; }
+ cat stdout
+
+ grep ' -c ' stdout
+ grep ' -o ' stdout
+
+ $EGREP '(CC|CXX|LD) ' stdout && Exit 1
+
+ # Ensure a clean reconfiguration/rebuild.
+ $MAKE clean
+ $MAKE maintainer-clean
+
+done
+
+:
diff --git a/t/silentcxx.sh b/t/silentcxx.sh
new file mode 100755
index 000000000..a41cc2d13
--- /dev/null
+++ b/t/silentcxx.sh
@@ -0,0 +1,110 @@
+#!/bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Check silent-rules mode for C++.
+# This test should work with generic C++ compilers; keep it in sync with
+# sister test 'silentcxx-gcc.test', which requires the GNU C++ compiler
+# and forces the use of gcc depmode.
+
+required=c++
+. ./defs || Exit 1
+
+mkdir sub
+
+cat >>configure.ac <<'EOF'
+AM_SILENT_RULES
+AC_PROG_CXX
+AC_CONFIG_FILES([sub/Makefile])
+AC_OUTPUT
+EOF
+
+cat > Makefile.am <<'EOF'
+# Need generic and non-generic rules.
+bin_PROGRAMS = foo1 foo2
+foo1_SOURCES = foo.cpp baz.cxx quux.cc
+foo2_SOURCES = $(foo1_SOURCES)
+foo2_CXXFLAGS = $(AM_CXXFLAGS)
+SUBDIRS = sub
+EOF
+
+cat > sub/Makefile.am <<'EOF'
+AUTOMAKE_OPTIONS = subdir-objects
+# Need generic and non-generic rules.
+bin_PROGRAMS = bar1 bar2
+bar1_SOURCES = bar.cpp
+bar2_SOURCES = $(bar1_SOURCES)
+bar2_CXXFLAGS = $(AM_CXXFLAGS)
+EOF
+
+cat > foo.cpp <<'EOF'
+using namespace std; /* C compilers fail on this. */
+int main (void) { return 0; }
+EOF
+
+# Let's try out other extensions too.
+echo 'class Baz { public: int i; };' > baz.cxx
+echo 'class Quux { public: bool b; };' > quux.cc
+
+cp foo.cpp sub/bar.cpp
+
+$ACLOCAL
+$AUTOMAKE --add-missing
+$AUTOCONF
+
+# Sanity check: make sure the cache variable we force is really used
+# by configure.
+$FGREP am_cv_CXX_dependencies_compiler_type configure
+
+# Force dependency tracking explicitly, so that slow dependency
+# extractors are not rejected. Try also with dependency tracking
+# explicitly disabled.
+for config_args in \
+ --enable-dependency-tracking --disable-dependency-tracking
+do
+ ./configure $config_args --enable-silent-rules
+ $MAKE >stdout || { cat stdout; Exit 1; }
+ cat stdout
+
+ $EGREP ' (-c|-o)' stdout && Exit 1
+ grep 'mv ' stdout && Exit 1
+
+ grep 'CXX .*foo\.' stdout
+ grep 'CXX .*baz\.' stdout
+ grep 'CXX .*quux\.' stdout
+ grep 'CXX .*bar\.' stdout
+ grep 'CXXLD .*foo1' stdout
+ grep 'CXXLD .*bar1' stdout
+ grep 'CXXLD .*foo2' stdout
+ grep 'CXXLD .*bar2' stdout
+
+ # Ensure a clean rebuild.
+ $MAKE clean
+
+ $MAKE V=1 >stdout || { cat stdout; Exit 1; }
+ cat stdout
+
+ grep ' -c ' stdout
+ grep ' -o ' stdout
+
+ $EGREP '(CXX|LD) ' stdout && Exit 1
+
+ # Ensure a clean reconfiguration/rebuild.
+ $MAKE clean
+ $MAKE maintainer-clean
+
+done
+
+:
diff --git a/t/silentf77.sh b/t/silentf77.sh
new file mode 100755
index 000000000..ce6f6a044
--- /dev/null
+++ b/t/silentf77.sh
@@ -0,0 +1,92 @@
+#!/bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Check silent-rules mode for Fortran 77.
+# Keep this ins sync with the sister test silentf90.test.
+
+required=fortran77
+. ./defs || Exit 1
+
+mkdir sub
+
+cat >>configure.ac <<'EOF'
+AM_SILENT_RULES
+AC_PROG_F77
+AC_CONFIG_FILES([sub/Makefile])
+AC_OUTPUT
+EOF
+
+cat > Makefile.am <<'EOF'
+# Need generic and non-generic rules.
+bin_PROGRAMS = foo1 foo2
+foo1_SOURCES = foo.f
+foo2_SOURCES = $(foo1_SOURCES)
+foo2_FFLAGS = $(AM_FFLAGS)
+SUBDIRS = sub
+EOF
+
+cat > sub/Makefile.am <<'EOF'
+AUTOMAKE_OPTIONS = subdir-objects
+# Need generic and non-generic rules.
+bin_PROGRAMS = bar1 bar2
+bar1_SOURCES = bar.f
+bar2_SOURCES = $(bar1_SOURCES)
+bar2_FFLAGS = $(AM_FFLAGS)
+EOF
+
+cat > foo.f <<'EOF'
+ program foo
+ stop
+ end
+EOF
+cp foo.f sub/bar.f
+
+$ACLOCAL
+$AUTOMAKE --add-missing
+$AUTOCONF
+
+./configure --enable-silent-rules
+$MAKE >stdout || { cat stdout; Exit 1; }
+cat stdout
+# Avoid spurious failures with SunStudio Fortran compilers.
+sed '/^NOTICE:/d' stdout > t
+mv -f t stdout
+cat stdout
+
+$EGREP ' (-c|-o)' stdout && Exit 1
+grep 'mv ' stdout && Exit 1
+
+grep 'F77 .*foo\.' stdout
+grep 'F77 .*bar\.' stdout
+grep 'F77LD .*foo1' stdout
+grep 'F77LD .*bar1' stdout
+grep 'F77LD .*foo2' stdout
+grep 'F77LD .*bar2' stdout
+
+$EGREP '(FC|FCLD) ' stdout && Exit 1
+
+# Ensure a clean rebuild.
+$MAKE clean
+
+$MAKE V=1 >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+grep ' -c ' stdout
+grep ' -o ' stdout
+
+$EGREP '(F77|FC|LD) ' stdout && Exit 1
+
+:
diff --git a/t/silentf90.sh b/t/silentf90.sh
new file mode 100755
index 000000000..8bb06b262
--- /dev/null
+++ b/t/silentf90.sh
@@ -0,0 +1,92 @@
+#!/bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Check silent-rules mode for Fortran 90.
+# Keep this ins sync with the sister test silentf77.test.
+
+required=fortran
+. ./defs || Exit 1
+
+mkdir sub
+
+cat >>configure.ac <<'EOF'
+AM_SILENT_RULES
+AC_PROG_FC
+AC_CONFIG_FILES([sub/Makefile])
+AC_OUTPUT
+EOF
+
+cat > Makefile.am <<'EOF'
+# Need generic and non-generic rules.
+bin_PROGRAMS = foo1 foo2
+foo1_SOURCES = foo.f90
+foo2_SOURCES = $(foo1_SOURCES)
+foo2_FCFLAGS = $(AM_FCLAGS)
+SUBDIRS = sub
+EOF
+
+cat > sub/Makefile.am <<'EOF'
+AUTOMAKE_OPTIONS = subdir-objects
+# Need generic and non-generic rules.
+bin_PROGRAMS = bar1 bar2
+bar1_SOURCES = bar.f90
+bar2_SOURCES = $(bar1_SOURCES)
+bar2_FCFLAGS = $(AM_FCLAGS)
+EOF
+
+cat > foo.f90 <<'EOF'
+ program foo
+ stop
+ end
+EOF
+cp foo.f90 sub/bar.f90
+
+$ACLOCAL
+$AUTOMAKE --add-missing
+$AUTOCONF
+
+./configure --enable-silent-rules
+$MAKE >stdout || { cat stdout; Exit 1; }
+cat stdout
+# Avoid spurious failures with SunStudio Fortran compilers.
+sed '/^NOTICE:/d' stdout > t
+mv -f t stdout
+cat stdout
+
+$EGREP ' (-c|-o)' stdout && Exit 1
+grep 'mv ' stdout && Exit 1
+
+grep 'FC .*foo\.' stdout
+grep 'FC .*bar\.' stdout
+grep 'FCLD .*foo1' stdout
+grep 'FCLD .*bar1' stdout
+grep 'FCLD .*foo2' stdout
+grep 'FCLD .*bar2' stdout
+
+$EGREP '(F77|F77LD) ' stdout && Exit 1
+
+# Ensure a clean rebuild.
+$MAKE clean
+
+$MAKE V=1 >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+grep ' -c ' stdout
+grep ' -o ' stdout
+
+$EGREP '(F77|FC|LD) ' stdout && Exit 1
+
+:
diff --git a/t/space.sh b/t/space.sh
new file mode 100755
index 000000000..c46ade12f
--- /dev/null
+++ b/t/space.sh
@@ -0,0 +1,29 @@
+#! /bin/sh
+# Copyright (C) 2000-2012 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/>.
+
+# Test leading space on macro assignment.
+
+. ./defs || Exit 1
+
+echo AC_PROG_CC >> configure.ac
+
+cat > Makefile.am << 'END'
+ bin_PROGRAMS = foo
+foo_SOURCES = foo.c
+END
+
+$ACLOCAL
+$AUTOMAKE
diff --git a/t/specflg-dummy.sh b/t/specflg-dummy.sh
new file mode 100755
index 000000000..1486f4c9c
--- /dev/null
+++ b/t/specflg-dummy.sh
@@ -0,0 +1,247 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that even "dummy" per-target flags triggers the use of renamed
+# objects. I.e., a definition like 'foo_CFLAGS = $(AM_CFLAGS)' should
+# always cause Automake to trigger the semantics for per-target CFLAGS,
+# even if AM_CFLAGS is undefined. Similarly for other *FLAGS variables
+# (CXXFLAGS, YFLAGS, LDFLAGS, ...)
+
+. ./defs || Exit 1
+
+# Disable shell globbing if possible.
+(set +f) >/dev/null 2>&1 && set +f
+
+oIFS=$IFS
+nl='
+'
+
+matches=
+add_match ()
+{
+ matches="$matches$nl$1"
+}
+
+do_check ()
+{
+ IFS=$nl
+ for string in $matches; do
+ IFS=$oIFS
+ $FGREP "$string" Makefile.in
+ done
+ IFS=$oIFS
+}
+
+# Fake libtool presence, so that we won't have to require it.
+cat > acinclude.m4 <<END
+AC_DEFUN([AC_PROG_LIBTOOL], [AC_SUBST([LIBTOOL], [dummy])])
+END
+: > ltmain.sh
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_PROG_CXX
+AC_PROG_YACC
+AC_PROG_LEX
+AC_PROG_F77
+AC_PROG_FC
+AM_PROG_GCJ
+AM_PROG_AR
+AC_PROG_RANLIB
+AC_PROG_LIBTOOL
+AM_PROG_UPC
+AC_PROG_OBJC
+AM_PROG_CC_C_O
+END
+
+cat > Makefile.am <<'END'
+bin_PROGRAMS =
+lib_LIBRARIES =
+lib_LTLIBRARIES =
+END
+
+$ACLOCAL
+
+cat >> Makefile.am <<'END'
+bin_PROGRAMS += prog1
+prog1_SOURCES = source1.c
+prog1_CFLAGS = $(AM_CFLAGS)
+END
+
+add_match 'prog1-source1.$(OBJEXT)'
+
+cat >> Makefile.am <<'END'
+bin_PROGRAMS += prog2
+prog2_SOURCES = source2.c
+prog2_CPPFLAGS = $(AM_CPPFLAGS)
+END
+
+add_match 'prog2-source2.$(OBJEXT)'
+
+cat >> Makefile.am <<'END'
+bin_PROGRAMS += prog3
+prog3_SOURCES = source3.cxx
+prog3_CXXFLAGS = $(AM_CXXFLAGS)
+END
+
+add_match 'prog3-source3.$(OBJEXT)'
+
+cat >> Makefile.am <<'END'
+bin_PROGRAMS += prog4
+prog4_SOURCES = source4.c++
+prog4_CPPFLAGS = $(AM_CPPFLAGS)
+END
+
+add_match 'prog4-source4.$(OBJEXT)'
+
+cat >> Makefile.am <<'END'
+bin_PROGRAMS += prog5
+prog5_SOURCES = source5.f
+prog5_FFLAGS = $(AM_FFLAGS)
+END
+
+add_match 'prog5-source5.$(OBJEXT)'
+
+cat >> Makefile.am <<'END'
+bin_PROGRAMS += prog6
+prog6_SOURCES = source6.f90
+prog6_FCFLAGS = $(AM_FCFLAGS)
+END
+
+add_match 'prog6-source6.$(OBJEXT)'
+
+cat >> Makefile.am <<'END'
+bin_PROGRAMS += prog7
+prog7_SOURCES = source7.r
+prog7_RFLAGS = $(AM_RFLAGS)
+END
+
+add_match 'prog7-source7.$(OBJEXT)'
+
+cat >> Makefile.am <<'END'
+bin_PROGRAMS += prog8
+prog8_SOURCES = source8.java
+prog8_GCJFLAGS = $(AM_GCJFLAGS)
+END
+
+add_match 'prog8-source8.$(OBJEXT)'
+
+cat >> Makefile.am <<'END'
+bin_PROGRAMS += prog9
+prog9_SOURCES = source9.upc
+prog9_UPCFLAGS = $(AM_UPCFLAGS)
+END
+
+add_match 'prog9-source9.$(OBJEXT)'
+
+cat >> Makefile.am <<'END'
+bin_PROGRAMS += prog10
+prog10_SOURCES = source10.m
+prog10_OBJCFLAGS = $(AM_OBJCFLAGS)
+END
+
+add_match 'prog10-source10.$(OBJEXT)'
+
+cat >> Makefile.am <<'END'
+bin_PROGRAMS += linkprog
+linkprog_SOURCES = linkprog.c
+linkprog_LDFLAGS = $(AM_LDFLAGS)
+END
+
+add_match 'linkprog_LINK ='
+
+cat >> Makefile.am <<'END'
+lib_LIBRARIES += libstatic.a
+libstatic_a_SOURCES = static123.c
+libstatic_a_CFLAGS = $(AM_CFLAGS)
+END
+
+add_match 'libstatic_a-static123.$(OBJEXT)'
+
+cat >> Makefile.am <<'END'
+lib_LTLIBRARIES += libshared1.la
+libshared1_la_SOURCES = shared1.c
+libshared1_la_LIBTOOLFLAGS = $(AM_LIBTOOLFLAGS)
+END
+
+add_match 'libshared1_la-shared1.lo'
+
+cat >> Makefile.am <<'END'
+lib_LTLIBRARIES += libshared2.la
+libshared2_la_SOURCES = shared2.cc
+libshared2_la_CXXFLAGS = $(AM_CXXFLAGS)
+END
+
+add_match 'libshared2_la-shared2.lo'
+
+cat >> Makefile.am <<'END'
+bin_PROGRAMS += parse1
+parse1_SOURCES = parse.y
+parse1_YFLAGS = $(AM_YFLAGS)
+END
+
+add_match 'parse1-parse.c'
+
+cat >> Makefile.am <<'END'
+bin_PROGRAMS += parse2
+parse2_SOURCES = parse.ypp
+parse2_YFLAGS = $(AM_YFLAGS)
+END
+
+add_match 'parse2-parse.cpp'
+
+cat >> Makefile.am <<'END'
+bin_PROGRAMS += lexer1
+lexer1_SOURCES = lex.l
+lexer1_LFLAGS = $(AM_YFLAGS)
+END
+
+add_match 'lexer1-lex.c'
+
+cat >> Makefile.am <<'END'
+bin_PROGRAMS += lexer2
+lexer2_SOURCES = lexer.ll
+lexer2_LFLAGS = $(AM_YFLAGS)
+END
+
+add_match 'lexer2-lexer.cc'
+
+# For debugging.
+cat Makefile.am
+
+$AUTOMAKE -a
+do_check
+
+sed '
+ s|^\(.*\)_SOURCES *= *|sub_\1_SOURCES = srcsub/|
+ s|^\(.*\)PROGRAMS *+= *|\1PROGRAMS += sub/|
+ s|^\(.*\)LIBRARIES *+= *|\1LIBRARIES += sub/|
+ s|^\(.*\)FLAGS *=|sub_\1FLAGS =|
+' Makefile.am > t
+
+cat - t > Makefile.am <<'END'
+AUTOMAKE_OPTIONS = subdir-objects
+END
+
+rm -f t
+
+# For debugging.
+cat Makefile.am
+
+$AUTOMAKE
+do_check
+
+:
diff --git a/t/specflg.sh b/t/specflg.sh
new file mode 100755
index 000000000..9d5c73ca0
--- /dev/null
+++ b/t/specflg.sh
@@ -0,0 +1,51 @@
+#! /bin/sh
+# Copyright (C) 1999-2012 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/>.
+
+# Test of flags specific to executable.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_CC_C_O
+END
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = no-dependencies
+bin_PROGRAMS = foo
+foo_SOURCES = foo.c
+foo_CFLAGS = -DBAR
+END
+
+# Make sure 'compile' is required.
+$ACLOCAL
+AUTOMAKE_fails
+grep 'required.*compile' stderr
+
+: > compile
+
+$AUTOMAKE
+
+# Look for $(COMPILE) -c in .c.o rule.
+grep 'COMPILE. [^-]' Makefile.in && Exit 1
+
+# Look for foo-foo.o.
+grep '[^-]foo\.o' Makefile.in && Exit 1
+
+# Regression test for missing space.
+$FGREP ')-c' Makefile.in && Exit 1
+
+Exit 0
diff --git a/t/specflg10.sh b/t/specflg10.sh
new file mode 100755
index 000000000..3b8fc5be4
--- /dev/null
+++ b/t/specflg10.sh
@@ -0,0 +1,87 @@
+#! /bin/sh
+# Copyright (C) 2008-2012 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/>.
+
+# AM_DEFAULT_SOURCE_EXT
+
+required='cc c++'
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_PROG_CXX
+AC_CONFIG_FILES([sub/Makefile sub2/Makefile])
+AM_CONDITIONAL([COND], [:])
+AC_OUTPUT
+END
+
+mkdir sub sub2
+
+cat > Makefile.am << 'END'
+SUBDIRS = sub sub2
+bin_PROGRAMS = foo
+END
+
+cat > sub/Makefile.am << 'END'
+bin_PROGRAMS = bar baz
+AM_DEFAULT_SOURCE_EXT = .cpp
+END
+
+cat > sub2/Makefile.am << 'END'
+bin_PROGRAMS = bla
+if COND
+AM_DEFAULT_SOURCE_EXT = .foo .quux
+endif
+SUFFIXES = .foo .c
+.foo.c:
+ cat $< >$@
+BUILT_SOURCES = bla.c
+CLEANFILES = bla.c
+END
+
+cat > foo.c << 'END'
+int main () { return 0; }
+END
+
+cp foo.c sub/bar.cpp
+cp foo.c sub/baz.cpp
+cp foo.c sub2/bla.foo
+
+$ACLOCAL
+$AUTOCONF
+
+# Conditional AM_DEFAULT_SOURCE_EXT does not work yet :-(
+# (this limitation could be lifted).
+AUTOMAKE_fails --add-missing
+grep 'defined conditionally' stderr
+
+sed '/^if/d; /^endif/d' sub2/Makefile.am > t
+mv -f t sub2/Makefile.am
+
+# AM_DEFAULT_SOURCE_EXT can only assume one value
+# (lifting this limitation is not such a good idea).
+AUTOMAKE_fails --add-missing
+grep 'at most one value' stderr
+
+sed 's/ \.quux//' sub2/Makefile.am > t
+mv -f t sub2/Makefile.am
+
+$AUTOMAKE --add-missing
+
+./configure
+$MAKE
+$MAKE distcheck
+
+:
diff --git a/t/specflg2.sh b/t/specflg2.sh
new file mode 100755
index 000000000..9f9569c8d
--- /dev/null
+++ b/t/specflg2.sh
@@ -0,0 +1,59 @@
+#! /bin/sh
+# Copyright (C) 1999-2012 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/>.
+
+# Test library-specific flags.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_PROG_CXX
+AM_PROG_AR
+AC_PROG_RANLIB
+END
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = no-dependencies
+lib_LIBRARIES = libfoo.a
+libfoo_a_SOURCES = foo.c bar.cc
+libfoo_a_CFLAGS = -DBAR
+libfoo_a_CXXFLAGS = -DZOT
+END
+
+: > ar-lib
+
+# Make sure 'compile' is required.
+$ACLOCAL
+AUTOMAKE_fails
+grep 'required.*compile' stderr
+
+: > compile
+
+$AUTOMAKE
+
+# Look for $(COMPILE) -c in .c.o rule.
+grep 'COMPILE. [^-]' Makefile.in && Exit 1
+
+# Look for libfoo_a-foo.o.
+grep foo Makefile.in
+grep '[^-]foo\.o' Makefile.in && Exit 1
+
+# Look for libfoo_a-bar.o.
+grep bar Makefile.in
+grep '[^-]bar\.o' Makefile.in && Exit 1
+
+Exit 0
diff --git a/t/specflg3.sh b/t/specflg3.sh
new file mode 100755
index 000000000..9e7887264
--- /dev/null
+++ b/t/specflg3.sh
@@ -0,0 +1,43 @@
+#! /bin/sh
+# Copyright (C) 1999-2012 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/>.
+
+# Test exe-specific flags with dependency tracking.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = foo
+foo_SOURCES = foo.c
+foo_CFLAGS = -DFOO
+END
+
+: > compile
+
+$ACLOCAL
+$AUTOMAKE
+
+$FGREP ' -o foo-foo' Makefile.in
+$FGREP 'foo.o.o' Makefile.in && Exit 1
+$FGREP 'foo.$(OBJEXT).$(OBJEXT)' Makefile.in && Exit 1
+$FGREP '$(foo_CFLAGS)' Makefile.in
+
+:
diff --git a/t/specflg6.sh b/t/specflg6.sh
new file mode 100755
index 000000000..f420cdfd2
--- /dev/null
+++ b/t/specflg6.sh
@@ -0,0 +1,56 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Regression test for multiple rules being generated for each target when
+# conditionals are present.
+# From Richard Boulton.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_CC_C_O
+AM_CONDITIONAL([BAR], [true])
+END
+
+cat > Makefile.am << 'END'
+if BAR
+BAR_SRCS = bar.c
+endif
+
+bin_PROGRAMS = foo
+foo_CFLAGS = -DFOO
+foo_SOURCES = foo.c
+END
+
+: > compile
+
+$ACLOCAL
+$AUTOMAKE
+
+uncondval=`$FGREP 'foo-foo.o: foo.c' Makefile.in`
+
+cat >> Makefile.am << 'END'
+foo_SOURCES += $(BAR_SRCS)
+END
+
+$AUTOMAKE
+
+condval=`$FGREP 'foo-foo.o: foo.c' Makefile.in`
+
+test "x$uncondval" = "x$condval"
+
+:
diff --git a/t/specflg7.sh b/t/specflg7.sh
new file mode 100755
index 000000000..26ad75cf5
--- /dev/null
+++ b/t/specflg7.sh
@@ -0,0 +1,65 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# The true/false example from the manual, plus a check for _SHORTNAME.
+
+required='cc native'
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = false true
+true_SOURCES = false.c
+true_CFLAGS = -DAM_TRUE
+true_SHORTNAME = t
+# No false_SOURCES definition. Use the default source.
+false_CFLAGS = -DAM_FALSE
+false_SHORTNAME = f
+END
+
+cat > false.c << 'END'
+#include <stdio.h>
+int
+main (int argc, char *argv[])
+{
+#ifdef AM_TRUE
+ puts ("true");
+#else
+ puts ("false");
+#endif
+ return 0;
+}
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+$MAKE
+./true | grep true
+./false | grep false
+
+objext=`sed -n -e 's/^OBJEXT = //p' < Makefile`
+test -f ./t-false.$objext
+test -f ./f-false.$objext
+
+:
diff --git a/t/specflg8.sh b/t/specflg8.sh
new file mode 100755
index 000000000..435ce1624
--- /dev/null
+++ b/t/specflg8.sh
@@ -0,0 +1,64 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Like the true/false example from the manual,
+# with one extra indirection in the sources (PR/315), and
+# use of _CPPFLAGS (PR/337).
+
+required='cc native'
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_OUTPUT
+END
+
+# Using a separate variable to hold all the sources for a program is
+# common when building many flavors of this program, each with
+# different flags.
+
+cat > Makefile.am << 'END'
+TRUESOURCE = true.c
+bin_PROGRAMS = false true
+true_SOURCES = $(TRUESOURCE)
+true_CPPFLAGS = -DEXIT_CODE=0
+false_SOURCES = $(TRUESOURCE)
+false_CPPFLAGS = -DEXIT_CODE=1
+END
+
+cat > true.c << 'END'
+int main (void)
+{
+ return EXIT_CODE;
+}
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+$MAKE
+
+./true
+./false && Exit 1
+
+objext=`sed -n -e 's/^OBJEXT = //p' < Makefile`
+test -f ./true-true.$objext
+test -f ./false-true.$objext
+
+:
diff --git a/t/specflg9.sh b/t/specflg9.sh
new file mode 100755
index 000000000..96e7a2e22
--- /dev/null
+++ b/t/specflg9.sh
@@ -0,0 +1,45 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Another check for per-target flag substitutions.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = zzfoo zzbar
+zzfoo_SOURCES = sub/foo.c
+zzbar_SOURCES = bar.c
+zzbar_CPPFLAGS = -Dfoo
+END
+
+$ACLOCAL
+$AUTOMAKE --add-missing
+
+$FGREP '$(AM_CFLAGS)' Makefile.in
+
+$FGREP '$(zzfoo_CFLAGS)' Makefile.in && Exit 1
+$FGREP '$(zzfoo_CPPFLAGS)' Makefile.in && Exit 1
+
+$FGREP '$(zzbar_CFLAGS)' Makefile.in && Exit 1
+$FGREP '$(zzbar_CPPFLAGS)' Makefile.in
+
+:
diff --git a/t/spell.sh b/t/spell.sh
new file mode 100755
index 000000000..a2b475278
--- /dev/null
+++ b/t/spell.sh
@@ -0,0 +1,29 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test to make sure misspellings in _SOURCES variables cause failure.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = zardoz foo
+zardoz_SOURCES = x.c
+boo_SOURCES = y.c
+END
+
+$ACLOCAL
+AUTOMAKE_fails
+grep 'Makefile.am:3:.*boo' stderr
diff --git a/t/spell2.sh b/t/spell2.sh
new file mode 100755
index 000000000..a4b0a4605
--- /dev/null
+++ b/t/spell2.sh
@@ -0,0 +1,31 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test to make sure misspellings in _SOURCES variables cause failure.
+
+. ./defs || Exit 1
+
+echo AC_PROG_CC >> configure.ac
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = zardoz
+zardoz_SOURCES = x.c
+qardoz_LDADD = -ljoe
+END
+
+$ACLOCAL
+AUTOMAKE_fails
+grep 'Makefile.am:3:.*qardoz' stderr
diff --git a/t/spell3.sh b/t/spell3.sh
new file mode 100755
index 000000000..a96fa036f
--- /dev/null
+++ b/t/spell3.sh
@@ -0,0 +1,31 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test to make sure some internal _DEPENDENCIES variables don't cause
+# errors.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+TAGS_DEPENDENCIES = joe
+## Required to avoid error.
+ETAGS_ARGS = joe
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+:
diff --git a/t/spelling.sh b/t/spelling.sh
new file mode 100755
index 000000000..fb68f3103
--- /dev/null
+++ b/t/spelling.sh
@@ -0,0 +1,30 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test to make sure that misspelled prefixes actually cause error.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'EOF'
+bni_PROGRAMS = zot
+EOF
+
+$ACLOCAL
+AUTOMAKE_fails
+grep 'bni_PROGRAMS' stderr
+grep 'bnidir.*undefined' stderr
+
+:
diff --git a/t/spy-rm.tap b/t/spy-rm.tap
new file mode 100755
index 000000000..af7ba2a5e
--- /dev/null
+++ b/t/spy-rm.tap
@@ -0,0 +1,48 @@
+#! /bin/sh
+# Copyright (C) 2012 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/>.
+
+# Check whether "rm -f" do not complain if called without file
+# operands. We'd like to depend on this behaviour (which seems
+# to hold on all non-museum systems, and will soon be mandated
+# by POSIX as well) in future version of automake, to simplify
+# automake-provided cleanup rules.
+# References:
+# <http://lists.gnu.org/archive/html/bug-autoconf/2012-02/msg00002.html>
+# <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=10819>
+# <http://austingroupbugs.net/view.php?id=542>
+
+am_create_testdir=empty
+. ./defs || Exit 1
+
+plan_ 10
+
+chk ()
+{
+ if test -f /bin/rm; then
+ command_ok_ "/bin/rm $*" /bin/rm "$@"
+ else
+ skip_ -r "/bin/rm not found"
+ fi
+ command_ok_ "rm $*" rm "$@"
+}
+
+chk -f
+chk -rf
+chk -fr
+chk -f -r
+chk -r -f
+
+:
diff --git a/t/spy.sh b/t/spy.sh
new file mode 100755
index 000000000..0d087a41a
--- /dev/null
+++ b/t/spy.sh
@@ -0,0 +1,106 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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/>.
+
+# Check whether double colon rules work. The Unix V7 make manual
+# mentions double-colon rules, but POSIX does not. They seem to be
+# supported by all Make implementation as far as we can tell. This test
+# case is a spy: we want to detect if there exist implementations where
+# these do not work. We might use these rules to simplify the rebuild
+# rules (instead of the $? hack).
+
+# Tom Tromey write:
+# | In the distant past we used :: rules extensively.
+# | Fran?ois convinced me to get rid of them:
+# |
+# | Thu Nov 23 18:02:38 1995 Tom Tromey <tromey@cambric>
+# | [ ... ]
+# | * subdirs.am: Removed "::" rules
+# | * header.am, libraries.am, mans.am, texinfos.am, footer.am:
+# | Removed "::" rules
+# | * scripts.am, programs.am, libprograms.am: Removed "::" rules
+# |
+# |
+# | I no longer remember the rationale for this. It may have only been a
+# | belief that they were unportable.
+
+# On a related topic, the Autoconf manual has the following text:
+# | 'VPATH' and double-colon rules
+# | Any assignment to 'VPATH' causes Sun 'make' to only execute
+# | the first set of double-colon rules. (This comment has been
+# | here since 1994 and the context has been lost. It's probably
+# | about SunOS 4. If you can reproduce this, please send us a
+# | test case for illustration.)
+
+# We already know that overlapping ::-rule like
+#
+# a :: b
+# echo rule1 >> $@
+# a :: c
+# echo rule2 >> $@
+# a :: b c
+# echo rule3 >> $@
+#
+# do not work equally on all platforms. It seems that in all cases
+# Make attempts to run all matching rules. However at least GNU Make,
+# NetBSD Make, and FreeBSD Make will detect that $@ was updated by the
+# first matching rule and skip remaining matches (with the above
+# example that means that unless 'a' was declared PHONY, only "rule1"
+# will be appended to 'a' if both b and c have changed). Other
+# implementations like OSF1 Make and HP-UX Make do not perform such a
+# check and execute all matching rules whatever they do ("rule1",
+# "rule2", abd "rule3" will all be appended to 'a' if b and c have
+# changed).
+
+# So it seems only non-overlapping ::-rule may be portable. This is
+# what we check now.
+
+. ./defs || Exit 1
+
+cat >Makefile <<\EOF
+a :: b
+ echo rule1 >> $@
+a :: c
+ echo rule2 >> $@
+EOF
+
+touch b c
+$sleep
+: > a
+$MAKE
+test "`cat a`" = ''
+$sleep
+touch b
+$MAKE
+test "`cat a`" = rule1
+# Ensure a is strictly newer than b, so HP-UX make does not execute rule2.
+$sleep
+: > a
+$sleep
+touch c
+$MAKE
+test "`cat a`" = rule2
+
+# Unfortunately, the following is not portable to FreeBSD/NetBSD/OpenBSD
+# make, see explanation above.
+
+#: > a
+#$sleep
+#touch b c
+#$MAKE
+#grep rule1 a
+#grep rule2 a
+
+:
diff --git a/t/srcsub.sh b/t/srcsub.sh
new file mode 100755
index 000000000..978a10538
--- /dev/null
+++ b/t/srcsub.sh
@@ -0,0 +1,33 @@
+#! /bin/sh
+# Copyright (C) 1999-2012 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/>.
+
+# Test to make sure config sub in _SOURCES fails.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = x
+x_SOURCES = x.c @FOO@
+EXTRA_x_SOURCES = y.c
+END
+
+$ACLOCAL
+AUTOMAKE_fails
+grep 'Makefile.am:2:.*x_SOURCES.*substitution' stderr
diff --git a/t/srcsub2.sh b/t/srcsub2.sh
new file mode 100755
index 000000000..2d6da9793
--- /dev/null
+++ b/t/srcsub2.sh
@@ -0,0 +1,36 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test to make sure config sub in _SOURCES fails.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = x
+bar = @FOO@
+foo = $(bar)
+x_SOURCES = x.c $(foo)
+EXTRA_x_SOURCES = y.c
+END
+
+$ACLOCAL
+AUTOMAKE_fails
+grep 'Makefile.am:2:.*bar.*substitution' stderr
+grep 'Makefile.am:2:.*x_SOURCES' stderr
diff --git a/t/stamph2.sh b/t/stamph2.sh
new file mode 100755
index 000000000..59a373a35
--- /dev/null
+++ b/t/stamph2.sh
@@ -0,0 +1,69 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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 stamp-h* files are created where we expect
+. ./defs || Exit 1
+
+cat >> configure.ac << END
+AM_CONFIG_HEADER([1.h
+ 2.h:config.hin
+ 3.h:sdir1/config1.hin])
+# AM_CONFIG_HEADER and AC_CONFIG_HEADERS should be synonyms.
+AC_CONFIG_HEADERS([sdir1/4.h
+ sdir1/5.h:config.hin
+ sdir1/6.h:sdir1/config1.hin
+ sdir1/7.h:sdir2/config2.hin])
+AC_OUTPUT
+END
+
+: > Makefile.am
+mkdir sdir1
+mkdir sdir2
+: > config.hin
+: > 1.h.in
+: > sdir1/4.h.in
+: > sdir1/config1.hin
+: > sdir2/config2.hin
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+
+test -f stamp-h1
+test -f stamp-h2
+test -f stamp-h3
+test -f sdir1/stamp-h4
+test -f sdir1/stamp-h5
+test -f sdir1/stamp-h6
+test -f sdir1/stamp-h7
+
+# Make sure './config.status foo' creates the right stamp file.
+# Report from Sander Niemeijer.
+
+rm -f stamp-h*
+rm -f sdir1/stamp-h*
+
+./config.status sdir1/7.h 2.h sdir1/4.h
+test ! -f stamp-h1
+test -f stamp-h2
+test ! -f stamp-h3
+test -f sdir1/stamp-h4
+test ! -f sdir1/stamp-h5
+test ! -f sdir1/stamp-h6
+test -f sdir1/stamp-h7
+
+:
diff --git a/t/stdinc.sh b/t/stdinc.sh
new file mode 100755
index 000000000..ec9948391
--- /dev/null
+++ b/t/stdinc.sh
@@ -0,0 +1,62 @@
+#! /bin/sh
+# Copyright (C) 2007-2012 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/>.
+
+# Test to make sure the standard include order is stable.
+# Report by Kent Boortz.
+
+required=cc
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_CONFIG_HEADERS([sub/config.h])
+AC_CONFIG_FILES([sub/bar.h])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = foo
+foo_SOURCES = foo.c
+BUILT_SOURCES = bar.h
+END
+
+mkdir sub
+
+cat >foo.c <<'END'
+#include <config.h>
+#include <bar.h>
+int main() { return bar (); }
+END
+cat >bar.h <<'END'
+int bar () { return 0; }
+END
+cat >sub/bar.h.in <<'END'
+choke me
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOHEADER
+$AUTOMAKE
+
+mkdir build
+cd build
+../configure -C
+$MAKE
+
+cd ..
+./configure -C
+$MAKE
diff --git a/t/stdlib.sh b/t/stdlib.sh
new file mode 100755
index 000000000..1594707c5
--- /dev/null
+++ b/t/stdlib.sh
@@ -0,0 +1,52 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test "not a standard library" error.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_RANLIB
+END
+
+cat > Makefile.am << 'END'
+noinst_LIBRARIES = sub/foo
+include $(srcdir)/foo.mk
+END
+
+cat > foo.mk << 'END'
+## A dummy automake comment.
+a = x \
+ y
+# A dummy make comment.
+lib_LIBRARIES = zardoz.a
+END
+
+: > ar-lib
+
+$ACLOCAL
+AUTOMAKE_fails
+q="[\`'\"]"
+badname='not a standard library name'
+# We're specifically testing for line-number information.
+grep "^Makefile\\.am:1:.*${q}sub/foo${q}.*$badname" stderr
+grep "^Makefile\\.am:1:.*sub/libfoo\\.a" stderr
+grep "^foo\\.mk:5:.*${q}zardoz\\.a${q}.*$badname" stderr
+grep "^foo\\.mk:5:.*libzardoz\\.a" stderr
+
+:
diff --git a/t/stdlib2.sh b/t/stdlib2.sh
new file mode 100755
index 000000000..ce5158f70
--- /dev/null
+++ b/t/stdlib2.sh
@@ -0,0 +1,94 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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/>.
+
+# Check for AM_LDFLAGS = -module
+# Report from Kevin P. Fleming.
+required=libtool
+. ./defs || Exit 1
+
+: > README
+: > NEWS
+: > AUTHORS
+: > ChangeLog
+: > ltconfig
+: > ltmain.sh
+: > config.guess
+: > config.sub
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_LIBTOOL
+AC_OUTPUT
+END
+
+: > Makefile.inc
+
+cat > Makefile.am << 'END'
+include Makefile.inc
+lib_LTLIBRARIES = nonstandard.la
+nonstandard_la_SOURCES = foo.c
+FOO = -module
+END
+
+$ACLOCAL
+AUTOMAKE_fails --add-missing --gnu
+grep 'Makefile.am:2:.*nonstandard.la.*standard libtool library name' stderr
+grep 'Makefile.am:2:.*libnonstandard.la' stderr
+
+# We will use -Wno-gnu to disable the warning about setting LDFLAGS (below)
+# Make sure nonstandard names are diagnosed anyway.
+AUTOMAKE_fails --add-missing --gnu -Wno-gnu
+grep 'Makefile.am:2:.*nonstandard.la.*standard libtool library name' stderr
+grep 'Makefile.am:2:.*libnonstandard.la' stderr
+
+# Make sure nonstandard_la_LDFLAGS is read even if LDFLAGS is used.
+cat >Makefile.inc <<'EOF'
+LDFLAGS = -lfoo
+nonstandard_la_LDFLAGS = $(FOO)
+EOF
+$AUTOMAKE -Wno-gnu
+
+# Make sure LDFLAGS is read even if nonstandard_la_LDFLAGS is used.
+cat >Makefile.inc <<'EOF'
+LDFLAGS = $(FOO)
+nonstandard_la_LDFLAGS = -lfoo
+EOF
+$AUTOMAKE -Wno-gnu
+
+# Make sure AM_LDFLAGS is not read if foo_LDFLAGS is used.
+cat >Makefile.inc <<'EOF'
+nonstandard_la_LDFLAGS = -lfoo
+AM_LDFLAGS = -module
+EOF
+AUTOMAKE_fails
+grep 'Makefile.am:2:.*nonstandard.la.*standard libtool library name' stderr
+grep 'Makefile.am:2:.*libnonstandard.la' stderr
+
+echo 'AM_LDFLAGS = -module' > Makefile.inc
+$AUTOMAKE
+
+# For module, Automake should not suggest the lib prefix.
+cat > Makefile.am << 'END'
+include Makefile.inc
+lib_LTLIBRARIES = nonstandard
+nonstandard_SOURCES = foo.c
+FOO = -module
+END
+
+AUTOMAKE_fails
+grep "Makefile.am:2:.*'nonstandard'.*standard libtool module name" stderr
+grep 'Makefile.am:2:.*nonstandard.la' stderr
diff --git a/t/strictness-override.sh b/t/strictness-override.sh
new file mode 100755
index 000000000..8c365f0a0
--- /dev/null
+++ b/t/strictness-override.sh
@@ -0,0 +1,123 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# The strictness specified in Makefile.am:AUTOMAKE_OPTIONS should
+# override that specified in configure.ac:AM_INIT_AUTOMAKE, and both
+# should override the strictness specified on the command line.
+# NOTE: the current semantics might not be the best one (even if it has
+# been in place for quite a long time); see also Automake bug #7673.
+# Update this test if the semantics are changed.
+
+. ./defs || Exit 1
+
+# We want complete control over automake options.
+AUTOMAKE=$am_original_AUTOMAKE
+
+cat > Makefile.am <<'END'
+AUTOMAKE_OPTIONS =
+END
+
+set_strictness ()
+{
+ set +x
+ sed <$2 >$2-t -e "s|^\\(AUTOMAKE_OPTIONS\\) *=.*|\\1 = $1|" \
+ -e "s|^\\(AM_INIT_AUTOMAKE\\).*|\\1([$1])|"
+ mv -f $2-t $2
+ set -x
+ cat $2
+}
+
+ok ()
+{
+ $AUTOMAKE -Werror $*
+}
+
+ko ()
+{
+ AUTOMAKE_fails $*
+ grep 'required file.*README' stderr
+}
+
+$ACLOCAL
+
+# Leave out only one of the required files, to avoid too much
+# repetition in the error messages.
+touch INSTALL NEWS AUTHORS ChangeLog COPYING
+
+rm -rf autom4te*.cache
+set_strictness '' Makefile.am
+set_strictness '' configure.ac
+ko --gnu
+ko
+ok --foreign
+
+rm -rf autom4te*.cache
+set_strictness 'gnu' Makefile.am
+set_strictness '' configure.ac
+ko --gnu
+ko
+ko --foreign
+
+rm -rf autom4te*.cache
+set_strictness '' Makefile.am
+set_strictness 'gnu' configure.ac
+ko --gnu
+ko
+ko --foreign
+
+rm -rf autom4te*.cache
+set_strictness 'foreign' Makefile.am
+set_strictness '' configure.ac
+ok --gnu
+ok
+ok --foreign
+
+rm -rf autom4te*.cache
+set_strictness '' Makefile.am
+set_strictness 'foreign' configure.ac
+ok --gnu
+ok
+ok --foreign
+
+rm -rf autom4te*.cache
+set_strictness 'gnu' Makefile.am
+set_strictness 'gnu' configure.ac
+ko --gnu
+ko
+ko --foreign
+
+rm -rf autom4te*.cache
+set_strictness 'foreign' Makefile.am
+set_strictness 'foreign' configure.ac
+ok --gnu
+ok
+ok --foreign
+
+rm -rf autom4te*.cache
+set_strictness 'foreign' Makefile.am
+set_strictness 'gnu' configure.ac
+ok --gnu
+ok
+ok --foreign
+
+rm -rf autom4te*.cache
+set_strictness 'gnu' Makefile.am
+set_strictness 'foreign' configure.ac
+ko --gnu
+ko
+ko --foreign
+
+:
diff --git a/t/strictness-precedence.sh b/t/strictness-precedence.sh
new file mode 100755
index 000000000..6f5a143da
--- /dev/null
+++ b/t/strictness-precedence.sh
@@ -0,0 +1,77 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# On the command line, in AM_INIT_AUTOMAKE, and in AUTOMAKE_OPTIONS,
+# strictness specified later should take precedence over strictness
+# specified earlier.
+
+. ./defs || Exit 1
+
+# We want complete control over automake options.
+AUTOMAKE=$am_original_AUTOMAKE
+
+cat > Makefile.am <<'END'
+AUTOMAKE_OPTIONS =
+END
+
+set_strictness ()
+{
+ set +x
+ sed <$2 >$2-t -e "s|^\\(AUTOMAKE_OPTIONS\\) *=.*|\\1 = $1|" \
+ -e "s|^\\(AM_INIT_AUTOMAKE\\).*|\\1([$1])|"
+ mv -f $2-t $2
+ set -x
+ cat $2
+}
+
+ok ()
+{
+ $AUTOMAKE -Werror $*
+}
+
+ko ()
+{
+ AUTOMAKE_fails $*
+ grep 'required file.*README' stderr
+}
+
+# Leave out only one of the required files, to avoid too much
+# repetition in the error messages.
+touch INSTALL NEWS AUTHORS ChangeLog COPYING
+
+$ACLOCAL
+ko --foreign --gnu
+ok --gnu --foreign
+
+set_strictness '' Makefile.am
+set_strictness 'gnu foreign' configure.ac
+rm -rf autom4te*.cache
+$ACLOCAL
+ok
+set_strictness 'foreign gnu' configure.ac
+rm -rf autom4te*.cache
+$ACLOCAL
+ko
+
+set_strictness '' configure.ac
+rm -rf autom4te*.cache
+$ACLOCAL
+set_strictness 'gnu foreign' Makefile.am
+ok
+set_strictness 'foreign gnu' Makefile.am
+ko
+
+:
diff --git a/t/strip.sh b/t/strip.sh
new file mode 100755
index 000000000..dfefcd9c2
--- /dev/null
+++ b/t/strip.sh
@@ -0,0 +1,50 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Test for install-strip.
+
+required=cc
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_SCRIPTS = foo
+END
+
+cat > foo << 'END'
+#! /bin/sh
+echo Maude
+END
+
+chmod +x foo
+
+mkdir install
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+prefix=`cd install && pwd` || Exit 1
+./configure --prefix="$prefix"
+$MAKE
+$MAKE install-strip
+diff foo "$prefix"/bin/foo
+
+:
diff --git a/t/strip2.sh b/t/strip2.sh
new file mode 100755
index 000000000..49a5c066c
--- /dev/null
+++ b/t/strip2.sh
@@ -0,0 +1,53 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Ensure install-strip works when STRIP consists of more than one word.
+# This test needs GNU binutils strip. See sister test strip3.
+
+required='cc strip'
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_RANLIB
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = foo
+lib_LIBRARIES = libfoo.a
+END
+
+cat > foo.c << 'END'
+int main () { return 0; }
+END
+
+cat > libfoo.c << 'END'
+int foo () { return 0; }
+END
+
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+prefix=`pwd`/inst
+./configure --prefix="$prefix" STRIP='strip --verbose'
+$MAKE
+$MAKE install-strip
+
+:
diff --git a/t/strip3.sh b/t/strip3.sh
new file mode 100755
index 000000000..187e8a58e
--- /dev/null
+++ b/t/strip3.sh
@@ -0,0 +1,53 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Ensure install-strip works when STRIP consists of more than one word.
+# This test needs GNU binutils strip. Libtool variant.
+
+required='cc libtoolize strip'
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_LIBTOOL
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = foo
+lib_LTLIBRARIES = libfoo.la
+END
+
+cat > foo.c << 'END'
+int main () { return 0; }
+END
+
+cat > libfoo.c << 'END'
+int foo () { return 0; }
+END
+
+libtoolize
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+prefix=`pwd`/inst
+./configure --prefix="$prefix" STRIP='strip --verbose'
+$MAKE
+$MAKE install-strip
+
+:
diff --git a/t/subcond.sh b/t/subcond.sh
new file mode 100755
index 000000000..c09e5ad4f
--- /dev/null
+++ b/t/subcond.sh
@@ -0,0 +1,42 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# It is ok to have a conditional SUBDIRS when using gettext.
+
+required=gettext
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AM_GNU_GETTEXT
+AM_CONDITIONAL(MAUDE, true)
+ALL_LINGUAS=
+AC_SUBST(ALL_LINGUAS)
+END
+
+mkdir po intl
+: >config.rpath
+
+cat > Makefile.am << 'END'
+if MAUDE
+SUBDIRS = po intl
+else
+SUBDIRS =
+endif
+END
+
+$ACLOCAL
+# Gettext wants config.guess etc.
+$AUTOMAKE --add-missing
diff --git a/t/subcond2.sh b/t/subcond2.sh
new file mode 100755
index 000000000..0e9f45137
--- /dev/null
+++ b/t/subcond2.sh
@@ -0,0 +1,89 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# The for conditional SUBDIRS.
+# SUBDIRS + AM_CONDITIONAL setup from the manual.
+# Lots of lines here are duplicated in subcond3.test.
+
+. ./defs || Exit 1
+
+cat >>configure.ac <<'END'
+AM_CONDITIONAL([COND_OPT], [test "$want_opt" = yes])
+AC_CONFIG_FILES([src/Makefile opt/Makefile])
+AC_OUTPUT
+END
+
+cat >Makefile.am << 'END'
+if COND_OPT
+ MAYBE_OPT = opt
+endif
+SUBDIRS = src $(MAYBE_OPT)
+
+# Testing targets.
+#
+# We want to ensure that
+# - src/source and opt/source are always distributed.
+# - src/result is always built
+# - opt/result is built conditionally
+#
+# We rely on 'distcheck' to run 'check-local' and use
+# 'sanity1' and 'sanity2' as evidences that test-build was run.
+
+if COND_OPT
+test-build: all
+ test -f src/result
+ test -f opt/result
+ : > $(top_builddir)/../../sanity2
+else
+test-build: all
+ test -f src/result
+ test ! -f opt/result
+ : > $(top_builddir)/../../sanity1
+endif
+
+test-dist: distdir
+ test -f $(distdir)/src/source
+ test -f $(distdir)/opt/source
+
+check-local: test-build test-dist
+END
+
+mkdir src opt
+: > src/source
+: > opt/source
+
+cat >src/Makefile.am << 'END'
+EXTRA_DIST = source
+all-local: result
+CLEANFILES = result
+
+result: source
+ cp $(srcdir)/source result
+END
+
+# We want in opt/ the same Makefile as in src/. Let's exercise 'include'.
+cat >opt/Makefile.am << 'END'
+include ../src/Makefile.am
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+./configure
+$MAKE distcheck
+test -f sanity1
+DISTCHECK_CONFIGURE_FLAGS=want_opt=yes $MAKE distcheck
+test -f sanity2
diff --git a/t/subcond3.sh b/t/subcond3.sh
new file mode 100755
index 000000000..e84aa4114
--- /dev/null
+++ b/t/subcond3.sh
@@ -0,0 +1,90 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# The for conditional SUBDIRS.
+# SUBDIRS + AC_SUBST setup from the manual.
+# Lots of lines here are duplicated in subcond2.test.
+
+. ./defs || Exit 1
+
+cat >>configure.ac <<'END'
+if test "$want_opt" = yes; then
+ MAYBE_OPT=opt
+else
+ MAYBE_OPT=
+fi
+AC_SUBST([MAYBE_OPT])
+AC_CONFIG_FILES([src/Makefile opt/Makefile])
+AC_OUTPUT
+END
+
+cat >Makefile.am << 'END'
+SUBDIRS = src $(MAYBE_OPT)
+DIST_SUBDIRS = src opt
+
+# Testing targets.
+#
+# We want to ensure that
+# - src/source and opt/source are always distributed.
+# - src/result is always built
+# - opt/result is built conditionally
+#
+# We rely on 'distcheck' to run 'check-local' and use
+# 'sanity1' and 'sanity2' as evidences that test-build was run.
+
+test-build: all
+ test -f src/result
+ if test -n "$(MAYBE_OPT)"; then \
+ test -f opt/result || exit 1; \
+ : > $(top_builddir)/../../sanity2 || exit 1; \
+ else \
+ test ! -f opt/result || exit 1; \
+ : > $(top_builddir)/../../sanity1 || exit 1; \
+ fi
+
+test-dist: distdir
+ test -f $(distdir)/src/source
+ test -f $(distdir)/opt/source
+
+check-local: test-build test-dist
+END
+
+mkdir src opt
+: > src/source
+: > opt/source
+
+cat >src/Makefile.am << 'END'
+EXTRA_DIST = source
+all-local: result
+CLEANFILES = result
+
+result: source
+ cp $(srcdir)/source result
+END
+
+# We want in opt/ the same Makefile as in src/. Let's exercise 'include'.
+cat >opt/Makefile.am << 'END'
+include ../src/Makefile.am
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+./configure
+$MAKE distcheck
+test -f sanity1
+DISTCHECK_CONFIGURE_FLAGS=want_opt=yes $MAKE distcheck
+test -f sanity2
diff --git a/t/subdir.sh b/t/subdir.sh
new file mode 100755
index 000000000..34b6ece88
--- /dev/null
+++ b/t/subdir.sh
@@ -0,0 +1,40 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test to make sure install-sh and mkinstalldirs correctly found in
+# subdirs.
+
+. ./defs || Exit 1
+
+mkdir zot
+
+cat >> configure.ac << 'END'
+AC_CONFIG_FILES([zot/Makefile])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+SUBDIRS = zot
+END
+
+cat > zot/Makefile.am << 'END'
+pkgdata_DATA =
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+:
diff --git a/t/subdir10.sh b/t/subdir10.sh
new file mode 100755
index 000000000..4ba791ad8
--- /dev/null
+++ b/t/subdir10.sh
@@ -0,0 +1,37 @@
+#! /bin/sh
+# Copyright (C) 2009-2012 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/>.
+
+# SUDBIRS with $fail set in the environment.
+
+. ./defs || Exit 1
+
+mkdir sub
+
+cat >> configure.ac <<'END'
+AC_CONFIG_FILES([sub/Makefile])
+AC_OUTPUT
+END
+
+echo SUBDIRS = sub >Makefile.am
+: > sub/Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+env fail=1 $MAKE all clean
+
+:
diff --git a/t/subdir2.sh b/t/subdir2.sh
new file mode 100755
index 000000000..31e3c61f2
--- /dev/null
+++ b/t/subdir2.sh
@@ -0,0 +1,52 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test to make sure sub-sub-dirs work correctly.
+
+. ./defs || Exit 1
+
+mkdir one
+mkdir one/two
+
+cat >> configure.ac << 'END'
+AC_CONFIG_FILES([one/Makefile one/two/Makefile])
+AC_OUTPUT
+END
+
+# Files required because we are using '--gnu'.
+: > INSTALL
+: > NEWS
+: > README
+: > COPYING
+: > AUTHORS
+: > ChangeLog
+
+cat > Makefile.am << 'END'
+SUBDIRS = one
+END
+
+cat > one/Makefile.am << 'END'
+SUBDIRS = two
+END
+
+cat > one/two/Makefile.am << 'END'
+pkgdata_DATA =
+END
+
+$ACLOCAL
+$AUTOMAKE --gnu
+
+:
diff --git a/t/subdir3.sh b/t/subdir3.sh
new file mode 100755
index 000000000..d9b160fa8
--- /dev/null
+++ b/t/subdir3.sh
@@ -0,0 +1,36 @@
+#! /bin/sh
+# Copyright (C) 1999-2012 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/>.
+
+# Test to make sure subdir source file generates explicit dependency.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = zardoz widdershins
+zardoz_SOURCES = y.c x/z.c
+widdershins_SOURCES = x/z.c
+END
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+grep '^z\.o: x/z\.c$' Makefile.in
+
+:
diff --git a/t/subdir4.sh b/t/subdir4.sh
new file mode 100755
index 000000000..81528b2af
--- /dev/null
+++ b/t/subdir4.sh
@@ -0,0 +1,70 @@
+#! /bin/sh
+# Copyright (C) 2000-2012 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 a top-level depcomp file is found when
+# AC_CONFIG_AUX_DIR is not specified.
+
+. ./defs || Exit 1
+
+mkdir lib src
+
+cat >> configure.ac << 'END'
+AC_PROG_RANLIB
+AC_PROG_CC
+AM_PROG_AR
+AC_CONFIG_FILES([lib/Makefile src/Makefile])
+AC_OUTPUT
+END
+
+# Files required because we are using '--gnu'.
+: > INSTALL
+: > NEWS
+: > README
+: > COPYING
+: > AUTHORS
+: > ChangeLog
+
+cat > Makefile.am << 'END'
+SUBDIRS = lib src
+END
+
+cat > lib/Makefile.am << 'END'
+pkgdata_DATA =
+noinst_LIBRARIES = libfoo.a
+libfoo_a_SOURCES = foo.c
+END
+
+cat > lib/foo.c << 'END'
+int foo () {}
+END
+
+cat > src/Makefile.am << 'END'
+pkgdata_DATA =
+END
+
+: > ar-lib
+
+$ACLOCAL
+$AUTOMAKE --gnu
+
+# Make sure that depcomp is *not* included in the definition
+# of DIST_COMMON in lib/Makefile.in. If you change this test
+# so that more files are included in lib's DIST_COMMON definition,
+# then you must handle the case in which depcomp is listed on a
+# continued line.
+grep '^DIST_COMMON.*depcomp' lib/Makefile.in && Exit 1
+
+:
diff --git a/t/subdir5.sh b/t/subdir5.sh
new file mode 100755
index 000000000..a74c746d0
--- /dev/null
+++ b/t/subdir5.sh
@@ -0,0 +1,95 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test to make sure that adding a new directory works.
+# This test runs 'make' from the top-level directory, the sister test
+# 'subdir8.test' do it from a subdirectory.
+# PR automake/46
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+: > Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+$MAKE
+
+# Now add new directories.
+
+# First we add a new directory by modifying configure.ac directly.
+# We update configure.ac *before* updating sub/Makefile.am; subdir8.test
+# does it in the other way: it updates confiles.m4 (which is m4_included
+# by configure.ac there) after Makefile.am.
+
+# Modified configure dependencies must be newer than config.status.
+$sleep
+sed <configure.ac >configure.tmp -e '/^AC_OUTPUT$/i\
+AC_CONFIG_FILES([maude/Makefile])\
+m4_include([confile.m4])\
+' # Last newline required by older OpenBSD sed.
+mv -f configure.tmp configure.ac
+
+cat configure.ac # For debugging.
+
+: > confile.m4
+
+mkdir maude
+
+cat > maude/Makefile.am << 'END'
+include_HEADERS = foo.h
+END
+
+: > maude/foo.h
+
+echo 'SUBDIRS = maude' >> Makefile.am
+
+# We want a simple rebuild to create maude/Makefile automatically.
+$MAKE
+grep '^SUBDIRS = *maude *$' Makefile.in
+grep '^SUBDIRS = *maude *$' Makefile
+test -f maude/Makefile
+
+# Then we add a new directory by modifying a file included (through
+# 'm4_include') by configure.ac.
+mkdir maude2
+# Modified configure dependencies must be newer than config.status.
+$sleep
+cat >> confile.m4 << 'END'
+AC_CONFIG_FILES([maude2/Makefile])
+AC_SUBST([GREPME])
+END
+: > maude2/Makefile.am
+echo 'SUBDIRS += maude2' >> Makefile.am
+
+# We want a simple rebuild to create maude2/Makefile and update
+# all other Makefiles automatically.
+$MAKE
+grep '^SUBDIRS =.* maude2' Makefile.in
+grep '^SUBDIRS =.* maude2' Makefile
+
+for ext in '.in' ''; do
+ for d in . maude maude2; do
+ grep '^GREPME =' $d/Makefile$ext
+ done
+done
+
+:
diff --git a/t/subdir6.sh b/t/subdir6.sh
new file mode 100755
index 000000000..5c17b6550
--- /dev/null
+++ b/t/subdir6.sh
@@ -0,0 +1,40 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Test to make sure config headers in subdirectories are cleaned.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AM_CONFIG_HEADER([sub/config.h:sub/config.hin])
+AC_OUTPUT
+END
+
+touch Makefile.am
+mkdir sub
+
+$ACLOCAL
+$AUTOCONF
+touch sub/config.hin
+$AUTOMAKE
+./configure
+test -f sub/stamp-h1
+$MAKE clean
+test -f sub/stamp-h1
+$MAKE distclean
+test -f sub/stamp-h1 && Exit 1
+
+:
diff --git a/t/subdir7.sh b/t/subdir7.sh
new file mode 100755
index 000000000..a2c47a14f
--- /dev/null
+++ b/t/subdir7.sh
@@ -0,0 +1,45 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Naming a subdirectory 'obj/' is a bad idea. Automake should say so.
+
+. ./defs || Exit 1
+
+mkdir obj
+
+cat >>configure.ac << 'END'
+AC_CONFIG_FILES([obj/Makefile])
+AC_OUTPUT
+END
+
+: > obj/Makefile.am
+echo 'SUBDIRS = obj' >Makefile.am
+
+$ACLOCAL
+
+AUTOMAKE_fails
+grep 'Makefile.am:1:.*obj.*BSD' stderr
+
+cat >Makefile.am <<'END'
+SUBDIRS = @STH@
+FOO = obj
+DIST_SUBDIRS = $(FOO)
+END
+
+AUTOMAKE_fails
+grep 'Makefile.am:2:.*obj.*BSD' stderr
+
+:
diff --git a/t/subdir8.sh b/t/subdir8.sh
new file mode 100755
index 000000000..ee9e0b0d5
--- /dev/null
+++ b/t/subdir8.sh
@@ -0,0 +1,97 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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/>.
+
+# Test to make sure that adding a new directory works, even from
+# subdirectories. The sister test 'subdir5.test' makes sure it works
+# when make is run from the top-level directory.
+# PR automake/46
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+m4_include([confiles.m4])
+MORE_DEFS
+AC_OUTPUT
+END
+
+echo 'AC_CONFIG_FILES([sub/Makefile])' > confiles.m4
+
+cat > Makefile.am << 'END'
+SUBDIRS = sub
+ACLOCAL_AMFLAGS = -I m4
+END
+
+mkdir sub
+
+: > sub/Makefile.am
+
+mkdir m4
+echo 'AC_DEFUN([MORE_DEFS], [])' > m4/moredefs.m4
+
+$ACLOCAL -I m4
+$AUTOCONF
+$AUTOMAKE
+./configure
+$MAKE
+
+# Now add new directories.
+
+# The first step users typically do when adding a new subdir is
+# editing configure.ac. That is already tested by subdir5.test,
+# though, so here we try to just edit a file that is included by
+# configure.ac, without touching configure.ac itself.
+
+mkdir sub/maude
+cat > sub/maude/Makefile.am << 'END'
+include_HEADERS = foo.h
+END
+
+: > sub/maude/foo.h
+
+echo 'SUBDIRS = maude' >> sub/Makefile.am
+
+mkdir maude
+: > maude/Makefile.am
+
+# Update confiles.m4 *after* updating sub/Makefile.am; subdir5.test do
+# it in the other way: it updates configure.ac before Makefile.am.
+# We sleep here because modified configure dependencies must be newer
+# than config.status.
+$sleep
+echo 'AC_CONFIG_FILES([maude/Makefile sub/maude/Makefile])' >> confiles.m4
+
+# We want a simple rebuild from sub/ to create sub/maude/Makefile
+# and maude/Makefile automatically.
+cd sub
+$MAKE
+cd ..
+grep '^SUBDIRS = *maude *$' sub/Makefile.in
+grep '^SUBDIRS = *maude *$' sub/Makefile
+test -f maude/Makefile
+test -f sub/maude/Makefile
+
+# Make sure the dependencies of aclocal.m4 or honored at least from
+# the top-level directory.
+echo 'AC_DEFUN([MORE_DEFS], [AC_SUBST([GREPME])])' > m4/moredefs.m4
+$MAKE
+
+for ext in '.in' ''; do
+ for d in . maude sub sub/maude; do
+ grep '^GREPME =' $d/Makefile$ext
+ done
+done
+
+:
diff --git a/t/subdir9.sh b/t/subdir9.sh
new file mode 100755
index 000000000..116e1c306
--- /dev/null
+++ b/t/subdir9.sh
@@ -0,0 +1,55 @@
+#! /bin/sh
+# Copyright (C) 2004-2012 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/>.
+
+# Test SUDBIRS with /.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_CONFIG_FILES([src/subdir/Makefile src/subdir2/Makefile])
+AC_OUTPUT
+END
+
+echo SUBDIRS = src/subdir >Makefile.am
+
+mkdir src
+mkdir src/subdir
+mkdir src/subdir2
+
+: >src/subdir/foo
+: >src/subdir2/foo
+
+cat >src/subdir/Makefile.am <<'EOF'
+EXTRA_DIST = foo
+SUBDIRS = ../subdir2
+EOF
+
+cat >src/subdir2/Makefile.am <<'EOF'
+EXTRA_DIST = foo
+EOF
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --copy --add-missing
+./configure
+$MAKE distdir
+test -f $distdir/src/subdir/foo
+test -f $distdir/src/subdir2/foo
+$MAKE clean
+$MAKE distclean
+test ! -f src/subdir2/Makefile
+
+:
diff --git a/t/subdirbuiltsources.sh b/t/subdirbuiltsources.sh
new file mode 100755
index 000000000..2f507083e
--- /dev/null
+++ b/t/subdirbuiltsources.sh
@@ -0,0 +1,71 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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 when using SUBDIR that all BUILT_SOURCES are built.
+# A bug occurred where subdirs do not have all-recursive or
+# all-recursive-am which depended on BUILT_SOURCES.
+
+required=cc
+. ./defs || Exit 1
+
+mkdir lib
+
+cat >> configure.ac << 'END'
+AC_CONFIG_FILES([lib/Makefile])
+AC_PROG_RANLIB
+AC_PROG_CC
+AM_PROG_AR
+AC_OUTPUT
+END
+
+# Files required because we are using '--gnu'.
+: > INSTALL
+: > NEWS
+: > README
+: > COPYING
+: > AUTHORS
+: > ChangeLog
+
+cat > Makefile.am << 'END'
+SUBDIRS = lib
+END
+
+cat > lib/Makefile.am << 'END'
+pkgdata_DATA =
+noinst_LIBRARIES = libfoo.a
+libfoo_a_SOURCES = foo.c
+BUILT_SOURCES=foo.h
+foo.h:
+ echo \#define FOO_DEFINE 1 >$@
+END
+
+cat > lib/foo.c << 'END'
+#include <foo.h>
+int foo () { return !FOO_DEFINE;}
+END
+
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --include-deps --copy --force-missing --add-missing --gnu
+
+./configure
+
+# Remove the comment to get a successful test.
+# $MAKE -C lib foo.h
+$MAKE
+
+:
diff --git a/t/subobj.sh b/t/subobj.sh
new file mode 100755
index 000000000..b7f6597d4
--- /dev/null
+++ b/t/subobj.sh
@@ -0,0 +1,45 @@
+#! /bin/sh
+# Copyright (C) 1999-2012 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/>.
+
+# Test of subdir objects with C.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_CC_C_O
+END
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = subdir-objects
+bin_PROGRAMS = wish
+wish_SOURCES = generic/a.c generic/b.c
+END
+
+$ACLOCAL
+$AUTOMAKE --add-missing 2>stderr || { cat stderr >&2; Exit 1; }
+cat stderr >&2
+# Make sure compile is installed, and that Automake says so.
+grep 'install.*compile' stderr
+test -f compile
+
+grep '^generic/a\.\$(OBJEXT):' Makefile.in
+grep '[^/]a\.\$(OBJEXT)' Makefile.in && Exit 1
+
+# Opportunistically test for a different bug.
+grep '^generic/b\.\$(OBJEXT):.*dirstamp' Makefile.in
+
+:
diff --git a/t/subobj10.sh b/t/subobj10.sh
new file mode 100755
index 000000000..db6bf7267
--- /dev/null
+++ b/t/subobj10.sh
@@ -0,0 +1,55 @@
+#! /bin/sh
+# Copyright (C) 2006-2012 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/>.
+
+# PR 492: Test asm subdir-objects.
+
+required=gcc
+. ./defs || Exit 1
+
+cat > configure.ac << END
+AC_INIT([$me], [1.0])
+AM_INIT_AUTOMAKE([subdir-objects])
+
+AM_PROG_AS
+AM_PROG_AR
+AC_PROG_RANLIB
+
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+noinst_LIBRARIES = libfoo.a libbar.a
+libfoo_a_SOURCES = src/a.s b.s
+libbar_a_SOURCES = src/c.s d.s
+libbar_a_CCASFLAGS =
+END
+
+mkdir src
+: >src/a.s
+: >b.s
+: >src/c.s
+: >d.s
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+$MAKE
+$MAKE distcheck
+
+:
diff --git a/t/subobj11a.sh b/t/subobj11a.sh
new file mode 100755
index 000000000..461325af2
--- /dev/null
+++ b/t/subobj11a.sh
@@ -0,0 +1,81 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Test that automake works around a bug of Solaris Make. The bug is the
+# following. If we have a Makefile containg a file inclusion like this:
+# include .//foo.mk
+# Solaris make fails with a message like:
+# make: ... can't find '/foo.mk': No such file or directory
+# make: fatal error ... read of include file '/foo.mk' failed
+# (even if the file 'foo.mk' exists). The error disappear by collapsing
+# the repeated slash '/' characters into a single one.
+#
+# See also sister "grepping" test 'subobj11b.test', and related test
+# 'subobj11c.test'.
+
+required=cc
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = subdir-objects
+bin_PROGRAMS = foo
+## The './/' below is meant.
+foo_SOURCES = .//src/foo.c
+END
+
+mkdir src
+
+cat > src/foo.c << 'END'
+int main(void)
+{
+ return 0;
+}
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure --enable-dependency-tracking
+
+depdir=`sed -n 's/^ *DEPDIR *= *//p' Makefile`
+if test x"$depdir" != x; then
+ depdir=src/$depdir
+else
+ echo "$me: cannot extract value of DEPDIR from Makefile" >&2
+ Exit 1
+fi
+
+ls -l "$depdir"
+test -f "$depdir"/foo.Po
+
+echo 'quux:; echo "z@rd@z" >$@' >> "$depdir"/foo.Po
+
+$MAKE quux
+$FGREP "z@rd@z" quux
+
+$MAKE
+
+DISTCHECK_CONFIGURE_FLAGS='--enable-dependency-tracking' $MAKE distcheck
+DISTCHECK_CONFIGURE_FLAGS='--disable-dependency-tracking' $MAKE distcheck
+
+:
diff --git a/t/subobj11b.sh b/t/subobj11b.sh
new file mode 100755
index 000000000..129b6ea61
--- /dev/null
+++ b/t/subobj11b.sh
@@ -0,0 +1,85 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Test that automake works around a bug of Solaris Make. The bug is the
+# following. If we have a Makefile containg a file inclusion like this:
+# include .//foo.mk
+# Solaris make fails with a message like:
+# make: ... can't find '/foo.mk': No such file or directory
+# make: fatal error ... read of include file '/foo.mk' failed
+# (even if the file 'foo.mk' exists). The error disappear by collapsing
+# the repeated slash '/' characters into a single one.
+#
+# See also "semantic" sister test 'subobj11a.test', and related test
+# 'subobj11c.test'.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_CC_C_O
+END
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = subdir-objects
+bin_PROGRAMS = foo
+## The 'zardoz' sources should activate a code paths in Automake that
+## cannot be sensibly tested by sister test 'subobj11a.test'. The other
+## sources provide some sort of stress testing.
+foo_SOURCES = \
+ //server/zardoz0.c \
+ //server//zardoz1.c \
+ //server/path/to/zardoz2.c \
+ //server/another//path///to////zardoz3.c \
+ /foobar0.c \
+ ///foobar1.c \
+ ////foobar2.c \
+ /sub///foobar3.c \
+ ///sub/foobar4.c \
+ .//foobar5.c \
+ .//sub/foobar6.c \
+ ./sub//foobar7.c \
+ .//sub//foobar8.c \
+ sub/sub//sub///sub////foobar9.c
+END
+
+$ACLOCAL
+$AUTOMAKE -a
+
+# Be lax in the regexp, to account for automake conditionals, the
+# use of @am__include@, and similar stuff.
+grep 'include.*//.*foobar' Makefile.in && Exit 1
+
+# These checks depend on automake internals, but presently this is
+# the only way to test the code path we are interested in.
+# Please update these checks when (and if) the relevant automake
+# internals are changed.
+for x in zardoz0 zardoz1 path/to/zardoz2 another/path/to/zardoz3; do
+ case $x in
+ */*) d=`echo $x | sed 's,[^/]*$,,'`; b=`echo $x | sed 's,^.*/,,'`;;
+ *) d=''; b=$x;;
+ esac
+ # Be a little lax in the regexp, to account for automake conditionals,
+ # quoting, and similar stuff.
+ grep "^[^/]*am__include[^/]*//server/$d\\\$(DEPDIR)/$b\\.[^/]*$" Makefile.in
+done
+
+# Sanity checks.
+for i in 0 1 2 3 4 5 6 7 8 9; do
+ grep "am__include.*/foobar$i\\." Makefile.in
+done
+
+:
diff --git a/t/subobj11c.sh b/t/subobj11c.sh
new file mode 100755
index 000000000..9f59c5f6c
--- /dev/null
+++ b/t/subobj11c.sh
@@ -0,0 +1,51 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Automatic dependency tracking with subdir-objects option active:
+# check for a pathological case of slash-collapsing in the name of
+# included makefile fragments (containing dependency info).
+# See also related tests 'subobj11a.test' and 'subobj11b.test'.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_CC_C_O
+END
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = subdir-objects
+bin_PROGRAMS = foo
+foo_SOURCES = //zardoz.c
+END
+
+$ACLOCAL
+$AUTOMAKE -a
+
+#
+# This check depends on automake internals, but presently this is
+# the only way to test the code path we are interested in.
+# Please update these checks when (and if) the relevant automake
+# internals are changed.
+#
+# Be a little lax in the regexp, to account for automake conditionals,
+# quoting, and similar stuff.
+#
+# FIXME: Are we sure this is the most sensible output in our situation?
+#
+grep '^[^/]*am__include[^/]*//\$(DEPDIR)/zardoz\.[^/]*$' Makefile.in
+
+:
diff --git a/t/subobj2.sh b/t/subobj2.sh
new file mode 100755
index 000000000..3a3f86192
--- /dev/null
+++ b/t/subobj2.sh
@@ -0,0 +1,38 @@
+#! /bin/sh
+# Copyright (C) 1999-2012 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/>.
+
+# Test of subdir objects with C++.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CXX
+END
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = subdir-objects
+bin_PROGRAMS = wish
+wish_SOURCES = generic/a.cc generic/b.cxx
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+$FGREP 'generic/a.$(OBJEXT)' Makefile.in
+grep '[^/]a\.\$(OBJEXT)' Makefile.in && Exit 1
+grep '.*-c -o' Makefile.in
+
+:
diff --git a/t/subobj4.sh b/t/subobj4.sh
new file mode 100755
index 000000000..975f8fbb8
--- /dev/null
+++ b/t/subobj4.sh
@@ -0,0 +1,52 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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 '../foo/foo.cpp' generates a rule.
+# Report from Dave Brolley.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_PROG_CXX
+AC_CONFIG_FILES([d1/Makefile d2/Makefile])
+AC_OUTPUT
+END
+
+mkdir d1 d2
+
+cat > Makefile.am << 'END'
+SUBDIRS = d1 d2
+END
+
+cat > d1/Makefile.am << 'END'
+bin_PROGRAMS = z
+z_SOURCES = ../d2/z.c
+END
+
+cat > d2/Makefile.am << 'END'
+END
+
+: > compile
+: > d2/z.c
+
+$ACLOCAL
+$AUTOMAKE
+
+grep '\$(CC) .*\.\./d2/z\.c' d1/Makefile.in
+
+:
diff --git a/t/subobj5.sh b/t/subobj5.sh
new file mode 100755
index 000000000..3b05b6a74
--- /dev/null
+++ b/t/subobj5.sh
@@ -0,0 +1,70 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test of subdir make dist rules.
+# From Robert Collins.
+
+required=cc
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_CONFIG_FILES([generic/Makefile])
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = subdir-objects
+bin_PROGRAMS = wish
+wish_SOURCES = generic/a.c
+
+.PHONY: test-distdir test-build
+test-distdir: distdir
+ ls -l $(distdir) $(distdir)/* ;: For debugging.
+ test ! -r $(distdir)/a.c
+ test -f $(distdir)/generic/a.c
+test-build: all
+ ls -l . generic ;: For debugging.
+ test -f generic/a.$(OBJEXT)
+ test -f wish$(EXEEXT)
+ test ! -r a.$(OBJEXT)
+ test ! -r a$(EXEEXT)
+ test ! -r generic/wish$(EXEEXT)
+ test ! -r generic/a$(EXEEXT)
+END
+
+mkdir generic
+: > generic/Makefile.am
+
+cat > generic/a.c << 'END'
+int main (void)
+{
+ return 0;
+}
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --include-deps --copy --add-missing
+
+./configure
+
+$MAKE test-distdir
+$MAKE dist
+$MAKE test-build
+
+:
diff --git a/t/subobj6.sh b/t/subobj6.sh
new file mode 100755
index 000000000..2f902f20a
--- /dev/null
+++ b/t/subobj6.sh
@@ -0,0 +1,85 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test of subdir make distclean rules.
+# From Robert Collins.
+
+required=cc
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AM_PROG_CC_C_O
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = subdir-objects
+bin_PROGRAMS = wish
+wish_SOURCES = generic/a.c
+
+test-all: all
+ test -f generic/$(am__dirstamp)
+test-mostlyclean: mostlyclean
+ test ! -f generic/a.o
+test-distclean: distclean
+ test ! -f generic/$(am__dirstamp)
+END
+
+mkdir generic
+cat > generic/a.c << 'END'
+#include <stdio.h>
+int main ()
+{
+ printf ("maude!\n");
+ return 0;
+}
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --include-deps --copy --add-missing
+
+mkdir build
+cd build
+
+../configure
+$MAKE test-all
+$MAKE test-mostlyclean
+$MAKE test-distclean
+
+cd ..
+
+# Now test without the subdir.
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = subdir-objects
+bin_PROGRAMS = wish
+wish_SOURCES = a.c
+END
+
+mv generic/a.c a.c
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --include-deps --copy --add-missing
+
+mkdir build2
+cd build2
+
+../configure
+$MAKE
+$MAKE mostlyclean
+
+:
diff --git a/t/subobj7.sh b/t/subobj7.sh
new file mode 100755
index 000000000..863cae031
--- /dev/null
+++ b/t/subobj7.sh
@@ -0,0 +1,38 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test to make sure AM_CFLAGS appears in subdir compilation rule.
+# Report from Steve M. Robbins.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = wish
+wish_SOURCES = foo.c generic/a.c
+END
+
+$ACLOCAL
+$AUTOMAKE --add-missing
+
+grep wish_CFLAGS Makefile.in && Exit 1
+
+:
diff --git a/t/subobj8.sh b/t/subobj8.sh
new file mode 100755
index 000000000..35b566f50
--- /dev/null
+++ b/t/subobj8.sh
@@ -0,0 +1,47 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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 'compile' is included when subdir-objects is used in a subdir.
+
+. ./defs || Exit 1
+
+cat > configure.ac << END
+AC_INIT([$me], [1.0])
+AC_CONFIG_AUX_DIR([tools])
+AM_INIT_AUTOMAKE
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_CONFIG_FILES([Makefile foo/Makefile])
+AC_OUTPUT
+END
+
+mkdir tools foo foo/bar
+
+cat > Makefile.am << 'END'
+SUBDIRS = foo
+END
+
+cat > foo/Makefile.am << 'END'
+AUTOMAKE_OPTIONS = subdir-objects
+bin_PROGRAMS = mumble
+mumble_SOURCES = bar/a.c
+END
+
+$ACLOCAL
+$AUTOMAKE --add-missing
+test -f tools/compile
+
+:
diff --git a/t/subobj9.sh b/t/subobj9.sh
new file mode 100755
index 000000000..f706edf4d
--- /dev/null
+++ b/t/subobj9.sh
@@ -0,0 +1,89 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Test for PR 312.
+#
+# == Report ==
+# When using non-recursive make to build a libtoolize-library from
+# sources in a subdirectory, 'make distcheck' fails because of incomplete
+# cleanup. "make clean" tries to remove '*.o' and '.../<file>.lo' but
+# forgets '.../<file>.o'.
+
+required='c++ libtoolize'
+. ./defs || Exit 1
+
+cat > configure.ac << END
+AC_INIT([$me], [1.0])
+AM_INIT_AUTOMAKE([subdir-objects])
+AC_PROG_CXX
+AM_PROG_AR
+AM_PROG_LIBTOOL
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+noinst_LTLIBRARIES = libfoo.la
+libfoo_la_SOURCES = src/foo.cc .//src/bar.cc # The `.//' is meant.
+.PHONY: print
+print:
+ @echo BEG1: "$(LTCXXCOMPILE)" :1END
+ @echo BEG2: "$(CXXLINK)" :2END
+END
+
+mkdir src
+cat > src/foo.cc << 'END'
+int doit2 (void);
+int doit (void)
+{
+ return doit2();
+}
+END
+
+cat > src/bar.cc << 'END'
+int doit2 (void)
+{
+ return 23;
+}
+END
+
+
+libtoolize --force
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+# Ensure './libtool --help' will use the right tool versions.
+export AUTOCONF AUTOMAKE
+
+# Opportunistically check that --tag=CXX is used when supported.
+if ./libtool --help | grep tag=TAG; then
+ $MAKE print >stdout || { cat stdout; Exit 1; }
+ cat stdout
+ grep 'BEG1: .*--tag=CXX.*--mode=compile.* :1END' stdout
+ grep 'BEG2: .*--tag=CXX.*--mode=link.* :2END' stdout
+fi
+
+$MAKE
+$MAKE distcheck >output 2>&1 || { cat output; Exit 1; }
+cat output
+# GNU Make used to complain that the Makefile contained two rules
+# for 'src/.dirstamp' and './/src/.dirstamp'.
+grep 'overriding commands' output && Exit 1
+
+:
diff --git a/t/subobjname.sh b/t/subobjname.sh
new file mode 100755
index 000000000..bef3bf0bd
--- /dev/null
+++ b/t/subobjname.sh
@@ -0,0 +1,72 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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 we reuse variables whenever possible, to limit
+# combinational explosion. (This test is named after the &subobjname
+# sub in Automake).
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_CONDITIONAL([FOO1], [some test])
+AM_CONDITIONAL([FOO2], [some test])
+AM_CONDITIONAL([FOO3], [some test])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+noinst_PROGRAMS = c d
+
+if FOO1
+A1=a1.c
+endif
+
+if FOO2
+A2=a2.c
+endif
+
+if FOO3
+A3=a3.c
+endif
+
+B=$(A1) $(A2) $(A3)
+
+c_SOURCES=$(B)
+d_SOURCES=$(B)
+END
+
+$ACLOCAL
+$AUTOMAKE -a
+
+# Sanity check: make sure am_c_OBJECTS and am_d_OBJECTS are used
+# in the Makefile. (This is an internal detail, so better make
+# sure we update this test if the naming changes in the future.)
+grep '^am_c_OBJECTS = ' Makefile.in
+grep '^am_d_OBJECTS = ' Makefile.in
+
+# Now the actual test. Are both values equal?
+cobj=`sed -n '/^am_c_OBJECTS = / {
+ s/.* = \(.*\)$/\1/
+ p
+ }' Makefile.in`
+dobj=`sed -n '/^am_d_OBJECTS = / {
+ s/^.* = \(.*\)$/\1/
+ p
+ }' Makefile.in`
+test "$cobj" = "$dobj"
+
+:
diff --git a/t/subpkg-yacc.sh b/t/subpkg-yacc.sh
new file mode 100755
index 000000000..f1b2ac31c
--- /dev/null
+++ b/t/subpkg-yacc.sh
@@ -0,0 +1,129 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Check that ylwrap is installed properly, and $(YLWRAP) us defined
+# properly, when a subpackage is involved.
+
+required='cc yacc'
+. ./defs || Exit 1
+
+cat >>configure.ac <<'END'
+AC_PROG_CC
+AC_CONFIG_SUBDIRS([lib])
+AC_OUTPUT
+END
+
+cat >Makefile.am <<'EOF'
+SUBDIRS = lib
+bin_PROGRAMS = MU
+MU_LDADD = lib/liblib.a
+# It's ok to override distdir.
+distdir = subpack-1
+# Remove a file created by rules in subdir lib.
+CLEANFILES = lib-dist-hook-has-run
+EOF
+
+cat >MU.c <<'EOF'
+int lib (void);
+int main (void)
+{
+ return lib ();
+}
+EOF
+
+mkdir lib
+mkdir lib/src
+
+cat >lib/configure.ac <<'EOF'
+AC_INIT([lib], [2.3])
+AM_INIT_AUTOMAKE
+AC_PROG_RANLIB
+AC_PROG_YACC
+dnl This comes after YACC and RANLIB checks, deliberately.
+AC_PROG_CC
+AM_PROG_AR
+AC_CONFIG_HEADERS([config.h:config.hin])
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+EOF
+
+cat >lib/Makefile.am <<'EOF'
+noinst_LIBRARIES = liblib.a
+liblib_a_SOURCES = src/x.c foo.y
+EXTRA_liblib_a_SOURCES = bar.y
+
+dist-hook:
+ test -d $(top_distdir)
+ test -d $(distdir)
+ find $(top_distdir) $(distdir) ;: For debugging.
+ test -f $(top_distdir)/MU.c
+ test ! -f $(distdir)/MU.c
+ for suf in y c; do \
+ for name in foo bar; do \
+ test -f $(distdir)/$$name.$$suf || exit 1; \
+ test ! -f $(top_distdir)/$$name.$$suf || exit 1; \
+ done; \
+ done
+ test -f $(distdir)/foo.y
+ test ! -f $(top_distdir)/foo.y
+ test -f $(distdir)/src/x.c
+ test ! -f $(top_distdir)/src/x.c
+ test -f $(YLWRAP)
+ : > $(top_builddir)/../lib-dist-hook-has-run
+EOF
+
+cat > lib/foo.y << 'END'
+%{
+int yylex (void) { return 0; }
+void yyerror (char *s) {}
+%}
+%%
+foobar : 'f' 'o' 'o' 'b' 'a' 'r' {};
+END
+
+cp lib/foo.y lib/bar.y
+
+cat >lib/src/x.c <<'EOF'
+#include <config.h>
+int lib (void)
+{
+ return 0;
+}
+EOF
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -Wno-override
+
+cd lib
+$ACLOCAL
+$AUTOCONF
+$AUTOHEADER
+$AUTOMAKE -Wno-override --add-missing
+cd ..
+
+./configure
+
+$MAKE dist
+test -f lib-dist-hook-has-run
+test -f subpack-1.tar.gz
+test ! -d subpack-1 # Make sure "dist" cleans up after itself.
+
+rm -f lib-dist-hook-has-run subpack-1.tar.gz
+
+yl_distcheck
+
+:
diff --git a/t/subpkg.sh b/t/subpkg.sh
new file mode 100755
index 000000000..82bf33818
--- /dev/null
+++ b/t/subpkg.sh
@@ -0,0 +1,113 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Check subpackage handling.
+
+required=cc
+. ./defs || Exit 1
+
+mkdir m4
+
+cat >m4/foo.m4 <<'EOF'
+AC_DEFUN([FOO],[
+ AC_PROG_CC
+ AC_OUTPUT
+])
+EOF
+
+cat >>configure.ac <<'END'
+AC_CONFIG_SUBDIRS([lib])
+FOO
+END
+
+cat >Makefile.am <<'EOF'
+SUBDIRS = lib
+# Yes, This program is named LDADD. So what?
+bin_PROGRAMS = LDADD
+LDADD_LDADD = lib/liblib.a
+
+# It's ok to override distdir.
+distdir = subpack-1
+
+# Make sure $(distdir) and $(top_distdir) work as expected.
+dist-hook:
+ test -f $(distdir)/LDADD.c
+ test -f $(top_distdir)/LDADD.c
+
+ACLOCAL_AMFLAGS = -I m4
+EOF
+
+cat >LDADD.c <<'EOF'
+int lib (void);
+int main (void)
+{
+ return lib ();
+}
+EOF
+
+mkdir lib
+mkdir lib/src
+
+cat >lib/configure.ac <<'EOF'
+AC_INIT([lib], [2.3])
+AM_INIT_AUTOMAKE
+AM_PROG_AR
+AC_PROG_RANLIB
+AC_CONFIG_HEADERS([config.h:config.hin])
+AC_CONFIG_FILES([Makefile])
+FOO
+EOF
+
+cat >lib/Makefile.am <<'EOF'
+noinst_LIBRARIES = liblib.a
+liblib_a_SOURCES = src/x.c
+
+dist-hook:
+ test ! -f $(distdir)/LDADD.c
+ test -f $(top_distdir)/LDADD.c
+ test -f $(distdir)/src/x.c
+ test ! -f $(top_distdir)/src/x.c
+
+ACLOCAL_AMFLAGS = -I ../m4
+EOF
+
+cat >lib/src/x.c <<'EOF'
+#include <config.h>
+int lib (void)
+{
+ return 0;
+}
+EOF
+
+$ACLOCAL -I m4
+$AUTOCONF
+$AUTOMAKE -Wno-override
+
+cd lib
+$ACLOCAL -I ../m4
+$FGREP 'm4_include([../m4/foo.m4])' aclocal.m4
+$AUTOCONF
+$AUTOHEADER
+$AUTOMAKE -Wno-override --add-missing
+cd ..
+
+./configure
+$MAKE
+$MAKE distcheck
+test ! -d subpack-1 # Make sure distcheck cleans up after itself.
+test -f subpack-1.tar.gz
+
+:
diff --git a/t/subpkg2.sh b/t/subpkg2.sh
new file mode 100755
index 000000000..af89fc173
--- /dev/null
+++ b/t/subpkg2.sh
@@ -0,0 +1,66 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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/>.
+
+# Try a DIST_SUBDIRS subpackage with no SUBDIRS.
+# Report from Gary V. Vaughan.
+
+. ./defs || Exit 1
+
+mkdir m4
+
+cat >m4/foo.m4 <<'EOF'
+AC_DEFUN([FOO],[
+ AC_OUTPUT
+])
+EOF
+
+cat >>configure.ac <<'END'
+AC_CONFIG_SUBDIRS([sub])
+AC_OUTPUT
+END
+
+cat >Makefile.am <<'EOF'
+DIST_SUBDIRS = sub
+dist-hook:
+ test -f $(distdir)/sub/script.in
+EOF
+
+mkdir sub
+
+cat >sub/configure.ac <<'EOF'
+AC_INIT([sub], [2.3])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([Makefile])
+AC_CONFIG_FILES([script])
+FOO
+EOF
+
+: >sub/script.in
+echo ACLOCAL_AMFLAGS = -I ../m4 > sub/Makefile.am
+
+$ACLOCAL -I m4
+$AUTOCONF
+$AUTOMAKE
+
+cd sub
+$ACLOCAL -I ../m4
+$FGREP 'm4_include([../m4/foo.m4])' aclocal.m4
+$AUTOCONF
+$AUTOMAKE -Wno-override
+cd ..
+
+./configure
+$MAKE distcheck
diff --git a/t/subpkg3.sh b/t/subpkg3.sh
new file mode 100755
index 000000000..38dc455b9
--- /dev/null
+++ b/t/subpkg3.sh
@@ -0,0 +1,55 @@
+#! /bin/sh
+# Copyright (C) 2006-2012 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 different subpackages may share files and directories.
+
+. ./defs || Exit 1
+
+cat >Makefile.am <<'END'
+SUBDIRS = subpkg
+EXTRA_DIST = subpkg/foobar
+END
+
+cat >>configure.ac <<'END'
+AC_CONFIG_SUBDIRS([subpkg])
+AC_OUTPUT
+END
+
+mkdir subpkg
+
+echo foobar >subpkg/foobar
+
+echo SUBDIRS = >subpkg/Makefile.am
+
+cat >subpkg/configure.ac <<'END'
+AC_INIT([subpkg], [1.0])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+END
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+
+cd subpkg
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+cd ..
+
+./configure
+$MAKE distcheck
diff --git a/t/subpkg4.sh b/t/subpkg4.sh
new file mode 100755
index 000000000..f8e9a2c49
--- /dev/null
+++ b/t/subpkg4.sh
@@ -0,0 +1,71 @@
+#! /bin/sh
+# Copyright (C) 2006-2012 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/>.
+
+# Test to ensure 'distdir' fixes the mode of files and directories
+# copied into '$(distdir)', even with sub-packages.
+
+. ./defs || Exit 1
+
+cat >Makefile.am <<'END'
+SUBDIRS = subpkg
+test-distdir-is-readable:
+ bad_dirs=`find $(distdir) -type d ! -perm -755 -print`; \
+ if test -n "$$bad_dirs"; then \
+ echo "directories not permissive: $$bad_dirs" >&2; \
+ exit 1; \
+ fi
+ bad_files=`find $(distdir) ! -type d ! -perm -444 -print`; \
+ if test -n "$$bad_files"; then \
+ echo "file not permissive: $$bad_files" >&2; \
+ exit 1; \
+ fi
+END
+
+cat >>configure.ac <<'END'
+AC_CONFIG_SUBDIRS([subpkg])
+AC_OUTPUT
+END
+
+mkdir subpkg subpkg/dir
+echo foobar >subpkg/foobar
+echo baz > subpkg/dir/baz
+
+chmod go-rwx subpkg/foobar subpkg/dir/baz subpkg/dir
+
+cat >subpkg/Makefile.am <<'END'
+EXTRA_DIST = foobar dir
+END
+
+cat >subpkg/configure.ac <<'END'
+AC_INIT([subpkg], [1.0])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+END
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+
+cd subpkg
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+cd ..
+
+./configure
+$MAKE distdir
+$MAKE test-distdir-is-readable
diff --git a/t/subst-no-trailing-empty-line.sh b/t/subst-no-trailing-empty-line.sh
new file mode 100755
index 000000000..2069e3a1c
--- /dev/null
+++ b/t/subst-no-trailing-empty-line.sh
@@ -0,0 +1,97 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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/>.
+
+# If the last line of a automake-rewritten definition is made only of
+# @substitutions@, automake should take care of appending an empty
+# variable to make sure that line cannot end up substituted as a blank
+# line (that would confuse HP-UX Make).
+# These checks have been introduced in commit 'Release-1-9-254-g9d0eaef'
+# into the former test 'subst2.test'.
+
+. ./defs || Exit 1
+
+# These are deliberately quite long, so that the xxx_PROGRAMS definition
+# in Makefile.am below will be split on multiple lines, with the last
+# line containing only @substituted@ stuff that expands to empty (this is
+# required to expose the bug we are testing).
+v1=ABCDEFGHIJKLMNOPQRSTUVWX
+v2=ABCDEFGHIJKLMNOPQRSTUVWXY
+v3=ABCDEFGHIJKLMNOPQRSTUVWXYZ
+
+# Literal backslash for use by grep.
+bs='\\'
+
+cat >> configure.ac <<END
+AC_SUBST([A], [''])
+AC_SUBST([$v1], [''])
+AC_SUBST([$v2], [''])
+AC_SUBST([$v3], [''])
+AC_OUTPUT
+END
+
+cat >Makefile.am <<END
+AUTOMAKE_OPTIONS = no-dependencies
+CC = false
+EXEEXT =
+
+## The "x" and "zardoz" strings and the use of '+=' are there to ensure
+## that these variables get rewritten by Automake.
+noinst_PROGRAMS = x @$v1@ @$v2@ @$v3@
+bin_PROGRAMS = @A@
+bin_PROGRAMS += @$v1@ @$v2@ @$v3@
+check_PROGRAMS = zardoz \$(noinst_PROGRAMS)
+
+## Required whenever there are @substituted@ values in the
+## PROGRAMS primary, otherwise automake will complain.
+EXTRA_PROGRAMS =
+
+print-programs:
+ @echo BEG1: \$(noinst_PROGRAMS) :END1
+ @echo BEG2: \$(bin_PROGRAMS) :END2
+ @echo BEG3: \$(check_PROGRAMS) :END3
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+# For debugging.
+$EGREP -n 'ABCD|am__empty' Makefile.in
+# Sanity check.
+test `$EGREP -c "^[ $tab]*@$v2@ @$v3@[ $tab]*$bs?$" Makefile.in` -eq 3
+
+./configure
+{
+ sed -n '/^noinst_PROGRAMS *=/,/[^\\]$/p' Makefile
+ sed -n '/^bin_PROGRAMS *=/,/[^\\]$/p' Makefile
+ sed -n '/^check_PROGRAMS *=/,/[^\\]$/p' Makefile
+ sed -n '/^am__EXEEXT.*=/,/[^\\]$/p' Makefile
+} >t-programs
+cat t-programs
+grep '^ *$' t-programs && Exit 1
+
+$MAKE print-programs >stdout || { cat stdout; Exit 1; }
+cat stdout
+grep '^BEG1: x :END1$' stdout
+grep '^BEG2: :END2$' stdout
+grep '^BEG3: zardoz x :END3$' stdout
+
+am__empty=X $MAKE -e print-programs >stdout || { cat stdout; Exit 1; }
+cat stdout
+grep '^BEG1: x X :END1$' stdout
+grep '^BEG2: X :END2$' stdout
+grep '^BEG3: zardoz x X :END3$' stdout
+
+:
diff --git a/t/subst.sh b/t/subst.sh
new file mode 100755
index 000000000..f46f2ed9a
--- /dev/null
+++ b/t/subst.sh
@@ -0,0 +1,39 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test that AC_SUBST($1) does something sensible. From Ulrich
+# Drepper.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+dnl This test used to have the following lines, which cannot have
+dnl worked sensibly with Autoconf for years, however:
+dnl AC_SUBST($1)
+dnl AC_SUBST([$]$1) dnl this is the actual invocation that was used
+dnl
+AC_DEFUN([FOO],
+[AC_SUBST([$1])])
+FOO([BAR])
+END
+
+: > Makefile.am
+
+$ACLOCAL
+$AUTOMAKE
+grep '^\$1' Makefile.in && Exit 1
+
+:
diff --git a/t/subst3.sh b/t/subst3.sh
new file mode 100755
index 000000000..cc81063e3
--- /dev/null
+++ b/t/subst3.sh
@@ -0,0 +1,177 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test installation with substitutions. This test is based on nobase.test.
+
+required=cc
+. ./defs || Exit 1
+
+cat >> configure.ac <<'EOF'
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_RANLIB
+if test -n "$doit"; then
+ AC_SUBST([basehdr], [sub/base.h])
+ AC_SUBST([nobasehdr], [sub/nobase.h])
+ AC_SUBST([basedata], [sub/base.dat])
+ AC_SUBST([nobasedata], [sub/nobase.dat])
+ AC_SUBST([basescript], [sub/base.sh])
+ AC_SUBST([nobasescript], [sub/nobase.sh])
+ AC_SUBST([baseprog], ['sub/base$(EXEEXT)'])
+ AC_SUBST([nobaseprog], ['sub/nobase$(EXEEXT)'])
+ AC_SUBST([baselib], [sub/libbase.a])
+ AC_SUBST([nobaselib], [sub/libnobase.a])
+fi
+AC_OUTPUT
+EOF
+
+cat > Makefile.am << 'EOF'
+foodir = $(prefix)/foo
+fooexecdir = $(prefix)/foo
+
+foo_HEADERS = @basehdr@
+nobase_foo_HEADERS = @nobasehdr@
+EXTRA_HEADERS = sub/base.h sub/nobase.h
+
+dist_foo_DATA = @basedata@
+nobase_dist_foo_DATA = @nobasedata@
+
+dist_fooexec_SCRIPTS = @basescript@
+nobase_dist_fooexec_SCRIPTS = @nobasescript@
+EXTRA_SCRIPTS = sub/base.sh sub/nobase.sh
+
+fooexec_PROGRAMS = @baseprog@
+nobase_fooexec_PROGRAMS = @nobaseprog@
+EXTRA_PROGRAMS = sub/base sub/nobase
+sub_base_SOURCES = source.c
+sub_nobase_SOURCES = source.c
+
+fooexec_LIBRARIES = @baselib@
+nobase_fooexec_LIBRARIES = @nobaselib@
+EXTRA_LIBRARIES = sub/libbase.a sub/libnobase.a
+sub_libbase_a_SOURCES = source.c
+sub_libnobase_a_SOURCES = source.c
+
+test-install-data: install-data
+ test -f inst/foo/sub/nobase.h
+ test ! -f inst/foo/nobase.h
+ test -f inst/foo/base.h
+ test -f inst/foo/sub/nobase.dat
+ test ! -f inst/foo/nobase.dat
+ test -f inst/foo/base.dat
+ test ! -f inst/foo/sub/pnobase.sh
+ test ! -f inst/foo/pbase.sh
+ test ! -f inst/foo/sub/pnobase$(EXEEXT)
+ test ! -f inst/foo/pbase$(EXEEXT)
+ test ! -f inst/foo/sub/libnobase.a
+ test ! -f inst/foo/libbase.a
+
+test-install-exec: install-exec
+ test -f inst/foo/sub/pnobase.sh
+ test ! -f inst/foo/pnobase.sh
+ test -f inst/foo/pbase.sh
+ test -f inst/foo/sub/pnobase$(EXEEXT)
+ test ! -f inst/foo/pnobase$(EXEEXT)
+ test -f inst/foo/pbase$(EXEEXT)
+ test -f inst/foo/sub/libnobase.a
+ test ! -f inst/foo/libnobase.a
+ test -f inst/foo/libbase.a
+
+test-install-nothing-data: install-data
+ test ! -f inst/foo/sub/nobase.h
+ test ! -f inst/foo/nobase.h
+ test ! -f inst/foo/base.h
+ test ! -f inst/foo/sub/nobase.dat
+ test ! -f inst/foo/nobase.dat
+ test ! -f inst/foo/base.dat
+ test ! -f inst/foo/sub/pnobase.sh
+ test ! -f inst/foo/pbase.sh
+ test ! -f inst/foo/sub/pnobase$(EXEEXT)
+ test ! -f inst/foo/pbase$(EXEEXT)
+ test ! -f inst/foo/sub/libnobase.a
+ test ! -f inst/foo/libbase.a
+
+test-install-nothing-exec: install-exec
+ test ! -f inst/foo/sub/pnobase.sh
+ test ! -f inst/foo/pnobase.sh
+ test ! -f inst/foo/pbase.sh
+ test ! -f inst/foo/sub/pnobase$(EXEEXT)
+ test ! -f inst/foo/pnobase$(EXEEXT)
+ test ! -f inst/foo/pbase$(EXEEXT)
+ test ! -f inst/foo/sub/libnobase.a
+ test ! -f inst/foo/libnobase.a
+ test ! -f inst/foo/libbase.a
+EOF
+
+mkdir sub
+
+: > sub/base.h
+: > sub/nobase.h
+: > sub/base.dat
+: > sub/nobase.dat
+: > sub/base.sh
+: > sub/nobase.sh
+
+cat >source.c <<'EOF'
+int
+main (int argc, char *argv[])
+{
+ return 0;
+}
+EOF
+cp source.c source2.c
+
+rm -f install-sh
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a --copy
+./configure --prefix "`pwd`/inst" --program-prefix=p doit=yes
+
+$MAKE
+$MAKE test-install-data
+$MAKE test-install-exec
+$MAKE uninstall
+$MAKE clean
+
+test `find inst/foo -type f -print | wc -l` = 0
+
+./configure --prefix "`pwd`/inst" --program-prefix=p doit=
+
+$MAKE
+$MAKE test-install-nothing-data
+$MAKE test-install-nothing-exec
+$MAKE uninstall
+
+
+# Likewise, in a VPATH build.
+
+$MAKE distclean
+mkdir build
+cd build
+../configure --prefix "`pwd`/inst" --program-prefix=p doit=yes
+$MAKE
+$MAKE test-install-data
+$MAKE test-install-exec
+$MAKE uninstall
+test `find inst/foo -type f -print | wc -l` = 0
+
+../configure --prefix "`pwd`/inst" --program-prefix=p doit=
+$MAKE
+$MAKE test-install-nothing-data
+$MAKE test-install-nothing-exec
+
+:
diff --git a/t/subst4.sh b/t/subst4.sh
new file mode 100755
index 000000000..ab3631e14
--- /dev/null
+++ b/t/subst4.sh
@@ -0,0 +1,44 @@
+#! /bin/sh
+# Copyright (C) 2008-2012 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/>.
+
+# Test AM_SUBST_NOTMAKE.
+
+. ./defs || Exit 1
+
+cat >> configure.ac <<'EOF'
+myrule="\
+foo: bar
+ echo making \$@ from bar
+ echo \$@ > \$@
+"
+AC_SUBST([myrule])
+AM_SUBST_NOTMAKE([myrule])
+AC_OUTPUT
+EOF
+
+cat > Makefile.am <<'EOF'
+@myrule@
+EOF
+: > bar
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+$MAKE foo
+test -f foo
+
+:
diff --git a/t/subst5.sh b/t/subst5.sh
new file mode 100755
index 000000000..2fef1b9d5
--- /dev/null
+++ b/t/subst5.sh
@@ -0,0 +1,40 @@
+#! /bin/sh
+# Copyright (C) 2009-2012 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 3 of the License, 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/>.
+
+# Complain about configure substitutions in EXTRA_PRIMARY variables.
+# Rationale: we need to know the literal values of, say, PROGRAMS.
+# Thus, we allow substitutions in bin_PROGRAMS, but then EXTRA_PROGRAMS
+# needs to list possible values of that substitution, literally.
+
+. ./defs || Exit 1
+
+cat >>configure.ac <<'END'
+AC_PROG_CC
+AC_SUBST([substed1])
+AC_SUBST([substed2])
+END
+
+cat > Makefile.am <<'END'
+bin_PROGRAMS = @substed1@
+EXTRA_PROGRAMS = @substed2@
+END
+
+$ACLOCAL
+AUTOMAKE_fails
+grep 'bin_PROGRAMS.*contains configure substitution' stderr && Exit 1
+grep 'EXTRA_PROGRAMS.*contains configure substitution' stderr
+
+Exit 0
diff --git a/t/substre2.sh b/t/substre2.sh
new file mode 100755
index 000000000..a205c085d
--- /dev/null
+++ b/t/substre2.sh
@@ -0,0 +1,50 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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/>.
+
+# Test for bug in variable substitution references, where
+# undefined variables break later substitutions.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_SUBST([CC], [whocares])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = no-dependencies
+
+foo = foo.a foo.b $(doesnt_exist)
+bar = bar.a bar.b
+var1 = $(foo:.a=1.c) $(doesnt_exist:.b=2.c) $(bar:.a=3.c)
+var2 = $(var1:.b=4.c)
+
+bin_PROGRAMS = foo
+foo_SOURCES = $(var2)
+
+OBJEXT = obj
+.PHONY: test
+test:
+ is $(foo_OBJECTS) == foo1.obj foo4.obj bar3.obj bar4.obj
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+./configure
+$MAKE test
+
+:
diff --git a/t/substref.sh b/t/substref.sh
new file mode 100755
index 000000000..7183a9146
--- /dev/null
+++ b/t/substref.sh
@@ -0,0 +1,54 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test for bug in variable substitution references when left hand
+# pattern is null.
+# Report from Richard Boulton.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_SUBST([CC], [whocares])
+AC_OUTPUT
+END
+
+: > hello.c
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = no-dependencies
+var1 = dlmain
+var2 = $(var1:=.)
+helldl_SOURCES = $(var2:=c)
+bin_PROGRAMS = helldl
+.PHONY: test
+test:
+ is $(helldl_SOURCES) $(helldl_OBJECTS) == dlmain.c dlmain.$(OBJEXT)
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+$MAKE test
+
+# This is unrelated to the rest of this test. But while we are
+# at it, make sure we don't use am__helldl_SOURCES_DIST here, since
+# it's not needed. DIST_SOURCES should contain $(helldl_SOURCES).
+grep am__helldl_SOURCES_DIST Makefile && Exit 1
+grep 'DIST_SOURCES.*\$(helldl_SOURCES)' Makefile
+
+:
diff --git a/t/substtarg.sh b/t/substtarg.sh
new file mode 100755
index 000000000..2e695f843
--- /dev/null
+++ b/t/substtarg.sh
@@ -0,0 +1,50 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test that substitutions in variables work.
+# From Lars J. Aas.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_CONFIG_SOURCE([fakelib.c])
+AC_PROG_CC
+AM_PROG_AR
+RANLIB=:
+AC_SUBST([RANLIB])
+SUBST=hei
+AC_SUBST([SUBST])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+noinst_LIBRARIES = libfake@SUBST@.a
+
+libfake@SUBST@_a_SOURCES = abra.c kadabra.c
+
+# Then we override the target rule:
+libfake@SUBST@.a: Makefile $(libfake@SUBST@_a_OBJECTS) $(libfake@SUBST@_a_DEPENDENCIES)
+ @echo here we do some custom stuff, instead of invoking the linker
+END
+
+: > ar-lib
+
+$ACLOCAL
+AUTOMAKE_fails
+grep 'overrid.*libfake@SUBST@.a' stderr
+$AUTOMAKE -Wno-override
+num=`grep '^libfake@SUBST@.a:' Makefile.in | wc -l`
+test $num -eq 1
diff --git a/t/suffix-chain.tap b/t/suffix-chain.tap
new file mode 100755
index 000000000..604e8a9c2
--- /dev/null
+++ b/t/suffix-chain.tap
@@ -0,0 +1,64 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Check that Automake can emit code that work round the inability of
+# some make implementations to automatically chain suffix rules.
+# See automake bug#7824 and bug#7670.
+
+required=cc
+. ./defs || Exit 1
+
+plan_ 8
+
+cat >> configure.ac <<'END'
+AC_PROG_CC
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+bin_PROGRAMS = foo
+foo_SOURCES = foo.c1
+.c1.c0:
+ (echo 'int main (void)' && echo '{' && cat $<) > $@
+.c0.c:
+ (cat $< && echo '}') > $@
+CLEANFILES = foo.c0 foo.c
+END
+
+echo 'return 0;' > foo.c1
+
+command_ok_ "aclocal" $ACLOCAL
+command_ok_ "automake" $AUTOMAKE
+command_ok_ "autoconf" $AUTOCONF
+command_ok_ "configure" ./configure
+
+directive=''; make_can_chain_suffix_rules || directive=TODO
+
+for target in all distcheck; do
+ command_ok_ "make $target" \
+ -D "$directive" -r "suffix rules not chained" \
+ $MAKE $target
+done
+
+command_ok_ "clean" $MAKE clean
+# Sanity check.
+cat >> Makefile <<'END'
+foo.c: foo.c0
+foo.c0: foo.c1
+END
+command_ok_ "make with explicit dependencies" $MAKE
+
+:
diff --git a/t/suffix.sh b/t/suffix.sh
new file mode 100755
index 000000000..f9944cb6c
--- /dev/null
+++ b/t/suffix.sh
@@ -0,0 +1,57 @@
+#! /bin/sh
+# Copyright (C) 1999-2012 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 proper suffix rules for C compilation are produced, and
+# only once.
+# See also related test 'suffix2.test'.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_PROG_RANLIB
+END
+
+cat > Makefile.am << 'END'
+noinst_PROGRAMS = foo
+noinst_LIBRARIES = libbar.a
+END
+
+for use_arlib in false :; do
+
+ if $use_arlib; then
+ am_warns=
+ echo AM_PROG_AR >> configure.ac
+ : > ar-lib
+ else
+ am_warns=-Wno-extra-portability
+ fi
+
+ $ACLOCAL --force
+
+ $AUTOMAKE $am_warns -i
+ grep '^ *\.c' Makefile.in # For debugging.
+ test `grep -c '^\.c\.o:' Makefile.in` -eq 1
+ test `grep -c '^\.c\.obj:' Makefile.in` -eq 1
+
+ $AUTOMAKE $am_warns
+ grep '^ *\.c' Makefile.in # For debugging.
+ test `grep -c '^\.c\.o:' Makefile.in` -eq 1
+ test `grep -c '^\.c\.obj:' Makefile.in` -eq 1
+
+done
+
+:
diff --git a/t/suffix10.tap b/t/suffix10.tap
new file mode 100755
index 000000000..72d0accb8
--- /dev/null
+++ b/t/suffix10.tap
@@ -0,0 +1,71 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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 that derivations work with .lo too.
+# (related to PR/37)
+
+required='cc libtoolize yacc'
+. ./defs || Exit 1
+
+plan_ 7
+
+cat >>configure.ac <<EOF
+AC_PROG_CC
+AC_PROG_YACC
+AM_PROG_AR
+AC_PROG_LIBTOOL
+AC_OUTPUT
+EOF
+
+cat >Makefile.am << 'END'
+lib_LTLIBRARIES = libfoo.la
+libfoo_la_SOURCES = foo.x_
+.x_.y:
+ rm -f $@ $@-t
+## The leading ':;' works around a bug in bash <= 3.2.
+ :; { echo '/* autogenerated */' \
+ && echo '%{' \
+ && echo 'int yylex () {return 0;}' \
+ && echo 'void yyerror (char *s) {}' \
+ && echo '%}' \
+ && echo '%%' \
+ && echo "foobar : 'f' 'o' 'o' 'b' 'a' 'r' {};" \
+ && echo '%%' \
+## Account for VPATH issues on weaker make implementations.
+ && cat `test -f '$<' || echo $(srcdir)/`$<; \
+ } > $@-t
+ mv -f $@-t $@
+.PHONY: test
+test:
+ echo $(libfoo_la_OBJECTS) | grep '^foo\.lo$$'
+END
+
+cat > foo.x_ << 'END'
+int foo (void) { return yyparse(); }
+END
+
+command_ok_ "libtoolize" libtoolize --force
+command_ok_ "aclocal" $ACLOCAL
+command_ok_ "autoconf" $AUTOCONF
+command_ok_ "automake" $AUTOMAKE --add-missing
+command_ok_ "configure" ./configure
+command_ok_ "make test" $MAKE test
+
+directive=''; make_can_chain_suffix_rules || directive=TODO
+command_ok_ "make all" -D "$directive" -r "suffix rules not chained" \
+ $MAKE all
+
+:
diff --git a/t/suffix11.tap b/t/suffix11.tap
new file mode 100755
index 000000000..d365fbcc7
--- /dev/null
+++ b/t/suffix11.tap
@@ -0,0 +1,82 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Tests that Automake understands multiple suffix rules on the same line.
+# PR/371 and PR/372: Reported by Duncan Gibson.
+# We also check for suffixes containing '-'.
+
+required=cc
+. ./defs || Exit 1
+
+plan_ 10
+
+cat >>configure.ac <<EOF
+AC_PROG_CC
+AC_OUTPUT
+EOF
+
+cat >Makefile.am << 'END'
+bin_PROGRAMS = foo bar baz
+foo_SOURCES = foo.x_
+bar_SOURCES = bar.y-z
+baz_SOURCES = baz1.x_ baz2.y-z
+
+.y-z.c .x_.c:
+## Account for VPATH issues on weaker make implementations (e.g. IRIX 6.5).
+ sed 's/INTEGER/int/g' `test -f '$<' || echo $(srcdir)/`$< >$@
+
+CLEANFILES = foo.c bar.c baz1.c baz2.c
+
+.PHONY: test-real test-fake
+test-fake:
+ echo $(foo_OBJECTS) | grep '^foo\.foo$$'
+ echo $(bar_OBJECTS) | grep '^bar\.foo$$'
+ echo $(baz_OBJECTS) | grep '^baz1\.foo baz2\.foo$$'
+test-real:
+ echo $(foo_OBJECTS) | grep '^foo\.$(OBJEXT)$$'
+ echo $(bar_OBJECTS) | grep '^bar\.$(OBJEXT)$$'
+ echo $(baz_OBJECTS) | grep '^baz1\.$(OBJEXT) baz2\.$(OBJEXT)$$'
+check-local: test-real
+END
+
+echo 'INTEGER main(void) { return 0; }' > foo.x_
+echo 'INTEGER main(void) { return 0; }' > bar.y-z
+echo 'INTEGER main(void) { INTEGER baz(void); return baz(); }' > baz1.x_
+echo 'INTEGER baz(void) { return 0; }' > baz2.y-z
+
+command_ok_ "aclocal" $ACLOCAL
+command_ok_ "autoconf" $AUTOCONF
+
+# What we do is not portable. Automake should warn.
+AUTOMAKE_fails -a
+command_ok_ "warn about unportable make usage" \
+ grep '[iI]nference rules can have only one target before the colon' stderr
+# But this should work anyway.
+command_ok_ "automake" $AUTOMAKE -a -Wno-portability
+
+command_ok_ "configure" ./configure
+command_ok_ "make test-fake" env OBJEXT=foo $MAKE -e test-fake
+command_ok_ "make test-real" $MAKE test-real
+
+directive=''; make_can_chain_suffix_rules || directive=TODO
+
+for target in '' distcheck; do
+ command_ok_ "make $target" \
+ -D "$directive" -r "suffix rules not chained" \
+ $MAKE $target
+done
+
+:
diff --git a/t/suffix12.sh b/t/suffix12.sh
new file mode 100755
index 000000000..5882df7d6
--- /dev/null
+++ b/t/suffix12.sh
@@ -0,0 +1,59 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Tests that Automake understands suffix rules with subdir objects.
+# Reported by John Ratliff.
+
+required=cc
+. ./defs || Exit 1
+
+cat >>configure.ac <<EOF
+AC_PROG_CC
+AC_OUTPUT
+EOF
+
+cat >Makefile.am << 'END'
+AUTOMAKE_OPTIONS = subdir-objects
+SUFFIXES = .baz .o
+# We fake here:
+.baz.o:
+## Account for VPATH issues on weaker make implementations.
+ cp `test -f '$<' || echo $(srcdir)/`$< $@
+
+bin_PROGRAMS = foo
+foo_SOURCES = foo.c sub/bar.baz
+
+.PHONY: test-fake test-real
+test-fake:
+ echo $(foo_OBJECTS) | grep '^foo\.quux sub/bar\.quux$$'
+test-real:
+ echo $(foo_OBJECTS) | grep '^foo\.$(OBJEXT) sub/bar\.$(OBJEXT)$$'
+END
+
+mkdir sub
+: > sub/bar.baz
+: > foo.c
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+OBJEXT=quux $MAKE -e test-fake
+$MAKE test-real
+
+:
diff --git a/t/suffix13.sh b/t/suffix13.sh
new file mode 100755
index 000000000..60222052a
--- /dev/null
+++ b/t/suffix13.sh
@@ -0,0 +1,72 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Tests that Automake understands suffix rules with renamed objects
+# and subdir objects.
+# Reported by Florian Briegel.
+
+required=cc
+. ./defs || Exit 1
+
+cat >>configure.ac <<EOF
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_OUTPUT
+EOF
+
+cat >Makefile.am << 'END'
+AUTOMAKE_OPTIONS = subdir-objects
+SUFFIXES = .baz .c
+.baz.c:
+ case $@ in sub/*) $(MKDIR_P) sub;; *) :;; esac
+## Account for VPATH issues on weaker make implementations (e.g. IRIX 6.5).
+ cp `test -f '$<' || echo $(srcdir)/`$< $@
+
+DISTCLEANFILES = sub/bar.c
+
+bin_PROGRAMS = foo
+foo_SOURCES = foo.c sub/bar.baz
+foo_CFLAGS =
+END
+
+mkdir sub
+cat > sub/bar.baz <<'END'
+extern int foo ();
+int main () { return foo (); }
+END
+cat > foo.c <<'END'
+int foo () { return 0; }
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+./configure
+$MAKE
+
+$MAKE distcheck
+$MAKE distclean
+
+# Should also work without subdir-objects.
+
+sed '/subdir-objects/d' < Makefile.am > t
+mv -f t Makefile.am
+$AUTOMAKE
+./configure
+$MAKE
+$MAKE distcheck
+
+:
diff --git a/t/suffix2.sh b/t/suffix2.sh
new file mode 100755
index 000000000..6dd26164d
--- /dev/null
+++ b/t/suffix2.sh
@@ -0,0 +1,54 @@
+#! /bin/sh
+# Copyright (C) 1999-2012 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 proper suffix rules for C compilation are produced,
+# and only once, even for libtool libraries.
+# See also related test 'suffix.test'.
+required=libtoolize
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_LIBTOOL
+END
+
+cat > Makefile.am << 'END'
+lib_LTLIBRARIES = libltdl.la
+libltdl_la_SOURCES = ltdl.c ltdl.h
+END
+
+# Create all the files created libtoolize so we don't run libtoolize.
+# We don't want the user to need libtool to run this test.
+: > ltconfig
+: > ltmain.sh
+: > config.guess
+: > config.sub
+
+$ACLOCAL
+
+$AUTOMAKE -a
+grep '^ *\.c' Makefile.in # For debugging.
+test `grep -c '^\.c\.o:' Makefile.in` -eq 1
+test `grep -c '^\.c\.obj:' Makefile.in` -eq 1
+
+$AUTOMAKE -i
+grep '^ *\.c' Makefile.in # For debugging.
+test `grep -c '^\.c\.o:' Makefile.in` -eq 1
+test `grep -c '^\.c\.obj:' Makefile.in` -eq 1
+
+:
diff --git a/t/suffix3.tap b/t/suffix3.tap
new file mode 100755
index 000000000..168c84264
--- /dev/null
+++ b/t/suffix3.tap
@@ -0,0 +1,82 @@
+#! /bin/sh
+# Copyright (C) 1999-2012 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/>.
+
+# Test to make sure that suffix rules chain.
+
+required=c++
+. ./defs || Exit 1
+
+plan_ 10
+
+cat >> configure.ac << 'END'
+AC_PROG_CXX
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+SUFFIXES = .zoo
+.zoo.cc:
+ sed 's/INTEGER/int/g' `test -f '$<' || echo $(srcdir)/`$< >$@
+bin_PROGRAMS = foo
+foo_SOURCES = foo.zoo
+# This is required by "make distcheck". The useless indirection is
+# reequired to avoid false positives by the grepping checks below.
+FOO = foo
+CLEANFILES = $(FOO).cc
+END
+
+command_ok_ "aclocal" $ACLOCAL
+command_ok_ "automake" $AUTOMAKE
+
+# The foo.cc intermediate step is implicit, it's a mistake if
+# Automake requires this file somewhere. Also, Automake should
+# not require the file 'foo.c' anywhere.
+command_ok_ "intermediate files not mentioned" \
+ not $FGREP foo.c Makefile.in
+# However Automake must figure that foo.zoo is eventually
+# transformed into foo.o, and use this latter file (to link foo).
+command_ok_ "final object file figured out" \
+ $FGREP 'foo.$(OBJEXT)' Makefile.in
+
+command_ok_ "autoconf" $AUTOCONF
+command_ok_ "configure" ./configure
+
+# This is deliberately valid C++, but invalid C.
+cat > foo.zoo <<'END'
+using namespace std;
+INTEGER main (void)
+{
+ return 0;
+}
+END
+
+directive=''; make_can_chain_suffix_rules || directive=TODO
+
+for target in all distcheck; do
+ command_ok_ "make $target" \
+ -D "$directive" -r "suffix rules not chained" \
+ $MAKE $target
+done
+
+# FIXME: should we check that intermediate file 'foo.cc' has
+# been removed? Or is this requiring too much from the make
+# implementation?
+
+# Intermediate files should not be distributed.
+command_ok_ "make distdir" $MAKE distdir
+command_ok_ "intermediate file not distributed" test ! -r $me-1.0/foo.cc
+
+:
diff --git a/t/suffix4.sh b/t/suffix4.sh
new file mode 100755
index 000000000..4523096a2
--- /dev/null
+++ b/t/suffix4.sh
@@ -0,0 +1,39 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test to make sure Automake doesn't abort on user-defined extensions.
+# Based on a report from Dmitry Mikhin <dmitrym@acres.com.au>.
+
+# Also make sure that .SUFFIXES is automatically adjusted with
+# extensions from implicit rules.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+.k.o:
+ echo $< > $@
+
+bin_PROGRAMS = foo
+foo_SOURCES = foo.k
+END
+
+$ACLOCAL
+$AUTOMAKE
+grep '^\.SUFFIXES:' Makefile.in | sed -e 's/$/ /' > suffixes
+cat suffixes
+$FGREP ' .k ' suffixes
+
+:
diff --git a/t/suffix5.sh b/t/suffix5.sh
new file mode 100755
index 000000000..8608a86b5
--- /dev/null
+++ b/t/suffix5.sh
@@ -0,0 +1,66 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test to make sure Automake include libtool objects resulting
+# from user-defined implicit rules.
+# Based on a report from Arkadiusz Miskiewicz <misiek@pld.ORG.PL>.
+
+required='cc libtool'
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_SUBST([LINK], [:])
+AM_PROG_AR
+AC_PROG_LIBTOOL
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+.k.lo:
+## Account for VPATH issues on weaker make implementations.
+ (echo $< && cat `test -f '$<' || echo $(srcdir)/`$<) > $@
+
+noinst_LTLIBRARIES = libfoo.la
+libfoo_la_SOURCES = foo.k
+
+.PHONY: test
+test: all
+ grep '^=GREP=ME=$$' foo.lo
+## Weaker regex to account for VPATH issues.
+ grep 'foo\.k$$' foo.lo
+check-local: test
+END
+
+: > ltmain.sh
+
+for auxscript in ar-lib config.guess config.sub; do
+ cp "$am_scriptdir/$auxscript" . \
+ || fatal_ "fetching auxiliary script '$auxscript'"
+done
+
+$ACLOCAL
+$AUTOMAKE
+grep '_OBJECTS.*foo\.lo' Makefile.in
+
+$AUTOCONF
+./configure
+
+echo '=GREP=ME=' > foo.k
+
+$MAKE test
+$MAKE distcheck
+
+:
diff --git a/t/suffix6.sh b/t/suffix6.sh
new file mode 100755
index 000000000..29ffc4d40
--- /dev/null
+++ b/t/suffix6.sh
@@ -0,0 +1,63 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test to make sure Automake supports implicit rules with dot-less
+# extensions. Also make sure that '.o' and '.obj' are handled like
+# '.$(OBJEXT)'. See also related "semantic" tests suffix6b.test
+# and suffix6c.test.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+SUFFIXES = a b .$(OBJEXT) c .o .obj
+bin_PROGRAMS = foo
+foo_SOURCES = fooa barc bazc
+ab:
+ dummy action 1
+b.$(OBJEXT):
+ dummy action 2
+c.o:
+ dummy action C
+c.obj:
+ dummy action C
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+sed -n -e '/foo_OBJECTS *=.*\\$/ {
+ :loop
+ p
+ n
+ t clear
+ :clear
+ s/\\$/\\/
+ t loop
+ p
+ n
+}' -e 's/$/ /' -e 's/^.*foo_OBJECTS *= */ /p' Makefile.in > foo-objects
+cat foo-objects
+
+# Automake must figure that fooa translates to foo.$(OBJEXT) and
+# foo.$(OBJEXT) using the following rules:
+# fooa --[ab]--> foob --[b.$(OBJEXT)]--> foo.$(OBJEXT)
+$FGREP ' foo.$(OBJEXT) ' foo-objects
+# barc --[c.o]--> bar.$(OBJEXT) ## This is really meant!
+$FGREP ' bar.$(OBJEXT) ' foo-objects
+# bazc --[c.obj]--> baz.$(OBJEXT) ## This is really meant!
+$FGREP ' baz.$(OBJEXT) ' foo-objects
+
+:
diff --git a/t/suffix6b.sh b/t/suffix6b.sh
new file mode 100755
index 000000000..319e02179
--- /dev/null
+++ b/t/suffix6b.sh
@@ -0,0 +1,75 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test to make sure Automake supports implicit rules with dot-less
+# extensions. Se also related "grepping" test suffix6.test.
+
+required=GNUmake # Other makes might not grok dot-less suffix rules.
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+# $(LINK) is not defined automatically by Automake, since the *_SOURCES
+# variables don't contain any known extension (.c, .cc, .f, ...).
+# So we need this hack -- but since such an hack can also serve as a
+# mild stress test, that's ok.
+AC_SUBST([LINK], ['cat >$@'])
+AC_SUBST([OBJEXT], [oOo])
+AC_SUBST([EXEEXT], [.XxX])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+SUFFIXES = a b c .$(OBJEXT)
+bin_PROGRAMS = foo
+foo_SOURCES = fooa
+ab:
+ { echo '=ab=' && cat $<; } >$@
+bc:
+ { echo '=bc=' && cat $<; } >$@
+c.$(OBJEXT):
+ { echo '=b.obj=' && cat $<; } >$@
+test:
+ : For debugging.
+ ls -l
+ : Implicit intermediate files should be removed by GNU make ...
+ test ! -r foob
+ test ! -r fooc
+ : ... but object files should not.
+ cat foo.$(OBJEXT)
+ : For debugging.
+ cat foo.XxX
+ : Now check that the chain of implicit rules has been executed
+ : completely and in the correct order.
+ (echo =b.obj= && echo =bc= && echo =ab= && echo =src=) > exp
+ diff exp foo.XxX
+ rm -f exp
+.PHONY: test
+check-local: test
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+
+echo =src= > fooa
+
+$MAKE
+$MAKE test
+$MAKE distcheck
+
+:
diff --git a/t/suffix6c.sh b/t/suffix6c.sh
new file mode 100755
index 000000000..80f3bf019
--- /dev/null
+++ b/t/suffix6c.sh
@@ -0,0 +1,92 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test to make sure that '.o' and '.obj' are handled like '.$(OBJEXT)'.
+# See also related "grepping" test suffix6.test.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+# $(LINK) is not defined automatically by Automake, since the *_SOURCES
+# variables don't contain any known extension (.c, .cc, .f ...),
+# So we need this hack -- but since such an hack can also serve as a
+# mild stress test, that's ok.
+OBJEXT=${OBJEXT-oOo}
+AC_SUBST([LINK], ['cat >$@'])
+AC_SUBST([EXEEXT], [.XxX])
+AC_SUBST([OBJEXT])
+AC_OUTPUT
+END
+
+unset OBJEXT || :
+
+cat > Makefile.am << 'END'
+SUFFIXES = .zoo .o .obj .@OBJEXT@
+
+bin_PROGRAMS = foo
+foo_SOURCES = foo.zoo
+
+.zoo.o:
+ { echo '=.zoo.o=' && cat $<; } >$@
+.zoo.obj:
+ { echo '=.zoo.obj=' && cat $<; } >$@
+.zoo.@OBJEXT@:
+ { echo '=.zoo.@OBJEXT@=' && cat $<; } >$@
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+
+cat > foo.exp <<'END'
+=.zoo.oOo=
+%ONE%
+END
+echo %ONE% > foo.zoo
+$MAKE
+cat foo.oOo
+cat foo.XxX
+diff foo.XxX foo.exp
+
+rm -f foo.* exp
+
+cat > foo.exp <<'END'
+=.zoo.o=
+%TWO%
+END
+echo %TWO% > foo.zoo
+OBJEXT=o $MAKE -e
+cat foo.o
+cat foo.XxX
+diff foo.XxX foo.exp
+
+rm -f foo.* exp
+
+cat > foo.exp <<'END'
+=.zoo.obj=
+%THREE%
+END
+echo %THREE% > foo.zoo
+OBJEXT=obj $MAKE -e
+cat foo.obj
+cat foo.XxX
+diff foo.XxX foo.exp
+
+rm -f foo.* exp
+
+:
diff --git a/t/suffix7.sh b/t/suffix7.sh
new file mode 100755
index 000000000..bef1031d2
--- /dev/null
+++ b/t/suffix7.sh
@@ -0,0 +1,37 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test to make sure Automake supports implicit rules "confusing"
+# extensions. Inspired by a mail from Alex Hornby.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+SUFFIXES = .idl S.cpp C.h
+SUFFIXES += C.cpp S.h
+.idlC.cpp:
+ cp $< $@
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+# Make sure Automake has NOT recognized .cpp and .idlC as two new
+# extensions.
+grep 'SUFFIXES.* \.cpp' Makefile.in && Exit 1
+grep 'SUFFIXES.* \.idlC' Makefile.in && Exit 1
+
+:
diff --git a/t/suffix8.tap b/t/suffix8.tap
new file mode 100755
index 000000000..288dd99df
--- /dev/null
+++ b/t/suffix8.tap
@@ -0,0 +1,94 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Test to make sure Automake supports multiple derivations for the
+# same suffix.
+# From PR/37.
+
+required='cc libtoolize'
+. ./defs || Exit 1
+
+plan_ 10
+
+cat >>configure.ac <<'END'
+AM_PROG_AR
+AM_PROG_LIBTOOL
+AC_OUTPUT
+END
+
+cat >Makefile.am << 'END'
+# $(LINK) is not defined automatically by Automake, since the *_SOURCES
+# variables don't contain any known extension (.c, .cc, .f ...),
+# So we need this hack.
+LINK = :
+
+bin_PROGRAMS = foo
+lib_LTLIBRARIES = libfoo.la
+
+foo_SOURCES = foo.x_
+libfoo_la_SOURCES = bar.x_
+
+# The elaborate cp commands below account for VPATH issues on
+# weaker make implementations (e.g. IRIX 6.5).
+.x_.y_:
+ cp `test -f '$<' || echo $(srcdir)/`$< $@
+.y_.o:
+ cp `test -f '$<' || echo $(srcdir)/`$< $@
+.y_.obj:
+ cp `test -f '$<' || echo $(srcdir)/`$< $@
+.y_.z_:
+ cp `test -f '$<' || echo $(srcdir)/`$< $@
+.z_.lo:
+ cp `test -f '$<' || echo $(srcdir)/`$< $@
+
+# Some make implementations don't remove intermediate files
+# automatically, thus causing "make distcheck" to fail if
+# this is not added.
+MOSTLYCLEANFILES = *.y_ *.z_
+
+.PHONY: test0 test1 test2
+test0:
+ echo $(foo_OBJECTS) | grep '^foo\.foo$$'
+ echo $(libfoo_la_OBJECTS) | grep '^bar\.lo$$'
+test1:
+ echo $(foo_OBJECTS) | grep '^foo\.$(OBJEXT)$$'
+ echo $(libfoo_la_OBJECTS) | grep '^bar\.lo$$'
+test2: $(foo_OBJECTS) $(libfoo_la_OBJECTS)
+ test -f foo.$(OBJEXT)
+ test -f bar.lo
+check-local: test1 test2
+END
+
+echo 'int main (void) { return 0; }' > foo.x_
+echo 'int bar (void) { return 0; }' > bar.x_
+
+command_ok_ "libtoolize" libtoolize
+command_ok_ "aclocal" $ACLOCAL
+command_ok_ "autoconf" $AUTOCONF
+command_ok_ "automake" $AUTOMAKE -a
+command_ok_ "configure" ./configure
+command_ok_ "make test0" env OBJEXT=foo $MAKE -e test0
+command_ok_ "make test1" $MAKE test1
+
+directive=''; make_can_chain_suffix_rules || directive=TODO
+
+for target in test2 all distcheck; do
+ command_ok_ "make $target" \
+ -D "$directive" -r "suffix rules not chained" \
+ $MAKE $target
+done
+
+:
diff --git a/t/suffix9.sh b/t/suffix9.sh
new file mode 100755
index 000000000..2c1d73dde
--- /dev/null
+++ b/t/suffix9.sh
@@ -0,0 +1,64 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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 that Automake choose the shorter route between suffixes
+# (related to PR/37)
+
+. ./defs || Exit 1
+
+cat >>configure.ac << 'END'
+AC_PROG_CC
+END
+
+$ACLOCAL
+
+# x_ -> y -> c -> o
+# \________/
+#
+# Automake should follow the bottom route: x_ -> c -> o because
+# it is shorter.
+#
+# It should not take the "-> y ->" route. We use 'y' here so that
+# then Automake will complains that YACC is not defined and the test will
+# fail when this happens.
+
+cat >Makefile.am << 'END'
+bin_PROGRAMS = foo
+foo_SOURCES = foo.x_
+
+.x_.y:
+ cp $< $@
+.x_.c:
+ cp $< $@
+END
+
+$AUTOMAKE -a
+
+# Idem with the rules the another order.
+
+cat >Makefile.am << 'END'
+bin_PROGRAMS = foo
+foo_SOURCES = foo.x_
+
+.x_.c:
+ cp $< $@
+.x_.y:
+ cp $< $@
+END
+
+$AUTOMAKE -a
+
+:
diff --git a/t/symlink.sh b/t/symlink.sh
new file mode 100755
index 000000000..f4b4338d8
--- /dev/null
+++ b/t/symlink.sh
@@ -0,0 +1,40 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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 we get an error if symlink creation fails.
+# Reported by Joerg-Martin Schwarz.
+
+am_create_testdir=empty
+. ./defs || Exit 1
+
+: > Makefile.am
+
+cat > configure.ac << 'END'
+AC_INIT([symlink], [1.0])
+AC_CONFIG_AUX_DIR([subdir])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([Makefile])
+END
+
+$ACLOCAL
+AUTOMAKE_fails --add-missing
+
+grep '^configure\.ac:3: .*missing.*error while making link' stderr
+grep '^configure\.ac:3: .*install-sh.*error while making link' stderr
+
+test `$FGREP -c 'error while making link' stderr` -eq 2
+
+:
diff --git a/t/symlink2.sh b/t/symlink2.sh
new file mode 100755
index 000000000..46e26db9c
--- /dev/null
+++ b/t/symlink2.sh
@@ -0,0 +1,32 @@
+#! /bin/sh
+# Copyright (C) 2000-2012 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/>.
+
+# Test to make sure that 'automake -a' redirects dangling symlinks.
+
+. ./defs || Exit 1
+
+rm -f install-sh
+ln -s Zardoz install-sh || skip_ "cannot create broken symlinks"
+
+: > Makefile.am
+
+$ACLOCAL
+$AUTOMAKE --add-missing
+
+test -f install-sh
+test ! -r Zardoz
+
+:
diff --git a/t/syntax.sh b/t/syntax.sh
new file mode 100755
index 000000000..5b51a7a60
--- /dev/null
+++ b/t/syntax.sh
@@ -0,0 +1,31 @@
+#! /bin/sh
+# Copyright (C) 1998-2012 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/>.
+
+# Test for error for bad syntax.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+foo = q \
+
+bin_SCRIPTS = foo.sh
+END
+
+$ACLOCAL
+AUTOMAKE_fails -Wnone
+grep '^Makefile\.am:2:.*blank line following trailing backslash' stderr
+
+:
diff --git a/t/tags.sh b/t/tags.sh
new file mode 100755
index 000000000..b1b95a2ae
--- /dev/null
+++ b/t/tags.sh
@@ -0,0 +1,29 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test for bug reported by Harlan Stenn: the tags target doesn't work
+# when there are only headers in a directory.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+noinst_HEADERS = iguana.h
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+grep '^ID:' Makefile.in
diff --git a/t/tags2.sh b/t/tags2.sh
new file mode 100755
index 000000000..7d4ee6440
--- /dev/null
+++ b/t/tags2.sh
@@ -0,0 +1,42 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# TAGS_DEPENDENCIES only make sense if other tag-worthy things (such as
+# sources) exist.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_OUTPUT
+END
+
+cat >Makefile.am << 'END'
+TAGS_DEPENDENCIES = foo
+END
+
+$ACLOCAL
+AUTOMAKE_fails
+grep 'define.*TAGS_DEPENDENCIES.*without' stderr
+
+cat >>Makefile.am << 'END'
+bin_PROGRAMS = bar
+END
+
+AUTOMAKE_run
+grep 'define.*TAGS_DEPENDENCIES.*without' stderr && Exit 1
+
+:
diff --git a/t/tagsub.sh b/t/tagsub.sh
new file mode 100755
index 000000000..5915d46c0
--- /dev/null
+++ b/t/tagsub.sh
@@ -0,0 +1,46 @@
+#! /bin/sh
+# Copyright (C) 1997-2012 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/>.
+
+# Test to make sure tags and subdirs work correctly. Bug report by
+# François Pinard, and later by Akim Demaille.
+
+required=etags
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_CONFIG_FILES([sub/Makefile])
+AC_OUTPUT
+END
+
+echo 'SUBDIRS = sub' > Makefile.am
+mkdir sub
+echo 'noinst_HEADERS = iguana.h' > sub/Makefile.am
+: > sub/iguana.h
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+$MAKE tags
+test -f sub/TAGS
+test -f TAGS
+$FGREP sub/TAGS TAGS
+$FGREP iguana.h sub/TAGS
+
+$MAKE distclean
+test ! -f sub/TAGS
+test ! -f TAGS
diff --git a/t/tap-ambiguous-directive.sh b/t/tap-ambiguous-directive.sh
new file mode 100755
index 000000000..32b1b803e
--- /dev/null
+++ b/t/tap-ambiguous-directive.sh
@@ -0,0 +1,56 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - handling of "ambiguous" TODO and SKIP directives
+# See also related test 'tap-todo-skip-together.test'.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > all.test <<END
+1..6
+ok 1 # foo SKIP
+not ok 2 # bar TODO
+ok 3 # :SKIP
+not ok 4 # :TODO
+ok 5 # SKIP SKIP
+not ok 6 # TODO TODO
+END
+
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=6 pass=2 fail=2 xpass=0 xfail=1 skip=1 error=0
+
+cat > exp << 'END'
+PASS: all.test 1 # foo SKIP
+FAIL: all.test 2 # bar TODO
+PASS: all.test 3 # :SKIP
+FAIL: all.test 4 # :TODO
+SKIP: all.test 5 # SKIP SKIP
+XFAIL: all.test 6 # TODO TODO
+END
+
+$FGREP ': all.test' stdout > got
+
+cat exp
+cat got
+diff exp got
+
+:
diff --git a/t/tap-autonumber.sh b/t/tap-autonumber.sh
new file mode 100755
index 000000000..4e88f3de0
--- /dev/null
+++ b/t/tap-autonumber.sh
@@ -0,0 +1,75 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - unnumbered tests are OK, as long as their final total number
+# agrees with the plan
+# - test results without number get automatically numbered in the
+# console progress output
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > all.test <<'END'
+1..14
+ok
+ok foo
+ok - foo2
+not ok
+not ok bar
+not ok - bar2
+; See that we can intermingle different kind of results without
+; messing up the autonumbering
+ok
+ok # TODO
+not ok # TODO who cares?
+ok
+not ok
+ok muuu # SKIP
+not ok
+ok
+END
+
+TESTS=all.test $MAKE -e check >stdout && { cat stdout; Exit 1; }
+cat stdout
+count_test_results total=14 pass=6 fail=5 xpass=1 xfail=1 skip=1 error=0
+
+cat > exp <<'END'
+PASS: all.test 1
+PASS: all.test 2 foo
+PASS: all.test 3 - foo2
+FAIL: all.test 4
+FAIL: all.test 5 bar
+FAIL: all.test 6 - bar2
+PASS: all.test 7
+XPASS: all.test 8 # TODO
+XFAIL: all.test 9 # TODO who cares?
+PASS: all.test 10
+FAIL: all.test 11
+SKIP: all.test 12 muuu # SKIP
+FAIL: all.test 13
+PASS: all.test 14
+END
+
+$FGREP ': all.test' stdout > got
+
+cat exp
+cat got
+diff exp got
+
+:
diff --git a/t/tap-bad-prog.tap b/t/tap-bad-prog.tap
new file mode 100755
index 000000000..580e7d31c
--- /dev/null
+++ b/t/tap-bad-prog.tap
@@ -0,0 +1,113 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - missing, unreadable, or not-executable test scripts cause proper
+# error reports
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+fetch_tap_driver
+
+plan_ 6
+
+cat >> configure.ac <<END
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TEST_LOG_DRIVER = $(srcdir)/tap-driver
+TESTS = none.test noread.test noexec.test
+none.test:
+END
+
+cat > noexec.test <<'END'
+#!/bin/sh
+echo 1..1
+echo ok 1
+END
+
+cp noexec.test noread.test
+chmod a-r noread.test
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+
+if $MAKE check >stdout; then
+ r='not ok'
+else
+ r='ok'
+fi
+cat stdout
+result_ "$r" '"make check" returns non-zero exit status'
+
+# FIXME: maybe grep for stricter error messages in the next checks?
+
+command_ok_ "non-existent test is reported" \
+ grep '^ERROR: none\.test' stdout
+
+desc="non-executable test is reported"
+# Redirect output to avoid confusing automake's testsuite own TAP driver.
+if ./noexec.test >/dev/null; then
+ skip_ -r "any file is executable" "$desc"
+else
+ command_ok_ "$desc" -- grep '^ERROR: noexec\.test' stdout
+fi
+
+desc="non-readable test is reported"
+if test -r noread.test; then
+ skip_ -r "any file is readable" "$desc"
+else
+ command_ok_ "$desc" -- grep '^ERROR: noread\.test' stdout
+fi
+
+# Check that no spurious test result is reported. This is lower-priority
+# (and in fact the check currently fails for our awk-based driver).
+directive=
+if test $am_tap_implementation = shell; then
+ directive=TODO
+else
+ # Older versions of IPC::Open3 (e.g., version 1.05 on perl 5.12.4 or
+ # version 1.0103 on perl 5.6.2) fail to properly trap errors in exec(2)
+ # calls in the child process; hence, the TAP driver cannot be properly
+ # informed of such error.
+ if $PERL -w -e '
+ use IPC::Open3 qw/open3/;
+ $@ = "";
+ eval { open3(*STDIN, *STDOUT, *STDERR, "am--no-such-command") };
+ $@ =~ m/\bopen3:.*am--no-such-command/
+ or die "Bad \$@ value: \"$@\"\n";
+ '; then
+ : # OK. IPC::Open3 should be good enough.
+ else
+ for s in '"missing plan" message' 'results'; do
+ skip_ -r "IPC::Open3 not good enough" "no spurious $s"
+ done
+ Exit 0
+ fi
+fi
+
+command_ok_ 'no spurious "missing plan" message' \
+ -D "$directive" -- not grep 'missing.* plan' stdout
+command_ok_ 'no spurious results' \
+ -D "$directive" -r 'still get "missing plan"' \
+ count_test_results total=3 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=3
+
+:
diff --git a/t/tap-bailout-and-logging.sh b/t/tap-bailout-and-logging.sh
new file mode 100755
index 000000000..cc95d9881
--- /dev/null
+++ b/t/tap-bailout-and-logging.sh
@@ -0,0 +1,49 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - even after a "Bail out!" directive, all input is still copied in
+# the log file
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > all.test <<END
+First line
+Bail out!
+non-TAP line after bailout
+# TAP diagnostic after bailout
+1..0 # SKIP TAP plan after bailout
+ok 1 - TAP result after bailout
+END
+
+$MAKE check && { cat all.log; Exit 1; }
+cat all.log
+
+for rx in \
+ 'First line' \
+ 'Bail out!' \
+ 'non-TAP line after bailout' \
+ '# TAP diagnostic after bailout' \
+ '1\.\.0 # SKIP TAP plan after bailout' \
+ 'ok 1 - TAP result after bailout' \
+; do
+ grep "^$rx$" all.log
+done
+
+:
diff --git a/t/tap-bailout-leading-space.sh b/t/tap-bailout-leading-space.sh
new file mode 100755
index 000000000..94084d460
--- /dev/null
+++ b/t/tap-bailout-leading-space.sh
@@ -0,0 +1,72 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Older versions of prove and TAP::Harness (e.g., 3.17) didn't recognize
+# a "Bail out!" directive that was preceded by whitespace, but more modern
+# versions (e.g., 3.23) do. So we leave this behaviour undefined for the
+# perl implementation of the Automake TAP driver, but expect the latter,
+# "more modern" behaviour in our awk TAP driver.
+
+am_parallel_tests=yes
+am_tap_implementation=shell
+. ./defs || Exit 1
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > a.test <<END
+1..1
+ok 1
+ Bail out!
+END
+
+cat > b.test <<END
+1..1
+ok 1 # SKIP
+${tab}Bail out!
+END
+
+cat > c.test <<END
+1..1
+ ${tab} ${tab}${tab}Bail out! FUBAR! $tab
+END
+
+cat >> exp <<END
+PASS: a.test 1
+ERROR: a.test - Bail out!
+SKIP: b.test 1
+ERROR: b.test - Bail out!
+ERROR: c.test - Bail out! FUBAR!
+END
+
+TESTS='a.test b.test c.test' $MAKE -e check >stdout \
+ && { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=5 pass=1 fail=0 xpass=0 xfail=0 skip=1 error=3
+
+LC_ALL=C sort exp > t
+mv -f t exp
+
+# We need the sort below to account for parallel make usage.
+grep ': [abcde]\.test' stdout \
+ | sed "s/[ $tab]*#[ $tab]*SKIP.*//" \
+ | LC_ALL=C sort > got
+
+cat exp
+cat got
+diff exp got
+
+:
diff --git a/t/tap-bailout-suppress-badexit.sh b/t/tap-bailout-suppress-badexit.sh
new file mode 100755
index 000000000..196263992
--- /dev/null
+++ b/t/tap-bailout-suppress-badexit.sh
@@ -0,0 +1,65 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Basic TAP test protocol support:
+# - A "Bail out!" directive causes the driver to ignore the exit
+# status of the test script.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+tests='exit.test exit127.test sighup.test sigterm.test'
+
+cat > Makefile.am <<END
+TESTS = $tests
+END
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > exit.test << 'END'
+#!/bin/sh
+echo 'Bail out!'
+exit 1
+END
+
+cat > exit127.test << 'END'
+#!/bin/sh
+echo 'Bail out!'
+exit 127
+END
+
+cat > sighup.test << 'END'
+#!/bin/sh
+echo 'Bail out!'
+kill -1 $$
+END
+
+cat > sigterm.test << 'END'
+#!/bin/sh
+echo 'Bail out!'
+kill -15 $$
+END
+
+chmod a+x $tests
+
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=4 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=4
+for tst in $tests; do grep "^ERROR: $tst - Bail out!" stdout; done
+$EGREP "ERROR: .*(exit.*status|terminat.*signal)" stdout && Exit 1
+
+:
diff --git a/t/tap-bailout-suppress-later-diagnostic.sh b/t/tap-bailout-suppress-later-diagnostic.sh
new file mode 100755
index 000000000..9bc29dec5
--- /dev/null
+++ b/t/tap-bailout-suppress-later-diagnostic.sh
@@ -0,0 +1,45 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - A "Bail out!" directive causes the driver to ignore any TAP
+# diagnostic message in the rest of the following TAP stream.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+echo AM_TEST_LOG_DRIVER_FLAGS = --comments >> Makefile
+
+cat > all.test <<END
+1..1
+# sanity check
+ok 1
+Bail out!
+# not seen
+END
+
+# Doing the sums above, we have:
+
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=2 pass=1 fail=0 xpass=0 xfail=0 skip=0 error=1
+grep '# all.test: sanity check' stdout
+grep 'not seen' stdout && Exit 1
+
+:
diff --git a/t/tap-bailout-suppress-later-errors.sh b/t/tap-bailout-suppress-later-errors.sh
new file mode 100755
index 000000000..e6cc6c237
--- /dev/null
+++ b/t/tap-bailout-suppress-later-errors.sh
@@ -0,0 +1,74 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - A "Bail out!" directive causes the driver to ignore any TAP
+# result or error in the rest of the following TAP stream.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+# Various errors that can all be squashed into a single test script.
+cat > foo.test << 'END'
+1..5
+Bail out!
+# All possible test results.
+# Test out-of-order.
+ok 4
+# Extra TAP plan.
+1..2
+# Another bailout directive.
+Bail out! Not seen.
+# Stop now, with too few tests run.
+END
+
+# Tests run after a "SKIP" plan.
+cat > bar.test << 'END'
+1..0 # SKIP
+Bail out!
+ok 1
+END
+
+# Too many tests run.
+cat > baz.test << 'END'
+1..1
+ok 1
+Bail out!
+ok 2
+ok 3
+END
+
+TESTS='foo.test bar.test baz.test' $MAKE -e check >stdout \
+ && { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=5 pass=1 fail=0 xpass=0 xfail=0 skip=1 error=3
+
+grep '^ERROR: foo\.test - Bail out!$' stdout
+grep '^ERROR: bar\.test - Bail out!$' stdout
+grep '^SKIP: bar\.test' stdout
+grep '^ERROR: baz\.test - Bail out!$' stdout
+grep '^PASS: baz\.test 1$' stdout
+
+$FGREP 'Not seen' stdout && Exit 1
+
+test `$FGREP -c ': foo.test' stdout` -eq 1
+test `$FGREP -c ': bar.test' stdout` -eq 2
+test `$FGREP -c ': baz.test' stdout` -eq 2
+
+:
diff --git a/t/tap-bailout.sh b/t/tap-bailout.sh
new file mode 100755
index 000000000..0def87ef5
--- /dev/null
+++ b/t/tap-bailout.sh
@@ -0,0 +1,138 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Basic TAP test protocol support:
+# - "Bail out!" magic
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+: > exp
+
+#------------------------------------------------------------------
+
+# Bailout without explanation.
+
+cat > a.test <<END
+1..4
+ok 1
+not ok 2
+Bail out!
+not ok 3
+ok 4 # SKIP
+END
+
+cat >> exp <<END
+PASS: a.test 1
+FAIL: a.test 2
+ERROR: a.test - Bail out!
+END
+
+# pass += 1, fail +=1, error += 1
+
+#------------------------------------------------------------------
+
+# Bailout with explanation.
+
+cat > b.test <<END
+1..7
+ok 1 # SKIP
+ok 2 # TODO
+not ok 3 # TODO
+Bail out! We're out of disk space.
+ok 4
+not ok 5
+not ok 6 # TODO
+ok 7 # TODO
+END
+
+cat >> exp <<END
+SKIP: b.test 1 # SKIP
+XPASS: b.test 2 # TODO
+XFAIL: b.test 3 # TODO
+ERROR: b.test - Bail out! We're out of disk space.
+END
+
+# skip += 1, xpass += 1, xfail += 1, error += 1
+
+#------------------------------------------------------------------
+
+# Bail out before the test plan.
+
+cat > c.test <<END
+ok 1
+ok 2
+Bail out! BOOOH!
+1..2
+END
+
+cat >> exp <<END
+PASS: c.test 1
+PASS: c.test 2
+ERROR: c.test - Bail out! BOOOH!
+END
+
+# pass += 2, error += 1
+
+#------------------------------------------------------------------
+
+# Bailout on the first line.
+
+cat > d.test <<END
+Bail out! mktemp -d: Permission denied
+ok 1
+END
+
+echo 'ERROR: d.test - Bail out! mktemp -d: Permission denied' >> exp
+
+# error += 1
+
+#------------------------------------------------------------------
+
+# TAP input comprised only of a bailout directive.
+
+cat > e.test <<END
+Bail out!
+END
+
+echo "ERROR: e.test - Bail out!" >> exp
+
+# error += 1
+
+#------------------------------------------------------------------
+
+# Doing the sums above, we have:
+test_counts='total=12 pass=3 fail=1 xpass=1 xfail=1 skip=1 error=5'
+
+TESTS='a.test b.test c.test d.test e.test' $MAKE -e check >stdout \
+ && { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results $test_counts
+
+LC_ALL=C sort exp > t
+mv -f t exp
+
+# We need the sort below to account for parallel make usage.
+grep ': [abcde]\.test' stdout | LC_ALL=C sort > got
+
+cat exp
+cat got
+diff exp got
+
+:
diff --git a/t/tap-basic.sh b/t/tap-basic.sh
new file mode 100755
index 000000000..3d6d8fe23
--- /dev/null
+++ b/t/tap-basic.sh
@@ -0,0 +1,175 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Basic TAP support:
+# - LOG_COMPILER support;
+# - basic support for TODO and SKIP directives, and "Bail out!" magic;
+# - testsuite progress output on console;
+# - runtime overriding of TESTS and TEST_LOGS;
+# - correct counts of test results (both in summary and in progress
+# output on console).
+# Note that some of the features checked here are checked in other
+# test cases too, usually in a more thorough and detailed way.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+fetch_tap_driver
+
+cat >> configure.ac <<END
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TEST_LOG_DRIVER = $(srcdir)/tap-driver
+## Defining LOG_COMPILER should work and not intefere with the
+## tap-driver script.
+TEST_LOG_COMPILER = cat
+TESTS = success.test
+
+ok.test:
+ echo '1..3' > $@-t
+ echo 'ok 1' >> $@-t
+ echo 'not ok 2 # TODO' >>$@-t
+ echo 'ok 3 # SKIP' >>$@-t
+ cat $@-t ;: For debugging.
+ mv -f $@-t $@
+END
+
+cat > success.test << 'END'
+1..20
+ok 1
+ok 2 two
+ok 3 - three
+ok 4 four four
+not ok 5
+not ok 6 six
+not ok 7 - seven
+not ok 8 eight eight
+ok 9 # TODO
+ok 10 ten # TODO
+ok 11 - eleven # TODO
+ok 12 twelve twelve # TODO
+not ok 13 # TODO
+not ok 14 fourteen # TODO
+not ok 15 - fifteen # TODO
+not ok 16 sixteen sixteen # TODO
+ok 17 # SKIP
+ok 18 eighteen # SKIP
+ok 19 - nineteen # SKIP
+ok 20 twenty twenty # SKIP
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+
+# Basilar usage and testsuite progress output.
+
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=20 pass=4 fail=4 xpass=4 xfail=4 skip=4 error=0
+
+test -f success.log
+test -f test-suite.log
+
+cat > exp << 'END'
+PASS: success.test 1
+PASS: success.test 2 two
+PASS: success.test 3 - three
+PASS: success.test 4 four four
+FAIL: success.test 5
+FAIL: success.test 6 six
+FAIL: success.test 7 - seven
+FAIL: success.test 8 eight eight
+XPASS: success.test 9 # TODO
+XPASS: success.test 10 ten # TODO
+XPASS: success.test 11 - eleven # TODO
+XPASS: success.test 12 twelve twelve # TODO
+XFAIL: success.test 13 # TODO
+XFAIL: success.test 14 fourteen # TODO
+XFAIL: success.test 15 - fifteen # TODO
+XFAIL: success.test 16 sixteen sixteen # TODO
+SKIP: success.test 17 # SKIP
+SKIP: success.test 18 eighteen # SKIP
+SKIP: success.test 19 - nineteen # SKIP
+SKIP: success.test 20 twenty twenty # SKIP
+END
+
+$FGREP ': success.test' stdout > got
+
+cat exp
+cat got
+diff exp got
+
+# Override TESTS from the command line.
+
+rm -f *.log *.test
+
+cat > bail.test <<'END'
+1..1
+Bail out!
+ok 1
+END
+
+TESTS=bail.test $MAKE -e check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=1 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=1
+
+test ! -f success.log
+test -f bail.log
+test -f test-suite.log
+
+grep '^ERROR: bail\.test - Bail out!' stdout
+grep '^PASS:' stdout && Exit 1
+test `$FGREP -c ': bail.test' stdout` -eq 1
+$FGREP 'success.test' stdout && Exit 1
+
+# Override TEST_LOGS from the command line, making it point to a test
+# (ok.test) that has to be generated at make time.
+
+rm -f *.log *.test
+
+TEST_LOGS=ok.log $MAKE -e check >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=3 pass=1 fail=0 xpass=0 xfail=1 skip=1 error=0
+
+test -f ok.test
+test -f ok.log
+test ! -f success.log
+test ! -f bail.log
+test -f test-suite.log
+
+$EGREP '(bail|success)\.test' stdout && Exit 1
+
+cat > exp << 'END'
+PASS: ok.test 1
+XFAIL: ok.test 2 # TODO
+SKIP: ok.test 3 # SKIP
+END
+
+$FGREP ': ok.test' stdout > got
+
+cat exp
+cat got
+diff exp got
+
+:
diff --git a/t/tap-color.sh b/t/tap-color.sh
new file mode 100755
index 000000000..b8c4004f9
--- /dev/null
+++ b/t/tap-color.sh
@@ -0,0 +1,173 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - colorization of TAP results and diagnostic messages
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+TERM=ansi; export TERM
+
+esc=''
+# Escape '[' for grep, below.
+red="$esc\[0;31m"
+grn="$esc\[0;32m"
+lgn="$esc\[1;32m"
+blu="$esc\[1;34m"
+mgn="$esc\[0;35m"
+std="$esc\[m"
+
+# Check that grep can parse nonprinting characters.
+# BSD 'grep' works from a pipe, but not a seekable file.
+# GNU or BSD 'grep -a' works on files, but is not portable.
+case `echo "$std" | grep .` in
+ "$std") ;;
+ *) echo "$me: grep can't parse nonprinting characters" >&2; Exit 77;;
+esac
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = color-tests
+AM_TEST_LOG_DRIVER_FLAGS = --comments
+TEST_LOG_COMPILER = cat
+TESTS = all.test skip.test bail.test badplan.test noplan.test \
+ few.test many.test order.test afterlate.test
+END
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > all.test << 'END'
+1..5
+ok 1 - foo
+# Hi! I shouldn't be colorized!
+not ok 2 - bar # TODO td
+ok 3 - baz # SKIP sk
+not ok 4 - quux
+ok 5 - zardoz # TODO
+END
+
+cat > skip.test << 'END'
+1..0 # SKIP whole script
+END
+
+cat > bail.test << 'END'
+1..1
+ok 1
+Bail out!
+END
+
+cat > badplan.test << 'END'
+1..2
+ok 1
+1..2
+ok 2
+END
+
+cat > noplan.test << 'END'
+ok 1
+END
+
+cat > few.test << 'END'
+1..2
+ok 1
+END
+
+cat > many.test << 'END'
+1..1
+ok 1
+ok 2
+END
+
+cat > order.test << 'END'
+1..1
+ok 5
+END
+
+cat > afterlate.test << 'END'
+ok 1
+1..2
+ok 2
+END
+
+AM_COLOR_TESTS=always $MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+test_color ()
+{
+ # Not a useless use of cat; see above comments about grep.
+ cat stdout | grep "^${grn}PASS${std}: all\.test 1 - foo$"
+ cat stdout | grep "^${lgn}XFAIL${std}: all\.test 2 - bar # TODO td$"
+ cat stdout | grep "^${blu}SKIP${std}: all\.test 3 - baz # SKIP sk$"
+ cat stdout | grep "^${red}FAIL${std}: all\.test 4 - quux$"
+ cat stdout | grep "^${red}XPASS${std}: all\.test 5 - zardoz # TODO$"
+ cat stdout | grep "^${blu}SKIP${std}: skip\.test - whole script$"
+ cat stdout | grep "^${grn}PASS${std}: bail\.test 1$"
+ cat stdout | grep "^${mgn}ERROR${std}: bail\.test - Bail out!$"
+ cat stdout | grep "^${mgn}ERROR${std}: badplan\.test - multiple test plans$"
+ cat stdout | grep "^${mgn}ERROR${std}: noplan\.test - missing test plan$"
+ cat stdout | grep "^${mgn}ERROR${std}: few.test - too few tests run (expected 2, got 1)$"
+ cat stdout | grep "^${mgn}ERROR${std}: many.test - too many tests run (expected 1, got 2)$"
+ cat stdout | grep "^${mgn}ERROR${std}: many.test 2 # UNPLANNED$"
+ cat stdout | grep "^${mgn}ERROR${std}: order.test 5 # OUT-OF-ORDER (expecting 1)$"
+ cat stdout | grep "^${mgn}ERROR${std}: afterlate\.test 2 # AFTER LATE PLAN$"
+ # Diagnostic messages shouldn't be colorized.
+ cat stdout | grep "^# all\.test: Hi! I shouldn't be colorized!$"
+ :
+}
+
+test_no_color ()
+{
+ # With make implementations that, like Solaris make, in case of errors
+ # print the whole failing recipe on standard output, we should content
+ # ourselves with a laxer check, to avoid false positives.
+ # Keep this in sync with lib/am/check.am:$(am__color_tests).
+ if $FGREP '= Xalways || test -t 1 ' stdout; then
+ # Extra verbose make, resort to laxer checks.
+ # But we also want to check that the testsuite summary is not unduly
+ # colorized.
+ (
+ set +e # In case some grepped regex below isn't matched.
+ # Not a useless use of cat; see above comments about grep.
+ cat stdout | grep "TOTAL.*:"
+ cat stdout | grep "PASS.*:"
+ cat stdout | grep "FAIL.*:"
+ cat stdout | grep "SKIP.*:"
+ cat stdout | grep "XFAIL.*:"
+ cat stdout | grep "XPASS.*:"
+ cat stdout | grep "ERROR.*:"
+ cat stdout | grep "^#"
+ cat stdout | grep 'test.*expected'
+ cat stdout | grep 'test.*not run'
+ cat stdout | grep '===='
+ cat stdout | grep '[Ss]ee .*test-suite\.log'
+ cat stdout | grep '[Tt]estsuite summary'
+ ) | grep "$esc" && Exit 1
+ : For shells with broken 'set -e'
+ else
+ cat stdout | grep "$esc" && Exit 1
+ : For shells with broken 'set -e'
+ fi
+}
+
+AM_COLOR_TESTS=always $MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+test_color
+
+$MAKE -e check >stdout && { cat stdout; Exit 1; }
+cat stdout
+test_no_color
+
+:
diff --git a/t/tap-common-setup.sh b/t/tap-common-setup.sh
new file mode 100755
index 000000000..b14099a5f
--- /dev/null
+++ b/t/tap-common-setup.sh
@@ -0,0 +1,43 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Auxiliary test to set up common data used by many tests on TAP support.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.ac << END
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TEST_LOG_DRIVER = $(srcdir)/tap-driver
+TEST_LOG_COMPILER = cat
+TESTS = all.test
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+
+rm -rf autom4te*.cache
+
+# So that the data files we've created won't be removed at exit.
+keep_testdirs=yes
+
+:
diff --git a/t/tap-deps.sh b/t/tap-deps.sh
new file mode 100755
index 000000000..5049171d5
--- /dev/null
+++ b/t/tap-deps.sh
@@ -0,0 +1,87 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Basic TAP test protocol support:
+# - dependencies between test scripts
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+# The tests are *deliberately* listed in inversed order here.
+TESTS = c.test b.test a.test
+b.log: a.log
+c.log: b.log
+END
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > a.test << 'END'
+#!/bin/sh
+echo 1..2
+echo ok 1
+# Creative quoting below to please maintainer-check.
+sleep '3'
+echo ok 2
+: > a.run
+END
+
+cat > b.test << 'END'
+#!/bin/sh
+echo 1..2
+if test -f a.run; then
+ echo ok 1
+else
+ echo not ok 1
+fi
+# Creative quoting below to please maintainer-check.
+sleep '3'
+echo ok 2
+: > b.run
+END
+
+cat > c.test << 'END'
+#!/bin/sh
+echo 1..1
+test -f b.run || { echo 'Bail out!'; exit 1; }
+echo ok 1
+rm -f a.run b.run
+END
+
+chmod a+x *.test
+
+$MAKE check >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=5 pass=5 fail=0 xpass=0 xfail=0 skip=0 error=0
+
+cat > exp << 'END'
+PASS: a.test 1
+PASS: a.test 2
+PASS: b.test 1
+PASS: b.test 2
+PASS: c.test 1
+END
+
+grep ': [abc]\.test' stdout > got
+
+cat exp
+cat got
+diff exp got
+
+# TODO: it would be nice to also redo the checks forcing parallel make...
+
+:
diff --git a/t/tap-diagnostic-custom.sh b/t/tap-diagnostic-custom.sh
new file mode 100755
index 000000000..d3f28a577
--- /dev/null
+++ b/t/tap-diagnostic-custom.sh
@@ -0,0 +1,94 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - option '--diagnostic-string' to customize the string introducing
+# TAP diagnostics
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+fetch_tap_driver
+
+cat >> configure.ac <<END
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+my_log_driver = $(srcdir)/tap-driver
+my_log_compiler = cat
+TEST_EXTENSIONS =
+TESTS =
+END
+
+: > later.mk
+
+# Quoting our comments below is an hack required to keep
+# comments near the things they refer to.
+i=0
+for string in \
+'## A letter' \
+ a \
+'## A number' \
+ 1023 \
+'## A non-alphabetic character' \
+ @ \
+'## Some metacharacters (we need to repeat the "$" for make)' \
+ '^>;&*"|$$' \
+'## A whitespace character' \
+ " " \
+'## A tab character' \
+ "$tab" \
+'## A string with more whitespace' \
+ " ${tab}a b${tab} c" \
+'## Note the we do not have the empty string here. We prefer to' \
+'## leave its behaviour in this context undefined for the moment.'
+do
+ case $string in '##'*) continue;; esac
+ i=`expr $i + 1`
+ unindent >> Makefile.am << END
+ TEST_EXTENSIONS += .t$i
+ TESTS += foo$i.t$i
+ T${i}_LOG_COMPILER = \$(my_log_compiler)
+ T${i}_LOG_DRIVER = \$(my_log_driver)
+ AM_T${i}_LOG_DRIVER_FLAGS = \
+ --comments \
+ --diagnostic-string '$string'
+END
+ unindent > foo$i.t$i <<END
+ 1..1
+ ok 1
+ $string blah blah $i
+END
+ echo "AM_T${i}_LOG_DRIVER_FLAGS = --no-comments" >> later.mk
+done
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+
+$MAKE check >stdout || { cat stdout; Exit 1; }
+cat stdout
+count_test_results total=$i pass=$i fail=0 xpass=0 xfail=0 skip=0 error=0
+
+cat later.mk >> Makefile
+$MAKE check >stdout || { cat stdout; Exit 1; }
+cat stdout
+$FGREP 'blah blah' stdout && Exit 1
+
+:
diff --git a/t/tap-diagnostic.sh b/t/tap-diagnostic.sh
new file mode 100755
index 000000000..31f5df6e2
--- /dev/null
+++ b/t/tap-diagnostic.sh
@@ -0,0 +1,124 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - diagnostic messages (TAP lines with leading "#")
+# - flags '--comments' and '--no-comments' of the TAP test driver
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+metacharacters=\''"\$!&()[]<>#;^?*'
+
+cat > all.test <<END
+1..4
+# Hi! I'm a comment.
+# Tests begin.
+ok 1
+not ok 2 - foo # TODO
+ok 3 - bar # SKIP
+# Tests end.
+ok - zardoz
+# Shell metacharacters here: $metacharacters
+.# Leading characters before "#", not a TAP diagnostic line.
+x # Leading characters before "#", not a TAP diagnostic line.
+ # Leading whitespace before "#", not a TAP diagnostic line.
+${tab}# Leading whitespace before "#", not a TAP diagnostic line.
+ ${tab} # Leading whitespace before "#", not a TAP diagnostic line.
+END
+
+cat > exp <<END
+# all.test: Hi! I'm a comment.
+# all.test: Tests begin.
+PASS: all.test 1
+XFAIL: all.test 2 - foo # TODO
+SKIP: all.test 3 - bar # SKIP
+# all.test: Tests end.
+PASS: all.test 4 - zardoz
+# all.test: Shell metacharacters here: $metacharacters
+END
+
+$MAKE check >stdout || { cat stdout; Exit 1; }
+cat stdout
+$EGREP -i "#.*all\\.test|a comment|(Tests|Shell) " stdout && Exit 1
+count_test_results total=4 pass=2 fail=0 xpass=0 xfail=1 skip=1 error=0
+
+echo 'AM_TEST_LOG_DRIVER_FLAGS = --comments' >> Makefile
+$MAKE check >stdout || { cat stdout; Exit 1; }
+cat stdout
+$FGREP ' all.test' stdout > got
+cat exp
+cat got
+diff exp got
+count_test_results total=4 pass=2 fail=0 xpass=0 xfail=1 skip=1 error=0
+
+TEST_LOG_DRIVER_FLAGS="--no-comments" $MAKE -e check >stdout \
+ || { cat stdout; Exit 1; }
+cat stdout
+$EGREP -i "#.*all\\.test|a comment|(Tests|Shell) " stdout && Exit 1
+count_test_results total=4 pass=2 fail=0 xpass=0 xfail=1 skip=1 error=0
+
+# The "#"-prepended lines here shouldn't be parsed as test results.
+cat > all.test <<END
+1..1
+ok
+# ok
+#ok
+# not ok
+#not ok
+# Bail out!
+#Bail out!
+# SKIP
+#SKIP
+# TODO
+#TODO
+END
+
+$MAKE check >stdout || { cat stdout; Exit 1; }
+cat stdout
+count_test_results total=1 pass=1 fail=0 xpass=0 xfail=0 skip=0 error=0
+
+# Diagnostic without leading whitespace, or with extra leading whitespace,
+# is ok. Be laxer in the grepping checks, to allow for whitespace
+# normalization by the TAP driver.
+
+ws="[ $tab]"
+ws0p="${ws}*"
+ws1p="${ws}${ws0p}"
+
+cat > all.test <<END
+1..1
+ok 1
+#foo
+#bar${tab}
+# zardoz ${tab}
+# ${tab} ${tab}${tab}foo bar${tab}baz ${tab}
+END
+
+$MAKE check >stdout || { cat stdout; Exit 1; }
+cat stdout
+count_test_results total=1 pass=1 fail=0 xpass=0 xfail=0 skip=0 error=0
+
+grep "^# all.test:${ws0p}foo$" stdout
+grep "^# all.test:${ws0p}bar${ws0p}$" stdout
+grep "^# all.test:${ws1p}zardoz${ws0p}$" stdout
+grep "^# all.test:${ws1p}foo bar${tab}baz${ws0p}$" stdout
+
+test `grep -c '^# all\.test:' stdout` -eq 4
+
+:
diff --git a/t/tap-doc.sh b/t/tap-doc.sh
new file mode 100755
index 000000000..46b3b510c
--- /dev/null
+++ b/t/tap-doc.sh
@@ -0,0 +1,98 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that an example given in the documentation really works.
+# See section "Simple Tests" subsection "Script-based Testsuites".
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+fetch_tap_driver
+
+cat >> configure.ac <<END
+AC_PROG_CC
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TESTS = foo.sh zardoz.tap bar.sh mu.tap
+TEST_EXTENSIONS = .sh .tap
+TAP_LOG_DRIVER = $(srcdir)/tap-driver
+## Ensure the test scripts are run in the correct order.
+mu.log: bar.log
+bar.log: zardoz.log
+zardoz.log: foo.log
+END
+
+cat > foo.sh <<'END'
+#!/bin/sh
+exit 0
+END
+
+cat > bar.sh <<'END'
+#!/bin/sh
+exit 77
+END
+
+cat > zardoz.tap << 'END'
+#!/bin/sh
+echo 1..4
+echo 'ok 1 - Daemon started'
+echo 'ok 2 - Daemon responding'
+echo 'ok 3 - Daemon uses /proc # SKIP /proc is not mounted'
+echo 'ok 4 - Daemon stopped'
+END
+
+cat > mu.tap << 'END'
+#!/bin/sh
+echo 1..2
+echo 'ok'
+echo 'not ok # TODO frobnication not yet implemented'
+END
+
+chmod a+x *.sh *.tap
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+$MAKE check >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+cat > exp <<'END'
+PASS: foo.sh
+PASS: zardoz.tap 1 - Daemon started
+PASS: zardoz.tap 2 - Daemon responding
+SKIP: zardoz.tap 3 - Daemon uses /proc # SKIP /proc is not mounted
+PASS: zardoz.tap 4 - Daemon stopped
+SKIP: bar.sh
+PASS: mu.tap 1
+XFAIL: mu.tap 2 # TODO frobnication not yet implemented
+END
+
+sed -n '/^PASS: foo\.sh/,/^XFAIL: mu\.tap/p' stdout > t
+cat t
+# Strip extra "informative" lines that could be printed by Solaris
+# Distributed Make.
+LC_ALL=C $EGREP -v ' --> ([0-9][0-9]* job|[Jj]ob output)' t > got
+
+cat exp
+cat got
+diff exp got
+
+:
diff --git a/t/tap-doc2.sh b/t/tap-doc2.sh
new file mode 100755
index 000000000..76e1ade5f
--- /dev/null
+++ b/t/tap-doc2.sh
@@ -0,0 +1,140 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that an example given in the documentation really works.
+# See section "Using the TAP test protocol", subsection "Use TAP
+# with the Automake test harness".
+
+am_create_testdir=empty
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat > Makefile.am <<'END'
+TEST_LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) \
+ $(top_srcdir)/build-aux/tap-driver.sh
+TESTS = foo.test bar.test baz.test
+EXTRA_DIST = $(TESTS)
+END
+
+cat > configure.ac <<'END'
+AC_INIT([GNU Try Tap], [1.0], [bug-automake@gnu.org])
+AC_CONFIG_AUX_DIR([build-aux])
+AM_INIT_AUTOMAKE([foreign parallel-tests -Wall -Werror])
+AC_CONFIG_FILES([Makefile])
+AC_REQUIRE_AUX_FILE([tap-driver.sh])
+AC_PROG_AWK
+AC_OUTPUT
+END
+
+cat > foo.test <<'END'
+#!/bin/sh
+echo 1..4 # Number of tests to be executed.
+echo 'ok 1 - Swallows fly'
+echo 'not ok 2 - Caterpillars fly # TODO metamorphosis in progress'
+echo 'ok 3 - Pigs fly # SKIP not enough acid'
+echo '# I just love word plays...'
+echo 'ok 4 - Flies fly too :-)'
+END
+
+cat > bar.test <<'END'
+#!/bin/sh
+echo 1..3
+echo 'not ok 1 - Bummer, this test has failed.'
+echo 'ok 2 - This passed though.'
+echo 'Bail out! Ennui kicking in, sorry...'
+echo 'ok 3 - This will not be seen.'
+END
+
+cat > baz.test <<'END'
+#!/bin/sh
+echo 1..1
+echo ok 1
+# Exit with error, even if all the tests have been successful.
+exit 7
+END
+
+chmod a+x *.test
+
+# Strip extra "informative" lines that could be printed by Solaris
+# Distributed Make.
+mkdir build-aux
+cp "$am_scriptdir"/tap-driver.sh build-aux \
+ || framework_failure_ "fetching the perl TAP driver"
+
+(export AUTOMAKE ACLOCAL AUTOCONF && $AUTORECONF -vi) || Exit 1
+
+./configure --help # Sanity check.
+./configure || skip_ "configure failed"
+
+case $MAKE in *\ -j*) skip_ "can't work easily with concurrent make";; esac
+
+# Prevent Sun Distributed Make from trying to run in parallel.
+DMAKE_MODE=serial; export DMAKE_MODE
+
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+cat > exp <<'END'
+PASS: foo.test 1 - Swallows fly
+XFAIL: foo.test 2 - Caterpillars fly # TODO metamorphosis in progress
+SKIP: foo.test 3 - Pigs fly # SKIP not enough acid
+PASS: foo.test 4 - Flies fly too :-)
+FAIL: bar.test 1 - Bummer, this test has failed.
+PASS: bar.test 2 - This passed though.
+ERROR: bar.test - Bail out! Ennui kicking in, sorry...
+PASS: baz.test 1
+ERROR: baz.test - exited with status 7
+END
+
+sed -n '/^PASS: foo\.test/,/^ERROR: baz\.test/p' stdout > got
+
+cat exp
+cat got
+diff exp got
+
+grep '^Please report to bug-automake@gnu\.org$' stdout
+
+env \
+ TESTS='foo.test baz.test' \
+ TEST_LOG_DRIVER_FLAGS='--comments --ignore-exit' \
+ $MAKE -e check >stdout || { cat stdout; Exit 1; }
+
+cat > exp <<'END'
+PASS: foo.test 1 - Swallows fly
+XFAIL: foo.test 2 - Caterpillars fly # TODO metamorphosis in progress
+SKIP: foo.test 3 - Pigs fly # SKIP not enough acid
+# foo.test: I just love word plays...
+PASS: foo.test 4 - Flies fly too :-)
+PASS: baz.test 1
+END
+
+sed -n '/^PASS: foo\.test/,/^PASS: baz\.test/p' stdout > got
+
+cat exp
+cat got
+diff exp got
+
+# Sanity check the distribution.
+cat > bar.test <<'END'
+#!/bin/sh
+echo 1..1
+echo ok 1
+END
+echo AM_TEST_LOG_DRIVER_FLAGS = --ignore-exit >> Makefile.in
+./config.status Makefile
+$MAKE distcheck
+
+:
diff --git a/t/tap-driver-stderr.sh b/t/tap-driver-stderr.sh
new file mode 100755
index 000000000..879d051b7
--- /dev/null
+++ b/t/tap-driver-stderr.sh
@@ -0,0 +1,50 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Unit test on TAP driver:
+# - error messages from awk/shell/perl goes to the console
+
+required=non-root
+am_parallel_tests=yes
+am_create_testdir=empty
+. ./defs || Exit 1
+
+fetch_tap_driver
+
+tst=zardoz
+
+for suf in trs log; do
+
+ rm -f $tst.log $tst.trs
+ touch $tst.$suf
+ chmod a-w $tst.$suf
+
+ st=0
+ ./tap-driver --test-name $tst --log-file $tst.log --trs-file $tst.trs \
+ -- sh -c 'echo 1..1; echo ok 1; echo "Hello, World!"' \
+ >stdout 2>stderr && st=1
+ cat stdout
+ cat stderr >&2
+ cat $tst.log || :
+ cat $tst.trs || :
+ test $st -eq 0
+
+ $FGREP 'Hello, World!' stderr stdout && Exit 1
+ $FGREP $tst.$suf stderr
+
+done
+
+:
diff --git a/t/tap-empty-diagnostic.sh b/t/tap-empty-diagnostic.sh
new file mode 100755
index 000000000..1a8a99ba2
--- /dev/null
+++ b/t/tap-empty-diagnostic.sh
@@ -0,0 +1,41 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - empty diagnostic messages are discarder
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+sed 's/\$$//' > all.test <<END
+1..1$
+ok 1$
+#$
+# $
+#${tab}$
+# ${tab} $tab${tab}$
+END
+
+$MAKE check >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+grep '^PASS:.*all\.test' stdout # Sanity check.
+grep '#.*all\.test' stdout && Exit 1
+grep "all\.test[ $tab]*:[ $tab]*$" stdout && Exit 1
+
+:
diff --git a/t/tap-empty.sh b/t/tap-empty.sh
new file mode 100755
index 000000000..4d3bfda9c
--- /dev/null
+++ b/t/tap-empty.sh
@@ -0,0 +1,55 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support: the following situations should be flagged as errors:
+# - empty TAP input
+# - blank TAP input
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+# Empty TAP input.
+: > empty.test
+
+# Blank TAP input (one empty line).
+echo > blank.test
+
+# Blank TAP input (one whitespace-only line).
+cat > white.test <<END
+ ${tab}
+END
+
+# Blank TAP input (few blank and whitespace-only lines).
+cat > white2.test <<END
+
+
+ ${tab} ${tab}${tab}
+
+${tab}
+
+END
+
+for input in empty blank white white2; do
+ cp $input.test all.test
+ $MAKE check >stdout && { cat stdout; Exit 1; }
+ cat stdout
+ count_test_results total=1 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=1
+ grep '^ERROR: all\.test - missing test plan$' stdout
+done
+
+:
diff --git a/t/tap-escape-directive-2.sh b/t/tap-escape-directive-2.sh
new file mode 100755
index 000000000..595c38458
--- /dev/null
+++ b/t/tap-escape-directive-2.sh
@@ -0,0 +1,55 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - "escape" TODO and SKIP directives (by escaping the "#" character)
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > all.test <<'END'
+1..8
+
+not ok \ # TODO
+ok \ # SKIP
+
+not ok \\# TODO
+ok \\# SKIP
+
+ok \\\# TODO
+ok \\\# SKIP
+
+not ok \\\\\\\\\\# TODO
+ok \\\\\\\\\\# SKIP
+END
+
+$MAKE check >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=8 pass=2 fail=0 xpass=0 xfail=3 skip=3 error=0
+
+grep '^XFAIL: all\.test 1 .*# TODO' stdout
+grep '^SKIP: all\.test 2 .*# SKIP' stdout
+grep '^XFAIL: all\.test 3 .*# TODO' stdout
+grep '^SKIP: all\.test 4 .*# SKIP' stdout
+grep '^PASS: all\.test 5 .*# TODO' stdout
+grep '^PASS: all\.test 6 .*# SKIP' stdout
+grep '^XFAIL: all\.test 7 .*# TODO' stdout
+grep '^SKIP: all\.test 8 .*# SKIP' stdout
+
+:
diff --git a/t/tap-escape-directive.sh b/t/tap-escape-directive.sh
new file mode 100755
index 000000000..8b242510b
--- /dev/null
+++ b/t/tap-escape-directive.sh
@@ -0,0 +1,39 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - "escape" TODO and SKIP directives (by escaping the "#" character)
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > all.test <<'END'
+1..2
+ok \# TODO
+ok \# SKIP
+END
+
+$MAKE check >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=2 pass=2 fail=0 xpass=0 xfail=0 skip=0 error=0
+
+grep '^PASS: all\.test 1 .*# TODO' stdout
+grep '^PASS: all\.test 2 .*# SKIP' stdout
+
+:
diff --git a/t/tap-exit.sh b/t/tap-exit.sh
new file mode 100755
index 000000000..abc1ace0d
--- /dev/null
+++ b/t/tap-exit.sh
@@ -0,0 +1,54 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - an exit status != 0 of a test script causes an hard error
+# - the '--ignore-exit' option causes the TAP test driver to ignore
+# exit statuses of the test scripts.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+echo TESTS = > Makefile.am
+for st in 1 2 77 99; do
+ unindent > exit${st}.test <<END
+ #!/bin/sh
+ echo 1..1
+ echo ok 1
+ exit $st
+END
+ echo TESTS += exit${st}.test >> Makefile.am
+done
+
+chmod a+x *.test
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+count_test_results total=8 pass=4 fail=0 xpass=0 xfail=0 skip=0 error=4
+
+grep '^ERROR: exit1\.test - exited with status 1$' stdout
+grep '^ERROR: exit2\.test - exited with status 2$' stdout
+grep '^ERROR: exit77\.test - exited with status 77$' stdout
+grep '^ERROR: exit99\.test - exited with status 99$' stdout
+
+echo TEST_LOG_DRIVER_FLAGS = --ignore-exit >> Makefile
+$MAKE check >stdout || { cat stdout; Exit 1; }
+cat stdout
+count_test_results total=4 pass=4 fail=0 xpass=0 xfail=0 skip=0 error=0
+
+:
diff --git a/t/tap-fancy.sh b/t/tap-fancy.sh
new file mode 100755
index 000000000..6815ac54b
--- /dev/null
+++ b/t/tap-fancy.sh
@@ -0,0 +1,133 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support: some unusual forms for valid TAP input.
+# See also related test 'tap-fancy2.test'.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+#
+# From manpage Test::Harness::TAP(3):
+#
+# ``Lines written to standard output matching /^(not )?ok\b/ must be
+# interpreted as test lines. All other lines must not be considered
+# test output.''
+#
+# Unfortunately, the exact format of TODO and SKIP directives is not as
+# clearly described in that manpage; but a simple reverse-engineering of
+# the prove(1) utility shows that it is probably given by the perl regex
+# /#\s*(TODO|SKIP)\b/.
+#
+
+cat > all.test <<END
+1..21
+
+ok? a question
+not ok? a question
+
+ok+plus
+not ok+plus
+
+ok-minus
+not ok-minus
+
+ok#55
+not ok#55
+
+ok${tab} ${tab}9
+ok ${tab}${tab} 10
+
+not ok${tab} ${tab}11
+not ok ${tab}${tab} 12
+
+ok# SKIP
+ok${tab}#SKIP--who cares?
+ok?#SKIP!
+ok!#SKIP?
+
+not ok# TODO
+not ok${tab}#TODO--who cares?
+not ok?#TODO!
+not ok!#TODO?
+
+ok~#TODO
+END
+
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=21 pass=6 fail=6 xfail=4 xpass=1 skip=4 error=0
+
+#
+# "Weird" characters support.
+#
+
+# The "#" character might cause confusion w.r.t. TAP directives (TODO,
+# SKIP), so we don't attempt to use it.
+weirdchars=\''"$!&()[]<>;^?*/@%=,.:'
+
+cat > all.test <<END
+1..6
+ok $weirdchars
+not ok $weirdchars
+ok $weirdchars # TODO
+not ok $weirdchars # TODO
+ok $weirdchars # SKIP
+Bail out! $weirdchars
+END
+
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=6 pass=1 fail=1 xfail=1 xpass=1 skip=1 error=1
+$FGREP "PASS: all.test 1 $weirdchars" stdout
+$FGREP "FAIL: all.test 2 $weirdchars" stdout
+$FGREP "XPASS: all.test 3 $weirdchars" stdout
+$FGREP "XFAIL: all.test 4 $weirdchars" stdout
+$FGREP "SKIP: all.test 5 $weirdchars" stdout
+$FGREP "ERROR: all.test - Bail out! $weirdchars" stdout
+
+#
+# Trailing backslashes does not confuse the parser.
+#
+
+bs='\'
+
+cat > all.test <<END
+1..6
+ok $bs
+not ok $bs
+ok # TODO $bs
+not ok # TODO $bs
+ok # SKIP $bs
+Bail out! $bs
+END
+
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=6 pass=1 fail=1 xfail=1 xpass=1 skip=1 error=1
+grep '^PASS: all\.test 1 \\$' stdout
+grep '^FAIL: all\.test 2 \\$' stdout
+grep '^XPASS: all\.test 3 # TODO \\$' stdout
+grep '^XFAIL: all\.test 4 # TODO \\$' stdout
+grep '^SKIP: all\.test 5 # SKIP \\$' stdout
+grep '^ERROR: all\.test - Bail out! \\$' stdout
+
+:
diff --git a/t/tap-fancy2.sh b/t/tap-fancy2.sh
new file mode 100755
index 000000000..bb51d54e5
--- /dev/null
+++ b/t/tap-fancy2.sh
@@ -0,0 +1,138 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support: more unusual forms for valid TAP input.
+# See also related test 'tap-fancy.test'.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+#
+# From manpage Test::Harness::TAP(3):
+#
+# ``Lines written to standard output matching /^(not )?ok\b/ must be
+# interpreted as test lines. All other lines must not be considered
+# test output.''
+#
+# Unfortunately, the exact format of TODO and SKIP directives is not as
+# clearly described in that manpage; but a simple reverse-engineering of
+# the prove(1) utility shows that it is probably given by the perl regex
+# /#\s*(TODO|SKIP)\b/.
+#
+
+# To avoid problems with backslashes in echo arguments.
+xecho () { printf '%s\n' "$*"; }
+
+# There are 34 values for $str ...
+for str in \
+ \' \
+ '"' \
+ '`' \
+ '#' \
+ '$' \
+ '!' \
+ '\' \
+ '/' \
+ '&' \
+ '%' \
+ '(' \
+ ')' \
+ '|' \
+ '^' \
+ '~' \
+ '?' \
+ '*' \
+ '+' \
+ '-' \
+ ',' \
+ ':' \
+ ';' \
+ '=' \
+ '<' \
+ '>' \
+ '@' \
+ '[' \
+ ']' \
+ '{' \
+ '}' \
+ '\\' \
+ '...' \
+ '?[a-zA-Z0-9]*' \
+ '*.*' \
+; do
+ # ... each of them add 1 pass, 1 fail, ...
+ xecho "ok${str}"
+ xecho "not ok${str}"
+ # ... and (generally) 4 skips, 4 xfails, and 4 xpasses ...
+ for settings in \
+ 'result="ok" directive=SKIP' \
+ 'result="not ok" directive=TODO' \
+ 'result="ok" directive=TODO' \
+ ; do
+ eval "$settings"
+ xecho "${result}# ${directive}${str}"
+ # ... but 6 skips, 6 xpasses and 6 xfails are to be removed, since
+ # they might not work with $str = '#' or $str = '\' ...
+ if test x"$str" != x'#' && test x"$str" != x'\'; then
+ xecho "${result}${str}#${directive}"
+ xecho "${result}${str}# ${tab}${tab} ${directive}"
+ xecho "${result}${str}#${directive}${str}"
+ fi
+ done
+done > all.test
+
+# Sanity check against a previous use of unportable usages of backslashes
+# with the "echo" builtin.
+if grep '[^\\]\\#' all.test; then
+ framework_failure_ "writing backslashes in all.test"
+fi
+
+# ... so that we finally have:
+pass=34
+fail=34
+xfail=130 # = 4 * 34 - 6
+xpass=130 # = 4 * 34 - 6
+skip=130 # = 4 * 34 - 6
+error=0
+total=`expr $pass + $fail + $xfail + $xpass + $skip`
+
+# Even nastier! But accordingly to the specifics, it should still work.
+for result in 'ok' 'not ok'; do
+ echo "${result}{[(<#${tab}TODO>)]}" >> all.test
+done
+echo "ok{[(<#${tab}SKIP>)]}" >> all.test
+
+# We have to update some test counts.
+xfail=`expr $xfail + 1`
+xpass=`expr $xpass + 1`
+skip=`expr $skip + 1`
+total=`expr $total + 3`
+
+# And add the test plan!
+echo 1..$total >> all.test
+
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+$EGREP '^(PASS|FAIL|SKIP).*#.*TODO' stdout && Exit 1
+$EGREP '^X?(PASS|FAIL).*#.*SKIP' stdout && Exit 1
+
+count_test_results total=$total pass=$pass fail=$fail skip=$skip \
+ xpass=$xpass xfail=$xfail error=$error
+
+:
diff --git a/t/tap-global-log.sh b/t/tap-global-log.sh
new file mode 100755
index 000000000..69dc5b016
--- /dev/null
+++ b/t/tap-global-log.sh
@@ -0,0 +1,122 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - which log files get copied in the global log?
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > ok.test << 'END'
+1..5
+ok 1
+ok 2
+ok 3
+not seen in global log
+ok 4
+ok 5
+END
+
+cat > top << 'END'
+1..6
+ok 1
+ok 2
+ok 3
+END
+
+cat > bot << 'END'
+ok 5
+ok 6
+END
+
+cat top - bot > skip.test << 'END'
+ok # SKIP
+::skip::
+END
+
+cat top - bot > todo.test << 'END'
+not ok # TODO
+::todo::
+END
+
+cat top - bot > fail.test << 'END'
+not ok
+::fail::
+END
+
+cat top - bot > xpass.test << 'END'
+ok # TODO
+::xpass::
+END
+
+cat top - bot > bail.test << 'END'
+::bail::
+Bail out!
+END
+
+cat top - bot > error.test << 'END'
+::error::
+1..7
+END
+
+# Created with "dd if=/dev/urandom count=1 | base64-encode"
+cat > hodgepodge <<'END'
+1+0 records in
+1+0 records out
+512 bytes (512 B) copied, 0.000241092 s, 2.1 MB/s
+gdivnV4VhL4DOzhE3zULJuun3PwqqQqMdATVcZbIQkNgyRvNBoqqHMBQEs7QsjDbp2nK+Szz
+EcelGyvXmHrW7yImaom6Yrg95k31VCmp/pGDRnTDwDrcOPJiv9jDReEmTAQkPuqLO+mFNly+
+DDHM9fNbzGumstsQ3wq3DOXz1pCV3JXwhjeaHSboeEbmr55bX0XHLSKaecctA0rXDXEyZWZ/
+ODlawSrAXzw0H7a+xBwjnNXZ3zYiwk3x+WQrPqNjb+qXiLLTxAKzx2/KnaFhxkPlte5jPRNB
+FciDolL+H/10LsCdSzLOrGnY2zH6vL2JMZfxjnb73zWFcdWWE01LTD7wpN5O1MP3+N47lcVe
+lWbkD04cJvhwxLElYSO24B743GG5EyGYt9SeZRE6xbgwq3fVOS8KqjwGxwi4adSBTtw0CV8W
+S/6n8dck1vBvjA+qpk0zMSYSqc3+jzW9UiGTmTEIwfw80p/lGNsfjcNBJ86nFkWUnHmrsi8k
+Dv57sK70mTg239g08f5Uvdga/5UreMBSgB0hUj5sbq57r7B1fsVr0Kag468la8zKy3ZEZ0gX
+++sbaJ9WGHhnKvjooeH+4Y6HwAFsdINde++FlCmp4EuNKKEEuXbSKLaOTy3+6pJ2DYdvRCL+
+frZwxH4hcrw8qh+8IakB02viewZS/qT57v4=
+END
+
+exec 5>misc.test
+echo 'ok # SKIP' >&5
+cat hodgepodge >&5
+echo 'not ok # TODO' >&5
+echo 'ok' >&5
+exec 5>&-
+
+cat > skipall.test << 'END'
+1..0 # SKIP all
+END
+
+# We don't care about the exit status of "make check" here.
+TESTS="`echo *.test`" $MAKE -e check || :
+cat test-suite.log
+
+grep ':.*ok|not seen' test-suite.log && Exit 1
+
+for s in skip todo fail xpass bail error; do
+ $FGREP "::$s::" test-suite.log
+done
+
+grep '^1\.\.0 # SKIP all$' test-suite.log
+
+case `cat test-suite.log` in
+ *"`cat hodgepodge`"*) ;;
+ *) Exit 1;;
+esac
+
+:
diff --git a/t/tap-global-result.sh b/t/tap-global-result.sh
new file mode 100755
index 000000000..78d5c9fea
--- /dev/null
+++ b/t/tap-global-result.sh
@@ -0,0 +1,187 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - which global test result derives from different test results
+# mixed in a single script?
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > ok.test <<END
+1..3
+ok 1
+not ok 2 # TODO
+ok 3 # SKIP
+END
+
+cat > skip.test <<'END'
+1..3
+ok 1 # SKIP
+ok 2 # SKIP
+ok 3 # SKIP
+END
+
+cat > skipall.test <<'END'
+1..0 # SKIP
+foo
+# bar
+END
+
+cat > fail.test <<'END'
+1..1
+not ok 1
+END
+
+(sed '1s/.*/1..4/' ok.test && echo 'not ok 4') > fail2.test
+
+cat > xpass.test <<'END'
+1..1
+ok 1 # TODO
+END
+
+(sed '1s/.*/1..4/' ok.test && echo 'ok 4 # TODO') > xpass2.test
+
+echo 'Bail out!' > bail.test
+
+(cat ok.test && echo 'Bail out!') > bail2.test
+
+cat > bail3.test <<'END'
+1..0 # SKIP
+Bail out!
+END
+
+# Too many tests.
+cat > error.test <<'END'
+1..2
+ok 1
+ok 2 # SKIP
+not ok 3
+not ok 4 # TODO
+END
+
+# Too few tests.
+cat > error2.test <<'END'
+1..4
+ok 1
+not ok 2 # TODO
+ok 3 # SKIP
+END
+
+# Repeated plan.
+cat > error3.test <<'END'
+1..2
+1..2
+ok 1
+ok 2
+END
+
+# Too many tests, after a "SKIP" plan.
+cat > error4.test <<'END'
+1..0 # SKIP
+ok 1
+ok 2
+END
+
+# Tests out of order.
+cat > error5.test <<'END'
+1..4
+not ok 1 # TODO
+ok 3
+ok 2
+ok 4
+END
+
+# Wrong test number.
+cat > error6.test <<'END'
+1..2
+ok 1 # SKIP
+ok 7
+END
+
+# No plan.
+cat > error7.test <<'END'
+ok 1 # SKIP
+ok 2 # TODO
+not ok 3 # TODO
+ok 4
+END
+
+cat > hodgepodge.test <<'END'
+1..2
+not ok 1
+ok 2 # TODO
+Bail out!
+END
+
+cat > hodgepodge-all.test <<'END'
+1..4
+ok 1
+ok 2 # SKIP
+not ok 2 # TODO
+not ok 3
+ok 4 # TODO
+Bail out!
+END
+
+tests=`echo *.test` # Also required later.
+
+TESTS="$tests" $MAKE -e check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+# Dirty trick required here.
+for tst in `echo " $tests " | sed 's/.test / /'`; do
+ echo :copy-in-global-log: yes >> $tst.trs
+done
+
+rm -f test-suite.log
+TESTS="$tests" $MAKE -e test-suite.log && Exit 1
+cat test-suite.log
+
+have_rst_section ()
+{
+ eqeq=`echo "$1" | sed 's/./=/g'`
+ # Assume $1 contains no RE metacharacters.
+ sed -n "/^$1$/,/^$eqeq$/p" test-suite.log > got
+ (echo "$1" && echo "$eqeq") > exp
+ cat exp
+ cat got
+ diff exp got
+}
+
+have_rst_section 'PASS: ok'
+have_rst_section 'SKIP: skip'
+have_rst_section 'SKIP: skipall'
+have_rst_section 'FAIL: fail'
+have_rst_section 'FAIL: fail2'
+have_rst_section 'FAIL: xpass'
+have_rst_section 'FAIL: xpass2'
+have_rst_section 'ERROR: bail'
+have_rst_section 'ERROR: bail2'
+have_rst_section 'ERROR: bail3'
+have_rst_section 'ERROR: error'
+have_rst_section 'ERROR: error2'
+have_rst_section 'ERROR: error3'
+have_rst_section 'ERROR: error4'
+have_rst_section 'ERROR: error5'
+have_rst_section 'ERROR: error6'
+have_rst_section 'ERROR: error7'
+have_rst_section 'ERROR: hodgepodge'
+have_rst_section 'ERROR: hodgepodge-all'
+
+:
diff --git a/t/tap-log.sh b/t/tap-log.sh
new file mode 100755
index 000000000..ca564e1e5
--- /dev/null
+++ b/t/tap-log.sh
@@ -0,0 +1,164 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - log file creation
+# - log file removal
+# - stdout and stderr of a script go in its log file
+# - TEST_SUITE_LOG redefinition, at either automake or make time
+# - VERBOSE environment variable support
+# Keep in sync with 'test-log.test'.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+TESTS = pass.test skip.test xfail.test fail.test xpass.test error.test
+TEST_SUITE_LOG = global.log
+END
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+# Custom markers, for use in grepping checks.
+cmarker=::: # comment marker
+pmarker=%%% # plain maker
+
+cat > pass.test <<END
+#! /bin/sh -e
+echo 1..1
+echo "$pmarker pass $pmarker" >&2
+echo "# $cmarker pass $cmarker" >&2
+echo "ok 1"
+END
+
+cat > skip.test <<END
+#! /bin/sh -e
+echo 1..1
+echo "$pmarker skip $pmarker"
+echo "# $cmarker skip $cmarker"
+echo "ok 1 # SKIP"
+END
+
+cat > xfail.test <<END
+#! /bin/sh -e
+echo 1..1
+echo "$pmarker xfail $pmarker" >&2
+echo "# $cmarker xfail $cmarker" >&2
+echo "not ok 1 # TODO"
+END
+
+cat > fail.test <<END
+#! /bin/sh -e
+echo 1..1
+echo "$pmarker fail $pmarker"
+echo "# $cmarker fail $cmarker"
+echo "not ok 1"
+END
+
+cat > xpass.test <<END
+#! /bin/sh -e
+echo 1..1
+echo "$pmarker xpass $pmarker" >&2
+echo "# $cmarker xpass $cmarker" >&2
+echo "ok 1 # TODO"
+END
+
+cat > error.test <<END
+#! /bin/sh -e
+echo 1..1
+echo "$pmarker error $pmarker"
+echo "# $cmarker error $cmarker"
+echo 'Bail out!'
+END
+
+chmod a+x *.test
+
+TEST_SUITE_LOG=my.log $MAKE -e check && Exit 1
+ls -l # For debugging.
+test ! -f test-suite.log
+test ! -f global.log
+test -f my.log
+st=0
+for result in pass fail xfail xpass skip error; do
+ cat $result.log # For debugging.
+ $FGREP "$pmarker $result $pmarker" $result.log || st=1
+ $FGREP "$cmarker $result $cmarker" $result.log || st=1
+done
+test $st -eq 0 || Exit 1
+cat my.log # For debugging.
+for result in xfail fail xpass skip error; do
+ cat $result.log # For debugging.
+ $FGREP "$pmarker $result $pmarker" my.log || st=1
+ $FGREP "$cmarker $result $cmarker" my.log || st=1
+done
+test `$FGREP -c "$pmarker" my.log` -eq 5
+test `$FGREP -c "$cmarker" my.log` -eq 5
+
+# Passed test scripts shouldn't be mentioned in the global log.
+$EGREP '(^pass|[^x]pass)\.test' my.log && Exit 1
+# But failing (expectedly or not) and skipped ones should.
+$FGREP 'xfail.test' my.log
+$FGREP 'skip.test' my.log
+$FGREP 'fail.test' my.log
+$FGREP 'xpass.test' my.log
+$FGREP 'error.test' my.log
+
+touch error2.log test-suite.log global.log
+TEST_SUITE_LOG=my.log $MAKE -e mostlyclean
+ls -l # For debugging.
+test ! -f my.log
+test ! -f pass.log
+test ! -f fail.log
+test ! -f xfail.log
+test ! -f xpass.log
+test ! -f skip.log
+test ! -f error.log
+# "make mostlyclean" shouldn't remove unrelated log files.
+test -f error2.log
+test -f test-suite.log
+test -f global.log
+
+rm -f *.log
+
+VERBOSE=yes $MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+cat global.log
+test ! -f my.log
+test ! -f test-suite.log
+# Check that VERBOSE causes the global testsuite log to be
+# emitted on stdout.
+out=`cat stdout`
+log=`cat global.log`
+case $out in *"$log"*) ;; *) Exit 1;; esac
+
+touch error2.log test-suite.log my.log
+$MAKE clean
+ls -l # For debugging.
+test ! -f global.log
+test ! -f pass.log
+test ! -f fail.log
+test ! -f xfail.log
+test ! -f xpass.log
+test ! -f skip.log
+test ! -f error.log
+# "make clean" shouldn't remove unrelated log files.
+test -f error2.log
+test -f test-suite.log
+test -f my.log
+
+rm -f *.log
+
+:
diff --git a/t/tap-merge-stdout-stderr.sh b/t/tap-merge-stdout-stderr.sh
new file mode 100755
index 000000000..351b10d58
--- /dev/null
+++ b/t/tap-merge-stdout-stderr.sh
@@ -0,0 +1,72 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - The Automake TAP driver has an option that instruct it to read TAP
+# input also from the stderr of the test command, not only its stdout.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+fetch_tap_driver
+
+cat > Makefile.am << 'END'
+AM_TEST_LOG_DRIVER_FLAGS = --comments --merge
+TESTS = all.test
+END
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > all.test <<END
+#!/bin/sh
+echo 1..4
+echo ok 1 >&2
+echo ok 2
+echo "not ok 3 # TODO" >&2
+echo "ok 4 # SKIP"
+echo "# foo foo foo" >&2
+END
+chmod a+x all.test
+
+$MAKE check >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=4 pass=2 fail=0 xpass=0 xfail=1 skip=1 error=0
+grep '^# all\.test: foo foo foo' stdout
+
+cat > all.test <<END
+#!/bin/sh
+echo 1..1
+echo ok 1
+echo 'Bail out!' >&2
+END
+
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=2 pass=1 fail=0 xpass=0 xfail=0 skip=0 error=1
+
+# See that the option '--no-merge' can override the effect of '--merge'.
+
+TEST_LOG_DRIVER_FLAGS=--no-merge $MAKE -e check >stdout \
+ || { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=1 pass=1 fail=0 xpass=0 xfail=0 skip=0 error=0
+
+
+
+:
diff --git a/t/tap-missing-plan-and-bad-exit.sh b/t/tap-missing-plan-and-bad-exit.sh
new file mode 100755
index 000000000..e1ea4fd40
--- /dev/null
+++ b/t/tap-missing-plan-and-bad-exit.sh
@@ -0,0 +1,43 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - if a test script exits with non-zero status before printing the TAP
+# plan, then the driver reports both "missing plan" and "exited with
+# non-zero status" errors.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat > foo.test <<END
+#!/bin/sh
+exit 123
+END
+
+echo TESTS = foo.test > Makefile.am
+
+chmod a+x foo.test
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+count_test_results total=2 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=2
+
+grep '^ERROR: foo\.test - exited with status 123$' stdout
+grep '^ERROR: foo\.test - missing test plan$' stdout
+
+:
diff --git a/t/tap-more.sh b/t/tap-more.sh
new file mode 100755
index 000000000..6f5d5fe4b
--- /dev/null
+++ b/t/tap-more.sh
@@ -0,0 +1,162 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# More on TAP support:
+# - more than one TAP-generating test script in $(TESTS)
+# - VPATH builds
+# - use with parallel make (if supported)
+# - basic use of diagnostic messages (lines beginning with "#")
+# - flags for TAP driver defined through AC_SUBST in configure.ac
+# - messages generated by the testsuite harness reference the
+# correct test script(s)
+# - "make distcheck" works
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+fetch_tap_driver
+
+cat >> configure.ac <<END
+AC_SUBST([AM_TEST_LOG_DRIVER_FLAGS], ['--comments'])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TEST_LOG_DRIVER = $(srcdir)/tap-driver
+TESTS = 1.test 2.test 3.test
+EXTRA_DIST = $(TESTS) tap-driver
+END
+
+cat > 1.test <<'END'
+#! /bin/sh
+echo 1..2
+echo ok 1 - mu
+if test -f not-skip; then
+ echo "not ok 2 zardoz"
+else
+ echo "ok 2 zardoz # SKIP"
+fi
+END
+
+cat > 2.test <<'END'
+#! /bin/sh
+echo 1..3
+echo "ok"
+echo "not ok # TODO not implemented"
+echo "ok 3"
+END
+
+cat > 3.test <<END
+#! /bin/sh
+echo 1..1
+echo ok - blah blah blah
+echo '# Some diagnostic'
+if test -f bail-out; then
+ echo 'Bail out! Kernel Panic'
+else
+ :
+fi
+END
+
+chmod a+x [123].test
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+# Try a VPATH and by default serial build first, and then an in-tree
+# and by default parallel build.
+for try in 0 1; do
+
+ if test $try -eq 0; then
+ # VPATH serial build.
+ mkdir build
+ cd build
+ srcdir=..
+ run_make=$MAKE
+ elif test $try -eq 1; then
+ # In-tree parallel build.
+ srcdir=.
+ case $MAKE in
+ *\ -j*)
+ # Degree of parallelism already specified by the user: do
+ # not override it.
+ run_make=$MAKE
+ ;;
+ *)
+ # Some make implementations (e.g., HP-UX) don't grok '-j',
+ # some require no space between '-j' and the number of jobs
+ # (e.g., older GNU make versions), and some *do* require a
+ # space between '-j' and the number of jobs (e.g., Solaris
+ # dmake). We need a runtime test to see what works.
+ echo 'all:' > Makefile
+ for run_make in "$MAKE -j3" "$MAKE -j 3" "$MAKE"; do
+ $run_make && break
+ done
+ rm -f Makefile
+ ;;
+ esac
+ else
+ fatal_ "internal error, invalid value of '$try' for \$try"
+ fi
+
+ $srcdir/configure
+ ls -l # For debugging.
+
+ # Success.
+
+ $run_make check >stdout || { cat stdout; Exit 1; }
+ cat stdout
+ count_test_results total=6 pass=4 fail=0 xpass=0 xfail=1 skip=1 error=0
+ grep '^PASS: 1\.test 1 - mu$' stdout
+ grep '^SKIP: 1\.test 2 zardoz # SKIP$' stdout
+ test `$FGREP -c '1.test' stdout` -eq 2
+ grep '^PASS: 2\.test 1$' stdout
+ grep '^XFAIL: 2\.test 2 # TODO not implemented$' stdout
+ grep '^PASS: 2\.test 3$' stdout
+ test `$FGREP -c '2.test' stdout` -eq 3
+ grep '^PASS: 3\.test 1 - blah blah blah$' stdout
+ grep '^# 3\.test: Some diagnostic$' stdout
+ test `$FGREP -c '3.test' stdout` -eq 2
+
+ # Failure.
+
+ # Use 'echo' here, since Solaris 10 /bin/sh would try to optimize
+ # a ':' away after the first iteration, even if it is redirected.
+ echo dummy > not-skip
+ echo dummy > bail-out
+ $run_make check >stdout && { cat stdout; Exit 1; }
+ cat stdout
+ count_test_results total=7 pass=4 fail=1 xpass=0 xfail=1 skip=0 error=1
+ grep '^PASS: 1\.test 1 - mu$' stdout
+ grep '^FAIL: 1\.test 2 zardoz$' stdout
+ test `$FGREP -c '1.test' stdout` -eq 2
+ grep '^PASS: 2\.test 1$' stdout
+ grep '^XFAIL: 2\.test 2 # TODO not implemented$' stdout
+ grep '^PASS: 2\.test 3$' stdout
+ test `$FGREP -c '2.test' stdout` -eq 3
+ grep '^PASS: 3\.test 1 - blah blah blah$' stdout
+ grep '^# 3\.test: Some diagnostic$' stdout
+ grep '^ERROR: 3\.test - Bail out! Kernel Panic$' stdout
+ test `$FGREP -c '3.test' stdout` -eq 3
+
+ cd $srcdir
+
+done
+
+$MAKE distcheck
+
+:
diff --git a/t/tap-more2.sh b/t/tap-more2.sh
new file mode 100755
index 000000000..3cefd5800
--- /dev/null
+++ b/t/tap-more2.sh
@@ -0,0 +1,91 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# More on TAP support:
+# - more LOG_COMPILER at once for TAP tests
+# - binary programs in $(TESTS)
+# - interactions with 'check_*' variables
+
+required='cc native'
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+fetch_tap_driver
+
+cat >> configure.ac <<END
+AC_PROG_CC
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TEST_EXTENSIONS = .sh .tap
+
+tap_driver = $(srcdir)/tap-driver
+
+LOG_DRIVER = $(tap_driver)
+SH_LOG_DRIVER = $(tap_driver)
+TAP_LOG_DRIVER = $(tap_driver)
+
+TAP_LOG_COMPILER = cat
+SH_LOG_COMPILER = $(SHELL)
+LOG_COMPILER =
+
+EXTRA_DIST = baz.tap
+
+check_SCRIPTS = bar.sh
+bar.sh: Makefile
+ echo '#!/bin/sh' > $@-t
+ echo 'echo 1..1' >> $@-t
+ echo 'echo "not ok 1 # TODO"' >> $@-t
+ chmod a-w $@-t && mv -f $@-t $@
+CLEANFILES = bar.sh
+
+check_PROGRAMS = foo-test
+foo_test_SOURCES = foo.c
+
+TESTS = foo-test $(check_SCRIPTS) baz.tap
+
+EXTRA_DIST += tap-driver
+END
+
+cat > foo.c <<'END'
+#include <stdio.h>
+int main (void)
+{
+ printf ("1..1\n");
+ printf ("ok 1\n");
+ return 0;
+}
+END
+
+cat > baz.tap << 'END'
+1..1
+ok 1 # SKIP
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+
+for target in check distcheck; do
+ $MAKE $target >stdout || { cat stdout; Exit 1; }
+ cat stdout
+ count_test_results total=3 pass=1 fail=0 xpass=0 xfail=1 skip=1 error=0
+done
+
+:
diff --git a/t/tap-msg0-bailout.sh b/t/tap-msg0-bailout.sh
new file mode 100755
index 000000000..115ffcdb9
--- /dev/null
+++ b/t/tap-msg0-bailout.sh
@@ -0,0 +1,38 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - literal strings "0" and "0.0" as a test description in the message
+# of a "plan with skip" TAP plan
+# generally true!
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+echo 'Bail out! 0' > a.test
+echo 'Bail out! 0.0' > b.test
+
+TESTS='a.test b.test' $MAKE -e check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=2 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=2
+
+grep '^ERROR: a.test - Bail out! 0$' stdout
+grep '^ERROR: b.test - Bail out! 0\.0$' stdout
+
+:
diff --git a/t/tap-msg0-directive.sh b/t/tap-msg0-directive.sh
new file mode 100755
index 000000000..04d379071
--- /dev/null
+++ b/t/tap-msg0-directive.sh
@@ -0,0 +1,41 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - literal string "0" as a TODO or SKIP message
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > all.test << 'END'
+1..3
+ok 1 # TODO 0
+not ok 2 # TODO 0
+ok 3 # SKIP 0
+END
+
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=3 pass=0 fail=0 xpass=1 xfail=1 skip=1 error=0
+
+grep '^XPASS: all\.test 1 # TODO 0$' stdout
+grep '^XFAIL: all\.test 2 # TODO 0$' stdout
+grep '^SKIP: all\.test 3 # SKIP 0$' stdout
+
+:
diff --git a/t/tap-msg0-misc.sh b/t/tap-msg0-misc.sh
new file mode 100755
index 000000000..6a515a8a8
--- /dev/null
+++ b/t/tap-msg0-misc.sh
@@ -0,0 +1,82 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - literal "0" and "0.0" in a test description and a TODO/SKIP message
+# at the same time
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > all.test << 'END'
+1..14
+
+ok 1 0
+ok 2 0.0
+
+ok 3 0 # TODO 0
+ok 4 0.0 # TODO 0
+ok 5 0 # TODO 0.0
+ok 6 0.0 # TODO 0.0
+
+not ok 7 0 # TODO 0
+not ok 8 0.0 # TODO 0
+not ok 9 0 # TODO 0.0
+not ok 10 0.0 # TODO 0.0
+
+ok 11 0 # SKIP 0
+ok 12 0.0 # SKIP 0
+ok 13 0 # SKIP 0.0
+ok 14 0.0 # SKIP 0.0
+
+END
+
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=14 pass=2 fail=0 xpass=4 xfail=4 skip=4 error=0
+
+sed '/^ *$/d' > exp << 'END'
+
+PASS: all.test 1 0
+PASS: all.test 2 0.0
+
+XPASS: all.test 3 0 # TODO 0
+XPASS: all.test 4 0.0 # TODO 0
+XPASS: all.test 5 0 # TODO 0.0
+XPASS: all.test 6 0.0 # TODO 0.0
+
+XFAIL: all.test 7 0 # TODO 0
+XFAIL: all.test 8 0.0 # TODO 0
+XFAIL: all.test 9 0 # TODO 0.0
+XFAIL: all.test 10 0.0 # TODO 0.0
+
+SKIP: all.test 11 0 # SKIP 0
+SKIP: all.test 12 0.0 # SKIP 0
+SKIP: all.test 13 0 # SKIP 0.0
+SKIP: all.test 14 0.0 # SKIP 0.0
+
+END
+
+$FGREP ': all.test' stdout > got
+
+cat exp
+cat got
+diff exp got
+
+:
diff --git a/t/tap-msg0-planskip.sh b/t/tap-msg0-planskip.sh
new file mode 100755
index 000000000..60aa5fe12
--- /dev/null
+++ b/t/tap-msg0-planskip.sh
@@ -0,0 +1,37 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - literal strings "0" and "0.0" as the reason of the skip in a "TAP
+# plan with skip" (i.e., "1..0 # SKIP ...").
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+echo '1..0 # SKIP 0' > a.test
+echo '1..0 # SKIP 0.0' > b.test
+
+TESTS='a.test b.test' $MAKE -e check >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=2 pass=0 fail=0 xpass=0 xfail=0 skip=2 error=0
+
+grep '^SKIP: a.test - 0$' stdout
+grep '^SKIP: b.test - 0\.0$' stdout
+
+:
diff --git a/t/tap-msg0-result.sh b/t/tap-msg0-result.sh
new file mode 100755
index 000000000..8c464c418
--- /dev/null
+++ b/t/tap-msg0-result.sh
@@ -0,0 +1,63 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - the string "0" as a test description
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > all.test << 'END'
+1..10
+ok 1 0
+ok - 0
+not ok 3 0
+not ok - 0
+ok 5 0 # TODO
+ok - 0 # TODO
+not ok 7 0 # TODO
+not ok - 0 # TODO
+ok 9 0 # SKIP
+ok - 0 # SKIP
+END
+
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=10 pass=2 fail=2 xpass=2 xfail=2 skip=2 error=0
+
+cat > exp << 'END'
+PASS: all.test 1 0
+PASS: all.test 2 - 0
+FAIL: all.test 3 0
+FAIL: all.test 4 - 0
+XPASS: all.test 5 0 # TODO
+XPASS: all.test 6 - 0 # TODO
+XFAIL: all.test 7 0 # TODO
+XFAIL: all.test 8 - 0 # TODO
+SKIP: all.test 9 0 # SKIP
+SKIP: all.test 10 - 0 # SKIP
+END
+
+$FGREP ': all.test' stdout > got
+
+cat exp
+cat got
+diff exp got
+
+:
diff --git a/t/tap-negative-numbers.sh b/t/tap-negative-numbers.sh
new file mode 100755
index 000000000..67ecb1e5e
--- /dev/null
+++ b/t/tap-negative-numbers.sh
@@ -0,0 +1,58 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - don't spuriously recognize negative TAP result numbers, but correctly
+# interpret them as test descriptions instead
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > all.test <<'END'
+1..7
+ok -1
+not ok -3
+ok -2 # SKIP
+not ok -5 # TODO
+ok -04 # TODO
+ok -121
+not ok -50000
+END
+
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=7 pass=2 fail=2 xpass=1 xfail=1 skip=1 error=0
+
+cat > exp <<'END'
+PASS: all.test 1 -1
+FAIL: all.test 2 -3
+SKIP: all.test 3 -2 # SKIP
+XFAIL: all.test 4 -5 # TODO
+XPASS: all.test 5 -04 # TODO
+PASS: all.test 6 -121
+FAIL: all.test 7 -50000
+END
+
+$FGREP ': all.test' stdout > got
+
+cat exp
+cat got
+diff exp got
+
+:
diff --git a/t/tap-no-disable-hard-error.sh b/t/tap-no-disable-hard-error.sh
new file mode 100755
index 000000000..c95e20e97
--- /dev/null
+++ b/t/tap-no-disable-hard-error.sh
@@ -0,0 +1,50 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - "Bail out!" magic and TAP parse errors are not disabled nor turned
+# into simple failures by the definition DISABLE_HARD_ERRORS.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+DISABLE_HARD_ERRORS = yes
+TEST_LOG_COMPILER = cat
+TESTS = bail.test few.test noplan.test
+END
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > bail.test <<END
+1..1
+Bail out!
+END
+
+cat > few.test <<END
+1..1
+END
+
+cat > noplan.test <<END
+# nothing here
+END
+
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=3 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=3
+
+:
diff --git a/t/tap-no-merge-stdout-stderr.sh b/t/tap-no-merge-stdout-stderr.sh
new file mode 100755
index 000000000..0236ef8ac
--- /dev/null
+++ b/t/tap-no-merge-stdout-stderr.sh
@@ -0,0 +1,53 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - By default, TAP input is only from the stdout (and not the stderr)
+# of the test command.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+TEST_LOG_DRIVER_FLAGS = --comments
+TESTS = all.test
+END
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > all.test <<END
+#!/bin/sh
+echo 1..2
+echo 'not ok' >&2
+echo 'not ok 1 # TODO' >&2
+echo 'ok 1'
+echo '# foo foo foo'
+echo '# bar bar bar' >&2
+echo 'ok 44 # TODO' >&2
+echo 'Bail out!' >&2
+echo 'ok 2 # SKIP'
+END
+
+chmod a+x all.test
+
+$MAKE check >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=2 pass=1 fail=0 xpass=0 xfail=0 skip=1 error=0
+$FGREP 'foo foo foo' stdout
+$FGREP 'bar bar bar' stdout && Exit 1
+
+:
diff --git a/t/tap-no-spurious-numbers.sh b/t/tap-no-spurious-numbers.sh
new file mode 100755
index 000000000..2fc993e01
--- /dev/null
+++ b/t/tap-no-spurious-numbers.sh
@@ -0,0 +1,99 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - we shouldn't spuriously recognize as TAP result numbers what it
+# not, even if it seems pretty close
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > prefixes <<'END'
+A
+a
+_
++
+-
+=
+/
+*
+.
+:
+,
+;
+$
+@
+%
+&
+#
+?
+!
+|
+\
+"
+`
+'
+(
+)
+[
+]
+{
+}
+<
+>
+END
+
+n=`wc -l <prefixes`
+
+# See the loop below to understand this initialization.
+pass=`expr $n '*' 3`
+fail=$pass
+skip=`expr $pass - 3`
+xfail=$skip
+xpass=$xfail
+error=0
+total=`expr $pass + $fail + $skip + $xfail + $xpass`
+
+echo 1..$total > all.test
+
+highno=1000
+
+for result in 'ok' 'not ok'; do
+ for spacing in "" " " "$tab"; do
+ subst="$result &$spacing$higno"
+ sed -e "s|.*|$subst|" prefixes
+ for directive in TODO SKIP; do
+ test "$result $directive" != "not ok SKIP" || continue
+ sed -e '/^#$/d' -e "s|.*|$subst # $directive|" prefixes
+ done
+ done
+done >> all.test
+
+cat all.test # For debugging.
+
+# Sanity checks.
+grep '#.*#' all.test && framework_failure_ "creating all.test"
+test `wc -l <all.test` -lt $highno || framework_failure_ "creating all.test"
+
+$MAKE check >stdout || :
+cat stdout
+
+count_test_results total=$total pass=$pass fail=$fail skip=$skip \
+ xpass=$xpass xfail=$xfail error=$error
+
+:
diff --git a/t/tap-no-spurious-summary.sh b/t/tap-no-spurious-summary.sh
new file mode 100755
index 000000000..8da15e8c3
--- /dev/null
+++ b/t/tap-no-spurious-summary.sh
@@ -0,0 +1,47 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - ':test-results:' directives in test scripts' output doesn't
+# originate spurious results in the testsuite summary
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > all.test <<'END'
+1..1
+:test-result: PASS
+:test-result: FAIL
+:test-result: XPASS
+:test-result: XFAIL
+:test-result: SKIP
+:test-result: ERROR
+:test-result: UNKNOWN
+ok 1
+END
+
+$MAKE check >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=1 pass=1 fail=0 xpass=0 xfail=0 skip=0 error=0
+
+for result in PASS FAIL XPASS XFAIL SKIP ERROR UNKNOWN; do
+ grep "^ *:test-result: $result$" all.log
+done
+
+:
diff --git a/t/tap-no-spurious.sh b/t/tap-no-spurious.sh
new file mode 100755
index 000000000..ac6e6687d
--- /dev/null
+++ b/t/tap-no-spurious.sh
@@ -0,0 +1,114 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - don't spuriously recognize lines that are "almost" TAP lines as
+# real TAP lines
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+echo 1..5 > all.test
+
+# The only recognized directives are "TODO" and "SKIP".
+# So the following should count as passed tests.
+cat >> all.test <<END
+ok 1 # XFAIL
+ok 2 # SKIPPED
+ok 3 # TO DO
+ok 4 # TODOALL
+ok 5 # FIXME
+END
+
+# According to documentation of Test::Harness::TAP(3):
+#
+# ``Lines written to standard output matching /^(not )?ok\b/
+# must be interpreted as test lines. All other lines must
+# not be considered test output.''
+
+cat >> all.test <<END
+ ok
+ ok 1
+${tab}ok
+${tab}ok 1
+ not ok
+ not ok 1
+${tab}not ok
+${tab}not ok 1
+notok
+notok 1
+not${tab}ok
+not${tab}ok 1
+not ok
+not ok 1
+no ok
+no ok 1
+# ok
+# not ok
+# ok 1
+# not ok 1
+#ok
+#not ok
+#ok 1
+#not ok 1
+END
+
+set +x # Don't pollute logs too much.
+for r in 'ok' 'not ok'; do
+ for s1 in \
+ a b c d e f g h i j k l m n o p q r s t u v w x y z \
+ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z \
+ 0 1 2 3 4 5 6 7 8 9 _ ab 0a 23 a1B2c _o _x_y_
+ do
+ for s2 in '' @ % + - = / . : \; \* \? \& \! \# \$ \< \> \\; do
+ printf '%s\n' "$r$s1$s2"
+ done
+ done
+done >> all.test
+set -x # Reset shell xtraces.
+
+# The prove(1) utility doesn't bail out on these, so our driver
+# shouldn't either.
+# See comments in 'tap-bailout-leading-space.test' for an explanation
+# of why we don't have a whitespace-prepended "Bail out!" line here.
+cat >> all.test <<'END'
+bailout
+bailout!
+bail out
+bail out!
+Bailout
+Bailout!
+Bail out
+ Bail out
+#Bail out!
+# Bail out!
+END
+
+cat all.test # For debugging.
+
+# Minor sanity check.
+test `grep -c '^ok1$' all.test` -eq 1 \
+ && test `grep -c '^not ok1$' all.test` -eq 1 \
+ || framework_failure_ "creating all.test"
+
+$MAKE check >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=5 pass=5 fail=0 xpass=0 xfail=0 skip=0 error=0
+
+:
diff --git a/t/tap-not-ok-skip.sh b/t/tap-not-ok-skip.sh
new file mode 100755
index 000000000..8cfffe2e4
--- /dev/null
+++ b/t/tap-not-ok-skip.sh
@@ -0,0 +1,39 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - a "not ok # SKIP" line should count as a failure, for consistency
+# with the prove(1) utility.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > all.test <<'END'
+1..4
+not ok # SKIP
+not ok 2 # SKIP
+not ok - foo # SKIP
+not ok 4 - bar # SKIP
+END
+
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=4 pass=0 fail=4 skip=0 xpass=0 xfail=0 error=0
+
+:
diff --git a/t/tap-number-wordboundary.sh b/t/tap-number-wordboundary.sh
new file mode 100755
index 000000000..7aa2c7f09
--- /dev/null
+++ b/t/tap-number-wordboundary.sh
@@ -0,0 +1,112 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - TAP result numbers terminated by a non-whitespace "word boundary"
+# character are recognized
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > all.test <<'END'
+1..5
+ok 1: foo1
+not ok 2- foo2
+ok 3@ foo3 # SKIP
+not ok 4?&%$ foo4 # TODO
+ok 5"`!! foo5 # TODO
+END
+
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=5 pass=1 fail=1 skip=1 xpass=1 xfail=1 error=0
+
+$EGREP '^PASS: all\.test 1 ?: foo1$' stdout
+$EGREP '^FAIL: all\.test 2 ?- foo2$' stdout
+$EGREP '^SKIP: all\.test 3 ?@ foo3 # SKIP$' stdout
+$EGREP '^XFAIL: all\.test 4 ?\?&%\$ foo4 # TODO$' stdout
+$EGREP '^XPASS: all\.test 5 ?"`!! foo5 # TODO$' stdout
+
+cat > all.test <<'END'
+1..3
+ok 2: quux
+not ok 1!
+ok 476$ # SKIP
+END
+
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=3 pass=0 fail=0 skip=0 xpass=0 xfail=0 error=3
+
+$EGREP '^ERROR: all\.test 2 ?: quux # OUT-OF-ORDER \(expecting 1\)$' stdout
+$EGREP '^ERROR: all\.test 1 ?! # OUT-OF-ORDER \(expecting 2\)$' stdout
+$EGREP '^ERROR: all\.test 476 ?\$ # OUT-OF-ORDER \(expecting 3\)$' stdout
+
+cat > punctuation <<'END'
+'
+"
+`
+#
+$
+!
+\
+/
+&
+%
+(
+)
+|
+^
+~
+?
+*
++
+-
+,
+:
+;
+=
+<
+>
+@
+[
+]
+{
+}
+\
+END
+
+# Strip any extra whitespace, for Solaris' wc.
+planned=`wc -l <punctuation | tr -d " $tab"`
+
+echo 1..$planned > all.test
+awk '{print "ok " NR $0 }' punctuation >> all.test
+# For debugging.
+cat all.test
+# Sanity check.
+grep "^ok 1'$" all.test || framework_failure_ "creating all.test"
+
+$MAKE check >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=$planned pass=$planned \
+ fail=0 skip=0 xpass=0 xfail=0 error=0
+
+:
diff --git a/t/tap-numbers-leading-zero.sh b/t/tap-numbers-leading-zero.sh
new file mode 100755
index 000000000..345b31f0f
--- /dev/null
+++ b/t/tap-numbers-leading-zero.sh
@@ -0,0 +1,109 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - how does TAP result numbers with leading zero fares?
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+do_checks ()
+{
+ $MAKE check >stdout && { cat stdout; Exit 1; }
+ cat stdout
+ count_test_results "$@"
+ # Allow some normalization of leading zeros, without forcing it.
+ LC_ALL=C sed -n 's/: all\.test 0*\([0-9]\)/: all.test \1/p' stdout > got
+ cat exp
+ cat got
+ diff exp got
+}
+
+cat > all.test <<END
+1..15
+
+ok 01
+ok 0002
+
+not ok 03
+not ok 0004
+
+ok 05 # SKIP
+ok 0006 # SKIP
+
+not ok 07 # TODO
+not ok 0008 # TODO
+
+ok 009
+ok 010
+
+ok 00000011
+not ok 0012
+ok 00000013 # SKIP
+not ok 0014 # TODO
+ok 00000015 # TODO
+END
+
+cat > exp <<END
+PASS: all.test 1
+PASS: all.test 2
+FAIL: all.test 3
+FAIL: all.test 4
+SKIP: all.test 5 # SKIP
+SKIP: all.test 6 # SKIP
+XFAIL: all.test 7 # TODO
+XFAIL: all.test 8 # TODO
+PASS: all.test 9
+PASS: all.test 10
+PASS: all.test 11
+FAIL: all.test 12
+SKIP: all.test 13 # SKIP
+XFAIL: all.test 14 # TODO
+XPASS: all.test 15 # TODO
+END
+
+do_checks total=15 pass=5 fail=3 xpass=1 xfail=3 skip=3 error=0
+
+cat > all.test <<END
+1..8
+
+ok 010
+not ok 003
+ok 0001 # SKIP
+not ok 010 # TODO
+ok 00100 # TODO
+
+ok 06
+ok 00007
+ok 8
+END
+
+cat > exp <<END
+ERROR: all.test 10 # OUT-OF-ORDER (expecting 1)
+ERROR: all.test 3 # OUT-OF-ORDER (expecting 2)
+ERROR: all.test 1 # OUT-OF-ORDER (expecting 3)
+ERROR: all.test 10 # OUT-OF-ORDER (expecting 4)
+ERROR: all.test 100 # OUT-OF-ORDER (expecting 5)
+PASS: all.test 6
+PASS: all.test 7
+PASS: all.test 8
+END
+
+do_checks total=8 pass=3 fail=0 xpass=0 xfail=0 skip=0 error=5
+
+:
diff --git a/t/tap-numeric-description.sh b/t/tap-numeric-description.sh
new file mode 100755
index 000000000..b2f54f3b7
--- /dev/null
+++ b/t/tap-numeric-description.sh
@@ -0,0 +1,69 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP result lines whose description is a number.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+# Some random numbers to be used as test names. The definitions below are
+# selected so that $x<n> != <n> for every n >= 1. We can't use positional
+# parameters for this unfortunately, since Solaris 10 /bin/sh doesn't allow
+# the dereferencing of parameters from ${10} onwards.
+x1=5 x2=7 x3=45 x4=11 x5=7 x6=3 x7=6 x8=9 x9=1000 x10=1
+
+cat > all.test <<END
+1..10
+ok 1 ${x1}
+ok - ${x2}
+not ok 3 ${x3}
+not ok - ${x4}
+ok 5 ${x5} # SKIP
+ok - ${x6} # SKIP
+not ok 7 ${x7} # TODO
+not ok - ${x8} # TODO
+ok 9 ${x9} # TODO
+ok - ${x10} # TODO
+END
+
+cat > exp <<END
+PASS: all.test 1 ${x1}
+PASS: all.test 2 - ${x2}
+FAIL: all.test 3 ${x3}
+FAIL: all.test 4 - ${x4}
+SKIP: all.test 5 ${x5} # SKIP
+SKIP: all.test 6 - ${x6} # SKIP
+XFAIL: all.test 7 ${x7} # TODO
+XFAIL: all.test 8 - ${x8} # TODO
+XPASS: all.test 9 ${x9} # TODO
+XPASS: all.test 10 - ${x10} # TODO
+END
+
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=10 pass=2 fail=2 xpass=2 xfail=2 skip=2 error=0
+
+$FGREP ': all.test' stdout > got
+
+cat exp
+cat got
+diff exp got
+
+
+:
diff --git a/t/tap-out-of-order.sh b/t/tap-out-of-order.sh
new file mode 100755
index 000000000..d9f36a251
--- /dev/null
+++ b/t/tap-out-of-order.sh
@@ -0,0 +1,81 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - out-of-order test results
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > a.test <<END
+1..3
+ok
+not ok 2 # TODO
+ok 71
+END
+
+cat > b.test <<END
+1..5
+ok 1
+ok 2
+ok 4 foo # SKIP mu
+not ok 2 bar # TODO um
+ok 5
+END
+
+cat > c.test <<END
+1..4
+ok 1
+ok foo
+ok 4 - zardoz
+not ok 3
+END
+
+# This is documented as an "test out of sequence" error in the
+# TAP::Parser documentation. Keep it in sync with the example
+# there.
+cat > d.test <<'END'
+1..5
+ok 1
+ok 2
+ok 15
+ok 16
+ok 17
+END
+
+TESTS='a.test b.test c.test d.test' $MAKE -e check >stdout \
+ && { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=17 pass=8 fail=0 xpass=0 xfail=1 skip=0 error=8
+
+test `$FGREP -c ': a.test' stdout` -eq 3
+test `$FGREP -c ': b.test' stdout` -eq 5
+test `$FGREP -c ': c.test' stdout` -eq 4
+test `$FGREP -c ': d.test' stdout` -eq 5
+
+grep '^ERROR: a\.test 71 # OUT-OF-ORDER (expecting 3)$' stdout
+grep '^ERROR: b\.test 4 foo # OUT-OF-ORDER (expecting 3)$' stdout
+grep '^ERROR: b\.test 2 bar # OUT-OF-ORDER (expecting 4)$' stdout
+grep '^ERROR: c\.test 4 - zardoz # OUT-OF-ORDER (expecting 3)$' stdout
+grep '^ERROR: c\.test 3 # OUT-OF-ORDER (expecting 4)$' stdout
+grep '^ERROR: d\.test 15 # OUT-OF-ORDER (expecting 3)$' stdout
+grep '^ERROR: d\.test 16 # OUT-OF-ORDER (expecting 4)$' stdout
+grep '^ERROR: d\.test 17 # OUT-OF-ORDER (expecting 5)$' stdout
+
+:
diff --git a/t/tap-passthrough-exit.sh b/t/tap-passthrough-exit.sh
new file mode 100755
index 000000000..75ce5f105
--- /dev/null
+++ b/t/tap-passthrough-exit.sh
@@ -0,0 +1,59 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - non-success exit status of a test script is reported in the
+# log file
+# See also related test 'tap-passthrough.test'.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+TEST_LOG_COMPILER = $(SHELL)
+TESTS =
+END
+
+exit_statuses='1 2 77 99'
+
+for e in $exit_statuses; do
+ unindent > exit-$e.test <<END
+ #!/bin/sh
+ echo 1..1
+ echo ok 1
+ exit $e
+END
+ echo TESTS += exit-$e.test >> Makefile.am
+done
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+st=0
+$MAKE check || st=$?
+for e in $exit_statuses; do cat exit-$e.log; done
+cat test-suite.log
+test $st -gt 0 || Exit 1
+
+for e in $exit_statuses; do
+ for log in exit-$e.log test-suite.log; do
+ grep "^ERROR: exit-$e\\.test - exited with status $e$" $log
+ done
+done
+
+env TEST_LOG_DRIVER_FLAGS='--ignore-exit' $MAKE -e check
+$FGREP ".test - exited with status" *.log && Exit 1
+
+:
diff --git a/t/tap-passthrough.sh b/t/tap-passthrough.sh
new file mode 100755
index 000000000..da05b1b1a
--- /dev/null
+++ b/t/tap-passthrough.sh
@@ -0,0 +1,166 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - all input (valid TAP lines, invalid TAP lines, non-TAP lines)
+# are passed through in the log file
+# - TAP errors are reported in the log file too
+# See also related test 'tap-passthrough-exit.test'.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+weirdchars=\''"\$@!&()[]<>#;,:.^?*/'
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+#
+# Only successful tests.
+#
+
+# The whitespace in this test might be normalized in the testsuite
+# progress output, but should be copied verbatim in the log files.
+cat > ok.test <<END
+1..6
+TAP plan in the previous line.
+ok${tab}
+ok 2
+ok - foo
+ok 4 - x
+ This is not a TAP line, but should still be copied in the log file!
+# some diagnostic${tab}
+not ok # TODO low priority
+ok # SKIP who cares?
+$weirdchars
+END
+
+TESTS=ok.test $MAKE -e check || { cat ok.log; Exit 1; }
+cat ok.log
+
+for rx in \
+ '1\.\.6' \
+ 'TAP plan in the previous line\.' \
+ "ok${tab}" \
+ 'ok 2' \
+ 'ok - foo' \
+ 'ok 4 - x' \
+ ' This is not a TAP line, but should still be copied in the log file!' \
+ "# some diagnostic${tab}" \
+ 'not ok # TODO low priority' \
+ 'ok # SKIP who cares?' \
+; do
+ grep "^$rx$" ok.log
+done
+$FGREP "$weirdchars" ok.log
+
+#
+# Mixed failing/successful tests.
+#
+
+cat > tiny.test <<END
+1..1
+ok
+END
+
+cat > ok.test <<END
+1..1
+ok
+only one success here
+END
+
+cat > ko.test <<END
+1..5
+foo foo foo
+ok${tab}
+ok 2
+not ok - foo
+not ok 4 - x
+# diagnostic ko
+ bar${tab}bar${tab}bar
+ok # TODO dunno
+$weirdchars
+END
+
+cat > bail.test <<END
+Bail out! Test is taking too long!
+END
+
+cat > skip.test <<END
+1..0 # Skipped: WWW::Mechanize not installed
+END
+
+cat > err.test <<END
+1..3
+ok 1
+Invalid test count
+ok 23
+Misplaced plan
+1..13
+ok
+Extra test
+ok
+Last line
+END
+
+st=0
+env TESTS='tiny.test ok.test ko.test bail.test skip.test err.test' \
+ $MAKE -e check || st=$?
+cat tiny.log
+cat ok.log
+cat ko.log
+cat bail.log
+cat skip.log
+cat err.log
+test $st -gt 0 || Exit 1
+
+grep '^1\.\.1$' tiny.log
+grep '^ok$' tiny.log
+grep '^only one success here$' ok.log
+
+for rx in \
+ '1\.\.5' \
+ 'foo foo foo' \
+ "ok${tab}" \
+ 'ok 2' \
+ 'not ok - foo' \
+ 'not ok 4 - x' \
+ '# diagnostic ko' \
+ " bar${tab}bar${tab}bar" \
+ 'ok # TODO dunno' \
+; do
+ grep "^$rx$" ko.log
+done
+$FGREP "$weirdchars" ko.log
+
+grep '^Bail out! Test is taking too long!$' bail.log
+grep '^1\.\.0 # Skipped: WWW::Mechanize not installed$' skip.log
+
+for rx in \
+ '^1\.\.3$' \
+ '^Invalid test count$' \
+ '^ok 23$' \
+ '^Misplaced plan$' \
+ '^1\.\.13$' \
+ '^ERROR:.* multiple test plans' \
+ '^Extra test$' \
+ '^Last line$' \
+ '^ERROR:.* [tT]oo many tests run.*expected 3, got 4' \
+ '^ERROR:.* err\.test 23 .*OUT[ -]OF[ -]ORDER.*expecting 2' \
+; do
+ grep "$rx" err.log
+done
+
+:
diff --git a/t/tap-plan-corner.sh b/t/tap-plan-corner.sh
new file mode 100755
index 000000000..3b9cd1fe9
--- /dev/null
+++ b/t/tap-plan-corner.sh
@@ -0,0 +1,198 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - some corner cases for TAP plan
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+# -------------------------------------------------------------------------
+
+cat > leading-repeated.test <<END
+1..1
+1..1
+ok 1
+END
+
+cat > trailing-repeated.test <<END
+ok 1
+1..1
+1..1
+END
+
+for pos in leading trailing; do
+ TESTS="$pos-repeated.test" $MAKE -e check >stdout \
+ && { cat stdout; Exit 1; }
+ cat stdout
+ count_test_results total=2 pass=1 fail=0 xpass=0 xfail=0 skip=0 error=1
+ grep "^ERROR: $pos-repeated\\.test - multiple test plans$" stdout
+done
+
+# -------------------------------------------------------------------------
+
+cat > leading-repeated.test <<END
+1..2
+ok 1
+1..2
+ok 2
+END
+
+cat > trailing-repeated.test <<END
+ok 1
+1..2
+ok 2
+1..2
+END
+
+env TESTS="leading-repeated.test trailing-repeated.test" \
+ $MAKE -e check >stdout && { cat stdout; Exit 1; }
+cat stdout
+count_test_results total=6 pass=3 fail=0 xpass=0 xfail=0 skip=0 error=3
+grep "^ERROR: leading-repeated\\.test - multiple test plans$" stdout
+grep "^ERROR: trailing-repeated\\.test - multiple test plans$" stdout
+grep "^ERROR: trailing-repeated\\.test 2 # AFTER LATE PLAN$" stdout
+grep "leading .*AFTER LATE PLAN" stdout && Exit 1
+
+# -------------------------------------------------------------------------
+
+cat > 1.test <<END
+1..0
+1..0
+END
+
+cat > 2.test <<END
+1..0 # SKIP
+1..0
+END
+
+cat > 3.test <<END
+1..0
+1..0 # SKIP
+END
+
+cat > 4.test <<END
+1..0 # SKIP
+1..0 # SKIP
+END
+
+env TESTS="1.test 2.test 3.test 4.test" \
+ $MAKE -e check >stdout && { cat stdout; Exit 1; }
+cat stdout
+count_test_results total=8 pass=0 fail=0 xpass=0 xfail=0 skip=4 error=4
+for i in 1 2 3 4; do
+ grep "^ERROR: $i\\.test - multiple test plans$" stdout
+done
+
+# -------------------------------------------------------------------------
+
+cat > all.test <<END
+1..5
+ok 1
+ok 2
+1..5
+ok 3
+1..5
+ok 4
+1..5
+ok 5
+END
+
+$MAKE -e check >stdout && { cat stdout; Exit 1; }
+cat stdout
+count_test_results total=8 pass=5 fail=0 xpass=0 xfail=0 skip=0 error=3
+
+cat > exp <<'END'
+PASS: all.test 1
+PASS: all.test 2
+ERROR: all.test - multiple test plans
+PASS: all.test 3
+ERROR: all.test - multiple test plans
+PASS: all.test 4
+ERROR: all.test - multiple test plans
+PASS: all.test 5
+END
+
+$FGREP ': all.test' stdout > got
+
+cat exp
+cat got
+diff exp got
+
+# -------------------------------------------------------------------------
+
+cat > all.test <<END
+1..2
+ok 1
+ok 2
+1..3
+ok 3
+END
+
+$MAKE -e check >stdout && { cat stdout; Exit 1; }
+cat stdout
+count_test_results total=5 pass=2 fail=0 xpass=0 xfail=0 skip=0 error=3
+
+cat > exp <<'END'
+PASS: all.test 1
+PASS: all.test 2
+ERROR: all.test - multiple test plans
+ERROR: all.test 3 # UNPLANNED
+ERROR: all.test - too many tests run (expected 2, got 3)
+END
+
+$FGREP ': all.test' stdout > got
+
+cat exp
+cat got
+diff exp got
+
+# -------------------------------------------------------------------------
+
+cat > all.test <<END
+ok 1
+ok 2
+ok 3
+1..5
+1..5
+ok 4
+1..5
+ok 5
+END
+
+$MAKE -e check >stdout && { cat stdout; Exit 1; }
+cat stdout
+count_test_results total=7 pass=3 fail=0 xpass=0 xfail=0 skip=0 error=4
+
+cat > exp <<'END'
+PASS: all.test 1
+PASS: all.test 2
+PASS: all.test 3
+ERROR: all.test - multiple test plans
+ERROR: all.test 4 # AFTER LATE PLAN
+ERROR: all.test - multiple test plans
+ERROR: all.test 5 # AFTER LATE PLAN
+END
+
+$FGREP ': all.test' stdout > got
+
+cat exp
+cat got
+diff exp got
+
+:
diff --git a/t/tap-plan-errors.sh b/t/tap-plan-errors.sh
new file mode 100755
index 000000000..1b740599e
--- /dev/null
+++ b/t/tap-plan-errors.sh
@@ -0,0 +1,114 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support: the following situations should be flagged as errors:
+# - unmatched test plan (too few tests run)
+# - multiple test plans
+# - missing test plan
+# - misplaced test plan (tests run after a late plan)
+# Checks about unplanned tests are performed in 'tap-unplanned.test'
+# and 'tap-skip-whole-badcount.test'. More checks about corner-cases
+# in TAP plans are performed in 'tap-plan-corner.test'.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+my_check ()
+{
+ cat > all.test
+ test -n "$err" || fatal_ "\$err not set before calling my_check"
+ cat all.test # For debugging.
+ $MAKE check >stdout && { cat stdout; Exit 1; }
+ cat stdout
+ count_test_results "$@"
+ grep "^ERROR: all\\.test $err$" stdout
+ unset err
+}
+
+err='- too few tests run (expected 2, got 1)'
+my_check total=2 pass=1 fail=0 xpass=0 xfail=0 skip=0 error=1 <<END
+1..2
+ok 1
+END
+
+err='- too few tests run (expected 12, got 3)'
+my_check total=4 pass=2 fail=0 xpass=0 xfail=1 skip=0 error=1 <<END
+ok 1
+ok 2
+not ok 3 # TODO
+1..12
+END
+
+err='- too few tests run (expected 1, got 0)'
+my_check total=1 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=1 <<END
+1..1
+END
+
+err='2 # AFTER LATE PLAN'
+my_check total=2 pass=1 fail=0 xpass=0 xfail=0 skip=0 error=1 <<END
+ok 1
+1..2
+ok 2
+END
+
+err='5 # AFTER LATE PLAN'
+my_check total=5 pass=4 fail=0 xpass=0 xfail=0 skip=0 error=1 <<END
+ok 1
+ok 2
+ok 3
+ok 4
+1..5
+ok 5
+END
+
+err='- missing test plan'
+my_check total=2 pass=1 fail=0 xpass=0 xfail=0 skip=0 error=1 <<END
+ok 1
+END
+
+
+# The two test plans here are deliberately equal.
+err='- multiple test plans'
+my_check total=3 pass=2 fail=0 xpass=0 xfail=0 skip=0 error=1 <<END
+1..2
+ok 1
+ok 2
+1..2
+END
+
+# The second plan is diagnosed as extra, and only the first one is
+# relevant w.r.t. the number of the expected test.
+err='- multiple test plans'
+my_check total=4 pass=3 fail=0 xpass=0 xfail=0 skip=0 error=1 <<END
+1..3
+ok 1
+ok 2
+1..2
+ok 3
+END
+
+# As above, in a slightly different situation.
+err='- multiple test plans'
+my_check total=3 pass=2 fail=0 xpass=0 xfail=0 skip=0 error=1 <<END
+1..2
+ok 1
+ok 2
+1..4
+END
+
+:
diff --git a/t/tap-plan-leading-zero.sh b/t/tap-plan-leading-zero.sh
new file mode 100755
index 000000000..bb45f31f6
--- /dev/null
+++ b/t/tap-plan-leading-zero.sh
@@ -0,0 +1,57 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - TAP plans with numbers having leading zeroes, as in "1..01"
+# - TAP "SKIP" plans with multiple zeroes, as in "1..00 # SKIP"
+# This is consistent with the behaviour of the 'prove' utility.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > a.test <<END
+1..01
+ok 1
+END
+
+cat > b.test <<END
+1..0002
+ok 1
+ok 2
+END
+
+echo 1..010 > c.test
+for i in 1 2 3 4 5 6 7 8 9 10; do echo ok $i; done >> c.test
+
+echo 1..00100 > d.test
+for i in 1 2 3 4 5 6 7 8 9 10; do
+ for j in 1 2 3 4 5 6 7 8 9 10; do
+ echo ok
+ done
+done >> d.test
+
+echo 1..00 > e.test
+echo '1..000 # SKIP' > f.test
+
+env TESTS='a.test b.test c.test d.test e.test f.test' \
+ $MAKE -e check >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=115 pass=113 xfail=0 skip=2 fail=0 xpass=0 error=0
+
+:
diff --git a/t/tap-plan-malformed.sh b/t/tap-plan-malformed.sh
new file mode 100755
index 000000000..c8d2cdc30
--- /dev/null
+++ b/t/tap-plan-malformed.sh
@@ -0,0 +1,60 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support: a malformed TAP plan is not recognized. The checks in
+# here should be consistent with the behaviour of the 'prove' utility.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > a.test <<END
+1..1 foo
+END
+
+cat > b.test <<END
+ 1..2
+ok 1
+ok 2
+END
+
+cat > c.test <<END
+1..1 # SKIP
+END
+
+cat > d.test <<END
+1..2 # foo bar
+not ok 1 # TODO
+not ok 2 # TODO
+END
+
+cat > e.test <<END
+0..0
+END
+
+tests_list=`echo *.test`
+
+TESTS="$tests_list" $MAKE -e check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=9 pass=2 fail=0 xpass=0 xfail=2 skip=0 error=5
+
+for tst in $tests_list; do
+ grep "^ERROR: $tst - missing test plan$" stdout
+done
+
+:
diff --git a/t/tap-plan-middle.sh b/t/tap-plan-middle.sh
new file mode 100755
index 000000000..0775f1029
--- /dev/null
+++ b/t/tap-plan-middle.sh
@@ -0,0 +1,83 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - test plan preceding and/or following non-result TAP lines
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > top1.test <<END
+non-TAP line, ignored
+1..1
+ok 1
+END
+
+cat > top2.test <<END
+some
+non-TAP
+lines
+are
+ignored
+# and a TAP comment won't cause problems either
+1..2
+ok 1
+ok 2
+END
+
+# Try with a blank line too, just to be sure.
+cat > top3.test <<END
+
+1..1
+ok 1
+END
+
+cat > bot1.test <<END
+ok 1 # SKIP
+1..1
+bla blah blah ...
+END
+
+cat > bot2.test <<END
+ok 1
+ok 2
+not ok 3 # TODO
+1..3
+#@$%! (a cursing comment :-)
+END
+
+# Try with a blank line too, just to be sure.
+cat > bot3.test <<END
+ok 1
+not ok 2 # TODO
+ok 3 # SKIP
+ok 4 # SKIP
+1..4
+
+END
+
+tests=`echo *.test`
+
+for tap_flags in "" "--comments"; do
+ env TEST_LOG_DRIVER_FLAGS="$tap_flags" TESTS="$tests" \
+ $MAKE -e check >stdout || { cat stdout; Exit 1; }
+ cat stdout
+ count_test_results total=12 pass=7 xfail=2 skip=3 fail=0 xpass=0 error=0
+done
+
+:
diff --git a/t/tap-plan-whitespace.sh b/t/tap-plan-whitespace.sh
new file mode 100755
index 000000000..7bdb4dc1d
--- /dev/null
+++ b/t/tap-plan-whitespace.sh
@@ -0,0 +1,41 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - plan line with trailing whitespace is recognized and handled correctly
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+sed 's/\$$//' > foo.test <<END
+1..2 $
+ok 1$
+ok 2$
+END
+
+cat > bar.test <<END
+1..1$tab $tab$tab
+ok 1
+END
+
+TESTS='foo.test bar.test' $MAKE -e check >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=3 pass=3 fail=0 error=0 xpass=0 xfail=0 skip=0
+
+:
diff --git a/t/tap-plan.sh b/t/tap-plan.sh
new file mode 100755
index 000000000..d85a3a21f
--- /dev/null
+++ b/t/tap-plan.sh
@@ -0,0 +1,52 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - test scripts with the test plan at the beginning
+# - test scripts with the test plan at the end
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > top.test <<END
+1..3
+ok 1
+ok 2 # SKIP
+ok 3
+# a trailing comment
+END
+
+cat > bot.test <<END
+ok 1
+# a comment
+ok 2
+not ok 3 # TODO
+# another comment
+ok
+1..4
+END
+
+for tap_flags in "" "--comments"; do
+ env TEST_LOG_DRIVER_FLAGS="$tap_flags" TESTS='top.test bot.test' \
+ $MAKE -e check >stdout || { cat stdout; Exit 1; }
+ cat stdout
+ count_test_results total=7 pass=5 xfail=1 skip=1 fail=0 xpass=0 error=0
+done
+
+
+:
diff --git a/t/tap-planskip-and-logging.sh b/t/tap-planskip-and-logging.sh
new file mode 100755
index 000000000..48b3e1238
--- /dev/null
+++ b/t/tap-planskip-and-logging.sh
@@ -0,0 +1,74 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - interactions between "TAP plan with SKIP" and logging of earlier or
+# later TAP or non-TAP text
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+echo TEST_LOG_DRIVER_FLAGS = --comments >> Makefile
+
+cat > foo.test <<END
+1..0
+a non-TAP line
+# a comment
+END
+
+cat > foo2.test <<END
+a non-TAP line 2
+# a comment 2
+1..0
+END
+
+cat > bar.test <<END
+# an early comment
+an early non-TAP line
+ $tab
+1..0 # SKIP
+# a later comment
+a later non-TAP line
+END
+
+TESTS='foo.test foo2.test bar.test' $MAKE -e check >stdout \
+ || { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=3 pass=0 fail=0 xpass=0 xfail=0 skip=3 error=0
+
+grep '^# foo\.test: a comment$' stdout
+grep '^# foo2\.test: a comment 2$' stdout
+grep '^# bar\.test: an early comment$' stdout
+grep '^# bar\.test: a later comment$' stdout
+
+cat foo.log
+cat foo2.log
+cat bar.log
+
+grep '^a non-TAP line$' foo.log
+grep '^# a comment$' foo.log
+grep '^a non-TAP line 2$' foo2.log
+grep '^# a comment 2$' foo2.log
+grep '^# an early comment' bar.log
+grep '^an early non-TAP line$' bar.log
+grep '^# a later comment' bar.log
+grep '^a later non-TAP line$' bar.log
+grep "^ $tab$" bar.log
+
+:
diff --git a/t/tap-planskip-badexit.sh b/t/tap-planskip-badexit.sh
new file mode 100755
index 000000000..fbb3b56e6
--- /dev/null
+++ b/t/tap-planskip-badexit.sh
@@ -0,0 +1,52 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - an exit status != 0 of a test script causes an hard error, even if
+# the last line of output is a "SKIP plan" (e.g., "1..0 # SKIP").
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+echo TESTS = one.test two.test > Makefile.am
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > one.test <<'END'
+#!/bin/sh
+echo '1..0 # SKIP'
+exit 1
+END
+
+cat > two.test <<'END'
+#!/bin/sh
+echo '1..0'
+exit 22
+END
+
+chmod a+x one.test two.test
+
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+# The 'prove' utility reports both the skip and the non-zero exit status,
+# so we do the same.
+count_test_results total=4 pass=0 fail=0 xpass=0 xfail=0 skip=2 error=2
+
+grep '^ERROR: one\.test - exited with status 1$' stdout
+grep '^ERROR: two\.test - exited with status 22$' stdout
+
+:
diff --git a/t/tap-planskip-bailout.sh b/t/tap-planskip-bailout.sh
new file mode 100755
index 000000000..7fb72e9d4
--- /dev/null
+++ b/t/tap-planskip-bailout.sh
@@ -0,0 +1,36 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - a "Bail out!" directive causes an hard error, even if coming after
+# a "SKIP plan" (e.g., "1..0 # SKIP").
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > all.test <<END
+1..0 # SKIP
+Bail out!
+END
+
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+count_test_results total=2 pass=0 fail=0 xpass=0 xfail=0 skip=1 error=1
+grep '^ERROR: all\.test - Bail out!' stdout
+
+:
diff --git a/t/tap-planskip-case-insensitive.sh b/t/tap-planskip-case-insensitive.sh
new file mode 100755
index 000000000..b26701c53
--- /dev/null
+++ b/t/tap-planskip-case-insensitive.sh
@@ -0,0 +1,46 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - "SKIP" keyword in a TAP plan is case-insensitive
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+# These nested loops are clearer without indentation.
+
+i=0
+for c1 in s S; do
+for c2 in k K; do
+for c3 in i I; do
+for c4 in p P; do
+ i=`expr $i + 1`
+ case $i in ?) i=0$i; esac
+ echo "1..0 # $c1$c2$c3$c4 foobar" > $i.test
+done; done; done; done
+
+TESTS="`echo *.test`" $MAKE -e check >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=16 pass=0 fail=0 xpass=0 xfail=0 skip=16 error=0
+
+for tst in *.test; do
+ grep "^SKIP: $tst .* foobar$" stdout
+done
+
+:
diff --git a/t/tap-planskip-late.sh b/t/tap-planskip-late.sh
new file mode 100755
index 000000000..f89a55dcc
--- /dev/null
+++ b/t/tap-planskip-late.sh
@@ -0,0 +1,44 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - the special "plan with SKIP" can also be used "late" in the TAP
+# stream, i.e., preceded by non-TAP output or TAP diagnostic.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > foo.test <<END
+some non-TAP text, will be copied in the global log
+1..0 # SKIP from the last line
+END
+
+cat > bar.test <<END
+# some TAP diagnostic, will go to console
+1..0
+END
+
+TESTS='foo.test bar.test' $MAKE -e check >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+grep '^SKIP: foo\.test .* from the last line$' stdout
+grep '^SKIP: bar\.test$' stdout
+test `grep -c ': .*\.test' stdout` -eq 2
+count_test_results total=2 pass=0 fail=0 xpass=0 xfail=0 skip=2 error=0
+
+:
diff --git a/t/tap-planskip-later-errors.sh b/t/tap-planskip-later-errors.sh
new file mode 100755
index 000000000..a73dbce36
--- /dev/null
+++ b/t/tap-planskip-later-errors.sh
@@ -0,0 +1,40 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - TAP errors following a "TAP plan with SKIP" are still diagnosed.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > all.test <<END
+1..0
+a non-TAP line
+1..3
+1..5
+# a comment
+1..1
+END
+
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=4 pass=0 fail=0 xpass=0 xfail=0 skip=1 error=3
+test `grep -c '^ERROR: all\.test - multiple test plans' stdout` -eq 3
+
+:
diff --git a/t/tap-planskip-unplanned-corner.sh b/t/tap-planskip-unplanned-corner.sh
new file mode 100755
index 000000000..6dff7ac27
--- /dev/null
+++ b/t/tap-planskip-unplanned-corner.sh
@@ -0,0 +1,48 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - test results seen in a TAP stream that has a "plan with SKIP" are
+# flagged as errors, even if all of them are "SKIP" results.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > foo.test <<END
+1..0 # SKIP
+ok 1 # SKIP
+END
+
+cat > bar.test <<END
+ok 1 # SKIP
+1..0 # SKIP
+END
+
+TESTS='foo.test bar.test' $MAKE -e check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=5 pass=0 fail=0 xpass=0 xfail=0 skip=2 error=3
+
+# Don't be too strict w.r.t. the format of the "skip whole test" message.
+grep '^SKIP: foo\.test$' stdout || grep '^SKIP: foo\.test [^0-9]' stdout
+grep '^ERROR: foo\.test 1 # UNPLANNED$' stdout
+grep '^ERROR: foo\.test - too many tests run (expected 0, got 1)$' stdout
+grep '^SKIP: bar\.test 1 # SKIP$' stdout
+grep '^ERROR: bar\.test - too many tests run (expected 0, got 1)$' stdout
+
+:
diff --git a/t/tap-planskip-unplanned.sh b/t/tap-planskip-unplanned.sh
new file mode 100755
index 000000000..4aeb4de81
--- /dev/null
+++ b/t/tap-planskip-unplanned.sh
@@ -0,0 +1,73 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - a "plan with skip" given after one or more test result have already
+# been seen is an error
+# - any test result following a "plan with skip" is an error.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > all.test <<END
+ok 1
+1..0 # SKIP too late
+END
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+count_test_results total=2 pass=1 fail=0 xpass=0 xfail=0 skip=0 error=1
+grep '^ERROR: all\.test - too many tests run (expected 0, got 1)$' stdout
+
+cat > all.test <<END
+ok 1
+ok 2 # SKIP
+not ok 3 # TODO
+1..0 # SKIP too late
+END
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+count_test_results total=4 pass=1 fail=0 xpass=0 xfail=1 skip=1 error=1
+grep '^ERROR: all\.test - too many tests run (expected 0, got 3)$' stdout
+
+cat > all.test <<END
+1..0 # SKIP falsified later
+ok 1
+END
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+count_test_results total=3 pass=0 fail=0 xpass=0 xfail=0 skip=1 error=2
+grep '^ERROR: all\.test 1 # UNPLANNED$' stdout
+grep '^ERROR: all\.test - too many tests run (expected 0, got 1)$' stdout
+
+cat > all.test <<END
+1..0 # SKIP falsified later
+ok 1
+ok 2 # SKIP
+not ok 3
+not ok 4 # TODO
+END
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+count_test_results total=6 pass=0 fail=0 xpass=0 xfail=0 skip=1 error=5
+grep '^ERROR: all\.test 1 # UNPLANNED$' stdout
+grep '^ERROR: all\.test 2 # UNPLANNED$' stdout
+grep '^ERROR: all\.test 3 # UNPLANNED$' stdout
+grep '^ERROR: all\.test 4 # UNPLANNED$' stdout
+grep '^ERROR: all\.test - too many tests run (expected 0, got 4)$' stdout
+
+:
diff --git a/t/tap-planskip-whitespace.sh b/t/tap-planskip-whitespace.sh
new file mode 100755
index 000000000..a4dae998b
--- /dev/null
+++ b/t/tap-planskip-whitespace.sh
@@ -0,0 +1,48 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - normalization of whitespace in console testsuite progress associated
+# with a SKIP directive in the TAP plan
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > foo.test <<END
+1..0${tab}${tab} #${tab}SKIP ${tab}Strip leading & trailing ${tab}${tab}
+END
+
+cat > bar.test <<END
+1..0 #SKIP Preserve ${tab} middle${tab}${tab}space
+END
+
+cat > baz.test <<END
+1..0 # SKIP${tab} Strip${tab}external preserve ${tab}middle ${tab}${sp}
+END
+
+TESTS='foo.test bar.test baz.test' $MAKE -e check > stdout \
+ || { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=3 pass=0 fail=0 error=0 xpass=0 xfail=0 skip=3
+
+grep "SKIP: foo\\.test - Strip leading & trailing$" stdout
+grep "SKIP: bar\\.test - Preserve ${tab} middle${tab}${tab}space" stdout
+grep "SKIP: baz\\.test - Strip${tab}external preserve ${tab}middle" stdout
+
+:
diff --git a/t/tap-planskip.sh b/t/tap-planskip.sh
new file mode 100755
index 000000000..97ebd0c66
--- /dev/null
+++ b/t/tap-planskip.sh
@@ -0,0 +1,78 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Basic TAP test protocol support:
+# - special plan format to skip all the tests in a script
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+weirdchars=\''"$!&()[]<>#;^?*/@%=,.:'
+
+cat > foo.test <<END
+1..0
+END
+
+cat > bar.test <<END
+blah
+# blah
+1..0$tab $tab
+END
+
+# It is undefined whether the comment after the plan below should
+# count as an explanation; still, the test should be skipped.
+cat > baz.test <<END
+1..0 # WWW::Mechanize not installed
+other
+ junk
+ lines
+END
+
+cat > wget.test <<END
+1..0 # SKIP wget(1) not installed
+# See also curl.test
+END
+
+cat > curl.test <<END
+1..0 # SKIP: Can't connect to gnu.org!
+# See also wget.test
+END
+
+cat > mu.test <<END
+1..0 # SKIP $weirdchars
+END
+
+env TESTS='foo.test bar.test baz.test wget.test curl.test mu.test' \
+ $MAKE -e check >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=6 pass=0 fail=0 xpass=0 xfail=0 skip=6 error=0
+
+# Look for a regression where the "1..0" wasn't being stripped from the
+# SKIP message.
+$FGREP '1..0' stdout && Exit 1
+
+grep '^SKIP: foo\.test$' stdout
+grep '^SKIP: bar\.test$' stdout
+grep '^SKIP: baz\.test' stdout # Deliberately laxer, see above for why.
+grep '^SKIP: wget\.test .* wget(1) not installed$' stdout
+grep '^SKIP: curl\.test .* Can'\''t connect to gnu\.org!$' stdout
+grep '^SKIP: mu\.test' stdout | $FGREP "$weirdchars" stdout
+test `grep -c ': .*\.test' stdout` -eq 6
+
+:
diff --git a/t/tap-realtime.sh b/t/tap-realtime.sh
new file mode 100755
index 000000000..51f7bba93
--- /dev/null
+++ b/t/tap-realtime.sh
@@ -0,0 +1,126 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - testsuite progress on console should happen mostly "in real time";
+# i.e., it's not acceptable for the driver to wait the end of the
+# script to start displaying results from it.
+# FIXME: this test uses expect(1) to ensure line buffering from make and
+# children, and is pretty hacky and complex; is there a better way to
+# accomplish the checks done here?
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >expect-check <<'END'
+eval spawn $env(SHELL) -c ":"
+expect eof
+END
+expect -f expect-check || {
+ echo "$me: failed to find a working expect program" >&2
+ Exit 77
+}
+rm -f expect-check
+
+# Unfortunately, some make implementations (among them, FreeBSD make,
+# NetBSD make, and Solaris Distributed make), when run in parallel mode,
+# serialize the output from their targets' recipes unconditionally. In
+# such a situation, there's no way the partial results of a TAP test can
+# be displayed until the test has terminated. And this is not something
+# our TAP driver script can work around; in fact, the driver *is* sending
+# out its output progressively and "in sync" with test execution -- it is
+# make that is stowing such output away instead of presenting it to the
+# user as soon as it gets it.
+if using_gmake; then :; else
+ case $MAKE in
+ *\ -j*) skip_ "doesn't with non-GNU concurrent make";;
+ esac
+ # Prevent Sun Distributed Make from trying to run in parallel.
+ DMAKE_MODE=serial; export DMAKE_MODE
+fi
+
+cat > Makefile.am << 'END'
+TESTS = all.test
+END
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > all.test <<'END'
+#! /bin/sh
+echo 1..3
+
+# Creative quoting to placate maintainer-check.
+sleep="sleep "3
+
+# The awk+shell implementation of the TAP driver must "read ahead" of one
+# line in order to catch the exit status of the test script it runs. So
+# be sure to echo one "dummy" line after each result line in order not to
+# cause false positives.
+
+echo ok 1 - foo
+echo DUMMY
+$sleep
+test -f ok-1 || { echo 'Bail out!'; exit 1; }
+
+echo ok 2 - bar
+echo DUMMY
+$sleep
+test -f ok-2 || { echo 'Bail out!'; exit 1; }
+
+echo ok 3 - baz
+echo DUMMY
+$sleep
+test -f ok-3 || { echo 'Bail out!'; exit 1; }
+
+: > all-is-well
+END
+
+chmod a+x all.test
+
+cat > expect-make <<'END'
+eval spawn $env(MAKE) check
+expect {
+ "PASS: all.test 1 - foo" {
+ open "ok-1" "w"
+ exp_continue
+ }
+ "PASS: all.test 2 - bar" {
+ open "ok-2" "w"
+ exp_continue
+ }
+ "PASS: all.test 3 - baz" {
+ open "ok-3" "w"
+ exp_continue
+ }
+ "Testsuite summary" {
+ exit 0
+ }
+ timeout {
+ puts "expect timed out"
+ exit 1
+ }
+ default {
+ puts "expect error"
+ exit 1
+ }
+}
+END
+
+# Expect should simulate a tty as stdout, which should ensure a
+# line-buffered output.
+MAKE=$MAKE expect -f expect-make
+test -f all-is-well
+
+:
diff --git a/t/tap-recheck-logs.sh b/t/tap-recheck-logs.sh
new file mode 100755
index 000000000..53b2370cb
--- /dev/null
+++ b/t/tap-recheck-logs.sh
@@ -0,0 +1,119 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - RECHECK_LOGS
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+TEST_LOG_COMPILER = cat
+TESTS = foo.test bar.test baz.test
+baz.log: zardoz
+END
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+: > zardoz
+
+cat > foo.test <<'END'
+1..2
+ok 1
+ok 2
+END
+
+cat > bar.test <<'END'
+1..1
+not ok 1
+END
+
+cat > baz.test <<'END'
+1..1
+Bail out!
+END
+
+# Even the tests that are not re-run should contribute to the testsuite
+# summary when obtained by "make check RECHECK_LOGS=".
+grep_summary ()
+{
+ grep '^# TOTAL: *4$' stdout
+ grep '^# PASS: *2$' stdout
+ grep '^# XPASS: *0$' stdout
+ grep '^# FAIL: *1$' stdout
+ grep '^# XFAIL: *0$' stdout
+ grep '^# SKIP: *0$' stdout
+ grep '^# ERROR: *1$' stdout
+}
+
+$MAKE -e check && Exit 1
+test -f foo.log
+test -f bar.log
+test -f baz.log
+
+rm -f foo.log bar.log
+
+env RECHECK_LOGS= $MAKE -e check > stdout && { cat stdout; Exit 1; }
+cat stdout
+test -f foo.log
+test -f bar.log
+grep '^PASS: foo\.test 1$' stdout
+grep '^PASS: foo\.test 2$' stdout
+grep '^FAIL: bar\.test 1$' stdout
+grep 'baz\.test' stdout && Exit 1
+grep_summary
+
+$sleep
+touch foo.test
+# We re-run only a successful test, but the tests that failed in the
+# previous run should still be taken into account, and cause an overall
+# failure.
+env RECHECK_LOGS= $MAKE -e check > stdout && { cat stdout; Exit 1; }
+cat stdout
+grep '^PASS: foo\.test 1$' stdout
+grep '^PASS: foo\.test 2$' stdout
+grep 'ba[rz]\.test' stdout && Exit 1
+is_newest foo.log foo.test
+grep_summary
+
+$sleep
+touch zardoz
+env RECHECK_LOGS= $MAKE -e check > stdout && { cat stdout; Exit 1; }
+cat stdout
+grep '^ERROR: baz\.test' stdout
+$EGREP '(foo|bar)\.test' stdout && Exit 1
+is_newest baz.log zardoz
+grep_summary
+
+# Now, explicitly retry with all test logs already updated, and ensure
+# that the summary is still displayed.
+env RECHECK_LOGS= $MAKE -e check > stdout && { cat stdout; Exit 1; }
+cat stdout
+$EGREP '(foo|bar|baz)\.test' stdout && Exit 1
+grep_summary
+
+# The following should re-run foo.test (and only foo.test), even if its
+# log file is up-to-date.
+: > older
+env RECHECK_LOGS=foo.log $MAKE -e check > stdout && { cat stdout; Exit 1; }
+cat stdout
+grep '^PASS: foo\.test 1$' stdout
+grep '^PASS: foo\.test 2$' stdout
+grep 'ba[rz]\.test' stdout && Exit 1
+is_newest foo.log older
+grep_summary
+
+:
diff --git a/t/tap-recheck.sh b/t/tap-recheck.sh
new file mode 100755
index 000000000..4b120a529
--- /dev/null
+++ b/t/tap-recheck.sh
@@ -0,0 +1,215 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Test the 'recheck' target for TAP test protocol.
+# Keep in sync with 'test-driver-custom-multitest-recheck.test'.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+fetch_tap_driver
+
+cat >> configure.ac <<END
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TEST_LOG_DRIVER = $(srcdir)/tap-driver
+TESTS = a.test b.test c.test d.test
+END
+
+cat > a.test << 'END'
+#! /bin/sh
+echo 1..2
+echo ok 1
+echo ok 2
+: > a.run
+END
+
+cat > b.test << 'END'
+#! /bin/sh
+: > b.run
+echo 1..2
+echo ok 1
+if test -f b.ok; then
+ echo ok 2
+else
+ echo 'Bail out!'
+fi
+END
+
+cat > c.test << 'END'
+#! /bin/sh
+echo 1..3
+if test -f c.pass; then
+ echo 'ok - c is ok :-)'
+else
+ echo 'not ok - c is ko :-('
+fi
+if test -f c.xfail; then
+ echo 'not ok 2 # TODO'
+else
+ echo 'ok 2 # TODO'
+fi
+echo 'not ok 3 - blah blah # TODO need better diagnostic'
+: > c.run
+END
+
+cat > d.test << 'END'
+#! /bin/sh
+test -f ./d.count && . ./d.count
+echo 1..${test_count-2}
+echo ok 1 '# SKIP: who cares ...'
+(. ./d.extra) || echo 'not ok 2 - d.extra failed'
+: > d.run
+END
+
+chmod a+x *.test
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+do_recheck ()
+{
+ case $* in
+ --fail) on_bad_rc='&&';;
+ --pass) on_bad_rc='||';;
+ *) fatal_ "invalid usage of function 'do_recheck'";;
+ esac
+ rm -f *.run
+ eval "\$MAKE recheck >stdout $on_bad_rc { cat stdout; ls -l; Exit 1; }; :"
+ cat stdout; ls -l
+}
+
+for vpath in : false; do
+ if $vpath; then
+ mkdir build
+ cd build
+ srcdir=..
+ else
+ srcdir=.
+ fi
+
+ $srcdir/configure
+
+ : A "make recheck" in a clean tree should run no tests.
+ do_recheck --pass
+ cat test-suite.log
+ test ! -r a.run
+ test ! -r a.log
+ test ! -r b.run
+ test ! -r b.log
+ test ! -r c.run
+ test ! -r c.log
+ test ! -r d.run
+ test ! -r d.log
+ count_test_results total=0 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=0
+
+ : Run the tests for the first time.
+ $MAKE check >stdout && { cat stdout; Exit 1; }
+ cat stdout
+ ls -l
+ # All the test scripts should have run.
+ test -f a.run
+ test -f b.run
+ test -f c.run
+ test -f d.run
+ count_test_results total=9 pass=3 fail=2 xpass=1 xfail=1 skip=1 error=1
+
+ : Let us make b.test pass.
+ echo OK > b.ok
+ do_recheck --fail
+ # a.test has been successful the first time, so no need to re-run it.
+ # Similar considerations apply to similar checks, below.
+ test ! -r a.run
+ test -f b.run
+ test -f c.run
+ test -f d.run
+ count_test_results total=7 pass=2 fail=2 xpass=1 xfail=1 skip=1 error=0
+
+ : Let us make the first part of c.test pass.
+ echo OK > c.pass
+ do_recheck --fail
+ test ! -r a.run
+ test ! -r b.run
+ test -f c.run
+ test -f d.run
+ count_test_results total=5 pass=1 fail=1 xpass=1 xfail=1 skip=1 error=0
+
+ : Let us make also the second part of c.test pass.
+ echo KO > c.xfail
+ do_recheck --fail
+ test ! -r a.run
+ test ! -r b.run
+ test -f c.run
+ test -f d.run
+ count_test_results total=5 pass=1 fail=1 xpass=0 xfail=2 skip=1 error=0
+
+ : Nothing changed, so only d.test should be run.
+ for i in 1 2; do
+ do_recheck --fail
+ test ! -r a.run
+ test ! -r b.run
+ test ! -r c.run
+ test -f d.run
+ count_test_results total=2 pass=0 fail=1 xpass=0 xfail=0 skip=1 error=0
+ done
+
+ : Let us make d.test run more testcases, and experience _more_ failures.
+ echo 'test_count=9' > d.count
+ unindent > d.extra <<'END'
+ echo 'ok # SKIP s'
+ echo 'not ok - f 1'
+ echo 'ok - p 1'
+ echo 'not ok - f 2'
+ echo 'ok # TODO xp'
+ echo 'not ok - f 3'
+ echo 'not ok - f 4'
+ echo 'ok - p 2'
+ echo 'ok' # Extra test.
+ echo 'Bail out!'
+END
+ do_recheck --fail
+ test ! -r a.run
+ test ! -r b.run
+ test ! -r c.run
+ test -f d.run
+ count_test_results total=11 pass=2 fail=4 xpass=1 xfail=0 skip=2 error=2
+
+ : Let us finally make d.test pass.
+ echo 'test_count=1' > d.count
+ echo : > d.extra
+ do_recheck --pass
+ test ! -r a.run
+ test ! -r b.run
+ test ! -r c.run
+ test -f d.run
+ count_test_results total=1 pass=0 fail=0 xpass=0 xfail=0 skip=1 error=0
+
+ : All tests have been successful or skipped, nothing should be re-run.
+ do_recheck --pass
+ test ! -r a.run
+ test ! -r b.run
+ test ! -r c.run
+ test ! -r d.run
+ count_test_results total=0 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=0
+
+ cd $srcdir
+
+done
+
+:
diff --git a/t/tap-result-comment.sh b/t/tap-result-comment.sh
new file mode 100755
index 000000000..7162df02a
--- /dev/null
+++ b/t/tap-result-comment.sh
@@ -0,0 +1,54 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - non-directive comments in TAP results are kept verbatim
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > all.test <<END
+1..5
+ok 1 # TDO
+not ok 2 # SKP
+ok #SIKP${tab}${sp}
+not ok # TOD${tab}
+ok 5 # ${tab}${tab}TOOD${tab}${sp}${sp}
+END
+
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=5 pass=3 fail=2 xpass=0 xfail=0 skip=0 error=0
+
+# Don't be too strict about trailing white space.
+$FGREP ': all.test' stdout | sed "s/[$sp$tab]*$//" > got
+
+cat > exp <<END
+PASS: all.test 1 # TDO
+FAIL: all.test 2 # SKP
+PASS: all.test 3 #SIKP
+FAIL: all.test 4 # TOD
+PASS: all.test 5 # ${tab}${tab}TOOD
+END
+
+cat exp
+cat got
+diff exp got
+
+:
diff --git a/t/tap-signal.tap b/t/tap-signal.tap
new file mode 100755
index 000000000..ab1cd40ef
--- /dev/null
+++ b/t/tap-signal.tap
@@ -0,0 +1,140 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - a test script terminated by a signal causes an hard error
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+fetch_tap_driver
+
+plan_ 10
+
+cat >> configure.ac <<END
+AC_OUTPUT
+END
+
+cat > Makefile.am << END
+TEST_LOG_DRIVER = \$(srcdir)/tap-driver
+TEST_LOG_COMPILER = $PERL -w
+## Will be updated later.
+TESTS =
+END
+
+all_signals='1 2 3 9 13 15'
+blocked_signals=''
+for sig in $all_signals; do
+ # Ignore blocked signals
+ if is_blocked_signal $sig; then
+ blocked_signals="$blocked_signals $sig"
+ continue
+ fi
+ # Write the dummy test scripts in perl, not as shell scripts, to work
+ # around unportabilities in the handling of signals (in fact, even
+ # with bash, the older script were unable to properly deliver a SIGQUIT
+ # to themselves consistently). The shebang is dummy here, as we prefer
+ # to rely on the definition of TEST_LOG_COMPILER instead.
+ unindent > signal-$sig.test <<END
+ #! perl
+ # We need autoflush to avoid losing output, which could cause spurious
+ # "no test plan seen" in the TAP driver.
+ BEGIN { $| = 1 }
+ use warnings FATAL => "all";
+ print "1..1\\n";
+ print "ok 1\\n";
+ kill $sig, \$\$;
+ print "Bail out! \$0 not killed?\\n";
+END
+ echo TESTS += signal-$sig.test >> Makefile.am
+done
+results_count=`ls *.test | wc -l | tr -d "$tab$sp"`
+
+chmod a+x *.test
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+
+system=`uname -s -r || echo unknown` # Needed later.
+
+signal_caught ()
+{
+ numeric=$1
+ case $numeric in
+ 1) symbolic=HUP;;
+ 2) symbolic=INT;;
+ 3) symbolic=QUIT;;
+ 9) symbolic=KILL;;
+ 13) symbolic=PIPE;;
+ 15) symbolic=TERM;;
+ *) fatal_ "unexpected signal number '$numeric'"
+ esac
+ # Sending a SIGQUIT on Cygwin 1.5 can cause a segmentation fault
+ # instead (sometimes). Don't let this older bug pollute the results
+ # of our testsuite.
+ case $numeric,$system in
+ 3,CYGWIN*\ 1.5.*) sig_re="((SIG)?($symbolic|SEGV)|$numeric|11)";;
+ *) sig_re="((SIG)?$symbolic|$numeric)";;
+ esac
+ wbound_re="($|[^a-zA-Z0-9_-])"
+ pfx_re="^ERROR: signal-$numeric\\.test"
+ case $am_tap_implementation in
+ perl) rx="$pfx_re - terminated by signal $sig_re$";;
+ shell) rx="$pfx_re .*terminated by signal $sig_re$wbound_re";;
+ *) fatal_ "invalid \$am_tap_implementation '$am_tap_implementation'";;
+ esac
+ desc="TAP driver catch test termination by signal SIG$symbolic"
+ case " $blocked_signals " in
+ *" $numeric "*) skip_ -r "SIG$symbolic is blocked" "$desc" ;;
+ *) command_ok_ "$desc" env LC_ALL=C $EGREP "$rx" stdout ;;
+ esac
+}
+
+command_ok_ '"make check" fails' eval '
+ (
+ st=0; $MAKE check >stdout || st=$?
+ cat stdout
+ # Extra "echo" and silencing of xtraces required to avoid possible
+ # garbled output with NetBSD make, which would miss some final
+ # newlines in the expected places and thus mess up our TAP output.
+ set +x; echo
+ test $st -gt 0
+ )
+'
+cat stdout # For debugging.
+
+command_ok_ "count of test results" count_test_results \
+ total=`expr $results_count '*' 2` \
+ pass=$results_count error=$results_count \
+ fail=0 xpass=0 xfail=0 skip=0
+
+for sig in $all_signals; do
+ signal_caught $sig
+done
+
+echo 'TEST_LOG_DRIVER_FLAGS = --ignore-exit' >> Makefile
+
+command_ok_ '"make check" passes [--ignore-exit]' eval '$MAKE check >stdout'
+cat stdout # For debugging.
+
+command_ok_ "count of test results [--ignore-exit]" count_test_results \
+ total=$results_count pass=$results_count \
+ fail=0 xpass=0 xfail=0 skip=0 error=0
+
+:
diff --git a/t/tap-summary-color.sh b/t/tap-summary-color.sh
new file mode 100755
index 000000000..a28512b69
--- /dev/null
+++ b/t/tap-summary-color.sh
@@ -0,0 +1,23 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - colorized testsuite summary
+
+. ./defs-static
+
+use_colors=yes
+. "$am_testauxdir"/tap-summary-aux.sh
diff --git a/t/tap-summary.sh b/t/tap-summary.sh
new file mode 100755
index 000000000..deee09984
--- /dev/null
+++ b/t/tap-summary.sh
@@ -0,0 +1,23 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - colorized testsuite summary
+
+. ./defs-static
+
+use_colors=no
+. "$am_testauxdir"/tap-summary-aux.sh
diff --git a/t/tap-test-number-0.sh b/t/tap-test-number-0.sh
new file mode 100755
index 000000000..cf75cef4f
--- /dev/null
+++ b/t/tap-test-number-0.sh
@@ -0,0 +1,86 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - a test result numbered as 0 is to be considered out-of-order
+# This is consistent with the behaviour of the 'prove' utility.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+if test $am_tap_implementation = perl; then
+ $PERL -MTAP::Parser -e 1 \
+ || skip_ "cannot import TAP::Parser perl module"
+ if $PERL -w -e '
+ use warnings FATAL => "all"; use strict;
+ use TAP::Parser;
+ my $parser = TAP::Parser->new({tap => "1..1\n" . "ok 0\n"});
+ my $result = $parser->next;
+ $result->is_plan or die "first line is not TAP plan";
+ $result = $parser->next;
+ $result->is_test or die "second line is not TAP test result";
+ my $testno = $result->number;
+ $parser->next and die "unexpected further TAP stream";
+ exit ($testno == 0 ? 0 : 77);
+ '; then
+ : # Nothing to do.
+ elif test $? -eq 77; then
+ skip_ 'TAP::Parser bug: test number 0 gets relabelled as 1'
+ else
+ fatal_ "error analyzing TAP::Parser module for bugs"
+ fi
+fi
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > a.test <<END
+1..1
+ok 0
+END
+
+cat > b.test <<END
+1..1
+not ok 0
+END
+
+cat > c.test <<END
+1..1
+ok 0 foo # SKIP
+END
+
+cat > d.test <<END
+1..1
+not ok 0 bar # TODO
+END
+
+cat > e.test <<END
+1..1
+ok 0 # TODO
+END
+
+TESTS='a.test b.test c.test d.test e.test' $MAKE -e check >stdout \
+ && { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=5 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=5
+
+grep '^ERROR: a\.test 0 # OUT-OF-ORDER (expecting 1)$' stdout
+grep '^ERROR: b\.test 0 # OUT-OF-ORDER (expecting 1)$' stdout
+grep '^ERROR: c\.test 0 foo # OUT-OF-ORDER (expecting 1)$' stdout
+grep '^ERROR: d\.test 0 bar # OUT-OF-ORDER (expecting 1)$' stdout
+grep '^ERROR: e\.test 0 # OUT-OF-ORDER (expecting 1)$' stdout
+
+:
diff --git a/t/tap-todo-skip-together.sh b/t/tap-todo-skip-together.sh
new file mode 100755
index 000000000..e91153238
--- /dev/null
+++ b/t/tap-todo-skip-together.sh
@@ -0,0 +1,40 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - TODO and SKIP directives on the same line: the first one wins
+# See also related test 'tap-ambiguous-directive.test'.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > all.test <<END
+1..2
+ok 1 # SKIP TODO
+not ok 2 # TODO SKIP
+END
+
+$MAKE check >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=2 pass=0 fail=0 xpass=0 xfail=1 skip=1 error=0
+
+grep '^SKIP: all\.test 1 ' stdout
+grep '^XFAIL: all\.test 2 ' stdout
+
+:
diff --git a/t/tap-todo-skip-whitespace.sh b/t/tap-todo-skip-whitespace.sh
new file mode 100755
index 000000000..9d7afb962
--- /dev/null
+++ b/t/tap-todo-skip-whitespace.sh
@@ -0,0 +1,100 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - normalization of whitespace in console testsuite progress associated
+# with TODO and SKIP directives
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > stub.tap <<END
+1 # TODO
+2 # TODO foo?
+3 # TODO: bar!
+4 aa # TODO
+5 bb # TODO fnord 5
+6 cc # TODO:${tab}fnord 6
+7 - x # TODO
+8 - y # TODO fnord $tab 8
+9 - z # TODO: fnord 9 $tab
+10# TODO x0
+11$tab# TODO x1
+12 $tab$tab # TODO x2
+13 asd# TODO x3
+14 sad$tab# TODO x4
+15 das$tab$tab # TODO x5
+END
+
+cat > stub.exp <<END
+1 # TODO
+2 # TODO foo?
+3 # TODO: bar!
+4 aa # TODO
+5 bb # TODO fnord 5
+6 cc # TODO:${tab}fnord 6
+7 - x # TODO
+8 - y # TODO fnord $tab 8
+9 - z # TODO: fnord 9
+10 # TODO x0
+11 # TODO x1
+12 # TODO x2
+13 asd # TODO x3
+14 sad # TODO x4
+15 das # TODO x5
+END
+
+plan=1..15
+
+my_make_check ()
+{
+ xpass=0 xfail=0 skip=0
+ case $1 in
+ xpass|xfail|skip) eval $1=15;;
+ *) fatal_ "bad argument '$1' for my_make_check";;
+ esac
+ cat all.test
+ $MAKE check >stdout || : # Don't care about the exit status in this test.
+ cat stdout
+ count_test_results total=15 pass=0 fail=0 error=0 \
+ xpass=$xpass xfail=$xfail skip=$skip
+ # Don't be too strict w.r.t. possible normalization of "TODO: foo" into
+ # "TODO : foo" (as is done by, e.g., the 'TAP::Parser' perl module).
+ LC_ALL=C grep '^[A-Z][A-Z]*:' stdout \
+ | sed -e 's/# TODO *:/# TODO:/' -e 's/# SKIP *:/# SKIP:/' > got
+ cat exp
+ cat got
+ diff exp got
+}
+
+# For "TODO" directives leading to XPASS results.
+(echo $plan && sed -e 's/^/ok /' stub.tap) > all.test
+sed -e 's/^/XPASS: all.test /' stub.exp > exp
+my_make_check xpass
+
+# For "TODO" directives leading to XFAIL results.
+(echo $plan && sed -e 's/^/not ok /' stub.tap) > all.test
+sed -e 's/^/XFAIL: all.test /' stub.exp > exp
+my_make_check xfail
+
+# For "SKIP" directives.
+(echo $plan && sed -e 's/^/ok /' -e 's/TODO/SKIP/' stub.tap) > all.test
+sed -e 's/TODO/SKIP/' -e 's/^/SKIP: all.test /' stub.exp > exp
+my_make_check skip
+
+:
diff --git a/t/tap-todo-skip.sh b/t/tap-todo-skip.sh
new file mode 100755
index 000000000..e261d5790
--- /dev/null
+++ b/t/tap-todo-skip.sh
@@ -0,0 +1,91 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - TODO and SKIP directives are case-insensitive
+# - TODO and SKIP directives can be followed optionally by a colon ":"
+# and by an optional explanation.
+# - our driver isn't fooled into recognizing TODO and SKIP directives
+# spuriously
+# - the reasons for TODO and SKIP, if present, are nicely printed in
+# the testsuite progress output
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+# ----------------------------------------------------- #
+# Check all possible combinations of: #
+# - uppercase/lowercase #
+# - with/without colon character ":" #
+# - with/without explanatory message #
+# in TODO and SKIP directives. #
+# ----------------------------------------------------- #
+
+# There are 2 * 2^6 + 2 * 2^6 = 256 tests.
+echo 1..256 > all.test
+
+# These nested loops are clearer without indentation.
+
+for c1 in t T; do
+for c2 in o O; do
+for c3 in d D; do
+for c4 in o O; do
+for ex in '' ':' ' foo' ': foo'; do
+ echo "not ok # $c1$c2$c3$c4$ex"
+ echo "not ok# $c1$c2$c3$c4$ex"
+done; done; done; done; done >> all.test
+
+for c1 in s S; do
+for c2 in k K; do
+for c3 in i I; do
+for c4 in p P; do
+for ex in '' ':' ' foo' ': foo'; do
+ echo "ok # $c1$c2$c3$c4$ex"
+ echo "ok# $c1$c2$c3$c4$ex"
+done; done; done; done; done >> all.test
+
+cat all.test # For debugging.
+
+$MAKE check >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=256 pass=0 fail=0 xpass=0 xfail=128 skip=128 error=0
+
+# -------------------------------------------------------- #
+# TODO ans SKIP directives aren't recognized spuriously. #
+# -------------------------------------------------------- #
+
+cat > all.test <<'END'
+1..9
+ok TODO
+ok - TODO
+ok 3 TODO
+ok 4 - TODO
+ok SKIP
+ok - SKIP
+ok 7 SKIP
+ok 8 - SKIP
+ok 9
+END
+
+$MAKE check >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=9 pass=9 fail=0 xpass=0 xfail=0 skip=0 error=0
+
+:
diff --git a/t/tap-unplanned.sh b/t/tap-unplanned.sh
new file mode 100755
index 000000000..252e946c9
--- /dev/null
+++ b/t/tap-unplanned.sh
@@ -0,0 +1,159 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - unplanned tests are properly reported as errors
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > all.test <<END
+1..1
+ok 1
+ok 2
+END
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+count_test_results total=3 pass=1 fail=0 xpass=0 xfail=0 skip=0 error=2
+grep '^ERROR: all\.test - too many tests run (expected 1, got 2)$' stdout
+grep '^ERROR: all\.test 2 # UNPLANNED$' stdout
+
+cat > all.test <<END
+1..2
+ok 1
+ok 2
+ok 3
+END
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+count_test_results total=4 pass=2 fail=0 xpass=0 xfail=0 skip=0 error=2
+grep '^ERROR: all\.test - too many tests run (expected 2, got 3)$' stdout
+grep '^ERROR: all\.test 3 # UNPLANNED$' stdout
+
+# Interaction with XFAIL_TESTS.
+cat > all.test <<END
+1..2
+not ok 1
+ok 2 # SKIP
+ok 3
+not ok 4
+ok 5 # SKIP
+END
+XFAIL_TESTS=all.test $MAKE -e check >stdout && { cat stdout; Exit 1; }
+cat stdout
+count_test_results total=6 pass=0 fail=0 xpass=0 xfail=1 skip=1 error=4
+grep '^ERROR: all\.test - too many tests run (expected 2, got 5)$' stdout
+grep '^ERROR: all\.test 3 # UNPLANNED$' stdout
+grep '^ERROR: all\.test 4 # UNPLANNED$' stdout
+grep '^ERROR: all\.test 5 # UNPLANNED$' stdout
+
+cat > all.test <<END
+1..1
+ok 1
+
+ok
+ok 3
+ok foo
+ok 5 - bar bar
+
+not ok
+not ok 7
+not ok foo
+not ok 9 - bar bar
+
+ok # TODO
+ok 11 # TODO
+ok foo # TODO
+ok 13 - bar bar # TODO
+
+not ok # TODO
+not ok 15 # TODO
+not ok foo # TODO
+not ok 17 - bar bar # TODO
+
+ok # SKIP
+ok 19 # SKIP
+ok foo # SKIP
+ok 21 - bar bar # SKIP
+END
+
+cat > t <<END
+
+2
+3
+4 foo
+5 - bar bar
+
+6
+7
+8 foo
+9 - bar bar
+
+10
+11
+12 foo
+13 - bar bar
+
+14
+15
+16 foo
+17 - bar bar
+
+18
+19
+20 foo
+21 - bar bar
+
+END
+
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+count_test_results total=22 pass=1 fail=0 xpass=0 xfail=0 skip=0 error=21
+
+echo 'PASS: all.test 1' > exp
+sed -e '/^$/d' -e 's/.*/ERROR: all.test & # UNPLANNED/' t >> exp
+echo 'ERROR: all.test - too many tests run (expected 1, got 21)' >> exp
+
+$FGREP ': all.test' stdout > got
+
+cat exp
+cat got
+diff exp got
+
+# Note that, if the TAP input has a trailing plan, it is not possible
+# to flag unplanned tests as such, since we do not know they're unplanned
+# until the plan is reached; still, we should give at least an error
+# message about the unmatched number of tests once we've got the plan.
+
+for x in 'ok' 'ok 3' 'not ok' 'not ok # TODO' 'ok # TODO' 'ok # SKIP'; do
+ unindent > all.test <<END
+ ok 1
+ ok 2 # SKIP
+ $x
+ 1..2
+END
+ $MAKE check >stdout && { cat stdout; Exit 1; }
+ cat stdout
+ test `$FGREP -c ': all.test' stdout` -eq 4
+ $EGREP '^PASS: all\.test 1($| )' stdout
+ $EGREP '^SKIP: all\.test 2($| )' stdout
+ $EGREP ': all\.test 3($| )' stdout
+ grep '^ERROR: all\.test - too many tests run (expected 2, got 3)$' stdout
+done
+
+:
diff --git a/t/tap-whitespace-normalization.sh b/t/tap-whitespace-normalization.sh
new file mode 100755
index 000000000..227467441
--- /dev/null
+++ b/t/tap-whitespace-normalization.sh
@@ -0,0 +1,165 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support: whitespace normalization (or lack thereof) in the testsuite
+# progress output on console. We keep all these checks here in a single
+# script so that a potential cosmetic change in the output format won't
+# force us to tweak dozens of other tests (hopefully).
+# See also related test 'tap-todo-skip-whitespace.test'.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+TEST_LOG_COMPILER = cat
+TESTS =
+END
+
+: > exp
+
+spaces_a=${sp}${tab}${tab}${sp}${sp}${tab}
+spaces_b=${tab}${tab}${sp}${tab}${sp}${sp}${sp}
+
+#-----------------------------------------------------------------------
+
+echo TESTS += numbers.test >> Makefile.am
+
+cat > numbers.test <<END
+1..6
+ok${spaces_a}1
+ok 2${spaces_b}
+ok${spaces_a}3${spaces_b}
+not ok${spaces_b}4
+not ok 5${spaces_a}
+not ok${spaces_b}6${spaces_a}
+END
+
+cat >> exp <<END
+PASS: numbers.test 1
+PASS: numbers.test 2
+PASS: numbers.test 3
+FAIL: numbers.test 4
+FAIL: numbers.test 5
+FAIL: numbers.test 6
+END
+
+#-----------------------------------------------------------------------
+
+echo TESTS += description.test >> Makefile.am
+
+cat > description.test <<END
+1..8
+ok${spaces_a}+foo
+ok +bar${spaces_b}
+ok${spaces_a}+baz${spaces_b}
+not ok${spaces_b}-foo
+not ok -bar${spaces_a}
+not ok${spaces_b}-baz${spaces_a}
+ok u${spaces_b}v${spaces_a}w${sp}
+not ok${spaces_a}x${spaces_a}y${tab}z${tab}
+END
+
+cat >> exp <<END
+PASS: description.test 1 +foo
+PASS: description.test 2 +bar
+PASS: description.test 3 +baz
+FAIL: description.test 4 -foo
+FAIL: description.test 5 -bar
+FAIL: description.test 6 -baz
+PASS: description.test 7 u${spaces_b}v${spaces_a}w
+FAIL: description.test 8 x${spaces_a}y${tab}z
+END
+
+#-----------------------------------------------------------------------
+
+# "Bail out!" magic.
+
+echo TESTS += bailout.test >> Makefile.am
+
+cat > bailout.test <<END
+1..1
+Bail out!${tab}${sp}${sp}${tab}We're out of disk space.
+ok 1
+END
+
+cat >> exp <<END
+ERROR: bailout.test - Bail out! We're out of disk space.
+END
+
+echo TESTS += bailout2.test >> Makefile.am
+
+cat > bailout2.test <<END
+1..1
+Bail out!foo${tab}${sp}
+ok 1
+END
+
+cat >> exp <<END
+ERROR: bailout2.test - Bail out! foo
+END
+
+#-----------------------------------------------------------------------
+
+# Diagnostic lines.
+
+echo AM_TEST_LOG_DRIVER_FLAGS = --comments >> Makefile.am
+echo TESTS += cmnt.test >> Makefile.am
+
+cat > cmnt.test <<END
+1..1
+ok 1
+#Leading whitespace gets added
+# ${tab}${tab} ${tab}Extra leading whitespace is stripped
+# Trailing whitespace is stripped ${tab} ${tab}${tab}
+# Middle${tab}whitespace is${tab} ${tab}${tab} kept
+# ${tab} And only${tab}middle ${tab}whitespace ${tab}${tab} ${tab}
+END
+
+cat >> exp <<END
+PASS: cmnt.test 1
+# cmnt.test: Leading whitespace gets added
+# cmnt.test: Extra leading whitespace is stripped
+# cmnt.test: Trailing whitespace is stripped
+# cmnt.test: Middle${tab}whitespace is${tab} ${tab}${tab} kept
+# cmnt.test: And only${tab}middle ${tab}whitespace
+END
+
+#-----------------------------------------------------------------------
+
+# TODO: we should have more checks here ... (but let's not over-do FTM).
+
+#-----------------------------------------------------------------------
+
+chmod a+x *.test
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+# Don't care about exit status or number of test results, they should be
+# checked for in many other tests.
+$MAKE check >stdout || :
+cat stdout
+
+LC_ALL=C sort exp > t
+mv -f t exp
+
+# We need the sort below to account for parallel make usage.
+LC_ALL=C grep '[a-z0-9][a-z0-9]*\.test' stdout | LC_ALL=C sort > got
+
+cat exp
+cat got
+diff exp got
+
+:
diff --git a/t/tap-with-and-without-number.sh b/t/tap-with-and-without-number.sh
new file mode 100755
index 000000000..fc795f6f9
--- /dev/null
+++ b/t/tap-with-and-without-number.sh
@@ -0,0 +1,50 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP support:
+# - numbered and unnumbered test results can coexist
+# - tests without explicit number get automatically numbered in the
+# testsuite progress output on console
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+cat > all.test <<'END'
+1..7
+ok 1 foo
+ok 2 - foo2
+ok - bar
+not ok baz # TODO
+not ok 5 - asd # TODO
+ok 6 # SKIP
+ok zardoz
+END
+
+$MAKE check >stdout || { cat stdout; Exit 1; }
+cat stdout
+count_test_results total=7 pass=4 fail=0 xpass=0 xfail=2 skip=1 error=0
+
+grep '^PASS: all\.test 1 foo$' stdout
+grep '^PASS: all\.test 2 - foo2$' stdout
+grep '^PASS: all\.test 3 - bar$' stdout
+grep '^XFAIL: all\.test 4 baz # TODO$' stdout
+grep '^XFAIL: all\.test 5 - asd # TODO$' stdout
+grep '^SKIP: all\.test 6 # SKIP$' stdout
+grep '^PASS: all\.test 7 zardoz$' stdout
+
+:
diff --git a/t/tap-xfail-tests.sh b/t/tap-xfail-tests.sh
new file mode 100755
index 000000000..610779201
--- /dev/null
+++ b/t/tap-xfail-tests.sh
@@ -0,0 +1,68 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# TAP and $(XFAIL_TESTS): test results without directives are turned from
+# PASS to XPASS and from FAIL to XFAIL; other results are unchanged.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+. "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
+
+echo 'XFAIL_TESTS = $(TESTS)' >> Makefile
+
+cat > all.test <<END
+1..6
+ok 1
+not ok 2
+ok 3 # TODO
+not ok 4 # TODO
+ok 5 # SKIP
+# The next should count as a failure (and thus will be
+# rendered into an expected failure by XFAIL_TESTS).
+not ok 6 # SKIP
+Bail out!
+END
+
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=7 pass=0 fail=0 xpass=2 xfail=3 skip=1 error=1
+
+grep '^XPASS: all\.test 1$' stdout
+grep '^XFAIL: all\.test 2$' stdout
+grep '^XPASS: all\.test 3 # TODO' stdout
+grep '^XFAIL: all\.test 4 # TODO' stdout
+grep '^SKIP: all\.test 5 # SKIP' stdout
+grep '^XFAIL: all\.test 6 # SKIP' stdout
+grep '^ERROR: all\.test - Bail out!' stdout
+
+# Check that the exit status of the testsuite is indeed 0 when we
+# would expect success.
+
+cat > all.test <<END
+1..3
+not ok 1
+ok 2 # SKIP
+not ok 3 # TODO
+END
+
+$MAKE check >stdout || { cat stdout; Exit 1; }
+cat stdout
+
+count_test_results total=3 pass=0 fail=0 xpass=0 xfail=2 skip=1 error=0
+
+:
diff --git a/t/tar-override.sh b/t/tar-override.sh
new file mode 100755
index 000000000..641ce861d
--- /dev/null
+++ b/t/tar-override.sh
@@ -0,0 +1,65 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that the user can override the tar program used by "make dist"
+# at runtime, by redefining the 'TAR' environment variable.
+# FIXME: currently this works only when the tar format used is 'v7'
+# FIXME: (which is the default one).
+
+. ./defs || Exit 1
+
+cwd=`pwd` || fatal_ "couldn't get current working directory"
+
+echo AC_OUTPUT >> configure.ac
+
+cat > am--tar <<'END'
+#!/bin/sh
+echo $1 > am--tar-has-run
+shift
+exec tar "$@"
+END
+chmod a+x am--tar
+
+cat > Makefile.am <<'END'
+check-local: dist
+ test -f am--tar-has-run
+CLEANFILES = am--tar-has-run
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+
+$MAKE dist
+test -f $me-1.0.tar.gz
+ls | grep has-run && Exit 1
+
+rm -f *.tar.* *has-run*
+
+TAR="$cwd/am--tar foo" $MAKE distcheck
+test -f $me-1.0.tar.gz
+test "`cat am--tar-has-run`" = foo
+
+rm -f *.tar.* *has-run*
+
+TAR=; unset TAR
+# Creative use of eval to pacify maintainer checks.
+eval \$'MAKE dist "TAR=./am--tar mu"'
+test -f $me-1.0.tar.gz
+test "`cat am--tar-has-run`" = mu
+
+:
diff --git a/t/tar.sh b/t/tar.sh
new file mode 100755
index 000000000..263049ad0
--- /dev/null
+++ b/t/tar.sh
@@ -0,0 +1,40 @@
+#! /bin/sh
+# Copyright (C) 2004-2012 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/>.
+
+# Check the tar-ustar option.
+
+. ./defs || Exit 1
+
+cat > configure.ac << 'END'
+AC_INIT([tar], [1.0])
+AM_INIT_AUTOMAKE([tar-ustar])
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+END
+
+: > Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+
+if grep 'am__tar.*false' Makefile; then
+ skip_ "cannot find proper archiver program"
+fi
+
+$MAKE distcheck
+test -f tar-1.0.tar.gz
diff --git a/t/tar2.sh b/t/tar2.sh
new file mode 100755
index 000000000..f9cc00052
--- /dev/null
+++ b/t/tar2.sh
@@ -0,0 +1,40 @@
+#! /bin/sh
+# Copyright (C) 2004-2012 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/>.
+
+# Check the tar-pax option.
+
+. ./defs || Exit 1
+
+cat > configure.ac << 'END'
+AC_INIT([tar2], [1.0])
+AM_INIT_AUTOMAKE([tar-pax])
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+END
+
+: > Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+
+if grep 'am__tar.*false' Makefile; then
+ skip_ "cannot find proper archiver program"
+fi
+
+$MAKE distcheck
+test -f tar2-1.0.tar.gz
diff --git a/t/tar3.sh b/t/tar3.sh
new file mode 100755
index 000000000..403ce9916
--- /dev/null
+++ b/t/tar3.sh
@@ -0,0 +1,52 @@
+#! /bin/sh
+# Copyright (C) 2004-2012 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/>.
+
+# Check the tar options diagnostics.
+
+. ./defs || Exit 1
+
+cat > configure.ac << 'END'
+AC_INIT([tar2], [1.0])
+AM_INIT_AUTOMAKE([tar-pax tar-v7])
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+END
+
+: > Makefile.am
+
+$ACLOCAL
+AUTOMAKE_fails
+grep "^configure\.ac:2:.*mutually exclusive" stderr > tar-err
+cat tar-err
+test 1 = `wc -l < tar-err`
+grep "'tar-pax'" tar-err
+grep "'tar-v7'" tar-err
+
+rm -rf autom4te.cache
+
+cat > configure.ac << 'END'
+AC_INIT([tar2], [1.0])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+END
+
+echo 'AUTOMAKE_OPTIONS = tar-pax' > Makefile.am
+
+AUTOMAKE_fails
+grep '^Makefile\.am:1:.*tar-pax.*AM_INIT_AUTOMAKE' stderr
+
+:
diff --git a/t/target-cflags.sh b/t/target-cflags.sh
new file mode 100755
index 000000000..ad0e94d4f
--- /dev/null
+++ b/t/target-cflags.sh
@@ -0,0 +1,76 @@
+#! /bin/sh
+# Copyright (C) 2000-2012 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/>.
+
+# Test to make sure target specific CFLAGS work
+# Assar Westerlund <assar@sics.se>
+
+required=cc
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = no-dependencies
+
+bin_PROGRAMS = foo bar
+foo_CFLAGS = -DFOO
+END
+
+cat > foo.c << 'END'
+#include <stdio.h>
+#ifdef FOO
+int main(void)
+{
+ return 0;
+}
+#endif
+END
+
+cat > bar.c << 'END'
+#ifndef FOO
+int main(void)
+{
+ return 0;
+}
+#endif
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+mkdir build
+
+cd build
+../configure
+$MAKE
+if cross_compiling; then :; else
+ ./foo
+ ./bar
+fi
+cd ..
+
+./configure
+$MAKE
+if cross_compiling; then :; else
+ ./foo
+ ./bar
+fi
+
+:
diff --git a/t/targetclash.sh b/t/targetclash.sh
new file mode 100755
index 000000000..43e227da1
--- /dev/null
+++ b/t/targetclash.sh
@@ -0,0 +1,33 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Check that target clashes are diagnosed.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = ctags
+END
+
+$ACLOCAL
+AUTOMAKE_fails -a
+grep 'redefinition.*ctags' stderr
+
+:
diff --git a/t/test-driver-acsubst.sh b/t/test-driver-acsubst.sh
new file mode 100755
index 000000000..7df66ae77
--- /dev/null
+++ b/t/test-driver-acsubst.sh
@@ -0,0 +1,88 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# parallel-tests:
+# - LOG_DRIVER variables can be AC_SUBST'd
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+mkdir test-drivers
+
+cp "$am_testauxdir"/trivial-test-driver test-drivers/triv \
+ || fatal_ "failed to fetch auxiliary script trivial-test-driver"
+cp "$am_scriptdir"/test-driver test-drivers/dflt \
+ || fatal_ "failed to fetch auxiliary script test-driver"
+
+cat >> configure.ac <<'END'
+AC_SUBST([LOG_DRIVER], ['${SHELL} test-drivers/triv'])
+AC_SUBST([TEST_LOG_DRIVER], ['${SHELL} test-drivers/dflt'])
+AC_SUBST([SH_LOG_DRIVER], ['${my_drv}'])
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+TEST_EXTENSIONS = .test .sh
+my_drv = $(SHELL) test-drivers/dflt
+TESTS = foo bar.test baz.sh
+XFAIL_TESTS = baz.sh
+.PHONY: check-autodefs
+check-autodefs:
+### For debugging.
+ @echo LOG_DRIVER = $(LOG_DRIVER)
+ @echo TEST_LOG_DRIVER = $(TEST_LOG_DRIVER)
+ @echo SH_LOG_DRIVER = $(SH_LOG_DRIVER)
+### Checks here.
+ @echo ' ' $(LOG_DRIVER) ' ' | grep ' test-drivers/triv '
+ @echo ' ' $(TEST_LOG_DRIVER) ' ' | grep ' test-drivers/dflt '
+ @echo ' ' $(SH_LOG_DRIVER) ' ' | grep ' test-drivers/dflt '
+END
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+
+./configure
+
+cat > foo <<'END'
+#!/bin/sh
+echo "PASS: from $0"
+exit 1 # Exit status should be ignored by the trivial-test-driver.
+END
+
+cat > bar.test <<'END'
+#!/bin/sh
+exit 77
+END
+
+cat > baz.sh <<'END'
+#!/bin/sh
+exit 1
+END
+
+chmod a+x foo bar.test baz.sh
+
+$MAKE check-autodefs
+st=0; $MAKE check >stdout || st=$?
+cat stdout
+cat test-suite.log
+cat foo.log
+cat bar.log
+cat baz.log
+test $st -eq 0 || Exit 1
+count_test_results total=3 pass=1 fail=0 skip=1 xfail=1 xpass=0 error=0
+
+:
diff --git a/t/test-driver-cond.sh b/t/test-driver-cond.sh
new file mode 100755
index 000000000..ac0b3f171
--- /dev/null
+++ b/t/test-driver-cond.sh
@@ -0,0 +1,119 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# parallel-tests:
+# - Automake can correctly handle conditionals contents for the
+# LOG_DRIVER variables.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cp "$am_testauxdir"/trivial-test-driver . \
+ || fatal_ "failed to fetch auxiliary script trivial-test-driver"
+cp "$am_scriptdir"/tap-driver.pl . \
+ || fatal_ "failed to fetch auxiliary script tap-driver.pl"
+
+cat >> configure.ac << END
+AM_CONDITIONAL([COND1], [:])
+AM_CONDITIONAL([COND2], [false])
+AM_CONDITIONAL([COND3], [false])
+AC_SUBST([PERL], ['$PERL'])
+AC_SUBST([my_LOG_DRIVER], ['\${SHELL} \${top_srcdir}/trivial-test-driver'])
+AM_SUBST_NOTMAKE([my_LOG_DRIVER])
+AC_OUTPUT
+END
+
+$ACLOCAL
+$AUTOCONF
+
+cat > Makefile.am << 'END'
+TESTS = foo bar.test baz.sh
+EXTRA_DIST = $(TESTS) tap-driver.pl trivial-test-driver
+TEST_EXTENSIONS = .test .sh
+LOG_DRIVER =
+SH_LOG_DRIVER = $(tap_rulez)
+if COND1
+LOG_DRIVER += @my_LOG_DRIVER@
+if COND2
+tap_rulez = false
+else !COND2
+tap_rulez = $(PERL) $(srcdir)/tap-driver.pl
+endif !COND2
+endif COND1
+END
+
+cat > foo <<'END'
+#!/bin/sh
+echo "PASS: from $0"
+echo "SKIP: from $0"
+exit 1 # Exit status should be ignored by the trivial-test-driver.
+END
+
+cat > bar.test <<'END'
+#!/bin/sh
+exit 0
+END
+
+cat > baz.sh <<'END'
+#!/bin/sh
+echo 1..3
+echo 'ok 1'
+echo 'not ok 2 # TODO'
+echo 'not ok 3 # TODO'
+END
+
+chmod a+x foo bar.test baz.sh
+
+$AUTOMAKE -a
+test -f test-driver
+
+grep DRIVER Makefile.in || Exit 99 # For debugging.
+
+grep '^my_LOG_DRIVER *=' Makefile.in \
+ && fatal_ 'unexpected $(my_LOG_DRIVER) in Makefile.in'
+
+grep '^TEST_LOG_DRIVER =.*\$(SHELL).*/test-driver' Makefile.in
+
+$PERL -MTAP::Parser -e 1 \
+ || skip_ "cannot import TAP::Parser perl module"
+
+./configure
+
+do_count ()
+{
+ count_test_results total=6 pass=3 fail=0 skip=1 xfail=2 xpass=0 error=0
+ grep '^PASS: foo, testcase 1 *$' stdout
+ grep '^SKIP: foo, testcase 2 *$' stdout
+ grep '^PASS: bar\.test *$' stdout
+ $EGREP 'PASS: baz\.sh 1( |$)' stdout
+ $EGREP 'XFAIL: baz\.sh 2( |$)' stdout
+ $EGREP 'XFAIL: baz\.sh 3( |$)' stdout
+}
+
+st=0; $MAKE check >stdout || st=$?
+cat stdout
+cat test-suite.log
+cat foo.log
+cat bar.log
+cat baz.log
+test $st -eq 0 || Exit 1
+do_count
+
+$MAKE distcheck >stdout || { cat stdout; Exit 1; }
+cat stdout
+do_count
+
+:
diff --git a/t/test-driver-create-log-dir.sh b/t/test-driver-create-log-dir.sh
new file mode 100755
index 000000000..bfca0b938
--- /dev/null
+++ b/t/test-driver-create-log-dir.sh
@@ -0,0 +1,83 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Custom test drivers: if a log file has a directory component (as in
+# e.g., 'sub/foo.log'), the Automake test harness must ensure that
+# directory exists before calling any custom test driver.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+# The extra '.' components below are meant.
+TESTS = sub/foo sub/subsub/bar.test ././sub1/./baz
+$(TESTS):
+LOG_DRIVER = $(srcdir)/checkdir-driver
+TEST_LOG_DRIVER = $(LOG_DRIVER)
+EXTRA_DIST = checkdir-driver
+
+check-local: $(TEST_SUITE_LOG)
+ test -d sub
+ test -d sub1
+ test -d sub/subsub
+ test -f sub/foo.log
+ test -f sub/subsub/bar.log
+ test -f sub1/baz.log
+ test -f sub/foo.trs
+ test -f sub/subsub/bar.trs
+ test -f sub1/baz.trs
+END
+
+cat > checkdir-driver <<'END'
+#! /bin/sh
+set -e; set -u
+while test $# -gt 0; do
+ case $1 in
+ --log-file) log_file=$2; shift;;
+ --trs-file) trs_file=$2; shift;;
+ --test-name|--expect-failure|--color-tests|--enable-hard-errors) shift;;
+ --) shift; break;;
+ *) echo "$0: invalid option/argument: '$1'" >&2; exit 2;;
+ esac
+ shift
+done
+echo "log: $log_file" # For debugging.
+echo "trs: $trs_file" # Ditto.
+case $log_file in */*);; *) exit 1;; esac
+dir_log=`expr "$log_file" : '\(.*\)/[^/]*'`
+dir_trs=`expr "$trs_file" : '\(.*\)/[^/]*'`
+echo "dir_log: $dir_log" # For debugging.
+echo "dir_trs: $dir_trs" # Likewise.
+test x"$dir_trs" = x"$dir_log" || exit 1
+test -d "$dir_log" || exit 1
+echo dummy1 > "$log_file"
+echo dummy2 > "$trs_file"
+END
+chmod a+x checkdir-driver
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+$MAKE check
+$MAKE distcheck
+
+:
diff --git a/t/test-driver-custom-multitest-recheck.sh b/t/test-driver-custom-multitest-recheck.sh
new file mode 100755
index 000000000..9b4f5dfa3
--- /dev/null
+++ b/t/test-driver-custom-multitest-recheck.sh
@@ -0,0 +1,214 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Custom test drivers: try the "recheck" functionality with test protocols
+# that allow multiple testcases in a single test script. This test not
+# only checks implementation details in Automake's custom test drivers
+# support, but also serves as a "usability test" for our APIs.
+# See also related tests 'test-driver-custom-multitest-recheck2.test'
+# and 'parallel-tests-recheck-override.test'.
+# Keep in sync with 'tap-recheck.test'.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cp "$am_testauxdir"/trivial-test-driver . \
+ || fatal_ "failed to fetch auxiliary script trivial-test-driver"
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TEST_LOG_DRIVER = $(SHELL) $(srcdir)/trivial-test-driver
+TESTS = a.test b.test c.test d.test
+END
+
+cat > a.test << 'END'
+#! /bin/sh
+echo PASS: aa
+echo PASS: AA
+: > a.run
+END
+
+cat > b.test << 'END'
+#! /bin/sh
+echo PASS:
+if test -f b.ok; then
+ echo PASS:
+else
+ echo ERROR:
+fi
+: > b.run
+END
+
+cat > c.test << 'END'
+#! /bin/sh
+if test -f c.pass; then
+ echo PASS: c0
+else
+ echo FAIL: c0
+fi
+if test -f c.xfail; then
+ echo XFAIL: c1
+else
+ echo XPASS: c1
+fi
+echo XFAIL: c2
+: > c.run
+END
+
+cat > d.test << 'END'
+#! /bin/sh
+echo SKIP: who cares ...
+(. ./d.extra) || echo FAIL: d.extra failed
+: > d.run
+END
+
+chmod a+x *.test
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+do_recheck ()
+{
+ case $* in
+ --fail) on_bad_rc='&&';;
+ --pass) on_bad_rc='||';;
+ *) fatal_ "invalid usage of function 'do_recheck'";;
+ esac
+ rm -f *.run
+ eval "\$MAKE recheck >stdout $on_bad_rc { cat stdout; ls -l; Exit 1; }; :"
+ cat stdout; ls -l
+}
+
+for vpath in : false; do
+ if $vpath; then
+ mkdir build
+ cd build
+ srcdir=..
+ else
+ srcdir=.
+ fi
+
+ $srcdir/configure
+
+ : A "make recheck" in a clean tree should run no tests.
+ do_recheck --pass
+ cat test-suite.log
+ test ! -r a.run
+ test ! -r a.log
+ test ! -r b.run
+ test ! -r b.log
+ test ! -r c.run
+ test ! -r c.log
+ test ! -r d.run
+ test ! -r d.log
+ count_test_results total=0 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=0
+
+ : Run the tests for the first time.
+ $MAKE check >stdout && { cat stdout; Exit 1; }
+ cat stdout
+ ls -l
+ # All the test scripts should have run.
+ test -f a.run
+ test -f b.run
+ test -f c.run
+ test -f d.run
+ count_test_results total=9 pass=3 fail=2 xpass=1 xfail=1 skip=1 error=1
+
+ : Let us make b.test pass.
+ echo OK > b.ok
+ do_recheck --fail
+ # a.test has been successful the first time, so no need to re-run it.
+ # Similar considerations apply to similar checks, below.
+ test ! -r a.run
+ test -f b.run
+ test -f c.run
+ test -f d.run
+ count_test_results total=7 pass=2 fail=2 xpass=1 xfail=1 skip=1 error=0
+
+ : Let us make the first part of c.test pass.
+ echo OK > c.pass
+ do_recheck --fail
+ test ! -r a.run
+ test ! -r b.run
+ test -f c.run
+ test -f d.run
+ count_test_results total=5 pass=1 fail=1 xpass=1 xfail=1 skip=1 error=0
+
+ : Let us make also the second part of c.test pass.
+ echo KO > c.xfail
+ do_recheck --fail
+ test ! -r a.run
+ test ! -r b.run
+ test -f c.run
+ test -f d.run
+ count_test_results total=5 pass=1 fail=1 xpass=0 xfail=2 skip=1 error=0
+
+ : Nothing changed, so only d.test should be run.
+ for i in 1 2; do
+ do_recheck --fail
+ test ! -r a.run
+ test ! -r b.run
+ test ! -r c.run
+ test -f d.run
+ count_test_results total=2 pass=0 fail=1 xpass=0 xfail=0 skip=1 error=0
+ done
+
+ : Let us make d.test run more testcases, and experience _more_ failures.
+ unindent > d.extra <<'END'
+ echo SKIP: s
+ echo FAIL: f 1
+ echo PASS: p 1
+ echo FAIL: f 2
+ echo XPASS: xp
+ echo FAIL: f 3
+ echo FAIL: f 4
+ echo ERROR: e 1
+ echo PASS: p 2
+ echo ERROR: e 2
+END
+ do_recheck --fail
+ test ! -r a.run
+ test ! -r b.run
+ test ! -r c.run
+ test -f d.run
+ count_test_results total=11 pass=2 fail=4 xpass=1 xfail=0 skip=2 error=2
+
+ : Let us finally make d.test pass.
+ echo : > d.extra
+ do_recheck --pass
+ test ! -r a.run
+ test ! -r b.run
+ test ! -r c.run
+ test -f d.run
+ count_test_results total=1 pass=0 fail=0 xpass=0 xfail=0 skip=1 error=0
+
+ : All tests have been successful or skipped, nothing should be re-run.
+ do_recheck --pass
+ test ! -r a.run
+ test ! -r b.run
+ test ! -r c.run
+ test ! -r d.run
+ count_test_results total=0 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=0
+
+ cd $srcdir
+
+done
+
+:
diff --git a/t/test-driver-custom-multitest-recheck2.sh b/t/test-driver-custom-multitest-recheck2.sh
new file mode 100755
index 000000000..3e7add6d4
--- /dev/null
+++ b/t/test-driver-custom-multitest-recheck2.sh
@@ -0,0 +1,188 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Custom test drivers: try the "recheck" functionality with test protocols
+# that allow multiple testcases in a single test script. In particular,
+# check that this still works when we override $(TESTS) and $(TEST_LOGS)
+# at make runtime.
+# See also related tests 'test-driver-custom-multitest-recheck.test' and
+# 'parallel-tests-recheck-override.test'.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cp "$am_testauxdir"/trivial-test-driver . \
+ || fatal_ "failed to fetch auxiliary script trivial-test-driver"
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TEST_LOG_DRIVER = $(SHELL) $(srcdir)/trivial-test-driver
+TESTS = a.test b.test c.test
+END
+
+cat > a.test << 'END'
+#! /bin/sh
+echo PASS: 1
+echo PASS: 2
+: > a.run
+END
+
+cat > b.test << 'END'
+#! /bin/sh
+echo SKIP: b0
+if test -f b.ok; then
+ echo XFAIL: b1
+else
+ echo FAIL: b2
+fi
+: > b.run
+END
+
+cat > c.test << 'END'
+#! /bin/sh
+if test -f c.err; then
+ echo ERROR: xxx
+elif test -f c.ok; then
+ echo PASS: ok
+else
+ echo XPASS: xp
+fi
+: > c.run
+END
+
+chmod a+x *.test
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+for vpath in : false; do
+ if $vpath; then
+ mkdir build
+ cd build
+ srcdir=..
+ else
+ srcdir=.
+ fi
+
+ $srcdir/configure
+
+ : Run the tests for the first time.
+ $MAKE check >stdout && { cat stdout; Exit 1; }
+ cat stdout
+ # All the test scripts should have run.
+ test -f a.run
+ test -f b.run
+ test -f c.run
+ count_test_results total=5 pass=2 fail=1 xpass=1 xfail=0 skip=1 error=0
+
+ rm -f *.run
+
+ : An empty '$(TESTS)' or '$(TEST_LOGS)' means that no test should be run.
+ for var in TESTS TEST_LOGS; do
+ env "$var=" $MAKE -e recheck >stdout || { cat stdout; Exit 1; }
+ cat stdout
+ count_test_results total=0 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=0
+ test ! -r a.run
+ test ! -r b.run
+ test ! -r c.run
+ done
+ unset var
+
+ : a.test was successful the first time, no need to re-run it.
+ env TESTS=a.test $MAKE -e recheck >stdout \
+ || { cat stdout; Exit 1; }
+ cat stdout
+ count_test_results total=0 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=0
+ test ! -r a.run
+ test ! -r b.run
+ test ! -r c.run
+
+ : b.test failed, it should be re-run. And make it pass this time.
+ echo OK > b.ok
+ TEST_LOGS=b.log $MAKE -e recheck >stdout \
+ || { cat stdout; Exit 1; }
+ cat stdout
+ test ! -r a.run
+ test -f b.run
+ test ! -r c.run
+ count_test_results total=2 pass=0 fail=0 xpass=0 xfail=1 skip=1 error=0
+
+ rm -f *.run
+
+ : No need to re-run a.test or b.test anymore.
+ TEST_LOGS=b.log $MAKE -e recheck >stdout \
+ || { cat stdout; Exit 1; }
+ cat stdout
+ count_test_results total=0 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=0
+ test ! -r a.run
+ test ! -r b.run
+ test ! -r c.run
+ TESTS='a.test b.test' $MAKE -e recheck >stdout \
+ || { cat stdout; Exit 1; }
+ cat stdout
+ count_test_results total=0 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=0
+ test ! -r a.run
+ test ! -r b.run
+ test ! -r c.run
+
+ : No need to re-run a.test anymore, but c.test should be rerun,
+ : as it contained an XPASS. And this time, make it fail with
+ : an hard error.
+ # Use 'echo' here, since Solaris 10 /bin/sh would try to optimize
+ # a ':' away after the first iteration, even if it is redirected.
+ echo dummy > c.err
+ env TEST_LOGS='a.log c.log' $MAKE -e recheck >stdout \
+ && { cat stdout; Exit 1; }
+ cat stdout
+ count_test_results total=1 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=1
+ test ! -r a.run
+ test ! -r b.run
+ test -f c.run
+
+ rm -f *.run *.err
+
+ : c.test contained and hard error the last time, so it should be re-run.
+ : This time, make it pass
+ # Use 'echo', not ':'; see comments above for why.
+ echo dummy > c.ok
+ env TESTS='c.test a.test' $MAKE -e recheck >stdout \
+ || { cat stdout; Exit 1; }
+ cat stdout
+ count_test_results total=1 pass=1 fail=0 xpass=0 xfail=0 skip=0 error=0
+ test ! -r a.run
+ test ! -r b.run
+ test -f c.run
+
+ rm -f *.run *.err *.ok
+
+ : Nothing should be rerun anymore, as all tests have been eventually
+ : successful.
+ $MAKE recheck >stdout || { cat stdout; Exit 1; }
+ cat stdout
+ count_test_results total=0 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=0
+ test ! -r a.run
+ test ! -r b.run
+ test ! -r c.run
+
+ cd $srcdir
+
+done
+
+:
diff --git a/t/test-driver-custom-multitest.sh b/t/test-driver-custom-multitest.sh
new file mode 100755
index 000000000..c7959cd42
--- /dev/null
+++ b/t/test-driver-custom-multitest.sh
@@ -0,0 +1,172 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Custom test drivers: check that we can easily support test protocols
+# that allow multiple testcases in a single test script. This test not
+# only checks implementation details in Automake's custom test drivers
+# support, but also serves as a "usability test" for our APIs.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cp "$am_testauxdir"/trivial-test-driver . \
+ || fatal_ "failed to fetch auxiliary script trivial-test-driver"
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TEST_EXTENSIONS = .t
+T_LOG_DRIVER = $(SHELL) $(srcdir)/trivial-test-driver
+
+TESTS = \
+ pass.t \
+ fail.t \
+ fail2.t \
+ pass-fail.t \
+ pass4-skip.t \
+ pass3-skip2-xfail.t \
+ pass-xpass-fail-xfail-skip-error.t
+END
+
+cat > pass.t << 'END'
+echo %% pass %%
+echo PASS: pass
+END
+
+cat > fail.t << 'END'
+echo %% fail %%
+echo FAIL: fail
+END
+
+cat > fail2.t << 'END'
+echo %% fail2 %%
+echo FAIL: stdout >&1
+echo FAIL: stderr >&2
+echo :PASS: this should be ignored
+END
+
+cat > pass-fail.t << 'END'
+echo %% pass-fail %%
+echo 'FAIL: this fails :-('
+echo 'some randome message'
+echo 'some randome warning' >&2
+echo 'PASS: this passes :-)'
+echo 'INFO: blah'
+echo 'WARNING: blah blah' >&2
+END
+
+cat > pass4-skip.t << 'END'
+echo %% pass4-skip %%
+echo PASS: on stdout >&1
+echo PASS: on stderr >&2
+echo PASS: 3
+echo PASS: 4
+echo SKIP: 1
+echo this FAIL: should be ignored
+echo FAIL as should this
+exit 99
+END
+
+cat > pass3-skip2-xfail.t << 'END'
+echo %% pass4-skip2-xfail %%
+echo 'PASS: -v'
+echo 'PASS: --verbose'
+echo 'SKIP: Oops, unsupported system.'
+echo 'PASS: -#-#-#-'
+cp || echo "SKIP: cp cannot read users' mind" >&2
+mv || echo "XFAIL: mv cannot read users' mind yet"
+exit 127
+END
+
+cat > pass-xpass-fail-xfail-skip-error.t << 'END'
+echo PASS:
+echo FAIL:
+echo XFAIL:
+echo XPASS:
+echo SKIP:
+echo ERROR:
+echo %% pass-xpass-fail-xfail-skip-error %%
+END
+
+chmod a+x *.t
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+for vpath in : false; do
+ if $vpath; then
+ mkdir build
+ cd build
+ srcdir=..
+ else
+ srcdir=.
+ fi
+
+ $srcdir/configure
+
+ $MAKE check >stdout && { cat stdout; cat test-suite.log; Exit 1; }
+ cat stdout
+ cat test-suite.log
+ # Couple of sanity checks. These might need to be updated if the
+ # 'trivial-test-driver' script is changed.
+ $FGREP INVALID.NAME stdout test-suite.log && Exit 1
+ test -f BAD.LOG && Exit 1
+ test -f BAD.TRS && Exit 1
+ # These log files must all have been created by the testsuite.
+ cat pass.log
+ cat fail.log
+ cat fail2.log
+ cat pass-fail.log
+ cat pass4-skip.log
+ cat pass3-skip2-xfail.log
+ cat pass-xpass-fail-xfail-skip-error.log
+
+ count_test_results total=23 pass=10 fail=5 skip=4 xfail=2 xpass=1 error=1
+
+ tst=pass-xpass-fail-xfail-skip-error
+ grep "^PASS: $tst\.t, testcase 1" stdout
+ grep "^FAIL: $tst\.t, testcase 2" stdout
+ grep "^XFAIL: $tst\.t, testcase 3" stdout
+ grep "^XPASS: $tst\.t, testcase 4" stdout
+ grep "^SKIP: $tst\.t, testcase 5" stdout
+ grep "^ERROR: $tst\.t, testcase 6" stdout
+
+ # Check that the content of, and only of, the test logs with at least
+ # one failing test case has been copied into 'test-suite.log'. Note
+ # that test logs containing skipped or xfailed test cases are *not*
+ # copied into 'test-suite.log' -- a behaviour that deliberately differs
+ # from the one of the built-in Automake test drivers.
+ grep '%%' test-suite.log # For debugging.
+ grep '%% fail %%' test-suite.log
+ grep '%% fail2 %%' test-suite.log
+ grep '%% pass-fail %%' test-suite.log
+ grep '%% pass-xpass-fail-xfail-skip-error %%' test-suite.log
+ test `grep -c '%% ' test-suite.log` -eq 4
+
+ TESTS='pass.t pass3-skip2-xfail.t' $MAKE -e check >stdout \
+ || { cat stdout; cat test-suite.log; Exit 1; }
+ cat test-suite.log
+ cat stdout
+ count_test_results total=7 pass=4 fail=0 skip=2 xfail=1 xpass=0 error=0
+
+ cd $srcdir
+
+done
+
+:
diff --git a/t/test-driver-custom-no-extra-driver.sh b/t/test-driver-custom-no-extra-driver.sh
new file mode 100755
index 000000000..31000aff1
--- /dev/null
+++ b/t/test-driver-custom-no-extra-driver.sh
@@ -0,0 +1,64 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that auxiliary script 'test-driver' doesn't get needlessly
+# installed or referenced if it's not used, i.e., if the user has
+# defined his own '*LOG_DRIVER' variables.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.ac <<'END'
+AC_PROG_CC
+AC_CONFIG_FILES([sub1/Makefile sub2/Makefile])
+AC_SUBST([X_LOG_DRIVER], [none])
+AC_OUTPUT
+END
+
+mkdir sub1 sub2
+
+cat > Makefile.am <<'END'
+SUBDIRS = sub1 sub2
+LOG_DRIVER =
+TEST_LOG_DRIVER = :
+TESTS = foo bar.test
+END
+
+cat > sub1/Makefile.am <<'END'
+TEST_EXTENSIONS = .x .sh .pl
+SH_LOG_DRIVER = dummy1
+PL_LOG_DRIVER = dummy2
+TESTS = a.pl b.sh c.x
+END
+
+cat > sub2/Makefile.am <<'END'
+TEST_EXTENSIONS = .bar
+LOG_DRIVER = x
+BAR_LOG_DRIVER = y
+TESTS = 1 2.bar 3.test 4.t 5.tt $(check_PROGRAMS)
+check_PROGRAMS = p1 p2$(EXEEXT) p3.bar p4.suf
+END
+
+$ACLOCAL
+
+for opts in '' '--add-missing' '-a -c'; do
+ $AUTOMAKE $opts
+ $FGREP test-driver Makefile.in sub[12]/Makefile.in && Exit 1
+ find . | $FGREP test-driver && Exit 1
+ : For shells with busted 'set -e'.
+done
+
+:
diff --git a/t/test-driver-custom-xfail-tests.sh b/t/test-driver-custom-xfail-tests.sh
new file mode 100755
index 000000000..9a4e3fec5
--- /dev/null
+++ b/t/test-driver-custom-xfail-tests.sh
@@ -0,0 +1,166 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Custom test drivers: "abstract" XFAIL_TESTS support.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.ac <<'END'
+AC_SUBST([nihil], [])
+AC_SUBST([ac_xfail_tests], ['x5.test x6$(test_suffix)'])
+AC_CONFIG_FILES([sub1/Makefile sub2/Makefile])
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+SUBDIRS = . sub1 sub2
+TEST_LOG_DRIVER = $(srcdir)/td
+TESTS = pass.test xfail.test
+XFAIL_TESTS = xfail.test
+END
+
+mkdir sub1 sub2
+
+cat > sub1/Makefile.am <<END
+empty =
+
+TEST_LOG_DRIVER = \$(top_srcdir)/td
+
+# XFAIL_TESTS should gracefully handle TAB characters, and multiple
+# whitespaces.
+XFAIL_TESTS =\$(empty)${tab}x1.test x2.test${tab}x3.test${tab}\
+x4.test ${tab} x5.test x6.test${tab}\$(empty)
+
+TESTS = pass.test x1.test x2.test x3.test x4.test x5.test x6.test
+END
+
+cat > sub2/Makefile.am <<'END'
+AUTOMAKE_OPTIONS = -Wno-portability-recursive
+
+TEST_LOG_DRIVER = $(srcdir)/../td
+
+# XFAIL_TESTS should gracefully AC_SUBST @substitution@ and
+# make variables indirections.
+an_xfail_test = x1.test
+test_suffix = .test
+v0 = x3.test
+v1 = v
+v2 = 0
+XFAIL_TESTS = $(an_xfail_test) x2.test @nihil@ x3${test_suffix}
+XFAIL_TESTS += $($(v1)$(v2)) x4.test @ac_xfail_tests@
+
+TESTS = pass.test x1.test x2.test x3.test x4.test x5.test x6.test
+END
+
+cat > pass.test <<'END'
+#!/bin/sh
+exit 0
+END
+
+cat > xfail.test <<'END'
+#!/bin/sh
+exit 1
+END
+
+chmod a+x pass.test xfail.test
+
+cp pass.test sub1/pass.test
+cp pass.test sub2/pass.test
+
+for i in 1 2 3 4 5 6; do
+ cp xfail.test sub1/x$i.test
+ cp xfail.test sub2/x$i.test
+done
+
+cat > td <<'END'
+#! /bin/sh
+set -e; set -u
+test_name=INVALID
+log_file=/dev/null
+trs_file=/dev/null
+expect_failure=no
+while test $# -gt 0; do
+ case $1 in
+ --test-name) test_name=$2; shift;;
+ --expect-failure) expect_failure=$2; shift;;
+ --log-file) log_file=$2; shift;;
+ --trs-file) trs_file=$2; shift;;
+ # Ignored.
+ --color-tests) shift;;
+ --enable-hard-errors) shift;;
+ # Explicitly terminate option list.
+ --) shift; break;;
+ # Shouldn't happen
+ *) echo "$0: invalid option/argument: '$1'" >&2; exit 2;;
+ esac
+ shift
+done
+st=0
+"$@" || st=$?
+case $st,$expect_failure in
+ 0,no)
+ echo "PASS: $test_name" | tee "$log_file"
+ echo ":test-result: PASS" > "$trs_file"
+ ;;
+ 1,no)
+ echo "FAIL: $test_name" | tee "$log_file"
+ echo ":test-result: FAIL" > "$trs_file"
+ ;;
+ 0,yes)
+ echo "XPASS: $test_name" | tee "$log_file"
+ echo ":test-result: XPASS" > "$trs_file"
+ ;;
+ 1,yes)
+ echo "XFAIL: $test_name" | tee "$log_file"
+ echo ":test-result: XFAIL" > "$trs_file"
+ ;;
+ *)
+ echo "INTERNAL ERROR" >&2
+ exit 99
+ ;;
+esac
+END
+chmod a+x td
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+
+$MAKE check >stdout || { cat stdout; Exit 1; }
+cat stdout
+test `grep -c '^PASS:' stdout` -eq 3
+test `grep -c '^XFAIL:' stdout` -eq 13
+
+for dir in sub1 sub2; do
+ cd $dir
+ cp pass.test x1.test
+ cp x2.test pass.test
+ $MAKE check >stdout && { cat stdout; Exit 1; }
+ cat stdout
+ test "`cat pass.trs`" = ":test-result: FAIL"
+ test "`cat x1.trs`" = ":test-result: XPASS"
+ test "`cat x2.trs`" = ":test-result: XFAIL"
+ grep '^FAIL: pass\.test$' stdout
+ grep '^XPASS: x1\.test$' stdout
+ grep '^XFAIL: x2\.test$' stdout
+ count_test_results total=7 pass=0 xpass=1 fail=1 xfail=5 skip=0 error=0
+ cd ..
+done
+
+:
diff --git a/t/test-driver-custom.sh b/t/test-driver-custom.sh
new file mode 100755
index 000000000..60ce07418
--- /dev/null
+++ b/t/test-driver-custom.sh
@@ -0,0 +1,144 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Custom test drivers: per-extension test drivers.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+# Automake shouldn't match the '/test' in 'sub/test' as '.test' suffix.
+TESTS = 1.chk 2.test 3 4.c.chk 5.suf sub/test
+
+TEST_EXTENSIONS = .chk .test
+
+CHK_LOG_DRIVER = ./chk-wrapper
+TEST_LOG_DRIVER = $(SHELL) $(srcdir)/test-wrapper
+LOG_DRIVER = noext-wrapper
+
+AM_CHK_LOG_DRIVER_FLAGS = --am-chk
+CHK_LOG_DRIVER_FLAGS = --chk
+AM_TEST_LOG_DRIVER_FLAGS = -am-test
+TEST_LOG_DRIVER_FLAGS = -test
+AM_LOG_DRIVER_FLAGS = am
+LOG_DRIVER_FLAGS = _
+END
+
+mkdir sub bin
+PATH=`pwd`/bin$PATH_SEPARATOR$PATH; export PATH
+
+cat > wrapper.skel <<'END'
+#! /bin/sh
+set -e
+
+me=`echo "$0" | sed 's,^.*/,,'`
+if test -z "$me"; then
+ echo "$0: cannot determine program name" >&2
+ exit 99
+fi
+
+am_log_wflags='@am_log_wflags@'
+log_wflags='@log_wflags@'
+
+test_name=INVALID
+log_file=BAD.log
+trs_file=BAD.trs
+extra_opts=
+while test $# -gt 0; do
+ case $1 in
+ --test-name) test_name=$2; shift;;
+ --log-file) log_file=$2; shift;;
+ --trs-file) trs_file=$2; shift;;
+ # Ignored.
+ --expect-failure) shift;;
+ --color-tests) shift;;
+ --enable-hard-errors) shift;;
+ # Remembered in the same order they're passed in.
+ $am_log_wflags|$log_wflags) extra_opts="$extra_opts $1";;
+ # Explicitly terminate option list.
+ --) shift; break;;
+ # Shouldn't happen
+ *) echo "$0: invalid option/argument: '$1'" >&2; exit 2;;
+ esac
+ shift
+done
+
+echo "$me" "$test_name" $extra_opts > "$log_file"
+: > "$trs_file"
+
+exec "$@"
+exit 127
+END
+
+sed -e 's|@am_log_wflags@|--am-chk|' \
+ -e 's|@log_wflags@|--chk|' \
+ < wrapper.skel > chk-wrapper
+
+sed -e 's|@am_log_wflags@|-am-test|' \
+ -e 's|@log_wflags@|-test|' \
+ < wrapper.skel > test-wrapper
+
+sed -e 's|@am_log_wflags@|am|' \
+ -e 's|@log_wflags@|_|' \
+ < wrapper.skel > bin/noext-wrapper
+
+# 'test-wrapper' is deliberately not made executable.
+chmod a+x chk-wrapper bin/noext-wrapper
+
+# Not needed anymore.
+rm -f wrapper.skel
+
+cat > 1.chk << 'END'
+#! /bin/sh
+exit 0
+END
+chmod a+x 1.chk
+cp 1.chk 2.test
+cp 1.chk 3
+cp 1.chk 4.c.chk
+cp 1.chk 5.suf
+cp 1.chk sub/test
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+$MAKE
+VERBOSE=yes $MAKE check
+ls -l . sub
+
+test ! -r BAD.log
+test ! -r BAD.trs
+
+echo 'chk-wrapper 1.chk --am-chk --chk' > 1.exp
+echo 'test-wrapper 2.test -am-test -test' > 2.exp
+echo 'noext-wrapper 3 am _' > 3.exp
+echo 'chk-wrapper 4.c.chk --am-chk --chk' > 4.c.exp
+echo 'noext-wrapper 5.suf am _' > 5.suf.exp
+echo 'noext-wrapper sub/test am _' > sub/test.exp
+
+st=0
+for x in 1 2 3 4.c 5.suf sub/test; do
+ cat $x.log
+ diff $x.exp $x.log || st=1
+done
+
+Exit $st
diff --git a/t/test-driver-fail.sh b/t/test-driver-fail.sh
new file mode 100755
index 000000000..0eb226800
--- /dev/null
+++ b/t/test-driver-fail.sh
@@ -0,0 +1,65 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Custom test drivers: what happens when a test driver fails? Well,
+# "make check" should at least fail too, and the test-suite.log
+# shouldn't be created. Unfortunately, we cannot truly control also
+# the (non-)creation of individual test logs, since those are expected
+# to be created by the drivers themselves, and an ill-behaved driver
+# (like our dummy one in this test) might leave around a test log even
+# in case of internal failures.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.ac <<'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+TEST_LOG_DRIVER = ./oops
+TESTS = foo.test
+END
+
+cat > foo.test <<'END'
+#! /bin/sh
+exit 0
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+
+# The testsuite driver does not exist.
+$MAKE check && Exit 1
+test ! -f test-suite.log
+
+# The testsuite driver exists and create the test log files, but fails.
+
+cat > oops <<'END'
+#!/bin/sh
+: > foo.log
+echo 'Oops, I fail!' >&2
+exit 1
+END
+chmod a+x oops
+
+$MAKE check && Exit 1
+test ! -f test-suite.log
+
+:
diff --git a/t/test-driver-is-distributed.sh b/t/test-driver-is-distributed.sh
new file mode 100755
index 000000000..fb4e540af
--- /dev/null
+++ b/t/test-driver-is-distributed.sh
@@ -0,0 +1,94 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check regression of parallel-tests:
+# - 'test-driver' script not correctly distributed when TESTS is
+# defined in a subdir Makefile
+
+am_create_testdir=empty
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+ocwd=`pwd` || fatal_ "getting current working directory"
+
+do_check ()
+{
+ whereopts=$1 auxdir=$2
+ case $#,$whereopts in
+ 2,ac) ac_opts=parallel-tests am_code= ;;
+ 2,am) am_opts=parallel-tests ac_code= ;;
+ *) fatal_ "do_check: bad usage";;
+ esac
+ mkdir $whereopts
+ cd $whereopts
+ mkdir tests
+ unindent > configure.ac << END
+ AC_INIT([$me], [1.0])
+ AC_CONFIG_AUX_DIR([$auxdir])
+ AM_INIT_AUTOMAKE([$ac_opts])
+ AC_CONFIG_FILES([Makefile tests/Makefile])
+ AC_OUTPUT
+END
+ if test $auxdir = .; then
+ test_driver=test-driver
+ else
+ mkdir $auxdir
+ test_driver=$auxdir/test-driver
+ fi
+ # No 'AUTOMAKE_OPTIONS' in here -- purposely.
+ unindent > Makefile.am << END
+ SUBDIRS = tests
+ check-local: test-top
+ test-top: distdir
+ ls -l \$(distdir) \$(distdir)/* ;: For debugging.
+ test -f \$(distdir)/$test_driver
+ .PHONY: test-top
+END
+ unindent > tests/Makefile.am << END
+ AUTOMAKE_OPTIONS = $am_opts
+ check-local: test-sub
+ test-sub:
+ echo ' ' \$(DIST_COMMON) ' ' | grep '[ /]$test_driver '
+ TESTS = foo.test
+ EXTRA_DIST = \$(TESTS)
+END
+ unindent > tests/foo.test << 'END'
+ #!/bin/sh
+ exit 0
+END
+ chmod a+x tests/foo.test
+ $ACLOCAL
+ $AUTOCONF
+ $AUTOMAKE -a
+ ./configure
+ $MAKE test-top
+ cd tests
+ $MAKE test-sub
+ cd ..
+ $MAKE distcheck
+ # Try code path without automatic installation of required files.
+ mv -f Makefile.in Makefile.sav
+ mv -f tests/Makefile.in tests/Makefile.sav
+ $AUTOMAKE
+ diff Makefile.in Makefile.sav
+ diff tests/Makefile.in tests/Makefile.sav
+ :
+}
+
+do_check ac .
+do_check am build-aux
+
+:
diff --git a/t/test-driver-strip-vpath.sh b/t/test-driver-strip-vpath.sh
new file mode 100755
index 000000000..967018854
--- /dev/null
+++ b/t/test-driver-strip-vpath.sh
@@ -0,0 +1,98 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Custom test drivers: check that the test name passed to the test
+# driver has any VPATH prefix stripped.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+ocwd=`pwd` || fatal_ "cannot get current working directory"
+
+mkdir src build
+mv install-sh missing configure.ac src
+rm -f depcomp
+
+cd src
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+# The directories of the 'bar.test' and 'baz.test' tests are deliberately
+# called as the source directory, to verify that the VPATH-stripping code
+# doesn't get too easily confused.
+# The $(empty) are for eliciting VPATH rewrites on make implementations
+# that support it (e.g., Solaris make), to improve coverage.
+empty =
+TESTS = $(empty) foo.test src/bar.test ./src/baz.test $(empty)
+$(TESTS):
+TEST_LOG_DRIVER = $(srcdir)/checkstrip-driver
+EXTRA_DIST = checkstrip-driver
+END
+
+cat > checkstrip-driver <<'END'
+#! /bin/sh
+set -e
+while test $# -gt 0; do
+ case $1 in
+ --log-file) log_file=$2; shift;;
+ --trs-file) trs_file=$2; shift;;
+ --test-name) test_name=$2; shift;;
+ --expect-failure|--color-tests|--enable-hard-errors) shift;;
+ --) shift; break;;
+ *) echo "$0: invalid option/argument: '$1'" >&2; exit 2;;
+ esac
+ shift
+done
+echo "test name: $test_name" # For debugging.
+case $test_name in
+ foo.test|./foo.test|src/ba[rz].test|./src/ba[rz].test);;
+ *) exit 1;;
+esac
+echo dummy > "$log_file"
+echo dummy > "$trs_file"
+END
+chmod a+x checkstrip-driver
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+cd ..
+
+mkdir build1
+cd build1
+../src/configure
+# "$MAKE -n" is for debugging, should highlight any VPATH rewrite.
+$MAKE -n check || :
+$MAKE check
+cd ..
+
+mkdir build2
+cd build2
+"$ocwd"/src/configure
+# "$MAKE -n" is for debugging, should highlight any VPATH rewrite.
+$MAKE -n check || :
+$MAKE check
+cd ..
+
+cd src
+./configure
+$MAKE distcheck
+
+:
diff --git a/t/test-driver-trs-suffix-registered.sh b/t/test-driver-trs-suffix-registered.sh
new file mode 100755
index 000000000..0c3734f88
--- /dev/null
+++ b/t/test-driver-trs-suffix-registered.sh
@@ -0,0 +1,58 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# parallel-tests support: the following are registered with '.SUFFIXES':
+# - .log
+# - .trs (used by files that store test results and metadata)
+# - .test if $(TEST_EXTENSIONS) is not defined
+# - stuff in $(TEST_EXTENSIONS) otherwise
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+: > Makefile.am
+
+cat > 1.am << 'END'
+TESTS =
+END
+
+cat > 2.am << 'END'
+TEST_EXTENSIONS = .SH .abcdef
+TESTS =
+END
+
+: > test-driver
+
+$ACLOCAL
+
+$AUTOMAKE 1
+$AUTOMAKE 2
+
+sed -e 's/$/ /' 1.in > mk.1
+sed -e 's/$/ /' 2.in > mk.2
+
+grep '^\.SUFFIXES:' mk.1
+grep '^\.SUFFIXES:' mk.2
+
+for suf in test log trs; do
+ grep "^\\.SUFFIXES:.* \\.$suf " mk.1
+done
+
+for suf in SH abcdef log trs; do
+ grep "^\\.SUFFIXES:.* \\.$suf " mk.2
+done
+
+:
diff --git a/t/test-extensions-cond.sh b/t/test-extensions-cond.sh
new file mode 100755
index 000000000..81808033a
--- /dev/null
+++ b/t/test-extensions-cond.sh
@@ -0,0 +1,70 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Expose bug in conditional definition of TEST_EXTENSIONS.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AM_CONDITIONAL([COND], [:])
+AM_CONDITIONAL([COND2], [:])
+END
+
+$ACLOCAL
+
+cat > 1.am << 'END'
+TESTS =
+if COND
+## lineno 4
+TEST_EXTENSIONS = .foo
+endif
+END
+
+cat > 2.am << 'END'
+TESTS =
+## lineno 3
+TEST_EXTENSIONS = .foo
+if COND
+# Do nothing.
+else
+TEST_EXTENSIONS += .bar
+endif
+END
+
+cat > 3.am << 'END'
+TESTS =
+if COND
+if !COND2
+TESTS = x
+else
+## lineno 7
+TEST_EXTENSIONS = .foo
+endif
+endif
+END
+
+: > test-driver
+
+for i in 1 2 3; do
+ AUTOMAKE_fails $i
+ lineno=`sed -n 's/^## lineno //p' $i.am` \
+ && test 0 -lt "$lineno" \
+ || Exit 99
+ grep "^$i\\.am:$lineno:.*TEST_EXTENSIONS.*conditional content" stderr
+done
+
+:
diff --git a/t/test-extensions.sh b/t/test-extensions.sh
new file mode 100755
index 000000000..d2fc2dd06
--- /dev/null
+++ b/t/test-extensions.sh
@@ -0,0 +1,72 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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 that Automake diagnose invalid entries in TEST_EXTENSIONS,
+# and do not diagnose valid (albeit more unusual) ones.
+# See automake bug#9400.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.ac <<'END'
+AC_OUTPUT
+END
+
+$ACLOCAL
+$AUTOCONF
+
+valid_extensions='sh T t1 _foo BAR x_Y_z _'
+
+echo TESTS = > Makefile.am
+echo " $valid_extensions" \
+ | sed -e 's/ / ./g' -e 's/^/TEST_EXTENSIONS =/' >> Makefile.am
+cat Makefile.am # For debugging.
+
+$AUTOMAKE -a
+
+grep -i 'log' Makefile.in # For debugging.
+
+for lc in $valid_extensions; do
+ uc=`echo $lc | tr '[a-z]' '[A-Z]'`
+ $FGREP "\$(${uc}_LOG_COMPILER)" Makefile.in
+ grep "^${uc}_LOG_COMPILE =" Makefile.in
+ grep "^\.${lc}\.log:" Makefile.in
+done
+
+# The produced Makefile is not broken.
+./configure
+$MAKE all check
+
+cat > Makefile.am << 'END'
+TESTS = foo.test bar.sh
+TEST_EXTENSIONS = .test mu .x-y a-b .t.1 .sh .6c .0 .11 .= @suf@ .@ext@
+TEST_EXTENSIONS += .= .t33 .a@b _&_
+END
+
+AUTOMAKE_fails
+for suf in mu .x-y a-b .t.1 .6c .0 .11 @suf@ .@ext@ '.=' '_&_'; do
+ suf2=`printf '%s\n' "$suf" | sed -e 's/\./\\./'`
+ $EGREP "^Makefile\.am:2:.*invalid test extension.* $suf2( |$)" stderr
+done
+
+# Verify that we accept valid suffixes, even if intermixed with
+# invalid ones.
+$EGREP '\.(sh|test|t33)' stderr && Exit 1
+
+# Verify that we don't try to handle invalid suffixes.
+$EGREP '(LOG_COMPILER|non-POSIX var|bad character)' stderr && Exit 1
+
+:
diff --git a/t/test-harness-vpath-rewrite.sh b/t/test-harness-vpath-rewrite.sh
new file mode 100755
index 000000000..f0f71c66f
--- /dev/null
+++ b/t/test-harness-vpath-rewrite.sh
@@ -0,0 +1,58 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Check that our concurrent test harness is not subject to spurious VPATH
+# rewrites.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+LOG_COMPILER = true
+TESTS = x0 foo bar baz x1
+EXTRA_DIST = $(TESTS)
+END
+
+: > x0
+: > foo
+: > bar
+: > baz
+: > x1
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+mkdir build
+cd build
+../configure
+$MAKE check
+test -f test-suite.log
+test -f foo.log
+test -f foo.trs
+test -f bar.log
+test -f bar.trs
+test -f baz.log
+test -f baz.trs
+# We don't want VPATH rewrites, really.
+$MAKE check -n | $EGREP '\.\./(foo|bar|baz)( |$)' && Exit 1
+$MAKE distcheck
+
+:
diff --git a/t/test-log.sh b/t/test-log.sh
new file mode 100755
index 000000000..d400b52bc
--- /dev/null
+++ b/t/test-log.sh
@@ -0,0 +1,178 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check parallel-tests features:
+# - log file creation
+# - log file removal
+# - stdout and stderr of a test script go in its log file
+# - TEST_SUITE_LOG redefinition, at either automake or make time
+# - VERBOSE environment variable support
+# Keep in sync with 'tap-log.test'.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.ac <<END
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TESTS = pass.test skip.test xfail.test fail.test xpass.test error.test
+XFAIL_TESTS = xpass.test xfail.test
+TEST_SUITE_LOG = global.log
+END
+
+# Custom markers, for use in grepping checks.
+cmarker=::: # comment marker
+pmarker=%%% # plain maker
+
+cat > pass.test <<END
+#! /bin/sh
+echo "$pmarker pass $pmarker" >&2
+echo "# $cmarker pass $cmarker" >&2
+exit 0
+END
+
+cat > skip.test <<END
+#! /bin/sh
+echo "$pmarker skip $pmarker"
+echo "# $cmarker skip $cmarker"
+exit 77
+END
+
+cat > xfail.test <<END
+#! /bin/sh
+echo "$pmarker xfail $pmarker" >&2
+echo "# $cmarker xfail $cmarker" >&2
+exit 1
+END
+
+cat > fail.test <<END
+#! /bin/sh
+echo "$pmarker fail $pmarker"
+echo "# $cmarker fail $cmarker"
+exit 1
+END
+
+cat > xpass.test <<END
+#! /bin/sh
+echo "$pmarker xpass $pmarker" >&2
+echo "# $cmarker xpass $cmarker" >&2
+exit 0
+END
+
+cat > error.test <<END
+#! /bin/sh
+echo "$pmarker error $pmarker"
+echo "# $cmarker error $cmarker"
+exit 99
+END
+
+chmod a+x *.test
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+TEST_SUITE_LOG=my.log $MAKE -e check && Exit 1
+ls -l # For debugging.
+test ! -f test-suite.log
+test ! -f global.log
+test -f my.log
+st=0
+for result in pass fail xfail xpass skip error; do
+ cat $result.log # For debugging.
+ $FGREP "$pmarker $result $pmarker" $result.log || st=1
+ $FGREP "$cmarker $result $cmarker" $result.log || st=1
+done
+test $st -eq 0 || Exit 1
+cat my.log # For debugging.
+for result in xfail fail xpass skip error; do
+ cat $result.log # For debugging.
+ $FGREP "$pmarker $result $pmarker" my.log || st=1
+ $FGREP "$cmarker $result $cmarker" my.log || st=1
+done
+test `$FGREP -c "$pmarker" my.log` -eq 5
+test `$FGREP -c "$cmarker" my.log` -eq 5
+
+have_rst_section ()
+{
+ eqeq=`echo "$1" | sed 's/./=/g'`
+ # Assume $1 contains no RE metacharacters.
+ sed -n "/^$1$/,/^$eqeq$/p" $2 > got
+ (echo "$1" && echo "$eqeq") > exp
+ cat exp
+ cat got
+ diff exp got
+}
+
+# Passed test scripts shouldn't be mentioned in the global log.
+$EGREP ':.*[^x]pass' my.log && Exit 1
+# But failing (expectedly or not) and skipped ones should.
+have_rst_section 'SKIP: skip' my.log
+have_rst_section 'FAIL: fail' my.log
+have_rst_section 'XFAIL: xfail' my.log
+have_rst_section 'XPASS: xpass' my.log
+have_rst_section 'ERROR: error' my.log
+
+touch error2.log test-suite.log global.log
+TEST_SUITE_LOG=my.log $MAKE -e mostlyclean
+ls -l # For debugging.
+test ! -f my.log
+test ! -f pass.log
+test ! -f fail.log
+test ! -f xfail.log
+test ! -f xpass.log
+test ! -f skip.log
+test ! -f error.log
+# "make mostlyclean" shouldn't remove unrelated log files.
+test -f error2.log
+test -f test-suite.log
+test -f global.log
+
+rm -f *.log
+
+VERBOSE=yes $MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+cat global.log
+test ! -f my.log
+test ! -f test-suite.log
+# Check that VERBOSE causes the global testsuite log to be
+# emitted on stdout.
+out=`cat stdout`
+log=`cat global.log`
+case $out in *"$log"*) ;; *) Exit 1;; esac
+
+touch error2.log test-suite.log my.log
+$MAKE clean
+ls -l # For debugging.
+test ! -f global.log
+test ! -f pass.log
+test ! -f fail.log
+test ! -f xfail.log
+test ! -f xpass.log
+test ! -f skip.log
+test ! -f error.log
+# "make clean" shouldn't remove unrelated log files.
+test -f error2.log
+test -f test-suite.log
+test -f my.log
+
+rm -f *.log
+
+:
diff --git a/t/test-logs-repeated.sh b/t/test-logs-repeated.sh
new file mode 100755
index 000000000..d75bbcb15
--- /dev/null
+++ b/t/test-logs-repeated.sh
@@ -0,0 +1,45 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check parallel-tests features:
+# - $(TESTS_LOGS) can end up holding duplicated entries
+# Such behaviour can be useful for projects that want to verify that
+# different test scripts don't end up sharing the same log file.
+# (Automake itself is such a project, BTW ;-)
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.ac <<END
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TEST_EXTENSIONS = .sh .test .bar
+TESTS = foo.sh mu.test foo.test foo.bar
+.PHONY: verify
+verify:
+ is $(TEST_LOGS) == foo.log mu.log foo.log foo.log
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+$MAKE verify
+
+:
diff --git a/t/test-metadata-global-log.sh b/t/test-metadata-global-log.sh
new file mode 100755
index 000000000..b10f481d2
--- /dev/null
+++ b/t/test-metadata-global-log.sh
@@ -0,0 +1,147 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Custom test drivers and parallel-tests harness: check the documented
+# semantics for deciding when the content of a test log file should be
+# copied in the global test-suite.log file. Currently, this is done
+# with the use of the reStructuredText field ':copy-in-global-log:' in
+# the associated '.trs' files.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TEST_LOG_DRIVER = ./passthrough-driver
+TEST_LOG_COMPILER = $(SHELL) -e
+END
+
+cat > passthrough-driver <<'END'
+#!/bin/sh
+set -e; set -u;
+while test $# -gt 0; do
+ case $1 in
+ --log-file) log_file=$2; shift;;
+ --trs-file) trs_file=$2; shift;;
+ --test-name) test_name=$2; shift;;
+ --expect-failure|--color-tests|--enable-hard-errors) shift;;
+ --) shift; break;;
+ *) echo "$0: invalid option/argument: '$1'" >&2; exit 2;;
+ esac
+ shift
+done
+echo "$test_name: RUN"
+"$@" >$log_file 2>&1 5>$trs_file
+END
+chmod a+x passthrough-driver
+
+# The ':test-result:' and ':recheck:' fields and the first line of the
+# log file should be be irrelevant for the decision of whether a test
+# output is to be copied in the 'test-suite.log'.
+
+cat > no-1.test <<END
+echo :test-result: SKIP >&5
+echo :copy-in-global-log: no >&5
+echo :test-result: FAIL >&5
+echo :test-result: XPASS >&5
+echo not seen 1
+END
+
+# In the last line, with leading and trailing whitespace in the value.
+cat > no-2.test <<END
+echo ":test-result: FAIL" >&5
+echo "not seen 2"
+echo ":recheck: yes" >&5
+echo ":copy-in-global-log:$tab $tab no $tab" >&5
+END
+
+for RES in XPASS FAIL XFAIL SKIP ERROR UNKNOWN; do
+ unindent > $RES.test <<END
+ echo :test-result: $RES >&5
+ echo :copy-in-global-log: no >&5
+ echo not seen $RES
+END
+done
+
+# In the first line, with no whitespace.
+cat > no-3.test <<END
+echo :copy-in-global-log:no >&5
+echo ":test-result: FAIL" >&5
+echo "not seen 3"
+END
+
+# Leading whitespace before the field.
+cat > no-4.test <<END
+echo ":test-result: FAIL" >&5
+echo " $tab $tab$tab :copy-in-global-log: no" >&5
+echo "not seen 4"
+END
+
+cat > yes-1.test <<END
+echo :test-result: PASS >&5
+echo :copy-in-global-log: yes >&5
+echo seen yes 1
+END
+
+# A lacking ':copy-in-global-log:' implies that the content of
+# the log file should be copied.
+cat > yes-2.test <<END
+echo :test-result: PASS >&5
+echo seen yes 2
+END
+
+# Three corner cases.
+
+cat > corn-1.test <<END
+echo seen corn 1
+echo ':copy-in-global-log:' >&5
+END
+
+cat > corn-2.test <<END
+echo seen corn 2
+echo '$tab $tab$tab' >&5
+END
+
+cat > corn-3.test <<'END'
+echo seen corn 31
+echo ':copy-in-global-log:#@%!' >&5
+echo seen corn 32
+END
+
+echo TESTS = *.test >> Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+
+# We don't care about the exit status of "make check" here, that
+# should be checked in other tests.
+$MAKE check || :
+cat test-suite.log
+grep '^seen yes 1$' test-suite.log
+grep '^seen yes 2$' test-suite.log
+grep '^seen corn 1$' test-suite.log
+grep '^seen corn 2$' test-suite.log
+grep '^seen corn 31$' test-suite.log
+grep '^seen corn 32$' test-suite.log
+$FGREP 'not seen' test-suite.log && Exit 1
+
+:
diff --git a/t/test-metadata-global-result.sh b/t/test-metadata-global-result.sh
new file mode 100755
index 000000000..b2474449c
--- /dev/null
+++ b/t/test-metadata-global-result.sh
@@ -0,0 +1,196 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Parallel testsuite harness: check APIs for the registering the
+# "global test result" in '*.trs' files, as documented in the automake
+# manual.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TEST_EXTENSIONS = .test .x
+TEST_LOG_DRIVER = ./dummy-driver
+X_LOG_DRIVER = ./dummy-driver
+TESTS = foo.test zar-doz.test
+END
+
+cat > dummy-driver <<'END'
+#! /bin/sh
+set -e; set -u
+while test $# -gt 0; do
+ case $1 in
+ --log-file) log_file=$2; shift;;
+ --trs-file) trs_file=$2; shift;;
+ --test-name) test_name=$2; shift;;
+ --expect-failure|--color-tests|--enable-hard-errors) shift;;
+ --) shift; break;;
+ *) echo "$0: invalid option/argument: '$1'" >&2; exit 2;;
+ esac
+ shift
+done
+echo logloglog > $log_file
+cp $1 $trs_file
+END
+chmod a+x dummy-driver
+
+# Do this in a subroutine to avoid quoting problem in the backticked
+# command substitution below.
+get_escaped_line()
+{
+ sed -e 's,[$^/\\\.],\\&,g' -e 1q "$@"
+}
+
+have_result ()
+{
+ cat > exp; echo >> exp; echo logloglog >> exp
+ eline=`get_escaped_line exp`
+ sed -n -e "/^$eline$/,/^logloglog$/p" test-suite.log > got
+ cat exp; cat got
+ diff exp got
+}
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+
+: Basic checks.
+
+echo :global-test-result: PASS > foo.test
+echo :global-test-result: ERROR > zar-doz.x
+
+$MAKE check
+cat test-suite.log
+
+have_result <<END
+PASS: foo
+=========
+END
+
+have_result <<END
+ERROR: zar-doz
+==============
+END
+
+: Try usage documented in the manual.
+
+echo :global-test-result: PASS/SKIP > foo.test
+echo :global-test-result: ALMOST PASSED > zar-doz.x
+
+$MAKE check
+cat test-suite.log
+
+have_result <<END
+PASS/SKIP: foo
+==============
+END
+
+have_result <<END
+ALMOST PASSED: zar-doz
+======================
+END
+
+: Fields ':test-result:' does not interfere with the global test result.
+
+cat > foo.test << 'END'
+:test-result: FAIL
+:global-test-result: PASS
+:test-result: ERROR
+END
+
+cat > zar-doz.x << 'END'
+:global-test-result: FAIL
+:test-result: SKIP
+:test-result: XFAIL
+END
+
+$MAKE check && Exit 1
+cat test-suite.log
+
+have_result <<END
+PASS: foo
+=========
+END
+
+have_result <<END
+FAIL: zar-doz
+=============
+END
+
+: What happens when ':global-test-result:' is absent.
+
+cat > foo.test << 'END'
+:test-result: PASS
+:test-result: ERROR
+END
+: > zar-doz.x
+
+$MAKE check && Exit 1
+cat test-suite.log
+
+have_result <<END
+RUN: foo
+========
+END
+
+have_result <<END
+RUN: zar-doz
+============
+END
+
+# Leading and trailing whitespace gets eaten/normalized.
+
+echo ":global-test-result:SKIP${tab} ${tab}${tab}" > foo.test
+echo ":global-test-result:${tab} ${tab}XFAIL ${tab} " > zar-doz.x
+
+$MAKE check
+cat test-suite.log
+
+have_result <<END
+SKIP: foo
+=========
+END
+
+have_result <<END
+XFAIL: zar-doz
+==============
+END
+
+# Whitespaces before and after ':global-test-result:' are handled OK.
+
+echo " $tab:global-test-result:PASS" > foo.test
+echo "${tab}${tab}:global-test-result:${tab} ${tab}SKIP" > zar-doz.x
+
+$MAKE check
+cat test-suite.log
+
+have_result <<END
+PASS: foo
+=========
+END
+
+have_result <<END
+SKIP: zar-doz
+=============
+END
+
+:
diff --git a/t/test-metadata-recheck.sh b/t/test-metadata-recheck.sh
new file mode 100755
index 000000000..0a7a7ccb4
--- /dev/null
+++ b/t/test-metadata-recheck.sh
@@ -0,0 +1,164 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Test the "make recheck" semantics for custom test drivers, as documented
+# in the Automake manual.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+LOG_DRIVER = ./dummy-driver
+TEST_EXTENSIONS =
+TESTS =
+END
+
+#
+# Tests to be re-run by "make recheck"
+#
+
+: > y-1
+echo "foo bar" > y-2
+echo ":recheck:" > y-3
+echo ":recheck:yes" > y-4
+echo ":recheck: who cares" > y-5
+echo ":recheck: $tab y" > y-6
+echo ":recheck: yeah!$tab$tab " > y-7
+cat > y-10 <<END
+:foo:
+:recheck: ???
+END
+cat > y-11 <<END
+:recheck: YES
+:foo:
+END
+cat > y-12 <<END
+foo
+:recheck:yes
+
+bar
+zardoz
+END
+
+echo " $tab $tab$tab :recheck: yes" > y-8
+
+# The :test-result: fields and the fist line of the log should be
+# irrelevant for the decision of whether "make recheck" should or
+# should not re-run a test.
+
+echo ":test-result: PASS" > y-100
+
+echo "PASS: y-101"
+
+cat > y-102 <<END
+PASS: y-102
+===========
+
+:test-result: PASS
+END
+
+#
+# Tests *not* to be re-run by "make recheck"
+#
+
+echo ":recheck:no" > n-1
+echo ":recheck: no " > n-2
+echo ":recheck: $tab no" > n-3
+echo ":recheck: no $tab$tab " > n-4
+cat > n-5 <<END
+:foo:
+:recheck:no
+END
+cat > n-6 <<END
+:recheck: no
+:foo:
+END
+cat > n-7 <<END
+foo
+:recheck: no$tab$tab
+
+bar
+zardoz
+END
+
+echo " $tab $tab$tab :recheck: no" > n-8
+
+# The :test-result: fields should be irrelevant for the decision of
+# whether "make recheck" should or should not re-run a test.
+cat > n-100 <<END
+:test-result: FAIL
+:test-result: XPASS
+:test-result: ERROR
+:test-result: UNKNOWN
+:recheck: no
+END
+
+rechecked=`echo y-[0-9]*`
+
+for t in [yn]-[0-9]*; do echo $t; done \
+ | sed 's/.*/TESTS += &/' >> Makefile.am
+
+cat Makefile.am # For debugging.
+
+cat > dummy-driver <<'END'
+#!/bin/sh
+set -e; set -u
+while test $# -gt 0; do
+ case $1 in
+ --log-file) log_file=$2; shift;;
+ --trs-file) trs_file=$2; shift;;
+ --test-name) test_name=$2; shift;;
+ --expect-failure|--color-tests|--enable-hard-errors) shift;;
+ --) shift; break;;
+ *) echo "$0: invalid option/argument: '$1'" >&2; exit 2;;
+ esac
+ shift
+done
+: > $test_name.run
+: > $log_file
+cp $1 $trs_file
+END
+chmod a+x dummy-driver
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+
+# The ':test-result:' fields should be ignored by "make recheck",
+# but should cause the testsuite report to detect errors.
+$MAKE check && Exit 1
+ls -l
+for t in $tests; do test -f $t.run; done
+rm -f *.run
+
+# But now the tests that actually get re-run have only ':test-result:'
+# fields indicating success, so "make recheck" must pass. Still, the
+# next "make recheck" call should still re-run the same set of tests.
+for iteration in 1 2; do
+ $MAKE recheck
+ ls -l
+ for t in $rechecked; do test -f $t.run; done
+ find . -name 'n-*.run' | grep . && Exit 1
+ : For shells with busted 'set -e'.
+done
+
+:
diff --git a/t/test-metadata-results.sh b/t/test-metadata-results.sh
new file mode 100755
index 000000000..5978f7f25
--- /dev/null
+++ b/t/test-metadata-results.sh
@@ -0,0 +1,176 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Parallel testsuite harness: check APIs for the registering of test
+# results in '*.trs' files, as documented in the automake manual.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TEST_LOG_DRIVER = ./dummy-driver
+TESTS = foo.test bar.test
+END
+
+cat > dummy-driver <<'END'
+#! /bin/sh
+set -e; set -u
+while test $# -gt 0; do
+ case $1 in
+ --log-file) log_file=$2; shift;;
+ --trs-file) trs_file=$2; shift;;
+ --test-name) test_name=$2; shift;;
+ --expect-failure|--color-tests|--enable-hard-errors) shift;;
+ --) shift; break;;
+ *) echo "$0: invalid option/argument: '$1'" >&2; exit 2;;
+ esac
+ shift
+done
+: > $log_file
+cp $1 $trs_file
+END
+chmod a+x dummy-driver
+
+mk_check ()
+{
+ st=0
+ $MAKE check >stdout || st=$?
+ cat stdout
+ # Our dummy driver make no testsuite progress report.
+ grep ': .*\.test' stdout && Exit 1
+ # Nor it writes to the log files.
+ test -s foo.log && Exit 1
+ test -s bar.log && Exit 1
+ return $st
+}
+
+# This must be different from the one defined in 'test/defs', as that
+# assumes that the driver does proper testsuite progress reporting.
+count_test_results ()
+{
+ total=ERR pass=ERR fail=ERR xpass=ERR xfail=ERR skip=ERR error=ERR
+ eval "$@"
+ st=0
+ grep "^# TOTAL: *$total$" stdout || rc=1
+ grep "^# PASS: *$pass$" stdout || rc=1
+ grep "^# XFAIL: *$xfail$" stdout || rc=1
+ grep "^# SKIP: *$skip$" stdout || rc=1
+ grep "^# FAIL: *$fail$" stdout || rc=1
+ grep "^# XPASS: *$xpass$" stdout || rc=1
+ grep "^# ERROR: *$error$" stdout || rc=1
+ test $st -eq 0 || Exit 1
+}
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+
+# Basic checks. Also that that ':global-test-result:' fields and
+# "old-style" directives with format "RESULT: test-name" are now ignored.
+
+: > foo.test
+echo blah blah blah > bar.test
+mk_check
+count_test_results total=0 pass=0 fail=0 xpass=0 xfail=0 skip=0 error=0
+
+cat > foo.test <<END
+:test-global-result: PASS
+:test-result: FAIL
+END
+cat > bar.test <<END
+:test-result: SKIP
+:test-global-result: ERROR
+END
+mk_check && Exit 1
+count_test_results total=2 pass=0 fail=1 xpass=0 xfail=0 skip=1 error=0
+
+cat > foo.test <<END
+FAIL: foo.test
+:test-result: PASS
+:test-global-result: XPASS
+END
+echo ERROR: bar.test > bar.test
+mk_check
+count_test_results total=1 pass=1 fail=0 xpass=0 xfail=0 skip=0 error=0
+
+cat > foo.test <<END
+:test-global-result: SKIP
+:test-result: FAIL
+END
+cat > bar.test <<END
+:test-global-result: PASS
+END
+mk_check && Exit 1
+count_test_results total=1 pass=0 fail=1 xpass=0 xfail=0 skip=0 error=0
+
+cat > foo.test <<END
+:test-result: XFAIL
+:test-result: PASS
+:test-result: SKIP
+END
+cat > bar.test <<END
+:test-result: SKIP
+:test-result: PASS
+:test-result: SKIP
+:test-result: PASS
+:test-result: PASS
+END
+mk_check
+count_test_results total=8 pass=4 fail=0 xpass=0 xfail=1 skip=3 error=0
+
+# Check that all results expected to be supported are *really* supported.
+
+cat > foo.test <<END
+:test-result: PASS
+:test-result: SKIP
+:test-result: XFAIL
+:test-result: FAIL
+:test-result: XPASS
+:test-result: ERROR
+END
+: > bar.test
+mk_check && Exit 1
+count_test_results total=6 pass=1 fail=1 xpass=1 xfail=1 skip=1 error=1
+
+cp foo.test bar.test
+mk_check && Exit 1
+count_test_results total=12 pass=2 fail=2 xpass=2 xfail=2 skip=2 error=2
+
+# Check that we are liberal w.r.t. whitespace use.
+
+: > foo.test
+: > bar.test
+for RESULT in PASS FAIL XPASS XFAIL SKIP ERROR; do
+ sed -e 's/^ *//' -e 's/|//g' >> foo.test <<END
+ |:test-result:$RESULT|
+ |:test-result: $tab $RESULT|
+ |:test-result:$RESULT $tab|
+ |:test-result:$tab$tab $RESULT$tab $tab |
+END
+ echo " $tab $tab$tab :test-result: $RESULT" >> bar.test
+done
+cat foo.test # For debugging.
+cat bar.test # Likewise.
+mk_check && Exit 1
+count_test_results total=30 pass=5 fail=5 xpass=5 xfail=5 skip=5 error=5
+
+:
diff --git a/t/test-missing.sh b/t/test-missing.sh
new file mode 100755
index 000000000..586190fb2
--- /dev/null
+++ b/t/test-missing.sh
@@ -0,0 +1,72 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# parallel-tests:
+# - non-existent scripts listed in TESTS get diagnosed
+# See also related test 'test-missing2.test'.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TESTS = ok.test zardoz.test
+TEST_LOG_COMPILER = true
+END
+
+: > ok.test
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+$MAKE check >output 2>&1 && { cat output; Exit 1; }
+cat output
+test -f ok.log
+grep '^PASS: ok\.test' output
+$FGREP 'zardoz.log' output
+test ! -f test-suite.log
+
+TESTS='zardoz2.test' $MAKE -e check >output 2>&1 \
+ && { cat output; Exit 1; }
+cat output
+$FGREP 'zardoz2.log' output
+test ! -f test-suite.log
+
+TEST_LOGS='zardoz3.log' $MAKE -e check >output 2>&1 \
+ && { cat output; Exit 1; }
+cat output
+$FGREP 'zardoz3.log' output
+test ! -f test-suite.log
+
+# The errors should persist even after 'test-suite.log'
+# has been created.
+
+: > zardoz.test
+$MAKE check
+rm -f zardoz.test
+
+$MAKE check >output 2>&1 && { cat output; Exit 1; }
+cat output
+$FGREP 'zardoz.log' output
+test ! -f test-suite.log
+
+:
diff --git a/t/test-missing2.sh b/t/test-missing2.sh
new file mode 100755
index 000000000..e511a8b4e
--- /dev/null
+++ b/t/test-missing2.sh
@@ -0,0 +1,54 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# parallel-tests:
+# - non-existent scripts listed in TESTS get diagnosed, even when
+# all the $(TEST_LOGS) have a dummy dependency.
+# See also related test 'test-missing.test'.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TESTS = foobar1.test foobar2.test
+$(TEST_LOGS):
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+$MAKE foobar1.log foobar2.log || Exit 99
+test ! -f foobar1.log || Exit 99
+test ! -f foobar1.trs || Exit 99
+test ! -f foobar2.log || Exit 99
+test ! -f foobar2.trs || Exit 99
+
+$MAKE check >output 2>&1 && { cat output; Exit 1; }
+cat output
+grep 'test-suite\.log.*foobar1\.log' output
+grep 'test-suite\.log.*foobar1\.trs' output
+grep 'test-suite\.log.*foobar2\.log' output
+grep 'test-suite\.log.*foobar2\.trs' output
+test ! -f test-suite.log
+
+:
diff --git a/t/test-trs-basic.sh b/t/test-trs-basic.sh
new file mode 100755
index 000000000..a82d260bd
--- /dev/null
+++ b/t/test-trs-basic.sh
@@ -0,0 +1,158 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check parallel harness features:
+# - creation and removal of '.trs' auxiliary files
+# - check some internals regarding the use of '.trs' files.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.ac <<END
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TEST_EXTENSIONS = .sh .test
+TESTS = foo.test bar.sh sub/zardoz.test
+TEST_LOG_COMPILER = $(SHELL)
+SH_LOG_COMPILER = $(SHELL)
+
+## Used to check some internal details. And yes, the quotes around
+## '$bases' are deliberate: they check for whitespace normalization.
+tb:
+ $(am__set_TESTS_bases); echo "$$bases" > $@
+END
+
+cat > foo.test << 'END'
+#! /bin/sh
+exit $FOO_STATUS
+END
+: > bar.sh
+mkdir sub
+: > sub/zardoz.test
+
+FOO_STATUS=0; export FOO_STATUS
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+
+#
+# Check some internal details first.
+#
+
+for vpath in : false; do
+
+ if $vpath; then
+ srcdir=..
+ mkdir build
+ cd build
+ else
+ srcdir=.
+ fi
+
+ $srcdir/configure
+
+ $MAKE tb
+ test x"`cat tb`" = x"foo bar sub/zardoz"
+ rm -f tb
+ # Please don't change the order of the stuff in TESTS, below.
+ TESTS='foo.test foo2.sh foo-log foolog.test a.log.b.sh 0.exe' $MAKE -e tb
+ test x"`cat tb`" = x"foo foo2 foo-log foolog a.log.b 0.exe"
+ rm -f tb
+
+ cd $srcdir
+
+done
+
+#
+# The 'test-suite.stamp' file and the '.trs' files get created by
+# "make check" and removed by "make clean" and "make mostlyclean".
+#
+
+: > unrelated.trs
+: > sub/foo.trs
+
+$MAKE check
+test -f foo.trs
+test -f bar.trs
+test -f sub/zardoz.trs
+$MAKE clean
+test ! -f foo.trs
+test ! -f bar.trs
+test ! -f sub/zardoz.trs
+# Unrelated '.trs' files shouldn't be removed.
+test -f unrelated.trs
+test -f sub/foo.trs
+
+# The files should be properly created in case of testsuite failure too.
+FOO_STATUS=1 $MAKE check && Exit 1
+test -f foo.trs
+test -f bar.trs
+test -f sub/zardoz.trs
+$MAKE mostlyclean
+test ! -f foo.trs
+test ! -f bar.trs
+test ! -f sub/zardoz.trs
+# Unrelated '.trs' files shouldn't be removed.
+test -f unrelated.trs
+test -f sub/foo.trs
+
+#
+# Try with a subset of TESTS.
+#
+
+TESTS=foo.test $MAKE -e check
+test -f foo.trs
+test ! -f bar.trs
+test ! -f sub/zardoz.trs
+$MAKE clean
+test ! -f foo.trs
+TESTS='foo.test bar.sh' $MAKE -e check
+test -f foo.trs
+test -f bar.trs
+test ! -f sub/zardoz.trs
+# "make clean" shouldn't remove '.trs' files for tests not in $(TESTS).
+TESTS=bar.sh $MAKE -e clean
+test -f foo.trs
+test ! -f bar.trs
+
+$MAKE clean
+
+#
+# Try with a subset of TEST_LOGS.
+#
+
+TEST_LOGS=sub/zardoz.log $MAKE -e check
+test ! -f foo.trs
+test ! -f bar.trs
+test -f sub/zardoz.trs
+$MAKE clean
+test ! -f sub/zardoz.trs
+TEST_LOGS='foo.log bar.log' $MAKE -e check
+test -f foo.trs
+test -f bar.trs
+test ! -f sub/zardoz.trs
+# "make clean" shouldn't remove '.trs' files for tests whose log
+# is not in $(TEST_LOGS).
+TEST_LOGS=foo.log $MAKE -e clean
+test ! -f foo.trs
+test -f bar.trs
+test ! -f sub/zardoz.trs
+
+:
diff --git a/t/test-trs-recover.sh b/t/test-trs-recover.sh
new file mode 100755
index 000000000..3632f61f7
--- /dev/null
+++ b/t/test-trs-recover.sh
@@ -0,0 +1,167 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check parallel harness features:
+# - recovery from deleted '.trs' files, in various scenarios
+# This test is complex and tricky, but that's acceptable since we are
+# testing semantics that are potentially complex and tricky.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.ac <<END
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TESTS = foo.test bar.test baz.test
+TEST_LOG_COMPILER = $(SHELL)
+END
+
+# Creative quoting below to please maintainer-check.
+echo exit '$TEST_STATUS' > foo.test
+echo exit '$TEST_STATUS' > bar.test
+: > baz.test
+
+TEST_STATUS=0; export TEST_STATUS
+
+# Slower and possible overkill in some situations, but also clearer
+# and safer.
+update_stamp () { $sleep && touch stamp && $sleep; }
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+: Create the required log files.
+$MAKE check
+
+: Recreate by hand.
+rm -f foo.trs bar.trs baz.trs
+$MAKE foo.trs
+test -f foo.trs
+test ! -f bar.trs
+test ! -f baz.trs
+
+: Recreate by hand, several at the same time.
+rm -f foo.trs bar.trs baz.trs
+$MAKE foo.trs bar.trs
+test -f foo.trs
+test -f bar.trs
+test ! -f baz.trs
+
+: Recreate by hand, with a failing test.
+rm -f foo.trs bar.trs
+TEST_STATUS=1 $MAKE bar.trs baz.trs >stdout || { cat stdout; Exit 1; }
+cat stdout
+test ! -f foo.trs
+test -f bar.trs
+test -f baz.trs
+grep '^FAIL: bar\.test' stdout
+$EGREP '^(baz|foo)\.test' stdout && Exit 1
+
+: Recreate with a sweeping "make check", and ensure that also up-to-date
+: '.trs' files are remade.
+update_stamp
+rm -f foo.trs bar.trs
+$MAKE check
+test -f foo.trs
+test -f bar.trs
+is_newest baz.trs stamp
+
+: Recreate with a sweeping "make check" with failing tests. Again,
+: ensure that also up-to-date '.trs' files are remade -- this time we
+: grep the "make check" output verify that.
+rm -f foo.trs bar.trs
+TEST_STATUS=1 $MAKE check >stdout && { cat stdout; Exit 1; }
+test -f foo.trs
+test -f bar.trs
+grep '^FAIL: foo\.test' stdout
+grep '^FAIL: bar\.test' stdout
+grep '^PASS: baz\.test' stdout
+
+: Recreate with a "make check" with redefined TESTS.
+rm -f foo.trs bar.trs baz.trs
+TESTS=foo.test $MAKE -e check
+test -f foo.trs
+test ! -f bar.trs
+test ! -f baz.trs
+
+: Recreate with a "make check" with redefined TEST_LOGS.
+rm -f foo.trs bar.trs baz.trs
+TEST_LOGS=bar.log $MAKE -e check
+test ! -f foo.trs
+test -f bar.trs
+test ! -f baz.trs
+
+: Interactions with "make recheck" are OK.
+rm -f foo.trs bar.trs baz.log baz.trs
+$MAKE recheck >stdout || { cat stdout; Exit 1; }
+cat stdout
+test -f foo.trs
+test -f bar.trs
+test ! -f baz.trs
+test ! -f baz.log
+grep '^PASS: foo\.test' stdout
+grep '^PASS: bar\.test' stdout
+grep 'baz\.test' stdout && Exit 1
+count_test_results total=2 pass=2 fail=0 xpass=0 xfail=0 skip=0 error=0
+
+: Setup for the next check.
+$MAKE check
+test -f foo.trs
+test -f bar.trs
+test -f baz.trs
+
+: Recreate by remaking the global test log, and ensure that up-to-date
+: '.trs' files are *not* remade.
+update_stamp
+rm -f foo.trs bar.trs test-suite.log
+$MAKE test-suite.log >stdout || { cat stdout; Exit 1; }
+cat stdout
+grep '^PASS: foo\.test' stdout
+grep '^PASS: bar\.test' stdout
+grep 'baz\.test' stdout && Exit 1
+stat *.trs *.log stamp || : # For debugging.
+# Check that make has updated what it needed to, but no more.
+test -f foo.trs
+test -f bar.trs
+is_newest stamp baz.trs
+is_newest test-suite.log foo.trs bar.trs
+
+: Setup for the next check.
+$MAKE check
+test -f foo.trs
+test -f bar.trs
+test -f baz.trs
+
+: Interactions with lazy test reruns are OK.
+rm -f foo.trs
+update_stamp
+touch bar.test
+RECHECK_LOGS= $MAKE -e check >stdout || { cat stdout; Exit 1; }
+cat stdout
+# Check that make has updated what it needed to, but no more.
+test -f foo.trs
+is_newest bar.trs bar.test
+is_newest stamp baz.trs
+grep '^PASS: foo\.test' stdout
+grep '^PASS: bar\.test' stdout
+grep 'baz\.test' stdout && Exit 1
+
+:
diff --git a/t/test-trs-recover2.sh b/t/test-trs-recover2.sh
new file mode 100755
index 000000000..97268703d
--- /dev/null
+++ b/t/test-trs-recover2.sh
@@ -0,0 +1,133 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check parallel harness features:
+# - recovery from unreadable '.trs' files, in various scenarios
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.ac <<END
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TESTS = foo.test bar.test
+TEST_LOG_COMPILER = true
+END
+
+: > foo.test
+: > bar.test
+
+TEST_STATUS=0; export TEST_STATUS
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+: > t
+chmod a-r t
+test ! -r t || Exit 77
+rm -f t
+
+: Create the required log files.
+$MAKE check
+test -f foo.trs
+test -f bar.trs
+
+: Recreate with a sweeping "make check".
+chmod a-r bar.trs
+$MAKE check
+test -f foo.trs
+test -r foo.trs
+test -f bar.trs
+test -r bar.trs
+
+: Again, this time with one .trs file missing and the other
+: one unreadable.
+rm -f foo.trs
+chmod a-r bar.trs
+$MAKE check
+test -f foo.trs
+test -r foo.trs
+test -f bar.trs
+test -r bar.trs
+
+: Again, but using "make recheck" this time.
+rm -f foo.trs
+chmod a-r bar.trs
+$MAKE recheck >stdout || { cat stdout; Exit 1; }
+cat stdout
+test -f foo.trs
+test -r foo.trs
+test -f bar.trs
+test -r bar.trs
+grep '^PASS: foo\.test' stdout
+grep '^PASS: bar\.test' stdout
+
+: More complex interactions with "make recheck" are OK.
+chmod a-r bar.log bar.trs
+$MAKE recheck >stdout || { cat stdout; Exit 1; }
+cat stdout
+test -f bar.trs
+test -r bar.trs
+grep '^PASS: bar\.test' stdout
+grep 'foo\.test' stdout && Exit 1
+count_test_results total=1 pass=1 fail=0 xpass=0 xfail=0 skip=0 error=0
+
+: Recreate by remaking the global test log.
+chmod a-r foo.trs
+rm -f test-suite.log
+$MAKE test-suite.log >stdout || { cat stdout; Exit 1; }
+cat stdout
+test -f foo.trs
+test -r foo.trs
+grep '^PASS: foo\.test' stdout
+grep 'bar\.test' stdout && Exit 1
+# Also test that have only run before should be counted in the final
+# testsuite summary.
+grep '^# TOTAL: *2$' stdout
+
+: Setup for the next check.
+: > baz.test
+sed 's/^TESTS =.*/& baz.test/' Makefile > t
+diff t Makefile && Exit 99
+mv -f t Makefile
+$MAKE check
+test -f foo.trs
+test -f bar.trs
+test -f baz.trs
+
+: Interactions with lazy test reruns are OK.
+chmod a-r foo.trs
+$sleep
+touch stamp
+$sleep
+touch bar.test
+RECHECK_LOGS= $MAKE -e check >stdout || { cat stdout; Exit 1; }
+cat stdout
+test -r foo.trs
+is_newest bar.trs bar.test
+grep '^PASS: foo\.test' stdout
+grep '^PASS: bar\.test' stdout
+grep 'baz\.test' stdout && Exit 1
+# Also test that have only run before should be counted in the final
+# testsuite summary.
+grep '^# TOTAL: *3$' stdout
+
+:
diff --git a/t/tests-environment-and-log-compiler.sh b/t/tests-environment-and-log-compiler.sh
new file mode 100755
index 000000000..0e9d6e737
--- /dev/null
+++ b/t/tests-environment-and-log-compiler.sh
@@ -0,0 +1,75 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# parallel-tests: check that we can use variables and functions set
+# by TESTS_ENVIRONMENT and AM_TESTS_ENVIRONMENT in LOG_COMPILER and
+# LOG_FLAGS (for tests both with and without registered extensions).
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+unset v0 v1 v2 v3 v4 || :
+
+cat > Makefile.am << 'END'
+TESTS_ENVIRONMENT = am__f3 () { echo 3; }; v0='$(srcdir)' v1=1; :;
+AM_TESTS_ENVIRONMENT = v2=2; v4=4 && am__f5 () { echo 5; }; :;
+
+LOG_COMPILER = $$v0/log-compiler $$v1
+AM_LOG_FLAGS = $$v2 `am__f3`
+LOG_FLAGS = $$v4 `am__f5`
+
+TEST_LOG_COMPILER = $$v0/test-log-compiler $$v2
+AM_TEST_LOG_FLAGS = `am__f5` $$v1
+TEST_LOG_FLAGS = $$v4 `am__f3`
+
+EXTRA_DIST = log-compiler test-log-compiler
+
+TESTS = a b.test
+$(TESTS):
+END
+
+cat > log-compiler << 'END'
+#! /bin/sh
+echo "$0: $*"
+test x"$1$2$3$4$5" = x"12345"
+END
+
+cat > test-log-compiler << 'END'
+#! /bin/sh
+echo "$0: $*"
+test x"$1$2$3$4$5" = x"25143"
+END
+
+chmod a+x test-log-compiler log-compiler
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+$MAKE -n check || : # For debugging.
+VERBOSE=yes $MAKE check
+cat a.log
+cat b.log
+
+VERBOSE=yes $MAKE distcheck
+
+:
diff --git a/t/tests-environment-backcompat.sh b/t/tests-environment-backcompat.sh
new file mode 100755
index 000000000..61b2728cf
--- /dev/null
+++ b/t/tests-environment-backcompat.sh
@@ -0,0 +1,59 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# With old serial testsuite driver, TESTS_ENVIRONMENT can be used to
+# define the "test runner", i.e. the program that the test scripts must
+# be run by (with the parallel-tests driver one should use LOG_COMPILER
+# for this). The behaviour tested here is also documented in the manual.
+
+am_parallel_tests=no
+. ./defs || Exit 1
+
+cat >> configure.ac <<END
+AC_SUBST([PERL], ['$PERL'])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TESTS_ENVIRONMENT = $(PERL) -Mstrict -w
+TESTS = foo.pl bar.pl baz.pl
+XFAIL_TESTS = baz.pl
+EXTRA_DIST = $(TESTS)
+END
+
+echo 'exit (0);' > foo.pl
+echo 'exit (0);' > bar.pl
+
+cat > baz.pl << 'END'
+# With "use strict" enacted, this will cause an error, since the
+# variable '$x' is not declared with 'my' nor specified with an
+# explicit package name.
+$x = 0;
+exit ($x);
+END
+
+chmod a+x *.pl
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+$MAKE check
+$MAKE distcheck
+
+:
diff --git a/t/tests-environment-fd-redirect.sh b/t/tests-environment-fd-redirect.sh
new file mode 100755
index 000000000..d62e537d6
--- /dev/null
+++ b/t/tests-environment-fd-redirect.sh
@@ -0,0 +1,94 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Test for a behaviour of 'TESTS_ENVIRONMENT' and 'AM_TESTS_ENVIRONMENT'
+# w.r.t. file descriptor redirections which, although undocumented,
+# is nonetheless required by Gnulib's 'tests/init.sh' and by coreutils'
+# testsuite.
+# The checked behaviour is that we can portably do file descriptor
+# redirections by placing them at the end of a {AM_,}TESTS_ENVIRONMENT
+# definition without a following semicolon. The need to support this
+# is detailedly motivated by coreutils bug#8846:
+# <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=8846>
+# and the following CC:ed thread on bug-autoconf list:
+# <http://lists.gnu.org/archive/html/bug-autoconf/2011-06/msg00002.html>
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+# Use both a shell script and a perl script as tests,
+# for better coverage.
+
+cat >foo.test <<'END'
+#! /bin/sh
+set -e
+echo " " $0: foofoofoo >&8
+echo " " $0: barbarbar >&9
+END
+
+echo "#! $PERL -w" > bar.test
+cat >>bar.test <<'END'
+use warnings FATAL => 'all';
+use strict;
+open(FD8, ">&=8") or die "$!";
+open(FD9, ">&=9") or die "$!";
+print FD8 " $0: 8888\n";
+print FD9 " $0: 9999\n";
+END
+
+chmod a+x foo.test bar.test
+
+$ACLOCAL
+$AUTOCONF
+
+# Korn Shells seem more vulnerable to the issue highlighted in coreutils
+# bug#8846 than other shells are. In particular, the default Korn Shell
+# on Debian GNU/Linux is affected by the issue. So let's try to run our
+# test with a system Korn Shell too, if that's available.
+bin_ksh=:
+case $SHELL in
+ ksh|*/ksh) ;;
+ *) for d in /bin /usr/bin; do
+ test -f $d/ksh && { bin_ksh=$d/ksh; break; }
+ done;;
+esac
+
+for sh in "$SHELL" "$bin_ksh"; do
+ test "$sh" = : && continue
+ for pfx in AM_ ''; do
+ unindent > Makefile.am <<END
+ TESTS = foo.test bar.test
+ ## No trailing semicolon here, *deliberately*.
+ ${pfx}TESTS_ENVIRONMENT = 8>&1 9>&8
+END
+ $AUTOMAKE -a
+ CONFIG_SHELL="$sh" $sh ./configure CONFIG_SHELL="$sh"
+ VERBOSE=y $MAKE check >stdout || { cat stdout; Exit 1; }
+ cat stdout
+ grep '[ /]foo\.test: foofoofoo$' stdout
+ grep '[ /]foo\.test: barbarbar$' stdout
+ grep '[ /]bar\.test: 8888$' stdout
+ grep '[ /]bar\.test: 9999$' stdout
+ $EGREP '(foofoofoo|barbarbar|8888|9999)' foo.log && Exit 1
+ : # For shells with buggy 'set -e'.
+ done
+done
+
+:
diff --git a/t/tests-environment.sh b/t/tests-environment.sh
new file mode 100755
index 000000000..27cd458f2
--- /dev/null
+++ b/t/tests-environment.sh
@@ -0,0 +1,45 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# "Simple Tests" testsuite driver: check TESTS_ENVIRONMENT support.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TESTS = foo.test
+EXTRA_DIST = $(TESTS)
+END
+
+cat > foo.test << 'END'
+#! /bin/sh
+test x"$FOO" = x"ok"
+END
+chmod a+x foo.test
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+FOO=bad TESTS_ENVIRONMENT='FOO=ok' $MAKE check
+FOO=ok TESTS_ENVIRONMENT='FOO=bad' $MAKE check && Exit 1
+
+:
diff --git a/t/testsuite-summary-color.sh b/t/testsuite-summary-color.sh
new file mode 100755
index 000000000..0f0070808
--- /dev/null
+++ b/t/testsuite-summary-color.sh
@@ -0,0 +1,199 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check coloring of the testsuite summary.
+
+. ./defs-static || Exit 1
+
+use_colors=yes
+use_vpath=no
+
+. "$am_testauxdir"/testsuite-summary-checks.sh || Exit 99
+
+./configure
+
+# ANSI colors.
+red=''
+grn=''
+lgn=''
+blu=''
+mgn=''
+brg='';
+std='';
+
+success_header="\
+${grn}${br}${std}
+${grn}Testsuite summary for GNU AutoFoo 7.1${std}
+${grn}${br}${std}"
+
+success_footer=${grn}${br}${std}
+
+failure_header="\
+${red}${br}${std}
+${red}Testsuite summary for GNU AutoFoo 7.1${std}
+${red}${br}${std}"
+
+failure_footer="\
+${red}${br}${std}
+${red}See ./test-suite.log${std}
+${red}Please report to bug-automake@gnu.org${std}
+${red}${br}${std}"
+
+do_check '' <<END
+$success_header
+# TOTAL: 0
+# PASS: 0
+# SKIP: 0
+# XFAIL: 0
+# FAIL: 0
+# XPASS: 0
+# ERROR: 0
+$success_footer
+END
+
+do_check pass.t <<END
+$success_header
+${brg}# TOTAL: 1${std}
+${grn}# PASS: 1${std}
+# SKIP: 0
+# XFAIL: 0
+# FAIL: 0
+# XPASS: 0
+# ERROR: 0
+$success_footer
+END
+
+do_check skip.t <<END
+$success_header
+${brg}# TOTAL: 1${std}
+# PASS: 0
+${blu}# SKIP: 1${std}
+# XFAIL: 0
+# FAIL: 0
+# XPASS: 0
+# ERROR: 0
+$success_footer
+END
+
+do_check xfail.t <<END
+$success_header
+${brg}# TOTAL: 1${std}
+# PASS: 0
+# SKIP: 0
+${lgn}# XFAIL: 1${std}
+# FAIL: 0
+# XPASS: 0
+# ERROR: 0
+$success_footer
+END
+
+do_check fail.t <<END
+$failure_header
+${brg}# TOTAL: 1${std}
+# PASS: 0
+# SKIP: 0
+# XFAIL: 0
+${red}# FAIL: 1${std}
+# XPASS: 0
+# ERROR: 0
+$failure_footer
+END
+
+do_check xpass.t <<END
+$failure_header
+${brg}# TOTAL: 1${std}
+# PASS: 0
+# SKIP: 0
+# XFAIL: 0
+# FAIL: 0
+${red}# XPASS: 1${std}
+# ERROR: 0
+$failure_footer
+END
+
+do_check error.t <<END
+$failure_header
+${brg}# TOTAL: 1${std}
+# PASS: 0
+# SKIP: 0
+# XFAIL: 0
+# FAIL: 0
+# XPASS: 0
+${mgn}# ERROR: 1${std}
+$failure_footer
+END
+
+do_check pass.t xfail.t skip.t <<END
+$success_header
+${brg}# TOTAL: 3${std}
+${grn}# PASS: 1${std}
+${blu}# SKIP: 1${std}
+${lgn}# XFAIL: 1${std}
+# FAIL: 0
+# XPASS: 0
+# ERROR: 0
+$success_footer
+END
+
+do_check pass.t fail.t skip.t <<END
+$failure_header
+${brg}# TOTAL: 3${std}
+${grn}# PASS: 1${std}
+${blu}# SKIP: 1${std}
+# XFAIL: 0
+${red}# FAIL: 1${std}
+# XPASS: 0
+# ERROR: 0
+$failure_footer
+END
+
+do_check pass.t xfail.t xpass.t <<END
+$failure_header
+${brg}# TOTAL: 3${std}
+${grn}# PASS: 1${std}
+# SKIP: 0
+${lgn}# XFAIL: 1${std}
+# FAIL: 0
+${red}# XPASS: 1${std}
+# ERROR: 0
+$failure_footer
+END
+
+do_check skip.t xfail.t error.t <<END
+$failure_header
+${brg}# TOTAL: 3${std}
+# PASS: 0
+${blu}# SKIP: 1${std}
+${lgn}# XFAIL: 1${std}
+# FAIL: 0
+# XPASS: 0
+${mgn}# ERROR: 1${std}
+$failure_footer
+END
+
+do_check pass.t skip.t xfail.t fail.t xpass.t error.t <<END
+$failure_header
+${brg}# TOTAL: 6${std}
+${grn}# PASS: 1${std}
+${blu}# SKIP: 1${std}
+${lgn}# XFAIL: 1${std}
+${red}# FAIL: 1${std}
+${red}# XPASS: 1${std}
+${mgn}# ERROR: 1${std}
+$failure_footer
+END
+
+:
diff --git a/t/testsuite-summary-count-many.sh b/t/testsuite-summary-count-many.sh
new file mode 100755
index 000000000..58157ad9b
--- /dev/null
+++ b/t/testsuite-summary-count-many.sh
@@ -0,0 +1,105 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check test counts in the testsuite summary, with test drivers allowing
+# multiple test results per test script, and for a huge number of tests.
+# Incidentally, this test also checks that the testsuite summary doesn't
+# give any bug-report address if it's not defined.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+for s in trivial-test-driver extract-testsuite-summary.pl; do
+ cp "$am_testauxdir/$s" . || fatal_ "failed to fetch auxiliary script $s"
+done
+
+br='============================================================================'
+
+header="\
+${br}
+Testsuite summary for $me 1.0
+${br}"
+
+footer="\
+${br}
+See ./test-suite.log
+${br}"
+
+echo AC_OUTPUT >> configure.ac
+
+cat > Makefile.am << 'END'
+TEST_LOG_DRIVER = $(SHELL) $(srcdir)/trivial-test-driver
+TESTS = all.test
+# Without this, the test driver will be horrendously slow.
+END
+
+cat > all.test <<'END'
+#!/bin/sh
+cat results.txt || { echo ERROR: weird; exit 99; }
+END
+chmod a+x all.test
+
+$PERL -w -e '
+ use warnings FATAL => "all";
+ use strict;
+
+ # FIXME: we would like this to be 1000 or even 10000, but the current
+ # implementation is too slow to handle that :-(
+ my $base = 5;
+ my %count = (
+ TOTAL => $base * 1000,
+ PASS => $base * 700,
+ SKIP => $base * 200,
+ XFAIL => $base * 80,
+ FAIL => $base * 10,
+ XPASS => $base * 7,
+ ERROR => $base * 3,
+ );
+ my @results = qw/PASS SKIP XFAIL FAIL XPASS ERROR/;
+
+ open (RES, ">results.txt") or die "opening results.txt: $!\n";
+ open (CNT, ">count.txt") or die "opening count.txt: $!\n";
+
+ printf CNT "# %-6s %d\n", "TOTAL:", $count{TOTAL};
+ for my $res (@results)
+ {
+ my $uc_res = uc $res;
+ print STDERR "Generating list of $res ...\n";
+ for (1..$count{$res})
+ {
+ print RES "$uc_res: $_\n";
+ }
+ printf CNT "# %-6s %d\n", $res . ":", $count{$res};
+ }
+'
+
+(echo "$header" && cat count.txt && echo "$footer") > summary.exp
+
+$ACLOCAL
+$AUTOMAKE -a
+$AUTOCONF
+
+./configure
+
+($MAKE check || : > make.fail) | tee stdout
+test -f make.fail
+
+$PERL extract-testsuite-summary.pl stdout > summary.got
+cat summary.exp
+cat summary.got
+diff summary.exp summary.got || Exit 1
+
+:
diff --git a/t/testsuite-summary-count.sh b/t/testsuite-summary-count.sh
new file mode 100755
index 000000000..1d13e7e6b
--- /dev/null
+++ b/t/testsuite-summary-count.sh
@@ -0,0 +1,161 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check test counts in the testsuite summary.
+
+. ./defs-static || Exit 1
+
+use_colors=no
+use_vpath=no
+
+. "$am_testauxdir"/testsuite-summary-checks.sh || Exit 99
+
+./configure
+
+header="\
+${br}
+Testsuite summary for GNU AutoFoo 7.1
+${br}"
+
+success_footer=${br}
+
+failure_footer="\
+${br}
+See ./test-suite.log
+Please report to bug-automake@gnu.org
+${br}"
+
+# Corner cases.
+
+do_check '' <<END
+$header
+# TOTAL: 0
+# PASS: 0
+# SKIP: 0
+# XFAIL: 0
+# FAIL: 0
+# XPASS: 0
+# ERROR: 0
+$success_footer
+END
+
+do_check pass.t <<END
+$header
+# TOTAL: 1
+# PASS: 1
+# SKIP: 0
+# XFAIL: 0
+# FAIL: 0
+# XPASS: 0
+# ERROR: 0
+$success_footer
+END
+
+do_check fail.t <<END
+$header
+# TOTAL: 1
+# PASS: 0
+# SKIP: 0
+# XFAIL: 0
+# FAIL: 1
+# XPASS: 0
+# ERROR: 0
+$failure_footer
+END
+
+# Some simpler checks, with low or moderate number of tests.
+
+do_check skip.t skip2.t skip3.t xfail.t xfail2.t <<END
+$header
+# TOTAL: 5
+# PASS: 0
+# SKIP: 3
+# XFAIL: 2
+# FAIL: 0
+# XPASS: 0
+# ERROR: 0
+$success_footer
+END
+
+do_check pass.t pass2.t xfail.t xpass.t error.t error2.t <<END
+$header
+# TOTAL: 6
+# PASS: 2
+# SKIP: 0
+# XFAIL: 1
+# FAIL: 0
+# XPASS: 1
+# ERROR: 2
+$failure_footer
+END
+
+pass_count=22
+skip_count=19
+xfail_count=21
+fail_count=18
+xpass_count=23
+error_count=17
+tests_count=120
+
+pass=` seq_ 1 $pass_count | sed 's/.*/pass-&.t/'`
+skip=` seq_ 1 $skip_count | sed 's/.*/skip-&.t/'`
+xfail=`seq_ 1 $xfail_count | sed 's/.*/xfail-&.t/'`
+fail=` seq_ 1 $fail_count | sed 's/.*/fail-&.t/'`
+xpass=`seq_ 1 $xpass_count | sed 's/.*/xpass-&.t/'`
+error=`seq_ 1 $error_count | sed 's/.*/error-&.t/'`
+
+do_check $pass $skip $xfail $fail $xpass $error <<END
+$header
+# TOTAL: $tests_count
+# PASS: $pass_count
+# SKIP: $skip_count
+# XFAIL: $xfail_count
+# FAIL: $fail_count
+# XPASS: $xpass_count
+# ERROR: $error_count
+$failure_footer
+END
+
+# Mild stress test with a lot of test scripts.
+
+tests_count=1888
+pass_count=1403
+skip_count=292
+xfail_count=41
+fail_count=126
+xpass_count=17
+error_count=9
+
+pass=` seq_ 1 $pass_count | sed 's/.*/pass-&.t/'`
+skip=` seq_ 1 $skip_count | sed 's/.*/skip-&.t/'`
+xfail=`seq_ 1 $xfail_count | sed 's/.*/xfail-&.t/'`
+fail=` seq_ 1 $fail_count | sed 's/.*/fail-&.t/'`
+xpass=`seq_ 1 $xpass_count | sed 's/.*/xpass-&.t/'`
+error=`seq_ 1 $error_count | sed 's/.*/error-&.t/'`
+
+do_check $pass $skip $xfail $fail $xpass $error <<END
+$header
+# TOTAL: $tests_count
+# PASS: $pass_count
+# SKIP: $skip_count
+# XFAIL: $xfail_count
+# FAIL: $fail_count
+# XPASS: $xpass_count
+# ERROR: $error_count
+$failure_footer
+END
+
+:
diff --git a/t/testsuite-summary-reference-log.sh b/t/testsuite-summary-reference-log.sh
new file mode 100755
index 000000000..480ec12d6
--- /dev/null
+++ b/t/testsuite-summary-reference-log.sh
@@ -0,0 +1,88 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that the global testsuite log file referenced in the testsuite
+# summary and in the global testsuite log itself is correct.
+
+am_parallel_tests=yes
+. ./defs || Exit 1
+
+mv configure.ac configure.stub
+
+cat > fail << 'END'
+#!/bin/sh
+exit 1
+END
+chmod a+x fail
+
+cat configure.stub - > configure.ac <<'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TEST_SUITE_LOG = my_test_suite.log
+TESTS = fail
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+mkdir build
+cd build
+
+../configure
+
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+grep '^See \./my_test_suite\.log$' stdout
+
+mkdir bar
+TEST_SUITE_LOG=bar/bar.log $MAKE -e check >stdout && { cat stdout; Exit 1; }
+cat stdout
+grep '^See \./bar/bar\.log$' stdout
+
+cd ..
+
+echo SUBDIRS = sub > Makefile.am
+mkdir sub
+echo TESTS = fail > sub/Makefile.am
+mv fail sub
+
+cat configure.stub - > configure.ac <<'END'
+AC_CONFIG_FILES([sub/Makefile])
+AC_OUTPUT
+END
+
+$ACLOCAL --force
+$AUTOCONF --force
+$AUTOMAKE
+
+./configure
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+grep '^See sub/test-suite\.log$' stdout
+cd sub
+$MAKE check >stdout && { cat stdout; Exit 1; }
+cat stdout
+grep '^See sub/test-suite\.log$' stdout
+cd ..
+
+TEST_SUITE_LOG=foo.log $MAKE -e check >stdout && { cat stdout; Exit 1; }
+cat stdout
+grep '^See sub/foo\.log$' stdout
+
+:
diff --git a/t/transform.sh b/t/transform.sh
new file mode 100755
index 000000000..7aa958ea0
--- /dev/null
+++ b/t/transform.sh
@@ -0,0 +1,65 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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 that --program-transform works.
+
+required=cc
+. ./defs || Exit 1
+
+cat >>configure.ac <<'END'
+AC_PROG_CC
+AC_OUTPUT
+END
+
+cat >Makefile.am <<'EOF'
+bin_PROGRAMS = h
+bin_SCRIPTS = h.sh
+man_MANS = h.1
+
+.PHONY: test-install
+test-install: install
+ test -f inst/bin/gnu-h$(EXEEXT)
+ test -f inst/bin/gnu-h.sh
+ test -f inst/man/man1/gnu-h.1
+EOF
+
+cat >h.c <<'EOF'
+int main (void)
+{
+ return 0;
+}
+EOF
+
+: > h.sh
+: > h.1
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure --program-prefix=gnu- --prefix "`pwd`/inst" --mandir "`pwd`/inst/man"
+$MAKE
+$MAKE test-install
+$MAKE uninstall
+test `find inst -type f -print | wc -l` = 0
+
+# Opportunistically test for installdirs.
+rm -rf inst
+$MAKE installdirs
+test -d inst/bin
+test -d inst/man/man1
+
+:
diff --git a/t/transform2.sh b/t/transform2.sh
new file mode 100755
index 000000000..a4a94f7a9
--- /dev/null
+++ b/t/transform2.sh
@@ -0,0 +1,95 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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 that --program-transform works even when multiple files are
+# collapsed.
+
+required=cc
+. ./defs || Exit 1
+
+cat >>configure.ac <<'END'
+AC_PROG_CC
+AC_OUTPUT
+END
+
+cat >Makefile.am <<'EOF'
+bin_PROGRAMS = p1 p2
+bin_SCRIPTS = s1.sh s2.sh
+man_MANS = m1.1 m2.1
+
+test-install: install
+ test -f inst/bin/p$(EXEEXT)
+ test -f inst/bin/s.sh
+ test -f inst/man/man1/m.1
+
+test-install-foo: install
+ test -f inst/bin/foo$(EXEEXT)
+ test -f inst/bin/foo
+ test -f inst/man/man1/foo.1
+ test ! -f inst/bin/p1$(EXEEXT)
+ test ! -f inst/bin/p2$(EXEEXT)
+ test ! -f inst/bin/s1.sh
+ test ! -f inst/bin/s2.sh
+ test ! -f inst/man/man/m1.1
+ test ! -f inst/man/man/m2.1
+EOF
+
+cat >p1.c <<'EOF'
+int
+main ()
+{
+ return 0;
+}
+EOF
+
+cp p1.c p2.c
+
+: > s1.sh
+: > s2.sh
+: > m1.1
+: > m2.1
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure --program-transform-name='s/[12]//' --prefix "`pwd`/inst" --mandir "`pwd`/inst/man"
+$MAKE
+$MAKE test-install
+$MAKE uninstall
+test `find inst -type f -print | wc -l` = 0
+
+# Also squash all file types in question.
+
+# On newer Cygwin versions, that won't work, likely due to overly
+# aggressive appending of '.exe' suffix when copying/renaming Windows
+# executables). So let's skip this part of the test if we detect the
+# faulty heuristic is present. See also:
+# <http://lists.gnu.org/archive/html/automake-patches/2010-08/msg00153.html>
+# <http://thread.gmane.org/gmane.os.cygwin/119380>
+echo Foo > foo
+echo Bar > bar.exe
+chmod a+x foo bar.exe
+cp foo bar && cmp foo bar \
+ || skip_ "your Cygwin is too aggressive in tweaking '.exe' suffixes"
+
+./configure --program-transform-name='s/.*/foo/' --prefix "`pwd`/inst" --mandir "`pwd`/inst/man"
+$MAKE
+$MAKE test-install-foo
+$MAKE uninstall
+test `find inst -type f -print | wc -l` = 0
+
+:
diff --git a/t/transform3.sh b/t/transform3.sh
new file mode 100755
index 000000000..aaa69cb8e
--- /dev/null
+++ b/t/transform3.sh
@@ -0,0 +1,87 @@
+#! /bin/sh
+# Copyright (C) 2012 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 that --program-transform does not transform too much
+# stuff (in particular, pgklibdir, pkgdatadir and pkglibexecdir).
+
+required=cc
+. ./defs || Exit 1
+
+cat > configure.ac <<'END'
+AC_INIT([foo], [1.0])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([Makefile])
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_RANLIB
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+bin_SCRIPTS = foo
+pkgdata_DATA = bar.txt
+pkglib_LIBRARIES = libzap.a
+pkglibexec_SCRIPTS = mu
+END
+
+cat > libzap.c <<'END'
+int zap (void)
+{
+ return 0;
+}
+END
+
+echo 'To be or not to be ...' > bar.txt
+
+cat > foo <<'END'
+#!/bin/sh
+exit 0
+END
+cp foo mu
+chmod a+x foo mu
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure --program-prefix=gnu- --prefix "`pwd`/inst"
+
+$MAKE install
+find inst # For debugging.
+test -f inst/bin/gnu-foo
+test -x inst/bin/gnu-foo
+test -f inst/share/foo/bar.txt
+test ! -d inst/share/gnu-foo
+test -f inst/lib/foo/libzap.a
+test ! -d inst/lib/gnu-foo
+test -f inst/libexec/foo/gnu-mu
+test -x inst/libexec/foo/gnu-mu
+test ! -d inst/libexec/gnu-foo
+
+$MAKE uninstall
+test `find inst -type f -print | wc -l` = 0
+
+# Opportunistically test for installdirs.
+rm -rf inst
+$MAKE installdirs
+test -d inst/share/foo
+test ! -d inst/share/gnu-foo
+test -d inst/lib/foo
+test ! -d inst/lib/gnu-foo
+test -d inst/libexec/foo
+test ! -d inst/libexec/gnu-foo
+
+:
diff --git a/t/txinfo-no-clutter.sh b/t/txinfo-no-clutter.sh
new file mode 100755
index 000000000..ae5e9f2d1
--- /dev/null
+++ b/t/txinfo-no-clutter.sh
@@ -0,0 +1,102 @@
+#! /bin/sh
+# Copyright (C) 2012 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/>.
+
+# The pdf, ps and dvi targets shouldn't let clutter in the build directory.
+# Related to automake bug#11146.
+
+required='makeinfo tex texi2dvi-o dvips'
+. ./defs || Exit 1
+
+mkdir sub
+
+echo AC_OUTPUT >> configure.ac
+
+cat > Makefile.am << 'END'
+all-local: ps pdf dvi html
+info_TEXINFOS = foo.texi sub/bar.texi
+END
+
+cat > foo.texi << 'END'
+\input texinfo
+@setfilename foo.info
+@settitle foo
+@node Top
+Hello walls.
+@include version.texi
+@bye
+END
+
+cat > sub/bar.texi << 'END'
+\input texinfo
+@setfilename bar.info
+@settitle bar
+@node Top
+Hello walls.
+@include version2.texi
+@bye
+END
+
+cat > baz.texi << 'END'
+\input texinfo
+@setfilename baz.info
+@settitle baz
+@node Top
+Hello walls.
+@bye
+END
+
+cat > baz.texi << 'END'
+\input texinfo
+@setfilename baz.info
+@settitle baz
+@defindex au
+@defindex sa
+@defindex sb
+@synindex sa sb
+@node Top
+Hello walls.
+@cindex foo
+foo
+@pindex bar
+bar
+@auindex baz
+baz
+@saindex sa
+sa
+@sbindex sb
+sb
+@bye
+END
+
+$ACLOCAL
+$AUTOMAKE --add-missing
+$AUTOCONF
+
+./configure
+
+# Try one by one, to ensure later targets don't involuntarily
+# clean up potential cruft left by earlier ones.
+for fmt in info pdf ps dvi html all; do
+ $MAKE $fmt
+ ls -l . sub # For debugging.
+ ls -d foo* baz* sub/bar* > lst
+ $EGREP -v '^(foo|sub/bar|baz)\.(texi|dvi|ps|pdf|html|info)$' lst && Exit 1
+ $MAKE clean
+done
+
+$MAKE distcheck
+
+:
diff --git a/t/txinfo-unrecognized-extension.sh b/t/txinfo-unrecognized-extension.sh
new file mode 100755
index 000000000..251658049
--- /dev/null
+++ b/t/txinfo-unrecognized-extension.sh
@@ -0,0 +1,38 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Test that automake complains properly when the files with unrecognized
+# extensions are passed to the TEXINFOS primary.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+info_TEXINFOS = foobar.foo bazquux.tex zardoz.c
+END
+
+echo '@setfilename foobar.info' > foobar.foo
+echo '@setfilename bazquux.info' > bazquux.tex
+echo '@setfilename zardoz.info' > zardoz.c
+: > texinfo.tex
+
+$ACLOCAL
+AUTOMAKE_fails
+
+for x in 'foobar\.foo' 'bazquux\.tex' 'zardoz\.c'; do
+ grep "^Makefile\\.am:.* texinfo file .*$x.* unrecognized extension" stderr
+done
+
+:
diff --git a/t/txinfo.sh b/t/txinfo.sh
new file mode 100755
index 000000000..e6667cbed
--- /dev/null
+++ b/t/txinfo.sh
@@ -0,0 +1,47 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test to ensure texinfo.tex is included in distribution. Bug report by
+# Jim Meyering.
+
+required=makeinfo
+. ./defs || Exit 1
+
+cat >> configure.ac <<'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+info_TEXINFOS = textutils.texi
+.PHONY: test1 test2
+test1:
+ @echo DISTFILES = $(DISTFILES)
+ echo ' ' $(DISTFILES) ' ' | grep '[ /]texinfo\.tex '
+test2: distdir
+ ls -l $(distdir)
+ test -f $(distdir)/texinfo.tex
+END
+
+echo '@setfilename textutils.info' > textutils.texi
+: > texinfo.tex
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure
+$MAKE test1 test2
+
+:
diff --git a/t/txinfo10.sh b/t/txinfo10.sh
new file mode 100755
index 000000000..6908ab847
--- /dev/null
+++ b/t/txinfo10.sh
@@ -0,0 +1,39 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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 dvi target recurses into subdir.
+# Reported by Pavel Roskin.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+SUBDIRS = sub
+END
+
+mkdir sub
+cat > sub/Makefile.am << 'END'
+info_TEXINFOS = maude.texi
+END
+
+echo '@setfilename maude.info' > sub/maude.texi
+: > sub/texinfo.tex
+
+$ACLOCAL
+$AUTOMAKE
+
+grep dvi-recursive Makefile.in
+grep '[^-]info-recursive' Makefile.in
+grep '[^n]install-info-recursive' Makefile.in
diff --git a/t/txinfo13.sh b/t/txinfo13.sh
new file mode 100755
index 000000000..77f9af785
--- /dev/null
+++ b/t/txinfo13.sh
@@ -0,0 +1,65 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Check for subdir Texinfo (PR/343).
+# Also make sure we do not distribute too much foo.info* files (Report
+# from Vincent Lefevre).
+
+required='makeinfo tex texi2dvi-o'
+. ./defs || Exit 1
+
+echo AC_OUTPUT >> configure.ac
+
+cat > Makefile.am << 'END'
+info_TEXINFOS = subdir/main.texi
+subdir_main_TEXINFOS = subdir/inc.texi
+
+installcheck-local:
+ test -f "$(infodir)/main.info"
+check-local:
+ test ! -f $(srcdir)/subdir/main.info.bak
+END
+
+mkdir subdir
+
+cat > subdir/main.texi << 'END'
+\input texinfo
+@setfilename main.info
+@settitle main
+@node Top
+Hello walls.
+@include version.texi
+@include inc.texi
+@bye
+END
+
+cat > subdir/inc.texi << 'END'
+I'm included.
+END
+
+touch subdir/main.info.bak
+
+$ACLOCAL
+$AUTOMAKE --add-missing
+$AUTOCONF
+
+mkdir build
+cd build
+../configure
+$MAKE distcheck
+test -f ../subdir/main.info
+test ! -f subdir/main.info
+test -f ../subdir/main.info.bak
diff --git a/t/txinfo16.sh b/t/txinfo16.sh
new file mode 100755
index 000000000..173a87a86
--- /dev/null
+++ b/t/txinfo16.sh
@@ -0,0 +1,91 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Check that info files are normally built in $(srcdir),
+# not in $(builddir).
+
+required='makeinfo tex texi2dvi'
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+info_TEXINFOS = main.texi
+END
+
+cat > main.texi << 'END'
+\input texinfo
+@setfilename main.info
+@settitle main
+@node Top
+Hello walls.
+@include version.texi
+@bye
+END
+
+$ACLOCAL
+$AUTOMAKE --add-missing
+$AUTOCONF
+
+mkdir build
+cd build
+../configure
+$MAKE
+test -f ../main.info
+test ! -f main.info
+test -f ../stamp-vti
+test ! -f stamp-vti
+test -f ../version.texi
+test ! -f version.texi
+
+cd ..
+rm -rf build make.info* stamp-vti version.texi
+./configure
+$MAKE
+test -f main.info
+
+# Make sure stamp-vti is older that version.texi.
+# (A common situation in a real tree.)
+# This is needed to test the "subtle" issue described below.
+test -f stamp-vti
+test -f version.texi
+$sleep
+touch stamp-vti
+
+$MAKE distclean
+test -f stamp-vti
+test -f version.texi
+
+mkdir build
+cd build
+../configure
+$MAKE
+# main.info should not be rebuilt in the current directory, since
+# it's up-to-date in $(srcdir).
+# This can be caused by a subtle issue related to VPATH handling
+# of version.texi (see also the comment in texi-vers.am): because
+# stamp-vti is newer than version.texi, the 'version.texi: stamp-vti'
+# rule is always triggered. Still that's not a reason for 'make'
+# to think 'version.texi' has been created...
+test ! -f main.info
+$MAKE dvi
+test -f main.dvi
+
+$MAKE distcheck
+
+:
diff --git a/t/txinfo17.sh b/t/txinfo17.sh
new file mode 100755
index 000000000..1de7e9a3f
--- /dev/null
+++ b/t/txinfo17.sh
@@ -0,0 +1,39 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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 Automake uses the _first_ @setfilname it sees.
+# Report from Karl Berry.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+info_TEXINFOS = texinfo.texi
+END
+
+cat > texinfo.texi << 'END'
+@setfilename texinfo
+...
+@verbatim
+@setfilename example.info
+@end verbatim
+...
+END
+
+$ACLOCAL
+$AUTOMAKE --add-missing
+
+grep 'example' Makefile.in && Exit 1
+grep 'texinfo:' Makefile.in
diff --git a/t/txinfo19.sh b/t/txinfo19.sh
new file mode 100755
index 000000000..e304b42e2
--- /dev/null
+++ b/t/txinfo19.sh
@@ -0,0 +1,70 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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/>.
+
+# Test support for DJGPP's .iNN info files.
+
+required='makeinfo tex'
+. ./defs || Exit 1
+
+echo AC_OUTPUT >> configure.ac
+
+cat > Makefile.am << 'END'
+info_TEXINFOS = main.texi
+END
+
+cat > main.texi << 'END'
+\input texinfo
+@setfilename main.info
+@settitle main
+@node Top
+Hello walls.
+@bye
+END
+
+$ACLOCAL
+$AUTOMAKE --add-missing
+$AUTOCONF
+
+./configure "--infodir=`pwd`/_inst"
+$MAKE
+
+# Make sure .iNN files are installed.
+: > main.i1
+: > main.i21
+$MAKE install
+test -f _inst/main.i1
+test -f _inst/main.i21
+
+# They should be uninstalled too.
+$MAKE uninstall
+test ! -f _inst/main.i1
+test ! -f _inst/main.i21
+
+# Make sure rebuild rules erase old .iNN files when they run makeinfo.
+$sleep
+touch main.texi
+test -f main.i1
+test -f main.i21
+$MAKE
+test ! -f main.i1
+test ! -f main.i21
+
+# Finally, we also want them erased by maintainer-clean.
+: > main.i7
+: > main.i39
+$MAKE maintainer-clean
+test ! -f main.i7
+test ! -f main.i39
diff --git a/t/txinfo2.sh b/t/txinfo2.sh
new file mode 100755
index 000000000..0daebd9a8
--- /dev/null
+++ b/t/txinfo2.sh
@@ -0,0 +1,45 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test to ensure that a ".info~" file doesn't end up in the
+# distribution. Bug report from Greg McGary.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+info_TEXINFOS = textutils.texi
+.PHONY: test
+test:
+ @echo DISTFILES = $(DISTFILES)
+ case '$(DISTFILES)' in *'~'*) exit 1;; *) exit 0;; esac
+END
+
+: > texinfo.tex
+echo '@setfilename textutils.info' > textutils.texi
+: > textutils.info~
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+$MAKE test
+
+:
diff --git a/t/txinfo20.sh b/t/txinfo20.sh
new file mode 100755
index 000000000..5c07880c1
--- /dev/null
+++ b/t/txinfo20.sh
@@ -0,0 +1,76 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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 info files survive makeinfo errors.
+
+required=makeinfo
+. ./defs || Exit 1
+
+echo AC_OUTPUT >> configure.ac
+
+cat > Makefile.am << 'END'
+info_TEXINFOS = main.texi sub/main.texi
+END
+
+mkdir sub
+
+cat > main.texi << 'END'
+\input texinfo
+@setfilename main
+@settitle main
+@node Top
+Hello walls.
+@bye
+END
+
+cp main.texi sub/main.texi
+
+$ACLOCAL
+$AUTOMAKE --add-missing
+$AUTOCONF
+
+./configure
+$MAKE
+
+# Feign more info files.
+: > main-1
+: > sub/main-1
+
+# Break main.texi.
+$sleep
+cp main.texi main.old
+cat > main.texi << 'END'
+\input texinfo
+@setfilename main
+@settitle main
+@node Top
+@unknown_macro{Hello walls.}
+@bye
+END
+
+# makeinfo will bail out, but we should conserve the old info files.
+$MAKE && Exit 1
+test -f main
+test -f main-1
+
+# Restore main.texi, and break sub/main.texi.
+cp main.texi sub/main.texi
+mv main.old main.texi
+$MAKE && Exit 1
+test -f main
+test ! -f main-1
+test -f sub/main
+test -f sub/main-1
diff --git a/t/txinfo21.sh b/t/txinfo21.sh
new file mode 100755
index 000000000..93543a785
--- /dev/null
+++ b/t/txinfo21.sh
@@ -0,0 +1,176 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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/>.
+
+# Test support for building HTML documentation, and the many
+# install-DOC flavors.
+
+required='makeinfo-html tex texi2dvi'
+. ./defs || Exit 1
+
+cat >>configure.ac <<\EOF
+AC_CONFIG_FILES([rec/Makefile])
+
+# At the time of writing, Autoconf does not supplies any of these
+# definitions (and those below are purposely not those of the standard).
+AC_SUBST([dvidir], ['${datadir}/${PACKAGE}/dvi'])
+AC_SUBST([htmldir], ['${datadir}/${PACKAGE}/html'])
+AC_SUBST([pdfdir], ['${datadir}/${PACKAGE}/pdf'])
+AC_SUBST([psdir], ['${datadir}/${PACKAGE}/ps'])
+
+AC_OUTPUT
+EOF
+
+cat > Makefile.am << 'END'
+SUBDIRS = rec
+info_TEXINFOS = main.texi sub/main2.texi
+END
+
+cat > main.texi << 'END'
+\input texinfo
+@setfilename main.info
+@settitle main
+@node Top
+Hello walls.
+@bye
+END
+
+mkdir sub
+cat > sub/main2.texi << 'END'
+\input texinfo
+@setfilename main2.info
+@settitle main2
+@node Top
+Hello walls.
+@bye
+END
+
+mkdir rec
+cat > rec/main3.texi << 'END'
+\input texinfo
+@setfilename main3.info
+@settitle main3
+@node Top
+Hello walls.
+@bye
+END
+
+cat > rec/Makefile.am << 'END'
+info_TEXINFOS = main3.texi
+
+install-pdf-local:
+ @$(MKDIR_P) "$(pdfdir)"
+ :> "$(pdfdir)/hello"
+uninstall-local:
+ rm -f "$(pdfdir)/hello"
+END
+
+$ACLOCAL
+$AUTOMAKE --add-missing
+$AUTOCONF
+
+./configure
+
+$MAKE
+
+$sleep
+# Test production of split-per-node HTML.
+$MAKE html
+test -d main.html
+test -d sub/main2.html
+test -d rec/main3.html
+
+# Rebuilding main.html should cause its timestamp to be updated.
+is_newest main.html main.texi
+$sleep
+touch main.texi
+$MAKE html
+is_newest main.html main.texi
+
+$MAKE clean
+test ! -d main.html
+test ! -d sub/main2.html
+test ! -d rec/main3.html
+
+# Test production of a single HTML file.
+MAKEINFOFLAGS=--no-split $MAKE -e html
+test -f main.html
+test -f sub/main2.html
+test -f rec/main3.html
+$MAKE clean
+test ! -f main.html
+test ! -f sub/main2.html
+test ! -f rec/main3.html
+
+# Make sure AM_MAKEINFOHTMLFLAGS is supported, and override AM_MAKEINFO.
+cat >>Makefile.am <<\EOF
+AM_MAKEINFOHTMLFLAGS = --no-headers --no-split
+AM_MAKEINFOFLAGS = --unsupported-option
+EOF
+$AUTOMAKE
+./configure --prefix "`pwd`"
+$MAKE html
+test -f main.html
+test -f sub/main2.html
+test -d rec/main3.html
+$MAKE clean
+test ! -f main.html
+test ! -f sub/main2.html
+test ! -d rec/main3.html
+
+$MAKE install-html
+test -f share/$me/html/main.html
+test -f share/$me/html/main2.html
+test -d share/$me/html/main3.html
+$MAKE uninstall
+test ! -f share/$me/html/main.html
+test ! -f share/$me/html/main2.html
+test ! -d share/$me/html/main3.html
+
+$MAKE install-dvi
+test -f share/$me/dvi/main.dvi
+test -f share/$me/dvi/main2.dvi
+test -f share/$me/dvi/main3.dvi
+$MAKE uninstall
+test ! -f share/$me/dvi/main.dvi
+test ! -f share/$me/dvi/main2.dvi
+test ! -f share/$me/dvi/main3.dvi
+
+dvips --help || skip_ "dvips is missing"
+
+$MAKE install-ps
+test -f share/$me/ps/main.ps
+test -f share/$me/ps/main2.ps
+test -f share/$me/ps/main3.ps
+$MAKE uninstall
+test ! -f share/$me/ps/main.ps
+test ! -f share/$me/ps/main2.ps
+test ! -f share/$me/ps/main3.ps
+
+pdfetex --help || pdftex --help \
+ || skip_ "pdftex and pdfetex are both missing"
+
+$MAKE install-pdf
+test -f share/$me/pdf/main.pdf
+test -f share/$me/pdf/main2.pdf
+test -f share/$me/pdf/main3.pdf
+test -f share/$me/pdf/hello
+$MAKE uninstall
+test ! -f share/$me/pdf/main.pdf
+test ! -f share/$me/pdf/main2.pdf
+test ! -f share/$me/pdf/main3.pdf
+test ! -f share/$me/pdf/hello
+
+:
diff --git a/t/txinfo22.sh b/t/txinfo22.sh
new file mode 100755
index 000000000..c33898b67
--- /dev/null
+++ b/t/txinfo22.sh
@@ -0,0 +1,68 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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 the user can override TEXINFO_TEX.
+# Also make sure TEXINFO_TEX is not distributed.
+# Report from Tom Tromey.
+
+required='makeinfo tex texi2dvi'
+. ./defs || Exit 1
+
+cat > configure.ac << END
+AC_INIT([$me], [1.0])
+AC_CONFIG_AUX_DIR([aux1])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+TEXINFO_TEX = $(srcdir)/tex/texinfo.tex
+info_TEXINFOS = main.texi
+sure_it_exists:
+ test -f $(TEXINFO_TEX)
+sure_it_is_not_distributed: distdir
+ test ! -f $(distdir)/tex/texinfo.tex
+END
+
+cat > main.texi << 'END'
+\input texinfo
+@setfilename main.info
+@settitle main
+@node Top
+Hello walls.
+@bye
+END
+
+mkdir aux1
+mkdir tex
+cp "$am_pkgvdatadir/texinfo.tex" tex
+
+$ACLOCAL
+$AUTOMAKE --add-missing
+$AUTOCONF
+
+test ! -f texinfo.tex
+test ! -f aux1/texinfo.tex
+test -f tex/texinfo.tex
+
+./configure
+
+$MAKE sure_it_exists
+$MAKE distcheck
+$MAKE sure_it_is_not_distributed
+
+:
diff --git a/t/txinfo23.sh b/t/txinfo23.sh
new file mode 100755
index 000000000..e5c17611d
--- /dev/null
+++ b/t/txinfo23.sh
@@ -0,0 +1,66 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Check that info files are built in builddir when needed.
+# Test with subdir Texinfo.
+# (Similar to txinfo13.test, plus DISTCLEANFILES).
+# (See also txinfo24.test and txinfo25.test).
+
+required='makeinfo tex texi2dvi-o'
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+DISTCLEANFILES = subdir/*.info*
+info_TEXINFOS = subdir/main.texi
+subdir_main_TEXINFOS = subdir/inc.texi
+
+installcheck-local:
+ test -f "$(infodir)/main.info"
+END
+
+mkdir subdir
+
+cat > subdir/main.texi << 'END'
+\input texinfo
+@setfilename main.info
+@settitle main
+@node Top
+Hello walls.
+@include version.texi
+@include inc.texi
+@bye
+END
+
+cat > subdir/inc.texi << 'END'
+I'm included.
+END
+
+$ACLOCAL
+$AUTOMAKE --add-missing
+$AUTOCONF
+
+mkdir build
+cd build
+../configure
+$MAKE distcheck
+test -f subdir/main.info
+test ! -f ../subdir/main.info
+
+:
diff --git a/t/txinfo24.sh b/t/txinfo24.sh
new file mode 100755
index 000000000..709cee71f
--- /dev/null
+++ b/t/txinfo24.sh
@@ -0,0 +1,83 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Check that info files are built in builddir when needed.
+# (Similar to txinfo16.test, plus CLEANFILES).
+# (See also txinfo23.test and txinfo25.test).
+
+required='makeinfo tex texi2dvi-o'
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+CLEANFILES = main.info
+info_TEXINFOS = main.texi
+END
+
+cat > main.texi << 'END'
+\input texinfo
+@setfilename main.info
+@settitle main
+@node Top
+Hello walls.
+@include version.texi
+@bye
+END
+
+$ACLOCAL
+$AUTOMAKE --add-missing
+$AUTOCONF
+
+mkdir build
+cd build
+../configure
+$MAKE
+test ! -f ../main.info
+test -f main.info
+
+cd ..
+rm -rf build
+./configure
+$MAKE
+test -f main.info
+
+# Make sure stamp-vti is older that version.texi.
+# (A common situation in a real tree).
+test -f stamp-vti
+test -f version.texi
+$sleep
+touch stamp-vti
+
+$MAKE distclean
+test -f stamp-vti
+test -f version.texi
+
+mkdir build
+cd build
+../configure
+$MAKE
+# main.info should be rebuilt in the current directory.
+test -f main.info
+test ! -f ../main.info
+$MAKE dvi
+test -f main.dvi
+
+$MAKE distcheck
+
+:
diff --git a/t/txinfo25.sh b/t/txinfo25.sh
new file mode 100755
index 000000000..7aa66ae9d
--- /dev/null
+++ b/t/txinfo25.sh
@@ -0,0 +1,111 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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/>.
+
+# Check that info files are built in builddir and in srcdir can safely
+# co-exist. This setup is obtained by having two info files, only one
+# of which being cleaned.
+# (Similar to txinfo16.test, plus CLEANFILES).
+# (See also txinfo23.test and txinfo24.test).
+
+required='makeinfo tex texi2dvi-o'
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+CLEANFILES = [a-m]*.info
+info_TEXINFOS = main.texi other.texi
+END
+
+cat > main.texi << 'END'
+\input texinfo
+@setfilename main.info
+@settitle main
+@node Top
+Hello walls.
+@include version.texi
+@bye
+END
+
+cat > other.texi << 'END'
+\input texinfo
+@setfilename other.info
+@settitle other
+@node Top
+Hello walls.
+@include version2.texi
+@bye
+END
+
+$ACLOCAL
+$AUTOMAKE --add-missing
+$AUTOCONF
+
+mkdir build
+cd build
+../configure
+$MAKE
+test -f main.info
+test ! -f ../main.info
+test ! -f other.info
+test -f ../other.info
+
+cd ..
+rm -rf build
+./configure
+$MAKE
+test -f main.info
+test -f other.info
+
+# Make sure stamp-vti is older that version.texi.
+# (A common situation in a real tree).
+# This is needed to test the "subtle" issue described below.
+test -f stamp-vti
+test -f version.texi
+test -f stamp-1
+test -f version2.texi
+$sleep
+touch stamp-vti
+touch stamp-1
+
+$MAKE distclean
+test -f stamp-vti
+test -f stamp-1
+test -f version.texi
+test -f version2.texi
+
+mkdir build
+cd build
+../configure
+$MAKE
+# other.info should not be rebuilt in the current directory, since
+# it's up-to-date in $(srcdir).
+# This can be caused by a subtle issue related to VPATH handling
+# of version.texi (see also the comment in texi-vers.am): because
+# stamp-vti is newer than version.texi, the 'version.texi: stamp-vti'
+# rule is always triggered. Still that's not a reason for 'make'
+# to think 'version.texi' has been created...
+test -f main.info
+test ! -f other.info
+$MAKE dvi
+test -f main.dvi
+test -f other.dvi
+
+$MAKE distcheck
+
+:
diff --git a/t/txinfo26.sh b/t/txinfo26.sh
new file mode 100755
index 000000000..e336bba79
--- /dev/null
+++ b/t/txinfo26.sh
@@ -0,0 +1,67 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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 Texinfo installation works when absolute --srcdir is used.
+# PR/408
+
+required='makeinfo'
+. ./defs || Exit 1
+
+echo AC_OUTPUT >> configure.ac
+
+cat > Makefile.am << 'END'
+info_TEXINFOS = main.texi
+END
+
+
+cat > main.texi << 'END'
+\input texinfo
+@setfilename main.info
+@settitle main
+@node Top
+Hello walls.
+@include version.texi
+@bye
+END
+
+
+$ACLOCAL
+$AUTOMAKE --add-missing
+$AUTOCONF
+
+./configure
+$MAKE
+$MAKE distclean
+
+case `pwd` in
+ *\ * | *\ *)
+ skip_ "this test might fail in a directory containing white spaces";;
+esac
+
+mkdir build
+cd build
+../configure "--srcdir=`pwd`/.." "--prefix=`pwd`/_inst" "--infodir=`pwd`/_inst/info"
+$MAKE install
+test -f ../main.info
+test ! -f ./main.info
+test -f _inst/info/main.info
+
+$MAKE uninstall
+test ! -f _inst/info/main.info
+test -f ../main.info
+
+# Multiple uninstall should not fail.
+$MAKE uninstall
diff --git a/t/txinfo27.sh b/t/txinfo27.sh
new file mode 100755
index 000000000..131300ae9
--- /dev/null
+++ b/t/txinfo27.sh
@@ -0,0 +1,46 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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 install-info works even if no-installinfo is given.
+
+required='makeinfo'
+. ./defs || Exit 1
+
+echo AC_OUTPUT >> configure.ac
+
+cat > Makefile.am << 'END'
+info_TEXINFOS = main.texi
+AUTOMAKE_OPTIONS = no-installinfo
+END
+
+cat > main.texi << 'END'
+\input texinfo
+@setfilename main.info
+@settitle main
+@node Top
+Hello walls.
+@include version.texi
+@bye
+END
+
+
+$ACLOCAL
+$AUTOMAKE --add-missing
+$AUTOCONF
+
+./configure "--prefix=`pwd`/inst" "--infodir=`pwd`/inst/info"
+$MAKE install-info
+test -f inst/info/main.info
diff --git a/t/txinfo28.sh b/t/txinfo28.sh
new file mode 100755
index 000000000..97b36d50a
--- /dev/null
+++ b/t/txinfo28.sh
@@ -0,0 +1,89 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Check that info files are built in builddir when needed.
+# Similar to txinfo24.test, but obfuscating filenames with variable
+# references.
+# Report from Ralf Corsepius.
+
+required='makeinfo tex texi2dvi-o'
+. ./defs || Exit 1
+
+# This setting, when honored by GNU ls, used to cause an infinite loop
+# in mdate-sh.
+TIME_STYLE="+%Y-%m-%d %H:%M:%S"
+export TIME_STYLE
+
+echo AC_OUTPUT >> configure.ac
+
+cat > Makefile.am << 'END'
+MA = ma
+IN = in
+PROJ = $(MA)$(IN)
+include fragment.mk
+info_TEXINFOS = ma$(IN).texi
+END
+
+echo 'CLEANFILES = $(PROJ).info' > fragment.mk
+
+cat > main.texi << 'END'
+\input texinfo
+@setfilename main.info
+@settitle main
+@node Top
+Hello walls.
+@include version.texi
+@bye
+END
+
+$ACLOCAL
+$AUTOMAKE --add-missing
+$AUTOCONF
+
+mkdir build
+cd build
+../configure
+$MAKE
+test -f main.info
+
+cd ..
+rm -rf build
+./configure
+$MAKE
+test -f main.info
+
+# Make sure stamp-vti is older that version.texi.
+# (A common situation in a real tree).
+test -f stamp-vti
+test -f version.texi
+$sleep
+touch stamp-vti
+
+$MAKE distclean
+test -f stamp-vti
+test -f version.texi
+
+mkdir build
+cd build
+../configure
+$MAKE
+# main.info should be rebuilt in the current directory.
+test -f main.info
+test ! -f ../main.info
+$MAKE dvi
+test -f main.dvi
+
+$MAKE distcheck
diff --git a/t/txinfo29.sh b/t/txinfo29.sh
new file mode 100755
index 000000000..a0013d252
--- /dev/null
+++ b/t/txinfo29.sh
@@ -0,0 +1,62 @@
+#! /bin/sh
+# Copyright (C) 2004-2012 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 that INFO_DEPS can be overridden.
+# Report from Bruce Korb.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+INFO_DEPS = foo.info
+info_TEXINFOS = bar.texi
+END
+
+echo '@setfilename baz.info' > bar.texi
+
+$ACLOCAL
+AUTOMAKE_fails --add-missing
+grep '^Makefile\.am:1:.*user variable.*INFO_DEPS' stderr
+grep 'overrides Automake variable.*INFO_DEPS' stderr
+
+$AUTOMAKE -Wno-override
+
+# There is only one definition of INFO_DEPS ...
+test 1 = `grep '^INFO_DEPS.*=' Makefile.in | wc -l`
+# ... and it is the right one.
+grep '^INFO_DEPS *= *foo.info *$' Makefile.in
+
+# Likewise with AC_SUBST.
+
+cat > Makefile.am << 'END'
+info_TEXINFOS = bar.texi
+END
+cat >> configure.ac << 'END'
+AC_SUBST([INFO_DEPS])
+END
+rm -rf autom4te.cache # Make sure autoconf sees the configure.ac update.
+AUTOMAKE_fails
+
+grep '^configure\.ac:4:.*user variable.*INFO_DEPS' stderr
+grep 'overrides Automake variable.*INFO_DEPS' stderr
+
+$AUTOMAKE -Wno-override
+
+# There is only one definition of INFO_DEPS ...
+test 1 = `grep '^INFO_DEPS.*=' Makefile.in | wc -l`
+# ... and it is the right one.
+grep '^INFO_DEPS *= *@INFO_DEPS@ *$' Makefile.in
+
+:
diff --git a/t/txinfo3.sh b/t/txinfo3.sh
new file mode 100755
index 000000000..88e1bacfe
--- /dev/null
+++ b/t/txinfo3.sh
@@ -0,0 +1,53 @@
+#! /bin/sh
+# Copyright (C) 1997-2012 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/>.
+
+# Test to make sure .info-less @setfilename works.
+
+required='makeinfo tex texi2dvi'
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+info_TEXINFOS = textutils.texi
+END
+
+cat > textutils.texi <<EOF
+\input texinfo
+@setfilename textutils
+@settitle main
+@node Top
+Hello walls.
+@bye
+EOF
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+grep '^INFO_DEPS.*textutils$' Makefile.in
+
+# We should not use single suffix inference rules (with separate
+# dependencies), this confuses Solaris make.
+grep '^\.texi:$' Makefile.in && Exit 1
+grep 'textutils: *textutils\.texi' Makefile.in
+
+./configure
+$MAKE distcheck
+
+:
diff --git a/t/txinfo30.sh b/t/txinfo30.sh
new file mode 100755
index 000000000..09ebd5e18
--- /dev/null
+++ b/t/txinfo30.sh
@@ -0,0 +1,63 @@
+#! /bin/sh
+# Copyright (C) 2005-2012 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 'missing texinfo' does not create empty files.
+# Report from Bob Proulx.
+
+. ./defs || Exit 1
+
+echo info_TEXINFOS = bar.texi >Makefile.am
+echo grepme >bar.info
+$sleep
+cat >bar.texi <<EOF
+@setfilename bar.info
+EOF
+
+echo AC_OUTPUT >>configure.ac
+
+cat >makeinfo <<\EOF
+#!/bin/sh
+# This script
+# 1. fails so 'missing' can take over
+# 2. does not understand '--version' so 'missing' thinks 'makeinfo' isn't
+# installed
+exec false
+EOF
+
+chmod +x makeinfo
+
+PATH=`pwd`$PATH_SEPARATOR$PATH
+export PATH
+
+# Otherwise configure might pick up a working makeinfo from the
+# environment. Seen in automake bug#10866.
+unset MAKEINFO || :
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+
+./configure
+$MAKE
+grep grepme bar.info
+test -f bar.info
+
+# We should not create a missing bar.info.
+rm -f bar.info
+$MAKE && Exit 1
+test ! -f bar.info
+
+:
diff --git a/t/txinfo31.sh b/t/txinfo31.sh
new file mode 100755
index 000000000..191bca4ee
--- /dev/null
+++ b/t/txinfo31.sh
@@ -0,0 +1,29 @@
+#! /bin/sh
+# Copyright (C) 2006-2012 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 file extensions are matched correctly.
+# Report from Eric Dorland.
+
+. ./defs || Exit 1
+
+echo info_TEXINFOS = bar.texi >Makefile.am
+cat >bar.texi <<EOF
+@setfilename bar-1.9.info
+EOF
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
diff --git a/t/txinfo32.sh b/t/txinfo32.sh
new file mode 100755
index 000000000..7fa793858
--- /dev/null
+++ b/t/txinfo32.sh
@@ -0,0 +1,40 @@
+#! /bin/sh
+# Copyright (C) 2009-2012 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 the documentation targets work as required with BSD make,
+# even in the presence of subdirs (requires presence of default *-am rules).
+
+. ./defs || Exit 1
+
+mkdir sub
+cat >>configure.ac <<'END'
+AC_CONFIG_FILES([sub/Makefile])
+AC_OUTPUT
+END
+cat >Makefile.am <<'END'
+SUBDIRS = sub
+END
+: >sub/Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure "--prefix=`pwd`/inst"
+$MAKE html dvi ps pdf info \
+ install-html install-dvi install-ps install-pdf install-info \
+ install-man install-data install-exec install uninstall
+
+Exit 0
diff --git a/t/txinfo33.sh b/t/txinfo33.sh
new file mode 100755
index 000000000..4bdd76734
--- /dev/null
+++ b/t/txinfo33.sh
@@ -0,0 +1,126 @@
+#! /bin/sh
+# Copyright (C) 2003-2012 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/>.
+
+# DVIS, PDFS, PSS, HTMLS should not be cleaned upon 'mostlyclean'.
+# Similar to txinfo25.test.
+
+required='makeinfo tex texi2dvi-o dvips'
+. ./defs || Exit 1
+
+mkdir sub
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+info_TEXINFOS = main.texi other.texi sub/another.texi
+END
+
+cat > main.texi << 'END'
+\input texinfo
+@setfilename main.info
+@settitle main
+@node Top
+Hello walls.
+@include version.texi
+@bye
+END
+
+cat > other.texi << 'END'
+\input texinfo
+@setfilename other.info
+@settitle other
+@node Top
+Hello walls.
+@include version2.texi
+@bye
+END
+
+cat > sub/another.texi << 'END'
+\input texinfo
+@setfilename another.info
+@settitle another
+@node Top
+Hello walls.
+@include version3.texi
+@bye
+END
+
+$ACLOCAL
+$AUTOMAKE --add-missing
+$AUTOCONF
+
+# In-tree build.
+./configure
+$MAKE dvi ps pdf html
+
+test -f main.dvi
+test -f main.ps
+test -f main.html || test -d main.html
+test -f main.pdf
+test -f other.pdf
+test -f sub/another.pdf
+
+test -f other.dvi
+test -f other.html || test -d other.html
+test -f other.ps
+test -f sub/another.dvi
+test -f sub/another.html || test -d sub/another.html
+test -f sub/another.ps
+
+$MAKE mostlyclean
+
+ls *.aux && Exit 1
+ls sub/*.aux && Exit 1
+
+test -f main.dvi
+test -f main.ps
+test -f main.html || test -d main.html
+test -f main.pdf
+test -f other.pdf
+test -f sub/another.pdf
+
+test -f other.dvi
+test -f other.html || test -d other.html
+test -f other.ps
+test -f sub/another.dvi
+test -f sub/another.html || test -d sub/another.html
+test -f sub/another.ps
+
+$MAKE clean
+
+test ! -f main.dvi
+test ! -f main.ps
+test ! -f main.html && test ! -d main.html
+test ! -f main.pdf
+test ! -f other.pdf
+test ! -f sub/another.pdf
+test ! -f sub/yetanother.pdf
+
+test ! -f other.dvi
+test ! -f other.html && test ! -d other.html
+test ! -f other.ps
+test ! -f sub/another.dvi
+test ! -f sub/another.html && test ! -d sub/another.html
+test ! -f sub/another.ps
+
+./configure
+$MAKE
+
+$MAKE distcheck
+
+:
diff --git a/t/txinfo4.sh b/t/txinfo4.sh
new file mode 100755
index 000000000..f92f9c1a4
--- /dev/null
+++ b/t/txinfo4.sh
@@ -0,0 +1,32 @@
+#! /bin/sh
+# Copyright (C) 1997-2012 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 non-empty, non-info suffixes are diagnosed.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+info_TEXINFOS = textutils.texi
+END
+
+echo '@setfilename textutils.frob' > textutils.texi
+: > texinfo.tex
+
+$ACLOCAL
+AUTOMAKE_fails
+grep 'textutils\.texi:1:.*textutils\.frob.*extension' stderr
+
+:
diff --git a/t/txinfo5.sh b/t/txinfo5.sh
new file mode 100755
index 000000000..9e42823ea
--- /dev/null
+++ b/t/txinfo5.sh
@@ -0,0 +1,38 @@
+#! /bin/sh
+# Copyright (C) 1998-2012 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/>.
+
+# Test to make sure that texinfo.tex is not required by --cygnus.
+# Also check that TEXINFOS + cygnus work without requiring the
+# '-Wno-override' option.
+# See also sister test txinfo5b.test.
+# Report from Ian Taylor.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AM_MAINTAINER_MODE
+END
+
+cat > Makefile.am << 'END'
+info_TEXINFOS = ian.texi
+END
+
+echo '@setfilename ian.info' > ian.texi
+
+$ACLOCAL
+$AUTOMAKE --cygnus
+
+:
diff --git a/t/txinfo5b.sh b/t/txinfo5b.sh
new file mode 100755
index 000000000..c4eac537e
--- /dev/null
+++ b/t/txinfo5b.sh
@@ -0,0 +1,41 @@
+#! /bin/sh
+# Copyright (C) 1998-2012 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/>.
+
+# Test to make sure that texinfo.tex is not required by --cygnus.
+# See also sister test txinfo5.test.
+# Report from Ian Taylor.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AM_MAINTAINER_MODE
+END
+
+cat > Makefile.am << 'END'
+# Disable 'override' warning to work around an unrelated
+# texi+cygnus bug.
+AUTOMAKE_OPTIONS = -Wno-override
+info_TEXINFOS = ian.texi
+END
+
+echo '@setfilename ian.info' > ian.texi
+
+$ACLOCAL
+$AUTOMAKE --cygnus
+$AUTOMAKE -a --cygnus
+test ! -f texinfo.tex
+
+:
diff --git a/t/txinfo6.sh b/t/txinfo6.sh
new file mode 100755
index 000000000..b289efee4
--- /dev/null
+++ b/t/txinfo6.sh
@@ -0,0 +1,33 @@
+#! /bin/sh
+# Copyright (C) 1998-2012 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/>.
+
+# Test to make sure '.txi' extension works.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+info_TEXINFOS = foo.txi
+END
+
+echo '@setfilename foo.info' > foo.txi
+: > texinfo.tex
+
+$ACLOCAL
+$AUTOMAKE
+
+grep '^\.txi\.info: *$' Makefile.in
+
+:
diff --git a/t/txinfo7.sh b/t/txinfo7.sh
new file mode 100755
index 000000000..2a5dc9dc0
--- /dev/null
+++ b/t/txinfo7.sh
@@ -0,0 +1,33 @@
+#! /bin/sh
+# Copyright (C) 1998-2012 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/>.
+
+# Test to make sure texinfo.tex correctly installed by -a. Bug report
+# by Per Cederqvist.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+info_TEXINFOS = textutils.texi
+END
+
+echo '@setfilename textutils.info' > textutils.texi
+
+$ACLOCAL
+$AUTOMAKE -a
+
+test -f texinfo.tex
+
+:
diff --git a/t/txinfo8.sh b/t/txinfo8.sh
new file mode 100755
index 000000000..4b186bc38
--- /dev/null
+++ b/t/txinfo8.sh
@@ -0,0 +1,62 @@
+#! /bin/sh
+# Copyright (C) 1999-2012 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/>.
+
+# Test to make sure texinfo.tex is correctly installed and disted by
+# -a when we're using AC_CONFIG_AUX_DIR. Bug report by by Per
+# Cederqvist.
+
+. ./defs || Exit 1
+
+cat > configure.ac << END
+AC_INIT([$me], [1.0])
+AC_CONFIG_AUX_DIR([auxdir])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+info_TEXINFOS = textutils.texi
+.PHONY: test1 test2
+test1:
+ @echo DISTFILES = $(DISTFILES)
+ echo ' ' $(DISTFILES) ' ' | grep '[ /]auxdir/texinfo\.tex '
+test2: distdir
+ ls -l $(distdir)/*
+ test -f $(distdir)/auxdir/texinfo.tex
+END
+
+echo '@setfilename textutils.info' > textutils.texi
+
+mkdir auxdir
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+test -f auxdir/texinfo.tex
+
+./configure
+
+# Create textutils.info by hand, so that we don't have to require
+# makeinfo. Also ensure it's really newer than textutils.texi, so
+# that make won't try to re-create it.
+$sleep
+: > textutils.info
+
+$MAKE test1 test2
+
+:
diff --git a/t/txinfo9.sh b/t/txinfo9.sh
new file mode 100755
index 000000000..eb2cbdcae
--- /dev/null
+++ b/t/txinfo9.sh
@@ -0,0 +1,41 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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 we only create texinfo-related targets once.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+info_TEXINFOS = maude.texi liver.txi heart.texinfo
+END
+
+echo '@setfilename maude.info' > maude.texi
+echo '@setfilename liver.info' > liver.txi
+echo '@setfilename heart.info' > heart.texinfo
+: > texinfo.tex
+
+$ACLOCAL
+$AUTOMAKE
+
+# These are just examples -- basically for many targets in texinfos.am
+# we only want them to appear once. But grepping them all would be
+# overkill.
+for t in info dist-info dvi-am install-html uninstall-pdf-am; do
+ $EGREP "(^| )$t*.:" Makefile.in # For debugging.
+ test `$EGREP -c "(^| )$t(:| *.:)" Makefile.in` -eq 1
+done
+
+:
diff --git a/t/uninstall-fail.sh b/t/uninstall-fail.sh
new file mode 100755
index 000000000..aee1fb5b7
--- /dev/null
+++ b/t/uninstall-fail.sh
@@ -0,0 +1,96 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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 uninstall" complains and errors out on failures.
+
+# FIXME: this test only deal with DATA primary; maybe we need sister
+# tests for other primaries too? E.g., SCRIPTS, PROGRAMS, LISP, PYTHON,
+# etc...
+
+. ./defs || Exit 1
+
+mkdir d
+: > d/f
+chmod a-w d || skip "cannot make directories unwritable"
+
+# On Solaris 10, if '/bin/rm' is run with the '-f' option, it doesn't
+# print any error message when failing to remove a file (due to e.g.,
+# "Permission denied"). Yikes. We'll cater to this incompatibility
+# by relaxing a test below if a faulty 'rm' is detected.
+st=0; rm -f d/f 2>stderr || st=$?
+cat stderr >&2
+test $st -gt 0 || skip_ "can delete files from unwritable directories"
+if grep 'rm:' stderr; then
+ rm_f_is_silent_on_error=no
+else
+ rm_f_is_silent_on_error=yes
+fi
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+data_DATA = foobar.txt
+END
+
+: > foobar.txt
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+
+inst=__inst-dir__
+
+./configure --prefix="`pwd`/$inst"
+
+mkdir $inst $inst/share
+: > $inst/share/foobar.txt
+
+chmod a-w $inst/share
+$MAKE uninstall >output 2>&1 && { cat output; Exit 1; }
+cat output
+if test $rm_f_is_silent_on_error = yes; then
+ : "rm -f" is silent on errors, skip the grepping of make output
+else
+ grep "rm: .*foobar\.txt" output
+fi
+
+chmod a-rwx $inst/share
+(cd $inst/share) && skip_ "cannot make directories fully unreadable"
+
+$MAKE uninstall >output 2>&1 && { cat output; Exit 1; }
+cat output
+#
+# Some shells, like Solaris 10 /bin/sh and /bin/ksh, do not report
+# the name of the 'cd' builtin upon a chdir error:
+#
+# $ /bin/sh -c 'cd /none'
+# /bin/sh: /none: does not exist
+#
+# In addition, some shells, like Solaris 10 /usr/xpg4/bin/sh, also print
+# a line number in the error message *if the command contains newlines*:
+#
+# $ /usr/xpg4/bin/sh -c 'cd unreadable'
+# /usr/xpg4/bin/sh: unreadable: permission denied
+# $ /usr/xpg4/bin/sh -c '\
+# > \
+# > cd unreadable'
+# /usr/xpg4/bin/sh[3]: unreadable: permission denied
+#
+$EGREP "(cd|sh)(\[[0-9]*[0-9]\])?: .*$inst/share" output
+
+:
diff --git a/t/uninstall-pr9578.sh b/t/uninstall-pr9578.sh
new file mode 100755
index 000000000..1ba6ac7ed
--- /dev/null
+++ b/t/uninstall-pr9578.sh
@@ -0,0 +1,67 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check against automake bug#9578: "make uninstall" issued before
+# "make install" or after a mere "make install-data" or a mere
+# "make install-exec" failed spuriously.
+#
+# FIXME: this test only deal with DATA and script primaries; maybe we
+# need sister tests for other primaries too? E.g., PROGRAMS, LISP,
+# PYTHON, etc...
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_OUTPUT
+END
+
+: > foo
+: > bar
+
+cat > Makefile.am << 'END'
+bin_SCRIPTS = foo
+data_DATA = bar
+END
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+
+./configure --prefix="`pwd`/inst"
+
+$MAKE uninstall
+test ! -d inst
+
+rm -rf inst
+
+$MAKE install-exec
+test -f inst/bin/foo || Exit 99 # Sanity check.
+$MAKE uninstall
+test ! -f inst/bin/foo
+
+$MAKE install-data
+test -f inst/share/bar || Exit 99 # Sanity check.
+$MAKE uninstall
+test ! -f inst/share/bar
+
+rm -rf inst
+
+$MAKE install-exec
+test -f inst/bin/foo || Exit 99 # Sanity check.
+$MAKE uninstall
+test ! -f inst/bin/foo
+
+:
diff --git a/t/unused.sh b/t/unused.sh
new file mode 100755
index 000000000..271273fe5
--- /dev/null
+++ b/t/unused.sh
@@ -0,0 +1,35 @@
+#! /bin/sh
+# Copyright (C) 1998-2012 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/>.
+
+# Test for failing check for unused macros. From Johan Danielsson.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+MACRO_1
+MACRO_1_2
+MACRO_1_2_3
+END
+
+cat > acinclude.m4 << 'END'
+AC_DEFUN([MACRO_1], echo 1)
+AC_DEFUN([MACRO_1_2], echo 12)
+AC_DEFUN([MACRO_1_2_3], echo 123)
+END
+
+$ACLOCAL 2>stderr || { cat stderr >&2; Exit 1; }
+cat stderr >&2
+test ! -s stderr
diff --git a/t/upc.sh b/t/upc.sh
new file mode 100755
index 000000000..320e02fc7
--- /dev/null
+++ b/t/upc.sh
@@ -0,0 +1,50 @@
+#! /bin/sh
+# Copyright (C) 2006-2012 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/>.
+
+# A simple Hello World for UPC.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AM_PROG_UPC
+AC_OUTPUT
+END
+
+cat > hello.upc << 'END'
+#include <stdio.h>
+#include <upc.h>
+int
+main (void)
+{
+ printf ("Thread %d says, 'Hello.'\n", MYTHREAD);
+ return 0;
+}
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = hello
+hello_SOURCES = hello.upc
+hello_LDADD = -lm
+END
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+
+./configure || Exit $?
+$MAKE distcheck
+
+:
diff --git a/t/upc2.sh b/t/upc2.sh
new file mode 100755
index 000000000..43575d8cb
--- /dev/null
+++ b/t/upc2.sh
@@ -0,0 +1,31 @@
+#! /bin/sh
+# Copyright (C) 2006-2012 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/>.
+
+# Test that Automake suggests using AM_PROG_UPC if Unified Parallel C
+# sources are used.
+
+. ./defs || Exit 1
+
+echo AC_PROG_CC >>configure.ac
+
+cat >Makefile.am <<'END'
+bin_PROGRAMS = hello
+hello_SOURCES = hello.upc
+END
+
+$ACLOCAL
+AUTOMAKE_fails
+grep AM_PROG_UPC stderr
diff --git a/t/upc3.sh b/t/upc3.sh
new file mode 100755
index 000000000..eb026792c
--- /dev/null
+++ b/t/upc3.sh
@@ -0,0 +1,65 @@
+#! /bin/sh
+# Copyright (C) 2006-2012 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/>.
+
+# Test that C and Unified Parallel C link safely.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_UPC
+AC_OUTPUT
+END
+
+cat > hello.upc << 'END'
+#include <stdio.h>
+#include <upc.h>
+#include "message.h"
+int
+main (void)
+{
+ printf ("Thread %d says, '%s'\n", MYTHREAD, message());
+ return 0;
+}
+END
+
+cat > message.h << 'END'
+const char *message (void);
+END
+
+cat > mix.c << 'END'
+#include "message.h"
+const char *
+message (void)
+{
+ return "Hello.";
+}
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = hello
+hello_SOURCES = hello.upc mix.c message.h
+hello_LDADD = -lm
+END
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+
+./configure || Exit $?
+$MAKE distcheck
+
+:
diff --git a/t/vala-mix.sh b/t/vala-mix.sh
new file mode 100755
index 000000000..58ab50028
--- /dev/null
+++ b/t/vala-mix.sh
@@ -0,0 +1,115 @@
+#! /bin/sh
+# Copyright (C) 2012 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/>.
+
+# Vala sources and C sources in the same program. Functional test.
+
+required='valac cc GNUmake'
+. ./defs || Exit 1
+
+cat >> configure.ac <<'END'
+AC_PROG_CC
+AM_PROG_CC_C_O
+AM_PROG_VALAC([0.7.3])
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+bin_PROGRAMS = zardoz mu
+AM_VALAFLAGS = --profile=posix
+zardoz_SOURCES = foo.vala bar.c
+mu_SOURCES = 1.vala 2.c
+mu_VALAFLAGS = $(AM_VALAFLAGS) --main=run
+mu_CFLAGS = -DHAVE_MU
+END
+
+if cross_compiling; then :; else
+ unindent >> Makefile.am <<'END'
+ check-local:
+ ./zardoz
+ ./mu
+ ./zardoz | grep "foo is alive"
+ ./mu | grep "Howdy, World!"
+END
+fi
+
+cat > foo.vala <<'END'
+int main ()
+{
+ stdout.printf ("foo is alive\n");
+ return 0;
+}
+END
+
+echo 'extern int i = 0;' > bar.c
+
+cat > 1.vala <<'END'
+int run ()
+{
+ stdout.printf ("Howdy, World!\n");
+ return 0;
+}
+END
+
+cat > 2.c <<'END'
+#ifdef HAVE_MU
+int all_is_ok = 1;
+#else
+#error "HAVE_MU no defined"
+chocke me
+#endif
+END
+
+$ACLOCAL
+$AUTOMAKE -a
+$AUTOCONF
+
+./configure
+
+$MAKE all
+ls -l # For debugging.
+$MAKE check
+
+have_generated_files ()
+{
+ test -f mu_vala.stamp
+ test -f zardoz_vala.stamp
+ test -f foo.c
+ test -f 1.c
+}
+
+# Our vala-related rules must create stamp files and intermediate
+# C files.
+have_generated_files
+
+# Remake rules are not uselessly triggered.
+$MAKE -q
+$MAKE -n | $FGREP vala.stamp && Exit 1
+
+# Check the distribution.
+$MAKE distcheck
+
+# Stamp files and intermediate C files should *not* be removed
+# by "make clean".
+$MAKE clean
+have_generated_files
+
+# But stamp files should be removed by "maintainer-clean" (the
+# behaviour w.r.t. intermediate C files is still unclear, and
+# better left undefined for the moment).
+$MAKE maintainer-clean
+ls *vala*.stamp | grep . && Exit 1
+
+:
diff --git a/t/vala-mix2.sh b/t/vala-mix2.sh
new file mode 100755
index 000000000..516246724
--- /dev/null
+++ b/t/vala-mix2.sh
@@ -0,0 +1,119 @@
+#! /bin/sh
+# Copyright (C) 2012 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/>.
+
+# Vala sources, C and C++ sources and C and C++ headers in the same
+# program. Functional test. See automake bug#10894.
+
+required='valac cc c++ GNUmake'
+. ./defs || Exit 1
+
+cat >> configure.ac <<'END'
+AC_PROG_CC
+AC_PROG_CXX
+AM_PROG_VALAC([0.7.3])
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+bin_PROGRAMS = zardoz
+AM_VALAFLAGS = --profile=posix
+zardoz_SOURCES = zardoz.vala foo.h bar.c baz.c zen.hh master.cxx
+END
+
+cat > zardoz.vala <<'END'
+int main ()
+{
+ stdout.printf ("foo is alive\n");
+ return 0;
+}
+END
+
+cat > foo.h <<'END'
+int foo;
+int bar (void);
+int baz (void);
+END
+
+cat > bar.c <<'END'
+#include "foo.h"
+int bar (void) { return foo + baz (); }
+END
+
+cat > baz.c <<'END'
+#include "foo.h"
+extern int foo = 0;
+int baz (void) { return 0; }
+END
+
+cat > zen.hh <<'END'
+#include <iostream>
+END
+
+cat > master.cxx <<'END'
+#include "zen.hh"
+void chatty (void) { std::cout << "Hello, stranger!\n"; }
+END
+
+$ACLOCAL
+$AUTOMAKE -a
+$AUTOCONF
+
+./configure
+
+$MAKE all
+ls -l # For debugging.
+
+have_generated_files ()
+{
+ test -f zardoz_vala.stamp
+ test -f zardoz.c
+}
+
+# Our vala-related rules must create stamp files and intermediate
+# C files.
+have_generated_files
+
+# Remake rules are not uselessly triggered.
+$MAKE -q
+$MAKE -n | $FGREP vala.stamp && Exit 1
+
+# But are triggered when they should.
+for file in zardoz.vala foo.h bar.c baz.c zen.hh master.cxx; do
+ $sleep
+ echo '& choke me !' >> $file
+ $MAKE && Exit 1
+ $sleep
+ sed '$d' $file > t
+ mv -f t $file
+ $MAKE
+done
+
+# Check the distribution.
+$MAKE distcheck
+
+# Stamp files and intermediate C files should *not* be removed
+# by "make clean".
+$MAKE clean
+ls -l # For debugging.
+have_generated_files
+
+# But stamp files should be removed by "maintainer-clean" (the
+# behaviour w.r.t. intermediate C files is still unclear, and
+# better left undefined for the moment).
+$MAKE maintainer-clean
+ls *vala*.stamp | grep . && Exit 1
+
+:
diff --git a/t/vala-vpath.sh b/t/vala-vpath.sh
new file mode 100755
index 000000000..a968afa0e
--- /dev/null
+++ b/t/vala-vpath.sh
@@ -0,0 +1,70 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Test to make sure vala support handles from-scratch VPATH builds.
+# See automake bug#8753.
+
+required="valac GNUmake"
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_CONFIG_SRCDIR([hello.vala])
+AC_PROG_CC
+AM_PROG_VALAC([0.7.3])
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+bin_PROGRAMS = foo
+foo_VALAFLAGS = --profile=posix
+foo_SOURCES = hello.vala
+END
+
+cat > hello.vala <<'END'
+void main ()
+{
+ stdout.printf ("foofoofoo\n");
+}
+END
+
+$ACLOCAL || framework_failure_ "aclocal error"
+$AUTOCONF || framework_failure_ "autoconf error"
+$AUTOMAKE || framework_failure_ "automake error"
+
+mkdir build
+cd build
+../configure || Exit 77
+$MAKE
+grep foofoofoo ../hello.c
+$MAKE distcheck
+
+# Rebuild rules work also in VPATH builds.
+cat > ../hello.vala <<'END'
+int main ()
+{
+ stdout.printf ("barbarbar\n");
+ return 0;
+}
+END
+
+$MAKE
+grep barbarbar ../hello.c
+
+# Rebuild rules are not uselessly triggered.
+$MAKE -q
+$MAKE -n | grep '\.stamp' && Exit 1
+
+:
diff --git a/t/vala.sh b/t/vala.sh
new file mode 100755
index 000000000..71c2ee6eb
--- /dev/null
+++ b/t/vala.sh
@@ -0,0 +1,86 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Basic "grepping" test on vala support.
+
+. ./defs || Exit 1
+
+# So that we won't require libtool macros.
+cat > acinclude.m4 <<'END'
+AC_DEFUN([AC_PROG_LIBTOOL],
+ [AC_SUBST([LIBTOOL], [:])])
+END
+
+cat >> 'configure.ac' << 'END'
+AC_PROG_CC
+AC_PROG_CXX
+AM_PROG_AR
+AC_PROG_LIBTOOL
+AM_PROG_VALAC
+AC_CONFIG_FILES([sub/Makefile])
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+SUBDIRS = sub
+
+bin_PROGRAMS = zardoz
+zardoz_SOURCES = zardoz.vala
+zardoz_VALAFLAGS = --debug
+
+lib_LTLIBRARIES = libzardoz.la
+libzardoz_la_SOURCES = zardoz-foo.vala zardoz-bar.vala
+END
+
+mkdir sub
+
+cat > sub/Makefile.am <<'END'
+bin_PROGRAMS = foo
+foo_SOURCES = bar.vala baz.vala mu.c zap.cxx
+END
+
+: > ltmain.sh
+: > config.sub
+: > config.guess
+
+$ACLOCAL
+$AUTOMAKE -a
+
+grep '\$(VALAC).* \$(AM_VALAFLAGS) \$(VALAFLAGS) ' Makefile.in
+grep '\$(VALAC).* \$(zardoz_VALAFLAGS) \$(VALAFLAGS) ' Makefile.in
+$FGREP 'am_zardoz_OBJECTS' Makefile.in
+$FGREP 'am_libzardoz_la_OBJECTS' Makefile.in
+$FGREP 'zardoz_vala.stamp:' Makefile.in
+$FGREP 'libzardoz_la_vala.stamp:' Makefile.in
+test `$FGREP -c '.stamp:' Makefile.in` -eq 2
+$FGREP 'zardoz.c' Makefile.in
+$FGREP 'zardoz-foo.c' Makefile.in
+$FGREP 'zardoz-bar.c' Makefile.in
+
+grep '\$(VALAC).* \$(AM_VALAFLAGS) \$(VALAFLAGS) ' sub/Makefile.in
+$FGREP 'foo_VALAFLAGS' sub/Makefile.in && Exit 1
+$FGREP 'am_foo_OBJECTS' sub/Makefile.in
+$FGREP 'bar.c' sub/Makefile.in
+$FGREP 'baz.c' sub/Makefile.in
+$FGREP 'foo_vala.stamp:' sub/Makefile.in
+test `$FGREP -c '.stamp:' sub/Makefile.in` -eq 1
+
+# Check against regression for weird bug due to unescaped '@'
+# characters used in a "..." perl string when writing the vala
+# rules from automake.in.
+grep '\$[0-9][0-9]*t' Makefile.in sub/Makefile.in && Exit 1
+
+:
diff --git a/t/vala1.sh b/t/vala1.sh
new file mode 100755
index 000000000..9aca0fbc3
--- /dev/null
+++ b/t/vala1.sh
@@ -0,0 +1,52 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test to make sure intermediate .c files are built from vala sources
+# in non-recursive automake mode.
+
+required="libtool"
+. ./defs || Exit 1
+
+cat >> 'configure.ac' << 'END'
+AC_PROG_CC
+AM_PROG_AR
+AC_PROG_LIBTOOL
+AM_PROG_VALAC
+AC_OUTPUT
+END
+
+cat > 'Makefile.am' <<'END'
+bin_PROGRAMS = src/zardoz
+src_zardoz_SOURCES = src/zardoz.vala
+
+lib_LTLIBRARIES = src/libzardoz.la
+src_libzardoz_la_SOURCES = src/zardoz-foo.vala src/zardoz-bar.vala
+END
+
+: > ltmain.sh
+: > config.sub
+: > config.guess
+
+$ACLOCAL
+$AUTOMAKE -a
+
+grep 'VALAC' Makefile.in
+grep 'src_zardoz_OBJECTS' Makefile.in
+grep 'src_libzardoz_la_OBJECTS' Makefile.in
+grep 'src_zardoz_vala.stamp' Makefile.in
+grep 'src_libzardoz_la_vala.stamp' Makefile.in
+grep 'zardoz\.c' Makefile.in
+grep 'src/zardoz-foo\.c' Makefile.in
diff --git a/t/vala2.sh b/t/vala2.sh
new file mode 100755
index 000000000..cceed5495
--- /dev/null
+++ b/t/vala2.sh
@@ -0,0 +1,87 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test to make sure compiling Vala code really works with recursive make.
+
+required="libtool libtoolize pkg-config valac gcc GNUmake"
+. ./defs || Exit 1
+
+mkdir src
+
+cat >> 'configure.ac' << 'END'
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_PROG_LIBTOOL
+AM_PROG_VALAC([0.7.0])
+PKG_CHECK_MODULES([GOBJECT],[gobject-2.0 >= 2.10])
+AC_CONFIG_FILES([src/Makefile])
+AC_OUTPUT
+END
+
+cat > 'Makefile.am' <<'END'
+SUBDIRS = src
+END
+
+cat > 'src/Makefile.am' <<'END'
+bin_PROGRAMS = zardoz
+zardoz_VALAFLAGS = -H zardoz.h
+zardoz_CFLAGS = $(GOBJECT_CFLAGS)
+zardoz_LDADD = $(GOBJECT_LIBS)
+zardoz_SOURCES = zardoz.vala
+END
+
+cat > 'src/zardoz.vala' <<'END'
+using GLib;
+
+public class Zardoz {
+ public static void main () {
+ stdout.printf ("Zardoz!\n");
+ }
+}
+END
+
+libtoolize
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure || skip_ "configure failure"
+$MAKE
+
+# Test rebuild rules.
+rm -f src/zardoz.h
+$MAKE -C src zardoz.h
+
+$MAKE distcheck
+$MAKE distclean
+mkdir build
+cd build
+../configure
+$MAKE
+$MAKE distcheck
+
+# Test rebuild rules from builddir.
+rm -f ../src/zardoz.c
+$MAKE
+grep 'Zardoz!' ../src/zardoz.c
+sed 's/Zardoz!/FooBar!/' ../src/zardoz.c > t
+mv -f t ../src/zardoz.c
+$MAKE
+grep 'FooBar!' ../src/zardoz.c
+grep 'Zardoz!' ../src/zardoz.c && Exit 1
+
+:
diff --git a/t/vala3.sh b/t/vala3.sh
new file mode 100755
index 000000000..c93db9a9b
--- /dev/null
+++ b/t/vala3.sh
@@ -0,0 +1,96 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test to make sure compiling Vala code really works with non-recursive make.
+
+required="libtool libtoolize pkg-config valac gcc GNUmake"
+. ./defs || Exit 1
+
+mkdir src
+
+cat >> 'configure.ac' << 'END'
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_PROG_LIBTOOL
+AM_PROG_VALAC([0.7.0])
+PKG_CHECK_MODULES([GOBJECT],[gobject-2.0 >= 2.10])
+AC_OUTPUT
+END
+
+cat > 'src/zardoz.vala' <<'END'
+using GLib;
+
+public class Zardoz {
+ public static void main () {
+ stdout.printf ("Zardoz!\n");
+ }
+}
+END
+
+cat > 'Makefile.am' <<'END'
+bin_PROGRAMS = src/zardoz
+src_zardoz_CFLAGS = $(GOBJECT_CFLAGS)
+src_zardoz_LDADD = $(GOBJECT_LIBS)
+src_zardoz_SOURCES = src/zardoz.vala
+END
+
+libtoolize
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure || skip_ "configure failure"
+$MAKE
+$MAKE distcheck
+$MAKE distclean
+mkdir build
+cd build
+../configure
+$MAKE
+$MAKE distcheck
+
+cd ..
+rm -rf build
+
+# Try again with subdir-objects.
+
+cat > 'Makefile.am' <<'END'
+AUTOMAKE_OPTIONS = subdir-objects
+
+bin_PROGRAMS = src/zardoz
+src_zardoz_CFLAGS = $(GOBJECT_CFLAGS)
+src_zardoz_LDADD = $(GOBJECT_LIBS)
+src_zardoz_SOURCES = src/zardoz.vala
+END
+
+libtoolize
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure || skip_ "configure failure"
+$MAKE
+$MAKE distcheck
+$MAKE distclean
+mkdir build
+cd build
+../configure
+$MAKE
+$MAKE distcheck
+
+
diff --git a/t/vala4.sh b/t/vala4.sh
new file mode 100755
index 000000000..2e776edc7
--- /dev/null
+++ b/t/vala4.sh
@@ -0,0 +1,61 @@
+#! /bin/sh
+# Copyright (C) 2008-2012 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/>.
+
+# Test AM_PROG_VALAC.
+
+required=libtoolize
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_PROG_LIBTOOL
+AM_PROG_VALAC([0.0.1])
+AC_OUTPUT
+END
+
+: > Makefile.am
+
+cat > valac << 'END'
+#! /bin/sh
+if test "x$1" = x--version; then
+ echo 1.2.3
+fi
+exit 0
+END
+chmod +x valac
+
+cwd=`pwd`
+
+# Use $cwd instead of `pwd` in the && list below to avoid a bug in
+# the way Solaris/Heirloom Sh handles 'set -e'.
+
+libtoolize
+$ACLOCAL
+$AUTOMAKE -a
+$AUTOCONF
+./configure "VALAC=$cwd/valac" || Exit $?
+
+sed 's/AM_PROG_VALAC.*/AM_PROG_VALAC([9999.9])/' < configure.ac >t
+mv -f t configure.ac
+$AUTOCONF --force
+./configure "VALAC=$cwd/valac" && Exit 1
+
+sed 's/AM_PROG_VALAC.*/AM_PROG_VALAC([1.2.3])/' < configure.ac >t
+mv -f t configure.ac
+$AUTOCONF --force
+./configure "VALAC=$cwd/valac" || Exit $?
+
+:
diff --git a/t/vala5.sh b/t/vala5.sh
new file mode 100755
index 000000000..79fb31623
--- /dev/null
+++ b/t/vala5.sh
@@ -0,0 +1,83 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test per-target flags.
+
+required="pkg-config valac gcc GNUmake"
+. ./defs || Exit 1
+
+mkdir src
+
+cat >> configure.ac <<'END'
+AC_PROG_CC
+AM_PROG_CC_C_O
+AM_PROG_VALAC([0.7.0])
+PKG_CHECK_MODULES([GOBJECT], [gobject-2.0 >= 2.10])
+AC_CONFIG_FILES([src/Makefile])
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+SUBDIRS = src
+END
+
+cat > src/Makefile.am <<'END'
+bin_PROGRAMS = foo bar
+foo_CFLAGS = $(GOBJECT_CFLAGS)
+foo_LDADD = $(GOBJECT_LIBS)
+foo_SOURCES = xfoo.vala
+bar_SOURCES = xbar.vala
+bar_VALAFLAGS = -D BAR
+bar_CFLAGS = $(GOBJECT_CFLAGS)
+bar_LDADD = $(GOBJECT_LIBS)
+END
+
+cat > src/xfoo.vala <<'END'
+int main ()
+{
+ stdout.printf ("foo\n");
+ return 0;
+}
+END
+
+cat > src/xbar.vala <<'END'
+void main ()
+{
+#if BAR
+ stdout.printf ("bar\n");
+#else
+ stdout.oops_an_invalid_method ();
+#endif
+}
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+grep PKG_CHECK_MODULES configure && skip_ "pkg-config m4 macros not found"
+
+./configure
+$MAKE
+
+if cross_compiling; then :; else
+ ./src/foo
+ ./src/bar
+ test `./src/foo` = foo
+ test `./src/bar` = bar
+fi
+
+:
diff --git a/t/vars.sh b/t/vars.sh
new file mode 100755
index 000000000..1e3e91e65
--- /dev/null
+++ b/t/vars.sh
@@ -0,0 +1,36 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test various variable definitions that include an '=' sign.
+# From Raja R Harinath.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+MY_FLAGS_1=-DABC=345
+MY_FLAGS_2= -DABC=345
+MY_FLAGS_3 =-DABC=345
+MY_FLAGS_4 = -DABC=345
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+for i in 1 2 3 4; do
+ grep "^MY_FLAGS_$i *= *-DABC=345 *$" Makefile.in
+done
+
+:
diff --git a/t/vars3.sh b/t/vars3.sh
new file mode 100755
index 000000000..246ea7095
--- /dev/null
+++ b/t/vars3.sh
@@ -0,0 +1,72 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Check that Automake warns about variables containing spaces
+# and other non-POSIX characters.
+
+. ./defs || Exit 1
+
+cat >Makefile.am <<'EOF'
+L01 = $(shell echo *)
+L02 = $$(not an error)
+L03 = $$(this is)$${ok too}
+L04 = $(nextvariableisbad)$(addsuffix .a, $(A))
+L05 = "$(bad boy)"
+L06 = $(this:is= ok)
+L07 = ${three errors}${on this} $(long line)
+L08$(o u c h): $(wildcard *.c)
+ ${another Error}
+ echo $${ok-this is}
+L11: $(thisis) $(ok)
+ ${here}
+EOF
+
+$ACLOCAL
+# Make sure this warning is print in the 'portability' category.
+$AUTOMAKE --warnings=no-error,none,portability 2>stderr \
+ || { cat stderr >&2; Exit 1; }
+cat stderr >&2
+
+# Lines number are printed in error message.
+# Use them to make sure errors are diagnosed against the right lines.
+
+# No error expected apart from those on these lines.
+grep -v '^Makefile\.am:[145789]:' stderr | grep . && Exit 1
+
+# Now check some individual values.
+grep ':1:.*shell echo' stderr
+grep 'nextvariableisbad' stderr && Exit 1
+grep ':4:.*addsuffix' stderr
+grep ':5:.*bad boy' stderr
+grep ':7:.*three errors' stderr
+grep ':7:.*on this' stderr
+grep ':7:.*long line' stderr
+grep ':8:.*o u c h' stderr
+grep ':8:.*wildcard' stderr
+grep ':9:.*another Error' stderr
+
+$EGREP 'ok|thisis|here' stderr && Exit 1
+
+# None of these errors be diagnosed with '-Wno-portability'.
+$AUTOMAKE -Wno-portability
+
+# Likewise if we add this in the Makefile.am
+# (although this makes some difference internally: AUTOMAKE_OPTIONS is
+# processed far later).
+echo 'AUTOMAKE_OPTIONS = -Wno-portability' >> Makefile.am
+$AUTOMAKE
+
+:
diff --git a/t/vartar.sh b/t/vartar.sh
new file mode 100755
index 000000000..ebac14ba0
--- /dev/null
+++ b/t/vartar.sh
@@ -0,0 +1,39 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Targets and macros are two different name spaces.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+install = install
+install:
+ $(install) install
+END
+
+$ACLOCAL
+$AUTOMAKE -Wno-override
+
+grep '^install = install$' Makefile.in
+
+cat > target.expected <<'EOF'
+install:
+ $(install) install
+EOF
+sed -n '/^install:/,/^ /p' Makefile.in > target.value
+diff target.expected target.value
+
+:
diff --git a/t/vartypo2.sh b/t/vartypo2.sh
new file mode 100755
index 000000000..9b52df683
--- /dev/null
+++ b/t/vartypo2.sh
@@ -0,0 +1,70 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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 we warn about possible variable typos when we should,
+# Libtool variant.
+
+required=libtoolize
+. ./defs || Exit 1
+
+cat >>configure.ac <<'END'
+AM_PROG_AR
+AC_PROG_LIBTOOL
+AC_OUTPUT
+END
+
+cat >Makefile.am <<'END'
+libfoo_la_SOURCES = unused
+nodist_libfoo_la_SOURCES = unused
+EXTRA_libfoo_la_SOURCES = unused
+libfoo_la_LIBADD = unused
+libfoo_la_DEPENDENCIES = unused
+EXTRA_libfoo_la_DEPENDENCIES = unused
+END
+
+libtoolize
+$ACLOCAL
+AUTOMAKE_fails --add-missing
+# The expected diagnostic is:
+# automake: warnings are treated as errors
+# Makefile.am:3: warning: variable `EXTRA_libfoo_la_SOURCES' is defined but no program or
+# Makefile.am:3: library has `libfoo_la' as canonical name (possible typo)
+# Makefile.am:1: warning: variable `libfoo_la_SOURCES' is defined but no program or
+# Makefile.am:1: library has `libfoo_la' as canonical name (possible typo)
+# Makefile.am:2: warning: variable `nodist_libfoo_la_SOURCES' is defined but no program or
+# Makefile.am:2: library has `libfoo_la' as canonical name (possible typo)
+# Makefile.am:4: warning: variable `libfoo_la_LIBADD' is defined but no program or
+# Makefile.am:4: library has `libfoo_la' as canonical name (possible typo)
+# Makefile.am:6: warning: variable `EXTRA_libfoo_la_DEPENDENCIES' is defined but no program or
+# Makefile.am:6: library has `libfoo_la' as canonical name (possible typo)
+# Makefile.am:5: warning: variable `libfoo_la_DEPENDENCIES' is defined but no program or
+# Makefile.am:5: library has `libfoo_la' as canonical name (possible typo)
+
+
+grep 'as canonical' stderr | grep -v ' .libfoo_la. ' && Exit 1
+test `grep 'variable.*is defined but' stderr | wc -l` = 6
+
+# If we add a global -Wnone, all warnings should disappear.
+$AUTOMAKE -Wnone
+
+# Likewise, if matching programs or libraries are defined.
+cat >>Makefile.am <<'END'
+lib_LTLIBRARIES = libfoo.la
+END
+
+$AUTOMAKE
+
+:
diff --git a/t/vartypos.sh b/t/vartypos.sh
new file mode 100755
index 000000000..eb924cc06
--- /dev/null
+++ b/t/vartypos.sh
@@ -0,0 +1,89 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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 we warn about possible variable typos when we should.
+
+. ./defs || Exit 1
+
+cat >>configure.ac <<'END'
+AC_PROG_RANLIB
+AC_OUTPUT
+END
+
+cat >Makefile.am <<'END'
+foo_SOURCES = unused
+nodist_foo_SOURCES = unused
+EXTRA_foo_SOURCES = unused
+foo_LDADD = unused
+foo_LDFLAGS = unused
+foo_DEPENDENCIES = unused
+EXTRA_foo_DEPENDENCIES = unused
+
+libfoo_a_SOURCES = unused
+nodist_libfoo_a_SOURCES = unused
+EXTRA_libfoo_a_SOURCES = unused
+libfoo_a_LIBADD = unused
+libfoo_a_DEPENDENCIES = unused
+EXTRA_libfoo_a_DEPENDENCIES = unused
+END
+
+$ACLOCAL
+AUTOMAKE_fails -Wno-extra-portability
+# The expected diagnostic is:
+# automake: warnings are treated as errors
+# Makefile.am:2: warning: variable 'nodist_foo_SOURCES' is defined but no program or
+# Makefile.am:2: library has 'foo' as canonical name (possible typo)
+# Makefile.am:1: warning: variable 'foo_SOURCES' is defined but no program or
+# Makefile.am:1: library has 'foo' as canonical name (possible typo)
+# Makefile.am:9: warning: variable 'libfoo_a_SOURCES' is defined but no program or
+# Makefile.am:9: library has 'libfoo_a' as canonical name (possible typo)
+# Makefile.am:10: warning: variable 'nodist_libfoo_a_SOURCES' is defined but no program or
+# Makefile.am:10: library has 'libfoo_a' as canonical name (possible typo)
+# Makefile.am:11: warning: variable 'EXTRA_libfoo_a_SOURCES' is defined but no program or
+# Makefile.am:11: library has 'libfoo_a' as canonical name (possible typo)
+# Makefile.am:3: warning: variable 'EXTRA_foo_SOURCES' is defined but no program or
+# Makefile.am:3: library has 'foo' as canonical name (possible typo)
+# Makefile.am:12: warning: variable 'libfoo_a_LIBADD' is defined but no program or
+# Makefile.am:12: library has 'libfoo_a' as canonical name (possible typo)
+# Makefile.am:4: warning: variable 'foo_LDADD' is defined but no program or
+# Makefile.am:4: library has 'foo' as canonical name (possible typo)
+# Makefile.am:5: warning: variable 'foo_LDFLAGS' is defined but no program or
+# Makefile.am:5: library has 'foo' as canonical name (possible typo)
+# Makefile.am:14: warning: variable 'EXTRA_libfoo_a_DEPENDENCIES' is defined but no program or
+# Makefile.am:14: library has 'libfoo_a' as canonical name (possible typo)
+# Makefile.am:7: warning: variable 'EXTRA_foo_DEPENDENCIES' is defined but no program or
+# Makefile.am:7: library has 'foo' as canonical name (possible typo)
+# Makefile.am:6: warning: variable 'foo_DEPENDENCIES' is defined but no program or
+# Makefile.am:6: library has 'foo' as canonical name (possible typo)
+# Makefile.am:13: warning: variable 'libfoo_a_DEPENDENCIES' is defined but no program or
+# Makefile.am:13: library has 'libfoo_a' as canonical name (possible typo)
+
+grep 'as canonical' stderr | grep -v ' .foo. ' | grep -v ' .libfoo_a. ' \
+ && Exit 1
+test `grep 'variable.*is defined but' stderr | wc -l` = 13
+
+# If we add a global -Wnone, all warnings should disappear.
+$AUTOMAKE -Wnone
+
+# Likewise, if matching programs or libraries are defined.
+cat >>Makefile.am <<'END'
+bin_PROGRAMS = foo
+lib_LIBRARIES = libfoo.a
+END
+
+$AUTOMAKE -Wno-extra-portability
+
+:
diff --git a/t/version.sh b/t/version.sh
new file mode 100755
index 000000000..98664e28c
--- /dev/null
+++ b/t/version.sh
@@ -0,0 +1,41 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test to make sure [...] is ok in version number. Report from Jim
+# Meyering.
+
+. ./defs || Exit 1
+
+cat > configure.ac << 'END'
+AC_INIT
+AM_INIT_AUTOMAKE([sh-utils], [1.12o])
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+END
+
+: > Makefile.am
+
+# Files required by Gnits.
+: > INSTALL
+: > NEWS
+: > README
+: > COPYING
+: > AUTHORS
+: > ChangeLog
+: > THANKS
+
+$ACLOCAL
+$AUTOMAKE --gnits
diff --git a/t/version2.sh b/t/version2.sh
new file mode 100755
index 000000000..71749f64b
--- /dev/null
+++ b/t/version2.sh
@@ -0,0 +1,41 @@
+#! /bin/sh
+# Copyright (C) 1997-2012 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/>.
+
+# Test to make sure 3rd arg to AM_INIT_AUTOMAKE not picked up in
+# version. From Joel Weber.
+
+. ./defs || Exit 1
+
+cat > configure.ac << 'END'
+AC_INIT
+AM_INIT_AUTOMAKE([sh-utils], [1.12o], [no])
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+END
+
+: > Makefile.am
+
+# Files required by Gnits.
+: > INSTALL
+: > NEWS
+: > README
+: > COPYING
+: > AUTHORS
+: > ChangeLog
+: > THANKS
+
+$ACLOCAL
+$AUTOMAKE --gnits
diff --git a/t/version3.sh b/t/version3.sh
new file mode 100755
index 000000000..2839467b4
--- /dev/null
+++ b/t/version3.sh
@@ -0,0 +1,27 @@
+#! /bin/sh
+# Copyright (C) 1998-2012 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/>.
+
+# Test to make sure version in AUTOMAKE_OPTIONS works.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = 9.9x
+END
+
+$ACLOCAL
+AUTOMAKE_fails
+grep 'Makefile.am:1:.*Automake 9.9x' stderr
diff --git a/t/version4.sh b/t/version4.sh
new file mode 100755
index 000000000..7fa429e17
--- /dev/null
+++ b/t/version4.sh
@@ -0,0 +1,26 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test to make sure we are compatible with the 1.4-p1 series.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = 1.4-p3
+END
+
+$ACLOCAL
+$AUTOMAKE
diff --git a/t/version6.sh b/t/version6.sh
new file mode 100755
index 000000000..1c04ab427
--- /dev/null
+++ b/t/version6.sh
@@ -0,0 +1,36 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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 the current version can be required.
+
+. ./defs || Exit 1
+
+amver=`$AUTOMAKE --version | sed -e 's/.* //;1q'`
+
+# Does the extracted version number seems legit?
+case $amver in
+ *[0-9].[0-9]*) ;;
+ *) fatal_ "couldn't extract version number from automake" ;;
+esac
+
+cat > Makefile.am << END
+AUTOMAKE_OPTIONS = $amver
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+:
diff --git a/t/version7.sh b/t/version7.sh
new file mode 100755
index 000000000..28929204b
--- /dev/null
+++ b/t/version7.sh
@@ -0,0 +1,67 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Test for a special setup where the package's version isn't defined
+# in configure.ac. We want GNU Make for this test (part of the test
+# is to make sure Makefile.ins get rebuilt when a m4_included file
+# changes -- we don't support this feature on non-GNU Makes).
+
+required='makeinfo tex texi2dvi'
+. ./defs || Exit 1
+
+cat >configure.ac <<END
+m4_include([version.m4])
+AC_INIT([$me], [THE_VERSION])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+END
+
+echo 'm4_define([THE_VERSION], [2.718])' > version.m4
+
+cat > Makefile.am << 'END'
+info_TEXINFOS = zardoz.texi
+
+check:
+ test -f $(srcdir)/version.m4
+END
+
+cat > zardoz.texi << 'END'
+\input texinfo
+@setfilename zardoz.info
+@settitle Zardoz
+@node Top
+Hello walls.
+@include version.texi
+@bye
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+./configure --version | grep '2\.718'
+./configure
+$MAKE
+grep '2\.718' version.texi
+
+$sleep
+echo 'm4_define([THE_VERSION], [3.141])' > version.m4
+using_gmake || $MAKE Makefile
+$MAKE distcheck
+./configure --version | grep '3\.141'
+grep '3\.141' version.texi
+
+:
diff --git a/t/version8.sh b/t/version8.sh
new file mode 100755
index 000000000..1e66280d4
--- /dev/null
+++ b/t/version8.sh
@@ -0,0 +1,24 @@
+#! /bin/sh
+# Copyright (C) 2005-2012 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/>.
+
+# Calling AM_AUTOMAKE_VERSION by hand is a bug.
+
+. ./defs || Exit 1
+
+echo 'AM_AUTOMAKE_VERSION([1.9])' >>configure.ac
+$ACLOCAL 2>stderr && { cat stderr >&2; Exit 0; }
+cat stderr >&2
+$FGREP 'AM_INIT_AUTOMAKE([1.9])' stderr
diff --git a/t/vpath.sh b/t/vpath.sh
new file mode 100755
index 000000000..4bfc9be90
--- /dev/null
+++ b/t/vpath.sh
@@ -0,0 +1,33 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test to make sure VPATH can be overridden.
+# Report from Anthony Green.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+VPATH = zardoz
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+grep VPATH Makefile.in # For debugging.
+grep '^VPATH = zardoz$' Makefile.in
+grep 'VPATH.*@srcdir@' Makefile.in && Exit 1
+
+:
diff --git a/t/vtexi.sh b/t/vtexi.sh
new file mode 100755
index 000000000..9d1bc2448
--- /dev/null
+++ b/t/vtexi.sh
@@ -0,0 +1,62 @@
+#!/bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Basic checks and some regressions testing on 'version.texi'
+# support for texinfo files.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+info_TEXINFOS = textutils.texi
+END
+
+cat > textutils.texi << 'END'
+@include version.texi
+@setfilename textutils.info
+END
+
+# Required when using Texinfo.
+: > mdate-sh
+: > texinfo.tex
+
+$ACLOCAL
+$AUTOMAKE
+
+# Test for bug reported by Jim Meyering:
+# When I ran automake-0.29 on textutils,
+# I noticed that doc/Makefile.in had
+# textutils.info: textutils.texi
+# instead of
+# textutils.info: textutils.texi version.texi
+# Today this should be:
+# $(srcdir)/textutils.info: $(srcdir)/version.texi
+# or:
+# $(srcdir)/textutils.info: version.texi
+grep '^\$(srcdir)/textutils\.info:.*[ /]version\.texi *$' Makefile.in
+
+# Test for bug reported by Lars Hecking:
+# When running the first version of configure.ac aware automake,
+# @CONFIGURE_AC@ was not properly substituted.
+$EGREP 'stamp-vti:.*textutils\.texi( .*)?$' Makefile.in
+$EGREP 'stamp-vti:.*\$\(top_srcdir\)/configure( .*)?$' Makefile.in
+
+# Check that the path to mdate-sh is correct. Over escaping of '$'
+# etc. once led to '\$\(srcdir\)/mdate-sh'.
+# Filter out '$(srcdir)/mdate-sh'; there should be no occurrences
+# of '.../mdate-sh' left then.
+sed 's,\$(srcdir)/mdate-sh,,g' Makefile.in | grep '/mdate-sh' && Exit 1
+
+:
diff --git a/t/vtexi2.sh b/t/vtexi2.sh
new file mode 100755
index 000000000..18f1e9ed1
--- /dev/null
+++ b/t/vtexi2.sh
@@ -0,0 +1,42 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test for bug reported by Glenn Amerine:
+# When automake sees version.texi is being included by a texi file,
+# version.texi gets listed as a dependency for the .info file but
+# not the .dvi file.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+info_TEXINFOS = zardoz.texi
+END
+
+cat > zardoz.texi << 'END'
+@setfilename zardoz
+@include version.texi
+END
+
+# Required when using Texinfo.
+: > mdate-sh
+: > texinfo.tex
+
+$ACLOCAL
+$AUTOMAKE
+
+grep '^zardoz\.dvi:.*[ /]version.texi' Makefile.in
+
+:
diff --git a/t/vtexi3.sh b/t/vtexi3.sh
new file mode 100755
index 000000000..9dd3e6712
--- /dev/null
+++ b/t/vtexi3.sh
@@ -0,0 +1,124 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that vers*.texi files are automatically created and distributed
+# if @included into a texi source. Also check that they correctly contain
+# the @values definitions they are advertised to.
+# See also the related test 'vtexi4.test', which does similar checks, but
+# for version.texi only, and requires makeinfo, tex and texi2dvi.
+
+. ./defs || Exit 1
+
+# We are going to override package version in AC_INIT, so we need
+# to redefine the name of the distdir as well.
+distdir=$me-7.45.3a
+
+# This should work without tex, texinfo or makeinfo.
+TEX=false TEXI2DVI=false MAKEINFO=false
+export TEX TEXI2DVI MAKEINFO
+
+cat > configure.ac << END
+AC_INIT([$me], [7.45.3a])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+info_TEXINFOS = foobar.texi quux.texi zardoz.texi
+.PHONY: echo-distfiles
+echo-distfiles:
+ @echo ' ' $(DISTFILES) ' '
+END
+
+cat > foobar.texi << 'END'
+@setfilename foobar.info
+random text
+@include version.texi
+END
+
+cat > quux.texi << 'END'
+@setfilename quux.info
+@include version-quux.texi
+random text
+END
+
+cat > zardoz.texi << 'END'
+@setfilename zardoz.info
+some randome text
+@include vers1a_2b.texi
+more random text
+END
+
+# Required when using Texinfo.
+: > texinfo.tex
+cp "$am_scriptdir"/mdate-sh .
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+day='([1-9]|1[0-9]|2[0-9]|3[01])'
+month='(January|February|March|April|May|June|July|August|September|October|November|December)'
+year='20[0-9][0-9]' # Hopefully automake will be obsolete in 80 years ;-)
+date="$day $month $year"
+
+do_check ()
+{
+ # Basename of the vers*.texi file.
+ vfile=$1
+ # The $(srcdir) of the current build.
+ srcdir=$2
+ # The vers*.texi file must be created in $(srcdir).
+ $MAKE $srcdir/$vfile.texi
+ cat $srcdir/$vfile.texi
+ # EDITION and VERSION are synonyms, as per documentation.
+ grep "^@set EDITION 7\\.45\\.3a$" $srcdir/$vfile.texi
+ grep "^@set VERSION 7\\.45\\.3a$" $srcdir/$vfile.texi
+ # Check that UPDATED seems right, and that UPDATED and UPDATED-MONTH
+ # are consistent.
+ $EGREP "^@set UPDATED $date$" $srcdir/$vfile.texi
+ vmonth=`grep '^@set UPDATED ' $srcdir/$vfile.texi | awk '{print $4, $5}'`
+ grep "^@set UPDATED-MONTH $vmonth$" $srcdir/$vfile.texi
+ # Check that the vers*.texi file is distributed according
+ # to $(DISTFILES).
+ $MAKE echo-distfiles # For debugging.
+ $MAKE -s echo-distfiles | grep "[ /]$vfile\\.texi"
+}
+
+mkdir build
+cd build
+../configure
+
+do_check version ..
+do_check version-quux ..
+do_check vers1a_2b ..
+
+# The various $(srcdir)/*.info are required for the distribution
+# and they must be newer than version.texi, so that make won't try
+# to rebuild them.
+$sleep
+touch ../foobar.info
+touch ../quux.info
+touch ../zardoz.info
+# Check that the vers*.texi files are really distributed.
+$MAKE distdir
+ls -l $distdir
+diff ../version.texi $distdir/version.texi
+diff ../version-quux.texi $distdir/version-quux.texi
+diff ../version.texi $distdir/vers1a_2b.texi
+
+:
diff --git a/t/vtexi4.sh b/t/vtexi4.sh
new file mode 100755
index 000000000..6038444b5
--- /dev/null
+++ b/t/vtexi4.sh
@@ -0,0 +1,113 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that the version.texi file is automatically created and distributed
+# if @included into a texi source. Also check that is correctly defined
+# @values definitions it is advertised to.
+# See also the related test 'vtexi3.test', which does similar checks, but
+# for more vers*.texi files, and does not require makeinfo, tex and
+# texi2dvi.
+
+required='makeinfo tex texi2dvi-o'
+. ./defs || Exit 1
+
+case `LC_ALL=C date '+%u'` in
+ [1-7]) date_is_posix=:;;
+ *) date_is_posx=false;;
+esac
+$date_is_posix \
+ && day=`LC_ALL=C date '+%d'` && test -n "$day" \
+ && month=`LC_ALL=C date '+%B'` && test -n "$month" \
+ && year=`LC_ALL=C date '+%Y'`&& test -n "$year" \
+ || skip_ "'date' is not POSIX-compliant enough"
+day=`echo "$day" | sed 's/^0//'`
+
+(echo 'x' | grep x) \
+ || skip_ "grep doesn't work on input that is not pure text"
+
+cat > configure.ac << END
+AC_INIT([$me], [123.456])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+END
+
+cat > defs.am <<END
+my_date_rx = $day $month $year
+my_month_rx = $month $year
+my_version_rx = 123\.456
+END
+
+cat > Makefile.am << 'END'
+include defs.am
+info_TEXINFOS = foo.texi
+test-grepinfo:
+## Not useless uses of cat: we only tested that grep worked on
+## non-text input when that's given from a pipe.
+ cat $(srcdir)/foo.info | grep 'GREPVERSION=$(my_version_rx)='
+ cat $(srcdir)/foo.info | grep 'GREPEDITION=$(my_version_rx)='
+ cat $(srcdir)/foo.info | grep 'GREPDATE=$(my_date_rx)='
+ cat $(srcdir)/foo.info | grep 'GREPMONTH=$(my_month_rx)='
+test-distfiles:
+ @echo DISTFILES = $(DISTFILES)
+ echo ' ' $(DISTFILES) ' ' | grep '[ /]version.texi '
+test-distdir: distdir
+ ls -l $(distdir)
+ diff $(srcdir)/version.texi $(distdir)/version.texi
+.PHONY: test-grepinfo test-distfiles test-distdir
+check-local: test-grepinfo test-distfiles test-distdir
+END
+
+cat > foo.texi << 'END'
+\input texinfo
+@c %**start of header
+@setfilename foo.info
+@settitle Zardoz
+@c %**end of header
+
+@node Top
+@include version.texi
+
+GREPVERSION=@value{VERSION}=
+
+GREPEDITION=@value{EDITION}=
+
+GREPDATE=@value{UPDATED}=
+
+GREPMONTH=@value{UPDATED-MONTH}=
+
+@bye
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+$MAKE all dvi
+
+# Debugging & sanity checks.
+ls -l
+cat version.texi
+cat foo.info
+test -f foo.dvi
+
+$MAKE test-grepinfo
+$MAKE test-distfiles
+$MAKE test-distdir
+$MAKE distcheck
+
+:
diff --git a/t/warning-groups-win-over-strictness.sh b/t/warning-groups-win-over-strictness.sh
new file mode 100755
index 000000000..3d3885d45
--- /dev/null
+++ b/t/warning-groups-win-over-strictness.sh
@@ -0,0 +1,64 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that explicitly-defined warning levels take precedence over
+# implicit strictness-implied warnings, even when these explicit warning
+# levels are "catch-all warnings" (such as '-Wall' and '-Wnone').
+# Since we are at it, also throw in *.am and *.m4 file inclusions.
+
+. ./defs || Exit 1
+
+# We want complete control over automake options.
+AUTOMAKE=$am_original_AUTOMAKE
+
+# Files required in gnu and/or gnits strictness.
+touch README INSTALL NEWS AUTHORS ChangeLog COPYING THANKS
+
+cat > configure.ac << END
+AC_INIT([$me], [1.0])
+m4_include([am-init-automake.m4])
+AC_PROG_CC
+AC_CONFIG_FILES([Makefile])
+# Other similar tests do not use AC_OUTPUT, so we use it here,
+# for completeness and for better coverage.
+AC_OUTPUT
+END
+
+cat > Makefile.am <<END
+include automake-options.am
+FOO := bar
+END
+
+rm -rf autom4te*.cache
+: > automake-options.am
+echo 'AM_INIT_AUTOMAKE' > am-init-automake.m4
+$ACLOCAL
+AUTOMAKE_fails -Werror -Wall --foreign
+grep '^Makefile\.am:.*:=.*not portable' stderr
+
+rm -rf autom4te*.cache
+: > automake-options.am
+echo 'AM_INIT_AUTOMAKE([-Werror -Wnone gnu])' > am-init-automake.m4
+$ACLOCAL
+$AUTOMAKE
+
+rm -rf autom4te*.cache
+echo 'AUTOMAKE_OPTIONS = -Werror -Wnone gnits' > automake-options.am
+echo 'AM_INIT_AUTOMAKE' > am-init-automake.m4
+$ACLOCAL
+$AUTOMAKE
+
+:
diff --git a/t/warnings-override.sh b/t/warnings-override.sh
new file mode 100755
index 000000000..9f973c6db
--- /dev/null
+++ b/t/warnings-override.sh
@@ -0,0 +1,111 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# The warnings specified in Makefile.am:AUTOMAKE_OPTIONS should override
+# those specified in configure.ac:AM_INIT_AUTOMAKE, and both should
+# override the warnings specified on the command line.
+# NOTE: the current semantics might not be the best one (even if it has
+# been in place for quite a long time); see also Automake bug #7673.
+# Update this test if the semantics are changed.
+
+. ./defs || Exit 1
+
+# We want (almost) complete control over automake options.
+AUTOMAKE="$am_original_AUTOMAKE -Werror"
+
+cat > Makefile.am <<'END'
+FOO := bar
+AUTOMAKE_OPTIONS =
+END
+
+set_warnings ()
+{
+ set +x
+ sed <$2 >$2-t -e "s|^\\(AUTOMAKE_OPTIONS\\) *=.*|\\1 = $1|" \
+ -e "s|^\\(AM_INIT_AUTOMAKE\\).*|\\1([$1])|"
+ mv -f $2-t $2
+ set -x
+ cat $2
+}
+
+ok ()
+{
+ $AUTOMAKE $*
+}
+
+ko ()
+{
+ AUTOMAKE_fails $*
+ grep '^Makefile\.am:1:.*:=.*not portable' stderr
+}
+
+$ACLOCAL
+
+# Files required in gnu strictness.
+touch README INSTALL NEWS AUTHORS ChangeLog COPYING
+
+rm -rf autom4te*.cache
+set_warnings '-Wno-portability' Makefile.am
+set_warnings '' configure.ac
+
+ok -Wportability
+ok
+
+rm -rf autom4te*.cache
+set_warnings '' Makefile.am
+set_warnings '-Wno-portability' configure.ac
+
+ok -Wportability
+ok
+
+rm -rf autom4te*.cache
+set_warnings '-Wno-portability' Makefile.am
+set_warnings '-Wno-portability' configure.ac
+
+ok -Wportability
+
+rm -rf autom4te*.cache
+set_warnings '-Wportability' Makefile.am
+set_warnings '' configure.ac
+
+ko
+ko -Wno-portability
+
+rm -rf autom4te*.cache
+set_warnings '' Makefile.am
+set_warnings '-Wportability' configure.ac
+
+ko
+ko -Wno-portability
+
+rm -rf autom4te*.cache
+set_warnings '-Wportability' Makefile.am
+set_warnings '-Wportability' configure.ac
+ko -Wno-portability
+
+rm -rf autom4te*.cache
+set_warnings '-Wno-portability' Makefile.am
+set_warnings '-Wportability' configure.ac
+ok
+ok -Wportability
+
+rm -rf autom4te*.cache
+set_warnings '-Wportability' Makefile.am
+set_warnings '-Wno-portability' configure.ac
+ko
+ko -Wno-portability
+
+:
diff --git a/t/warnings-precedence.sh b/t/warnings-precedence.sh
new file mode 100755
index 000000000..a5886701a
--- /dev/null
+++ b/t/warnings-precedence.sh
@@ -0,0 +1,77 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# On the command line, in AM_INIT_AUTOMAKE, and in AUTOMAKE_OPTIONS,
+# warnings specified later should take precedence over those specified
+# earlier.
+
+. ./defs || Exit 1
+
+# We want (almost) complete control over automake options.
+AUTOMAKE="$am_original_AUTOMAKE -Werror"
+
+cat > Makefile.am <<'END'
+FOO := bar
+AUTOMAKE_OPTIONS =
+END
+
+set_warnings ()
+{
+ set +x
+ sed <$2 >$2-t -e "s|^\\(AUTOMAKE_OPTIONS\\) *=.*|\\1 = $1|" \
+ -e "s|^\\(AM_INIT_AUTOMAKE\\).*|\\1([$1])|"
+ mv -f $2-t $2
+ set -x
+ cat $2
+}
+
+ok ()
+{
+ $AUTOMAKE $*
+}
+
+ko ()
+{
+ AUTOMAKE_fails $*
+ grep '^Makefile\.am:1:.*:=.*not portable' stderr
+}
+
+# Files required in gnu strictness.
+touch README INSTALL NEWS AUTHORS ChangeLog COPYING
+
+$ACLOCAL
+ok -Wportability -Wno-portability
+ko -Wno-portability -Wportability
+
+set_warnings '' Makefile.am
+set_warnings '-Wportability -Wno-portability' configure.ac
+rm -rf autom4te*.cache
+$ACLOCAL
+ok
+set_warnings '-Wno-portability -Wportability' configure.ac
+rm -rf autom4te*.cache
+$ACLOCAL
+ko
+
+set_warnings '' configure.ac
+rm -rf autom4te*.cache
+$ACLOCAL
+set_warnings '-Wportability -Wno-portability' Makefile.am
+ok
+set_warnings '-Wno-portability -Wportability' Makefile.am
+ko
+
+:
diff --git a/t/warnings-strictness-interactions.sh b/t/warnings-strictness-interactions.sh
new file mode 100755
index 000000000..774fd3aae
--- /dev/null
+++ b/t/warnings-strictness-interactions.sh
@@ -0,0 +1,59 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that the default warnings triggered by a strictness specified
+# in AUTOMAKE_OPTIONS take precedence over explicit warnings given in
+# AM_INIT_AUTOMAKE.
+
+. ./defs || Exit 1
+
+# We want (almost) complete control over automake options.
+AUTOMAKE="$am_original_AUTOMAKE -Werror"
+
+cat > Makefile.am <<END
+AUTOMAKE_OPTIONS =
+FOO := bar
+END
+
+set_am_opts ()
+{
+ set +x
+ sed <$2 >$2-t -e "s|^\\(AUTOMAKE_OPTIONS\\) *=.*|\\1 = $1|" \
+ -e "s|^\\(AM_INIT_AUTOMAKE\\).*|\\1([$1])|"
+ mv -f $2-t $2
+ set -x
+ cat $2
+}
+
+set_am_opts '-Wportability' configure.ac
+set_am_opts 'foreign' Makefile.am
+
+$ACLOCAL
+$AUTOMAKE
+
+rm -rf autom4te*.cache
+
+# Files required in gnu strictness.
+touch README INSTALL NEWS AUTHORS ChangeLog COPYING
+
+set_am_opts '-Wno-portability' configure.ac
+set_am_opts 'gnu' Makefile.am
+
+AUTOMAKE_fails
+$ACLOCAL
+grep '^Makefile\.am:2:.*:=.*not portable' stderr
+
+:
diff --git a/t/warnings-unknown.sh b/t/warnings-unknown.sh
new file mode 100755
index 000000000..4d64059e0
--- /dev/null
+++ b/t/warnings-unknown.sh
@@ -0,0 +1,48 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that automake complains about unknown warnings.
+
+. ./defs || Exit 1
+
+# We want (almost) complete control over automake options.
+AUTOMAKE="$am_original_AUTOMAKE --foreign -Werror"
+
+cat > configure.ac <<END
+AC_INIT([$me], [1.0])
+AM_INIT_AUTOMAKE([-Wno-zardoz])
+AC_CONFIG_FILES([Makefile])
+END
+
+cat > Makefile.am <<END
+AUTOMAKE_OPTIONS = -Wfoobar
+END
+
+$ACLOCAL
+
+AUTOMAKE_fails -Wbazquux
+# FIXME: we could get rid of this once we improve our wrapper scripts.
+sed "s/^automake:/automake-$APIVERSION:/" stderr > t
+mv -f t stderr
+cat stderr >&2
+grep '^configure\.ac:2:.* unknown warning category.*zardoz' stderr
+grep '^Makefile\.am:1:.* unknown warning category.*foobar' stderr
+grep "^automake-$APIVERSION:.* unknown warning category.*bazquux" stderr
+
+# Check that we can override warnings about unknown warning categories.
+$AUTOMAKE -Wno-unsupported -Wbazquux
+
+:
diff --git a/t/warnings-win-over-strictness.sh b/t/warnings-win-over-strictness.sh
new file mode 100755
index 000000000..5d47f5047
--- /dev/null
+++ b/t/warnings-win-over-strictness.sh
@@ -0,0 +1,90 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that, on the command line, explicitly-defined warnings take
+# precedence over implicit strictness-implied warnings.
+
+. ./defs || Exit 1
+
+# We want complete control over automake options.
+AUTOMAKE=$am_original_AUTOMAKE
+
+ok ()
+{
+ AUTOMAKE_run $*
+ test ! -s stderr
+}
+
+ko ()
+{
+ AUTOMAKE_run $*
+ grep '^Makefile\.am:.*:=.*not portable' stderr
+ test `wc -l <stderr` -eq 1
+}
+
+set_am_opts()
+{
+ set +x
+ sed <$2 >$2-t -e "s|^\\(AUTOMAKE_OPTIONS\\) *=.*|\\1 = $1|" \
+ -e "s|^\\(AM_INIT_AUTOMAKE\\).*|\\1([$1])|"
+ mv -f $2-t $2
+ set -x
+ cat $2
+}
+
+# Files required in gnu strictness.
+touch README INSTALL NEWS AUTHORS ChangeLog COPYING
+
+cat > Makefile.am <<END
+AUTOMAKE_OPTIONS =
+FOO := bar
+END
+
+$ACLOCAL
+
+ko --foreign -Wportability
+ko -Wportability --foreign
+ok --gnu -Wno-portability
+ok -Wno-portability --gnu
+
+set_am_opts '' Makefile.am
+
+rm -rf autom4te*.cache
+set_am_opts 'foreign -Wportability' configure.ac
+ko
+rm -rf autom4te*.cache
+set_am_opts '-Wportability foreign' configure.ac
+ko
+rm -rf autom4te*.cache
+set_am_opts 'gnu -Wno-portability' configure.ac
+ok
+rm -rf autom4te*.cache
+set_am_opts '-Wno-portability gnu' configure.ac
+ok
+
+rm -rf autom4te*.cache
+set_am_opts '' configure.ac
+
+set_am_opts 'foreign -Wportability' Makefile.am
+ko
+set_am_opts '-Wportability foreign' Makefile.am
+ko
+set_am_opts 'gnu -Wno-portability' Makefile.am
+ok
+set_am_opts '-Wno-portability gnu' Makefile.am
+ok
+
+:
diff --git a/t/warnopts.sh b/t/warnopts.sh
new file mode 100755
index 000000000..1662d91d6
--- /dev/null
+++ b/t/warnopts.sh
@@ -0,0 +1,73 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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 that we can enable or disable warnings on a per-file basis.
+
+. ./defs || Exit 1
+
+cat >>configure.ac <<END
+AC_CONFIG_FILES([sub/Makefile])
+AC_OUTPUT
+END
+
+mkdir sub
+
+# These two Makefile contain the same errors, but have different
+# warnings disabled.
+
+cat >Makefile.am <<END
+AUTOMAKE_OPTIONS = -Wno-obsolete
+INCLUDES = -Ifoo
+foo_SOURCES = unused
+SUBDIRS = sub
+END
+
+cat >sub/Makefile.am <<END
+AUTOMAKE_OPTIONS = -Wno-syntax
+INCLUDES = -Ifoo
+foo_SOURCES = unused
+END
+
+$ACLOCAL
+AUTOMAKE_fails
+# The expected diagnostic is
+# Makefile.am:3: warning: variable 'foo_SOURCES' is defined but no program or
+# library has 'foo' as canonical name (possible typo)
+# sub/Makefile.am:2: warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS'
+grep '^Makefile.am:.*foo_SOURCES' stderr
+grep '^sub/Makefile.am:.*INCLUDES' stderr
+grep '^sub/Makefile.am:.*foo_SOURCES' stderr && Exit 1
+grep '^Makefile.am:.*INCLUDES' stderr && Exit 1
+# Only three lines of warnings.
+test `grep -v 'warnings are treated as errors' stderr | wc -l` = 3
+
+# On fast machines the autom4te.cache created during the above run of
+# $AUTOMAKE is likely to have the same time stamp as the configure.ac
+# created below; thus causing traces for the old configure.ac to be
+# used. We could do '$sleep', but it's faster to erase the
+# directory. (Erase autom4te*.cache, not autom4te.cache, because some
+# bogus installations of Autoconf use a versioned cache).
+rm -rf autom4te*.cache
+
+# If we add a global -Wnone, all warnings should disappear.
+cat >configure.ac <<END
+AC_INIT([warnopts], [1.0])
+AM_INIT_AUTOMAKE([-Wnone])
+AC_CONFIG_FILES([Makefile sub/Makefile])
+AC_OUTPUT
+END
+$ACLOCAL
+$AUTOMAKE
diff --git a/t/werror.sh b/t/werror.sh
new file mode 100755
index 000000000..606fed620
--- /dev/null
+++ b/t/werror.sh
@@ -0,0 +1,26 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test to make sure -Werror and --add-missing work together.
+
+. ./defs || Exit 1
+
+: > Makefile.am
+
+rm -f install-sh depcomp missing mkinstalldirs
+
+$ACLOCAL
+$AUTOMAKE -Werror --add-missing
diff --git a/t/werror2.sh b/t/werror2.sh
new file mode 100755
index 000000000..67e0e01f7
--- /dev/null
+++ b/t/werror2.sh
@@ -0,0 +1,48 @@
+#! /bin/sh
+# Copyright (C) 2004-2012 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 that Makefile.in is not overwritten on error. Otherwise
+# although the rebuilding rules would fail on error, they would
+# succeed if make is run a second time immediately afterwards.
+# Report from Harlan Stenn.
+
+. ./defs || Exit 1
+
+echo AC_OUTPUT>>configure.ac
+
+: > Makefile.am
+
+$ACLOCAL
+# Create Makefile.in before configure. configure ensures files
+# generated by it or later are newer than configure, so this allows
+# us to avoid a $sleep before updating Makefile.am below.
+$AUTOMAKE
+$AUTOCONF
+
+./configure
+$MAKE
+
+cat >Makefile.am <<END
+AUTOMAKE_OPTIONS = -Werror
+INCLUDES = -Ifoo
+foo_SOURCES = unused
+END
+
+# This repetition is deliberate; see heading comments.
+$MAKE && Exit 1
+$MAKE && Exit 1
+
+:
diff --git a/t/werror3.sh b/t/werror3.sh
new file mode 100755
index 000000000..b5e35e370
--- /dev/null
+++ b/t/werror3.sh
@@ -0,0 +1,48 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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 a per-Makefile.am -Werror setting is not carried over
+# to another Makefile.am.
+
+. ./defs || Exit 1
+
+cat >>configure.ac <<\END
+AC_CONFIG_FILES([sub/Makefile])
+AC_OUTPUT
+END
+
+mkdir sub
+cat >sub/Makefile.am <<\END
+AUTOMAKE_OPTIONS = -Werror
+END
+cat >Makefile.am <<\END
+VAR = foo
+VAR = bar
+END
+
+$ACLOCAL
+
+# The issue would not manifest with threaded execution.
+unset AUTOMAKE_JOBS || :
+AUTOMAKE_run -Wno-error
+grep 'VAR multiply defined' stderr
+
+AUTOMAKE_JOBS=2
+export AUTOMAKE_JOBS
+AUTOMAKE_run -Wno-error
+grep 'VAR multiply defined' stderr
+
+:
diff --git a/t/werror4.sh b/t/werror4.sh
new file mode 100755
index 000000000..b2f3f6a78
--- /dev/null
+++ b/t/werror4.sh
@@ -0,0 +1,66 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# -Werror and local -Werror settings should be flagged for the user.
+
+. ./defs || Exit 1
+
+cat >>configure.ac <<\END
+AC_CONFIG_FILES([sub/Makefile])
+AC_OUTPUT
+END
+
+mkdir sub
+cat >sub/Makefile.am <<\END
+AUTOMAKE_OPTIONS = -Werror
+SUB = foo
+SUB = bar
+END
+cat >Makefile.am <<\END
+AUTOMAKE_OPTIONS = -Werror
+VAR = foo
+VAR = bar
+END
+
+$ACLOCAL
+
+AUTOMAKE_fails -Wno-error
+grep 'VAR multiply defined' stderr
+grep 'SUB multiply defined' stderr
+test `grep -c 'warnings are treated as errors' stderr` -eq 1
+
+sed '/AUTOMAKE_OPTIONS/d' sub/Makefile.am > t
+mv -f t sub/Makefile.am
+
+AUTOMAKE_fails -Wno-error
+grep 'VAR multiply defined' stderr
+grep 'SUB multiply defined' stderr
+test `grep -c 'warnings are treated as errors' stderr` -eq 1
+
+sed '/AUTOMAKE_OPTIONS/d' Makefile.am > t
+mv -f t Makefile.am
+
+AUTOMAKE_fails -Werror
+grep 'VAR multiply defined' stderr
+grep 'SUB multiply defined' stderr
+test `grep -c 'warnings are treated as errors' stderr` -eq 1
+
+AUTOMAKE_run -Wno-error
+grep 'VAR multiply defined' stderr
+grep 'SUB multiply defined' stderr
+grep 'warnings are treated as errors' stderr && Exit 1
+
+:
diff --git a/t/whoami.sh b/t/whoami.sh
new file mode 100755
index 000000000..72153cada
--- /dev/null
+++ b/t/whoami.sh
@@ -0,0 +1,27 @@
+#! /bin/sh
+# Copyright (C) 1998-2012 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/>.
+
+# Test to make sure aclocal doesn't barf on "WHO_AM_I=...". Report
+# from Johan Danielsson (and a very nice bug report, too, I might
+# add).
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+WHO_AM_I=17
+END
+
+$ACLOCAL
diff --git a/t/wrap/aclocal.in b/t/wrap/aclocal.in
new file mode 100644
index 000000000..18ee13a82
--- /dev/null
+++ b/t/wrap/aclocal.in
@@ -0,0 +1,32 @@
+#!/bin/sh
+# @configure_input@
+
+# Copyright (C) 2012 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/>.
+
+# Be Bourne compatible
+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+"$@"}'='"$@"'
+fi
+
+perllibdir="@abs_top_builddir@/lib@PATH_SEPARATOR@@abs_top_srcdir@/lib"
+export perllibdir
+
+exec "@abs_top_builddir@/aclocal" "--automake-acdir=@abs_top_srcdir@/m4" \
+ "--system-acdir=@abs_top_srcdir@/m4/acdir" ${1+"$@"}
diff --git a/t/wrap/automake.in b/t/wrap/automake.in
new file mode 100644
index 000000000..14f437f1e
--- /dev/null
+++ b/t/wrap/automake.in
@@ -0,0 +1,30 @@
+#!/bin/sh
+# @configure_input@
+
+# Copyright (C) 2012 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/>.
+
+# Be Bourne compatible
+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+"$@"}'='"$@"'
+fi
+
+perllibdir="@abs_top_builddir@/lib@PATH_SEPARATOR@@abs_top_srcdir@/lib"
+export perllibdir
+exec "@abs_top_builddir@/automake" "--libdir=@abs_top_srcdir@/lib" ${1+"$@"}
diff --git a/t/xsource.sh b/t/xsource.sh
new file mode 100755
index 000000000..5f89dc9c6
--- /dev/null
+++ b/t/xsource.sh
@@ -0,0 +1,38 @@
+#! /bin/sh
+# Copyright (C) 1997-2012 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/>.
+
+# Test to make sure multiple source files with the same object
+# file causes error.
+
+. ./defs || Exit 1
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = zardoz
+zardoz_SOURCES = z.c x/z.c
+END
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+END
+
+mkdir x
+
+: > z.c
+: > x/z.c
+
+$ACLOCAL
+AUTOMAKE_fails
+$FGREP 'z.$(OBJEXT)' stderr
diff --git a/t/yacc-auxdir.sh b/t/yacc-auxdir.sh
new file mode 100755
index 000000000..1b494e82c
--- /dev/null
+++ b/t/yacc-auxdir.sh
@@ -0,0 +1,56 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test to make sure ylwrap is put in right location.
+# Report from Tim Van Holder.
+
+. ./defs || Exit 1
+
+mkdir aux1 sub
+
+cat > configure.ac << END
+AC_INIT([$me], [1.0])
+# 'aux' is not an acceptable file/directory name on Windows systems
+AC_CONFIG_AUX_DIR([aux1])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([Makefile sub/Makefile])
+AC_PROG_CC
+AC_PROG_YACC
+END
+
+cat > Makefile.am << 'END'
+SUBDIRS = sub
+bin_PROGRAMS = foo
+AM_YFLAGS = -d
+foo_SOURCES = foo.y
+END
+
+cat > sub/Makefile.am << 'END'
+bin_PROGRAMS = bar
+AM_YFLAGS = -d
+bar_SOURCES = bar.y main.c
+END
+
+$ACLOCAL
+$AUTOMAKE -a
+test -f aux1/ylwrap
+test ! -f ylwrap
+test ! -f sub/ylwrap
+grep -i 'ylwrap' Makefile.in sub/Makefile.in # For debugging.
+$FGREP '$(top_srcdir)/aux1/ylwrap' Makefile.in
+$FGREP '$(top_srcdir)/aux1/ylwrap' sub/Makefile.in
+
+:
diff --git a/t/yacc-basic.sh b/t/yacc-basic.sh
new file mode 100755
index 000000000..71a17e58e
--- /dev/null
+++ b/t/yacc-basic.sh
@@ -0,0 +1,109 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Basic semantic checks on Yacc support (without yacc-generated headers).
+# Keep in sync with sister test 'yacc-cxx.test'.
+
+required='cc yacc'
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_PROG_YACC
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = foo bar
+foo_SOURCES = parse.y foo.c
+bar_SOURCES = $(foo_SOURCES)
+bar_YFLAGS = -v
+
+.PHONY: echo-distcom
+echo-distcom:
+ @echo ' ' $(DIST_COMMON) ' '
+END
+
+cat > parse.y << 'END'
+%{
+#include <stdio.h>
+#include <stdlib.h>
+int yylex () { return getchar (); }
+void yyerror (char *s) {}
+%}
+%%
+a : 'a' { exit(0); };
+END
+
+cat > foo.c << 'END'
+int main () { yyparse (); return 1; }
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+$MAKE
+ls -l
+# The Yacc-derived C sources must be created, and not removed once
+# compiled (i.e., not treated like "intermediate files" in the GNU
+# make sense).
+test -f parse.c
+test -f bar-parse.c
+# Check that per-object flags are honored.
+test -f bar-parse.output
+
+if cross_compiling; then :; else
+ echo a | ./foo
+ echo b | ./foo && Exit 1
+ : For shells with busted 'set -e'.
+fi
+
+echo a | ./bar
+echo b | ./bar && Exit 1
+
+# The Yacc-derived C sources must be shipped.
+$MAKE echo-distcom
+$MAKE -s echo-distcom | grep '[ /]parse\.c '
+$MAKE -s echo-distcom | grep '[ /]bar-parse\.c '
+$MAKE distdir
+ls -l $distdir
+test -f $distdir/parse.c
+test -f $distdir/bar-parse.c
+
+# Sanity check on distribution.
+# Note that, for this to succeed, bar-parse.output must either not
+# be distributed, or properly cleaned by automake-generated rules.
+# We don't want to set the exact semantics yet, but want to ensure
+# they are are consistent.
+yl_distcheck
+
+# Make sure that the Yacc-derived C sources are erased by
+# maintainer-clean, and not by distclean.
+test -f parse.c
+test -f bar-parse.c
+$MAKE distclean
+ls -l
+test -f parse.c
+test -f bar-parse.c
+./configure # We must re-create 'Makefile'.
+$MAKE maintainer-clean
+ls -l
+test ! -f parse.c
+test ! -f bar-parse.c
+
+:
diff --git a/t/yacc-bison-skeleton-cxx.sh b/t/yacc-bison-skeleton-cxx.sh
new file mode 100755
index 000000000..30f254340
--- /dev/null
+++ b/t/yacc-bison-skeleton-cxx.sh
@@ -0,0 +1,98 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Test to make sure bison + bison's C++ skeleton + C++ works.
+# For Automake bug#7648 and PR automake/491.
+
+required=bison
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CXX
+AC_PROG_YACC
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = zardoz
+zardoz_SOURCES = zardoz.yy foo.cc
+
+# This is required even with %defines in zardoz.yy.
+AM_YFLAGS = -d
+
+BUILT_SOURCES = zardoz.hh
+EXTRA_DIST = stack.hh location.hh position.hh
+END
+
+cat > zardoz.yy << 'END'
+%skeleton "lalr1.cc"
+%defines
+
+%{
+#define YYSTYPE int
+int yylex(YYSTYPE* yylval_param);
+%}
+
+%%
+start : /* empty */
+%%
+
+int
+yylex(YYSTYPE*)
+{
+ return 0;
+}
+
+void
+yy::parser::error(const yy::parser::location_type&, const std::string& m)
+{
+ return;
+}
+END
+
+cat > foo.cc << 'END'
+#include "zardoz.hh"
+
+using namespace std;
+
+int
+main(int argc, char** argv)
+{
+ yy::parser my_parser;
+ return my_parser.parse ();
+}
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+# Try a VPATH build first.
+mkdir build
+cd build
+../configure YACC='bison -y'
+$MAKE
+cd ..
+
+# Now try an in-tree build.
+./configure YACC='bison -y'
+$MAKE
+
+# Check that distribution is self-contained, and do not require
+# bison to be built.
+env YACC=false DISTCHECK_CONFIGURE_FLAGS='YACC=false' $MAKE -e distcheck
+
+:
diff --git a/t/yacc-bison-skeleton.sh b/t/yacc-bison-skeleton.sh
new file mode 100755
index 000000000..b341401d3
--- /dev/null
+++ b/t/yacc-bison-skeleton.sh
@@ -0,0 +1,72 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Test to make sure bison + bison's skeleton works.
+# For Automake bug#7648 and PR automake/491.
+
+required=bison
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_PROG_YACC
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = zardoz
+zardoz_SOURCES = zardoz.y foo.c
+AM_YFLAGS = -d --skeleton glr.c
+END
+
+# Parser.
+cat > zardoz.y << 'END'
+%{
+int yylex () { return 0; }
+void yyerror (const char *s) { return; }
+%}
+%%
+foobar : 'f' 'o' 'o' 'b' 'a' 'r' {};
+END
+
+cat > foo.c << 'END'
+#include "zardoz.h"
+int main (void)
+{
+ return yyparse ();
+}
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+# Try a VPATH build first.
+mkdir build
+cd build
+../configure YACC='bison -y'
+$MAKE
+cd ..
+
+# Now try an in-tree build.
+./configure YACC='bison -y'
+$MAKE
+
+# Check that distribution is self-contained, and do not require
+# bison to be built.
+env YACC=false DISTCHECK_CONFIGURE_FLAGS='YACC=false' $MAKE -e distcheck
+
+:
diff --git a/t/yacc-clean-cxx.sh b/t/yacc-clean-cxx.sh
new file mode 100755
index 000000000..ea21bffd7
--- /dev/null
+++ b/t/yacc-clean-cxx.sh
@@ -0,0 +1,163 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that C++ source and header files derived from non-distributed
+# Yacc sources are cleaned by "make clean", while C++ source and
+# header files derived from distributed Yacc sources are cleaned by
+# "make maintainer-clean".
+# See also sister test 'yacc-clean.test'.
+
+required=yacc
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CXX
+AC_PROG_YACC
+AC_CONFIG_FILES([sub1/Makefile sub2/Makefile])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+# Use two subdirectories, one to test with '-d' in YFLAGS, the
+# other one to test with empty YFLAGS.
+SUBDIRS = sub1 sub2
+END
+
+mkdir sub1 sub2
+
+cat > sub1/Makefile.am << 'END'
+bin_PROGRAMS = foo bar baz qux
+
+foo_SOURCES = mainfoo.cc parsefoo.yxx
+
+bar_SOURCES = mainbar.cpp parsebar.yy
+bar_YFLAGS = $(AM_YFLAGS)
+
+baz_SOURCES = mainbaz.c++
+nodist_baz_SOURCES = parsebaz.y++
+
+qux_SOURCES = mainqux.cxx
+nodist_qux_SOURCES = parsequx.ypp
+qux_YFLAGS = $(AM_YFLAGS)
+
+parsebaz.y++ parsequx.ypp:
+ cp $(srcdir)/parsefoo.yxx $@
+
+CLEANFILES = parsebaz.y++ parsequx.ypp
+END
+
+cat > sub2/Makefile.am << 'END'
+include $(top_srcdir)/sub1/Makefile.am
+AM_YFLAGS = -d
+END
+
+cat > sub1/parsefoo.yxx << 'END'
+%{
+// This file should contain valid C++ but invalid C.
+#include <cstdio>
+int yylex (void) { return (getchar ()); }
+void yyerror (const char *s) { return; }
+%}
+%%
+x : 'x' { };
+END
+cp sub1/parsefoo.yxx sub1/parsebar.yy
+cp sub1/parsefoo.yxx sub2/parsefoo.yxx
+cp sub1/parsefoo.yxx sub2/parsebar.yy
+
+cat > sub1/mainfoo.cc << 'END'
+// This file should contain valid C++ but invalid C.
+using namespace std;
+int main (int argc, char **argv)
+{
+ extern int yyparse (void);
+ return yyparse ();
+}
+END
+cp sub1/mainfoo.cc sub1/mainbar.cpp
+cp sub1/mainfoo.cc sub1/mainbaz.c++
+cp sub1/mainfoo.cc sub1/mainqux.cxx
+cp sub1/main???.c* sub2
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+cp config.status config.sav
+
+$MAKE
+ls -l . sub1 sub2
+# Sanity checks.
+test -f sub1/parsefoo.cxx
+test -f sub1/bar-parsebar.cc
+test -f sub1/parsebaz.y++
+test -f sub1/parsebaz.c++
+test -f sub1/parsequx.ypp
+test -f sub1/qux-parsequx.cpp
+test -f sub2/parsefoo.cxx
+test -f sub2/parsefoo.hxx
+test -f sub2/bar-parsebar.cc
+test -f sub2/bar-parsebar.hh
+test -f sub2/parsebaz.y++
+test -f sub2/parsebaz.c++
+test -f sub2/parsebaz.h++
+test -f sub2/parsequx.ypp
+test -f sub2/qux-parsequx.cpp
+test -f sub2/qux-parsequx.hpp
+
+for target in clean distclean; do
+ $MAKE $target
+ ls -l . sub1 sub2
+ test -f sub1/parsefoo.cxx
+ test -f sub1/bar-parsebar.cc
+ test ! -r sub1/parsebaz.y++
+ test ! -r sub1/parsebaz.c++
+ test ! -r sub1/parsequx.ypp
+ test ! -r sub1/qux-parsequx.cpp
+ test -f sub2/parsefoo.cxx
+ test -f sub2/parsefoo.hxx
+ test -f sub2/bar-parsebar.cc
+ test -f sub2/bar-parsebar.hh
+ test ! -r sub2/parsebaz.y++
+ test ! -r sub2/parsebaz.c++
+ test ! -r sub2/parsebaz.h++
+ test ! -r sub2/parsequx.ypp
+ test ! -r sub2/qux-parsequx.cpp
+ test ! -r sub2/qux-parsequx.hpp
+done
+
+cp config.sav config.status
+./config.status # re-create Makefile
+
+$MAKE maintainer-clean
+ls -l . sub1 sub2
+test -f sub1/parsefoo.yxx
+test -f sub1/parsebar.yy
+test ! -r sub1/parsefoo.cxx
+test ! -r sub1/bar-parsebar.cc
+test -f sub2/parsefoo.yxx
+test -f sub2/parsebar.yy
+test ! -r sub2/parsefoo.cxx
+test ! -r sub2/parsefoo.hxx
+test ! -r sub2/bar-parsebar.cc
+test ! -r sub2/bar-parsebar.hh
+
+cp config.sav config.status
+./config.status # re-create Makefile
+
+:
diff --git a/t/yacc-clean.sh b/t/yacc-clean.sh
new file mode 100755
index 000000000..530f87fb1
--- /dev/null
+++ b/t/yacc-clean.sh
@@ -0,0 +1,147 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that .c and .h files derived from non-distributed .y sources
+# are cleaned by "make clean", while .c and .h files derived from
+# distributed .y sources are cleaned by "make maintainer-clean".
+# See also sister test 'yacc-cxx-clean.test'.
+
+required='cc yacc'
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_PROG_YACC
+AC_CONFIG_FILES([sub1/Makefile sub2/Makefile])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+# Use two subdirectories, one to test with '-d' in YFLAGS, the
+# other one to test with empty YFLAGS.
+SUBDIRS = sub1 sub2
+END
+
+mkdir sub1 sub2
+
+cat > sub1/Makefile.am << 'END'
+bin_PROGRAMS = foo bar baz qux
+
+foo_SOURCES = main.c parse.y
+
+bar_SOURCES = main.c parse.y
+bar_YFLAGS = $(AM_YFLAGS)
+
+baz_SOURCES = main.c
+nodist_baz_SOURCES = baz.y
+
+qux_SOURCES = main.c
+nodist_qux_SOURCES = baz.y
+qux_YFLAGS = $(AM_YFLAGS)
+
+baz.y:
+ cp $(srcdir)/parse.y $@
+
+CLEANFILES = baz.y
+END
+
+cat > sub2/Makefile.am << 'END'
+include $(top_srcdir)/sub1/Makefile.am
+AM_YFLAGS = -d
+END
+
+cat > sub1/parse.y << 'END'
+%{
+int yylex () { return (getchar ()); }
+void yyerror (char *s) {}
+%}
+%%
+x : 'x' { };
+END
+cp sub1/parse.y sub2/parse.y
+
+cat > sub1/main.c << 'END'
+int main ()
+{
+ return yyparse ();
+}
+END
+cp sub1/main.c sub2/main.c
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+cp config.status config.sav
+
+$MAKE
+ls -l . sub1 sub2
+# Sanity checks.
+test -f sub1/parse.y
+test -f sub1/parse.c
+test -f sub1/bar-parse.c
+test -f sub1/baz.y
+test -f sub1/baz.c
+test -f sub1/qux-baz.c
+test -f sub2/parse.y
+test -f sub2/parse.c
+test -f sub2/parse.h
+test -f sub2/bar-parse.c
+test -f sub2/bar-parse.h
+test -f sub2/baz.y
+test -f sub2/baz.c
+test -f sub2/baz.h
+test -f sub2/qux-baz.c
+test -f sub2/qux-baz.h
+
+for target in clean distclean; do
+ $MAKE $target
+ ls -l . sub1 sub2
+ test -f sub1/parse.y
+ test -f sub1/parse.c
+ test -f sub1/bar-parse.c
+ test ! -r sub1/baz.y
+ test ! -r sub1/baz.c
+ test ! -r sub1/qux-baz.c
+ test -f sub2/parse.y
+ test -f sub2/parse.c
+ test -f sub2/parse.h
+ test -f sub2/bar-parse.c
+ test -f sub2/bar-parse.h
+ test ! -r sub2/baz.y
+ test ! -r sub2/baz.c
+ test ! -r sub2/baz.h
+ test ! -r sub2/qux-baz.c
+ test ! -r sub2/qux-baz.h
+done
+
+cp config.sav config.status
+./config.status # Re-create 'Makefile'.
+
+$MAKE maintainer-clean
+ls -l . sub1 sub2
+test -f sub1/parse.y
+test ! -r sub1/parse.c
+test ! -r sub1/bar-parse.c
+test -f sub2/parse.y
+test ! -r sub2/parse.c
+test ! -r sub2/parse.h
+test ! -r sub2/bar-parse.c
+test ! -r sub2/bar-parse.h
+
+:
diff --git a/t/yacc-cxx.sh b/t/yacc-cxx.sh
new file mode 100755
index 000000000..fe348cb20
--- /dev/null
+++ b/t/yacc-cxx.sh
@@ -0,0 +1,137 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Basic semantic checks on Yacc + C++ support (when yacc-generated
+# headers are not involved).
+# Keep in sync with sister test 'yacc-basic.test'.
+
+required=yacc
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CXX
+AC_PROG_YACC
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = foo1 foo2 foo3 foo4
+foo1_SOURCES = parse1.yy foo.cc
+foo2_SOURCES = parse2.y++ bar.c++
+foo3_SOURCES = parse3.yxx foo.cc
+foo4_SOURCES = parse4.ypp bar2.cxx
+foo3_YFLAGS = -v
+foo4_YFLAGS = $(foo3_YFLAGS)
+
+.PHONY: echo-distcom
+echo-distcom:
+ @echo ' ' $(DIST_COMMON) ' '
+END
+
+cat > parse1.yy << 'END'
+%{
+// Valid C++, but deliberately invalid C.
+#include <cstdio>
+#include <cstdlib>
+int yylex (void) { return getchar (); }
+void yyerror (const char *s) { return; }
+%}
+%%
+a : 'a' { exit(0); };
+END
+cp parse1.yy parse2.y++
+cp parse1.yy parse3.yxx
+cp parse1.yy parse4.ypp
+
+cat > foo.cc << 'END'
+// Valid C++, but deliberately invalid C.
+using namespace std;
+int main (int argc, char **argv)
+{
+ int yyparse (void);
+ yyparse ();
+ return 1;
+}
+END
+cp foo.cc bar.c++
+cp foo.cc bar2.cxx
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+$MAKE
+
+# The Yacc-derived C++ sources must be created, and not removed once
+# compiled (i.e., not treated like "intermediate files" in the GNU
+# make sense).
+test -f parse1.cc
+test -f parse2.c++
+test -f foo3-parse3.cxx
+test -f foo4-parse4.cpp
+# Check that per-object flags are honored.
+test -f foo3-parse3.output
+test -f foo4-parse4.output
+
+for i in 1 2 3 4; do
+ echo a | ./foo$i
+ echo b | ./foo$i && Exit 1
+ : For shells with busted 'set -e'.
+done
+
+# The Yacc-derived C++ sources must be shipped.
+$MAKE echo-distcom
+$MAKE -s echo-distcom | grep '[ /]parse1\.cc '
+$MAKE -s echo-distcom | grep '[ /]parse2\.c++ '
+$MAKE -s echo-distcom | grep '[ /]foo3-parse3\.cxx '
+$MAKE -s echo-distcom | grep '[ /]foo4-parse4\.cpp '
+$MAKE distdir
+ls -l $distdir
+test -f $distdir/parse1.cc
+test -f $distdir/parse2.c++
+test -f $distdir/foo3-parse3.cxx
+test -f $distdir/foo4-parse4.cpp
+
+# Sanity check on distribution.
+# Note that, for this to succeed, foo3-parse3.output and foo4-parse4.output
+# must either not be distributed, or properly cleaned by automake-generated
+# rules. We don't want to set the exact semantics yet, but want to ensure
+# they are are consistent.
+yl_distcheck
+
+# Make sure that the Yacc-derived C++ sources are erased by
+# maintainer-clean, and not by distclean.
+test -f parse1.cc
+test -f parse2.c++
+test -f foo3-parse3.cxx
+test -f foo4-parse4.cpp
+$MAKE distclean
+ls -l
+test -f parse1.cc
+test -f parse2.c++
+test -f foo3-parse3.cxx
+test -f foo4-parse4.cpp
+./configure # Re-create 'Makefile'.
+$MAKE maintainer-clean
+ls -l
+test ! -f parse1.cc
+test ! -f parse2.c++
+test ! -f foo3-parse3.cxx
+test ! -f foo4-parse4.cpp
+
+:
diff --git a/t/yacc-d-basic.sh b/t/yacc-d-basic.sh
new file mode 100755
index 000000000..a633f411a
--- /dev/null
+++ b/t/yacc-d-basic.sh
@@ -0,0 +1,154 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Tests Yacc support with yacc-generated headers
+# (i.e., '-d' in *YFLAGS).
+# Keep in sync with sister test 'yacc-d-cxx.test'.
+
+required='cc yacc'
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_PROG_YACC
+AC_CONFIG_FILES([foo/Makefile bar/Makefile baz/Makefile])
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+SUBDIRS = foo bar baz
+END
+
+mkdir foo bar baz
+
+cat > foo/Makefile.am <<'END'
+bin_PROGRAMS = zardoz
+zardoz_SOURCES = parse.y main.c
+.PHONY: echo-distcom
+echo-distcom:
+ @echo ' ' $(DIST_COMMON) ' '
+END
+cp foo/Makefile.am bar/Makefile.am
+cp foo/Makefile.am baz/Makefile.am
+
+cat > foo/parse.y << 'END'
+%{
+#include "parse.h"
+int yylex () { return 0; }
+void yyerror (char *s) {}
+%}
+%%
+x : 'x' {};
+%%
+END
+cp foo/parse.y bar/parse.y
+
+cat > foo/main.c << 'END'
+#include "parse.h"
+int main ()
+{
+ return yyparse ();
+}
+END
+cp foo/main.c bar/main.c
+
+# Even the generated header file is renamed when target-specific YFLAGS
+# are used. This might not be the best behavior, but it has been in
+# place for quite a long time, so just go along with it for now.
+sed 's/"parse\.h"/"zardoz-parse.h"/' foo/parse.y > baz/parse.y
+sed 's/"parse\.h"/"zardoz-parse.h"/' foo/main.c > baz/main.c
+
+$ACLOCAL
+$AUTOCONF
+
+$AUTOMAKE -a
+$FGREP parse.h foo/Makefile.in bar/Makefile.in baz/Makefile.in && Exit 1
+
+cat >> foo/Makefile.am <<END
+BUILT_SOURCES = parse.h
+YFLAGS=\
+-d
+END
+$AUTOMAKE -Wno-gnu foo/Makefile
+
+sed 's/EOL$//' >> bar/Makefile.am <<END
+AM_YFLAGS${tab}= -d EOL
+BUILT_SOURCES = parse.h
+END
+$AUTOMAKE bar/Makefile
+
+cat >> baz/Makefile.am <<END
+BUILT_SOURCES = zardoz-parse.h
+zardoz_YFLAGS =-d${tab}
+END
+$AUTOMAKE baz/Makefile
+
+./configure
+
+$MAKE
+
+test -f foo/parse.c
+test -f foo/parse.h
+test -f bar/parse.c
+test -f bar/parse.h
+test -f baz/zardoz-parse.c
+test -f baz/zardoz-parse.h
+
+# The generated C source and header files must be shipped.
+for dir in foo bar; do
+ cd $dir
+ $MAKE echo-distcom
+ $MAKE -s echo-distcom | grep '[ /]parse.c '
+ $MAKE -s echo-distcom | grep '[ /]parse.h '
+ cd ..
+done
+cd baz
+$MAKE echo-distcom
+$MAKE -s echo-distcom | grep '[ /]zardoz-parse.c '
+$MAKE -s echo-distcom | grep '[ /]zardoz-parse.h '
+cd ..
+
+$MAKE distdir
+ls -l $distdir
+test -f $distdir/foo/parse.c
+test -f $distdir/foo/parse.h
+test -f $distdir/bar/parse.c
+test -f $distdir/bar/parse.h
+test -f $distdir/baz/zardoz-parse.c
+test -f $distdir/baz/zardoz-parse.h
+
+# Sanity check the distribution.
+yl_distcheck
+
+# While we are at it, make sure that 'parse.c' and 'parse.h' are erased
+# by maintainer-clean, and not by distclean.
+$MAKE distclean
+test -f foo/parse.c
+test -f foo/parse.h
+test -f bar/parse.c
+test -f bar/parse.h
+test -f baz/zardoz-parse.c
+test -f baz/zardoz-parse.h
+./configure # Re-create 'Makefile'.
+$MAKE maintainer-clean
+test ! -f foo/parse.c
+test ! -f foo/parse.h
+test ! -f bar/parse.c
+test ! -f bar/parse.h
+test ! -f baz/zardoz-parse.c
+test ! -f baz/zardoz-parse.h
+
+:
diff --git a/t/yacc-d-cxx.sh b/t/yacc-d-cxx.sh
new file mode 100755
index 000000000..51d78f1b3
--- /dev/null
+++ b/t/yacc-d-cxx.sh
@@ -0,0 +1,231 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Various tests on Yacc/C++ support with yacc-generated headers
+# (i.e., '-d' in *YFLAGS).
+# Keep in sync with sister test 'yacc-d-basic.test'.
+
+required=yacc
+. ./defs || Exit 1
+
+write_parse ()
+{
+ header=$1
+ unindent <<END
+ %{
+ // Valid C++, but deliberately invalid C.
+ #include <cstdlib>
+ #include "$header"
+ int yylex (void) { return 0; }
+ void yyerror (const char *s) {}
+ %}
+ %%
+ x : 'x' {};
+ %%
+END
+}
+
+write_main ()
+{
+ header=$1
+ unindent <<END
+ // Valid C++, but deliberately invalid C.
+ #include <cstdio>
+ #include "$header"
+ int main (int argc, char **argv)
+ {
+ int yyparse (void);
+ return yyparse ();
+ }
+END
+}
+
+cat >> configure.ac << 'END'
+AC_PROG_CXX
+AC_PROG_YACC
+AC_CONFIG_FILES([foo/Makefile bar/Makefile baz/Makefile qux/Makefile])
+AC_OUTPUT
+END
+
+mkdir foo bar baz qux baz/sub
+
+# These makefiles will be extended later.
+cat > Makefile.am <<'END'
+.PHONY: echo-distcom
+echo-distcom:
+ @echo ' ' $(DIST_COMMON) ' '
+END
+cp Makefile.am foo/Makefile.am
+cp Makefile.am bar/Makefile.am
+cp Makefile.am baz/Makefile.am
+cp Makefile.am qux/Makefile.am
+
+cat >> Makefile.am <<'END'
+SUBDIRS = foo bar baz qux
+END
+
+$ACLOCAL
+$AUTOCONF
+
+cp $testsrcdir/../lib/ylwrap .
+
+$AUTOMAKE Makefile
+
+# Try with -d in $(YFLAGS) (don't do this in real life!).
+cat >> foo/Makefile.am <<END
+bin_PROGRAMS = zardoz
+zardoz_SOURCES = parse.yy main.cc
+BUILT_SOURCES = parse.hh
+YFLAGS=\
+-d
+END
+
+$AUTOMAKE -Wno-gnu foo/Makefile
+
+write_parse parse.hh > foo/parse.yy
+write_main parse.hh > foo/main.cc
+
+# Try with -d in $(AM_YFLAGS).
+cat >> bar/Makefile.am <<END
+bin_PROGRAMS = zardoz
+zardoz_SOURCES = parse.ypp main.cpp
+BUILT_SOURCES = parse.hpp
+AM_YFLAGS${tab}= -d ${tab}
+END
+
+$AUTOMAKE bar/Makefile
+
+write_parse parse.hpp > bar/parse.ypp
+write_main parse.hpp > bar/main.cpp
+
+# Try with -d in $(AM_YFLAGS), and a subdir parser.
+cat >> baz/Makefile.am <<END
+AUTOMAKE_OPTIONS = subdir-objects
+bin_PROGRAMS = joe
+joe_SOURCES = sub/parse.y++ sub/main.c++
+BUILT_SOURCES = sub/parse.h++
+AM_YFLAGS = \
+${tab}-d
+END
+
+$AUTOMAKE baz/Makefile
+
+write_parse sub/parse.h++ > baz/sub/parse.y++
+write_main sub/parse.h++ > baz/sub/main.c++
+
+# Try with -d in $(xxx_YFLAGS) (per-object flag).
+cat >> qux/Makefile.am <<END
+bin_PROGRAMS = maude
+maude_SOURCES = parse.yxx main.cxx
+maude_YFLAGS=${tab} -d${tab}
+BUILT_SOURCES = maude-parse.hxx
+END
+
+$AUTOMAKE qux/Makefile
+
+write_parse maude-parse.hxx > qux/parse.yxx
+write_main maude-parse.hxx > qux/main.cxx
+
+./configure
+
+$MAKE
+ls -l . foo bar baz baz/sub qux # For debugging.
+
+test -f foo/parse.cc
+test -f foo/parse.hh
+test -f bar/parse.cpp
+test -f bar/parse.hpp
+test -f baz/sub/parse.c++
+test -f baz/sub/parse.h++
+test -f qux/maude-parse.cxx
+test -f qux/maude-parse.hxx
+
+# The ylwrap script must be shipped.
+$MAKE echo-distcom
+$MAKE -s echo-distcom | grep '[ /]ylwrap '
+
+# The generated C++ source and header files must be shipped.
+cd foo
+$MAKE echo-distcom
+$MAKE -s echo-distcom | grep '[ /]parse\.cc '
+$MAKE -s echo-distcom | grep '[ /]parse\.hh '
+cd ..
+cd bar
+$MAKE echo-distcom
+$MAKE -s echo-distcom | grep '[ /]parse\.cpp '
+$MAKE -s echo-distcom | grep '[ /]parse\.hpp '
+cd ..
+cd baz
+$MAKE echo-distcom
+$MAKE -s echo-distcom | grep '[ /]sub/parse\.c++ '
+$MAKE -s echo-distcom | grep '[ /]sub/parse\.h++ '
+cd ..
+cd qux
+$MAKE echo-distcom
+$MAKE -s echo-distcom | grep '[ /]maude-parse\.cxx '
+$MAKE -s echo-distcom | grep '[ /]maude-parse\.hxx '
+cd ..
+
+$MAKE distdir
+find $distdir # For debugging.
+
+test -f $distdir/ylwrap
+test -f $distdir/foo/parse.cc
+test -f $distdir/foo/parse.hh
+test -f $distdir/bar/parse.cpp
+test -f $distdir/bar/parse.hpp
+test -f $distdir/baz/sub/parse.c++
+test -f $distdir/baz/sub/parse.h++
+test -f $distdir/qux/maude-parse.cxx
+test -f $distdir/qux/maude-parse.hxx
+
+# The Yacc-derived C++ sources must be created, and not removed once
+# compiled (i.e., not treated like "intermediate files" in the GNU
+# make sense).
+yl_distcheck
+
+# Check that we can recover from deleted headers.
+$MAKE clean
+rm -f foo/parse.hh bar/parse.hpp baz/sub/parse.h++ qux/maude-parse.hxx
+$MAKE
+test -f foo/parse.hh
+test -f bar/parse.hpp
+test -f baz/sub/parse.h++
+test -f qux/maude-parse.hxx
+
+# Make sure that the Yacc-derived C++ sources are erased by
+# maintainer-clean, and not by distclean.
+$MAKE distclean
+test -f foo/parse.cc
+test -f foo/parse.hh
+test -f bar/parse.cpp
+test -f bar/parse.hpp
+test -f baz/sub/parse.c++
+test -f baz/sub/parse.h++
+test -f qux/maude-parse.cxx
+test -f qux/maude-parse.hxx
+./configure # Re-create 'Makefile'.
+$MAKE maintainer-clean
+test ! -f foo/parse.cc
+test ! -f foo/parse.hh
+test ! -f bar/parse.cpp
+test ! -f bar/parse.hpp
+test ! -f baz/sub/parse.c++
+test ! -f baz/sub/parse.h++
+test ! -f qux/maude-parse.cxx
+test ! -f qux/maude-parse.hxx
+
+:
diff --git a/t/yacc-d-vpath.sh b/t/yacc-d-vpath.sh
new file mode 100755
index 000000000..78a486a70
--- /dev/null
+++ b/t/yacc-d-vpath.sh
@@ -0,0 +1,108 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# This test checks that dependent files are updated before including
+# in the distribution. 'parse.c' depends on 'parse.y'. The latter is
+# updated so that 'parse.c' should be rebuilt. Then we are running
+# 'make' and 'make distdir' and check whether the version of 'parse.c'
+# to be distributed is up to date.
+
+# Please keep this in sync with sister test 'yaccvpath.test'.
+
+required='cc yacc'
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_PROG_YACC
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = foo
+foo_SOURCES = parse.y foo.c
+AM_YFLAGS = -d
+END
+
+# Original parser, with 'foobar'.
+cat > parse.y << 'END'
+%{
+int yylex () { return 0; }
+void yyerror (char *s) {}
+%}
+%token FOOBAR
+%%
+foobar : 'f' 'o' 'o' 'b' 'a' 'r' {};
+END
+
+cat > foo.c << 'END'
+#include "parse.h"
+int main () { return 0; }
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+$YACC -d parse.y
+mv y.tab.c parse.c
+mv y.tab.h parse.h
+# Sanity checks.
+grep foobar parse.c
+grep FOOBAR parse.h
+
+mkdir sub
+cd sub
+../configure
+
+$sleep
+
+# New parser, with 'fubar'.
+cat > ../parse.y << 'END'
+%{
+int yylex () { return 0; }
+void yyerror (char *s) {}
+%}
+%token FUBAR
+%%
+fubar : 'f' 'u' 'b' 'a' 'r' {};
+END
+
+$MAKE
+$MAKE distdir
+$FGREP fubar $distdir/parse.c
+$FGREP FUBAR $distdir/parse.h
+
+# Now check to make sure that 'make dist' will rebuild the parser.
+
+$sleep
+
+# New parser, with 'maude'.
+cat > ../parse.y << 'END'
+%{
+int yylex () { return 0; }
+void yyerror (char *s) {}
+%}
+%token MAUDE
+%%
+maude : 'm' 'a' 'u' 'd' 'e' {};
+END
+
+$MAKE distdir
+$FGREP maude $distdir/parse.c
+$FGREP MAUDE $distdir/parse.h
+
+:
diff --git a/t/yacc-deleted-headers.sh b/t/yacc-deleted-headers.sh
new file mode 100755
index 000000000..5ab8d871a
--- /dev/null
+++ b/t/yacc-deleted-headers.sh
@@ -0,0 +1,163 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Tests that we can recover from deleted headers generated by 'yacc -d'.
+
+required=yacc
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_PROG_YACC
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+bin_PROGRAMS = p1 p2 p3 p4
+# The order in which files are listed in the p*_SOURCES variables
+# below is significant, since it causes make failures whenever
+# the proper definition of BUILT_SOURCES or the declaration of
+# extra dependencies for 'main3.o' are removed.
+p1_SOURCES = main1.c parse1.y
+p2_SOURCES = main2.c parse2.y
+p3_SOURCES = main3.c parse3.y parse3.h
+p4_SOURCES = parse4.y
+AM_YFLAGS = -d
+p2_YFLAGS = -d
+
+BUILT_SOURCES = parse1.h p2-parse2.h
+
+# When we know which files include a yacc-generated header, we
+# should be able to just declare dependencies directly instead
+# of relying on the BUILT_SOURCES hack, and things should still
+# work correctly.
+main3.@OBJEXT@: parse3.h
+
+.PHONY: clean-p3 build-p3
+build-p3: p3$(EXEEXT)
+clean-p3:
+ rm -f p3$(EXEEXT)
+END
+
+cat > parse1.y << 'END'
+%{
+#include "parse1.h"
+int yylex () { return 0; }
+void yyerror (char *s) { return; }
+%}
+%token ZARDOZ
+%%
+x : 'x' {};
+%%
+END
+
+cat > main1.c << 'END'
+#include "parse1.h"
+int main (void)
+{
+ return ZARDOZ + yyparse ();
+}
+END
+
+sed 's/"parse1\.h"/"p2-parse2.h"/' parse1.y > parse2.y
+sed 's/"parse1\.h"/"p2-parse2.h"/' main1.c > main2.c
+
+sed 's/"parse1\.h"/"parse3.h"/' parse1.y > parse3.y
+sed 's/"parse1\.h"/"parse3.h"/' main1.c > main3.c
+
+cat > parse4.y << 'END'
+%{
+int yylex () { return 0; }
+void yyerror (char *s) { return; }
+%}
+%%
+x : 'x' {};
+%%
+int main (void)
+{
+ return 0;
+}
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+$MAKE
+
+headers='parse1.h p2-parse2.h parse3.h parse4.h'
+
+# Check that we remake only the necessary headers.
+
+rm -f $headers
+$MAKE parse1.h
+test -f parse1.h
+test ! -r p2-parse2.h
+test ! -r parse3.h
+test ! -r parse4.h
+
+rm -f $headers
+$MAKE p2-parse2.h
+test ! -r parse1.h
+test -f p2-parse2.h
+test ! -r parse3.h
+test ! -r parse4.h
+
+rm -f $headers
+$MAKE parse3.h
+test ! -r parse1.h
+test ! -r p2-parse2.h
+test -f parse3.h
+test ! -r parse4.h
+# Since we declared parse3.h into $(p3_SOURCES), make should be
+# able to rebuild it automatically before remaking 'p3'.
+rm -f $headers
+$MAKE clean-p3
+test ! -f parse3.h # Sanity check.
+$MAKE build-p3
+test -f parse3.h
+
+$MAKE
+
+rm -f $headers
+$MAKE parse4.h
+test ! -r parse1.h
+test ! -r p2-parse2.h
+test ! -r parse3.h
+test -f parse4.h
+
+# Now remake all the headers together.
+
+rm -f $headers
+$MAKE $headers
+test -f parse1.h
+test -f p2-parse2.h
+test -f parse3.h
+test -f parse4.h
+
+# Most headers should be remade by "make all".
+
+rm -f $headers
+$MAKE all
+test -f parse1.h
+test -f p2-parse2.h
+test -f parse3.h
+# parse4.h is not declared in any *_SOURCES variable, nor #included
+# by any C source file, so it shouldn't be rebuilt by "make all".
+test ! -r parse4.h
+
+:
diff --git a/t/yacc-depend.sh b/t/yacc-depend.sh
new file mode 100755
index 000000000..73d64ad12
--- /dev/null
+++ b/t/yacc-depend.sh
@@ -0,0 +1,82 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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 depcomp does not needlessly update headers for yacc rules.
+# Report from Paolo Bonzini.
+
+required=yacc
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_PROG_YACC
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = foo
+AM_YFLAGS = -d
+foo_SOURCES = foo.y main.c
+BUILT_SOURCES = foo.h
+END
+
+cat > foo.y << 'END'
+%{
+int yylex () { return 0; }
+void yyerror (char *s) { return; }
+%}
+%token TOKEN
+%%
+foobar : 'f' 'o' 'o' 'b' 'a' 'r' {};
+END
+
+
+cat > main.c << 'END'
+#include "foo.h"
+int main(void)
+{
+ return yyparse ();
+}
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+# Try to enable dependency tracking if possible, even if that means
+# using slow dependency extractors.
+./configure --enable-dependency-tracking
+$MAKE
+ls -l # For debugging.
+
+# Make sure foo.h is not updated if not really needed.
+$sleep
+: > my-timestamp
+$sleep
+touch foo.y
+$MAKE
+stat my-timestamp foo.* || : # For debugging.
+is_newest my-timestamp foo.h
+
+# Make sure foo.h is updated if needed.
+$sleep
+sed 's/TOKEN/TEKON/g' foo.y > t
+mv -f t foo.y
+$MAKE
+stat my-timestamp foo.* || : # For debugging.
+is_newest foo.h my-timestamp
+
+:
diff --git a/t/yacc-depend2.sh b/t/yacc-depend2.sh
new file mode 100755
index 000000000..879cc5911
--- /dev/null
+++ b/t/yacc-depend2.sh
@@ -0,0 +1,86 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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 depcomp does not needlessly update headers and objects
+# for yacc rules. This test still fails with FreeBSD make (but passes
+# with NetBSD make).
+
+required=yacc
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_PROG_YACC
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = foo
+AM_YFLAGS = -d
+foo_SOURCES = foo.y main.c
+BUILT_SOURCES = foo.h
+.PHONY: debug-info test-time-unchanged test-time-changed
+debug-info:
+ ls -l
+ stat *.[ch] *.$(OBJEXT) my-timestamp || :
+test-time-unchanged: debug-info
+ test `ls -1t main.$(OBJEXT) my-timestamp | sed 1q` = my-timestamp
+test-time-changed: debug-info
+ test `ls -1t main.$(OBJEXT) my-timestamp | sed 1q` = main.$(OBJEXT)
+END
+
+cat > foo.y << 'END'
+%{
+int yylex () { return 0; }
+void yyerror (char *s) { return; }
+%}
+%token TOKEN
+%%
+foobar : 'f' 'o' 'o' 'b' 'a' 'r' {};
+END
+
+
+cat > main.c << 'END'
+#include "foo.h"
+int main(void)
+{
+ return yyparse ();
+}
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+# Try to enable dependency tracking if possible, even if that means
+# using slow dependency extractors.
+./configure --enable-dependency-tracking
+$MAKE
+ls -l # For debugging.
+
+$sleep
+: > my-timestamp
+$sleep
+touch foo.y
+$MAKE
+$MAKE test-time-unchanged
+$sleep
+sed 's/TOKEN/TEKON/g' foo.y > t
+mv -f t foo.y
+$MAKE
+$MAKE test-time-changed
+
+:
diff --git a/t/yacc-dist-nobuild-subdir.sh b/t/yacc-dist-nobuild-subdir.sh
new file mode 100755
index 000000000..3fdae8d2a
--- /dev/null
+++ b/t/yacc-dist-nobuild-subdir.sh
@@ -0,0 +1,93 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that VPATH builds and "make distcheck" works with packages
+# using yacc and the automake 'subdir-objects' option.
+# Exposes automake bug#8485.
+
+required=yacc
+. ./defs || Exit 1
+
+# This test is bounded to fail for any implementation that
+# triggers automake bug#7884.
+useless_vpath_rebuild && skip_ "would trip on automake bug#7884"
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_PROG_YACC
+AC_OUTPUT
+END
+
+mkdir sub
+
+cat > sub/parse.y << 'END'
+%{
+int yylex () { return 0; }
+void yyerror (char *s) { return; }
+%}
+%%
+x : 'x' {};
+%%
+int main (void)
+{
+ return yyparse ();
+}
+END
+
+cat > Makefile.am <<'END'
+AUTOMAKE_OPTIONS = subdir-objects
+noinst_PROGRAMS = foo bar
+foo_SOURCES = sub/parse.y
+bar_SOURCES = $(foo_SOURCES)
+AM_YFLAGS = -d
+bar_YFLAGS =
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+$MAKE distdir
+
+# Yacc-derived C source and header files must be built and distributed.
+
+test -f sub/parse.c
+test -f sub/parse.h
+test -f sub/bar-parse.c
+test ! -r sub/bar-parse.h
+
+test -f $distdir/sub/parse.c
+test -f $distdir/sub/parse.h
+test -f $distdir/sub/bar-parse.c
+test ! -r $distdir/sub/bar-parse.h
+
+# But they shouldn't be rebuilt in VPATH builds.
+
+mkdir $distdir/build
+chmod -R a-w $distdir
+cd $distdir/build
+chmod u+w .
+# Try to enable dependency tracking even with slow dependency
+# extractors, to improve coverage.
+../configure --enable-dependency-tracking YACC=false
+$MAKE
+ls -l sub/*.[ch] && Exit 1
+
+env DISTCHECK_CONFIGURE_FLAGS='YACC=false' $MAKE distcheck
+
+:
diff --git a/t/yacc-dist-nobuild.sh b/t/yacc-dist-nobuild.sh
new file mode 100755
index 000000000..6f02f1109
--- /dev/null
+++ b/t/yacc-dist-nobuild.sh
@@ -0,0 +1,90 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that distributed Yacc-generated parsers are not uselessly
+# remade from an unpacked distributed tarball.
+# See automake bug#7884.
+
+required='cc yacc'
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_PROG_YACC
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = foobar zardoz
+foobar_SOURCES = parse.y main.c
+zardoz_SOURCES = $(foobar_SOURCES)
+zardoz_YFLAGS = -d
+END
+
+cat > parse.y << 'END'
+%{
+int yylex () { return 0; }
+void yyerror (char *s) {}
+%}
+%%
+foobar : 'f' 'o' 'o' 'b' 'a' 'r' {};
+END
+
+cat > main.c << 'END'
+int main () { return 0; }
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+$MAKE
+
+$MAKE distdir
+chmod -R a-w $distdir
+
+mkdir bin
+cat > bin/yacc <<'END'
+#!/bin/sh
+echo "$0 invoked, shouldn't happen!" >&2
+exit 1
+END
+cp bin/yacc bin/bison
+chmod a+x bin/yacc bin/bison
+PATH=`pwd`/bin$PATH_SEPARATOR$PATH
+
+YACC=yacc BISON=bison
+export YACC BISON
+
+mkdir build
+cd build
+../$distdir/configure
+$MAKE
+
+# Sanity check.
+cd ..
+chmod u+w $distdir
+rm -f $distdir/parse.c
+chmod a-w $distdir
+mkdir build2
+cd build2
+../$distdir/configure
+$MAKE >out 2>&1 && { cat out; Exit 1; }
+cat out
+$FGREP parse.c out
+
+:
diff --git a/t/yacc-line.sh b/t/yacc-line.sh
new file mode 100755
index 000000000..ac6a0aa98
--- /dev/null
+++ b/t/yacc-line.sh
@@ -0,0 +1,113 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Check that automake yacc support ensures that yacc-generated C
+# files use correct "#line" directives. Try also with the
+# 'subdir-object' option enabled.
+# See also sister test 'lex-line.test'.
+
+required=yacc
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_CONFIG_FILES([sub/Makefile])
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_PROG_YACC
+AC_OUTPUT
+END
+
+mkdir dir sub sub/dir
+
+cat > Makefile.am << 'END'
+SUBDIRS = sub
+bin_PROGRAMS = foo bar
+AM_YFLAGS = -d
+bar_YFLAGS =
+foo_SOURCES = zardoz.y
+bar_SOURCES = dir/quux.y
+## Avoid spurious failures with Solaris make.
+zardoz.@OBJEXT@: zardoz.c
+bar-quux.@OBJEXT@: bar-quux.c
+END
+
+cat > sub/Makefile.am << 'END'
+AUTOMAKE_OPTIONS = subdir-objects
+noinst_PROGRAMS = foo bar
+foo_YFLAGS = -d
+foo_SOURCES = zardoz.y
+bar_SOURCES = dir/quux.y
+## Avoid spurious failures with Solaris make.
+foo-zardoz.@OBJEXT@: foo-zardoz.c
+dir/quux.@OBJEXT@: dir/quux.c
+END
+
+cat > zardoz.y << 'END'
+%{
+int yylex () { return 0; }
+void yyerror (char *s) { return; }
+%}
+%%
+x : 'x' {};
+%%
+int main(void)
+{
+ return yyparse ();
+}
+END
+
+cp zardoz.y dir/quux.y
+cp zardoz.y sub/zardoz.y
+cp zardoz.y sub/dir/quux.y
+
+c_outputs='zardoz.c bar-quux.c sub/foo-zardoz.c sub/dir/quux.c'
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+for vpath in : false; do
+
+ if $vpath; then
+ srcdir=..
+ mkdir build
+ cd build
+ else
+ srcdir=.
+ fi
+
+ $srcdir/configure
+ $MAKE
+
+ # For debugging,
+ ls -l . sub sub/dir
+ $FGREP '.y' $c_outputs
+
+ # Adjusted "#line" should not contain reference to the builddir.
+ $EGREP '#.*line.*(build|\.\.).*\.y' $c_outputs && Exit 1
+ # Adjusted "#line" should not contain reference to the default
+ # output file names, e.g., 'y.tab.c' and 'y.tab.h'.
+ $EGREP '#.*line.*y\.tab\.' $c_outputs && Exit 1
+ # Don't be excessively strict in grepping, to avoid spurious failures.
+ grep '#.*line.*zardoz\.y' zardoz.c
+ grep '#.*line.*quux\.y' bar-quux.c
+ grep '#.*line.*zardoz\.y' sub/foo-zardoz.c
+ grep '#.*line.*quux\.y' sub/dir/quux.c
+ cd $srcdir
+
+done
+
+:
diff --git a/t/yacc-mix-c-cxx.sh b/t/yacc-mix-c-cxx.sh
new file mode 100755
index 000000000..8f72b35c4
--- /dev/null
+++ b/t/yacc-mix-c-cxx.sh
@@ -0,0 +1,206 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that many different Yacc parsers (both C and C++) can co-exists
+# in the same directory.
+
+required=yacc
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_PROG_CXX
+AC_PROG_YACC
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = c1 c2 cxx1 cxx2 cxx3
+AM_YFLAGS = -d
+
+c1_SOURCES = p.y p.h 1.c
+c2_SOURCES = p.y 2.c
+c2_YFLAGS =
+
+cxx1_SOURCES = parse.yy main1.cc parse.hh
+
+cxx2_SOURCES = parse2.y++ main2.c++
+cxx2_YFLAGS =
+
+cxx3_SOURCES = parse3.yxx main3.cxx
+
+BUILT_SOURCES = p.h parse.hh parse3.hxx
+END
+
+# The content of all the .c and .y files created below is valid C but
+# deliberately invalid C++.
+# Vice versa, the content of all the .c++, .cxx, .cc, .y++, .yxx and
+# .yy files created below is valid C++ but deliberately invalid C.
+
+cat > p.y <<'END'
+%{
+int yylex (void) { int new = 0; return new; }
+void yyerror (char *s) { return; }
+%}
+%token ZARDOZ
+%%
+x : 'x' {};
+%%
+END
+
+cat > 1.c <<'END'
+#include "p.h"
+int main ()
+{
+ int new = ZARDOZ;
+ return yyparse () + new;
+}
+
+END
+
+cat > 2.c <<'END'
+int main ()
+{
+ int yyparse ();
+ int new = 0;
+ return yyparse () + new;
+}
+END
+
+cat > parse.yy <<'END'
+%{
+#include <cstdlib>
+#include "parse.hh"
+int yylex (void) { return 0; }
+void yyerror (const char *s) { return; }
+%}
+%token FOOBAR
+%%
+x : 'x' {};
+%%
+END
+
+cat > parse2.y++ <<'END'
+%{
+#include <cstdlib>
+int yylex (void) { return 0; }
+void yyerror (const char *s) { return; }
+%}
+%%
+x : 'x' {};
+%%
+END
+
+cat > main1.cc <<'END'
+using namespace std;
+#include "parse.hh"
+int main (int argc, char **argv)
+{
+ int yyparse (void);
+ return yyparse () + FOOBAR;
+}
+END
+
+cat > main2.c++ <<'END'
+using namespace std;
+int main (int argc, char **argv)
+{
+ int yyparse (void);
+ return yyparse ();
+}
+END
+
+edit () { sed -e 's/FOOBAR/BAZQUUX/' -e 's/"parse\.hh"/"parse3.hxx"/'; }
+edit <parse.yy >parse3.yxx
+edit <main1.cc >main3.cxx
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+# Try a VPATH and by default serial build first, and then an in-tree
+# and by default parallel build.
+
+for try in 0 1; do
+
+ if test $try -eq 0; then
+ # VPATH serial build.
+ mkdir build
+ cd build
+ srcdir=..
+ debug_info="ls -l . $srcdir"
+ run_make=$MAKE
+ elif test $try -eq 1; then
+ # In-tree parallel build.
+ srcdir=.
+ debug_info="ls -l"
+ case $MAKE in
+ *\ -j*)
+ # Degree of parallelism already specified by the user: do
+ # not override it.
+ run_make=$MAKE;;
+ *)
+ # Some make implementations (e.g., HP-UX) don't grok '-j',
+ # some require no space between '-j' and the number of jobs
+ # (e.g., older GNU make versions), and some *do* require a
+ # space between '-j' and the number of jobs (e.g., Solaris
+ # dmake). We need a runtime test to see what works.
+ echo 'all:' > Makefile
+ for run_make in "$MAKE -j3" "$MAKE -j 3" "$MAKE"; do
+ $run_make && break
+ done
+ rm -f Makefile
+ esac
+ else
+ echo "$me: invalid value of \$try '$try'" >&2
+ Exit 99
+ fi
+
+ $srcdir/configure
+
+ $run_make
+ $debug_info
+
+ test -f p.c
+ test -f p.h
+ test -f c2-p.c
+ test ! -r c2-p.h
+
+ test -f parse.cc
+ test -f parse.hh
+ test -f parse3.cxx
+ test -f parse3.hxx
+
+ test -f cxx2-parse2.c++
+ test ! -r parse2.h++
+ test ! -r cxx2-parse2.h++
+
+ # Minimal checks about recovering from header removal.
+ rm -f p.h parse.hh parse3.hxx
+ $run_make p.h parse.hh
+ $debug_info
+ test -f p.h
+ test -f parse.hh
+ test ! -r parse3.hxx
+ $run_make
+ $debug_info
+ test -f parse3.hxx
+
+ cd $srcdir
+
+done
+
+:
diff --git a/t/yacc-nodist.sh b/t/yacc-nodist.sh
new file mode 100755
index 000000000..2124357d5
--- /dev/null
+++ b/t/yacc-nodist.sh
@@ -0,0 +1,104 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Checks for .c and .h files derived from non-distributed yacc sources.
+# The test 'yacc-pr204.test' does similar check with AM_MAINTAINER_MODE
+# enabled.
+# The tests 'lex-nodist.test' and 'lex-pr204.test' does similar checks
+# for lex-generated .c files.
+
+required='cc yacc'
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_PROG_YACC
+AC_CONFIG_FILES([sub1/Makefile sub2/Makefile])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+SUBDIRS = sub1 sub2
+.PHONY: test-build test-dist
+test-build: all
+ ls -l . sub1 sub2
+ test -f sub1/parse.y
+ test -f sub1/parse.c
+ test -f sub2/parse.y
+ test -f sub2/parse.c
+ test -f sub2/parse.h
+test-dist: distdir
+ ls -l $(distdir) $(distdir)/sub1 $(distdir)/sub2
+ test ! -r $(distdir)/sub1/parse.y
+ test ! -r $(distdir)/sub1/parse.c
+ test ! -r $(distdir)/sub1/parse.h
+ test ! -r $(distdir)/sub2/parse.y
+ test ! -r $(distdir)/sub2/parse.c
+ test ! -r $(distdir)/sub2/parse.h
+check-local: test-build test-dist
+END
+
+mkdir sub1 sub2
+
+cat > sub1/Makefile.am << 'END'
+parse.y:
+ rm -f $@ $@-t
+ :; { : \
+ && echo "%{" \
+ && echo "int yylex () { return 0; }" \
+ && echo "void yyerror (char *s) {}" \
+ && echo "%}" \
+ && echo "%%" \
+ && echo "maude : 'm' 'a' 'u' 'd' 'e' {}"; \
+ } > $@-t
+ chmod a-w $@-t && mv -f $@-t $@
+
+bin_PROGRAMS = prog
+prog_SOURCES = main.c
+nodist_prog_SOURCES = parse.y
+CLEANFILES = $(nodist_prog_SOURCES)
+END
+
+cat sub1/Makefile.am - > sub2/Makefile.am << 'END'
+AM_YFLAGS = -d
+BUILT_SOURCES = parse.h
+END
+
+cat > sub1/main.c << 'END'
+int main ()
+{
+ return yyparse ();
+}
+END
+cat - sub1/main.c > sub2/main.c << 'END'
+#include "parse.h"
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+$MAKE
+$MAKE test-build
+$MAKE test-dist
+
+# But the distribution must work correctly, assuming the user has
+# the proper tools to process yacc files. Do this check only with
+# GNU make, to avoid tripping on automake bug#7884.
+if using_gmake; then $MAKE distcheck; fi
+
+:
diff --git a/t/yacc-pr204.sh b/t/yacc-pr204.sh
new file mode 100755
index 000000000..6507b5103
--- /dev/null
+++ b/t/yacc-pr204.sh
@@ -0,0 +1,84 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# For PR 204.
+# C sources derived from nodist_ yacc sources should not be distributed.
+# See also related test 'yacc-nodist.test'.
+# The tests 'lex-nodist.test' and 'lex-pr204.test' does similar checks
+# for lex-generated C files.
+
+required='cc yacc'
+. ./defs || Exit 1
+
+cat >> configure.ac <<'EOF'
+AM_MAINTAINER_MODE
+AC_PROG_CC
+AC_PROG_YACC
+AC_OUTPUT
+EOF
+
+# The PARSE2 intermediate variable is there to make
+# sure Automake match 'nodist_' against the right
+# variable name...
+cat > Makefile.am << 'EOF'
+AM_YFLAGS = -d
+EXTRA_PROGRAMS = foo
+PARSE2 = parse2.y
+nodist_foo_SOURCES = parse.y $(PARSE2)
+
+distdirtest: distdir
+ test ! -f $(distdir)/parse.c
+ test ! -f $(distdir)/parse.y
+ test ! -f $(distdir)/parse.h
+ test ! -f $(distdir)/parse2.c
+ test ! -f $(distdir)/parse2.y
+ test ! -f $(distdir)/parse2.h
+EOF
+
+cat > parse.y << 'END'
+%{
+int yylex () {return 0;}
+void yyerror (char *s) {}
+%}
+%%
+maude : 'm' 'a' 'u' 'd' 'e' {};
+END
+
+cp parse.y parse2.y
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+$MAKE distdirtest
+
+# Make sure parse.c and parse2.c are still targets.
+$MAKE parse.c parse2.c
+test -f parse.c
+test -f parse2.c
+
+# Ensure the rebuild rule works despite AM_MAINTAINER_MODE, because
+# it's a nodist_ parser.
+$sleep
+touch parse.y parse2.y
+$sleep
+$MAKE parse.c parse2.c
+stat parse.c parse.y parse2.c parse2.y || : # For debugging.
+test `ls -t parse.c parse.y | sed 1q` = parse.c
+test `ls -t parse2.c parse2.y | sed 1q` = parse2.c
+
+:
diff --git a/t/yacc-weirdnames.sh b/t/yacc-weirdnames.sh
new file mode 100755
index 000000000..82270fe96
--- /dev/null
+++ b/t/yacc-weirdnames.sh
@@ -0,0 +1,54 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that yacc sources with many dots in their name are handled
+# correctly.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_PROG_CXX
+AC_PROG_YACC
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = foo bar foo2 bar2
+
+foo_SOURCES = parse.y.y
+bar_SOURCES = parse.s.f..y
+bar_YFLAGS = -d
+
+foo2_SOURCES = parse..5.y++
+bar2_SOURCES = parse.yxx.yy
+bar2_YFLAGS = -d
+END
+
+outputs=' parse.y.c bar-parse.s.f..c bar-parse.s.f..h
+ parse..5.c++ bar2-parse.yxx.cc bar2-parse.yxx.hh '
+
+$ACLOCAL
+$AUTOMAKE -a
+
+$EGREP '(\.[ch]|parse)' Makefile.in # For debugging.
+
+# All expected files should be mentioned in the generated Makefile.in.
+for s in $outputs; do
+ $FGREP $s Makefile.in
+done
+
+:
diff --git a/t/yacc.sh b/t/yacc.sh
new file mode 100755
index 000000000..60b5a4ffc
--- /dev/null
+++ b/t/yacc.sh
@@ -0,0 +1,37 @@
+#! /bin/sh
+# Copyright (C) 1996-2012 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/>.
+
+# Test to make sure intermediate .c file is built from yacc source.
+# Bug from Thomas Morgan.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_PROG_YACC
+END
+
+cat > Makefile.am <<'END'
+bin_PROGRAMS = zardoz
+zardoz_SOURCES = zardoz.y
+END
+
+$ACLOCAL
+$AUTOMAKE -a
+
+$FGREP 'zardoz.c' Makefile.in
+
+:
diff --git a/t/yacc2.sh b/t/yacc2.sh
new file mode 100755
index 000000000..bfab7522d
--- /dev/null
+++ b/t/yacc2.sh
@@ -0,0 +1,72 @@
+#! /bin/sh
+# Copyright (C) 1999-2012 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/>.
+
+# Test to make sure intermediate .h file is not generated nor removed
+# if (AM_)?YFLAGS do not contain -d. Requested by Jim Meyering.
+# See also the related semantic test 'yacc-d-basic.test'.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_PROG_YACC
+END
+
+# Run it here once and for all, since we are not going to modify
+# configure.ac anymore.
+$ACLOCAL
+
+cat > Makefile.am <<'END'
+bin_PROGRAMS = zardoz
+zardoz_SOURCES = zardoz.y
+END
+
+# Don't redefine several times the same variable.
+cp Makefile.am Makefile.src
+
+$AUTOMAKE -a
+# If zardoz.h IS mentioned, fail.
+$FGREP 'zardoz.h' Makefile.in && Exit 1
+
+cp Makefile.src Makefile.am
+echo 'AM_YFLAGS = -d' >> Makefile.am
+$AUTOMAKE
+# If zardoz.h is NOT mentioned, fail.
+$FGREP 'zardoz.h' Makefile.in
+
+cp Makefile.src Makefile.am
+echo 'AM_YFLAGS = ' >> Makefile.am
+$AUTOMAKE
+# If zardoz.h IS mentioned, fail.
+$FGREP 'zardoz.h' Makefile.in && Exit 1
+
+cp Makefile.src Makefile.am
+echo 'YFLAGS = -d' >> Makefile.am
+# YFLAGS is a user variable.
+AUTOMAKE_fails
+grep 'YFLAGS.* user variable' stderr
+grep 'AM_YFLAGS.* instead' stderr
+$AUTOMAKE -Wno-gnu
+# If zardoz.h is NOT mentioned, fail.
+$FGREP 'zardoz.h' Makefile.in
+
+cp Makefile.src Makefile.am
+echo 'YFLAGS = ' >> Makefile.am
+$AUTOMAKE -Wno-gnu
+# If zardoz.h IS mentioned, fail.
+$FGREP 'zardoz.h' Makefile.in && Exit 1
+
+:
diff --git a/t/yacc4.sh b/t/yacc4.sh
new file mode 100755
index 000000000..3f9a20478
--- /dev/null
+++ b/t/yacc4.sh
@@ -0,0 +1,86 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Some simple tests of ylwrap functionality.
+
+required='cc yacc'
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_PROG_YACC
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = foo bar
+foo_SOURCES = parse.y foo.c
+bar_SOURCES = bar.y foo.c
+END
+
+# First parser.
+cat > parse.y << 'END'
+%{
+int yylex () { return 0; }
+void yyerror (char *s) {}
+%}
+%%
+foobar : 'f' 'o' 'o' 'b' 'a' 'r' {};
+END
+
+# Second parser.
+cat > bar.y << 'END'
+%{
+int yylex () { return 0; }
+void yyerror (char *s) {}
+%}
+%%
+fubar : 'f' 'o' 'o' 'b' 'a' 'r' {};
+END
+
+cat > foo.c << 'END'
+int main (void)
+{
+ return 0;
+}
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+test -f ylwrap
+
+mkdir sub
+cd sub
+
+../configure
+$MAKE
+
+grep '^#.*/sub/\.\./' bar.c && Exit 1
+grep '^#.*/sub/\.\./' parse.c && Exit 1
+
+# Make distclean must not erase bar.c nor parse.c (by GNU standards) ...
+$MAKE distclean
+test -f bar.c
+test -f parse.c
+# ... but maintainer-clean should.
+../configure
+$MAKE maintainer-clean
+test ! -f bar.c
+test ! -f parse.c
+
+:
diff --git a/t/yacc5.sh b/t/yacc5.sh
new file mode 100755
index 000000000..ab24b563d
--- /dev/null
+++ b/t/yacc5.sh
@@ -0,0 +1,80 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test of yacc functionality, derived from GNU binutils
+# by Tim Van Holder.
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_PROG_YACC
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = maude
+maude_SOURCES = sub/maude.y
+END
+
+mkdir sub
+
+: > sub/maude.y
+
+$ACLOCAL
+$AUTOMAKE -a
+
+grep '^maude\.c:.*maude\.y' Makefile.in
+
+
+## Try again with subdir-objects.
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = subdir-objects
+bin_PROGRAMS = maude
+maude_SOURCES = sub/maude.y
+END
+
+$ACLOCAL
+$AUTOMAKE -a
+
+# No rule needed, the default .y.c: inference rule is enough
+# (but there may be an additional dependency on a dirstamp file).
+grep '^sub/maude\.c:.*maude\.y' Makefile.in && Exit 1
+
+
+## Try again with per-exe flags.
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = maude
+maude_SOURCES = sub/maude.y
+## A particularly trickey case.
+maude_YFLAGS = -d
+END
+
+$ACLOCAL
+$AUTOMAKE -a
+
+# Rule should use maude_YFLAGS.
+grep 'AM_YFLAGS.*maude' Makefile.in && Exit 1
+
+# Silly regression.
+grep 'maudec' Makefile.in && Exit 1
+
+# Make sure the .o file is required.
+grep '^am_maude_OBJECTS.*maude' Makefile.in
+
+:
diff --git a/t/yacc7.sh b/t/yacc7.sh
new file mode 100755
index 000000000..a3602e9fa
--- /dev/null
+++ b/t/yacc7.sh
@@ -0,0 +1,89 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# Test to make sure dependencies are generated correctly for .h files.
+# Report from Richard Boulton.
+#
+# Also check that the sources of the generated parser are distributed.
+# PR/47.
+
+required='cc yacc'
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_PROG_YACC
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = foo
+foo_SOURCES = foo.y
+AM_YFLAGS = -d
+
+check-dist: distdir
+ test -f $(distdir)/foo.y
+ test -f $(distdir)/foo.c
+ test -f $(distdir)/foo.h
+END
+
+# The %union will cause Bison to output '#line's in y.tab.h too.
+cat > foo.y << 'END'
+%union
+{
+ int i;
+ char c;
+}
+%%
+WORD: "up";
+%%
+END
+
+$ACLOCAL
+$AUTOMAKE -a
+$AUTOCONF
+./configure
+
+$MAKE foo.h
+
+test -f foo.h
+
+rm -f foo.h foo.c
+$MAKE check-dist
+
+# We should be able to recover if foo.h is deleted.
+
+rm -f foo.h
+$MAKE foo.h
+test -f foo.h
+
+# Make sure '#line ... y.tab.h' gets replaced.
+$FGREP 'y.tab.h' foo.h && Exit 1
+
+# Make distclean must not erase foo.c nor foo.h (by GNU standards) ...
+$MAKE foo.c
+test -f foo.h
+test -f foo.c
+$MAKE distclean
+test -f foo.h
+test -f foo.c
+# ... but maintainer-clean should.
+./configure # Re-create 'Makefile'.
+$MAKE maintainer-clean
+test ! -f foo.h
+test ! -f foo.c
+
+:
diff --git a/t/yacc8.sh b/t/yacc8.sh
new file mode 100755
index 000000000..bab627dfb
--- /dev/null
+++ b/t/yacc8.sh
@@ -0,0 +1,109 @@
+#! /bin/sh
+# Copyright (C) 2002-2012 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/>.
+
+# Test for subdir parsers.
+
+required='cc yacc'
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_PROG_YACC
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS = subdir-objects
+bin_PROGRAMS = foo/foo
+foo_foo_SOURCES = foo/parse.y
+AM_YFLAGS = -d
+
+.PHONY: obj
+obj: foo/parse.$(OBJEXT)
+
+.PHONY: test1 test2
+test1: foo/parse.$(OBJEXT)
+ test -f foo/parse.c
+ test -f foo/parse.$(OBJEXT)
+test2: foo/parse2.$(OBJEXT)
+ test -f foo/parse2.c
+ test -f foo/parse2.$(OBJEXT)
+END
+
+mkdir foo
+
+cat > foo/parse.y << 'END'
+%{
+int yylex () { return 0; }
+void yyerror (char *s) {}
+%}
+%%
+foobar : 'f' 'o' 'o' 'b' 'a' 'r' {};
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+mkdir sub
+cd sub
+
+../configure
+$MAKE test1
+
+# Aside of the rest of this test, let's see if we can recover from
+# parse.h removal.
+test -f foo/parse.h
+rm -f foo/parse.h
+$MAKE foo/parse.h
+test -f foo/parse.h
+
+# Make sure foo/parse.h is not updated, unless when needed.
+$sleep
+: > z
+$sleep
+touch ../foo/parse.y
+$MAKE obj
+test `ls -1t foo/parse.h z | sed 1q` = z
+$sleep
+sed 's/%%/%token TOKEN\n%%/g' ../foo/parse.y >../foo/parse.yt
+mv -f ../foo/parse.yt ../foo/parse.y
+$MAKE obj
+test `ls -1t foo/parse.h z | sed 1q` = foo/parse.h
+
+# Now, adds another parser to test ylwrap.
+
+cd ..
+
+# Sleep some to make sure timestamp of Makefile.am will change.
+$sleep
+
+cp foo/parse.y foo/parse2.y
+cat >> Makefile.am << 'END'
+EXTRA_foo_foo_SOURCES = foo/parse2.y
+END
+
+$AUTOMAKE -a
+test -f ./ylwrap
+
+cd sub
+# Regenerate Makefile (automatic in GNU Make, but not in other Makes).
+./config.status
+$MAKE test2
+
+:
diff --git a/t/yaccdry.sh b/t/yaccdry.sh
new file mode 100755
index 000000000..3100ce360
--- /dev/null
+++ b/t/yaccdry.sh
@@ -0,0 +1,58 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Removal recovery rules for headers should not remove files with 'make -n'.
+
+required='cc yacc'
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_PROG_YACC
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+AM_YFLAGS = -d
+bin_PROGRAMS = foo
+foo_SOURCES = foo.c parse.y
+END
+
+cat > foo.c << 'END'
+int main () { return 0; }
+END
+
+cat > parse.y << 'END'
+%{
+int yylex () { return 0; }
+void yyerror (char *s) {}
+%}
+%%
+foobar : 'f' 'o' 'o' 'b' 'a' 'r' {};
+END
+
+$ACLOCAL
+$AUTOMAKE --add-missing
+$AUTOCONF
+./configure
+$MAKE
+
+rm -f parse.h
+$MAKE -n parse.h
+test -f parse.c
+test ! -f parse.h
+
+:
diff --git a/t/yaccpp.sh b/t/yaccpp.sh
new file mode 100755
index 000000000..c065a50da
--- /dev/null
+++ b/t/yaccpp.sh
@@ -0,0 +1,81 @@
+#! /bin/sh
+# Copyright (C) 1997-2012 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/>.
+
+# Test to make sure Yacc + C++ is not obviously broken.
+# See also related tests 'yacc-cxx.test' and 'yacc-d-cxx.test',
+# which does much more in-depth checks (but requires an actual
+# Yacc program and a working C++ compiler).
+
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CXX
+AC_PROG_YACC
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = foo bar baz qux
+foo_SOURCES = foo.y++
+bar_SOURCES = bar.ypp
+baz_SOURCES = baz.yy
+qux_SOURCES = qux.yxx
+END
+
+$ACLOCAL
+$AUTOMAKE -a
+
+$EGREP '(\.[ch]|foo|bar|baz|qux)' Makefile.in # For debugging.
+
+$EGREP '(foo|bar|baz|qux)\.h' Makefile.in && Exit 1
+
+sed -e 's/^/ /' -e 's/$/ /' Makefile.in >mk
+
+$FGREP ' foo.c++ ' mk
+$FGREP ' bar.cpp ' mk
+$FGREP ' baz.cc ' mk
+$FGREP ' qux.cxx ' mk
+
+cat >> Makefile.am <<END
+AM_YFLAGS = -d
+qux_YFLAGS = foo
+END
+
+$AUTOMAKE
+
+$EGREP '(\.[ch]|foo|bar|baz|qux)' Makefile.in # For debugging.
+
+sed -e 's/^/ /' -e 's/$/ /' Makefile.in >mk
+
+$FGREP ' foo.c++ ' mk
+$FGREP ' foo.h++ ' mk
+$FGREP ' bar.cpp ' mk
+$FGREP ' bar.hpp ' mk
+$FGREP ' baz.cc ' mk
+$FGREP ' baz.hh ' mk
+
+$EGREP '(^| )foo\.h\+\+(:| .*:)' Makefile.in
+$EGREP '(^| )bar\.hpp(:| .*:)' Makefile.in
+$EGREP '(^| )baz\.hh(:| .*:)' Makefile.in
+
+grep ' foo\.h[ :]' mk && Exit 1
+grep ' bar\.h[ :]' mk && Exit 1
+grep ' baz\.h[ :]' mk && Exit 1
+
+$FGREP ' qux-qux.cxx ' mk
+$EGREP '(^| )qux-qux\.cxx(:| .*:)' Makefile.in
+grep 'qux\.h.*:' Makefile.in && Exit 1
+
+:
diff --git a/t/yaccvpath.sh b/t/yaccvpath.sh
new file mode 100755
index 000000000..65ab53bf9
--- /dev/null
+++ b/t/yaccvpath.sh
@@ -0,0 +1,97 @@
+#! /bin/sh
+# Copyright (C) 2001-2012 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/>.
+
+# This test checks that dependent files are updated before including
+# in the distribution. 'parse.c' depends on 'parse.y'. The later is
+# updated so that 'parse.c' should be rebuild. Then we are running
+# 'make' and 'make distdir' and check whether the version of 'parse.c'
+# to be distributed is up to date.
+
+# Please keep this in sync with sister test 'yacc-d-vpath.test'.
+
+required='cc yacc'
+. ./defs || Exit 1
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AC_PROG_YACC
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = foo
+foo_SOURCES = parse.y foo.c
+END
+
+# Original parser, with 'foobar'.
+cat > parse.y << 'END'
+%{
+int yylex () { return 0; }
+void yyerror (char *s) {}
+%}
+%%
+foobar : 'f' 'o' 'o' 'b' 'a' 'r' {};
+END
+
+cat > foo.c << 'END'
+int main () { return 0; }
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+$YACC parse.y
+mv y.tab.c parse.c
+
+mkdir sub
+cd sub
+../configure
+
+$sleep
+
+# New parser, with 'fubar'.
+cat > ../parse.y << 'END'
+%{
+int yylex () { return 0; }
+void yyerror (char *s) {}
+%}
+%%
+fubar : 'f' 'o' 'o' 'b' 'a' 'r' {};
+END
+
+$MAKE
+$MAKE distdir
+$FGREP fubar $distdir/parse.c
+
+# Now check to make sure that 'make dist' will rebuild the parser.
+
+$sleep
+
+# New parser, with 'maude'.
+cat > ../parse.y << 'END'
+%{
+int yylex () { return 0; }
+void yyerror (char *s) {}
+%}
+%%
+maude : 'm' 'a' 'u' 'd' 'e' {};
+END
+
+$MAKE distdir
+$FGREP maude $distdir/parse.c
+
+:
diff --git a/t/yflags-cmdline-override.sh b/t/yflags-cmdline-override.sh
new file mode 100755
index 000000000..fb27c0bab
--- /dev/null
+++ b/t/yflags-cmdline-override.sh
@@ -0,0 +1,88 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that automake can cope with user-redefinition of $(YFLAGS)
+# at configure time and/or at make time.
+
+required='cc yacc'
+. ./defs || Exit 1
+
+unset YFLAGS || :
+
+cat >> configure.ac <<'END'
+AC_PROG_CC
+AC_PROG_YACC
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+bin_PROGRAMS = foo
+foo_SOURCES = foo.y
+# A minor automake wart: automake doesn't generate code to clean
+# '*.output' files generated by yacc (it's not even clear if that
+# would be useful in general, so it's probably better to be
+# conservative).
+CLEANFILES = foo.output
+# Another automake wart: '-d' flag won't be given at automake time,
+# so automake won't be able to generate code to clean 'foo.h' :-(
+MAINTAINERCLEANFILES = foo.h
+END
+
+cat > foo.y << 'END'
+%{
+int yylex () { return 0; }
+void yyerror (char *s) { return; }
+int main () { return 0; }
+%}
+%%
+foobar : 'f' 'o' 'o' 'b' 'a' 'r' {};
+END
+
+$ACLOCAL
+$AUTOMAKE -a
+$AUTOCONF
+
+./configure YFLAGS='-d -v'
+$MAKE
+ls -l
+test -f foo.c
+test -f foo.h
+test -f foo.output
+
+$MAKE maintainer-clean
+ls -l
+
+./configure YFLAGS='-v'
+$MAKE
+ls -l
+test -f foo.c
+test ! -r foo.h
+test -f foo.output
+
+$MAKE maintainer-clean
+ls -l
+
+./configure YFLAGS='-v'
+YFLAGS=-d $MAKE -e
+ls -l
+test -f foo.c
+test -f foo.h
+test ! -r foo.output
+
+$MAKE maintainer-clean
+ls -l
+
+:
diff --git a/t/yflags-conditional.sh b/t/yflags-conditional.sh
new file mode 100755
index 000000000..0cd09d29a
--- /dev/null
+++ b/t/yflags-conditional.sh
@@ -0,0 +1,143 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that automake complains about *_YFLAGS variables which have
+# conditional content.
+
+. ./defs || Exit 1
+
+cat >> configure.ac <<'END'
+AC_PROG_CC
+
+# 'YFLAGS' is AC_SUBST'd by AC_PROG_YACC by default, but we
+# don't want this, since it might confuse our error messages.
+# Also, AM_SUBST_NOTMAKE seems not to help about this.
+# So we simply define $(YACC) by hand.
+AC_SUBST([YACC], [yacc])
+
+AM_CONDITIONAL([COND], [:])
+END
+
+$ACLOCAL
+
+cat > Makefile.am <<'END'
+bin_PROGRAMS = foo zardoz
+foo_SOURCES = foo.y
+zardoz_SOURCES = zardoz.y
+if COND
+AM_YFLAGS = -v
+zardoz_YFLAGS = -v
+endif COND
+END
+
+cat > Makefile1.am <<'END'
+bin_PROGRAMS = foo
+foo_SOURCES = foo.y
+## This is a dummy comment to keep line count right.
+if COND
+YFLAGS = foo
+endif COND
+END
+
+cat > Makefile2.am <<'END'
+bin_PROGRAMS = foo
+foo_SOURCES = foo.y
+AM_YFLAGS = am_yflags
+if COND
+YFLAGS = yflags
+endif COND
+END
+
+cat > Makefile3.am <<'END'
+bin_PROGRAMS = foo
+foo_SOURCES = foo.y
+foo_YFLAGS = foo_yflags
+if COND
+YFLAGS = yflags
+endif COND
+END
+
+cat > Makefile4.am <<'END'
+bin_PROGRAMS = foo zardoz
+
+foo_SOURCES = foo.y
+zardoz_SOURCES = $(foo_SOURCES)
+
+YFLAGS =
+AM_YFLAGS = $(COND_VAR1)
+zardoz_YFLAGS = $(COND_VAR2:z=r)
+
+COND_VAR2 = foo
+if COND
+YFLAGS += -v
+COND_VAR2 += bar
+else !COND
+COND_VAR1 = -d
+endif !COND
+END
+
+cat > Makefile5.am <<'END'
+bin_PROGRAMS = foo zardoz
+foo_SOURCES = foo.y
+zardoz_SOURCES = zardoz.y
+YFLAGS = -v
+AM_YFLAGS = -v
+if COND
+zardoz_YFLAGS = -v
+endif
+END
+
+cat > Makefile6.am <<'END'
+bin_PROGRAMS = foo
+foo_SOURCES = foo.y
+foo_YFLAGS = -v
+if COND
+quux_YFLAGS = -v
+AM_YFLAGS = -v
+endif
+END
+
+: > ylwrap
+
+LC_ALL=C; export LC_ALL; # For grep regexes below.
+
+AUTOMAKE_fails -Wnone -Wunsupported Makefile
+grep '^Makefile\.am:5:.*AM_YFLAGS.* conditional contents' stderr
+grep '^Makefile\.am:6:.*zardoz_YFLAGS.* conditional contents' stderr
+
+for i in 1 2 3; do
+ AUTOMAKE_fails -Wnone -Wunsupported Makefile$i
+ grep "^Makefile$i\\.am:5:.*[^a-zA-Z0-9_]YFLAGS.* conditional contents" \
+ stderr
+done
+
+AUTOMAKE_fails -Wnone -Wunsupported Makefile4
+grep '^Makefile4\.am:6:.*[^a-zA-Z0-9_]YFLAGS.* conditional contents' stderr
+grep '^Makefile4\.am:7:.*AM_YFLAGS.* conditional contents' stderr
+grep '^Makefile4\.am:8:.*zardoz_YFLAGS.* conditional contents' stderr
+
+# Now let's check we avoid false positives.
+
+# Disable 'gnu' warnings because we override the user variable 'YFLAGS'.
+AUTOMAKE_fails -Wno-gnu Makefile5
+grep -v '^Makefile5\.am:.*zardoz_YFLAGS' stderr \
+ | grep -v ': warnings are treated as errors' \
+ | grep . && Exit 1
+
+# Disable 'gnu' warnings because we override the user variable 'YFLAGS'.
+$AUTOMAKE -Wno-gnu Makefile6
+
+:
diff --git a/t/yflags-d-false-positives.sh b/t/yflags-d-false-positives.sh
new file mode 100755
index 000000000..78820caba
--- /dev/null
+++ b/t/yflags-d-false-positives.sh
@@ -0,0 +1,41 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check for false positives in automake recognition of '-d' in YFLAGS.
+
+. ./defs || Exit 1
+
+cat >> configure.ac <<'END'
+AC_PROG_CC
+AC_PROG_YACC
+END
+
+$ACLOCAL
+
+cat > Makefile.am <<'END'
+bin_PROGRAMS = zardoz foobar
+zardoz_SOURCES = zardoz.y
+foobar_SOURCES = foobar.y
+# All the "almost -d" substrings ("- d", "-dd", etc.) are meant.
+AM_YFLAGS = -xd --d - d --output=d
+foobar_YFLAGS = - d $(foovar)-d -dd
+END
+
+$AUTOMAKE -a
+$EGREP '(foobar|zardoz)\.h.*:' Makefile.in && Exit 1
+$EGREP '(foobar|zardoz)\.h' Makefile.in | $FGREP -v '$(YLWRAP) ' && Exit 1
+
+:
diff --git a/t/yflags-force-conditional.sh b/t/yflags-force-conditional.sh
new file mode 100755
index 000000000..53038a82a
--- /dev/null
+++ b/t/yflags-force-conditional.sh
@@ -0,0 +1,85 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that the user can force automake to use *_YFLAGS variables
+# which have conditional content.
+
+. ./defs || Exit 1
+
+cat >> configure.ac <<'END'
+AC_SUBST([CC], [false])
+AC_PROG_YACC
+AM_CONDITIONAL([COND], [test x"$cond" = x"yes"])
+AC_OUTPUT
+END
+
+mkdir bin
+cat > bin/fake-yacc <<'END'
+#!/bin/sh
+echo "/* $* */" > y.tab.c
+echo 'extern int dummy;' >> y.tab.c
+END
+chmod a+x bin/fake-yacc
+PATH=`pwd`/bin$PATH_SEPARATOR$PATH; export PATH
+YACC=fake-yacc; export YACC
+
+cat > Makefile.am <<'END'
+AUTOMAKE_OPTIONS = no-dependencies
+bin_PROGRAMS = foo bar
+foo_SOURCES = foo.y main.c
+bar_SOURCES = $(foo_SOURCES)
+bar_YFLAGS = $(bar_yflags2)
+if COND
+AM_YFLAGS = __am_cond_yes__
+bar_YFLAGS += __bar_cond_yes__
+else !COND
+AM_YFLAGS = __am_cond_no__
+bar_yflags2 = __bar_cond_no__
+endif !COND
+END
+
+: > foo.y
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a -Wno-unsupported
+
+$EGREP '(YFLAGS|yflags|am__append)' Makefile.in # For debugging.
+
+./configure cond=yes
+$MAKE foo.c bar-foo.c
+
+cat foo.c
+cat bar-foo.c
+
+$FGREP ' __am_cond_yes__ ' foo.c
+$FGREP ' __bar_cond_yes__ ' bar-foo.c
+$FGREP 'cond_no' foo.c bar-foo.c && Exit 1
+
+$MAKE maintainer-clean
+ls -l
+
+./configure cond=no
+$MAKE foo.c bar-foo.c
+
+cat foo.c
+cat bar-foo.c
+
+$FGREP ' __am_cond_no__ ' foo.c
+$FGREP ' __bar_cond_no__ ' bar-foo.c
+$FGREP 'cond_yes' foo.c bar-foo.c && Exit 1
+
+:
diff --git a/t/yflags-force-override.sh b/t/yflags-force-override.sh
new file mode 100755
index 000000000..3f4755ed1
--- /dev/null
+++ b/t/yflags-force-override.sh
@@ -0,0 +1,62 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that automake can cope with a definition of the $(YFLAGS) variable
+# in Makefile.am (even if that is extremely bad practice, because that
+# variable is user-reserved).
+
+required='cc yacc'
+. ./defs || Exit 1
+
+cat >> configure.ac <<'END'
+AC_PROG_CC
+AC_PROG_YACC
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+bin_PROGRAMS = foo
+foo_SOURCES = foo.y
+# Don't do this in a real-life Makefile.am!
+YFLAGS = -d -v
+END
+
+cat > foo.y << 'END'
+%{
+int yylex () { return 0; }
+void yyerror (char *s) { return; }
+int main () { return 0; }
+%}
+%%
+foobar : 'f' 'o' 'o' 'b' 'a' 'r' {};
+END
+
+$ACLOCAL
+$AUTOMAKE -a -Wno-gnu
+
+$EGREP '(foo|YFLAGS)' Makefile.in # For debugging.
+grep '^foo.h *:' Makefile.in
+
+$AUTOCONF
+./configure
+
+$MAKE
+
+test -f foo.c
+test -f foo.h
+test -f foo.output
+
+:
diff --git a/t/yflags-var-expand.sh b/t/yflags-var-expand.sh
new file mode 100755
index 000000000..d3bd0d447
--- /dev/null
+++ b/t/yflags-var-expand.sh
@@ -0,0 +1,61 @@
+#! /bin/sh
+# Copyright (C) 2011-2012 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/>.
+
+# Check that automake expand variables when looking for '-d' in YFLAGS;
+# for example, the following is supposed to work:
+# foo_flags = -d
+# AM_YFLAGS = $(foo_flags)
+
+. ./defs || Exit 1
+
+cat >> configure.ac <<'END'
+AC_PROG_CC
+AC_PROG_YACC
+END
+
+$ACLOCAL
+
+cat > Makefile.am <<'END'
+bin_PROGRAMS = foo bar
+foo_SOURCES = foo.y
+bar_SOURCES = bar.y
+my_YFLAGS = -x
+AM_YFLAGS = $(my_YFLAGS:x=d)
+bar_YFLAGS = $(AM_YFLAGS)
+END
+
+$AUTOMAKE -a
+
+$EGREP '(foo|bar|YFLAGS)' Makefile.in # For debugging.
+grep '^foo.h *:' Makefile.in
+grep '^bar-bar.h *:' Makefile.in
+
+cat > Makefile.am <<'END'
+AUTOMAKE_OPTIONS = -Wno-gnu
+bin_PROGRAMS = zardoz
+zardoz_SOURCES = parser.y
+my_YFLAGS = $(my_YFLAGS_1)
+my_YFLAGS += $(my_YFLAGS_2)
+my_YFLAGS_2 = -d
+YFLAGS = $(my_YFLAGS)
+END
+
+$AUTOMAKE
+
+$EGREP 'parser|YFLAGS' Makefile.in # For debugging.
+grep '^parser.h *:' Makefile.in
+
+:
diff --git a/t/yflags.sh b/t/yflags.sh
new file mode 100755
index 000000000..fbc39f56f
--- /dev/null
+++ b/t/yflags.sh
@@ -0,0 +1,70 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Check that $(YFLAGS) takes precedence over both $(AM_YFLAGS) and
+# $(foo_YFLAGS).
+# Please keep this in sync with the sister tests yflags2.test, lflags.test
+# and lflags2.test.
+
+. ./defs || Exit 1
+
+cat >fake-yacc <<'END'
+#!/bin/sh
+echo '/*' "$*" '*/' >y.tab.c
+echo 'extern int dummy;' >> y.tab.c
+END
+chmod a+x fake-yacc
+
+# Remove Yacc from the environment, so that it won't interfere
+# with 'make -e' below.
+unset YACC || :
+
+cat >> configure.ac <<'END'
+AC_SUBST([CC], [false])
+# Simulate presence of Yacc using our fake-yacc script.
+AC_SUBST([YACC], ['$(abs_top_srcdir)'/fake-yacc])
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+AUTOMAKE_OPTIONS = no-dependencies
+bin_PROGRAMS = foo bar
+foo_SOURCES = main.c foo.y
+bar_SOURCES = main.c bar.y
+AM_YFLAGS = __am_flags__
+bar_YFLAGS = __bar_flags__
+END
+
+$ACLOCAL
+$AUTOMAKE -a
+
+grep '\$(YFLAGS).*\$(bar_YFLAGS)' Makefile.in && Exit 1
+grep '\$(YFLAGS).*\$(AM_YFLAGS)' Makefile.in && Exit 1
+
+: > foo.y
+: > bar.y
+
+$AUTOCONF
+./configure
+env YFLAGS=__user_flags__ $MAKE -e foo.c bar-bar.c
+
+cat foo.c
+cat bar-bar.c
+
+grep '__am_flags__.*__user_flags__' foo.c
+grep '__bar_flags__.*__user_flags__' bar-bar.c
+
+:
diff --git a/t/yflags2.sh b/t/yflags2.sh
new file mode 100755
index 000000000..a933447d3
--- /dev/null
+++ b/t/yflags2.sh
@@ -0,0 +1,70 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 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/>.
+
+# Check that $(YFLAGS) takes precedence over both $(AM_YFLAGS) and
+# $(foo_YFLAGS).
+# Please keep this in sync with the sister tests yflags.test, lflags.test
+# and lflags2.test.
+
+. ./defs || Exit 1
+
+cat >fake-yacc <<'END'
+#!/bin/sh
+echo '/*' "$*" '*/' >y.tab.c
+echo 'extern int dummy;' >> y.tab.c
+END
+chmod a+x fake-yacc
+
+# Remove Yacc from the environment, so that it won't interfere
+# with 'make -e' below.
+unset YACC || :
+
+cat >> configure.ac <<'END'
+AC_SUBST([CXX], [false])
+# Simulate presence of Yacc using our fake-yacc script.
+AC_SUBST([YACC], ['$(abs_top_srcdir)'/fake-yacc])
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+AUTOMAKE_OPTIONS = no-dependencies
+bin_PROGRAMS = foo bar
+foo_SOURCES = main.cc foo.yy
+bar_SOURCES = main.cc bar.y++
+AM_YFLAGS = __am_flags__
+bar_YFLAGS = __bar_flags__
+END
+
+$ACLOCAL
+$AUTOMAKE -a
+
+grep '\$(YFLAGS).*\$(bar_YFLAGS)' Makefile.in && Exit 1
+grep '\$(YFLAGS).*\$(AM_YFLAGS)' Makefile.in && Exit 1
+
+: > foo.yy
+: > bar.y++
+
+$AUTOCONF
+./configure
+env YFLAGS=__user_flags__ $MAKE -e foo.cc bar-bar.c++
+
+cat foo.cc
+cat bar-bar.c++
+
+grep '__am_flags__.*__user_flags__' foo.cc
+grep '__bar_flags__.*__user_flags__' bar-bar.c++
+
+: