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