[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Compilation flags and variables

From: Guillaume Rousse
Subject: Compilation flags and variables
Date: Wed, 31 May 2006 10:38:42 +0200
User-agent: Thunderbird (X11/20060425)

I read the automake and autoconf manual several times, but I'm still a
bit uncertain at how to manage compilation flags properly, meaning:
- which flags to use
- where to use them

First, you have per-primary targets options (discarding non-C language

foo_(LIBADD|LDADD), for programs and libraries respectively

My understanding of documention is that foo_LIBADD|LDADD) expect either
real linker options among -l, -L, -dlopen and -dlpreopen, or library
names such as foo that will automatically get expanded into -lfoo
-L/path/to/foo, and foo_LDFLAGS expect all other linker flags. I don't
understand foo_DEPENDENCIES purpose, however.

Then they are per options:

Those are pure-automake ones, and used in place of per-target ones of
the same name if not defined. AM_(LIBADD|LDADD) and AM_DEPENDENCIES
don't exists, however.

Then they are per-project flags, definable either in or in


They are always used in addition to previous ones. CFLAGS is exaclty
similar to AM_CFLAGS, but CPPFLAGS and LDFLAGS are not equivalent to
their AM_* forms, as the first one is supposed to exclude -D options (to
be defined in DEFS), and LDFLAGS include all linker flags excepted -l
ones (to be defined in LIBS).

How are you supposed to manage automake vs autoconf flags ? The most
simpler seems to use preferentially automake-defined variables in, and keep autoconf ones in However, this is
not always possible. Imagine you want to link all programs in a given
directory with a library, and such you need global linker options (-L
and -l) for this directory only. The only solution seems to use autoconf
variables LIBS and LDFLAGS in AM_LDFLAGS isn't supposed to
accept -L options, and there is no AM_(LIBADD|LDADD).

I don't even mention than standard *-config scripts and pkgconfig use
--cflags option to output actually preprocessor flags, and --libs to
output linker flags...

reply via email to

[Prev in Thread] Current Thread [Next in Thread]