ltcond2.sh 1.9 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. # Test for bug in conditionals.
  17. required='cc native libtoolize'
  18. . test-init.sh
  19. cat >> configure.ac << 'END'
  20. AC_PROG_CC
  21. AM_PROG_AR
  22. AC_PROG_LIBTOOL
  23. AC_SUBST([HELLO_SYSTEM], [hello-generic.lo])
  24. AM_CONDITIONAL([LINUX], [true])
  25. AC_OUTPUT
  26. END
  27. cat > Makefile.am << 'END'
  28. lib_LTLIBRARIES = libhello.la
  29. libhello_la_SOURCES = hello-common.c
  30. EXTRA_libhello_la_SOURCES = hello-linux.c hello-generic.c
  31. libhello_la_LIBADD = $(HELLO_SYSTEM)
  32. libhello_la_DEPENDENCIES = $(HELLO_SYSTEM)
  33. lib_LTLIBRARIES += libhello2.la
  34. libhello2_la_SOURCES = hello-common.c
  35. if LINUX
  36. libhello2_la_SOURCES += hello-linux.c
  37. else
  38. libhello2_la_SOURCES += hello-generic.c
  39. endif
  40. bin_PROGRAMS = hello hello2
  41. hello_SOURCES = main.c
  42. hello_LDADD = libhello.la
  43. hello2_SOURCES = main.c
  44. hello2_LDADD = libhello2.la
  45. check-local:
  46. ./hello$(EXEEXT) | grep hello-generic
  47. ./hello2$(EXEEXT) | grep hello-linux
  48. : > check-ok
  49. END
  50. cat > hello-linux.c <<'END'
  51. const char* str = "hello-linux";
  52. END
  53. cat > hello-generic.c <<'END'
  54. const char* str = "hello-generic";
  55. END
  56. cat > hello-common.c <<'END'
  57. #include <stdio.h>
  58. extern const char* str;
  59. void print (void)
  60. {
  61. puts (str);
  62. }
  63. END
  64. cat > main.c <<'END'
  65. int main (void)
  66. {
  67. print();
  68. return 0;
  69. }
  70. END
  71. libtoolize
  72. $ACLOCAL
  73. $AUTOCONF
  74. $AUTOMAKE --add-missing
  75. ./configure
  76. $MAKE check
  77. test -f check-ok
  78. :