bsd.port.mk revision 17464
1193326Sed#-*- mode: Fundamental; tab-width: 4; -*-
2193326Sed#
3193326Sed#	bsd.port.mk - 940820 Jordan K. Hubbard.
4193326Sed#	This file is in the public domain.
5193326Sed#
6193326Sed# $Id: bsd.port.mk,v 1.217 1996/07/27 11:54:30 andreas Exp $
7193326Sed#
8193326Sed# Please view me with 4 column tabs!
9193326Sed
10193326Sed
11193326Sed# Supported Variables and their behaviors:
12193326Sed#
13193326Sed# Variables that typically apply to all ports:
14193326Sed# 
15200583Srdivacky# PORTSDIR		- The root of the ports tree (default: /usr/ports).
16199482Srdivacky# DISTDIR 		- Where to get gzip'd, tarballed copies of original sources
17193326Sed#				  (default: ${PORTSDIR}/distfiles/${DIST_SUBDIR}).
18193326Sed# PREFIX		- Where to install things in general (default: /usr/local).
19207619Srdivacky# MASTER_SITES	- Primary location(s) for distribution files if not found
20198092Srdivacky#				  locally (default:
21193326Sed#				   ftp://ftp.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/)
22207619Srdivacky# PATCH_SITES	- Primary location(s) for distribution patch files
23207619Srdivacky#				  (see PATCHFILES below) if not found locally (default:
24200583Srdivacky#				   ftp://ftp.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/)
25193326Sed#
26199482Srdivacky# MASTER_SITE_OVERRIDE - If set, override the MASTER_SITES setting with this
27199482Srdivacky#				  value.
28198092Srdivacky# MASTER_SITE_FREEBSD - If set, only use the FreeBSD master repository for
29193326Sed#				  MASTER_SITES.
30193326Sed# PACKAGES		- A top level directory where all packages go (rather than
31193326Sed#				  going locally to each port). (default: ${PORTSDIR}/packages).
32198092Srdivacky# GMAKE			- Set to path of GNU make if not in $PATH (default: gmake).
33193326Sed# XMKMF			- Set to path of `xmkmf' if not in $PATH (default: xmkmf -a ).
34193326Sed# MAINTAINER	- The e-mail address of the contact person for this port
35193326Sed#				  (default: ports@FreeBSD.ORG).
36193326Sed# CATEGORIES	- A list of descriptive categories into which this port falls
37193326Sed#				  (default: orphans).
38193326Sed#
39193326Sed# Variables that typically apply to an individual port.  Non-Boolean
40193326Sed# variables without defaults are *mandatory*.
41193326Sed# 
42193326Sed#
43193326Sed# WRKDIR 		- A temporary working directory that gets *clobbered* on clean
44193326Sed#				  (default: ${.CURDIR}/work).
45193326Sed# WRKSRC		- A subdirectory of ${WRKDIR} where the distribution actually
46199990Srdivacky#				  unpacks to.  (Default: ${WRKDIR}/${DISTNAME} unless
47193326Sed#				  NO_WRKSUBDIR is set, in which case simply ${WRKDIR}).
48193326Sed# DISTNAME		- Name of port or distribution.
49193326Sed# DISTFILES		- Name(s) of archive file(s) containing distribution
50193326Sed#				  (default: ${DISTNAME}${EXTRACT_SUFX}).
51193326Sed# PATCHFILES	- Name(s) of additional files that contain distribution
52198092Srdivacky#				  patches (default: none).  make will look for them at
53193326Sed#				  PATCH_SITES (see above).  They will automatically be
54193326Sed#				  uncompressed before patching if the names end with
55193326Sed#				  ".gz" or ".Z".
56193326Sed# DIST_SUBDIR	- Suffix to ${DISTDIR} (see above).  If set, all ${DISTFILES} 
57193326Sed#				  and ${PATCHFILES} will be put in this subdirectory of
58193326Sed#				  ${DISTDIR}.  Also they will be fetched in this subdirectory 
59193326Sed#				  from FreeBSD mirror sites.
60193326Sed# PKGNAME		- Name of the package file to create if the DISTNAME 
61193326Sed#				  isn't really relevant for the port/package
62193326Sed#				  (default: ${DISTNAME}).
63198092Srdivacky# EXTRACT_ONLY	- If defined, a subset of ${DISTFILES} you want to
64193326Sed#			  	  actually extract.
65193326Sed# PATCHDIR 		- A directory containing any additional patches you made
66193326Sed#				  to port this software to FreeBSD (default:
67193326Sed#				  ${.CURDIR}/patches)
68193326Sed# SCRIPTDIR 	- A directory containing any auxiliary scripts
69193326Sed#				  (default: ${.CURDIR}/scripts)
70193326Sed# FILESDIR 		- A directory containing any miscellaneous additional files.
71193326Sed#				  (default: ${.CURDIR}/files)
72193326Sed# PKGDIR 		- A direction containing any package creation files.
73193326Sed#				  (default: ${.CURDIR}/pkg)
74193326Sed# PKG_DBDIR		- Where package installation is recorded (default: /var/db/pkg)
75193326Sed# FORCE_PKG_REGISTER - If set, it will overwrite any existing package
76193326Sed#				  registration information in ${PKG_DBDIR}/${PKGNAME}.
77193326Sed# NO_MTREE		- If set, will not invoke mtree from bsd.port.mk from
78193326Sed#				  the "install" target.  This is the default if
79193326Sed#				  USE_IMAKE or USE_X11 is set.
80193326Sed#
81193326Sed# NO_BUILD		- Use a dummy (do-nothing) build target.
82193326Sed# NO_CONFIGURE	- Use a dummy (do-nothing) configure target.
83198092Srdivacky# NO_CDROM		- Use dummy (do-nothing) targets if FOR_CDROM is set.
84193326Sed# NO_DESCRIBE	- Use a dummy (do-nothing) describe target.
85193326Sed# NO_EXTRACT	- Use a dummy (do-nothing) extract target.
86193326Sed# NO_INSTALL	- Use a dummy (do-nothing) install target.
87193326Sed# NO_PACKAGE	- Use a dummy (do-nothing) package target.
88193326Sed# NO_PKG_REGISTER - Don't register a port install as a package.
89193326Sed# NO_WRKSUBDIR	- Assume port unpacks directly into ${WRKDIR}.
90193326Sed# NO_WRKDIR		- There's no work directory at all; port does this someplace
91198092Srdivacky#				  else.
92193326Sed# NO_DEPENDS	- Don't verify build of dependencies.
93193326Sed# BROKEN		- Port is broken.
94193326Sed# RESTRICTED	- Port is restricted.  Set this string to the reason why.
95193326Sed# USE_GMAKE		- Says that the port uses gmake.
96193326Sed# USE_IMAKE		- Says that the port uses imake.
97193326Sed# USE_X11		- Says that the port uses X11.
98193326Sed# NO_INSTALL_MANPAGES - For imake ports that don't like the install.man
99193326Sed#						target.
100193326Sed# HAS_CONFIGURE	- Says that the port has its own configure script.
101193326Sed# GNU_CONFIGURE	- Set if you are using GNU configure (optional).
102193326Sed# CONFIGURE_SCRIPT - Name of configure script, defaults to 'configure'.
103193326Sed# CONFIGURE_ARGS - Pass these args to configure if ${HAS_CONFIGURE} is set.
104193326Sed# CONFIGURE_ENV  - Pass these env (shell-like) to configure if
105193326Sed#				  ${HAS_CONFIGURE} is set.
106193326Sed# IS_INTERACTIVE - Set this if your port needs to interact with the user
107193326Sed#				  during a build.  User can then decide to skip this port by
108193326Sed#				  setting ${BATCH}, or compiling only the interactive ports
109193326Sed#				  by setting ${INTERACTIVE}.
110198092Srdivacky# FETCH_DEPENDS - A list of "prog:dir" pairs of other ports this
111198092Srdivacky#				  package depends in the "fetch" stage.  "prog" is the
112198092Srdivacky#				  name of an executable.  make will search your $PATH
113198092Srdivacky#				  for it and go into "dir" to do a "make all install"
114198092Srdivacky#				  if it's not found.
115198092Srdivacky# BUILD_DEPENDS - A list of "prog:dir" pairs of other ports this
116198092Srdivacky#				  package depends to build (between the "extract"
117198092Srdivacky#				  and "build" stages, inclusive).  "prog" is the name
118198092Srdivacky#				  of an executable.  make will search your $PATH for
119198092Srdivacky#				  it and go into "dir" to do a "make all install" if
120198092Srdivacky#				  it's not found.
121198092Srdivacky# RUN_DEPENDS	- A list of "prog:dir" pairs of other ports this package
122198092Srdivacky#				  depends to run.  "prog" is the name of an
123198092Srdivacky#				  executable.  make will search your $PATH for it and
124198092Srdivacky#				  go into "dir" to do a "make all install" if it's not
125198092Srdivacky#				  found.  This will be build during the "install" stage
126198092Srdivacky#				  and its name will be put into the package as well.
127201361Srdivacky# LIB_DEPENDS	- A list of "lib:dir" pairs of other ports this package
128201361Srdivacky#				  depends on.  "lib" is the name of a shared library.
129201361Srdivacky#				  make will use "ldconfig -r" to search for the
130201361Srdivacky#				  library.  Note that lib can be any regular expression,
131201361Srdivacky#				  and you need two backslashes in front of dots (.) to
132201361Srdivacky#				  supress its special meaning (e.g., use
133201361Srdivacky#				  "foo\\.2\\.:${PORTSDIR}/utils/foo" to match "libfoo.2.*").
134198092Srdivacky# DEPENDS		- A list of other ports this package depends on being
135201361Srdivacky#				  made first.  Use this for things that don't fall into
136198092Srdivacky#				  the above two categories.
137201361Srdivacky# EXTRACT_CMD	- Command for extracting archive (default: tar).
138198092Srdivacky# EXTRACT_SUFX	- Suffix for archive names (default: .tar.gz).
139198092Srdivacky# EXTRACT_BEFORE_ARGS -
140198092Srdivacky#				  Arguments to ${EXTRACT_CMD} before filename
141198092Srdivacky#				  (default: -C ${WRKDIR} -xzf).
142198092Srdivacky# EXTRACT_AFTER_ARGS -
143198092Srdivacky#				  Arguments to ${EXTRACT_CMD} following filename
144198092Srdivacky#				  (default: none).
145198092Srdivacky#
146198092Srdivacky# FETCH_CMD		  - Full path to ftp/http fetch command if not in $PATH
147193326Sed#				  (default: /usr/bin/fetch).
148193326Sed# FETCH_BEFORE_ARGS -
149193326Sed#				  Arguments to ${FETCH_CMD} before filename (default: none).
150193326Sed# FETCH_AFTER_ARGS -
151198092Srdivacky#				  Arguments to ${FETCH_CMD} following filename (default: none).
152193326Sed#
153194711Sed# Motif support:
154194711Sed#
155198092Srdivacky# REQUIRES_MOTIF - Set this in your port if it requires Motif.  It will  be
156193326Sed#				  built only if HAVE_MOTIF is set.
157194179Sed# HAVE_MOTIF	- If set, means system has Motif.  Typically set in
158194179Sed#				  /etc/make.conf.
159193326Sed# MOTIF_STATIC	- If set, link libXm statically; otherwise, link it
160193326Sed#				  dynamically.
161193326Sed#
162193326Sed# Variables to change if you want a special behavior:
163193326Sed#
164193326Sed# ECHO_MSG		- Used to print all the '===>' style prompts - override this
165193326Sed#				  to turn them off (default: /bin/echo).
166193326Sed# IS_DEPENDED_TARGET -
167193326Sed#				  The target to execute when a port is called as a
168193326Sed#				  dependency (default: install).  E.g., "make fetch
169193326Sed#				  IS_DEPENDED_TARGET=fetch" will fetch all the distfiles,
170193326Sed#				  including those of dependencies, without actually building
171193326Sed#				  any of them).
172193326Sed#
173193326Sed# 
174193326Sed# Default targets and their behaviors:
175193326Sed#
176198092Srdivacky# fetch			- Retrieves ${DISTFILES} (and ${PATCHFILES} if defined)
177193326Sed#				  into ${DISTDIR} as necessary.
178193326Sed# fetch-list	- Show list of files that would be retrieved by fetch
179193326Sed# extract		- Unpacks ${DISTFILES} into ${WRKDIR}.
180193326Sed# patch			- Apply any provided patches to the source.
181193326Sed# configure		- Runs either GNU configure, one or more local configure
182193326Sed#				  scripts or nothing, depending on what's available.
183198092Srdivacky# build			- Actually compile the sources.
184194179Sed# install		- Install the results of a build.
185194179Sed# reinstall		- Install the results of a build, ignoring "already installed"
186194711Sed#				  flag.
187194711Sed# package		- Create a package from an _installed_ port.
188198092Srdivacky# describe		- Try to generate a one-line description for each port for
189193326Sed#				  use in INDEX files and the like.
190193326Sed# checkpatch	- Do a "patch -C" instead of a "patch".  Note that it may
191193326Sed#				  give incorrect results if multiple patches deal with
192198092Srdivacky#				  the same file.
193194179Sed# checksum		- Use files/md5 to ensure that your distfiles are valid.
194193326Sed# makesum		- Generate files/md5 (only do this for your own ports!).
195193326Sed#
196193326Sed# Default sequence for "all" is:  fetch checksum extract patch configure build
197193326Sed#
198193326Sed# Please read the comments in the targets section below, you
199194711Sed# should be able to use the pre-* or post-* targets/scripts
200194711Sed# (which are available for every stage except checksum) or
201198092Srdivacky# override the do-* targets to do pretty much anything you want.
202194179Sed#
203198092Srdivacky# NEVER override the "regular" targets unless you want to open
204194179Sed# a major can of worms.
205198092Srdivacky
206194179Sed.if exists(${.CURDIR}/../Makefile.inc)
207193326Sed.include "${.CURDIR}/../Makefile.inc"
208193326Sed.endif
209193326Sed
210193326Sed
211193326Sed# These need to be absolute since we don't know how deep in the ports
212193326Sed# tree we are and thus can't go relative.  They can, of course, be overridden
213193326Sed# by individual Makefiles.
214193326SedPORTSDIR?=		${DESTDIR}/usr/ports
215193326SedLOCALBASE?=		/usr/local
216193326SedX11BASE?=		/usr/X11R6
217193326SedDISTDIR?=		${PORTSDIR}/distfiles/${DIST_SUBDIR}
218193326SedPACKAGES?=		${PORTSDIR}/packages
219193326SedTEMPLATES?=		${PORTSDIR}/templates
220193326Sed.if !defined(NO_WRKDIR)
221193326SedWRKDIR?=		${.CURDIR}/work
222193326Sed.else
223193326SedWRKDIR?=		${.CURDIR}
224193326Sed.endif
225193326Sed.if defined(NO_WRKSUBDIR)
226193326SedWRKSRC?=		${WRKDIR}
227193326Sed.else
228193326SedWRKSRC?=		${WRKDIR}/${DISTNAME}
229193326Sed.endif
230193326SedPATCHDIR?=		${.CURDIR}/patches
231193326SedSCRIPTDIR?=		${.CURDIR}/scripts
232193326SedFILESDIR?=		${.CURDIR}/files
233193326SedPKGDIR?=		${.CURDIR}/pkg
234193326Sed.if defined(USE_IMAKE) || defined(USE_X11)
235193326SedPREFIX?=		${X11BASE}
236193326Sed.else
237193326SedPREFIX?=		${LOCALBASE}
238193326Sed.endif
239193326Sed# The following 4 lines should go away as soon as the ports are all updated
240193326Sed.if defined(EXEC_DEPENDS)
241193326SedBUILD_DEPENDS+=	${EXEC_DEPENDS}
242193326SedRUN_DEPENDS+=	${EXEC_DEPENDS}
243193326Sed.endif
244193326Sed.if defined(USE_GMAKE)
245193326SedBUILD_DEPENDS+=               gmake:${PORTSDIR}/devel/gmake
246193326Sed.endif
247193326Sed
248193326Sed.if exists(${PORTSDIR}/../Makefile.inc)
249193326Sed.include "${PORTSDIR}/../Makefile.inc"
250193326Sed.endif
251193326Sed
252193326Sed# Don't change these!!!  These names are built into the _TARGET_USE macro,
253193326Sed# there is no way to refer to them cleanly from within the macro AFAIK.
254193326SedEXTRACT_COOKIE?=	${WRKDIR}/.extract_done
255193326SedCONFIGURE_COOKIE?=	${WRKDIR}/.configure_done
256193326SedINSTALL_COOKIE?=	${WRKDIR}/.install_done
257193326SedBUILD_COOKIE?=		${WRKDIR}/.build_done
258193326SedPATCH_COOKIE?=		${WRKDIR}/.patch_done
259193326SedPACKAGE_COOKIE?=	${WRKDIR}/.package_done
260193326Sed
261193326Sed# How to do nothing.  Override if you, for some strange reason, would rather
262193326Sed# do something.
263198092SrdivackyDO_NADA?=		/usr/bin/true
264198092Srdivacky
265198092Srdivacky# Miscellaneous overridable commands:
266198092SrdivackyGMAKE?=			gmake
267198092SrdivackyXMKMF?=			xmkmf -a
268198092SrdivackyMD5?=			/sbin/md5
269193326SedMD5_FILE?=		${FILESDIR}/md5
270193326Sed
271193326SedMAKE_FLAGS?=	-f
272193326SedMAKEFILE?=		Makefile
273198092SrdivackyMAKE_ENV+=		PREFIX=${PREFIX} LOCALBASE=${LOCALBASE} X11BASE=${X11BASE} MOTIFLIB="${MOTIFLIB}" CFLAGS="${CFLAGS}"
274202379Srdivacky
275202379SrdivackyFETCH_CMD?=		/usr/bin/fetch
276202379Srdivacky
277202379SrdivackyTOUCH?=			/usr/bin/touch
278202379SrdivackyTOUCH_FLAGS?=	-f
279202379Srdivacky
280202379SrdivackyPATCH?=			/usr/bin/patch
281202379SrdivackyPATCH_STRIP?=	-p0
282202379SrdivackyPATCH_DIST_STRIP?=	-p0
283198092Srdivacky.if defined(PATCH_DEBUG)
284193326SedPATCH_ARGS?=	-d ${WRKSRC} -E ${PATCH_STRIP}
285202379SrdivackyPATCH_DIST_ARGS?=	-d ${WRKSRC} -E ${PATCH_DIST_STRIP}
286198092Srdivacky.else
287198092SrdivackyPATCH_ARGS?=	-d ${WRKSRC} --forward --quiet -E ${PATCH_STRIP}
288198092SrdivackyPATCH_DIST_ARGS?=	-d ${WRKSRC} --forward --quiet -E ${PATCH_DIST_STRIP}
289198092Srdivacky.endif
290198092Srdivacky.if defined(BATCH)
291198092SrdivackyPATCH_ARGS+=		--batch
292198092SrdivackyPATCH_DIST_ARGS+=	--batch
293198092Srdivacky.endif
294198092Srdivacky
295198092Srdivacky.if defined(PATCH_CHECK_ONLY)
296198092SrdivackyPATCH_ARGS+=	-C
297198092SrdivackyPATCH_DIST_ARGS+=	-C
298198092Srdivacky.endif
299193326Sed
300198092SrdivackyEXTRACT_CMD?=	/usr/bin/tar
301207619SrdivackyEXTRACT_SUFX?=	.tar.gz
302207619Srdivacky# Backwards compatability.
303207619Srdivacky.if defined(EXTRACT_ARGS)
304205219SrdivackyEXTRACT_BEFORE_ARGS?=   ${EXTRACT_ARGS}
305198092Srdivacky.else
306198092SrdivackyEXTRACT_BEFORE_ARGS?=   -xzf
307198092Srdivacky.endif
308198092Srdivacky
309207619Srdivacky# Figure out where the local mtree file is
310198092Srdivacky.if !defined(MTREE_LOCAL) && exists(/etc/mtree/BSD.local.dist)
311198092SrdivackyMTREE_LOCAL=	/etc/mtree/BSD.local.dist
312198092Srdivacky.endif
313198092SrdivackyMTREE_CMD?=	/usr/sbin/mtree
314198092SrdivackyMTREE_ARGS?=	-U -f ${MTREE_LOCAL} -d -e -p
315198092Srdivacky.if defined(USE_X11) || defined(USE_IMAKE) || !defined(MTREE_LOCAL)
316198092SrdivackyNO_MTREE=	yes
317198092Srdivacky.endif
318198092Srdivacky
319198092Srdivacky# The user can override the NO_PACKAGE by specifying this from
320198092Srdivacky# the make command line
321198092Srdivacky.if defined(FORCE_PACKAGE)
322198092Srdivacky.undef NO_PACKAGE
323198092Srdivacky.endif
324198092Srdivacky
325198092SrdivackyPKG_CMD?=		/usr/sbin/pkg_create
326198092Srdivacky.if !defined(PKG_ARGS)
327198092SrdivackyPKG_ARGS=		-v -c ${PKGDIR}/COMMENT -d ${PKGDIR}/DESCR -f ${PKGDIR}/PLIST -p ${PREFIX} -P "`${MAKE} package-depends|sort|uniq`"
328198092Srdivacky.if exists(${PKGDIR}/INSTALL)
329198092SrdivackyPKG_ARGS+=		-i ${PKGDIR}/INSTALL
330198092Srdivacky.endif
331198092Srdivacky.if exists(${PKGDIR}/DEINSTALL)
332198092SrdivackyPKG_ARGS+=		-k ${PKGDIR}/DEINSTALL
333198092Srdivacky.endif
334198092Srdivacky.if exists(${PKGDIR}/REQ)
335198092SrdivackyPKG_ARGS+=		-r ${PKGDIR}/REQ
336198092Srdivacky.endif
337198092Srdivacky.if !defined(NO_MTREE) && defined(MTREE_LOCAL)
338198092SrdivackyPKG_ARGS+=		-m ${MTREE_LOCAL}
339198092Srdivacky.endif
340198092Srdivacky.endif
341198092SrdivackyPKG_SUFX?=		.tgz
342198092Srdivacky# where pkg_add records its dirty deeds.
343198092SrdivackyPKG_DBDIR?=		/var/db/pkg
344198092Srdivacky
345198092Srdivacky# shared/dynamic motif libs
346198092Srdivacky.if defined(HAVE_MOTIF)
347198092Srdivacky.if defined(MOTIF_STATIC)
348198092SrdivackyMOTIFLIB?=	${X11BASE}/lib/libXm.a
349198092Srdivacky.else
350198092SrdivackyMOTIFLIB?=	-L${X11BASE}/lib -lXm
351198092Srdivacky.endif
352198092Srdivacky.endif
353198092Srdivacky
354198092SrdivackyECHO?=		/bin/echo
355198092SrdivackyCAT+=		/bin/cat
356198092SrdivackyCP?=		/bin/cp
357198092SrdivackySETENV?=	/usr/bin/env
358198092SrdivackyRM?=		/bin/rm
359198092SrdivackyMKDIR?=		/bin/mkdir
360193326SedGZCAT?=		/usr/bin/gzcat
361193326SedBASENAME?=	/usr/bin/basename
362193326SedSED?=		/usr/bin/sed
363203955SrdivackyCAT?=		/bin/cat
364195341SedGREP?=		/usr/bin/grep
365195341SedAWK?=		/usr/bin/awk
366193326Sed
367193326Sed# Used to print all the '===>' style prompts - override this to turn them off.
368193326SedECHO_MSG?=		${ECHO}
369193326Sed
370193326SedALL_TARGET?=		all
371193326SedINSTALL_TARGET?=	install
372193326Sed
373193326Sed# If the user has this set, go to the FreeBSD respository for everything.
374193326Sed.if defined(MASTER_SITE_FREEBSD)
375193326SedMASTER_SITE_OVERRIDE=  ftp://ftp.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/
376193326Sed.endif
377193326Sed
378193326Sed# I guess we're in the master distribution business! :)  As we gain mirror
379198092Srdivacky# sites for distfiles, add them to this list.
380193326Sed.if !defined(MASTER_SITE_OVERRIDE)
381193326SedMASTER_SITES+=	ftp://ftp.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/
382193326SedPATCH_SITES+=	ftp://ftp.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/
383193326Sed.else
384193326SedMASTER_SITES?=	# to avoid "variable MASTER_SITES recursive" error
385193326SedMASTER_SITES:=	${MASTER_SITE_OVERRIDE} ${MASTER_SITES}
386193326SedPATCH_SITES:=	${MASTER_SITE_OVERRIDE} ${PATCH_SITES}
387193326Sed.endif
388193326Sed
389193326Sed# Derived names so that they're easily overridable.
390198092SrdivackyDISTFILES?=		${DISTNAME}${EXTRACT_SUFX}
391193326SedPKGNAME?=		${DISTNAME}
392198092Srdivacky
393193326Sed# This is what is actually going to be extracted, and is overridable
394193326Sed#  by user.
395193326SedEXTRACT_ONLY?=	${DISTFILES}
396198092Srdivacky
397193326Sed# Documentation
398193326SedMAINTAINER?=	ports@FreeBSD.ORG
399193326SedCATEGORIES?=	orphans
400198092Srdivacky
401193326Sed# Note this has to start with a capital letter (or more accurately, it
402198092Srdivacky#  shouldn't match "[a-z]*"), see the target "delete-package-links" below.
403193326SedPKGREPOSITORYSUBDIR?=	All
404193326SedPKGREPOSITORY?=		${PACKAGES}/${PKGREPOSITORYSUBDIR}
405193326Sed.if exists(${PACKAGES})
406193326SedPKGFILE?=		${PKGREPOSITORY}/${PKGNAME}${PKG_SUFX}
407193326Sed.else
408193326SedPKGFILE?=		${PKGNAME}${PKG_SUFX}
409193326Sed.endif
410193326Sed
411193326SedCONFIGURE_SCRIPT?=	configure
412193326Sed
413193326Sed.if defined(GNU_CONFIGURE)
414194179SedCONFIGURE_ARGS+=	--prefix=${PREFIX}
415193326SedHAS_CONFIGURE=		yes
416193326Sed.endif
417193326Sed
418193326Sed.MAIN: all
419193326Sed
420193326Sed################################################################
421193326Sed# Many ways to disable a port.
422193326Sed#
423193326Sed# If we're in BATCH mode and the port is interactive, or we're
424193326Sed# in interactive mode and the port is non-interactive, skip all
425193326Sed# the important targets.  The reason we have two modes is that
426193326Sed# one might want to leave a build in BATCH mode running
427193326Sed# overnight, then come back in the morning and do _only_ the
428193326Sed# interactive ones that required your intervention.
429202379Srdivacky#
430202379Srdivacky# Don't attempt to build ports that require Motif if you don't
431193326Sed# have Motif.
432193326Sed#
433198092Srdivacky# Ignore ports that can't be resold if building for a CDROM.
434193326Sed#
435193326Sed# Don't build a port if it's restricted and we don't want to get
436193326Sed# into that.
437193326Sed#
438203955Srdivacky# Don't build a port if it's broken.
439193326Sed################################################################
440193326Sed
441193326Sed.if (defined(IS_INTERACTIVE) && defined(BATCH)) || \
442193326Sed	(!defined(IS_INTERACTIVE) && defined(INTERACTIVE)) || \
443193326Sed	(defined(REQUIRES_MOTIF) && !defined(HAVE_MOTIF)) || \
444198092Srdivacky	(defined(NO_CDROM) && defined(FOR_CDROM)) || \
445193326Sed	(defined(RESTRICTED) && defined(NO_RESTRICTED)) || \
446193326Sed	defined(BROKEN)
447193326SedIGNORE=	yes
448193326Sed.endif
449193326Sed
450193326Sed.if defined(IGNORE)
451193326Sedall:
452198092Srdivacky	@${DO_NADA}
453193326Sedbuild:
454193326Sed	@${DO_NADA}
455193326Sedinstall:
456193326Sed	@${DO_NADA}
457193326Sedfetch:
458193326Sed	@${DO_NADA}
459193326Sedconfigure:
460193326Sed	@${DO_NADA}
461193326Sedpackage:
462193326Sed	@${DO_NADA}
463198092Srdivacky.endif
464193326Sed
465193326Sed.if defined(ALL_HOOK)
466193326Sedall:
467193326Sed	@cd ${.CURDIR} && ${SETENV} CURDIR=${.CURDIR} DISTNAME=${DISTNAME} \
468193326Sed	  DISTDIR=${DISTDIR} WRKDIR=${WRKDIR} WRKSRC=${WRKSRC} \
469193326Sed	  PATCHDIR=${PATCHDIR} SCRIPTDIR=${SCRIPTDIR} \
470193326Sed	  FILESDIR=${FILESDIR} PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} \
471193326Sed	  DEPENDS="${DEPENDS}" BUILD_DEPENDS="${BUILD_DEPENDS}" \
472193326Sed	  RUN_DEPENDS="${RUN_DEPENDS}" X11BASE=${X11BASE} \
473193326Sed	${ALL_HOOK}
474193326Sed.endif
475193326Sed
476193326Sed.if !target(all)
477193326Sedall: build
478193326Sed.endif
479193326Sed
480193326Sed.if !defined(IS_DEPENDED_TARGET)
481193326SedIS_DEPENDED_TARGET=	install
482193326Sed.endif
483198092Srdivacky
484198092Srdivacky.if !target(is_depended)
485198092Srdivackyis_depended:	${IS_DEPENDED_TARGET}
486193326Sed.endif
487193326Sed
488198092Srdivacky################################################################
489198092Srdivacky# The following are used to create easy dummy targets for
490193326Sed# disabling some bit of default target behavior you don't want.
491203955Srdivacky# They still check to see if the target exists, and if so don't
492193326Sed# do anything, since you might want to set this globally for a
493198092Srdivacky# group of ports in a Makefile.inc, but still be able to
494198092Srdivacky# override from an individual Makefile.
495200583Srdivacky################################################################
496199990Srdivacky
497199990Srdivacky# Disable extract
498199990Srdivacky.if defined(NO_EXTRACT) && !target(extract)
499200583Srdivackyextract: checksum
500200583Srdivacky	@${TOUCH} ${TOUCH_FLAGS} ${EXTRACT_COOKIE}
501199990Srdivackychecksum: fetch
502199990Srdivacky	@${DO_NADA}
503193326Sedmakesum:
504200583Srdivacky	@${DO_NADA}
505200583Srdivacky.endif
506200583Srdivacky
507200583Srdivacky# Disable configure
508200583Srdivacky.if defined(NO_CONFIGURE) && !target(configure)
509200583Srdivackyconfigure: patch
510200583Srdivacky	@${TOUCH} ${TOUCH_FLAGS} ${CONFIGURE_COOKIE}
511200583Srdivacky.endif
512200583Srdivacky
513200583Srdivacky# Disable describe
514200583Srdivacky.if defined(NO_DESCRIBE) && !target(describe)
515200583Srdivackydescribe:
516200583Srdivacky	@${DO_NADA}
517200583Srdivacky.endif
518200583Srdivacky
519200583Srdivacky# Disable build
520200583Srdivacky.if defined(NO_BUILD) && !target(build)
521200583Srdivackybuild: configure
522200583Srdivacky	@${TOUCH} ${TOUCH_FLAGS} ${BUILD_COOKIE}
523200583Srdivacky.endif
524200583Srdivacky
525200583Srdivacky# Disable package
526200583Srdivacky.if defined(NO_PACKAGE) && !target(package)
527193326Sedpackage:
528193326Sed	@${DO_NADA}
529193326Sed.endif
530200583Srdivacky
531200583Srdivacky# Disable install
532200583Srdivacky.if defined(NO_INSTALL) && !target(install)
533193326Sedinstall: build
534193326Sed	@${TOUCH} ${TOUCH_FLAGS} ${INSTALL_COOKIE}
535200583Srdivacky.endif
536193326Sed
537193326Sed# Disable patch
538193326Sed.if defined(NO_PATCH) && !target(patch)
539198092Srdivackypatch: extract
540198092Srdivacky	@${TOUCH} ${TOUCH_FLAGS} ${PATCH_COOKIE}
541198092Srdivacky.endif
542198092Srdivacky
543198092Srdivacky################################################################
544198092Srdivacky# More standard targets start here.
545198092Srdivacky#
546198092Srdivacky# These are the body of the build/install framework.  If you are
547198092Srdivacky# not happy with the default actions, and you can't solve it by
548198092Srdivacky# adding pre-* or post-* targets/scripts, override these.
549198092Srdivacky################################################################
550198092Srdivacky
551198092Srdivacky# Fetch
552198092Srdivacky
553193326Sed.if !target(do-fetch)
554193326Seddo-fetch:
555198092Srdivacky	@if [ ! -d ${DISTDIR} ]; then ${MKDIR} -p ${DISTDIR}; fi
556193326Sed	@(cd ${DISTDIR}; \
557200583Srdivacky	 for file in ${DISTFILES}; do \
558198092Srdivacky		if [ ! -f $$file -a ! -f `${BASENAME} $$file` ]; then \
559198092Srdivacky			if [ -h $$file -o -h `${BASENAME} $$file` ]; then \
560198092Srdivacky				${ECHO_MSG} ">> ${DISTDIR}/$$file is a broken symlink."; \
561198092Srdivacky				${ECHO_MSG} ">> Perhaps a filesystem (most likely a CD) isn't mounted?"; \
562198092Srdivacky				${ECHO_MSG} ">> Please correct this problem and try again."; \
563200583Srdivacky				exit 1; \
564198092Srdivacky			fi ; \
565198092Srdivacky			${ECHO_MSG} ">> $$file doesn't seem to exist on this system."; \
566198092Srdivacky			for site in ${MASTER_SITES}; do \
567198092Srdivacky			    ${ECHO_MSG} ">> Attempting to fetch from $${site}."; \
568198092Srdivacky				if ${FETCH_CMD} ${FETCH_BEFORE_ARGS} $${site}$${file} ${FETCH_AFTER_ARGS}; then \
569200583Srdivacky					continue 2; \
570198092Srdivacky				fi \
571193326Sed			done; \
572193326Sed			${ECHO_MSG} ">> Couldn't fetch it - please try to retrieve this";\
573193326Sed			${ECHO_MSG} ">> port manually into ${DISTDIR} and try again."; \
574193326Sed			exit 1; \
575193326Sed	    fi \
576200583Srdivacky	 done)
577198092Srdivacky.if defined(PATCHFILES)
578193326Sed	@if [ ! -d ${DISTDIR} ]; then ${MKDIR} -p ${DISTDIR}; fi
579193326Sed	@(cd ${DISTDIR}; \
580193326Sed	 for file in ${PATCHFILES}; do \
581193326Sed		if [ ! -f $$file -a ! -f `${BASENAME} $$file` ]; then \
582198092Srdivacky			if [ -h $$file -o -h `${BASENAME} $$file` ]; then \
583198092Srdivacky				${ECHO_MSG} ">> ${DISTDIR}/$$file is a broken symlink."; \
584193326Sed				${ECHO_MSG} ">> Perhaps a filesystem (most likely a CD) isn't mounted?"; \
585198092Srdivacky				${ECHO_MSG} ">> Please correct this problem and try again."; \
586193326Sed				exit 1; \
587193326Sed			fi ; \
588193326Sed			${ECHO_MSG} ">> $$file doesn't seem to exist on this system."; \
589194711Sed			for site in ${PATCH_SITES}; do \
590194711Sed			    ${ECHO_MSG} ">> Attempting to fetch from $${site}."; \
591194711Sed				if ${FETCH_CMD} ${FETCH_BEFORE_ARGS} $${site}$${file} ${FETCH_AFTER_ARGS}; then \
592193326Sed					continue 2; \
593204643Srdivacky				fi \
594204643Srdivacky			done; \
595204643Srdivacky			${ECHO_MSG} ">> Couldn't fetch it - please try to retrieve this";\
596204643Srdivacky			${ECHO_MSG} ">> port manually into ${DISTDIR} and try again."; \
597198092Srdivacky			exit 1; \
598193326Sed	    fi \
599193326Sed	 done)
600193326Sed.endif
601193326Sed.endif
602198092Srdivacky
603193326Sed# Extract
604193326Sed
605193326Sed.if !target(do-extract)
606193326Seddo-extract:
607193326Sed.if !defined(NO_WRKDIR)
608193326Sed	@${RM} -rf ${WRKDIR}
609193326Sed	@${MKDIR} -p ${WRKDIR}
610193326Sed.endif
611193326Sed	@for file in ${EXTRACT_ONLY}; do \
612193326Sed		if !(cd ${WRKDIR} && ${EXTRACT_CMD} ${EXTRACT_BEFORE_ARGS} ${DISTDIR}/$$file ${EXTRACT_AFTER_ARGS});\
613193326Sed		then \
614193326Sed			exit 1; \
615193326Sed		fi \
616193326Sed	done
617193326Sed.endif
618193326Sed
619193326Sed# Patch
620193326Sed
621193326Sed.if !target(do-patch)
622193326Seddo-patch:
623198092Srdivacky.if defined(PATCHFILES)
624193326Sed	@${ECHO_MSG} "===>  Applying distribution patches for ${PKGNAME}"
625199482Srdivacky.if defined(PATCH_DEBUG)
626193326Sed	@(cd ${DISTDIR}; \
627193326Sed	  for i in ${PATCHFILES}; do \
628193326Sed		${ECHO_MSG} "===>   Applying distribution patch $$i" ; \
629193326Sed		case $$i in \
630193326Sed			*.Z|*.gz) \
631193326Sed				${GZCAT} $$i | ${PATCH} ${PATCH_DIST_ARGS}; \
632193326Sed				;; \
633193326Sed			*) \
634193326Sed				${PATCH} ${PATCH_DIST_ARGS} < $$i; \
635193326Sed				;; \
636193326Sed		esac; \
637193326Sed	  done)
638198092Srdivacky.else
639193326Sed	@(cd ${DISTDIR}; \
640193326Sed	  for i in ${PATCHFILES}; do \
641193326Sed		case $$i in \
642193326Sed			*.Z|*.gz) \
643193326Sed				${GZCAT} $$i | ${PATCH} ${PATCH_DIST_ARGS}; \
644193326Sed				;; \
645193326Sed			*) \
646193326Sed				${PATCH} ${PATCH_DIST_ARGS} < $$i; \
647193326Sed				;; \
648193326Sed		esac; \
649203955Srdivacky	  done)
650193326Sed.endif
651193326Sed.endif
652193326Sed.if defined(PATCH_DEBUG)
653193326Sed	@if [ -d ${PATCHDIR} ]; then \
654198092Srdivacky		${ECHO_MSG} "===>  Applying FreeBSD patches for ${PKGNAME}" ; \
655193326Sed		for i in ${PATCHDIR}/patch-*; do \
656193326Sed			case $$i in \
657193326Sed				*.orig|*~) \
658193326Sed					${ECHO_MSG} "===>   Ignoring patchfile $$i" ; \
659193326Sed					;; \
660193326Sed				*) \
661193326Sed					${ECHO_MSG} "===>   Applying FreeBSD patch $$i" ; \
662198092Srdivacky					${PATCH} ${PATCH_ARGS} < $$i; \
663193326Sed					;; \
664193326Sed			esac; \
665193326Sed		done; \
666193326Sed	fi
667193326Sed.else
668193326Sed	@if [ -d ${PATCHDIR} ]; then \
669193326Sed		${ECHO_MSG} "===>  Applying FreeBSD patches for ${PKGNAME}" ; \
670193326Sed		for i in ${PATCHDIR}/patch-*; do \
671193326Sed			case $$i in \
672204962Srdivacky				*.orig|*~) \
673204962Srdivacky					${ECHO_MSG} "===>   Ignoring patchfile $$i" ; \
674204962Srdivacky					;; \
675204962Srdivacky				*) \
676204962Srdivacky					${PATCH} ${PATCH_ARGS} < $$i; \
677204962Srdivacky					;; \
678204962Srdivacky			esac; \
679204962Srdivacky		done;\
680204962Srdivacky	fi
681198092Srdivacky.endif
682198092Srdivacky.endif
683198092Srdivacky
684198092Srdivacky# Configure
685198092Srdivacky
686204962Srdivacky.if !target(do-configure)
687204962Srdivackydo-configure:
688204962Srdivacky	@if [ -f ${SCRIPTDIR}/${CONFIGURE_SCRIPT} ]; then \
689198092Srdivacky		cd ${.CURDIR} && ${SETENV} CURDIR=${.CURDIR} DISTDIR=${DISTDIR}\
690198092Srdivacky		  WRKDIR=${WRKDIR} WRKSRC=${WRKSRC} PATCHDIR=${PATCHDIR} \
691204962Srdivacky		  SCRIPTDIR=${SCRIPTDIR} FILESDIR=${FILESDIR} \
692204962Srdivacky		  PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} DEPENDS="${DEPENDS}" \
693198092Srdivacky		  X11BASE=${X11BASE} /bin/sh ${SCRIPTDIR}/${CONFIGURE_SCRIPT}; \
694198092Srdivacky	fi
695203955Srdivacky.if defined(HAS_CONFIGURE)
696203955Srdivacky	@(cd ${WRKSRC} && CC="${CC}" ac_cv_path_CC="${CC}" CFLAGS="${CFLAGS}" \
697198092Srdivacky	    INSTALL="/usr/bin/install -c -o ${BINOWN} -g ${BINGRP}" \
698198092Srdivacky	    INSTALL_PROGRAM="/usr/bin/install ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE}" \
699198092Srdivacky	    ${CONFIGURE_ENV} ./${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS})
700198092Srdivacky.endif
701198092Srdivacky.if defined(USE_IMAKE)
702198092Srdivacky	@(cd ${WRKSRC} && ${XMKMF})
703198092Srdivacky.endif
704198092Srdivacky.endif
705204962Srdivacky
706204962Srdivacky# Build
707198092Srdivacky
708198092Srdivacky.if !target(do-build)
709204962Srdivackydo-build:
710204962Srdivacky.if defined(USE_GMAKE)
711198092Srdivacky	@(cd ${WRKSRC}; ${SETENV} ${MAKE_ENV} ${GMAKE} ${MAKE_FLAGS} ${MAKEFILE} ${ALL_TARGET})
712198092Srdivacky.else defined(USE_GMAKE)
713198092Srdivacky	@(cd ${WRKSRC}; ${SETENV} ${MAKE_ENV} ${MAKE} ${MAKE_FLAGS} ${MAKEFILE} ${ALL_TARGET})
714198092Srdivacky.endif
715198092Srdivacky.endif
716207619Srdivacky
717207619Srdivacky# Install
718207619Srdivacky
719207619Srdivacky.if !target(do-install)
720207619Srdivackydo-install:
721207619Srdivacky.if defined(USE_GMAKE)
722207619Srdivacky	@(cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} ${GMAKE} ${MAKE_FLAGS} ${MAKEFILE} ${INSTALL_TARGET})
723207619Srdivacky.if defined(USE_IMAKE) && !defined(NO_INSTALL_MANPAGES)
724207619Srdivacky	@(cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} ${GMAKE} ${MAKE_FLAGS} ${MAKEFILE} install.man)
725207619Srdivacky.endif
726207619Srdivacky.else defined(USE_GMAKE)
727207619Srdivacky	@(cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} ${MAKE} ${MAKE_FLAGS} ${MAKEFILE} ${INSTALL_TARGET})
728207619Srdivacky.if defined(USE_IMAKE) && !defined(NO_INSTALL_MANPAGES)
729207619Srdivacky	@(cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} ${MAKE} ${MAKE_FLAGS} ${MAKEFILE} install.man)
730207619Srdivacky.endif
731207619Srdivacky.endif
732207619Srdivacky.endif
733207619Srdivacky
734207619Srdivacky# Package
735207619Srdivacky
736207619Srdivacky.if !target(do-package)
737207619Srdivackydo-package:
738207619Srdivacky	@if [ -e ${PKGDIR}/PLIST ]; then \
739198092Srdivacky		${ECHO_MSG} "===>  Building package for ${PKGNAME}"; \
740198092Srdivacky		if [ -d ${PACKAGES} ]; then \
741198092Srdivacky			if [ ! -d ${PKGREPOSITORY} ]; then \
742198092Srdivacky				if ! ${MKDIR} -p ${PKGREPOSITORY}; then \
743198092Srdivacky					${ECHO_MSG} ">> Can't create directory ${PKGREPOSITORY}."; \
744198092Srdivacky					exit 1; \
745198092Srdivacky				fi; \
746198092Srdivacky			fi; \
747198092Srdivacky		fi; \
748198092Srdivacky		if ${PKG_CMD} ${PKG_ARGS} ${PKGFILE}; then \
749205219Srdivacky			if [ -d ${PACKAGES} ]; then \
750198092Srdivacky				${MAKE} ${.MAKEFLAGS} package-links; \
751198092Srdivacky			fi; \
752207619Srdivacky		else \
753207619Srdivacky			${MAKE} ${.MAKEFLAGS} delete-package; \
754198092Srdivacky			exit 1; \
755198092Srdivacky		fi; \
756198092Srdivacky	fi
757198092Srdivacky.endif
758198092Srdivacky
759198092Srdivacky# Some support rules for do-package
760198092Srdivacky
761198092Srdivacky.if !target(package-links)
762198092Srdivackypackage-links:
763198092Srdivacky	@${MAKE} ${.MAKEFLAGS} delete-package-links
764198092Srdivacky	@for cat in ${CATEGORIES}; do \
765198092Srdivacky		if [ ! -d ${PACKAGES}/$$cat ]; then \
766207619Srdivacky			if ! ${MKDIR} -p ${PACKAGES}/$$cat; then \
767207619Srdivacky				${ECHO_MSG} ">> Can't create directory ${PACKAGES}/$$cat."; \
768207619Srdivacky				exit 1; \
769207619Srdivacky			fi; \
770207619Srdivacky		fi; \
771207619Srdivacky		ln -s ../${PKGREPOSITORYSUBDIR}/${PKGNAME}${PKG_SUFX} ${PACKAGES}/$$cat; \
772207619Srdivacky	done;
773207619Srdivacky.endif
774207619Srdivacky
775207619Srdivacky.if !target(delete-package-links)
776207619Srdivackydelete-package-links:
777203955Srdivacky	@${RM} -f ${PACKAGES}/[a-z]*/${PKGNAME}${PKG_SUFX};
778207619Srdivacky.endif
779207619Srdivacky
780207619Srdivacky.if !target(delete-package)
781207619Srdivackydelete-package:
782207619Srdivacky	@${MAKE} ${.MAKEFLAGS} delete-package-links
783198092Srdivacky	@${RM} -f ${PKGFILE}
784198092Srdivacky.endif
785198092Srdivacky
786198092Srdivacky################################################################
787198092Srdivacky# This is the "generic" port target, actually a macro used from the
788198092Srdivacky# six main targets.  See below for more.
789198092Srdivacky################################################################
790198092Srdivacky
791198092Srdivacky_PORT_USE: .USE
792198092Srdivacky.if make(real-fetch)
793198092Srdivacky	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} fetch-depends
794198092Srdivacky.endif
795198092Srdivacky.if make(real-extract)
796198092Srdivacky	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} build-depends lib-depends misc-depends
797198092Srdivacky.endif
798198092Srdivacky.if make(real-install)
799198092Srdivacky	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} run-depends
800198092Srdivacky.endif
801198092Srdivacky.if make(real-install)
802198092Srdivacky.if !defined(NO_MTREE)
803198092Srdivacky	@if [ `id -u` = 0 ]; then \
804198092Srdivacky		${MTREE_CMD} ${MTREE_ARGS} ${PREFIX}/; \
805198092Srdivacky	else \
806198092Srdivacky		${ECHO_MSG} "Warning: not superuser, can't run mtree."; \
807198092Srdivacky		${ECHO_MSG} "Become root and try again to ensure correct permissions."; \
808198092Srdivacky	fi
809198092Srdivacky.endif
810199482Srdivacky.endif
811207619Srdivacky	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} ${.TARGET:S/^real-/pre-/}
812199482Srdivacky	@if [ -f ${SCRIPTDIR}/${.TARGET:S/^real-/pre-/} ]; then \
813198092Srdivacky		cd ${.CURDIR} && ${SETENV} CURDIR=${.CURDIR} DISTDIR=${DISTDIR} WRKDIR=${WRKDIR} \
814205219Srdivacky		  WRKSRC=${WRKSRC} PATCHDIR=${PATCHDIR} SCRIPTDIR=${SCRIPTDIR} \
815205219Srdivacky		  FILESDIR=${FILESDIR} PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} \
816198092Srdivacky		  DEPENDS="${DEPENDS}" X11BASE=${X11BASE} \
817207619Srdivacky			/bin/sh ${SCRIPTDIR}/${.TARGET:S/^real-/pre-/}; \
818207619Srdivacky	fi
819198092Srdivacky	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} ${.TARGET:S/^real-/do-/}
820198092Srdivacky	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} ${.TARGET:S/^real-/post-/}
821198092Srdivacky	@if [ -f ${SCRIPTDIR}/${.TARGET:S/^real-/post-/} ]; then \
822198092Srdivacky		cd ${.CURDIR} && ${SETENV} CURDIR=${.CURDIR} DISTDIR=${DISTDIR}\
823198092Srdivacky		  WRKDIR=${WRKDIR} WRKSRC=${WRKSRC} PATCHDIR=${PATCHDIR} \
824198092Srdivacky		  SCRIPTDIR=${SCRIPTDIR} FILESDIR=${FILESDIR} \
825198092Srdivacky		  PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} DEPENDS="${DEPENDS}" \
826198092Srdivacky		  X11BASE=${X11BASE} \
827198092Srdivacky			/bin/sh ${SCRIPTDIR}/${.TARGET:S/^real-/post-/}; \
828198092Srdivacky	fi
829198092Srdivacky.if make(real-install)  && !defined(NO_PKG_REGISTER)
830198092Srdivacky	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} fake-pkg
831198092Srdivacky.endif
832198092Srdivacky.if !make(real-fetch) \
833198092Srdivacky	&& (!make(real-patch) || !defined(PATCH_CHECK_ONLY)) \
834198092Srdivacky	&& (!make(real-package) || !defined(PACKAGE_NOINSTALL))
835198092Srdivacky	@${TOUCH} ${TOUCH_FLAGS} ${WRKDIR}/.${.TARGET:S/^real-//}_done
836198092Srdivacky.endif
837198092Srdivacky
838198092Srdivacky################################################################
839198092Srdivacky# Skeleton targets start here
840198092Srdivacky# 
841198092Srdivacky# You shouldn't have to change these.  Either add the pre-* or
842198092Srdivacky# post-* targets/scripts or redefine the do-* targets.  These
843198092Srdivacky# targets don't do anything other than checking for cookies and
844198092Srdivacky# call the necessary targets/scripts.
845198092Srdivacky################################################################
846198092Srdivacky
847198092Srdivacky.if !target(fetch)
848198092Srdivackyfetch:
849198092Srdivacky	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} real-fetch
850198092Srdivacky.endif
851198092Srdivacky
852198092Srdivacky.if !target(extract)
853193326Sedextract: checksum ${EXTRACT_COOKIE}
854193326Sed.endif
855193326Sed
856193326Sed.if !target(patch)
857193326Sedpatch: extract ${PATCH_COOKIE}
858193326Sed.endif
859193326Sed
860193326Sed.if !target(configure)
861193326Sedconfigure: patch ${CONFIGURE_COOKIE}
862193326Sed.endif
863198092Srdivacky
864199990Srdivacky.if !target(build)
865199990Srdivackybuild: configure ${BUILD_COOKIE}
866193326Sed.endif
867193326Sed
868193326Sed.if !target(install)
869193326Sedinstall: build ${INSTALL_COOKIE}
870193326Sed.endif
871193326Sed
872193326Sed.if !target(package)
873193326Sedpackage: install ${PACKAGE_COOKIE}
874198092Srdivacky.endif
875198092Srdivacky
876193326Sed${EXTRACT_COOKIE}:
877193326Sed	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} real-extract
878193326Sed${PATCH_COOKIE}:
879193326Sed	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} real-patch
880193326Sed${CONFIGURE_COOKIE}:
881193326Sed	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} real-configure
882193326Sed${BUILD_COOKIE}:
883193326Sed	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} real-build
884193326Sed${INSTALL_COOKIE}:
885193326Sed	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} real-install
886193326Sed${PACKAGE_COOKIE}:
887193326Sed	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} real-package
888193326Sed
889193326Sed# And call the macros
890193326Sed
891193326Sedreal-fetch: _PORT_USE
892193326Sedreal-extract: _PORT_USE
893198092Srdivacky	@${ECHO_MSG} "===>  Extracting for ${PKGNAME}"
894193326Sedreal-patch: _PORT_USE
895193326Sed	@${ECHO_MSG} "===>  Patching for ${PKGNAME}"
896193326Sedreal-configure: _PORT_USE
897193326Sed	@${ECHO_MSG} "===>  Configuring for ${PKGNAME}"
898193326Sedreal-build: _PORT_USE
899193326Sed	@${ECHO_MSG} "===>  Building for ${PKGNAME}"
900193326Sedreal-install: _PORT_USE
901193326Sed	@${ECHO_MSG} "===>  Installing for ${PKGNAME}"
902193326Sedreal-package: _PORT_USE
903193326Sed
904193326Sed# Empty pre-* and post-* targets, note we can't use .if !target()
905193326Sed# in the _PORT_USE macro
906193326Sed
907193326Sed.for name in fetch extract patch configure build install package
908193326Sed
909193326Sed.if !target(pre-${name})
910193326Sedpre-${name}:
911193326Sed	@${DO_NADA}
912193326Sed.endif
913193326Sed
914193326Sed.if !target(post-${name})
915193326Sedpost-${name}:
916193326Sed	@${DO_NADA}
917193326Sed.endif
918193326Sed
919193326Sed.endfor
920193326Sed
921193326Sed# Checkpatch
922193326Sed#
923193326Sed# Special target to verify patches
924193326Sed
925193326Sed.if !target(checkpatch)
926193326Sedcheckpatch:
927193326Sed	@cd ${.CURDIR} && ${MAKE} PATCH_CHECK_ONLY=yes ${.MAKEFLAGS} patch
928193326Sed.endif
929193326Sed
930193326Sed# Reinstall
931193326Sed#
932198092Srdivacky# Special target to re-run install
933193326Sed
934193326Sed.if !target(reinstall)
935193326Sedreinstall: pre-reinstall install
936193326Sed
937193326Sedpre-reinstall:
938193326Sed	@${RM} -f ${INSTALL_COOKIE}
939193326Sed	@${RM} -f ${PACKAGE_COOKIE}
940193326Sed.endif
941193326Sed
942198092Srdivacky################################################################
943193326Sed# Some more targets supplied for users' convenience
944193326Sed################################################################
945193326Sed
946193326Sed# Cleaning up
947199990Srdivacky
948198092Srdivacky.if !target(pre-clean)
949193326Sedpre-clean:
950193326Sed	@${DO_NADA}
951193326Sed.endif
952193326Sed
953193326Sed.if !target(clean)
954193326Sedclean: pre-clean
955193326Sed	@${ECHO_MSG} "===>  Cleaning for ${PKGNAME}"
956193326Sed.if !defined(NO_WRKDIR)
957193326Sed	@${RM} -rf ${WRKDIR}
958193326Sed.else
959193326Sed	@${RM} -f ${WRKDIR}/.*_done
960193326Sed.endif
961193326Sed.endif
962193326Sed
963193326Sed# Prints out a list of files to fetch (useful to do a batch fetch)
964193326Sed
965193326Sed.if !target(fetch-list)
966193326Sedfetch-list:
967193326Sed	@if [ ! -d ${DISTDIR} ]; then ${MKDIR} -p ${DISTDIR}; fi
968193326Sed	@(cd ${DISTDIR}; \
969193326Sed	 for file in ${DISTFILES}; do \
970193326Sed		if [ ! -f $$file -a ! -f `${BASENAME} $$file` ]; then \
971198092Srdivacky			for site in ${MASTER_SITES}; do \
972193326Sed				${ECHO} -n ${FETCH_CMD} ${FETCH_BEFORE_ARGS} $${site}$${file} "${FETCH_AFTER_ARGS}" '||' ; \
973193326Sed					break; \
974198092Srdivacky			done; \
975193326Sed			${ECHO} "echo $${file} not fetched" ; \
976193326Sed		fi \
977193326Sed	done)
978193326Sed.if defined(PATCHFILES)
979193326Sed	@(cd ${DISTDIR}; \
980193326Sed	 for file in ${PATCHFILES}; do \
981198092Srdivacky		if [ ! -f $$file -a ! -f `${BASENAME} $$file` ]; then \
982198092Srdivacky			for site in ${PATCH_SITES}; do \
983198092Srdivacky				${ECHO} -n ${FETCH_CMD} ${FETCH_BEFORE_ARGS} $${site}$${file} "${FETCH_AFTER_ARGS}" '||' ; \
984198092Srdivacky					break; \
985198092Srdivacky			done; \
986193326Sed			${ECHO} "echo $${file} not fetched" ; \
987193326Sed		fi \
988193326Sed	 done)
989193326Sed.endif
990193326Sed.endif
991193326Sed
992193326Sed# Checksumming utilities
993193326Sed
994193326Sed.if !target(makesum)
995193326Sedmakesum: fetch
996193326Sed	@if [ ! -d ${FILESDIR} ]; then ${MKDIR} -p ${FILESDIR}; fi
997193326Sed	@if [ -f ${MD5_FILE} ]; then ${RM} -f ${MD5_FILE}; fi
998193326Sed	@(cd ${DISTDIR}; \
999193326Sed	 for file in ${DISTFILES} ${PATCHFILES}; do \
1000193326Sed		${MD5} $$file >> ${MD5_FILE}; \
1001193326Sed	 done)
1002201361Srdivacky.endif
1003201361Srdivacky
1004201361Srdivacky.if !target(checksum)
1005201361Srdivackychecksum: fetch
1006201361Srdivacky	@if [ ! -f ${MD5_FILE} ]; then \
1007201361Srdivacky		${ECHO_MSG} ">> No MD5 checksum file."; \
1008201361Srdivacky	else \
1009201361Srdivacky		(cd ${DISTDIR}; OK=""; \
1010201361Srdivacky		  for file in ${DISTFILES} ${PATCHFILES}; do \
1011201361Srdivacky			CKSUM=`${MD5} < $$file`; \
1012201361Srdivacky			CKSUM2=`${GREP} "($$file)" ${MD5_FILE} | ${AWK} '{print $$4}'`; \
1013201361Srdivacky			if [ "$$CKSUM2" = "" ]; then \
1014201361Srdivacky				${ECHO_MSG} ">> No checksum recorded for $$file"; \
1015201361Srdivacky				OK="false"; \
1016201361Srdivacky			elif [ "$$CKSUM" != "$$CKSUM2" ]; then \
1017201361Srdivacky				${ECHO_MSG} ">> Checksum mismatch for $$file"; \
1018201361Srdivacky				exit 1; \
1019201361Srdivacky			fi; \
1020201361Srdivacky		  done; \
1021201361Srdivacky		  if [ "$$OK" = "" ]; then \
1022201361Srdivacky			${ECHO_MSG} "Checksums OK."; \
1023201361Srdivacky		  else \
1024201361Srdivacky			${ECHO_MSG} "Checksums OK for files that have them."; \
1025201361Srdivacky		  fi) ; \
1026201361Srdivacky	fi
1027201361Srdivacky.endif
1028201361Srdivacky
1029201361Srdivacky################################################################
1030201361Srdivacky# The special package-building targets
1031201361Srdivacky# You probably won't need to touch these
1032201361Srdivacky################################################################
1033201361Srdivacky
1034201361Srdivacky# Nobody should want to override this unless PKGNAME is simply bogus.
1035201361Srdivacky
1036201361Srdivacky.if !target(package-name)
1037201361Srdivackypackage-name:
1038201361Srdivacky	@${ECHO} ${PKGNAME}
1039201361Srdivacky.endif
1040201361Srdivacky
1041201361Srdivacky# Show (recursively) all the packages this package depends on.
1042201361Srdivacky
1043201361Srdivacky.if !target(package-depends)
1044201361Srdivackypackage-depends:
1045201361Srdivacky	@for i in ${RUN_DEPENDS} ${LIB_DEPENDS} ${DEPENDS}; do \
1046201361Srdivacky		dir=`${ECHO} $$i | ${SED} -e 's/.*://'`; \
1047193326Sed		(cd $$dir ; ${MAKE} package-name package-depends); \
1048198092Srdivacky	done
1049193326Sed.endif
1050193326Sed
1051207619Srdivacky# Build a package but don't check the package cookie
1052193326Sed
1053195341Sed.if !target(repackage)
1054193326Sedrepackage: pre-repackage package
1055193326Sed
1056193326Sedpre-repackage:
1057193326Sed	@${RM} -f ${PACKAGE_COOKIE}
1058193326Sed.endif
1059194711Sed
1060194711Sed# Build a package but don't check the cookie for installation, also don't
1061198092Srdivacky# install package cookie
1062198092Srdivacky
1063198092Srdivacky.if !target(package-noinstall)
1064198092Srdivackypackage-noinstall:
1065193326Sed	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} PACKAGE_NOINSTALL=yes real-package
1066193326Sed.endif
1067193326Sed
1068193326Sed################################################################
1069193326Sed# Dependency checking
1070193326Sed################################################################
1071193326Sed
1072193326Sed.if !target(depends)
1073193326Seddepends: lib-depends misc-depends
1074193326Sed	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} fetch-depends
1075193326Sed	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} build-depends
1076193326Sed	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} run-depends
1077193326Sed
1078193326Sed.if make(fetch-depends)
1079193326SedDEPENDS_TMP+=	${FETCH_DEPENDS}
1080193326Sed.endif
1081193326Sed
1082193326Sed.if make(build-depends)
1083193326SedDEPENDS_TMP+=	${BUILD_DEPENDS}
1084193326Sed.endif
1085193326Sed
1086195341Sed.if make(run-depends)
1087195341SedDEPENDS_TMP+=	${RUN_DEPENDS}
1088195341Sed.endif
1089198092Srdivacky
1090195341Sed_DEPENDS_USE:	.USE
1091195341Sed.if defined(DEPENDS_TMP)
1092195341Sed.if defined(NO_DEPENDS)
1093193326Sed# Just print out messages
1094195341Sed	@for i in ${DEPENDS_TMP}; do \
1095193326Sed		prog=`${ECHO} $$i | ${SED} -e 's/:.*//'`; \
1096198092Srdivacky		dir=`${ECHO} $$i | ${SED} -e 's/.*://'`; \
1097198092Srdivacky		if expr "$$prog" : \\/ >/dev/null; then \
1098200583Srdivacky			${ECHO_MSG} "===>  ${PKGNAME} depends on file:  $$prog ($$dir)"; \
1099193326Sed		else \
1100193326Sed			${ECHO_MSG} "===>  ${PKGNAME} depends on executable:  $$prog ($$dir)"; \
1101200583Srdivacky		fi; \
1102201361Srdivacky	done
1103200583Srdivacky.else
1104201361Srdivacky	@for i in ${DEPENDS_TMP}; do \
1105200583Srdivacky		prog=`${ECHO} $$i | ${SED} -e 's/:.*//'`; \
1106201361Srdivacky		dir=`${ECHO} $$i | ${SED} -e 's/.*://'`; \
1107201361Srdivacky		if expr "$$prog" : \\/ >/dev/null; then \
1108201361Srdivacky			if [ -e "$$prog" ]; then \
1109193326Sed				${ECHO_MSG} "===>  ${PKGNAME} depends on file: $$prog - found"; \
1110201361Srdivacky				notfound=0; \
1111201361Srdivacky			else \
1112201361Srdivacky				${ECHO_MSG} "===>  ${PKGNAME} depends on file: $$prog - not found"; \
1113201361Srdivacky				notfound=1; \
1114207619Srdivacky			fi; \
1115207619Srdivacky		else \
1116207619Srdivacky			if which -s "$$prog"; then \
1117202879Srdivacky				${ECHO_MSG} "===>  ${PKGNAME} depends on executable: $$prog - found"; \
1118202879Srdivacky				notfound=0; \
1119202879Srdivacky			else \
1120202879Srdivacky				${ECHO_MSG} "===>  ${PKGNAME} depends on executable: $$prog - not found"; \
1121202879Srdivacky				notfound=1; \
1122202879Srdivacky			fi; \
1123202879Srdivacky		fi; \
1124202879Srdivacky		if [ $$notfound != 0 ]; then \
1125202879Srdivacky			${ECHO_MSG} "===>  Verifying build for $$prog in $$dir"; \
1126207619Srdivacky			if [ ! -d "$$dir" ]; then \
1127207619Srdivacky				${ECHO_MSG} ">> No directory for $$prog.  Skipping.."; \
1128202879Srdivacky			else \
1129204962Srdivacky				(cd $$dir; ${MAKE} ${.MAKEFLAGS} is_depended) ; \
1130204962Srdivacky				${ECHO_MSG} "===>  Returning to build of ${PKGNAME}"; \
1131204962Srdivacky			fi; \
1132202879Srdivacky		fi; \
1133202879Srdivacky	done
1134202879Srdivacky.endif
1135202879Srdivacky.else
1136201361Srdivacky	@${DO_NADA}
1137202879Srdivacky.endif
1138207619Srdivacky
1139207619Srdivackyfetch-depends:	_DEPENDS_USE
1140201361Srdivackybuild-depends:	_DEPENDS_USE
1141201361Srdivackyrun-depends:	_DEPENDS_USE
1142201361Srdivacky
1143201361Srdivackylib-depends:
1144201361Srdivacky.if defined(LIB_DEPENDS)
1145201361Srdivacky.if defined(NO_DEPENDS)
1146201361Srdivacky# Just print out messages
1147206084Srdivacky	@for i in ${LIB_DEPENDS}; do \
1148206084Srdivacky		lib=`${ECHO} $$i | ${SED} -e 's/:.*//'`; \
1149202379Srdivacky		dir=`${ECHO} $$i | ${SED} -e 's/.*://'`; \
1150202379Srdivacky		${ECHO_MSG} "===>  ${PKGNAME} depends on shared library:  $$lib ($$dir)"; \
1151201361Srdivacky	done
1152201361Srdivacky.else
1153201361Srdivacky	@for i in ${LIB_DEPENDS}; do \
1154201361Srdivacky		lib=`${ECHO} $$i | ${SED} -e 's/:.*//'`; \
1155201361Srdivacky		dir=`${ECHO} $$i | ${SED} -e 's/.*://'`; \
1156201361Srdivacky		if /sbin/ldconfig -r | ${GREP} -q -e "-l$$lib"; then \
1157201361Srdivacky			${ECHO_MSG} "===>  ${PKGNAME} depends on shared library: $$lib - found"; \
1158201361Srdivacky		else \
1159201361Srdivacky			${ECHO_MSG} "===>  ${PKGNAME} depends on shared library: $$lib - not found"; \
1160201361Srdivacky			${ECHO_MSG} "===>  Verifying build for $$lib in $$dir"; \
1161201361Srdivacky			if [ ! -d "$$dir" ]; then \
1162201361Srdivacky				${ECHO_MSG} ">> No directory for $$lib.  Skipping.."; \
1163201361Srdivacky			else \
1164201361Srdivacky				(cd $$dir; ${MAKE} ${.MAKEFLAGS} is_depended) ; \
1165201361Srdivacky				${ECHO_MSG} "===>  Returning to build of ${PKGNAME}"; \
1166206084Srdivacky			fi; \
1167206084Srdivacky		fi; \
1168202379Srdivacky	done
1169202379Srdivacky.endif
1170202379Srdivacky.else
1171202379Srdivacky	@${DO_NADA}
1172202379Srdivacky.endif
1173202379Srdivacky
1174202379Srdivackymisc-depends:
1175202379Srdivacky.if defined(DEPENDS)
1176201361Srdivacky	@${ECHO_MSG} "===>  ${PKGNAME} depends on:  ${DEPENDS}"
1177201361Srdivacky.if !defined(NO_DEPENDS)
1178201361Srdivacky	@for i in ${DEPENDS}; do \
1179201361Srdivacky		${ECHO_MSG} "===>  Verifying build for $$i"; \
1180201361Srdivacky		if [ ! -d $$i ]; then \
1181202879Srdivacky			${ECHO_MSG} ">> No directory for $$i.  Skipping.."; \
1182201361Srdivacky		else \
1183201361Srdivacky			(cd $$i; ${MAKE} ${.MAKEFLAGS} is_depended) ; \
1184201361Srdivacky		fi \
1185201361Srdivacky	done
1186201361Srdivacky	@${ECHO_MSG} "===>  Returning to build of ${PKGNAME}"
1187201361Srdivacky.endif
1188202879Srdivacky.else
1189202879Srdivacky	@${DO_NADA}
1190202879Srdivacky.endif
1191202879Srdivacky
1192202879Srdivacky.endif
1193201361Srdivacky
1194202879Srdivacky.if !target(depends-list)
1195202879Srdivackydepends-list:
1196202879Srdivacky	@for i in ${FETCH_DEPENDS} ${BUILD_DEPENDS} ${LIB_DEPENDS} ${DEPENDS}; do \
1197201361Srdivacky		dir=`/bin/echo $$i | /usr/bin/sed -e 's/.*://'`; \
1198201361Srdivacky		(cd $$dir ; ${MAKE} package-name depends-list); \
1199201361Srdivacky	done
1200200583Srdivacky.endif
1201200583Srdivacky
1202198092Srdivacky################################################################
1203200583Srdivacky# Everything after here are internal targets and really
1204200583Srdivacky# shouldn't be touched by anybody but the release engineers.
1205198092Srdivacky################################################################
1206198092Srdivacky
1207198954Srdivacky# This target generates an index entry suitable for aggregation into
1208198954Srdivacky# a large index.  Format is:
1209198954Srdivacky#
1210198954Srdivacky# distribution-name|port-path|installation-prefix|comment| \
1211198954Srdivacky#  description-file|maintainer|categories|build deps|run deps
1212198954Srdivacky#
1213198954Srdivacky.if !target(describe)
1214198954Srdivackydescribe:
1215198954Srdivacky	@${ECHO} -n "${PKGNAME}|${.CURDIR}|"
1216198954Srdivacky	@${ECHO} -n "${PREFIX}|"
1217198954Srdivacky	@if [ -f ${PKGDIR}/COMMENT ]; then \
1218198954Srdivacky		${ECHO} -n "`${CAT} ${PKGDIR}/COMMENT`"; \
1219198954Srdivacky	else \
1220198954Srdivacky		${ECHO} -n "** No Description"; \
1221198954Srdivacky	fi
1222198954Srdivacky	@if [ -f ${PKGDIR}/DESCR ]; then \
1223198954Srdivacky		${ECHO} -n "|${PKGDIR}/DESCR"; \
1224198954Srdivacky	else \
1225198954Srdivacky		${ECHO} -n "|/dev/null"; \
1226198954Srdivacky	fi
1227198954Srdivacky	@${ECHO} -n "|${MAINTAINER}|${CATEGORIES}|"
1228198954Srdivacky	@cd ${.CURDIR} && ${ECHO} -n `make depends-list|sort|uniq`
1229198954Srdivacky	@${ECHO} -n "|"
1230198954Srdivacky	@cd ${.CURDIR} && ${ECHO} -n `make package-depends|sort|uniq`
1231198954Srdivacky	@${ECHO} ""
1232198954Srdivacky.endif
1233198954Srdivacky
1234198954Srdivacky.if !target(readmes)
1235198954Srdivackyreadmes:	readme
1236198954Srdivacky.endif
1237198954Srdivacky
1238198954Srdivacky.if !target(readme)
1239198954Srdivackyreadme:
1240198954Srdivacky	@rm -f README.html
1241198954Srdivacky	@cd ${.CURDIR} && make README.html
1242198954Srdivacky.endif
1243198954Srdivacky
1244198954SrdivackyREADME.html:
1245198954Srdivacky	@${ECHO_MSG} "===>  Creating README.html for ${PKGNAME}"
1246198954Srdivacky	@${CAT} ${TEMPLATES}/README.port | \
1247198954Srdivacky		${SED} -e 's%%PORT%%'`${ECHO} ${.CURDIR} | ${SED} -e 's.*/\([^/]*/[^/]*\)$$\1'`'g' \
1248198954Srdivacky			-e 's%%PKG%%${PKGNAME}g' \
1249198954Srdivacky			-e '/%%COMMENT%%/r${PKGDIR}/COMMENT' \
1250198092Srdivacky			-e '/%%COMMENT%%/d' \
1251198092Srdivacky			-e 's%%BUILD_DEPENDS%%'"`${MAKE} print-depends-list`"'' \
1252198092Srdivacky			-e 's%%RUN_DEPENDS%%'"`${MAKE} print-package-depends`"'' \
1253200583Srdivacky		>> $@
1254198092Srdivacky
1255198954Srdivacky.if !target(print-depends-list)
1256198954Srdivackyprint-depends-list:
1257198954Srdivacky.if defined(FETCH_DEPENDS) || defined(BUILD_DEPENDS) || \
1258198954Srdivacky	defined(LIB_DEPENDS) || defined(DEPENDS)
1259198954Srdivacky	@${ECHO} -n 'This port requires package(s) "'
1260198954Srdivacky	@${ECHO} -n `make depends-list | sort | uniq`
1261198954Srdivacky	@${ECHO} '" to build.'
1262198954Srdivacky.endif
1263198954Srdivacky.endif
1264198954Srdivacky
1265198954Srdivacky.if !target(print-package-depends)
1266198954Srdivackyprint-package-depends:
1267198954Srdivacky.if defined(RUN_DEPENDS) || defined(LIB_DEPENDS) || defined(DEPENDS)
1268198954Srdivacky	@${ECHO} -n 'This port requires package(s) "'
1269198954Srdivacky	@${ECHO} -n `make package-depends | sort | uniq`
1270198954Srdivacky	@${ECHO} '" to run.'
1271198954Srdivacky.endif
1272198092Srdivacky.endif
1273198092Srdivacky
1274198092Srdivacky# Fake installation of package so that user can pkg_delete it later.
1275198092Srdivacky# Also, make sure that an installed port is recognized correctly in
1276198092Srdivacky# accordance to the @pkgdep directive in the packing lists
1277198092Srdivacky
1278198092Srdivacky.if !target(fake-pkg)
1279203955Srdivackyfake-pkg:
1280203955Srdivacky	@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
1281203955Srdivacky	@if [ ! -d ${PKG_DBDIR} ]; then ${RM} -f ${PKG_DBDIR}; ${MKDIR} -p ${PKG_DBDIR}; fi
1282203955Srdivacky.if defined(FORCE_PKG_REGISTER)
1283203955Srdivacky	@${RM} -rf ${PKG_DBDIR}/${PKGNAME}
1284203955Srdivacky.endif
1285203955Srdivacky	@if [ ! -d ${PKG_DBDIR}/${PKGNAME} ]; then \
1286203955Srdivacky		${ECHO_MSG} "===>  Registering installation for ${PKGNAME}"; \
1287203955Srdivacky		${MKDIR} -p ${PKG_DBDIR}/${PKGNAME}; \
1288203955Srdivacky		${PKG_CMD} ${PKG_ARGS} -O ${PKGFILE} > ${PKG_DBDIR}/${PKGNAME}/+CONTENTS; \
1289203955Srdivacky		${CP} ${PKGDIR}/DESCR ${PKG_DBDIR}/${PKGNAME}/+DESC; \
1290203955Srdivacky		${CP} ${PKGDIR}/COMMENT ${PKG_DBDIR}/${PKGNAME}/+COMMENT; \
1291203955Srdivacky		if [ -f ${PKGDIR}/INSTALL ]; then \
1292203955Srdivacky			${CP} ${PKGDIR}/INSTALL ${PKG_DBDIR}/${PKGNAME}/+INSTALL; \
1293203955Srdivacky		fi; \
1294203955Srdivacky		if [ -f ${PKGDIR}/DEINSTALL ]; then \
1295203955Srdivacky			${CP} ${PKGDIR}/DEINSTALL ${PKG_DBDIR}/${PKGNAME}/+DEINSTALL; \
1296203955Srdivacky		fi; \
1297203955Srdivacky		if [ -f ${PKGDIR}/REQ ]; then \
1298193326Sed			${CP} ${PKGDIR}/REQ ${PKG_DBDIR}/${PKGNAME}/+REQ; \
1299199482Srdivacky		fi; \
1300203955Srdivacky	else \
1301203955Srdivacky		${ECHO_MSG} "===> ${PKGNAME} is already installed - perhaps an older version?"; \
1302199482Srdivacky		${ECHO_MSG} "     If so, you may wish to \`\`pkg_delete ${PKGNAME}'' and install"; \
1303203955Srdivacky		${ECHO_MSG} "     this port again by \`\`make reinstall'' to upgrade it properly."; \
1304203955Srdivacky	fi
1305203955Srdivacky.endif
1306203955Srdivacky
1307203955Srdivacky# Depend is generally meaningless for arbitrary ports, but if someone wants
1308203955Srdivacky# one they can override this.  This is just to catch people who've gotten into
1309203955Srdivacky# the habit of typing `make depend all install' as a matter of course.
1310203955Srdivacky#
1311203955Srdivacky.if !target(depend)
1312203955Srdivackydepend:
1313203955Srdivacky.endif
1314203955Srdivacky
1315203955Srdivacky# Same goes for tags
1316203955Srdivacky.if !target(tags)
1317203955Srdivackytags:
1318203955Srdivacky.endif
1319203955Srdivacky