aclocal-path-install-serial.sh 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #! /bin/sh
  2. # Copyright (C) 2011-2017 Free Software Foundation, Inc.
  3. #
  4. # This program is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation; either version 2, or (at your option)
  7. # any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. # ACLOCAL_PATH, acdir and '--install' interactions when serial number
  17. # are involved.
  18. am_create_testdir=empty
  19. . test-init.sh
  20. cat > configure.ac << 'END'
  21. AC_INIT
  22. AM_FOO
  23. END
  24. set_serial ()
  25. {
  26. serial=$1 file=$2
  27. sed '/^# serial/d' $file > t
  28. case $serial in
  29. none) mv -f t $file;;
  30. *) (echo "# serial $serial" && cat t) > $file; rm -f t;;
  31. esac
  32. cat $file # For debugging.
  33. }
  34. win ()
  35. {
  36. case $1 in
  37. sdir) ok=sdir ko=pdir;;
  38. pdir) ok=pdir ko=sdir;;
  39. *) fatal_ "win(): invalid argument '$1'";;
  40. esac
  41. # This is required on fast machine, to avoid caching and timestamp
  42. # issues with the autotools (already happened in practice).
  43. rm -rf configure aclocal.m4 autom4te*.cache m4/*
  44. $ACLOCAL -I m4 --install
  45. test -f m4/foo.m4 # Sanity check.
  46. $AUTOCONF
  47. $FGREP "::$ok:" m4/foo.m4
  48. $FGREP "::$ok::" configure
  49. $FGREP "::$ko::" m4/foo.m4 configure && exit 1
  50. :
  51. }
  52. mkdir sdir pdir m4
  53. ACLOCAL="$ACLOCAL --system-acdir=$(pwd)/sdir"
  54. ACLOCAL_PATH=./pdir; export ACLOCAL_PATH
  55. cat > sdir/foo.m4 << 'END'
  56. AC_DEFUN([AM_FOO], [::sdir::])
  57. END
  58. cat > pdir/foo.m4 << 'END'
  59. AC_DEFUN([AM_FOO], [::pdir::])
  60. END
  61. set_serial 2 sdir/foo.m4
  62. set_serial 1 pdir/foo.m4
  63. win sdir
  64. set_serial 3.3 sdir/foo.m4
  65. set_serial 5.7 pdir/foo.m4
  66. win pdir
  67. set_serial 0 sdir/foo.m4
  68. set_serial none pdir/foo.m4
  69. win sdir
  70. set_serial none sdir/foo.m4
  71. set_serial 1.2.3 pdir/foo.m4
  72. win pdir
  73. :