bsd.port.mk revision 16495
1135446Strhodes#-*- mode: Fundamental; tab-width: 4; -*-
2193149Sdougb#
3135446Strhodes#	bsd.port.mk - 940820 Jordan K. Hubbard.
4135446Strhodes#	This file is in the public domain.
5193149Sdougb#
6135446Strhodes# $Id: bsd.port.mk,v 1.207 1996/06/19 01:04:23 jkh Exp $
7135446Strhodes#
8135446Strhodes# Please view me with 4 column tabs!
9135446Strhodes
10135446Strhodes
11135446Strhodes# Supported Variables and their behaviors:
12135446Strhodes#
13135446Strhodes# Variables that typically apply to all ports:
14135446Strhodes# 
15135446Strhodes# PORTSDIR		- The root of the ports tree (default: /usr/ports).
16135446Strhodes# DISTDIR 		- Where to get gzip'd, tarballed copies of original sources
17135446Strhodes#				  (default: ${PORTSDIR}/distfiles/${DIST_SUBDIR}).
18224092Sdougb# PREFIX		- Where to install things in general (default: /usr/local).
19135446Strhodes# MASTER_SITES	- Primary location(s) for distribution files if not found
20135446Strhodes#				  locally (default:
21135446Strhodes#				   ftp://ftp.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/)
22135446Strhodes# PATCH_SITES	- Primary location(s) for distribution patch files
23193149Sdougb#				  (see PATCHFILES below) if not found locally (default:
24170222Sdougb#				   ftp://ftp.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/)
25135446Strhodes#
26135446Strhodes# MASTER_SITE_OVERRIDE - If set, override the MASTER_SITES setting with this
27170222Sdougb#				  value.
28135446Strhodes# MASTER_SITE_FREEBSD - If set, only use the FreeBSD master repository for
29135446Strhodes#				  MASTER_SITES.
30135446Strhodes# PACKAGES		- A top level directory where all packages go (rather than
31135446Strhodes#				  going locally to each port). (default: ${PORTSDIR}/packages).
32135446Strhodes# GMAKE			- Set to path of GNU make if not in $PATH (default: gmake).
33135446Strhodes# XMKMF			- Set to path of `xmkmf' if not in $PATH (default: xmkmf -a ).
34135446Strhodes# MAINTAINER	- The e-mail address of the contact person for this port
35170222Sdougb#				  (default: ports@FreeBSD.ORG).
36170222Sdougb# CATEGORIES	- A list of descriptive categories into which this port falls
37135446Strhodes#				  (default: orphans).
38135446Strhodes#
39135446Strhodes# Variables that typically apply to an individual port.  Non-Boolean
40193149Sdougb# variables without defaults are *mandatory*.
41193149Sdougb# 
42193149Sdougb#
43193149Sdougb# WRKDIR 		- A temporary working directory that gets *clobbered* on clean
44170222Sdougb#				  (default: ${.CURDIR}/work).
45135446Strhodes# WRKSRC		- A subdirectory of ${WRKDIR} where the distribution actually
46170222Sdougb#				  unpacks to.  (Default: ${WRKDIR}/${DISTNAME} unless
47170222Sdougb#				  NO_WRKSUBDIR is set, in which case simply ${WRKDIR}).
48170222Sdougb# DISTNAME		- Name of port or distribution.
49170222Sdougb# DISTFILES		- Name(s) of archive file(s) containing distribution
50170222Sdougb#				  (default: ${DISTNAME}${EXTRACT_SUFX}).
51170222Sdougb# PATCHFILES	- Name(s) of additional files that contain distribution
52135446Strhodes#				  patches (default: none).  make will look for them at
53135446Strhodes#				  PATCH_SITES (see above).  They will automatically be
54135446Strhodes#				  uncompressed before patching if the names end with
55193149Sdougb#				  ".gz" or ".Z".
56193149Sdougb# DIST_SUBDIR	- Suffix to ${DISTDIR} (see above).  If set, all ${DISTFILES} 
57135446Strhodes#				  and ${PATCHFILES} will be put in this subdirectory of
58193149Sdougb#				  ${DISTDIR}.  Also they will be fetched in this subdirectory 
59135446Strhodes#				  from FreeBSD mirror sites.
60193149Sdougb# PKGNAME		- Name of the package file to create if the DISTNAME 
61135446Strhodes#				  isn't really relevant for the port/package
62193149Sdougb#				  (default: ${DISTNAME}).
63135446Strhodes# EXTRACT_ONLY	- If defined, a subset of ${DISTFILES} you want to
64135446Strhodes#			  	  actually extract.
65170222Sdougb# PATCHDIR 		- A directory containing any additional patches you made
66135446Strhodes#				  to port this software to FreeBSD (default:
67135446Strhodes#				  ${.CURDIR}/patches)
68135446Strhodes# SCRIPTDIR 	- A directory containing any auxiliary scripts
69135446Strhodes#				  (default: ${.CURDIR}/scripts)
70135446Strhodes# FILESDIR 		- A directory containing any miscellaneous additional files.
71135446Strhodes#				  (default: ${.CURDIR}/files)
72193149Sdougb# PKGDIR 		- A direction containing any package creation files.
73224092Sdougb#				  (default: ${.CURDIR}/pkg)
74224092Sdougb# PKG_DBDIR		- Where package installation is recorded (default: /var/db/pkg)
75224092Sdougb# FORCE_PKG_REGISTER - If set, it will overwrite any existing package
76224092Sdougb#				  registration information in ${PKG_DBDIR}/${PKGNAME}.
77224092Sdougb# NO_MTREE		- If set, will not invoke mtree from bsd.port.mk from
78224092Sdougb#				  the "install" target.  This is the default if
79193149Sdougb#				  USE_IMAKE or USE_X11 is set.
80135446Strhodes#
81135446Strhodes# NO_BUILD		- Use a dummy (do-nothing) build target.
82135446Strhodes# NO_CONFIGURE	- Use a dummy (do-nothing) configure target.
83193149Sdougb# NO_CDROM		- Use dummy (do-nothing) targets if FOR_CDROM is set.
84193149Sdougb# NO_DESCRIBE	- Use a dummy (do-nothing) describe target.
85193149Sdougb# NO_EXTRACT	- Use a dummy (do-nothing) extract target.
86193149Sdougb# NO_INSTALL	- Use a dummy (do-nothing) install target.
87135446Strhodes# NO_PACKAGE	- Use a dummy (do-nothing) package target.
88193149Sdougb# NO_PKG_REGISTER - Don't register a port install as a package.
89135446Strhodes# NO_WRKSUBDIR	- Assume port unpacks directly into ${WRKDIR}.
90193149Sdougb# NO_WRKDIR		- There's no work directory at all; port does this someplace
91193149Sdougb#				  else.
92193149Sdougb# NO_DEPENDS	- Don't verify build of dependencies.
93193149Sdougb# BROKEN		- Port is broken.
94193149Sdougb# RESTRICTED	- Port is restricted.  Set this string to the reason why.
95193149Sdougb# USE_GMAKE		- Says that the port uses gmake.
96193149Sdougb# USE_IMAKE		- Says that the port uses imake.
97193149Sdougb# USE_X11		- Says that the port uses X11.
98170222Sdougb# NO_INSTALL_MANPAGES - For imake ports that don't like the install.man
99170222Sdougb#						target.
100135446Strhodes# HAS_CONFIGURE	- Says that the port has its own configure script.
101135446Strhodes# GNU_CONFIGURE	- Set if you are using GNU configure (optional).
102193149Sdougb# CONFIGURE_SCRIPT - Name of configure script, defaults to 'configure'.
103224092Sdougb# CONFIGURE_ARGS - Pass these args to configure if ${HAS_CONFIGURE} is set.
104135446Strhodes# CONFIGURE_ENV  - Pass these env (shell-like) to configure if
105135446Strhodes#				  ${HAS_CONFIGURE} is set.
106135446Strhodes# IS_INTERACTIVE - Set this if your port needs to interact with the user
107135446Strhodes#				  during a build.  User can then decide to skip this port by
108193149Sdougb#				  setting ${BATCH}, or compiling only the interactive ports
109193149Sdougb#				  by setting ${INTERACTIVE}.
110193149Sdougb# FETCH_DEPENDS - A list of "prog:dir" pairs of other ports this
111224092Sdougb#				  package depends in the "fetch" stage.  "prog" is the
112224092Sdougb#				  name of an executable.  make will search your $PATH
113193149Sdougb#				  for it and go into "dir" to do a "make all install"
114193149Sdougb#				  if it's not found.
115204619Sdougb# BUILD_DEPENDS - A list of "prog:dir" pairs of other ports this
116170222Sdougb#				  package depends to build (somewhere between the
117135446Strhodes#				  "extract" to "build" stage).  "prog" is the name
118135446Strhodes#				  of an executable.  make will search your $PATH for
119135446Strhodes#				  it and go into "dir" to do a "make all install" if
120135446Strhodes#				  it's not found.
121135446Strhodes# RUN_DEPENDS	- A list of "prog:dir" pairs of other ports this package
122170222Sdougb#				  depends to run.  "prog" is the name of an
123170222Sdougb#				  executable.  make will search your $PATH for it and
124135446Strhodes#				  go into "dir" to do a "make all install" if it's not
125135446Strhodes#				  found.  This will be build during the "install" stage
126135446Strhodes#				  and its name will be put into the package as well.
127135446Strhodes# LIB_DEPENDS	- A list of "lib:dir" pairs of other ports this package
128135446Strhodes#				  depends on.  "lib" is the name of a shared library.
129135446Strhodes#				  make will use "ldconfig -r" to search for the
130135446Strhodes#				  library.  Note that lib can be any regular expression,
131170222Sdougb#				  and you need two backslashes in front of dots (.) to
132135446Strhodes#				  supress its special meaning (e.g., use
133170222Sdougb#				  "foo\\.2\\.:${PORTSDIR}/utils/foo" to match "libfoo.2.*").
134170222Sdougb# DEPENDS		- A list of other ports this package depends on being
135170222Sdougb#				  made first.  Use this for things that don't fall into
136170222Sdougb#				  the above two categories.
137193149Sdougb# EXTRACT_CMD	- Command for extracting archive (default: tar).
138135446Strhodes# EXTRACT_SUFX	- Suffix for archive names (default: .tar.gz).
139135446Strhodes# EXTRACT_BEFORE_ARGS -
140135446Strhodes#				  Arguments to ${EXTRACT_CMD} before filename
141135446Strhodes#				  (default: -C ${WRKDIR} -xzf).
142135446Strhodes# EXTRACT_AFTER_ARGS -
143135446Strhodes#				  Arguments to ${EXTRACT_CMD} following filename
144193149Sdougb#				  (default: none).
145135446Strhodes#
146135446Strhodes# NCFTP			- Full path to ncftp command if not in $PATH (default: ncftp).
147170222Sdougb# NCFTPFLAGS    - Arguments to ${NCFTP} (default: -N).
148135446Strhodes#
149135446Strhodes# Motif support:
150135446Strhodes#
151135446Strhodes# REQUIRES_MOTIF - Set this in your port if it requires Motif.  It will  be
152135446Strhodes#				  built only if HAVE_MOTIF is set.
153135446Strhodes# HAVE_MOTIF	- If set, means system has Motif.  Typically set in
154135446Strhodes#				  /etc/make.conf.
155135446Strhodes# MOTIF_STATIC	- If set, link libXm statically; otherwise, link it
156135446Strhodes#				  dynamically.
157135446Strhodes#
158135446Strhodes# Variables to change if you want a special behavior:
159135446Strhodes#
160135446Strhodes# ECHO_MSG		- Used to print all the '===>' style prompts - override this
161193149Sdougb#				  to turn them off (default: /bin/echo).
162135446Strhodes# IS_DEPENDED_TARGET -
163135446Strhodes#				  The target to execute when a port is called as a
164135446Strhodes#				  dependency (default: install).  E.g., "make fetch
165135446Strhodes#				  IS_DEPENDED_TARGET=fetch" will fetch all the distfiles,
166135446Strhodes#				  including those of dependencies, without actually building
167135446Strhodes#				  any of them).
168135446Strhodes#
169135446Strhodes# 
170135446Strhodes# Default targets and their behaviors:
171135446Strhodes#
172135446Strhodes# fetch			- Retrieves ${DISTFILES} (and ${PATCHFILES} if defined)
173135446Strhodes#				  into ${DISTDIR} as necessary.
174135446Strhodes# fetch-list	- Show list of files that would be retrieved by fetch
175135446Strhodes# extract		- Unpacks ${DISTFILES} into ${WRKDIR}.
176135446Strhodes# patch			- Apply any provided patches to the source.
177135446Strhodes# configure		- Runs either GNU configure, one or more local configure
178135446Strhodes#				  scripts or nothing, depending on what's available.
179135446Strhodes# build			- Actually compile the sources.
180135446Strhodes# install		- Install the results of a build.
181135446Strhodes# reinstall		- Install the results of a build, ignoring "already installed"
182135446Strhodes#				  flag.
183135446Strhodes# package		- Create a package from an _installed_ port.
184135446Strhodes# describe		- Try to generate a one-line description for each port for
185135446Strhodes#				  use in INDEX files and the like.
186170222Sdougb# checkpatch	- Do a "patch -C" instead of a "patch".  Note that it may
187135446Strhodes#				  give incorrect results if multiple patches deal with
188135446Strhodes#				  the same file.
189135446Strhodes# checksum		- Use files/md5 to ensure that your distfiles are valid.
190135446Strhodes# makesum		- Generate files/md5 (only do this for your own ports!).
191135446Strhodes#
192135446Strhodes# Default sequence for "all" is:  fetch checksum extract patch configure build
193135446Strhodes#
194135446Strhodes# Please read the comments in the targets section below, you
195135446Strhodes# should be able to use the pre-* or post-* targets/scripts
196135446Strhodes# (which are available for every stage except checksum) or
197135446Strhodes# override the do-* targets to do pretty much anything you want.
198193149Sdougb#
199193149Sdougb# NEVER override the "regular" targets unless you want to open
200170222Sdougb# a major can of worms.
201135446Strhodes
202135446Strhodes.if exists(${.CURDIR}/../Makefile.inc)
203135446Strhodes.include "${.CURDIR}/../Makefile.inc"
204135446Strhodes.endif
205135446Strhodes
206193149Sdougb# Support for an encapsulation in /usr/src - these are essentially simplied ports
207170222Sdougb# and have a number of defaults we can presume right off the bat.
208135446Strhodes.if defined(SRC_ENCAPSULATION)
209135446Strhodes.if exists (${.CURDIR}/obj)
210135446StrhodesWRKDIR=${.CURDIR}/obj
211135446Strhodes.else
212135446StrhodesNO_WRKDIR=			yes
213135446Strhodes.endif
214135446Strhodes
215193149Sdougb# Disable things that should be disabled for encapsulations.
216170222SdougbNO_PACKAGE=			yes
217135446StrhodesNO_MTREE=			yes
218135446StrhodesNO_FETCH=			yes
219135446StrhodesNO_PKG_REGISTER=	yes
220135446Strhodesdescribe:
221135446Strhodes	@${DO_NADA}
222135446Strhodes
223135446Strhodes# Finally, give us working obj and cleandir targets to make us more compatible
224193149Sdougb# with "traditional" /usr/src ports.
225170222Sdougb.if !target(obj)
226135446Strhodes.if defined(NOOBJ)
227135446Strhodesobj:
228135446Strhodes	@${DO_NADA}
229135446Strhodes.else
230135446Strhodesobj:
231135446Strhodes	@cd ${.CURDIR}; rm -rf obj; here=`pwd`; \
232193149Sdougb		dest=/usr/obj`echo $$here | sed 's,^/usr/src,,'`; ${ECHO} "$$here -> $$dest"; \
233135446Strhodes		ln -s $$dest obj; if test -d /usr/obj -a ! -d $$dest; then mkdir -p $$dest; fi
234135446Strhodes.endif
235135446Strhodes.endif
236135446Strhodes
237135446Strhodes.if !target(cleandir)
238135446Strhodes.if defined(NOCLEANDIR)
239135446Strhodescleandir:
240135446Strhodes	@${DO_NADA}
241170222Sdougb.else
242135446Strhodescleandir: clean
243135446Strhodes	@if [ "${WRKDIR}" != "${.CURDIR}" ]; then ${RM} -rf ${WRKDIR}/; fi
244135446Strhodes	@rm -f ${.CURDIR}/obj
245193149Sdougb.endif
246193149Sdougb.endif
247193149Sdougb
248193149Sdougb.endif
249193149Sdougb
250135446Strhodes# These need to be absolute since we don't know how deep in the ports
251135446Strhodes# tree we are and thus can't go relative.  They can, of course, be overridden
252193149Sdougb# by individual Makefiles.
253193149SdougbPORTSDIR?=		${DESTDIR}/usr/ports
254193149SdougbLOCALBASE?=		/usr/local
255135446StrhodesX11BASE?=		/usr/X11R6
256135446StrhodesDISTDIR?=		${PORTSDIR}/distfiles/${DIST_SUBDIR}
257193149SdougbPACKAGES?=		${PORTSDIR}/packages
258193149SdougbTEMPLATES?=		${PORTSDIR}/templates
259135446Strhodes.if !defined(NO_WRKDIR)
260193149SdougbWRKDIR?=		${.CURDIR}/work
261193149Sdougb.else
262135446StrhodesWRKDIR?=		${.CURDIR}
263135446Strhodes.endif
264193149Sdougb.if defined(NO_WRKSUBDIR)
265193149SdougbWRKSRC?=		${WRKDIR}
266135446Strhodes.else
267135446StrhodesWRKSRC?=		${WRKDIR}/${DISTNAME}
268135446Strhodes.endif
269135446StrhodesPATCHDIR?=		${.CURDIR}/patches
270170222SdougbSCRIPTDIR?=		${.CURDIR}/scripts
271135446StrhodesFILESDIR?=		${.CURDIR}/files
272135446StrhodesPKGDIR?=		${.CURDIR}/pkg
273135446Strhodes.if defined(USE_IMAKE) || defined(USE_X11)
274193149SdougbPREFIX?=		${X11BASE}
275193149Sdougb.else
276193149SdougbPREFIX?=		${LOCALBASE}
277193149Sdougb.endif
278193149Sdougb# The following 4 lines should go away as soon as the ports are all updated
279193149Sdougb.if defined(EXEC_DEPENDS)
280135446StrhodesBUILD_DEPENDS+=	${EXEC_DEPENDS}
281135446StrhodesRUN_DEPENDS+=	${EXEC_DEPENDS}
282193149Sdougb.endif
283193149Sdougb.if defined(USE_GMAKE)
284135446StrhodesBUILD_DEPENDS+=               gmake:${PORTSDIR}/devel/gmake
285135446Strhodes.endif
286193149Sdougb
287135446Strhodes.if exists(${PORTSDIR}/../Makefile.inc)
288193149Sdougb.include "${PORTSDIR}/../Makefile.inc"
289193149Sdougb.endif
290135446Strhodes
291193149Sdougb# Don't change these!!!  These names are built into the _TARGET_USE macro,
292193149Sdougb# there is no way to refer to them cleanly from within the macro AFAIK.
293193149SdougbEXTRACT_COOKIE?=	${WRKDIR}/.extract_done
294135446StrhodesCONFIGURE_COOKIE?=	${WRKDIR}/.configure_done
295193149SdougbINSTALL_COOKIE?=	${WRKDIR}/.install_done
296193149SdougbBUILD_COOKIE?=		${WRKDIR}/.build_done
297135446StrhodesPATCH_COOKIE?=		${WRKDIR}/.patch_done
298193149SdougbPACKAGE_COOKIE?=	${WRKDIR}/.package_done
299193149Sdougb
300135446Strhodes# How to do nothing.  Override if you, for some strange reason, would rather
301135446Strhodes# do something.
302193149SdougbDO_NADA?=		/usr/bin/true
303193149Sdougb
304193149Sdougb# Miscellaneous overridable commands:
305193149SdougbGMAKE?=			gmake
306135446StrhodesXMKMF?=			xmkmf -a
307135446StrhodesMD5?=			/sbin/md5
308135446StrhodesMD5_FILE?=		${FILESDIR}/md5
309135446Strhodes
310135446StrhodesMAKE_FLAGS?=	-f
311170222SdougbMAKEFILE?=		Makefile
312135446StrhodesMAKE_ENV+=		PREFIX=${PREFIX} LOCALBASE=${LOCALBASE} X11BASE=${X11BASE} MOTIFLIB="${MOTIFLIB}" CFLAGS="${CFLAGS}"
313135446Strhodes
314135446StrhodesNCFTP?=			/usr/bin/ncftp
315193149SdougbNCFTPFLAGS?=	-N
316193149Sdougb
317193149SdougbTOUCH?=			/usr/bin/touch
318135446StrhodesTOUCH_FLAGS?=	-f
319135446Strhodes
320193149SdougbPATCH?=			/usr/bin/patch
321135446StrhodesPATCH_STRIP?=	-p0
322193149SdougbPATCH_DIST_STRIP?=	-p0
323193149Sdougb.if defined(PATCH_DEBUG)
324135446StrhodesPATCH_ARGS?=	-d ${WRKSRC} -E ${PATCH_STRIP}
325193149SdougbPATCH_DIST_ARGS?=	-d ${WRKSRC} -E ${PATCH_DIST_STRIP}
326193149Sdougb.else
327193149SdougbPATCH_ARGS?=	-d ${WRKSRC} --forward --quiet -E ${PATCH_STRIP}
328135446StrhodesPATCH_DIST_ARGS?=	-d ${WRKSRC} --forward --quiet -E ${PATCH_DIST_STRIP}
329193149Sdougb.endif
330193149Sdougb.if defined(BATCH)
331193149SdougbPATCH_ARGS+=		--batch
332135446StrhodesPATCH_DIST_ARGS+=	--batch
333193149Sdougb.endif
334193149Sdougb
335135446Strhodes.if defined(PATCH_CHECK_ONLY)
336135446StrhodesPATCH_ARGS+=	-C
337193149SdougbPATCH_DIST_ARGS+=	-C
338193149Sdougb.endif
339193149Sdougb
340135446StrhodesEXTRACT_CMD?=	/usr/bin/tar
341135446StrhodesEXTRACT_SUFX?=	.tar.gz
342135446Strhodes# Backwards compatability.
343135446Strhodes.if defined(EXTRACT_ARGS)
344135446StrhodesEXTRACT_BEFORE_ARGS?=   ${EXTRACT_ARGS}
345170222Sdougb.else
346135446StrhodesEXTRACT_BEFORE_ARGS?=   -xzf
347135446Strhodes.endif
348135446Strhodes
349193149Sdougb# Figure out where the local mtree file is
350170222Sdougb.if !defined(MTREE_LOCAL) && exists(/etc/mtree/BSD.local.dist)
351193149SdougbMTREE_LOCAL=	/etc/mtree/BSD.local.dist
352135446Strhodes.endif
353170222SdougbMTREE_CMD?=	/usr/sbin/mtree
354170222SdougbMTREE_ARGS?=	-U -f ${MTREE_LOCAL} -d -e -p
355135446Strhodes.if defined(USE_X11) || defined(USE_IMAKE) || !defined(MTREE_LOCAL)
356135446StrhodesNO_MTREE=	yes
357193149Sdougb.endif
358193149Sdougb
359193149Sdougb# The user can override the NO_PACKAGE by specifying this from
360135446Strhodes# the make command line
361135446Strhodes.if defined(FORCE_PACKAGE)
362193149Sdougb.undef NO_PACKAGE
363135446Strhodes.endif
364193149Sdougb
365193149SdougbPKG_CMD?=		/usr/sbin/pkg_create
366135446Strhodes.if !defined(PKG_ARGS)
367193149SdougbPKG_ARGS=		-v -c ${PKGDIR}/COMMENT -d ${PKGDIR}/DESCR -f ${PKGDIR}/PLIST -p ${PREFIX} -P "`${MAKE} package-depends|sort|uniq`"
368193149Sdougb.if exists(${PKGDIR}/INSTALL)
369193149SdougbPKG_ARGS+=		-i ${PKGDIR}/INSTALL
370135446Strhodes.endif
371193149Sdougb.if exists(${PKGDIR}/DEINSTALL)
372193149SdougbPKG_ARGS+=		-k ${PKGDIR}/DEINSTALL
373135446Strhodes.endif
374135446Strhodes.if exists(${PKGDIR}/REQ)
375193149SdougbPKG_ARGS+=		-r ${PKGDIR}/REQ
376193149Sdougb.endif
377193149Sdougb.if !defined(NO_MTREE) && defined(MTREE_LOCAL)
378193149SdougbPKG_ARGS+=		-m ${MTREE_LOCAL}
379135446Strhodes.endif
380135446Strhodes.endif
381135446StrhodesPKG_SUFX?=		.tgz
382135446Strhodes# where pkg_add records its dirty deeds.
383135446StrhodesPKG_DBDIR?=		/var/db/pkg
384135446Strhodes
385135446Strhodes# shared/dynamic motif libs
386170222Sdougb.if defined(HAVE_MOTIF)
387135446Strhodes.if defined(MOTIF_STATIC)
388135446StrhodesMOTIFLIB?=	${X11BASE}/lib/libXm.a
389135446Strhodes.else
390193149SdougbMOTIFLIB?=	-L${X11BASE}/lib -lXm
391193149Sdougb.endif
392193149Sdougb.endif
393135446Strhodes
394193149SdougbECHO?=		/bin/echo
395193149SdougbCAT+=		/bin/cat
396193149SdougbCP?=		/bin/cp
397193149SdougbSETENV?=	/usr/bin/env
398135446StrhodesRM?=		/bin/rm
399193149SdougbMKDIR?=		/bin/mkdir
400193149SdougbGZCAT?=		/usr/bin/gzcat
401193149SdougbBASENAME?=	/usr/bin/basename
402193149SdougbSED?=		/usr/bin/sed
403193149SdougbCAT?=		/bin/cat
404193149SdougbGREP?=		/usr/bin/grep
405193149SdougbAWK?=		/usr/bin/awk
406135446Strhodes
407193149Sdougb# Used to print all the '===>' style prompts - override this to turn them off.
408193149SdougbECHO_MSG?=		${ECHO}
409135446Strhodes
410193149SdougbALL_TARGET?=		all
411193149SdougbINSTALL_TARGET?=	install
412193149Sdougb
413193149Sdougb# If the user has this set, go to the FreeBSD respository for everything.
414193149Sdougb.if defined(MASTER_SITE_FREEBSD)
415193149SdougbMASTER_SITE_OVERRIDE=  ftp://ftp.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/
416135446Strhodes.endif
417193149Sdougb
418193149Sdougb# I guess we're in the master distribution business! :)  As we gain mirror
419193149Sdougb# sites for distfiles, add them to this list.
420193149Sdougb.if !defined(MASTER_SITE_OVERRIDE)
421193149SdougbMASTER_SITES+=	ftp://ftp.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/
422135446StrhodesPATCH_SITES+=	ftp://ftp.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/
423193149Sdougb.else
424135446StrhodesMASTER_SITES?=	# to avoid "variable MASTER_SITES recursive" error
425135446StrhodesMASTER_SITES:=	${MASTER_SITE_OVERRIDE} ${MASTER_SITES}
426193149SdougbPATCH_SITES:=	${MASTER_SITE_OVERRIDE} ${PATCH_SITES}
427193149Sdougb.endif
428193149Sdougb
429193149Sdougb# Derived names so that they're easily overridable.
430193149SdougbDISTFILES?=		${DISTNAME}${EXTRACT_SUFX}
431193149SdougbPKGNAME?=		${DISTNAME}
432193149Sdougb
433193149Sdougb# This is what is actually going to be extracted, and is overridable
434193149Sdougb#  by user.
435193149SdougbEXTRACT_ONLY?=	${DISTFILES}
436135446Strhodes
437135446Strhodes# Documentation
438193149SdougbMAINTAINER?=	ports@FreeBSD.ORG
439193149SdougbCATEGORIES?=	orphans
440193149Sdougb
441193149Sdougb# Note this has to start with a capital letter (or more accurately, it
442193149Sdougb#  shouldn't match "[a-z]*"), see the target "delete-package-links" below.
443135446StrhodesPKGREPOSITORYSUBDIR?=	All
444135446StrhodesPKGREPOSITORY?=		${PACKAGES}/${PKGREPOSITORYSUBDIR}
445193149Sdougb.if exists(${PACKAGES})
446135446StrhodesPKGFILE?=		${PKGREPOSITORY}/${PKGNAME}${PKG_SUFX}
447193149Sdougb.else
448170222SdougbPKGFILE?=		${PKGNAME}${PKG_SUFX}
449193149Sdougb.endif
450170222Sdougb
451193149SdougbCONFIGURE_SCRIPT?=	configure
452193149Sdougb
453170222Sdougb.if defined(GNU_CONFIGURE)
454193149SdougbCONFIGURE_ARGS+=	--prefix=${PREFIX}
455135446StrhodesHAS_CONFIGURE=		yes
456193149Sdougb.endif
457170222Sdougb
458135446Strhodes.MAIN: all
459193149Sdougb
460170222Sdougb################################################################
461193149Sdougb# Many ways to disable a port.
462193149Sdougb#
463135446Strhodes# If we're in BATCH mode and the port is interactive, or we're
464193149Sdougb# in interactive mode and the port is non-interactive, skip all
465193149Sdougb# the important targets.  The reason we have two modes is that
466135446Strhodes# one might want to leave a build in BATCH mode running
467193149Sdougb# overnight, then come back in the morning and do _only_ the
468170222Sdougb# interactive ones that required your intervention.
469135446Strhodes#
470193149Sdougb# Don't attempt to build ports that require Motif if you don't
471170222Sdougb# have Motif.
472193149Sdougb#
473135446Strhodes# Ignore ports that can't be resold if building for a CDROM.
474193149Sdougb#
475135446Strhodes# Don't build a port if it's restricted and we don't want to get
476193149Sdougb# into that.
477170222Sdougb#
478135446Strhodes# Don't build a port if it's broken.
479135446Strhodes################################################################
480193149Sdougb
481193149Sdougb.if (defined(IS_INTERACTIVE) && defined(BATCH)) || \
482193149Sdougb	(!defined(IS_INTERACTIVE) && defined(INTERACTIVE)) || \
483193149Sdougb	(defined(REQUIRES_MOTIF) && !defined(HAVE_MOTIF)) || \
484135446Strhodes	(defined(NO_CDROM) && defined(FOR_CDROM)) || \
485135446Strhodes	(defined(RESTRICTED) && defined(NO_RESTRICTED)) || \
486135446Strhodes	defined(BROKEN)
487135446StrhodesIGNORE=	yes
488170222Sdougb.endif
489135446Strhodes
490135446Strhodes.if defined(IGNORE)
491135446Strhodesall:
492193149Sdougb	@${DO_NADA}
493135446Strhodesbuild:
494135446Strhodes	@${DO_NADA}
495135446Strhodesinstall:
496193149Sdougb	@${DO_NADA}
497193149Sdougbfetch:
498135446Strhodes	@${DO_NADA}
499135446Strhodesconfigure:
500193149Sdougb	@${DO_NADA}
501135446Strhodespackage:
502193149Sdougb	@${DO_NADA}
503193149Sdougb.endif
504135446Strhodes
505193149Sdougb.if defined(ALL_HOOK)
506193149Sdougball:
507193149Sdougb	@cd ${.CURDIR} && ${SETENV} CURDIR=${.CURDIR} DISTNAME=${DISTNAME} \
508193149Sdougb	  DISTDIR=${DISTDIR} WRKDIR=${WRKDIR} WRKSRC=${WRKSRC} \
509135446Strhodes	  PATCHDIR=${PATCHDIR} SCRIPTDIR=${SCRIPTDIR} \
510193149Sdougb	  FILESDIR=${FILESDIR} PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} \
511193149Sdougb	  DEPENDS="${DEPENDS}" BUILD_DEPENDS="${BUILD_DEPENDS}" \
512193149Sdougb	  RUN_DEPENDS="${RUN_DEPENDS}" X11BASE=${X11BASE} \
513135446Strhodes	${ALL_HOOK}
514193149Sdougb.endif
515193149Sdougb
516193149Sdougb.if !target(all)
517193149Sdougball: build
518193149Sdougb.endif
519135446Strhodes
520135446Strhodes.if !defined(IS_DEPENDED_TARGET)
521193149SdougbIS_DEPENDED_TARGET=	install
522193149Sdougb.endif
523193149Sdougb
524193149Sdougb.if !target(is_depended)
525193149Sdougbis_depended:	${IS_DEPENDED_TARGET}
526193149Sdougb.endif
527135446Strhodes
528135446Strhodes################################################################
529135446Strhodes# The following are used to create easy dummy targets for
530135446Strhodes# disabling some bit of default target behavior you don't want.
531170222Sdougb# They still check to see if the target exists, and if so don't
532135446Strhodes# do anything, since you might want to set this globally for a
533135446Strhodes# group of ports in a Makefile.inc, but still be able to
534135446Strhodes# override from an individual Makefile.
535193149Sdougb################################################################
536193149Sdougb
537135446Strhodes# Disable extract
538135446Strhodes.if defined(NO_EXTRACT) && !target(extract)
539193149Sdougbextract: checksum
540193149Sdougb	@${TOUCH} ${TOUCH_FLAGS} ${EXTRACT_COOKIE}
541135446Strhodeschecksum: fetch
542135446Strhodes	@${DO_NADA}
543193149Sdougbmakesum:
544193149Sdougb	@${DO_NADA}
545135446Strhodes.endif
546193149Sdougb
547193149Sdougb# Disable configure
548193149Sdougb.if defined(NO_CONFIGURE) && !target(configure)
549193149Sdougbconfigure: patch
550193149Sdougb	@${TOUCH} ${TOUCH_FLAGS} ${CONFIGURE_COOKIE}
551193149Sdougb.endif
552135446Strhodes
553193149Sdougb# Disable describe
554193149Sdougb.if defined(NO_DESCRIBE) && !target(describe)
555193149Sdougbdescribe:
556135446Strhodes	@${DO_NADA}
557135446Strhodes.endif
558193149Sdougb
559193149Sdougb# Disable build
560193149Sdougb.if defined(NO_BUILD) && !target(build)
561135446Strhodesbuild: configure
562135446Strhodes	@${TOUCH} ${TOUCH_FLAGS} ${BUILD_COOKIE}
563135446Strhodes.endif
564135446Strhodes
565170222Sdougb# Disable package
566135446Strhodes.if defined(NO_PACKAGE) && !target(package)
567135446Strhodespackage:
568135446Strhodes	@${DO_NADA}
569193149Sdougb.endif
570193149Sdougb
571135446Strhodes# Disable install
572193149Sdougb.if defined(NO_INSTALL) && !target(install)
573193149Sdougbinstall: build
574193149Sdougb	@${TOUCH} ${TOUCH_FLAGS} ${INSTALL_COOKIE}
575135446Strhodes.endif
576135446Strhodes
577193149Sdougb# Disable patch
578135446Strhodes.if defined(NO_PATCH) && !target(patch)
579135446Strhodespatch: extract
580193149Sdougb	@${TOUCH} ${TOUCH_FLAGS} ${PATCH_COOKIE}
581135446Strhodes.endif
582193149Sdougb
583193149Sdougb################################################################
584135446Strhodes# More standard targets start here.
585193149Sdougb#
586193149Sdougb# These are the body of the build/install framework.  If you are
587135446Strhodes# not happy with the default actions, and you can't solve it by
588135446Strhodes# adding pre-* or post-* targets/scripts, override these.
589135446Strhodes################################################################
590135446Strhodes
591170222Sdougb# Fetch
592135446Strhodes
593135446Strhodes.if !target(do-fetch)
594135446Strhodesdo-fetch:
595193149Sdougb	@if [ ! -d ${DISTDIR} ]; then ${MKDIR} -p ${DISTDIR}; fi
596193149Sdougb	@(cd ${DISTDIR}; \
597193149Sdougb	 for file in ${DISTFILES}; do \
598135446Strhodes		if [ ! -f $$file -a ! -f `${BASENAME} $$file` ]; then \
599135446Strhodes			if [ -h $$file -o -h `${BASENAME} $$file` ]; then \
600193149Sdougb				${ECHO_MSG} ">> ${DISTDIR}/$$file is a broken symlink."; \
601193149Sdougb				${ECHO_MSG} ">> Perhaps a filesystem (most likely a CD) isn't mounted?"; \
602135446Strhodes				${ECHO_MSG} ">> Please correct this problem and try again."; \
603135446Strhodes				exit 1; \
604193149Sdougb			fi ; \
605193149Sdougb			${ECHO_MSG} ">> $$file doesn't seem to exist on this system."; \
606193149Sdougb			for site in ${MASTER_SITES}; do \
607135446Strhodes			    ${ECHO_MSG} ">> Attempting to fetch from $${site}."; \
608135446Strhodes				(${NCFTP} ${NCFTPFLAGS} $${site}$${file} ${NCFTPTAIL} || true); \
609135446Strhodes				if [ -f $$file -o -f `${BASENAME} $$file` ]; then \
610135446Strhodes					continue 2; \
611135446Strhodes				fi \
612170222Sdougb			done; \
613135446Strhodes			${ECHO_MSG} ">> Couldn't fetch it - please try to retreive this";\
614135446Strhodes			${ECHO_MSG} ">> port manually into ${DISTDIR} and try again."; \
615135446Strhodes			exit 1; \
616193149Sdougb	    fi \
617193149Sdougb	 done)
618135446Strhodes.if defined(PATCHFILES)
619135446Strhodes	@if [ ! -d ${DISTDIR} ]; then ${MKDIR} -p ${DISTDIR}; fi
620193149Sdougb	@(cd ${DISTDIR}; \
621135446Strhodes	 for file in ${PATCHFILES}; do \
622135446Strhodes		if [ ! -f $$file -a ! -f `${BASENAME} $$file` ]; then \
623193149Sdougb			if [ -h $$file -o -h `${BASENAME} $$file` ]; then \
624135446Strhodes				${ECHO_MSG} ">> ${DISTDIR}/$$file is a broken symlink."; \
625135446Strhodes				${ECHO_MSG} ">> Perhaps a filesystem (most likely a CD) isn't mounted?"; \
626135446Strhodes				${ECHO_MSG} ">> Please correct this problem and try again."; \
627135446Strhodes				exit 1; \
628170222Sdougb			fi ; \
629135446Strhodes			${ECHO_MSG} ">> $$file doesn't seem to exist on this system."; \
630135446Strhodes			for site in ${PATCH_SITES}; do \
631135446Strhodes			    ${ECHO_MSG} ">> Attempting to fetch from $${site}."; \
632193149Sdougb				(${NCFTP} ${NCFTPFLAGS} $${site}$${file} ${NCFTPTAIL} || true); \
633135446Strhodes				if [ -f $$file -o -f `${BASENAME} $$file` ]; then \
634135446Strhodes					continue 2; \
635135446Strhodes				fi \
636135446Strhodes			done; \
637135446Strhodes			${ECHO_MSG} ">> Couldn't fetch it - please try to retreive this";\
638135446Strhodes			${ECHO_MSG} ">> port manually into ${DISTDIR} and try again."; \
639170222Sdougb			exit 1; \
640193149Sdougb	    fi \
641143731Sdougb	 done)
642143731Sdougb.endif
643143731Sdougb.endif
644143731Sdougb
645143731Sdougb# Extract
646143731Sdougb
647193149Sdougb.if !target(do-extract)
648135446Strhodesdo-extract:
649193149Sdougb.if !defined(NO_WRKDIR)
650135446Strhodes	@${RM} -rf ${WRKDIR}
651143731Sdougb	@${MKDIR} -p ${WRKDIR}
652193149Sdougb.endif
653135446Strhodes	@for file in ${EXTRACT_ONLY}; do \
654193149Sdougb		if !(cd ${WRKDIR} && ${EXTRACT_CMD} ${EXTRACT_BEFORE_ARGS} ${DISTDIR}/$$file ${EXTRACT_AFTER_ARGS});\
655135446Strhodes		then \
656135446Strhodes			exit 1; \
657193149Sdougb		fi \
658193149Sdougb	done
659135446Strhodes.endif
660135446Strhodes
661135446Strhodes# Patch
662135446Strhodes
663170222Sdougb.if !target(do-patch)
664135446Strhodesdo-patch:
665135446Strhodes.if defined(PATCHFILES)
666135446Strhodes	@${ECHO_MSG} "===>  Applying distribution patches for ${PKGNAME}"
667135446Strhodes.if defined(PATCH_DEBUG)
668193149Sdougb	@(cd ${DISTDIR}; \
669193149Sdougb	  for i in ${PATCHFILES}; do \
670193149Sdougb		${ECHO_MSG} "===>   Applying distribution patch $$i" ; \
671193149Sdougb		case $$i in \
672135446Strhodes			*.Z|*.gz) \
673135446Strhodes				${GZCAT} $$i | ${PATCH} ${PATCH_DIST_ARGS}; \
674135446Strhodes				;; \
675135446Strhodes			*) \
676135446Strhodes				${PATCH} ${PATCH_DIST_ARGS} < $$i; \
677135446Strhodes				;; \
678135446Strhodes		esac; \
679135446Strhodes	  done)
680170222Sdougb.else
681135446Strhodes	@(cd ${DISTDIR}; \
682135446Strhodes	  for i in ${PATCHFILES}; do \
683135446Strhodes		case $$i in \
684193149Sdougb			*.Z|*.gz) \
685135446Strhodes				${GZCAT} $$i | ${PATCH} ${PATCH_DIST_ARGS}; \
686193149Sdougb				;; \
687135446Strhodes			*) \
688135446Strhodes				${PATCH} ${PATCH_DIST_ARGS} < $$i; \
689193149Sdougb				;; \
690135446Strhodes		esac; \
691135446Strhodes	  done)
692135446Strhodes.endif
693135446Strhodes.endif
694170222Sdougb.if defined(PATCH_DEBUG)
695135446Strhodes	@if [ -d ${PATCHDIR} ]; then \
696135446Strhodes		${ECHO_MSG} "===>  Applying FreeBSD patches for ${PKGNAME}" ; \
697135446Strhodes		for i in ${PATCHDIR}/patch-*; do \
698135446Strhodes			case $$i in \
699193149Sdougb				*.orig|*~) \
700135446Strhodes					${ECHO_MSG} "===>   Ignoring patchfile $$i" ; \
701135446Strhodes					;; \
702193149Sdougb				*) \
703135446Strhodes					${ECHO_MSG} "===>   Applying FreeBSD patch $$i" ; \
704135446Strhodes					${PATCH} ${PATCH_ARGS} < $$i; \
705135446Strhodes					;; \
706135446Strhodes			esac; \
707170222Sdougb		done; \
708135446Strhodes	fi
709135446Strhodes.else
710135446Strhodes	@if [ -d ${PATCHDIR} ]; then \
711193149Sdougb		${ECHO_MSG} "===>  Applying FreeBSD patches for ${PKGNAME}" ; \
712193149Sdougb		for i in ${PATCHDIR}/patch-*; do \
713193149Sdougb			case $$i in \
714135446Strhodes				*.orig|*~) \
715135446Strhodes					${ECHO_MSG} "===>   Ignoring patchfile $$i" ; \
716193149Sdougb					;; \
717135446Strhodes				*) \
718135446Strhodes					${PATCH} ${PATCH_ARGS} < $$i; \
719193149Sdougb					;; \
720135446Strhodes			esac; \
721135446Strhodes		done;\
722135446Strhodes	fi
723135446Strhodes.endif
724135446Strhodes.endif
725170222Sdougb
726135446Strhodes# Configure
727135446Strhodes
728135446Strhodes.if !target(do-configure)
729193149Sdougbdo-configure:
730193149Sdougb	@if [ -f ${SCRIPTDIR}/configure ]; then \
731193149Sdougb		cd ${.CURDIR} && ${SETENV} CURDIR=${.CURDIR} DISTDIR=${DISTDIR}\
732135446Strhodes		  WRKDIR=${WRKDIR} WRKSRC=${WRKSRC} PATCHDIR=${PATCHDIR} \
733135446Strhodes		  SCRIPTDIR=${SCRIPTDIR} FILESDIR=${FILESDIR} \
734193149Sdougb		  PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} DEPENDS="${DEPENDS}" \
735135446Strhodes		  X11BASE=${X11BASE} /bin/sh ${SCRIPTDIR}/configure; \
736135446Strhodes	fi
737193149Sdougb.if defined(HAS_CONFIGURE)
738193149Sdougb	@(cd ${WRKSRC} && CC="${CC}" ac_cv_path_CC="${CC}" CFLAGS="${CFLAGS}" \
739193149Sdougb	    INSTALL="/usr/bin/install -c -o ${BINOWN} -g ${BINGRP}" \
740193149Sdougb	    INSTALL_PROGRAM="/usr/bin/install ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE}" \
741193149Sdougb	    ${CONFIGURE_ENV} ./${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS})
742135446Strhodes.endif
743193149Sdougb.if defined(USE_IMAKE)
744193149Sdougb	@(cd ${WRKSRC} && ${XMKMF})
745193149Sdougb.endif
746193149Sdougb.endif
747193149Sdougb
748193149Sdougb# Build
749193149Sdougb
750135446Strhodes.if !target(do-build)
751193149Sdougbdo-build:
752193149Sdougb.if defined(USE_GMAKE)
753193149Sdougb	@(cd ${WRKSRC}; ${SETENV} ${MAKE_ENV} ${GMAKE} ${MAKE_FLAGS} ${MAKEFILE} ${ALL_TARGET})
754135446Strhodes.else defined(USE_GMAKE)
755135446Strhodes	@(cd ${WRKSRC}; ${SETENV} ${MAKE_ENV} ${MAKE} ${MAKE_FLAGS} ${MAKEFILE} ${ALL_TARGET})
756135446Strhodes.endif
757193149Sdougb.endif
758193149Sdougb
759193149Sdougb# Install
760135446Strhodes
761135446Strhodes.if !target(do-install)
762135446Strhodesdo-install:
763135446Strhodes.if defined(USE_GMAKE)
764135446Strhodes	@(cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} ${GMAKE} ${MAKE_FLAGS} ${MAKEFILE} ${INSTALL_TARGET})
765170222Sdougb.if defined(USE_IMAKE) && !defined(NO_INSTALL_MANPAGES)
766135446Strhodes	@(cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} ${GMAKE} ${MAKE_FLAGS} ${MAKEFILE} install.man)
767135446Strhodes.endif
768135446Strhodes.else defined(USE_GMAKE)
769193149Sdougb	@(cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} ${MAKE} ${MAKE_FLAGS} ${MAKEFILE} ${INSTALL_TARGET})
770193149Sdougb.if defined(USE_IMAKE) && !defined(NO_INSTALL_MANPAGES)
771193149Sdougb	@(cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} ${MAKE} ${MAKE_FLAGS} ${MAKEFILE} install.man)
772135446Strhodes.endif
773135446Strhodes.endif
774193149Sdougb.endif
775193149Sdougb
776135446Strhodes# Package
777135446Strhodes
778193149Sdougb.if !target(do-package)
779135446Strhodesdo-package:
780193149Sdougb	@if [ -e ${PKGDIR}/PLIST ]; then \
781193149Sdougb		${ECHO_MSG} "===>  Building package for ${PKGNAME}"; \
782135446Strhodes		if [ -d ${PACKAGES} ]; then \
783135446Strhodes			if [ ! -d ${PKGREPOSITORY} ]; then \
784193149Sdougb				if ! ${MKDIR} -p ${PKGREPOSITORY}; then \
785193149Sdougb					${ECHO_MSG} ">> Can't create directory ${PKGREPOSITORY}."; \
786135446Strhodes					exit 1; \
787135446Strhodes				fi; \
788135446Strhodes			fi; \
789135446Strhodes		fi; \
790135446Strhodes		if ${PKG_CMD} ${PKG_ARGS} ${PKGFILE}; then \
791170222Sdougb			if [ -d ${PACKAGES} ]; then \
792135446Strhodes				${MAKE} ${.MAKEFLAGS} package-links; \
793135446Strhodes			fi; \
794135446Strhodes		else \
795193149Sdougb			${MAKE} ${.MAKEFLAGS} delete-package; \
796193149Sdougb			exit 1; \
797135446Strhodes		fi; \
798135446Strhodes	fi
799193149Sdougb.endif
800135446Strhodes
801193149Sdougb# Some support rules for do-package
802193149Sdougb
803135446Strhodes.if !target(package-links)
804135446Strhodespackage-links:
805193149Sdougb	@${MAKE} ${.MAKEFLAGS} delete-package-links
806193149Sdougb	@for cat in ${CATEGORIES}; do \
807193149Sdougb		if [ ! -d ${PACKAGES}/$$cat ]; then \
808135446Strhodes			if ! ${MKDIR} -p ${PACKAGES}/$$cat; then \
809135446Strhodes				${ECHO_MSG} ">> Can't create directory ${PACKAGES}/$$cat."; \
810135446Strhodes				exit 1; \
811135446Strhodes			fi; \
812135446Strhodes		fi; \
813170222Sdougb		ln -s ../${PKGREPOSITORYSUBDIR}/${PKGNAME}${PKG_SUFX} ${PACKAGES}/$$cat; \
814135446Strhodes	done;
815135446Strhodes.endif
816135446Strhodes
817135446Strhodes.if !target(delete-package-links)
818193149Sdougbdelete-package-links:
819193149Sdougb	@${RM} -f ${PACKAGES}/[a-z]*/${PKGNAME}${PKG_SUFX};
820193149Sdougb.endif
821193149Sdougb
822193149Sdougb.if !target(delete-package)
823135446Strhodesdelete-package:
824135446Strhodes	@${MAKE} ${.MAKEFLAGS} delete-package-links
825193149Sdougb	@${RM} -f ${PKGFILE}
826135446Strhodes.endif
827193149Sdougb
828193149Sdougb################################################################
829135446Strhodes# This is the "generic" port target, actually a macro used from the
830193149Sdougb# six main targets.  See below for more.
831135446Strhodes################################################################
832135446Strhodes
833193149Sdougb_PORT_USE: .USE
834193149Sdougb.if make(real-fetch)
835193149Sdougb	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} fetch-depends
836193149Sdougb.endif
837193149Sdougb.if make(real-extract)
838135446Strhodes	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} build-depends lib-depends misc-depends
839135446Strhodes.endif
840135446Strhodes.if make(real-install)
841135446Strhodes	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} run-depends
842135446Strhodes.endif
843170222Sdougb.if make(real-install)
844135446Strhodes.if !defined(NO_MTREE)
845135446Strhodes	@if [ `id -u` = 0 ]; then \
846135446Strhodes		${MTREE_CMD} ${MTREE_ARGS} ${PREFIX}/; \
847135446Strhodes	else \
848193149Sdougb		${ECHO_MSG} "Warning: not superuser, can't run mtree."; \
849193149Sdougb		${ECHO_MSG} "Become root and try again to ensure correct permissions."; \
850193149Sdougb	fi
851193149Sdougb.endif
852193149Sdougb.endif
853135446Strhodes	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} ${.TARGET:S/^real-/pre-/}
854135446Strhodes	@if [ -f ${SCRIPTDIR}/${.TARGET:S/^real-/pre-/} ]; then \
855193149Sdougb		cd ${.CURDIR} && ${SETENV} CURDIR=${.CURDIR} DISTDIR=${DISTDIR} WRKDIR=${WRKDIR} \
856135446Strhodes		  WRKSRC=${WRKSRC} PATCHDIR=${PATCHDIR} SCRIPTDIR=${SCRIPTDIR} \
857193149Sdougb		  FILESDIR=${FILESDIR} PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} \
858193149Sdougb		  DEPENDS="${DEPENDS}" X11BASE=${X11BASE} \
859135446Strhodes			/bin/sh ${SCRIPTDIR}/${.TARGET:S/^real-/pre-/}; \
860193149Sdougb	fi
861135446Strhodes	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} ${.TARGET:S/^real-/do-/}
862135446Strhodes	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} ${.TARGET:S/^real-/post-/}
863193149Sdougb	@if [ -f ${SCRIPTDIR}/${.TARGET:S/^real-/post-/} ]; then \
864193149Sdougb		cd ${.CURDIR} && ${SETENV} CURDIR=${.CURDIR} DISTDIR=${DISTDIR}\
865193149Sdougb		  WRKDIR=${WRKDIR} WRKSRC=${WRKSRC} PATCHDIR=${PATCHDIR} \
866193149Sdougb		  SCRIPTDIR=${SCRIPTDIR} FILESDIR=${FILESDIR} \
867193149Sdougb		  PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} DEPENDS="${DEPENDS}" \
868135446Strhodes		  X11BASE=${X11BASE} \
869135446Strhodes			/bin/sh ${SCRIPTDIR}/${.TARGET:S/^real-/post-/}; \
870193149Sdougb	fi
871193149Sdougb.if make(real-install)  && !defined(NO_PKG_REGISTER)
872193149Sdougb	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} fake-pkg
873193149Sdougb.endif
874193149Sdougb.if !make(real-fetch) \
875193149Sdougb	&& (!make(real-patch) || !defined(PATCH_CHECK_ONLY)) \
876193149Sdougb	&& (!make(real-package) || !defined(PACKAGE_NOINSTALL))
877193149Sdougb	@${TOUCH} ${TOUCH_FLAGS} ${WRKDIR}/.${.TARGET:S/^real-//}_done
878193149Sdougb.endif
879193149Sdougb
880193149Sdougb################################################################
881193149Sdougb# Skeleton targets start here
882193149Sdougb# 
883170222Sdougb# You shouldn't have to change these.  Either add the pre-* or
884170222Sdougb# post-* targets/scripts or redefine the do-* targets.  These
885170222Sdougb# targets don't do anything other than checking for cookies and
886170222Sdougb# call the necessary targets/scripts.
887170222Sdougb################################################################
888170222Sdougb
889170222Sdougb.if !target(fetch)
890170222Sdougbfetch:
891193149Sdougb	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} real-fetch
892193149Sdougb.endif
893193149Sdougb
894193149Sdougb.if !target(extract)
895193149Sdougbextract: checksum ${EXTRACT_COOKIE}
896193149Sdougb.endif
897193149Sdougb
898193149Sdougb.if !target(patch)
899193149Sdougbpatch: extract ${PATCH_COOKIE}
900170222Sdougb.endif
901193149Sdougb
902193149Sdougb.if !target(configure)
903170222Sdougbconfigure: patch ${CONFIGURE_COOKIE}
904193149Sdougb.endif
905193149Sdougb
906193149Sdougb.if !target(build)
907170222Sdougbbuild: configure ${BUILD_COOKIE}
908193149Sdougb.endif
909193149Sdougb
910193149Sdougb.if !target(install)
911170222Sdougbinstall: build ${INSTALL_COOKIE}
912193149Sdougb.endif
913170222Sdougb
914193149Sdougb.if !target(package)
915224092Sdougbpackage: install ${PACKAGE_COOKIE}
916193149Sdougb.endif
917193149Sdougb
918193149Sdougb${EXTRACT_COOKIE}:
919193149Sdougb	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} real-extract
920193149Sdougb${PATCH_COOKIE}:
921193149Sdougb	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} real-patch
922193149Sdougb${CONFIGURE_COOKIE}:
923193149Sdougb	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} real-configure
924193149Sdougb${BUILD_COOKIE}:
925193149Sdougb	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} real-build
926193149Sdougb${INSTALL_COOKIE}:
927193149Sdougb	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} real-install
928193149Sdougb${PACKAGE_COOKIE}:
929193149Sdougb	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} real-package
930193149Sdougb
931193149Sdougb# And call the macros
932193149Sdougb
933193149Sdougbreal-fetch: _PORT_USE
934193149Sdougbreal-extract: _PORT_USE
935193149Sdougb	@${ECHO_MSG} "===>  Extracting for ${PKGNAME}"
936193149Sdougbreal-patch: _PORT_USE
937193149Sdougb	@${ECHO_MSG} "===>  Patching for ${PKGNAME}"
938170222Sdougbreal-configure: _PORT_USE
939170222Sdougb	@${ECHO_MSG} "===>  Configuring for ${PKGNAME}"
940135446Strhodesreal-build: _PORT_USE
941135446Strhodes	@${ECHO_MSG} "===>  Building for ${PKGNAME}"
942135446Strhodesreal-install: _PORT_USE
943	@${ECHO_MSG} "===>  Installing for ${PKGNAME}"
944real-package: _PORT_USE
945
946# Empty pre-* and post-* targets, note we can't use .if !target()
947# in the _PORT_USE macro
948
949.for name in fetch extract patch configure build install package
950
951.if !target(pre-${name})
952pre-${name}:
953	@${DO_NADA}
954.endif
955
956.if !target(post-${name})
957post-${name}:
958	@${DO_NADA}
959.endif
960
961.endfor
962
963# Checkpatch
964#
965# Special target to verify patches
966
967.if !target(checkpatch)
968checkpatch:
969	@cd ${.CURDIR} && ${MAKE} PATCH_CHECK_ONLY=yes ${.MAKEFLAGS} patch
970.endif
971
972# Reinstall
973#
974# Special target to re-run install
975
976.if !target(reinstall)
977reinstall: pre-reinstall install
978
979pre-reinstall:
980	@${RM} -f ${INSTALL_COOKIE}
981	@${RM} -f ${PACKAGE_COOKIE}
982.endif
983
984################################################################
985# Some more targets supplied for users' convenience
986################################################################
987
988# Cleaning up
989
990.if !target(pre-clean)
991pre-clean:
992	@${DO_NADA}
993.endif
994
995.if !target(clean)
996clean: pre-clean
997	@${ECHO_MSG} "===>  Cleaning for ${PKGNAME}"
998.if !defined(NO_WRKDIR) && !exists(${.CURDIR}/obj)
999	${RM} -rf ${WRKDIR}
1000.else
1001	@${RM} -f ${WRKDIR}/.*_done
1002.endif
1003.endif
1004
1005# Prints out a list of files to fetch (useful to do a batch fetch)
1006
1007.if !target(fetch-list)
1008fetch-list:
1009	@if [ ! -d ${DISTDIR} ]; then ${MKDIR} -p ${DISTDIR}; fi
1010	@(cd ${DISTDIR}; \
1011	 for file in ${DISTFILES}; do \
1012		if [ ! -f $$file -a ! -f `${BASENAME} $$file` ]; then \
1013			for site in ${MASTER_SITES}; do \
1014				${ECHO} -n ${NCFTP} ${NCFTPFLAGS} $${site}$${file} "${NCFTPTAIL}" '||' ; \
1015					break; \
1016			done; \
1017			${ECHO} "echo $${file} not fetched" ; \
1018		fi \
1019	done)
1020.if defined(PATCHFILES)
1021	@(cd ${DISTDIR}; \
1022	 for file in ${PATCHFILES}; do \
1023		if [ ! -f $$file -a ! -f `${BASENAME} $$file` ]; then \
1024			for site in ${PATCH_SITES}; do \
1025				${ECHO} -n ${NCFTP} ${NCFTPFLAGS} $${site}$${file} "${NCFTPTAIL}" '||' ; \
1026					break; \
1027			done; \
1028			${ECHO} "echo $${file} not fetched" ; \
1029		fi \
1030	 done)
1031.endif
1032.endif
1033
1034# Checksumming utilities
1035
1036.if !target(makesum)
1037makesum: fetch
1038	@if [ ! -d ${FILESDIR} ]; then ${MKDIR} -p ${FILESDIR}; fi
1039	@if [ -f ${MD5_FILE} ]; then ${RM} -f ${MD5_FILE}; fi
1040	@(cd ${DISTDIR}; \
1041	 for file in ${DISTFILES} ${PATCHFILES}; do \
1042		${MD5} $$file >> ${MD5_FILE}; \
1043	 done)
1044.endif
1045
1046.if !target(checksum)
1047checksum: fetch
1048	@if [ ! -f ${MD5_FILE} ]; then \
1049		${ECHO_MSG} ">> No MD5 checksum file."; \
1050	else \
1051		(cd ${DISTDIR}; OK=""; \
1052		  for file in ${DISTFILES} ${PATCHFILES}; do \
1053			CKSUM=`${MD5} < $$file`; \
1054			CKSUM2=`${GREP} "($$file)" ${MD5_FILE} | ${AWK} '{print $$4}'`; \
1055			if [ "$$CKSUM2" = "" ]; then \
1056				${ECHO_MSG} ">> No checksum recorded for $$file"; \
1057				OK="false"; \
1058			elif [ "$$CKSUM" != "$$CKSUM2" ]; then \
1059				${ECHO_MSG} ">> Checksum mismatch for $$file"; \
1060				exit 1; \
1061			fi; \
1062		  done; \
1063		  if [ "$$OK" = "" ]; then \
1064			${ECHO_MSG} "Checksums OK."; \
1065		  else \
1066			${ECHO_MSG} "Checksums OK for files that have them."; \
1067		  fi) ; \
1068	fi
1069.endif
1070
1071################################################################
1072# The special package-building targets
1073# You probably won't need to touch these
1074################################################################
1075
1076# Nobody should want to override this unless PKGNAME is simply bogus.
1077
1078.if !target(package-name)
1079package-name:
1080	@${ECHO} ${PKGNAME}
1081.endif
1082
1083# Show (recursively) all the packages this package depends on.
1084
1085.if !target(package-depends)
1086package-depends:
1087	@for i in ${RUN_DEPENDS} ${LIB_DEPENDS} ${DEPENDS}; do \
1088		dir=`${ECHO} $$i | ${SED} -e 's/.*://'`; \
1089		(cd $$dir ; ${MAKE} package-name package-depends); \
1090	done
1091.endif
1092
1093# Build a package but don't check the package cookie
1094
1095.if !target(repackage)
1096repackage: pre-repackage package
1097
1098pre-repackage:
1099	@${RM} -f ${PACKAGE_COOKIE}
1100.endif
1101
1102# Build a package but don't check the cookie for installation, also don't
1103# install package cookie
1104
1105.if !target(package-noinstall)
1106package-noinstall:
1107	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} PACKAGE_NOINSTALL=yes real-package
1108.endif
1109
1110################################################################
1111# Dependency checking
1112################################################################
1113
1114.if !target(depends)
1115depends: lib-depends misc-depends
1116	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} fetch-depends
1117	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} build-depends
1118	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} run-depends
1119
1120.if make(fetch-depends)
1121DEPENDS_TMP+=	${FETCH_DEPENDS}
1122.endif
1123
1124.if make(build-depends)
1125DEPENDS_TMP+=	${BUILD_DEPENDS}
1126.endif
1127
1128.if make(run-depends)
1129DEPENDS_TMP+=	${RUN_DEPENDS}
1130.endif
1131
1132_DEPENDS_USE:	.USE
1133.if defined(DEPENDS_TMP)
1134.if defined(NO_DEPENDS)
1135# Just print out messages
1136	@for i in ${DEPENDS_TMP}; do \
1137		prog=`${ECHO} $$i | ${SED} -e 's/:.*//'`; \
1138		dir=`${ECHO} $$i | ${SED} -e 's/.*://'`; \
1139		if expr "$$prog" : \\/ >/dev/null; then \
1140			${ECHO_MSG} "===>  ${PKGNAME} depends on file:  $$prog ($$dir)"; \
1141		else \
1142			${ECHO_MSG} "===>  ${PKGNAME} depends on executable:  $$prog ($$dir)"; \
1143		fi; \
1144	done
1145.else
1146	@for i in ${DEPENDS_TMP}; do \
1147		prog=`${ECHO} $$i | ${SED} -e 's/:.*//'`; \
1148		dir=`${ECHO} $$i | ${SED} -e 's/.*://'`; \
1149		if expr "$$prog" : \\/ >/dev/null; then \
1150			if [ -e "$$prog" ]; then \
1151				${ECHO_MSG} "===>  ${PKGNAME} depends on file: $$prog - found"; \
1152				notfound=0; \
1153			else \
1154				${ECHO_MSG} "===>  ${PKGNAME} depends on file: $$prog - not found"; \
1155				notfound=1; \
1156			fi; \
1157		else \
1158			if which -s "$$prog"; then \
1159				${ECHO_MSG} "===>  ${PKGNAME} depends on executable: $$prog - found"; \
1160				notfound=0; \
1161			else \
1162				${ECHO_MSG} "===>  ${PKGNAME} depends on executable: $$prog - not found"; \
1163				notfound=1; \
1164			fi; \
1165		fi; \
1166		if [ $$notfound != 0 ]; then \
1167			${ECHO_MSG} "===>  Verifying build for $$prog in $$dir"; \
1168			if [ ! -d "$$dir" ]; then \
1169				${ECHO_MSG} ">> No directory for $$prog.  Skipping.."; \
1170			else \
1171				(cd $$dir; ${MAKE} ${.MAKEFLAGS} is_depended) ; \
1172				${ECHO_MSG} "===>  Returning to build of ${PKGNAME}"; \
1173			fi; \
1174		fi; \
1175	done
1176.endif
1177.else
1178	@${DO_NADA}
1179.endif
1180
1181fetch-depends:	_DEPENDS_USE
1182build-depends:	_DEPENDS_USE
1183run-depends:	_DEPENDS_USE
1184
1185lib-depends:
1186.if defined(LIB_DEPENDS)
1187.if defined(NO_DEPENDS)
1188# Just print out messages
1189	@for i in ${LIB_DEPENDS}; do \
1190		lib=`${ECHO} $$i | ${SED} -e 's/:.*//'`; \
1191		dir=`${ECHO} $$i | ${SED} -e 's/.*://'`; \
1192		${ECHO_MSG} "===>  ${PKGNAME} depends on shared library:  $$lib ($$dir)"; \
1193	done
1194.else
1195	@for i in ${LIB_DEPENDS}; do \
1196		lib=`${ECHO} $$i | ${SED} -e 's/:.*//'`; \
1197		dir=`${ECHO} $$i | ${SED} -e 's/.*://'`; \
1198		if /sbin/ldconfig -r | ${GREP} -q -e "-l$$lib"; then \
1199			${ECHO_MSG} "===>  ${PKGNAME} depends on shared library: $$lib - found"; \
1200		else \
1201			${ECHO_MSG} "===>  ${PKGNAME} depends on shared library: $$lib - not found"; \
1202			${ECHO_MSG} "===>  Verifying build for $$lib in $$dir"; \
1203			if [ ! -d "$$dir" ]; then \
1204				${ECHO_MSG} ">> No directory for $$lib.  Skipping.."; \
1205			else \
1206				(cd $$dir; ${MAKE} ${.MAKEFLAGS} is_depended) ; \
1207				${ECHO_MSG} "===>  Returning to build of ${PKGNAME}"; \
1208			fi; \
1209		fi; \
1210	done
1211.endif
1212.else
1213	@${DO_NADA}
1214.endif
1215
1216misc-depends:
1217.if defined(DEPENDS)
1218	@${ECHO_MSG} "===>  ${PKGNAME} depends on:  ${DEPENDS}"
1219.if !defined(NO_DEPENDS)
1220	@for i in ${DEPENDS}; do \
1221		${ECHO_MSG} "===>  Verifying build for $$i"; \
1222		if [ ! -d $$i ]; then \
1223			${ECHO_MSG} ">> No directory for $$i.  Skipping.."; \
1224		else \
1225			(cd $$i; ${MAKE} ${.MAKEFLAGS} is_depended) ; \
1226		fi \
1227	done
1228	@${ECHO_MSG} "===>  Returning to build of ${PKGNAME}"
1229.endif
1230.else
1231	@${DO_NADA}
1232.endif
1233
1234.endif
1235
1236.if !target(depends-list)
1237depends-list:
1238	@for i in ${FETCH_DEPENDS} ${BUILD_DEPENDS} ${LIB_DEPENDS} ${DEPENDS}; do \
1239		dir=`/bin/echo $$i | /usr/bin/sed -e 's/.*://'`; \
1240		(cd $$dir ; ${MAKE} package-name depends-list); \
1241	done
1242.endif
1243
1244################################################################
1245# Everything after here are internal targets and really
1246# shouldn't be touched by anybody but the release engineers.
1247################################################################
1248
1249# This target generates an index entry suitable for aggregation into
1250# a large index.  Format is:
1251#
1252# distribution-name|port-path|installation-prefix|comment| \
1253#  description-file|maintainer|categories|build deps|run deps
1254#
1255.if !target(describe)
1256describe:
1257	@${ECHO} -n "${PKGNAME}|${.CURDIR}/${PKGNAME}|"
1258	@${ECHO} -n "${PREFIX}|"
1259	@if [ -f ${PKGDIR}/COMMENT ]; then \
1260		${ECHO} -n "`${CAT} ${PKGDIR}/COMMENT`"; \
1261	else \
1262		${ECHO} -n "** No Description"; \
1263	fi
1264	@if [ -f ${PKGDIR}/DESCR ]; then \
1265		${ECHO} -n "|${PKGDIR}/DESCR"; \
1266	else \
1267		${ECHO} -n "|/dev/null"; \
1268	fi
1269	@${ECHO} -n "|${MAINTAINER}|${CATEGORIES}|"
1270	@cd ${.CURDIR} && ${ECHO} -n `make depends-list|sort|uniq`
1271	@${ECHO} -n "|"
1272	@cd ${.CURDIR} && ${ECHO} -n `make package-depends|sort|uniq`
1273	@${ECHO} ""
1274.endif
1275
1276.if !target(readmes)
1277readmes:	readme
1278.endif
1279
1280.if !target(readme)
1281readme:
1282	@rm -f README.html
1283	@cd ${.CURDIR} && make README.html
1284.endif
1285
1286README.html:
1287	@${ECHO_MSG} "===>  Creating README.html for ${PKGNAME}"
1288	@${CAT} ${TEMPLATES}/README.port | \
1289		${SED} -e 's%%PORT%%'`${ECHO} ${.CURDIR} | ${SED} -e 's.*/\([^/]*/[^/]*\)$$\1'`'g' \
1290			-e 's%%PKG%%${PKGNAME}g' \
1291			-e '/%%COMMENT%%/r${PKGDIR}/COMMENT' \
1292			-e '/%%COMMENT%%/d' \
1293			-e 's%%BUILD_DEPENDS%%'"`${MAKE} print-depends-list`"'' \
1294			-e 's%%RUN_DEPENDS%%'"`${MAKE} print-package-depends`"'' \
1295		>> $@
1296
1297.if !target(print-depends-list)
1298print-depends-list:
1299.if defined(FETCH_DEPENDS) || defined(BUILD_DEPENDS) || \
1300	defined(LIB_DEPENDS) || defined(DEPENDS)
1301	@${ECHO} -n 'This port requires package(s) "'
1302	@${ECHO} -n `make depends-list | sort | uniq`
1303	@${ECHO} '" to build.'
1304.endif
1305.endif
1306
1307.if !target(print-package-depends)
1308print-package-depends:
1309.if defined(RUN_DEPENDS) || defined(LIB_DEPENDS) || defined(DEPENDS)
1310	@${ECHO} -n 'This port requires package(s) "'
1311	@${ECHO} -n `make package-depends | sort | uniq`
1312	@${ECHO} '" to run.'
1313.endif
1314.endif
1315
1316# Fake installation of package so that user can pkg_delete it later.
1317# Also, make sure that an installed port is recognized correctly in
1318# accordance to the @pkgdep directive in the packing lists
1319
1320.if !target(fake-pkg)
1321fake-pkg:
1322	@if [ ! -f ${PKGDIR}/PLIST -o ! -f ${PKGDIR}/COMMENT -o ! -f ${PKGDIR}/DESCR ]; then ${ECHO} "** Missing package files for ${PKGNAME} - installation not recorded."; exit 1; fi
1323	@if [ ! -d ${PKG_DBDIR} ]; then ${RM} -f ${PKG_DBDIR}; ${MKDIR} -p ${PKG_DBDIR}; fi
1324.if defined(FORCE_PKG_REGISTER)
1325	@${RM} -rf ${PKG_DBDIR}/${PKGNAME}
1326.endif
1327	@if [ ! -d ${PKG_DBDIR}/${PKGNAME} ]; then \
1328		${ECHO_MSG} "===>  Registering installation for ${PKGNAME}"; \
1329		${MKDIR} -p ${PKG_DBDIR}/${PKGNAME}; \
1330		${PKG_CMD} ${PKG_ARGS} -O ${PKGFILE} > ${PKG_DBDIR}/${PKGNAME}/+CONTENTS; \
1331		${CP} ${PKGDIR}/DESCR ${PKG_DBDIR}/${PKGNAME}/+DESC; \
1332		${CP} ${PKGDIR}/COMMENT ${PKG_DBDIR}/${PKGNAME}/+COMMENT; \
1333		if [ -f ${PKGDIR}/INSTALL ]; then \
1334			${CP} ${PKGDIR}/INSTALL ${PKG_DBDIR}/${PKGNAME}/+INSTALL; \
1335		fi; \
1336		if [ -f ${PKGDIR}/DEINSTALL ]; then \
1337			${CP} ${PKGDIR}/DEINSTALL ${PKG_DBDIR}/${PKGNAME}/+DEINSTALL; \
1338		fi; \
1339		if [ -f ${PKGDIR}/REQ ]; then \
1340			${CP} ${PKGDIR}/REQ ${PKG_DBDIR}/${PKGNAME}/+REQ; \
1341		fi; \
1342	else \
1343		${ECHO_MSG} "===> ${PKGNAME} is already installed - perhaps an older version?"; \
1344		${ECHO_MSG} "     If so, you may wish to \`\`pkg_delete ${PKGNAME}'' and install"; \
1345		${ECHO_MSG} "     this port again by \`\`make reinstall'' to upgrade it properly."; \
1346	fi
1347.endif
1348
1349# Depend is generally meaningless for arbitrary ports, but if someone wants
1350# one they can override this.  This is just to catch people who've gotten into
1351# the habit of typing `make depend all install' as a matter of course.
1352#
1353.if !target(depend)
1354depend:
1355.endif
1356
1357# Same goes for tags
1358.if !target(tags)
1359tags:
1360.endif
1361