vala-libs.sh 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. # Building libraries (libtool and static) from Vala sources.
  17. # And use of vapi files to call C code from Vala.
  18. required="valac cc pkg-config libtoolize GNUmake"
  19. . test-init.sh
  20. cat >> configure.ac << 'END'
  21. AC_PROG_CC
  22. AM_PROG_AR
  23. AC_PROG_RANLIB
  24. AC_PROG_LIBTOOL
  25. AM_PROG_VALAC([0.7.3])
  26. PKG_CHECK_MODULES([GOBJECT], [gobject-2.0 >= 2.4])
  27. AC_OUTPUT
  28. END
  29. cat > Makefile.am << 'END'
  30. AUTOMAKE_OPTIONS = subdir-objects
  31. lib_LIBRARIES = libmu.a
  32. lib_LTLIBRARIES = src/libzardoz.la
  33. libmu_a_SOURCES = mu.vala mu2.c mu.vapi mu2.h
  34. libmu_a_CPPFLAGS = -DOKOKIMDEFINED=1
  35. libmu_a_VALAFLAGS = --vapidir=$(srcdir)
  36. AM_CFLAGS = $(GOBJECT_CFLAGS)
  37. src_libzardoz_la_LIBADD = $(GOBJECT_LIBS)
  38. src_libzardoz_la_SOURCES = src/zardoz-foo.vala src/zardoz-bar.vala
  39. src/zardoz-bar.vala: src/zardoz-foo.vala
  40. sed 's/Foo/Bar/g' $< >$@
  41. END
  42. libtoolize
  43. $ACLOCAL
  44. $AUTOCONF
  45. $AUTOMAKE -a
  46. ./configure
  47. cat > mu2.c << 'END'
  48. #include "mu2.h"
  49. int mu2 (void)
  50. {
  51. return OKOKIMDEFINED;
  52. }
  53. END
  54. cat > mu2.h << 'END'
  55. int mu2 (void);
  56. END
  57. cat > mu.vapi <<'END'
  58. [CCode (cheader_filename = "mu2.h", cname = "mu2")]
  59. public int c_mu2 ();
  60. END
  61. cat > mu.vala << 'END'
  62. int main ()
  63. {
  64. stdout.printf ("mumumu\n");
  65. return c_mu2 ();
  66. }
  67. END
  68. mkdir -p src
  69. cat > src/zardoz-foo.vala << 'END'
  70. using GLib;
  71. public class Foo {
  72. public static void zap () {
  73. stdout.printf ("FooFooFoo!\n");
  74. }
  75. }
  76. END
  77. $MAKE
  78. test -f libmu.a
  79. test -f src/libzardoz.la
  80. $FGREP "mumumu" mu.c
  81. $FGREP "FooFooFoo" src/zardoz-foo.c
  82. $FGREP "BarBarBar" src/zardoz-bar.c
  83. test -f libmu_a_vala.stamp
  84. test -f src_libzardoz_la_vala.stamp
  85. $MAKE distcheck
  86. :