objcxx-flags.sh 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #! /bin/sh
  2. # Copyright (C) 2012-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 Objective C++ compilation flags.
  17. # See also sister test 'objc-flags.sh'.
  18. . test-init.sh
  19. cat >> configure.ac << 'END'
  20. AC_PROG_OBJCXX
  21. AC_OUTPUT
  22. END
  23. cat > Makefile.am << 'END'
  24. AM_DEFAULT_SOURCE_EXT = .mm
  25. bin_PROGRAMS = foo2 foo4
  26. AM_OBJCXXFLAGS = -DVALUE=2 -DERROR=1
  27. foo4_OBJCXXFLAGS = -DVALUE=4 -DERROR=1
  28. END
  29. for i in 2 4; do
  30. unindent > foo$i.mm << END
  31. /* Let's make this file valid Objective C but invalid C. */
  32. #import <stdlib.h>
  33. @interface Who_Cares { } @end
  34. #ifdef ERROR
  35. # error "macro ERROR is defined for foo.mm"
  36. #else
  37. # if VALUE == $i
  38. int main (void) { exit (0); }
  39. # else
  40. # error "VALUE is != $i in foo.mm"
  41. # endif
  42. #endif
  43. END
  44. done
  45. $ACLOCAL
  46. $AUTOCONF
  47. $AUTOMAKE -a
  48. $FGREP OBJCXXFLAGS Makefile.in # For debugging.
  49. grep '\$(OBJCXXFLAGS).*\$(AM_OBJCXXFLAGS)' Makefile.in && exit 1
  50. grep '\$(OBJCXXFLAGS).*\$(foo.*_OBJCXXFLAGS)' Makefile.in && exit 1
  51. grep '\$(foo.*_OBJCXXFLAGS).*\$(AM_OBJCXXFLAGS)' Makefile.in && exit 1
  52. ./configure OBJCXXFLAGS=-UERROR
  53. $MAKE
  54. :