[librsvg/rustification] Make cargo run when srcdir != builddir



commit 30a91d1e1f2df9ad4d6b28ed635e69619b1ed8b3
Author: Federico Mena Quintero <federico gnome org>
Date:   Wed Dec 14 09:31:43 2016 -0600

    Make cargo run when srcdir != builddir
    
    Thanks to Jeff Waugh and Hubert Figuière for the trick.

 Makefile.am                   |   19 +++++++++++--------
 configure.ac                  |    2 ++
 gdk-pixbuf-loader/Makefile.am |   23 ++++++++++++++++++++++-
 3 files changed, 35 insertions(+), 9 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index ae78b0c..1b81ab4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -88,20 +88,22 @@ RUST_SOURCES =                                      \
        rust/src/state.rs                       \
        rust/src/strtod.rs
 
-RUST_LIB = rust/target/debug/librsvg_internals.a
+RUST_EXTRA =                                   \
+       rust/Cargo.lock
+
+RUST_LIB = @abs_top_builddir@/target/debug/librsvg_internals.a
 
 check-local:
        cd $(srcdir)/rust && \
-       cargo test
+       CARGO_TARGET_DIR=@abs_top_builddir@/target cargo test
 
 clean-local:
-       cd $(srcdir)/rust && \
-       cargo clean
+       cd $(top_srcdir)/rust && \
+       CARGO_TARGET_DIR=@abs_top_builddir@/target cargo clean
 
-.PHONY: $(RUST_LIB)
-$(RUST_LIB):
-       cd $(srcdir)/rust && \
-       cargo build --verbose
+$(RUST_LIB): $(RUST_SOURCES)
+       cd $(top_srcdir)/rust && \
+       CARGO_TARGET_DIR=@abs_top_builddir@/target cargo build --verbose
 
 librsvg_@RSVG_API_MAJOR_VERSION@_la_CPPFLAGS = \
        -I$(top_srcdir)                         \
@@ -190,6 +192,7 @@ endif # OS_WIN32
 
 EXTRA_DIST =                           \
        $(RUST_SOURCES)                 \
+       $(RUST_EXTRA)                   \
        librsvg.doap                    \
        AUTHORS                         \
        NEWS                            \
diff --git a/configure.ac b/configure.ac
index ddae002..8c67d9f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -187,6 +187,8 @@ AC_SUBST([gdk_pixbuf_cache_file])
 
 AM_CONDITIONAL([ENABLE_PIXBUF_LOADER],[test "$enable_pixbuf_loader" = "yes"])
 
+AM_CONDITIONAL(CROSS_COMPILING, test $cross_compiling = yes)
+
 ##########################################################
 # Check for -Bsymbolic-functions linker flag used to avoid
 # intra-library PLT jumps, if available.
diff --git a/gdk-pixbuf-loader/Makefile.am b/gdk-pixbuf-loader/Makefile.am
index 4c12d66..cbf2ba3 100644
--- a/gdk-pixbuf-loader/Makefile.am
+++ b/gdk-pixbuf-loader/Makefile.am
@@ -51,10 +51,31 @@ EXTRA_rsvg_loader_DEPENDENCIES = libpixbufloader-svg.la gdk-pixbuf-loaders
 gdk-pixbuf-loaders: Makefile
        $(AM_V_GEN) ( $(GDK_PIXBUF_QUERYLOADERS) ./libpixbufloader-svg.la && $(GDK_PIXBUF_QUERYLOADERS)) > 
gdk-pixbuf.loaders 2>/dev/null
 
+if CROSS_COMPILING
+RUN_QUERY_LOADER_TEST=false
+else
+RUN_QUERY_LOADER_TEST=test -z "$(DESTDIR)"
+endif
+
+# The following bit is stolen from gdk-pixbuf/gdk-pixbuf/Makefile.am:
+#
+# Running this if cross compiling or if DESTDIR is set is going to
+# not work at all, so skip it
+# We use install-data-hook here to workaround a bug in automake and/or libtool
+# that makes the install target for the loader libraries a dependency on
+# install-data-am, and not install-exec-am. We need to ensure this gets run
+# after the libraries are installed in their final locations.
 install-data-hook:
-       if test -z "$(DESTDIR)"; then \
+       @if $(RUN_QUERY_LOADER_TEST) ; then \
                $(mkinstalldirs) $(DESTDIR)$(gdk_pixbuf_binarydir) ; \
                $(GDK_PIXBUF_QUERYLOADERS) > $(DESTDIR)$(gdk_pixbuf_cache_file) ; \
+       else \
+         echo "***" ; \
+         echo "*** Warning: loaders.cache not built" ; \
+         echo "***" ; \
+         echo "*** Generate this file manually on host" ; \
+         echo "*** system using gdk-pixbuf-query-loaders" ; \
+         echo "***" ; \
        fi
 
 CLEANFILES = \


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]