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