target-cflags.sh 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #! /bin/sh
  2. # Copyright (C) 2000-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 to make sure target specific CFLAGS work
  17. # Assar Westerlund <assar@sics.se>
  18. required=cc
  19. . test-init.sh
  20. cat >> configure.ac << 'END'
  21. AC_PROG_CC
  22. AC_OUTPUT
  23. END
  24. cat > Makefile.am << 'END'
  25. AUTOMAKE_OPTIONS = no-dependencies
  26. bin_PROGRAMS = foo bar
  27. foo_CFLAGS = -DFOO
  28. END
  29. cat > foo.c << 'END'
  30. #include <stdio.h>
  31. #ifdef FOO
  32. int main(void)
  33. {
  34. return 0;
  35. }
  36. #endif
  37. END
  38. cat > bar.c << 'END'
  39. #ifndef FOO
  40. int main(void)
  41. {
  42. return 0;
  43. }
  44. #endif
  45. END
  46. $ACLOCAL
  47. $AUTOCONF
  48. $AUTOMAKE -a
  49. mkdir build
  50. cd build
  51. ../configure
  52. $MAKE
  53. if ! cross_compiling; then
  54. ./foo
  55. ./bar
  56. fi
  57. cd ..
  58. ./configure
  59. $MAKE
  60. if ! cross_compiling; then
  61. ./foo
  62. ./bar
  63. fi
  64. :