[PATCH 3/5] Improve wayland-scanner m4 rules

Thierry Reding thierry.reding at gmail.com
Mon May 19 08:12:41 PDT 2014


From: Thierry Reding <treding at nvidia.com>

When cross-compiling always look up the wayland-scanner binary in the
PATH. Using the value from the wayland-scanner.pc file will not work
because it will point to a binary built for the host.

While trying to find the path of the wayland-scanner makefile snippet,
check that the pkgdatadir variable can be properly retrieved from the
pkg-config file.

Signed-off-by: Thierry Reding <treding at nvidia.com>
---
 wayland-scanner.m4 | 35 +++++++++++++++++++++++++++++------
 wayland-scanner.mk |  6 +++---
 2 files changed, 32 insertions(+), 9 deletions(-)

diff --git a/wayland-scanner.m4 b/wayland-scanner.m4
index e7f383a4c74f..e28d93318d27 100644
--- a/wayland-scanner.m4
+++ b/wayland-scanner.m4
@@ -1,11 +1,34 @@
 AC_DEFUN([WAYLAND_SCANNER_RULES], [
-    PKG_PROG_PKG_CONFIG
+    AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
 
-    PKG_CHECK_MODULES([WAYLAND_SCANNER], [wayland-scanner])
+    if test "x$cross_compiling" = "xyes"; then
+        AC_PATH_PROG([WAYLAND_SCANNER], [wayland-scanner])
 
-    wayland_scanner=`$PKG_CONFIG --variable=wayland_scanner wayland-scanner`
-    AC_SUBST([wayland_scanner])
+        if test "x$WAYLAND_SCANNER" = "x"; then
+            AC_MSG_ERROR([Cross-compiling but wayland-scanner not found.])
+        fi
+    else
+        AC_MSG_CHECKING([for wayland-scanner])
+        PKG_CHECK_VAR([WAYLAND_SCANNER], [wayland-scanner], [wayland_scanner])
+        AC_MSG_RESULT([$WAYLAND_SCANNER])
 
-    wayland_scanner_rules=`$PKG_CONFIG --variable=pkgdatadir wayland-scanner`/wayland-scanner.mk
-    AC_SUBST_FILE([wayland_scanner_rules])
+        if test "x$WAYLAND_SCANNER" = "x"; then
+            AC_MSG_ERROR([wayland-scanner not found])
+        fi
+    fi
+
+    AC_MSG_CHECKING([for wayland-scanner make rules])
+    PKG_CHECK_VAR([wayland_pkgdatadir], [wayland-scanner], [pkgdatadir])
+    if test "x$wayland_pkgdatadir" != "x"; then
+        WAYLAND_SCANNER_MAKE_RULES=$wayland_pkgdatadir/wayland-scanner.mk
+    else
+        WAYLAND_SCANNER_MAKE_RULES=no
+    fi
+    AC_MSG_RESULT([$WAYLAND_SCANNER_MAKE_RULES])
+
+    if test "x$WAYLAND_SCANNER_MAKE_RULES" = "xno"; then
+        AC_MSG_ERROR([wayland-scanner make rules not found])
+    fi
+
+    AC_SUBST_FILE([WAYLAND_SCANNER_MAKE_RULES])
 ])
diff --git a/wayland-scanner.mk b/wayland-scanner.mk
index b6e0f444aaa5..33d97a33ed8e 100644
--- a/wayland-scanner.mk
+++ b/wayland-scanner.mk
@@ -1,8 +1,8 @@
 %-protocol.c: %.xml
-	$(AM_V_GEN)$(wayland_scanner) code < $< > $@
+	$(AM_V_GEN)$(WAYLAND_SCANNER) code < $< > $@
 
 %-server-protocol.h: %.xml
-	$(AM_V_GEN)$(wayland_scanner) server-header < $< > $@
+	$(AM_V_GEN)$(WAYLAND_SCANNER) server-header < $< > $@
 
 %-client-protocol.h: %.xml
-	$(AM_V_GEN)$(wayland_scanner) client-header < $< > $@
+	$(AM_V_GEN)$(WAYLAND_SCANNER) client-header < $< > $@
-- 
1.9.2



More information about the wayland-devel mailing list