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