Ports HowTo
Table of Contents
- Where are they?
- How do I use them?
- Making an new port
- Stages of a build
- Targets and Variables
- Bare Bones Makefile
- A simple example
- All Options for Porting
Where are they?
By default every port is installed into it's own directory in /usr/src/ports/. You can change it with a configure option when you install spkgtool.
How do I use them?
Spkgtool will allow you to build and install your ports. But developers and power users will probably want to bust out ye'ol xterm and use the command line. To work with a particular port, simply "cd" to that port's directory (ie: /usr/src/ports/ed for the "ed" port) and use "make" with one of the following targets:
# make download : Download sources # make unpack: Unpack source # make patch: Patch source # make configure: Configure # make build: Build # make install: Do it all # make register: Register install info # make md5: Download source and update checksum # make clean: Remove source build directory # make tarball-clean: Remove source tarball # make real-clean: clean and tarball-clean # make link: Link package into main tree # make Web: Build a web page describing the package
Making a new port
- Create a directory
- Create a Makefile
- Create a checksum file
- Test it
- Clean it up
- Tar it up
- Send it to me
$ mkdir /usr/src/ports/foo
$ vi /usr/src/ports/foo/Makefile
$ cd /usr/src/ports/foo $ make md5
$ make install
$ make real-clean
$ cd ../ $ tar zcvf foo-port.tar.gz foo
Stages of a build
There are seven stages to a build, in which you have the power to add custom targets. All of these have "pre" and "post" hooks (see All Options for Porting)
- DOWNLOAD
- UNPACK
- PATCH
- CONFIGURE
- BUILD
- INSTALL
- LINK
Targets and Variables
There are two options to add to a ports Makefile, targets and variables. "Targets" are used to define custom "make targets" (make the install procedure do something out of the ordinary). "Variables" are used for things like adding options and features as well as describe the port. The examples should clear this up.
Bare Bones Makefile
The following is the smallest possible Makefile and actually works on alot of packages, if they install with the usual "./configure; make; make prefix=/usr/local/pkgs/package-version install"
PORTNAME= autoconf
PORTVERSION= 2.13
CATEGORIES= devel
MASTER_SITES= ${MASTER_GNU_SITE}/autoconf
DISTFILES= ${PORTNAME}-${PORTVERSION}.tar.gz
DIRECTORY= ${PORTNAME}-${PORTVERSION}
MAINTAINER= larry@scrudgeware.org
include spkg.port.mk
A simple example
Here's a simple example with extra variables and a custom targets. This package doesn't run the "./configure" command and has some special options to use with "make". It also has a custom target that runs "ldconfig" after the package is linked into the main tree.
PORTNAME= ld.so
PORTVERSION= 1.9.9
CATEGORIES= sysutils
MASTER_SITES= ${MASTER_SUNSITE_SITE}/GCC/
DISTFILES= ${PORTNAME}-${PORTVERSION}.tar.gz
DIRECTORY= ${PORTNAME}-${PORTVERSION}
MAINTAINER= larry@scrudgeware.org
NO_CONFIGURE= yes
MAKE_FLAGS=-C util ldd ldconfig
post-link:
/sbin/ldconfig
include spkg.port.mk
All Options for Porting
The following contains all the targets and variables available. If you need all these, you should problably send an email to the developers of the package you are trying to port and tell them to fix their stuff :-)
PORTNAME= PORTVERSION= DESCRIPTION= CATEGORIES= DEPENDENCIES= MASTER_SITES= DISTFILES= PATCHFILES= DIRECTORY= MAINTAINER= include spkg.port.mk pre-download: post-download: NO_DOWNLOAD=yes pre-patch: post-patch: NO_PATCH=yes pre-unpack: post-unpack: NO_UNPACK=yes pre-configure: post-configure: CONFIGURE_COMMAND= CONFIGURE_OPTIONS= CONFIGURE_FLAGS= NO_CONFIGURE=yes pre-build: post-build: MAKE_OPTIONS= NO_MAKE=yes pre-install: post-install: MAKE_INSTALL_OPTIONS= INSTALL_FLAGS= NO_INSTALL=yes pre-link: post-link: NO_LINK=yes pre-web: post-web: NO_WEB=yes
