per-target-flags.sh 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #! /bin/sh
  2. # Copyright (C) 1999-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. # Test executable-specific and library-specific flags, both with
  17. # and without dependency tracking.
  18. . test-init.sh
  19. makefiles='Makefile libMakefile Makefile2 libMakefile2'
  20. cat > configure.ac << END
  21. AC_INIT([$me], [1.0])
  22. AM_INIT_AUTOMAKE([-Wno-extra-portability])
  23. AC_CONFIG_FILES([$makefiles])
  24. AC_PROG_CC
  25. AC_PROG_CXX
  26. AC_PROG_RANLIB
  27. AC_OUTPUT
  28. END
  29. $ACLOCAL
  30. cat > Makefile.am << 'END'
  31. bin_PROGRAMS = foo
  32. foo_SOURCES = foo.c
  33. foo_CFLAGS = -DBAR
  34. END
  35. cat > libMakefile.am << 'END'
  36. lib_LIBRARIES = libfoo.a
  37. libfoo_a_SOURCES = foo.c bar.cc
  38. libfoo_a_CFLAGS = -DBAR
  39. libfoo_a_CXXFLAGS = -DZOT
  40. END
  41. cat - Makefile.am > Makefile2.am << 'END'
  42. AUTOMAKE_OPTIONS = no-dependencies
  43. END
  44. cat - libMakefile.am > libMakefile2.am << 'END'
  45. AUTOMAKE_OPTIONS = no-dependencies
  46. END
  47. makefiles=$(for mkf in $makefiles; do echo $mkf.in; done)
  48. $AUTOMAKE
  49. # Sanity check.
  50. for mkf in $makefiles; do test -f $mkf || exit 99; done
  51. # Regression test for missing space.
  52. $FGREP ')-c' $makefiles && exit 1
  53. # Regression test for botchedly transformed object names.
  54. $FGREP '.o.o' $makefiles && exit 1
  55. $FGREP '.obj.obj' $makefiles && exit 1
  56. $FGREP '.$(OBJEXT).$(OBJEXT)' $makefiles && exit 1
  57. # Watch against non-transformed "foo.$(OBJEXT)", "foo.o" and "foo.obj"
  58. # (and similarly for bar).
  59. $EGREP '[^-](foo|bar)\.[o$]' $makefiles && exit 1
  60. # All our programs and libraries have per-target flags, so all
  61. # the compilers invocations must use an explicit '-c' option.
  62. grep '\$.COMPILE' $makefiles | grep -v ' -c' && exit 1
  63. $FGREP 'foo-foo.$(OBJEXT)' Makefile.in
  64. $FGREP 'foo-foo.$(OBJEXT)' Makefile2.in
  65. $FGREP 'libfoo_a-foo.$(OBJEXT)' libMakefile.in
  66. $FGREP 'libfoo_a-foo.$(OBJEXT)' libMakefile2.in
  67. $FGREP 'libfoo_a-bar.$(OBJEXT)' libMakefile.in
  68. $FGREP 'libfoo_a-bar.$(OBJEXT)' libMakefile2.in
  69. $FGREP '$(foo_CFLAGS)' Makefile.in
  70. $FGREP '$(foo_CFLAGS)' Makefile2.in
  71. $FGREP '$(libfoo_a_CFLAGS)' libMakefile.in
  72. $FGREP '$(libfoo_a_CFLAGS)' libMakefile2.in
  73. :