automake
[Top][All Lists]
Advanced

[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 1.5.0.2 (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
ones):

foo_CPPFLAGS
foo_CFLAGS
foo_(LIBADD|LDADD), for programs and libraries respectively
foo_LDFLAGS
foo_DEPENDENCIES

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 Makefile.am options:
AM_CPPFLAGS
AM_CFLAGS
AM_LDFLAGS

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 configure.ac or in
Makefile.am:

CPPFLAGS
CFLAGS
LDFLAGS
LIBS
DEFS

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
Makefile.am, and keep autoconf ones in configure.ac. 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 Makefile.am: 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]