To make a slackware package, this is the general process i use.

This writeup assumes the source uses autoconf/automake (has a normal configure-script and a Makefile generated by automake).

Before making the package, make sure to check it doesn't already exist in slackware-current.
If there is a package in slackware-current, but it is the wrong version, then just take the SlackBuild-script used for building that package from the source-directory and change it. Often you just have to change a VERSION-variable at the top of the script.

If you're still making the package manually, then read on.

Running configure

First run configure using the parameters you want to use, and with the prefix you want to use.
Default prefix if you don't supply one is /usr/local, which is why software is installed there by default. You probably want /usr.

./configure --prefix=/usr

Building

Build just as always:

make

Installing

This is where it gets neat. Instead of installing the software onto the system we want to put it in a directory where we can package it.

Makefiles made by recent versions of automake support a variable called DESTDIR, which controls where make install puts the files. If the project uses an older version of automake, you'll have to supply another prefix instead.

Switch user to root

su

I run this as root, to make sure that files get the same permissions as they would if they were installed normally.

Checking if the Makefile supports DESTDIR

grep -r DESTDIR *

The -r is there to also search subdirectories, since some Makefiles somtimes include the automake-part from a Makefile in a subdirectory.
If this returns anything in any file that looks like a Makefile, DESTDIR is most likely supported.

Installing with DESTDIR-support

make DESTDIR=/tmp/slackpack/example-0.1-beta install

Installing without DESTDIR-support

No worries, just put the wanted DESTDIR in front of the prefix, and install like so:

make prefix=/tmp/slackpack/example-0.1-beta/usr install

Lousy Makefiles

When i feel that the Makefile seems to be somewhat buggy and unfeatureful, i use the -n option of make to simulate an install, just to see what would happen.

Packaging

Go to the destination directory:

cd /tmp/slackpack/example-0.1-beta

Checking the package

I look through the directories created to check if all files seem to be there, and that everything looks OK.

Stripping binaries

I go into the bin, lib, and sbin directories and run strip *. This often reduces the size of the package considerably. Sometimes you can use the make-target install-strip to do this.

Including documentation and other files

I then usually copy documentation files, like AUTHORS, LICENSE, README, ChangeLog, and any other documentation, from the source-directory into the documentation directory of the destination which i also create:

mkdir -p /tmp/slackpack/example-0.1-beta/usr/doc/example-0.1beta
cd /tmp/source/example-0.1-beta
cp -R docs/ AUTHORS ChangeLog COPYING INSTALL README NEWS /tmp/slackpack/example-0.1-beta/usr/doc/example-0.1beta

The name of the documentation directory should match the "name-version" of the package name, see note below.

I also chown the files, since the files copied aren't owned by root.

chown -R root:root /tmp/slackpack/example-0.1-beta/usr/doc/example-0.1beta

I then go over the package one last time, making sure everything is OK, and then i make the package.

Making the package

Choosing a package name

A slackware package name consists of four parts, separated by hyphens.

  1. The name
  2. The version - For example 0.1 or 1.2.3 or 1.1pre2.
  3. The architecture. - Usually i386 or i686 or noarch.
  4. The build number. - Increment this if you want to make another (better?) package with the same name and version.

Of these, only the name can contain hyphens. Sometimes you want a hyphen in the version number. Just use an underscore or (better) squash it together. For example, 0.1-beta becomes 0.1beta.
Note that the name of the documentation directory should match the "name-version" of the package name, so if you squash the version in the package name, do so in the name of the documentation directory too.

Running makepkg

To make a package you use makepkg(8):

cd /tmp/slackpack/example-0.1-beta
makepkg example-0.1beta-i386-1.tgz

makepkg(8) will ask you if you want to create an installation script and add all symbolic links to it, and if you want to change ownership and permissions of all directories to root:root and 0755. Just answer yes to both question, unless there is anything specific in this package that calls for special treatment.

We're done!

Now the package is complete! You can either installpkg(8) it or upgradepkg(8) another package with it!

History: Making slackware-packages