vala-per-target-flags.sh 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #! /bin/sh
  2. # Copyright (C) 1996-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 per-target flags in vala support.
  17. required="pkg-config valac gcc GNUmake"
  18. . test-init.sh
  19. mkdir src
  20. cat >> configure.ac <<'END'
  21. AC_PROG_CC
  22. AM_PROG_VALAC([0.7.0])
  23. PKG_CHECK_MODULES([GOBJECT], [gobject-2.0 >= 2.4])
  24. AC_CONFIG_FILES([src/Makefile])
  25. AC_OUTPUT
  26. END
  27. cat > Makefile.am <<'END'
  28. SUBDIRS = src
  29. END
  30. cat > src/Makefile.am <<'END'
  31. bin_PROGRAMS = foo bar
  32. foo_CFLAGS = $(GOBJECT_CFLAGS)
  33. foo_LDADD = $(GOBJECT_LIBS)
  34. foo_SOURCES = xfoo.vala
  35. bar_SOURCES = xbar.vala
  36. bar_VALAFLAGS = -D BAR
  37. bar_CFLAGS = $(GOBJECT_CFLAGS)
  38. bar_LDADD = $(GOBJECT_LIBS)
  39. END
  40. cat > src/xfoo.vala <<'END'
  41. int main ()
  42. {
  43. stdout.printf ("foo\n");
  44. return 0;
  45. }
  46. END
  47. cat > src/xbar.vala <<'END'
  48. void main ()
  49. {
  50. #if BAR
  51. stdout.printf ("bar\n");
  52. #else
  53. stdout.oops_an_invalid_method ();
  54. #endif
  55. }
  56. END
  57. $ACLOCAL
  58. $AUTOCONF
  59. $AUTOMAKE -a
  60. ./configure
  61. $MAKE
  62. if ! cross_compiling; then
  63. ./src/foo
  64. ./src/bar
  65. test "$(./src/foo)" = foo
  66. test "$(./src/bar)" = bar
  67. fi
  68. # Test clean rules.
  69. cp config.status config.sav
  70. $MAKE clean
  71. test -f src/xfoo.c
  72. test -f src/xbar.c
  73. $MAKE distclean
  74. test -f src/xfoo.c
  75. test -f src/xbar.c
  76. # Re-create Makefile.
  77. mv config.sav config.status
  78. ./config.status
  79. $MAKE maintainer-clean
  80. test ! -e src/xfoo.c
  81. test ! -e src/xbar.c
  82. :