comment7.sh 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. # Make sure comment for conditional variables are output near the
  17. # corresponding conditional definitions.
  18. . test-init.sh
  19. cat >> configure.ac <<'EOF'
  20. AM_CONDITIONAL([COND], [true])
  21. EOF
  22. cat > Makefile.am << 'EOF'
  23. if COND
  24. # Comment for VAR in COND_TRUE.
  25. VAR = foo
  26. else
  27. # Comment for VAR in COND_FALSE.
  28. VAR = bar
  29. endif
  30. EOF
  31. $ACLOCAL
  32. $AUTOMAKE
  33. $FGREP '@COND' Makefile.in # For debugging, mostly.
  34. # The VAR definition appears once for each condition.
  35. test $(grep -c '@COND_TRUE@VAR' Makefile.in) = 1
  36. test $(grep -c '@COND_FALSE@VAR' Makefile.in) = 1
  37. # Make sure the right definition follows each comment.
  38. sed -n '/^#.*VAR.*COND_TRUE/ {
  39. n
  40. p
  41. }' Makefile.in |
  42. grep '@COND_TRUE@VAR = foo'
  43. sed -n '/^#.*VAR.*COND_FALSE/ {
  44. n
  45. p
  46. }' Makefile.in |
  47. grep '@COND_FALSE@VAR = bar'
  48. :