Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-common
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Core Modules
dune-common
Commits
86a6be4a
Commit
86a6be4a
authored
15 years ago
by
Jorrit Fahlke
Browse files
Options
Downloads
Patches
Plain Diff
Some more documentation on the automake variables. I think I'm finally seeing the light...
[[Imported from SVN: r5781]]
parent
24db4d58
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
doc/buildsystem/buildsystem.tex
+212
-93
212 additions, 93 deletions
doc/buildsystem/buildsystem.tex
with
212 additions
and
93 deletions
doc/buildsystem/buildsystem.tex
+
212
−
93
View file @
86a6be4a
...
...
@@ -551,136 +551,255 @@ AM_CPPFLAGS = @AM_CPPFLAGS@ $(SUPERLU_CPPFLAGS)
There are five classes of variables in automake-generated makefiles:
\begin{description}
\item
[automake]
Example:
\texttt
{
AM
\_
CPPFLAGS
}
. Values for these variables
are determined by
\texttt
{
configure
}
and substituted by
\texttt
{
config.sub
}
when generating the
\texttt
{
Makefile
}
from the
\texttt
{
Makefile.in
}
. To
make this possible, automake puts something like the following line into the
\texttt
{
Makefile.in
}
:
\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 =
@AM
_
CPPFLAGS@
AM
_
CPPFLAGS =
-DMY
_
DIR=`pwd`
\end{lstlisting}
The names of these variables begin with
\texttt
{
AM
\_
}
most of the time, but
there are some variables which don't have that prefix. Often these
variables are used as defaults for
{
\bf
target-specific
}
variables (they
also belong to the
{
\bf
makefile-default
}
class below. In that case, the
\texttt
{
configure
}
-detected value for that variable can be augmented by
putting something like
\begin{lstlisting}
[language=make]
AM
_
CPPFLAGS = @AM
_
CPPFLAGS@ -DMY
_
DIR=`pwd`
{
\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
}
in the
\texttt
{
Makefile.am
}
. Automake will then put this line into the
\texttt
{
Makefile.in
}
instead of the default one.
\item
[makefile-default]
Example:
\texttt
{
LDADD
}
. These variables usually
provide default values and can be overridden by
{
\bf
target-specific
}
variables. If they are
{
\bf
automake
}
variables, a default value will be
provided by
\texttt
{
configure
}
. Otherwise, they are per default undefined
and the developer can give them a default value in the
\texttt
{
Makefile.am
}
:
%$\end{lstlisting}
The value substituted by
\texttt
{
configure
}
can be augmented in the
\texttt
{
Makefile.am
}
like this:
\begin
{
lstlisting
}
[
language
=
make
]
LDADD = -lm
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
makefile-default
}
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
makefile-default
}
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
makefile-default
}
variable it provides a default which
is used when the
{
\bf
target-specific
}
is not defined. Example definition:
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
}
(
see
autoconf manual
)
, so the user can tell
\texttt
{
configure
}
what values these
variables should have. Thus, the developer should not usually set this
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
\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)
$
(
SUPERLU
_
CPPFLAGS
)
testprog
_
CPPFLAGS =
$
(
AM
_
CPPFLAGS
)
$
(SUPERLUCPPFLAGS)
\end{lstlisting}
or the
{
\bf
makefile-default
}
variable
\begin{lstlisting}
[language=make]
AM
_
CPPFLAGS
=
@AM
_
CPPFLAGS@
$
(SUPERLU
_
CPPFLAGS)
AM
_
CPPFLAGS = @AM
_
CPPFLAGS@
$
(
SUPERLUCPPFLAGS
)
\end
{
lstlisting
}
%$\end{lstlisting}
Values for these variables are determined by
\texttt
{
configure
}
. Usually,
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.
\end{description}
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
{
description
}
\item
[C-preprocessor flags]
\texttt
{
CPPFLAGS
}
(user),
\texttt
{
AM
\_
CPPFLAGS
}
(automake),
\texttt
{
\textit
{
program
}
\_
CPPFLAGS
}
/
\texttt
{
\textit
{
library
}
\_
CPPFLAGS
}
(program/library),
\texttt
{
\textit
{
LIBRARY
}
\_
CPPFLAGS
}
(dependend library).
These flags contain things like the include path
\texttt
{
-I
\textit
{
path
}}
and preprocessor defines
\texttt
{
-D
\textit
{
DEFINE
}}
/
\texttt
{
-U
\textit
{
DEFINE
}}
. Include paths should
rarely go in the user variable. For defines it depends on what the define
does: things like
\texttt
{
NDEBUG
}
are a definite candidate for the user
variable, while
\texttt
{
HAVE
\_
CONFIG
\_
H
}
is set by autoconf in
\texttt
{
AM
\_
CPPFLAGS
}
.
\item
[C++-compiler flags]
\texttt
{
CXXFLAGS
}
(user),
\texttt
{
AM
\_
CXXFLAGS
}
(automake),
\texttt
{
\textit
{
program
}
\_
CXXFLAGS
}
/
\texttt
{
\textit
{
library
}
\_
CXXFLAGS
}
(program/library),
\texttt
{
\textit
{
LIBRARY
}
\_
CXXFLAGS
}
(dependend library).
This includes things that change the behaviour of the compiler. Candidates
for the user variable are
\texttt
{
-g
}
,
\texttt
{
-Wall
}
,
\texttt
{
-O3
}
and
\texttt
{
-funroll
\_
loops
}
. Candidates for the other variables are
\texttt
{
-std=c++0x
}
. These variables are used not only when compiling, but
also when calling the C++-compiler to do linking only.
\item
[C-compiler flags]
\texttt
{
CFLAGS
}
(user),
\texttt
{
AM
\_
CFLAGS
}
(automake),
\texttt
{
\textit
{
program
}
\_
CFLAGS
}
/
\texttt
{
\textit
{
library
}
\_
CFLAGS
}
(program/library),
\texttt
{
\textit
{
LIBRARY
}
\_
CFLAGS
}
(dependend library).
Like the variables for C++-compiler, but for the plain C-compiler. If you
link a library written in C to a program or library written in C++, it may
be neccessary to include
\texttt
{
\textit
{
LIBRARY
}
\_
CFLAGS
}
in
\texttt
{
\textit
{
program
}
\_
CXXFLAGS
}
/
\texttt
{
\textit
{
library
}
\_
CXXFLAGS
}
or
\texttt
{
AM
\_
CXXFLAGS
}
.
\item
[linker flags]
\texttt
{
LDFLAGS
}
(user),
\texttt
{
AM
\_
LDFLAGS
}
(automake),
\texttt
{
\textit
{
program
}
\_
LDFLAGS
}
/
\texttt
{
\textit
{
library
}
\_
LDFLAGS
}
(program/library),
\texttt
{
\textit
{
LIBRARY
}
\_
LDFLAGS
}
(dependend library).
This variable should not contain any
\texttt
{
-L
\textit
{
path
}}
or
\texttt
{
-l
\textit
{
library
}}
options -- those should go into the following
variables.
\item
[libraries to link to]
\texttt
{
LIBS
}
(automake),
\texttt
{
\textit
{
program
}
\_
LDADD
}
/
\texttt
{
\textit
{
library
}
\_
LIBADD
}
(program/library),
\texttt
{
\textit
{
LIBRARY
}
\_
LIBS
}
(dependend library).
Note that there is no user variable. This variables should contain the
libraries to link to -- either directly by file name
\texttt
{
\textit
{
path/to/library.so
}}
or by using the
\texttt
{
-L
\textit
{
path
}}
and
\texttt
{
-l
\textit
{
library
}}
options. If
\texttt
{
-l
\textit
{
library
}}
is used, it must be preceded by a matching
\texttt
{
-L
\textit
{
path
}}
(except for standard libraries like
\texttt
{
-lm
}
).
This is especially importand for the dependend library variable
\texttt
{
\textit
{
LIBRARY
}
\_
LIBS
}
-- otherwise different dependend libraries
will fight for control other the linkers search path. It has happend that
one dependend library wanted to link against a library
\texttt
{
-l
\textit
{
foo
}}
, which was incorrectly found in another libraries
linker search path. Object files
\texttt
{
\textit
{
foo
}
.o
}
should not usually
be directly included.
\item
[source files]
\texttt
{
\textit
{
program
}
\_
SOURCES
}
/
\texttt
{
\textit
{
library
}
\_
SOURCES
}
(program/library). This is used to list the source files for a binary in a
\texttt
{
Makefile.am
}
. See the automake documentation for details.
\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.
\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
-
O
2
-
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
-
O
2
-
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
\texttt
{
-
L
}
or
\texttt
{
-
l
}
options or library files. 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.
\end
{
description
}
\item
[
libraries to link to
]
These variables are used to determine the
libraries 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
}
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}
%$\end{lstlisting}
Linker flags except
\texttt
{
-L
}
or
\texttt
{
-l
}
are generally inapropriate
for there variables.
\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
target-specific
}
. 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.
\end{description}
\end{description}
\minisec
{
Conditional builds
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment