multilib.sh 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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. # Check multilib support.
  17. # Based on a test case from Ralf Corsepius.
  18. required='gcc GNUmake'
  19. . test-init.sh
  20. mldir=$am_top_srcdir/contrib/multilib
  21. mkdir m4
  22. cp "$mldir"/config-ml.in "$mldir"/symlink-tree .
  23. cp "$mldir"/multi.m4 m4
  24. ACLOCAL_PATH=${ACLOCAL_PATH+"$ACLOCAL_PATH:"}$(pwd)/m4
  25. export ACLOCAL_PATH
  26. cat >configure.ac <<'END'
  27. AC_INIT([multlib], [1.0])
  28. AC_CONFIG_SRCDIR(libfoo/foo.c)
  29. AC_CONFIG_AUX_DIR(.)
  30. AM_INIT_AUTOMAKE
  31. AC_CONFIG_FILES([Makefile])
  32. AC_CONFIG_SUBDIRS(libfoo)
  33. AC_CONFIG_SUBDIRS(libbar)
  34. AC_OUTPUT
  35. END
  36. cat >mycc <<'END'
  37. #! /bin/sh
  38. case ${1+"$@"} in
  39. *-print-multi-lib*)
  40. echo ".;"
  41. echo "debug;@g"
  42. exit 0 ;;
  43. esac
  44. gcc ${1+"$@"}
  45. END
  46. chmod +x mycc
  47. PATH=$(pwd)$PATH_SEPARATOR$PATH; export PATH
  48. cat >Makefile.am <<'EOF'
  49. SUBDIRS = @subdirs@
  50. EXTRA_DIST = config-ml.in symlink-tree
  51. check-all:
  52. test -f debug/libfoo/libfoo.a
  53. test -f debug/libbar/libbar.a
  54. test -f libfoo/libfoo.a
  55. test -f libbar/libbar.a
  56. EOF
  57. # libfoo tests multilib supports when there are no subdirectories
  58. # libbar tests multilib supports when there are subdirectories
  59. mkdir libfoo
  60. cp "$mldir"/multilib.am libfoo/
  61. cat >libfoo/configure.ac <<'END'
  62. AC_PREREQ(2.57)
  63. AC_INIT(libfoo, 0.1, nobody@localhost)
  64. AC_CONFIG_SRCDIR(foo.c)
  65. # Apparently it doesn't work to have auxdir=.. when
  66. # multilib uses symlinked trees.
  67. AC_CONFIG_AUX_DIR(.)
  68. AM_INIT_AUTOMAKE
  69. AC_PROG_CC
  70. AM_PROG_AR
  71. AC_PROG_RANLIB
  72. AM_ENABLE_MULTILIB(Makefile,[..])
  73. AC_CONFIG_FILES([Makefile])
  74. AC_OUTPUT
  75. END
  76. cat >libfoo/Makefile.am <<'END'
  77. noinst_LIBRARIES = libfoo.a
  78. libfoo_a_SOURCES = foo.c
  79. include $(top_srcdir)/multilib.am
  80. END
  81. : > libfoo/foo.c
  82. mkdir libbar
  83. cp "$mldir"/multilib.am libbar/
  84. cat >libbar/configure.ac <<'END'
  85. AC_PREREQ(2.57)
  86. AC_INIT(libbar, 0.1, nobody@localhost)
  87. # Apparently it doesn't work to have auxdir=.. when
  88. # multilib uses symlinked trees.
  89. AC_CONFIG_AUX_DIR(.)
  90. AM_INIT_AUTOMAKE
  91. AC_PROG_CC
  92. AM_PROG_AR
  93. AC_PROG_RANLIB
  94. AM_ENABLE_MULTILIB(Makefile,[..])
  95. AC_CONFIG_FILES([Makefile sub/Makefile])
  96. AC_OUTPUT
  97. END
  98. cat >libbar/Makefile.am <<'END'
  99. SUBDIRS = sub
  100. noinst_LIBRARIES = libbar.a
  101. libbar_a_SOURCES = bar.c
  102. include $(top_srcdir)/multilib.am
  103. END
  104. mkdir libbar/sub
  105. echo 'include $(top_srcdir)/multilib.am' >libbar/sub/Makefile.am
  106. : > libbar/bar.c
  107. $ACLOCAL
  108. $AUTOCONF
  109. $AUTOMAKE --add-missing
  110. cd libfoo
  111. $ACLOCAL
  112. $AUTOCONF
  113. $AUTOMAKE --add-missing
  114. cd ..
  115. cd libbar
  116. $ACLOCAL
  117. $AUTOCONF
  118. $AUTOMAKE --add-missing
  119. cd ..
  120. # Check VPATH builds
  121. mkdir build
  122. cd build
  123. ../configure --enable-multilib CC=mycc
  124. $MAKE
  125. test -f debug/libfoo/libfoo.a
  126. test -f debug/libbar/libbar.a
  127. test -f libfoo/libfoo.a
  128. test -f libbar/libbar.a
  129. $MAKE install
  130. $MAKE distcleancheck
  131. # Check standard builds.
  132. cd ..
  133. # Why to I have to specify --with-target-subdir?
  134. ./configure --enable-multilib --with-target-subdir=. CC=mycc
  135. $MAKE check
  136. DISTCHECK_CONFIGURE_FLAGS='--enable-multilib CC=mycc' $MAKE distcheck
  137. :