pr401c.sh 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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 ALLOCA.
  17. # (pr401.sh and pr401b.sh do the same for LIBOBJS and LTLIBOBJS)
  18. required=cc
  19. . test-init.sh
  20. mkdir lib src
  21. ac_cv_func_alloca_works=no; export ac_cv_func_alloca_works
  22. cat >lib/alloca.c <<'EOF'
  23. const char *feep (void)
  24. {
  25. return "feep";
  26. }
  27. EOF
  28. cat >src/main.c <<'EOF'
  29. #include <stdio.h>
  30. extern const char *feep (void);
  31. int main (void)
  32. {
  33. puts (feep ());
  34. return 0;
  35. }
  36. EOF
  37. cat >>configure.ac << 'EOF'
  38. ## These lines are activated for later tests.
  39. #: AC_CONFIG_LIBOBJ_DIR([lib])
  40. AC_PROG_CC
  41. AM_PROG_AR
  42. AC_PROG_RANLIB
  43. AC_FUNC_ALLOCA
  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 ALLOCA 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 = $(ALLOCA)
  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 ALLOCA 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 = @ALLOCA@/' 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 ALLOCA 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 = $(ALLOCA) $(LIBOBJS) # Add LIBOBJS for fun.
  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. $MAKE
  117. test ! -e src/lib
  118. test ! -e 'src/$(top_builddir)'
  119. $MAKE check
  120. $MAKE distclean
  121. ## ---------------------------------------- ##
  122. ## Test using ALLOCA 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 = $(ALLOCA)
  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/alloca.$(OBJEXT)
  140. test ! -f src/$(DEPDIR)/alloca.Po
  141. EOF
  142. $ACLOCAL
  143. $AUTOCONF
  144. $AUTOMAKE
  145. ./configure
  146. $MAKE distcheck
  147. :