aclocal-path-precedence.sh 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. # Check precedence rules for ACLOCAL_PATH.
  17. am_create_testdir=empty
  18. . test-init.sh
  19. cat > configure.ac << 'END'
  20. AC_INIT([foo], [1.0])
  21. AM_INIT_AUTOMAKE
  22. FOO_MACRO
  23. BAR_MACRO
  24. AC_PROG_LIBTOOL
  25. AM_GNU_GETTEXT
  26. END
  27. mkdir mdir1 mdir2 mdir3 sysdir extradir
  28. cat > mdir1/foo1.m4 << 'END'
  29. AC_DEFUN([FOO_MACRO], [::pass-foo::])
  30. END
  31. cat > mdir2/foo2.m4 << 'END'
  32. AC_DEFUN([FOO_MACRO], [::fail-foo::])
  33. END
  34. cat > mdir1/baz.m4 << 'END'
  35. AC_DEFUN([BAR_MACRO], [::fail-bar::])
  36. END
  37. cat > mdir3/bar.m4 << 'END'
  38. AC_DEFUN([BAR_MACRO], [::pass-bar::])
  39. END
  40. cat > mdir2/quux.m4 << 'END'
  41. AC_DEFUN([AM_INIT_AUTOMAKE], [::fail-init::])
  42. AC_DEFUN([AC_PROG_LIBTOOL], [::pass-libtool::])
  43. AC_DEFUN([AM_GNU_GETTEXT], [::pass-gettext::])
  44. END
  45. cat > sysdir/libtool.m4 << 'END'
  46. AC_DEFUN([AC_PROG_LIBTOOL], [::fail-libtool::])
  47. END
  48. cat > extradir/gettext.m4 << 'END'
  49. AC_DEFUN([AM_GNU_GETTEXT], [::fail-gettext::])
  50. END
  51. echo ./extradir > sysdir/dirlist
  52. ACLOCAL_PATH=mdir1:mdir2 $ACLOCAL -I mdir3 --system-acdir sysdir
  53. $AUTOCONF
  54. $FGREP '::' configure # For debugging.
  55. # Directories coming first in ACLOCAL_PATH should take precedence
  56. # over those coming later.
  57. $FGREP '::pass-foo::' configure
  58. # Directories from '-I' options should take precedence over directories
  59. # in ACLOCAL_PATH.
  60. $FGREP '::pass-bar::' configure
  61. # Directories in ACLOCAL_PATH should take precedence over system acdir
  62. # (typically '${prefix}/share/aclocal'), and any directory added through
  63. # the 'dirlist' special file.
  64. $FGREP '::pass-gettext::' configure
  65. $FGREP '::pass-libtool::' configure
  66. # Directories in ACLOCAL_PATH shouldn't take precedence over the internal
  67. # automake acdir (typically '${prefix}/share/aclocal-${APIVERSION}').
  68. $FGREP 'am__api_version' configure
  69. # A final sanity check.
  70. $FGREP '::fail' configure && exit 1
  71. :