bsd.port.mk revision 13952
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.190 1996/02/06 21:25:23 ache 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(NO_MTREE) && 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 defined(ALL_HOOK)
410all:
411	@/usr/bin/env CURDIR=${.CURDIR} DISTNAME=${DISTNAME} \
412	  DISTDIR=${DISTDIR} WRKDIR=${WRKDIR} WRKSRC=${WRKSRC} \
413	  PATCHDIR=${PATCHDIR} SCRIPTDIR=${SCRIPTDIR} \
414	  FILESDIR=${FILESDIR} PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} \
415	  DEPENDS="${DEPENDS}" BUILD_DEPENDS="${BUILD_DEPENDS}" \
416	  RUN_DEPENDS="${RUN_DEPENDS}" X11BASE=${X11BASE} \
417	${ALL_HOOK}
418
419.endif
420
421.if !target(all)
422all: build
423.endif
424
425.if !defined(IS_DEPENDED_TARGET)
426IS_DEPENDED_TARGET=	install
427.endif
428
429.if !target(is_depended)
430is_depended:	${IS_DEPENDED_TARGET}
431.endif
432
433################################################################
434# The following are used to create easy dummy targets for
435# disabling some bit of default target behavior you don't want.
436# They still check to see if the target exists, and if so don't
437# do anything, since you might want to set this globally for a
438# group of ports in a Makefile.inc, but still be able to
439# override from an individual Makefile.
440################################################################
441
442.if defined(NO_EXTRACT) && !target(extract)
443extract: checksum
444	@${TOUCH} ${TOUCH_FLAGS} ${EXTRACT_COOKIE}
445checksum: fetch
446	@${DO_NADA}
447makesum:
448	@${DO_NADA}
449.endif
450.if defined(NO_CONFIGURE) && !target(configure)
451configure: patch
452	@${TOUCH} ${TOUCH_FLAGS} ${CONFIGURE_COOKIE}
453.endif
454.if defined(NO_BUILD) && !target(build)
455build: configure
456	@${TOUCH} ${TOUCH_FLAGS} ${BUILD_COOKIE}
457.endif
458.if defined(NO_PACKAGE) && !target(package)
459package:
460	@${DO_NADA}
461.endif
462.if defined(NO_PACKAGE) && !target(repackage)
463repackage:
464	@${DO_NADA}
465.endif
466.if defined(NO_INSTALL) && !target(install)
467install: build
468	@${TOUCH} ${TOUCH_FLAGS} ${INSTALL_COOKIE}
469.endif
470.if defined(NO_PATCH) && !target(patch)
471patch: extract
472	@${TOUCH} ${TOUCH_FLAGS} ${PATCH_COOKIE}
473.endif
474
475################################################################
476# More standard targets start here.
477#
478# These are the body of the build/install framework.  If you are
479# not happy with the default actions, and you can't solve it by
480# adding pre-* or post-* targets/scripts, override these.
481################################################################
482
483# Fetch
484
485.if !target(do-fetch)
486do-fetch:
487	@if [ ! -d ${DISTDIR} ]; then /bin/mkdir -p ${DISTDIR}; fi
488	@(cd ${DISTDIR}; \
489	 for file in ${DISTFILES}; do \
490		if [ ! -f $$file -a ! -f `/usr/bin/basename $$file` ]; then \
491			${ECHO_MSG} ">> $$file doesn't seem to exist on this system."; \
492			for site in ${MASTER_SITES}; do \
493			    ${ECHO_MSG} ">> Attempting to fetch from $${site}."; \
494				(${NCFTP} ${NCFTPFLAGS} $${site}$${file} ${NCFTPTAIL} || true); \
495				if [ -f $$file -o -f `/usr/bin/basename $$file` ]; then \
496					continue 2; \
497				fi \
498			done; \
499			${ECHO_MSG} ">> Couldn't fetch it - please try to retreive this";\
500			${ECHO_MSG} ">> port manually into ${DISTDIR} and try again."; \
501			exit 1; \
502	    fi \
503	 done)
504.if defined(PATCHFILES)
505	@if [ ! -d ${PATCHDIST} ]; then /bin/mkdir -p ${PATCHDIST}; fi
506	@(cd ${PATCHDIST}; \
507	 for file in ${PATCHFILES}; do \
508		if [ ! -f $$file -a ! -f `/usr/bin/basename $$file` ]; then \
509			${ECHO_MSG} ">> $$file doesn't seem to exist on this system."; \
510			for site in ${PATCH_SITES}; do \
511			    ${ECHO_MSG} ">> Attempting to fetch from $${site}."; \
512				(${NCFTP} ${NCFTPFLAGS} $${site}$${file} ${NCFTPTAIL} || true); \
513				if [ -f $$file -o -f `/usr/bin/basename $$file` ]; then \
514					continue 2; \
515				fi \
516			done; \
517			${ECHO_MSG} ">> Couldn't fetch it - please try to retreive this";\
518			${ECHO_MSG} ">> port manually into ${PATCHDIST} and try again."; \
519			exit 1; \
520	    fi \
521	 done)
522.endif
523.endif
524
525# Extract
526
527.if !target(do-extract)
528do-extract:
529	@/bin/rm -rf ${WRKDIR}
530	@/bin/mkdir -p ${WRKDIR}
531	@for file in ${EXTRACT_ONLY}; do \
532		if ! (cd ${WRKDIR};${EXTRACT_CMD} ${EXTRACT_BEFORE_ARGS} ${DISTDIR}/$$file ${EXTRACT_AFTER_ARGS});\
533		then \
534			exit 1; \
535		fi \
536	done
537.endif
538
539# Patch
540
541.if !target(do-patch)
542do-patch:
543.if defined(PATCHFILES)
544	@${ECHO_MSG} "===>  Applying distributed patches for ${PKGNAME}"
545.if defined(PATCH_DEBUG)
546	@(cd ${PATCHDIST}; \
547	  for i in ${PATCHFILES}; do \
548		${ECHO_MSG} "===>   Applying distributed patch $$i" ; \
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.else
559	@(cd ${PATCHDIST}; \
560	  for i in ${PATCHFILES}; do \
561		case $$i in \
562			*.Z|*.gz) \
563				/usr/bin/gzcat $$i | ${PATCH} ${PATCH_DIST_ARGS}; \
564				;; \
565			*) \
566				${PATCH} ${PATCH_DIST_ARGS} < $$i; \
567				;; \
568		esac; \
569	  done)
570.endif
571.endif
572.if defined(PATCH_DEBUG)
573	@if [ -d ${PATCHDIR} ]; then \
574		${ECHO_MSG} "===>  Applying FreeBSD patches for ${PKGNAME}" ; \
575		for i in ${PATCHDIR}/patch-*; do \
576			case $$i in \
577				*.orig|*~) \
578					${ECHO_MSG} "===>   Ignoring patchfile $$i" ; \
579					;; \
580				*) \
581					${ECHO_MSG} "===>   Applying FreeBSD patch $$i" ; \
582					${PATCH} ${PATCH_ARGS} < $$i; \
583					;; \
584			esac; \
585		done; \
586	fi
587.else
588	@if [ -d ${PATCHDIR} ]; then \
589		${ECHO_MSG} "===>  Applying FreeBSD patches for ${PKGNAME}" ; \
590		for i in ${PATCHDIR}/patch-*; do \
591			case $$i in \
592				*.orig|*~) \
593					${ECHO_MSG} "===>   Ignoring patchfile $$i" ; \
594					;; \
595				*) \
596					${PATCH} ${PATCH_ARGS} < $$i; \
597					;; \
598			esac; \
599		done;\
600	fi
601.endif
602.endif
603
604# Configure
605
606.if !target(do-configure)
607do-configure:
608	@if [ -f ${SCRIPTDIR}/configure ]; then \
609		/usr/bin/env CURDIR=${.CURDIR} DISTDIR=${DISTDIR} WRKDIR=${WRKDIR} \
610		  WRKSRC=${WRKSRC} PATCHDIR=${PATCHDIR} SCRIPTDIR=${SCRIPTDIR} \
611		  FILESDIR=${FILESDIR} PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} \
612		  DEPENDS="${DEPENDS}" X11BASE=${X11BASE} \
613		/bin/sh ${SCRIPTDIR}/configure; \
614	fi
615.if defined(HAS_CONFIGURE)
616	@(cd ${WRKSRC}; CC="${CC}" ac_cv_path_CC="${CC}" CFLAGS="${CFLAGS}" \
617	    INSTALL="/usr/bin/install -c -o ${BINOWN} -g ${BINGRP}" \
618	    INSTALL_PROGRAM="/usr/bin/install ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE}" \
619	    ${CONFIGURE_ENV} ./${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS})
620.endif
621.if defined(USE_IMAKE)
622	@(cd ${WRKSRC}; ${XMKMF})
623.endif
624.endif
625
626# Build
627
628.if !target(do-build)
629do-build:
630.if defined(USE_GMAKE)
631	@(cd ${WRKSRC}; ${GMAKE} PREFIX=${PREFIX} X11BASE=${X11BASE} ${MAKE_FLAGS} ${MAKEFILE} ${ALL_TARGET})
632.else defined(USE_GMAKE)
633	@(cd ${WRKSRC}; ${MAKE} PREFIX=${PREFIX} X11BASE=${X11BASE} ${MAKE_FLAGS} ${MAKEFILE} ${ALL_TARGET})
634.endif
635.endif
636
637# Install
638
639.if !target(do-install)
640do-install:
641.if defined(USE_GMAKE)
642	@(cd ${WRKSRC}; ${GMAKE} PREFIX=${PREFIX} X11BASE=${X11BASE} ${MAKE_FLAGS} ${MAKEFILE} ${INSTALL_TARGET})
643.if defined(USE_IMAKE) && !defined(NO_INSTALL_MANPAGES)
644	@(cd ${WRKSRC}; ${GMAKE} ${MAKE_FLAGS} ${MAKEFILE} install.man)
645.endif
646.else defined(USE_GMAKE)
647	@(cd ${WRKSRC}; ${MAKE} PREFIX=${PREFIX} X11BASE=${X11BASE} ${MAKE_FLAGS} ${MAKEFILE} ${INSTALL_TARGET})
648.if defined(USE_IMAKE) && !defined(NO_INSTALL_MANPAGES)
649	@(cd ${WRKSRC}; ${MAKE} ${MAKE_FLAGS} ${MAKEFILE} install.man)
650.endif
651.endif
652.endif
653
654# Package
655
656.if !target(do-package)
657do-package:
658	@if [ -e ${PKGDIR}/PLIST ]; then \
659		${ECHO_MSG} "===>  Building package for ${PKGNAME}"; \
660		if [ -d ${PACKAGES} ]; then \
661			if [ ! -d ${PKGREPOSITORY} ]; then \
662				if ! /bin/mkdir -p ${PKGREPOSITORY}; then \
663					${ECHO_MSG} ">> Can't create directory ${PKGREPOSITORY}."; \
664					exit 1; \
665				fi; \
666			fi; \
667		fi; \
668		if ${PKG_CMD} ${PKG_ARGS} ${PKGFILE}; then \
669			if [ -d ${PACKAGES} ]; then \
670				${MAKE} ${.MAKEFLAGS} package-links; \
671			fi; \
672		else \
673			${MAKE} ${.MAKEFLAGS} delete-package; \
674			exit 1; \
675		fi; \
676	fi
677.endif
678
679# Some support rules for do-package
680
681.if !target(package-links)
682package-links:
683	@${MAKE} ${.MAKEFLAGS} delete-package-links
684	@for cat in ${CATEGORIES}; do \
685		if [ ! -d ${PACKAGES}/$$cat ]; then \
686			if ! /bin/mkdir -p ${PACKAGES}/$$cat; then \
687				${ECHO_MSG} ">> Can't create directory ${PACKAGES}/$$cat."; \
688				exit 1; \
689			fi; \
690		fi; \
691		ln -s ../${PKGREPOSITORYSUBDIR}/${PKGNAME}${PKG_SUFX} ${PACKAGES}/$$cat; \
692	done;
693.endif
694
695.if !target(delete-package-links)
696delete-package-links:
697	@/bin/rm -f ${PACKAGES}/[a-z]*/${PKGNAME}${PKG_SUFX};
698.endif
699
700.if !target(delete-package)
701delete-package:
702	@${MAKE} ${.MAKEFLAGS} delete-package-links
703	@/bin/rm -f ${PKGFILE}
704.endif
705
706################################################################
707# This is the "generic" port target, actually a macro used from the
708# six main targets.  See below for more.
709################################################################
710
711_PORT_USE: .USE
712.if make(real-fetch)
713	@${MAKE} ${.MAKEFLAGS} fetch-depends
714.endif
715.if make(real-extract)
716	@${MAKE} ${.MAKEFLAGS} build-depends lib-depends misc-depends
717.endif
718.if make(real-install)
719	@${MAKE} ${.MAKEFLAGS} run-depends
720.endif
721.if make(real-install)
722.if !defined(NO_MTREE)
723	@if [ `id -u` = 0 ]; then \
724		${MTREE_CMD} ${MTREE_ARGS} ${PREFIX}/; \
725	else \
726		${ECHO_MSG} "Warning: not superuser, can't run mtree."; \
727		${ECHO_MSG} "Become root and try again to ensure correct permissions."; \
728	fi
729.endif
730.endif
731	@${MAKE} ${.MAKEFLAGS} ${.TARGET:S/^real-/pre-/}
732	@if [ -f ${SCRIPTDIR}/${.TARGET:S/^real-/pre-/} ]; then \
733		/usr/bin/env CURDIR=${.CURDIR} DISTDIR=${DISTDIR} WRKDIR=${WRKDIR} \
734		  WRKSRC=${WRKSRC} PATCHDIR=${PATCHDIR} SCRIPTDIR=${SCRIPTDIR} \
735		  FILESDIR=${FILESDIR} PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} \
736		  DEPENDS="${DEPENDS}" X11BASE=${X11BASE} \
737			/bin/sh ${SCRIPTDIR}/${.TARGET:S/^real-/pre-/}; \
738	fi
739	@${MAKE} ${.MAKEFLAGS} ${.TARGET:S/^real-/do-/}
740	@${MAKE} ${.MAKEFLAGS} ${.TARGET:S/^real-/post-/}
741	@if [ -f ${SCRIPTDIR}/${.TARGET:S/^real-/post-/} ]; then \
742		/usr/bin/env CURDIR=${.CURDIR} DISTDIR=${DISTDIR} WRKDIR=${WRKDIR} \
743		  WRKSRC=${WRKSRC} PATCHDIR=${PATCHDIR} SCRIPTDIR=${SCRIPTDIR} \
744		  FILESDIR=${FILESDIR} PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} \
745		  DEPENDS="${DEPENDS}" X11BASE=${X11BASE} \
746			/bin/sh ${SCRIPTDIR}/${.TARGET:S/^real-/post-/}; \
747	fi
748.if make(real-install)
749	@${MAKE} ${.MAKEFLAGS} fake-pkg
750.endif
751.if !make(real-fetch) \
752	&& (!make(real-patch) || !defined(PATCH_CHECK_ONLY)) \
753	&& (!make(real-package) || !defined(PACKAGE_NOINSTALL))
754	@${TOUCH} ${TOUCH_FLAGS} ${WRKDIR}/.${.TARGET:S/^real-//}_done
755.endif
756
757################################################################
758# Skeleton targets start here
759# 
760# You shouldn't have to change these.  Either add the pre-* or
761# post-* targets/scripts or redefine the do-* targets.  These
762# targets don't do anything other than checking for cookies and
763# call the necessary targets/scripts.
764################################################################
765
766.if !target(fetch)
767fetch:
768	@${MAKE} ${.MAKEFLAGS} real-fetch
769.endif
770
771.if !target(extract)
772extract: checksum ${EXTRACT_COOKIE}
773.endif
774
775.if !target(patch)
776patch: extract ${PATCH_COOKIE}
777.endif
778
779.if !target(configure)
780configure: patch ${CONFIGURE_COOKIE}
781.endif
782
783.if !target(build)
784build: configure ${BUILD_COOKIE}
785.endif
786
787.if !target(install)
788install: build ${INSTALL_COOKIE}
789.endif
790
791.if !target(package)
792package: install ${PACKAGE_COOKIE}
793.endif
794
795${EXTRACT_COOKIE}:
796	@${MAKE} ${.MAKEFLAGS} real-extract
797${PATCH_COOKIE}:
798	@${MAKE} ${.MAKEFLAGS} real-patch
799${CONFIGURE_COOKIE}:
800	@${MAKE} ${.MAKEFLAGS} real-configure
801${BUILD_COOKIE}:
802	@${MAKE} ${.MAKEFLAGS} real-build
803${INSTALL_COOKIE}:
804	@${MAKE} ${.MAKEFLAGS} real-install
805${PACKAGE_COOKIE}:
806	@${MAKE} ${.MAKEFLAGS} real-package
807
808# And call the macros
809
810real-fetch: _PORT_USE
811real-extract: _PORT_USE
812	@${ECHO_MSG} "===>  Extracting for ${PKGNAME}"
813real-patch: _PORT_USE
814	@${ECHO_MSG} "===>  Patching for ${PKGNAME}"
815real-configure: _PORT_USE
816	@${ECHO_MSG} "===>  Configuring for ${PKGNAME}"
817real-build: _PORT_USE
818	@${ECHO_MSG} "===>  Building for ${PKGNAME}"
819real-install: _PORT_USE
820	@${ECHO_MSG} "===>  Installing for ${PKGNAME}"
821real-package: _PORT_USE
822
823# Empty pre-* and post-* targets, note we can't use .if !target()
824# in the _PORT_USE macro
825
826.for name in fetch extract patch configure build install package
827
828.if !target(pre-${name})
829pre-${name}:
830	@${DO_NADA}
831.endif
832
833.if !target(post-${name})
834post-${name}:
835	@${DO_NADA}
836.endif
837
838.endfor
839
840# Checkpatch
841#
842# Special target to verify patches
843
844.if !target(checkpatch)
845checkpatch:
846	@${MAKE} PATCH_CHECK_ONLY=yes ${.MAKEFLAGS} patch
847.endif
848
849# Reinstall
850#
851# Special target to re-run install
852
853.if !target(reinstall)
854reinstall: pre-reinstall install
855
856pre-reinstall:
857	@/bin/rm -f ${INSTALL_COOKIE}
858	@/bin/rm -f ${PACKAGE_COOKIE}
859.endif
860
861################################################################
862# Some more targets supplied for users' convenience
863################################################################
864
865# Cleaning up
866
867.if !target(pre-clean)
868pre-clean:
869	@${DO_NADA}
870.endif
871
872.if !target(clean)
873clean: pre-clean
874	@${ECHO_MSG} "===>  Cleaning for ${PKGNAME}"
875	@/bin/rm -f ${EXTRACT_COOKIE} ${CONFIGURE_COOKIE} ${INSTALL_COOKIE} \
876		${BUILD_COOKIE} ${PATCH_COOKIE}
877.if defined(NO_WRKDIR)
878	@/bin/rm -f ${WRKDIR}/.*_done
879.else
880	@/bin/rm -rf ${WRKDIR}
881.endif
882.endif
883
884# Prints out a list of files to fetch (useful to do a batch fetch)
885
886.if !target(fetch-list)
887fetch-list:
888	@if [ ! -d ${DISTDIR} ]; then /bin/mkdir -p ${DISTDIR}; fi
889	@(cd ${DISTDIR}; \
890	 for file in ${DISTFILES}; do \
891		if [ ! -f $$file -a ! -f `/usr/bin/basename $$file` ]; then \
892			for site in ${MASTER_SITES}; do \
893				/bin/echo -n ${NCFTP} ${NCFTPFLAGS} $${site}$${file} "${NCFTPTAIL}" '||' ; \
894					break; \
895			done; \
896			/bin/echo "echo $${file} not fetched" ; \
897		fi \
898	done)
899.if defined(PATCHFILES)
900	@(cd ${DISTDIR}; \
901	 for file in ${PATCHFILES}; do \
902		if [ ! -f $$file -a ! -f `/usr/bin/basename $$file` ]; then \
903			for site in ${PATCH_SITES}; do \
904				/bin/echo -n ${NCFTP} ${NCFTPFLAGS} $${site}$${file} ${PATCH_PRFX}$${file} "${NCFTPTAIL}" '||' ; \
905					break; \
906			done; \
907			/bin/echo "echo $${file} not fetched" ; \
908		fi \
909	 done)
910.endif
911.endif
912
913# Checksumming utilities
914
915.if !target(makesum)
916makesum: fetch
917	@if [ ! -d ${FILESDIR} ]; then /bin/mkdir -p ${FILESDIR}; fi
918	@if [ -f ${MD5_FILE} ]; then /bin/rm -f ${MD5_FILE}; fi
919	@(cd ${DISTDIR}; \
920	 for file in ${DISTFILES} ${PATCHFILES:S|^|${PATCH_PRFX}|}; do \
921		${MD5} $$file >> ${MD5_FILE}; \
922	 done)
923.endif
924
925.if !target(checksum)
926checksum: fetch
927	@if [ ! -f ${MD5_FILE} ]; then \
928		${ECHO_MSG} ">> No MD5 checksum file."; \
929	else \
930		(cd ${DISTDIR}; OK=""; \
931		  for file in ${DISTFILES} ${PATCHFILES:S|^|${PATCH_PRFX}|}; do \
932			CKSUM=`${MD5} $$file | awk '{print $$4}'`; \
933			CKSUM2=`grep "($$file)" ${MD5_FILE} | awk '{print $$4}'`; \
934			if [ "$$CKSUM2" = "" ]; then \
935				${ECHO_MSG} ">> No checksum recorded for $$file"; \
936				OK="false"; \
937			elif [ "$$CKSUM" != "$$CKSUM2" ]; then \
938				${ECHO_MSG} ">> Checksum mismatch for $$file"; \
939				exit 1; \
940			fi; \
941		  done; \
942		  if [ "$$OK" = "" ]; then \
943			${ECHO_MSG} "Checksums OK."; \
944		  else \
945			${ECHO_MSG} "Checksums OK for files that have them."; \
946		  fi) ; \
947	fi
948.endif
949
950################################################################
951# The special package-building targets
952# You probably won't need to touch these
953################################################################
954
955# Nobody should want to override this unless PKGNAME is simply bogus.
956
957.if !target(package-name)
958package-name:
959.if !defined(NO_PACKAGE)
960	@/bin/echo ${PKGNAME}
961.endif
962.endif
963
964# Show (recursively) all the packages this package depends on.
965
966.if !target(package-depends)
967package-depends:
968	@for i in ${RUN_DEPENDS} ${LIB_DEPENDS} ${DEPENDS}; do \
969		dir=`/bin/echo $$i | /usr/bin/sed -e 's/.*://'`; \
970		(cd $$dir ; ${MAKE} package-name package-depends); \
971	done
972.endif
973
974# Build a package but don't check the package cookie
975
976.if !target(repackage)
977repackage: pre-repackage package
978
979pre-repackage:
980	@/bin/rm -f ${PACKAGE_COOKIE}
981.endif
982
983# Build a package but don't check the cookie for installation, also don't
984# install package cookie
985
986.if !target(package-noinstall)
987package-noinstall:
988	@${MAKE} ${.MAKEFLAGS} PACKAGE_NOINSTALL=yes real-package
989.endif
990
991################################################################
992# Dependency checking
993################################################################
994
995.if !target(depends)
996depends: lib-depends misc-depends
997	@${MAKE} ${.MAKEFLAGS} fetch-depends
998	@${MAKE} ${.MAKEFLAGS} build-depends
999	@${MAKE} ${.MAKEFLAGS} run-depends
1000
1001.if make(fetch-depends)
1002DEPENDS_TMP+=	${FETCH_DEPENDS}
1003.endif
1004
1005.if make(build-depends)
1006DEPENDS_TMP+=	${BUILD_DEPENDS}
1007.endif
1008
1009.if make(run-depends)
1010DEPENDS_TMP+=	${RUN_DEPENDS}
1011.endif
1012
1013_DEPENDS_USE:	.USE
1014.if defined(DEPENDS_TMP)
1015.if defined(NO_DEPENDS)
1016# Just print out messages
1017	@for i in ${DEPENDS_TMP}; do \
1018		prog=`/bin/echo $$i | /usr/bin/sed -e 's/:.*//'`; \
1019		dir=`/bin/echo $$i | /usr/bin/sed -e 's/.*://'`; \
1020		if expr "$$prog" : \\/ >/dev/null; then \
1021			${ECHO_MSG} "===>  ${PKGNAME} depends on file:  $$prog ($$dir)"; \
1022		else \
1023			${ECHO_MSG} "===>  ${PKGNAME} depends on executable:  $$prog ($$dir)"; \
1024		fi; \
1025	done
1026.else
1027	@for i in ${DEPENDS_TMP}; do \
1028		prog=`/bin/echo $$i | /usr/bin/sed -e 's/:.*//'`; \
1029		dir=`/bin/echo $$i | /usr/bin/sed -e 's/.*://'`; \
1030		if expr "$$prog" : \\/ >/dev/null; then \
1031			if [ -e "$$prog" ]; then \
1032				${ECHO_MSG} "===>  ${PKGNAME} depends on file: $$prog - found"; \
1033				notfound=0; \
1034			else \
1035				${ECHO_MSG} "===>  ${PKGNAME} depends on file: $$prog - not found"; \
1036				notfound=1; \
1037			fi; \
1038		else \
1039			if which -s "$$prog"; then \
1040				${ECHO_MSG} "===>  ${PKGNAME} depends on executable: $$prog - found"; \
1041				notfound=0; \
1042			else \
1043				${ECHO_MSG} "===>  ${PKGNAME} depends on executable: $$prog - not found"; \
1044				notfound=1; \
1045			fi; \
1046		fi; \
1047		if [ $$notfound != 0 ]; then \
1048			${ECHO_MSG} "===>  Verifying build for $$prog in $$dir"; \
1049			if [ ! -d "$$dir" ]; then \
1050				${ECHO_MSG} ">> No directory for $$prog.  Skipping.."; \
1051			else \
1052				(cd $$dir; ${MAKE} ${.MAKEFLAGS} is_depended) ; \
1053				${ECHO_MSG} "===>  Returning to build of ${PKGNAME}"; \
1054			fi; \
1055		fi; \
1056	done
1057.endif
1058.else
1059	@${DO_NADA}
1060.endif
1061
1062fetch-depends:	_DEPENDS_USE
1063build-depends:	_DEPENDS_USE
1064run-depends:	_DEPENDS_USE
1065
1066lib-depends:
1067.if defined(LIB_DEPENDS)
1068.if defined(NO_DEPENDS)
1069# Just print out messages
1070	@for i in ${LIB_DEPENDS}; do \
1071		lib=`/bin/echo $$i | /usr/bin/sed -e 's/:.*//'`; \
1072		dir=`/bin/echo $$i | /usr/bin/sed -e 's/.*://'`; \
1073		${ECHO_MSG} "===>  ${PKGNAME} depends on shared library:  $$lib ($$dir)"; \
1074	done
1075.else
1076	@for i in ${LIB_DEPENDS}; do \
1077		lib=`/bin/echo $$i | /usr/bin/sed -e 's/:.*//'`; \
1078		dir=`/bin/echo $$i | /usr/bin/sed -e 's/.*://'`; \
1079		if /sbin/ldconfig -r | grep -q -e "-l$$lib"; then \
1080			${ECHO_MSG} "===>  ${PKGNAME} depends on shared library: $$lib - found"; \
1081		else \
1082			${ECHO_MSG} "===>  ${PKGNAME} depends on shared library: $$lib - not found"; \
1083			${ECHO_MSG} "===>  Verifying build for $$lib in $$dir"; \
1084			if [ ! -d "$$dir" ]; then \
1085				${ECHO_MSG} ">> No directory for $$lib.  Skipping.."; \
1086			else \
1087				(cd $$dir; ${MAKE} ${.MAKEFLAGS} is_depended) ; \
1088				${ECHO_MSG} "===>  Returning to build of ${PKGNAME}"; \
1089			fi; \
1090		fi; \
1091	done
1092.endif
1093.else
1094	@${DO_NADA}
1095.endif
1096
1097misc-depends:
1098.if defined(DEPENDS)
1099	@${ECHO_MSG} "===>  ${PKGNAME} depends on:  ${DEPENDS}"
1100.if !defined(NO_DEPENDS)
1101	@for i in ${DEPENDS}; do \
1102		${ECHO_MSG} "===>  Verifying build for $$i"; \
1103		if [ ! -d $$i ]; then \
1104			${ECHO_MSG} ">> No directory for $$i.  Skipping.."; \
1105		else \
1106			(cd $$i; ${MAKE} ${.MAKEFLAGS} is_depended) ; \
1107		fi \
1108	done
1109	@${ECHO_MSG} "===>  Returning to build of ${PKGNAME}"
1110.endif
1111.else
1112	@${DO_NADA}
1113.endif
1114
1115.endif
1116
1117################################################################
1118# Everything after here are internal targets and really
1119# shouldn't be touched by anybody but the release engineers.
1120################################################################
1121
1122# This target generates an index entry suitable for aggregation into
1123# a large index.  Format is:
1124#
1125# distribution-name|port-path|installation-prefix|comment| \
1126#  description-file|maintainer|categories|keywords
1127#
1128.if !target(describe)
1129describe:
1130	@/bin/echo -n "${PKGNAME}|${.CURDIR}/${PKGNAME}|"
1131	@/bin/echo -n "${PREFIX}|"
1132	@if [ -f ${PKGDIR}/COMMENT ]; then \
1133		/bin/echo -n "`/bin/cat ${PKGDIR}/COMMENT`"; \
1134	else \
1135		/bin/echo -n "** No Description"; \
1136	fi
1137	@if [ -f ${PKGDIR}/DESCR ]; then \
1138		/bin/echo -n "|${PKGDIR}/DESCR"; \
1139	else \
1140		/bin/echo -n "|/dev/null"; \
1141	fi
1142	@/bin/echo -n "|${MAINTAINER}|${CATEGORIES}|${KEYWORDS}"
1143	@/bin/echo ""
1144.endif
1145
1146# Fake installation of package so that user can pkg_delete it later.
1147# Also, make sure that an installed port is recognized correctly in
1148# accordance to the @pkgdep directive in the packing lists
1149
1150.if !target(fake-pkg)
1151fake-pkg:
1152	@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
1153	@if [ ! -d ${PKG_DBDIR} ]; then /bin/rm -f ${PKG_DBDIR}; /bin/mkdir -p ${PKG_DBDIR}; fi
1154.if defined(FORCE_PKG_REGISTER)
1155	@/bin/rm -rf ${PKG_DBDIR}/${PKGNAME}
1156.endif
1157	@if [ ! -d ${PKG_DBDIR}/${PKGNAME} ]; then \
1158		${ECHO_MSG} "===>  Registering installation for ${PKGNAME}"; \
1159		/bin/mkdir -p ${PKG_DBDIR}/${PKGNAME}; \
1160		${PKG_CMD} ${PKG_ARGS} -O ${PKGFILE} > ${PKG_DBDIR}/${PKGNAME}/+CONTENTS; \
1161		/bin/cp ${PKGDIR}/DESCR ${PKG_DBDIR}/${PKGNAME}/+DESC; \
1162		/bin/cp ${PKGDIR}/COMMENT ${PKG_DBDIR}/${PKGNAME}/+COMMENT; \
1163		if [ -f ${PKGDIR}/INSTALL ]; then \
1164			/bin/cp ${PKGDIR}/INSTALL ${PKG_DBDIR}/${PKGNAME}/+INSTALL; \
1165		fi; \
1166		if [ -f ${PKGDIR}/DEINSTALL ]; then \
1167			/bin/cp ${PKGDIR}/DEINSTALL ${PKG_DBDIR}/${PKGNAME}/+DEINSTALL; \
1168		fi; \
1169		if [ -f ${PKGDIR}/REQ ]; then \
1170			/bin/cp ${PKGDIR}/REQ ${PKG_DBDIR}/${PKGNAME}/+REQ; \
1171		fi; \
1172	else \
1173		${ECHO_MSG} "===> ${PKGNAME} is already installed - perhaps an older version?"; \
1174		${ECHO_MSG} "     If so, you may wish to \`\`pkg_delete ${PKGNAME}'' and install"; \
1175		${ECHO_MSG} "     this port again by \`\`make reinstall'' to upgrade it properly."; \
1176	fi
1177.endif
1178
1179# Depend is generally meaningless for arbitrary ports, but if someone wants
1180# one they can override this.  This is just to catch people who've gotten into
1181# the habit of typing `make depend all install' as a matter of course.
1182#
1183.if !target(depend)
1184depend:
1185.endif
1186
1187# Same goes for tags
1188.if !target(tags)
1189tags:
1190.endif
1191