diff --git a/Makefile.am b/Makefile.am index a8d681f6a22..b4e5b17f5e6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -6,6 +6,7 @@ SUBDIRS = include #src AUTOMAKE_OPTIONS = subdir-objects ACLOCAL_AMFLAGS = -I m4 AM_CFLAGS = $(libmesh_CFLAGS) +AM_LDFLAGS = $(libmesh_LDFLAGS) # AM_CPPFLAGS are method-independent cppflags that # we use when compiling libmesh proper, or its utility diff --git a/configure.ac b/configure.ac index 28f14415d45..6d7a93ad94a 100644 --- a/configure.ac +++ b/configure.ac @@ -125,7 +125,10 @@ LIBMESH_SET_METHODS #----------------------------------------------------- LT_INIT([disable-static]) - +#----------------------------------------------------- +# See if the user requested --enable-all-static +#----------------------------------------------------- +AX_ALL_STATIC # -------------------------------------------------------------- # Release versioning - after we find the C++ compiler diff --git a/contrib/Make.common b/contrib/Make.common index d3b2528596b..e259c92723a 100644 --- a/contrib/Make.common +++ b/contrib/Make.common @@ -10,6 +10,7 @@ AUTOMAKE_OPTIONS = subdir-objects AM_CPPFLAGS = $(pkg_cppflags) # any defined package-specific include paths AM_CFLAGS = AM_CXXFLAGS = +AM_LDFLAGS = $(libmesh_LDFLAGS) ###################################################################### # diff --git a/contrib/Makefile.am b/contrib/Makefile.am index d53c95c1d1a..ca95e368e86 100644 --- a/contrib/Makefile.am +++ b/contrib/Makefile.am @@ -9,6 +9,10 @@ devel_libs = prof_libs = oprof_libs = +# Doesn't seem to be used directly in this Makefile; add +# it in case someone includes this Makefile? +AM_LDFLAGS = $(libmesh_LDFLAGS) + if LIBMESH_INSTALL_INTERNAL_BOOST SUBDIRS += boost/include endif diff --git a/examples/Make.common b/examples/Make.common index 08ec6868aa4..7185c8fc9d4 100644 --- a/examples/Make.common +++ b/examples/Make.common @@ -11,6 +11,7 @@ AUTOMAKE_OPTIONS = subdir-objects AM_CPPFLAGS = $(libmesh_optional_INCLUDES) -I$(top_builddir)/include AM_CFLAGS = $(libmesh_CFLAGS) AM_CXXFLAGS = $(libmesh_CXXFLAGS) +AM_LDFLAGS = $(libmesh_LDFLAGS) LIBS = $(libmesh_optional_LIBS) examples_source_path = $(top_srcdir)/examples diff --git a/examples/Makefile.am b/examples/Makefile.am index 028ac63e2ed..6aadcf7617b 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -57,6 +57,7 @@ AM_CPPFLAGS = $(libmesh_CPPFLAGS) AM_CFLAGS = $(libmesh_CFLAGS) AM_CXXFLAGS = $(libmesh_CXXFLAGS) AM_CPPFLAGS += $(libmesh_optional_INCLUDES) -I$(top_builddir)/include +AM_LDFLAGS = $(libmesh_LDFLAGS) LIBS = $(libmesh_optional_LIBS) examples_source_path = $(top_srcdir)/examples diff --git a/m4/all_static.m4 b/m4/all_static.m4 new file mode 100644 index 00000000000..669733b74de --- /dev/null +++ b/m4/all_static.m4 @@ -0,0 +1,25 @@ +# Configure option to pass -all-static to libtool's link mode. So +# far, this was only required on the BG/Q machine Mira to get static +# linking to work. Off by default. Other than LDFLAGS, AM_LDFLAGS +# seems to be the only flag that makes it into the Makefile.in files +# after the --mode=link arguments to libtool. +AC_DEFUN([AX_ALL_STATIC], +[ + AC_ARG_ENABLE(all-static, + [AC_HELP_STRING([--enable-all-static],[Pass -all-static to libtool's link mode])], + enableallstatic=$enableval, + enableallstatic=no) + + if (test $enableallstatic = yes); then + if (test "x$libmesh_LDFLAGS" != x) ; then + # Append to whatever the user has for libmesh_LDFLAGS in their environment + libmesh_LDFLAGS="$libmesh_LDFLAGS -all-static" + else + # Set libmesh_LDFLAGS to -all-static + libmesh_LDFLAGS=-all-static + fi + + # Substitute into Makefiles where relevant. + AC_SUBST(libmesh_LDFLAGS) + fi +]) diff --git a/tests/Makefile.am b/tests/Makefile.am index ee69fbcb66b..444e17f4d76 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -5,6 +5,7 @@ AM_CFLAGS = $(libmesh_CFLAGS) AM_CPPFLAGS = $(libmesh_optional_INCLUDES) -I$(top_builddir)/include \ $(libmesh_contrib_INCLUDES) $(CPPUNIT_CFLAGS) \ -DLIBMESH_IS_UNIT_TESTING +AM_LDFLAGS = $(libmesh_LDFLAGS) LIBS = $(libmesh_optional_LIBS) $(CPPUNIT_LIBS) unit_tests_sources = \