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