pr401.sh 3.9 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 LIBOBJS.
  17. # (pr401b.sh and pr401c.sh do the same for LTLIBOBJS and ALLOCA)
  18. required=cc
  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_RANLIB
  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 LIBOBJS usage. ##
  50. ## ------------------------------------------ ##
  51. cat >Makefile.am <<'EOF'
  52. SUBDIRS = lib src
  53. EOF
  54. cat >lib/Makefile.am <<'EOF'
  55. noinst_LIBRARIES = libfeep.a
  56. libfeep_a_SOURCES =
  57. libfeep_a_LIBADD = $(LIBOBJS)
  58. EOF
  59. cat >src/Makefile.am <<'EOF'
  60. check_PROGRAMS = main
  61. main_LDADD = ../lib/libfeep.a
  62. if !CROSS_COMPILING
  63. TESTS = main
  64. endif
  65. EOF
  66. cp "$am_scriptdir/ar-lib" . || fatal_ "fetching auxiliary script 'ar-lib'"
  67. $ACLOCAL
  68. $AUTOCONF
  69. $AUTOMAKE -a
  70. ./configure
  71. $MAKE distcheck
  72. ## ------------------------------------------ ##
  73. ## Traditional LIBOBJS with LIBOBJDIR set. ##
  74. ## ------------------------------------------ ##
  75. # Invocation of AC_CONFIG_LIBOBJ_DIR may be necessary for reasons
  76. # unrelated to Automake or Makefile.am layout.
  77. sed 's/#: //' configure.ac >configure.tmp
  78. mv -f configure.tmp configure.ac
  79. $ACLOCAL
  80. $AUTOCONF
  81. $AUTOMAKE
  82. ./configure
  83. test ! -e lib/lib
  84. $MAKE distcheck
  85. ## -------------------------------------------- ##
  86. ## Error message with usage in wrong directory. ##
  87. ## -------------------------------------------- ##
  88. mv -f src/Makefile.am src/t
  89. sed 's/LDADD = .*/LDADD = @LIBOBJS@/' src/t > src/Makefile.am
  90. AUTOMAKE_fails
  91. grep 'cannot be used outside.*lib' stderr
  92. mv -f src/t src/Makefile.am
  93. ## -------------------------------------------- ##
  94. ## Test using LIBOBJS from a sibling directory. ##
  95. ## -------------------------------------------- ##
  96. sed 's/lib\/Makefile //' configure.ac >configure.tmp
  97. mv -f configure.tmp configure.ac
  98. cat >Makefile.am <<'EOF'
  99. SUBDIRS = src
  100. EOF
  101. cat > src/Makefile.am <<'EOF'
  102. AUTOMAKE_OPTIONS = subdir-objects
  103. noinst_LIBRARIES = libfeep.a
  104. libfeep_a_SOURCES =
  105. libfeep_a_LIBADD = $(LIBOBJS)
  106. check_PROGRAMS = main
  107. main_LDADD = libfeep.a
  108. if !CROSS_COMPILING
  109. TESTS = main
  110. endif
  111. EOF
  112. $ACLOCAL
  113. $AUTOCONF
  114. $AUTOMAKE --add-missing
  115. ./configure
  116. test ! -e src/lib
  117. test ! -e 'src/$(top_builddir)'
  118. $MAKE
  119. $MAKE check
  120. $MAKE distclean
  121. ## ----------------------------------------- ##
  122. ## Test using LIBOBJS from parent directory. ##
  123. ## ----------------------------------------- ##
  124. sed 's/^.*src\/Makefile.*$//' configure.ac >configure.tmp
  125. mv -f configure.tmp configure.ac
  126. cat >Makefile.am <<'EOF'
  127. AUTOMAKE_OPTIONS = subdir-objects
  128. noinst_LIBRARIES = lib/libfeep.a
  129. lib_libfeep_a_SOURCES =
  130. lib_libfeep_a_LIBADD = $(LIBOBJS)
  131. check_PROGRAMS = src/main
  132. src_main_SOURCES = src/main.c
  133. src_main_LDADD = lib/libfeep.a
  134. if !CROSS_COMPILING
  135. TESTS = src/main
  136. endif
  137. check-local:
  138. test -f src/main.$(OBJEXT)
  139. test -f lib/feep.$(OBJEXT)
  140. test ! -f src/$(DEPDIR)/feep.Po
  141. EOF
  142. $ACLOCAL
  143. $AUTOCONF
  144. $AUTOMAKE
  145. ./configure
  146. $MAKE distcheck
  147. :