I've had the same problem with a little Qt based game, which I made as a learning project for programming in Linux to get to know g++, Qt, automake, autoconf, emacs, gdb, etc.
This game wants to find some pixmap files, which by default get installed in a subdir of /usr/local/share. But when the installing person changes the installation dir with "./configure --prefix=..." the pixmaps get installed in some other place. Also, I wanted the game to be able to find it's pixmaps even
without being installed.
I solved it by making the program search for it's pixmaps in this order:
1) from an specific environment variable, if it is set.
2) from various paths relative to the source directory. (the dir where the program was compiled). This to make it possible to run the program from the source dir (not-installed). The source dir known through a string #defined by the configure script. (so this path is hardcoded into the executable.)
3) from the path relative to the path of the running executable. It tries to determine by reading the "_" env. var. which some shell set to the path of the current process. If that doesn't work it tries to find it through argv[0].
4) from the full path to the datadir as #defined by the configure script.
You can find this "learning project" at
http://qleuren.sf.net/.
The source file that handles this searching for the pixmaps is src/tdir.cpp.
If you run ./configure this way:
bash$ CXXFLAGS=-DDBG ./configure
then the program will tell on stdout where it get the pixmap files from, and how it found them.
I still think this is not a very clean way. If anybody has a better idea to solve this, I would be interested.