xref: /freebsd/share/mk/bsd.port.mk (revision 2ad872c5794e4c26fdf6ed219ad3f09ca0d5304a)
1#-*- mode: Fundamental; tab-width: 4; -*-
2# ex:ts=4
3#
4#	$Id: bsd.port.mk,v 1.299 1998/11/25 00:12:27 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# There are two different types of "maintainers" in the whole ports
13# framework concept.  Maintainers of the bsd.port*.mk files
14# are listed below in the ${OPSYS}_MAINTAINER entries (this file
15# is used by multiple *BSD flavors).  You should consult them directly
16# if you have any questions/suggestions regarding this file since only
17# they are allowed to modify the master copies in the CVS repository!
18
19FreeBSD_MAINTAINER=	asami@FreeBSD.ORG
20OpenBSD_MAINTAINER=	imp@OpenBSD.ORG
21
22# For each port, the MAINTAINER variable is what you should consult for
23# contact information on the person(s) to contact if you have questions/
24# suggestions about that specific port.  By default (if no MAINTAINER
25# is listed), a port is maintained by the subscribers of the ports@freebsd.org
26# mailing list, and any correspondece should be directed there.
27#
28# MAINTAINER	- The e-mail address of the contact person for this port
29#				  (default: ports@FreeBSD.ORG).
30#
31# These are meta-variables that are automatically set to the system
32# you are running on.
33#
34# ARCH			- The architecture, as returned by "uname -m".
35# OPSYS			- Portability clause.  This is the operating system the
36#				  makefile is being used on.  Automatically set to
37#				  "FreeBSD," "NetBSD," or "OpenBSD" as appropriate.
38# OSREL			- The release version (numeric) of the operating system.
39# OSVERSION		- The value of __FreeBSD_version.
40# PORTOBJFORMAT	- The object format ("aout" or "elf").
41#
42# These variables are used to identify your port.
43#
44# DISTNAME		- Name of port or distribution.
45# PKGNAME		- Name of the package file to create if the DISTNAME
46#				  isn't really relevant for the port/package
47#				  (default: ${DISTNAME}).
48# CATEGORIES	- A list of descriptive categories into which this port falls.
49#
50# These variable describe how to fetch files required for building the port.
51#
52# DISTFILES		- Name(s) of archive file(s) containing distribution
53#				  (default: ${DISTNAME}${EXTRACT_SUFX}).  Set this to
54#				  an empty string if the port doesn't require it.
55# EXTRACT_SUFX	- Suffix for archive names (default: .tar.gz).  You
56#				  never have to set both DISTFILES and EXTRACT_SUFX.
57# MASTER_SITES	- Primary location(s) for distribution files if not found
58#				  locally.
59# PATCHFILES	- Name(s) of additional files that contain distribution
60#				  patches (default: none).  make will look for them at
61#				  PATCH_SITES (see below).  They will automatically be
62#				  uncompressed before patching if the names end with
63#				  ".gz" or ".Z".
64# PATCH_SITES	- Primary location(s) for distribution patch files
65#				  if not found locally.
66# DIST_SUBDIR	- Suffix to ${DISTDIR}.  If set, all ${DISTFILES}
67#				  and ${PATCHFILES} will be put in this subdirectory of
68#				  ${DISTDIR} (see below).  Also they will be fetched in
69#				  this subdirectory from FreeBSD mirror sites.
70# ALLFILES		- All of ${DISTFILES} and ${PATCHFILES}.
71# IGNOREFILES	- If some of the ${ALLFILES} are not checksum-able, set
72#				  this variable to their names.
73# EXTRACT_ONLY	- If defined, a subset of ${DISTFILES} you want to
74#			  	  actually extract.
75#
76# These three variables are typically set in /etc/make.conf to indicate
77# the user's preferred location to fetch files from.
78#
79# MASTER_SITE_BACKUP - Backup location(s) for distribution files and patch
80#				  files if not found locally and ${MASTER_SITES}/${PATCH_SITES}
81#				  (default:
82#				  ftp://ftp.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/)
83# MASTER_SITE_OVERRIDE - If set, override the MASTER_SITES setting with this
84#				  value.
85# MASTER_SITE_FREEBSD - If set, only use ${MASTER_SITE_BACKUP} for
86#				  MASTER_SITES.
87#
88# Set these if your port should not be built under certain circumstances.
89# These are string variables; you should set them to the reason why
90# they are necessary.
91#
92# RESTRICTED	- Port is restricted (e.g., contains cryptography, etc.).
93# NO_CDROM		- Port may not go on CDROM.
94# NO_PACKAGE	- Port should not be packaged but distfiles can be put on
95#				  ftp sites and CDROMs.
96# BROKEN_ELF	- Port doesn't build on ELF machines.
97# BROKEN		- Port is broken.
98#
99# This variable is a boolean, so you don't need to set it to the reason.
100#
101# IS_INTERACTIVE - Set this if your port needs to interact with the user
102#				  during a build.  User can then decide to skip this port by
103#				  setting ${BATCH}, or compiling only the interactive ports
104#				  by setting ${INTERACTIVE}.
105#
106# Use these if your port uses some of the common software packages.
107#
108# USE_GMAKE		- Says that the port uses gmake.
109# GMAKE			- Set to path of GNU make if not in $PATH (default: gmake).
110# USE_AUTOCONF	- Says that the port uses autoconf.  Implies GNU_CONFIGURE.
111# AUTOCONF		- Set to path of GNU autoconf if not in $PATH (default:
112#				  autoconf).
113# USE_PERL5		- Says that the port uses perl5 for building and running.
114# PERL5			- Set to full path of perl5, either in the system or
115#				  installed from a port.
116# PERL			- Set to full path of perl5, either in the system or
117#				  installed from a port, but without the version number.
118#				  Use this if you need to replace "#!" lines in scripts.
119# PERL_VERSION	- Full version of perl5 (see below for current value).
120# PERL_VER		- Short version of perl5 (see below for current value).
121# USE_IMAKE		- Says that the port uses imake.  Implies USE_X_PREFIX.
122# XMKMF			- Set to path of `xmkmf' if not in $PATH (default: xmkmf -a ).
123# NO_INSTALL_MANPAGES - For imake ports that don't like the install.man
124#						target.
125# USE_X_PREFIX	- Says that the port installs in ${X11BASE}.  Implies USE_XLIB.
126# USE_XLIB		- Says that the port uses X libraries.
127# USE_QT		- Says that the port uses the latest version of qt toolkit.
128#
129# Dependency checking.  Use these if your port requires another port
130# not in the list above.
131#
132# FETCH_DEPENDS - A list of "path:dir[:target]" tuples of other ports this
133#				  package depends in the "fetch" stage.  "path" is the
134#				  name of a file if it starts with a slash (/), an
135#				  executable otherwise.  make will test for the
136#				  existence (if it is a full pathname) or search for
137#				  it in your $PATH (if it is an executable) and go
138#				  into "dir" to do a "make all install" if it's not
139#				  found.  If the third field ("target") exists, it will
140#				  be used instead of ${DEPENDS_TARGET}.
141# BUILD_DEPENDS - A list of "path:dir[:target]" tuples of other ports this
142#				  package depends to build (between the "extract" and
143#				  "build" stages, inclusive).  The test done to
144#				  determine the existence of the dependency is the
145#				  same as FETCH_DEPENDS.  If the third field ("target")
146#				  exists, it will be used instead of ${DEPENDS_TARGET}.
147# RUN_DEPENDS	- A list of "path:dir[:target]" tuples 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.  If the third field
153#				  ("target") exists, it will be used instead of
154#				  ${DEPENDS_TARGET}.
155# LIB_DEPENDS	- A list of "lib:dir[:target]" tuples of other ports this
156#				  package depends on.  "lib" is the name of a shared library.
157#				  make will use "ldconfig -r" to search for the
158#				  library.  Note that lib can not contain regular expressions.
159# DEPENDS		- A list of "dir[:target]" tuples of other ports this
160#				  package depends on being made first.  Use this only for
161#				  things that don't fall into the above four categories.
162#				  If the second field ("target") exists, it will be used
163#				  instead of ${DEPENDS_TARGET}.
164# DEPENDS_TARGET - The default target to execute when a port is calling a
165#				  dependency (default: "install").
166#
167# Various directory definitions and variables to control them.
168# You rarely need to redefine any of these except WRKSRC and NO_WRKSUBDIR.
169#
170# X11BASE		- Where X11 ports install things (default: /usr/X11R6).
171# LOCALBASE		- Where non-X11 ports install things (default: /usr/local).
172# PREFIX		- Where *this* port installs its files (default: ${X11BASE}
173#				  if USE_X_PREFIX is set, otherwise ${LOCALBASE}).
174# MASTERDIR		- Where the port finds patches, package files, etc.  Define
175#				  this is you have two or more ports that share most of the
176#				  files (default: ${.CURDIR}).
177# PORTSDIR		- The root of the ports tree.  Defaults:
178#					FreeBSD/OpenBSD: /usr/ports
179#					NetBSD:          /usr/opt
180# DISTDIR 		- Where to get gzip'd, tarballed copies of original sources
181#				  (default: ${PORTSDIR}/distfiles).
182# PACKAGES		- A top level directory where all packages go (rather than
183#				  going locally to each port). (default: ${PORTSDIR}/packages).
184# WRKDIRPREFIX	- The place to root the temporary working directory
185#				  hierarchy (default: none).
186# WRKDIR 		- A temporary working directory that gets *clobbered* on clean
187#				  (default: ${WRKDIRPREFIX}${.CURDIR}/work).
188# WRKSRC		- A subdirectory of ${WRKDIR} where the distribution actually
189#				  unpacks to.  (Default: ${WRKDIR}/${DISTNAME} unless
190#				  NO_WRKSUBDIR is set, in which case simply ${WRKDIR}).
191# NO_WRKSUBDIR	- Assume port unpacks directly into ${WRKDIR}.
192# PATCHDIR 		- A directory containing any additional patches you made
193#				  to port this software to FreeBSD (default:
194#				  ${MASTERDIR}/patches)
195# SCRIPTDIR 	- A directory containing any auxiliary scripts
196#				  (default: ${MASTERDIR}/scripts)
197# FILESDIR 		- A directory containing any miscellaneous additional files.
198#				  (default: ${MASTERDIR}/files)
199# PKGDIR 		- A direction containing any package creation files.
200#				  (default: ${MASTERDIR}/pkg)
201#
202# Motif support:
203#
204# REQUIRES_MOTIF - Set this in your port if it requires Motif.  It will  be
205#				  built only if HAVE_MOTIF is set.
206# HAVE_MOTIF	- If set, means system has Motif.  Typically set in
207#				  /etc/make.conf.
208# MOTIF_STATIC	- If set, link libXm statically; otherwise, link it
209#				  dynamically.  Typically set in /etc/make.conf.
210# MOTIFLIB		- Set automatically to appropriate value depending on
211#				  ${MOTIF_STATIC}.  Substitute references to -lXm with
212#				  patches to make your port conform to our standards.
213# MOTIF_ONLY	- If set, build Motif ports only.  (Not much use except for
214#				  building packages.)
215#
216# Variables that serve as convenient "aliases" for your *-install targets.
217# Use these like: "${INSTALL_PROGRAM} ${WRKSRC}/prog ${PREFIX}/bin".
218#
219# INSTALL_PROGRAM - A command to install binary executables.
220# INSTALL_SCRIPT - A command to install executable scripts.
221# INSTALL_DATA	- A command to install sharable data.
222# INSTALL_MAN	- A command to install manpages (doesn't compress).
223#
224# Set the following to specify all manpages that your port installs.
225# These manpages will be automatically listed in ${PLIST}.  Depending
226# on the setting of NOMANCOMPRESS, the make rules will compress the
227# manpages for you.
228#
229# MAN<sect>		- A list of manpages, categorized by section.  For
230#				  example, if your port has "man/man1/foo.1" and
231#				  "man/mann/bar.n", set "MAN1=foo.1" and "MANN=bar.n".
232#				  The available sections chars are "123456789LN".
233# MLINKS		- A list of <target, source> tuples for creating links
234#				  for manpages.  For example, "MLINKS= a.1 b.1 c.3 d.3"
235#				  will do an "ln -sf a.1 b.1" and "ln -sf c.3 and d.3" in
236#				  appropriate directories.  (Use this even if the port
237#				  installs its own manpage links so they will show up
238#				  correctly in ${PLIST}.)
239# MANPREFIX		- The directory prefix for ${MAN<sect>} and ${MLINKS}
240#				  (default: ${PREFIX}).
241# MAN<sect>PREFIX - If manual pages of some sections install in different
242#				  locations than others, use these (default: ${MANPREFIX}).
243# MANCOMPRESSED - This variable can take values "yes", "no" or
244#				  "maybe".  "yes" means manpages are installed
245#				  compressed; "no" means they are not; "maybe" means
246#				  it changes depending on the value of
247#				  NOMANCOMPRESS.  The default is "yes" if USE_IMAKE
248#				  is set and NO_INSTALL_MANPAGES is not set, and
249#				  "no" otherwise.
250#
251# Default targets and their behaviors:
252#
253# fetch			- Retrieves ${DISTFILES} (and ${PATCHFILES} if defined)
254#				  into ${DISTDIR} as necessary.
255# fetch-list	- Show list of files that would be retrieved by fetch
256# extract		- Unpacks ${DISTFILES} into ${WRKDIR}.
257# patch			- Apply any provided patches to the source.
258# configure		- Runs either GNU configure, one or more local configure
259#				  scripts or nothing, depending on what's available.
260# build			- Actually compile the sources.
261# install		- Install the results of a build.
262# reinstall		- Install the results of a build, ignoring "already installed"
263#				  flag.
264# deinstall		- Remove the installation.
265# package		- Create a package from an _installed_ port.
266# describe		- Try to generate a one-line description for each port for
267#				  use in INDEX files and the like.
268# checkpatch	- Do a "patch -C" instead of a "patch".  Note that it may
269#				  give incorrect results if multiple patches deal with
270#				  the same file.
271# checksum		- Use files/md5 to ensure that your distfiles are valid.
272# makesum		- Generate files/md5 (only do this for your own ports!).
273#
274# Default sequence for "all" is:  fetch checksum extract patch configure build
275#
276# Please read the comments in the targets section below, you
277# should be able to use the pre-* or post-* targets/scripts
278# (which are available for every stage except checksum) or
279# override the do-* targets to do pretty much anything you want.
280#
281# NEVER override the "regular" targets unless you want to open
282# a major can of worms.
283#
284# Set these variables if your port doesn't need some of the steps.
285# Note that there are no NO_PATCH or NO_CONFIGURE variables becuase
286# those steps are empty by default.  NO_EXTRACT is not allowed anymore
287# since we need to at least create ${WRKDIR}.  Also, NO_CHECKSUM is a user
288# variable and is not to be set in a port's Makefile.  See above for NO_PACKAGE.
289#
290# NO_BUILD		- Use a dummy (do-nothing) build target.
291# NO_INSTALL	- Use a dummy (do-nothing) install target.
292#
293# Here are some variables used in various stages.
294#
295# For fetch:
296#
297# FETCH_CMD		  - Full path to ftp/http fetch command if not in $PATH
298#				  (default: /usr/bin/fetch).
299# FETCH_BEFORE_ARGS -
300#				  Arguments to ${FETCH_CMD} before filename (default: none).
301# FETCH_AFTER_ARGS -
302#				  Arguments to ${FETCH_CMD} following filename (default: none).
303#
304# For extract:
305#
306# EXTRACT_CMD	- Command for extracting archive (default: tar).
307# EXTRACT_BEFORE_ARGS -
308#				  Arguments to ${EXTRACT_CMD} before filename
309#				  (default: -xzf).
310# EXTRACT_AFTER_ARGS -
311#				  Arguments to ${EXTRACT_CMD} following filename
312#				  (default: none).
313#
314# For configure:
315#
316# HAS_CONFIGURE	- Says that the port has its own configure script.  The
317#				  configure stage will not do anything if this is not set.
318# GNU_CONFIGURE	- Set if you are using GNU configure (optional).  Implies
319#				  HAS_CONFIGURE.
320# CONFIGURE_SCRIPT - Name of configure script (defaults: configure).
321# CONFIGURE_ARGS - Pass these args to configure if ${HAS_CONFIGURE} is set.
322# CONFIGURE_ENV - Pass these env (shell-like) to configure if
323#				  ${HAS_CONFIGURE} is set.
324#
325# For build and install:
326#
327# MAKE_ENV		- Additional environment vars passed to sub-make in build
328#				  and install stages (default: see below).
329# MAKE_ARGS		- Any extra arguments to sub-make in build and install
330#				  stages (default: none).
331#
332# For install:
333#
334# NO_MTREE		- If set, will not invoke mtree from bsd.port.mk from
335#				  the "install" target.
336# MTREE_FILE	- The name of the mtree file (default: /etc/mtree/BSD.x11.dist
337#				  if USE_X_PREFIX is set, /etc/mtree/BSD.local.dist
338#				  otherwise.)
339# PLIST			- Name of the `packing list' file (default: ${PKGDIR}/PLIST).
340#				  Change this to ${WRKDIR}/PLIST or something if you
341#				  need to write to it.  (It is not a good idea for a port
342#				  to write to any file outside ${WRKDIR} during a normal
343#				  build.)
344# TMPPLIST		- Name of the `packing list' file after processing
345#				  (default: ${WRKDIR}/.PLIST.mktmp).
346# PLIST_SUB		- List of "variable=value" pair for substitution in ${PLIST}
347# 				  (default: see below).
348#
349# Note that the install target will automatically add manpages (see
350# above) and also substitute special sequences of characters (delimited
351# by "%%") as defined in PLIST_SUB to generate ${TMPPLIST}.  For
352# instance, "OSREL=${OSREL}" in PLIST_SUB causes all occurrences of
353# "%%OSREL%%" in ${PLIST} to be substituted by the value of OSREL.
354# ${TMPPLIST} is generated between the do-install and post-install
355# stages.  If you are generating the packing list on-the-fly, make
356# sure it's generated by the end of do-install!
357#
358# For package:
359#
360# NO_LATEST_LINK - Do not install the "Latest" link for package.  Define this
361#				  if this port is a beta version of another stable port
362#				  which is also in the tree.
363#
364# This is used in all stages:
365#
366# SCRIPTS_ENV	- Additional environment vars passed to scripts in
367#                 ${SCRIPTDIR} executed by bsd.port.mk (default: see below).
368#
369# Finally, variables to change if you want a special behavior.  These
370# are for debugging purposes.  Don't set them in your Makefile.
371#
372# ECHO_MSG		- Used to print all the '===>' style prompts - override this
373#				  to turn them off (default: /bin/echo).
374# PATCH_DEBUG	- If set, print out more information about the patches as
375#				  it attempts to apply them.
376# PKG_DBDIR		- Where package installation is recorded (default: /var/db/pkg)
377# NO_PKG_REGISTER - Don't register a port install as a package.
378# FORCE_PKG_REGISTER - If set, it will overwrite any existing package
379#				  registration information in ${PKG_DBDIR}/${PKGNAME}.
380# NO_DEPENDS	- Don't verify build of dependencies.
381# NO_CHECKSUM	- Don't verify the checksum.  Typically used when
382#				  when you noticed the distfile you just fetched has
383#				  a different checksum and you intend to verify if
384#				  the port still works with it.
385
386# Start of pre-makefile section.
387.if !defined(AFTERPORTMK)
388
389# Get the architecture
390.if !defined(ARCH)
391ARCH!=	/usr/bin/uname -m
392.endif
393
394# Get the operating system type
395.if !defined(OPSYS)
396OPSYS!=	/usr/bin/uname -s
397.endif
398
399# Get the operating system revision
400.if !defined(OSREL)
401OSREL!=	/usr/bin/uname -r | sed -e 's/[-(].*//'
402.endif
403
404# Get __FreeBSD_version
405.if !defined(OSVERSION)
406.if exists(/sbin/sysctl)
407OSVERSION!=	/sbin/sysctl -n kern.osreldate
408.else
409OSVERSION!=	/usr/sbin/sysctl -n kern.osreldate
410.endif
411.endif
412
413# Get the object format.
414.if !defined(PORTOBJFORMAT)
415PORTOBJFORMAT!=	test -x /usr/bin/objformat && /usr/bin/objformat || echo aout
416.endif
417
418MASTERDIR?=	${.CURDIR}
419
420# If they exist, include Makefile.inc, then architecture/operating
421# system specific Makefiles, then local Makefile.local.
422
423.if exists(${MASTERDIR}/../Makefile.inc)
424.include "${MASTERDIR}/../Makefile.inc"
425.endif
426
427.if exists(${MASTERDIR}/Makefile.${ARCH}-${OPSYS})
428.include "${MASTERDIR}/Makefile.${ARCH}-${OPSYS}"
429.elif exists(${MASTERDIR}/Makefile.${OPSYS})
430.include "${MASTERDIR}/Makefile.${OPSYS}"
431.elif exists(${MASTERDIR}/Makefile.${ARCH})
432.include "${MASTERDIR}/Makefile.${ARCH}"
433.endif
434
435.if exists(${MASTERDIR}/Makefile.local)
436.include "${MASTERDIR}/Makefile.local"
437.endif
438
439# These need to be absolute since we don't know how deep in the ports
440# tree we are and thus can't go relative.  They can, of course, be overridden
441# by individual Makefiles or local system make configuration.
442.if (${OPSYS} == "NetBSD")
443PORTSDIR?=		/usr/opt
444.else
445PORTSDIR?=		/usr/ports
446.endif
447LOCALBASE?=		${DESTDIR}/usr/local
448X11BASE?=		${DESTDIR}/usr/X11R6
449DISTDIR?=		${PORTSDIR}/distfiles
450_DISTDIR?=		${DISTDIR}/${DIST_SUBDIR}
451PACKAGES?=		${PORTSDIR}/packages
452TEMPLATES?=		${PORTSDIR}/templates
453
454.if exists(${MASTERDIR}/patches.${ARCH}-${OPSYS})
455PATCHDIR?=		${MASTERDIR}/patches.${ARCH}-${OPSYS}
456.elif exists(${MASTERDIR}/patches.${OPSYS})
457PATCHDIR?=		${MASTERDIR}/patches.${OPSYS}
458.elif exists(${MASTERDIR}/patches.${ARCH})
459PATCHDIR?=		${MASTERDIR}/patches.${ARCH}
460.else
461PATCHDIR?=		${MASTERDIR}/patches
462.endif
463
464.if exists(${MASTERDIR}/scripts.${ARCH}-${OPSYS})
465SCRIPTDIR?=		${MASTERDIR}/scripts.${ARCH}-${OPSYS}
466.elif exists(${MASTERDIR}/scripts.${OPSYS})
467SCRIPTDIR?=		${MASTERDIR}/scripts.${OPSYS}
468.elif exists(${MASTERDIR}/scripts.${ARCH})
469SCRIPTDIR?=		${MASTERDIR}/scripts.${ARCH}
470.else
471SCRIPTDIR?=		${MASTERDIR}/scripts
472.endif
473
474.if exists(${MASTERDIR}/files.${ARCH}-${OPSYS})
475FILESDIR?=		${MASTERDIR}/files.${ARCH}-${OPSYS}
476.elif exists(${MASTERDIR}/files.${OPSYS})
477FILESDIR?=		${MASTERDIR}/files.${OPSYS}
478.elif exists(${MASTERDIR}/files.${ARCH})
479FILESDIR?=		${MASTERDIR}/files.${ARCH}
480.else
481FILESDIR?=		${MASTERDIR}/files
482.endif
483
484.if exists(${MASTERDIR}/pkg.${ARCH}-${OPSYS})
485PKGDIR?=		${MASTERDIR}/pkg.${ARCH}-${OPSYS}
486.elif exists(${MASTERDIR}/pkg.${OPSYS})
487PKGDIR?=		${MASTERDIR}/pkg.${OPSYS}
488.elif exists(${MASTERDIR}/pkg.${ARCH})
489PKGDIR?=		${MASTERDIR}/pkg.${ARCH}
490.else
491PKGDIR?=		${MASTERDIR}/pkg
492.endif
493
494.if defined(USE_IMAKE)
495USE_X_PREFIX=	yes
496.endif
497.if defined(USE_X_PREFIX)
498USE_XLIB=		yes
499.endif
500.if defined(USE_X_PREFIX)
501PREFIX?=		${X11BASE}
502.else
503PREFIX?=		${LOCALBASE}
504.endif
505
506.endif
507# End of pre-makefile section.
508
509# Start of post-makefile section.
510.if !defined(BEFOREPORTMK)
511
512WRKDIR?=		${WRKDIRPREFIX}${.CURDIR}/work
513.if defined(NO_WRKSUBDIR)
514WRKSRC?=		${WRKDIR}
515.else
516WRKSRC?=		${WRKDIR}/${DISTNAME}
517.endif
518
519PLIST_SUB+=	OSREL=${OSREL}
520
521CONFIGURE_ENV+=	PORTOBJFORMAT=${PORTOBJFORMAT}
522SCRIPTS_ENV+=	PORTOBJFORMAT=${PORTOBJFORMAT}
523MAKE_ENV+=		PORTOBJFORMAT=${PORTOBJFORMAT}
524PLIST_SUB+=		PORTOBJFORMAT=${PORTOBJFORMAT}
525
526.if defined(MANCOMPRESSED)
527.if ${MANCOMPRESSED} != yes && ${MANCOMPRESSED} != no && \
528	${MANCOMPRESSED} != maybe
529.BEGIN:
530	@${ECHO_MSG} "Error: Value of MANCOMPRESSED (is \"${MANCOMPRESSED}\") can only be \"yes\", \"no\" or \"maybe\"".
531	@${FALSE}
532.endif
533.endif
534
535.if defined(USE_IMAKE) && ${OPSYS} != OpenBSD && !defined(NO_INSTALL_MANPAGES)
536MANCOMPRESSED?=	yes
537.else
538MANCOMPRESSED?=	no
539.endif
540
541.if defined(USE_GMAKE)
542BUILD_DEPENDS+=		gmake:${PORTSDIR}/devel/gmake
543.endif
544.if defined(USE_AUTOCONF)
545GNU_CONFIGURE=	yes
546BUILD_DEPENDS+=		autoconf:${PORTSDIR}/devel/autoconf
547.endif
548
549#.if defined(REQUIRES_MOTIF)
550#BUILD_DEPENDS+=		${X11BASE}/lib/libXm.a:${PORTSDIR}/tmp/motif
551#.endif
552
553PERL_VERSION=	5.00502
554PERL_VER=		5.005
555PLIST_SUB+=		PERL_VERSION=${PERL_VERSION} \
556				PERL_VER=${PERL_VER}
557.if exists(/usr/bin/perl5)
558# 3.0-current after perl5 import
559.if !exists(/usr/bin/perl${PERL_VERSION}) && defined(USE_PERL5)
560.BEGIN:
561	@${ECHO_MSG} "Error: you don't have the right version of perl in /usr/bin."
562	@${FALSE}
563.endif
564PERL5=			/usr/bin/perl${PERL_VERSION}
565PERL=			/usr/bin/perl
566.else
567PERL5=			${LOCALBASE}/bin/perl${PERL_VERSION}
568PERL=			${LOCALBASE}/bin/perl
569.if defined(USE_PERL5)
570BUILD_DEPENDS+=	perl${PERL_VERSION}:${PORTSDIR}/lang/perl5
571RUN_DEPENDS+=	perl${PERL_VERSION}:${PORTSDIR}/lang/perl5
572.endif
573.endif
574
575.if defined(USE_XLIB)
576LIB_DEPENDS+=	X11.6:${PORTSDIR}/x11/XFree86
577.endif
578
579.if defined(USE_QT)
580LIB_DEPENDS+=	qt.1:${PORTSDIR}/x11-toolkits/qt141
581.endif
582
583.if exists(${PORTSDIR}/../Makefile.inc)
584.include "${PORTSDIR}/../Makefile.inc"
585.endif
586
587# Don't change these!!!  These names are built into the _TARGET_USE macro,
588# there is no way to refer to them cleanly from within the macro AFAIK.
589EXTRACT_COOKIE?=	${WRKDIR}/.extract_done
590CONFIGURE_COOKIE?=	${WRKDIR}/.configure_done
591INSTALL_COOKIE?=	${WRKDIR}/.install_done
592BUILD_COOKIE?=		${WRKDIR}/.build_done
593PATCH_COOKIE?=		${WRKDIR}/.patch_done
594PACKAGE_COOKIE?=	${WRKDIR}/.package_done
595
596# How to do nothing.  Override if you, for some strange reason, would rather
597# do something.
598DO_NADA?=		/usr/bin/true
599
600# Miscellaneous overridable commands:
601GMAKE?=			gmake
602AUTOCONF?=		autoconf
603XMKMF?=			xmkmf -a
604.if exists(/sbin/md5)
605MD5?=			/sbin/md5
606.elif exists(/bin/md5)
607MD5?=			/bin/md5
608.elif exists(/usr/bin/md5)
609MD5?=			/usr/bin/md5
610.else
611MD5?=			md5
612.endif
613MD5_FILE=		${FILESDIR}/md5
614
615MAKE_FLAGS?=	-f
616MAKEFILE?=		Makefile
617MAKE_ENV+=		PREFIX=${PREFIX} LOCALBASE=${LOCALBASE} X11BASE=${X11BASE} MOTIFLIB="${MOTIFLIB}" CFLAGS="${CFLAGS}" LIBDIR="${LIBDIR}"
618
619.if exists(/usr/bin/fetch)
620FETCH_CMD?=		/usr/bin/fetch
621#FETCH_BEFORE_ARGS+=	$${CKSIZE:+-S $$CKSIZE}
622.else
623FETCH_CMD?=		/usr/bin/ftp
624.endif
625
626TOUCH?=			/usr/bin/touch
627TOUCH_FLAGS?=	-f
628
629PATCH?=			/usr/bin/patch
630PATCH_STRIP?=	-p0
631PATCH_DIST_STRIP?=	-p0
632.if defined(PATCH_DEBUG)
633PATCH_DEBUG_TMP=	yes
634PATCH_ARGS?=	-d ${WRKSRC} -E ${PATCH_STRIP}
635PATCH_DIST_ARGS?=	-d ${WRKSRC} -E ${PATCH_DIST_STRIP}
636.else
637PATCH_DEBUG_TMP=	no
638PATCH_ARGS?=	-d ${WRKSRC} --forward --quiet -E ${PATCH_STRIP}
639PATCH_DIST_ARGS?=	-d ${WRKSRC} --forward --quiet -E ${PATCH_DIST_STRIP}
640.endif
641.if defined(BATCH)
642PATCH_ARGS+=		--batch
643PATCH_DIST_ARGS+=	--batch
644.endif
645
646.if defined(PATCH_CHECK_ONLY)
647PATCH_ARGS+=	-C
648PATCH_DIST_ARGS+=	-C
649.endif
650
651.if exists(/bin/tar)
652EXTRACT_CMD?=	/bin/tar
653.else
654EXTRACT_CMD?=	/usr/bin/tar
655.endif
656EXTRACT_SUFX?=	.tar.gz
657# Backwards compatability.
658.if defined(EXTRACT_ARGS)
659EXTRACT_BEFORE_ARGS?=   ${EXTRACT_ARGS}
660.else
661EXTRACT_BEFORE_ARGS?=   -xzf
662.endif
663
664# Figure out where the local mtree file is
665.if !defined(MTREE_FILE)
666.if defined(USE_X_PREFIX)
667MTREE_FILE=	/etc/mtree/BSD.x11.dist
668.else
669MTREE_FILE=	/etc/mtree/BSD.local.dist
670.endif
671.endif
672MTREE_CMD?=	/usr/sbin/mtree
673MTREE_ARGS?=	-U -f ${MTREE_FILE} -d -e -p
674
675# A few aliases for *-install targets
676INSTALL_PROGRAM= \
677	${INSTALL} ${COPY} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE}
678INSTALL_SCRIPT= \
679	${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE}
680INSTALL_DATA= \
681	${INSTALL} ${COPY} -o ${SHAREOWN} -g ${SHAREGRP} -m ${SHAREMODE}
682INSTALL_MAN= \
683	${INSTALL} ${COPY} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE}
684
685INSTALL_MACROS=	BSD_INSTALL_PROGRAM="${INSTALL_PROGRAM}" \
686			BSD_INSTALL_SCRIPT="${INSTALL_SCRIPT}" \
687			BSD_INSTALL_DATA="${INSTALL_DATA}" \
688			BSD_INSTALL_MAN="${INSTALL_MAN}"
689MAKE_ENV+=	${INSTALL_MACROS}
690SCRIPTS_ENV+=	${INSTALL_MACROS}
691
692# The user can override the NO_PACKAGE by specifying this from
693# the make command line
694.if defined(FORCE_PACKAGE)
695.undef NO_PACKAGE
696.endif
697
698COMMENT?=	${PKGDIR}/COMMENT
699DESCR?=		${PKGDIR}/DESCR
700PLIST?=		${PKGDIR}/PLIST
701TMPPLIST?=	${WRKDIR}/.PLIST.mktmp
702PKGINSTALL?=		${PKGDIR}/INSTALL
703PKGDEINSTALL?=		${PKGDIR}/DEINSTALL
704PKGREQ?=			${PKGDIR}/REQ
705PKGMESSAGE?=		${PKGDIR}/MESSAGE
706
707PKG_CMD?=		/usr/sbin/pkg_create
708PKG_DELETE?=	/usr/sbin/pkg_delete
709.if !defined(PKG_ARGS)
710PKG_ARGS=		-v -c ${COMMENT} -d ${DESCR} -f ${TMPPLIST} -p ${PREFIX} -P "`${MAKE} package-depends|sort -u`" ${EXTRA_PKG_ARGS}
711.if exists(${PKGINSTALL})
712PKG_ARGS+=		-i ${PKGINSTALL}
713.endif
714.if exists(${PKGDEINSTALL})
715PKG_ARGS+=		-k ${PKGDEINSTALL}
716.endif
717.if exists(${PKGREQ})
718PKG_ARGS+=		-r ${PKGREQ}
719.endif
720.if exists(${PKGMESSAGE})
721PKG_ARGS+=		-D ${PKGMESSAGE}
722.endif
723.if !defined(NO_MTREE)
724PKG_ARGS+=		-m ${MTREE_FILE}
725.endif
726.endif
727.if defined(PKG_NOCOMPRESS)
728PKG_SUFX?=		.tar
729.else
730PKG_SUFX?=		.tgz
731.endif
732# where pkg_add records its dirty deeds.
733PKG_DBDIR?=		/var/db/pkg
734
735# shared/dynamic motif libs
736.if defined(HAVE_MOTIF)
737.if defined(MOTIF_STATIC)
738MOTIFLIB?=	${X11BASE}/lib/libXm.a
739.else
740MOTIFLIB?=	-L${X11BASE}/lib -lXm
741.endif
742.endif
743
744AWK?=		/usr/bin/awk
745BASENAME?=	/usr/bin/basename
746CAT?=		/bin/cat
747CP?=		/bin/cp
748ECHO?=		/bin/echo
749EXPR?=		/bin/expr
750FALSE?=		/usr/bin/false
751GREP?=		/usr/bin/grep
752GUNZIP_CMD?=	/usr/bin/gunzip -f
753GZCAT?=		/usr/bin/gzcat
754GZIP?=		-9
755GZIP_CMD?=	/usr/bin/gzip -nf ${GZIP}
756LDCONFIG?=	/sbin/ldconfig
757LN?=		/bin/ln
758MKDIR?=		/bin/mkdir -p
759MV?=		/bin/mv
760RM?=		/bin/rm
761RMDIR?=		/bin/rmdir
762SED?=		/usr/bin/sed
763SETENV?=	/usr/bin/env
764SH?=		/bin/sh
765TR?=		/usr/bin/tr
766TRUE?=		/usr/bin/true
767
768# Used to print all the '===>' style prompts - override this to turn them off.
769ECHO_MSG?=		${ECHO}
770
771.for sub in ${PLIST_SUB}
772_sedsubplist!=	sym=`${ECHO} "${sub}" | ${SED} -e 's/=.*//'`; \
773		val=`${ECHO} "${sub}" | ${SED} -e 's/^[^=][^=]*=//'`; \
774		echo "${_sedsubplist} -e s!%%$${sym}%%!$${val}!g"
775.endfor
776
777ALL_TARGET?=		all
778INSTALL_TARGET?=	install
779
780# Popular master sites
781MASTER_SITE_XCONTRIB+=	\
782	ftp://crl.dec.com/pub/X11/contrib/%SUBDIR%/ \
783    ftp://ftp.eu.net/X11/contrib/%SUBDIR%/
784
785MASTER_SITE_GNU+=	\
786	ftp://prep.ai.mit.edu/pub/gnu/%SUBDIR%/ \
787	ftp://wuarchive.wustl.edu/systems/gnu/%SUBDIR%/ \
788	ftp://ftp.kddlabs.co.jp/pub/gnu/%SUBDIR%/ \
789	ftp://ftp.digex.net/pub/gnu/%SUBDIR%/ \
790	ftp://ftp.univ-evry.fr/pub/gnu/%SUBDIR%/ \
791	ftp://ftp.cdrom.com/pub/gnu/%SUBDIR%/ \
792	ftp://ftp.duke.edu/pub/gnu/%SUBDIR%/ \
793	ftp://ftp.gamma.ru/pub/gnu/%SUBDIR%/ \
794	ftp://ftp.nihon-u.ac.jp/pub/gnu/%SUBDIR%/
795
796MASTER_SITE_PERL_CPAN+=	\
797	ftp://ftp.digital.com/pub/plan/perl/CPAN/modules/by-module/%SUBDIR%/ \
798	ftp://ftp.cdrom.com/pub/perl/CPAN/modules/by-module/%SUBDIR%/
799
800MASTER_SITE_TEX_CTAN+=  \
801        ftp://ftp.cdrom.com/pub/tex/ctan/%SUBDIR%/  \
802        ftp://wuarchive.wustl.edu/packages/TeX/%SUBDIR%/  \
803        ftp://ftp.funet.fi/pub/TeX/CTAN/%SUBDIR%/  \
804        ftp://ftp.tex.ac.uk/tex-archive/%SUBDIR%/  \
805        ftp://ftp.dante.de/tex-archive/%SUBDIR%/
806
807MASTER_SITE_SUNSITE+=	\
808	ftp://sunsite.unc.edu/pub/Linux/%SUBDIR%/ \
809	ftp://ftp.infomagic.com/pub/mirrors/linux/sunsite/%SUBDIR%/ \
810	ftp://ftp.funet.fi/pub/mirrors/sunsite.unc.edu/pub/Linux/%SUBDIR%/
811
812MASTER_SITE_KDE+=	\
813	ftp://ftp.us.kde.org/pub/kde/%SUBDIR%/ \
814	ftp://ftp.kde.org/pub/kde/%SUBDIR%/ \
815	ftp://ftp.tuniv.szczecin.pl/pub/kde/%SUBDIR%/ \
816	ftp://ftp.fu-berlin.de/pub/unix/X11/gui/kde/%SUBDIR%/ \
817	ftp://ftp.blaze.net.au/pub/kde/%SUBDIR%/ \
818	ftp://ftp.dataplus.se/pub/linux/kde/%SUBDIR%/ \
819	ftp://ftp.caldera.com/pub/mirrors/kde/%SUBDIR%/
820
821# Empty declaration to avoid "variable MASTER_SITES recursive" error
822MASTER_SITES?=
823PATCH_SITES?=
824
825# To avoid double-slashes
826MASTER_SITE_SUBDIR?=	.
827PATCH_SITE_SUBDIR?=	.
828
829# Substitute subdirectory names
830MASTER_SITES:=	${MASTER_SITES:S/%SUBDIR%/${MASTER_SITE_SUBDIR}/}
831PATCH_SITES:=	${PATCH_SITES:S/%SUBDIR%/${PATCH_SITE_SUBDIR}/}
832
833# The primary backup site.
834MASTER_SITE_BACKUP?=	\
835	ftp://ftp.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/
836
837# If the user has this set, go to the FreeBSD repository for everything.
838.if defined(MASTER_SITE_FREEBSD)
839MASTER_SITE_OVERRIDE=  ${MASTER_SITE_BACKUP}
840.endif
841
842# Where to put distfiles that don't have any other master site
843MASTER_SITE_LOCAL?= \
844	ftp://ftp.freebsd.org/pub/FreeBSD/distfiles/LOCAL_PORTS/
845
846# I guess we're in the master distribution business! :)  As we gain mirror
847# sites for distfiles, add them to this list.
848.if !defined(MASTER_SITE_OVERRIDE)
849MASTER_SITES+=	${MASTER_SITE_BACKUP}
850PATCH_SITES+=	${MASTER_SITE_BACKUP}
851.else
852MASTER_SITES:=	${MASTER_SITE_OVERRIDE} ${MASTER_SITES}
853PATCH_SITES:=	${MASTER_SITE_OVERRIDE} ${PATCH_SITES}
854.endif
855
856# Search CDROM first if mounted, symlink instead of copy if
857# FETCH_SYMLINK_DISTFILES is set
858CD_MOUNTPT?=	/cdrom
859.if exists(${CD_MOUNTPT}/ports/distfiles)
860MASTER_SITES:=	file:${CD_MOUNTPT}/ports/distfiles/${DIST_SUBDIR}/ ${MASTER_SITES}
861PATCH_SITES:=	file:${CD_MOUNTPT}/ports/distfiles/${DIST_SUBDIR}/ ${PATCH_SITES}
862.if defined(FETCH_SYMLINK_DISTFILES)
863FETCH_BEFORE_ARGS+=	-l
864.endif
865.endif
866
867# Derived names so that they're easily overridable.
868DISTFILES?=		${DISTNAME}${EXTRACT_SUFX}
869PKGNAME?=		${DISTNAME}
870
871ALLFILES?=	${DISTFILES} ${PATCHFILES}
872
873.if defined(IGNOREFILES)
874CKSUMFILES!=	\
875	for file in ${ALLFILES}; do \
876		ignore=0; \
877		for tmp in ${IGNOREFILES}; do \
878			if [ "$$file" = "$$tmp" ]; then \
879				ignore=1; \
880			fi; \
881		done; \
882		if [ "$$ignore" = 0 ]; then \
883			echo "$$file"; \
884		fi; \
885	done
886.else
887CKSUMFILES=		${ALLFILES}
888.endif
889
890# List of all files, with ${DIST_SUBDIR} in front.  Used for checksum.
891.if defined(DIST_SUBDIR)
892_CKSUMFILES?=	${CKSUMFILES:S/^/${DIST_SUBDIR}\//}
893_IGNOREFILES?=	${IGNOREFILES:S/^/${DIST_SUBDIR}\//}
894.else
895_CKSUMFILES?=	${CKSUMFILES}
896_IGNOREFILES?=	${IGNOREFILES}
897.endif
898
899# This is what is actually going to be extracted, and is overridable
900#  by user.
901EXTRACT_ONLY?=	${DISTFILES}
902
903# Documentation
904MAINTAINER?=	ports@FreeBSD.ORG
905
906.if !defined(CATEGORIES)
907.BEGIN:
908	@${ECHO_MSG} "CATEGORIES is mandatory."
909	@${FALSE}
910.endif
911
912# Note this has to start with a capital letter (or more accurately, it
913#  shouldn't match "[a-z]*"), see the target "delete-package-links" below.
914PKGREPOSITORYSUBDIR?=	All
915PKGREPOSITORY?=		${PACKAGES}/${PKGREPOSITORYSUBDIR}
916.if exists(${PACKAGES})
917PKGFILE?=		${PKGREPOSITORY}/${PKGNAME}${PKG_SUFX}
918.else
919PKGFILE?=		${.CURDIR}/${PKGNAME}${PKG_SUFX}
920.endif
921
922# The "latest version" link -- ${PKGNAME} minus everthing after the last '-'
923PKGLATESTREPOSITORY?=	${PACKAGES}/Latest
924PKGBASE!=	${ECHO} ${PKGNAME} | ${SED} -e 's/-[^-]*$$//'
925PKGLATESTFILE?=		${PKGLATESTREPOSITORY}/${PKGBASE}${PKG_SUFX}
926
927CONFIGURE_SCRIPT?=	configure
928
929.if defined(GNU_CONFIGURE)
930CONFIGURE_ARGS+=	--prefix=${PREFIX}
931HAS_CONFIGURE=		yes
932.endif
933
934# Passed to most of script invocations
935SCRIPTS_ENV+=	CURDIR=${MASTERDIR} DISTDIR=${DISTDIR} \
936		  WRKDIR=${WRKDIR} WRKSRC=${WRKSRC} PATCHDIR=${PATCHDIR} \
937		  SCRIPTDIR=${SCRIPTDIR} FILESDIR=${FILESDIR} \
938		  PORTSDIR=${PORTSDIR} DEPENDS="${DEPENDS}" \
939		  PREFIX=${PREFIX} LOCALBASE=${LOCALBASE} X11BASE=${X11BASE}
940
941.if defined(BATCH)
942SCRIPTS_ENV+=	BATCH=yes
943.endif
944
945MANPREFIX?=	${PREFIX}
946
947.for sect in 1 2 3 4 5 6 7 8 9
948MAN${sect}PREFIX?=	${MANPREFIX}
949.endfor
950MANLPREFIX?=	${MANPREFIX}
951MANNPREFIX?=	${MANPREFIX}
952
953MANLANG?=	""	# english only by default
954
955.if !defined(NOMANCOMPRESS)
956MANEXT=	.gz
957.endif
958
959.if defined(MLINKS)
960__pmlinks!=	${ECHO} '${MLINKS:S/	/ /}' | ${AWK} \
961 '{ if (NF % 2 != 0) { print "broken"; exit; } \
962	for (i=1; i<=NF; i++) { \
963		if ($$i ~ /^-$$/ && i != 1 && i % 2 != 0) \
964			{ $$i = $$(i-2); printf " " $$i " "; } \
965		else if ($$i ~ /^[^ ]+\.[1-9ln][^. ]*$$/ || $$i ~ /^\//) \
966			printf " " $$i " "; \
967		else \
968			{ print "broken"; exit; } \
969	} \
970  }' | ${SED} -e 's/ \/[^ ]*/ &x/g' -e 's/ [^/ ][^ ]*\.\(.\)[^. ]*/ &\1/g'
971.if ${__pmlinks:Mbroken} == "broken"
972.BEGIN:
973	@${ECHO_MSG} "Error: Unable to parse MLINKS."
974	@${FALSE}
975.endif
976.endif
977
978.for lang in ${MANLANG}
979
980.for sect in 1 2 3 4 5 6 7 8 9
981.if defined(MAN${sect})
982_MANPAGES+=	${MAN${sect}:S%^%${MAN${sect}PREFIX}/man/${lang}/man${sect}/%}
983.endif
984.endfor
985
986.if defined(MANL)
987_MANPAGES+=	${MANL:S%^%${MANLPREFIX}/man/${lang}/manl/%}
988.endif
989
990.if defined(MANN)
991_MANPAGES+=	${MANN:S%^%${MANNPREFIX}/man/${lang}/mann/%}
992.endif
993
994.if defined(MLINKS)
995.for __page in ${__pmlinks}
996__name=	${__page:S// /:N[1-9lnx]}
997__sect=	${__page:S// /:M[1-9lnx]}
998.if ${__name:M/*}x == x
999_MLINKS+=	${MAN${__sect:S/l/L/:S/n/N/}PREFIX}/man/${lang}/man${__sect}/${__name}${MANEXT}
1000.else
1001_MLINKS+=	${__name}${MANEXT}
1002.endif
1003_MLINKS:=	${_MLINKS}
1004.endfor
1005.endif
1006
1007.endfor lang in ${MANLANG}
1008
1009_TMLINKS!=	${ECHO} ${_MLINKS} | ${AWK} '{for (i=2; i<=NF; i+=2) print $$i}'
1010
1011.if defined(_MANPAGES) && defined(NOMANCOMPRESS)
1012__MANPAGES:=	${_MANPAGES:S^${PREFIX}/^^:S/""//:S^//^/^g}
1013.elif defined(_MANPAGES)
1014__MANPAGES:=	${_MANPAGES:S^${PREFIX}/^^:S/""//:S^//^/^g:S/$/.gz/}
1015.endif
1016
1017.if defined(_MANPAGES) && ${MANCOMPRESSED} == "yes"
1018_MANPAGES:=	${_MANPAGES:S/$/.gz/}
1019.endif
1020
1021.MAIN: all
1022
1023################################################################
1024# Many ways to disable a port.
1025#
1026# If we're in BATCH mode and the port is interactive, or we're
1027# in interactive mode and the port is non-interactive, skip all
1028# the important targets.  The reason we have two modes is that
1029# one might want to leave a build in BATCH mode running
1030# overnight, then come back in the morning and do _only_ the
1031# interactive ones that required your intervention.
1032#
1033# Don't attempt to build ports that require Motif if you don't
1034# have Motif.
1035#
1036# Ignore ports that can't be resold if building for a CDROM.
1037#
1038# Don't build a port if it's restricted and we don't want to get
1039# into that.
1040#
1041# Don't build a port on an ELF machine if it's broken for ELF.
1042#
1043# Don't build a port if it's broken.
1044################################################################
1045
1046OLDSYSTCL!=	${ECHO} /usr/include/tcl.h /usr/lib/libtcl??.so.*.*
1047OLDTCL=		${LOCALBASE}/include/tcl.h ${LOCALBASE}/lib/tclConfig.sh
1048OLDTK=		${LOCALBASE}/include/tk.h ${LOCALBASE}/lib/tkConfig.sh
1049
1050.if !defined(NO_IGNORE)
1051.for file in ${OLDSYSTCL} ${OLDTCL}
1052.if exists(${file})
1053IGNORE=	": You have an old file \(${file}\) that could cause problems for some ports to compile.  Please remove it and try again.  You may have to reinstall tcl from the ports tree afterwards"
1054.endif
1055.endfor
1056.for file in ${OLDTK}
1057.if exists(${file})
1058IGNORE=	": You have an old file \(${file}\) that could cause problems for some ports to compile.  Please remove it and try again.  You may have to reinstall tk from the ports tree afterwards"
1059.endif
1060.endfor
1061.endif
1062
1063.if !defined(NO_IGNORE)
1064.if (defined(IS_INTERACTIVE) && defined(BATCH))
1065IGNORE=	"is an interactive port"
1066.elif (!defined(IS_INTERACTIVE) && defined(INTERACTIVE))
1067IGNORE=	"is not an interactive port"
1068.elif (defined(REQUIRES_MOTIF) && !defined(HAVE_MOTIF))
1069IGNORE=	"requires Motif"
1070.elif (defined(MOTIF_ONLY) && !defined(REQUIRES_MOTIF))
1071IGNORE=	"does not require Motif"
1072.elif (defined(NO_CDROM) && defined(FOR_CDROM))
1073IGNORE=	"may not be placed on a CDROM: ${NO_CDROM}"
1074.elif (defined(RESTRICTED) && defined(NO_RESTRICTED))
1075IGNORE=	"is restricted: ${RESTRICTED}"
1076.elif defined(NO_WRKDIR)
1077IGNORE=	"defines NO_WRKDIR, which is obsoleted.  If you are defining NO_WRKDIR and NO_EXTRACT, try changing it to NO_WRKSUBDIR=yes and EXTRACT_ONLY= \(the right side intentionally left empty\)"
1078.elif defined(NO_EXTRACT)
1079IGNORE=	"defines NO_EXTRACT, which is obsoleted.  Try changing it to EXTRACT_ONLY= \(the right side intentionally left empty\)"
1080.elif defined(NO_CONFIGURE)
1081IGNORE=	"defines NO_CONFIGURE, which is obsoleted"
1082.elif defined(NO_PATCH)
1083IGNORE=	"defines NO_PATCH, which is obsoleted"
1084.elif (defined(BROKEN_ELF) && (${PORTOBJFORMAT} == "elf"))
1085IGNORE=	"is broken for ELF: ${BROKEN_ELF}"
1086.elif defined(BROKEN)
1087IGNORE=	"is marked as broken: ${BROKEN}"
1088.endif
1089
1090.if (defined(MANUAL_PACKAGE_BUILD) && defined(PACKAGE_BUILDING) && !defined(PARALLEL_PACKAGE_BUILD))
1091IGNORE=	"has to be built manually: ${MANUAL_PACKAGE_BUILD}"
1092clean:
1093	@${IGNORECMD}
1094.endif
1095
1096.if defined(IGNORE)
1097.if defined(IGNORE_SILENT)
1098IGNORECMD=	${DO_NADA}
1099.else
1100IGNORECMD=	${ECHO_MSG} "===>  ${PKGNAME} ${IGNORE}."
1101.endif
1102fetch:
1103	@${IGNORECMD}
1104checksum:
1105	@${IGNORECMD}
1106extract:
1107	@${IGNORECMD}
1108patch:
1109	@${IGNORECMD}
1110configure:
1111	@${IGNORECMD}
1112all:
1113	@${IGNORECMD}
1114build:
1115	@${IGNORECMD}
1116install:
1117	@${IGNORECMD}
1118reinstall:
1119	@${IGNORECMD}
1120package:
1121	@${IGNORECMD}
1122ignorelist: package-name
1123.else
1124ignorelist:
1125	@${DO_NADA}
1126.endif
1127
1128.endif
1129
1130################################################################
1131# Clean directories for ftp or CDROM.
1132################################################################
1133
1134.if defined(RESTRICTED)
1135clean-restricted:	delete-distfiles delete-package
1136.else
1137clean-restricted:
1138.endif
1139
1140.if defined(NO_CDROM)
1141clean-for-cdrom:	delete-distfiles delete-package
1142.else
1143clean-for-cdrom:
1144.endif
1145
1146.if defined(ALL_HOOK)
1147all:
1148	@cd ${.CURDIR} && ${SETENV} CURDIR=${.CURDIR} DISTNAME=${DISTNAME} \
1149	  DISTDIR=${DISTDIR} WRKDIR=${WRKDIR} WRKSRC=${WRKSRC} \
1150	  PATCHDIR=${PATCHDIR} SCRIPTDIR=${SCRIPTDIR} \
1151	  FILESDIR=${FILESDIR} PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} \
1152	  DEPENDS="${DEPENDS}" BUILD_DEPENDS="${BUILD_DEPENDS}" \
1153	  RUN_DEPENDS="${RUN_DEPENDS}" X11BASE=${X11BASE} \
1154	${ALL_HOOK}
1155.endif
1156
1157.if !target(all)
1158all: build
1159.endif
1160
1161.if !defined(DEPENDS_TARGET)
1162.if make(reinstall)
1163DEPENDS_TARGET=	reinstall
1164.else
1165DEPENDS_TARGET=	install
1166.endif
1167.endif
1168
1169################################################################
1170# The following are used to create easy dummy targets for
1171# disabling some bit of default target behavior you don't want.
1172# They still check to see if the target exists, and if so don't
1173# do anything, since you might want to set this globally for a
1174# group of ports in a Makefile.inc, but still be able to
1175# override from an individual Makefile.
1176################################################################
1177
1178# Disable checksum
1179.if defined(NO_CHECKSUM) && !target(checksum)
1180checksum: fetch
1181	@${DO_NADA}
1182.endif
1183
1184# Disable build
1185.if defined(NO_BUILD) && !target(build)
1186build: configure
1187	@${TOUCH} ${TOUCH_FLAGS} ${BUILD_COOKIE}
1188.endif
1189
1190# Disable install
1191.if defined(NO_INSTALL) && !target(install)
1192install: build
1193	@${TOUCH} ${TOUCH_FLAGS} ${INSTALL_COOKIE}
1194.endif
1195
1196# Disable package
1197.if defined(NO_PACKAGE) && !target(package)
1198package:
1199.if defined(IGNORE_SILENT)
1200	@${DO_NADA}
1201.else
1202	@${ECHO_MSG} "===>  ${PKGNAME} may not be packaged: ${NO_PACKAGE}."
1203.endif
1204.endif
1205
1206# Disable describe
1207.if defined(NO_DESCRIBE) && !target(describe)
1208describe:
1209	@${DO_NADA}
1210.endif
1211
1212################################################################
1213# More standard targets start here.
1214#
1215# These are the body of the build/install framework.  If you are
1216# not happy with the default actions, and you can't solve it by
1217# adding pre-* or post-* targets/scripts, override these.
1218################################################################
1219
1220# Fetch
1221
1222.if !target(do-fetch)
1223do-fetch:
1224	@${MKDIR} ${_DISTDIR}
1225	@(cd ${_DISTDIR}; \
1226	 for file in ${DISTFILES}; do \
1227		if [ ! -f $$file -a ! -f `${BASENAME} $$file` ]; then \
1228			if [ -h $$file -o -h `${BASENAME} $$file` ]; then \
1229				${ECHO_MSG} ">> ${_DISTDIR}/$$file is a broken symlink."; \
1230				${ECHO_MSG} ">> Perhaps a filesystem (most likely a CD) isn't mounted?"; \
1231				${ECHO_MSG} ">> Please correct this problem and try again."; \
1232				exit 1; \
1233			fi ; \
1234			${ECHO_MSG} ">> $$file doesn't seem to exist on this system."; \
1235			for site in ${MASTER_SITES}; do \
1236			    ${ECHO_MSG} ">> Attempting to fetch from $${site}."; \
1237				DIR=${DIST_SUBDIR}; \
1238				CKSIZE=`${GREP} "^SIZE ($${DIR:+$$DIR/}$$file)" ${MD5_FILE} | ${AWK} '{print $$4}'`; \
1239				if ${FETCH_CMD} ${FETCH_BEFORE_ARGS} $${site}$${file} ${FETCH_AFTER_ARGS}; then \
1240					continue 2; \
1241				fi \
1242			done; \
1243			${ECHO_MSG} ">> Couldn't fetch it - please try to retrieve this";\
1244			${ECHO_MSG} ">> port manually into ${_DISTDIR} and try again."; \
1245			exit 1; \
1246	    fi \
1247	 done)
1248.if defined(PATCHFILES)
1249	@(cd ${_DISTDIR}; \
1250	 for file in ${PATCHFILES}; do \
1251		if [ ! -f $$file -a ! -f `${BASENAME} $$file` ]; then \
1252			if [ -h $$file -o -h `${BASENAME} $$file` ]; then \
1253				${ECHO_MSG} ">> ${_DISTDIR}/$$file is a broken symlink."; \
1254				${ECHO_MSG} ">> Perhaps a filesystem (most likely a CD) isn't mounted?"; \
1255				${ECHO_MSG} ">> Please correct this problem and try again."; \
1256				exit 1; \
1257			fi ; \
1258			${ECHO_MSG} ">> $$file doesn't seem to exist on this system."; \
1259			for site in ${PATCH_SITES}; do \
1260			    ${ECHO_MSG} ">> Attempting to fetch from $${site}."; \
1261				DIR=${DIST_SUBDIR}; \
1262				CKSIZE=`${GREP} "^SIZE ($${DIR:+$$DIR/}$$file)" ${MD5_FILE} | ${AWK} '{print $$4}'`; \
1263				if ${FETCH_CMD} ${FETCH_BEFORE_ARGS} $${site}$${file} ${FETCH_AFTER_ARGS}; then \
1264					continue 2; \
1265				fi \
1266			done; \
1267			${ECHO_MSG} ">> Couldn't fetch it - please try to retrieve this";\
1268			${ECHO_MSG} ">> port manually into ${_DISTDIR} and try again."; \
1269			exit 1; \
1270	    fi \
1271	 done)
1272.endif
1273.endif
1274
1275# Extract
1276
1277.if !target(do-extract)
1278do-extract:
1279	@${RM} -rf ${WRKDIR}
1280	@${MKDIR} ${WRKDIR}
1281	@for file in ${EXTRACT_ONLY}; do \
1282		if ! (cd ${WRKDIR} && ${EXTRACT_CMD} ${EXTRACT_BEFORE_ARGS} ${_DISTDIR}/$$file ${EXTRACT_AFTER_ARGS});\
1283		then \
1284			exit 1; \
1285		fi \
1286	done
1287.endif
1288
1289# Patch
1290
1291.if !target(do-patch)
1292do-patch:
1293.if defined(PATCHFILES)
1294	@${ECHO_MSG} "===>  Applying distribution patches for ${PKGNAME}"
1295	@(cd ${_DISTDIR}; \
1296	  for i in ${PATCHFILES}; do \
1297		if [ ${PATCH_DEBUG_TMP} = yes ]; then \
1298			${ECHO_MSG} "===>   Applying distribution patch $$i" ; \
1299		fi; \
1300		case $$i in \
1301			*.Z|*.gz) \
1302				${GZCAT} $$i | ${PATCH} ${PATCH_DIST_ARGS}; \
1303				;; \
1304			*) \
1305				${PATCH} ${PATCH_DIST_ARGS} < $$i; \
1306				;; \
1307		esac; \
1308	  done)
1309.endif
1310	@if [ -d ${PATCHDIR} ]; then \
1311		if [ "`echo ${PATCHDIR}/patch-*`" = "${PATCHDIR}/patch-*" ]; then \
1312			${ECHO_MSG} "===>   Ignoring empty patch directory"; \
1313			if [ -d ${PATCHDIR}/CVS ]; then \
1314				${ECHO_MSG} "===>   Perhaps you forgot the -P flag to cvs co or update?"; \
1315			fi; \
1316		else \
1317			${ECHO_MSG} "===>  Applying ${OPSYS} patches for ${PKGNAME}" ; \
1318			for i in ${PATCHDIR}/patch-*; do \
1319				case $$i in \
1320					*.orig|*.rej|*~) \
1321						${ECHO_MSG} "===>   Ignoring patchfile $$i" ; \
1322						;; \
1323					*) \
1324						if [ ${PATCH_DEBUG_TMP} = yes ]; then \
1325							${ECHO_MSG} "===>   Applying ${OPSYS} patch $$i" ; \
1326						fi; \
1327						${PATCH} ${PATCH_ARGS} < $$i; \
1328						;; \
1329				esac; \
1330			done; \
1331		fi; \
1332	fi
1333.endif
1334
1335# Configure
1336
1337.if !target(do-configure)
1338do-configure:
1339.if defined(USE_AUTOCONF)
1340	@(cd ${WRKSRC} && ${AUTOCONF})
1341.endif
1342	@if [ -f ${SCRIPTDIR}/configure ]; then \
1343		cd ${.CURDIR} && ${SETENV} ${SCRIPTS_ENV} ${SH} \
1344		  ${SCRIPTDIR}/configure; \
1345	fi
1346.if defined(HAS_CONFIGURE)
1347	@(cd ${WRKSRC} && CC="${CC}" CXX="${CXX}" ac_cv_path_CC="${CC}" \
1348	    CFLAGS="${CFLAGS}" \
1349	    INSTALL="/usr/bin/install -c -o ${BINOWN} -g ${BINGRP}" \
1350	    INSTALL_DATA="${INSTALL_DATA}" \
1351	    INSTALL_PROGRAM="${INSTALL_PROGRAM}" \
1352	    INSTALL_SCRIPT="${INSTALL_SCRIPT}" \
1353	    ${CONFIGURE_ENV} ./${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS})
1354.endif
1355.if defined(USE_IMAKE)
1356	@(cd ${WRKSRC} && ${XMKMF})
1357.endif
1358.endif
1359
1360# Build
1361
1362.if !target(do-build)
1363do-build:
1364.if defined(USE_GMAKE)
1365	@(cd ${WRKSRC}; ${SETENV} ${MAKE_ENV} ${GMAKE} ${MAKE_FLAGS} ${MAKEFILE} ${MAKE_ARGS} ${ALL_TARGET})
1366.else defined(USE_GMAKE)
1367	@(cd ${WRKSRC}; ${SETENV} ${MAKE_ENV} ${MAKE} ${MAKE_FLAGS} ${MAKEFILE} ${MAKE_ARGS} ${ALL_TARGET})
1368.endif
1369.endif
1370
1371# Install
1372
1373.if !target(do-install)
1374do-install:
1375.if defined(USE_GMAKE)
1376	@(cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} ${GMAKE} ${MAKE_FLAGS} ${MAKEFILE} ${MAKE_ARGS} ${INSTALL_TARGET})
1377.if defined(USE_IMAKE) && !defined(NO_INSTALL_MANPAGES)
1378	@(cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} ${GMAKE} ${MAKE_FLAGS} ${MAKEFILE} ${MAKE_ARGS} install.man)
1379.endif
1380.else defined(USE_GMAKE)
1381	@(cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} ${MAKE} ${MAKE_FLAGS} ${MAKEFILE} ${MAKE_ARGS} ${INSTALL_TARGET})
1382.if defined(USE_IMAKE) && !defined(NO_INSTALL_MANPAGES)
1383	@(cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} ${MAKE} ${MAKE_FLAGS} ${MAKEFILE} ${MAKE_ARGS} install.man)
1384.endif
1385.endif
1386.endif
1387
1388# Package
1389
1390.if !target(do-package)
1391do-package: ${TMPPLIST}
1392	@${ECHO_MSG} "===>  Building package for ${PKGNAME}"
1393	@if [ -d ${PACKAGES} ]; then \
1394		if [ ! -d ${PKGREPOSITORY} ]; then \
1395			if ! ${MKDIR} ${PKGREPOSITORY}; then \
1396				${ECHO_MSG} ">> Can't create directory ${PKGREPOSITORY}."; \
1397				exit 1; \
1398			fi; \
1399		fi; \
1400	fi
1401	@if ${PKG_CMD} ${PKG_ARGS} ${PKGFILE}; then \
1402		if [ -d ${PACKAGES} ]; then \
1403			${MAKE} ${.MAKEFLAGS} package-links; \
1404		fi; \
1405	else \
1406		${MAKE} ${.MAKEFLAGS} delete-package; \
1407		exit 1; \
1408	fi
1409.endif
1410
1411# Some support rules for do-package
1412
1413.if !target(package-links)
1414package-links:
1415	@${MAKE} ${.MAKEFLAGS} delete-package-links
1416	@for cat in ${CATEGORIES}; do \
1417		if [ ! -d ${PACKAGES}/$$cat ]; then \
1418			if ! ${MKDIR} ${PACKAGES}/$$cat; then \
1419				${ECHO_MSG} ">> Can't create directory ${PACKAGES}/$$cat."; \
1420				exit 1; \
1421			fi; \
1422		fi; \
1423		${LN} -s ../${PKGREPOSITORYSUBDIR}/${PKGNAME}${PKG_SUFX} ${PACKAGES}/$$cat; \
1424	done
1425.if !defined(NO_LATEST_LINK)
1426	@if [ ! -d ${PKGLATESTREPOSITORY} ]; then \
1427		if ! ${MKDIR} ${PKGLATESTREPOSITORY}; then \
1428			${ECHO_MSG} ">> Can't create directory ${PKGLATESTREPOSITORY}."; \
1429			exit 1; \
1430		fi; \
1431	fi
1432	@${LN} -s ../${PKGREPOSITORYSUBDIR}/${PKGNAME}${PKG_SUFX} ${PKGLATESTFILE}
1433.endif
1434.endif
1435
1436.if !target(delete-package-links)
1437delete-package-links:
1438	@${RM} -f ${PACKAGES}/[a-z]*/${PKGNAME}${PKG_SUFX}
1439.if !defined(NO_LATEST_LINK)
1440	@${RM} -f ${PKGLATESTFILE}
1441.endif
1442.endif
1443
1444.if !target(delete-package)
1445delete-package:
1446	@${MAKE} ${.MAKEFLAGS} delete-package-links
1447	@${RM} -f ${PKGFILE}
1448.endif
1449
1450################################################################
1451# This is the "generic" port target, actually a macro used from the
1452# six main targets.  See below for more.
1453################################################################
1454
1455_PORT_USE: .USE
1456.if make(real-fetch)
1457	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} fetch-depends
1458.endif
1459.if make(real-extract)
1460	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} checksum REAL_EXTRACT=yes
1461	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} build-depends lib-depends misc-depends
1462.endif
1463.if make(real-install)
1464.if !defined(NO_PKG_REGISTER) && !defined(FORCE_PKG_REGISTER)
1465	@if [ -d ${PKG_DBDIR}/${PKGNAME} ]; then \
1466		${ECHO_MSG} "===>  ${PKGNAME} is already installed - perhaps an older version?"; \
1467		${ECHO_MSG} "      If so, you may wish to \`\`make deinstall'' and install"; \
1468		${ECHO_MSG} "      this port again by \`\`make reinstall'' to upgrade it properly."; \
1469		${ECHO_MSG} "      If you really wish to overwrite the old port of ${PKGNAME}"; \
1470		${ECHO_MSG} "      without deleting it first, set the variable \"FORCE_PKG_REGISTER\""; \
1471		${ECHO_MSG} "      in your environment or the \"make install\" command line."; \
1472		exit 1; \
1473	fi
1474.endif
1475	@if [ `${SH} -c umask` != 0022 ]; then \
1476		${ECHO_MSG} "===>  Warning: your umask is \"`${SH} -c umask`"\".; \
1477		${ECHO_MSG} "      If this is not desired, set it to an appropriate value"; \
1478		${ECHO_MSG} "      and install this port again by \`\`make reinstall''."; \
1479	fi
1480	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} run-depends lib-depends
1481.endif
1482.if make(real-install)
1483.if !defined(NO_MTREE)
1484	@if [ `id -u` = 0 ]; then \
1485		${MKDIR} ${PREFIX}; \
1486		if [ ! -f ${MTREE_FILE} ]; then \
1487			${ECHO_MSG} "Error: mtree file \"${MTREE_FILE}\" is missing."; \
1488			${ECHO_MSG} "Copy it from a suitable location (e.g., /usr/src/etc/mtree) and try again."; \
1489			exit 1; \
1490		else \
1491			${MTREE_CMD} ${MTREE_ARGS} ${PREFIX}/ >/dev/null; \
1492		fi; \
1493	else \
1494		${ECHO_MSG} "Warning: not superuser, can't run mtree."; \
1495		${ECHO_MSG} "Become root and try again to ensure correct permissions."; \
1496	fi
1497.endif
1498.endif
1499	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} ${.TARGET:S/^real-/pre-/}
1500	@if [ -f ${SCRIPTDIR}/${.TARGET:S/^real-/pre-/} ]; then \
1501		cd ${.CURDIR} && ${SETENV} ${SCRIPTS_ENV} ${SH} \
1502			${SCRIPTDIR}/${.TARGET:S/^real-/pre-/}; \
1503	fi
1504	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} ${.TARGET:S/^real-/do-/}
1505# put here so ports can change the contents of ${TMPPLIST} if necessary
1506.if make(real-install)
1507	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} generate-plist
1508.endif
1509	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} ${.TARGET:S/^real-/post-/}
1510	@if [ -f ${SCRIPTDIR}/${.TARGET:S/^real-/post-/} ]; then \
1511		cd ${.CURDIR} && ${SETENV} ${SCRIPTS_ENV} ${SH} \
1512			${SCRIPTDIR}/${.TARGET:S/^real-/post-/}; \
1513	fi
1514.if make(real-install) && (defined(_MANPAGES) || defined(_MLINKS))
1515	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} compress-man
1516.endif
1517.if make(real-install) && !defined(NO_PKG_REGISTER)
1518	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} fake-pkg
1519.endif
1520.if !make(real-fetch) \
1521	&& (!make(real-patch) || !defined(PATCH_CHECK_ONLY)) \
1522	&& (!make(real-package) || !defined(PACKAGE_NOINSTALL))
1523	@${TOUCH} ${TOUCH_FLAGS} ${WRKDIR}/.${.TARGET:S/^real-//}_done
1524.endif
1525
1526################################################################
1527# Skeleton targets start here
1528#
1529# You shouldn't have to change these.  Either add the pre-* or
1530# post-* targets/scripts or redefine the do-* targets.  These
1531# targets don't do anything other than checking for cookies and
1532# call the necessary targets/scripts.
1533################################################################
1534
1535.if !target(fetch)
1536fetch:
1537	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} real-fetch
1538.endif
1539
1540.if !target(extract)
1541extract: ${EXTRACT_COOKIE}
1542.endif
1543
1544.if !target(patch)
1545patch: ${PATCH_COOKIE}
1546.endif
1547
1548.if !target(configure)
1549configure: ${CONFIGURE_COOKIE}
1550.endif
1551
1552.if !target(build)
1553build: ${BUILD_COOKIE}
1554.endif
1555
1556.if !target(install)
1557install: ${INSTALL_COOKIE}
1558.endif
1559
1560.if !target(package)
1561package: ${PACKAGE_COOKIE}
1562.endif
1563
1564${EXTRACT_COOKIE}:
1565	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} fetch
1566	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} real-extract
1567${PATCH_COOKIE}:
1568	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} extract
1569	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} real-patch
1570${CONFIGURE_COOKIE}:
1571	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} patch
1572	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} real-configure
1573${BUILD_COOKIE}:
1574	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} configure
1575	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} real-build
1576${INSTALL_COOKIE}:
1577	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} build
1578	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} real-install
1579${PACKAGE_COOKIE}:
1580	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} install
1581	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} real-package
1582
1583# And call the macros
1584
1585real-fetch: _PORT_USE
1586real-extract: _PORT_USE
1587	@${ECHO_MSG} "===>  Extracting for ${PKGNAME}"
1588real-patch: _PORT_USE
1589	@${ECHO_MSG} "===>  Patching for ${PKGNAME}"
1590real-configure: _PORT_USE
1591	@${ECHO_MSG} "===>  Configuring for ${PKGNAME}"
1592real-build: _PORT_USE
1593	@${ECHO_MSG} "===>  Building for ${PKGNAME}"
1594real-install: _PORT_USE
1595	@${ECHO_MSG} "===>  Installing for ${PKGNAME}"
1596real-package: _PORT_USE
1597
1598# Empty pre-* and post-* targets, note we can't use .if !target()
1599# in the _PORT_USE macro
1600
1601.for name in fetch extract patch configure build install package
1602
1603.if !target(pre-${name})
1604pre-${name}:
1605	@${DO_NADA}
1606.endif
1607
1608.if !target(post-${name})
1609post-${name}:
1610	@${DO_NADA}
1611.endif
1612
1613.endfor
1614
1615# Checkpatch
1616#
1617# Special target to verify patches
1618
1619.if !target(checkpatch)
1620checkpatch:
1621	@cd ${.CURDIR} && ${MAKE} PATCH_CHECK_ONLY=yes ${.MAKEFLAGS} patch
1622.endif
1623
1624# Reinstall
1625#
1626# Special target to re-run install
1627
1628.if !target(reinstall)
1629reinstall:
1630	@${RM} -f ${INSTALL_COOKIE} ${PACKAGE_COOKIE}
1631	@DEPENDS_TARGET=${DEPENDS_TARGET} ${MAKE} install
1632.endif
1633
1634# Deinstall
1635#
1636# Special target to remove installation
1637
1638.if !target(deinstall)
1639deinstall:
1640	@${ECHO_MSG} "===>  Deinstalling for ${PKGNAME}"
1641	@${PKG_DELETE} -f ${PKGNAME}
1642	@${RM} -f ${INSTALL_COOKIE} ${PACKAGE_COOKIE}
1643.endif
1644
1645################################################################
1646# Some more targets supplied for users' convenience
1647################################################################
1648
1649# Cleaning up
1650
1651.if !target(pre-clean)
1652pre-clean:
1653	@${DO_NADA}
1654.endif
1655
1656.if !target(clean)
1657clean: pre-clean
1658.if !defined(NOCLEANDEPENDS)
1659	@${MAKE} clean-depends
1660.endif
1661	@${ECHO_MSG} "===>  Cleaning for ${PKGNAME}"
1662	@if [ -d ${WRKDIR} ]; then \
1663		if [ -w ${WRKDIR} ]; then \
1664			${RM} -rf ${WRKDIR}; \
1665		else \
1666			${ECHO_MSG} "===>   ${WRKDIR} not writable, skipping"; \
1667		fi; \
1668	fi
1669.endif
1670
1671.if !target(pre-distclean)
1672pre-distclean:
1673	@${DO_NADA}
1674.endif
1675
1676.if !target(distclean)
1677distclean: pre-distclean clean delete-distfiles
1678.endif
1679
1680.if !target(delete-distfiles)
1681delete-distfiles:
1682	@${ECHO_MSG} "===>  Deleting distfiles for ${PKGNAME}"
1683	@(if [ "X${DISTFILES}${PATCHFILES}" != "X" -a -d ${_DISTDIR} ]; then \
1684		cd ${_DISTDIR}; \
1685		${RM} -f ${DISTFILES} ${PATCHFILES}; \
1686	fi)
1687.if defined(DIST_SUBDIR)
1688	-@${RMDIR} ${_DISTDIR}
1689.endif
1690.endif
1691
1692# Prints out a list of files to fetch (useful to do a batch fetch)
1693
1694.if !target(fetch-list)
1695fetch-list:
1696	@${MKDIR} ${_DISTDIR}
1697	@(cd ${_DISTDIR}; \
1698	 for file in ${DISTFILES}; do \
1699		if [ ! -f $$file -a ! -f `${BASENAME} $$file` ]; then \
1700			for site in ${MASTER_SITES}; do \
1701				DIR=${DIST_SUBDIR}; \
1702				CKSIZE=`${GREP} "^SIZE ($${DIR:+$$DIR/}$$file)" ${MD5_FILE} | ${AWK} '{print $$4}'`; \
1703				${ECHO} -n ${FETCH_CMD} ${FETCH_BEFORE_ARGS} $${site}$${file} "${FETCH_AFTER_ARGS}" '||' ; \
1704					break; \
1705			done; \
1706			${ECHO} "echo $${file} not fetched" ; \
1707		fi \
1708	done)
1709.if defined(PATCHFILES)
1710	@(cd ${_DISTDIR}; \
1711	 for file in ${PATCHFILES}; do \
1712		if [ ! -f $$file -a ! -f `${BASENAME} $$file` ]; then \
1713			for site in ${PATCH_SITES}; do \
1714				DIR=${DIST_SUBDIR}; \
1715				CKSIZE=`${GREP} "^SIZE ($${DIR:+$$DIR/}$$file)" ${MD5_FILE} | ${AWK} '{print $$4}'`; \
1716				${ECHO} -n ${FETCH_CMD} ${FETCH_BEFORE_ARGS} $${site}$${file} "${FETCH_AFTER_ARGS}" '||' ; \
1717					break; \
1718			done; \
1719			${ECHO} "echo $${file} not fetched" ; \
1720		fi \
1721	 done)
1722.endif
1723.endif
1724
1725# Checksumming utilities
1726
1727.if !target(makesum)
1728makesum: fetch
1729	@${MKDIR} ${FILESDIR}
1730	@if [ -f ${MD5_FILE} ]; then ${RM} -f ${MD5_FILE}; fi
1731	@(cd ${DISTDIR}; \
1732	 for file in ${_CKSUMFILES}; do \
1733		${MD5} $$file >> ${MD5_FILE}; \
1734	 done)
1735	@for file in ${_IGNOREFILES}; do \
1736		${ECHO} "MD5 ($$file) = IGNORE" >> ${MD5_FILE}; \
1737	done
1738.endif
1739# this line goes after the ${MD5} above
1740#		echo "SIZE ($$file) = "`wc -c < $$file` >> ${MD5_FILE}; \
1741
1742
1743.if !target(checksum)
1744checksum:
1745.if !defined(REAL_EXTRACT)
1746	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} fetch
1747.endif
1748	@if [ ! -f ${MD5_FILE} ]; then \
1749		${ECHO_MSG} ">> No MD5 checksum file."; \
1750	else \
1751		(cd ${DISTDIR}; OK="true"; \
1752		  for file in ${_CKSUMFILES}; do \
1753			CKSUM=`${MD5} < $$file`; \
1754			CKSUM2=`${GREP} "^MD5 ($$file)" ${MD5_FILE} | ${AWK} '{print $$4}'`; \
1755			if [ "$$CKSUM2" = "" ]; then \
1756				${ECHO_MSG} ">> No checksum recorded for $$file."; \
1757				OK="false"; \
1758			elif [ "$$CKSUM2" = "IGNORE" ]; then \
1759				${ECHO_MSG} ">> Checksum for $$file is set to IGNORE in md5 file even though"; \
1760				${ECHO_MSG} "   the file is not in the "'$$'"{IGNOREFILES} list."; \
1761				OK="false"; \
1762			elif ${EXPR} "$$CKSUM2" : ".*$$CKSUM" > /dev/null; then \
1763				${ECHO_MSG} ">> Checksum OK for $$file."; \
1764			else \
1765				${ECHO_MSG} ">> Checksum mismatch for $$file."; \
1766				OK="false"; \
1767			fi; \
1768		  done; \
1769		  for file in ${_IGNOREFILES}; do \
1770			CKSUM2=`${GREP} "($$file)" ${MD5_FILE} | ${AWK} '{print $$4}'`; \
1771			if [ "$$CKSUM2" = "" ]; then \
1772				${ECHO_MSG} ">> No checksum recorded for $$file, file is in "'$$'"{IGNOREFILES} list."; \
1773				OK="false"; \
1774			elif [ "$$CKSUM2" != "IGNORE" ]; then \
1775				${ECHO_MSG} ">> Checksum for $$file is not set to IGNORE in md5 file even though"; \
1776				${ECHO_MSG} "   the file is in the "'$$'"{IGNOREFILES} list."; \
1777				OK="false"; \
1778			fi; \
1779		  done; \
1780		  if [ "$$OK" != "true" ]; then \
1781			${ECHO_MSG} "Make sure the Makefile and md5 file (${MD5_FILE})"; \
1782			${ECHO_MSG} "are up to date.  If you want to override this check, type"; \
1783			${ECHO_MSG} "\"make NO_CHECKSUM=yes [other args]\"."; \
1784			exit 1; \
1785		  fi) ; \
1786	fi
1787.endif
1788
1789################################################################
1790# The special package-building targets
1791# You probably won't need to touch these
1792################################################################
1793
1794# Nobody should want to override this unless PKGNAME is simply bogus.
1795
1796.if !target(package-name)
1797package-name:
1798	@${ECHO} ${PKGNAME}
1799.endif
1800
1801# Build a package but don't check the package cookie
1802
1803.if !target(repackage)
1804repackage: pre-repackage package
1805
1806pre-repackage:
1807	@${RM} -f ${PACKAGE_COOKIE}
1808.endif
1809
1810# Build a package but don't check the cookie for installation, also don't
1811# install package cookie
1812
1813.if !target(package-noinstall)
1814package-noinstall:
1815	@${MKDIR} ${WRKDIR}
1816	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} PACKAGE_NOINSTALL=yes real-package
1817	@${RM} ${TMPPLIST}
1818	-@${RMDIR} ${WRKDIR}
1819.endif
1820
1821################################################################
1822# Dependency checking
1823################################################################
1824
1825.if !target(depends)
1826depends: lib-depends misc-depends
1827	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} fetch-depends
1828	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} build-depends
1829	@cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} run-depends
1830
1831.if make(fetch-depends)
1832DEPENDS_TMP+=	${FETCH_DEPENDS}
1833.endif
1834
1835.if make(build-depends)
1836DEPENDS_TMP+=	${BUILD_DEPENDS}
1837.endif
1838
1839.if make(run-depends)
1840DEPENDS_TMP+=	${RUN_DEPENDS}
1841.endif
1842
1843_DEPENDS_USE:	.USE
1844.if defined(DEPENDS_TMP)
1845.if !defined(NO_DEPENDS)
1846	@for i in ${DEPENDS_TMP}; do \
1847		prog=`${ECHO} $$i | ${SED} -e 's/:.*//'`; \
1848		dir=`${ECHO} $$i | ${SED} -e 's/[^:]*://'`; \
1849		if ${EXPR} "$$dir" : '.*:' > /dev/null; then \
1850			target=`${ECHO} $$dir | ${SED} -e 's/.*://'`; \
1851			dir=`${ECHO} $$dir | ${SED} -e 's/:.*//'`; \
1852		else \
1853			target=${DEPENDS_TARGET}; \
1854		fi; \
1855		if ${EXPR} "$$prog" : \\/ >/dev/null; then \
1856			if [ -e "$$prog" ]; then \
1857				${ECHO_MSG} "===>   ${PKGNAME} depends on file: $$prog - found"; \
1858				notfound=0; \
1859			else \
1860				${ECHO_MSG} "===>   ${PKGNAME} depends on file: $$prog - not found"; \
1861				notfound=1; \
1862			fi; \
1863		else \
1864			if which "$$prog" > /dev/null 2>&1 ; then \
1865				${ECHO_MSG} "===>   ${PKGNAME} depends on executable: $$prog - found"; \
1866				notfound=0; \
1867			else \
1868				${ECHO_MSG} "===>   ${PKGNAME} depends on executable: $$prog - not found"; \
1869				notfound=1; \
1870			fi; \
1871		fi; \
1872		if [ $$notfound != 0 ]; then \
1873			${ECHO_MSG} "===>    Verifying $$target for $$prog in $$dir"; \
1874			if [ ! -d "$$dir" ]; then \
1875				${ECHO_MSG} "     >> No directory for $$prog.  Skipping.."; \
1876			else \
1877				(cd $$dir; ${MAKE} ${.MAKEFLAGS} $$target) ; \
1878				${ECHO_MSG} "===>   Returning to build of ${PKGNAME}"; \
1879			fi; \
1880		fi; \
1881	done
1882.endif
1883.else
1884	@${DO_NADA}
1885.endif
1886
1887fetch-depends:	_DEPENDS_USE
1888build-depends:	_DEPENDS_USE
1889run-depends:	_DEPENDS_USE
1890
1891lib-depends:
1892.if defined(LIB_DEPENDS)
1893.if !defined(NO_DEPENDS)
1894	@for i in ${LIB_DEPENDS}; do \
1895		lib=`${ECHO} $$i | ${SED} -e 's/:.*//'`; \
1896		dir=`${ECHO} $$i | ${SED} -e 's/[^:]*://'`; \
1897		if ${EXPR} "$$dir" : '.*:' > /dev/null; then \
1898			target=`${ECHO} $$dir | ${SED} -e 's/.*://'`; \
1899			dir=`${ECHO} $$dir | ${SED} -e 's/:.*//'`; \
1900		else \
1901			target=${DEPENDS_TARGET}; \
1902		fi; \
1903		if ${LDCONFIG} -r | ${GREP} -qwF -e "-l$$lib"; then \
1904			${ECHO_MSG} "===>   ${PKGNAME} depends on shared library: $$lib - found"; \
1905		else \
1906			${ECHO_MSG} "===>   ${PKGNAME} depends on shared library: $$lib - not found"; \
1907			${ECHO_MSG} "===>    Verifying $$target for $$lib in $$dir"; \
1908			if [ ! -d "$$dir" ]; then \
1909				${ECHO_MSG} "     >> No directory for $$lib.  Skipping.."; \
1910			else \
1911				(cd $$dir; ${MAKE} ${.MAKEFLAGS} $$target) ; \
1912				${ECHO_MSG} "===>   Returning to build of ${PKGNAME}"; \
1913				if ${LDCONFIG} -r | ${GREP} -qwF -e "-l$$lib"; then \
1914					${TRUE}; \
1915				else \
1916					${ECHO_MSG} "Error: shared library \"$$lib\" does not exist"; \
1917					${FALSE}; \
1918				fi; \
1919			fi; \
1920		fi; \
1921	done
1922.endif
1923.else
1924	@${DO_NADA}
1925.endif
1926
1927misc-depends:
1928.if defined(DEPENDS)
1929.if !defined(NO_DEPENDS)
1930	@for dir in ${DEPENDS}; do \
1931		if ${EXPR} "$$dir" : '.*:' > /dev/null; then \
1932			target=`${ECHO} $$dir | ${SED} -e 's/.*://'`; \
1933			dir=`${ECHO} $$dir | ${SED} -e 's/:.*//'`; \
1934		else \
1935			target=${DEPENDS_TARGET}; \
1936		fi; \
1937		${ECHO_MSG} "===>   ${PKGNAME} depends on: $$dir"; \
1938		${ECHO_MSG} "===>    Verifying $$target for $$dir"; \
1939		if [ ! -d $$dir ]; then \
1940			${ECHO_MSG} "     >> No directory for $$dir.  Skipping.."; \
1941		else \
1942			(cd $$dir; ${MAKE} ${.MAKEFLAGS} $$target) ; \
1943		fi \
1944	done
1945	@${ECHO_MSG} "===>   Returning to build of ${PKGNAME}"
1946.endif
1947.else
1948	@${DO_NADA}
1949.endif
1950
1951.endif
1952
1953.if !target(clean-depends)
1954clean-depends:
1955.if defined(FETCH_DEPENDS) || defined(BUILD_DEPENDS) || defined(LIB_DEPENDS) \
1956	|| defined(RUN_DEPENDS)
1957	@for dir in `${ECHO} "${FETCH_DEPENDS} ${BUILD_DEPENDS} ${LIB_DEPENDS} ${RUN_DEPENDS}" | ${TR} '\040' '\012' | ${SED} -e 's/^[^:]*://' -e 's/:.*//' | sort -u`; do \
1958		if [ -d $$dir ] ; then \
1959			(cd $$dir; ${MAKE} NOCLEANDEPENDS=yes clean clean-depends); \
1960		fi \
1961	done
1962.endif
1963.if defined(DEPENDS)
1964	@for dir in `${ECHO} "${DEPENDS}" | ${TR} '\040' '\012' | ${SED} -e 's/:.*//' | sort -u`; do \
1965		if [ -d $$dir ] ; then \
1966			(cd $$dir; ${MAKE} NOCLEANDEPENDS=yes clean clean-depends); \
1967		fi \
1968	done
1969.endif
1970.endif
1971
1972# Dependency lists: build and runtime.  Print out directory names.
1973
1974build-depends-list:
1975	@for dir in `${ECHO} "${FETCH_DEPENDS} ${BUILD_DEPENDS} ${LIB_DEPENDS}" | ${TR} '\040' '\012' | ${SED} -e 's/^[^:]*://' -e 's/:.*//' | sort -u` `${ECHO} ${DEPENDS} | ${TR} '\040' '\012' | ${SED} -e 's/:.*//' | sort -u`; do \
1976		if [ -d $$dir ]; then \
1977			${ECHO} $$dir; \
1978		else \
1979			${ECHO_MSG} "${PKGNAME}: \"$$dir\" non-existent -- dependency list incomplete" >&2; \
1980		fi; \
1981	done | sort -u
1982
1983run-depends-list:
1984	@for dir in `${ECHO} "${LIB_DEPENDS} ${RUN_DEPENDS}" | ${TR} '\040' '\012' | ${SED} -e 's/^[^:]*://' -e 's/:.*//' | sort -u` `${ECHO} ${DEPENDS} | ${TR} '\040' '\012' | ${SED} -e 's/:.*//' | sort -u`; do \
1985		if [ -d $$dir ]; then \
1986			${ECHO} $$dir; \
1987		else \
1988			${ECHO_MSG} "${PKGNAME}: \"$$dir\" non-existent -- dependency list incomplete" >&2; \
1989		fi; \
1990	done | sort -u
1991
1992# This one does not print out directory names -- it could take a long time.
1993package-depends:
1994	@for dir in `${ECHO} "${LIB_DEPENDS} ${RUN_DEPENDS}" | ${TR} '\040' '\012' | ${SED} -e 's/^[^:]*://' -e 's/:.*//' | sort -u` `${ECHO} ${DEPENDS} | ${TR} '\040' '\012' | ${SED} -e 's/:.*//' | sort -u`; do \
1995		if [ -d $$dir ]; then \
1996			(cd $$dir ; ${MAKE} package-name package-depends); \
1997		else \
1998			${ECHO_MSG} "${PKGNAME}: \"$$dir\" non-existent -- dependency list incomplete" >&2; \
1999		fi; \
2000	done
2001
2002################################################################
2003# Everything after here are internal targets and really
2004# shouldn't be touched by anybody but the release engineers.
2005################################################################
2006
2007# This target generates an index entry suitable for aggregation into
2008# a large index.  Format is:
2009#
2010# distribution-name|port-path|installation-prefix|comment| \
2011#  description-file|maintainer|categories|build deps|run deps
2012
2013.if !target(describe)
2014describe:
2015	@${ECHO} -n "${PKGNAME}|${.CURDIR}|"; \
2016	${ECHO} -n "${PREFIX}|"; \
2017	if [ -f ${COMMENT} ]; then \
2018		${ECHO} -n "`${CAT} ${COMMENT}`"; \
2019	else \
2020		${ECHO} -n "** No Description"; \
2021	fi; \
2022	if [ -f ${DESCR} ]; then \
2023		${ECHO} -n "|${DESCR}"; \
2024	else \
2025		${ECHO} -n "|/dev/null"; \
2026	fi; \
2027	${ECHO} -n "|${MAINTAINER}|${CATEGORIES}|"; \
2028	case "A${FETCH_DEPENDS}B${BUILD_DEPENDS}C${LIB_DEPENDS}D${DEPENDS}E" in \
2029		ABCDE) ;; \
2030		*) cd ${.CURDIR} && ${ECHO} -n `${MAKE} build-depends-list|sort -u`;; \
2031	esac; \
2032	${ECHO} -n "|"; \
2033	case "A${RUN_DEPENDS}B${LIB_DEPENDS}C${DEPENDS}D" in \
2034		ABCD) ;; \
2035		*) cd ${.CURDIR} && ${ECHO} -n `${MAKE} run-depends-list|sort -u`;; \
2036	esac; \
2037	${ECHO} ""
2038.endif
2039
2040.if !target(readmes)
2041readmes:	readme
2042.endif
2043
2044.if !target(readme)
2045readme:
2046	@rm -f README.html
2047	@cd ${.CURDIR} && make README.html
2048.endif
2049
2050README.html:
2051	@${ECHO_MSG} "===>   Creating README.html for ${PKGNAME}"
2052	@${CAT} ${TEMPLATES}/README.port | \
2053		${SED} -e 's%%PORT%%'`${ECHO} ${.CURDIR} | ${SED} -e 's.*/\([^/]*/[^/]*\)$$\1'`'g' \
2054			-e 's%%PKG%%${PKGNAME}g' \
2055			-e '/%%COMMENT%%/r${PKGDIR}/COMMENT' \
2056			-e '/%%COMMENT%%/d' \
2057			-e 's%%BUILD_DEPENDS%%'"`${MAKE} pretty-print-build-depends-list`"'' \
2058			-e 's%%RUN_DEPENDS%%'"`${MAKE} pretty-print-run-depends-list`"'' \
2059		>> $@
2060
2061# The following two targets require an up-to-date INDEX in ${PORTSDIR}
2062
2063.if !target(pretty-print-build-depends-list)
2064pretty-print-build-depends-list:
2065.if defined(FETCH_DEPENDS) || defined(BUILD_DEPENDS) || \
2066	defined(LIB_DEPENDS) || defined(DEPENDS)
2067	@${ECHO} -n 'This port requires package(s) "'
2068	@${ECHO} -n `grep '^${PKGNAME}|' ${PORTSDIR}/INDEX | awk -F\| '{print $$8;}'`
2069	@${ECHO} '" to build.'
2070.endif
2071.endif
2072
2073.if !target(pretty-print-run-depends-list)
2074pretty-print-run-depends-list:
2075.if defined(RUN_DEPENDS) || defined(LIB_DEPENDS) || defined(DEPENDS)
2076	@${ECHO} -n 'This port requires package(s) "'
2077	@${ECHO} -n `grep '^${PKGNAME}|' ${PORTSDIR}/INDEX | awk -F\| '{print $$9;}'`
2078	@${ECHO} '" to run.'
2079.endif
2080.endif
2081
2082# Generate packing list.  Also tests to make sure all required package
2083# files exist.
2084
2085.if !target(generate-plist)
2086generate-plist:
2087	@${ECHO_MSG} "===>   Generating temporary packing list"
2088	@if [ ! -f ${PLIST} -o ! -f ${COMMENT} -o ! -f ${DESCR} ]; then ${ECHO} "** Missing package files for ${PKGNAME}."; exit 1; fi
2089	@>${TMPPLIST}
2090.for man in ${__MANPAGES}
2091	@${ECHO} ${man} >> ${TMPPLIST}
2092.endfor
2093.for _PREFIX in ${PREFIX}
2094.if ${_TMLINKS:M${_PREFIX}*}x != x
2095	@for i in ${_TMLINKS:M${_PREFIX}*:S,^${_PREFIX}/,,}; do \
2096		${ECHO} "$$i" >> ${TMPPLIST}; \
2097	done
2098.endif
2099.if ${_TMLINKS:N${_PREFIX}*}x != x
2100	@${ECHO} @cwd / >> ${TMPPLIST}
2101	@for i in ${_TMLINKS:N${_PREFIX}*:S,^/,,}; do \
2102		${ECHO} "$$i" >> ${TMPPLIST}; \
2103	done
2104	@${ECHO} '@cwd ${PREFIX}' >> ${TMPPLIST}
2105.endif
2106.endfor
2107	@${SED} ${_sedsubplist} ${PLIST} >> ${TMPPLIST}
2108.if !defined(NO_FILTER_SHLIBS)
2109.if (${PORTOBJFORMAT} == "aout")
2110	@${SED} -e 's,\(/lib.*\.so\.[0-9]*\)$$,\1.0,' ${TMPPLIST} > ${TMPPLIST}.tmp
2111.else
2112	@${SED} -e 's,\(/lib.*\.so\.[0-9]*\)\.[0-9]*$$,\1,' ${TMPPLIST} > ${TMPPLIST}.tmp
2113.endif
2114	@${MV} -f ${TMPPLIST}.tmp ${TMPPLIST}
2115.endif
2116.endif
2117
2118${TMPPLIST}:
2119	@cd ${.CURDIR} && ${MAKE} generate-plist
2120
2121# Compress (or uncompress) and symlink manpages.
2122.if !target(compress-man)
2123compress-man:
2124.if ${MANCOMPRESSED} == yes && defined(NOMANCOMPRESS)
2125	@${ECHO_MSG} "===>   Uncompressing manual pages for ${PKGNAME}"
2126.for manpage in ${_MANPAGES}
2127	@${GUNZIP_CMD} ${manpage}
2128.endfor
2129.elif ${MANCOMPRESSED} == no && !defined(NOMANCOMPRESS)
2130	@${ECHO_MSG} "===>   Compressing manual pages for ${PKGNAME}"
2131.for manpage in ${_MANPAGES}
2132	@${GZIP_CMD} ${manpage}
2133.endfor
2134.endif
2135.if defined(_MLINKS)
2136	@set ${_MLINKS:S,"",,g:S,//,/,g}; \
2137	while :; do \
2138		[ $$# -eq 0 ] && break || ${TRUE}; \
2139		${RM} -f $${2%.gz}; ${RM} -f $$2.gz; \
2140		${LN} -fs `${ECHO} $$1 $$2 | ${AWK} '{ \
2141					z=split($$1, a, /\//); x=split($$2, b, /\//); \
2142					while (a[i] == b[i]) i++; \
2143					for (q=i; q<x; q++) printf "../"; \
2144					for (; i<z; i++) printf a[i] "/"; printf a[z]; }'` $$2; \
2145		shift; shift; \
2146	done
2147.endif
2148.endif
2149
2150# Fake installation of package so that user can pkg_delete it later.
2151# Also, make sure that an installed port is recognized correctly in
2152# accordance to the @pkgdep directive in the packing lists
2153
2154.if !target(fake-pkg)
2155fake-pkg:
2156	@if [ ! -d ${PKG_DBDIR} ]; then ${RM} -f ${PKG_DBDIR}; ${MKDIR} ${PKG_DBDIR}; fi
2157.if defined(FORCE_PKG_REGISTER)
2158	@${RM} -rf ${PKG_DBDIR}/${PKGNAME}
2159.endif
2160	@if [ ! -d ${PKG_DBDIR}/${PKGNAME} ]; then \
2161		${ECHO_MSG} "===>   Registering installation for ${PKGNAME}"; \
2162		${MKDIR} ${PKG_DBDIR}/${PKGNAME}; \
2163		${PKG_CMD} ${PKG_ARGS} -O ${PKGFILE} > ${PKG_DBDIR}/${PKGNAME}/+CONTENTS; \
2164		${CP} ${DESCR} ${PKG_DBDIR}/${PKGNAME}/+DESC; \
2165		${CP} ${COMMENT} ${PKG_DBDIR}/${PKGNAME}/+COMMENT; \
2166		if [ -f ${PKGINSTALL} ]; then \
2167			${CP} ${PKGINSTALL} ${PKG_DBDIR}/${PKGNAME}/+INSTALL; \
2168		fi; \
2169		if [ -f ${PKGDEINSTALL} ]; then \
2170			${CP} ${PKGDEINSTALL} ${PKG_DBDIR}/${PKGNAME}/+DEINSTALL; \
2171		fi; \
2172		if [ -f ${PKGREQ} ]; then \
2173			${CP} ${PKGREQ} ${PKG_DBDIR}/${PKGNAME}/+REQUIRE; \
2174		fi; \
2175		if [ -f ${PKGMESSAGE} ]; then \
2176			${CP} ${PKGMESSAGE} ${PKG_DBDIR}/${PKGNAME}/+DISPLAY; \
2177		fi; \
2178		for dep in `${MAKE} package-depends ECHO_MSG=/usr/bin/true | sort -u`; do \
2179			if [ -d ${PKG_DBDIR}/$$dep ]; then \
2180				if ! ${GREP} ^${PKGNAME}$$ ${PKG_DBDIR}/$$dep/+REQUIRED_BY \
2181					>/dev/null 2>&1; then \
2182					${ECHO} ${PKGNAME} >> ${PKG_DBDIR}/$$dep/+REQUIRED_BY; \
2183				fi; \
2184			fi; \
2185		done; \
2186	fi
2187.endif
2188
2189# Depend is generally meaningless for arbitrary ports, but if someone wants
2190# one they can override this.  This is just to catch people who've gotten into
2191# the habit of typing `make depend all install' as a matter of course.
2192#
2193.if !target(depend)
2194depend:
2195.endif
2196
2197# Same goes for tags
2198.if !target(tags)
2199tags:
2200.endif
2201
2202.endif
2203# End of post-makefile section.
2204