xref: /freebsd/share/mk/bsd.port.mk (revision 8e6b01171e30297084bb0b4457c4183c2746aacc)
1#-*- mode: Fundamental; tab-width: 4; -*-
2#
3#	bsd.port.mk - 940820 Jordan K. Hubbard.
4#	This file is in the public domain.
5#
6# $Id: bsd.port.mk,v 1.183 1995/10/11 09:25:58 asami Exp $
7#
8# Please view me with 4 column tabs!
9
10
11# Supported Variables and their behaviors:
12#
13# Variables that typically apply to all ports:
14#
15# PORTSDIR		- The root of the ports tree (default: /usr/ports).
16# DISTDIR 		- Where to get gzip'd, tarballed copies of original sources
17#				  (default: ${PORTSDIR}/distfiles).
18# PREFIX		- Where to install things in general (default: /usr/local).
19# MASTER_SITES	- Primary location(s) for distribution files if not found
20#				  locally (default:
21#				   ftp://ftp.freebsd.org/pub/FreeBSD/distfiles)
22# PATCH_SITES	- Primary location(s) for distributed patch files
23#				  (see PATCHFILES below) if not found locally (default:
24#				   ftp://ftp.freebsd.org/pub/FreeBSD/distfiles)
25#
26# MASTER_SITE_OVERRIDE - If set, override the MASTER_SITES setting with this
27#				  value.
28# MASTER_SITE_FREEBSD - If set, only use the FreeBSD master repository for
29#				  MASTER_SITES.
30# PACKAGES		- A top level directory where all packages go (rather than
31#				  going locally to each port). (default: ${PORTSDIR}/packages).
32# GMAKE			- Set to path of GNU make if not in $PATH (default: gmake).
33# XMKMF			- Set to path of `xmkmf' if not in $PATH (default: xmkmf -a ).
34# MAINTAINER	- The e-mail address of the contact person for this port
35#				  (default: ports@FreeBSD.ORG).
36# CATEGORIES	- A list of descriptive categories into which this port falls
37#				  (default: orphans).
38# KEYWORDS		- A list of descriptive keywords that might index well for this
39#				  port (default: orphans).
40#
41# Variables that typically apply to an individual port.  Non-Boolean
42# variables without defaults are *mandatory*.
43#
44#
45# WRKDIR 		- A temporary working directory that gets *clobbered* on clean
46#				  (default: ${.CURDIR}/work).
47# WRKSRC		- A subdirectory of ${WRKDIR} where the distribution actually
48#				  unpacks to.  (Default: ${WRKDIR}/${DISTNAME} unless
49#				  NO_WRKSUBDIR is set, in which case simply ${WRKDIR}).
50# DISTNAME		- Name of port or distribution.
51# DISTFILES		- Name(s) of archive file(s) containing distribution
52#				  (default: ${DISTDIR}/${DISTNAME}${EXTRACT_SUFX}).
53# PATCHFILES	- Name(s) of additional files that contain distributed
54#				  patches (default: none).  make will look for them at
55#				  PATCH_SITES (see above).  They will automatically be
56#				  uncompressed before patching if the names end with
57#				  ".gz" or ".Z".
58# PATCH_PRFX	- Filename prefix for distribution patches (default: none)
59#				  typically ${DISTNAME}/ or foo-
60# PKGNAME		- Name of the package file to create if the DISTNAME
61#				  isn't really relevant for the port/package
62#				  (default: ${DISTNAME}).
63# EXTRACT_ONLY	- If defined, a subset of ${DISTFILES} you want to
64#			  	  actually extract.
65# PATCHDIR 		- A directory containing any additional patches you made
66#				  to port this software to FreeBSD (default:
67#				  ${.CURDIR}/patches)
68# SCRIPTDIR 	- A directory containing any auxiliary scripts
69#				  (default: ${.CURDIR}/scripts)
70# FILESDIR 		- A directory containing any miscellaneous additional files.
71#				  (default: ${.CURDIR}/files)
72# PKGDIR 		- A direction containing any package creation files.
73#				  (default: ${.CURDIR}/pkg)
74# PKG_DBDIR		- Where package installation is recorded (default: /var/db/pkg)
75# FORCE_PKG_REGISTER - If set, it will overwrite any existing package
76#				  registration information in ${PKG_DBDIR}/${PKGNAME}.
77# NO_MTREE		- If set, will not invoke mtree from bsd.port.mk from
78#				  the "install" target.  This is the default if
79#				  USE_IMAKE or USE_X11 is set.
80#
81# NO_EXTRACT	- Use a dummy (do-nothing) extract target.
82# NO_CONFIGURE	- Use a dummy (do-nothing) configure target.
83# NO_BUILD		- Use a dummy (do-nothing) build target.
84# NO_PACKAGE	- Use a dummy (do-nothing) package target.
85# NO_INSTALL	- Use a dummy (do-nothing) install target.
86# NO_WRKSUBDIR	- Assume port unpacks directly into ${WRKDIR}.
87# NO_WRKDIR		- There's no work directory at all; port does this someplace
88#				  else.
89# NO_DEPENDS	- Don't verify build of dependencies.
90# USE_GMAKE		- Says that the port uses gmake.
91# USE_IMAKE		- Says that the port uses imake.
92# USE_X11		- Says that the port uses X11.
93# NO_INSTALL_MANPAGES - For imake ports that don't like the install.man
94#						target.
95# HAS_CONFIGURE	- Says that the port has its own configure script.
96# GNU_CONFIGURE	- Set if you are using GNU configure (optional).
97# CONFIGURE_SCRIPT - Name of configure script, defaults to 'configure'.
98# CONFIGURE_ARGS - Pass these args to configure, if ${HAS_CONFIGURE} set.
99# CONFIGURE_ENV  - Pass these env (shell-like) to configure, if ${HAS_CONFIGURE} set.
100# IS_INTERACTIVE - Set this if your port needs to interact with the user
101#				  during a build.  User can then decide to skip this port by
102#				  setting ${BATCH}, or compiling only the interactive ports
103#				  by setting ${INTERACTIVE}.
104# FETCH_DEPENDS - A list of "prog:dir" pairs of other ports this
105#				  package depends in the "fetch" stage.  "prog" is the
106#				  name of an executable.  make will search your $PATH
107#				  for it and go into "dir" to do a "make all install"
108#				  if it's not found.
109# BUILD_DEPENDS - A list of "prog:dir" pairs of other ports this
110#				  package depends to build (somewhere between the
111#				  "extract" to "build" stage).  "prog" is the name
112#				  of an executable.  make will search your $PATH for
113#				  it and go into "dir" to do a "make all install" if
114#				  it's not found.
115# RUN_DEPENDS	- A list of "prog:dir" pairs of other ports this package
116#				  depends to run.  "prog" is the name of an
117#				  executable.  make will search your $PATH for it and
118#				  go into "dir" to do a "make all install" if it's not
119#				  found.  This will be build during the "install" stage
120#				  and its name will be put into the package as well.
121# LIB_DEPENDS	- A list of "lib:dir" pairs of other ports this package
122#				  depends on.  "lib" is the name of a shared library.
123#				  make will use "ldconfig -r" to search for the
124#				  library.  Note that lib can be any regular expression,
125#				  and you need two backslashes in front of dots (.) to
126#				  supress its special meaning (e.g., use
127#				  "foo\\.2\\.:${PORTSDIR}/utils/foo" to match "libfoo.2.*").
128# DEPENDS		- A list of other ports this package depends on being
129#				  made first.  Use this for things that don't fall into
130#				  the above two categories.
131# EXTRACT_CMD	- Command for extracting archive (default: tar).
132# EXTRACT_SUFX	- Suffix for archive names (default: .tar.gz).
133# EXTRACT_BEFORE_ARGS -
134#				  Arguments to ${EXTRACT_CMD} before filename
135#				  (default: -C ${WRKDIR} -xzf).
136# EXTRACT_AFTER_ARGS -
137#				  Arguments to ${EXTRACT_CMD} following filename
138#				  (default: none).
139#
140# NCFTP			- Full path to ncftp command if not in $PATH (default: ncftp).
141# NCFTPFLAGS    - Arguments to ${NCFTP} (default: -N).
142#
143#
144# Variables to change if you want a special behavior:
145#
146# ECHO_MSG		- Used to print all the '===>' style prompts - override this
147#				  to turn them off (default: /bin/echo).
148# IS_DEPENDED_TARGET -
149#				  The target to execute when a port is called as a
150#				  dependency (default: install).  E.g., "make fetch
151#				  IS_DEPENDED_TARGET=fetch" will fetch all the distfiles,
152#				  including those of dependencies, without actually building
153#				  any of them).
154#
155#
156# Default targets and their behaviors:
157#
158# fetch			- Retrieves ${DISTFILES} (and ${PATCHFILES} if defined)
159#				  into ${DISTDIR} as necessary.
160# fetch-list	- Show list of files that would be retrieved by fetch
161# extract		- Unpacks ${DISTFILES} into ${WRKDIR}.
162# patch			- Apply any provided patches to the source.
163# configure		- Runs either GNU configure, one or more local configure
164#				  scripts or nothing, depending on what's available.
165# build			- Actually compile the sources.
166# install		- Install the results of a build.
167# reinstall		- Install the results of a build, ignoring "already installed"
168#				  flag.
169# package		- Create a package from an _installed_ port.
170# describe		- Try to generate a one-line description for each port for
171#				  use in INDEX files and the like.
172# checkpatch	- Do a "patch -C" instead of a "patch".  Note that it may
173#				  give incorrect results if multiple patches deal with
174#				  the same file.
175# checksum		- Use files/md5 to ensure that your distfiles are valid
176# makesum		- Generate files/md5 (only do this for your own ports!)
177#
178# Default sequence for "all" is:  fetch checksum extract patch configure build
179#
180# Please read the comments in the targets section below, you
181# should be able to use the pre-* or post-* targets/scripts
182# (which are available for every stage except checksum) or
183# override the do-* targets to do pretty much anything you want.
184#
185# NEVER override the "regular" targets unless you want to open
186# a major can of worms.
187
188.if exists(${.CURDIR}/../Makefile.inc)
189.include "${.CURDIR}/../Makefile.inc"
190.endif
191
192# These need to be absolute since we don't know how deep in the ports
193# tree we are and thus can't go relative.  They can, of course, be overridden
194# by individual Makefiles.
195PORTSDIR?=		${DESTDIR}/usr/ports
196X11BASE?=		/usr/X11R6
197DISTDIR?=		${PORTSDIR}/distfiles
198PACKAGES?=		${PORTSDIR}/packages
199.if !defined(NO_WRKDIR)
200WRKDIR?=		${.CURDIR}/work
201.else
202WRKDIR?=		${.CURDIR}
203.endif
204.if defined(NO_WRKSUBDIR)
205WRKSRC?=		${WRKDIR}
206.else
207WRKSRC?=		${WRKDIR}/${DISTNAME}
208.endif
209PATCHDIR?=		${.CURDIR}/patches
210SCRIPTDIR?=		${.CURDIR}/scripts
211FILESDIR?=		${.CURDIR}/files
212PKGDIR?=		${.CURDIR}/pkg
213.if defined(USE_IMAKE) || defined(USE_X11)
214PREFIX?=		${X11BASE}
215.else
216PREFIX?=		/usr/local
217.endif
218# The following 4 lines should go away as soon as the ports are all updated
219.if defined(EXEC_DEPENDS)
220BUILD_DEPENDS+=	${EXEC_DEPENDS}
221RUN_DEPENDS+=	${EXEC_DEPENDS}
222.endif
223.if defined(USE_GMAKE)
224BUILD_DEPENDS+=               gmake:${PORTSDIR}/devel/gmake
225.endif
226
227.if exists(${PORTSDIR}/../Makefile.inc)
228.include "${PORTSDIR}/../Makefile.inc"
229.endif
230
231# Don't change these!!!  These names are built into the _TARGET_USE macro,
232# there is no way to refer to them cleanly from within the macro AFAIK.
233EXTRACT_COOKIE?=	${WRKDIR}/.extract_done
234CONFIGURE_COOKIE?=	${WRKDIR}/.configure_done
235INSTALL_COOKIE?=	${WRKDIR}/.install_done
236BUILD_COOKIE?=		${WRKDIR}/.build_done
237PATCH_COOKIE?=		${WRKDIR}/.patch_done
238PACKAGE_COOKIE?=	${WRKDIR}/.package_done
239
240# How to do nothing.  Override if you, for some strange reason, would rather
241# do something.
242DO_NADA?=		echo -n
243
244# Miscellaneous overridable commands:
245GMAKE?=			gmake
246XMKMF?=			xmkmf -a
247MD5?=			/sbin/md5
248MD5_FILE?=		${FILESDIR}/md5
249MAKE_FLAGS?=	-f
250MAKEFILE?=		Makefile
251
252NCFTP?=			/usr/bin/ncftp
253NCFTPFLAGS?=	-N
254
255TOUCH?=			/usr/bin/touch
256TOUCH_FLAGS?=	-f
257
258PATCH?=			/usr/bin/patch
259PATCH_STRIP?=	-p0
260PATCH_DIST_STRIP?=	-p0
261.if defined(PATCH_DEBUG)
262PATCH_ARGS?=	-d ${WRKSRC} -E ${PATCH_STRIP}
263PATCH_DIST_ARGS?=	-d ${WRKSRC} -E ${PATCH_DIST_STRIP}
264.else
265PATCH_ARGS?=	-d ${WRKSRC} --forward --quiet -E ${PATCH_STRIP}
266PATCH_DIST_ARGS?=	-d ${WRKSRC} --forward --quiet -E ${PATCH_DIST_STRIP}
267.endif
268.if defined(BATCH)
269PATCH_ARGS+=		--batch
270PATCH_DIST_ARGS+=	--batch
271.endif
272
273.if defined(PATCH_CHECK_ONLY)
274PATCH_ARGS+=	-C
275PATCH_DIST_ARGS+=	-C
276.endif
277
278EXTRACT_CMD?=	/usr/bin/tar
279EXTRACT_SUFX?=	.tar.gz
280# Backwards compatability.
281.if defined(EXTRACT_ARGS)
282EXTRACT_BEFORE_ARGS?=   ${EXTRACT_ARGS}
283.else
284EXTRACT_BEFORE_ARGS?=   -xzf
285.endif
286
287# Figure out where the local mtree file is
288.if !defined(MTREE_LOCAL) && exists(/etc/mtree/BSD.local.dist)
289MTREE_LOCAL=	/etc/mtree/BSD.local.dist
290.endif
291MTREE_CMD?=	/usr/sbin/mtree
292MTREE_ARGS?=	-U -f ${MTREE_LOCAL} -d -e -p
293.if defined(USE_X11) || defined(USE_IMAKE) || !defined(MTREE_LOCAL)
294NO_MTREE=	yes
295.endif
296
297# The user can override the NO_PACKAGE by specifying this from
298# the make command line
299.if defined(FORCE_PACKAGE)
300.undef NO_PACKAGE
301.endif
302
303PKG_CMD?=		/usr/sbin/pkg_create
304.if !defined(PKG_ARGS)
305PKG_ARGS=		-v -c ${PKGDIR}/COMMENT -d ${PKGDIR}/DESCR -f ${PKGDIR}/PLIST -p ${PREFIX} -P "`${MAKE} package-depends|sort|uniq`"
306.if exists(${PKGDIR}/INSTALL)
307PKG_ARGS+=		-i ${PKGDIR}/INSTALL
308.endif
309.if exists(${PKGDIR}/DEINSTALL)
310PKG_ARGS+=		-k ${PKGDIR}/DEINSTALL
311.endif
312.if exists(${PKGDIR}/REQ)
313PKG_ARGS+=		-r ${PKGDIR}/REQ
314.endif
315.if !defined(USE_X11) && !defined(USE_IMAKE) && defined(MTREE_LOCAL)
316PKG_ARGS+=		-m ${MTREE_LOCAL}
317.endif
318.endif
319PKG_SUFX?=		.tgz
320# where pkg_add records its dirty deeds.
321PKG_DBDIR?=		/var/db/pkg
322
323# Used to print all the '===>' style prompts - override this to turn them off.
324ECHO_MSG?=		/bin/echo
325
326ALL_TARGET?=		all
327INSTALL_TARGET?=	install
328
329# If the user has this set, go to the FreeBSD respository for everything.
330.if defined(MASTER_SITE_FREEBSD)
331MASTER_SITE_OVERRIDE=  ftp://ftp.freebsd.org/pub/FreeBSD/distfiles/
332.endif
333
334# I guess we're in the master distribution business! :)  As we gain mirror
335# sites for distfiles, add them to this list.
336.if !defined(MASTER_SITE_OVERRIDE)
337MASTER_SITES+=	ftp://ftp.freebsd.org/pub/FreeBSD/distfiles/
338PATCH_SITES+=	ftp://ftp.freebsd.org/pub/FreeBSD/distfiles/${PATCH_PRFX}
339.else
340MASTER_SITES:=	${MASTER_SITE_OVERRIDE} ${MASTER_SITES}
341PATCH_SITES:=	${MASTER_SITE_OVERRIDE}${PATCH_PRFX} ${PATCH_SITES}
342.endif
343
344.if defined(PATCH_PRFX)
345PATCHDIST!=	/bin/echo ${PATCH_PRFX} | sed 's|^\(.*\)/$$|/\1|'
346PATCHDIST:=	${DISTDIR}${PATCHDIST}
347.else
348PATCHDIST:=	${DISTDIR}
349.endif
350
351# Derived names so that they're easily overridable.
352DISTFILES?=		${DISTNAME}${EXTRACT_SUFX}
353PKGNAME?=		${DISTNAME}
354
355# This is what is actually going to be extracted, and is overridable
356#  by user.
357EXTRACT_ONLY?=	${DISTFILES}
358
359# Documentation
360MAINTAINER?=	ports@FreeBSD.ORG
361CATEGORIES?=	orphans
362KEYWORDS+=		${CATEGORIES}
363
364# Note this has to start with a capital letter (or more accurately, it
365#  shouldn't match "[a-z]*"), see the target "delete-package-links" below.
366PKGREPOSITORYSUBDIR?=	All
367PKGREPOSITORY?=		${PACKAGES}/${PKGREPOSITORYSUBDIR}
368.if exists(${PACKAGES})
369PKGFILE?=		${PKGREPOSITORY}/${PKGNAME}${PKG_SUFX}
370.else
371PKGFILE?=		${PKGNAME}${PKG_SUFX}
372.endif
373
374CONFIGURE_SCRIPT?=	configure
375
376.if defined(GNU_CONFIGURE)
377CONFIGURE_ARGS?=	--prefix=${PREFIX}
378HAS_CONFIGURE=		yes
379.endif
380
381.MAIN: all
382
383################################################################
384# If we're in BATCH mode and the port is interactive, or we're
385# in interactive mode and the port is non-interactive, skip all
386# the important targets.  The reason we have two modes is that
387# one might want to leave a build in BATCH mode running
388# overnight, then come back in the morning and do _only_ the
389# interactive ones that required your intervention.
390#
391# This allows you to do both.
392################################################################
393
394.if (defined(IS_INTERACTIVE) && defined(BATCH)) || (!defined(IS_INTERACTIVE) && defined(INTERACTIVE))
395all:
396	@${DO_NADA}
397build:
398	@${DO_NADA}
399install:
400	@${DO_NADA}
401fetch:
402	@${DO_NADA}
403configure:
404	@${DO_NADA}
405package:
406	@${DO_NADA}
407.endif
408
409.if !target(all)
410all: build
411.endif
412
413.if !defined(IS_DEPENDED_TARGET)
414IS_DEPENDED_TARGET=	install
415.endif
416
417.if !target(is_depended)
418is_depended:	${IS_DEPENDED_TARGET}
419.endif
420
421################################################################
422# The following are used to create easy dummy targets for
423# disabling some bit of default target behavior you don't want.
424# They still check to see if the target exists, and if so don't
425# do anything, since you might want to set this globally for a
426# group of ports in a Makefile.inc, but still be able to
427# override from an individual Makefile.
428################################################################
429
430.if defined(NO_EXTRACT) && !target(extract)
431extract: checksum
432	@${TOUCH} ${TOUCH_FLAGS} ${EXTRACT_COOKIE}
433checksum: fetch
434	@${DO_NADA}
435makesum:
436	@${DO_NADA}
437.endif
438.if defined(NO_CONFIGURE) && !target(configure)
439configure: patch
440	@${TOUCH} ${TOUCH_FLAGS} ${CONFIGURE_COOKIE}
441.endif
442.if defined(NO_BUILD) && !target(build)
443build: configure
444	@${TOUCH} ${TOUCH_FLAGS} ${BUILD_COOKIE}
445.endif
446.if defined(NO_PACKAGE) && !target(package)
447package:
448	@${DO_NADA}
449.endif
450.if defined(NO_PACKAGE) && !target(repackage)
451repackage:
452	@${DO_NADA}
453.endif
454.if defined(NO_INSTALL) && !target(install)
455install: build
456	@${TOUCH} ${TOUCH_FLAGS} ${INSTALL_COOKIE}
457.endif
458.if defined(NO_PATCH) && !target(patch)
459patch: extract
460	@${TOUCH} ${TOUCH_FLAGS} ${PATCH_COOKIE}
461.endif
462
463################################################################
464# More standard targets start here.
465#
466# These are the body of the build/install framework.  If you are
467# not happy with the default actions, and you can't solve it by
468# adding pre-* or post-* targets/scripts, override these.
469################################################################
470
471# Fetch
472
473.if !target(do-fetch)
474do-fetch:
475	@if [ ! -d ${DISTDIR} ]; then /bin/mkdir -p ${DISTDIR}; fi
476	@(cd ${DISTDIR}; \
477	 for file in ${DISTFILES}; do \
478		if [ ! -f $$file -a ! -f `/usr/bin/basename $$file` ]; then \
479			${ECHO_MSG} ">> $$file doesn't seem to exist on this system."; \
480			for site in ${MASTER_SITES}; do \
481			    ${ECHO_MSG} ">> Attempting to fetch from $${site}."; \
482				(${NCFTP} ${NCFTPFLAGS} $${site}$${file} || true); \
483				if [ -f $$file -o -f `/usr/bin/basename $$file` ]; then \
484					continue 2; \
485				fi \
486			done; \
487			${ECHO_MSG} ">> Couldn't fetch it - please try to retreive this";\
488			${ECHO_MSG} ">> port manually into ${DISTDIR} and try again."; \
489			exit 1; \
490	    fi \
491	 done)
492.if defined(PATCHFILES)
493	@if [ ! -d ${PATCHDIST} ]; then /bin/mkdir -p ${PATCHDIST}; fi
494	@(cd ${PATCHDIST}; \
495	 for file in ${PATCHFILES}; do \
496		if [ ! -f $$file -a ! -f `/usr/bin/basename $$file` ]; then \
497			${ECHO_MSG} ">> $$file doesn't seem to exist on this system."; \
498			for site in ${PATCH_SITES}; do \
499			    ${ECHO_MSG} ">> Attempting to fetch from $${site}."; \
500				(${NCFTP} ${NCFTPFLAGS} $${site}$${file} || true); \
501				if [ -f $$file -o -f `/usr/bin/basename $$file` ]; then \
502					continue 2; \
503				fi \
504			done; \
505			${ECHO_MSG} ">> Couldn't fetch it - please try to retreive this";\
506			${ECHO_MSG} ">> port manually into ${PATCHDIST} and try again."; \
507			exit 1; \
508	    fi \
509	 done)
510.endif
511.endif
512
513# Extract
514
515.if !target(do-extract)
516do-extract:
517	@/bin/rm -rf ${WRKDIR}
518	@/bin/mkdir -p ${WRKDIR}
519	@for file in ${EXTRACT_ONLY}; do \
520		if ! (cd ${WRKDIR};${EXTRACT_CMD} ${EXTRACT_BEFORE_ARGS} ${DISTDIR}/$$file ${EXTRACT_AFTER_ARGS});\
521		then \
522			exit 1; \
523		fi \
524	done
525.endif
526
527# Patch
528
529.if !target(do-patch)
530do-patch:
531.if defined(PATCHFILES)
532	@${ECHO_MSG} "===>  Applying distributed patches for ${PKGNAME}"
533.if defined(PATCH_DEBUG)
534	@(cd ${PATCHDIST}; \
535	  for i in ${PATCHFILES}; do \
536		${ECHO_MSG} "===>   Applying distributed patch $$i" ; \
537		case $$i in \
538			*.Z|*.gz) \
539				/usr/bin/gzcat $$i | ${PATCH} ${PATCH_DIST_ARGS}; \
540				;; \
541			*) \
542				${PATCH} ${PATCH_DIST_ARGS} < $$i; \
543				;; \
544		esac; \
545	  done)
546.else
547	@(cd ${PATCHDIST}; \
548	  for i in ${PATCHFILES}; do \
549		case $$i in \
550			*.Z|*.gz) \
551				/usr/bin/gzcat $$i | ${PATCH} ${PATCH_DIST_ARGS}; \
552				;; \
553			*) \
554				${PATCH} ${PATCH_DIST_ARGS} < $$i; \
555				;; \
556		esac; \
557	  done)
558.endif
559.endif
560.if defined(PATCH_DEBUG)
561	@if [ -d ${PATCHDIR} ]; then \
562		${ECHO_MSG} "===>  Applying FreeBSD patches for ${PKGNAME}" ; \
563		for i in ${PATCHDIR}/patch-*; do \
564			case $$i in \
565				*.orig|*~) \
566					${ECHO_MSG} "===>   Ignoring patchfile $$i" ; \
567					;; \
568				*) \
569					${ECHO_MSG} "===>   Applying FreeBSD patch $$i" ; \
570					${PATCH} ${PATCH_ARGS} < $$i; \
571					;; \
572			esac; \
573		done; \
574	fi
575.else
576	@if [ -d ${PATCHDIR} ]; then \
577		${ECHO_MSG} "===>  Applying FreeBSD patches for ${PKGNAME}" ; \
578		for i in ${PATCHDIR}/patch-*; do \
579			case $$i in \
580				*.orig|*~) \
581					${ECHO_MSG} "===>   Ignoring patchfile $$i" ; \
582					;; \
583				*) \
584					${PATCH} ${PATCH_ARGS} < $$i; \
585					;; \
586			esac; \
587		done;\
588	fi
589.endif
590.endif
591
592# Configure
593
594.if !target(do-configure)
595do-configure:
596	@if [ -f ${SCRIPTDIR}/configure ]; then \
597		/usr/bin/env CURDIR=${.CURDIR} DISTDIR=${DISTDIR} WRKDIR=${WRKDIR} \
598		  WRKSRC=${WRKSRC} PATCHDIR=${PATCHDIR} SCRIPTDIR=${SCRIPTDIR} \
599		  FILESDIR=${FILESDIR} PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} \
600		  DEPENDS="${DEPENDS}" X11BASE=${X11BASE} \
601		/bin/sh ${SCRIPTDIR}/configure; \
602	fi
603.if defined(HAS_CONFIGURE)
604	@(cd ${WRKSRC}; CC="${CC}" ac_cv_path_CC="${CC}" CFLAGS="${CFLAGS}" \
605	    INSTALL="/usr/bin/install -c -o ${BINOWN} -g ${BINGRP}" \
606	    INSTALL_PROGRAM="/usr/bin/install ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE}" \
607	    ${CONFIGURE_ENV} ./${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS})
608.endif
609.if defined(USE_IMAKE)
610	@(cd ${WRKSRC}; ${XMKMF})
611.endif
612.endif
613
614# Build
615
616.if !target(do-build)
617do-build:
618.if defined(USE_GMAKE)
619	@(cd ${WRKSRC}; ${GMAKE} PREFIX=${PREFIX} X11BASE=${X11BASE} ${MAKE_FLAGS} ${MAKEFILE} ${ALL_TARGET})
620.else defined(USE_GMAKE)
621	@(cd ${WRKSRC}; ${MAKE} PREFIX=${PREFIX} X11BASE=${X11BASE} ${MAKE_FLAGS} ${MAKEFILE} ${ALL_TARGET})
622.endif
623.endif
624
625# Install
626
627.if !target(do-install)
628do-install:
629.if defined(USE_GMAKE)
630	@(cd ${WRKSRC}; ${GMAKE} PREFIX=${PREFIX} X11BASE=${X11BASE} ${MAKE_FLAGS} ${MAKEFILE} ${INSTALL_TARGET})
631.if defined(USE_IMAKE) && !defined(NO_INSTALL_MANPAGES)
632	@(cd ${WRKSRC}; ${GMAKE} ${MAKE_FLAGS} ${MAKEFILE} install.man)
633.endif
634.else defined(USE_GMAKE)
635	@(cd ${WRKSRC}; ${MAKE} PREFIX=${PREFIX} X11BASE=${X11BASE} ${MAKE_FLAGS} ${MAKEFILE} ${INSTALL_TARGET})
636.if defined(USE_IMAKE) && !defined(NO_INSTALL_MANPAGES)
637	@(cd ${WRKSRC}; ${MAKE} ${MAKE_FLAGS} ${MAKEFILE} install.man)
638.endif
639.endif
640.endif
641
642# Package
643
644.if !target(do-package)
645do-package:
646	@if [ -e ${PKGDIR}/PLIST ]; then \
647		${ECHO_MSG} "===>  Building package for ${PKGNAME}"; \
648		if [ -d ${PACKAGES} ]; then \
649			if [ ! -d ${PKGREPOSITORY} ]; then \
650				if ! /bin/mkdir -p ${PKGREPOSITORY}; then \
651					${ECHO_MSG} ">> Can't create directory ${PKGREPOSITORY}."; \
652					exit 1; \
653				fi; \
654			fi; \
655		fi; \
656		if ${PKG_CMD} ${PKG_ARGS} ${PKGFILE}; then \
657			if [ -d ${PACKAGES} ]; then \
658				${MAKE} ${.MAKEFLAGS} package-links; \
659			fi; \
660		else \
661			${MAKE} ${.MAKEFLAGS} delete-package; \
662			exit 1; \
663		fi; \
664	fi
665.endif
666
667# Some support rules for do-package
668
669.if !target(package-links)
670package-links:
671	@${MAKE} ${.MAKEFLAGS} delete-package-links
672	@for cat in ${CATEGORIES}; do \
673		if [ ! -d ${PACKAGES}/$$cat ]; then \
674			if ! /bin/mkdir -p ${PACKAGES}/$$cat; then \
675				${ECHO_MSG} ">> Can't create directory ${PACKAGES}/$$cat."; \
676				exit 1; \
677			fi; \
678		fi; \
679		ln -s ../${PKGREPOSITORYSUBDIR}/${PKGNAME}${PKG_SUFX} ${PACKAGES}/$$cat; \
680	done;
681.endif
682
683.if !target(delete-package-links)
684delete-package-links:
685	@/bin/rm -f ${PACKAGES}/[a-z]*/${PKGNAME}${PKG_SUFX};
686.endif
687
688.if !target(delete-package)
689delete-package:
690	@${MAKE} ${.MAKEFLAGS} delete-package-links
691	@/bin/rm -f ${PKGFILE}
692.endif
693
694################################################################
695# This is the "generic" port target, actually a macro used from the
696# six main targets.  See below for more.
697################################################################
698
699_PORT_USE: .USE
700.if make(real-fetch)
701	@${MAKE} ${.MAKEFLAGS} fetch-depends
702.endif
703.if make(real-extract)
704	@${MAKE} ${.MAKEFLAGS} build-depends lib-depends misc-depends
705.endif
706.if make(real-install)
707	@${MAKE} ${.MAKEFLAGS} run-depends
708.endif
709.if make(real-install)
710.if !defined(NO_MTREE)
711	@if [ `id -u` = 0 ]; then \
712		${MTREE_CMD} ${MTREE_ARGS} ${PREFIX}/; \
713	else \
714		${ECHO_MSG} "Warning: not superuser, can't run mtree."; \
715		${ECHO_MSG} "Become root and try again to ensure correct permissions."; \
716	fi
717.endif
718.endif
719	@${MAKE} ${.MAKEFLAGS} ${.TARGET:S/^real-/pre-/}
720	@if [ -f ${SCRIPTDIR}/${.TARGET:S/^real-/pre-/} ]; then \
721		/usr/bin/env CURDIR=${.CURDIR} DISTDIR=${DISTDIR} WRKDIR=${WRKDIR} \
722		  WRKSRC=${WRKSRC} PATCHDIR=${PATCHDIR} SCRIPTDIR=${SCRIPTDIR} \
723		  FILESDIR=${FILESDIR} PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} \
724		  DEPENDS="${DEPENDS}" X11BASE=${X11BASE} \
725			/bin/sh ${SCRIPTDIR}/${.TARGET:S/^real-/pre-/}; \
726	fi
727	@${MAKE} ${.MAKEFLAGS} ${.TARGET:S/^real-/do-/}
728	@${MAKE} ${.MAKEFLAGS} ${.TARGET:S/^real-/post-/}
729	@if [ -f ${SCRIPTDIR}/${.TARGET:S/^real-/post-/} ]; then \
730		/usr/bin/env CURDIR=${.CURDIR} DISTDIR=${DISTDIR} WRKDIR=${WRKDIR} \
731		  WRKSRC=${WRKSRC} PATCHDIR=${PATCHDIR} SCRIPTDIR=${SCRIPTDIR} \
732		  FILESDIR=${FILESDIR} PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} \
733		  DEPENDS="${DEPENDS}" X11BASE=${X11BASE} \
734			/bin/sh ${SCRIPTDIR}/${.TARGET:S/^real-/post-/}; \
735	fi
736.if make(real-install)
737	@${MAKE} ${.MAKEFLAGS} fake-pkg
738.endif
739.if !make(real-fetch) \
740	&& (!make(real-patch) || !defined(PATCH_CHECK_ONLY)) \
741	&& (!make(real-package) || !defined(PACKAGE_NOINSTALL))
742	@${TOUCH} ${TOUCH_FLAGS} ${WRKDIR}/.${.TARGET:S/^real-//}_done
743.endif
744
745################################################################
746# Skeleton targets start here
747#
748# You shouldn't have to change these.  Either add the pre-* or
749# post-* targets/scripts or redefine the do-* targets.  These
750# targets don't do anything other than checking for cookies and
751# call the necessary targets/scripts.
752################################################################
753
754.if !target(fetch)
755fetch:
756	@${MAKE} ${.MAKEFLAGS} real-fetch
757.endif
758
759.if !target(extract)
760extract: checksum ${EXTRACT_COOKIE}
761.endif
762
763.if !target(patch)
764patch: extract ${PATCH_COOKIE}
765.endif
766
767.if !target(configure)
768configure: patch ${CONFIGURE_COOKIE}
769.endif
770
771.if !target(build)
772build: configure ${BUILD_COOKIE}
773.endif
774
775.if !target(install)
776install: build ${INSTALL_COOKIE}
777.endif
778
779.if !target(package)
780package: install ${PACKAGE_COOKIE}
781.endif
782
783${EXTRACT_COOKIE}:
784	@${MAKE} ${.MAKEFLAGS} real-extract
785${PATCH_COOKIE}:
786	@${MAKE} ${.MAKEFLAGS} real-patch
787${CONFIGURE_COOKIE}:
788	@${MAKE} ${.MAKEFLAGS} real-configure
789${BUILD_COOKIE}:
790	@${MAKE} ${.MAKEFLAGS} real-build
791${INSTALL_COOKIE}:
792	@${MAKE} ${.MAKEFLAGS} real-install
793${PACKAGE_COOKIE}:
794	@${MAKE} ${.MAKEFLAGS} real-package
795
796# And call the macros
797
798real-fetch: _PORT_USE
799real-extract: _PORT_USE
800	@${ECHO_MSG} "===>  Extracting for ${PKGNAME}"
801real-patch: _PORT_USE
802	@${ECHO_MSG} "===>  Patching for ${PKGNAME}"
803real-configure: _PORT_USE
804	@${ECHO_MSG} "===>  Configuring for ${PKGNAME}"
805real-build: _PORT_USE
806	@${ECHO_MSG} "===>  Building for ${PKGNAME}"
807real-install: _PORT_USE
808	@${ECHO_MSG} "===>  Installing for ${PKGNAME}"
809real-package: _PORT_USE
810
811# Empty pre-* and post-* targets, note we can't use .if !target()
812# in the _PORT_USE macro
813
814.for name in fetch extract patch configure build install package
815
816.if !target(pre-${name})
817pre-${name}:
818	@${DO_NADA}
819.endif
820
821.if !target(post-${name})
822post-${name}:
823	@${DO_NADA}
824.endif
825
826.endfor
827
828# Checkpatch
829#
830# Special target to verify patches
831
832.if !target(checkpatch)
833checkpatch:
834	@${MAKE} PATCH_CHECK_ONLY=yes ${.MAKEFLAGS} patch
835.endif
836
837# Reinstall
838#
839# Special target to re-run install
840
841.if !target(reinstall)
842reinstall: pre-reinstall install
843
844pre-reinstall:
845	@/bin/rm -f ${INSTALL_COOKIE}
846	@/bin/rm -f ${PACKAGE_COOKIE}
847.endif
848
849################################################################
850# Some more targets supplied for users' convenience
851################################################################
852
853# Cleaning up
854
855.if !target(pre-clean)
856pre-clean:
857	@${DO_NADA}
858.endif
859
860.if !target(clean)
861clean: pre-clean
862	@${ECHO_MSG} "===>  Cleaning for ${PKGNAME}"
863	@/bin/rm -f ${EXTRACT_COOKIE} ${CONFIGURE_COOKIE} ${INSTALL_COOKIE} \
864		${BUILD_COOKIE} ${PATCH_COOKIE}
865.if defined(NO_WRKDIR)
866	@/bin/rm -f ${WRKDIR}/.*_done
867.else
868	@/bin/rm -rf ${WRKDIR}
869.endif
870.endif
871
872# Prints out a list of files to fetch (useful to do a batch fetch)
873
874.if !target(fetch-list)
875fetch-list:
876	@if [ ! -d ${DISTDIR} ]; then /bin/mkdir -p ${DISTDIR}; fi
877	@(cd ${DISTDIR}; \
878	 for file in ${DISTFILES}; do \
879		if [ ! -f $$file -a ! -f `/usr/bin/basename $$file` ]; then \
880			for site in ${MASTER_SITES}; do \
881				/bin/echo -n ${NCFTP} ${NCFTPFLAGS} $${site}$${file} '||' ; \
882					break; \
883			done; \
884			/bin/echo "echo $${file} not fetched" ; \
885		fi \
886	done)
887.if defined(PATCHFILES)
888	@(cd ${DISTDIR}; \
889	 for file in ${PATCHFILES}; do \
890		if [ ! -f $$file -a ! -f `/usr/bin/basename $$file` ]; then \
891			for site in ${PATCH_SITES}; do \
892				/bin/echo -n ${NCFTP} ${NCFTPFLAGS} $${site}$${file} ${PATCH_PRFX}$${file} '||' ; \
893					break; \
894			done; \
895			/bin/echo "echo $${file} not fetched" ; \
896		fi \
897	 done)
898.endif
899.endif
900
901# Checksumming utilities
902
903.if !target(makesum)
904makesum: fetch
905	@if [ ! -d ${FILESDIR} ]; then /bin/mkdir -p ${FILESDIR}; fi
906	@if [ -f ${MD5_FILE} ]; then /bin/rm -f ${MD5_FILE}; fi
907	@(cd ${DISTDIR}; \
908	 for file in ${DISTFILES} ${PATCHFILES:S|^|${PATCH_PRFX}|}; do \
909		${MD5} $$file >> ${MD5_FILE}; \
910	 done)
911.endif
912
913.if !target(checksum)
914checksum: fetch
915	@if [ ! -f ${MD5_FILE} ]; then \
916		${ECHO_MSG} ">> No MD5 checksum file."; \
917	else \
918		(cd ${DISTDIR}; OK=""; \
919		  for file in ${DISTFILES} ${PATCHFILES:S|^|${PATCH_PRFX}|}; do \
920			CKSUM=`${MD5} $$file | awk '{print $$4}'`; \
921			CKSUM2=`grep "($$file)" ${MD5_FILE} | awk '{print $$4}'`; \
922			if [ "$$CKSUM2" = "" ]; then \
923				${ECHO_MSG} ">> No checksum recorded for $$file"; \
924				OK="false"; \
925			elif [ "$$CKSUM" != "$$CKSUM2" ]; then \
926				${ECHO_MSG} ">> Checksum mismatch for $$file"; \
927				exit 1; \
928			fi; \
929		  done; \
930		  if [ "$$OK" = "" ]; then \
931			${ECHO_MSG} "Checksums OK."; \
932		  else \
933			${ECHO_MSG} "Checksums OK for files that have them."; \
934		  fi) ; \
935	fi
936.endif
937
938################################################################
939# The special package-building targets
940# You probably won't need to touch these
941################################################################
942
943# Nobody should want to override this unless PKGNAME is simply bogus.
944
945.if !target(package-name)
946package-name:
947.if !defined(NO_PACKAGE)
948	@/bin/echo ${PKGNAME}
949.endif
950.endif
951
952# Show (recursively) all the packages this package depends on.
953
954.if !target(package-depends)
955package-depends:
956	@for i in ${RUN_DEPENDS} ${LIB_DEPENDS} ${DEPENDS}; do \
957		dir=`/bin/echo $$i | /usr/bin/sed -e 's/.*://'`; \
958		(cd $$dir ; ${MAKE} package-name package-depends); \
959	done
960.endif
961
962# Build a package but don't check the package cookie
963
964.if !target(repackage)
965repackage: pre-repackage package
966
967pre-repackage:
968	@/bin/rm -f ${PACKAGE_COOKIE}
969.endif
970
971# Build a package but don't check the cookie for installation, also don't
972# install package cookie
973
974.if !target(package-noinstall)
975package-noinstall:
976	@${MAKE} ${.MAKEFLAGS} PACKAGE_NOINSTALL=yes real-package
977.endif
978
979################################################################
980# Dependency checking
981################################################################
982
983.if !target(depends)
984depends: lib-depends misc-depends
985	@${MAKE} ${.MAKEFLAGS} fetch-depends
986	@${MAKE} ${.MAKEFLAGS} build-depends
987	@${MAKE} ${.MAKEFLAGS} run-depends
988
989.if make(fetch-depends)
990DEPENDS_TMP+=	${FETCH_DEPENDS}
991.endif
992
993.if make(build-depends)
994DEPENDS_TMP+=	${BUILD_DEPENDS}
995.endif
996
997.if make(run-depends)
998DEPENDS_TMP+=	${RUN_DEPENDS}
999.endif
1000
1001_DEPENDS_USE:	.USE
1002.if defined(DEPENDS_TMP)
1003.if defined(NO_DEPENDS)
1004# Just print out messages
1005	@for i in ${DEPENDS_TMP}; do \
1006		prog=`/bin/echo $$i | /usr/bin/sed -e 's/:.*//'`; \
1007		dir=`/bin/echo $$i | /usr/bin/sed -e 's/.*://'`; \
1008		${ECHO_MSG} "===>  ${PKGNAME} depends on executable:  $$prog ($$dir)"; \
1009	done
1010.else
1011	@for i in ${DEPENDS_TMP}; do \
1012		prog=`/bin/echo $$i | /usr/bin/sed -e 's/:.*//'`; \
1013		dir=`/bin/echo $$i | /usr/bin/sed -e 's/.*://'`; \
1014		if which -s "$$prog"; then \
1015			${ECHO_MSG} "===>  ${PKGNAME} depends on executable: $$prog - found"; \
1016		else \
1017			${ECHO_MSG} "===>  ${PKGNAME} depends on executable: $$prog - not found"; \
1018			${ECHO_MSG} "===>  Verifying build for $$prog in $$dir"; \
1019			if [ ! -d "$$dir" ]; then \
1020				${ECHO_MSG} ">> No directory for $$prog.  Skipping.."; \
1021			else \
1022				(cd $$dir; ${MAKE} ${.MAKEFLAGS} is_depended) ; \
1023				${ECHO_MSG} "===>  Returning to build of ${PKGNAME}"; \
1024			fi; \
1025		fi; \
1026	done
1027.endif
1028.else
1029	@${DO_NADA}
1030.endif
1031
1032fetch-depends:	_DEPENDS_USE
1033build-depends:	_DEPENDS_USE
1034run-depends:	_DEPENDS_USE
1035
1036lib-depends:
1037.if defined(LIB_DEPENDS)
1038.if defined(NO_DEPENDS)
1039# Just print out messages
1040	@for i in ${LIB_DEPENDS}; do \
1041		lib=`/bin/echo $$i | /usr/bin/sed -e 's/:.*//'`; \
1042		dir=`/bin/echo $$i | /usr/bin/sed -e 's/.*://'`; \
1043		${ECHO_MSG} "===>  ${PKGNAME} depends on shared library:  $$lib ($$dir)"; \
1044	done
1045.else
1046	@for i in ${LIB_DEPENDS}; do \
1047		lib=`/bin/echo $$i | /usr/bin/sed -e 's/:.*//'`; \
1048		dir=`/bin/echo $$i | /usr/bin/sed -e 's/.*://'`; \
1049		if /sbin/ldconfig -r | grep -q -e "-l$$lib"; then \
1050			${ECHO_MSG} "===>  ${PKGNAME} depends on shared library: $$lib - found"; \
1051		else \
1052			${ECHO_MSG} "===>  ${PKGNAME} depends on shared library: $$lib - not found"; \
1053			${ECHO_MSG} "===>  Verifying build for $$lib in $$dir"; \
1054			if [ ! -d "$$dir" ]; then \
1055				${ECHO_MSG} ">> No directory for $$lib.  Skipping.."; \
1056			else \
1057				(cd $$dir; ${MAKE} ${.MAKEFLAGS} is_depended) ; \
1058				${ECHO_MSG} "===>  Returning to build of ${PKGNAME}"; \
1059			fi; \
1060		fi; \
1061	done
1062.endif
1063.else
1064	@${DO_NADA}
1065.endif
1066
1067misc-depends:
1068.if defined(DEPENDS)
1069	@${ECHO_MSG} "===>  ${PKGNAME} depends on:  ${DEPENDS}"
1070.if !defined(NO_DEPENDS)
1071	@for i in ${DEPENDS}; do \
1072		${ECHO_MSG} "===>  Verifying build for $$i"; \
1073		if [ ! -d $$i ]; then \
1074			${ECHO_MSG} ">> No directory for $$i.  Skipping.."; \
1075		else \
1076			(cd $$i; ${MAKE} ${.MAKEFLAGS} is_depended) ; \
1077		fi \
1078	done
1079	@${ECHO_MSG} "===>  Returning to build of ${PKGNAME}"
1080.endif
1081.else
1082	@${DO_NADA}
1083.endif
1084
1085.endif
1086
1087################################################################
1088# Everything after here are internal targets and really
1089# shouldn't be touched by anybody but the release engineers.
1090################################################################
1091
1092# This target generates an index entry suitable for aggregation into
1093# a large index.  Format is:
1094#
1095# distribution-name|port-path|installation-prefix|comment| \
1096#  description-file|maintainer|categories|keywords
1097#
1098.if !target(describe)
1099describe:
1100	@/bin/echo -n "${PKGNAME}|${.CURDIR}/${PKGNAME}|"
1101	@/bin/echo -n "${PREFIX}|"
1102	@if [ -f ${PKGDIR}/COMMENT ]; then \
1103		/bin/echo -n "`/bin/cat ${PKGDIR}/COMMENT`"; \
1104	else \
1105		/bin/echo -n "** No Description"; \
1106	fi
1107	@if [ -f ${PKGDIR}/DESCR ]; then \
1108		/bin/echo -n "|${PKGDIR}/DESCR"; \
1109	else \
1110		/bin/echo -n "|/dev/null"; \
1111	fi
1112	@/bin/echo -n "|${MAINTAINER}|${CATEGORIES}|${KEYWORDS}"
1113	@/bin/echo ""
1114.endif
1115
1116# Fake installation of package so that user can pkg_delete it later.
1117# Also, make sure that an installed port is recognized correctly in
1118# accordance to the @pkgdep directive in the packing lists
1119
1120.if !target(fake-pkg)
1121fake-pkg:
1122	@if [ ! -f ${PKGDIR}/PLIST -o ! -f ${PKGDIR}/COMMENT -o ! -f ${PKGDIR}/DESCR ]; then /bin/echo "** Missing package files for ${PKGNAME} - installation not recorded."; exit 1; fi
1123	@if [ ! -d ${PKG_DBDIR} ]; then /bin/rm -f ${PKG_DBDIR}; /bin/mkdir -p ${PKG_DBDIR}; fi
1124.if defined(FORCE_PKG_REGISTER)
1125	@/bin/rm -rf ${PKG_DBDIR}/${PKGNAME}
1126.endif
1127	@if [ ! -d ${PKG_DBDIR}/${PKGNAME} ]; then \
1128		${ECHO_MSG} "===>  Registering installation for ${PKGNAME}"; \
1129		/bin/mkdir -p ${PKG_DBDIR}/${PKGNAME}; \
1130		${PKG_CMD} ${PKG_ARGS} -O ${PKGFILE} > ${PKG_DBDIR}/${PKGNAME}/+CONTENTS; \
1131		/bin/cp ${PKGDIR}/DESCR ${PKG_DBDIR}/${PKGNAME}/+DESC; \
1132		/bin/cp ${PKGDIR}/COMMENT ${PKG_DBDIR}/${PKGNAME}/+COMMENT; \
1133		if [ -f ${PKGDIR}/INSTALL ]; then \
1134			/bin/cp ${PKGDIR}/INSTALL ${PKG_DBDIR}/${PKGNAME}/+INSTALL; \
1135		fi; \
1136		if [ -f ${PKGDIR}/DEINSTALL ]; then \
1137			/bin/cp ${PKGDIR}/DEINSTALL ${PKG_DBDIR}/${PKGNAME}/+DEINSTALL; \
1138		fi; \
1139		if [ -f ${PKGDIR}/REQ ]; then \
1140			/bin/cp ${PKGDIR}/REQ ${PKG_DBDIR}/${PKGNAME}/+REQ; \
1141		fi; \
1142	else \
1143		${ECHO_MSG} "===> ${PKGNAME} is already installed - perhaps an older version?"; \
1144		${ECHO_MSG} "     If so, you may wish to \`\`pkg_delete ${PKGNAME}'' and install"; \
1145		${ECHO_MSG} "     this port again to upgrade it properly."; \
1146	fi
1147.endif
1148
1149# Depend is generally meaningless for arbitrary ports, but if someone wants
1150# one they can override this.  This is just to catch people who've gotten into
1151# the habit of typing `make depend all install' as a matter of course.
1152#
1153.if !target(depend)
1154depend:
1155.endif
1156
1157# Same goes for tags
1158.if !target(tags)
1159tags:
1160.endif
1161