Peter Johansson <[EMAIL PROTECTED]> - Wed, 27 Aug 2008 10:50:48 -0400
>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 > Because program will evolve, hopefully, independently from the build system. And as such, the program's version is independent from configure.ac... So it should be stored in a separate file. From a beginner's point of view the tutorial should enlighten the difficult pattern of program versioning. That's more complex but do not introduce a false pattern more difficult to fix later. > > >> # 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 > I'll try that, thank you Peter. Cheers, Michel -- .''`. : :' : We are debian.org. Lower your prices, surrender your code. `. `' We will add your hardware and software distinctiveness to `- our own. Resistance is futile.