Product SiteDocumentation Site

18.2.4. Making relocatable packages

You should aim to make your packages relocatable so that users can install your packages into any directory. This makes it easier to deal with the locations chosen by different Linux distributions, such as /usr, /usr/local, or /opt, for installing add-on software.
Cross Reference
Chapter 9, Working with Spec Files covers the spec file format. Chapter 10, Advanced RPM Packaging covers making relocatable packages.
You can use the %{_bindir} macro in your spec files, which will help create per-distribution packages using the right settings.
In addition, you can define macros in your spec files that define the location for dependencies. You can then use the --define option to the rpmbuild command to define values for your macros that specify the locations for the dependencies.
Note
This technique of setting up Linux distribution-specific macros can help solve a lot of problems with cross-platform RPMs.