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

packaging games

This question really isn't a Linux game programming question, but rather
a Linux game packaging question.  In the game I'm working on, I have a
data directory in which I place the graphics.  In my code I have a line

const string DATADIR = "/usr/local/share/games/fred";

This works great when building from source.  If you don't want the data
directory there, then just change that line before compiling.  The
problem is that I don't really like hard-coding a path like that since
it does involve modifying the source code.  Plus it would be nicer if it
wasn't that way for distributing binary copies of the game.

Is the best way to handle this to create a configuration file in /etc or
~/ and put the DATADIR path in that file?

If so, is there a library I can use to get the path that checks /etc
and ~/ automatically, or would I have to program that into my game
myself.  It wouldn't be hard to add that in, but I'm wondering if there
is a standard way that already exists.

I was also thinking about not installing a configuration file, but still
check for it in my program.  If it does exist, I can use that path and
if it doesn't exist, then I can use what I already have hard-coded.

The other thing I was wondering about is if it is possible to set this
as a compile time option somehow.  Is there a way to put something in a
Makefile that can set this path so it gets compiled into the program
that way?  That would be better than having it hard-coded in the program

If there is documentation out there describing what I am asking, please
just point me to the docs.
Jason Stechschulte

If you keep anything long enough, you can throw it away.