summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Chimento <philip@endlessm.com>2015-05-14 12:32:46 -0700
committerPhilip Chimento <philip@endlessm.com>2015-05-20 17:24:49 -0700
commita47ad9418cee71920d293fdae0f3c1589a1d50d0 (patch)
tree5f1c975cc1cf0b1eda0ba2c4fac3dfe48451100e
parent596b01daa99d8a5d1605cb57a4bbc6e7b0045edf (diff)
Check for webhelper's required GIR files
Make sure that the necessary GIR packages are installed before building. [endlessm/eos-sdk#291]
-rw-r--r--configure.ac3
-rw-r--r--m4/eos-gir.m490
2 files changed, 93 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index 4bc10e6..2f1d344 100644
--- a/configure.ac
+++ b/configure.ac
@@ -217,6 +217,9 @@ PKG_CHECK_MODULES([EOS_SDK], [
$EOS_REQUIRED_MODULES
$EOS_REQUIRED_MODULES_PRIVATE])
+# Check installed GIRs for webhelper JS module
+EOS_CHECK_GJS_GIR([GLib], [2.0])
+EOS_CHECK_GJS_GIR([WebKit], [3.0])
# Code coverage reports support
EOS_COVERAGE_REPORT([c js])
diff --git a/m4/eos-gir.m4 b/m4/eos-gir.m4
new file mode 100644
index 0000000..f598ca4
--- /dev/null
+++ b/m4/eos-gir.m4
@@ -0,0 +1,90 @@
+dnl Copyright 2013 Endless Mobile, Inc.
+dnl
+dnl Macros to check for GObject introspection libraries
+
+# EOS_PROG_GJS
+# ------------
+# Checks for the presence of GJS in the path. Issues an error
+# if it is not.
+
+AC_DEFUN_ONCE([EOS_PROG_GJS], [
+ AC_PATH_PROG([GJS], [gjs], [notfound])
+ AS_IF([test "x$GJS" = "xnotfound"],
+ [AC_MSG_ERROR([GJS is required, but was not found. If GJS is installed, try passing
+its path in an environment variable as GJS=/path/to/gjs.])])
+])
+
+# _EOS_GJS_IFELSE(program, [action-if-true], [action-if-false])
+# -------------------------------------------------------------
+# Comparable to AC_RUN_IFELSE(), but runs the program using GJS
+# instead of trying to compile it and link it.
+
+AC_DEFUN([_EOS_GJS_IFELSE], [
+ AC_REQUIRE([EOS_PROG_GJS])
+ echo "$1" >conftest.js
+ $GJS conftest.js >/dev/null 2>&1
+ AS_IF([test $? -eq 0], [$2], [$3])
+])
+
+# EOS_CHECK_GJS_GIR(<module>, [<version>])
+# ------------------------------------
+# Example:
+# EOS_CHECK_GJS_GIR([Gtk], [3.0])
+#
+# Check that the GIR <module> is importable in GJS. The API
+# version must be at least <version>, if given. Note that the
+# API version is different from the release version; GTK
+# currently has API version 3.0, but that could mean any
+# release from the 3.0, 3.2, 3.4,... series. To check for
+# specific API that was added in a later version, use
+# EOS_CHECK_GJS_GIR_API.
+
+AC_DEFUN([EOS_CHECK_GJS_GIR], [
+ AS_IF([test -z "$2"], [
+ AC_MSG_CHECKING([for $1])
+ _EOS_GJS_IFELSE([const Library = imports.gi.$1;],
+ [AC_MSG_RESULT([yes])],
+ [AC_MSG_FAILURE([no])]
+ )
+ ], [
+ AC_MSG_CHECKING([for version $2 of $1])
+ _EOS_GJS_IFELSE([
+ imports.gi.versions@<:@\"$1\"@:>@ = \"$2\";
+ const Library = imports.gi.$1;
+ ],
+ [AC_MSG_RESULT([yes])],
+ [
+ AC_MSG_RESULT([no])
+ GIRNAME="gir1.2-m4_tolower($1)-$2"
+ AC_MSG_ERROR([You do not have at least API version $2 of
+the GObject Introspection bindings for the $1 library.
+If on Ubuntu, try installing the '$GIRNAME' package.])
+ ]
+ )
+ ])
+])
+
+# EOS_CHECK_GJS_GIR_API(<module>, <symbol>)
+# -----------------------------------------
+# Example:
+# EOS_CHECK_GJS_GIR_API([Gtk], [ListBox])
+#
+# Check that <symbol> is defined inside the GIR <module> and
+# is discoverable (not undefined) in GJS.
+
+AC_DEFUN([EOS_CHECK_GJS_GIR_API], [
+ AC_MSG_CHECKING([for $1.$2])
+ _EOS_GJS_IFELSE([
+ const Library = imports.gi.$1;
+ if(typeof Library.$2 === 'undefined')
+ throw 1;
+ ],
+ [AC_MSG_RESULT([yes])],
+ [
+ AC_MSG_RESULT([no])
+ AC_MSG_ERROR([Your GObject Introspection bindings for
+the $1 library do not define the symbol $1.$2.
+Perhaps you need a newer version of the library?])
+ ])
+])
+