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