pr401b.sh 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. #! /bin/sh
  2. # Copyright (C) 2005-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. # Check support for AC_CONFIG_LIBOBJ_DIR vs LTLIBOBJS.
  17. # (pr401.sh and pr401c.sh do the same for LIBOBJS and ALLOCA)
  18. required='cc libtoolize'
  19. . test-init.sh
  20. mkdir lib src
  21. cat >lib/feep.c <<'EOF'
  22. const char *feep (void)
  23. {
  24. return "feep";
  25. }
  26. EOF
  27. cat >src/main.c <<'EOF'
  28. #include <stdio.h>
  29. extern const char *feep (void);
  30. int main (void)
  31. {
  32. puts (feep ());
  33. return 0;
  34. }
  35. EOF
  36. cat >>configure.ac << 'EOF'
  37. ## These lines are activated for later tests
  38. #: AC_CONFIG_LIBOBJ_DIR([lib])
  39. AC_PROG_CC
  40. AC_LIBOBJ([feep])
  41. AC_LIBSOURCE([feep.c])
  42. AM_PROG_AR
  43. AC_PROG_LIBTOOL
  44. AC_CONFIG_FILES([lib/Makefile src/Makefile])
  45. AM_CONDITIONAL([CROSS_COMPILING], [test $cross_compiling = yes])
  46. AC_OUTPUT
  47. EOF
  48. ## -------------------------------------------- ##
  49. ## First a test of traditional LTLIBOBJS usage. ##
  50. ## -------------------------------------------- ##
  51. cat >Makefile.am <<'EOF'
  52. SUBDIRS = lib src
  53. EOF
  54. cat >lib/Makefile.am <<'EOF'
  55. noinst_LTLIBRARIES = libfeep.la
  56. libfeep_la_SOURCES =
  57. libfeep_la_LIBADD = $(LTLIBOBJS)
  58. EOF
  59. cat >src/Makefile.am <<'EOF'
  60. check_PROGRAMS = main
  61. main_LDADD = ../lib/libfeep.la
  62. if !CROSS_COMPILING
  63. TESTS = main
  64. endif
  65. EOF
  66. cp "$am_scriptdir/ar-lib" . || fatal_ "fetching auxiliary script 'ar-lib'"
  67. libtoolize
  68. $ACLOCAL
  69. $AUTOCONF
  70. $AUTOMAKE -a
  71. ./configure
  72. $MAKE distcheck
  73. ## ----------------------------------------- ##
  74. ## Traditional LTLIBOBJS with LIBOBJDIR set. ##
  75. ## ----------------------------------------- ##
  76. # Invocation of AC_CONFIG_LIBOBJ_DIR may be necessary for reasons
  77. # unrelated to Automake or Makefile.am layout.
  78. sed 's/#: //' configure.ac >configure.tmp
  79. mv -f configure.tmp configure.ac
  80. $ACLOCAL
  81. $AUTOCONF
  82. $AUTOMAKE -a
  83. ./configure
  84. test ! -e lib/lib
  85. $MAKE distcheck
  86. ## -------------------------------------------- ##
  87. ## Error message with usage in wrong directory. ##
  88. ## -------------------------------------------- ##
  89. mv -f src/Makefile.am src/t
  90. sed 's/LDADD = .*/LDADD = @LTLIBOBJS@/' src/t > src/Makefile.am
  91. AUTOMAKE_fails
  92. grep 'cannot be used outside.*lib' stderr
  93. mv -f src/t src/Makefile.am
  94. ## ---------------------------------------------- ##
  95. ## Test using LTLIBOBJS from a sibling directory. ##
  96. ## ---------------------------------------------- ##
  97. sed 's/lib\/Makefile //' configure.ac >configure.tmp
  98. mv -f configure.tmp configure.ac
  99. cat >Makefile.am <<'EOF'
  100. SUBDIRS = src
  101. EOF
  102. cat > src/Makefile.am <<'EOF'
  103. AUTOMAKE_OPTIONS = subdir-objects
  104. noinst_LTLIBRARIES = libfeep.la
  105. libfeep_la_SOURCES =
  106. libfeep_la_LIBADD = $(LTLIBOBJS)
  107. check_PROGRAMS = main
  108. main_LDADD = libfeep.la
  109. if !CROSS_COMPILING
  110. TESTS = main
  111. endif
  112. EOF
  113. $ACLOCAL
  114. $AUTOCONF
  115. $AUTOMAKE --add-missing
  116. ./configure
  117. test ! -e src/lib
  118. test ! -e 'src/$(top_builddir)'
  119. $MAKE
  120. $MAKE check
  121. $MAKE distclean
  122. ## ------------------------------------------- ##
  123. ## Test using LTLIBOBJS from parent directory. ##
  124. ## ------------------------------------------- ##
  125. sed 's/^.*src\/Makefile.*$//' configure.ac >configure.tmp
  126. mv -f configure.tmp configure.ac
  127. cat >Makefile.am <<'EOF'
  128. AUTOMAKE_OPTIONS = subdir-objects
  129. noinst_LTLIBRARIES = lib/libfeep.la
  130. lib_libfeep_la_SOURCES =
  131. lib_libfeep_la_LIBADD = $(LTLIBOBJS)
  132. check_PROGRAMS = src/main
  133. src_main_SOURCES = src/main.c
  134. src_main_LDADD = lib/libfeep.la
  135. if !CROSS_COMPILING
  136. TESTS = src/main
  137. endif
  138. check-local:
  139. test -f src/main.$(OBJEXT)
  140. test -f lib/feep.lo
  141. test ! -f src/$(DEPDIR)/feep.Po
  142. EOF
  143. $ACLOCAL
  144. $AUTOCONF
  145. $AUTOMAKE
  146. ./configure
  147. $MAKE distcheck
  148. :