ltcond.sh 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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 conditional libtool libraries.
  17. # This combines two examples from the manual.
  18. required='cc libtoolize'
  19. . test-init.sh
  20. cat >>configure.ac <<'END'
  21. AM_CONDITIONAL([WANT_LIBFOO], [true])
  22. AM_CONDITIONAL([WANT_LIBBAR], [false])
  23. AC_SUBST([WANTEDLIBS], ['lib1foo.la lib1bar.la'])
  24. AC_PROG_CC
  25. AM_PROG_AR
  26. AC_PROG_LIBTOOL
  27. AC_OUTPUT
  28. END
  29. cat >Makefile.am <<'END'
  30. EXTRA_LTLIBRARIES = lib1foo.la lib1bar.la lib3bar.la
  31. lib_LTLIBRARIES = $(WANTEDLIBS)
  32. lib1foo_la_SOURCES = foo.c
  33. lib1foo_la_LDFLAGS = -rpath '$(libdir)'
  34. lib1bar_la_SOURCES = bar.c
  35. lib1bar_la_LDFLAGS = -rpath '$(libdir)'
  36. lib3bar_la_SOURCES = bar.c
  37. if WANT_LIBFOO
  38. lib_LTLIBRARIES += lib2foo.la
  39. check_LTLIBRARIES = lib3foo.la
  40. endif
  41. if WANT_LIBBAR
  42. lib_LTLIBRARIES += lib2bar.la
  43. endif
  44. lib2foo_la_SOURCES = foo.c
  45. lib2bar_la_SOURCES = bar.c
  46. lib3foo_la_SOURCES = foo.c
  47. END
  48. echo 'int one () { return 1; }' >foo.c
  49. echo 'int two () { return 2; }' >bar.c
  50. mkdir empty
  51. libtoolize
  52. $ACLOCAL
  53. $AUTOCONF
  54. $AUTOMAKE --add-missing
  55. cwd=$(pwd) || fatal_ "getting current working directory"
  56. # Install libraries in lib/, and the rest in empty/.
  57. # (in fact there is no "rest", so as the name imply empty/ is
  58. # expected to remain empty).
  59. ./configure --prefix="$cwd/empty" --libdir="$cwd/lib"
  60. $MAKE
  61. test -f lib1foo.la
  62. test -f lib1bar.la
  63. test -f lib2foo.la
  64. test ! -e lib2bar.la
  65. test ! -e lib3foo.la
  66. test ! -e lib3bar.la
  67. $MAKE check
  68. test ! -e lib2bar.la
  69. test -f lib3foo.la
  70. test ! -e lib3bar.la
  71. $MAKE install
  72. test -f lib/lib1foo.la
  73. test -f lib/lib1bar.la
  74. test -f lib/lib2foo.la
  75. test ! -e lib/lib3foo.la
  76. find empty -type f -print > empty.lst
  77. test -s empty.lst && { cat empty.lst; exit 1; }
  78. $MAKE uninstall
  79. find lib -type f -print > lib.lst
  80. test -s lib.lst && { cat lib.lst; exit 1; }
  81. test -f lib1foo.la
  82. test -f lib1bar.la
  83. test -f lib2foo.la
  84. test -f lib3foo.la
  85. $MAKE clean
  86. test ! -e lib1foo.la
  87. test ! -e lib1bar.la
  88. test ! -e lib2foo.la
  89. test ! -e lib3foo.la
  90. :