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