bsd.port.mk revision 16500
1#-*- mode: Fundamental; tab-width: 4; -*-
2#
3#	bsd.port.mk - 940820 Jordan K. Hubbard.
4#	This file is in the public domain.
5#
6# $Id: bsd.port.mk,v 1.208 1996/06/19 01:26:18 jkh Exp $
7#
8# Please view me with 4 column tabs!
9
10
11# Supported Variables and their behaviors:
12#
13# Variables that typically apply to all ports:
14# 
15# PORTSDIR		- The root of the ports tree (default: /usr/ports).
16# DISTDIR 		- Where to get gzip'd, tarballed copies of original sources
17#				  (default: ${PORTSDIR}/distfiles/${DIST_SUBDIR}).
18# PREFIX		- Where to install things in general (default: /usr/local).
19# MASTER_SITES	- Primary location(s) for distribution files if not found
20#				  locally (default:
21#				   ftp://ftp.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/)
22# PATCH_SITES	- Primary location(s) for distribution patch files
23#				  (see PATCHFILES below) if not found locally (default:
24#				   ftp://ftp.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/)
25#
26# MASTER_SITE_OVERRIDE - If set, override the MASTER_SITES setting with this
27#				  value.
28# MASTER_SITE_FREEBSD - If set, only use the FreeBSD master repository for
29#				  MASTER_SITES.
30# PACKAGES		- A top level directory where all packages go (rather than
31#				  going locally to each port). (default: ${PORTSDIR}/packages).
32# GMAKE			- Set to path of GNU make if not in $PATH (default: gmake).
33# XMKMF			- Set to path of `xmkmf' if not in $PATH (default: xmkmf -a ).
34# MAINTAINER	- The e-mail address of the contact person for this port
35#				  (default: ports@FreeBSD.ORG).
36# CATEGORIES	- A list of descriptive categories into which this port falls
37#				  (default: orphans).
38#
39# Variables that typically apply to an individual port.  Non-Boolean
40# variables without defaults are *mandatory*.
41# 
42#
43# WRKDIR 		- A temporary working directory that gets *clobbered* on clean
44#				  (default: ${.CURDIR}/work).
45# WRKSRC		- A subdirectory of ${WRKDIR} where the distribution actually
46#				  unpacks to.  (Default: ${WRKDIR}/${DISTNAME} unless
47#				  NO_WRKSUBDIR is set, in which case simply ${WRKDIR}).
48# DISTNAME		- Name of port or distribution.
49# DISTFILES		- Name(s) of archive file(s) containing distribution
50#				  (default: ${DISTNAME}${EXTRACT_SUFX}).
51# PATCHFILES	- Name(s) of additional files that contain distribution
52#				  patches (default: none).  make will look for them at
53#				  PATCH_SITES (see above).  They will automatically be
54#				  uncompressed before patching if the names end with
55#				  ".gz" or ".Z".
56# DIST_SUBDIR	- Suffix to ${DISTDIR} (see above).  If set, all ${DISTFILES} 
57#				  and ${PATCHFILES} will be put in this subdirectory of
58#				  ${DISTDIR}.  Also they will be fetched in this subdirectory 
59#				  from FreeBSD mirror sites.
60# PKGNAME		- Name of the package file to create if the DISTNAME 
61#				  isn't really relevant for the port/package
62#				  (default: ${DISTNAME}).
63# EXTRACT_ONLY	- If defined, a subset of ${DISTFILES} you want to
64#			  	  actually extract.
65# PATCHDIR 		- A directory containing any additional patches you made
66#				  to port this software to FreeBSD (default:
67#				  ${.CURDIR}/patches)
68# SCRIPTDIR 	- A directory containing any auxiliary scripts
69#				  (default: ${.CURDIR}/scripts)
70# FILESDIR 		- A directory containing any miscellaneous additional files.
71#				  (default: ${.CURDIR}/files)
72# PKGDIR 		- A direction containing any package creation files.
73#				  (default: ${.CURDIR}/pkg)
74# PKG_DBDIR		- Where package installation is recorded (default: /var/db/pkg)
75# FORCE_PKG_REGISTER - If set, it will overwrite any existing package
76#				  registration information in ${PKG_DBDIR}/${PKGNAME}.
77# NO_MTREE		- If set, will not invoke mtree from bsd.port.mk from
78#				  the "install" target.  This is the default if
79#				  USE_IMAKE or USE_X11 is set.
80#
81# NO_BUILD		- Use a dummy (do-nothing) build target.
82# NO_CONFIGURE	- Use a dummy (do-nothing) configure target.
83# NO_CDROM		- Use dummy (do-nothing) targets if FOR_CDROM is set.
84# NO_DESCRIBE	- Use a dummy (do-nothing) describe target.
85# NO_EXTRACT	- Use a dummy (do-nothing) extract target.
86# NO_INSTALL	- Use a dummy (do-nothing) install target.
87# NO_PACKAGE	- Use a dummy (do-nothing) package target.
88# NO_PKG_REGISTER - Don't register a port install as a package.
89# NO_WRKSUBDIR	- Assume port unpacks directly into ${WRKDIR}.
90# NO_WRKDIR		- There's no work directory at all; port does this someplace
91#				  else.
92# NO_DEPENDS	- Don't verify build of dependencies.
93# BROKEN		- Port is broken.
94# RESTRICTED	- Port is restricted.  Set this string to the reason why.
95# USE_GMAKE		- Says that the port uses gmake.
96# USE_IMAKE		- Says that the port uses imake.
97# USE_X11		- Says that the port uses X11.
98# NO_INSTALL_MANPAGES - For imake ports that don't like the install.man
99#						target.
100# HAS_CONFIGURE	- Says that the port has its own configure script.
101# GNU_CONFIGURE	- Set if you are using GNU configure (optional).
102# CONFIGURE_SCRIPT - Name of configure script, defaults to 'configure'.
103# CONFIGURE_ARGS - Pass these args to configure if ${HAS_CONFIGURE} is set.
104# CONFIGURE_ENV  - Pass these env (shell-like) to configure if
105#				  ${HAS_CONFIGURE} is set.
106# IS_INTERACTIVE - Set this if your port needs to interact with the user
107#				  during a build.  User can then decide to skip this port by
108#				  setting ${BATCH}, or compiling only the interactive ports
109#				  by setting ${INTERACTIVE}.
110# FETCH_DEPENDS - A list of "prog:dir" pairs of other ports this
111#				  package depends in the "fetch" stage.  "prog" is the
112#				  name of an executable.  make will search your $PATH
113#				  for it and go into "dir" to do a "make all install"
114#				  if it's not found.
115# BUILD_DEPENDS - A list of "prog:dir" pairs of other ports this
116#				  package depends to build (somewhere between the
117#				  "extract" to "build" stage).  "prog" is the name
118#				  of an executable.  make will search your $PATH for
119#				  it and go into "dir" to do a "make all install" if
120#				  it's not found.
121# RUN_DEPENDS	- A list of "prog:dir" pairs of other ports this package
122#				  depends to run.  "prog" is the name of an
123#				  executable.  make will search your $PATH for it and
124#				  go into "dir" to do a "make all install" if it's not
125#				  found.  This will be build during the "install" stage
126#				  and its name will be put into the package as well.
127# LIB_DEPENDS	- A list of "lib:dir" pairs of other ports this package
128#				  depends on.  "lib" is the name of a shared library.
129#				  make will use "ldconfig -r" to search for the
130#				  library.  Note that lib can be any regular expression,
131#				  and you need two backslashes in front of dots (.) to
132#				  supress its special meaning (e.g., use
133#				  "foo\\.2\\.:${PORTSDIR}/utils/foo" to match "libfoo.2.*").
134# DEPENDS		- A list of other ports this package depends on being
135#				  made first.  Use this for things that don't fall into
136#				  the above two categories.
137# EXTRACT_CMD	- Command for extracting archive (default: tar).
138# EXTRACT_SUFX	- Suffix for archive names (default: .tar.gz).
139# EXTRACT_BEFORE_ARGS -
140#				  Arguments to ${EXTRACT_CMD} before filename
141#				  (default: -C ${WRKDIR} -xzf).
142# EXTRACT_AFTER_ARGS -
143#				  Arguments to ${EXTRACT_CMD} following filename
144#				  (default: none).
145#
146# NCFTP			- Full path to ncftp command if not in $PATH (default: ncftp).
147# NCFTPFLAGS    - Arguments to ${NCFTP} (default: -N).
148#
149# Motif support:
150#
151# REQUIRES_MOTIF - Set this in your port if it requires Motif.  It will  be
152#				  built only if HAVE_MOTIF is set.
153# HAVE_MOTIF	- If set, means system has Motif.  Typically set in
154#				  /etc/make.conf.
155# MOTIF_STATIC	- If set, link libXm statically; otherwise, link it
156#				  dynamically.
157#
158# Variables to change if you want a special behavior:
159#
160# ECHO_MSG		- Used to print all the '===>' style prompts - override this
161#				  to turn them off (default: /bin/echo).
162# IS_DEPENDED_TARGET -
163#				  The target to execute when a port is called as a
164#				  dependency (default: install).  E.g., "make fetch
165#				  IS_DEPENDED_TARGET=fetch" will fetch all the distfiles,
166#				  including those of dependencies, without actually building
167#				  any of them).
168#
169# 
170# Default targets and their behaviors:
171#
172# fetch			- Retrieves ${DISTFILES} (and ${PATCHFILES} if defined)
173#				  into ${DISTDIR} as necessary.
174# fetch-list	- Show list of files that would be retrieved by fetch
175# extract		- Unpacks ${DISTFILES} into ${WRKDIR}.
176# patch			- Apply any provided patches to the source.
177# configure		- Runs either GNU configure, one or more local configure
178#				  scripts or nothing, depending on what's available.
179# build			- Actually compile the sources.
180# install		- Install the results of a build.
181# reinstall		- Install the results of a build, ignoring "already installed"
182#				  flag.
183# package		- Create a package from an _installed_ port.
184# describe		- Try to generate a one-line description for each port for
185#				  use in INDEX files and the like.
186# checkpatch	- Do a "patch -C" instead of a "patch".  Note that it may
187#				  give incorrect results if multiple patches deal with
188#				  the same file.
189# checksum		- Use files/md5 to ensure that your distfiles are valid.
190# makesum		- Generate files/md5 (only do this for your own ports!).
191#
192# Default sequence for "all" is:  fetch checksum extract patch configure build
193#
194# Please read the comments in the targets section below, you
195# should be able to use the pre-* or post-* targets/scripts
196# (which are available for every stage except checksum) or
197# override the do-* targets to do pretty much anything you want.
198#
199# NEVER override the "regular" targets unless you want to open
200# a major can of worms.
201
202.if exists(${.CURDIR}/../Makefile.inc)
203.include "${.CURDIR}/../Makefile.inc"
204.endif
205
206# Support for an encapsulation in /usr/src - these are essentially simplied ports
207# and have a number of defaults we can presume right off the bat.
208.if defined(SRC_ENCAPSULATION)
209.if exists (${.CURDIR}/obj)
210WRKDIR=${.CURDIR}/obj
211.else
212NO_WRKDIR=			yes
213.endif
214
215# Disable things that should be disabled for encapsulations.
216NO_PACKAGE=			yes
217NO_MTREE=			yes
218NO_FETCH=			yes
219NO_PKG_REGISTER=	yes
220describe:
221	@${DO_NADA}
222
223# Finally, give us working obj and cleandir targets to make us more compatible
224# with "traditional" /usr/src ports.
225.if !target(obj)
226.if defined(NOOBJ)
227obj:
228	@${DO_NADA}
229.else
230obj:
231	@cd ${.CURDIR}; rm -rf obj; here=`pwd`; \
232		dest=/usr/obj`echo $$here | sed 's,^/usr/src,,'`; ${ECHO} "$$here -> $$dest"; \
233		ln -s $$dest obj; if test -d /usr/obj -a ! -d $$dest; then mkdir -p $$dest; fi
234.endif
235.endif
236
237.if !target(cleandir)
238.if defined(NOCLEANDIR)
239cleandir:
240	@${DO_NADA}
241.else
242cleandir: clean
243	@if [ "${WRKDIR}" != "${.CURDIR}" ]; then ${RM} -rf ${WRKDIR}/; fi
244	@rm -f ${.CURDIR}/obj
245.endif
246.endif
247
248.endif
249
250# These need to be absolute since we don't know how deep in the ports
251# tree we are and thus can't go relative.  They can, of course, be overridden
252# by individual Makefiles.
253PORTSDIR?=		${DESTDIR}/usr/ports
254LOCALBASE?=		/usr/local
255X11BASE?=		/usr/X11R6
256DISTDIR?=		${PORTSDIR}/distfiles/${DIST_SUBDIR}
257PACKAGES?=		${PORTSDIR}/packages
258TEMPLATES?=		${PORTSDIR}/templates
259.if !defined(NO_WRKDIR)
260WRKDIR?=		${.CURDIR}/work
261.else
262WRKDIR?=		${.CURDIR}
263.endif
264.if defined(NO_WRKSUBDIR)
265WRKSRC?=		${WRKDIR}
266.else
267WRKSRC?=		${WRKDIR}/${DISTNAME}
268.endif
269PATCHDIR?=		${.CURDIR}/patches
270SCRIPTDIR?=		${.CURDIR}/scripts
271FILESDIR?=		${.CURDIR}/files
272PKGDIR?=		${.CURDIR}/pkg
273.if defined(USE_IMAKE) || defined(USE_X11)
274PREFIX?=		${X11BASE}
275.else
276PREFIX?=		${LOCALBASE}
277.endif
278# The following 4 lines should go away as soon as the ports are all updated
279.if defined(EXEC_DEPENDS)
280BUILD_DEPENDS+=	${EXEC_DEPENDS}
281RUN_DEPENDS+=	${EXEC_DEPENDS}
282.endif
283.if defined(USE_GMAKE)
284BUILD_DEPENDS+=               gmake:${PORTSDIR}/devel/gmake
285.endif
286
287.if exists(${PORTSDIR}/../Makefile.inc)
288.include "${PORTSDIR}/../Makefile.inc"
289.endif
290
291# Don't change these!!!  These names are built into the _TARGET_USE macro,
292# there is no way to refer to them cleanly from within the macro AFAIK.
293EXTRACT_COOKIE?=	${WRKDIR}/.extract_done
294CONFIGURE_COOKIE?=	${WRKDIR}/.configure_done
295INSTALL_COOKIE?=	${WRKDIR}/.install_done
296BUILD_COOKIE?=		${WRKDIR}/.build_done
297PATCH_COOKIE?=		${WRKDIR}/.patch_done
298PACKAGE_COOKIE?=	${WRKDIR}/.package_done
299
300# How to do nothing.  Override if you, for some strange reason, would rather
301# do something.
302DO_NADA?=		/usr/bin/true
303
304# Miscellaneous overridable commands:
305GMAKE?=			gmake
306XMKMF?=			xmkmf -a
307MD5?=			/sbin/md5
308MD5_FILE?=		${FILESDIR}/md5
309
310MAKE_FLAGS?=	-f
311MAKEFILE?=		Makefile
312MAKE_ENV+=		PREFIX=${PREFIX} LOCALBASE=${LOCALBASE} X11BASE=${X11BASE} MOTIFLIB="${MOTIFLIB}" CFLAGS="${CFLAGS}"
313
314NCFTP?=			/usr/bin/ncftp
315NCFTPFLAGS?=	-N
316
317TOUCH?=			/usr/bin/touch
318TOUCH_FLAGS?=	-f
319
320PATCH?=			/usr/bin/patch
321PATCH_STRIP?=	-p0
322PATCH_DIST_STRIP?=	-p0
323.if defined(PATCH_DEBUG)
324PATCH_ARGS?=	-d ${WRKSRC} -E ${PATCH_STRIP}
325PATCH_DIST_ARGS?=	-d ${WRKSRC} -E ${PATCH_DIST_STRIP}
326.else
327PATCH_ARGS?=	-d ${WRKSRC} --forward --quiet -E ${PATCH_STRIP}
328PATCH_DIST_ARGS?=	-d ${WRKSRC} --forward --quiet -E ${PATCH_DIST_STRIP}
329.endif
330.if defined(BATCH)
331PATCH_ARGS+=		--batch
332PATCH_DIST_ARGS+=	--batch
333.endif
334
335.if defined(PATCH_CHECK_ONLY)
336PATCH_ARGS+=	-C
337PATCH_DIST_ARGS+=	-C
338.endif
339
340EXTRACT_CMD?=	/usr/bin/tar
341EXTRACT_SUFX?=	.tar.gz
342# Backwards compatability.
343.if defined(EXTRACT_ARGS)
344EXTRACT_BEFORE_ARGS?=   ${EXTRACT_ARGS}
345.else
346EXTRACT_BEFORE_ARGS?=   -xzf
347.endif
348
349# Figure out where the local mtree file is
350.if !defined(MTREE_LOCAL) && exists(/etc/mtree/BSD.local.dist)
351MTREE_LOCAL=	/etc/mtree/BSD.local.dist
352.endif
353MTREE_CMD?=	/usr/sbin/mtree
354MTREE_ARGS?=	-U -f ${MTREE_LOCAL} -d -e -p
355.if defined(USE_X11) || defined(USE_IMAKE) || !defined(MTREE_LOCAL)
356NO_MTREE=	yes
357.endif
358
359# The user can override the NO_PACKAGE by specifying this from
360# the make command line
361.if defined(FORCE_PACKAGE)
362.undef NO_PACKAGE
363.endif
364
365PKG_CMD?=		/usr/sbin/pkg_create
366.if !defined(PKG_ARGS)
367PKG_ARGS=		-v -c ${PKGDIR}/COMMENT -d ${PKGDIR}/DESCR -f ${PKGDIR}/PLIST -p ${PREFIX} -P "`${MAKE} package-depends|sort|uniq`"
368.if exists(${PKGDIR}/INSTALL)
369PKG_ARGS+=		-i ${PKGDIR}/INSTALL
370.endif
371.if exists(${PKGDIR}/DEINSTALL)
372PKG_ARGS+=		-k ${PKGDIR}/DEINSTALL
373.endif
374.if exists(${PKGDIR}/REQ)
375PKG_ARGS+=		-r ${PKGDIR}/REQ
376.endif
377.if !defined(NO_MTREE) && defined(MTREE_LOCAL)
378PKG_ARGS+=		-m ${MTREE_LOCAL}
379.endif
380.endif
381PKG_SUFX?=		.tgz
382# where pkg_add records its dirty deeds.
383PKG_DBDIR?=		/var/db/pkg
384
385# shared/dynamic motif libs
386.if defined(HAVE_MOTIF)
387.if defined(MOTIF_STATIC)
388MOTIFLIB?=	${X11BASE}/lib/libXm.a
389.else
390MOTIFLIB?=	-L${X11BASE}/lib -lXm
391.endif
392.endif
393
394ECHO?=		/bin/echo
395CAT+=		/bin/cat
396CP?=		/bin/cp
397SETENV?=	/usr/bin/env
398RM?=		/bin/rm
399MKDIR?=		/bin/mkdir
400GZCAT?=		/usr/bin/gzcat
401BASENAME?=	/usr/bin/basename
402SED?=		/usr/bin/sed
403CAT?=		/bin/cat
404GREP?=		/usr/bin/grep
405AWK?=		/usr/bin/awk
406
407# Used to print all the '===>' style prompts - override this to turn them off.
408ECHO_MSG?=		${ECHO}
409
410ALL_TARGET?=		all
411INSTALL_TARGET?=	install
412
413# If the user has this set, go to the FreeBSD respository for everything.
414.if defined(MASTER_SITE_FREEBSD)
415MASTER_SITE_OVERRIDE=  ftp://ftp.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/
416.endif
417
418# I guess we're in the master distribution business! :)  As we gain mirror
419# sites for distfiles, add them to this list.
420.if !defined(MASTER_SITE_OVERRIDE)
421MASTER_SITES+=	ftp://ftp.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/
422PATCH_SITES+=	ftp://ftp.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/
423.else
424MASTER_SITES?=	# to avoid "variable MASTER_SITES recursive" error
425MASTER_SITES:=	${MASTER_SITE_OVERRIDE} ${MASTER_SITES}
426PATCH_SITES:=	${MASTER_SITE_OVERRIDE} ${PATCH_SITES}
427.endif
428
429# Derived names so that they're easily overridable.
430DISTFILES?=		${DISTNAME}${EXTRACT_SUFX}
431PKGNAME?=		${DISTNAME}
432
433# This is what is actually going to be extracted, and is overridable
434#  by user.
435EXTRACT_ONLY?=	${DISTFILES}
436
437# Documentation
438MAINTAINER?=	ports@FreeBSD.ORG
439CATEGORIES?=	orphans
440
441# Note this has to start with a capital letter (or more accurately, it
442#  shouldn't match "[a-z]*"), see the target "delete-package-links" below.
443PKGREPOSITORYSUBDIR?=	All
444PKGREPOSITORY?=		${PACKAGES}/${PKGREPOSITORYSUBDIR}
445.if exists(${PACKAGES})
446PKGFILE?=		${PKGREPOSITORY}/${PKGNAME}${PKG_SUFX}
447.else
448PKGFILE?=		${PKGNAME}${PKG_SUFX}
449.endif
450
451CONFIGURE_SCRIPT?=	configure
452
453.if defined(GNU_CONFIGURE)
454CONFIGURE_ARGS+=	--prefix=${PREFIX}
455HAS_CONFIGURE=		yes
456.endif
457
458.MAIN: all
459
460################################################################
461# Many ways to disable a port.
462#
463# If we're in BATCH mode and the port is interactive, or we're
464# in interactive mode and the port is non-interactive, skip all
465# the important targets.  The reason we have two modes is that
466# one might want to leave a build in BATCH mode running
467# overnight, then come back in the morning and do _only_ the
468# interactive ones that required your intervention.
469#
470# Don't attempt to build ports that require Motif if you don't
471# have Motif.
472#
473# Ignore ports that can't be resold if building for a CDROM.
474#
475# Don't build a port if it's restricted and we don't want to get
476# into that.
477#
478# Don't build a port if it's broken.
479################################################################
480
481.if (defined(IS_INTERACTIVE) && defined(BATCH)) || \
482	(!defined(IS_INTERACTIVE) && defined(INTERACTIVE)) || \
483	(defined(REQUIRES_MOTIF) && !defined(HAVE_MOTIF)) || \
484	(defined(NO_CDROM) && defined(FOR_CDROM)) || \
485	(defined(RESTRICTED) && defined(NO_RESTRICTED)) || \
486	defined(BROKEN)
487IGNORE=	yes
488.endif
489
490.if defined(IGNORE)
491all:
492	@${DO_NADA}
493build:
494	@${DO_NADA}
495install:
496	@${DO_NADA}
497fetch:
498	@${DO_NADA}
499configure:
500	@${DO_NADA}
501package:
502	@${DO_NADA}
503.endif
504
505.if defined(ALL_HOOK)
506all:
507	@cd ${.CURDIR} && ${SETENV} CURDIR=${.CURDIR} DISTNAME=${DISTNAME} \
508	  DISTDIR=${DISTDIR} WRKDIR=${WRKDIR} WRKSRC=${WRKSRC} \
509	  PATCHDIR=${PATCHDIR} SCRIPTDIR=${SCRIPTDIR} \
510	  FILESDIR=${FILESDIR} PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} \
511	  DEPENDS="${DEPENDS}" BUILD_DEPENDS="${BUILD_DEPENDS}" \
512	  RUN_DEPENDS="${RUN_DEPENDS}" X11BASE=${X11BASE} \
513	${ALL_HOOK}
514.endif
515
516.if !target(all)
517all: build
518.endif
519
520.if !defined(IS_DEPENDED_TARGET)
521IS_DEPENDED_TARGET=	install
522.endif
523
524.if !target(is_depended)
525is_depended:	${IS_DEPENDED_TARGET}
526.endif
527
528################################################################
529# The following are used to create easy dummy targets for
530# disabling some bit of default target behavior you don't want.
531# They still check to see if the target exists, and if so don't
532# do anything, since you might want to set this globally for a
533# group of ports in a Makefile.inc, but still be able to
534# override from an individual Makefile.
535################################################################
536
537# Disable extract
538.if defined(NO_EXTRACT) && !target(extract)
539extract: checksum
540	@${TOUCH} ${TOUCH_FLAGS} ${EXTRACT_COOKIE}
541checksum: fetch
542	@${DO_NADA}
543makesum:
544	@${DO_NADA}
545.endif
546
547# Disable configure
548.if defined(NO_CONFIGURE) && !target(configure)
549configure: patch
550	@${TOUCH} ${TOUCH_FLAGS} ${CONFIGURE_COOKIE}
551.endif
552
553# Disable describe
554.if defined(NO_DESCRIBE) && !target(describe)
555describe:
556	@${DO_NADA}
557.endif
558
559# Disable build
560.if defined(NO_BUILD) && !target(build)
561build: configure
562	@${TOUCH} ${TOUCH_FLAGS} ${BUILD_COOKIE}
563.endif
564
565# Disable package
566.if defined(NO_PACKAGE) && !target(package)
567package:
568	@${DO_NADA}
569.endif
570
571# Disable install
572.if defined(NO_INSTALL) && !target(install)
573install: build
574	@${TOUCH} ${TOUCH_FLAGS} ${INSTALL_COOKIE}
575.endif
576
577# Disable patch
578.if defined(NO_PATCH) && !target(patch)
579patch: extract
580	@${TOUCH} ${TOUCH_FLAGS} ${PATCH_COOKIE}
581.endif
582
583################################################################
584# More standard targets start here.
585#
586# These are the body of the build/install framework.  If you are
587# not happy with the default actions, and you can't solve it by
588# adding pre-* or post-* targets/scripts, override these.
589################################################################
590
591# Fetch
592
593.if !target(do-fetch)
594do-fetch:
595	@if [ ! -d ${DISTDIR} ]; then ${MKDIR} -p ${DISTDIR}; fi
596	@(cd ${DISTDIR}; \
597	 for file in ${DISTFILES}; do \
598		if [ ! -f $$file -a ! -f `${BASENAME} $$file` ]; then \
599			if [ -h $$file -o -h `${BASENAME} $$file` ]; then \
600				${ECHO_MSG} ">> ${DISTDIR}/$$file is a broken symlink."; \
601				${ECHO_MSG} ">> Perhaps a filesystem (most likely a CD) isn't mounted?"; \
602				${ECHO_MSG} ">> Please correct this problem and try again."; \
603				exit 1; \
604			fi ; \
605			${ECHO_MSG} ">> $$file doesn't seem to exist on this system."; \
606			for site in ${MASTER_SITES}; do \
607			    ${ECHO_MSG} ">> Attempting to fetch from $${site}."; \
608				(${NCFTP} ${NCFTPFLAGS} $${site}$${file} ${NCFTPTAIL} || true); \
609				if [ -f $$file -o -f `${BASENAME} $$file` ]; then \
610					continue 2; \
611				fi \
612			done; \
613			${ECHO_MSG} ">> Couldn't fetch it - please try to retreive this";\
614			${ECHO_MSG} ">> port manually into ${DISTDIR} and try again."; \
615			exit 1; \
616	    fi \
617	 done)
618.if defined(PATCHFILES)
619	@if [ ! -d ${DISTDIR} ]; then ${MKDIR} -p ${DISTDIR}; fi
620	@(cd ${DISTDIR}; \
621	 for file in ${PATCHFILES}; do \
622		if [ ! -f $$file -a ! -f `${BASENAME} $$file` ]; then \
623			if [ -h $$file -o -h `${BASENAME} $$file` ]; then \
624				${ECHO_MSG} ">> ${DISTDIR}/$$file is a broken symlink."; \
625				${ECHO_MSG} ">> Perhaps a filesystem (most likely a CD) isn't mounted?"; \
626				${ECHO_MSG} ">> Please correct this problem and try again."; \
627				exit 1; \
628			fi ; \
629			${ECHO_MSG} ">> $$file doesn't seem to exist on this system."; \
630			for site in ${PATCH_SITES}; do \
631			    ${ECHO_MSG} ">> Attempting to fetch from $${site}."; \
632				(${NCFTP} ${NCFTPFLAGS} $${site}$${file} ${NCFTPTAIL} || true); \
633				if [ -f $$file -o -f `${BASENAME} $$file` ]; then \
634					continue 2; \
635				fi \
636			done; \
637			${ECHO_MSG} ">> Couldn't fetch it - please try to retreive this";\
638			${ECHO_MSG} ">> port manually into ${DISTDIR} and try again."; \
639			exit 1; \
640	    fi \
641	 done)
642.endif
643.endif
644
645# Extract
646
647.if !target(do-extract)
648do-extract:
649.if !defined(NO_WRKDIR)
650	@${RM} -rf ${WRKDIR}
651	@${MKDIR} -p ${WRKDIR}
652.endif
653	@for file in ${EXTRACT_ONLY}; do \
654		if !(cd ${WRKDIR} && ${EXTRACT_CMD} ${EXTRACT_BEFORE_ARGS} ${DISTDIR}/$$file ${EXTRACT_AFTER_ARGS});\
655		then \
656			exit 1; \
657		fi \
658	done
659.endif
660
661# Patch
662
663.if !target(do-patch)
664do-patch:
665.if defined(PATCHFILES)
666	@${ECHO_MSG} "===>  Applying distribution patches for ${PKGNAME}"
667.if defined(PATCH_DEBUG)
668	@(cd ${DISTDIR}; \
669	  for i in ${PATCHFILES}; do \
670		${ECHO_MSG} "===>   Applying distribution patch $$i" ; \
671		case $$i in \
672			*.Z|*.gz) \
673				${GZCAT} $$i | ${PATCH} ${PATCH_DIST_ARGS}; \
674				;; \
675			*) \
676				${PATCH} ${PATCH_DIST_ARGS} < $$i; \
677				;; \
678		esac; \
679	  done)
680.else
681	@(cd ${DISTDIR}; \
682	  for i in ${PATCHFILES}; do \
683		case $$i in \
684			*.Z|*.gz) \
685				${GZCAT} $$i | ${PATCH} ${PATCH_DIST_ARGS}; \
686				;; \
687			*) \
688				${PATCH} ${PATCH_DIST_ARGS} < $$i; \
689				;; \
690		esac; \
691	  done)
692.endif
693.endif
694.if defined(PATCH_DEBUG)
695	@if [ -d ${PATCHDIR} ]; then \
696		${ECHO_MSG} "===>  Applying FreeBSD patches for ${PKGNAME}" ; \
697		for i in ${PATCHDIR}/patch-*; do \
698			case $$i in \
699				*.orig|*~) \
700					${ECHO_MSG} "===>   Ignoring patchfile $$i" ; \
701					;; \
702				*) \
703					${ECHO_MSG} "===>   Applying FreeBSD patch $$i" ; \
704					${PATCH} ${PATCH_ARGS} < $$i; \
705					;; \
706			esac; \
707		done; \
708	fi
709.else
710	@if [ -d ${PATCHDIR} ]; then \
711		${ECHO_MSG} "===>  Applying FreeBSD patches for ${PKGNAME}" ; \
712		for i in ${PATCHDIR}/patch-*; do \
713			case $$i in \
714				*.orig|*~) \
715					${ECHO_MSG} "===>   Ignoring patchfile $$i" ; \
716					;; \
717				*) \
718					${PATCH} ${PATCH_ARGS} < $$i; \
719					;; \
720			esac; \
721		done;\
722	fi
723.endif
724.endif
725
726# Configure
727
728.if !target(do-configure)
729do-configure:
730	@if [ -f ${SCRIPTDIR}/configure ]; then \
731		cd ${.CURDIR} && ${SETENV} CURDIR=${.CURDIR} DISTDIR=${DISTDIR}\
732		  WRKDIR=${WRKDIR} WRKSRC=${WRKSRC} PATCHDIR=${PATCHDIR} \
733		  SCRIPTDIR=${SCRIPTDIR} FILESDIR=${FILESDIR} \
734		  PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} DEPENDS="${DEPENDS}" \
735		  X11BASE=${X11BASE} /bin/sh ${SCRIPTDIR}/configure; \
736	fi
737.if defined(HAS_CONFIGURE)
738	@(cd ${WRKSRC} && CC="${CC}" ac_cv_path_CC="${CC}" CFLAGS="${CFLAGS}" \
739	    INSTALL="/usr/bin/install -c -o ${BINOWN} -g ${BINGRP}" \
740	    INSTALL_PROGRAM="/usr/bin/install ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE}" \
741	    ${CONFIGURE_ENV} ./${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS})
742.endif
743.if defined(USE_IMAKE)
744	@(cd ${WRKSRC} && ${XMKMF})
745.endif
746.endif
747
748# Build
749
750.if !target(do-build)
751do-build:
752.if defined(USE_GMAKE)
753	@(cd ${WRKSRC}; ${SETENV} ${MAKE_ENV} ${GMAKE} ${MAKE_FLAGS} ${MAKEFILE} ${ALL_TARGET})
754.else defined(USE_GMAKE)
755	@(cd ${WRKSRC}; ${SETENV} ${MAKE_ENV} ${MAKE} ${MAKE_FLAGS} ${MAKEFILE} ${ALL_TARGET})
756.endif
757.endif
758
759# Install
760
761.if !target(do-install)
762do-install:
763.if defined(USE_GMAKE)
764	@(cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} ${GMAKE} ${MAKE_FLAGS} ${MAKEFILE} ${INSTALL_TARGET})
765.if defined(USE_IMAKE) && !defined(NO_INSTALL_MANPAGES)
766	@(cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} ${GMAKE} ${MAKE_FLAGS} ${MAKEFILE} install.man)
767.endif
768.else defined(USE_GMAKE)
769	@(cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} ${MAKE} ${MAKE_FLAGS} ${MAKEFILE} ${INSTALL_TARGET})
770.if defined(USE_IMAKE) && !defined(NO_INSTALL_MANPAGES)
771	@(cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} ${MAKE} ${MAKE_FLAGS} ${MAKEFILE} install.man)
772.endif
773.endif
774.endif
775
776# Package
777
778.if !target(do-package)
779do-package:
780	@if [ -e ${PKGDIR}/PLIST ]; then \
781		${ECHO_MSG} "===>  Building package for ${PKGNAME}"; \
782		if [ -d ${PACKAGES} ]; then \
783			if [ ! -d ${PKGREPOSITORY} ]; then \
784				if ! ${MKDIR} -p ${PKGREPOSITORY}; then \
785					${ECHO_MSG} ">> Can't create directory ${PKGREPOSITORY}."; \
786					exit 1; \
787				fi; \
788			fi; \
789		fi; \
790		if ${PKG_CMD} ${PKG_ARGS} ${PKGFILE}; then \
791			if [ -d ${PACKAGES} ]; then \
792				${MAKE} ${.MAKEFLAGS} package-links; \
793			fi; \
794		else \
795			${MAKE} ${.MAKEFLAGS} delete-package; \
796			exit 1; \
797		fi; \
798	fi
799.endif
800
801# Some support rules for do-package
802
803.if !target(package-links)
804package-links:
805	@${MAKE} ${.MAKEFLAGS} delete-package-links
806	@for cat in ${CATEGORIES}; do \
807		if [ ! -d ${PACKAGES}/$$cat ]; then \
808			if ! ${MKDIR} -p ${PACKAGES}/$$cat; then \
809				${ECHO_MSG} ">> Can't create directory ${PACKAGES}/$$cat."; \
810				exit 1; \
811			fi; \
812		fi; \
813		ln -s ../${PKGREPOSITORYSUBDIR}/${PKGNAME}${PKG_SUFX} ${PACKAGES}/$$cat; \
814	done;
815.endif
816
817.if !target(delete-package-links)
818delete-package-links:
819	@${RM} -f ${PACKAGES}/[a-z]*/${PKGNAME}${PKG_SUFX};
820.endif
821
822.if !target(delete-package)
823delete-package:
824	@${MAKE} ${.MAKEFLAGS} delete-package-links
825	@${RM} -f ${PKGFILE}
826.endif
827
828################################################################
829# This is the "generic" port target, actually a macro used from the
830# six main targets.  See below for more.
831################################################################
832
833_PORT_USE: .USE
834.if make(real-fetch)
835	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} fetch-depends
836.endif
837.if make(real-extract)
838	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} build-depends lib-depends misc-depends
839.endif
840.if make(real-install)
841	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} run-depends
842.endif
843.if make(real-install)
844.if !defined(NO_MTREE)
845	@if [ `id -u` = 0 ]; then \
846		${MTREE_CMD} ${MTREE_ARGS} ${PREFIX}/; \
847	else \
848		${ECHO_MSG} "Warning: not superuser, can't run mtree."; \
849		${ECHO_MSG} "Become root and try again to ensure correct permissions."; \
850	fi
851.endif
852.endif
853	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} ${.TARGET:S/^real-/pre-/}
854	@if [ -f ${SCRIPTDIR}/${.TARGET:S/^real-/pre-/} ]; then \
855		cd ${.CURDIR} && ${SETENV} CURDIR=${.CURDIR} DISTDIR=${DISTDIR} WRKDIR=${WRKDIR} \
856		  WRKSRC=${WRKSRC} PATCHDIR=${PATCHDIR} SCRIPTDIR=${SCRIPTDIR} \
857		  FILESDIR=${FILESDIR} PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} \
858		  DEPENDS="${DEPENDS}" X11BASE=${X11BASE} \
859			/bin/sh ${SCRIPTDIR}/${.TARGET:S/^real-/pre-/}; \
860	fi
861	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} ${.TARGET:S/^real-/do-/}
862	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} ${.TARGET:S/^real-/post-/}
863	@if [ -f ${SCRIPTDIR}/${.TARGET:S/^real-/post-/} ]; then \
864		cd ${.CURDIR} && ${SETENV} CURDIR=${.CURDIR} DISTDIR=${DISTDIR}\
865		  WRKDIR=${WRKDIR} WRKSRC=${WRKSRC} PATCHDIR=${PATCHDIR} \
866		  SCRIPTDIR=${SCRIPTDIR} FILESDIR=${FILESDIR} \
867		  PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} DEPENDS="${DEPENDS}" \
868		  X11BASE=${X11BASE} \
869			/bin/sh ${SCRIPTDIR}/${.TARGET:S/^real-/post-/}; \
870	fi
871.if make(real-install)  && !defined(NO_PKG_REGISTER)
872	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} fake-pkg
873.endif
874.if !make(real-fetch) \
875	&& (!make(real-patch) || !defined(PATCH_CHECK_ONLY)) \
876	&& (!make(real-package) || !defined(PACKAGE_NOINSTALL))
877	@${TOUCH} ${TOUCH_FLAGS} ${WRKDIR}/.${.TARGET:S/^real-//}_done
878.endif
879
880################################################################
881# Skeleton targets start here
882# 
883# You shouldn't have to change these.  Either add the pre-* or
884# post-* targets/scripts or redefine the do-* targets.  These
885# targets don't do anything other than checking for cookies and
886# call the necessary targets/scripts.
887################################################################
888
889.if !target(fetch)
890fetch:
891	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} real-fetch
892.endif
893
894.if !target(extract)
895extract: checksum ${EXTRACT_COOKIE}
896.endif
897
898.if !target(patch)
899patch: extract ${PATCH_COOKIE}
900.endif
901
902.if !target(configure)
903configure: patch ${CONFIGURE_COOKIE}
904.endif
905
906.if !target(build)
907build: configure ${BUILD_COOKIE}
908.endif
909
910.if !target(install)
911install: build ${INSTALL_COOKIE}
912.endif
913
914.if !target(package)
915package: install ${PACKAGE_COOKIE}
916.endif
917
918${EXTRACT_COOKIE}:
919	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} real-extract
920${PATCH_COOKIE}:
921	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} real-patch
922${CONFIGURE_COOKIE}:
923	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} real-configure
924${BUILD_COOKIE}:
925	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} real-build
926${INSTALL_COOKIE}:
927	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} real-install
928${PACKAGE_COOKIE}:
929	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} real-package
930
931# And call the macros
932
933real-fetch: _PORT_USE
934real-extract: _PORT_USE
935	@${ECHO_MSG} "===>  Extracting for ${PKGNAME}"
936real-patch: _PORT_USE
937	@${ECHO_MSG} "===>  Patching for ${PKGNAME}"
938real-configure: _PORT_USE
939	@${ECHO_MSG} "===>  Configuring for ${PKGNAME}"
940real-build: _PORT_USE
941	@${ECHO_MSG} "===>  Building for ${PKGNAME}"
942real-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}|"
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