Next Previous Contents

4. Some tips about of to make that with automake/autoconf?

4.1 Tweaking the path

The problem with automake, which I really recommend to use, is that it installed the files at default in the normal places, thats perfectly OK, but since games are a bit different there is the need to tweak the pathnames a bit. That can be done by placing the following in the Makefile.am's

              # Tweaking the `datadir' to install the files in the correct location
              pkgdatadir = $(datadir)/games/@PACKAGE@
            

4.2 How to find out where the package is installed?

If you are using automake/autoconf the user has the choice to override the default prefix, which is /usr/local. So the question is how to I get the install directory? Therefore we have to hardcode the path into the binary, but how to accomplish that? The problem is that we need to expand the variable $prefix to the full pathname, else we would end up with a useless string like "$prefix/". Place the following in the file acinclude.m4:

              AC_DEFUN(MY_EXPAND_DIR, [
                $1=$2
                $1=`(
                     test "x$prefix" = xNONE && prefix="$ac_default_prefix"
                     test "x$exec_prefix" = xNONE && exec_prefix="${prefix}"
                     eval echo \""[$]$1"\"
                    )`
              ])
            

And the following into configure.in:

              MY_EXPAND_DIR(game_datadir, "$datadir/games/$PACKAGE")
              AC_DEFINE_UNQUOTED( GAME_DATADIR, "$game_datadir")
            

This will create a macro called GAME_DATADIR, which will expand into the path where your game data resist. For example if the game is installed into /usr/local GAME_DATADIR will expand to /usr/local/share/GAME/, when you need other data then the one that resist in share/$GAME you can also use "$prefix" in the example.


Next Previous Contents