[PATCH 1/5] Always build wayland-scanner

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


From: Thierry Reding <treding at nvidia.com>

When cross-compiling, wayland-scanner cannot be used to generate files
because it is built for the host architecture. To overcome this, users
currently need to instruct the build not to create wayland-scanner and
provide a native variant in the PATH. This has the disadvantage of not
installing the scanner either and in turn users running a distribution
that was cross-built cannot use it.

This commit changes the build process to always create and install the
wayland-scanner binary. The configure script determines whether to use
the version being built or a native version found in the PATH.

Signed-off-by: Thierry Reding <treding at nvidia.com>
---
 Makefile.am  | 11 +++--------
 configure.ac | 31 ++++++++++++++++---------------
 2 files changed, 19 insertions(+), 23 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index c15d8b8b853d..028d0d4837b5 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -61,25 +61,20 @@ nodist_libwayland_client_la_SOURCES =		\
 
 pkgconfig_DATA += src/wayland-client.pc src/wayland-server.pc
 
-if ENABLE_SCANNER
-wayland_scanner = $(top_builddir)/wayland-scanner
 bin_PROGRAMS = wayland-scanner
 wayland_scanner_SOURCES = src/scanner.c
 wayland_scanner_LDADD = $(EXPAT_LIBS) libwayland-util.la
 $(BUILT_SOURCES) : wayland-scanner
 pkgconfig_DATA += src/wayland-scanner.pc
-else
-wayland_scanner = wayland-scanner
-endif
 
 protocol/%-protocol.c : $(top_srcdir)/protocol/%.xml
-	$(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(wayland_scanner) code < $< > $@
+	$(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(WAYLAND_SCANNER) code < $< > $@
 
 protocol/%-server-protocol.h : $(top_srcdir)/protocol/%.xml
-	$(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(wayland_scanner) server-header < $< > $@
+	$(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(WAYLAND_SCANNER) server-header < $< > $@
 
 protocol/%-client-protocol.h : $(top_srcdir)/protocol/%.xml
-	$(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(wayland_scanner) client-header < $< > $@
+	$(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(WAYLAND_SCANNER) client-header < $< > $@
 
 BUILT_SOURCES =					\
 	$(nodist_libwayland_server_la_SOURCES)	\
diff --git a/configure.ac b/configure.ac
index 393310cd6699..d14142bbc8c3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -31,6 +31,17 @@ AC_PROG_CC
 LT_PREREQ([2.2])
 LT_INIT
 
+if test "x$cross_compiling" = "xyes"; then
+	AC_PATH_PROG(WAYLAND_SCANNER, wayland-scanner)
+
+	if test "x$WAYLAND_SCANNER" = "x"; then
+		AC_MSG_ERROR([Cross-compiling but wayland-scanner not found.])
+	fi
+else
+	WAYLAND_SCANNER='$(top_builddir)/wayland-scanner'
+	AC_SUBST([WAYLAND_SCANNER])
+fi
+
 PKG_PROG_PKG_CONFIG()
 PKG_CHECK_MODULES(FFI, [libffi])
 
@@ -52,20 +63,12 @@ AC_CHECK_DECL(CLOCK_MONOTONIC,[],
 	      [[#include <time.h>]])
 AC_CHECK_HEADERS([execinfo.h])
 
-AC_ARG_ENABLE([scanner],
-              [AC_HELP_STRING([--disable-scanner],
-                              [Disable compilation of wayland-scanner])],
-              [],
-              [enable_scanner=yes])
-
 AC_ARG_ENABLE([documentation],
 	      [AC_HELP_STRING([--disable-documentation],
 		              [Disable building the documentation])],
 	      [],
 	      [enable_documentation=yes])
 
-AM_CONDITIONAL(ENABLE_SCANNER, test "x$enable_scanner" = xyes)
-
 AC_ARG_WITH(icondir, [  --with-icondir=<dir>    Look for cursor icons here],
 		     [  ICONDIR=$withval],
 		     [  ICONDIR=${datadir}/icons])
@@ -76,13 +79,11 @@ AC_ARG_WITH(expat, [  --with-expat=<dir>      Use expat from here],
 		   [ expat=$withval
 		     CPPFLAGS="$CPPFLAGS -I$withval/include"
 		     LDFLAGS="$LDFLAGS -L$withval/lib" ] )
-if test "x$enable_scanner" = "xyes"; then
-	AC_CHECK_HEADERS(expat.h, [AC_DEFINE(HAVE_EXPAT_H)],
-			 [AC_MSG_ERROR([Can't find expat.h. Please install expat.])])
-	AC_CHECK_LIB(expat, XML_ParserCreate, [EXPAT_LIBS="-lexpat"],
-		     [AC_MSG_ERROR([Can't find expat library. Please install expat.])])
-	AC_SUBST(EXPAT_LIBS)
-fi
+AC_CHECK_HEADERS(expat.h, [AC_DEFINE(HAVE_EXPAT_H)],
+		 [AC_MSG_ERROR([Can't find expat.h. Please install expat.])])
+AC_CHECK_LIB(expat, XML_ParserCreate, [EXPAT_LIBS="-lexpat"],
+	     [AC_MSG_ERROR([Can't find expat library. Please install expat.])])
+AC_SUBST(EXPAT_LIBS)
 
 AC_PATH_PROG(XSLTPROC, xsltproc)
 AM_CONDITIONAL([HAVE_XSLTPROC], [test "x$XSLTPROC" != "x"])
-- 
1.9.2



More information about the wayland-devel mailing list