| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445 | #! /bin/sh# Copyright (C) 2012-2017 Free Software Foundation, Inc.## This program is free software; you can redistribute it and/or modify# it under the terms of the GNU General Public License as published by# the Free Software Foundation; either version 2, or (at your option)# any later version.## This program is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the# GNU General Public License for more details.## You should have received a copy of the GNU General Public License# along with this program.  If not, see <http://www.gnu.org/licenses/>.# Several tests on the use of the m4 macro AC_CONFIG_MACRO_DIRS with# aclocal.  See also related test 'aclocal-macrodir.tap'.am_create_testdir=empty. test-init.shplan_ 15ocwd=$(pwd) || fatal_ "getting current working directory"unset ACLOCAL_PATH## General utility functions and variables.## TODO: These should maybe be refactored, generalized and#       moved into 't/ax/tap-functions.sh' ...#tcount=0r=invaliddescription=''directive=''test_begin (){  if test -n "$description"; then    fatal_ "'test_begin' called, but another test seems active already"  else    r=ok    description=$1    directive=${2-}    echo "$description" > README.txt    shift  fi  tcount=$(($tcount + 1)) && test $tcount -gt 0 \    || fatal_ "failed to bump the test count"  mkdir $tcount.d  cd $tcount.d}test_end (){  if test -z "$description"; then    fatal_ "'test_end' called, but no test seems active"  else    cd "$ocwd" || fatal_ "cannot chdir back to top-level directory"    result_ "$r" -D "$directive" -- "$description"    # Don't leave directories for successful subtests hanging around.    if test -z "$directive" && test "$r" = ok; then      rm -rf "$tcount.d" || fatal_ "removing subdir $tcount.d"    fi    r=invalid directive= description=  fi}#---------------------------------------------------------------------------test_begin "AC_CONFIG_MACRO_DIRS is honored"cat > configure.ac <<'END'AC_INIT([md], [10.0])AC_CONFIG_MACRO_DIRS([macro-dir])MY_FOOENDmkdir macro-direcho 'AC_DEFUN([MY_FOO], [::my::foo::])' > macro-dir/foo.m4$ACLOCAL \  && $FGREP 'm4_include([macro-dir/foo.m4])' aclocal.m4 \  && $AUTOCONF \  && not $FGREP 'MY_FOO' configure \  && $FGREP '::my::foo::' configure \  || r='not ok'test_end#---------------------------------------------------------------------------three_dirs_check (){  mkdir dir1 dir2 dir3  echo 'AC_DEFUN([MY_FOO], [::my::foo::])' > dir1/foo.m4  echo 'AC_DEFUN([MY_BAR], [!!my!!bar!!])' > dir2/zap.m4  echo 'AC_DEFUN([MY_BAZ], [==my==baz==])' > dir3/0.m4  $ACLOCAL \    && $FGREP 'm4_include([dir1/foo.m4])' aclocal.m4 \    && $FGREP 'm4_include([dir2/zap.m4])' aclocal.m4 \    && $FGREP 'm4_include([dir3/0.m4])'   aclocal.m4 \    && $AUTOCONF \    && not $EGREP 'MY_(FOO|BAR|BAZ)' configure \    && $FGREP '::my::foo::' configure \    && $FGREP '!!my!!bar!!' configure \    && $FGREP '==my==baz==' configure \    || r='not ok'}#---------------------------------------------------------------------------test_begin "AC_CONFIG_MACRO_DIRS several arguments"cat > configure.ac <<'END'AC_INIT([more-args], [0.2])AC_CONFIG_MACRO_DIRS([dir1 dir2 dir3])MY_FOOMY_BARMY_BAZENDthree_dirs_checktest_end#---------------------------------------------------------------------------test_begin "AC_CONFIG_MACRO_DIRS several calls"cat > configure.ac <<'END'AC_INIT([more-calls], [2.0])AC_CONFIG_MACRO_DIRS([dir1])AC_CONFIG_MACRO_DIRS([dir2 dir3])MY_FOOMY_BARMY_BAZENDthree_dirs_checktest_end#---------------------------------------------------------------------------test_begin "AC_CONFIG_MACRO_DIRS extra whitespace"bslash=\\cat > configure.ac <<ENDAC_INIT([more-args], [0.2])AC_CONFIG_MACRO_DIRS([   dir1${bslash}${tab} dir2   ${tab}${tab}dir3${bslash}])MY_FOOMY_BARMY_BAZENDthree_dirs_checktest_end#---------------------------------------------------------------------------test_begin "AC_CONFIG_MACRO_DIRS precedence"cat > configure.ac <<'END'AC_INIT([more-calls], [2.0])AC_CONFIG_MACRO_DIRS([dir1])AC_CONFIG_MACRO_DIRS([dir2 dir3])MY_FOOMY_BARMY_BAZENDmkdir dir1 dir2 dir3echo 'AC_DEFUN([MY_FOO], [OK-Foo])' > dir1/b.m4echo 'AC_DEFUN([MY_FOO], [KO-Foo])' > dir2/a.m4echo 'AC_DEFUN([MY_BAR], [OK-Bar])' > dir2/1.m4echo 'AC_DEFUN([MY_BAR], [KO-Bar])' > dir3/0.m4echo 'AC_DEFUN([MY_BAZ], [OK-Baz])' > dir3/x.m4$ACLOCAL \  && $FGREP 'm4_include([dir1/b.m4])' aclocal.m4 \  && $FGREP 'm4_include([dir2/1.m4])' aclocal.m4 \  && $FGREP 'm4_include([dir3/x.m4])' aclocal.m4 \  && test $($FGREP -c 'm4_include([dir1' aclocal.m4) -eq 1 \  && test $($FGREP -c 'm4_include([dir2' aclocal.m4) -eq 1 \  && test $($FGREP -c 'm4_include([dir3' aclocal.m4) -eq 1 \  && $AUTOCONF \  && not $EGREP 'MY_(FOO|BAR|BAZ)' configure \  && $FGREP 'OK-Foo' configure \  && $FGREP 'OK-Bar' configure \  && $FGREP 'OK-Baz' configure \  && not $FGREP 'KO-' configure \  || r='not ok'test_end#---------------------------------------------------------------------------test_begin "AC_CONFIG_MACRO_DIRS interaction with --install"cat > configure.ac << 'END'AC_INIT([inst], [1.0])AC_CONFIG_MACRO_DIRS([the-dir])THE_MACROENDmkdir sys-dir the-direcho 'AC_DEFUN([THE_MACRO], [:])' > sys-dir/my.m4test ! -r the-dir/my.m4 \  && $ACLOCAL --install --system-acdir ./sys-dir \  && diff sys-dir/my.m4 the-dir/my.m4 \  || r='not ok'test_end#---------------------------------------------------------------------------two_dirs_install_check (){  mkdir sys-dir dir1 dir2  echo 'AC_DEFUN([THE_MACRO], [:])' > sys-dir/my.m4  echo 'AC_DEFUN([AX_FOO], [:])' > dir2/zap.m4  test ! -r dir1/my.m4 \    && $ACLOCAL --install --system-acdir ./sys-dir \    && diff sys-dir/my.m4 dir1/my.m4 \    && test ! -e dir2/my.m4 \    && $FGREP 'm4_include([dir1/my.m4])' aclocal.m4 \    && $FGREP 'm4_include([dir2/zap.m4])' aclocal.m4 \    || r='not ok'}#---------------------------------------------------------------------------test_begin "several AC_CONFIG_MACRO_DIRS arguments and --install"cat > configure.ac << 'END'AC_INIT([inst2a], [1.0])AC_CONFIG_MACRO_DIRS([dir1 dir2])THE_MACROAX_FOOENDtwo_dirs_install_checktest_end#---------------------------------------------------------------------------test_begin "several AC_CONFIG_MACRO_DIRS calls and --install"cat > configure.ac << 'END'AC_INIT([inst2b], [1.0])AC_CONFIG_MACRO_DIRS([dir1])AC_CONFIG_MACRO_DIRS([dir2])THE_MACROAX_FOOENDtwo_dirs_install_checktest_end#---------------------------------------------------------------------------test_begin "'-I' option wins over AC_CONFIG_MACRO_DIRS"cat > configure.ac <<'END'AC_INIT([md], [4.6])AC_CONFIG_MACRO_DIRS([dir1])MY_FOOENDmkdir dir1 dir2echo 'AC_DEFUN([MY_FOO], [::ko::ko::])' > dir1/1.m4echo 'AC_DEFUN([MY_FOO], [::ok::ok::])' > dir2/2.m4$ACLOCAL -I dir2 \  && $FGREP 'm4_include([dir2/2.m4])' aclocal.m4 \  && not $FGREP 'm4_include([dir1/1.m4])' aclocal.m4 \  && $AUTOCONF \  && not $FGREP '::ko::ko::' configure \  && $FGREP '::ok::ok::' configure \  || r='not ok'test_end#---------------------------------------------------------------------------test_begin "AC_CONFIG_MACRO_DIRS([foo]) can create directory 'foo'"cat > configure.ac << 'END'AC_INIT([x], [1.0])AC_CONFIG_MACRO_DIRS([foo])MY_MACROENDmkdir acdirecho 'AC_DEFUN([MY_MACRO], [:])' > acdir/bar.m4test ! -d foo \  && $ACLOCAL --install --system-acdir ./acdir \  && diff acdir/bar.m4 foo/bar.m4 \  || r='not ok'test_end#---------------------------------------------------------------------------test_begin "AC_CONFIG_MACRO_DIRS([non-existent]) warns (1)"cat > configure.ac << 'END'AC_INIT([oops], [1.0])AC_CONFIG_MACRO_DIRS([non-existent])AM_INIT_AUTOMAKEEND$ACLOCAL -Wno-error 2>stderr \  && cat stderr >&2 \  && grep "couldn't open directory 'non-existent'" stderr \  && test -f aclocal.m4 \  || r='not ok'rm -rf aclocal.m4 autom4te*.cache$ACLOCAL -Werror -Wno-unsupported \  && test -f aclocal.m4 \  || r='not ok'test_end#---------------------------------------------------------------------------test_begin "AC_CONFIG_MACRO_DIRS([non-existent]) warns (2)"cat > configure.ac << 'END'AC_INIT([oops], [1.0])AC_CONFIG_MACRO_DIRS([dir-ok])AC_CONFIG_MACRO_DIRS([dir-ko])ENDmkdir dir-oknot $ACLOCAL 2>stderr \  && cat stderr >&2 \  && grep "couldn't open directory 'dir-ko'" stderr \  && not grep "dir-ok" stderr \  && test ! -e aclocal.m4 \  || r='not ok'test_end#---------------------------------------------------------------------------test_begin "AC_CONFIG_MACRO_DIRS([existent non-existent]) errors out"cat > configure.ac << 'END'AC_INIT([oops], [1.0])AC_CONFIG_MACRO_DIRS([dir-ok])AC_CONFIG_MACRO_DIRS([dir-ko])ENDmkdir dir-oknot $ACLOCAL -Wnone --install 2>stderr \  && cat stderr >&2 \  && grep "couldn't open directory 'dir-ko'" stderr \  && test ! -e dir-ko \  || r='not ok'test_end#---------------------------------------------------------------------------test_begin "AC_CONFIG_MACRO_DIRS([not-exist]) and ACLOCAL_AMFLAGS = -I not-exist"cat > configure.ac << 'END'AC_INIT([oops], [1.0])AC_CONFIG_MACRO_DIRS([not-exist])ENDcat > Makefile.am << 'END'ACLOCAL_AMFLAGS = -I not-existEND$ACLOCAL -Wno-error 2>stderr \  && cat stderr >&2 \  && test $(grep -c "couldn't open directory 'not-exist'" stderr) -eq 1 \  || r='not ok'test_end#---------------------------------------------------------------------------# Avoid spurious failures with pre-2.70 autoconf.# FIXME: remove this in automake 2.0, once we require Autoconf 2.70.if echo 'AC_INIT AC_CONFIG_MACRO_DIRS' | $AUTOCONF -o/dev/null -; then  test_begin "AC_CONFIG_MACRO_DIRS interaction with AC_REQUIRE"  unindent > configure.ac <<'END'  AC_INIT([req], [1.0])  AC_CONFIG_MACRO_DIRS([m1 m2])  AC_DEFUN([MY_FOO], [    AC_REQUIRE([MY_BAR])    AC_REQUIRE([MY_BAZ])  ])  MY_FOOEND  mkdir m1 m2  echo 'AC_DEFUN([MY_BAR], [^^my^^bar^^])' > m1/x.m4  echo 'AC_DEFUN([MY_BAZ], [~~my~~baz~~])' > m2/x.m4  st=0; $ACLOCAL 2>stderr || st=$?  cat stderr >&2  test $st -eq 0 \    && test ! -s stderr \    && $FGREP 'm4_include([m1/x.m4])' aclocal.m4 \    && $FGREP 'm4_include([m2/x.m4])' aclocal.m4 \    && $AUTOCONF \    && not $EGREP 'MY_(FOO|BAR|BAZ)' configure \    && $FGREP '^^my^^bar^^' configure \    && $FGREP '~~my~~baz~~' configure \    || r='not ok'  test_endelse  skip_ -r "autoconf is too old (AC_CONFIG_MACRO_DIRS not defined)"fi:
 |