vala-mix.sh 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. # Vala sources and C sources in the same program. Functional test.
  17. required='valac cc pkg-config GNUmake'
  18. . test-init.sh
  19. cat >> configure.ac <<'END'
  20. AC_PROG_CC
  21. AM_PROG_VALAC([0.7.3])
  22. PKG_CHECK_MODULES([GOBJECT], [gobject-2.0 >= 2.4])
  23. AC_OUTPUT
  24. END
  25. cat > Makefile.am <<'END'
  26. bin_PROGRAMS = zardoz mu baz
  27. AM_CFLAGS = $(GOBJECT_CFLAGS)
  28. LDADD = $(GOBJECT_LIBS)
  29. zardoz_SOURCES = foo.vala bar.c
  30. mu_SOURCES = 1.vala 2.c
  31. mu_VALAFLAGS = --main=run
  32. mu_CFLAGS = -DHAVE_MU $(AM_CFLAGS)
  33. baz_SOURCES = baz.c
  34. END
  35. if ! cross_compiling; then
  36. unindent >> Makefile.am <<'END'
  37. check-local:
  38. ./zardoz
  39. ./mu
  40. ./zardoz | grep "foo is alive"
  41. ./mu | grep "Howdy, World!"
  42. END
  43. fi
  44. cat > foo.vala <<'END'
  45. int main ()
  46. {
  47. stdout.printf ("foo is alive\n");
  48. return 0;
  49. }
  50. END
  51. echo 'extern int i = 0;' > bar.c
  52. cat > 1.vala <<'END'
  53. int run ()
  54. {
  55. stdout.printf ("Howdy, World!\n");
  56. return 0;
  57. }
  58. END
  59. cat > 2.c <<'END'
  60. #ifdef HAVE_MU
  61. int all_is_ok = 1;
  62. #else
  63. #error "HAVE_MU no defined"
  64. chocke me
  65. #endif
  66. END
  67. # For automake bug#11229.
  68. cat > baz.c <<'END'
  69. int main (void)
  70. {
  71. return 0;
  72. }
  73. END
  74. $ACLOCAL
  75. $AUTOMAKE -a
  76. $AUTOCONF
  77. ./configure
  78. $MAKE all
  79. ls -l # For debugging.
  80. $MAKE check
  81. have_generated_files ()
  82. {
  83. test -f mu_vala.stamp
  84. test -f zardoz_vala.stamp
  85. test -f foo.c
  86. test -f 1.c
  87. }
  88. # Our vala-related rules must create stamp files and intermediate
  89. # C files.
  90. have_generated_files
  91. # Remake rules are not uselessly triggered.
  92. $MAKE -q
  93. $MAKE -n | $FGREP vala.stamp && exit 1
  94. # Check the distribution.
  95. $MAKE distcheck
  96. # Stamp files and intermediate C files should *not* be removed
  97. # by "make clean".
  98. $MAKE clean
  99. have_generated_files
  100. # But stamp files should be removed by "maintainer-clean" (the
  101. # behaviour w.r.t. intermediate C files is still unclear, and
  102. # better left undefined for the moment).
  103. $MAKE maintainer-clean
  104. ls *vala*.stamp | grep . && exit 1
  105. :