[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: packaging games
On Sat, Nov 23, 2002 at 08:39:40PM -0600, Steve Baker wrote:
> I have the 'configure' script generate that as a '#define' so the
> program can know where the files will go when you do a 'make install'.
Ok, that is what occurred to me as I was typing my post. I guess I
should just start reading up on autoconf and automake, and then have
that do a #define also.
> Additionally, I have the program check other 'likely' places where
> it's data files might have been abandoned.
> Check in this order:
> 1) getenv ( "FRED_DATADIR" )
> 2) The current working directory.
> 3) The place where the configure script will install it.
> 4) The place it was compiled from (as given by the 'configure'
> 5) /usr/local/games/fred
> 6) /usr/share/games/fred
> 7) /usr/games/fred
> I find the simplest thing is to try fopen'ing a file that I know
> exists in my data directory. If the file doesn't open - then I try
> the next likely location on my list. You could use 'stat' if you
> need more info.
This makes sense too. I never really thought about just falling back to
a bunch of the likely candidates.
> ...I don't think games should be putting stuff in /etc - configuration
> files belong in someplace like: ~/.fredrc
That is a good point. I guess I never really noticed that nearly every
game I've ever installed has worked this way. The one exception I did
notice on my system is nethack.
> >If so, is there a library I can use to get the path that checks /etc
> >and ~/ automatically...
> Why do you need a libray? It's only 3 lines of code:
> char s [ 1000 ] ;
> sprintf ( s, "%s/.fredrc", getenv("HOME") ) ;
> FILE *fd = fopen ( s, "r" ) ;
> ...easy. (Well, you'll be doing more error checks - but still)...
I know it is very easy. I just figured it is something that nearly
every program has to do, so maybe there exists some system library that
handles this and other things. I just wanted to make sure that however
I did it, I was doing it the standard way.
Faith is under the left nipple.
-- Martin Luther