bsd.port.mk revision 32947
167217Sn_hibma#-*- mode: Fundamental; tab-width: 4; -*-
261560Sn_hibma# ex:ts=4
361560Sn_hibma#
461560Sn_hibma#	$Id: bsd.port.mk,v 1.268 1998/01/02 10:37:14 asami Exp $
561560Sn_hibma#	$NetBSD: $
661560Sn_hibma#
761560Sn_hibma#	bsd.port.mk - 940820 Jordan K. Hubbard.
861560Sn_hibma#	This file is in the public domain.
961560Sn_hibma#
1061560Sn_hibma# Please view me with 4 column tabs!
1161560Sn_hibma
1261560Sn_hibma# There are two different types of "maintainers" in the whole ports
1361560Sn_hibma# framework concept.  Maintainers of the bsd.port*.mk files
1461560Sn_hibma# are listed below in the ${OSNAME}_MAINTAINER entries (this file
1561560Sn_hibma# is used by multiple *BSD flavors).  You should consult them directly
1661560Sn_hibma# if you have any questions/suggestions regarding this file since only
1761560Sn_hibma# they are allowed to modify the master copies in the CVS repository!
1861560Sn_hibma
1961560Sn_hibma# For each port, the MAINTAINER variable is what you should consult for
2061560Sn_hibma# contact information on the person(s) to contact if you have questions/
2161560Sn_hibma# suggestions about that specific port.  By default (if no MAINTAINER
2261560Sn_hibma# is listed), a port is maintained by the subscribers of the ports@freebsd.org
2361560Sn_hibma# mailing list, and any correspondece should be directed there.
2461560Sn_hibma#
2561560Sn_hibmaFreeBSD_MAINTAINER=	asami@FreeBSD.ORG
2661560Sn_hibmaOpenBSD_MAINTAINER=	imp@OpenBSD.ORG
2761560Sn_hibma
2861560Sn_hibma# Supported Variables and their behaviors:
2961560Sn_hibma#
3061560Sn_hibma# Variables that typically apply to all ports:
3161560Sn_hibma# 
3261560Sn_hibma# ARCH			- The architecture, as returned by "uname -m".
3361560Sn_hibma# OPSYS			- Portability clause.  This is the operating system the
3461560Sn_hibma#				  makefile is being used on.  Automatically set to
3561560Sn_hibma#				  "FreeBSD," "NetBSD," or "OpenBSD" as appropriate.
3661560Sn_hibma# PORTSDIR		- The root of the ports tree.  Defaults:
3761560Sn_hibma#					FreeBSD/OpenBSD: /usr/ports
3861560Sn_hibma#					NetBSD:          /usr/opt
3961560Sn_hibma# DISTDIR 		- Where to get gzip'd, tarballed copies of original sources
4061560Sn_hibma#				  (default: ${PORTSDIR}/distfiles).
4161560Sn_hibma# PREFIX		- Where to install things in general (default: /usr/local).
4261560Sn_hibma# MASTER_SITES	- Primary location(s) for distribution files if not found
4361560Sn_hibma#				  locally.
4461560Sn_hibma# PATCH_SITES	- Primary location(s) for distribution patch files
4561560Sn_hibma#				  (see PATCHFILES below) if not found locally.
4661560Sn_hibma#
4761560Sn_hibma# MASTER_SITE_BACKUP - Backup location(s) for distribution files and patch
4861560Sn_hibma#				  files if not found locally and ${MASTER_SITES}/${PATCH_SITES}
4961560Sn_hibma#				  (default:
5061560Sn_hibma#				  ftp://ftp.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/)
5161560Sn_hibma# MASTER_SITE_OVERRIDE - If set, override the MASTER_SITES setting with this
5261560Sn_hibma#				  value.
5361560Sn_hibma# MASTER_SITE_FREEBSD - If set, only use ${MASTER_SITE_BACKUP} for
5461560Sn_hibma#				  MASTER_SITES.
5567217Sn_hibma# PACKAGES		- A top level directory where all packages go (rather than
5667217Sn_hibma#				  going locally to each port). (default: ${PORTSDIR}/packages).
5767217Sn_hibma# GMAKE			- Set to path of GNU make if not in $PATH (default: gmake).
5867217Sn_hibma# AUTOCONF		- Set to path of GNU autoconf if not in $PATH (default: autoconf).
5967217Sn_hibma# XMKMF			- Set to path of `xmkmf' if not in $PATH (default: xmkmf -a ).
6061560Sn_hibma# MAINTAINER	- The e-mail address of the contact person for this port
6161560Sn_hibma#				  (default: ports@FreeBSD.ORG).
6261560Sn_hibma# CATEGORIES	- A list of descriptive categories into which this port falls.
6361560Sn_hibma#
6461560Sn_hibma# Variables that typically apply to an individual port.  Non-Boolean
6561560Sn_hibma# variables without defaults are *mandatory*.
6661560Sn_hibma#
6761560Sn_hibma# WRKDIR 		- A temporary working directory that gets *clobbered* on clean
6861560Sn_hibma#				  (default: ${.CURDIR}/work).
6961560Sn_hibma# WRKSRC		- A subdirectory of ${WRKDIR} where the distribution actually
7061560Sn_hibma#				  unpacks to.  (Default: ${WRKDIR}/${DISTNAME} unless
7161560Sn_hibma#				  NO_WRKSUBDIR is set, in which case simply ${WRKDIR}).
7261560Sn_hibma# DISTNAME		- Name of port or distribution.
7361560Sn_hibma# DISTFILES		- Name(s) of archive file(s) containing distribution
7461560Sn_hibma#				  (default: ${DISTNAME}${EXTRACT_SUFX}).
7561560Sn_hibma# PATCHFILES	- Name(s) of additional files that contain distribution
7661560Sn_hibma#				  patches (default: none).  make will look for them at
7761560Sn_hibma#				  PATCH_SITES (see above).  They will automatically be
7861560Sn_hibma#				  uncompressed before patching if the names end with
7961560Sn_hibma#				  ".gz" or ".Z".
8061560Sn_hibma# DIST_SUBDIR	- Suffix to ${DISTDIR}.  If set, all ${DISTFILES} 
8161560Sn_hibma#				  and ${PATCHFILES} will be put in this subdirectory of
8261560Sn_hibma#				  ${DISTDIR}.  Also they will be fetched in this subdirectory 
8361560Sn_hibma#				  from FreeBSD mirror sites.
8461560Sn_hibma# ALLFILES		- All of ${DISTFILES} and ${PATCHFILES}.
8561560Sn_hibma# IGNOREFILES	- If some of the ${ALLFILES} are not checksum-able, set
8661560Sn_hibma#				  this variable to their names.
8761560Sn_hibma# PKGNAME		- Name of the package file to create if the DISTNAME 
8861560Sn_hibma#				  isn't really relevant for the port/package
8961560Sn_hibma#				  (default: ${DISTNAME}).
9061560Sn_hibma# EXTRACT_ONLY	- If defined, a subset of ${DISTFILES} you want to
9161560Sn_hibma#			  	  actually extract.
9261560Sn_hibma# PATCHDIR 		- A directory containing any additional patches you made
9361560Sn_hibma#				  to port this software to FreeBSD (default:
9461560Sn_hibma#				  ${.CURDIR}/patches)
9561560Sn_hibma# SCRIPTDIR 	- A directory containing any auxiliary scripts
9661560Sn_hibma#				  (default: ${.CURDIR}/scripts)
9761560Sn_hibma# FILESDIR 		- A directory containing any miscellaneous additional files.
9861560Sn_hibma#				  (default: ${.CURDIR}/files)
9961560Sn_hibma# PKGDIR 		- A direction containing any package creation files.
10061560Sn_hibma#				  (default: ${.CURDIR}/pkg)
10161560Sn_hibma# PKG_DBDIR		- Where package installation is recorded (default: /var/db/pkg)
10261560Sn_hibma# FORCE_PKG_REGISTER - If set, it will overwrite any existing package
10361560Sn_hibma#				  registration information in ${PKG_DBDIR}/${PKGNAME}.
10461560Sn_hibma# NO_MTREE		- If set, will not invoke mtree from bsd.port.mk from
10561560Sn_hibma#				  the "install" target.
10661560Sn_hibma# MTREE_FILE	- The name of the mtree file (default: /etc/mtree/BSD.x11.dist
10767217Sn_hibma#				  if USE_IMAKE or USE_X11 is set, /etc/mtree/BSD.local.dist
10861560Sn_hibma#				  otherwise.)
10961560Sn_hibma#
11061560Sn_hibma# NO_BUILD		- Use a dummy (do-nothing) build target.
11161560Sn_hibma# NO_CONFIGURE	- Use a dummy (do-nothing) configure target.
11261560Sn_hibma# NO_CDROM		- Port may not go on CDROM.  Set this string to reason.
11367217Sn_hibma# NO_DESCRIBE	- Use a dummy (do-nothing) describe target.
11461560Sn_hibma# NO_EXTRACT	- Use a dummy (do-nothing) extract target.
11561560Sn_hibma# NO_INSTALL	- Use a dummy (do-nothing) install target.
11661560Sn_hibma# NO_PACKAGE	- Use a dummy (do-nothing) package target.
11761560Sn_hibma# NO_PKG_REGISTER - Don't register a port install as a package.
11861560Sn_hibma# NO_WRKSUBDIR	- Assume port unpacks directly into ${WRKDIR}.
11961560Sn_hibma# NO_WRKDIR		- There's no work directory at all; port does this someplace
12061560Sn_hibma#				  else.
12161560Sn_hibma# NO_DEPENDS	- Don't verify build of dependencies.
12261560Sn_hibma# BROKEN		- Port is broken.  Set this string to the reason why.
12367217Sn_hibma# RESTRICTED	- Port is restricted.  Set this string to the reason why.
12467217Sn_hibma# USE_GMAKE		- Says that the port uses gmake.
12567217Sn_hibma# USE_AUTOCONF	- Says that the port uses autoconf.  Implies GNU_CONFIGURE.
12667217Sn_hibma# USE_PERL5		- Says that the port uses perl5 for building and running.
12767217Sn_hibma# USE_IMAKE		- Says that the port uses imake.  Implies USE_X11.
12861560Sn_hibma# USE_X11		- Says that the port uses X11 (i.e., installs in ${X11BASE}).
12961560Sn_hibma# NO_INSTALL_MANPAGES - For imake ports that don't like the install.man
13061560Sn_hibma#						target.
13161560Sn_hibma# HAS_CONFIGURE	- Says that the port has its own configure script.
13261560Sn_hibma# GNU_CONFIGURE	- Set if you are using GNU configure (optional).
13361560Sn_hibma# CONFIGURE_SCRIPT - Name of configure script, defaults to 'configure'.
13461560Sn_hibma# CONFIGURE_ARGS - Pass these args to configure if ${HAS_CONFIGURE} is set.
13561560Sn_hibma# CONFIGURE_ENV - Pass these env (shell-like) to configure if
13661560Sn_hibma#				  ${HAS_CONFIGURE} is set.
13761560Sn_hibma# SCRIPTS_ENV	- Additional environment vars passed to scripts in
13861560Sn_hibma#                 ${SCRIPTDIR} executed by bsd.port.mk.
13961560Sn_hibma# MAKE_ENV		- Additional environment vars passed to sub-make in build
14061560Sn_hibma#				  stage.
14161560Sn_hibma# IS_INTERACTIVE - Set this if your port needs to interact with the user
14261560Sn_hibma#				  during a build.  User can then decide to skip this port by
14361560Sn_hibma#				  setting ${BATCH}, or compiling only the interactive ports
14461560Sn_hibma#				  by setting ${INTERACTIVE}.
14561560Sn_hibma# FETCH_DEPENDS - A list of "path:dir" pairs of other ports this
14661560Sn_hibma#				  package depends in the "fetch" stage.  "path" is the
14761560Sn_hibma#				  name of a file if it starts with a slash (/), an
14861560Sn_hibma#				  executable otherwise.  make will test for the
14961560Sn_hibma#				  existence (if it is a full pathname) or search for
15061560Sn_hibma#				  it in your $PATH (if it is an executable) and go
15161560Sn_hibma#				  into "dir" to do a "make all install" if it's not
15261560Sn_hibma#				  found.
15361560Sn_hibma# BUILD_DEPENDS - A list of "path:dir" pairs of other ports this
15461560Sn_hibma#				  package depends to build (between the "extract" and
15561560Sn_hibma#				  "build" stages, inclusive).  The test done to
15661560Sn_hibma#				  determine the existence of the dependency is the
15761560Sn_hibma#				  same as FETCH_DEPENDS.
15861560Sn_hibma# RUN_DEPENDS	- A list of "path:dir" pairs of other ports this
15961560Sn_hibma#				  package depends to run.  The test done to determine
16061560Sn_hibma#				  the existence of the dependency is the same as
16161560Sn_hibma#				  FETCH_DEPENDS.  This will be checked during the
16261560Sn_hibma#				  "install" stage and the name of the dependency will
16361560Sn_hibma#				  be put into the package as well.
16461560Sn_hibma# LIB_DEPENDS	- A list of "lib:dir" pairs of other ports this package
16561560Sn_hibma#				  depends on.  "lib" is the name of a shared library.
16661560Sn_hibma#				  make will use "ldconfig -r" to search for the
16761560Sn_hibma#				  library.  Note that lib can be any regular expression,
16861560Sn_hibma#				  and you need two backslashes in front of dots (.) to
16961560Sn_hibma#				  supress its special meaning (e.g., use
17061560Sn_hibma#				  "foo\\.2\\.:${PORTSDIR}/utils/foo" to match "libfoo.2.*").
17161560Sn_hibma# DEPENDS		- A list of other ports this package depends on being
17261560Sn_hibma#				  made first.  Use this for things that don't fall into
17361560Sn_hibma#				  the above two categories.
17461560Sn_hibma# EXTRACT_CMD	- Command for extracting archive (default: tar).
17561560Sn_hibma# EXTRACT_SUFX	- Suffix for archive names (default: .tar.gz).
17661560Sn_hibma# EXTRACT_BEFORE_ARGS -
17761560Sn_hibma#				  Arguments to ${EXTRACT_CMD} before filename
17861560Sn_hibma#				  (default: -xzf).
17961560Sn_hibma# EXTRACT_AFTER_ARGS -
18061560Sn_hibma#				  Arguments to ${EXTRACT_CMD} following filename
18161560Sn_hibma#				  (default: none).
18261560Sn_hibma#
18361560Sn_hibma# FETCH_CMD		  - Full path to ftp/http fetch command if not in $PATH
18461560Sn_hibma#				  (default: /usr/bin/fetch).
18561560Sn_hibma# FETCH_BEFORE_ARGS -
18661560Sn_hibma#				  Arguments to ${FETCH_CMD} before filename (default: none).
18761560Sn_hibma# FETCH_AFTER_ARGS -
18861560Sn_hibma#				  Arguments to ${FETCH_CMD} following filename (default: none).
18967217Sn_hibma#
19067217Sn_hibma# Motif support:
19167217Sn_hibma#
19267217Sn_hibma# REQUIRES_MOTIF - Set this in your port if it requires Motif.  It will  be
19367217Sn_hibma#				  built only if HAVE_MOTIF is set.
19461560Sn_hibma# HAVE_MOTIF	- If set, means system has Motif.  Typically set in
19567217Sn_hibma#				  /etc/make.conf.
19667217Sn_hibma# MOTIF_STATIC	- If set, link libXm statically; otherwise, link it
19761560Sn_hibma#				  dynamically.  Typically set in /etc/make.conf.
19861560Sn_hibma# MOTIFLIB		- Set automatically to appropriate value depending on
19961560Sn_hibma#				  ${MOTIF_STATIC}.  Substitute references to -lXm with 
20061560Sn_hibma#				  patches to make your port conform to our standards.
20161560Sn_hibma# MOTIF_ONLY	- If set, build Motif ports only.  (Not much use except for
20261560Sn_hibma#				  building packages.)
20361560Sn_hibma#
20461560Sn_hibma# Variables to change if you want a special behavior:
20561560Sn_hibma#
20661560Sn_hibma# ECHO_MSG		- Used to print all the '===>' style prompts - override this
20761560Sn_hibma#				  to turn them off (default: /bin/echo).
20861560Sn_hibma# DEPENDS_TARGET - The target to execute when a port is calling a
20961560Sn_hibma#				  dependency (default: "install").
21061560Sn_hibma# PATCH_DEBUG	- If set, print out more information about the patches as
21161560Sn_hibma#				  it attempts to apply them.
21261560Sn_hibma#
21361560Sn_hibma# Variables that serve as convenient "aliases" for your *-install targets.
21461560Sn_hibma# Use these like: "${INSTALL_PROGRAM} ${WRKSRC}/prog ${PREFIX}/bin".
21561560Sn_hibma#
21661560Sn_hibma# INSTALL_PROGRAM - A command to install binary executables.
21761560Sn_hibma# INSTALL_SCRIPT - A command to install executable scripts.
21867217Sn_hibma# INSTALL_DATA	- A command to install sharable data.
21967217Sn_hibma# INSTALL_MAN	- A command to install manpages (doesn't compress).
22061560Sn_hibma#
22161560Sn_hibma# If your port doesn't automatically compress manpages, set the following.
22261560Sn_hibma# Depending on the setting of NOMANCOMPRESS, the make rules will compress
22361560Sn_hibma# the manpages for you.
22461560Sn_hibma#
22567217Sn_hibma# MAN<sect>		- A list of manpages, categorized by section.  For
22661560Sn_hibma#				  example, if your port has "man/man1/foo.1" and
22761560Sn_hibma#				  "man/mann/bar.n", set "MAN1=foo.1" and "MANN=bar.n".
22861560Sn_hibma#				  The available sections chars are "123456789LN".
22961560Sn_hibma# MANPREFIX		- The directory prefix for ${MAN<sect>} (default: ${PREFIX}).
23061560Sn_hibma#
23161560Sn_hibma# Default targets and their behaviors:
23261560Sn_hibma#
23361560Sn_hibma# fetch			- Retrieves ${DISTFILES} (and ${PATCHFILES} if defined)
23461560Sn_hibma#				  into ${DISTDIR} as necessary.
23561560Sn_hibma# fetch-list	- Show list of files that would be retrieved by fetch
23661560Sn_hibma# extract		- Unpacks ${DISTFILES} into ${WRKDIR}.
23767217Sn_hibma# patch			- Apply any provided patches to the source.
23861560Sn_hibma# configure		- Runs either GNU configure, one or more local configure
23961560Sn_hibma#				  scripts or nothing, depending on what's available.
24061560Sn_hibma# build			- Actually compile the sources.
24161560Sn_hibma# install		- Install the results of a build.
24261560Sn_hibma# reinstall		- Install the results of a build, ignoring "already installed"
24361560Sn_hibma#				  flag.
24461560Sn_hibma# deinstall		- Remove the installation.
24561560Sn_hibma# package		- Create a package from an _installed_ port.
24661560Sn_hibma# describe		- Try to generate a one-line description for each port for
24761560Sn_hibma#				  use in INDEX files and the like.
24861560Sn_hibma# checkpatch	- Do a "patch -C" instead of a "patch".  Note that it may
24961560Sn_hibma#				  give incorrect results if multiple patches deal with
25061560Sn_hibma#				  the same file.
25161560Sn_hibma# checksum		- Use files/md5 to ensure that your distfiles are valid.
25261560Sn_hibma# makesum		- Generate files/md5 (only do this for your own ports!).
25361560Sn_hibma#
25461560Sn_hibma# Default sequence for "all" is:  fetch checksum extract patch configure build
25561560Sn_hibma#
25661560Sn_hibma# Please read the comments in the targets section below, you
25761560Sn_hibma# should be able to use the pre-* or post-* targets/scripts
25861560Sn_hibma# (which are available for every stage except checksum) or
25961560Sn_hibma# override the do-* targets to do pretty much anything you want.
26061560Sn_hibma#
26161560Sn_hibma# NEVER override the "regular" targets unless you want to open
26261560Sn_hibma# a major can of worms.
26361560Sn_hibma
26461560Sn_hibma# Get the architecture
26561560Sn_hibmaARCH!=	uname -m
26661560Sn_hibma
26761560Sn_hibma# Get the operating system type
26861560Sn_hibmaOPSYS!=	uname -s
26961560Sn_hibma
27061560Sn_hibma.if exists(${.CURDIR}/../Makefile.inc)
27161560Sn_hibma.include "${.CURDIR}/../Makefile.inc"
27261560Sn_hibma.endif
27361560Sn_hibma
27461560Sn_hibma.if exists(${.CURDIR}/Makefile.${ARCH}-${OPSYS})
27561560Sn_hibma.include "${.CURDIR}/Makefile.${ARCH}-${OPSYS}"
27661560Sn_hibma.elif exists(${.CURDIR}/Makefile.${OPSYS})
27761560Sn_hibma.include "${.CURDIR}/Makefile.${OPSYS}"
27861560Sn_hibma.elif exists(${.CURDIR}/Makefile.${ARCH})
27961560Sn_hibma.include "${.CURDIR}/Makefile.${ARCH}"
28061560Sn_hibma.endif
28161560Sn_hibma
28261560Sn_hibma# These need to be absolute since we don't know how deep in the ports
28361560Sn_hibma# tree we are and thus can't go relative.  They can, of course, be overridden
28461560Sn_hibma# by individual Makefiles or local system make configuration.
28561560Sn_hibma.if (${OPSYS} == "NetBSD")
28661560Sn_hibmaPORTSDIR?=		/usr/opt
28761560Sn_hibma.else
28861560Sn_hibmaPORTSDIR?=		/usr/ports
28961560Sn_hibma.endif
29061560Sn_hibmaLOCALBASE?=		${DESTDIR}/usr/local
29161560Sn_hibmaX11BASE?=		${DESTDIR}/usr/X11R6
29261560Sn_hibmaDISTDIR?=		${PORTSDIR}/distfiles
29361560Sn_hibma_DISTDIR?=		${DISTDIR}/${DIST_SUBDIR}
29461560Sn_hibmaPACKAGES?=		${PORTSDIR}/packages
29561560Sn_hibmaTEMPLATES?=		${PORTSDIR}/templates
29661560Sn_hibma.if !defined(NO_WRKDIR)
29761560Sn_hibmaWRKDIR?=		${.CURDIR}/work
29861560Sn_hibma.else
29961560Sn_hibmaWRKDIR?=		${.CURDIR}
30061560Sn_hibma.endif
30161560Sn_hibma.if defined(NO_WRKSUBDIR)
30261560Sn_hibmaWRKSRC?=		${WRKDIR}
30361560Sn_hibma.else
30461560Sn_hibmaWRKSRC?=		${WRKDIR}/${DISTNAME}
30561560Sn_hibma.endif
30661560Sn_hibma
30761560Sn_hibma.if exists(${.CURDIR}/patches.${ARCH}-${OPSYS})
30861560Sn_hibmaPATCHDIR?=		${.CURDIR}/patches.${ARCH}-${OPSYS}
30961560Sn_hibma.elif exists(${.CURDIR}/patches.${OPSYS})
31061560Sn_hibmaPATCHDIR?=		${.CURDIR}/patches.${OPSYS}
31161560Sn_hibma.elif exists(${.CURDIR}/patches.${ARCH})
31261560Sn_hibmaPATCHDIR?=		${.CURDIR}/patches.${ARCH}
31361560Sn_hibma.else
31461560Sn_hibmaPATCHDIR?=		${.CURDIR}/patches
31561560Sn_hibma.endif
31661560Sn_hibma
31761560Sn_hibma.if exists(${.CURDIR}/scripts.${ARCH}-${OPSYS})
31861560Sn_hibmaSCRIPTDIR?=		${.CURDIR}/scripts.${ARCH}-${OPSYS}
31961560Sn_hibma.elif exists(${.CURDIR}/scripts.${OPSYS})
32061560Sn_hibmaSCRIPTDIR?=		${.CURDIR}/scripts.${OPSYS}
32161560Sn_hibma.elif exists(${.CURDIR}/scripts.${ARCH})
32261560Sn_hibmaSCRIPTDIR?=		${.CURDIR}/scripts.${ARCH}
32361560Sn_hibma.else
32461560Sn_hibmaSCRIPTDIR?=		${.CURDIR}/scripts
32561560Sn_hibma.endif
32661560Sn_hibma
32761560Sn_hibma.if exists(${.CURDIR}/files.${ARCH}-${OPSYS})
32861560Sn_hibmaFILESDIR?=		${.CURDIR}/files.${ARCH}-${OPSYS}
32961560Sn_hibma.elif exists(${.CURDIR}/files.${OPSYS})
33061560Sn_hibmaFILESDIR?=		${.CURDIR}/files.${OPSYS}
33161560Sn_hibma.elif exists(${.CURDIR}/files.${ARCH})
33261560Sn_hibmaFILESDIR?=		${.CURDIR}/files.${ARCH}
33361560Sn_hibma.else
33461560Sn_hibmaFILESDIR?=		${.CURDIR}/files
33561560Sn_hibma.endif
33661560Sn_hibma
33761560Sn_hibma.if exists(${.CURDIR}/pkg.${ARCH}-${OPSYS})
33861560Sn_hibmaPKGDIR?=		${.CURDIR}/pkg.${ARCH}-${OPSYS}
33961560Sn_hibma.elif exists(${.CURDIR}/pkg.${OPSYS})
34061560Sn_hibmaPKGDIR?=		${.CURDIR}/pkg.${OPSYS}
34161560Sn_hibma.elif exists(${.CURDIR}/pkg.${ARCH})
34261560Sn_hibmaPKGDIR?=		${.CURDIR}/pkg.${ARCH}
34361560Sn_hibma.else
34461560Sn_hibmaPKGDIR?=		${.CURDIR}/pkg
34561560Sn_hibma.endif
34661560Sn_hibma
34761560Sn_hibma.if defined(USE_IMAKE)
34861560Sn_hibmaUSE_X11=		yes
34961560Sn_hibma.endif
35061560Sn_hibma
35161560Sn_hibma.if defined(USE_X11)
35261560Sn_hibmaPREFIX?=		${X11BASE}
35361560Sn_hibma.else
35461560Sn_hibmaPREFIX?=		${LOCALBASE}
35567217Sn_hibma.endif
35661560Sn_hibma# The following 4 lines should go away as soon as the ports are all updated
35761560Sn_hibma.if defined(EXEC_DEPENDS)
35861560Sn_hibmaBUILD_DEPENDS+=	${EXEC_DEPENDS}
35967217Sn_hibmaRUN_DEPENDS+=	${EXEC_DEPENDS}
36061560Sn_hibma.endif
36161560Sn_hibma.if defined(USE_GMAKE)
36267217Sn_hibmaBUILD_DEPENDS+=		gmake:${PORTSDIR}/devel/gmake
36367217Sn_hibma.endif
36467217Sn_hibma.if defined(USE_AUTOCONF)
36567217Sn_hibmaGNU_CONFIGURE=	yes
36667217Sn_hibmaBUILD_DEPENDS+=		autoconf:${PORTSDIR}/devel/autoconf
36767217Sn_hibma.endif
36861560Sn_hibma.if defined(USE_PERL5)
36961560Sn_hibmaBUILD_DEPENDS+=		perl5.00404:${PORTSDIR}/lang/perl5
37061560Sn_hibmaRUN_DEPENDS+=		perl5.00404:${PORTSDIR}/lang/perl5
37167217Sn_hibma.endif
37267217Sn_hibma
37367217Sn_hibma.if exists(${PORTSDIR}/../Makefile.inc)
37467217Sn_hibma.include "${PORTSDIR}/../Makefile.inc"
37567217Sn_hibma.endif
37661560Sn_hibma
37761560Sn_hibma# Don't change these!!!  These names are built into the _TARGET_USE macro,
37861560Sn_hibma# there is no way to refer to them cleanly from within the macro AFAIK.
37967217Sn_hibmaEXTRACT_COOKIE?=	${WRKDIR}/.extract_done
38061560Sn_hibmaCONFIGURE_COOKIE?=	${WRKDIR}/.configure_done
38161560Sn_hibmaINSTALL_COOKIE?=	${WRKDIR}/.install_done
38261560Sn_hibmaBUILD_COOKIE?=		${WRKDIR}/.build_done
38361560Sn_hibmaPATCH_COOKIE?=		${WRKDIR}/.patch_done
38461560Sn_hibmaPACKAGE_COOKIE?=	${WRKDIR}/.package_done
38561560Sn_hibma
38661560Sn_hibma# How to do nothing.  Override if you, for some strange reason, would rather
38761560Sn_hibma# do something.
38861560Sn_hibmaDO_NADA?=		/usr/bin/true
38961560Sn_hibma
39061560Sn_hibma# Miscellaneous overridable commands:
39161560Sn_hibmaGMAKE?=			gmake
39261560Sn_hibmaAUTOCONF?=		autoconf
393XMKMF?=			xmkmf -a
394.if exists(/sbin/md5)
395MD5?=			/sbin/md5
396.elif exists(/bin/md5)
397MD5?=			/bin/md5
398.elif exists(/usr/bin/md5)
399MD5?=			/usr/bin/md5
400.else
401MD5?=			md5
402.endif
403MD5_FILE?=		${FILESDIR}/md5
404
405MAKE_FLAGS?=	-f
406MAKEFILE?=		Makefile
407MAKE_ENV+=		PREFIX=${PREFIX} LOCALBASE=${LOCALBASE} X11BASE=${X11BASE} MOTIFLIB="${MOTIFLIB}" CFLAGS="${CFLAGS}"
408
409.if exists(/usr/bin/fetch)
410FETCH_CMD?=		/usr/bin/fetch
411.else
412FETCH_CMD?=		/usr/bin/ftp
413.endif
414
415TOUCH?=			/usr/bin/touch
416TOUCH_FLAGS?=	-f
417
418PATCH?=			/usr/bin/patch
419PATCH_STRIP?=	-p0
420PATCH_DIST_STRIP?=	-p0
421.if defined(PATCH_DEBUG)
422PATCH_DEBUG_TMP=	yes
423PATCH_ARGS?=	-d ${WRKSRC} -E ${PATCH_STRIP}
424PATCH_DIST_ARGS?=	-d ${WRKSRC} -E ${PATCH_DIST_STRIP}
425.else
426PATCH_DEBUG_TMP=	no
427PATCH_ARGS?=	-d ${WRKSRC} --forward --quiet -E ${PATCH_STRIP}
428PATCH_DIST_ARGS?=	-d ${WRKSRC} --forward --quiet -E ${PATCH_DIST_STRIP}
429.endif
430.if defined(BATCH)
431PATCH_ARGS+=		--batch
432PATCH_DIST_ARGS+=	--batch
433.endif
434
435.if defined(PATCH_CHECK_ONLY)
436PATCH_ARGS+=	-C
437PATCH_DIST_ARGS+=	-C
438.endif
439
440.if exists(/bin/tar)
441EXTRACT_CMD?=	/bin/tar
442.else
443EXTRACT_CMD?=	/usr/bin/tar
444.endif
445EXTRACT_SUFX?=	.tar.gz
446# Backwards compatability.
447.if defined(EXTRACT_ARGS)
448EXTRACT_BEFORE_ARGS?=   ${EXTRACT_ARGS}
449.else
450EXTRACT_BEFORE_ARGS?=   -xzf
451.endif
452
453# Figure out where the local mtree file is
454.if !defined(MTREE_FILE)
455.if defined(USE_X11)
456MTREE_FILE=	/etc/mtree/BSD.x11.dist
457.else
458MTREE_FILE=	/etc/mtree/BSD.local.dist
459.endif
460.endif
461MTREE_CMD?=	/usr/sbin/mtree
462MTREE_ARGS?=	-U -f ${MTREE_FILE} -d -e -p
463
464# A few aliases for *-install targets
465INSTALL_PROGRAM= \
466	${INSTALL} ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE}
467INSTALL_SCRIPT= \
468	${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE}
469INSTALL_DATA= \
470	${INSTALL} ${COPY} -o ${SHAREOWN} -g ${SHAREGRP} -m ${SHAREMODE}
471INSTALL_MAN= \
472	${INSTALL} ${COPY} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE}
473
474INSTALL_MACROS=	BSD_INSTALL_PROGRAM="${INSTALL_PROGRAM}" \
475			BSD_INSTALL_SCRIPT="${INSTALL_SCRIPT}" \
476			BSD_INSTALL_DATA="${INSTALL_DATA}" \
477			BSD_INSTALL_MAN="${INSTALL_MAN}"
478MAKE_ENV+=	${INSTALL_MACROS}
479SCRIPTS_ENV+=	${INSTALL_MACROS}
480
481# The user can override the NO_PACKAGE by specifying this from
482# the make command line
483.if defined(FORCE_PACKAGE)
484.undef NO_PACKAGE
485.endif
486
487COMMENT?=	${PKGDIR}/COMMENT
488DESCR?=		${PKGDIR}/DESCR
489PLIST?=		${PKGDIR}/PLIST
490
491PKG_CMD?=		/usr/sbin/pkg_create
492.if !defined(PKG_ARGS)
493PKG_ARGS=		-v -c ${COMMENT} -d ${DESCR} -f ${PLIST} -p ${PREFIX} -P "`${MAKE} package-depends|sort -u`"
494.if exists(${PKGDIR}/INSTALL)
495PKG_ARGS+=		-i ${PKGDIR}/INSTALL
496.endif
497.if exists(${PKGDIR}/DEINSTALL)
498PKG_ARGS+=		-k ${PKGDIR}/DEINSTALL
499.endif
500.if exists(${PKGDIR}/REQ)
501PKG_ARGS+=		-r ${PKGDIR}/REQ
502.endif
503.if exists(${PKGDIR}/MESSAGE)
504PKG_ARGS+=		-D ${PKGDIR}/MESSAGE
505.endif
506.if !defined(NO_MTREE)
507PKG_ARGS+=		-m ${MTREE_FILE}
508.endif
509.endif
510PKG_SUFX?=		.tgz
511# where pkg_add records its dirty deeds.
512PKG_DBDIR?=		/var/db/pkg
513
514# shared/dynamic motif libs
515.if defined(HAVE_MOTIF)
516.if defined(MOTIF_STATIC)
517MOTIFLIB?=	${X11BASE}/lib/libXm.a
518.else
519MOTIFLIB?=	-L${X11BASE}/lib -lXm
520.endif
521.endif
522
523AWK?=		/usr/bin/awk
524BASENAME?=	/usr/bin/basename
525CAT?=		/bin/cat
526CP?=		/bin/cp
527ECHO?=		/bin/echo
528FALSE?=		/usr/bin/false
529GREP?=		/usr/bin/grep
530GUNZIP_CMD?=	/usr/bin/gunzip -f
531GZCAT?=		/usr/bin/gzcat
532GZIP?=		-9
533GZIP_CMD?=	/usr/bin/gzip -nf ${GZIP}
534LDCONFIG?=	/sbin/ldconfig
535LN?=		/bin/ln
536MKDIR?=		/bin/mkdir -p
537MV?=		/bin/mv
538RM?=		/bin/rm
539RMDIR?=		/bin/rmdir
540SED?=		/usr/bin/sed
541SETENV?=	/usr/bin/env
542SH?=		/bin/sh
543TR?=		/usr/bin/tr
544
545# Used to print all the '===>' style prompts - override this to turn them off.
546ECHO_MSG?=		${ECHO}
547
548ALL_TARGET?=		all
549INSTALL_TARGET?=	install
550
551# Popular master sites
552MASTER_SITE_XCONTRIB+=	\
553	ftp://crl.dec.com/pub/X11/contrib/%SUBDIR%/ \
554    ftp://ftp.eu.net/X11/contrib/%SUBDIR%/
555
556MASTER_SITE_GNU+=	\
557	ftp://prep.ai.mit.edu/pub/gnu/%SUBDIR%/ \
558	ftp://wuarchive.wustl.edu/systems/gnu/%SUBDIR%/
559
560MASTER_SITE_PERL_CPAN+=	\
561	ftp://ftp.digital.com/pub/plan/perl/CPAN/modules/by-module/%SUBDIR%/ \
562	ftp://ftp.cdrom.com/pub/perl/CPAN/modules/by-module/%SUBDIR%/
563
564MASTER_SITE_TEX_CTAN+=  \
565        ftp://ftp.cdrom.com/pub/tex/ctan/%SUBDIR%/  \
566        ftp://wuarchive.wustl.edu/packages/TeX/%SUBDIR%/  \
567        ftp://ftp.funet.fi/pub/TeX/CTAN/%SUBDIR%/  \
568        ftp://ftp.tex.ac.uk/public/ctan/tex-archive/%SUBDIR%/  \
569        ftp://ftp.dante.de/tex-archive/%SUBDIR%/
570
571MASTER_SITE_SUNSITE+=	\
572	ftp://sunsite.unc.edu/pub/Linux/%SUBDIR%/ \
573	ftp://ftp.infomagic.com/pub/mirrors/linux/sunsite/%SUBDIR%/ \
574	ftp://ftp.funet.fi/pub/mirrors/sunsite.unc.edu/pub/Linux/%SUBDIR%/
575
576MASTER_SITE_KDE+=	\
577	ftp://ftp.kde.org/pub/kde/%SUBDIR%/ \
578	ftp://ftp.tuniv.szczecin.pl/pub/kde/%SUBDIR%/ \
579	ftp://ftp.fu-berlin.de/pub/unix/X11/gui/kde/%SUBDIR%/ \
580	ftp://ftp.blaze.net.au/pub/kde/%SUBDIR%/ \
581	ftp://ftp.dataplus.se/pub/linux/kde/%SUBDIR%/ \
582	ftp://ftp.caldera.com/pub/mirrors/kde/%SUBDIR%/
583
584# Empty declaration to avoid "variable MASTER_SITES recursive" error
585MASTER_SITES?=
586PATCH_SITES?=
587
588# To avoid double-slashes
589MASTER_SITE_SUBDIR?=	.
590PATCH_SITE_SUBDIR?=	.
591
592# Substitute subdirectory names
593MASTER_SITES:=	${MASTER_SITES:S/%SUBDIR%/${MASTER_SITE_SUBDIR}/}
594PATCH_SITES:=	${PATCH_SITES:S/%SUBDIR%/${PATCH_SITE_SUBDIR}/}
595
596# The primary backup site.
597MASTER_SITE_BACKUP?=	\
598	ftp://ftp.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/
599
600# If the user has this set, go to the FreeBSD repository for everything.
601.if defined(MASTER_SITE_FREEBSD)
602MASTER_SITE_OVERRIDE=  ${MASTER_SITE_BACKUP}
603.endif
604
605# Where to put distfiles that don't have any other master site
606MASTER_SITE_LOCAL?= \
607	ftp://ftp.freebsd.org/pub/FreeBSD/distfiles/LOCAL_PORTS/
608
609# I guess we're in the master distribution business! :)  As we gain mirror
610# sites for distfiles, add them to this list.
611.if !defined(MASTER_SITE_OVERRIDE)
612MASTER_SITES+=	${MASTER_SITE_BACKUP}
613PATCH_SITES+=	${MASTER_SITE_BACKUP}
614.else
615MASTER_SITES:=	${MASTER_SITE_OVERRIDE} ${MASTER_SITES}
616PATCH_SITES:=	${MASTER_SITE_OVERRIDE} ${PATCH_SITES}
617.endif
618
619# Search CDROM first if mounted, symlink instead of copy if
620# FETCH_SYMLINK_DISTFILES is set
621.if exists(/cdrom/ports/distfiles)
622MASTER_SITES:=	file:/cdrom/ports/distfiles/${DIST_SUBDIR}/ ${MASTER_SITES}
623PATCH_SITES:=	file:/cdrom/ports/distfiles/${DIST_SUBDIR}/ ${PATCH_SITES}
624.if defined(FETCH_SYMLINK_DISTFILES)
625FETCH_BEFORE_ARGS+=	-l
626.endif
627.endif
628
629# Derived names so that they're easily overridable.
630DISTFILES?=		${DISTNAME}${EXTRACT_SUFX}
631PKGNAME?=		${DISTNAME}
632
633ALLFILES?=	${DISTFILES} ${PATCHFILES}
634
635.if defined(IGNOREFILES)
636CKSUMFILES!=	\
637	for file in ${ALLFILES}; do \
638		ignore=0; \
639		for tmp in ${IGNOREFILES}; do \
640			if [ "$$file" = "$$tmp" ]; then \
641				ignore=1; \
642			fi; \
643		done; \
644		if [ "$$ignore" = 0 ]; then \
645			echo "$$file"; \
646		fi; \
647	done
648.else
649CKSUMFILES=		${ALLFILES}
650.endif
651
652# List of all files, with ${DIST_SUBDIR} in front.  Used for checksum.
653.if defined(DIST_SUBDIR)
654_CKSUMFILES?=	${CKSUMFILES:S/^/${DIST_SUBDIR}\//}
655_IGNOREFILES?=	${IGNOREFILES:S/^/${DIST_SUBDIR}\//}
656.else
657_CKSUMFILES?=	${CKSUMFILES}
658_IGNOREFILES?=	${IGNOREFILES}
659.endif
660
661# This is what is actually going to be extracted, and is overridable
662#  by user.
663EXTRACT_ONLY?=	${DISTFILES}
664
665# Documentation
666MAINTAINER?=	ports@FreeBSD.ORG
667
668.if !defined(CATEGORIES)
669.BEGIN:
670	@${ECHO_MSG} "CATEGORIES is mandatory."
671	@${FALSE}
672.endif
673
674# Note this has to start with a capital letter (or more accurately, it
675#  shouldn't match "[a-z]*"), see the target "delete-package-links" below.
676PKGREPOSITORYSUBDIR?=	All
677PKGREPOSITORY?=		${PACKAGES}/${PKGREPOSITORYSUBDIR}
678.if exists(${PACKAGES})
679PKGFILE?=		${PKGREPOSITORY}/${PKGNAME}${PKG_SUFX}
680.else
681PKGFILE?=		${.CURDIR}/${PKGNAME}${PKG_SUFX}
682.endif
683
684# The "latest version" link -- ${PKGNAME} minus everthing after the last '-'
685PKGLATESTREPOSITORY?=	${PACKAGES}/Latest
686PKGBASE!=	${ECHO} ${PKGNAME} | ${SED} -e 's/-[^-]*$$//'
687PKGLATESTFILE?=		${PKGLATESTREPOSITORY}/${PKGBASE}${PKG_SUFX}
688
689CONFIGURE_SCRIPT?=	configure
690
691.if defined(GNU_CONFIGURE)
692CONFIGURE_ARGS+=	--prefix=${PREFIX}
693HAS_CONFIGURE=		yes
694.endif
695
696# Passed to most of script invocations
697SCRIPTS_ENV+=	CURDIR=${.CURDIR} DISTDIR=${DISTDIR} \
698		  WRKDIR=${WRKDIR} WRKSRC=${WRKSRC} PATCHDIR=${PATCHDIR} \
699		  SCRIPTDIR=${SCRIPTDIR} FILESDIR=${FILESDIR} \
700		  PORTSDIR=${PORTSDIR} DEPENDS="${DEPENDS}" \
701		  PREFIX=${PREFIX} LOCALBASE=${LOCALBASE} X11BASE=${X11BASE}
702
703.if defined(BATCH)
704SCRIPTS_ENV+=	BATCH=yes
705.endif
706
707MANPREFIX?=	${PREFIX}
708
709.for sect in 1 2 3 4 5 6 7 8 9
710MAN${sect}PREFIX?=	${MANPREFIX}
711.endfor
712MANLPREFIX?=	${MANPREFIX}
713MANNPREFIX?=	${MANPREFIX}
714
715MANLANG?=	""	# english only by default
716
717.for lang in ${MANLANG}
718
719.for sect in 1 2 3 4 5 6 7 8 9
720.if defined(MAN${sect})
721_MANPAGES+=	${MAN${sect}:S%^%${MAN${sect}PREFIX}/man/${lang}/man${sect}/%}
722.endif
723.endfor
724
725.if defined(MANL)
726_MANPAGES+=	${MANL:S%^%${MANLPREFIX}/man/${lang}/manl/%}
727.endif
728
729.if defined(MANN)
730_MANPAGES+=	${MANN:S%^%${MANNPREFIX}/man/${lang}/mann/%}
731.endif
732
733.endfor
734
735.if defined(_MANPAGES) && defined(MANCOMPRESSED)
736_MANPAGES:=	${_MANPAGES:S/$/.gz/}
737.endif
738
739.MAIN: all
740
741################################################################
742# Many ways to disable a port.
743#
744# If we're in BATCH mode and the port is interactive, or we're
745# in interactive mode and the port is non-interactive, skip all
746# the important targets.  The reason we have two modes is that
747# one might want to leave a build in BATCH mode running
748# overnight, then come back in the morning and do _only_ the
749# interactive ones that required your intervention.
750#
751# Don't attempt to build ports that require Motif if you don't
752# have Motif.
753#
754# Ignore ports that can't be resold if building for a CDROM.
755#
756# Don't build a port if it's restricted and we don't want to get
757# into that.
758#
759# Don't build a port if it's broken.
760################################################################
761
762.if !defined(NO_IGNORE)
763.if (defined(IS_INTERACTIVE) && defined(BATCH))
764IGNORE=	"is an interactive port"
765.elif (!defined(IS_INTERACTIVE) && defined(INTERACTIVE))
766IGNORE=	"is not an interactive port"
767.elif (defined(REQUIRES_MOTIF) && !defined(HAVE_MOTIF))
768IGNORE=	"requires Motif"
769.elif (defined(MOTIF_ONLY) && !defined(REQUIRES_MOTIF))
770IGNORE=	"does not require Motif"
771.elif (defined(NO_CDROM) && defined(FOR_CDROM))
772IGNORE=	"may not be placed on a CDROM: ${NO_CDROM}"
773.elif (defined(RESTRICTED) && defined(NO_RESTRICTED))
774IGNORE=	"is restricted: ${RESTRICTED}"
775.elif (defined(USE_X11) && !exists(${X11BASE}))
776IGNORE=	"uses X11, but ${X11BASE} not found"
777.elif exists(/usr/include/tcl.h)
778IGNORE=	": You have an old tcl installation on your machine.  Remove everything that matches '/usr/*/*tcl*' first"
779.elif exists(${LOCALBASE}/include/tcl.h) || exists(${LOCALBASE}/lib/tclConfig.sh)
780IGNORE=	": You have an old tcl installation on your machine.  Remove everything that matches '${PREFIX}/*/*tcl*' first"
781.elif exists(${LOCALBASE}/include/tk.h) || exists(${LOCALBASE}/lib/tkConfig.sh)
782IGNORE=	": You have an old tk installation on your machine.  Remove everything that matches '${PREFIX}/*/*tk*' first"
783.elif defined(BROKEN)
784IGNORE=	"is marked as broken: ${BROKEN}"
785.endif
786
787.if (defined(MANUAL_PACKAGE_BUILD) && defined(PACKAGE_BUILDING))
788IGNORE=	"package has to be built manually: ${MANUAL_PACKAGE_BUILD}"
789clean:
790	@${IGNORECMD}
791.endif
792
793.if defined(IGNORE)
794.if defined(IGNORE_SILENT)
795IGNORECMD=	${DO_NADA}
796.else
797IGNORECMD=	${ECHO_MSG} "===>  ${PKGNAME} ${IGNORE}."
798.endif
799fetch:
800	@${IGNORECMD}
801checksum:
802	@${IGNORECMD}
803extract:
804	@${IGNORECMD}
805patch:
806	@${IGNORECMD}
807configure:
808	@${IGNORECMD}
809all:
810	@${IGNORECMD}
811build:
812	@${IGNORECMD}
813install:
814	@${IGNORECMD}
815deinstall:
816	@${IGNORECMD}
817package:
818	@${IGNORECMD}
819.endif
820.endif
821
822.if defined(ALL_HOOK)
823all:
824	@cd ${.CURDIR} && ${SETENV} CURDIR=${.CURDIR} DISTNAME=${DISTNAME} \
825	  DISTDIR=${DISTDIR} WRKDIR=${WRKDIR} WRKSRC=${WRKSRC} \
826	  PATCHDIR=${PATCHDIR} SCRIPTDIR=${SCRIPTDIR} \
827	  FILESDIR=${FILESDIR} PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} \
828	  DEPENDS="${DEPENDS}" BUILD_DEPENDS="${BUILD_DEPENDS}" \
829	  RUN_DEPENDS="${RUN_DEPENDS}" X11BASE=${X11BASE} \
830	${ALL_HOOK}
831.endif
832
833.if !target(all)
834all: build
835.endif
836
837.if !defined(DEPENDS_TARGET)
838.if make(reinstall)
839DEPENDS_TARGET=	reinstall
840.else
841DEPENDS_TARGET=	install
842.endif
843.endif
844
845################################################################
846# The following are used to create easy dummy targets for
847# disabling some bit of default target behavior you don't want.
848# They still check to see if the target exists, and if so don't
849# do anything, since you might want to set this globally for a
850# group of ports in a Makefile.inc, but still be able to
851# override from an individual Makefile.
852################################################################
853
854# Disable checksum
855.if defined(NO_CHECKSUM) && !target(checksum)
856checksum: fetch
857	@${DO_NADA}
858.endif
859
860# Disable extract
861.if defined(NO_EXTRACT) && !target(extract)
862extract: checksum
863	@${TOUCH} ${TOUCH_FLAGS} ${EXTRACT_COOKIE}
864checksum: fetch
865	@${DO_NADA}
866makesum:
867	@${DO_NADA}
868.endif
869
870# Disable patch
871.if defined(NO_PATCH) && !target(patch)
872patch: extract
873	@${TOUCH} ${TOUCH_FLAGS} ${PATCH_COOKIE}
874.endif
875
876# Disable configure
877.if defined(NO_CONFIGURE) && !target(configure)
878configure: patch
879	@${TOUCH} ${TOUCH_FLAGS} ${CONFIGURE_COOKIE}
880.endif
881
882# Disable build
883.if defined(NO_BUILD) && !target(build)
884build: configure
885	@${TOUCH} ${TOUCH_FLAGS} ${BUILD_COOKIE}
886.endif
887
888# Disable install
889.if defined(NO_INSTALL) && !target(install)
890install: build
891	@${TOUCH} ${TOUCH_FLAGS} ${INSTALL_COOKIE}
892.endif
893
894# Disable package
895.if defined(NO_PACKAGE) && !target(package)
896package:
897.if defined(IGNORE_SILENT)
898	@${DO_NADA}
899.else
900	@${ECHO_MSG} "===>  ${PKGNAME} may not be packaged: ${NO_PACKAGE}."
901.endif
902.endif
903
904# Disable describe
905.if defined(NO_DESCRIBE) && !target(describe)
906describe:
907	@${DO_NADA}
908.endif
909
910################################################################
911# More standard targets start here.
912#
913# These are the body of the build/install framework.  If you are
914# not happy with the default actions, and you can't solve it by
915# adding pre-* or post-* targets/scripts, override these.
916################################################################
917
918# Fetch
919
920.if !target(do-fetch)
921do-fetch:
922	@${MKDIR} ${_DISTDIR}
923	@(cd ${_DISTDIR}; \
924	 for file in ${DISTFILES}; do \
925		if [ ! -f $$file -a ! -f `${BASENAME} $$file` ]; then \
926			if [ -h $$file -o -h `${BASENAME} $$file` ]; then \
927				${ECHO_MSG} ">> ${_DISTDIR}/$$file is a broken symlink."; \
928				${ECHO_MSG} ">> Perhaps a filesystem (most likely a CD) isn't mounted?"; \
929				${ECHO_MSG} ">> Please correct this problem and try again."; \
930				exit 1; \
931			fi ; \
932			${ECHO_MSG} ">> $$file doesn't seem to exist on this system."; \
933			for site in ${MASTER_SITES}; do \
934			    ${ECHO_MSG} ">> Attempting to fetch from $${site}."; \
935				if ${FETCH_CMD} ${FETCH_BEFORE_ARGS} $${site}$${file} ${FETCH_AFTER_ARGS}; then \
936					continue 2; \
937				fi \
938			done; \
939			${ECHO_MSG} ">> Couldn't fetch it - please try to retrieve this";\
940			${ECHO_MSG} ">> port manually into ${_DISTDIR} and try again."; \
941			exit 1; \
942	    fi \
943	 done)
944.if defined(PATCHFILES)
945	@(cd ${_DISTDIR}; \
946	 for file in ${PATCHFILES}; do \
947		if [ ! -f $$file -a ! -f `${BASENAME} $$file` ]; then \
948			if [ -h $$file -o -h `${BASENAME} $$file` ]; then \
949				${ECHO_MSG} ">> ${_DISTDIR}/$$file is a broken symlink."; \
950				${ECHO_MSG} ">> Perhaps a filesystem (most likely a CD) isn't mounted?"; \
951				${ECHO_MSG} ">> Please correct this problem and try again."; \
952				exit 1; \
953			fi ; \
954			${ECHO_MSG} ">> $$file doesn't seem to exist on this system."; \
955			for site in ${PATCH_SITES}; do \
956			    ${ECHO_MSG} ">> Attempting to fetch from $${site}."; \
957				if ${FETCH_CMD} ${FETCH_BEFORE_ARGS} $${site}$${file} ${FETCH_AFTER_ARGS}; then \
958					continue 2; \
959				fi \
960			done; \
961			${ECHO_MSG} ">> Couldn't fetch it - please try to retrieve this";\
962			${ECHO_MSG} ">> port manually into ${_DISTDIR} and try again."; \
963			exit 1; \
964	    fi \
965	 done)
966.endif
967.endif
968
969# Extract
970
971.if !target(do-extract)
972do-extract:
973.if !defined(NO_WRKDIR)
974	@${RM} -rf ${WRKDIR}
975	@${MKDIR} ${WRKDIR}
976.endif
977	@for file in ${EXTRACT_ONLY}; do \
978		if ! (cd ${WRKDIR} && ${EXTRACT_CMD} ${EXTRACT_BEFORE_ARGS} ${_DISTDIR}/$$file ${EXTRACT_AFTER_ARGS});\
979		then \
980			exit 1; \
981		fi \
982	done
983.endif
984
985# Patch
986
987.if !target(do-patch)
988do-patch:
989.if defined(PATCHFILES)
990	@${ECHO_MSG} "===>  Applying distribution patches for ${PKGNAME}"
991	@(cd ${_DISTDIR}; \
992	  for i in ${PATCHFILES}; do \
993		if [ ${PATCH_DEBUG_TMP} = yes ]; then \
994			${ECHO_MSG} "===>   Applying distribution patch $$i" ; \
995		fi; \
996		case $$i in \
997			*.Z|*.gz) \
998				${GZCAT} $$i | ${PATCH} ${PATCH_DIST_ARGS}; \
999				;; \
1000			*) \
1001				${PATCH} ${PATCH_DIST_ARGS} < $$i; \
1002				;; \
1003		esac; \
1004	  done)
1005.endif
1006	@if [ -d ${PATCHDIR} ]; then \
1007		if [ "`echo ${PATCHDIR}/patch-*`" = "${PATCHDIR}/patch-*" ]; then \
1008			${ECHO_MSG} "===>   Ignoring empty patch directory"; \
1009			if [ -d ${PATCHDIR}/CVS ]; then \
1010				${ECHO_MSG} "===>   Perhaps you forgot the -P flag to cvs co or update?"; \
1011			fi; \
1012		else \
1013			${ECHO_MSG} "===>  Applying ${OPSYS} patches for ${PKGNAME}" ; \
1014			for i in ${PATCHDIR}/patch-*; do \
1015				case $$i in \
1016					*.orig|*.rej|*~) \
1017						${ECHO_MSG} "===>   Ignoring patchfile $$i" ; \
1018						;; \
1019					*) \
1020						if [ ${PATCH_DEBUG_TMP} = yes ]; then \
1021							${ECHO_MSG} "===>   Applying ${OPSYS} patch $$i" ; \
1022						fi; \
1023						${PATCH} ${PATCH_ARGS} < $$i; \
1024						;; \
1025				esac; \
1026			done; \
1027		fi; \
1028	fi
1029.endif
1030
1031# Configure
1032
1033.if !target(do-configure)
1034do-configure:
1035.if defined(USE_AUTOCONF)
1036	@(cd ${WRKSRC} && ${AUTOCONF})
1037.endif
1038	@if [ -f ${SCRIPTDIR}/configure ]; then \
1039		cd ${.CURDIR} && ${SETENV} ${SCRIPTS_ENV} ${SH} \
1040		  ${SCRIPTDIR}/configure; \
1041	fi
1042.if defined(HAS_CONFIGURE)
1043	@(cd ${WRKSRC} && CC="${CC}" ac_cv_path_CC="${CC}" CFLAGS="${CFLAGS}" \
1044	    INSTALL="/usr/bin/install -c -o ${BINOWN} -g ${BINGRP}" \
1045	    INSTALL_DATA="${INSTALL_DATA}" \
1046	    INSTALL_PROGRAM="${INSTALL_PROGRAM}" \
1047	    INSTALL_SCRIPT="${INSTALL_SCRIPT}" \
1048	    ${CONFIGURE_ENV} ./${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS})
1049.endif
1050.if defined(USE_IMAKE)
1051	@(cd ${WRKSRC} && ${XMKMF})
1052.endif
1053.endif
1054
1055# Build
1056
1057.if !target(do-build)
1058do-build:
1059.if defined(USE_GMAKE)
1060	@(cd ${WRKSRC}; ${SETENV} ${MAKE_ENV} ${GMAKE} ${MAKE_FLAGS} ${MAKEFILE} ${ALL_TARGET})
1061.else defined(USE_GMAKE)
1062	@(cd ${WRKSRC}; ${SETENV} ${MAKE_ENV} ${MAKE} ${MAKE_FLAGS} ${MAKEFILE} ${ALL_TARGET})
1063.endif
1064.endif
1065
1066# Install
1067
1068.if !target(do-install)
1069do-install:
1070.if defined(USE_GMAKE)
1071	@(cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} ${GMAKE} ${MAKE_FLAGS} ${MAKEFILE} ${INSTALL_TARGET})
1072.if defined(USE_IMAKE) && !defined(NO_INSTALL_MANPAGES)
1073	@(cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} ${GMAKE} ${MAKE_FLAGS} ${MAKEFILE} install.man)
1074.endif
1075.else defined(USE_GMAKE)
1076	@(cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} ${MAKE} ${MAKE_FLAGS} ${MAKEFILE} ${INSTALL_TARGET})
1077.if defined(USE_IMAKE) && !defined(NO_INSTALL_MANPAGES)
1078	@(cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} ${MAKE} ${MAKE_FLAGS} ${MAKEFILE} install.man)
1079.endif
1080.endif
1081.endif
1082
1083# Package
1084
1085.if !target(do-package)
1086do-package:
1087	@if [ -e ${PLIST} ]; then \
1088		${ECHO_MSG} "===>  Building package for ${PKGNAME}"; \
1089		if [ -d ${PACKAGES} ]; then \
1090			if [ ! -d ${PKGREPOSITORY} ]; then \
1091				if ! ${MKDIR} ${PKGREPOSITORY}; then \
1092					${ECHO_MSG} ">> Can't create directory ${PKGREPOSITORY}."; \
1093					exit 1; \
1094				fi; \
1095			fi; \
1096		fi; \
1097		if ${PKG_CMD} ${PKG_ARGS} ${PKGFILE}; then \
1098			if [ -d ${PACKAGES} ]; then \
1099				${MAKE} ${.MAKEFLAGS} package-links; \
1100			fi; \
1101		else \
1102			${MAKE} ${.MAKEFLAGS} delete-package; \
1103			exit 1; \
1104		fi; \
1105	fi
1106.endif
1107
1108# Some support rules for do-package
1109
1110.if !target(package-links)
1111package-links:
1112	@${MAKE} ${.MAKEFLAGS} delete-package-links
1113	@for cat in ${CATEGORIES}; do \
1114		if [ ! -d ${PACKAGES}/$$cat ]; then \
1115			if ! ${MKDIR} ${PACKAGES}/$$cat; then \
1116				${ECHO_MSG} ">> Can't create directory ${PACKAGES}/$$cat."; \
1117				exit 1; \
1118			fi; \
1119		fi; \
1120		${LN} -s ../${PKGREPOSITORYSUBDIR}/${PKGNAME}${PKG_SUFX} ${PACKAGES}/$$cat; \
1121	done
1122	@if [ ! -d ${PKGLATESTREPOSITORY} ]; then \
1123		if ! ${MKDIR} ${PKGLATESTREPOSITORY}; then \
1124			${ECHO_MSG} ">> Can't create directory ${PKGLATESTREPOSITORY}."; \
1125			exit 1; \
1126		fi; \
1127	fi
1128	@${LN} -s ../${PKGREPOSITORYSUBDIR}/${PKGNAME}${PKG_SUFX} ${PKGLATESTFILE}
1129.endif
1130
1131.if !target(delete-package-links)
1132delete-package-links:
1133	@${RM} -f ${PACKAGES}/[a-z]*/${PKGNAME}${PKG_SUFX} ${PKGLATESTFILE}
1134.endif
1135
1136.if !target(delete-package)
1137delete-package:
1138	@${MAKE} ${.MAKEFLAGS} delete-package-links
1139	@${RM} -f ${PKGFILE}
1140.endif
1141
1142################################################################
1143# This is the "generic" port target, actually a macro used from the
1144# six main targets.  See below for more.
1145################################################################
1146
1147_PORT_USE: .USE
1148.if make(real-fetch)
1149	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} fetch-depends
1150.endif
1151.if make(real-extract)
1152	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} build-depends lib-depends misc-depends
1153.endif
1154.if make(real-install)
1155.if !defined(NO_PKG_REGISTER) && !defined(FORCE_PKG_REGISTER)
1156	@if [ -d ${PKG_DBDIR}/${PKGNAME} ]; then \
1157		${ECHO_MSG} "===>  ${PKGNAME} is already installed - perhaps an older version?"; \
1158		${ECHO_MSG} "      If so, you may wish to \`\`make deinstall'' and install"; \
1159		${ECHO_MSG} "      this port again by \`\`make reinstall'' to upgrade it properly."; \
1160		${ECHO_MSG} "      If you really wish to overwrite the old port of ${PKGNAME}"; \
1161		${ECHO_MSG} "      without deleting it first, set the variable \"FORCE_PKG_REGISTER\""; \
1162		${ECHO_MSG} "      in your environment or the \"make install\" command line."; \
1163		exit 1; \
1164	fi
1165.endif
1166	@if [ `${SH} -c umask` != 0022 ]; then \
1167		${ECHO_MSG} "===>  Warning: your umask is \"`${SH} -c umask`"\".; \
1168		${ECHO_MSG} "      If this is not desired, set it to an appropriate value"; \
1169		${ECHO_MSG} "      and install this port again by \`\`make reinstall''."; \
1170	fi
1171	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} run-depends lib-depends
1172.endif
1173.if make(real-install)
1174.if !defined(NO_MTREE)
1175	@if [ `id -u` = 0 ]; then \
1176		if [ ! -f ${MTREE_FILE} ]; then \
1177			${ECHO_MSG} "Error: mtree file \"${MTREE_FILE}\" is missing."; \
1178			${ECHO_MSG} "Copy it from a suitable location (e.g., /usr/src/etc/mtree) and try again."; \
1179			exit 1; \
1180		else \
1181			${MTREE_CMD} ${MTREE_ARGS} ${PREFIX}/; \
1182		fi; \
1183	else \
1184		${ECHO_MSG} "Warning: not superuser, can't run mtree."; \
1185		${ECHO_MSG} "Become root and try again to ensure correct permissions."; \
1186	fi
1187.endif
1188.endif
1189	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} ${.TARGET:S/^real-/pre-/}
1190	@if [ -f ${SCRIPTDIR}/${.TARGET:S/^real-/pre-/} ]; then \
1191		cd ${.CURDIR} && ${SETENV} ${SCRIPTS_ENV} ${SH} \
1192			${SCRIPTDIR}/${.TARGET:S/^real-/pre-/}; \
1193	fi
1194	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} ${.TARGET:S/^real-/do-/}
1195	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} ${.TARGET:S/^real-/post-/}
1196	@if [ -f ${SCRIPTDIR}/${.TARGET:S/^real-/post-/} ]; then \
1197		cd ${.CURDIR} && ${SETENV} ${SCRIPTS_ENV} ${SH} \
1198			${SCRIPTDIR}/${.TARGET:S/^real-/post-/}; \
1199	fi
1200.if make(real-install) && defined(_MANPAGES)
1201.if defined(MANCOMPRESSED) && defined(NOMANCOMPRESS)
1202	@${ECHO_MSG} "===>   Uncompressing manual pages for ${PKGNAME}"
1203.for manpage in ${_MANPAGES}
1204	@${GUNZIP_CMD} ${manpage}
1205.endfor
1206.elif !defined(MANCOMPRESSED) && !defined(NOMANCOMPRESS)
1207	@${ECHO_MSG} "===>   Compressing manual pages for ${PKGNAME}"
1208.for manpage in ${_MANPAGES}
1209	@${GZIP_CMD} ${manpage}
1210.endfor
1211.endif
1212.endif
1213.if make(real-install) && !defined(NO_PKG_REGISTER)
1214	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} fake-pkg
1215.endif
1216.if !make(real-fetch) \
1217	&& (!make(real-patch) || !defined(PATCH_CHECK_ONLY)) \
1218	&& (!make(real-package) || !defined(PACKAGE_NOINSTALL))
1219	@${TOUCH} ${TOUCH_FLAGS} ${WRKDIR}/.${.TARGET:S/^real-//}_done
1220.endif
1221
1222################################################################
1223# Skeleton targets start here
1224# 
1225# You shouldn't have to change these.  Either add the pre-* or
1226# post-* targets/scripts or redefine the do-* targets.  These
1227# targets don't do anything other than checking for cookies and
1228# call the necessary targets/scripts.
1229################################################################
1230
1231.if !target(fetch)
1232fetch:
1233	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} real-fetch
1234.endif
1235
1236.if !target(extract)
1237extract: checksum ${EXTRACT_COOKIE}
1238.endif
1239
1240.if !target(patch)
1241patch: extract ${PATCH_COOKIE}
1242.endif
1243
1244.if !target(configure)
1245configure: patch ${CONFIGURE_COOKIE}
1246.endif
1247
1248.if !target(build)
1249build: configure ${BUILD_COOKIE}
1250.endif
1251
1252.if !target(install)
1253install: build ${INSTALL_COOKIE}
1254.endif
1255
1256.if !target(package)
1257package: install ${PACKAGE_COOKIE}
1258.endif
1259
1260${EXTRACT_COOKIE}:
1261	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} real-extract
1262${PATCH_COOKIE}:
1263	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} real-patch
1264${CONFIGURE_COOKIE}:
1265	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} real-configure
1266${BUILD_COOKIE}:
1267	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} real-build
1268${INSTALL_COOKIE}:
1269	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} real-install
1270${PACKAGE_COOKIE}:
1271	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} real-package
1272
1273# And call the macros
1274
1275real-fetch: _PORT_USE
1276real-extract: _PORT_USE
1277	@${ECHO_MSG} "===>  Extracting for ${PKGNAME}"
1278real-patch: _PORT_USE
1279	@${ECHO_MSG} "===>  Patching for ${PKGNAME}"
1280real-configure: _PORT_USE
1281	@${ECHO_MSG} "===>  Configuring for ${PKGNAME}"
1282real-build: _PORT_USE
1283	@${ECHO_MSG} "===>  Building for ${PKGNAME}"
1284real-install: _PORT_USE
1285	@${ECHO_MSG} "===>  Installing for ${PKGNAME}"
1286real-package: _PORT_USE
1287
1288# Empty pre-* and post-* targets, note we can't use .if !target()
1289# in the _PORT_USE macro
1290
1291.for name in fetch extract patch configure build install package
1292
1293.if !target(pre-${name})
1294pre-${name}:
1295	@${DO_NADA}
1296.endif
1297
1298.if !target(post-${name})
1299post-${name}:
1300	@${DO_NADA}
1301.endif
1302
1303.endfor
1304
1305# Checkpatch
1306#
1307# Special target to verify patches
1308
1309.if !target(checkpatch)
1310checkpatch:
1311	@cd ${.CURDIR} && ${MAKE} PATCH_CHECK_ONLY=yes ${.MAKEFLAGS} patch
1312.endif
1313
1314# Reinstall
1315#
1316# Special target to re-run install
1317
1318.if !target(reinstall)
1319reinstall:
1320	@${RM} -f ${INSTALL_COOKIE} ${PACKAGE_COOKIE}
1321	@DEPENDS_TARGET=${DEPENDS_TARGET} ${MAKE} install
1322.endif
1323
1324# Deinstall
1325#
1326# Special target to remove installation
1327
1328.if !target(deinstall)
1329deinstall:
1330	@${ECHO_MSG} "===> Deinstalling for ${PKGNAME}"
1331	@pkg_delete -f `make package-name`
1332	@${RM} -f ${INSTALL_COOKIE} ${PACKAGE_COOKIE}
1333.endif
1334
1335################################################################
1336# Some more targets supplied for users' convenience
1337################################################################
1338
1339# Cleaning up
1340
1341.if !target(pre-clean)
1342pre-clean:
1343	@${DO_NADA}
1344.endif
1345
1346.if !target(clean)
1347clean: pre-clean
1348.if !defined(NOCLEANDEPENDS)
1349	@${MAKE} clean-depends
1350.endif
1351	@${ECHO_MSG} "===>  Cleaning for ${PKGNAME}"
1352.if !defined(NO_WRKDIR)
1353	@if [ -d ${WRKDIR} ]; then \
1354		if [ -w ${WRKDIR} ]; then \
1355			${RM} -rf ${WRKDIR}; \
1356		else \
1357			${ECHO_MSG} "===>   ${WRKDIR} not writable, skipping"; \
1358		fi; \
1359	fi
1360.else
1361	@${RM} -f ${WRKDIR}/.*_done
1362.endif
1363.endif
1364
1365.if !target(pre-distclean)
1366pre-distclean:
1367	@${DO_NADA}
1368.endif
1369
1370.if !target(distclean)
1371distclean: pre-distclean clean
1372	@${ECHO_MSG} "===>  Dist cleaning for ${PKGNAME}"
1373	@(if [ -d ${_DISTDIR} ]; then \
1374		cd ${_DISTDIR}; \
1375		${RM} -f ${DISTFILES} ${PATCHFILES}; \
1376	fi)
1377.if defined(DIST_SUBDIR)
1378	-@${RMDIR} ${_DISTDIR}  
1379.endif
1380.endif
1381
1382# Prints out a list of files to fetch (useful to do a batch fetch)
1383
1384.if !target(fetch-list)
1385fetch-list:
1386	@${MKDIR} ${_DISTDIR}
1387	@(cd ${_DISTDIR}; \
1388	 for file in ${DISTFILES}; do \
1389		if [ ! -f $$file -a ! -f `${BASENAME} $$file` ]; then \
1390			for site in ${MASTER_SITES}; do \
1391				${ECHO} -n ${FETCH_CMD} ${FETCH_BEFORE_ARGS} $${site}$${file} "${FETCH_AFTER_ARGS}" '||' ; \
1392					break; \
1393			done; \
1394			${ECHO} "echo $${file} not fetched" ; \
1395		fi \
1396	done)
1397.if defined(PATCHFILES)
1398	@(cd ${_DISTDIR}; \
1399	 for file in ${PATCHFILES}; do \
1400		if [ ! -f $$file -a ! -f `${BASENAME} $$file` ]; then \
1401			for site in ${PATCH_SITES}; do \
1402				${ECHO} -n ${FETCH_CMD} ${FETCH_BEFORE_ARGS} $${site}$${file} "${FETCH_AFTER_ARGS}" '||' ; \
1403					break; \
1404			done; \
1405			${ECHO} "echo $${file} not fetched" ; \
1406		fi \
1407	 done)
1408.endif
1409.endif
1410
1411# Checksumming utilities
1412
1413.if !target(makesum)
1414makesum: fetch
1415	@${MKDIR} ${FILESDIR}
1416	@if [ -f ${MD5_FILE} ]; then ${RM} -f ${MD5_FILE}; fi
1417	@(cd ${DISTDIR}; \
1418	 for file in ${_CKSUMFILES}; do \
1419		${MD5} $$file >> ${MD5_FILE}; \
1420	 done)
1421	@for file in ${_IGNOREFILES}; do \
1422		${ECHO} "MD5 ($$file) = IGNORE" >> ${MD5_FILE}; \
1423	done
1424.endif
1425
1426.if !target(checksum)
1427checksum: fetch
1428	@if [ ! -f ${MD5_FILE} ]; then \
1429		${ECHO_MSG} ">> No MD5 checksum file."; \
1430	else \
1431		(cd ${DISTDIR}; OK="true"; \
1432		  for file in ${_CKSUMFILES}; do \
1433			CKSUM=`${MD5} < $$file`; \
1434			CKSUM2=`${GREP} "^MD5 ($$file)" ${MD5_FILE} | ${AWK} '{print $$4}'`; \
1435			if [ "$$CKSUM2" = "" ]; then \
1436				${ECHO_MSG} ">> No checksum recorded for $$file."; \
1437				OK="false"; \
1438			elif [ "$$CKSUM2" = "IGNORE" ]; then \
1439				${ECHO_MSG} ">> Checksum for $$file is set to IGNORE in md5 file even though"; \
1440				${ECHO_MSG} "   the file is not in the "'$$'"{IGNOREFILES} list."; \
1441				OK="false"; \
1442			elif expr "$$CKSUM2" : ".*$$CKSUM" > /dev/null; then \
1443				${ECHO_MSG} ">> Checksum OK for $$file."; \
1444			else \
1445				${ECHO_MSG} ">> Checksum mismatch for $$file."; \
1446				OK="false"; \
1447			fi; \
1448		  done; \
1449		  for file in ${_IGNOREFILES}; do \
1450			CKSUM2=`${GREP} "($$file)" ${MD5_FILE} | ${AWK} '{print $$4}'`; \
1451			if [ "$$CKSUM2" = "" ]; then \
1452				${ECHO_MSG} ">> No checksum recorded for $$file, file is in "'$$'"{IGNOREFILES} list."; \
1453				OK="false"; \
1454			elif [ "$$CKSUM2" != "IGNORE" ]; then \
1455				${ECHO_MSG} ">> Checksum for $$file is not set to IGNORE in md5 file even though"; \
1456				${ECHO_MSG} "   the file is in the "'$$'"{IGNOREFILES} list."; \
1457				OK="false"; \
1458			fi; \
1459		  done; \
1460		  if [ "$$OK" != "true" ]; then \
1461			${ECHO_MSG} "Make sure the Makefile and md5 file (${MD5_FILE})"; \
1462			${ECHO_MSG} "are up to date.  If you want to override this check, type"; \
1463			${ECHO_MSG} "\"make NO_CHECKSUM=yes [other args]\"."; \
1464			exit 1; \
1465		  fi) ; \
1466	fi
1467.endif
1468
1469################################################################
1470# The special package-building targets
1471# You probably won't need to touch these
1472################################################################
1473
1474# Nobody should want to override this unless PKGNAME is simply bogus.
1475
1476.if !target(package-name)
1477package-name:
1478	@${ECHO} ${PKGNAME}
1479.endif
1480
1481# Show (recursively) all the packages this package depends on.
1482
1483.if !target(package-depends)
1484package-depends:
1485	@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 \
1486		if [ -d $$dir ]; then \
1487			(cd $$dir ; ${MAKE} package-name package-depends); \
1488		else \
1489			${ECHO_MSG} "Warning: \"$$dir\" non-existent -- @pkgdep registration incomplete" >&2; \
1490		fi; \
1491	done
1492.endif
1493
1494# Build a package but don't check the package cookie
1495
1496.if !target(repackage)
1497repackage: pre-repackage package
1498
1499pre-repackage:
1500	@${RM} -f ${PACKAGE_COOKIE}
1501.endif
1502
1503# Build a package but don't check the cookie for installation, also don't
1504# install package cookie
1505
1506.if !target(package-noinstall)
1507package-noinstall:
1508	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} PACKAGE_NOINSTALL=yes real-package
1509.endif
1510
1511################################################################
1512# Dependency checking
1513################################################################
1514
1515.if !target(depends)
1516depends: lib-depends misc-depends
1517	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} fetch-depends
1518	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} build-depends
1519	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} run-depends
1520
1521.if make(fetch-depends)
1522DEPENDS_TMP+=	${FETCH_DEPENDS}
1523.endif
1524
1525.if make(build-depends)
1526DEPENDS_TMP+=	${BUILD_DEPENDS}
1527.endif
1528
1529.if make(run-depends)
1530DEPENDS_TMP+=	${RUN_DEPENDS}
1531.endif
1532
1533_DEPENDS_USE:	.USE
1534.if defined(DEPENDS_TMP)
1535.if !defined(NO_DEPENDS)
1536	@for i in ${DEPENDS_TMP}; do \
1537		prog=`${ECHO} $$i | ${SED} -e 's/:.*//'`; \
1538		dir=`${ECHO} $$i | ${SED} -e 's/[^:]*://'`; \
1539		if expr "$$dir" : '.*:' > /dev/null; then \
1540			target=`${ECHO} $$dir | ${SED} -e 's/.*://'`; \
1541			dir=`${ECHO} $$dir | ${SED} -e 's/:.*//'`; \
1542		else \
1543			target=${DEPENDS_TARGET}; \
1544		fi; \
1545		if expr "$$prog" : \\/ >/dev/null; then \
1546			if [ -e "$$prog" ]; then \
1547				${ECHO_MSG} "===>  ${PKGNAME} depends on file: $$prog - found"; \
1548				notfound=0; \
1549			else \
1550				${ECHO_MSG} "===>  ${PKGNAME} depends on file: $$prog - not found"; \
1551				notfound=1; \
1552			fi; \
1553		else \
1554			if which "$$prog" > /dev/null 2>&1 ; then \
1555				${ECHO_MSG} "===>  ${PKGNAME} depends on executable: $$prog - found"; \
1556				notfound=0; \
1557			else \
1558				${ECHO_MSG} "===>  ${PKGNAME} depends on executable: $$prog - not found"; \
1559				notfound=1; \
1560			fi; \
1561		fi; \
1562		if [ $$notfound != 0 ]; then \
1563			${ECHO_MSG} "===>  Verifying $$target for $$prog in $$dir"; \
1564			if [ ! -d "$$dir" ]; then \
1565				${ECHO_MSG} ">> No directory for $$prog.  Skipping.."; \
1566			else \
1567				(cd $$dir; ${MAKE} ${.MAKEFLAGS} $$target) ; \
1568				${ECHO_MSG} "===>  Returning to build of ${PKGNAME}"; \
1569			fi; \
1570		fi; \
1571	done
1572.endif
1573.else
1574	@${DO_NADA}
1575.endif
1576
1577fetch-depends:	_DEPENDS_USE
1578build-depends:	_DEPENDS_USE
1579run-depends:	_DEPENDS_USE
1580
1581lib-depends:
1582.if defined(LIB_DEPENDS)
1583.if !defined(NO_DEPENDS)
1584	@for i in ${LIB_DEPENDS}; do \
1585		lib=`${ECHO} $$i | ${SED} -e 's/:.*//'`; \
1586		dir=`${ECHO} $$i | ${SED} -e 's/[^:]*://'`; \
1587		if expr "$$dir" : '.*:' > /dev/null; then \
1588			target=`${ECHO} $$dir | ${SED} -e 's/.*://'`; \
1589			dir=`${ECHO} $$dir | ${SED} -e 's/:.*//'`; \
1590		else \
1591			target=${DEPENDS_TARGET}; \
1592		fi; \
1593		if /sbin/ldconfig -r | ${GREP} -q -e "-l$$lib"; then \
1594			${ECHO_MSG} "===>  ${PKGNAME} depends on shared library: $$lib - found"; \
1595		else \
1596			${ECHO_MSG} "===>  ${PKGNAME} depends on shared library: $$lib - not found"; \
1597			${ECHO_MSG} "===>  Verifying $$target for $$lib in $$dir"; \
1598			if [ ! -d "$$dir" ]; then \
1599				${ECHO_MSG} ">> No directory for $$lib.  Skipping.."; \
1600			else \
1601				(cd $$dir; ${MAKE} ${.MAKEFLAGS} $$target) ; \
1602				${ECHO_MSG} "===>  Returning to build of ${PKGNAME}"; \
1603			fi; \
1604		fi; \
1605	done
1606.endif
1607.else
1608	@${DO_NADA}
1609.endif
1610
1611misc-depends:
1612.if defined(DEPENDS)
1613.if !defined(NO_DEPENDS)
1614	@for dir in ${DEPENDS}; do \
1615		if expr "$$dir" : '.*:' > /dev/null; then \
1616			target=`${ECHO} $$dir | ${SED} -e 's/.*://'`; \
1617			dir=`${ECHO} $$dir | ${SED} -e 's/:.*//'`; \
1618		else \
1619			target=${DEPENDS_TARGET}; \
1620		fi; \
1621		${ECHO_MSG} "===>  ${PKGNAME} depends on: $$dir"; \
1622		${ECHO_MSG} "===>  Verifying $$target for $$dir"; \
1623		if [ ! -d $$dir ]; then \
1624			${ECHO_MSG} ">> No directory for $$dir.  Skipping.."; \
1625		else \
1626			(cd $$dir; ${MAKE} ${.MAKEFLAGS} $$target) ; \
1627		fi \
1628	done
1629	@${ECHO_MSG} "===>  Returning to build of ${PKGNAME}"
1630.endif
1631.else
1632	@${DO_NADA}
1633.endif
1634
1635.endif
1636
1637.if !target(clean-depends)
1638clean-depends:
1639.if defined(FETCH_DEPENDS) || defined(BUILD_DEPENDS) || defined(LIB_DEPENDS) \
1640	|| defined(RUN_DEPENDS)
1641	@for dir in `${ECHO} ${FETCH_DEPENDS} ${BUILD_DEPENDS} ${LIB_DEPENDS} ${RUN_DEPENDS} | ${TR} '\040' '\012' | ${SED} -e 's/^[^:]*://' -e 's/:.*//' | sort -u`; do \
1642		if [ -d $$dir ] ; then \
1643			(cd $$dir; ${MAKE} NOCLEANDEPENDS=yes clean clean-depends); \
1644		fi \
1645	done
1646.endif
1647.if defined(DEPENDS)
1648	@for dir in `${ECHO} ${DEPENDS} | ${TR} '\040' '\012' | ${SED} -e 's/:.*//' | sort -u`; do \
1649		if [ -d $$dir ] ; then \
1650			(cd $$dir; ${MAKE} NOCLEANDEPENDS=yes clean clean-depends); \
1651		fi \
1652	done
1653.endif
1654.endif
1655
1656.if !target(depends-list)
1657depends-list:
1658	@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 \
1659		(cd $$dir; ${MAKE} package-name depends-list); \
1660	done
1661.endif
1662
1663################################################################
1664# Everything after here are internal targets and really
1665# shouldn't be touched by anybody but the release engineers.
1666################################################################
1667
1668# This target generates an index entry suitable for aggregation into
1669# a large index.  Format is:
1670#
1671# distribution-name|port-path|installation-prefix|comment| \
1672#  description-file|maintainer|categories|build deps|run deps
1673#
1674.if !target(describe)
1675describe:
1676	@${ECHO} -n "${PKGNAME}|${.CURDIR}|"; \
1677	${ECHO} -n "${PREFIX}|"; \
1678	if [ -f ${COMMENT} ]; then \
1679		${ECHO} -n "`${CAT} ${COMMENT}`"; \
1680	else \
1681		${ECHO} -n "** No Description"; \
1682	fi; \
1683	if [ -f ${DESCR} ]; then \
1684		${ECHO} -n "|${DESCR}"; \
1685	else \
1686		${ECHO} -n "|/dev/null"; \
1687	fi; \
1688	${ECHO} -n "|${MAINTAINER}|${CATEGORIES}|"; \
1689	case "A${FETCH_DEPENDS}B${BUILD_DEPENDS}C${LIB_DEPENDS}D${DEPENDS}E" in \
1690		ABCDE) ;; \
1691		*) cd ${.CURDIR} && ${ECHO} -n `make depends-list|sort -u`;; \
1692	esac; \
1693	${ECHO} -n "|"; \
1694	case "A${RUN_DEPENDS}B${LIB_DEPENDS}C${DEPENDS}D" in \
1695		ABCD) ;; \
1696		*) cd ${.CURDIR} && ${ECHO} -n `make package-depends|sort -u`;; \
1697	esac; \
1698	${ECHO} ""
1699.endif
1700
1701.if !target(readmes)
1702readmes:	readme
1703.endif
1704
1705.if !target(readme)
1706readme:
1707	@rm -f README.html
1708	@cd ${.CURDIR} && make README.html
1709.endif
1710
1711README.html:
1712	@${ECHO_MSG} "===>  Creating README.html for ${PKGNAME}"
1713	@${CAT} ${TEMPLATES}/README.port | \
1714		${SED} -e 's%%PORT%%'`${ECHO} ${.CURDIR} | ${SED} -e 's.*/\([^/]*/[^/]*\)$$\1'`'g' \
1715			-e 's%%PKG%%${PKGNAME}g' \
1716			-e '/%%COMMENT%%/r${PKGDIR}/COMMENT' \
1717			-e '/%%COMMENT%%/d' \
1718			-e 's%%BUILD_DEPENDS%%'"`${MAKE} print-depends-list`"'' \
1719			-e 's%%RUN_DEPENDS%%'"`${MAKE} print-package-depends`"'' \
1720		>> $@
1721
1722.if !target(print-depends-list)
1723print-depends-list:
1724.if defined(FETCH_DEPENDS) || defined(BUILD_DEPENDS) || \
1725	defined(LIB_DEPENDS) || defined(DEPENDS)
1726	@${ECHO} -n 'This port requires package(s) "'
1727	@${ECHO} -n `make depends-list | sort -u`
1728	@${ECHO} '" to build.'
1729.endif
1730.endif
1731
1732.if !target(print-package-depends)
1733print-package-depends:
1734.if defined(RUN_DEPENDS) || defined(LIB_DEPENDS) || defined(DEPENDS)
1735	@${ECHO} -n 'This port requires package(s) "'
1736	@${ECHO} -n `make package-depends | sort -u`
1737	@${ECHO} '" to run.'
1738.endif
1739.endif
1740
1741# Fake installation of package so that user can pkg_delete it later.
1742# Also, make sure that an installed port is recognized correctly in
1743# accordance to the @pkgdep directive in the packing lists
1744
1745.if !target(fake-pkg)
1746fake-pkg:
1747	@if [ ! -f ${PLIST} -o ! -f ${COMMENT} -o ! -f ${DESCR} ]; then ${ECHO} "** Missing package files for ${PKGNAME} - installation not recorded."; exit 1; fi
1748	@if [ ! -d ${PKG_DBDIR} ]; then ${RM} -f ${PKG_DBDIR}; ${MKDIR} ${PKG_DBDIR}; fi
1749.if defined(FORCE_PKG_REGISTER)
1750	@${RM} -rf ${PKG_DBDIR}/${PKGNAME}
1751.endif
1752	@if [ ! -d ${PKG_DBDIR}/${PKGNAME} ]; then \
1753		${ECHO_MSG} "===>  Registering installation for ${PKGNAME}"; \
1754		${MKDIR} ${PKG_DBDIR}/${PKGNAME}; \
1755		${PKG_CMD} ${PKG_ARGS} -O ${PKGFILE} > ${PKG_DBDIR}/${PKGNAME}/+CONTENTS; \
1756		${CP} ${DESCR} ${PKG_DBDIR}/${PKGNAME}/+DESC; \
1757		${CP} ${COMMENT} ${PKG_DBDIR}/${PKGNAME}/+COMMENT; \
1758		if [ -f ${PKGDIR}/INSTALL ]; then \
1759			${CP} ${PKGDIR}/INSTALL ${PKG_DBDIR}/${PKGNAME}/+INSTALL; \
1760		fi; \
1761		if [ -f ${PKGDIR}/DEINSTALL ]; then \
1762			${CP} ${PKGDIR}/DEINSTALL ${PKG_DBDIR}/${PKGNAME}/+DEINSTALL; \
1763		fi; \
1764		if [ -f ${PKGDIR}/REQ ]; then \
1765			${CP} ${PKGDIR}/REQ ${PKG_DBDIR}/${PKGNAME}/+REQ; \
1766		fi; \
1767		if [ -f ${PKGDIR}/MESSAGE ]; then \
1768			${CP} ${PKGDIR}/MESSAGE ${PKG_DBDIR}/${PKGNAME}/+DISPLAY; \
1769		fi; \
1770		for dep in `make package-depends ECHO_MSG=/usr/bin/true | sort -u`; do \
1771			if [ -d ${PKG_DBDIR}/$$dep ]; then \
1772				if ! ${GREP} ^${PKGNAME}$$ ${PKG_DBDIR}/$$dep/+REQUIRED_BY \
1773					>/dev/null 2>&1; then \
1774					${ECHO} ${PKGNAME} >> ${PKG_DBDIR}/$$dep/+REQUIRED_BY; \
1775				fi; \
1776			fi; \
1777		done; \
1778	fi
1779.endif
1780
1781# Depend is generally meaningless for arbitrary ports, but if someone wants
1782# one they can override this.  This is just to catch people who've gotten into
1783# the habit of typing `make depend all install' as a matter of course.
1784#
1785.if !target(depend)
1786depend:
1787.endif
1788
1789# Same goes for tags
1790.if !target(tags)
1791tags:
1792.endif
1793