built-sources-cond.sh 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. # Interaction of BUILT_SOURCES with conditionals.
  17. . test-init.sh
  18. cat >> configure.ac <<'END'
  19. AM_CONDITIONAL([COND1], [test $cond1 = yes])
  20. AM_CONDITIONAL([COND2], [test $cond2 = yes])
  21. AC_OUTPUT
  22. END
  23. cat > Makefile.am << 'END'
  24. if COND1
  25. BUILT_SOURCES = a
  26. else
  27. BUILT_SOURCES = b
  28. endif
  29. if COND2
  30. BUILT_SOURCES += c
  31. endif
  32. a b c:
  33. echo who cares > $@
  34. END
  35. $ACLOCAL
  36. $AUTOMAKE
  37. $AUTOCONF
  38. cleanup ()
  39. {
  40. # Files in $(BUILT_SOURCES) should be automatically removed
  41. # upon maintainer-clean.
  42. $MAKE maintainer-clean
  43. test ! -f a
  44. test ! -f b
  45. test ! -f c
  46. }
  47. ./configure cond1=yes cond2=yes
  48. $MAKE
  49. test -f a
  50. test ! -f b
  51. test -f c
  52. cleanup
  53. ./configure cond1=no cond2=yes
  54. $MAKE
  55. test ! -f a
  56. test -f b
  57. test -f c
  58. cleanup
  59. ./configure cond1=yes cond2=no
  60. $MAKE
  61. test -f a
  62. test ! -f b
  63. test ! -f c
  64. cleanup
  65. ./configure cond1=no cond2=no
  66. $MAKE
  67. test ! -f a
  68. test -f b
  69. test ! -f c
  70. cleanup
  71. :