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