xref: /freebsd/share/mk/bsd.port.mk (revision a8445737e740901f5f2c8d24c12ef7fc8b00134e)
1#-*- mode: Fundamental; tab-width: 4; -*-
2# ex:ts=4
3#
4#	$Id: bsd.port.mk,v 1.286 1998/08/28 18:41:04 dima Exp $
5#	$NetBSD: $
6#
7#	bsd.port.mk - 940820 Jordan K. Hubbard.
8#	This file is in the public domain.
9#
10# Please view me with 4 column tabs!
11
12# There are two different types of "maintainers" in the whole ports
13# framework concept.  Maintainers of the bsd.port*.mk files
14# are listed below in the ${OPSYS}_MAINTAINER entries (this file
15# is used by multiple *BSD flavors).  You should consult them directly
16# if you have any questions/suggestions regarding this file since only
17# they are allowed to modify the master copies in the CVS repository!
18
19FreeBSD_MAINTAINER=	asami@FreeBSD.ORG
20OpenBSD_MAINTAINER=	imp@OpenBSD.ORG
21
22# For each port, the MAINTAINER variable is what you should consult for
23# contact information on the person(s) to contact if you have questions/
24# suggestions about that specific port.  By default (if no MAINTAINER
25# is listed), a port is maintained by the subscribers of the ports@freebsd.org
26# mailing list, and any correspondece should be directed there.
27#
28# MAINTAINER	- The e-mail address of the contact person for this port
29#				  (default: ports@FreeBSD.ORG).
30#
31# These are meta-variables that are automatically set to the system
32# you are running on.
33#
34# ARCH			- The architecture, as returned by "uname -m".
35# OPSYS			- Portability clause.  This is the operating system the
36#				  makefile is being used on.  Automatically set to
37#				  "FreeBSD," "NetBSD," or "OpenBSD" as appropriate.
38# OSREL			- The release version (numeric) of the operating system.
39# PORTOBJFORMAT	- The object format ("aout" or "elf").
40#
41# These variables are used to identify your port.
42#
43# DISTNAME		- Name of port or distribution.
44# PKGNAME		- Name of the package file to create if the DISTNAME
45#				  isn't really relevant for the port/package
46#				  (default: ${DISTNAME}).
47# CATEGORIES	- A list of descriptive categories into which this port falls.
48#
49# These variable describe how to fetch files required for building the port.
50#
51# DISTFILES		- Name(s) of archive file(s) containing distribution
52#				  (default: ${DISTNAME}${EXTRACT_SUFX}).  Set this to
53#				  an empty string if the port doesn't require it.
54# EXTRACT_SUFX	- Suffix for archive names (default: .tar.gz).  You
55#				  never have to set both DISTFILES and EXTRACT_SUFX.
56# MASTER_SITES	- Primary location(s) for distribution files if not found
57#				  locally.
58# PATCHFILES	- Name(s) of additional files that contain distribution
59#				  patches (default: none).  make will look for them at
60#				  PATCH_SITES (see below).  They will automatically be
61#				  uncompressed before patching if the names end with
62#				  ".gz" or ".Z".
63# PATCH_SITES	- Primary location(s) for distribution patch files
64#				  if not found locally.
65# DIST_SUBDIR	- Suffix to ${DISTDIR}.  If set, all ${DISTFILES}
66#				  and ${PATCHFILES} will be put in this subdirectory of
67#				  ${DISTDIR} (see below).  Also they will be fetched in
68#				  this subdirectory from FreeBSD mirror sites.
69# ALLFILES		- All of ${DISTFILES} and ${PATCHFILES}.
70# IGNOREFILES	- If some of the ${ALLFILES} are not checksum-able, set
71#				  this variable to their names.
72# EXTRACT_ONLY	- If defined, a subset of ${DISTFILES} you want to
73#			  	  actually extract.
74#
75# These three variables are typically set in /etc/make.conf to indicate
76# the user's preferred location to fetch files from.
77#
78# MASTER_SITE_BACKUP - Backup location(s) for distribution files and patch
79#				  files if not found locally and ${MASTER_SITES}/${PATCH_SITES}
80#				  (default:
81#				  ftp://ftp.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/)
82# MASTER_SITE_OVERRIDE - If set, override the MASTER_SITES setting with this
83#				  value.
84# MASTER_SITE_FREEBSD - If set, only use ${MASTER_SITE_BACKUP} for
85#				  MASTER_SITES.
86#
87# Set these if your port should not be built under certain circumstances.
88# These are string variables; you should set them to the reason why
89# they are necessary.
90#
91# RESTRICTED	- Port is restricted (e.g., contains cryptography, etc.).
92# NO_CDROM		- Port may not go on CDROM.
93# NO_PACKAGE	- Port should not be packaged but distfiles can be put on
94#				  ftp sites and CDROMs.
95# BROKEN		- Port is broken.
96#
97# This variable is a boolean, so you don't need to set it to the reason.
98#
99# IS_INTERACTIVE - Set this if your port needs to interact with the user
100#				  during a build.  User can then decide to skip this port by
101#				  setting ${BATCH}, or compiling only the interactive ports
102#				  by setting ${INTERACTIVE}.
103#
104# Use these if your port uses some of the common software packages.
105#
106# USE_GMAKE		- Says that the port uses gmake.
107# GMAKE			- Set to path of GNU make if not in $PATH (default: gmake).
108# USE_AUTOCONF	- Says that the port uses autoconf.  Implies GNU_CONFIGURE.
109# AUTOCONF		- Set to path of GNU autoconf if not in $PATH (default:
110#				  autoconf).
111# USE_PERL5		- Says that the port uses perl5 for building and running.
112# PERL_VERSION	- Full version of perl5 (see below for current value).
113# PERL_VER		- Short version of perl5 (see below for current value).
114# USE_IMAKE		- Says that the port uses imake.  Implies USE_X_PREFIX.
115# XMKMF			- Set to path of `xmkmf' if not in $PATH (default: xmkmf -a ).
116# NO_INSTALL_MANPAGES - For imake ports that don't like the install.man
117#						target.
118# USE_X_PREFIX	- Says that the port installs in ${X11BASE}.  Implies USE_XLIB.
119# USE_XLIB		- Says that the port uses X libraries.
120# USE_QT		- Says that the port uses the latest version of qt toolkit.
121#
122# Dependency checking.  Use these if your port requires another port
123# not in the list above.
124#
125# FETCH_DEPENDS - A list of "path:dir[:target]" tuples of other ports this
126#				  package depends in the "fetch" stage.  "path" is the
127#				  name of a file if it starts with a slash (/), an
128#				  executable otherwise.  make will test for the
129#				  existence (if it is a full pathname) or search for
130#				  it in your $PATH (if it is an executable) and go
131#				  into "dir" to do a "make all install" if it's not
132#				  found.  If the third field ("target") exists, it will
133#				  be used instead of ${DEPENDS_TARGET}.
134# BUILD_DEPENDS - A list of "path:dir[:target]" tuples of other ports this
135#				  package depends to build (between the "extract" and
136#				  "build" stages, inclusive).  The test done to
137#				  determine the existence of the dependency is the
138#				  same as FETCH_DEPENDS.  If the third field ("target")
139#				  exists, it will be used instead of ${DEPENDS_TARGET}.
140# RUN_DEPENDS	- A list of "path:dir[:target]" tuples of other ports this
141#				  package depends to run.  The test done to determine
142#				  the existence of the dependency is the same as
143#				  FETCH_DEPENDS.  This will be checked during the
144#				  "install" stage and the name of the dependency will
145#				  be put into the package as well.  If the third field
146#				  ("target") exists, it will be used instead of
147#				  ${DEPENDS_TARGET}.
148# LIB_DEPENDS	- A list of "lib:dir[:target]" tuples of other ports this
149#				  package depends on.  "lib" is the name of a shared library.
150#				  make will use "ldconfig -r" to search for the
151#				  library.  Note that lib can be any regular expression,
152#				  and you need two backslashes in front of dots (.) to
153#				  supress its special meaning (e.g., use
154#				  "foo\\.2\\.:${PORTSDIR}/utils/foo" to match "libfoo.2.*").
155#				  If the third field ("target") exists, it will be used
156#				  instead of ${DEPENDS_TARGET}.
157# DEPENDS		- A list of "dir[:target]" tuples of other ports this
158#				  package depends on being made first.  Use this only for
159#				  things that don't fall into the above four categories.
160#				  If the second field ("target") exists, it will be used
161#				  instead of ${DEPENDS_TARGET}.
162# DEPENDS_TARGET - The default target to execute when a port is calling a
163#				  dependency (default: "install").
164#
165# Various directory definitions and variables to control them.
166# You rarely need to redefine any of these except WRKSRC and NO_WRKSUBDIR.
167#
168# X11BASE		- Where X11 ports install things (default: /usr/X11R6).
169# LOCALBASE		- Where non-X11 ports install things (default: /usr/local).
170# PREFIX		- Where *this* port installs its files (default: ${X11BASE}
171#				  if USE_X_PREFIX is set, otherwise ${LOCALBASE}).
172# PORTSDIR		- The root of the ports tree.  Defaults:
173#					FreeBSD/OpenBSD: /usr/ports
174#					NetBSD:          /usr/opt
175# DISTDIR 		- Where to get gzip'd, tarballed copies of original sources
176#				  (default: ${PORTSDIR}/distfiles).
177# PACKAGES		- A top level directory where all packages go (rather than
178#				  going locally to each port). (default: ${PORTSDIR}/packages).
179# WRKDIR 		- A temporary working directory that gets *clobbered* on clean
180#				  (default: ${.CURDIR}/work).
181# WRKSRC		- A subdirectory of ${WRKDIR} where the distribution actually
182#				  unpacks to.  (Default: ${WRKDIR}/${DISTNAME} unless
183#				  NO_WRKSUBDIR is set, in which case simply ${WRKDIR}).
184# NO_WRKSUBDIR	- Assume port unpacks directly into ${WRKDIR}.
185# NO_WRKDIR		- There's no work directory at all; port does this someplace
186#				  else.
187# PATCHDIR 		- A directory containing any additional patches you made
188#				  to port this software to FreeBSD (default:
189#				  ${.CURDIR}/patches)
190# SCRIPTDIR 	- A directory containing any auxiliary scripts
191#				  (default: ${.CURDIR}/scripts)
192# FILESDIR 		- A directory containing any miscellaneous additional files.
193#				  (default: ${.CURDIR}/files)
194# PKGDIR 		- A direction containing any package creation files.
195#				  (default: ${.CURDIR}/pkg)
196#
197# Motif support:
198#
199# REQUIRES_MOTIF - Set this in your port if it requires Motif.  It will  be
200#				  built only if HAVE_MOTIF is set.
201# HAVE_MOTIF	- If set, means system has Motif.  Typically set in
202#				  /etc/make.conf.
203# MOTIF_STATIC	- If set, link libXm statically; otherwise, link it
204#				  dynamically.  Typically set in /etc/make.conf.
205# MOTIFLIB		- Set automatically to appropriate value depending on
206#				  ${MOTIF_STATIC}.  Substitute references to -lXm with
207#				  patches to make your port conform to our standards.
208# MOTIF_ONLY	- If set, build Motif ports only.  (Not much use except for
209#				  building packages.)
210#
211# Variables that serve as convenient "aliases" for your *-install targets.
212# Use these like: "${INSTALL_PROGRAM} ${WRKSRC}/prog ${PREFIX}/bin".
213#
214# INSTALL_PROGRAM - A command to install binary executables.
215# INSTALL_SCRIPT - A command to install executable scripts.
216# INSTALL_DATA	- A command to install sharable data.
217# INSTALL_MAN	- A command to install manpages (doesn't compress).
218#
219# Set the following to specify all manpages that your port installs.
220# These manpages will be automatically listed in ${PLIST}.  Depending
221# on the setting of NOMANCOMPRESS, the make rules will compress the
222# manpages for you.
223#
224# MAN<sect>		- A list of manpages, categorized by section.  For
225#				  example, if your port has "man/man1/foo.1" and
226#				  "man/mann/bar.n", set "MAN1=foo.1" and "MANN=bar.n".
227#				  The available sections chars are "123456789LN".
228# MLINKS		- A list of <target, source> tuples for creating links
229#				  for manpages.  For example, "MLINKS= a.1 b.1 c.3 d.3"
230#				  will do an "ln -sf a.1 b.1" and "ln -sf c.3 and d.3" in
231#				  appropriate directories.  (Use this even if the port
232#				  installs its own manpage links so they will show up
233#				  correctly in ${PLIST}.)
234# MANPREFIX		- The directory prefix for ${MAN<sect>} and ${MLINKS}
235#				  (default: ${PREFIX}).
236# MAN<sect>PREFIX - If manual pages of some sections install in different
237#				  locations than others, use these (default: ${MANPREFIX}).
238# MANCOMPRESSED - This variable can take values "yes", "no" or
239#				  "maybe".  "yes" means manpages are installed
240#				  compressed; "no" means they are not; "maybe" means
241#				  it changes depending on the value of
242#				  NOMANCOMPRESS.  The default is "yes" if USE_IMAKE
243#				  is set and NO_INSTALL_MANPAGES is not set, and
244#				  "no" otherwise.
245#
246# Default targets and their behaviors:
247#
248# fetch			- Retrieves ${DISTFILES} (and ${PATCHFILES} if defined)
249#				  into ${DISTDIR} as necessary.
250# fetch-list	- Show list of files that would be retrieved by fetch
251# extract		- Unpacks ${DISTFILES} into ${WRKDIR}.
252# patch			- Apply any provided patches to the source.
253# configure		- Runs either GNU configure, one or more local configure
254#				  scripts or nothing, depending on what's available.
255# build			- Actually compile the sources.
256# install		- Install the results of a build.
257# reinstall		- Install the results of a build, ignoring "already installed"
258#				  flag.
259# deinstall		- Remove the installation.
260# package		- Create a package from an _installed_ port.
261# describe		- Try to generate a one-line description for each port for
262#				  use in INDEX files and the like.
263# checkpatch	- Do a "patch -C" instead of a "patch".  Note that it may
264#				  give incorrect results if multiple patches deal with
265#				  the same file.
266# checksum		- Use files/md5 to ensure that your distfiles are valid.
267# makesum		- Generate files/md5 (only do this for your own ports!).
268#
269# Default sequence for "all" is:  fetch checksum extract patch configure build
270#
271# Please read the comments in the targets section below, you
272# should be able to use the pre-* or post-* targets/scripts
273# (which are available for every stage except checksum) or
274# override the do-* targets to do pretty much anything you want.
275#
276# NEVER override the "regular" targets unless you want to open
277# a major can of worms.
278#
279# Set these variables if your port doesn't need some of the steps.
280# Note that there are no NO_PATCH or NO_CONFIGURE variables becuase
281# those steps are empty by default.  Also, NO_CHECKSUM is a user variable
282# and is not to be set in a port's Makefile.  See above for NO_PACKAGE.
283#
284# NO_EXTRACT	- Use a dummy (do-nothing) extract target.
285# NO_BUILD		- Use a dummy (do-nothing) build target.
286# NO_INSTALL	- Use a dummy (do-nothing) install target.
287#
288# Here are some variables used in various stages.
289#
290# For fetch:
291#
292# FETCH_CMD		  - Full path to ftp/http fetch command if not in $PATH
293#				  (default: /usr/bin/fetch).
294# FETCH_BEFORE_ARGS -
295#				  Arguments to ${FETCH_CMD} before filename (default: none).
296# FETCH_AFTER_ARGS -
297#				  Arguments to ${FETCH_CMD} following filename (default: none).
298#
299# For extract:
300#
301# EXTRACT_CMD	- Command for extracting archive (default: tar).
302# EXTRACT_BEFORE_ARGS -
303#				  Arguments to ${EXTRACT_CMD} before filename
304#				  (default: -xzf).
305# EXTRACT_AFTER_ARGS -
306#				  Arguments to ${EXTRACT_CMD} following filename
307#				  (default: none).
308#
309# For configure:
310#
311# HAS_CONFIGURE	- Says that the port has its own configure script.  The
312#				  configure stage will not do anything if this is not set.
313# GNU_CONFIGURE	- Set if you are using GNU configure (optional).  Implies
314#				  HAS_CONFIGURE.
315# CONFIGURE_SCRIPT - Name of configure script (defaults: configure).
316# CONFIGURE_ARGS - Pass these args to configure if ${HAS_CONFIGURE} is set.
317# CONFIGURE_ENV - Pass these env (shell-like) to configure if
318#				  ${HAS_CONFIGURE} is set.
319#
320# For build and install:
321#
322# MAKE_ENV		- Additional environment vars passed to sub-make in build
323#				  and install stages (default: see below).
324#
325# For install:
326#
327# NO_MTREE		- If set, will not invoke mtree from bsd.port.mk from
328#				  the "install" target.
329# MTREE_FILE	- The name of the mtree file (default: /etc/mtree/BSD.x11.dist
330#				  if USE_X_PREFIX is set, /etc/mtree/BSD.local.dist
331#				  otherwise.)
332# PLIST			- Name of the `packing list' file (default: ${PKGDIR}/PLIST).
333#				  Change this to ${WRKDIR}/PLIST or something if you
334#				  need to write to it.  (It is not a good idea for a port
335#				  to write to any file outside ${WRKDIR} during a normal
336#				  build.)
337# TMPPLIST		- Name of the `packing list' file after processing
338#				  (default: ${WRKDIR}/.PLIST.mktmp).
339# PLIST_SUB		- List of "variable=value" pair for substitution in ${PLIST}
340# 				  (default: see below).
341#
342# Note that the install target will automatically add manpages (see
343# above) and also substitute special sequences of characters (delimited
344# by "%%") as defined in PLIST_SUB to generate ${TMPPLIST}.  For
345# instance, "OSREL=${OSREL}" in PLIST_SUB causes all occurrences of
346# "%%OSREL%%" in ${PLIST} to be substituted by the value of OSREL.
347# ${TMPPLIST} is generated between the do-install and post-install
348# stages.  If you are generating the packing list on-the-fly, make
349# sure it's generated by the end of do-install!
350#
351# For package:
352#
353# NO_LATEST_LINK - Do not install the "Latest" link for package.  Define this
354#				  if this port is a beta version of another stable port
355#				  which is also in the tree.
356#
357# This is used in all stages:
358#
359# SCRIPTS_ENV	- Additional environment vars passed to scripts in
360#                 ${SCRIPTDIR} executed by bsd.port.mk (default: see below).
361#
362# Finally, variables to change if you want a special behavior.  These
363# are for debugging purposes.  Don't set them in your Makefile.
364#
365# ECHO_MSG		- Used to print all the '===>' style prompts - override this
366#				  to turn them off (default: /bin/echo).
367# PATCH_DEBUG	- If set, print out more information about the patches as
368#				  it attempts to apply them.
369# PKG_DBDIR		- Where package installation is recorded (default: /var/db/pkg)
370# NO_PKG_REGISTER - Don't register a port install as a package.
371# FORCE_PKG_REGISTER - If set, it will overwrite any existing package
372#				  registration information in ${PKG_DBDIR}/${PKGNAME}.
373# NO_DEPENDS	- Don't verify build of dependencies.
374# NO_CHECKSUM	- Don't verify the checksum.  Typically used when
375#				  when you noticed the distfile you just fetched has
376#				  a different checksum and you intend to verify if
377#				  the port still works with it.
378
379# Get the architecture
380ARCH!=	uname -m
381
382# Get the operating system type
383OPSYS!=	uname -s
384
385# Get the operating system revision
386OSREL!=	uname -r | sed -e 's/[-(].*//'
387PLIST_SUB+=	OSREL=${OSREL}
388
389# Get the object format.
390PORTOBJFORMAT!=	test -x /usr/bin/objformat && /usr/bin/objformat || echo aout
391CONFIGURE_ENV+=	PORTOBJFORMAT=${PORTOBJFORMAT}
392MAKE_ENV+=		PORTOBJFORMAT=${PORTOBJFORMAT}
393PLIST_SUB+=		PORTOBJFORMAT=${PORTOBJFORMAT}
394
395# If they exist, include Makefile.inc, then architecture/operating
396# system specific Makefiles, then local Makefile.local.
397
398.if exists(${.CURDIR}/../Makefile.inc)
399.include "${.CURDIR}/../Makefile.inc"
400.endif
401
402.if exists(${.CURDIR}/Makefile.${ARCH}-${OPSYS})
403.include "${.CURDIR}/Makefile.${ARCH}-${OPSYS}"
404.elif exists(${.CURDIR}/Makefile.${OPSYS})
405.include "${.CURDIR}/Makefile.${OPSYS}"
406.elif exists(${.CURDIR}/Makefile.${ARCH})
407.include "${.CURDIR}/Makefile.${ARCH}"
408.endif
409
410.if exists(${.CURDIR}/Makefile.local)
411.include "${.CURDIR}/Makefile.local"
412.endif
413
414# These need to be absolute since we don't know how deep in the ports
415# tree we are and thus can't go relative.  They can, of course, be overridden
416# by individual Makefiles or local system make configuration.
417.if (${OPSYS} == "NetBSD")
418PORTSDIR?=		/usr/opt
419.else
420PORTSDIR?=		/usr/ports
421.endif
422LOCALBASE?=		${DESTDIR}/usr/local
423X11BASE?=		${DESTDIR}/usr/X11R6
424DISTDIR?=		${PORTSDIR}/distfiles
425_DISTDIR?=		${DISTDIR}/${DIST_SUBDIR}
426PACKAGES?=		${PORTSDIR}/packages
427TEMPLATES?=		${PORTSDIR}/templates
428.if !defined(NO_WRKDIR)
429WRKDIR?=		${.CURDIR}/work
430.else
431WRKDIR?=		${.CURDIR}
432.endif
433.if defined(NO_WRKSUBDIR)
434WRKSRC?=		${WRKDIR}
435.else
436WRKSRC?=		${WRKDIR}/${DISTNAME}
437.endif
438
439.if exists(${.CURDIR}/patches.${ARCH}-${OPSYS})
440PATCHDIR?=		${.CURDIR}/patches.${ARCH}-${OPSYS}
441.elif exists(${.CURDIR}/patches.${OPSYS})
442PATCHDIR?=		${.CURDIR}/patches.${OPSYS}
443.elif exists(${.CURDIR}/patches.${ARCH})
444PATCHDIR?=		${.CURDIR}/patches.${ARCH}
445.else
446PATCHDIR?=		${.CURDIR}/patches
447.endif
448
449.if exists(${.CURDIR}/scripts.${ARCH}-${OPSYS})
450SCRIPTDIR?=		${.CURDIR}/scripts.${ARCH}-${OPSYS}
451.elif exists(${.CURDIR}/scripts.${OPSYS})
452SCRIPTDIR?=		${.CURDIR}/scripts.${OPSYS}
453.elif exists(${.CURDIR}/scripts.${ARCH})
454SCRIPTDIR?=		${.CURDIR}/scripts.${ARCH}
455.else
456SCRIPTDIR?=		${.CURDIR}/scripts
457.endif
458
459.if exists(${.CURDIR}/files.${ARCH}-${OPSYS})
460FILESDIR?=		${.CURDIR}/files.${ARCH}-${OPSYS}
461.elif exists(${.CURDIR}/files.${OPSYS})
462FILESDIR?=		${.CURDIR}/files.${OPSYS}
463.elif exists(${.CURDIR}/files.${ARCH})
464FILESDIR?=		${.CURDIR}/files.${ARCH}
465.else
466FILESDIR?=		${.CURDIR}/files
467.endif
468
469.if exists(${.CURDIR}/pkg.${ARCH}-${OPSYS})
470PKGDIR?=		${.CURDIR}/pkg.${ARCH}-${OPSYS}
471.elif exists(${.CURDIR}/pkg.${OPSYS})
472PKGDIR?=		${.CURDIR}/pkg.${OPSYS}
473.elif exists(${.CURDIR}/pkg.${ARCH})
474PKGDIR?=		${.CURDIR}/pkg.${ARCH}
475.else
476PKGDIR?=		${.CURDIR}/pkg
477.endif
478
479.if defined(MANCOMPRESSED)
480.if ${MANCOMPRESSED} != yes && ${MANCOMPRESSED} != no && \
481	${MANCOMPRESSED} != maybe
482.BEGIN:
483	@${ECHO_MSG} "Error: Value of MANCOMPRESSED (is \"${MANCOMPRESSED}\") can only be \"yes\", \"no\" or \"maybe\"".
484	@${FALSE}
485.endif
486.endif
487
488.if defined(USE_IMAKE) && ${OPSYS} != OpenBSD && !defined(NO_INSTALL_MANPAGES)
489MANCOMPRESSED?=	yes
490.else
491MANCOMPRESSED?=	no
492.endif
493
494.if defined(USE_IMAKE)
495USE_X_PREFIX=	yes
496.endif
497.if defined(USE_X_PREFIX)
498USE_XLIB=		yes
499.endif
500.if defined(USE_X_PREFIX)
501PREFIX?=		${X11BASE}
502.else
503PREFIX?=		${LOCALBASE}
504.endif
505
506.if defined(USE_GMAKE)
507BUILD_DEPENDS+=		gmake:${PORTSDIR}/devel/gmake
508.endif
509.if defined(USE_AUTOCONF)
510GNU_CONFIGURE=	yes
511BUILD_DEPENDS+=		autoconf:${PORTSDIR}/devel/autoconf
512.endif
513
514PERL_VERSION=	5.00502
515PERL_VER=		5.005
516PLIST_SUB+=		PERL_VERSION=${PERL_VERSION} \
517				PERL_VER=${PERL_VER}
518.if exists(/usr/bin/perl5)
519# 3.0-current after perl5 import
520PERL5=			/usr/bin/perl5
521.else
522PERL5=			${LOCALBASE}/bin/perl${PERL_VERSION}
523.if defined(USE_PERL5)
524BUILD_DEPENDS+=	perl${PERL_VERSION}:${PORTSDIR}/lang/perl5
525RUN_DEPENDS+=	perl${PERL_VERSION}:${PORTSDIR}/lang/perl5
526.endif
527.endif
528
529.if defined(USE_XLIB)
530LIB_DEPENDS+=	X11\\.6:${PORTSDIR}/x11/XFree86
531.endif
532
533.if defined(USE_QT)
534LIB_DEPENDS+=	qt\\.1\\.\\\(33\\\|40\\\):${PORTSDIR}/x11-toolkits/qt140
535.endif
536
537.if exists(${PORTSDIR}/../Makefile.inc)
538.include "${PORTSDIR}/../Makefile.inc"
539.endif
540
541# Don't change these!!!  These names are built into the _TARGET_USE macro,
542# there is no way to refer to them cleanly from within the macro AFAIK.
543EXTRACT_COOKIE?=	${WRKDIR}/.extract_done
544CONFIGURE_COOKIE?=	${WRKDIR}/.configure_done
545INSTALL_COOKIE?=	${WRKDIR}/.install_done
546BUILD_COOKIE?=		${WRKDIR}/.build_done
547PATCH_COOKIE?=		${WRKDIR}/.patch_done
548PACKAGE_COOKIE?=	${WRKDIR}/.package_done
549
550# How to do nothing.  Override if you, for some strange reason, would rather
551# do something.
552DO_NADA?=		/usr/bin/true
553
554# Miscellaneous overridable commands:
555GMAKE?=			gmake
556AUTOCONF?=		autoconf
557XMKMF?=			xmkmf -a
558.if exists(/sbin/md5)
559MD5?=			/sbin/md5
560.elif exists(/bin/md5)
561MD5?=			/bin/md5
562.elif exists(/usr/bin/md5)
563MD5?=			/usr/bin/md5
564.else
565MD5?=			md5
566.endif
567MD5_FILE?=		${FILESDIR}/md5
568
569MAKE_FLAGS?=	-f
570MAKEFILE?=		Makefile
571MAKE_ENV+=		PREFIX=${PREFIX} LOCALBASE=${LOCALBASE} X11BASE=${X11BASE} MOTIFLIB="${MOTIFLIB}" CFLAGS="${CFLAGS}" LIBDIR="${LIBDIR}"
572
573.if exists(/usr/bin/fetch)
574FETCH_CMD?=		/usr/bin/fetch
575.else
576FETCH_CMD?=		/usr/bin/ftp
577.endif
578
579TOUCH?=			/usr/bin/touch
580TOUCH_FLAGS?=	-f
581
582PATCH?=			/usr/bin/patch
583PATCH_STRIP?=	-p0
584PATCH_DIST_STRIP?=	-p0
585.if defined(PATCH_DEBUG)
586PATCH_DEBUG_TMP=	yes
587PATCH_ARGS?=	-d ${WRKSRC} -E ${PATCH_STRIP}
588PATCH_DIST_ARGS?=	-d ${WRKSRC} -E ${PATCH_DIST_STRIP}
589.else
590PATCH_DEBUG_TMP=	no
591PATCH_ARGS?=	-d ${WRKSRC} --forward --quiet -E ${PATCH_STRIP}
592PATCH_DIST_ARGS?=	-d ${WRKSRC} --forward --quiet -E ${PATCH_DIST_STRIP}
593.endif
594.if defined(BATCH)
595PATCH_ARGS+=		--batch
596PATCH_DIST_ARGS+=	--batch
597.endif
598
599.if defined(PATCH_CHECK_ONLY)
600PATCH_ARGS+=	-C
601PATCH_DIST_ARGS+=	-C
602.endif
603
604.if exists(/bin/tar)
605EXTRACT_CMD?=	/bin/tar
606.else
607EXTRACT_CMD?=	/usr/bin/tar
608.endif
609EXTRACT_SUFX?=	.tar.gz
610# Backwards compatability.
611.if defined(EXTRACT_ARGS)
612EXTRACT_BEFORE_ARGS?=   ${EXTRACT_ARGS}
613.else
614EXTRACT_BEFORE_ARGS?=   -xzf
615.endif
616
617# Figure out where the local mtree file is
618.if !defined(MTREE_FILE)
619.if defined(USE_X_PREFIX)
620MTREE_FILE=	/etc/mtree/BSD.x11.dist
621.else
622MTREE_FILE=	/etc/mtree/BSD.local.dist
623.endif
624.endif
625MTREE_CMD?=	/usr/sbin/mtree
626MTREE_ARGS?=	-U -f ${MTREE_FILE} -d -e -p
627
628# A few aliases for *-install targets
629INSTALL_PROGRAM= \
630	${INSTALL} ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE}
631INSTALL_SCRIPT= \
632	${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE}
633INSTALL_DATA= \
634	${INSTALL} ${COPY} -o ${SHAREOWN} -g ${SHAREGRP} -m ${SHAREMODE}
635INSTALL_MAN= \
636	${INSTALL} ${COPY} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE}
637
638INSTALL_MACROS=	BSD_INSTALL_PROGRAM="${INSTALL_PROGRAM}" \
639			BSD_INSTALL_SCRIPT="${INSTALL_SCRIPT}" \
640			BSD_INSTALL_DATA="${INSTALL_DATA}" \
641			BSD_INSTALL_MAN="${INSTALL_MAN}"
642MAKE_ENV+=	${INSTALL_MACROS}
643SCRIPTS_ENV+=	${INSTALL_MACROS}
644
645# The user can override the NO_PACKAGE by specifying this from
646# the make command line
647.if defined(FORCE_PACKAGE)
648.undef NO_PACKAGE
649.endif
650
651COMMENT?=	${PKGDIR}/COMMENT
652DESCR?=		${PKGDIR}/DESCR
653PLIST?=		${PKGDIR}/PLIST
654TMPPLIST?=	${WRKDIR}/.PLIST.mktmp
655
656PKG_CMD?=		/usr/sbin/pkg_create
657PKG_DELETE?=	/usr/sbin/pkg_delete
658.if !defined(PKG_ARGS)
659PKG_ARGS=		-v -c ${COMMENT} -d ${DESCR} -f ${TMPPLIST} -p ${PREFIX} -P "`${MAKE} package-depends|sort -u`"
660.if exists(${PKGDIR}/INSTALL)
661PKG_ARGS+=		-i ${PKGDIR}/INSTALL
662.endif
663.if exists(${PKGDIR}/DEINSTALL)
664PKG_ARGS+=		-k ${PKGDIR}/DEINSTALL
665.endif
666.if exists(${PKGDIR}/REQ)
667PKG_ARGS+=		-r ${PKGDIR}/REQ
668.endif
669.if exists(${PKGDIR}/MESSAGE)
670PKG_ARGS+=		-D ${PKGDIR}/MESSAGE
671.endif
672.if !defined(NO_MTREE)
673PKG_ARGS+=		-m ${MTREE_FILE}
674.endif
675.endif
676PKG_SUFX?=		.tgz
677# where pkg_add records its dirty deeds.
678PKG_DBDIR?=		/var/db/pkg
679
680# shared/dynamic motif libs
681.if defined(HAVE_MOTIF)
682.if defined(MOTIF_STATIC)
683MOTIFLIB?=	${X11BASE}/lib/libXm.a
684.else
685MOTIFLIB?=	-L${X11BASE}/lib -lXm
686.endif
687.endif
688
689AWK?=		/usr/bin/awk
690BASENAME?=	/usr/bin/basename
691CAT?=		/bin/cat
692CP?=		/bin/cp
693ECHO?=		/bin/echo
694EXPR?=		/bin/expr
695FALSE?=		/usr/bin/false
696GREP?=		/usr/bin/grep
697GUNZIP_CMD?=	/usr/bin/gunzip -f
698GZCAT?=		/usr/bin/gzcat
699GZIP?=		-9
700GZIP_CMD?=	/usr/bin/gzip -nf ${GZIP}
701LDCONFIG?=	/sbin/ldconfig
702LN?=		/bin/ln
703MKDIR?=		/bin/mkdir -p
704MV?=		/bin/mv
705RM?=		/bin/rm
706RMDIR?=		/bin/rmdir
707SED?=		/usr/bin/sed
708SETENV?=	/usr/bin/env
709SH?=		/bin/sh
710TR?=		/usr/bin/tr
711TRUE?=		/usr/bin/true
712
713# Used to print all the '===>' style prompts - override this to turn them off.
714ECHO_MSG?=		${ECHO}
715
716.for sub in ${PLIST_SUB}
717_sedsubplist!=	sym=`${ECHO} "${sub}" | ${SED} -e 's/=.*//'`; \
718		val=`${ECHO} "${sub}" | ${SED} -e 's/^[^=][^=]*=//'`; \
719		echo "${_sedsubplist} -e s!%%$${sym}%%!$${val}!g"
720.endfor
721
722ALL_TARGET?=		all
723INSTALL_TARGET?=	install
724
725# Popular master sites
726MASTER_SITE_XCONTRIB+=	\
727	ftp://crl.dec.com/pub/X11/contrib/%SUBDIR%/ \
728    ftp://ftp.eu.net/X11/contrib/%SUBDIR%/
729
730MASTER_SITE_GNU+=	\
731	ftp://prep.ai.mit.edu/pub/gnu/%SUBDIR%/ \
732	ftp://wuarchive.wustl.edu/systems/gnu/%SUBDIR%/
733
734MASTER_SITE_PERL_CPAN+=	\
735	ftp://ftp.digital.com/pub/plan/perl/CPAN/modules/by-module/%SUBDIR%/ \
736	ftp://ftp.cdrom.com/pub/perl/CPAN/modules/by-module/%SUBDIR%/
737
738MASTER_SITE_TEX_CTAN+=  \
739        ftp://ftp.cdrom.com/pub/tex/ctan/%SUBDIR%/  \
740        ftp://wuarchive.wustl.edu/packages/TeX/%SUBDIR%/  \
741        ftp://ftp.funet.fi/pub/TeX/CTAN/%SUBDIR%/  \
742        ftp://ftp.tex.ac.uk/tex-archive/%SUBDIR%/  \
743        ftp://ftp.dante.de/tex-archive/%SUBDIR%/
744
745MASTER_SITE_SUNSITE+=	\
746	ftp://sunsite.unc.edu/pub/Linux/%SUBDIR%/ \
747	ftp://ftp.infomagic.com/pub/mirrors/linux/sunsite/%SUBDIR%/ \
748	ftp://ftp.funet.fi/pub/mirrors/sunsite.unc.edu/pub/Linux/%SUBDIR%/
749
750MASTER_SITE_KDE+=	\
751	ftp://ftp.us.kde.org/pub/kde/%SUBDIR%/ \
752	ftp://ftp.kde.org/pub/kde/%SUBDIR%/ \
753	ftp://ftp.tuniv.szczecin.pl/pub/kde/%SUBDIR%/ \
754	ftp://ftp.fu-berlin.de/pub/unix/X11/gui/kde/%SUBDIR%/ \
755	ftp://ftp.blaze.net.au/pub/kde/%SUBDIR%/ \
756	ftp://ftp.dataplus.se/pub/linux/kde/%SUBDIR%/ \
757	ftp://ftp.caldera.com/pub/mirrors/kde/%SUBDIR%/
758
759# Empty declaration to avoid "variable MASTER_SITES recursive" error
760MASTER_SITES?=
761PATCH_SITES?=
762
763# To avoid double-slashes
764MASTER_SITE_SUBDIR?=	.
765PATCH_SITE_SUBDIR?=	.
766
767# Substitute subdirectory names
768MASTER_SITES:=	${MASTER_SITES:S/%SUBDIR%/${MASTER_SITE_SUBDIR}/}
769PATCH_SITES:=	${PATCH_SITES:S/%SUBDIR%/${PATCH_SITE_SUBDIR}/}
770
771# The primary backup site.
772MASTER_SITE_BACKUP?=	\
773	ftp://ftp.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/
774
775# If the user has this set, go to the FreeBSD repository for everything.
776.if defined(MASTER_SITE_FREEBSD)
777MASTER_SITE_OVERRIDE=  ${MASTER_SITE_BACKUP}
778.endif
779
780# Where to put distfiles that don't have any other master site
781MASTER_SITE_LOCAL?= \
782	ftp://ftp.freebsd.org/pub/FreeBSD/distfiles/LOCAL_PORTS/
783
784# I guess we're in the master distribution business! :)  As we gain mirror
785# sites for distfiles, add them to this list.
786.if !defined(MASTER_SITE_OVERRIDE)
787MASTER_SITES+=	${MASTER_SITE_BACKUP}
788PATCH_SITES+=	${MASTER_SITE_BACKUP}
789.else
790MASTER_SITES:=	${MASTER_SITE_OVERRIDE} ${MASTER_SITES}
791PATCH_SITES:=	${MASTER_SITE_OVERRIDE} ${PATCH_SITES}
792.endif
793
794# Search CDROM first if mounted, symlink instead of copy if
795# FETCH_SYMLINK_DISTFILES is set
796CD_MOUNTPT?=	/cdrom
797.if exists(${CD_MOUNTPT}/ports/distfiles)
798MASTER_SITES:=	file:${CD_MOUNTPT}/ports/distfiles/${DIST_SUBDIR}/ ${MASTER_SITES}
799PATCH_SITES:=	file:${CD_MOUNTPT}/ports/distfiles/${DIST_SUBDIR}/ ${PATCH_SITES}
800.if defined(FETCH_SYMLINK_DISTFILES)
801FETCH_BEFORE_ARGS+=	-l
802.endif
803.endif
804
805# Derived names so that they're easily overridable.
806DISTFILES?=		${DISTNAME}${EXTRACT_SUFX}
807PKGNAME?=		${DISTNAME}
808
809ALLFILES?=	${DISTFILES} ${PATCHFILES}
810
811.if defined(IGNOREFILES)
812CKSUMFILES!=	\
813	for file in ${ALLFILES}; do \
814		ignore=0; \
815		for tmp in ${IGNOREFILES}; do \
816			if [ "$$file" = "$$tmp" ]; then \
817				ignore=1; \
818			fi; \
819		done; \
820		if [ "$$ignore" = 0 ]; then \
821			echo "$$file"; \
822		fi; \
823	done
824.else
825CKSUMFILES=		${ALLFILES}
826.endif
827
828# List of all files, with ${DIST_SUBDIR} in front.  Used for checksum.
829.if defined(DIST_SUBDIR)
830_CKSUMFILES?=	${CKSUMFILES:S/^/${DIST_SUBDIR}\//}
831_IGNOREFILES?=	${IGNOREFILES:S/^/${DIST_SUBDIR}\//}
832.else
833_CKSUMFILES?=	${CKSUMFILES}
834_IGNOREFILES?=	${IGNOREFILES}
835.endif
836
837# This is what is actually going to be extracted, and is overridable
838#  by user.
839EXTRACT_ONLY?=	${DISTFILES}
840
841# Documentation
842MAINTAINER?=	ports@FreeBSD.ORG
843
844.if !defined(CATEGORIES)
845.BEGIN:
846	@${ECHO_MSG} "CATEGORIES is mandatory."
847	@${FALSE}
848.endif
849
850# Note this has to start with a capital letter (or more accurately, it
851#  shouldn't match "[a-z]*"), see the target "delete-package-links" below.
852PKGREPOSITORYSUBDIR?=	All
853PKGREPOSITORY?=		${PACKAGES}/${PKGREPOSITORYSUBDIR}
854.if exists(${PACKAGES})
855PKGFILE?=		${PKGREPOSITORY}/${PKGNAME}${PKG_SUFX}
856.else
857PKGFILE?=		${.CURDIR}/${PKGNAME}${PKG_SUFX}
858.endif
859
860# The "latest version" link -- ${PKGNAME} minus everthing after the last '-'
861PKGLATESTREPOSITORY?=	${PACKAGES}/Latest
862PKGBASE!=	${ECHO} ${PKGNAME} | ${SED} -e 's/-[^-]*$$//'
863PKGLATESTFILE?=		${PKGLATESTREPOSITORY}/${PKGBASE}${PKG_SUFX}
864
865CONFIGURE_SCRIPT?=	configure
866
867.if defined(GNU_CONFIGURE)
868CONFIGURE_ARGS+=	--prefix=${PREFIX}
869HAS_CONFIGURE=		yes
870.endif
871
872# Passed to most of script invocations
873SCRIPTS_ENV+=	CURDIR=${.CURDIR} DISTDIR=${DISTDIR} \
874		  WRKDIR=${WRKDIR} WRKSRC=${WRKSRC} PATCHDIR=${PATCHDIR} \
875		  SCRIPTDIR=${SCRIPTDIR} FILESDIR=${FILESDIR} \
876		  PORTSDIR=${PORTSDIR} DEPENDS="${DEPENDS}" \
877		  PREFIX=${PREFIX} LOCALBASE=${LOCALBASE} X11BASE=${X11BASE}
878
879.if defined(BATCH)
880SCRIPTS_ENV+=	BATCH=yes
881.endif
882
883MANPREFIX?=	${PREFIX}
884
885.for sect in 1 2 3 4 5 6 7 8 9
886MAN${sect}PREFIX?=	${MANPREFIX}
887.endfor
888MANLPREFIX?=	${MANPREFIX}
889MANNPREFIX?=	${MANPREFIX}
890
891MANLANG?=	""	# english only by default
892
893.if !defined(NOMANCOMPRESS)
894MANEXT=	.gz
895.endif
896
897.if defined(MLINKS)
898__pmlinks!=	${ECHO} '${MLINKS:S/	/ /}' | ${AWK} \
899 '{ if (NF % 2 != 0) { print "broken"; exit; } \
900	for (i=1; i<=NF; i++) { \
901		if ($$i ~ /^-$$/ && i != 1 && i % 2 != 0) \
902			{ $$i = $$(i-2); printf " " $$i " "; } \
903		else if ($$i ~ /^[^ ]+\.[1-9ln][^. ]*$$/ || $$i ~ /^\//) \
904			printf " " $$i " "; \
905		else \
906			{ print "broken"; exit; } \
907	} \
908  }' | ${SED} -e 's/ \/[^ ]*/ &x/g' -e 's/ [^/ ][^ ]*\.\(.\)[^. ]*/ &\1/g'
909.if ${__pmlinks:Mbroken} == "broken"
910.BEGIN:
911	@${ECHO_MSG} "Error: Unable to parse MLINKS."
912	@${FALSE}
913.endif
914.endif
915
916.for lang in ${MANLANG}
917
918.for sect in 1 2 3 4 5 6 7 8 9
919.if defined(MAN${sect})
920_MANPAGES+=	${MAN${sect}:S%^%${MAN${sect}PREFIX}/man/${lang}/man${sect}/%}
921.endif
922.endfor
923
924.if defined(MANL)
925_MANPAGES+=	${MANL:S%^%${MANLPREFIX}/man/${lang}/manl/%}
926.endif
927
928.if defined(MANN)
929_MANPAGES+=	${MANN:S%^%${MANNPREFIX}/man/${lang}/mann/%}
930.endif
931
932.if defined(MLINKS)
933.for __page in ${__pmlinks}
934__name=	${__page:S// /:N[1-9lnx]}
935__sect=	${__page:S// /:M[1-9lnx]}
936.if ${__name:M/*}x == x
937_MLINKS+=	${MAN${__sect:S/l/L/:S/n/N/}PREFIX}/man/${lang}/man${__sect}/${__name}${MANEXT}
938.else
939_MLINKS+=	${__name}${MANEXT}
940.endif
941_MLINKS:=	${_MLINKS}
942.endfor
943.endif
944
945.endfor lang in ${MANLANG}
946
947_TMLINKS!=	${ECHO} ${_MLINKS} | ${AWK} '{for (i=2; i<=NF; i+=2) print $$i}'
948
949.if defined(_MANPAGES) && defined(NOMANCOMPRESS)
950__MANPAGES:=	${_MANPAGES:S^${PREFIX}/^^:S/""//:S^//^/^g}
951.elif defined(_MANPAGES)
952__MANPAGES:=	${_MANPAGES:S^${PREFIX}/^^:S/""//:S^//^/^g:S/$/.gz/}
953.endif
954
955.if defined(_MANPAGES) && ${MANCOMPRESSED} == "yes"
956_MANPAGES:=	${_MANPAGES:S/$/.gz/}
957.endif
958
959.MAIN: all
960
961################################################################
962# Many ways to disable a port.
963#
964# If we're in BATCH mode and the port is interactive, or we're
965# in interactive mode and the port is non-interactive, skip all
966# the important targets.  The reason we have two modes is that
967# one might want to leave a build in BATCH mode running
968# overnight, then come back in the morning and do _only_ the
969# interactive ones that required your intervention.
970#
971# Don't attempt to build ports that require Motif if you don't
972# have Motif.
973#
974# Ignore ports that can't be resold if building for a CDROM.
975#
976# Don't build a port if it's restricted and we don't want to get
977# into that.
978#
979# Don't build a port if it's broken.
980################################################################
981
982OLDSYSTCL!=	${ECHO} /usr/include/tcl.h /usr/lib/libtcl??.so.*.*
983OLDTCL=		${LOCALBASE}/include/tcl.h ${LOCALBASE}/lib/tclConfig.sh
984OLDTK=		${LOCALBASE}/include/tk.h ${LOCALBASE}/lib/tkConfig.sh
985
986.if !defined(NO_IGNORE)
987.for file in ${OLDSYSTCL} ${OLDTCL}
988.if exists(${file})
989IGNORE=	": You have an old file \(${file}\) that could cause problems for some ports to compile.  Please remove it and try again.  You may have to reinstall tcl from the ports tree afterwards"
990.endif
991.endfor
992.for file in ${OLDTK}
993.if exists(${file})
994IGNORE=	": You have an old file \(${file}\) that could cause problems for some ports to compile.  Please remove it and try again.  You may have to reinstall tk from the ports tree afterwards"
995.endif
996.endfor
997.endif
998
999.if !defined(NO_IGNORE)
1000.if (defined(IS_INTERACTIVE) && defined(BATCH))
1001IGNORE=	"is an interactive port"
1002.elif (!defined(IS_INTERACTIVE) && defined(INTERACTIVE))
1003IGNORE=	"is not an interactive port"
1004.elif (defined(REQUIRES_MOTIF) && !defined(HAVE_MOTIF))
1005IGNORE=	"requires Motif"
1006.elif (defined(MOTIF_ONLY) && !defined(REQUIRES_MOTIF))
1007IGNORE=	"does not require Motif"
1008.elif (defined(NO_CDROM) && defined(FOR_CDROM))
1009IGNORE=	"may not be placed on a CDROM: ${NO_CDROM}"
1010.elif (defined(RESTRICTED) && defined(NO_RESTRICTED))
1011IGNORE=	"is restricted: ${RESTRICTED}"
1012.elif defined(NO_CONFIGURE)
1013IGNORE=	"defines NO_CONFIGURE, which is obsoleted"
1014.elif defined(NO_PATCH)
1015IGNORE=	"defines NO_PATCH, which is obsoleted"
1016.elif defined(BROKEN)
1017IGNORE=	"is marked as broken: ${BROKEN}"
1018.endif
1019
1020.if (defined(MANUAL_PACKAGE_BUILD) && defined(PACKAGE_BUILDING))
1021IGNORE=	"package has to be built manually: ${MANUAL_PACKAGE_BUILD}"
1022clean:
1023	@${IGNORECMD}
1024.endif
1025
1026.if defined(IGNORE)
1027.if defined(IGNORE_SILENT)
1028IGNORECMD=	${DO_NADA}
1029.else
1030IGNORECMD=	${ECHO_MSG} "===>  ${PKGNAME} ${IGNORE}."
1031.endif
1032fetch:
1033	@${IGNORECMD}
1034checksum:
1035	@${IGNORECMD}
1036extract:
1037	@${IGNORECMD}
1038patch:
1039	@${IGNORECMD}
1040configure:
1041	@${IGNORECMD}
1042all:
1043	@${IGNORECMD}
1044build:
1045	@${IGNORECMD}
1046install:
1047	@${IGNORECMD}
1048reinstall:
1049	@${IGNORECMD}
1050package:
1051	@${IGNORECMD}
1052.endif
1053.endif
1054
1055.if defined(ALL_HOOK)
1056all:
1057	@cd ${.CURDIR} && ${SETENV} CURDIR=${.CURDIR} DISTNAME=${DISTNAME} \
1058	  DISTDIR=${DISTDIR} WRKDIR=${WRKDIR} WRKSRC=${WRKSRC} \
1059	  PATCHDIR=${PATCHDIR} SCRIPTDIR=${SCRIPTDIR} \
1060	  FILESDIR=${FILESDIR} PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} \
1061	  DEPENDS="${DEPENDS}" BUILD_DEPENDS="${BUILD_DEPENDS}" \
1062	  RUN_DEPENDS="${RUN_DEPENDS}" X11BASE=${X11BASE} \
1063	${ALL_HOOK}
1064.endif
1065
1066.if !target(all)
1067all: build
1068.endif
1069
1070.if !defined(DEPENDS_TARGET)
1071.if make(reinstall)
1072DEPENDS_TARGET=	reinstall
1073.else
1074DEPENDS_TARGET=	install
1075.endif
1076.endif
1077
1078################################################################
1079# The following are used to create easy dummy targets for
1080# disabling some bit of default target behavior you don't want.
1081# They still check to see if the target exists, and if so don't
1082# do anything, since you might want to set this globally for a
1083# group of ports in a Makefile.inc, but still be able to
1084# override from an individual Makefile.
1085################################################################
1086
1087# Disable checksum
1088.if defined(NO_CHECKSUM) && !target(checksum)
1089checksum: fetch
1090	@${DO_NADA}
1091.endif
1092
1093# Disable extract
1094.if defined(NO_EXTRACT) && !target(extract)
1095extract: fetch
1096	@${TOUCH} ${TOUCH_FLAGS} ${EXTRACT_COOKIE}
1097.endif
1098
1099# Disable build
1100.if defined(NO_BUILD) && !target(build)
1101build: configure
1102	@${TOUCH} ${TOUCH_FLAGS} ${BUILD_COOKIE}
1103.endif
1104
1105# Disable install
1106.if defined(NO_INSTALL) && !target(install)
1107install: build
1108	@${TOUCH} ${TOUCH_FLAGS} ${INSTALL_COOKIE}
1109.endif
1110
1111# Disable package
1112.if defined(NO_PACKAGE) && !target(package)
1113package:
1114.if defined(IGNORE_SILENT)
1115	@${DO_NADA}
1116.else
1117	@${ECHO_MSG} "===>  ${PKGNAME} may not be packaged: ${NO_PACKAGE}."
1118.endif
1119.endif
1120
1121# Disable describe
1122.if defined(NO_DESCRIBE) && !target(describe)
1123describe:
1124	@${DO_NADA}
1125.endif
1126
1127################################################################
1128# More standard targets start here.
1129#
1130# These are the body of the build/install framework.  If you are
1131# not happy with the default actions, and you can't solve it by
1132# adding pre-* or post-* targets/scripts, override these.
1133################################################################
1134
1135# Fetch
1136
1137.if !target(do-fetch)
1138do-fetch:
1139	@${MKDIR} ${_DISTDIR}
1140	@(cd ${_DISTDIR}; \
1141	 for file in ${DISTFILES}; do \
1142		if [ ! -f $$file -a ! -f `${BASENAME} $$file` ]; then \
1143			if [ -h $$file -o -h `${BASENAME} $$file` ]; then \
1144				${ECHO_MSG} ">> ${_DISTDIR}/$$file is a broken symlink."; \
1145				${ECHO_MSG} ">> Perhaps a filesystem (most likely a CD) isn't mounted?"; \
1146				${ECHO_MSG} ">> Please correct this problem and try again."; \
1147				exit 1; \
1148			fi ; \
1149			${ECHO_MSG} ">> $$file doesn't seem to exist on this system."; \
1150			for site in ${MASTER_SITES}; do \
1151			    ${ECHO_MSG} ">> Attempting to fetch from $${site}."; \
1152				if ${FETCH_CMD} ${FETCH_BEFORE_ARGS} $${site}$${file} ${FETCH_AFTER_ARGS}; then \
1153					continue 2; \
1154				fi \
1155			done; \
1156			${ECHO_MSG} ">> Couldn't fetch it - please try to retrieve this";\
1157			${ECHO_MSG} ">> port manually into ${_DISTDIR} and try again."; \
1158			exit 1; \
1159	    fi \
1160	 done)
1161.if defined(PATCHFILES)
1162	@(cd ${_DISTDIR}; \
1163	 for file in ${PATCHFILES}; do \
1164		if [ ! -f $$file -a ! -f `${BASENAME} $$file` ]; then \
1165			if [ -h $$file -o -h `${BASENAME} $$file` ]; then \
1166				${ECHO_MSG} ">> ${_DISTDIR}/$$file is a broken symlink."; \
1167				${ECHO_MSG} ">> Perhaps a filesystem (most likely a CD) isn't mounted?"; \
1168				${ECHO_MSG} ">> Please correct this problem and try again."; \
1169				exit 1; \
1170			fi ; \
1171			${ECHO_MSG} ">> $$file doesn't seem to exist on this system."; \
1172			for site in ${PATCH_SITES}; do \
1173			    ${ECHO_MSG} ">> Attempting to fetch from $${site}."; \
1174				if ${FETCH_CMD} ${FETCH_BEFORE_ARGS} $${site}$${file} ${FETCH_AFTER_ARGS}; then \
1175					continue 2; \
1176				fi \
1177			done; \
1178			${ECHO_MSG} ">> Couldn't fetch it - please try to retrieve this";\
1179			${ECHO_MSG} ">> port manually into ${_DISTDIR} and try again."; \
1180			exit 1; \
1181	    fi \
1182	 done)
1183.endif
1184.endif
1185
1186# Extract
1187
1188.if !target(do-extract)
1189do-extract:
1190.if !defined(NO_WRKDIR)
1191	@${RM} -rf ${WRKDIR}
1192	@${MKDIR} ${WRKDIR}
1193.endif
1194	@for file in ${EXTRACT_ONLY}; do \
1195		if ! (cd ${WRKDIR} && ${EXTRACT_CMD} ${EXTRACT_BEFORE_ARGS} ${_DISTDIR}/$$file ${EXTRACT_AFTER_ARGS});\
1196		then \
1197			exit 1; \
1198		fi \
1199	done
1200.endif
1201
1202# Patch
1203
1204.if !target(do-patch)
1205do-patch:
1206.if defined(PATCHFILES)
1207	@${ECHO_MSG} "===>  Applying distribution patches for ${PKGNAME}"
1208	@(cd ${_DISTDIR}; \
1209	  for i in ${PATCHFILES}; do \
1210		if [ ${PATCH_DEBUG_TMP} = yes ]; then \
1211			${ECHO_MSG} "===>   Applying distribution patch $$i" ; \
1212		fi; \
1213		case $$i in \
1214			*.Z|*.gz) \
1215				${GZCAT} $$i | ${PATCH} ${PATCH_DIST_ARGS}; \
1216				;; \
1217			*) \
1218				${PATCH} ${PATCH_DIST_ARGS} < $$i; \
1219				;; \
1220		esac; \
1221	  done)
1222.endif
1223	@if [ -d ${PATCHDIR} ]; then \
1224		if [ "`echo ${PATCHDIR}/patch-*`" = "${PATCHDIR}/patch-*" ]; then \
1225			${ECHO_MSG} "===>   Ignoring empty patch directory"; \
1226			if [ -d ${PATCHDIR}/CVS ]; then \
1227				${ECHO_MSG} "===>   Perhaps you forgot the -P flag to cvs co or update?"; \
1228			fi; \
1229		else \
1230			${ECHO_MSG} "===>  Applying ${OPSYS} patches for ${PKGNAME}" ; \
1231			for i in ${PATCHDIR}/patch-*; do \
1232				case $$i in \
1233					*.orig|*.rej|*~) \
1234						${ECHO_MSG} "===>   Ignoring patchfile $$i" ; \
1235						;; \
1236					*) \
1237						if [ ${PATCH_DEBUG_TMP} = yes ]; then \
1238							${ECHO_MSG} "===>   Applying ${OPSYS} patch $$i" ; \
1239						fi; \
1240						${PATCH} ${PATCH_ARGS} < $$i; \
1241						;; \
1242				esac; \
1243			done; \
1244		fi; \
1245	fi
1246.endif
1247
1248# Configure
1249
1250.if !target(do-configure)
1251do-configure:
1252.if defined(USE_AUTOCONF)
1253	@(cd ${WRKSRC} && ${AUTOCONF})
1254.endif
1255	@if [ -f ${SCRIPTDIR}/configure ]; then \
1256		cd ${.CURDIR} && ${SETENV} ${SCRIPTS_ENV} ${SH} \
1257		  ${SCRIPTDIR}/configure; \
1258	fi
1259.if defined(HAS_CONFIGURE)
1260	@(cd ${WRKSRC} && CC="${CC}" CXX="${CXX}" ac_cv_path_CC="${CC}" \
1261	    CFLAGS="${CFLAGS}" \
1262	    INSTALL="/usr/bin/install -c -o ${BINOWN} -g ${BINGRP}" \
1263	    INSTALL_DATA="${INSTALL_DATA}" \
1264	    INSTALL_PROGRAM="${INSTALL_PROGRAM}" \
1265	    INSTALL_SCRIPT="${INSTALL_SCRIPT}" \
1266	    ${CONFIGURE_ENV} ./${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS})
1267.endif
1268.if defined(USE_IMAKE)
1269	@(cd ${WRKSRC} && ${XMKMF})
1270.endif
1271.endif
1272
1273# Build
1274
1275.if !target(do-build)
1276do-build:
1277.if defined(USE_GMAKE)
1278	@(cd ${WRKSRC}; ${SETENV} ${MAKE_ENV} ${GMAKE} ${MAKE_FLAGS} ${MAKEFILE} ${ALL_TARGET})
1279.else defined(USE_GMAKE)
1280	@(cd ${WRKSRC}; ${SETENV} ${MAKE_ENV} ${MAKE} ${MAKE_FLAGS} ${MAKEFILE} ${ALL_TARGET})
1281.endif
1282.endif
1283
1284# Install
1285
1286.if !target(do-install)
1287do-install:
1288.if defined(USE_GMAKE)
1289	@(cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} ${GMAKE} ${MAKE_FLAGS} ${MAKEFILE} ${INSTALL_TARGET})
1290.if defined(USE_IMAKE) && !defined(NO_INSTALL_MANPAGES)
1291	@(cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} ${GMAKE} ${MAKE_FLAGS} ${MAKEFILE} install.man)
1292.endif
1293.else defined(USE_GMAKE)
1294	@(cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} ${MAKE} ${MAKE_FLAGS} ${MAKEFILE} ${INSTALL_TARGET})
1295.if defined(USE_IMAKE) && !defined(NO_INSTALL_MANPAGES)
1296	@(cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} ${MAKE} ${MAKE_FLAGS} ${MAKEFILE} install.man)
1297.endif
1298.endif
1299.endif
1300
1301# Package
1302
1303.if !target(do-package)
1304do-package: ${TMPPLIST}
1305	@${ECHO_MSG} "===>  Building package for ${PKGNAME}"
1306	@if [ -d ${PACKAGES} ]; then \
1307		if [ ! -d ${PKGREPOSITORY} ]; then \
1308			if ! ${MKDIR} ${PKGREPOSITORY}; then \
1309				${ECHO_MSG} ">> Can't create directory ${PKGREPOSITORY}."; \
1310				exit 1; \
1311			fi; \
1312		fi; \
1313	fi
1314	@if ${PKG_CMD} ${PKG_ARGS} ${PKGFILE}; then \
1315		if [ -d ${PACKAGES} ]; then \
1316			${MAKE} ${.MAKEFLAGS} package-links; \
1317		fi; \
1318	else \
1319		${MAKE} ${.MAKEFLAGS} delete-package; \
1320		exit 1; \
1321	fi
1322.endif
1323
1324# Some support rules for do-package
1325
1326.if !target(package-links)
1327package-links:
1328	@${MAKE} ${.MAKEFLAGS} delete-package-links
1329	@for cat in ${CATEGORIES}; do \
1330		if [ ! -d ${PACKAGES}/$$cat ]; then \
1331			if ! ${MKDIR} ${PACKAGES}/$$cat; then \
1332				${ECHO_MSG} ">> Can't create directory ${PACKAGES}/$$cat."; \
1333				exit 1; \
1334			fi; \
1335		fi; \
1336		${LN} -s ../${PKGREPOSITORYSUBDIR}/${PKGNAME}${PKG_SUFX} ${PACKAGES}/$$cat; \
1337	done
1338.if !defined(NO_LATEST_LINK)
1339	@if [ ! -d ${PKGLATESTREPOSITORY} ]; then \
1340		if ! ${MKDIR} ${PKGLATESTREPOSITORY}; then \
1341			${ECHO_MSG} ">> Can't create directory ${PKGLATESTREPOSITORY}."; \
1342			exit 1; \
1343		fi; \
1344	fi
1345	@${LN} -s ../${PKGREPOSITORYSUBDIR}/${PKGNAME}${PKG_SUFX} ${PKGLATESTFILE}
1346.endif
1347.endif
1348
1349.if !target(delete-package-links)
1350delete-package-links:
1351	@${RM} -f ${PACKAGES}/[a-z]*/${PKGNAME}${PKG_SUFX}
1352.if !defined(NO_LATEST_LINK)
1353	@${RM} -f ${PKGLATESTFILE}
1354.endif
1355.endif
1356
1357.if !target(delete-package)
1358delete-package:
1359	@${MAKE} ${.MAKEFLAGS} delete-package-links
1360	@${RM} -f ${PKGFILE}
1361.endif
1362
1363################################################################
1364# This is the "generic" port target, actually a macro used from the
1365# six main targets.  See below for more.
1366################################################################
1367
1368_PORT_USE: .USE
1369.if make(real-fetch)
1370	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} fetch-depends
1371.endif
1372.if make(real-extract)
1373	@cd ${.CURDIR} && ${MAKE} checksum
1374	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} build-depends lib-depends misc-depends
1375.endif
1376.if make(real-install)
1377.if !defined(NO_PKG_REGISTER) && !defined(FORCE_PKG_REGISTER)
1378	@if [ -d ${PKG_DBDIR}/${PKGNAME} ]; then \
1379		${ECHO_MSG} "===>  ${PKGNAME} is already installed - perhaps an older version?"; \
1380		${ECHO_MSG} "      If so, you may wish to \`\`make deinstall'' and install"; \
1381		${ECHO_MSG} "      this port again by \`\`make reinstall'' to upgrade it properly."; \
1382		${ECHO_MSG} "      If you really wish to overwrite the old port of ${PKGNAME}"; \
1383		${ECHO_MSG} "      without deleting it first, set the variable \"FORCE_PKG_REGISTER\""; \
1384		${ECHO_MSG} "      in your environment or the \"make install\" command line."; \
1385		exit 1; \
1386	fi
1387.endif
1388	@if [ `${SH} -c umask` != 0022 ]; then \
1389		${ECHO_MSG} "===>  Warning: your umask is \"`${SH} -c umask`"\".; \
1390		${ECHO_MSG} "      If this is not desired, set it to an appropriate value"; \
1391		${ECHO_MSG} "      and install this port again by \`\`make reinstall''."; \
1392	fi
1393	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} run-depends lib-depends
1394.endif
1395.if make(real-install)
1396.if !defined(NO_MTREE)
1397	@if [ `id -u` = 0 ]; then \
1398		${MKDIR} ${PREFIX}; \
1399		if [ ! -f ${MTREE_FILE} ]; then \
1400			${ECHO_MSG} "Error: mtree file \"${MTREE_FILE}\" is missing."; \
1401			${ECHO_MSG} "Copy it from a suitable location (e.g., /usr/src/etc/mtree) and try again."; \
1402			exit 1; \
1403		else \
1404			${MTREE_CMD} ${MTREE_ARGS} ${PREFIX}/; \
1405		fi; \
1406	else \
1407		${ECHO_MSG} "Warning: not superuser, can't run mtree."; \
1408		${ECHO_MSG} "Become root and try again to ensure correct permissions."; \
1409	fi
1410.endif
1411.endif
1412	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} ${.TARGET:S/^real-/pre-/}
1413	@if [ -f ${SCRIPTDIR}/${.TARGET:S/^real-/pre-/} ]; then \
1414		cd ${.CURDIR} && ${SETENV} ${SCRIPTS_ENV} ${SH} \
1415			${SCRIPTDIR}/${.TARGET:S/^real-/pre-/}; \
1416	fi
1417	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} ${.TARGET:S/^real-/do-/}
1418# put here so ports can change the contents of ${TMPPLIST} if necessary
1419.if make(real-install)
1420	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} generate-plist
1421.endif
1422	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} ${.TARGET:S/^real-/post-/}
1423	@if [ -f ${SCRIPTDIR}/${.TARGET:S/^real-/post-/} ]; then \
1424		cd ${.CURDIR} && ${SETENV} ${SCRIPTS_ENV} ${SH} \
1425			${SCRIPTDIR}/${.TARGET:S/^real-/post-/}; \
1426	fi
1427.if make(real-install) && (defined(_MANPAGES) || defined(_MLINKS))
1428	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} compress-man
1429.endif
1430.if make(real-install) && !defined(NO_PKG_REGISTER)
1431	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} fake-pkg
1432.endif
1433.if !make(real-fetch) \
1434	&& (!make(real-patch) || !defined(PATCH_CHECK_ONLY)) \
1435	&& (!make(real-package) || !defined(PACKAGE_NOINSTALL))
1436	@${TOUCH} ${TOUCH_FLAGS} ${WRKDIR}/.${.TARGET:S/^real-//}_done
1437.endif
1438
1439################################################################
1440# Skeleton targets start here
1441#
1442# You shouldn't have to change these.  Either add the pre-* or
1443# post-* targets/scripts or redefine the do-* targets.  These
1444# targets don't do anything other than checking for cookies and
1445# call the necessary targets/scripts.
1446################################################################
1447
1448.if !target(fetch)
1449fetch:
1450	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} real-fetch
1451.endif
1452
1453.if !target(extract)
1454extract: ${EXTRACT_COOKIE}
1455.endif
1456
1457.if !target(patch)
1458patch: ${PATCH_COOKIE}
1459.endif
1460
1461.if !target(configure)
1462configure: ${CONFIGURE_COOKIE}
1463.endif
1464
1465.if !target(build)
1466build: ${BUILD_COOKIE}
1467.endif
1468
1469.if !target(install)
1470install: ${INSTALL_COOKIE}
1471.endif
1472
1473.if !target(package)
1474package: ${PACKAGE_COOKIE}
1475.endif
1476
1477${EXTRACT_COOKIE}:
1478	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} fetch
1479	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} real-extract
1480${PATCH_COOKIE}:
1481	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} extract
1482	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} real-patch
1483${CONFIGURE_COOKIE}:
1484	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} patch
1485	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} real-configure
1486${BUILD_COOKIE}:
1487	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} configure
1488	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} real-build
1489${INSTALL_COOKIE}:
1490	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} build
1491	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} real-install
1492${PACKAGE_COOKIE}:
1493	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} install
1494	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} real-package
1495
1496# And call the macros
1497
1498real-fetch: _PORT_USE
1499real-extract: _PORT_USE
1500	@${ECHO_MSG} "===>  Extracting for ${PKGNAME}"
1501real-patch: _PORT_USE
1502	@${ECHO_MSG} "===>  Patching for ${PKGNAME}"
1503real-configure: _PORT_USE
1504	@${ECHO_MSG} "===>  Configuring for ${PKGNAME}"
1505real-build: _PORT_USE
1506	@${ECHO_MSG} "===>  Building for ${PKGNAME}"
1507real-install: _PORT_USE
1508	@${ECHO_MSG} "===>  Installing for ${PKGNAME}"
1509real-package: _PORT_USE
1510
1511# Empty pre-* and post-* targets, note we can't use .if !target()
1512# in the _PORT_USE macro
1513
1514.for name in fetch extract patch configure build install package
1515
1516.if !target(pre-${name})
1517pre-${name}:
1518	@${DO_NADA}
1519.endif
1520
1521.if !target(post-${name})
1522post-${name}:
1523	@${DO_NADA}
1524.endif
1525
1526.endfor
1527
1528# Checkpatch
1529#
1530# Special target to verify patches
1531
1532.if !target(checkpatch)
1533checkpatch:
1534	@cd ${.CURDIR} && ${MAKE} PATCH_CHECK_ONLY=yes ${.MAKEFLAGS} patch
1535.endif
1536
1537# Reinstall
1538#
1539# Special target to re-run install
1540
1541.if !target(reinstall)
1542reinstall:
1543	@${RM} -f ${INSTALL_COOKIE} ${PACKAGE_COOKIE}
1544	@DEPENDS_TARGET=${DEPENDS_TARGET} ${MAKE} install
1545.endif
1546
1547# Deinstall
1548#
1549# Special target to remove installation
1550
1551.if !target(deinstall)
1552deinstall:
1553	@${ECHO_MSG} "===>  Deinstalling for ${PKGNAME}"
1554	@${PKG_DELETE} -f ${PKGNAME}
1555	@${RM} -f ${INSTALL_COOKIE} ${PACKAGE_COOKIE}
1556.endif
1557
1558################################################################
1559# Some more targets supplied for users' convenience
1560################################################################
1561
1562# Cleaning up
1563
1564.if !target(pre-clean)
1565pre-clean:
1566	@${DO_NADA}
1567.endif
1568
1569.if !target(clean)
1570clean: pre-clean
1571.if !defined(NOCLEANDEPENDS)
1572	@${MAKE} clean-depends
1573.endif
1574	@${ECHO_MSG} "===>  Cleaning for ${PKGNAME}"
1575.if !defined(NO_WRKDIR)
1576	@if [ -d ${WRKDIR} ]; then \
1577		if [ -w ${WRKDIR} ]; then \
1578			${RM} -rf ${WRKDIR}; \
1579		else \
1580			${ECHO_MSG} "===>   ${WRKDIR} not writable, skipping"; \
1581		fi; \
1582	fi
1583.else
1584	@${RM} -f ${WRKDIR}/.*_done ${TMPPLIST}
1585.endif
1586.endif
1587
1588.if !target(pre-distclean)
1589pre-distclean:
1590	@${DO_NADA}
1591.endif
1592
1593.if !target(distclean)
1594distclean: pre-distclean clean
1595	@${ECHO_MSG} "===>  Dist cleaning for ${PKGNAME}"
1596	@(if [ -d ${_DISTDIR} ]; then \
1597		cd ${_DISTDIR}; \
1598		${RM} -f ${DISTFILES} ${PATCHFILES}; \
1599	fi)
1600.if defined(DIST_SUBDIR)
1601	-@${RMDIR} ${_DISTDIR}
1602.endif
1603.endif
1604
1605# Prints out a list of files to fetch (useful to do a batch fetch)
1606
1607.if !target(fetch-list)
1608fetch-list:
1609	@${MKDIR} ${_DISTDIR}
1610	@(cd ${_DISTDIR}; \
1611	 for file in ${DISTFILES}; do \
1612		if [ ! -f $$file -a ! -f `${BASENAME} $$file` ]; then \
1613			for site in ${MASTER_SITES}; do \
1614				${ECHO} -n ${FETCH_CMD} ${FETCH_BEFORE_ARGS} $${site}$${file} "${FETCH_AFTER_ARGS}" '||' ; \
1615					break; \
1616			done; \
1617			${ECHO} "echo $${file} not fetched" ; \
1618		fi \
1619	done)
1620.if defined(PATCHFILES)
1621	@(cd ${_DISTDIR}; \
1622	 for file in ${PATCHFILES}; do \
1623		if [ ! -f $$file -a ! -f `${BASENAME} $$file` ]; then \
1624			for site in ${PATCH_SITES}; do \
1625				${ECHO} -n ${FETCH_CMD} ${FETCH_BEFORE_ARGS} $${site}$${file} "${FETCH_AFTER_ARGS}" '||' ; \
1626					break; \
1627			done; \
1628			${ECHO} "echo $${file} not fetched" ; \
1629		fi \
1630	 done)
1631.endif
1632.endif
1633
1634# Checksumming utilities
1635
1636.if !target(makesum)
1637makesum: fetch
1638	@${MKDIR} ${FILESDIR}
1639	@if [ -f ${MD5_FILE} ]; then ${RM} -f ${MD5_FILE}; fi
1640	@(cd ${DISTDIR}; \
1641	 for file in ${_CKSUMFILES}; do \
1642		${MD5} $$file >> ${MD5_FILE}; \
1643	 done)
1644	@for file in ${_IGNOREFILES}; do \
1645		${ECHO} "MD5 ($$file) = IGNORE" >> ${MD5_FILE}; \
1646	done
1647.endif
1648
1649.if !target(checksum)
1650checksum: fetch
1651	@if [ ! -f ${MD5_FILE} ]; then \
1652		${ECHO_MSG} ">> No MD5 checksum file."; \
1653	else \
1654		(cd ${DISTDIR}; OK="true"; \
1655		  for file in ${_CKSUMFILES}; do \
1656			CKSUM=`${MD5} < $$file`; \
1657			CKSUM2=`${GREP} "^MD5 ($$file)" ${MD5_FILE} | ${AWK} '{print $$4}'`; \
1658			if [ "$$CKSUM2" = "" ]; then \
1659				${ECHO_MSG} ">> No checksum recorded for $$file."; \
1660				OK="false"; \
1661			elif [ "$$CKSUM2" = "IGNORE" ]; then \
1662				${ECHO_MSG} ">> Checksum for $$file is set to IGNORE in md5 file even though"; \
1663				${ECHO_MSG} "   the file is not in the "'$$'"{IGNOREFILES} list."; \
1664				OK="false"; \
1665			elif ${EXPR} "$$CKSUM2" : ".*$$CKSUM" > /dev/null; then \
1666				${ECHO_MSG} ">> Checksum OK for $$file."; \
1667			else \
1668				${ECHO_MSG} ">> Checksum mismatch for $$file."; \
1669				OK="false"; \
1670			fi; \
1671		  done; \
1672		  for file in ${_IGNOREFILES}; do \
1673			CKSUM2=`${GREP} "($$file)" ${MD5_FILE} | ${AWK} '{print $$4}'`; \
1674			if [ "$$CKSUM2" = "" ]; then \
1675				${ECHO_MSG} ">> No checksum recorded for $$file, file is in "'$$'"{IGNOREFILES} list."; \
1676				OK="false"; \
1677			elif [ "$$CKSUM2" != "IGNORE" ]; then \
1678				${ECHO_MSG} ">> Checksum for $$file is not set to IGNORE in md5 file even though"; \
1679				${ECHO_MSG} "   the file is in the "'$$'"{IGNOREFILES} list."; \
1680				OK="false"; \
1681			fi; \
1682		  done; \
1683		  if [ "$$OK" != "true" ]; then \
1684			${ECHO_MSG} "Make sure the Makefile and md5 file (${MD5_FILE})"; \
1685			${ECHO_MSG} "are up to date.  If you want to override this check, type"; \
1686			${ECHO_MSG} "\"make NO_CHECKSUM=yes [other args]\"."; \
1687			exit 1; \
1688		  fi) ; \
1689	fi
1690.endif
1691
1692################################################################
1693# The special package-building targets
1694# You probably won't need to touch these
1695################################################################
1696
1697# Nobody should want to override this unless PKGNAME is simply bogus.
1698
1699.if !target(package-name)
1700package-name:
1701	@${ECHO} ${PKGNAME}
1702.endif
1703
1704# Show (recursively) all the packages this package depends on.
1705
1706.if !target(package-depends)
1707package-depends:
1708	@for dir in `${ECHO} "${LIB_DEPENDS} ${RUN_DEPENDS}" | ${TR} '\040' '\012' | ${SED} -e 's/^[^:]*://' -e 's/:.*//' | sort -u` `${ECHO} ${DEPENDS} | ${TR} '\040' '\012' | ${SED} -e 's/:.*//' | sort -u`; do \
1709		if [ -d $$dir ]; then \
1710			(cd $$dir ; ${MAKE} package-name package-depends); \
1711		else \
1712			${ECHO_MSG} "${PKGNAME}: \"$$dir\" non-existent -- dependency list incomplete" >&2; \
1713		fi; \
1714	done
1715.endif
1716
1717# Build a package but don't check the package cookie
1718
1719.if !target(repackage)
1720repackage: pre-repackage package
1721
1722pre-repackage:
1723	@${RM} -f ${PACKAGE_COOKIE}
1724.endif
1725
1726# Build a package but don't check the cookie for installation, also don't
1727# install package cookie
1728
1729.if !target(package-noinstall)
1730package-noinstall:
1731	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} PACKAGE_NOINSTALL=yes real-package
1732.endif
1733
1734################################################################
1735# Dependency checking
1736################################################################
1737
1738.if !target(depends)
1739depends: lib-depends misc-depends
1740	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} fetch-depends
1741	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} build-depends
1742	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} run-depends
1743
1744.if make(fetch-depends)
1745DEPENDS_TMP+=	${FETCH_DEPENDS}
1746.endif
1747
1748.if make(build-depends)
1749DEPENDS_TMP+=	${BUILD_DEPENDS}
1750.endif
1751
1752.if make(run-depends)
1753DEPENDS_TMP+=	${RUN_DEPENDS}
1754.endif
1755
1756_DEPENDS_USE:	.USE
1757.if defined(DEPENDS_TMP)
1758.if !defined(NO_DEPENDS)
1759	@for i in ${DEPENDS_TMP}; do \
1760		prog=`${ECHO} $$i | ${SED} -e 's/:.*//'`; \
1761		dir=`${ECHO} $$i | ${SED} -e 's/[^:]*://'`; \
1762		if ${EXPR} "$$dir" : '.*:' > /dev/null; then \
1763			target=`${ECHO} $$dir | ${SED} -e 's/.*://'`; \
1764			dir=`${ECHO} $$dir | ${SED} -e 's/:.*//'`; \
1765		else \
1766			target=${DEPENDS_TARGET}; \
1767		fi; \
1768		if ${EXPR} "$$prog" : \\/ >/dev/null; then \
1769			if [ -e "$$prog" ]; then \
1770				${ECHO_MSG} "===>   ${PKGNAME} depends on file: $$prog - found"; \
1771				notfound=0; \
1772			else \
1773				${ECHO_MSG} "===>   ${PKGNAME} depends on file: $$prog - not found"; \
1774				notfound=1; \
1775			fi; \
1776		else \
1777			if which "$$prog" > /dev/null 2>&1 ; then \
1778				${ECHO_MSG} "===>   ${PKGNAME} depends on executable: $$prog - found"; \
1779				notfound=0; \
1780			else \
1781				${ECHO_MSG} "===>   ${PKGNAME} depends on executable: $$prog - not found"; \
1782				notfound=1; \
1783			fi; \
1784		fi; \
1785		if [ $$notfound != 0 ]; then \
1786			${ECHO_MSG} "===>    Verifying $$target for $$prog in $$dir"; \
1787			if [ ! -d "$$dir" ]; then \
1788				${ECHO_MSG} "     >> No directory for $$prog.  Skipping.."; \
1789			else \
1790				(cd $$dir; ${MAKE} ${.MAKEFLAGS} $$target) ; \
1791				${ECHO_MSG} "===>   Returning to build of ${PKGNAME}"; \
1792			fi; \
1793		fi; \
1794	done
1795.endif
1796.else
1797	@${DO_NADA}
1798.endif
1799
1800fetch-depends:	_DEPENDS_USE
1801build-depends:	_DEPENDS_USE
1802run-depends:	_DEPENDS_USE
1803
1804lib-depends:
1805.if defined(LIB_DEPENDS)
1806.if !defined(NO_DEPENDS)
1807	@for i in ${LIB_DEPENDS}; do \
1808		lib=`${ECHO} $$i | ${SED} -e 's/:.*//'`; \
1809		dir=`${ECHO} $$i | ${SED} -e 's/[^:]*://'`; \
1810		if ${EXPR} "$$dir" : '.*:' > /dev/null; then \
1811			target=`${ECHO} $$dir | ${SED} -e 's/.*://'`; \
1812			dir=`${ECHO} $$dir | ${SED} -e 's/:.*//'`; \
1813		else \
1814			target=${DEPENDS_TARGET}; \
1815		fi; \
1816		if ${LDCONFIG} -r | ${GREP} -q -e "-l$$lib"; then \
1817			${ECHO_MSG} "===>   ${PKGNAME} depends on shared library: $$lib - found"; \
1818		else \
1819			${ECHO_MSG} "===>   ${PKGNAME} depends on shared library: $$lib - not found"; \
1820			${ECHO_MSG} "===>    Verifying $$target for $$lib in $$dir"; \
1821			if [ ! -d "$$dir" ]; then \
1822				${ECHO_MSG} "     >> No directory for $$lib.  Skipping.."; \
1823			else \
1824				(cd $$dir; ${MAKE} ${.MAKEFLAGS} $$target) ; \
1825				${ECHO_MSG} "===>   Returning to build of ${PKGNAME}"; \
1826				if ${LDCONFIG} -r | ${GREP} -q -e "-l$$lib"; then \
1827					${TRUE}; \
1828				else \
1829					${ECHO_MSG} "Error: shared library \"$$lib\" does not exist"; \
1830					${FALSE}; \
1831				fi; \
1832			fi; \
1833		fi; \
1834	done
1835.endif
1836.else
1837	@${DO_NADA}
1838.endif
1839
1840misc-depends:
1841.if defined(DEPENDS)
1842.if !defined(NO_DEPENDS)
1843	@for dir in ${DEPENDS}; do \
1844		if ${EXPR} "$$dir" : '.*:' > /dev/null; then \
1845			target=`${ECHO} $$dir | ${SED} -e 's/.*://'`; \
1846			dir=`${ECHO} $$dir | ${SED} -e 's/:.*//'`; \
1847		else \
1848			target=${DEPENDS_TARGET}; \
1849		fi; \
1850		${ECHO_MSG} "===>   ${PKGNAME} depends on: $$dir"; \
1851		${ECHO_MSG} "===>    Verifying $$target for $$dir"; \
1852		if [ ! -d $$dir ]; then \
1853			${ECHO_MSG} "     >> No directory for $$dir.  Skipping.."; \
1854		else \
1855			(cd $$dir; ${MAKE} ${.MAKEFLAGS} $$target) ; \
1856		fi \
1857	done
1858	@${ECHO_MSG} "===>   Returning to build of ${PKGNAME}"
1859.endif
1860.else
1861	@${DO_NADA}
1862.endif
1863
1864.endif
1865
1866.if !target(clean-depends)
1867clean-depends:
1868.if defined(FETCH_DEPENDS) || defined(BUILD_DEPENDS) || defined(LIB_DEPENDS) \
1869	|| defined(RUN_DEPENDS)
1870	@for dir in `${ECHO} "${FETCH_DEPENDS} ${BUILD_DEPENDS} ${LIB_DEPENDS} ${RUN_DEPENDS}" | ${TR} '\040' '\012' | ${SED} -e 's/^[^:]*://' -e 's/:.*//' | sort -u`; do \
1871		if [ -d $$dir ] ; then \
1872			(cd $$dir; ${MAKE} NOCLEANDEPENDS=yes clean clean-depends); \
1873		fi \
1874	done
1875.endif
1876.if defined(DEPENDS)
1877	@for dir in `${ECHO} "${DEPENDS}" | ${TR} '\040' '\012' | ${SED} -e 's/:.*//' | sort -u`; do \
1878		if [ -d $$dir ] ; then \
1879			(cd $$dir; ${MAKE} NOCLEANDEPENDS=yes clean clean-depends); \
1880		fi \
1881	done
1882.endif
1883.endif
1884
1885.if !target(depends-list)
1886depends-list:
1887	@for dir in `${ECHO} "${FETCH_DEPENDS} ${BUILD_DEPENDS} ${LIB_DEPENDS}" | ${TR} '\040' '\012' | ${SED} -e 's/^[^:]*://' -e 's/:.*//' | sort -u` `${ECHO} ${DEPENDS} | ${TR} '\040' '\012' | ${SED} -e 's/:.*//' | sort -u`; do \
1888		if [ -d $$dir ]; then \
1889			(cd $$dir ; ${MAKE} package-name depends-list); \
1890		else \
1891			${ECHO_MSG} "${PKGNAME}: \"$$dir\" non-existent -- dependency list incomplete" >&2; \
1892		fi; \
1893	done
1894.endif
1895
1896################################################################
1897# Everything after here are internal targets and really
1898# shouldn't be touched by anybody but the release engineers.
1899################################################################
1900
1901# This target generates an index entry suitable for aggregation into
1902# a large index.  Format is:
1903#
1904# distribution-name|port-path|installation-prefix|comment| \
1905#  description-file|maintainer|categories|build deps|run deps
1906#
1907.if !target(describe)
1908describe:
1909	@${ECHO} -n "${PKGNAME}|${.CURDIR}|"; \
1910	${ECHO} -n "${PREFIX}|"; \
1911	if [ -f ${COMMENT} ]; then \
1912		${ECHO} -n "`${CAT} ${COMMENT}`"; \
1913	else \
1914		${ECHO} -n "** No Description"; \
1915	fi; \
1916	if [ -f ${DESCR} ]; then \
1917		${ECHO} -n "|${DESCR}"; \
1918	else \
1919		${ECHO} -n "|/dev/null"; \
1920	fi; \
1921	${ECHO} -n "|${MAINTAINER}|${CATEGORIES}|"; \
1922	case "A${FETCH_DEPENDS}B${BUILD_DEPENDS}C${LIB_DEPENDS}D${DEPENDS}E" in \
1923		ABCDE) ;; \
1924		*) cd ${.CURDIR} && ${ECHO} -n `${MAKE} depends-list|sort -u`;; \
1925	esac; \
1926	${ECHO} -n "|"; \
1927	case "A${RUN_DEPENDS}B${LIB_DEPENDS}C${DEPENDS}D" in \
1928		ABCD) ;; \
1929		*) cd ${.CURDIR} && ${ECHO} -n `${MAKE} package-depends|sort -u`;; \
1930	esac; \
1931	${ECHO} ""
1932.endif
1933
1934.if !target(readmes)
1935readmes:	readme
1936.endif
1937
1938.if !target(readme)
1939readme:
1940	@rm -f README.html
1941	@cd ${.CURDIR} && make README.html
1942.endif
1943
1944README.html:
1945	@${ECHO_MSG} "===>   Creating README.html for ${PKGNAME}"
1946	@${CAT} ${TEMPLATES}/README.port | \
1947		${SED} -e 's%%PORT%%'`${ECHO} ${.CURDIR} | ${SED} -e 's.*/\([^/]*/[^/]*\)$$\1'`'g' \
1948			-e 's%%PKG%%${PKGNAME}g' \
1949			-e '/%%COMMENT%%/r${PKGDIR}/COMMENT' \
1950			-e '/%%COMMENT%%/d' \
1951			-e 's%%BUILD_DEPENDS%%'"`${MAKE} print-depends-list`"'' \
1952			-e 's%%RUN_DEPENDS%%'"`${MAKE} print-package-depends`"'' \
1953		>> $@
1954
1955.if !target(print-depends-list)
1956print-depends-list:
1957.if defined(FETCH_DEPENDS) || defined(BUILD_DEPENDS) || \
1958	defined(LIB_DEPENDS) || defined(DEPENDS)
1959	@${ECHO} -n 'This port requires package(s) "'
1960	@${ECHO} -n `${MAKE} depends-list | sort -u`
1961	@${ECHO} '" to build.'
1962.endif
1963.endif
1964
1965.if !target(print-package-depends)
1966print-package-depends:
1967.if defined(RUN_DEPENDS) || defined(LIB_DEPENDS) || defined(DEPENDS)
1968	@${ECHO} -n 'This port requires package(s) "'
1969	@${ECHO} -n `${MAKE} package-depends | sort -u`
1970	@${ECHO} '" to run.'
1971.endif
1972.endif
1973
1974# Generate packing list.  Also tests to make sure all required package
1975# files exist.
1976
1977.if !target(generate-plist)
1978generate-plist:
1979	@${ECHO_MSG} "===>   Generating temporary packing list"
1980	@if [ ! -f ${PLIST} -o ! -f ${COMMENT} -o ! -f ${DESCR} ]; then ${ECHO} "** Missing package files for ${PKGNAME}."; exit 1; fi
1981	@>${TMPPLIST}
1982.for man in ${__MANPAGES}
1983	@${ECHO} ${man} >> ${TMPPLIST}
1984.endfor
1985.for _PREFIX in ${PREFIX}
1986.if ${_TMLINKS:M${_PREFIX}*}x != x
1987	@for i in ${_TMLINKS:M${_PREFIX}*:S,^${_PREFIX}/,,}; do \
1988		${ECHO} "$$i" >> ${TMPPLIST}; \
1989	done
1990.endif
1991.if ${_TMLINKS:N${_PREFIX}*}x != x
1992	@${ECHO} @cwd / >> ${TMPPLIST}
1993	@for i in ${_TMLINKS:N${_PREFIX}*:S,^/,,}; do \
1994		${ECHO} "$$i" >> ${TMPPLIST}; \
1995	done
1996	@${ECHO} '@cwd ${PREFIX}' >> ${TMPPLIST}
1997.endif
1998.endfor
1999	@${SED} ${_sedsubplist} ${PLIST} >> ${TMPPLIST}
2000.if (${PORTOBJFORMAT} == "aout")
2001	@${SED} -e 's,\(/lib.*\.so\.[0-9]*\)$$,\1.0,' ${TMPPLIST} > ${TMPPLIST}.tmp
2002	@${MV} -f ${TMPPLIST}.tmp ${TMPPLIST}
2003.endif
2004.endif
2005
2006${TMPPLIST}:
2007	@cd ${.CURDIR} && ${MAKE} generate-plist
2008
2009# Compress (or uncompress) and symlink manpages.
2010.if !target(compress-man)
2011compress-man:
2012.if ${MANCOMPRESSED} == yes && defined(NOMANCOMPRESS)
2013	@${ECHO_MSG} "===>   Uncompressing manual pages for ${PKGNAME}"
2014.for manpage in ${_MANPAGES}
2015	@${GUNZIP_CMD} ${manpage}
2016.endfor
2017.elif ${MANCOMPRESSED} == no && !defined(NOMANCOMPRESS)
2018	@${ECHO_MSG} "===>   Compressing manual pages for ${PKGNAME}"
2019.for manpage in ${_MANPAGES}
2020	@${GZIP_CMD} ${manpage}
2021.endfor
2022.endif
2023.if defined(_MLINKS)
2024	@set ${_MLINKS:S,"",,g:S,//,/,g}; \
2025	while :; do \
2026		[ $$# -eq 0 ] && break || ${TRUE}; \
2027		${RM} -f $${2%.gz}; ${RM} -f $$2.gz; \
2028		${LN} -fs `${ECHO} $$1 $$2 | ${AWK} '{ \
2029					z=split($$1, a, /\//); x=split($$2, b, /\//); \
2030					while (a[i] == b[i]) i++; \
2031					for (q=i; q<x; q++) printf "../"; \
2032					for (; i<z; i++) printf a[i] "/"; printf a[z]; }'` $$2; \
2033		shift; shift; \
2034	done
2035.endif
2036.endif
2037
2038# Fake installation of package so that user can pkg_delete it later.
2039# Also, make sure that an installed port is recognized correctly in
2040# accordance to the @pkgdep directive in the packing lists
2041
2042.if !target(fake-pkg)
2043fake-pkg:
2044	@if [ ! -d ${PKG_DBDIR} ]; then ${RM} -f ${PKG_DBDIR}; ${MKDIR} ${PKG_DBDIR}; fi
2045.if defined(FORCE_PKG_REGISTER)
2046	@${RM} -rf ${PKG_DBDIR}/${PKGNAME}
2047.endif
2048	@if [ ! -d ${PKG_DBDIR}/${PKGNAME} ]; then \
2049		${ECHO_MSG} "===>   Registering installation for ${PKGNAME}"; \
2050		${MKDIR} ${PKG_DBDIR}/${PKGNAME}; \
2051		${PKG_CMD} ${PKG_ARGS} -O ${PKGFILE} > ${PKG_DBDIR}/${PKGNAME}/+CONTENTS; \
2052		${CP} ${DESCR} ${PKG_DBDIR}/${PKGNAME}/+DESC; \
2053		${CP} ${COMMENT} ${PKG_DBDIR}/${PKGNAME}/+COMMENT; \
2054		if [ -f ${PKGDIR}/INSTALL ]; then \
2055			${CP} ${PKGDIR}/INSTALL ${PKG_DBDIR}/${PKGNAME}/+INSTALL; \
2056		fi; \
2057		if [ -f ${PKGDIR}/DEINSTALL ]; then \
2058			${CP} ${PKGDIR}/DEINSTALL ${PKG_DBDIR}/${PKGNAME}/+DEINSTALL; \
2059		fi; \
2060		if [ -f ${PKGDIR}/REQ ]; then \
2061			${CP} ${PKGDIR}/REQ ${PKG_DBDIR}/${PKGNAME}/+REQUIRE; \
2062		fi; \
2063		if [ -f ${PKGDIR}/MESSAGE ]; then \
2064			${CP} ${PKGDIR}/MESSAGE ${PKG_DBDIR}/${PKGNAME}/+DISPLAY; \
2065		fi; \
2066		for dep in `${MAKE} package-depends ECHO_MSG=/usr/bin/true | sort -u`; do \
2067			if [ -d ${PKG_DBDIR}/$$dep ]; then \
2068				if ! ${GREP} ^${PKGNAME}$$ ${PKG_DBDIR}/$$dep/+REQUIRED_BY \
2069					>/dev/null 2>&1; then \
2070					${ECHO} ${PKGNAME} >> ${PKG_DBDIR}/$$dep/+REQUIRED_BY; \
2071				fi; \
2072			fi; \
2073		done; \
2074	fi
2075.endif
2076
2077# Depend is generally meaningless for arbitrary ports, but if someone wants
2078# one they can override this.  This is just to catch people who've gotten into
2079# the habit of typing `make depend all install' as a matter of course.
2080#
2081.if !target(depend)
2082depend:
2083.endif
2084
2085# Same goes for tags
2086.if !target(tags)
2087tags:
2088.endif
2089