FreeBSD Handbook : Installing Applications: The Ports collection : Skeletons : Makefile
Previous: Skeletons
Next: The files directory

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
#
# $Id: ports.sgml,v 1.35 1999/01/20 11:51:51 asami Exp $
#

DISTNAME=	ElectricFence-2.0.5
CATEGORIES=	devel
MASTER_SITES=	${MASTER_SITE_SUNSITE}
MASTER_SITE_SUBDIR=	devel/lang/c

MAINTAINER=	jraynard@freebsd.org

MAN3=		libefence.3

do-install:
	${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.


FreeBSD Handbook : Installing Applications: The Ports collection : Skeletons : Makefile
Previous: Skeletons
Next: The files directory