[LC++]changing the source depending on a value in the configure script

Chris Vine chris at cvine.freeserve.co.uk
Sat Jan 10 23:44:02 UTC 2004


On Friday 09 January 2004 8:43 am, alain wrote:
> Hi all,
>
> My question is limit out of topic but I don't know where to ask it.
>
> In the QT c++ toolkit, one need to hardcode the path of the .qm file
> used for translation.
> It would make sense to modify this path depending on the --prefix value
> passed to the configure script.
> Does anybody know of a little tutorial or example of such a
> modification?

Autoconf provides a prefix variable for you.  Just test the value of $prefix 
(note though that I expect you should really be using the datadir variable, 
also provided by autoconf).

I have no idea where .qm files go, or what they are, but if you are not using 
automake, you can include something like this in your aclocal.m4 file:

  QMDIR="/usr/local/share/qm"
  if test -n "$datadir" && test "$datadir" != "NONE"; then
    QMDIR="$datadir/qm"
  fi

and then export it in your Makefile.in file with something like:

  QMDIR=@QMDIR@

and then pass that as a definition using the g++ -D flag.

If you are using automake all this is handled for you.  You just need 
something like:

  qmdir = $(datadir)/qm
  INCLUDES = -DQMDIR=\"$(qmdir)\"

in your Makefile.am file.  QMDIR will then appear as a standard C preprocessor 
macro definition which you can use in the usual way.

Chris.




More information about the tuxCPProgramming mailing list