Author: Andreas Beckmann <anbe@debian.org>
Description: support building the examples out-of-tree and link them dynamically

--- a/src/components/Makefile_comp_tests.target.in
+++ b/src/components/Makefile_comp_tests.target.in
@@ -2,10 +2,10 @@
 exec_prefix = @exec_prefix@
 PACKAGE_TARNAME = @PACKAGE_TARNAME@
 datadir = @datadir@/${PACKAGE_TARNAME}
-testlibdir = $(datadir)/testlib
+testlibdir = ../testlib
 INCLUDE = -I. -I@includedir@ -I$(testlibdir)
 LIBDIR  = @libdir@
-PAPILIB = $(LIBDIR)/@LIBRARY@
+PAPILIB = -lpapi
 TESTLIB = $(testlibdir)/libtestlib.a
 LDFLAGS = @LDL@
 CC	= @CC@
@@ -28,4 +28,5 @@
 	-cp Makefile $(DATADIR)/$(NAME)/tests
 	-cp ../../Makefile_comp_tests $(DATADIR)
 
-
+$(TESTLIB):
+	$(MAKE) -C $(testlibdir)
--- a/src/ctests/Makefile.recipies
+++ b/src/ctests/Makefile.recipies
@@ -421,3 +421,6 @@
 
 clean:
 	rm -f *.o *.stderr *.stdout core *~ $(ALL) unregister_pthreads
+
+$(TESTLIB):
+	$(MAKE) -C $(testlibdir)
--- a/src/ctests/Makefile.target.in
+++ b/src/ctests/Makefile.target.in
@@ -2,12 +2,12 @@
 exec_prefix = @exec_prefix@
 PACKAGE_TARNAME = @PACKAGE_TARNAME@
 datadir = @datadir@/${PACKAGE_TARNAME}
-testlibdir = $(datadir)/testlib
+testlibdir = ../testlib
 INCLUDE = -I. -I@includedir@ -I$(testlibdir)
 LIBDIR  = @libdir@
 LIBRARY=@LIBRARY@
 SHLIB=@SHLIB@
-PAPILIB = $(LIBDIR)/@LINKLIB@
+PAPILIB = -lpapi
 TESTLIB = $(testlibdir)/libtestlib.a
 LDFLAGS = @LDL@ @STATIC@
 CC	= @CC@
--- a/src/ftests/Makefile.recipies
+++ b/src/ftests/Makefile.recipies
@@ -77,3 +77,6 @@
 
 clean:
 	rm -f *.o *genmod.f90 *genmod.mod *.stderr *.stdout core *~ $(ALL)
+
+$(TESTLIB):
+	$(MAKE) -C $(testlibdir)
--- a/src/ftests/Makefile.target.in
+++ b/src/ftests/Makefile.target.in
@@ -4,10 +4,10 @@
 exec_prefix = @exec_prefix@
 PACKAGE_TARNAME = @PACKAGE_TARNAME@
 datadir = @datadir@/${PACKAGE_TARNAME}
-testlibdir = $(datadir)/testlib
+testlibdir = ../testlib
 INCLUDE = -I. -I@includedir@ -I$(testlibdir)
 LIBDIR  = @libdir@
-PAPILIB = $(LIBDIR)/@LIBRARY@
+PAPILIB = -lpapi
 TESTLIB = $(testlibdir)/libtestlib.a
 LDFLAGS = @LDL@
 CC	= @CC@
