Index: cjs/Makefile-test.am
===================================================================
--- cjs.orig/Makefile-test.am	2014-07-16 17:01:55.248277737 +0200
+++ cjs/Makefile-test.am	2014-07-16 17:02:22.583187779 +0200
@@ -67,19 +67,26 @@
 EXTRA_DIST +=			\
 	scripts/make-tests
 
+check_LTLIBRARIES =
 # noinst_ always builds a static library
 if ENABLE_TESTS
-testlib_LTLIBRARIES = libregress.la libgimarshallingtests.la
-testlibdir = $(prefix)/unused
-install-testlibLTLIBRARIES: # prevent it from being installed
+check_LTLIBRARIES += libregress.la libgimarshallingtests.la
 endif
 
+# This rpath /nowhere thing is the libtool upstream recommended way to
+# force generation of shared libraries, which we need in order for the
+# tests to work uninstalled.
+common_test_ldflags = -avoid-version -rpath /nowhere
+common_test_libadd = $(GJS_LIBS)
+
 nodist_libregress_la_SOURCES = $(GI_DATADIR)/tests/regress.c $(GI_DATADIR)/tests/regress.h
 libregress_la_CFLAGS = $(GJS_CFLAGS) $(GJS_CAIRO_CFLAGS)
-libregress_la_LDFLAGS = -avoid-version $(GJS_LIBS) $(GJS_CAIRO_LIBS)
+libregress_la_LDFLAGS = $(common_test_ldflags) $(GJS_CAIRO_LIBS)
+libregress_la_LIBADD = $(common_test_libadd)
 nodist_libgimarshallingtests_la_SOURCES = $(GI_DATADIR)/tests/gimarshallingtests.c $(GI_DATADIR)/tests/gimarshallingtests.h
 libgimarshallingtests_la_CFLAGS = $(GJS_CFLAGS)
-libgimarshallingtests_la_LDFLAGS = -avoid-version $(GJS_LIBS)
+libgimarshallingtests_la_LDFLAGS = $(common_test_ldflags)
+libgimarshallingtests_la_LIBADD = $(common_test_libadd)
 
 # g-i doesn't ship these as shared libraries anymore; we build them here
 Regress-1.0.gir: libregress.la Makefile
