subobjname.sh 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 we reuse variables whenever possible, to limit
  17. # combinational explosion. (This test is named after the &subobjname
  18. # sub in Automake).
  19. . test-init.sh
  20. cat >> configure.ac << 'END'
  21. AC_PROG_CC
  22. AM_CONDITIONAL([FOO1], [some test])
  23. AM_CONDITIONAL([FOO2], [some test])
  24. AM_CONDITIONAL([FOO3], [some test])
  25. AC_OUTPUT
  26. END
  27. cat > Makefile.am << 'END'
  28. noinst_PROGRAMS = c d
  29. if FOO1
  30. A1=a1.c
  31. endif
  32. if FOO2
  33. A2=a2.c
  34. endif
  35. if FOO3
  36. A3=a3.c
  37. endif
  38. B=$(A1) $(A2) $(A3)
  39. c_SOURCES=$(B)
  40. d_SOURCES=$(B)
  41. END
  42. $ACLOCAL
  43. $AUTOMAKE -a
  44. # Sanity check: make sure am_c_OBJECTS and am_d_OBJECTS are used
  45. # in the Makefile. (This is an internal detail, so better make
  46. # sure we update this test if the naming changes in the future.)
  47. grep '^am_c_OBJECTS = ' Makefile.in
  48. grep '^am_d_OBJECTS = ' Makefile.in
  49. # Now the actual test. Are both values equal?
  50. cobj=$(sed -n '/^am_c_OBJECTS = / {
  51. s/.* = \(.*\)$/\1/
  52. p
  53. }' Makefile.in)
  54. dobj=$(sed -n '/^am_d_OBJECTS = / {
  55. s/^.* = \(.*\)$/\1/
  56. p
  57. }' Makefile.in)
  58. test "$cobj" = "$dobj"
  59. :