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