[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Protux-devel] getting installation dir from autostuff
From: |
Martin Herren |
Subject: |
Re: [Protux-devel] getting installation dir from autostuff |
Date: |
Sat, 7 Dec 2002 13:28:21 +0100 |
On Fri, 06 Dec 2002 17:58:11 +0000
Luciano Giordana <address@hidden> wrote:
> do you have some tip on how to get the installation dir from autostuff from
> withing the code ?
> something like, QString p = getenv("INSTALLPATH") ?
getenv loads the environement variable at runtime, is it what you want ? In
this case the variable should be set in the shell's config file... i don't
think this would be a clean solution, but would allow to change the install-dir
without recompiling the code.
I think this kind of stuff should be choosen at compile time and 'compiled-in'.
I don't really know how autoconf can set this variable so that you can get it
from within the code, but i know how you can give it to the compiler so that
you can get it within the code... and Tapio will perhaps know how autoconf will
be able to give the install-dir to the compiler ;-)
ok, lot's of unclear talking... let me give an example in C:
----- program.c -----
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char **argv)
{
printf("install-path = %s\n", INSTALLPATH);
exit(0);
}
-----
if now you compile it with
gcc program.c -o program -D INSTALLPATH=\"/usr/local/bin\"
the program will output
install-path = /usr/local/bin
of course if you forget to give -D INSTALLPATH=\"...\" to the compiler, it
won't compile.
Now all we need is that autoconf adds a -D INSTALLPATH=\"...\" containing the
right path to the compiler options...
hth
/Martin
--
Open your Windows - Free your Mind - Enjoy
http://gnuwin.epfl.ch
Martin Herren +41 (0)79 746 57 83
OpenPGP Public key @ http://www.on-the-web.ch/sputnik/gpg.asc
pgpBakKXTRQjd.pgp
Description: PGP signature