ltconv.sh 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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 libtool convenience libraries.
  17. # This example is taken from the manual.
  18. required='cc native libtoolize'
  19. . test-init.sh
  20. cat >>configure.ac <<'END'
  21. AC_PROG_CC
  22. AM_PROG_AR
  23. AC_PROG_LIBTOOL
  24. AC_CONFIG_FILES([sub1/Makefile
  25. sub2/Makefile
  26. sub2/sub21/Makefile
  27. sub2/sub22/Makefile])
  28. AC_OUTPUT
  29. END
  30. mkdir sub1
  31. mkdir sub2
  32. mkdir sub2/sub21
  33. mkdir sub2/sub22
  34. mkdir empty
  35. cat >Makefile.am <<'END'
  36. SUBDIRS = sub1 sub2
  37. lib_LTLIBRARIES = libtop.la
  38. libtop_la_SOURCES =
  39. libtop_la_LIBADD = \
  40. sub1/libsub1.la \
  41. sub2/libsub2.la
  42. bin_PROGRAMS = ltconvtest
  43. ltconvtest_SOURCES = test.c
  44. ltconvtest_LDADD = libtop.la
  45. check-local:
  46. ./ltconvtest$(EXEEXT)
  47. : > check-ok
  48. installcheck-local:
  49. $(bindir)/ltconvtest$(EXEEXT)
  50. : > installcheck-ok
  51. END
  52. cat >sub1/Makefile.am <<'END'
  53. noinst_LTLIBRARIES = libsub1.la
  54. libsub1_la_SOURCES = sub1.c
  55. END
  56. echo 'int sub1 () { return 1; }' > sub1/sub1.c
  57. cat >sub2/Makefile.am <<'END'
  58. SUBDIRS = sub21 sub22
  59. noinst_LTLIBRARIES = libsub2.la
  60. libsub2_la_SOURCES = sub2.c
  61. libsub2_la_LIBADD = \
  62. sub21/libsub21.la \
  63. sub22/libsub22.la
  64. END
  65. echo 'int sub2 () { return 2; }' > sub2/sub2.c
  66. cat >sub2/sub21/Makefile.am <<'END'
  67. noinst_LTLIBRARIES = libsub21.la
  68. libsub21_la_SOURCES = sub21.c
  69. END
  70. echo 'int sub21 () { return 21; }' > sub2/sub21/sub21.c
  71. cat >sub2/sub22/Makefile.am <<'END'
  72. noinst_LTLIBRARIES = libsub22.la
  73. libsub22_la_SOURCES = sub22.c
  74. END
  75. echo 'int sub22 () { return 22; }' > sub2/sub22/sub22.c
  76. cat >test.c <<'EOF'
  77. #include <stdio.h>
  78. int main ()
  79. {
  80. if (1 != sub1 ())
  81. return 1;
  82. if (2 != sub2 ())
  83. return 2;
  84. if (21 != sub21 ())
  85. return 3;
  86. if (22 != sub22 ())
  87. return 4;
  88. return 0;
  89. }
  90. EOF
  91. libtoolize
  92. $ACLOCAL
  93. $AUTOCONF
  94. $AUTOMAKE --add-missing
  95. cwd=$(pwd) || fatal_ "getting current working directory"
  96. # Install libraries in lib/, programs in bin/, and the rest in empty/.
  97. # (in fact there is no "rest", so as the name imply empty/ is
  98. # expected to remain empty).
  99. ./configure --prefix="$cwd/empty" --libdir="$cwd/lib" --bindir="$cwd/bin"
  100. $MAKE
  101. test -f libtop.la
  102. test -f sub1/libsub1.la
  103. test -f sub2/libsub2.la
  104. test -f sub2/sub21/libsub21.la
  105. test -f sub2/sub22/libsub22.la
  106. $MAKE check
  107. test -f check-ok
  108. rm -f check-ok
  109. $MAKE install
  110. test -f lib/libtop.la
  111. $MAKE installcheck
  112. test -f installcheck-ok
  113. rm -f installcheck-ok
  114. find empty -type f -print > empty.lst
  115. test -s empty.lst && { cat empty.lst; exit 1; }
  116. $MAKE clean
  117. test ! -e libtop.la
  118. test ! -e sub1/libsub1.la
  119. test ! -e sub2/libsub2.la
  120. test ! -e sub2/sub21/libsub21.la
  121. test ! -e sub2/sub22/libsub22.la
  122. test ! -e ltconvtest
  123. $MAKE installcheck
  124. test -f installcheck-ok
  125. rm -f installcheck-ok
  126. $MAKE uninstall
  127. for d in lib bin; do
  128. find $d -type f -print > $d.lst
  129. test -s $d.lst && { cat $d.lst; exit 1; }
  130. : For shells with busted 'set -e'.
  131. done
  132. :