From 8dce932acbc245d67d49c0b0b9d51bb1abeb32b2 Mon Sep 17 00:00:00 2001
From: Thomas Jahns <jahns@dkrz.de>
Date: Wed, 21 Aug 2019 18:37:18 +0200
Subject: [PATCH] Update to libtool 2.4.6.

* This was needed to get working builds on Piz Daint, libtool 2.4.2 generated
  bogus dependencies on libquadmath.so.
---
 app/Makefile.am                | 15 +++++++++++++++
 examples/Makefile.am           | 14 ++++++++++++++
 examples/pio/Makefile.am       | 18 ++++++++++++++++++
 interfaces/Makefile.am         | 15 +++++++++++++--
 tests/Makefile.am              | 22 +++++++++++++++++++---
 tests/test_resource_copy_mpi.c |  2 ++
 6 files changed, 81 insertions(+), 5 deletions(-)
 create mode 100644 tests/test_resource_copy_mpi.c

diff --git a/app/Makefile.am b/app/Makefile.am
index d1ac60911..3b4b919d1 100644
--- a/app/Makefile.am
+++ b/app/Makefile.am
@@ -35,3 +35,18 @@ clean-local: clean-local-dirs
 .PHONY: clean-local-dirs
 clean-local-dirs:
 	-rm -rf *.dSYM
+
+# overrides to make regular compilations also use libtool
+COMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+        $(LIBTOOLFLAGS) --mode=compile $(CC) -static $(DEFS) \
+        $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+        $(AM_CFLAGS) $(CFLAGS)
+FCCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=FC $(AM_LIBTOOLFLAGS) \
+        $(LIBTOOLFLAGS) --mode=compile $(FC) -static $(AM_FCFLAGS) $(FCFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+        $(LIBTOOLFLAGS) --mode=compile $(CXX) -static $(DEFS) \
+        $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+        $(AM_CXXFLAGS) $(CXXFLAGS)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+	$(AM_LDFLAGS) $(LDFLAGS) -o $@
diff --git a/examples/Makefile.am b/examples/Makefile.am
index cad9a8acd..815912289 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -50,3 +50,17 @@ clean-local: clean-local-dirs
 .PHONY: clean-local-dirs
 clean-local-dirs:
 	-rm -rf *.dSYM
+
+# overrides to make regular compilations also use libtool
+# static because the libtool libraries in this directory are meant to
+# be statically linked and there is no use for the PIC object
+COMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+        $(LIBTOOLFLAGS) --mode=compile $(CC) -static $(DEFS) \
+        $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+        $(AM_CFLAGS) $(CFLAGS)
+FCCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=FC $(AM_LIBTOOLFLAGS) \
+        $(LIBTOOLFLAGS) --mode=compile $(FC) -static $(AM_FCFLAGS) $(FCFLAGS)
+CXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+        $(LIBTOOLFLAGS) --mode=compile $(CXX) -static $(DEFS) \
+        $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+        $(AM_CXXFLAGS) $(CXXFLAGS)
diff --git a/examples/pio/Makefile.am b/examples/pio/Makefile.am
index 79aed1549..b00a5a15f 100644
--- a/examples/pio/Makefile.am
+++ b/examples/pio/Makefile.am
@@ -33,3 +33,21 @@ clean-local: clean-local-dirs
 .PHONY: clean-local-dirs
 clean-local-dirs:
 	-rm -rf *.dSYM
+
+# overrides to make regular compilations also use libtool
+# static because the libtool libraries in this directory are meant to
+# be statically linked and there is no use for the PIC object
+COMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+        $(LIBTOOLFLAGS) --mode=compile $(CC) -static $(DEFS) \
+        $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+        $(AM_CFLAGS) $(CFLAGS)
+FCCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=FC $(AM_LIBTOOLFLAGS) \
+        $(LIBTOOLFLAGS) --mode=compile $(FC) -static $(AM_FCFLAGS) $(FCFLAGS)
+CXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+        $(LIBTOOLFLAGS) --mode=compile $(CXX) -static $(DEFS) \
+        $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+        $(AM_CXXFLAGS) $(CXXFLAGS)
+PPFCCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=FC $(AM_LIBTOOLFLAGS) \
+        $(LIBTOOLFLAGS) --mode=compile $(FC) -static $(DEFS) \
+        $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+        $(AM_FCFLAGS) $(FCFLAGS)
diff --git a/interfaces/Makefile.am b/interfaces/Makefile.am
index c8a56799c..f219e7c51 100644
--- a/interfaces/Makefile.am
+++ b/interfaces/Makefile.am
@@ -35,11 +35,10 @@ locallibs = $(abs_top_builddir)/src/.libs/libcdi.so @LTLIBOBJS@ @NETCDF_LIBS@ @S
 
 libcdipp_la_SOURCES = cdi.cpp cdi.hpp
 libcdipp_la_LIBADD  = $(top_builddir)/src/libcdi.la
-libcdipp_la_LDFLAGS = @NETCDF_LIBS@ @SZLIB_LIBS@ $(LDFLAGS)
+AM_LDFLAGS = @NETCDF_LIBS@ @SZLIB_LIBS@ $(LDFLAGS)
 
 CdiInfo_SOURCES     = CdiInfo.cpp
 CdiInfo_LDADD       = libcdipp.la
-CdiInfo_LDFLAGS     = @NETCDF_LIBS@ @SZLIB_LIBS@ $(LDFLAGS)
 
 mulval.nc: $(abs_top_srcdir)/interfaces/mulval.nc.gz
 	gunzip -c $< > $@
@@ -97,3 +96,15 @@ all-local: $(BINDINGS)
 test: $(BINDING_TESTS)
 #
 CLEANFILES  += `ls *~ *.o *.la`
+
+# overrides to make regular compilations also use libtool
+COMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+        $(LIBTOOLFLAGS) --mode=compile $(CC) -static $(DEFS) \
+        $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+        $(AM_CFLAGS) $(CFLAGS)
+FCCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=FC $(AM_LIBTOOLFLAGS) \
+        $(LIBTOOLFLAGS) --mode=compile $(FC) -static $(AM_FCFLAGS) $(FCFLAGS)
+CXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+        $(LIBTOOLFLAGS) --mode=compile $(CXX) -static $(DEFS) \
+        $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+        $(AM_CXXFLAGS) $(CXXFLAGS)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 4a3456ce3..eff281acd 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -52,7 +52,7 @@ pio_write_deco2d_SOURCES = pio_write.c pio_write.h deco2d_model.c \
 	pio_write_setup_grid.h pio_write_setup_grid.c
 test_resource_copy_SOURCES = test_resource_copy.c
 test_resource_copy_LDADD = ../src/libcdiresunpack.la $(LDADD)
-test_resource_copy_mpi_SOURCES = test_resource_copy.c
+test_resource_copy_mpi_SOURCES = test_resource_copy_mpi.c
 test_cdf_write_SOURCES = test_cdf_write.c \
 	simple_model_helper.h simple_model_helper.c
 test_cdf_read_SOURCES = test_cdf_read.c
@@ -66,8 +66,6 @@ pio_write_deco2d_LDADD = ../src/libcdipio.la ../src/libcdi.la $(PPM_CORE_LIBS) $
 TESTS +=  test_resource_copy_mpi_run
 check_PROGRAMS += test_resource_copy_mpi
 test_resource_copy_mpi_LDADD = ../src/libcdipio.la ../src/libcdi.la $(UUID_C_LIB)
-test_resource_copy_mpi_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS) \
-	-DMPI_MARSHALLING
 else
 pio_write_LDADD = $(LDADD)
 pio_write_deco2d_LDADD = $(LDADD)
@@ -87,3 +85,21 @@ clean-local: clean-local-dirs
 .PHONY: clean-local-dirs
 clean-local-dirs:
 	-rm -rf test_cdf_const.d *.dSYM
+
+# overrides to make regular compilations also use libtool
+# static because the libtool libraries in this directory are meant to
+# be statically linked and there is no use for the PIC object
+COMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+        $(LIBTOOLFLAGS) --mode=compile $(CC) -static $(DEFS) \
+        $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+        $(AM_CFLAGS) $(CFLAGS)
+FCCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=FC $(AM_LIBTOOLFLAGS) \
+        $(LIBTOOLFLAGS) --mode=compile $(FC) -static $(AM_FCFLAGS) $(FCFLAGS)
+CXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+        $(LIBTOOLFLAGS) --mode=compile $(CXX) -static $(DEFS) \
+        $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+        $(AM_CXXFLAGS) $(CXXFLAGS)
+PPFCCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=FC $(AM_LIBTOOLFLAGS) \
+        $(LIBTOOLFLAGS) --mode=compile $(FC) -static $(DEFS) \
+        $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+        $(AM_FCFLAGS) $(FCFLAGS)
diff --git a/tests/test_resource_copy_mpi.c b/tests/test_resource_copy_mpi.c
new file mode 100644
index 000000000..4c6679fde
--- /dev/null
+++ b/tests/test_resource_copy_mpi.c
@@ -0,0 +1,2 @@
+#define MPI_MARSHALLING
+#include "test_resource_copy.c"
-- 
GitLab