xref: /freebsd/share/mk/bsd.port.mk (revision ce834215a70ff69e7e222827437116eee2f9ac6f)
1#-*- mode: Fundamental; tab-width: 4; -*-
2# ex:ts=4
3#
4#	$Id: bsd.port.mk,v 1.261 1997/06/29 10:51:55 obrien 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.004:${PORTSDIR}/lang/perl5
359RUN_DEPENDS+=		perl5.004:${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)
794DEPENDS_TARGET=	install
795.endif
796
797################################################################
798# The following are used to create easy dummy targets for
799# disabling some bit of default target behavior you don't want.
800# They still check to see if the target exists, and if so don't
801# do anything, since you might want to set this globally for a
802# group of ports in a Makefile.inc, but still be able to
803# override from an individual Makefile.
804################################################################
805
806# Disable checksum
807.if defined(NO_CHECKSUM) && !target(checksum)
808checksum: fetch
809	@${DO_NADA}
810.endif
811
812# Disable extract
813.if defined(NO_EXTRACT) && !target(extract)
814extract: checksum
815	@${TOUCH} ${TOUCH_FLAGS} ${EXTRACT_COOKIE}
816checksum: fetch
817	@${DO_NADA}
818makesum:
819	@${DO_NADA}
820.endif
821
822# Disable patch
823.if defined(NO_PATCH) && !target(patch)
824patch: extract
825	@${TOUCH} ${TOUCH_FLAGS} ${PATCH_COOKIE}
826.endif
827
828# Disable configure
829.if defined(NO_CONFIGURE) && !target(configure)
830configure: patch
831	@${TOUCH} ${TOUCH_FLAGS} ${CONFIGURE_COOKIE}
832.endif
833
834# Disable build
835.if defined(NO_BUILD) && !target(build)
836build: configure
837	@${TOUCH} ${TOUCH_FLAGS} ${BUILD_COOKIE}
838.endif
839
840# Disable install
841.if defined(NO_INSTALL) && !target(install)
842install: build
843	@${TOUCH} ${TOUCH_FLAGS} ${INSTALL_COOKIE}
844.endif
845
846# Disable package
847.if defined(NO_PACKAGE) && !target(package)
848package:
849.if defined(IGNORE_SILENT)
850	@${DO_NADA}
851.else
852	@${ECHO_MSG} "===>  ${PKGNAME} may not be packaged: ${NO_PACKAGE}."
853.endif
854.endif
855
856# Disable describe
857.if defined(NO_DESCRIBE) && !target(describe)
858describe:
859	@${DO_NADA}
860.endif
861
862################################################################
863# More standard targets start here.
864#
865# These are the body of the build/install framework.  If you are
866# not happy with the default actions, and you can't solve it by
867# adding pre-* or post-* targets/scripts, override these.
868################################################################
869
870# Fetch
871
872.if !target(do-fetch)
873do-fetch:
874	@${MKDIR} ${_DISTDIR}
875	@(cd ${_DISTDIR}; \
876	 for file in ${DISTFILES}; do \
877		if [ ! -f $$file -a ! -f `${BASENAME} $$file` ]; then \
878			if [ -h $$file -o -h `${BASENAME} $$file` ]; then \
879				${ECHO_MSG} ">> ${_DISTDIR}/$$file is a broken symlink."; \
880				${ECHO_MSG} ">> Perhaps a filesystem (most likely a CD) isn't mounted?"; \
881				${ECHO_MSG} ">> Please correct this problem and try again."; \
882				exit 1; \
883			fi ; \
884			${ECHO_MSG} ">> $$file doesn't seem to exist on this system."; \
885			for site in ${MASTER_SITES}; do \
886			    ${ECHO_MSG} ">> Attempting to fetch from $${site}."; \
887				if ${FETCH_CMD} ${FETCH_BEFORE_ARGS} $${site}$${file} ${FETCH_AFTER_ARGS}; then \
888					continue 2; \
889				fi \
890			done; \
891			${ECHO_MSG} ">> Couldn't fetch it - please try to retrieve this";\
892			${ECHO_MSG} ">> port manually into ${_DISTDIR} and try again."; \
893			exit 1; \
894	    fi \
895	 done)
896.if defined(PATCHFILES)
897	@(cd ${_DISTDIR}; \
898	 for file in ${PATCHFILES}; do \
899		if [ ! -f $$file -a ! -f `${BASENAME} $$file` ]; then \
900			if [ -h $$file -o -h `${BASENAME} $$file` ]; then \
901				${ECHO_MSG} ">> ${_DISTDIR}/$$file is a broken symlink."; \
902				${ECHO_MSG} ">> Perhaps a filesystem (most likely a CD) isn't mounted?"; \
903				${ECHO_MSG} ">> Please correct this problem and try again."; \
904				exit 1; \
905			fi ; \
906			${ECHO_MSG} ">> $$file doesn't seem to exist on this system."; \
907			for site in ${PATCH_SITES}; do \
908			    ${ECHO_MSG} ">> Attempting to fetch from $${site}."; \
909				if ${FETCH_CMD} ${FETCH_BEFORE_ARGS} $${site}$${file} ${FETCH_AFTER_ARGS}; then \
910					continue 2; \
911				fi \
912			done; \
913			${ECHO_MSG} ">> Couldn't fetch it - please try to retrieve this";\
914			${ECHO_MSG} ">> port manually into ${_DISTDIR} and try again."; \
915			exit 1; \
916	    fi \
917	 done)
918.endif
919.endif
920
921# Extract
922
923.if !target(do-extract)
924do-extract:
925.if !defined(NO_WRKDIR)
926	@${RM} -rf ${WRKDIR}
927	@${MKDIR} ${WRKDIR}
928.endif
929	@for file in ${EXTRACT_ONLY}; do \
930		if ! (cd ${WRKDIR} && ${EXTRACT_CMD} ${EXTRACT_BEFORE_ARGS} ${_DISTDIR}/$$file ${EXTRACT_AFTER_ARGS});\
931		then \
932			exit 1; \
933		fi \
934	done
935.endif
936
937# Patch
938
939.if !target(do-patch)
940do-patch:
941.if defined(PATCHFILES)
942	@${ECHO_MSG} "===>  Applying distribution patches for ${PKGNAME}"
943	@(cd ${_DISTDIR}; \
944	  for i in ${PATCHFILES}; do \
945		if [ ${PATCH_DEBUG_TMP} = yes ]; then \
946			${ECHO_MSG} "===>   Applying distribution patch $$i" ; \
947		fi; \
948		case $$i in \
949			*.Z|*.gz) \
950				${GZCAT} $$i | ${PATCH} ${PATCH_DIST_ARGS}; \
951				;; \
952			*) \
953				${PATCH} ${PATCH_DIST_ARGS} < $$i; \
954				;; \
955		esac; \
956	  done)
957.endif
958	@if [ -d ${PATCHDIR} ]; then \
959		if [ "`echo ${PATCHDIR}/patch-*`" = "${PATCHDIR}/patch-*" ]; then \
960			${ECHO_MSG} "===>   Ignoring empty patch directory"; \
961			if [ -d ${PATCHDIR}/CVS ]; then \
962				${ECHO_MSG} "===>   Perhaps you forgot the -P flag to cvs co or update?"; \
963			fi; \
964		else \
965			${ECHO_MSG} "===>  Applying ${OPSYS} patches for ${PKGNAME}" ; \
966			for i in ${PATCHDIR}/patch-*; do \
967				case $$i in \
968					*.orig|*.rej|*~) \
969						${ECHO_MSG} "===>   Ignoring patchfile $$i" ; \
970						;; \
971					*) \
972						if [ ${PATCH_DEBUG_TMP} = yes ]; then \
973							${ECHO_MSG} "===>   Applying ${OPSYS} patch $$i" ; \
974						fi; \
975						${PATCH} ${PATCH_ARGS} < $$i; \
976						;; \
977				esac; \
978			done; \
979		fi; \
980	fi
981.endif
982
983# Configure
984
985.if !target(do-configure)
986do-configure:
987	@if [ -f ${SCRIPTDIR}/configure ]; then \
988		cd ${.CURDIR} && ${SETENV} ${SCRIPTS_ENV} ${SH} \
989		  ${SCRIPTDIR}/configure; \
990	fi
991.if defined(HAS_CONFIGURE)
992	@(cd ${WRKSRC} && CC="${CC}" ac_cv_path_CC="${CC}" CFLAGS="${CFLAGS}" \
993	    INSTALL="/usr/bin/install -c -o ${BINOWN} -g ${BINGRP}" \
994	    INSTALL_PROGRAM="${INSTALL_PROGRAM}" \
995	    ${CONFIGURE_ENV} ./${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS})
996.endif
997.if defined(USE_IMAKE)
998	@(cd ${WRKSRC} && ${XMKMF})
999.endif
1000.endif
1001
1002# Build
1003
1004.if !target(do-build)
1005do-build:
1006.if defined(USE_GMAKE)
1007	@(cd ${WRKSRC}; ${SETENV} ${MAKE_ENV} ${GMAKE} ${MAKE_FLAGS} ${MAKEFILE} ${ALL_TARGET})
1008.else defined(USE_GMAKE)
1009	@(cd ${WRKSRC}; ${SETENV} ${MAKE_ENV} ${MAKE} ${MAKE_FLAGS} ${MAKEFILE} ${ALL_TARGET})
1010.endif
1011.endif
1012
1013# Install
1014
1015.if !target(do-install)
1016do-install:
1017.if defined(USE_GMAKE)
1018	@(cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} ${GMAKE} ${MAKE_FLAGS} ${MAKEFILE} ${INSTALL_TARGET})
1019.if defined(USE_IMAKE) && !defined(NO_INSTALL_MANPAGES)
1020	@(cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} ${GMAKE} ${MAKE_FLAGS} ${MAKEFILE} install.man)
1021.endif
1022.else defined(USE_GMAKE)
1023	@(cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} ${MAKE} ${MAKE_FLAGS} ${MAKEFILE} ${INSTALL_TARGET})
1024.if defined(USE_IMAKE) && !defined(NO_INSTALL_MANPAGES)
1025	@(cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} ${MAKE} ${MAKE_FLAGS} ${MAKEFILE} install.man)
1026.endif
1027.endif
1028.endif
1029
1030# Package
1031
1032.if !target(do-package)
1033do-package:
1034	@if [ -e ${PLIST} ]; then \
1035		${ECHO_MSG} "===>  Building package for ${PKGNAME}"; \
1036		if [ -d ${PACKAGES} ]; then \
1037			if [ ! -d ${PKGREPOSITORY} ]; then \
1038				if ! ${MKDIR} ${PKGREPOSITORY}; then \
1039					${ECHO_MSG} ">> Can't create directory ${PKGREPOSITORY}."; \
1040					exit 1; \
1041				fi; \
1042			fi; \
1043		fi; \
1044		if ${PKG_CMD} ${PKG_ARGS} ${PKGFILE}; then \
1045			if [ -d ${PACKAGES} ]; then \
1046				${MAKE} ${.MAKEFLAGS} package-links; \
1047			fi; \
1048		else \
1049			${MAKE} ${.MAKEFLAGS} delete-package; \
1050			exit 1; \
1051		fi; \
1052	fi
1053.endif
1054
1055# Some support rules for do-package
1056
1057.if !target(package-links)
1058package-links:
1059	@${MAKE} ${.MAKEFLAGS} delete-package-links
1060	@for cat in ${CATEGORIES}; do \
1061		if [ ! -d ${PACKAGES}/$$cat ]; then \
1062			if ! ${MKDIR} ${PACKAGES}/$$cat; then \
1063				${ECHO_MSG} ">> Can't create directory ${PACKAGES}/$$cat."; \
1064				exit 1; \
1065			fi; \
1066		fi; \
1067		ln -s ../${PKGREPOSITORYSUBDIR}/${PKGNAME}${PKG_SUFX} ${PACKAGES}/$$cat; \
1068	done;
1069.endif
1070
1071.if !target(delete-package-links)
1072delete-package-links:
1073	@${RM} -f ${PACKAGES}/[a-z]*/${PKGNAME}${PKG_SUFX};
1074.endif
1075
1076.if !target(delete-package)
1077delete-package:
1078	@${MAKE} ${.MAKEFLAGS} delete-package-links
1079	@${RM} -f ${PKGFILE}
1080.endif
1081
1082################################################################
1083# This is the "generic" port target, actually a macro used from the
1084# six main targets.  See below for more.
1085################################################################
1086
1087_PORT_USE: .USE
1088.if make(real-fetch)
1089	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} fetch-depends
1090.endif
1091.if make(real-extract)
1092	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} build-depends lib-depends misc-depends
1093.endif
1094.if make(real-install)
1095.if !defined(NO_PKG_REGISTER) && !defined(FORCE_PKG_REGISTER)
1096	@if [ -d ${PKG_DBDIR}/${PKGNAME} ]; then \
1097		${ECHO_MSG} "===>  ${PKGNAME} is already installed - perhaps an older version?"; \
1098		${ECHO_MSG} "      If so, you may wish to \`\`pkg_delete ${PKGNAME}'' and install"; \
1099		${ECHO_MSG} "      this port again by \`\`make reinstall'' to upgrade it properly."; \
1100		${ECHO_MSG} "      If you really wish to overwrite the old port of ${PKGNAME}"; \
1101		${ECHO_MSG} "      without deleting it first, set the variable \"FORCE_PKG_REGISTER\""; \
1102		${ECHO_MSG} "      in your environment or the \"make install\" command line."; \
1103		exit 1; \
1104	fi
1105.endif
1106	@if [ `${SH} -c umask` != 0022 ]; then \
1107		${ECHO_MSG} "===>  Warning: your umask is \"`${SH} -c umask`"\".; \
1108		${ECHO_MSG} "      If this is not desired, set it to an appropriate value"; \
1109		${ECHO_MSG} "      and install this port again by \`\`make reinstall''."; \
1110	fi
1111	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} run-depends lib-depends
1112.endif
1113.if make(real-install)
1114.if !defined(NO_MTREE)
1115	@if [ `id -u` = 0 ]; then \
1116		${MTREE_CMD} ${MTREE_ARGS} ${PREFIX}/; \
1117	else \
1118		${ECHO_MSG} "Warning: not superuser, can't run mtree."; \
1119		${ECHO_MSG} "Become root and try again to ensure correct permissions."; \
1120	fi
1121.endif
1122.endif
1123	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} ${.TARGET:S/^real-/pre-/}
1124	@if [ -f ${SCRIPTDIR}/${.TARGET:S/^real-/pre-/} ]; then \
1125		cd ${.CURDIR} && ${SETENV} ${SCRIPTS_ENV} ${SH} \
1126			${SCRIPTDIR}/${.TARGET:S/^real-/pre-/}; \
1127	fi
1128	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} ${.TARGET:S/^real-/do-/}
1129	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} ${.TARGET:S/^real-/post-/}
1130	@if [ -f ${SCRIPTDIR}/${.TARGET:S/^real-/post-/} ]; then \
1131		cd ${.CURDIR} && ${SETENV} ${SCRIPTS_ENV} ${SH} \
1132			${SCRIPTDIR}/${.TARGET:S/^real-/post-/}; \
1133	fi
1134.if make(real-install) && defined(_MANPAGES)
1135.if defined(MANCOMPRESSED) && defined(NOMANCOMPRESS)
1136	@${ECHO_MSG} "===>   Uncompressing manual pages for ${PKGNAME}"
1137.for manpage in ${_MANPAGES}
1138	@${GUNZIP_CMD} ${manpage}
1139.endfor
1140.elif !defined(MANCOMPRESSED) && !defined(NOMANCOMPRESS)
1141	@${ECHO_MSG} "===>   Compressing manual pages for ${PKGNAME}"
1142.for manpage in ${_MANPAGES}
1143	@${GZIP_CMD} ${manpage}
1144.endfor
1145.endif
1146.endif
1147.if make(real-install) && !defined(NO_PKG_REGISTER)
1148	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} fake-pkg
1149.endif
1150.if !make(real-fetch) \
1151	&& (!make(real-patch) || !defined(PATCH_CHECK_ONLY)) \
1152	&& (!make(real-package) || !defined(PACKAGE_NOINSTALL))
1153	@${TOUCH} ${TOUCH_FLAGS} ${WRKDIR}/.${.TARGET:S/^real-//}_done
1154.endif
1155
1156################################################################
1157# Skeleton targets start here
1158#
1159# You shouldn't have to change these.  Either add the pre-* or
1160# post-* targets/scripts or redefine the do-* targets.  These
1161# targets don't do anything other than checking for cookies and
1162# call the necessary targets/scripts.
1163################################################################
1164
1165.if !target(fetch)
1166fetch:
1167	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} real-fetch
1168.endif
1169
1170.if !target(extract)
1171extract: checksum ${EXTRACT_COOKIE}
1172.endif
1173
1174.if !target(patch)
1175patch: extract ${PATCH_COOKIE}
1176.endif
1177
1178.if !target(configure)
1179configure: patch ${CONFIGURE_COOKIE}
1180.endif
1181
1182.if !target(build)
1183build: configure ${BUILD_COOKIE}
1184.endif
1185
1186.if !target(install)
1187install: build ${INSTALL_COOKIE}
1188.endif
1189
1190.if !target(package)
1191package: install ${PACKAGE_COOKIE}
1192.endif
1193
1194${EXTRACT_COOKIE}:
1195	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} real-extract
1196${PATCH_COOKIE}:
1197	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} real-patch
1198${CONFIGURE_COOKIE}:
1199	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} real-configure
1200${BUILD_COOKIE}:
1201	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} real-build
1202${INSTALL_COOKIE}:
1203	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} real-install
1204${PACKAGE_COOKIE}:
1205	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} real-package
1206
1207# And call the macros
1208
1209real-fetch: _PORT_USE
1210real-extract: _PORT_USE
1211	@${ECHO_MSG} "===>  Extracting for ${PKGNAME}"
1212real-patch: _PORT_USE
1213	@${ECHO_MSG} "===>  Patching for ${PKGNAME}"
1214real-configure: _PORT_USE
1215	@${ECHO_MSG} "===>  Configuring for ${PKGNAME}"
1216real-build: _PORT_USE
1217	@${ECHO_MSG} "===>  Building for ${PKGNAME}"
1218real-install: _PORT_USE
1219	@${ECHO_MSG} "===>  Installing for ${PKGNAME}"
1220real-package: _PORT_USE
1221
1222# Empty pre-* and post-* targets, note we can't use .if !target()
1223# in the _PORT_USE macro
1224
1225.for name in fetch extract patch configure build install package
1226
1227.if !target(pre-${name})
1228pre-${name}:
1229	@${DO_NADA}
1230.endif
1231
1232.if !target(post-${name})
1233post-${name}:
1234	@${DO_NADA}
1235.endif
1236
1237.endfor
1238
1239# Checkpatch
1240#
1241# Special target to verify patches
1242
1243.if !target(checkpatch)
1244checkpatch:
1245	@cd ${.CURDIR} && ${MAKE} PATCH_CHECK_ONLY=yes ${.MAKEFLAGS} patch
1246.endif
1247
1248# Reinstall
1249#
1250# Special target to re-run install
1251
1252.if !target(reinstall)
1253reinstall:
1254	@${RM} -f ${INSTALL_COOKIE} ${PACKAGE_COOKIE}
1255	@${MAKE} install
1256.endif
1257
1258################################################################
1259# Some more targets supplied for users' convenience
1260################################################################
1261
1262# Cleaning up
1263
1264.if !target(pre-clean)
1265pre-clean:
1266	@${DO_NADA}
1267.endif
1268
1269.if !target(clean)
1270clean: pre-clean
1271.if !defined(NOCLEANDEPENDS)
1272	@${MAKE} clean-depends
1273.endif
1274	@${ECHO_MSG} "===>  Cleaning for ${PKGNAME}"
1275.if !defined(NO_WRKDIR)
1276	@if [ -d ${WRKDIR} ]; then \
1277		if [ -w ${WRKDIR} ]; then \
1278			${RM} -rf ${WRKDIR}; \
1279		else \
1280			${ECHO_MSG} "===>   ${WRKDIR} not writable, skipping"; \
1281		fi; \
1282	fi
1283.else
1284	@${RM} -f ${WRKDIR}/.*_done
1285.endif
1286.endif
1287
1288.if !target(pre-distclean)
1289pre-distclean:
1290	@${DO_NADA}
1291.endif
1292
1293.if !target(distclean)
1294distclean: pre-distclean clean
1295	@${ECHO_MSG} "===>  Dist cleaning for ${PKGNAME}"
1296	@(if [ -d ${_DISTDIR} ]; then \
1297		cd ${_DISTDIR}; \
1298		${RM} -f ${DISTFILES} ${PATCHFILES}; \
1299	fi)
1300.if defined(DIST_SUBDIR)
1301	-@${RMDIR} ${_DISTDIR}
1302.endif
1303.endif
1304
1305# Prints out a list of files to fetch (useful to do a batch fetch)
1306
1307.if !target(fetch-list)
1308fetch-list:
1309	@${MKDIR} ${_DISTDIR}
1310	@(cd ${_DISTDIR}; \
1311	 for file in ${DISTFILES}; do \
1312		if [ ! -f $$file -a ! -f `${BASENAME} $$file` ]; then \
1313			for site in ${MASTER_SITES}; do \
1314				${ECHO} -n ${FETCH_CMD} ${FETCH_BEFORE_ARGS} $${site}$${file} "${FETCH_AFTER_ARGS}" '||' ; \
1315					break; \
1316			done; \
1317			${ECHO} "echo $${file} not fetched" ; \
1318		fi \
1319	done)
1320.if defined(PATCHFILES)
1321	@(cd ${_DISTDIR}; \
1322	 for file in ${PATCHFILES}; do \
1323		if [ ! -f $$file -a ! -f `${BASENAME} $$file` ]; then \
1324			for site in ${PATCH_SITES}; do \
1325				${ECHO} -n ${FETCH_CMD} ${FETCH_BEFORE_ARGS} $${site}$${file} "${FETCH_AFTER_ARGS}" '||' ; \
1326					break; \
1327			done; \
1328			${ECHO} "echo $${file} not fetched" ; \
1329		fi \
1330	 done)
1331.endif
1332.endif
1333
1334# Checksumming utilities
1335
1336.if !target(makesum)
1337makesum: fetch
1338	@${MKDIR} ${FILESDIR}
1339	@if [ -f ${MD5_FILE} ]; then ${RM} -f ${MD5_FILE}; fi
1340	@(cd ${DISTDIR}; \
1341	 for file in ${_CKSUMFILES}; do \
1342		${MD5} $$file >> ${MD5_FILE}; \
1343	 done)
1344	@for file in ${_IGNOREFILES}; do \
1345		${ECHO} "MD5 ($$file) = IGNORE" >> ${MD5_FILE}; \
1346	done
1347.endif
1348
1349.if !target(checksum)
1350checksum: fetch
1351	@if [ ! -f ${MD5_FILE} ]; then \
1352		${ECHO_MSG} ">> No MD5 checksum file."; \
1353	else \
1354		(cd ${DISTDIR}; OK="true"; \
1355		  for file in ${_CKSUMFILES}; do \
1356			CKSUM=`${MD5} < $$file`; \
1357			CKSUM2=`${GREP} "^MD5 ($$file)" ${MD5_FILE} | ${AWK} '{print $$4}'`; \
1358			if [ "$$CKSUM2" = "" ]; then \
1359				${ECHO_MSG} ">> No checksum recorded for $$file."; \
1360				OK="false"; \
1361			elif [ "$$CKSUM2" = "IGNORE" ]; then \
1362				${ECHO_MSG} ">> Checksum for $$file is set to IGNORE in md5 file even though"; \
1363				${ECHO_MSG} "   the file is not in the "'$$'"{IGNOREFILES} list."; \
1364				OK="false"; \
1365			elif [ "$$CKSUM" = "$$CKSUM2" ]; then \
1366				${ECHO_MSG} ">> Checksum OK for $$file."; \
1367			else \
1368				${ECHO_MSG} ">> Checksum mismatch for $$file."; \
1369				OK="false"; \
1370			fi; \
1371		  done; \
1372		  for file in ${_IGNOREFILES}; do \
1373			CKSUM2=`${GREP} "($$file)" ${MD5_FILE} | ${AWK} '{print $$4}'`; \
1374			if [ "$$CKSUM2" = "" ]; then \
1375				${ECHO_MSG} ">> No checksum recorded for $$file, file is in "'$$'"{IGNOREFILES} list."; \
1376				OK="false"; \
1377			elif [ "$$CKSUM2" != "IGNORE" ]; then \
1378				${ECHO_MSG} ">> Checksum for $$file is not set to IGNORE in md5 file even though"; \
1379				${ECHO_MSG} "   the file is in the "'$$'"{IGNOREFILES} list."; \
1380				OK="false"; \
1381			fi; \
1382		  done; \
1383		  if [ "$$OK" != "true" ]; then \
1384			${ECHO_MSG} "Make sure the Makefile and md5 file (${MD5_FILE})"; \
1385			${ECHO_MSG} "are up to date.  If you want to override this check, type"; \
1386			${ECHO_MSG} "\"make NO_CHECKSUM=yes [other args]\"."; \
1387			exit 1; \
1388		  fi) ; \
1389	fi
1390.endif
1391
1392################################################################
1393# The special package-building targets
1394# You probably won't need to touch these
1395################################################################
1396
1397# Nobody should want to override this unless PKGNAME is simply bogus.
1398
1399.if !target(package-name)
1400package-name:
1401	@${ECHO} ${PKGNAME}
1402.endif
1403
1404# Show (recursively) all the packages this package depends on.
1405
1406.if !target(package-depends)
1407package-depends:
1408	@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 \
1409		if [ -d $$dir ]; then \
1410			(cd $$dir ; ${MAKE} package-name package-depends); \
1411		else \
1412			${ECHO_MSG} "Warning: \"$$dir\" non-existent -- @pkgdep registration incomplete" >&2; \
1413		fi; \
1414	done
1415.endif
1416
1417# Build a package but don't check the package cookie
1418
1419.if !target(repackage)
1420repackage: pre-repackage package
1421
1422pre-repackage:
1423	@${RM} -f ${PACKAGE_COOKIE}
1424.endif
1425
1426# Build a package but don't check the cookie for installation, also don't
1427# install package cookie
1428
1429.if !target(package-noinstall)
1430package-noinstall:
1431	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} PACKAGE_NOINSTALL=yes real-package
1432.endif
1433
1434################################################################
1435# Dependency checking
1436################################################################
1437
1438.if !target(depends)
1439depends: lib-depends misc-depends
1440	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} fetch-depends
1441	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} build-depends
1442	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} run-depends
1443
1444.if make(fetch-depends)
1445DEPENDS_TMP+=	${FETCH_DEPENDS}
1446.endif
1447
1448.if make(build-depends)
1449DEPENDS_TMP+=	${BUILD_DEPENDS}
1450.endif
1451
1452.if make(run-depends)
1453DEPENDS_TMP+=	${RUN_DEPENDS}
1454.endif
1455
1456_DEPENDS_USE:	.USE
1457.if defined(DEPENDS_TMP)
1458.if !defined(NO_DEPENDS)
1459	@for i in ${DEPENDS_TMP}; do \
1460		prog=`${ECHO} $$i | ${SED} -e 's/:.*//'`; \
1461		dir=`${ECHO} $$i | ${SED} -e 's/[^:]*://'`; \
1462		if expr "$$dir" : '.*:' > /dev/null; then \
1463			target=`${ECHO} $$dir | ${SED} -e 's/.*://'`; \
1464			dir=`${ECHO} $$dir | ${SED} -e 's/:.*//'`; \
1465		else \
1466			target=${DEPENDS_TARGET}; \
1467		fi; \
1468		if expr "$$prog" : \\/ >/dev/null; then \
1469			if [ -e "$$prog" ]; then \
1470				${ECHO_MSG} "===>  ${PKGNAME} depends on file: $$prog - found"; \
1471				notfound=0; \
1472			else \
1473				${ECHO_MSG} "===>  ${PKGNAME} depends on file: $$prog - not found"; \
1474				notfound=1; \
1475			fi; \
1476		else \
1477			if which "$$prog" > /dev/null 2>&1 ; then \
1478				${ECHO_MSG} "===>  ${PKGNAME} depends on executable: $$prog - found"; \
1479				notfound=0; \
1480			else \
1481				${ECHO_MSG} "===>  ${PKGNAME} depends on executable: $$prog - not found"; \
1482				notfound=1; \
1483			fi; \
1484		fi; \
1485		if [ $$notfound != 0 ]; then \
1486			${ECHO_MSG} "===>  Verifying $$target for $$prog in $$dir"; \
1487			if [ ! -d "$$dir" ]; then \
1488				${ECHO_MSG} ">> No directory for $$prog.  Skipping.."; \
1489			else \
1490				(cd $$dir; ${MAKE} ${.MAKEFLAGS} $$target) ; \
1491				${ECHO_MSG} "===>  Returning to build of ${PKGNAME}"; \
1492			fi; \
1493		fi; \
1494	done
1495.endif
1496.else
1497	@${DO_NADA}
1498.endif
1499
1500fetch-depends:	_DEPENDS_USE
1501build-depends:	_DEPENDS_USE
1502run-depends:	_DEPENDS_USE
1503
1504lib-depends:
1505.if defined(LIB_DEPENDS)
1506.if !defined(NO_DEPENDS)
1507	@for i in ${LIB_DEPENDS}; do \
1508		lib=`${ECHO} $$i | ${SED} -e 's/:.*//'`; \
1509		dir=`${ECHO} $$i | ${SED} -e 's/[^:]*://'`; \
1510		if expr "$$dir" : '.*:' > /dev/null; then \
1511			target=`${ECHO} $$dir | ${SED} -e 's/.*://'`; \
1512			dir=`${ECHO} $$dir | ${SED} -e 's/:.*//'`; \
1513		else \
1514			target=${DEPENDS_TARGET}; \
1515		fi; \
1516		if /sbin/ldconfig -r | ${GREP} -q -e "-l$$lib"; then \
1517			${ECHO_MSG} "===>  ${PKGNAME} depends on shared library: $$lib - found"; \
1518		else \
1519			${ECHO_MSG} "===>  ${PKGNAME} depends on shared library: $$lib - not found"; \
1520			${ECHO_MSG} "===>  Verifying $$target for $$lib in $$dir"; \
1521			if [ ! -d "$$dir" ]; then \
1522				${ECHO_MSG} ">> No directory for $$lib.  Skipping.."; \
1523			else \
1524				(cd $$dir; ${MAKE} ${.MAKEFLAGS} $$target) ; \
1525				${ECHO_MSG} "===>  Returning to build of ${PKGNAME}"; \
1526			fi; \
1527		fi; \
1528	done
1529.endif
1530.else
1531	@${DO_NADA}
1532.endif
1533
1534misc-depends:
1535.if defined(DEPENDS)
1536.if !defined(NO_DEPENDS)
1537	@for dir in ${DEPENDS}; do \
1538		if expr "$$dir" : '.*:' > /dev/null; then \
1539			target=`${ECHO} $$dir | ${SED} -e 's/.*://'`; \
1540			dir=`${ECHO} $$dir | ${SED} -e 's/:.*//'`; \
1541		else \
1542			target=${DEPENDS_TARGET}; \
1543		fi; \
1544		${ECHO_MSG} "===>  ${PKGNAME} depends on: $$dir"; \
1545		${ECHO_MSG} "===>  Verifying $$target for $$dir"; \
1546		if [ ! -d $$dir ]; then \
1547			${ECHO_MSG} ">> No directory for $$dir.  Skipping.."; \
1548		else \
1549			(cd $$dir; ${MAKE} ${.MAKEFLAGS} $$target) ; \
1550		fi \
1551	done
1552	@${ECHO_MSG} "===>  Returning to build of ${PKGNAME}"
1553.endif
1554.else
1555	@${DO_NADA}
1556.endif
1557
1558.endif
1559
1560.if !target(clean-depends)
1561clean-depends:
1562.if defined(FETCH_DEPENDS) || defined(BUILD_DEPENDS) || defined(LIB_DEPENDS) \
1563	|| defined(RUN_DEPENDS)
1564	@for dir in `${ECHO} ${FETCH_DEPENDS} ${BUILD_DEPENDS} ${LIB_DEPENDS} ${RUN_DEPENDS} | ${TR} '\040' '\012' | ${SED} -e 's/^[^:]*://' -e 's/:.*//' | sort -u`; do \
1565		if [ -d $$dir ] ; then \
1566			(cd $$dir; ${MAKE} NOCLEANDEPENDS=yes clean clean-depends); \
1567		fi \
1568	done
1569.endif
1570.if defined(DEPENDS)
1571	@for dir in `${ECHO} ${DEPENDS} | ${TR} '\040' '\012' | ${SED} -e 's/:.*//' | sort -u`; do \
1572		if [ -d $$dir ] ; then \
1573			(cd $$dir; ${MAKE} NOCLEANDEPENDS=yes clean clean-depends); \
1574		fi \
1575	done
1576.endif
1577.endif
1578
1579.if !target(depends-list)
1580depends-list:
1581	@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 \
1582		(cd $$dir; ${MAKE} package-name depends-list); \
1583	done
1584.endif
1585
1586################################################################
1587# Everything after here are internal targets and really
1588# shouldn't be touched by anybody but the release engineers.
1589################################################################
1590
1591# This target generates an index entry suitable for aggregation into
1592# a large index.  Format is:
1593#
1594# distribution-name|port-path|installation-prefix|comment| \
1595#  description-file|maintainer|categories|build deps|run deps
1596#
1597.if !target(describe)
1598describe:
1599	@${ECHO} -n "${PKGNAME}|${.CURDIR}|"; \
1600	${ECHO} -n "${PREFIX}|"; \
1601	if [ -f ${COMMENT} ]; then \
1602		${ECHO} -n "`${CAT} ${COMMENT}`"; \
1603	else \
1604		${ECHO} -n "** No Description"; \
1605	fi; \
1606	if [ -f ${DESCR} ]; then \
1607		${ECHO} -n "|${DESCR}"; \
1608	else \
1609		${ECHO} -n "|/dev/null"; \
1610	fi; \
1611	${ECHO} -n "|${MAINTAINER}|${CATEGORIES}|"; \
1612	case "A${FETCH_DEPENDS}B${BUILD_DEPENDS}C${LIB_DEPENDS}D${DEPENDS}E" in \
1613		ABCDE) ;; \
1614		*) cd ${.CURDIR} && ${ECHO} -n `make depends-list|sort -u`;; \
1615	esac; \
1616	${ECHO} -n "|"; \
1617	case "A${RUN_DEPENDS}B${LIB_DEPENDS}C${DEPENDS}D" in \
1618		ABCD) ;; \
1619		*) cd ${.CURDIR} && ${ECHO} -n `make package-depends|sort -u`;; \
1620	esac; \
1621	${ECHO} ""
1622.endif
1623
1624.if !target(readmes)
1625readmes:	readme
1626.endif
1627
1628.if !target(readme)
1629readme:
1630	@rm -f README.html
1631	@cd ${.CURDIR} && make README.html
1632.endif
1633
1634README.html:
1635	@${ECHO_MSG} "===>  Creating README.html for ${PKGNAME}"
1636	@${CAT} ${TEMPLATES}/README.port | \
1637		${SED} -e 's%%PORT%%'`${ECHO} ${.CURDIR} | ${SED} -e 's.*/\([^/]*/[^/]*\)$$\1'`'g' \
1638			-e 's%%PKG%%${PKGNAME}g' \
1639			-e '/%%COMMENT%%/r${PKGDIR}/COMMENT' \
1640			-e '/%%COMMENT%%/d' \
1641			-e 's%%BUILD_DEPENDS%%'"`${MAKE} print-depends-list`"'' \
1642			-e 's%%RUN_DEPENDS%%'"`${MAKE} print-package-depends`"'' \
1643		>> $@
1644
1645.if !target(print-depends-list)
1646print-depends-list:
1647.if defined(FETCH_DEPENDS) || defined(BUILD_DEPENDS) || \
1648	defined(LIB_DEPENDS) || defined(DEPENDS)
1649	@${ECHO} -n 'This port requires package(s) "'
1650	@${ECHO} -n `make depends-list | sort -u`
1651	@${ECHO} '" to build.'
1652.endif
1653.endif
1654
1655.if !target(print-package-depends)
1656print-package-depends:
1657.if defined(RUN_DEPENDS) || defined(LIB_DEPENDS) || defined(DEPENDS)
1658	@${ECHO} -n 'This port requires package(s) "'
1659	@${ECHO} -n `make package-depends | sort -u`
1660	@${ECHO} '" to run.'
1661.endif
1662.endif
1663
1664# Fake installation of package so that user can pkg_delete it later.
1665# Also, make sure that an installed port is recognized correctly in
1666# accordance to the @pkgdep directive in the packing lists
1667
1668.if !target(fake-pkg)
1669fake-pkg:
1670	@if [ ! -f ${PLIST} -o ! -f ${COMMENT} -o ! -f ${DESCR} ]; then ${ECHO} "** Missing package files for ${PKGNAME} - installation not recorded."; exit 1; fi
1671	@if [ ! -d ${PKG_DBDIR} ]; then ${RM} -f ${PKG_DBDIR}; ${MKDIR} ${PKG_DBDIR}; fi
1672.if defined(FORCE_PKG_REGISTER)
1673	@${RM} -rf ${PKG_DBDIR}/${PKGNAME}
1674.endif
1675	@if [ ! -d ${PKG_DBDIR}/${PKGNAME} ]; then \
1676		${ECHO_MSG} "===>  Registering installation for ${PKGNAME}"; \
1677		${MKDIR} ${PKG_DBDIR}/${PKGNAME}; \
1678		${PKG_CMD} ${PKG_ARGS} -O ${PKGFILE} > ${PKG_DBDIR}/${PKGNAME}/+CONTENTS; \
1679		${CP} ${DESCR} ${PKG_DBDIR}/${PKGNAME}/+DESC; \
1680		${CP} ${COMMENT} ${PKG_DBDIR}/${PKGNAME}/+COMMENT; \
1681		if [ -f ${PKGDIR}/INSTALL ]; then \
1682			${CP} ${PKGDIR}/INSTALL ${PKG_DBDIR}/${PKGNAME}/+INSTALL; \
1683		fi; \
1684		if [ -f ${PKGDIR}/DEINSTALL ]; then \
1685			${CP} ${PKGDIR}/DEINSTALL ${PKG_DBDIR}/${PKGNAME}/+DEINSTALL; \
1686		fi; \
1687		if [ -f ${PKGDIR}/REQ ]; then \
1688			${CP} ${PKGDIR}/REQ ${PKG_DBDIR}/${PKGNAME}/+REQ; \
1689		fi; \
1690		for dep in `make package-depends ECHO_MSG=/usr/bin/true | sort -u`; do \
1691			if [ -d ${PKG_DBDIR}/$$dep ]; then \
1692				if ! ${GREP} ^${PKGNAME}$$ ${PKG_DBDIR}/$$dep/+REQUIRED_BY \
1693					>/dev/null 2>&1; then \
1694					${ECHO} ${PKGNAME} >> ${PKG_DBDIR}/$$dep/+REQUIRED_BY; \
1695				fi; \
1696			fi; \
1697		done; \
1698	fi
1699.endif
1700
1701# Depend is generally meaningless for arbitrary ports, but if someone wants
1702# one they can override this.  This is just to catch people who've gotten into
1703# the habit of typing `make depend all install' as a matter of course.
1704#
1705.if !target(depend)
1706depend:
1707.endif
1708
1709# Same goes for tags
1710.if !target(tags)
1711tags:
1712.endif
1713