am-default-source-ext.sh 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #! /bin/sh
  2. # Copyright (C) 2008-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. # AM_DEFAULT_SOURCE_EXT
  17. required='cc c++'
  18. . test-init.sh
  19. cat >> configure.ac << 'END'
  20. AC_PROG_CC
  21. AC_PROG_CXX
  22. AC_CONFIG_FILES([sub/Makefile sub2/Makefile])
  23. AM_CONDITIONAL([COND], [:])
  24. AC_OUTPUT
  25. END
  26. mkdir sub sub2
  27. cat > Makefile.am << 'END'
  28. SUBDIRS = sub sub2
  29. bin_PROGRAMS = foo
  30. END
  31. cat > sub/Makefile.am << 'END'
  32. bin_PROGRAMS = bar baz
  33. AM_DEFAULT_SOURCE_EXT = .cpp
  34. END
  35. cat > sub2/Makefile.am << 'END'
  36. bin_PROGRAMS = bla
  37. if COND
  38. AM_DEFAULT_SOURCE_EXT = .foo .quux
  39. endif
  40. SUFFIXES = .foo .c
  41. .foo.c:
  42. cat $< >$@
  43. BUILT_SOURCES = bla.c
  44. CLEANFILES = bla.c
  45. END
  46. cat > foo.c << 'END'
  47. int main () { return 0; }
  48. END
  49. cp foo.c sub/bar.cpp
  50. cp foo.c sub/baz.cpp
  51. cp foo.c sub2/bla.foo
  52. $ACLOCAL
  53. $AUTOCONF
  54. # Conditional AM_DEFAULT_SOURCE_EXT does not work yet :-(
  55. # (this limitation could be lifted).
  56. AUTOMAKE_fails --add-missing
  57. grep 'defined conditionally' stderr
  58. sed '/^if/d; /^endif/d' sub2/Makefile.am > t
  59. mv -f t sub2/Makefile.am
  60. # AM_DEFAULT_SOURCE_EXT can only assume one value
  61. # (lifting this limitation is not such a good idea).
  62. AUTOMAKE_fails --add-missing
  63. grep 'at most one value' stderr
  64. sed 's/ \.quux//' sub2/Makefile.am > t
  65. mv -f t sub2/Makefile.am
  66. $AUTOMAKE --add-missing
  67. ./configure
  68. $MAKE
  69. $MAKE distcheck
  70. :