objc-flags.sh 1.6 KB

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