---
title: Capítulo 14. Um Exemplo de Makefile
prev: books/porters-handbook/porting-dads
next: books/porters-handbook/order
showBookMenu: true
weight: 14
params:
  path: "/books/porters-handbook/porting-samplem/"
---

[[porting-samplem]]
= Um Exemplo de Makefile
:doctype: book
:toc: macro
:toclevels: 1
:icons: font
:sectnums:
:sectnumlevels: 6
:sectnumoffset: 14
:partnums:
:source-highlighter: rouge
:experimental:
:images-path: books/porters-handbook/

ifdef::env-beastie[]
ifdef::backend-html5[]
:imagesdir: ../../../../images/{images-path}
endif::[]
ifndef::book[]
include::shared/authors.adoc[]
include::shared/mirrors.adoc[]
include::shared/releases.adoc[]
include::shared/attributes/attributes-{{% lang %}}.adoc[]
include::shared/{{% lang %}}/teams.adoc[]
include::shared/{{% lang %}}/mailing-lists.adoc[]
include::shared/{{% lang %}}/urls.adoc[]
toc::[]
endif::[]
ifdef::backend-pdf,backend-epub3[]
include::../../../../../shared/asciidoctor.adoc[]
endif::[]
endif::[]

ifndef::env-beastie[]
toc::[]
include::../../../../../shared/asciidoctor.adoc[]
endif::[]

Aqui está um exemplo de [.filename]#Makefile# que pode ser usado para criar um novo port. Certifique-se de remover todos os comentários extras (entre colchetes).

O formato apresentado é o recomendado para ordenar variáveis, linhas vazias entre seções e assim por diante. Esse formato é projetado para que as informações mais importantes sejam fáceis de serem localizadas. Recomendamos usar o <<porting-portlint,portlint>> para verificar o [.filename]#Makefile#.

[.programlisting]
....
[the header...just to make it easier for us to identify the ports.]
# $FreeBSD: head/pt_BR.ISO8859-1/books/porters-handbook/book.xml 54410 2020-08-05 22:13:01Z dbaio $
[ ^^^^^^^^^ This will be automatically replaced with RCS ID string by SVN
when it is committed to our repository.  If upgrading a port, do not alter
this line back to "$FreeBSD: head/pt_BR.ISO8859-1/books/porters-handbook/book.xml 54410 2020-08-05 22:13:01Z dbaio $".  SVN deals with it automatically.]

[section to describe the port itself and the master site - PORTNAME
 and PORTVERSION or the DISTVERSION* variables are always first,
 followed by CATEGORIES, and then MASTER_SITES, which can be followed
 by MASTER_SITE_SUBDIR.  PKGNAMEPREFIX and PKGNAMESUFFIX, if needed,
 will be after that.  Then comes DISTNAME, EXTRACT_SUFX and/or
 DISTFILES, and then EXTRACT_ONLY, as necessary.]
PORTNAME=	xdvi
DISTVERSION=	18.2
CATEGORIES=	print
[do not forget the trailing slash ("/")!
 if not using MASTER_SITE_* macros]
MASTER_SITES=	${MASTER_SITE_XCONTRIB}
MASTER_SITE_SUBDIR=	applications
PKGNAMEPREFIX=	ja-
DISTNAME=	xdvi-pl18
[set this if the source is not in the standard ".tar.gz" form]
EXTRACT_SUFX=	.tar.Z

[section for distributed patches -- can be empty]
PATCH_SITES=	ftp://ftp.sra.co.jp/pub/X11/japanese/
PATCHFILES=	xdvi-18.patch1.gz xdvi-18.patch2.gz
[If the distributed patches were not made relative to ${WRKSRC},
 this may need to be tweaked]
PATCH_DIST_STRIP=	-p1

[maintainer; *mandatory*!  This is the person who is volunteering to
 handle port updates, build breakages, and to whom a users can direct
 questions and bug reports.  To keep the quality of the Ports Collection
 as high as possible, we do not accept new ports that are assigned to
 "ports@FreeBSD.org".]
MAINTAINER=	asami@FreeBSD.org
COMMENT=	DVI Previewer for the X Window System

[license -- should not be empty]
LICENSE=	BSD2CLAUSE
LICENSE_FILE=	${WRKSRC}/LICENSE

[dependencies -- can be empty]
RUN_DEPENDS=	gs:print/ghostscript

[If it requires GNU make, not /usr/bin/make, to build...]
USES= gmake
[If it is an X application and requires "xmkmf -a" to be run...]
USES= imake

[this section is for other standard bsd.port.mk variables that do not]
 belong to any of the above]
[If it asks questions during configure, build, install...]
IS_INTERACTIVE=	yes
[If it extracts to a directory other than ${DISTNAME}...]
WRKSRC=		${WRKDIR}/xdvi-new
[If it requires a "configure" script generated by GNU autoconf to be run]
GNU_CONFIGURE=	yes
[et cetera.]

[If it requires options, this section is for options]
OPTIONS_DEFINE=	DOCS EXAMPLES FOO
OPTIONS_DEFAULT=	FOO
[If options will change the files in plist]
OPTIONS_SUB=yes

FOO_DESC=		Enable foo support

FOO_CONFIGURE_ENABLE=	foo

[non-standard variables to be used in the rules below]
MY_FAVORITE_RESPONSE=	"yeah, right"

[then the special rules, in the order they are called]
pre-fetch:
	i go fetch something, yeah

post-patch:
	i need to do something after patch, great

pre-install:
	and then some more stuff before installing, wow

[and then the epilogue]

.include <bsd.port.mk>
....
