subpkg-macrodir.sh 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #! /bin/sh
  2. # Copyright (C) 2002-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. # Subpackages that want to use m4 macros from their superpackages,
  17. # with AC_CONFIG_MACRO_DIRS.
  18. . test-init.sh
  19. cat > configure.ac <<'END'
  20. AC_INIT([super], [1.0])
  21. AM_INIT_AUTOMAKE
  22. AC_CONFIG_MACRO_DIR([m4])
  23. AC_CONFIG_SUBDIRS([pkg])
  24. AX_BAR
  25. AX_FOO
  26. END
  27. mkdir m4
  28. cat > m4/foo.m4 <<'EOF'
  29. AC_DEFUN([AX_FOO], [
  30. AC_CONFIG_FILES([Makefile])
  31. AC_OUTPUT
  32. ])
  33. EOF
  34. cat > m4/bar.m4 <<'EOF'
  35. AC_DEFUN([AX_BAR], [AC_SUBST([WHOAMI], [SuperPkg])])
  36. EOF
  37. cat > Makefile.am << 'END'
  38. test-whoami:
  39. test '$(WHOAMI)' = SuperPkg
  40. check-local: test-whoami
  41. END
  42. mkdir pkg
  43. cat > pkg/configure.ac <<'END'
  44. AC_INIT([super], [1.0])
  45. AM_INIT_AUTOMAKE
  46. AC_CONFIG_MACRO_DIRS([macros ../m4])
  47. AX_BAR
  48. AX_FOO
  49. END
  50. mkdir pkg/macros
  51. cat > pkg/macros/zardoz.m4 << 'END'
  52. AC_DEFUN([AX_BAR], [AC_SUBST([WHOAMI], [sub-pkg])])
  53. END
  54. cat > pkg/Makefile.am << 'END'
  55. test-whoami:
  56. test '$(WHOAMI)' = sub-pkg
  57. check-local: test-whomai
  58. END
  59. AUTOMAKE=$AUTOMAKE ACLOCAL=$ACLOCAL AUTOCONF=$AUTOCONF $AUTORECONF -vi
  60. $FGREP 'm4_include([m4/foo.m4])' aclocal.m4
  61. $FGREP 'm4_include([m4/bar.m4])' aclocal.m4
  62. $FGREP 'm4_include([../m4/foo.m4])' pkg/aclocal.m4
  63. $FGREP 'm4_include([macros/zardoz.m4])' pkg/aclocal.m4
  64. ./configure
  65. $MAKE test-whoami
  66. (cd pkg && $MAKE test-whoami) || exit 1
  67. $MAKE distcheck
  68. :