built-sources.sh 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #! /bin/sh
  2. # Copyright (C) 2003-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. # Basic test on BUILT_SOURCES.
  17. required=cc
  18. . test-init.sh
  19. cat >> configure.ac <<'END'
  20. AC_PROG_CC
  21. AC_OUTPUT
  22. END
  23. cat > Makefile.am << 'END'
  24. BUILT_SOURCES = foo.c
  25. noinst_PROGRAMS = bar baz
  26. foo.c:
  27. rm -f $@ $@-t
  28. ## Use printf, not echo, to avoid spurious interpretation of
  29. ## the "\n" as a newline (seen on NetBSD 5.1).
  30. printf '%s\n' '#include <stdio.h>' > $@-t
  31. printf '%s\n' 'int main (void)' >> $@-t
  32. printf '%s\n' '{ ' >> $@-t
  33. printf '%s\n' ' printf ("%s\n", FOOMSG);' >> $@-t
  34. printf '%s\n' ' return 0;' >> $@-t
  35. printf '%s\n' '}' >> $@-t
  36. mv -f $@-t $@
  37. CLEANFILES = foo.c
  38. END
  39. cat > bar.c <<'END'
  40. #define FOOMSG "Howdy, World"
  41. #include "foo.c"
  42. END
  43. cat > baz.c <<'END'
  44. #define FOOMSG "Hello, Earth"
  45. #include "foo.c"
  46. END
  47. $ACLOCAL
  48. $AUTOMAKE
  49. $AUTOCONF
  50. ./configure
  51. $MAKE
  52. if cross_compiling; then :; else
  53. ./bar
  54. ./bar | grep 'Howdy, World'
  55. ./baz
  56. ./baz | grep 'Hello, Earth'
  57. fi
  58. $MAKE distcheck
  59. :