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