Полезная информация

4.4. Skeletons

A team of compulsive hackers who have forgotten to eat in a frantic attempt to make a deadline? Something unpleasant lurking in the FreeBSD attic? No, a skeleton here is a minimal framework that supplies everything needed to make the ports magic work.

4.4.1. Makefile

The most important component of a skeleton is the Makefile. This contains various statements that specify how the port should be compiled and installed. Here is the Makefile for ElectricFence:-

    # New ports collection makefile for:  Electric Fence
    # Version required: 2.0.5
    # Date created:     13 November 1997
    # Whom:         jraynard
    # $FreeBSD$
    DISTNAME=       ElectricFence-2.0.5
    CATEGORIES=     devel
    MASTER_SITE_SUBDIR= devel/lang/c
    MAINTAINER= jraynard@FreeBSD.org
    MAN3=           libefence.3
            ${INSTALL_DATA} ${WRKSRC}/libefence.a ${PREFIX}/lib
            ${INSTALL_MAN} ${WRKSRC}/libefence.3 ${PREFIX}/man/man3
    .include <bsd.port.mk>

The lines beginning with a "#" sign are comments for the benefit of human readers (as in most Unix script files).

DISTNAME specifies the name of the tarball, but without the extension.

CATEGORIES states what kind of program this is. In this case, a utility for developers. See the categories section of this handbook for a complete list.

MASTER_SITES is the URL(s) of the master FTP site, which is used to retrieve the tarball if it is not available on the local system. This is a site which is regarded as reputable, and is normally the one from which the program is officially distributed (in so far as any software is "officially" distributed on the Internet).

MAINTAINER is the email address of the person who is responsible for updating the skeleton if, for example a new version of the program comes out.

Skipping over the next few lines for a minute, the line .include <bsd.port.mk> says that the other statements and commands needed for this port are in a standard file called bsd.port.mk. As these are the same for all ports, there is no point in duplicating them all over the place, so they are kept in a single standard file.

This is probably not the place to go into a detailed examination of how Makefiles work; suffice it to say that the line starting with MAN3 ensures that the ElectricFence man page is compressed after installation, to help conserve your precious disk space. The original port did not provide an install target, so the three lines from do-install ensure that the files produced by this port are placed in the correct destination.

4.4.2. The files directory

The file containing the checksum for the port is called md5, after the MD5 algorithm used for ports checksums. It lives in a directory with the slightly confusing name of files.

This directory can also contain other miscellaneous files that are required by the port and do not belong anywhere else.

4.4.3. The patches directory

This directory contains the patches needed to make everything work properly under FreeBSD.

4.4.4. The pkg directory

This program contains three quite useful files:-