libtool9.sh 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. # Make sure xxx_LINK is defined for each target that requires specific
  17. # flags.
  18. # Quite similar to 'libtool7.sh', using AM_LDFLAGS in addition to
  19. # xxx_LDFLAGS.
  20. required='cc libtoolize'
  21. . test-init.sh
  22. cat >> configure.ac << 'END'
  23. AC_PROG_CC
  24. AM_PROG_AR
  25. AC_LIBTOOL_DLOPEN
  26. AM_PROG_LIBTOOL
  27. AC_OUTPUT
  28. END
  29. cat > Makefile.am << 'END'
  30. AM_LDFLAGS = -module
  31. lib_LTLIBRARIES = libmod1.la mod2.la
  32. libmod1_la_SOURCES = mod1.c
  33. libmod1_la_LDFLAGS =
  34. libmod1_la_LIBADD = -dlopen mod2.la
  35. mod2_la_SOURCES = mod2.c
  36. bin_PROGRAMS = prg prg2
  37. prg_SOURCES = prg.c
  38. prg_LDADD = -dlopen libmod1.la -dlpreopen mod2.la
  39. prg_CPPFLAGS = -DXYZ=1
  40. prg2_SOURCES = prg.c
  41. prg2_CFLAGS =
  42. print:
  43. @echo 1BEG: $(prg_DEPENDENCIES) :END1
  44. @echo 2BEG: $(libmod1_la_DEPENDENCIES) :END2
  45. @echo 3BEG: $(libmod1_la_LINK) :END3
  46. @echo 4BEG: $(mod2_la_LINK) :END4
  47. @echo 5BEG: $(prg_LINK) :END5
  48. @echo 6BEG: $(prg2_LINK) :END6
  49. END
  50. mkdir liba
  51. cat > mod1.c << 'END'
  52. int mod1 (void)
  53. {
  54. return 1;
  55. }
  56. END
  57. cat > mod2.c << 'END'
  58. int mod2 (void)
  59. {
  60. return 2;
  61. }
  62. END
  63. cat > prg.c << 'END'
  64. int main (void)
  65. {
  66. return 0;
  67. }
  68. END
  69. libtoolize --force --copy
  70. $ACLOCAL
  71. $AUTOCONF
  72. $AUTOMAKE --add-missing --copy
  73. ./configure
  74. run_make -M -- print \
  75. LDFLAGS=ldflags \
  76. AM_LDFLAGS=am_ldflags \
  77. libmod1_la_LDFLAGS=lm1_la_ldflags \
  78. CFLAGS=cflags \
  79. AM_CFLAGS=am_cflags \
  80. prg2_CFLAGS=prg2_cflags
  81. grep '1BEG: libmod1.la mod2.la :END1' output
  82. grep '2BEG: mod2.la :END2' output
  83. grep '3BEG:.* am_cflags cflags .*lm1_la_ldflags ldflags.* :END3' output
  84. grep '3BEG: .*am_ldflags.* :END3' output && exit 1
  85. grep '4BEG: :END4' output
  86. grep '5BEG: :END5' output
  87. grep '6BEG:.* prg2_cflags cflags .*am_ldflags ldflags.* :END6' output
  88. grep '6BEG: .*am_cflags.* :END6' output && exit 1
  89. $MAKE
  90. :