automake
[Top][All Lists]
Advanced

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

Re: [automake] Dependency question with _LDADD


From: Peter Johansson
Subject: Re: [automake] Dependency question with _LDADD
Date: Wed, 27 Aug 2008 10:50:48 -0400
User-agent: Thunderbird 2.0.0.16 (X11/20080723)

Michel Briand wrote:

::::::::::::::
src/lib/Makefile.am
::::::::::::::
# Library: libtraining
# Generates its own pkg-config definition file

AM_CPPFLAGS = -DLIBRARY_VERSION=\"$(LIBRARY_VERSION)\"
Why not put
 AC_DEFINE([LIBRARY_VERSION], ...)

in configure.ac, so you don't need the above?  Of course you may want to
use a less generic name, e.g. TRAINING_LIBRARY_VERSION.

Similar applies to -DPROGRAM_VERSION in src/bin/Makefile.am.


OK. That's a lot more concise. But having done this:

# Step 1: extract version number from a source file
TRAINING_PROGRAM_VERSION=`cat PROGRAM_VERSION`
Why do you keep that info in a separate file; why not just:

TRAINING_PROGRAM_VERSION=1.0



# Step 2: export this variable to Makefile
AC_SUBST(TRAINING_PROGRAM_VERSION)
and if since you AC_SUBST the variable you could (if it is important) create file PROGRAM_VERSION from a PROGRAM_VERSION.in

Setting the version in configure.ac you can avoid all the headache with setting dependencies correctly, especially for a beginners' template that is not appropriate.

FWIW, you could actually add ../../LIBRARY_VERSION to this variable.


Yes, it works well too. I'll have all my dependencies handled that way.

But working a little with it, I have one remark:
since, with AC_DEFINE, the version is stored in config.h and that all
source files depend on it, all my C files are rebuild (in lib or bin)
if I change the version file. The smart dependency is lost. So I'll
remove library's and program's versions from config.h and rely on the
old define on the command line. That's better for my need. But I wait
for you comments/tips on the AC_DEFINE I showed earlier in this mail.

Defining the version like that at command line, (as far as I can see) you've lost the dependency, in other words, if you change the version number it will not cause a re-compilation. If you want the smart dependency, you could let aclocal create a version.h (AC_CONFIG_FILES) from a version.h.in and then include version.h in only those c files in which it is needed.

Cheers,
Peter





reply via email to

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