posixsubst-sources.sh 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #! /bin/sh
  2. # Copyright (C) 2010-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. # Test that POSIX variable expansion '$(var:str=rpl)' works when used
  17. # with the SOURCES primary.
  18. required=cc
  19. . test-init.sh
  20. cat >> configure.ac << 'END'
  21. AC_PROG_CC
  22. AC_OUTPUT
  23. END
  24. cat > Makefile.am << 'END'
  25. bin_PROGRAMS = foo
  26. FOO = foo.cxx
  27. BAR = bar__
  28. BAZ = baz.
  29. # Also try an empty match suffix, to ensure that the ':=' in there is
  30. # not confused by the parser with an unportable assignment operator.
  31. foo_SOURCES = main.c $(FOO:.cxx=.c)
  32. dist_foo_SOURCES = $(BAR:__=.c)
  33. nodist_foo_SOURCES = $(BAZ:=c)
  34. bar.c baz.c:
  35. echo 'int $@ (void) { return 0; }' | sed 's/\.c //' > $@
  36. CLEANFILES = baz.c
  37. CLEANFILES += bar.c # For FreeBSD make.
  38. .PHONY: test test2
  39. check-local: test1 test2
  40. test1:
  41. ls -l . $(srcdir)
  42. test -f $(srcdir)/bar.c
  43. test -f baz.c
  44. test2: distdir
  45. ls -l $(distdir)
  46. ## These sources should be distributed ...
  47. test -f $(distdir)/bar.c
  48. test -f $(distdir)/foo.c
  49. test -f $(distdir)/main.c
  50. ## ... and this shouldn't.
  51. test ! -r $(distdir)/baz.c
  52. END
  53. cat > main.c <<'END'
  54. int main(void)
  55. {
  56. int foo(void), bar(void), baz(void);
  57. return foo() + bar() + baz();
  58. }
  59. END
  60. echo 'int foo(void) { return 0; }' > foo.c
  61. $ACLOCAL
  62. $AUTOCONF
  63. $AUTOMAKE
  64. ./configure
  65. $MAKE
  66. $MAKE test1 test2
  67. $MAKE distcheck
  68. :