<div dir="ltr">You need to use AS_IF instead of shell 'if' if you want to use AC_SUBST inside a conditional.<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, May 27, 2014 at 3:23 AM, Thierry Reding <span dir="ltr"><<a href="mailto:thierry.reding@gmail.com" target="_blank">thierry.reding@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Tue, May 27, 2014 at 09:22:30AM +0300, Pekka Paalanen wrote:<br>
> On Mon, 19 May 2014 17:12:39 +0200<br>
> Thierry Reding <<a href="mailto:thierry.reding@gmail.com">thierry.reding@gmail.com</a>> wrote:<br>
><br>
> > From: Thierry Reding <<a href="mailto:treding@nvidia.com">treding@nvidia.com</a>><br>
> ><br>
> > When cross-compiling, wayland-scanner cannot be used to generate files<br>
> > because it is built for the host architecture. To overcome this, users<br>
> > currently need to instruct the build not to create wayland-scanner and<br>
> > provide a native variant in the PATH. This has the disadvantage of not<br>
> > installing the scanner either and in turn users running a distribution<br>
> > that was cross-built cannot use it.<br>
> ><br>
> > This commit changes the build process to always create and install the<br>
> > wayland-scanner binary. The configure script determines whether to use<br>
> > the version being built or a native version found in the PATH.<br>
> ><br>
> > Signed-off-by: Thierry Reding <<a href="mailto:treding@nvidia.com">treding@nvidia.com</a>><br>
> > ---<br>
> > Makefile.am | 11 +++--------<br>
> > <a href="http://configure.ac" target="_blank">configure.ac</a> | 31 ++++++++++++++++---------------<br>
> > 2 files changed, 19 insertions(+), 23 deletions(-)<br>
> ><br>
> > diff --git a/Makefile.am b/Makefile.am<br>
> > index c15d8b8b853d..028d0d4837b5 100644<br>
> > --- a/Makefile.am<br>
> > +++ b/Makefile.am<br>
> > @@ -61,25 +61,20 @@ nodist_libwayland_client_la_SOURCES = \<br>
> ><br>
> > pkgconfig_DATA += src/wayland-client.pc src/wayland-server.pc<br>
> ><br>
> > -if ENABLE_SCANNER<br>
> > -wayland_scanner = $(top_builddir)/wayland-scanner<br>
> > bin_PROGRAMS = wayland-scanner<br>
> > wayland_scanner_SOURCES = src/scanner.c<br>
> > wayland_scanner_LDADD = $(EXPAT_LIBS) <a href="http://libwayland-util.la" target="_blank">libwayland-util.la</a><br>
> > $(BUILT_SOURCES) : wayland-scanner<br>
> > pkgconfig_DATA += src/wayland-scanner.pc<br>
> > -else<br>
> > -wayland_scanner = wayland-scanner<br>
> > -endif<br>
> ><br>
> > protocol/%-protocol.c : $(top_srcdir)/protocol/%.xml<br>
> > - $(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(wayland_scanner) code < $< > $@<br>
> > + $(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(WAYLAND_SCANNER) code < $< > $@<br>
> ><br>
> > protocol/%-server-protocol.h : $(top_srcdir)/protocol/%.xml<br>
> > - $(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(wayland_scanner) server-header < $< > $@<br>
> > + $(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(WAYLAND_SCANNER) server-header < $< > $@<br>
> ><br>
> > protocol/%-client-protocol.h : $(top_srcdir)/protocol/%.xml<br>
> > - $(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(wayland_scanner) client-header < $< > $@<br>
> > + $(AM_V_GEN)$(MKDIR_P) $(dir $@) && $(WAYLAND_SCANNER) client-header < $< > $@<br>
> ><br>
> > BUILT_SOURCES = \<br>
> > $(nodist_libwayland_server_la_SOURCES) \<br>
> > diff --git a/<a href="http://configure.ac" target="_blank">configure.ac</a> b/<a href="http://configure.ac" target="_blank">configure.ac</a><br>
> > index 393310cd6699..d14142bbc8c3 100644<br>
> > --- a/<a href="http://configure.ac" target="_blank">configure.ac</a><br>
> > +++ b/<a href="http://configure.ac" target="_blank">configure.ac</a><br>
> > @@ -31,6 +31,17 @@ AC_PROG_CC<br>
> > LT_PREREQ([2.2])<br>
> > LT_INIT<br>
> ><br>
> > +if test "x$cross_compiling" = "xyes"; then<br>
> > + AC_PATH_PROG(WAYLAND_SCANNER, wayland-scanner)<br>
> > +<br>
> > + if test "x$WAYLAND_SCANNER" = "x"; then<br>
> > + AC_MSG_ERROR([Cross-compiling but wayland-scanner not found.])<br>
> > + fi<br>
> > +else<br>
> > + WAYLAND_SCANNER='$(top_builddir)/wayland-scanner'<br>
> > + AC_SUBST([WAYLAND_SCANNER])<br>
> > +fi<br>
><br>
> Is it ok to have AC_SUBST inside a condition?<br>
> I found one message where it seems to imply, that it is not a good<br>
> practice:<br>
> <a href="http://lists.gnu.org/archive/html/autoconf/2010-01/msg00091.html" target="_blank">http://lists.gnu.org/archive/html/autoconf/2010-01/msg00091.html</a><br>
><br>
> Otherwise looks fine to me.<br>
<br>
</div></div>I think it doesn't matter at all where AC_SUBST is placed since it will<br>
be evaluated outside of the shell context anyway. If you prefer I can<br>
move it outside of the conditional block, though.<br>
<span class="HOEnZb"><font color="#888888"><br>
Thierry<br>
</font></span><br>_______________________________________________<br>
wayland-devel mailing list<br>
<a href="mailto:wayland-devel@lists.freedesktop.org">wayland-devel@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/wayland-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/wayland-devel</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br> Jasper<br>
</div>