objc-minidemo.sh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. # Dummy demo package using Objective C and doing distcheck.
  17. # See also sister test 'objcxx-minidemo.sh'.
  18. required=native
  19. . test-init.sh
  20. cat >> configure.ac << 'END'
  21. AC_PROG_OBJC
  22. AC_CONFIG_HEADERS([config.h])
  23. AC_OUTPUT
  24. END
  25. cat > Makefile.am << 'END'
  26. AM_DEFAULT_SOURCE_EXT = .m
  27. bin_PROGRAMS = ok
  28. noinst_PROGRAMS = ko
  29. TESTS = $(bin_PROGRAMS) $(XFAIL_TESTS)
  30. XFAIL_TESTS = $(noinst_PROGRAMS)
  31. END
  32. cat > ok.m << 'END'
  33. /* The use of #import makes this valid Object C but invalid C. */
  34. #import <stdio.h>
  35. #import <config.h>
  36. int main (void)
  37. {
  38. printf ("Success (%s)\n", PACKAGE_STRING);
  39. return 0;
  40. }
  41. END
  42. cat > ko.m << 'END'
  43. /* The use of #import makes this valid Object C but invalid C. */
  44. #import <stdio.h>
  45. int main (void)
  46. {
  47. printf("Failure\n");
  48. return 1;
  49. }
  50. END
  51. if $ACLOCAL; then
  52. : We have a modern enough autoconf, go ahead.
  53. elif test $? -eq 63; then
  54. skip_ "Object C++ support requires Autoconf 2.65 or later"
  55. else
  56. exit 1 # Some other aclocal failure.
  57. fi
  58. $ACLOCAL
  59. $AUTOCONF
  60. $AUTOHEADER
  61. $AUTOMAKE --add-missing
  62. ./configure
  63. $MAKE
  64. $MAKE check
  65. $MAKE distcheck
  66. :