How to handle the install location (prefix)?

Kjeldgaard Morten mok at bioxray.dk
Tue Sep 4 16:04:12 BST 2007


Alexander Glitter wrote:

> I'm currently creating a package for a game called "sfz" with the
> following directory layout in mind:
>
> - /usr/bin for the executable
> - /usr/share/sfz for the data files
>
> Is it a good idea to define a prefix-macro in the source code and use
> that whereever the game tries to access some of its data?

In a similar case, I've used the construction below in configure.ac  
(using GNU autotools). My problem was that a library needed access to  
a data file in $prefix/share/gpp4. However, under Fink on Mac OS X,  
everything is installed in the /sw tree, so there that file would be  
in /sw/share/gpp4. Under linux, $prefix is /usr, of course. The  
variable GPP4_PREFIX takes on the value of the --prefix switch passed  
on to the configure script. It can be used in both Makefiles and  
within C and C++ code.

# gpp4 wants to know it's prefix
test "x$prefix" = xNONE && prefix=$ac_default_prefix
AC_DEFINE_UNQUOTED([GPP4_PREFIX],["$prefix"],[Base directory of gpp4  
installation])
GPP4_PREFIX=$prefix
AC_SUBST(GPP4_PREFIX)

Cheers,
Morten




More information about the Ubuntu-motu-mentors mailing list