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