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