Skip to content
Snippets Groups Projects
Commit 53544de9 authored by Jorrit Fahlke's avatar Jorrit Fahlke
Browse files

Merge the LDFLAGS stuff done so far to trunk. This consists mainly of

 * Documentation of the various autoconf/configure/automake
   variables/substitutions in the buildsytem doc.

 * Move of the MPI detection to better defined variables.

[[Imported from SVN: r5816]]
parents 1a20bd97 306c4c41
No related branches found
No related tags found
No related merge requests found
......@@ -496,8 +496,31 @@ noinst_PROGRAMS = ${CMODULE}
${CMODULE}_SOURCES = $CMODULE.cc
${CMODULE}_CXXFLAGS = \$(MPI_CPPFLAGS) \$(UG_CPPFLAGS) \$(AMIRAMESH_CPPFLAGS) \$(ALBERTA_CPPFLAGS) \$(ALUGRID_CPPFLAGS)
${CMODULE}_LDADD = \$(MPI_LDFLAGS) \$(ALBERTA_LDFLAGS) \$(ALBERTA_LIBS) \$(ALUGRID_LDFLAGS) \$(ALUGRID_LIBS) \$(AMIRAMESH_LDFLAGS) \$(AMIRAMESH_LIBS) \$(UG_LDFLAGS) \$(UG_LIBS) \$(MPI_LDFLAGS) \$(DUNE_LDFLAGS) \$(DUNE_LIBS)
${CMODULE}_CXXFLAGS = \$(AM_CXXFLAGS) \\
\$(DUNEMPICPPFLAGS) \\
\$(UG_CPPFLAGS) \\
\$(AMIRAMESH_CPPFLAGS) \\
\$(ALBERTA_CPPFLAGS) \\
\$(ALUGRID_CPPFLAGS)
# The libraries have to be given in reverse order (most basic libraries
# last). Also, due to some misunderstanding, a lot of libraries include the
# -L option in LDFLAGS instead of LIBS -- so we have to include the LDFLAGS
# here as well.
${CMODULE}_LDADD = \\
\$(DUNE_LDFLAGS) \$(DUNE_LIBS) \\
\$(ALUGRID_LDFLAGS) \$(ALUGRID_LIBS) \\
\$(ALBERTA_LDFLAGS) \$(ALBERTA_LIBS) \\
\$(AMIRAMESH_LDFLAGS) \$(AMIRAMESH_LIBS) \\
\$(UG_LDFLAGS) \$(UG_LIBS) \\
\$(DUNEMPILIBS) \\
\$(LDADD)
${CMODULE}_LDFLAGS = \$(AM_LDFLAGS) \\
\$(DUNEMPILDFLAGS) \\
\$(UG_LDFLAGS) \\
\$(AMIRAMESH_LDFLAGS) \\
\$(ALBERTA_LDFLAGS) \\
\$(ALUGRID_LDFLAGS) \\
\$(DUNE_LDFLAGS)
# don't follow the full GNU-standard
# we need automake 1.5
......
......@@ -104,6 +104,9 @@ while test $# -gt 0 ; do
--cflags)
tasks="$tasks print_cflags"
;;
--ldflags)
tasks="$tasks print_ldflags"
;;
--libs)
tasks="$tasks print_libs"
;;
......@@ -169,14 +172,19 @@ print_mpiversion() {
print_cflags() {
get_mpiparameters
if test x$disablecxx = xyes; then
MPI_CPPFLAGS="$MPI_CPPFLAGS $MPI_NOCXXFLAGS"
DUNEMPICPPFLAGS="$DUNEMPICPPFLAGS $MPI_NOCXXFLAGS"
fi
echo $MPI_CPPFLAGS
echo $DUNEMPICPPFLAGS
}
print_ldflags() {
get_mpiparameters
echo $DUNEMPILDFLAGS
}
print_libs() {
get_mpiparameters
echo $MPI_LDFLAGS
echo $DUNEMPILIBS
}
for task in $tasks; do
......
......@@ -527,25 +527,332 @@ user wishes to modify the values, you should use the \texttt{AM\_*}
version.
The real compile-command always uses both \texttt{AM\_\textit{VAR}} and
\texttt{\textit{VAR}}. Options that
\texttt{\textit{VAR}} (or \texttt{\texttt{progname}\_\textit{VAR}} and
\texttt{\textit{VAR}}). Options that
autoconf finds are stored in the user variables (so that they may be
overridden)
overridden).
Besides the three types of variables mentioned so far (user-, automake- and
program-variables) there exists a fourth type by convention: variables of
dependend libraries. These variables have the form
\texttt{\textit{LIBRARY}\_\textit{VAR}} and contain flags neccessary to build
programs or libraries which depend on that library. They are usually included
in \texttt{\textit{program}\_\textit{VAR}}, like this:
\begin{lstlisting}[language=make]
foo_CPPFLAGS = $(AM_CPPFLAGS) $(SUPERLU_CPPFLAGS)
\end{lstlisting}
If all programs build by the same makefile depend on a library,
\texttt{\textit{program}\_\textit{VAR}} can be included in
\texttt{AM\_\textit{VAR}} instead:
\begin{lstlisting}[language=make]
AM_CPPFLAGS = @AM_CPPFLAGS@ $(SUPERLU_CPPFLAGS)
\end{lstlisting}
%$\end{lstlisting}
There are five classes of variables in automake-generated makefiles:
\begin{description}
\item[automake] Example: \texttt{AM\_CPPFLAGS}. These variables are usually
undefined by default and the developer may assign them default values in the
\texttt{Makefile.am}:
\begin{lstlisting}[language=make]
AM_CPPFLAGS = -DMY_DIR=`pwd`
\end{lstlisting}
{\bf Automake} variables are not automatically substituted by
\texttt{configure}, though it is common for the developer to
\lstinline[language=make]{AC_SUBST} them. In this case a different
technique must be used to assign values to them, or the substituted value
will be ignored. See the {\bf configure-substituted} class below. The
names of {\bf automake} variables begin with \texttt{AM\_} most of the time,
but there are some variables which don't have that prefix. These variables
give defaults for {\bf target-specific} variables.
\item[configure-substituted] Example: \lstinline[language=make]{srcdir}.
Anything can be made a {\bf configure-substituted} variable by calling
\lstinline[language=sh]{AC_SUBST} in \texttt{configure.ac}. Some
variables always substituted by autoconf\footnote{autoconf manual, section
``Preset Output Variables''} or automake, others are only substituted when
certain autoconf macros are used. In Dune, it is quiet common to substitute
{\bf automake} variables:
\begin{lstlisting}[language=sh]
AC_SUBST(AM_CPPFLAGS, $DUNE_CPPFLAGS)
\end{lstlisting}
%$\end{lstlisting}
The value substituted by \texttt{configure} can be augmented in the
\texttt{Makefile.am} like this:
\begin{lstlisting}[language=make]
AM_CPPFLAGS = @AM_CPPFLAGS@ -DMY_DIR=`pwd`
\end{lstlisting}
\item[target-specific] Example: \texttt{\textit{target}\_CPPFLAGS}. The names
of these variables are of the form canonical target name followed by an
underscore followed some uppercase letters. If there is a {\bf automake}
variable corresponding to this {\bf target-specific} variable, the uppercase
letters at the end of the name usually correspond to the name of that {\bf
automake} variable. These variables provide target-specific information.
They are defined by the developer in the \texttt{Makefile.am} and are
documented in the automake manual. If there is corresponding a {\bf
automake} variable it provides a default which is used when the {\bf
target-specific} variable is not defined. Example definition:
\begin{lstlisting}[language=make]
false_SOURCES = true.c
false_CPPFLAGS = $(AM_CPPFLAGS) -DEXIT_CODE=1
\end{lstlisting}
%$\end{lstlisting}
This example also shows how to include the value of the corresponding {\bf
automake} variable.
\item[user] Example: \texttt{CPPFLAGS}. These variables are for the user to
set on the make command line:
\begin{lstlisting}[language=sh]
make CPPFLAGS=-DNDEBUG
\end{lstlisting}
They usually augment some {\bf target-specific} or {\bf makefile-default}
variable in the build rules. Often these variables are {\em
precious}\footnote{autoconf manual,
\lstinline[language=sh]{AC_ARG_VAR}}, and the user can tell
\texttt{configure} what values these variables should have. These variables
are {\bf configure-substituted}.
The developer should never set this
variables in the \texttt{Makefile.am}, because that would override the
user-provided values given to configure. Instead, \texttt{configure.ac}
must be tweaked to set a different default if the user does not give a value
to \texttt{configure}.
\item[external-library] Example: \texttt{\textit{LIB}CPPFLAGS}. These
variables contain settings needed when using external libraries in a
target. They should be included in the value for the corresponding {\bf
target-specific} variable
\begin{lstlisting}[language=make]
testprog_CPPFLAGS = $(AM_CPPFLAGS) $(SUPERLUCPPFLAGS)
\end{lstlisting}
or the {\bf makefile-default} variable
\begin{lstlisting}[language=make]
AM_CPPFLAGS = @AM_CPPFLAGS@ $(SUPERLUCPPFLAGS)
\end{lstlisting}
%$\end{lstlisting}
Values for these variables are determined by \texttt{configure}, thus they
are {\bf configure-substituted}. Usually,
\texttt{configure.ac} must call the right autoconf macro to determine these
variables.
Note that the variable name with an underscore
\texttt{\textit{LIB}\_CPPFLAGS} is not recommended\footnote{Autoconf
manual, section ``Flag Variables Ordering''}, although this pattern is
common.
\end{description}
Commonly used variables are:
\begin{itemize}
\item \texttt{AM\_CPPFLAGS}: flags for the C-Preprocessor. This
includes preprocessor defines like \texttt{-DNDEBUG} and include
pathes like \texttt{-I/usr/local/package/include}
\item \texttt{AM\_CFLAGS}, \texttt{AM\_CXXFLAGS}: flags for the
compiler (-g, -O, ...). One difference between these and the
\texttt{CPPFLAGS} is that the linker will get
\texttt{CFLAGS}/\texttt{CXXFLAGS} and \texttt{LDFLAGS} but not
\texttt{CPPFLAGS}
\item \texttt{AM\_LDFLAGS} options for the linker
\item \texttt{LDADD}: libraries to link to a binary
\item \texttt{LIBADD}: libraries to add to a library
\item \texttt{SOURCES}: list of source-files (may include headers as well)
\end{itemize}
\begin{description}
\item[preprocessor flags] These flags are passed in any build rule that calls
the preprocessor. If there is a {\bf target-specific} variable
\texttt{\textit{target}\_CPPFLAGS} defined, the flags are given by
\begin{lstlisting}[language=make]
$(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(target_CPPFLAGS) $(CPPFLAGS)
\end{lstlisting}
%$\end{lstlisting}
otherwise
\begin{lstlisting}[language=make]
$(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS)
\end{lstlisting}
%$\end{lstlisting}
is used.
\begin{description}
\item[\texttt{DEFS}] Class: {\bf configure-substituted}. Contains all the
preprocessor defines from \lstinline[language=sh]{AC_DEFINE} and friends.
If a \texttt{config.h} header is used, contains just the value
\texttt{-DHAVE\_CONFIG\_H} instead.
\item[\texttt{DEFAULT\_INCLUDES}] Class: {\bf configure-substituted}. This
variables contains a set of default include paths: \texttt{-I.},
\texttt{-I\$(srcdir)}, and an path to the directory of \texttt{config.h},
if that is used.
\item[\texttt{INCLUDES}] Class: {\bf automake}. This is an obsolete
alternative to \texttt{AM\_CPPFLAGS}. Use that instead.
\item[\texttt{\textit{target}\_CPPFLAGS}] Class: {\bf target-specific}.
Target-specific preprocessor flags. If this variable exists, it overrides
\texttt{AM\_CPPFLAGS} and causes the renaming of object
files\footnote{automake manual, ``Why are object files sometimes
renamed?''}.
\item[\texttt{AM\_CPPFLAGS}] Class: {\bf automake}. This is the makefile
default for any preprocessor flags.
\item[\texttt{CPPFLAGS}] Class: {\bf user}, {\bf configure-substituted}.
Flags given by the user, either to \texttt{configure} or when invoking
\texttt{make}. If the user didn't provide any value to
\texttt{configure}, it may contain debugging and optimization options per
default (like \texttt{-DNDEBUG}). The value of \texttt{CPPFLAGS} always
appears after the other preprocessor flags.
\item[\texttt{\textit{LIB}CPPFLAGS}] Class: {\bf external-library}.
Preprocessor flags when building with library \textit{LIB}. This variable
should be include in \texttt{\textit{target}\_CPPFLAGS} or
\texttt{AM\_CPPFLAGS} in the \texttt{Makefile.am}.
\end{description}
\item[C-compiler flags] These flags are passed in any build rule that calls
the C compiler or the C linker. If there is a {\bf target-specific}
variable \texttt{\textit{target}\_CFLAGS} defined, the flags are given by
\begin{lstlisting}[language=make]
$(target_CFLAGS) $(CFLAGS)
\end{lstlisting}
otherwise
\begin{lstlisting}[language=make]
$(AM_CFLAGS) $(CFLAGS)
\end{lstlisting}
is used.
\begin{description}
\item[\texttt{\textit{target}\_CFLAGS}] Class: {\bf target-specific}.
Target-specific C compiler flags. If this variable exists, it overrides
\texttt{AM\_CFLAGS} and causes the renaming of object
files\footnote{automake manual, ``Why are object files sometimes
renamed?''}.
\item[\texttt{AM\_CFLAGS}] Class: {\bf automake}. This is the makefile
default for any C compiler flags.
\item[\texttt{CFLAGS}] Class: {\bf user}, {\bf configure-substituted}.
Flags given by the user, either to \texttt{configure} or when invoking
\texttt{make}. If the user didn't provide any value to
\texttt{configure}, it may contain debugging, optimization and warning
options per default (like \texttt{-g -O2 -Wall}). The value of
\texttt{CFLAGS} always appears after the other C compiler flags.
\end{description}
\item[C++-compiler flags] These flags are passed in any build rule that calls
the C++ compiler or the C++ linker. If there is a {\bf target-specific}
variable \texttt{\textit{target}\_CXXFLAGS} defined, the flags are given by
\begin{lstlisting}[language=make]
$(target_CXXFLAGS) $(CXXFLAGS)
\end{lstlisting}
otherwise
\begin{lstlisting}[language=make]
$(AM_CXXFLAGS) $(CXXFLAGS)
\end{lstlisting}
is used.
\begin{description}
\item[\texttt{\textit{target}\_CXXFLAGS}] Class: {\bf target-specific}.
Target-specific C++ compiler flags. If this variable exists, it overrides
\texttt{AM\_CXXFLAGS} and causes the renaming of object
files\footnote{automake manual, ``Why are object files sometimes
renamed?''}.
\item[\texttt{AM\_CXXFLAGS}] Class: {\bf automake}. This is the makefile
default for any C++ compiler flags.
\item[\texttt{CXXFLAGS}] Class: {\bf user}, {\bf configure-substituted}.
Flags given by the user, either to \texttt{configure} or when invoking
\texttt{make}. If the user didn't provide any value to
\texttt{configure}, it may contain debugging, optimization and warning
options per default (like \texttt{-g -O2 -Wall}). The value of
\texttt{CXXFLAGS} always appears after the other C++ compiler flags.
\end{description}
\item[linker flags] These flags are passed in any build rule that calls the
linker. If there is a {\bf target-specific} variable
\texttt{\textit{target}\_LDFLAGS} defined, the flags are given by
\begin{lstlisting}[language=make]
$(target_LDFLAGS) $(LDFLAGS)
\end{lstlisting}
otherwise
\begin{lstlisting}[language=make]
$(AM_LDFLAGS) $(LDFLAGS)
\end{lstlisting}
is used. These variables are inapropriate to pass any options or parameters
that specify libraries of object files, in particular \texttt{-L} or
\texttt{-l} or the libtool options \texttt{-dlopen} and \texttt{-dlpreopen}.
Use a variable from the {\em libraries to link to} set to do that.
\begin{description}
\item[\texttt{\textit{target}\_LDFLAGS}] Class: {\bf target-specific}.
Target-specific C++ compiler flags. If this variable exists, it overrides
\texttt{AM\_LDFLAGS}. The existance of this variable does {\em not} cause
renaming of object files\footnote{automake manual, ``Why are object files
sometimes renamed?''}.
\item[\texttt{AM\_LDFLAGS}] Class: {\bf automake}. This is the makefile
default for any linker flags.
\item[\texttt{LDFLAGS}] Class: {\bf user}, {\bf configure-substituted}.
Flags given by the user, either to \texttt{configure} or when invoking
\texttt{make}. If the user didn't provide any value to
\texttt{configure}, it may contain debugging, optimization and warning
options per default. The value of \texttt{LDFLAGS} always appears after
the other linker flags.
\item[\texttt{\textit{LIB}LDFLAGS}] Class: {\bf external-library}. Linker
flags needed when linking to library \textit{LIB}. This variable should
be include in \texttt{\textit{target}\_LDFLAGS} or \texttt{AM\_LDFLAGS} in
the \texttt{Makefile.am}.
\end{description}
\item[libraries to link to] These variables are used to determine the
libraries and object files to link to. They are passed whenever the linker
is called. When
linking a program, extra libraries and objects to link to are given by
\begin{lstlisting}[language=make]
$(target_LDADD) $(LIBS)
\end{lstlisting}
If the {\bf target-specific} variable \texttt{\textit{target}\_LDADD} is not
defined, automake supplies
\begin{lstlisting}[language=make]
target_LDADD = $(LDADD)
\end{lstlisting}
%$\end{lstlisting}
When linking a library, extra libraries and objects to link to are given by
\begin{lstlisting}[language=make]
$(target_LIBADD) $(LIBS)
\end{lstlisting}
If the {\bf target-specific} variable \texttt{\textit{target}\_LIBADD} is
not defined, automake defines it empty
\begin{lstlisting}[language=make]
target_LIBADD =
\end{lstlisting}
Libraries and objects to link to must be given in reverse order: a library
or object file must come before the libraries or object files it depends on
on the linker command line. Thus the value of the \texttt{LIBS} variable is
included after the value of the \texttt{\textit{target}\_LDADD} or
\texttt{\textit{target}\_LIBADD} variable.
In general, any linker flags and argument that specify libraries and object
files should be included in these variables, and nothing else. In
particular that means library and object file names, the options \texttt{-L}
and \texttt{-l}, and the libtool options \texttt{-dlopen} and
\texttt{-dlpreopen}. The option \texttt{-L} should come directly before any
\texttt{-l} options it sets the linker path for, otherwise a path set by
another \texttt{-L} option may take precedence, which may happen to contain
a library by the same name.
\begin{description}
\item[\texttt{\textit{target}\_LDADD}] Class: {\bf target-specific}.
Target-specific libraries and objects to link to {\em for programs}. If
this variable does not exist, it defaults to \texttt{\$(LDADD)}.
\item[\texttt{LDADD}] Class: {\bf automake}. Libraries and objects
to link to {\em for programs}. Default for
\texttt{\textit{target}\_LDADD}.
\item[\texttt{\textit{target}\_LIBADD}] Class: {\bf target-specific}.
Target-specific objects to link to {\em for libraries}. If the target is
a libtool library, then other libtool libraries may also be specified
here. This variable has no makefile-wide default, if it does not exist
the empty value is assumed.
\item[\texttt{LIBS}] Class: {\bf automake}, {\bf configure-substituted}.
Libraries discovered by configure.
\item[\texttt{\textit{LIB}LIBS}] Class: {\bf external-library}. Libraries
and object files needed to linking against library \textit{LIB}, including
that library itself. This variable should be include in
\texttt{\textit{target}\_LDADD}, \texttt{LDADD}, or
\texttt{\textit{target}\_LIBADD} in the \texttt{Makefile.am}.
\end{description}
\end{description}
\minisec{Individual library variables}
\begin{description}
\item[MPI] The \texttt{DUNE\_MPI} macro sets the following variables with the
help of the macros \texttt{ACX\_MPI} and \texttt{MPI\_CONFIG}: For
compilation with the MPI compiler \texttt{MPICC} and \texttt{MPILIBS}.
These are not used in \dune except that \texttt{MPICC} may be set on the
configure command line to select which MPI installation to use. For
compilation with the standard compiler it sets \texttt{DUNEMPICPPFLAGS},
\texttt{DUNEMPILDFLAGS} and \texttt{DUNEMPILIBS}, and the deprecated
variables \texttt{MPI\_CPPFLAGS} and \texttt{MPI\_LDFLAGS} (note there is no
\texttt{MPI\_LIBS}). Unfortunately with most MPI implementations it is
impossible to obtain the linker flags seperately from the libraries to link
to. Therefore, this macro stuffs everything into \texttt{DUNEMPILIBS},
which has the advantage that it works and the disavantage that users are
unable to overwrite the linker flags. If that is a problem users should set
these variables themselves on the configure command line.
In addition, this macro substitutes \texttt{MPI\_VERSION} a text string
identifying the detected version of MPI. It defines the following
preprocessor defines: \texttt{MPI\_2}, defined if the detected MPI supports
the MPI-2 standard. \texttt{HAVE\_MPI}, 1 if MPI is detected and enabled.
It also defines the automake conditional \texttt{MPI}.
\end{description}
\minisec{Conditional builds}
......
......@@ -39,7 +39,7 @@ check_PROGRAMS = $(TESTPROGS)
noinst_HEADERS = dummyiterator.hh
AM_LDFLAGS = $(LOCAL_LIBS)
LDADD = $(LOCAL_LIBS)
# define the programs
smallobject_SOURCES = smallobject.cc
......@@ -48,7 +48,7 @@ bitsetvectortest_SOURCES = bitsetvectortest.cc
nullptr_test_SOURCES = nullptr-test.cc nullptr-test2.cc
nullptr_test_fail_SOURCES = nullptr-test.cc
nullptr_test_fail_CPPFLAGS = -DFAIL
nullptr_test_fail_CPPFLAGS = $(AM_CPPFLAGS) -DFAIL
static_assert_test_SOURCES = static_assert_test.cc
static_assert_test_fail_SOURCES = static_assert_test_fail.cc
......@@ -90,18 +90,18 @@ settest_SOURCES=settest.cc
gcdlcmtest_SOURCES = gcdlcmtest.cc
mpihelpertest_SOURCES = mpihelpertest.cc
mpihelpertest_CXXFLAGS = $(MPI_CPPFLAGS)
mpihelpertest_LDFLAGS = $(LOCAL_LIBS) $(MPI_LDFLAGS) $(MPI_LIBS)
mpihelpertest_CPPFLAGS = $(AM_CPPFLAGS) $(DUNEMPICPPFLAGS)
mpihelpertest_LDADD = $(DUNEMPILIBS) $(LDADD)
mpihelpertest_LDFLAGS = $(AM_LDFLAGS) $(DUNEMPILDFLAGS)
mpicollcomm_SOURCES = mpicollectivecommunication.cc
mpicollcomm_CXXFLAGS = $(MPI_CPPFLAGS)
mpicollcomm_LDFLAGS = $(LOCAL_LIBS) $(MPI_LDFLAGS) $(MPI_LIBS)
mpicollcomm_CPPFLAGS = $(AM_CPPFLAGS) $(DUNEMPICPPFLAGS)
mpicollcomm_LDADD = $(DUNEMPILIBS) $(LDADD)
mpicollcomm_LDFLAGS = $(AM_LDFLAGS) $(DUNEMPILDFLAGS)
singletontest_SOURCES = singletontest.cc
singletontest_LDFLAGS = $(LOCAL_LIBS)
utilitytest_SOURCES = utilitytest.cc
utilitytest_LDFLAGS = $(LOCAL_LIBS)
testfassign1_SOURCES = testfassign.cc testfassign2.cc
testfassign1_CPPFLAGS = $(AM_CPPFLAGS) -D_N=3 -D_VALUES="1,2,3"
......
......@@ -2,7 +2,12 @@
ALLM4S = acx_blas.m4 acx_lapack.m4 acx_mpi.m4 acx_pthread.m4 \
ax_check_gl.m4 ax_lang_compiler_ms.m4 dune_all.m4 \
dune_autobuild.m4 dune_common.m4 dune_compiler.m4 dune_deprecated.m4 \
dune_autobuild.m4 \
dune_check_lib.m4 \
dune_common.m4 \
dune_compiler.m4 \
dune_deprecated.m4 \
dune_deprecated_cppflags.m4 \
dune_docu.m4 dune_exprtmpl.m4 dune_linkcxx.m4 \
dune.m4 \
dune_mpi.m4 dune_streams.m4 \
......
dnl -*- autoconf -*-
# Just like AC_CHECK_LIB, but in allow a library path to be specified. The
# default ACTION-IF-FOUND is extended to also add that library path to LIBS.
#
# DUNE_CHECK_LIB_EXT(PATH, LIBRARY, FUNCTION, [ACTION-IF-FOUND],
# [ACTION-IF-NOT-FOUND], [OTHER-LIBRARIES])
AC_DEFUN([DUNE_CHECK_LIB_EXT],
[
dune_cle_save_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS -L$1"
m4_ifelse(m4_eval([$# <= 3]), [1],
[AC_CHECK_LIBS([$2], [$3],
[
LIBS="-L$1 -l$2 $LIBS"
AC_DEFINE([HAVE_LIB]m4_translit([[$2]], [-a-z], [_A-Z]), [1],
[Define to 1 if you have the `$2' library (-l$2).])
])],
[AC_CHECK_LIBS(m4_shift($@))])
LDFLAGS="$dune_cle_save_LDFLAGS"
])
dnl -*- autoconf -*-
# Define configure substitution SUBSTITUTION. Assign value to it but add an
# additional preprocessor define which may be detected by config.h. Add some
# text to config.h which detects that define and issues the warning in
# message.
#
# DUNE_DEPRECATED_CPPFLAGS(SUBSTITUTION, VALUE, MESSAGE)
AC_DEFUN([DUNE_DEPRECATED_CPPFLAGS],
[
AH_VERBATIM([DEPRECATED_$1_USED],
[#ifdef DEPRECATED_$1_USED
#warning $3
#endif])
AC_SUBST([$1], [$2" -D DEPRECATED_$1_USED"])
])
dnl -*- autoconf -*-
# $Id$
# wrapper for the autoconf-archive check. Note: compiling MPI-stuff sucks!
......@@ -50,6 +51,39 @@
# --disable-parallel
# [Christian 9.7.2006]
# DUNE_MPI()
#
# With the help of ACX_MPI find the MPI compiler, and with the help of
# MPI_CONFIG find the libraries and compiler and linker options necessary to
# compile MPI programs with the standard compiler. Will set the following
# things:
#
# configure shell variables:
# MPICC
# MPILIBS
# DUNEMPICPPFLAGS
# DUNEMPILDFLAGS
# DUNEMPILIBS
# MPI_CPPFLAGS (deprecated in favor of DUNEMPICPPFLAGS)
# MPI_LDFLAGS (deprecated in favor of DUNEMPILIBS and DUNEMPILDFLAGS)
# dune_MPI_VERSION
# with_mpi
#
# configure substitutions/Makefile variables
# MPICC
# MPILIBS
# DUNEMPICPPFLAGS
# DUNEMPILDFLAGS
# DUNEMPILIBS
# MPI_CPPFLAGS (deprecated in favor of DUNEMPICPPFLAGS)
# MPI_LDFLAGS (deprecated in favor of DUNEMPILIBS and DUNEMPILDFLAGS)
# MPI_VERSION (set from dune_MPI_VERSION)
#
# preprocessor defines
# HAVE_MPI (defined when $with_mpi!=no)
#
# automake conditionals
# MPI (true when $with_mpi!=no)
AC_DEFUN([DUNE_MPI],[
AC_PREREQ(2.50) dnl for AC_LANG_CASE
......@@ -84,7 +118,7 @@ AC_DEFUN([DUNE_MPI],[
MPICOMP="$MPICC"
MPI_CONFIG()
MPI_CPPFLAGS="$MPI_CPPFLAGS $MPI_NOCXXFLAGS -DENABLE_MPI=1"
DUNEMPICPPFLAGS="$DUNEMPICPPFLAGS $MPI_NOCXXFLAGS -DENABLE_MPI=1"
with_mpi="yes ($dune_MPI_VERSION)"
],[
......@@ -99,12 +133,14 @@ AC_DEFUN([DUNE_MPI],[
# store old values
ac_save_LIBS="$LIBS"
ac_save_LDFLAGS="$LDFLAGS"
ac_save_CPPFLAGS="$CPPFLAGS"
# looks weird but as the -l... are contained in the MPI_LDFLAGS these
# parameters have to be last on the commandline: with LIBS this is true
LIBS="$MPI_LDFLAGS"
CPPFLAGS="$CPPFLAGS $MPI_CPPFLAGS"
LIBS="$DUNEMPILIBS $LIBS"
LDFLAGS="$LDFLAGS $DUNEMPILDFLAGS"
CPPFLAGS="$CPPFLAGS $DUNEMPICPPFLAGS"
# try to create MPI program
AC_LANG_PUSH([C++])
......@@ -122,7 +158,7 @@ AC_DEFUN([DUNE_MPI],[
)
AS_IF([test "x$mpiruntest" != "xyes"],[
AC_MSG_WARN([Diabled test whether running with $dune_MPI_VERSION works.])
AC_MSG_WARN([Disabled test whether running with $dune_MPI_VERSION works.])
],[
AC_MSG_CHECKING([whether running with $dune_MPI_VERSION works])
AC_RUN_IFELSE(
......@@ -159,16 +195,21 @@ AC_DEFUN([DUNE_MPI],[
# set flags
AS_IF([test "x$with_mpi" != "xno"],[
AC_SUBST(MPI_CPPFLAGS, $MPI_CPPFLAGS)
AC_SUBST(MPI_LDFLAGS, $MPI_LDFLAGS)
AC_SUBST(MPI_VERSION, $dune_MPI_VERSION)
MPI_LDFLAGS="$DUNEMPILDFLAGS $DUNEMPILIBS"
AC_DEFINE(HAVE_MPI,ENABLE_MPI,[Define if you have the MPI library.
This is only true if MPI was found by configure
_and_ if the application uses the MPI_CPPFLAGS])
This is only true if MPI was found by configure _and_ if the application
uses the DUNEMPICPPFLAGS (or the deprecated MPI_CPPFLAGS)])
],[
AC_SUBST(MPI_CPPFLAGS, "")
AC_SUBST(MPI_LDFLAGS, "")
MPI_LDFLAGS=""
])
AC_SUBST(DUNEMPICPPFLAGS)
AC_SUBST(DUNEMPILDFLAGS)
AC_SUBST(DUNEMPILIBS)
AC_SUBST(MPI_VERSION, $dune_MPI_VERSION)
DUNE_DEPRECATED_CPPFLAGS(MPI_CPPFLAGS, "$DUNEMPICPPFLAGS",
[The MPI_CPPFLAGS configure substitute is deprecated. Please change your Makefile.am to use DUNEMPICPPFLAGS instead. Note that it is a good idea to change any occurance of MPI_LDFLAGS into DUNEMPILIBS and DUNEMPILDFLAGS as apropriate, since it is not possible to issue a deprecation warning in that case.])
AC_SUBST(MPI_LDFLAGS)
AM_CONDITIONAL(MPI, [test "x$with_mpi" != "xno"])
......
......@@ -39,9 +39,9 @@ AC_DEFUN([DUNE_PATH_HDF5],[
# test if we are parallel
AC_CHECK_DECL(H5_HAVE_PARALLEL, [dnl
LIBS="$LIBS $MPI_LIB"
LDFLAGS="$LDFLAGS $MPI_LDFLAGS"
CPPFLAGS="$CPPFLAGS $MPI_CPPFLAGS"
LIBS="$DUNEMPILIBS $LIBS"
LDFLAGS="$LDFLAGS $DUNEMPILDFLAGS"
CPPFLAGS="$CPPFLAGS $DUNEMPICPPFLAGS"
HDF5_PARALLEL=1],[],[#include"H5pubconf.h"])
# test for an arbitrary header
......
......@@ -52,16 +52,24 @@ _EOF
# seems like LAM >= 7.1 which supports extraction of parameters without
# dummy files
dune_MPI_VERSION="LAM >= 7.1"
MPI_CPPFLAGS="$retval"
mpi_getflags "-showme:link"
MPI_LDFLAGS="$retval"
if test x"$DUNEMPICPPFLAGS" = x; then
DUNEMPICPPFLAGS="$retval"
fi
if test x"$DUNEMPILIBS" = x; then
mpi_getflags "-showme:link"
DUNEMPILIBS="$retval"
fi
else
dune_MPI_VERSION="LAM < 7.1"
# use -showme and dummy parameters to extract flags
mpi_getflags "-showme" "-c $MPISOURCE"
MPI_CPPFLAGS="$retval"
mpi_getflags "-showme" "dummy.o -o dummy"
MPI_LDFLAGS="$retval"
if test x"$DUNEMPICPPFLAGS" = x; then
mpi_getflags "-showme" "-c $MPISOURCE"
DUNEMPICPPFLAGS="$retval"
fi
if test x"$DUNEMPILIBS" = x; then
mpi_getflags "-showme" "dummy.o -o dummy"
DUNEMPILIBS="$retval"
fi
fi
# hack in option to disable LAM-C++-bindings...
# we fake to have mpicxx.h read already
......@@ -77,49 +85,55 @@ _EOF
}
mpi_getmpichflags() {
if test x"$DUNEMPICPPFLAGS" = x; then
# use special commands to extract options
mpi_getflags "-compile_info"
MPI_CPPFLAGS="$retval"
DUNEMPICPPFLAGS="$retval"
# remove implicitly set -c
mpi_remove "$MPI_CPPFLAGS" '-c'
MPI_CPPFLAGS="$retval"
mpi_remove "$DUNEMPICPPFLAGS" '-c'
DUNEMPICPPFLAGS="$retval"
fi
if test x"$DUNEMPILIBS" = x; then
# get linker options
mpi_getflags "-link_info"
MPI_LDFLAGS="$retval"
DUNEMPILIBS="$retval"
# strip -o option
mpi_remove "$MPI_LDFLAGS" "-o"
MPI_LDFLAGS="$retval"
#strip MPI_CPPFLAGS (which are included for mpich2 on jugene)
enc=`echo "$MPI_CPPFLAGS" | sed -e 's/\\//\\\\\\//g'`
MPI_LDFLAGS=`echo "$retval" | sed -e "s/$enc / /"`
mpi_remove "$DUNEMPILIBS" "-o"
DUNEMPILIBS="$retval"
#strip DUNEMPICPPFLAGS (which are included for mpich2 on jugene)
enc=`echo "$DUNEMPICPPFLAGS" | sed -e 's/\\//\\\\\\//g'`
DUNEMPILIBS=`echo "$retval" | sed -e "s/$enc / /"`
fi
# hack in option to disable MPICH-C++-bindings...
MPI_NOCXXFLAGS="-DMPICH_SKIP_MPICXX"
# hack in option to disable MPICH-C++-bindings...
MPI_NOCXXFLAGS="-DMPICH_SKIP_MPICXX"
}
mpi_getmpich2flags() {
if test x"$DUNEMPICPPFLAGS" = x; then
# use special commands to extract options
mpi_getflags "-show" "-c"
MPI_CPPFLAGS="$retval"
DUNEMPICPPFLAGS="$retval"
# remove implicitly set -c
mpi_remove "$MPI_CPPFLAGS" '-c'
MPI_CPPFLAGS="$retval"
mpi_remove "$DUNEMPICPPFLAGS" '-c'
DUNEMPICPPFLAGS="$retval"
fi
if test x"$DUNEMPILIBS" = x; then
# get linker options
mpi_getflags "-show" "-o"
MPI_LDFLAGS="$retval"
DUNEMPILIBS="$retval"
# strip -o option
mpi_remove "$MPI_LDFLAGS" "-o"
MPI_LDFLAGS="$retval"
#strip MPI_CPPFLAGS (which are included for mpich2 on jugene)
enc=`echo "$MPI_CPPFLAGS" | sed -e 's/\\//\\\\\\//g'`
MPI_LDFLAGS=`echo "$retval" | sed -e "s/$enc / /"`
mpi_remove "$DUNEMPILIBS" "-o"
DUNEMPILIBS="$retval"
#strip DUNEMPICPPFLAGS (which are included for mpich2 on jugene)
enc=`echo "$DUNEMPICPPFLAGS" | sed -e 's/\\//\\\\\\//g'`
DUNEMPILIBS=`echo "$retval" | sed -e "s/$enc / /"`
fi
# hack in option to disable MPICH-C++-bindings...
MPI_NOCXXFLAGS="-DMPICH_SKIP_MPICXX"
# hack in option to disable MPICH-C++-bindings...
MPI_NOCXXFLAGS="-DMPICH_SKIP_MPICXX"
}
test_mpich () {
......@@ -178,10 +192,14 @@ _EOF
if (mpi_preprocess conftest.c | grep -q ompi_communicator_t); then
dune_MPI_VERSION="OpenMPI"
mpi_getflags "-showme:compile"
MPI_CPPFLAGS="$retval"
mpi_getflags "-showme:link"
MPI_LDFLAGS="$retval"
if test x"$DUNEMPICPPFLAGS" = x; then
mpi_getflags "-showme:compile"
DUNEMPICPPFLAGS="$retval"
fi
if test x"$DUNEMPILIBS" = x; then
mpi_getflags "-showme:link"
DUNEMPILIBS="$retval"
fi
MPI_NOCXXFLAGS="-DMPIPP_H"
AC_MSG_RESULT([yes])
......@@ -247,30 +265,14 @@ test_ibmmpi() {
if (echo $retval | grep '^xl[[cC]]'); then
dune_MPI_VERSION="IBM MPI"
# get compilation script
# AC_LANG_CASE([C],[
# MPICOMP="$MPICC"
# dune_mpi_isgnu="$GCC"
# ],
# [C++],[
# MPICOMP="$MPICXX"
# dune_mpi_isgnu="$GXX"
# ])
# mpCC assumes xlc is used...
# if test x$dune_mpi_isgnu = xyes ; then
# # change commandline if GNU compiler is used
# retval=`echo $retval | sed -e 's/\(-b[[^ ]]*\)/-Xlinker \1/g'`
# fi
MPI_CPPFLAGS="$retval"
if test x"$DUNEMPICPPFLAGS" = x; then
DUNEMPICPPFLAGS="$retval"
fi
mpi_getflags "-v" "dummy.o -o dummy"
# if test x$dune_mpi_isgnu = xyes ; then
# # change commandline if GNU compiler is used
# retval=`echo $retval | sed -e 's/\(-b[[^ ]]*\)/-Xlinker \1/g'`
# fi
MPI_LDFLAGS="$retval"
if test x"$DUNEMPILIBS" = x; then
mpi_getflags "-v" "dummy.o -o dummy"
DUNEMPILIBS="$retval"
fi
AC_MSG_RESULT([yes])
rm -f conftest*
......
#! /bin/bash
dnl -*- mode: autoconf; tab-width: 8; indent-tabs-mode: nil; -*-
dnl vi: set et ts=8 sw=2 sts=2:
# $Id$
# searches for ParMetis headers and libs
......@@ -55,13 +56,14 @@ AC_DEFUN([DUNE_PATH_PARMETIS],[
ac_save_LIBS="$LIBS"
## do nothing if --without-parmetis is used
if test x"$MPI_LDFLAGS" != x"" && test x"$with_parmetis" != x"no" ; then
if test x"$with_mpi" != x"no" && test x"$with_parmetis" != x"no" ; then
# defaultpath
PARMETIS_LIB_PATH="$with_parmetis$lib_path"
PARMETIS_INCLUDE_PATH="$with_parmetis$lib_path"
PARMETIS_LIBS="-L$PARMETIS_LIB_PATH $MPI_LDFLAGS $MPI_LIBS"
PARMETIS_LIBS="-L$PARMETIS_LIB_PATH -lmetis $DUNEMPILIBS -lm"
PARMETIS_LDFLAGS="$DUNEMPILDFLAGS"
# set variables so that tests can use them
CPPFLAGS="$CPPFLAGS -I$PARMETIS_INCLUDE_PATH $MPI_CPPFLAGS"
......@@ -80,22 +82,27 @@ AC_DEFUN([DUNE_PATH_PARMETIS],[
# if header is found check for the libs
LIBS="$LIBS $PARMETIS_LIBS -lm"
LIBS="$DUNEMPILIBS -lm $LIBS"
if test x$HAVE_PARMETIS = x1 ; then
AC_CHECK_LIB(metis, [metis_partgraphkway],[
PARMETIS_LIBS="$PARMETIS_LIBS -lmetis"
LIBS="$LIBS -lmetis"],[
DUNE_CHECK_LIB_EXT(["$PARMETIS_LIB_PATH"], [metis], [metis_partgraphkway],
[
PARMETIS_LIBS="-L$PARMETIS_LIB_PATH -lmetis $DUNEMPILIBS -lm"
LIBS="$PARMETIS_LIBS $ac_save_LIBS"
],[
HAVE_PARMETIS="0"
AC_MSG_WARN(libmetis not found!)])
AC_MSG_WARN(libmetis not found!)
])
fi
if test x$HAVE_PARMETIS = x1 ; then
AC_CHECK_LIB(parmetis, [parmetis_v3_partkway],[
PARMETIS_LIBS="$PARMETIS_LIBS -lparmetis -lmetis"
HAVE_PARMETIS="1"],[
DUNE_CHECK_LIB_EXT(["$PARMETIS_LIB_PATH"], [parmetis], [parmetis_v3_partkway],
[
PARMETIS_LIBS="-L$PARMETIS_LIB_PATH -lparmetis -lmetis $DUNEMPILIBS -lm"
],[
HAVE_PARMETIS="0"
AC_MSG_WARN(libparmetis not found!)])
AC_MSG_WARN(libparmetis not found!)
])
fi
# AC_LANG_POP([C++])
......@@ -107,6 +114,7 @@ AC_DEFUN([DUNE_PATH_PARMETIS],[
AC_MSG_CHECKING(ParMETIS in $with_parmetis)
if test x$HAVE_PARMETIS = x1 ; then
AC_SUBST(PARMETIS_LIBS, $PARMETIS_LIBS)
AC_SUBST(PARMETIS_LDFLAGS, $PARMETIS_LDFLAGS)
AC_SUBST(PARMETIS_CPPFLAGS, $PARMETIS_CPPFLAGS)
AC_DEFINE(HAVE_PARMETIS,ENABLE_PARMETIS,[Define if you have the Parmetis library.
This is only true if MPI was found by configure
......@@ -114,7 +122,8 @@ AC_DEFUN([DUNE_PATH_PARMETIS],[
AC_MSG_RESULT(ok)
# add to global list
DUNE_PKG_LIBS="$DUNE_PKG_LIBS $PARMETIS_LIBS"
DUNE_PKG_LIBS="$PARMETIS_LIBS $DUNE_PKG_LIBS"
DUNE_PKG_LDFLAGS="$DUNE_PKG_LDFLAGS $PARMETIS_LDFLAGS"
DUNE_PKG_CPPFLAGS="$DUNE_PKG_CPPFLAGS $PARMETIS_CPPFLAGS"
# re-set variable correctly
......@@ -140,7 +149,3 @@ AC_DEFUN([DUNE_PATH_PARMETIS],[
DUNE_ADD_SUMMARY_ENTRY([ParMETIS],[$with_parmetis])
])
dnl Local Variables:
dnl mode: shell-script
dnl End:
......@@ -95,10 +95,10 @@ AC_DEFUN([DUNE_PATH_SUPERLU_DIST],[
SUPERLU_DIST_LIB_PATH="$with_superlu_dist/$my_lib_path"
SUPERLU_DIST_INCLUDE_PATH="$with_superlu_dist/$my_include_path"
SUPERLU_DIST_LDFLAGS="-L$SUPERLU_DIST_LIB_PATH $MPI_LDFLAGS"
SUPERLU_DIST_LDFLAGS="-L$SUPERLU_DIST_LIB_PATH $DUNEMPILDFLAGS"
# set variables so that tests can use them
CPPFLAGS="$CPPFLAGS -I$SUPERLU_DIST_INCLUDE_PATH $MPI_CPPFLAGS"
CPPFLAGS="$CPPFLAGS -I$SUPERLU_DIST_INCLUDE_PATH $DUNEMPICPPFLAGS"
# check for central header
AC_CHECK_HEADER([superlu_ddefs.h],[
......@@ -108,7 +108,7 @@ AC_DEFUN([DUNE_PATH_SUPERLU_DIST],[
AC_MSG_WARN([superlu_ddefs.h not found in $SUPERLU_DIST_INCLUDE_PATH with $CPPFLAGS])]
)
SUPERLU_DIST_CPPFLAGS="-I$SUPERLU_DIST_INCLUDE_PATH $MPI_CPPFLAGS"
SUPERLU_DIST_CPPFLAGS="-I$SUPERLU_DIST_INCLUDE_PATH $DUNEMPICPPFLAGS"
# if header is found check for the libs
......@@ -116,8 +116,8 @@ AC_DEFUN([DUNE_PATH_SUPERLU_DIST],[
# set variables so that tests can use them
OLDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS -L$SUPERLU_DIST_LIB_PATH $MPI_LDFLAGS"
LIBS="$BLAS_LIBS $LIBS $FLIBS $MPILIBS $MPI_LDFLAGS"
LDFLAGS="$LDFLAGS -L$SUPERLU_DIST_LIB_PATH $DUNEMPILDFLAGS"
LIBS="$BLAS_LIBS $LIBS $FLIBS $DUNEMPILIBS"
AC_CHECK_LIB(superlu-mpi, [pdgssvx],
[dnl
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment