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