Before you think about putting your code into an RPM, it is much useful if you have at least three targets in your Makefile:
It is important that after make install the binaries are well installed, and that even after removal of the source-direcotry, the program still runs. Furthermore it is necessary to have an optional variable for the Makefile, preferably called RPM_BUILD_ROOT, that is prefixed on all installed files. So, for example, if RPM_BUILD_ROOT points to /tmp/rpm, a file usually installed in /usr/bin would be installed in /tmp/rpm/usr/bin. Once you have done this, you may take the next step: The spec file
If you are working with xemacs (I advise you too, but vi seems to be pretty OK, too), you can open a new file in your project-directory that is called <project_name>.spec XEmacs then will fill it with the standard lines. I will go through the lines from Etrans.spec, the specification-file used in the Etrans-project: </project_name>
Summary: Etrans - the Software Radio from EPFL/Eurecom Name: Etrans Version: 0.3 Release: 1 URL: http://lcmpc10.epfl.ch] Source0: %{name}-%{version}.tar.gz License: GPL Group:Development/System BuildRoot: %{_tmppath}/%{name}-root Requires: rtlkernel = 2.4.4rtl rtlinux = 3.1 %description This is a remake of the software radio originally written by Raymond Knopp and others. It is put in a usable shape, bound with a frontend and should also get some documentation. %prep %setup -q %build make %install rm -rf $RPM_BUILD_ROOT make install %clean rm -rf $RPM_BUILD_ROOT %files %defattr(-,root,root) /opt/radio /etc/profile.d /dev/daq0 %changelog * Tue Mar 5 2002 root <> - Initial build.
We will no go through the file line by line and look what this rpm-spec file is all about:
Once you have your spec-file, you only need to pack up your project and let it build:
tar cvzf Etrans-0.3.tar.gz Etrans-0.3/. rpmbuild -ta Etrans-0.3.tar.gz
The '.' in Etrans-0.3/. is there because on my system, Etrans-0.3 is a symbolic link. So rather than tarring a symbolic link, I'd like to tar the content of this symbolic link! The second command then does everything from decompressing the tar.gz to calling all necessary scripts and building up a rpm. If all goes right, you can find your rpm in
/usr/src/redhat/RPMS/i386
If you're on an intel machine, of course. Try the file on a clean, freshly installed machine, to look if you didn't forget any dependencies.