dpkg-buildpackage: install to /usr/games instead of /usr bin

I'm building my first Debian package for a small game project, and it builds fine from the C sources, but the compiled executable gets installed in /usr/bin. How can I get it installed in /usr/games instead?

I've tried adding it to debian/install like so:

obj-x86_64-linux-gnu/mygame usr/games

but that only works when building a package for x86_64, because on other architectures, the build directory is obviously going have a different name.


Solution 1:

You can try to learn by small example like https://packages.ubuntu.com/source/hirsute/xball .

This xball package has the following in debian/rules:

override_dh_auto_configure:
    dh_auto_configure -- \
        --prefix=/usr \
        --bindir=/usr/games \
        --datadir=/usr/share/games/xball

in the above --bindir=/usr/games will do what you want.

You can do the same for your code.


Update based on comment from OP. For cmake based build:

I ended up looking at blockattack, which does this:

override_dh_auto_configure: 
  dh_auto_configure -- \
      -DCMAKE_BUILD_TYPE=Release \ -DINSTALL_BIN_DIR=/usr/games \
      -DINSTALL_DATA_DIR=share/games/blockattack