cond32.sh 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. # Make sure the user can override a conditional _DEPENDENCIES.
  17. . test-init.sh
  18. cat >>configure.ac <<'EOF'
  19. AM_CONDITIONAL([C1], [test -z "$two"])
  20. AM_CONDITIONAL([C2], [test -n "$two"])
  21. AM_CONDITIONAL([C3], [test -z "$three"])
  22. # We define CC in Makefile.am, but OBJEXT here.
  23. OBJEXT=o; AC_SUBST([OBJEXT])
  24. AC_SUBST([MYSUB], ["foo.$OBJEXT"])
  25. AC_OUTPUT
  26. EOF
  27. cat >>Makefile.am <<'EOF'
  28. AUTOMAKE_OPTIONS = no-dependencies
  29. CC = :
  30. bin_PROGRAMS = a
  31. if C1
  32. a_LDADD = $(MYSUB)
  33. a_DEPENDENCIES = $(MYSUB) nonsense.a
  34. # Note that 'nonsense.a' is there just to make sure Automake insn't
  35. # using some self computed a_DEPENDENCIES variable.
  36. endif
  37. if C2
  38. if C3
  39. BAR = bar.o
  40. else
  41. BAR = baz.o
  42. endif
  43. a_LDADD = $(BAR)
  44. endif
  45. test:
  46. is $(exp) == $(a_DEPENDENCIES)
  47. .PHONY: test
  48. EOF
  49. $ACLOCAL
  50. $AUTOCONF
  51. $AUTOMAKE
  52. ./configure
  53. $MAKE test exp='foo.o nonsense.a'
  54. ./configure two=yes three=
  55. $MAKE test exp='bar.o'
  56. ./configure two=yes three=yes
  57. $MAKE test exp='baz.o'
  58. :