Import security/amavis-stats version 0.1.12_3
[dports.git] / Mk / bsd.port.mk
1 #-*- tab-width: 4; -*-
2 # ex:ts=4
3 #
4 # $FreeBSD$
5 #       $NetBSD: $
6 #
7 #       bsd.port.mk - 940820 Jordan K. Hubbard.
8 #       This file is in the public domain.
9 #
10 # Please view me with 4 column tabs!
11
12 # This is the master file for the most common elements to all port
13 # Makefile in the ports system.  For a more general overview of its
14 # use and importance, see the Porter's Handbook.
15
16 # There are two different types of "maintainers" in the ports framework.
17 # The maintainer alias of the bsd.port.mk file is listed below in the
18 # FreeBSD_MAINTAINER entry.  You should consult them if you have any
19 # questions/suggestions regarding this file.
20 #
21 # DO NOT COMMIT CHANGES TO THIS FILE BY YOURSELF, EVEN IF YOU DID NOT GET
22 # A RESPONSE FROM THE MAINTAINER(S) WITHIN A REASONABLE TIMEFRAME! ALL
23 # UNAUTHORISED CHANGES WILL BE UNCONDITIONALLY REVERTED!
24
25 FreeBSD_MAINTAINER=     portmgr@FreeBSD.org
26
27 # For each port, the MAINTAINER variable is what you should consult for
28 # contact information on the person(s) to contact if you have questions/
29 # suggestions about that specific port.  By default (if no MAINTAINER
30 # is listed), a port is maintained by the subscribers of the ports@FreeBSD.org
31 # mailing list, and any correspondence should be directed there.
32 #
33 # MAINTAINER    - The e-mail address of the contact person for this port.
34 #                                 Default: ports@FreeBSD.org
35 #
36 # These are meta-variables that are automatically set to the system
37 # you are running on.  These are provided in case you need to take
38 # different actions for different values.
39 #
40 # ARCH                  - The architecture of the target machine, such as would be
41 #                                 returned by "uname -p".
42 # OPSYS                 - Portability clause.  This is the operating system the
43 #                                 makefile is being used on.  Automatically set to
44 #                                 "FreeBSD," "NetBSD," or "OpenBSD" as appropriate.
45 # OSREL                 - The release version (numeric) of the operating system.
46 # OSVERSION             - 9999999 - try to ignore FreeBSD version check
47 # DFLYVERSION           - The value of __DragonFly_version.
48 #
49 # This is the beginning of the list of all variables that need to be
50 # defined in a port, listed in order that they should be included
51 # to fit in with existing conventions.  (Exception: MAINTAINER actually
52 # should appear after EXTRACT_ONLY and before MASTER_SITE_BACKUP).
53 #
54 # These variables are used to identify your port.
55 #
56 # PORTNAME              - Name of software.  Mandatory.
57 # PORTVERSION   - Version of software.  Mandatory when no DISTVERSION is given.
58 # PORTREVISION  - Version of port.  Optional.  Commonly used to indicate
59 #                                 that an update has happened that affects the port
60 #                                 framework itself, but not the distributed software
61 #                                 (e.g., local patches or Makefile changes).
62 # PORTEPOCH             - Optional.  In certain odd cases, the PORTREVISION logic
63 #                                 can be fooled by ports that appear to go backwards
64 #                                 numerically (e.g. if port-0.3 is newer than port-1998).
65 #                                 In this case, incrementing PORTEPOCH forces the revision.
66 #                                 Default: 0 (no effect).
67 # PKGNAME               - Always defined as
68 #                                 ${PKGNAMEPREFIX}${PORTNAME}${PKGNAMESUFFIX}-${PORTVERSION}.
69 #                                 Do not define this in your Makefile.
70 # PKGNAMEPREFIX - Prefix to specify that port is language-specific, etc.
71 #                                 Optional.
72 # PKGNAMESUFFIX - Suffix to specify compilation options or a version
73 #                                 designator (in case there are different versions of
74 #                                 one port as is the case for Tcl).
75 #                                 Optional.
76 # PKGVERSION    - Always defined as ${PORTVERSION}.
77 #                                 Do not define this in your Makefile.
78 # UNIQUENAME    - A name for your port that is globally unique.  By default,
79 #                                 this is set to ${LATEST_LINK} when LATEST_LINK is set,
80 #                                 and to ${PKGNAMEPREFIX}${PORTNAME} otherwise.
81 # DISTVERSION   - Vendor version of the distribution.
82 #                                 Default: ${PORTVERSION}
83 # DISTNAME              - Name of port or distribution used in generating
84 #                                 WRKSRC and DISTFILES below.
85 #                                 Default:
86 #                                 ${PORTNAME}-${DISTVERSIONPREFIX}${DISTVERSION}${DISTVERSIONSUFFIX}
87 # CATEGORIES    - A list of descriptive categories into which this port falls.
88 #                                 Mandatory.
89 #
90 # These variable describe how to fetch files required for building the port.
91 #
92 # DISTFILES             - Name(s) of archive file(s) containing distribution.
93 #                                 Set this to an empty string if the port doesn't require it.
94 #                                 Default: ${DISTNAME}${EXTRACT_SUFX}
95 # EXTRACT_SUFX  - Suffix for archive names
96 #                                 You never have to set both DISTFILES and EXTRACT_SUFX.
97 #                                 Default: .tar.bz2 if USE_BZIP2 is set, .tar.xz if USE_XZ is set,
98 #                                 .tar.gz otherwise).
99 # MASTER_SITES  - Primary location(s) for distribution files if not found
100 #                                 locally.  See bsd.sites.mk for common choices for
101 #                                 MASTER_SITES.
102 # MASTER_SITE_SUBDIR
103 #                               - Subdirectory of MASTER_SITES. Will sometimes need to be
104 #                                 set to ${PORTNAME} for (e.g.) MASTER_SITE_SOURCEFORGE.
105 #                                 Only guaranteed to work for choices of ${MASTER_SITES}
106 #                                 defined in bsd.sites.mk.
107 #                                 Default: not set.
108 # PATCHFILES    - Name(s) of additional files that contain distribution
109 #                                 patches. Make will look for them at PATCH_SITES (see below).
110 #                                 They will automatically be uncompressed before patching if
111 #                                 the names end with ".gz", ".bz2" or ".Z".
112 #                                 For each file you can optionally specify a strip
113 #                                 flag of patch(1) after a colon if it has a different
114 #                                 base directory, e.g. "file1 file2:-p1 file3".
115 #                                 You can also use a :group at the end for matching up to
116 #                                 dist file groups. See Porters Handbook for more information.
117 #                                 Syntax: PATCHFILES= patch[:-pX][:group]
118 #                                 Default: not set.
119 # PATCH_SITES   - Primary location(s) for distribution patch files
120 #                                 if not found locally.
121 # DIST_SUBDIR   - Suffix to ${DISTDIR}.  If set, all ${DISTFILES} and
122 #                                 ${PATCHFILES} will be put in this subdirectory of
123 #                                 ${DISTDIR} (see below).  Also they will be fetched in this
124 #                                 subdirectory from FreeBSD mirror sites.
125 # ALLFILES              - All of ${DISTFILES} and ${PATCHFILES}.
126 # IGNOREFILES   - If set, don't perform checksum checks on these files.
127 # NOFETCHFILES  - If set, don't download these files from the ${MASTER_SITES}
128 #                                 or ${MASTER_SITE_BACKUP} (but do from
129 #                                 ${MASTER_SITE_OVERRIDE})
130 # EXTRACT_ONLY  - If set, a subset of ${DISTFILES} you want to
131 #                                 actually extract.
132 # ALWAYS_KEEP_DISTFILES
133 #                               - If set, the package building cluster will save the distfiles
134 #                                 along with the packages. This may be required to comply with
135 #                                 some licenses, e.g. GPL in some cases.
136 #                                 Default: not set.
137 #
138 # (NOTE: by convention, the MAINTAINER entry (see above) should go here.)
139 #
140 # These variables are typically set in /etc/make.conf to indicate
141 # the user's preferred location to fetch files from.  You should
142 # rarely need to set these.
143 #
144 # MASTER_SITE_BACKUP
145 #                               - Backup location(s) for distribution files and patch
146 #                                 files if not found locally and ${MASTER_SITES}/${PATCH_SITES}
147 #                                 Default:
148 #                                 ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/distfiles/${DIST_SUBDIR}/
149 # MASTER_SITE_OVERRIDE
150 #                               - If set, override the MASTER_SITES setting with this
151 #                                 value.
152 # MASTER_SITE_FREEBSD
153 #                               - If set, only use ${MASTER_SITE_BACKUP} for
154 #                                 MASTER_SITES.
155 # CD_MOUNTPTS   - List of CDROM mountpoints to look for distfiles under.
156 #                                 This variable supercedes CD_MOUNTPT, which is
157 #                                 obsolete.
158 #
159 # Set these if your port should not be built under certain circumstances.
160 # These are string variables; you should set them to the reason why
161 # they are necessary.
162 #
163 # RESTRICTED    - Prevent the distribution of distfiles and packages to
164 #                                 the FTP sites or on CDROM (e.g. forbidden by license
165 #                                 considerations).
166 # NO_CDROM              - Packages and distfiles may not go on CDROM (e.g. must
167 #                                 not be re-sold) but can go on FTP sites.
168 # NO_PACKAGE    - Port should not be packaged for ftp sites or CDROMs,
169 #                                 but distfiles can be put on ftp sites and CDROMs.
170 # FORBIDDEN             - Package build should not be attempted because of
171 #                                 security vulnerabilities.
172 # LEGAL_TEXT    - Port has legal issues (e.g., special permission to distribute, lacks a license).
173 # LEGAL_PACKAGE - Port has no legal issues but defines NO_PACKAGE
174 # IGNORE                - Package build should be skipped entirely (e.g.
175 #                                 because of serious unfixable problems in the build,
176 #                                 because it cannot be manually fetched, etc).  Error
177 #                                 logs will not appear on pointyhat, so this should be
178 #                                 used sparingly.
179 # BROKEN                - Port is believed to be broken.  Package builds can
180 #                                 still be attempted using TRYBROKEN to test this
181 #                                 assumption.
182 # BROKEN_${ARCH}  Port is believed to be broken on ${ARCH}. Package builds
183 #                                 can still be attempted using TRYBROKEN to test this
184 #                                 assumption.
185 # DEPRECATED    - Port is deprecated to install. Advisory only.
186 # EXPIRATION_DATE
187 #                               - If DEPRECATED is set, determines a date when
188 #                                 the port is planed to remove. The date format is
189 #                                 ISO 8601 (YYYY-MM-DD).
190 #
191 # DISABLE_VULNERABILITIES
192 #                               - If set, do not check if the port is listed in the
193 #                                 vulnerabilities database.
194 #
195 # In addition to RESTRICTED or NO_CDROM, if only a subset of distfiles
196 # or patchfiles have redistribution restrictions, set the following
197 # to the list of such files.
198 #
199 # RESTRICTED_FILES
200 #                               - List of files that cannot be redistributed.
201 #                                 Default: "${DISTFILES} ${PATCHFILES}" if RESTRICTED
202 #                                 or NO_CDROM is set, empty otherwise.
203 #
204 # These variables are booleans, so you don't need to set them to the reason.
205 #
206 # IS_INTERACTIVE
207 #                               - Set this if your port needs to interact with the user
208 #                                 during any step in a package build.  User can then decide
209 #                                 to skip this port by setting ${BATCH}, or compiling only
210 #                                 the interactive ports by setting ${INTERACTIVE}.
211 #                                 Default: not set.
212 # USE_SUBMAKE   - Set this if you want that each of the port's main 7 targets
213 #                                 (extract, patch, configure, build, stage, install and
214 #                                 package) to be executed in a separate make(1) process.
215 #                                 Useful when one of the stages needs to influence make(1)
216 #                                 variables of the later stages using ${WRKDIR}/Makefile.inc
217 #                                 generated on the fly.
218 #                                 Default: not set.
219 #
220 # NO_ARCH                       - Set this if port is architecture neutral.
221 #
222 # Set these if your port only makes sense to certain architectures.
223 # They are lists containing names for them (e.g., "amd64 i386").
224 # (Defaults: not set.)
225 #
226 # ONLY_FOR_ARCHS
227 #                               - Only build ports if ${ARCH} matches one of these.
228 # NOT_FOR_ARCHS - Only build ports if ${ARCH} doesn't match one of these.
229 # ONLY_FOR_ARCHS_REASON
230 # ONLY_FOR_ARCHS_REASON_${ARCH}
231 #                               - Reason why it's only for ${ONLY_FOR_ARCHS}s
232 # NOT_FOR_ARCHS_REASON
233 # NOT_FOR_ARCHS_REASON_${ARCH}
234 #                               - Reason why it's not for ${NOT_FOR_ARCHS}s
235 # IA32_BINARY_PORT
236 #                               - Set this instead of ONLY_FOR_ARCHS if the given port
237 #                                 fetches and installs compiled i386 binaries.
238 #
239 # Dependency checking.  Use these if your port requires another port
240 # not in the list below.  (Default: empty.)
241 #
242 # EXTRACT_DEPENDS
243 #                               - A list of "path:dir[:target]" tuples of other ports this
244 #                                 package depends on in the "extract" stage.  "path" is
245 #                                 the name of a file if it starts with a slash (/), an
246 #                                 executable otherwise.  make will test for the existence
247 #                                 (if it is a full pathname) or search for it in your
248 #                                 $PATH (if it is an executable) and go into "dir" to do
249 #                                 a "make all install" if it's not found.  If the third
250 #                                 field ("target") exists, it will be used instead of
251 #                                 ${DEPENDS_TARGET}.  The first field also supports a
252 #                                 package name with a version range, in the form package>=1.2
253 #                                 if a particular version is desired.
254 # PATCH_DEPENDS - A list of "path:dir[:target]" tuples of other ports this
255 #                                 package depends on in the "patch" stage.  "path" is the
256 #                                 name of a file if it starts with a slash (/), an
257 #                                 executable otherwise.  make will test for the existence
258 #                                 (if it is a full pathname) or search for it in your
259 #                                 $PATH (if it is an executable) and go into "dir" to do
260 #                                 a "make all install" if it's not found.  If the third
261 #                                 field ("target") exists, it will be used instead of
262 #                                 ${DEPENDS_TARGET}.  The first field also supports a
263 #                                 package name with a version range, in the form package>=1.2
264 #                                 if a particular version is desired.
265 # FETCH_DEPENDS - A list of "path:dir[:target]" tuples of other ports this
266 #                                 package depends in the "fetch" stage.  "path" is the
267 #                                 name of a file if it starts with a slash (/), an
268 #                                 executable otherwise.  make will test for the
269 #                                 existence (if it is a full pathname) or search for
270 #                                 it in your $PATH (if it is an executable) and go
271 #                                 into "dir" to do a "make all install" if it's not
272 #                                 found.  If the third field ("target") exists, it will
273 #                                 be used instead of ${DEPENDS_TARGET}.  The first field
274 #                                 also supports a package name with a version range, in
275 #                                 the form package>=1.2 if a particular version is desired.
276 # BUILD_DEPENDS - A list of "path:dir[:target]" tuples of other ports this
277 #                                 package depends to build (between the "extract" and
278 #                                 "build" stages, inclusive).  The test done to
279 #                                 determine the existence of the dependency is the
280 #                                 same as FETCH_DEPENDS.  If the third field ("target")
281 #                                 exists, it will be used instead of ${DEPENDS_TARGET}.
282 # RUN_DEPENDS   - A list of "path:dir[:target]" tuples of other ports this
283 #                                 package depends to run.  The test done to determine
284 #                                 the existence of the dependency is the same as
285 #                                 FETCH_DEPENDS.  This will be checked during the
286 #                                 "install" stage and the name of the dependency will
287 #                                 be put into the package as well.  If the third field
288 #                                 ("target") exists, it will be used instead of
289 #                                 ${DEPENDS_TARGET}.  The first field also supports a
290 #                                 package name with a version range, in the form package>=1.2
291 #                                 if a particular version is desired.
292 # LIB_DEPENDS   - A list of "lib:dir[:target]" tuples of other ports this
293 #                                 package depends on.  "lib" is the name of a shared library.
294 #                                 make will use "ldconfig -r" to search for the library.
295 #                                 lib can contain extended regular expressions.
296 # DEPENDS_TARGET
297 #                               - The default target to execute when a port is calling a
298 #                                 dependency.
299 #                                 Default: install
300 #
301 # These variables control options about how a port gets built and/or
302 # are shorthand notations for common sets of dependencies.
303 # Use these if your port uses some of the common software packages. By
304 # convention these should be set to 'yes', although they only need to be
305 # defined. Defaults: not set, unless explicitly indicated below.
306 #
307 # Note: the distinction between the USE_* and WANT_* variables, and the
308 # WITH_* and WITHOUT_* variables, are that the former are restricted to
309 # usage inside the ports framework, and the latter are reserved for user-
310 # settable options.  (Setting USE_* in /etc/make.conf is always wrong).
311 #
312 # WITH_DEBUG            - If set, debugging flags are added to CFLAGS and the
313 #                         binaries don't get stripped by INSTALL_PROGRAM or
314 #                         INSTALL_LIB. Besides, individual ports might
315 #                         add their specific to produce binaries for debugging
316 #                         purposes. You can override the debug flags that are
317 #                         passed to the compiler by setting DEBUG_FLAGS. It is
318 #                         set to "-g" at default.
319 #
320 # WITH_DEBUG_PORTS              - A list of origins for which WITH_DEBUG will be set
321 #
322 # WITH_SSP_PORTS
323 #                               - If set, SSP_FLAGS (defaults to -fstack-protector)
324 #                                 is added to CFLAGS and the necessary flags
325 #                                 are added to LDFLAGS. Note that SSP_UNSAFE
326 #                                 can be used in Makefiles by port maintainers
327 #                                 if a port breaks with it (it should be
328 #                                 extremely rare).
329 #
330 # USE_BZIP2             - If set, this port tarballs use bzip2, not gzip, for
331 #                                 compression.
332 # USE_XZ                - If set, this port tarballs use xz (or lzma)
333 #                                 for compression
334 # USE_GCC               - If set, this port requires this version of gcc, either in
335 #                                 the system or installed from a port.
336 # USE_CSTD              - Override the default C language standard (gnu89, gnu99)
337 # USE_CXXSTD      Override the default C++ language standard
338 # USE_BINUTILS  - Use binutils suite from port instead of the version in base.
339 # CFLAGS_${ARCH}  Append the cflags to CFLAGS only on the specified architecture
340 # CXXFLAGS_${ARCH}
341 #                                Append the cxxflags to CXXFLAGS only on the specified architecture
342 ##
343 # USE_GHOSTSCRIPT
344 #                               - If set, this port needs ghostscript to both
345 #                                 build and run.  If a number is specified,
346 #                                 the specified version will be used.
347 #                                 The valid value is '7', '8', or '9' in that case.
348 # USE_GHOSTSCRIPT_BUILD
349 #                               - If set, this port needs ghostscript to build.
350 # USE_GHOSTSCRIPT_RUN
351 #                               - If set, this port needs ghostscript to run.
352 # GHOSTSCRIPT_PORT
353 #                               - The port that provides postscript functionality.
354 #                                 Some installations may wish to override the default
355 #                                 to specify a version without X11 and/or localized
356 #                                 versions for their nationality.
357 #                                 Default: print/ghostscript9
358 # WITH_GHOSTSCRIPT_VER
359 #                               - If set, the specified version of ghostscript will be
360 #                                 used.  The valid value is "7", "8", or "9".  Note that
361 #                                 this is for users, not for port maintainers.  This
362 #                                 should not be used in Makefile.
363 ##
364 # USE_GL                - A list of Mesa or GL related dependencies needed by the port.
365 #                                 Supported components are: egl, glesv2, glut, glu, glw, and gl.
366 #                                 If set to "yes", this is equivalent to "glu". Note that
367 #                                 glew and glut depend on glu, glw and glu depend on gl.
368 ##
369 # USE_SDL               - If set, this port uses the sdl libraries.
370 #                                 See bsd.sdl.mk for more information.
371 ##
372 # USE_OPENSSL   - If set, this port relies on the OpenSSL package.
373 ##
374 # USE_OPENLDAP  - If set, this port uses the OpenLDAP libraries.
375 #                                 Implies: WANT_OPENLDAP_VER?=24
376 # WANT_OPENLDAP_VER
377 #                               - Legal values are: 23, 24
378 #                                 If set to an unknown value, the port is marked BROKEN.
379 # WANT_OPENLDAP_SASL
380 #                               - If set, the system should use OpenLDAP libraries
381 #                                 with SASL support.
382 ##
383 # USE_AUTOTOOLS - If set, this port uses various GNU autotools
384 #                                 (libtool, autoconf, autoheader, automake et al.)
385 #                                 See bsd.autotools.mk for more details.
386 ##
387 # USE_SCONS             - If set, this port uses the Python-based SCons build system
388 #                                 See bsd.scons.mk for more details.
389 ##
390 # USE_EFL               - If set, this port use EFL libraries.
391 #                                 Implies inclusion of bsd.efl.mk.  (Also see
392 #                                 that file for more information on USE_EFL_*).
393 # USE_FPC               - If set, this port relies on the Free Pascal language.
394 #                                 Implies inclusion of bsd.fpc.mk.  (Also see
395 #                                 that file for more information on WANT_FPC_*).
396 # USE_JAVA              - If set, this port relies on the Java language.
397 #                                 Implies inclusion of bsd.java.mk.  (Also see
398 #                                 that file for more information on USE_JAVA_*).
399 # USE_OCAML             - If set, this port relies on the OCaml language.
400 #                                 Implies inclusion of bsd.ocaml.mk.  (Also see
401 #                                 that file for more information on USE_OCAML*).
402 # USE_PYTHON    - If set, this port relies on the Python language.
403 #                                 Implies inclusion of bsd.python.mk. (Also see
404 #                                 that file for more information on USE_PYTHON_*
405 #                                 and USE_PYDISTUTILS).
406 # USE_RUBY              - If set, this port relies on the Ruby language.
407 #                                 Implies inclusion of bsd.ruby.mk.  (Also see
408 #                                 that file for more information on USE_RUBY_*).
409 # USE_GNUSTEP   - If set, this port relies on the GNUstep system.
410 #                                 Implies the inclusion of bsd.gnustep.mk.
411 #                                 (Also see that file for more information on
412 #                                 USE_GNUSTEP_*).
413 ##
414 # USE_GECKO             - If set, this port uses the Gecko/Mozilla product.
415 #                                 See bsd.gecko.mk for more details.
416 ##
417 # USE_GNOME             - A list of the Gnome dependencies the port has (e.g.,
418 #                                 glib12, gtk12).  Implies that the port needs Gnome.
419 #                                 Implies inclusion of bsd.gnome.mk.  See bsd.gnome.mk
420 #                                 or http://www.FreeBSD.org/gnome/docs/porting.html
421 #                                 for more details.
422 ##
423 # USE_MATE              - A list of the MATE dependencies the port has. Implies
424 #                                 that the port needs MATE. Implies inclusion of
425 #                                 bsd.mate.mk. See bsd.mate.mk for more details.
426 ##
427 # USE_LUA               - If set, this port uses the Lua library and related
428 #                                 components. See bsd.lua.mk for more details.
429 ##
430 # USE_WX                - If set, this port uses the WxWidgets library and related
431 #                                 components. See bsd.wx.mk for more details.
432 ##
433 # USE_KDE4              - A list of the KDE 4 dependencies the port has (e.g.,
434 #                                 kdelibs, kdebase).  Implies that the port needs KDE.
435 #                                 Implies inclusion of bsd.kde4.mk.  See bsd.kde4.mk
436 #                                 for more details.
437 #
438 # USE_QT4               - A list of the Qt 4 dependencies the port has (e.g,
439 #                                 corelib, webkit).  Implies that the port needs Qt.
440 #                                 Implies the inclusion of bsd.qt.mk.  See bsd.qt.mk
441 #                                 for more details.
442 #
443 # USE_QT5               - A list of the Qt 5 dependencies the port has (e.g,
444 #                                 core, webkit).  Implies that the port needs Qt.
445 #                                 Implies the inclusion of bsd.qt.mk.  See bsd.qt.mk
446 #                                 for more details.
447 #
448 # USE_LINUX             - Set to yes to say the port needs the default linux base port.
449 #                                 Set to value <X>, if the port needs emulators/linux_base-<X>.
450 #                                 Implies appropriate settings for STRIP and STRIP_CMD.
451 # USE_LINUX_PREFIX
452 #                               - controls the action of PREFIX (see above). Only use this
453 #                                 if the port is a linux infrastructure port (e.g. contains libs
454 #                                 or a sound server which supports the FreeBSD native one),
455 #                                 use the default or the X11 prefix if it's a leaf port
456 #                                 (e.g. a game or program).
457 #                                 Implies NO_MTREE=yes, and, if USE_LDCONFIG is defined:
458 #                                   - USE_LINUX=yes
459 #                                   - appropriate invocation of the Linux ldconfig
460 # USE_LINUX_RPM - Set to yes to pull in variables and targets useful to Linux
461 #                                 RPM ports.
462 #                                 Implies inclusion of bsd.linux-rpm.mk.
463 #
464 # LINUX_OSRELEASE       - Contains the value of compat.linux.osrelease sysctl.
465 #                                 Will be used to distinguish which linux
466 #                                 infrastructure ports should be used.
467 #                                 Valid values: 2.6.16.
468 # AUTOMATIC_PLIST
469 #                               - Set to yes to enable automatic packing list generation.
470 #                                 Currently has no effect unless USE_LINUX_RPM is set.
471 #
472 # OVERRIDE_LINUX_BASE_PORT
473 #                               - This specifies the default linux base to use, for valid
474 #                                 values have a look at the description of USE_LINUX. This is
475 #                                 an user-only variable. Don't use it in any port, it's meant
476 #                                 to be used in make.conf.
477 #
478 # LINUX_BASE_PORT
479 #                               - This is a read-only variable, it gets set to a value which is
480 #                                 usable in *_DEPENDS (e.g. BUILD_DEPENDS=${LINUX_BASE_PORT}).
481 #                                 It honors USE_LINUX=foo and OVERRIDE_LINUX_BASE_PORT.
482 ##
483 # USE_XORG                      - Set to a list of X.org module dependencies.
484 #                                 Implies inclusion of bsd.xorg.mk.
485 ##
486 # USE_TEX                       - A list of the TeX dependencies the port has.
487 #
488 ##
489 # USE_RC_SUBR   - If set, the ports startup/shutdown script uses the common
490 #                                 routines found in /etc/rc.subr.
491 #                                 If this is set to a list of files, these files will be
492 #                                 automatically added to ${SUB_FILES}, some %%VAR%%'s will
493 #                                 automatically be expanded, they will be installed in
494 #                                 ${PREFIX}/etc/rc.d and added to the packing list.
495 # USE_RCORDER   - List of rc.d startup scripts to be called early in the boot
496 #                                 process. This acts exactly like USE_RC_SUBR except that
497 #                                 scripts are installed in /etc/rc.d.
498 #                                 Because local rc.d scripts are included in the base rcorder
499 #                                 this option is not needed unless the port installs in the base.
500 ##
501 # USE_APACHE    - If set, this port relies on an apache webserver.
502 #
503 # Conflict checking.  Use if your port cannot be installed at the same time as
504 # another package.
505 #
506 # CONFLICTS             - A list of package name patterns that the port conflicts
507 #                                 with, separated by blanks.  The names may include shell
508 #                                 pattern meta-characters "*", "?", "[", "]", and "!".
509 #                                 Example: apache*-1.2* apache*-1.3.[012345] apache-*+ssl_*
510 #
511 # CONFLICTS_BUILD
512 #                               - Check conflict prior to the build.
513 #
514 # CONFLICTS_INSTALL
515 #                               - Check conflict prior to the installation stage.
516 #
517 # Various directory definitions and variables to control them.
518 # You rarely need to redefine any of these except WRKSRC and NO_WRKSUBDIR.
519 #
520 # LOCALBASE             - Where non-X11 ports install things.
521 #                                 Default: /usr/local
522 # LINUXBASE             - Where Linux ports install things.
523 #                                 Default: /compat/linux
524 # PREFIX                - Where *this* port installs its files.
525 #                                 Default: ${LINUXBASE} if USE_LINUX_PREFIX is set,
526 #                                 otherwise ${LOCALBASE}
527 #
528 # IGNORE_PATH_CHECKS
529 #                               - There are some sanity checks against PREFIX.
530 #                                 You can disable these checks with defining
531 #                                 this variable, but this is not recommended!
532 #                                 Only do this if you really know what you are
533 #                                 doing.  These sanity checks are the following:
534 #                                   - PREFIX has to be an absolute path.
535 #                                   - PREFIX can't have a trailing slash.
536 #
537 # MASTERDIR             - Where the port finds patches, package files, etc.  Define
538 #                                 this is you have two or more ports that share most of the
539 #                                 files.
540 #                                 Default: ${.CURDIR}
541 # PORTSDIR              - The root of the ports tree.
542 #                                 Default: /usr/ports
543 # DISTDIR               - Where to search for and store copies of original sources
544 #                                 Default: ${PORTSDIR}/distfiles
545 # PACKAGES              - A top level directory where all packages go (rather than
546 #                                 going locally to each port).
547 #                                 Default: ${PORTSDIR}/packages
548 # WRKDIRPREFIX  - The place to root the temporary working directory
549 #                                 hierarchy.
550 #                                 Default: none
551 # WRKDIR                - A temporary working directory that gets *clobbered* on clean
552 #                                 Default: ${WRKDIRPREFIX}${.CURDIR}/work
553 # WRKSRC                - A subdirectory of ${WRKDIR} where the distribution actually
554 #                                 unpacks to.
555 #                                 Default: ${WRKDIR}/${DISTNAME} unless NO_WRKSUBDIR is set,
556 #                                 in which case simply ${WRKDIR}
557 # WRKSRC_SUBDIR - A subdirectory of ${WRKSRC} where the distribution actually
558 #                                 builds in.
559 #                                 Default: not set
560 # NO_WRKSUBDIR  - Assume port unpacks directly into ${WRKDIR}.
561 # PATCHDIR              - A directory containing any additional patches you made
562 #                                 to port this software to FreeBSD.
563 #                                 Default: ${MASTERDIR}/files
564 # SCRIPTDIR             - A directory containing any auxiliary scripts
565 #                                 Default: ${MASTERDIR}/scripts
566 # FILESDIR              - A directory containing any miscellaneous additional files.
567 #                                 Default: ${MASTERDIR}/files
568 # DFLY_PATCHDIR=        - A directory containing additional patches required
569 #                                 to build port on DragonFly
570 #                                 Default: ${MASTERDIR}/dragonfly
571 # DFLY_FILESDIR         - A directory containing any miscellaneous files
572 #                                 needed to build port on DragonFly
573 #                                 Default: ${MASTERDIR}/dragonfly
574 # PKGDIR                - A directory containing any package creation files.
575 #                                 Default: ${MASTERDIR}
576 # SRC_BASE              - The root of the src tree.  (Some ports require this to get
577 #                                 kernel sources).  Default: /usr/src
578 # UID_FILES             - A list of files containing information about registered UIDs.
579 #                                 Note that files have decreasing priority.
580 # GID_FILES             - A list of files containing information about registered GIDs.
581 #                                 Note that files have decreasing priority.
582 #
583 # Variables that serve as convenient "aliases" for your *-install targets.
584 # Use these like: "${INSTALL_PROGRAM} ${WRKSRC}/prog ${PREFIX}/bin".
585 #
586 # INSTALL_PROGRAM
587 #                               - A command to install binary executables.  (By
588 #                                 default, also strips them, unless ${STRIP} is
589 #                                 overridden to be the empty string).
590 # INSTALL_KLD   - As INSTALL_PROGRAM, but without the STRIP.
591 # INSTALL_LIB   - As INSTALL_DATA, but also strips the file.
592 # INSTALL_SCRIPT
593 #                               - A command to install executable scripts.
594 # INSTALL_DATA  - A command to install sharable data.
595 # INSTALL_MAN   - A command to install manpages.  May or not compress,
596 #                                 depending on the value of MANCOMPRESSED (see below).
597 # COPYTREE_BIN
598 # COPYTREE_SHARE
599 #                               - Similiar to INSTALL commands but working on whole
600 #                                 trees of directories, takes 3 arguments, last one is
601 #                                 find(1) arguments and optional.
602 #                                 Example use: 
603 #                                 cd ${WRKSRC}/doc && ${COPYTREE} . ${DOCSDIR} "! -name *.bak"
604 #
605 #                                 Installs all directories and files from ${WRKSRC}/doc
606 #                                 to ${DOCSDIR} except sed backup files.
607 #
608 # Boolean to control whether manpages are installed.
609 #
610 # NO_INSTALL_MANPAGES
611 #                               - If set, this port doesn't want to install any manpages.
612 #                                 Default: not set, i.e. manpages are installed by default.
613 #
614 # Set the following to specify all manpages that your port installs.
615 # These manpages will be automatically listed in ${PLIST}.  Depending
616 # on the setting of NO_MANCOMPRESS, the make rules will compress the
617 # manpages for you.
618 #
619 # MAN<sect>             - A list of manpages, categorized by section.  For
620 #                                 example, if your port has "man/man1/foo.1" and
621 #                                 "man/mann/bar.n", set "MAN1=foo.1" and "MANN=bar.n".
622 #                                 The available sections chars are "123456789LN".
623 # MAN<sect>_<lang>
624 #                               - If your port does not install all man pages for all
625 #                                 languages in MANLANG, language specific pages for
626 #                                 a language can be specified with this. For example,
627 #                                 if the port installs foo.1 in English, Japanese, and
628 #                                 German, bar.1 in English only, and baz.3 in German
629 #                                 only, set
630 #                                       MANLANG=        "" de ja
631 #                                       MAN1=           foo.1
632 #                                       MAN1_EN=        bar.1
633 #                                       MAN3_DE=        baz.3
634 # MLINKS                - A list of <source, target> tuples for creating links
635 #                                 for manpages.  For example, "MLINKS= a.1 b.1 c.3 d.3"
636 #                                 will do an "ln -sf a.1 b.1" and "ln -sf c.3 d.3" in
637 #                                 appropriate directories.  (Use this even if the port
638 #                                 installs its own manpage links so they will show up
639 #                                 correctly in ${PLIST}.)
640 # MANPREFIX             - The directory prefix for ${MAN<sect>} and ${MLINKS}.
641 #                                 Default: ${PREFIX}
642 # MAN<sect>PREFIX
643 #                               - If manual pages of some sections install in different
644 #                                 locations than others, use these.
645 #                                 Default: ${MANPREFIX}
646 # MANCOMPRESSED - This variable can take values "yes", "no" or
647 #                                 "maybe".  "yes" means manpages are installed
648 #                                 compressed; "no" means they are not; "maybe" means
649 #                                 it changes depending on the value of NO_MANCOMPRESS.
650 #                                 Default: "yes" if USES=imake is set and NO_INSTALL_MANPAGES
651 #                                 is not set, and "no" otherwise.
652 #
653 # Set the following to specify all .info files your port installs.
654 #
655 # INFO                  - A list of .info files (omitting the trailing ".info");
656 #                                 only one entry per document! These files are listed in
657 #                                 the path relative to ${INFO_PATH}.
658 # INFO_PATH             - Path, where all .info files will be installed by your
659 #                                 port, relative to ${PREFIX}
660 #                                 Default: "share/info" if ${PREFIX} is equal to /usr
661 #                                 and "info" otherwise.
662 #
663 # Set the following to specify all documentation your port installs into
664 # ${DOCSDIR}
665 #
666 # PORTDOCS              - A list of files and directories relative to DOCSDIR.
667 #                                 Shell glob patterns can be used, directories include
668 #                                 the entire subtree of contained files and directories.
669 #                                 Should not be set when no documentation files are
670 #                                 installed.
671 #                                 Useful for dynamically generated documentation.
672 #
673 # Set the following to specify all documentation your port installs into
674 # ${EXAMPLESDIR}
675 #
676 # PORTEXAMPLES          - A list of files and directories relative to EXAMPLESDIR.
677 #                                 Shell glob patterns can be used, directories include
678 #                                 the entire subtree of contained files and directories.
679 #                                 Should not be set when no examples files are
680 #                                 installed.
681 #                                 Useful for dynamically generated examples.
682 #
683 # Set the following to specify all files and directories your port installs into
684 # ${DATADIR}
685 #
686 # PORTDATA              - A list of files and directories relative to DATADIR.
687 #                                 Shell glob patterns can be used, directories include
688 #                                 the entire subtree of contained files and directories.
689 #                                 Should not be set when no data files are
690 #                                 installed.
691 #                                 Useful for dynamically generated data files.
692 #
693 # Default targets and their behaviors:
694 #
695 # fetch                 - Retrieves missing ${DISTFILES} and ${PATCHFILES} for this
696 #                                 port.
697 # fetch-list    - Show list of commands to retrieve missing ${DISTFILES} and
698 #                                 ${PATCHFILES} for this port.
699 # fetch-recursive
700 #                               - Retrieves missing ${DISTFILES} and ${PATCHFILES} for this
701 #                                 port and dependencies.
702 # fetch-recursive-list
703 #                               - Show list of commands to retrieve missing ${DISTFILES} and
704 #                                 ${PATCHFILES} for this port and dependencies.
705 # fetch-required
706 #                               - Retrieves missing ${DISTFILES} and ${PATCHFILES} for this
707 #                                 port and dependencies.
708 # fetch-required-list
709 #                               - Show list of commands to retrieve missing ${DISTFILES} and
710 #                                 ${PATCHFILES} for this port and dependencies.
711 # fetch-url-list
712 #                               - Show list of URLS to retrieve missing ${DISTFILES} and
713 #                                 ${PATCHFILES} for this port.
714 # fetch-urlall-list
715 #                               - Show list of URLS to retrieve ${DISTFILES} and
716 #                                 ${PATCHFILES} for this port.
717 #
718 # all-depends-list
719 #                               - Show all directories which are dependencies
720 #                                 for this port.
721 # build-depends-list
722 #                               - Show all directories which are build-dependencies
723 #                                 for this port.
724 # package-depends-list
725 #                               - Show all directories which are package-dependencies
726 #                                 for this port. This is based upon the dependency
727 #                                 tree as recorded in the Makefiles of the ports
728 #                                 collection, not as recorded in the currently
729 #                                 installed ports.
730 # actual-package-depends
731 #                               - Like package-depends-list but with the difference
732 #                                 that the dependencies of the currently installed
733 #                                 ports are used instead of the dependencies as
734 #                                 recorded in the ports collection.
735 # run-depends-list
736 #                               - Show all directories which are run-dependencies
737 #                                 for this port.
738 #
739 # extract               - Unpacks ${DISTFILES} into ${WRKDIR}.
740 # patch                 - Apply any provided patches to the source.
741 # configure             - Runs either GNU configure, one or more local configure
742 #                                 scripts or nothing, depending on what's available.
743 # build                 - Actually compile the sources.
744 # install               - Install the results of a build.
745 # reinstall             - Install the results of a build, ignoring "already installed"
746 #                                 flag.
747 # deinstall             - Remove the installation.
748 # deinstall-all - Remove all installations with the same PKGORIGIN.
749 # package               - Create a package from an _installed_ port.
750 # package-recursive
751 #                               - Create a package for a port and _all_ of its dependencies.
752 # describe              - Try to generate a one-line description for each port for
753 #                                 use in INDEX files and the like.
754 # checkpatch    - Do a "patch -C" instead of a "patch".  Note that it may
755 #                                 give incorrect results if multiple patches deal with
756 #                                 the same file.
757 # checksum              - Use distinfo to ensure that your distfiles are valid.
758 # checksum-recursive
759 #                               - Run checksum in this port and all dependencies.
760 # makesum               - Generate distinfo (only do this for your own ports!).
761 # clean                 - Remove ${WRKDIR} and other temporary files used for building.
762 # clean-depends - Do a "make clean" for all dependencies.
763 # config                - Configure options for this port (using ${DIALOG}).
764 #                                 Automatically run prior to extract, patch, configure, build,
765 #                                 install, and package.
766 # config-recursive
767 #                               - Configure options for this port for a port and all its
768 #                                 dependencies.
769 # showconfig    - Display options config for this port.
770 # showconfig-recursive
771 #                               - Display options config for this port and all its
772 #                                 dependencies.
773 # rmconfig              - Remove the options config for this port.
774 # rmconfig-recursive
775 #                               - Remove the options config for this port and all its
776 #                                 dependencies.
777 #
778 # Default sequence for "all" is:
779 #
780 #               check-sanity fetch checksum extract patch configure build
781 #
782 # Please read the comments in the targets section below; you
783 # should be able to use the pre-* or post-* targets/scripts
784 # (which are available for every stage except checksum) or
785 # override the do-* targets to do pretty much anything you want.
786 #
787 # NEVER override the "regular" targets unless you want to open
788 # a major can of worms.
789 #
790 # Set these variables if your port doesn't need some of the steps.
791 # Note that there are no NO_PATCH or NO_CONFIGURE variables because
792 # those steps are empty by default.  NO_EXTRACT is not allowed anymore
793 # since we need to at least create ${WRKDIR}.  Also, NO_CHECKSUM is a user
794 # variable and is not to be set in a port's Makefile.  See above for NO_PACKAGE.
795 #
796 # NO_BUILD              - Use a dummy (do-nothing) build target.
797 # NO_INSTALL    - Use a dummy (do-nothing) install target.
798 #
799 # Here are some variables used in various stages.
800 #
801 # For options see bsd.options.mk
802 #
803 # For fetch:
804 #
805 # FETCH_BINARY  - Path to ftp/http fetch command if not in $PATH.
806 #                                 Default: "/usr/bin/fetch"
807 # FETCH_ARGS    - Arguments to ftp/http fetch command.
808 #                                 Default: "-Fpr"
809 # FETCH_CMD             - ftp/http fetch command.
810 #                                 Default: ${FETCH_BINARY} ${FETCH_ARGS}
811 # FETCH_BEFORE_ARGS
812 #                               - Arguments to ${FETCH_CMD} before filename.
813 #                                 Default: none
814 # FETCH_AFTER_ARGS
815 #                               - Arguments to ${FETCH_CMD} following filename.
816 #                                 Default: none
817 # FETCH_ENV             - Environment to pass to ${FETCH_CMD}.
818 #                                 Default: none
819 # FETCH_REGET   - Times to retry fetching of files on checksum errors.
820 #                                 Default: 1
821 # CLEAN_FETCH_ENV
822 #                               - Disable package dependency in fetch target for mass
823 #                                 fetching.  User settable.
824 #
825 # For extract:
826 #
827 # EXTRACT_CMD   - Command for extracting archive: "bzip2" if USE_BZIP2
828 #                                 is set, "gzip" otherwise.
829 # EXTRACT_BEFORE_ARGS
830 #                               - Arguments to ${EXTRACT_CMD} before filename.
831 #                                 Default: "-dc"
832 # EXTRACT_AFTER_ARGS
833 #                               - Arguments to ${EXTRACT_CMD} following filename.
834 #                                 default: "| tar -xf -"
835 # EXTRACT_PRESERVE_OWNERSHIP
836 #                               - Normally, when run as "root", the extract stage will
837 #                                 change the owner and group of all files under ${WRKDIR}
838 #                                 to 0:0.  Set this variable if you want to turn off this
839 #                                 feature.
840 # For patch:
841 #
842 # EXTRA_PATCHES - Define this variable if you have patches not in
843 #                                 ${PATCHDIR}.  This usually happens when you need to
844 #                                 do some pre-processing before some distribution
845 #                                 patches can be applied.  In that case, fetch them as
846 #                                 extra distfiles, put the processed results in
847 #                                 ${WRKDIR}, then point EXTRA_PATCHES to them.
848 #                                 The patches specified by this variable will be
849 #                                 applied after the normal distribution patches but
850 #                                 before those in ${PATCHDIR}.
851 # PATCH_WRKSRC  - Directory to apply patches in.
852 #                                 Default: ${WRKSRC}
853 #
854 # For configure:
855 #
856 # HAS_CONFIGURE - If set, this port has its own configure script.  The
857 #                                 configure stage will not do anything if this is not set.
858 # GNU_CONFIGURE - If set, you are using GNU configure (optional).  Implies
859 #                                 HAS_CONFIGURE.
860 # CONFIGURE_WRKSRC
861 #                               - Directory to run configure in.
862 #                                 Default: ${WRKSRC}
863 # CONFIGURE_SCRIPT
864 #                               - Name of configure script, relative to ${CONFIGURE_WRKSRC}.
865 #                                 Default: "Makefile.PL" if USES=perl5 and USE_PERL5=configure
866 #                                 are set, "configure" otherwise.
867 # CONFIGURE_TARGET
868 #                               - The name of target to call when GNU_CONFIGURE is
869 #                                 defined.
870 #                                 Default: ${ARCH}-dports-dragonfly${OSREL}
871 # GNU_CONFIGURE_PREFIX
872 #                               - The directory passed as prefix to the configure script if
873 #                                 GNU_CONFIGURE is set.
874 #                                 Default: ${PREFIX}
875 # CONFIGURE_ARGS
876 #                               - Pass these args to configure if ${HAS_CONFIGURE} is set.
877 #                                 Default: "--prefix=${GNU_CONFIGURE_PREFIX} --infodir=${PREFIX}/${INFO_PATH}
878 #                                 --mandir=${MANPREFIX}/man --build=${CONFIGURE_TARGET}" if
879 #                                 GNU_CONFIGURE is set, "CC=${CC} CFLAGS=${CFLAGS}
880 #                                 PREFIX=${PREFIX} INSTALLPRIVLIB=${PREFIX}/lib
881 #                                 INSTALLARCHLIB=${PREFIX}/lib" if USES=perl5 and
882 #                                 USE_PERL5=configure are set, empty otherwise.
883 # CONFIGURE_ENV - Pass these env (shell-like) to configure if
884 #                                 ${HAS_CONFIGURE} is set.
885 # CONFIGURE_LOG - The name of configure log file. It will be printed to
886 #                                 the screen if configure fails.
887 #                                 Default: config.log
888 # CONFIGURE_FAIL_MESSAGE
889 #                               - A message displayed to users when configure
890 #                                 fails (note: this assumes the do-configure
891 #                                 target has not been overwritten).  This message
892 #                                 will be passed through /usr/bin/fmt before
893 #                                 being shown to the user.
894 #
895 # WITHOUT_FBSD10_FIX              Disable FreeBSD 10.0 autotools workaround.
896 #
897 # For build and install:
898 #
899 # MAKEFILE              - Name of the makefile.
900 #                                 Default: Makefile
901 # ALL_TARGET    - Default target for sub-make in build stage.
902 #                                 Default: all
903 # BUILD_WRKSRC  - Directory to do build in (default: ${WRKSRC}).
904 # MAKE_ENV              - Additional environment vars passed to sub-make in build
905 #                                 and install stages.
906 #                                 Default: see below
907 # MAKE_ARGS             - Any extra arguments to sub-make in build and install stages.
908 #                                 Default: none
909 ##
910 # MAKE_JOBS_UNSAFE
911 #                               - Disallow multiple jobs even when user set a global override.
912 #                                 To be used with known bad ports.
913 # DISABLE_MAKE_JOBS
914 #                               - Set to disable the multiple jobs feature.  User settable.
915 # MAKE_JOBS_NUMBER
916 #                               - Override the number of make jobs to be used.  User settable.
917 # MAKE_JOBS_NUMBER_LIMIT
918 #                               - Set a limit for maximum number of make jobs allowed to be
919 #                                 used.
920 ## cacche
921 #
922 # WITH_CCACHE_BUILD
923 #                               - Enable CCACHE support (devel/ccache).  User settable.
924 # CCACHE_DIR
925 #                               - Which directory to use for ccache (default: $HOME/.ccache)
926 # NO_CCACHE
927 #                               - Disable CCACHE support for example for certain ports if
928 #                                 CCACHE is enabled.  User settable.
929 #
930 # For install:
931 #
932 # INSTALL_TARGET
933 #                               - Default target for sub-make in install stage.
934 #                                 Default: install
935 # INSTALL_WRKSRC
936 #                               - Directory to install from
937 #                                 Default: ${WRKSRC}
938 # NO_MTREE              - If set, will not invoke mtree from bsd.port.mk from
939 #                                 the "install" target.
940 # MTREE_FILE    - The name of the mtree file.
941 #                                 Default: ${PORTSDIR}/Templates/BSD.local.dist or
942 #                                 /etc/mtree/BSD.usr.dist if ${PREFIX} == "/usr".
943 # PLIST_DIRS    - Directories to be added to packing list
944 # PLIST_DIRSTRY - Directories to be added to packing list and try to remove them.
945 # PLIST_FILES   - Files and symbolic links to be added to packing list
946 #
947 # PLIST                 - Name of the `packing list' file.
948 #                                 Change this to ${WRKDIR}/PLIST or something if you
949 #                                 need to write to it.  (It is not a good idea for a port
950 #                                 to write to any file outside ${WRKDIR} during a normal
951 #                                 build.)
952 #                                 Default: ${PKGDIR}/pkg-plist
953 # TMPPLIST              - Name of the `packing list' file after processing
954 #                                 Default: ${WRKDIR}/.PLIST.mktmp
955 # PLIST_SUB             - List of "variable=value" pair for substitution in ${PLIST}
956 #                                 Default: see below
957 #
958 # SUB_FILES             - Files that should be passed through sed and redirected to
959 #                                 ${WRKDIR}.
960 #                               - For each file specified in SUB_FILES, there must be a
961 #                                 corresponding file in ${FILESDIR} whose suffix is ".in". For
962 #                                 instance, if the Makefile specifies "SUB_FILES= pkg-message"
963 #                                 then there must be a file called pkg-message.in in
964 #                                 ${FILESDIR}.
965 #                               - The substitution process is the same as PLIST_FILES, as
966 #                                 described below except that any line beginning with @comment
967 #                                 is deleted.
968 # SUB_LIST              - List of "variable=value" pair for substitution in ${SUB_FILES}
969 #                                 Some pairs are added by default: eg. PREFIX=${PREFIX}
970 #
971 # USE_LDCONFIG  - If set to "yes", this adds ${PREFIX}/lib to the list of
972 #                                 directories to be searched for shared libraries.
973 #                                 Otherwise, this is a list of directories to be added to that
974 #                                 list. The directory names are written to
975 #                                 ${PREFIX}/libdata/ldconfig/${UNIQUENAME} which is then
976 #                                 used by the ldconfig startup script.
977 #                                 This mechanism replaces ldconfig scripts installed by some
978 #                                 ports, often under such names as 000.${UNQUENAME}.sh.
979 #                                 If USE_LINUX_PREFIX is defined, the Linux version of
980 #                                 ldconfig will be used instead of the native FreeBSD
981 #                                 version, and the directory list given will be ignored.
982 # USE_LDCONFIG32
983 #                               - Same as USE_LDCONFIG but the target file is
984 #                                 ${PREFIX}/libdata/ldconfig32/${UNIQUENAME} instead.
985 #                                 Note: that should only be used on 64-bit architectures.
986 # NO_LDCONFIG_MTREE
987 #                               - Denotes whether the libdata/ldconfig directory is part of
988 #                                 the mtree on a given OSVERSION system.  If it is not, we
989 #                                 create the directory, pull in the ldconfig_compat port,
990 #                                 and clean up on de-installation.  NOTE: this variable is
991 #                                 internal to bsd.port.mk and must not be set in your Makefile.
992 #
993 # DOCSDIR               - Name of the directory to install the packages docs in.
994 #                                 Default: ${PREFIX}/share/doc/${PORTNAME}
995 # DOCSDIR_REL   - The DOCSDIR relative to ${PREFIX}
996 # EXAMPLESDIR   - Name of the directory to install the packages examples in.
997 #                                 Default: ${PREFIX}/share/examples/${PORTNAME}
998 # EXAMPLESDIR_REL
999 #                               - The EXAMPLESDIR relative to ${PREFIX}
1000 # DATADIR               - Name of the directory to install the packages shared data in.
1001 #                                 Default: ${PREFIX}/share/${PORTNAME}
1002 # DATADIR_REL   - The DATADIR relative to ${PREFIX}
1003 #
1004 # WWWDIR                - Name of the directory to install the packages www data in.
1005 #                                 Default: ${PREFIX}/www/${PORTNAME}
1006 # WWWDIR_REL    - The WWWDIR relative to ${PREFIX}
1007 #
1008 # USERS                 - List of users to create at install time. Each login must
1009 #                                 have a corresponding entry in ${UID_FILES}.
1010 # GROUPS                - List of groups to create at install time. Each group must
1011 #                                 have a corresponding entry in ${GID_FILES}.
1012 #
1013 # DESKTOPDIR    - Name of the directory to install ${DESKTOP_ENTRIES} in.
1014 #                                 Default: ${PREFIX}/share/applications
1015 # DESKTOP_ENTRIES
1016 #                               - List of desktop entry files to generate and install in
1017 #                                 ${DESKTOPDIR}. The format is
1018 #                                 "Name" "Comment" "Icon" "Exec" "Categories" StartupNotify
1019 #                                 Rules:
1020 #                                       * Only add desktop entries for applications which do not
1021 #                                         require a terminal (ie. X applications).
1022 #                                       * If the upstream distribution already installs .desktop
1023 #                                         files, you do not need to use this.
1024 #                                       * If you require a more elaborate .desktop file than this
1025 #                                         variable permits, write it yourself and install it
1026 #                                         in ${DESKTOPDIR}.
1027 #                                 Notes:
1028 #                                       * Comment, Icon and StartupNotify may be empty
1029 #                                         strings (""). Categories may be an empty string in some
1030 #                                         cases (see below). The other fields are mandatory.
1031 #                                       * If Comment is an empty string, port ${COMMENT} will be
1032 #                                         used.
1033 #                                       * If set, Icon must be either absolute path (usually
1034 #                                         ${PREFIX}/share/pixmaps/${PORTNAME}.png) or icon name
1035 #                                         without extension if installed icons follow Icon Theme
1036 #                                         Specification.
1037 #                                       * If Categories is an empty string, bsd.port.mk will try
1038 #                                         to deduce a default value using the CATEGORIES variable.
1039 #                                         If the deduction fails, you will have to set Categories
1040 #                                         manually. You should check the generated value using
1041 #                                         "make desktop-categories", and override it if necessary.
1042 #                                       * Exec will also be used to name the .desktop file.
1043 #                                       * StartupNotify may be true, false or empty (see Desktop
1044 #                                         Entry Specification for details).
1045 #                                       * The files will be automatically added to ${PLIST}.
1046 #                                 Example:
1047 #                                       "X Window Information" \
1048 #                                       "Get information about X windows" \
1049 #                                       "${PREFIX}/share/pixmaps/wininfo.png" \
1050 #                                       "${PREFIX}/bin/wininfo" \
1051 #                                       "System;" \
1052 #                                       ""
1053 #                                 See http://standards.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html
1054 #                                 for an explanation of the fields. If you need to create more
1055 #                                 than one file, just chain them into a single variable.
1056 #
1057 # Note that the install target will automatically add manpages (see
1058 # above) and also substitute special sequences of characters (delimited
1059 # by "%%") as defined in PLIST_SUB to generate ${TMPPLIST}.  For
1060 # instance, "OSREL=${OSREL}" in PLIST_SUB causes all occurrences of
1061 # "%%OSREL%%" in ${PLIST} to be substituted by the value of OSREL.
1062 # ${TMPPLIST} is generated before the do-install stage.  If you are
1063 # generating the packing list on-the-fly, make sure it's generated before
1064 # do-install is called!
1065 #
1066 # For package:
1067 #
1068 # NO_LATEST_LINK
1069 #                               - Do not install the "Latest" link for package.  Define this
1070 #                                 if this port is a beta version of another stable port
1071 #                                 which is also in the tree.
1072 # LATEST_LINK   - Install the "Latest" link for the package as ___.  Define
1073 #                                 this if the "Latest" link name will be incorrectly determined.
1074 #
1075 # This is used in all stages:
1076 #
1077 # SCRIPTS_ENV   - Additional environment vars passed to scripts in
1078 #                                 ${SCRIPTDIR} executed by bsd.port.mk.
1079 #                                 Default: see below
1080 #
1081 # Finally, variables to change if you want a special behavior.  These
1082 # are for debugging purposes.  Don't set them in your Makefile.
1083 #
1084 # ECHO_MSG              - Used to print all the '===>' style prompts - override this
1085 #                                 to turn them off.
1086 #                                 Default: ${ECHO_CMD}
1087 # PATCH_DEBUG   - If set, print out more information about the patches as
1088 #                                 it attempts to apply them.
1089 # PKG_DBDIR             - Where package installation is recorded; this directory
1090 #                                 must not contain anything else.
1091 #                                 Default: /var/db/pkg
1092 # PORT_DBDIR    - Where port configuration options are recorded.
1093 #                                 Default: /var/db/ports
1094 # NO_PKG_REGISTER
1095 #                               - Don't register a port installation as a package.
1096 # FORCE_PKG_REGISTER
1097 #                               - If set, it will overwrite any existing package
1098 #                                 registration information in ${PKG_DBDIR}/${PKGNAME}.
1099 # NO_DEPENDS    - Don't verify build of dependencies.
1100 # CHECKSUM_ALGORITHMS
1101 #                               - Different checksum algorithms to check for verifying the
1102 #                                 integrity of the distfiles. The absence of the algorithm
1103 #                                 in distinfo doesn't make it fail.
1104 #                                 Default: sha256
1105 # NO_CHECKSUM   - Don't verify the checksum.  Typically used when
1106 #                                 when you noticed the distfile you just fetched has
1107 #                                 a different checksum and you intend to verify if
1108 #                                 the port still works with it.
1109 # USE_PACKAGE_DEPENDS
1110 #                               - Try to install dependencies from existing packages instead
1111 #                                 of building the port from scratch. Fallback on source
1112 #                                 if an existing package is not present.
1113 # USE_PACKAGE_DEPENDS_ONLY
1114 #                               - Like USE_PACKAGE_DEPENDS, but do not fallback on source.
1115 # INSTALL_AS_USER
1116 #                               - Define this to install as the current user, intended
1117 #                                 for systems where you have no root access.
1118 # DISABLE_SIZE  - Do not check the size of a distfile even if the SIZE field
1119 #                                 has been specified in distinfo.  This is useful
1120 #                                 when using an alternate FETCH_CMD.
1121 #
1122 # End of the list of all variables that need to be defined in a port.
1123 # Most port authors should not need to understand anything after this point.
1124 #
1125
1126 # These need to be absolute since we don't know how deep in the ports
1127 # tree we are and thus can't go relative.  They can, of course, be overridden
1128 # by individual Makefiles or local system make configuration.
1129 WITH_PKGNG?=            yes
1130 WITHOUT_FBSD10_FIX?=    yes
1131 DFLY_PATCHDIR?=         ${MASTERDIR}/dragonfly
1132 DFLY_FILESDIR?=         ${MASTERDIR}/dragonfly
1133 PORTSDIR?=              /usr/dports
1134 LOCALBASE?=             /usr/local
1135 LINUXBASE?=             /compat/linux
1136 DISTDIR?=               /usr/distfiles
1137 WRKDIRPREFIX?=          /usr/obj/dports
1138 _DISTDIR?=              ${DISTDIR}/${DIST_SUBDIR}
1139 INDEXDIR?=              ${PORTSDIR}
1140 SRC_BASE?=              /usr/src
1141 USESDIR?=               ${PORTSDIR}/Mk/Uses
1142 SCRIPTSDIR?=    ${PORTSDIR}/Mk/Scripts
1143 LIB_DIRS?=              /lib /usr/lib ${LOCALBASE}/lib
1144 NOTPHONY?=
1145 PKG_ENV+=               PORTSDIR=${PORTSDIR}
1146
1147 .if defined(FORCE_STAGE)
1148 .undef NO_STAGE
1149 .endif
1150
1151 # Prevent dport from building profile libraries
1152 NOPROFILE=              yes
1153 .export NOPROFILE
1154
1155 .include "${PORTSDIR}/Mk/bsd.commands.mk"
1156
1157 .if defined(X_BUILD_FOR)
1158 .if defined(NO_STAGE)
1159 IGNORE= Cross building is only compatible with stagified ports
1160 .endif
1161 .if !defined(.PARSEDIR)
1162 IGNORE= Cross building can only be done when using bmake(1) as make(1)
1163 .endif
1164 BUILD_DEPENDS=  ${X_BUILD_FOR}-cc:${PORTSDIR}/devel/${X_BUILD_FOR}-xdev
1165 # Do not define CPP on purpose
1166 .if !defined(HCC)
1167 HCC:=   ${CC}
1168 HCXX:=  ${CXX}
1169 .endif
1170 .if !exists(/usr/${X_BUILD_FOR}/usr/bin/cc)
1171 CC=             ${LOCALBASE}/${X_BUILD_FOR}/usr/bin/cc
1172 CXX=            ${LOCALBASE}/${X_BUILD_FOR}/usr/bin/c++
1173 PKG_ENV+=       ABI_FILE=${LOCALBASE}/${X_BUILD_FOR}/usr/lib/crt1.o
1174 .else
1175 CC=             /usr/${X_BUILD_FOR}/usr/bin/cc
1176 CXX=    /usr/${X_BUILD_FOR}/usr/bin/c++
1177 PKG_ENV+=       ABI_FILE=/usr/${X_BUILD_FOR}/usr/lib/crt1.o
1178 .endif
1179 NM=             ${X_BUILD_FOR}-nm
1180 STRIP_CMD=      ${X_BUILD_FOR}-strip
1181 MAKE_ENV+=      NM=${NM} STRIPBIN=${X_BUILD_FOR}-strip
1182 # only bmake support the below
1183 STRIPBIN=       ${STRIP_CMD}
1184 .export.env STRIPBIN
1185 .endif
1186
1187 #
1188 # DESTDIR section to start a chrooted process if invoked with DESTDIR set
1189 #
1190
1191 .if defined(DESTDIR) && !empty(DESTDIR) && !defined(CHROOTED) && \
1192         !defined(BEFOREPORTMK) && !defined(INOPTIONSMK)
1193
1194 .include "${PORTSDIR}/Mk/bsd.destdir.mk"
1195
1196 .else
1197
1198 # Look for ${PATCH_WRKSRC}/.../*.orig files, and (re-)create
1199 # ${FILEDIR}/patch-* files from them.
1200
1201 .if !target(makepatch)
1202 makepatch:
1203         @${MKDIR} ${FILESDIR}
1204         @(cd ${PATCH_WRKSRC}; \
1205                 for i in `find . -type f -name '*.orig'`; do \
1206                         ORG=$$i; \
1207                         NEW=$${i%.orig}; \
1208                         OUT=${FILESDIR}`${ECHO} $${NEW} | \
1209                                 ${SED} -e 's|/|__|g' \
1210                                         -e 's|^\.__|/patch-|'`; \
1211                         ${ECHO} ${DIFF} -ud $${ORG} $${NEW} '>' $${OUT}; \
1212                         ${DIFF} -ud $${ORG} $${NEW} > $${OUT} || ${TRUE}; \
1213                 done \
1214         )
1215 .endif
1216
1217
1218 # Start of options section
1219 .if defined(INOPTIONSMK) || ( !defined(USEOPTIONSMK) && !defined(AFTERPORTMK) )
1220
1221
1222 # Get the default maintainer
1223 MAINTAINER?=    ports@FreeBSD.org
1224
1225 # Get the architecture
1226 .if !defined(ARCH)
1227 ARCH!=  ${UNAME} -p
1228 .endif
1229
1230 # Get the operating system type
1231 .if !defined(OPSYS)
1232 OPSYS!= ${UNAME} -s
1233 .endif
1234
1235 # Get __FreeBSD_version
1236 .if !defined(OSVERSION)
1237 OSVERSION=      9999999
1238 .endif
1239
1240 .if !defined(DFLYVERSION)
1241 .if exists(/usr/include/sys/param.h)
1242 DFLYVERSION!=   ${AWK} '/^\#define[[:blank:]]__DragonFly_version/ {print $$3}' < /usr/include/sys/param.h
1243 OSREL!=         ${ECHO} ${DFLYVERSION} | ${AWK} '{a=int($$1/100000); b=int(($$1-(a*100000))/100); print a "." b}'
1244 .else
1245 DFLYVERSION!=   ${SYSCTL} -n kern.osreldate
1246 OSREL!=         ${UNAME} -r | ${SED} -e 's/[-(].*//'
1247 .endif
1248 .endif
1249
1250 .if !defined(WITH_PKGNG) && !defined(NO_WARNING_PKG_INSTALL_EOL)
1251 WARNING+=       "pkg_install EOL is scheduled for 2014-09-01. Please consider migrating to pkgng"
1252 WARNING+=       "http://blogs.freebsdish.org/portmgr/2014/02/03/time-to-bid-farewell-to-the-old-pkg_-tools/"
1253 WARNING+=       "If you do not want to see this message again set NO_WARNING_PKG_INSTALL_EOL=yes in your make.conf"
1254 .endif
1255
1256 # Enable new xorg for FreeBSD versions after Radeon KMS was imported unless
1257 # WITHOUT_NEW_XORG is set.
1258 .if ${OPSYS} == FreeBSD && ${OSVERSION} >= 1100000
1259 . if !defined(WITHOUT_NEW_XORG)
1260 WITH_NEW_XORG?= yes
1261 . else
1262 .undef WITH_NEW_XORG
1263 . endif
1264 .endif
1265
1266 # Only define tools here (for transition period with between pkg tools)
1267 .include "${PORTSDIR}/Mk/bsd.commands.mk"
1268
1269 MASTERDIR?=     ${.CURDIR}
1270
1271 .if ${MASTERDIR} != ${.CURDIR}
1272 SLAVE_PORT?=    yes
1273 MASTER_PORT?=${MASTERDIR:C/[^\/]+\/\.\.\///:C/[^\/]+\/\.\.\///:C/^.*\/([^\/]+\/[^\/]+)$/\\1/}
1274 .else
1275 SLAVE_PORT?=    no
1276 MASTER_PORT?=
1277 .endif
1278
1279 # If they exist, include Makefile.inc, then architecture/operating
1280 # system specific Makefiles, then local Makefile.local.
1281
1282 .if ${MASTERDIR} != ${.CURDIR} && exists(${.CURDIR}/../Makefile.inc)
1283 .include "${.CURDIR}/../Makefile.inc"
1284 USE_SUBMAKE=    yes
1285 .endif
1286
1287 .if exists(${MASTERDIR}/../Makefile.inc)
1288 .include "${MASTERDIR}/../Makefile.inc"
1289 USE_SUBMAKE=    yes
1290 .endif
1291
1292 .if exists(${MASTERDIR}/Makefile.${ARCH}-${OPSYS})
1293 .include "${MASTERDIR}/Makefile.${ARCH}-${OPSYS}"
1294 USE_SUBMAKE=    yes
1295 .elif exists(${MASTERDIR}/Makefile.${OPSYS})
1296 .include "${MASTERDIR}/Makefile.${OPSYS}"
1297 USE_SUBMAKE=    yes
1298 .elif exists(${MASTERDIR}/Makefile.${ARCH})
1299 .include "${MASTERDIR}/Makefile.${ARCH}"
1300 USE_SUBMAKE=    yes
1301 .endif
1302
1303 .if exists(${MASTERDIR}/Makefile.local)
1304 .include "${MASTERDIR}/Makefile.local"
1305 USE_SUBMAKE=    yes
1306 .endif
1307
1308 .for _CATEGORY in ${CATEGORIES}
1309 PKGCATEGORY?=   ${_CATEGORY}
1310 .endfor
1311 _PORTDIRNAME=   ${.CURDIR:T}
1312 PORTDIRNAME?=   ${_PORTDIRNAME}
1313 PKGORIGIN?=             ${PKGCATEGORY}/${PORTDIRNAME}
1314
1315 # where 'make config' records user configuration options
1316 PORT_DBDIR?=    /var/db/ports
1317
1318 UID_FILES?=     ${PORTSDIR}/UIDs
1319 GID_FILES?=     ${PORTSDIR}/GIDs
1320 UID_OFFSET?=    0
1321 GID_OFFSET?=    0
1322
1323 # predefined accounts from src/etc/master.passwd
1324 # alpha numeric sort order
1325 USERS_BLACKLIST=        _dhcp _pflogd auditdistd bin bind daemon games hast kmem mailnull man news nobody operator pop proxy root smmsp sshd toor tty uucp www
1326
1327 LDCONFIG_DIR=   libdata/ldconfig
1328 LDCONFIG32_DIR= libdata/ldconfig32
1329
1330 .if defined(LATEST_LINK)
1331 UNIQUENAME?=    ${LATEST_LINK}
1332 .else
1333 UNIQUENAME?=    ${PKGNAMEPREFIX}${PORTNAME}
1334 .endif
1335
1336 .endif
1337
1338 # At least KDE needs TMPDIR for the package building,
1339 # so we're setting it to the known default value.
1340 .if defined(PACKAGE_BUILDING)
1341 TMPDIR?=        /tmp
1342 .endif # defined(PACKAGE_BUILDING)
1343
1344 # Respect TMPDIR passed via make.conf or similar and pass it down
1345 # to configure and make.
1346 .if defined(TMPDIR)
1347 MAKE_ENV+=      TMPDIR="${TMPDIR}"
1348 CONFIGURE_ENV+= TMPDIR="${TMPDIR}"
1349 .endif # defined(TMPDIR)
1350
1351 .if defined(WITH_DEBUG_PORTS)
1352 .if ${WITH_DEBUG_PORTS:M${PKGORIGIN}}
1353 WITH_DEBUG=     yes
1354 .endif
1355 .endif
1356
1357 .include "${PORTSDIR}/Mk/bsd.options.mk"
1358
1359 # Multiple make jobs support
1360 .if defined(DISABLE_MAKE_JOBS) || defined(MAKE_JOBS_UNSAFE)
1361 _MAKE_JOBS=             #
1362 MAKE_JOBS_NUMBER=       1
1363 .else
1364 .if defined(MAKE_JOBS_NUMBER)
1365 _MAKE_JOBS_NUMBER:=     ${MAKE_JOBS_NUMBER}
1366 .else
1367 _MAKE_JOBS_NUMBER!=     ${SYSCTL} -n hw.ncpu
1368 .endif
1369 .if defined(MAKE_JOBS_NUMBER_LIMIT) && ( ${MAKE_JOBS_NUMBER_LIMIT} < ${_MAKE_JOBS_NUMBER} )
1370 MAKE_JOBS_NUMBER=       ${MAKE_JOBS_NUMBER_LIMIT}
1371 .else
1372 MAKE_JOBS_NUMBER=       ${_MAKE_JOBS_NUMBER}
1373 .endif
1374 _MAKE_JOBS?=            -j${MAKE_JOBS_NUMBER}
1375 BUILD_FAIL_MESSAGE+=    Try to set MAKE_JOBS_UNSAFE=yes and rebuild before reporting the failure to the maintainer.
1376 .endif
1377
1378 # Start of pre-makefile section.
1379 .if !defined(AFTERPORTMK) && !defined(INOPTIONSMK)
1380
1381 .include "${PORTSDIR}/Mk/bsd.sanity.mk"
1382
1383 _PREMKINCLUDED= yes
1384
1385 .if defined(PORTVERSION)
1386 .if ${PORTVERSION:M*[-_,]*}x != x
1387 IGNORE=                 PORTVERSION ${PORTVERSION} may not contain '-' '_' or ','
1388 .endif
1389 DISTVERSION?=   ${PORTVERSION:S/:/::/g}
1390 .elif defined(DISTVERSION)
1391 PORTVERSION=    ${DISTVERSION:tl:C/([a-z])[a-z]+/\1/g:C/([0-9])([a-z])/\1.\2/g:C/:(.)/\1/g:C/[^a-z0-9+]+/./g}
1392 .endif
1393
1394 PORTREVISION?=  0
1395 .if ${PORTREVISION} != 0
1396 _SUF1=  _${PORTREVISION}
1397 .endif
1398
1399 PORTEPOCH?=             0
1400 .if ${PORTEPOCH} != 0
1401 _SUF2=  ,${PORTEPOCH}
1402 .endif
1403
1404 PKGVERSION=     ${PORTVERSION:C/[-_,]/./g}${_SUF1}${_SUF2}
1405 PKGNAME=        ${PKGNAMEPREFIX}${PORTNAME}${PKGNAMESUFFIX}-${PKGVERSION}
1406 DISTNAME?=      ${PORTNAME}-${DISTVERSIONPREFIX}${DISTVERSION:C/:(.)/\1/g}${DISTVERSIONSUFFIX}
1407
1408 INDEXFILE?=             INDEX-${DFLYVERSION:C/([0-9]*)[0-9]{5}/\1/}
1409
1410 DOCSDIR?=               ${PREFIX}/share/doc/${PORTNAME}
1411 EXAMPLESDIR?=           ${PREFIX}/share/examples/${PORTNAME}
1412 DATADIR?=               ${PREFIX}/share/${PORTNAME}
1413 WWWDIR?=                ${PREFIX}/www/${PORTNAME}
1414 ETCDIR?=                ${PREFIX}/etc/${PORTNAME}
1415
1416 .if defined(USE_LINUX_RPM)
1417 .include "${PORTSDIR}/Mk/bsd.linux-rpm.mk"
1418 .endif
1419
1420 .if defined(USE_LINUX_APPS)
1421 .include "${PORTSDIR}/Mk/bsd.linux-apps.mk"
1422 .endif
1423
1424 .if defined(USE_XORG) || defined(XORG_CAT)
1425 .include "${PORTSDIR}/Mk/bsd.xorg.mk"
1426 .endif
1427
1428 PACKAGES?=              /usr/packages
1429 TEMPLATES?=             ${PORTSDIR}/Templates
1430 KEYWORDS?=              ${PORTSDIR}/Keywords
1431
1432 PATCHDIR?=              ${MASTERDIR}/files
1433 FILESDIR?=              ${MASTERDIR}/files
1434 SCRIPTDIR?=             ${MASTERDIR}/scripts
1435 PKGDIR?=                ${MASTERDIR}
1436
1437 .if defined(USE_LINUX_PREFIX)
1438 PREFIX?=                ${LINUXBASE}
1439 NO_MTREE=               yes
1440 .else
1441 PREFIX?=                ${LOCALBASE}
1442 .endif
1443
1444 .if defined(USE_LINUX_PREFIX)
1445 LDCONFIG_CMD?=                  ${LINUXBASE}/sbin/ldconfig -r ${LINUXBASE}
1446 .endif
1447
1448 PKGCOMPATDIR?=          ${LOCALBASE}/lib/compat/pkg
1449
1450 .if defined(USE_LOCAL_MK)
1451 .include "${PORTSDIR}/Mk/bsd.local.mk"
1452 .endif
1453
1454 .if defined(USE_OPENSSL)
1455 .include "${PORTSDIR}/Mk/bsd.openssl.mk"
1456 .endif
1457
1458 .if defined(USE_EMACS)
1459 .include "${PORTSDIR}/Mk/bsd.emacs.mk"
1460 .endif
1461
1462 .if defined(USE_GNUSTEP)
1463 .include "${PORTSDIR}/Mk/bsd.gnustep.mk"
1464 .endif
1465
1466 .if defined(USE_PHP)
1467 .include "${PORTSDIR}/Mk/bsd.php.mk"
1468 .endif
1469
1470 .if defined(USE_PYTHON) || defined(USE_PYTHON_BUILD) || defined(USE_PYTHON_RUN)
1471 .include "${PORTSDIR}/Mk/bsd.python.mk"
1472 .endif
1473
1474 .if defined(USE_EFL) || defined(WANT_EFL) || defined(USE_EFL_ESMART)
1475 .include "${PORTSDIR}/Mk/bsd.efl.mk"
1476 .endif
1477
1478 .if defined(USE_FPC) || defined(WANT_FPC_BASE) || defined(WANT_FPC_ALL)
1479 .include "${PORTSDIR}/Mk/bsd.fpc.mk"
1480 .endif
1481
1482 .if defined(USE_JAVA)
1483 .include "${PORTSDIR}/Mk/bsd.java.mk"
1484 .endif
1485
1486 .if defined(USE_RUBY) || defined(USE_LIBRUBY)
1487 .include "${PORTSDIR}/Mk/bsd.ruby.mk"
1488 .endif
1489
1490 .if defined(USE_OCAML)
1491 .include "${PORTSDIR}/Mk/bsd.ocaml.mk"
1492 .endif
1493
1494 .if defined(USE_APACHE) || defined(USE_APACHE_BUILD) || defined(USE_APACHE_RUN)
1495 .include "${PORTSDIR}/Mk/bsd.apache.mk"
1496 .endif
1497
1498 .if defined(USE_QT4) || defined(USE_QT5)
1499 .include "${PORTSDIR}/Mk/bsd.qt.mk"
1500 .endif
1501
1502 .if defined(USE_TEX)
1503 .include "${PORTSDIR}/Mk/bsd.tex.mk"
1504 .endif
1505
1506 .if defined(USE_DRUPAL)
1507 .include "${PORTSDIR}/Mk/bsd.drupal.mk"
1508 .endif
1509
1510 .if defined(WANT_GECKO) || defined(USE_GECKO)
1511 .include "${PORTSDIR}/Mk/bsd.gecko.mk"
1512 .endif
1513
1514 .if defined(WANT_GNOME) || defined(USE_GNOME) || defined(INSTALLS_ICONS)
1515 .include "${PORTSDIR}/Mk/bsd.gnome.mk"
1516 .endif
1517
1518 .if defined(USE_MATE)
1519 .include "${PORTSDIR}/Mk/bsd.mate.mk"
1520 .endif
1521
1522 .if defined(WANT_LUA) || defined(USE_LUA) || defined(USE_LUA_NOT)
1523 .include "${PORTSDIR}/Mk/bsd.lua.mk"
1524 .endif
1525
1526 .if defined(WANT_WX) || defined(USE_WX) || defined(USE_WX_NOT)
1527 .include "${PORTSDIR}/Mk/bsd.wx.mk"
1528 .endif
1529
1530 .if defined(WANT_GSTREAMER) || defined(USE_GSTREAMER) || defined(USE_GSTREAMER1)
1531 .include "${PORTSDIR}/Mk/bsd.gstreamer.mk"
1532 .endif
1533
1534 .if defined(USE_SDL) || defined(WANT_SDL)
1535 .include "${PORTSDIR}/Mk/bsd.sdl.mk"
1536 .endif
1537
1538 .if defined(USE_XFCE)
1539 .include "${PORTSDIR}/Mk/bsd.xfce.mk"
1540 .endif
1541
1542 .if defined(USE_KDE4) || defined(KDE4_BUILDENV)
1543 .include "${PORTSDIR}/Mk/bsd.kde4.mk"
1544 .endif
1545
1546 .include "${PORTSDIR}/Mk/bsd.pbi.mk"
1547
1548 .if defined(USE_GMAKE)
1549 USES+=  gmake
1550 .endif
1551
1552 .if defined(USE_DOS2UNIX)
1553 .if ${USE_DOS2UNIX:tu}=="YES"
1554 DOS2UNIX_REGEX?=        .*
1555 .else
1556 .if ${USE_DOS2UNIX:M*/*}
1557 DOS2UNIX_FILES+=        ${USE_DOS2UNIX}
1558 .else
1559 DOS2UNIX_GLOB+= ${USE_DOS2UNIX}
1560 .endif
1561 .endif
1562 USES+=  dos2unix
1563 .endif
1564
1565 .if !defined(UID)
1566 UID!=   ${ID} -u
1567 .endif
1568
1569 # Loading features
1570 .for f in ${USES}
1571 _f=${f:C/\:.*//g}
1572 .if ${_f} != ${f}
1573 ${_f}_ARGS:=    ${f:C/^[^\:]*\://g}
1574 .endif
1575 .include "${USESDIR}/${_f}.mk"
1576 .endfor
1577
1578 .if defined(USE_BZIP2)
1579 EXTRACT_SUFX?=                  .tar.bz2
1580 .elif defined(USE_XZ)
1581 EXTRACT_SUFX?=                  .tar.xz
1582 .else
1583 EXTRACT_SUFX?=                  .tar.gz
1584 .endif
1585
1586 # You can force skipping these test by defining IGNORE_PATH_CHECKS
1587 .if !defined(IGNORE_PATH_CHECKS)
1588 .if ! ${PREFIX:M/*}
1589 .BEGIN:
1590         @${ECHO_MSG} "PREFIX must be defined as an absolute path so that when 'make'"
1591         @${ECHO_MSG} "is invoked in the work area PREFIX points to the right place."
1592         @${FALSE}
1593 .endif
1594 .endif
1595
1596 # Location of mounted CDROM(s) to search for files
1597 CD_MOUNTPTS?=   /cdrom ${CD_MOUNTPT}
1598
1599 # Owner and group of the WWW user
1600 WWWOWN?=        www
1601 WWWGRP?=        www
1602
1603 .endif
1604 # End of pre-makefile section.
1605
1606 # Start of post-makefile section.
1607 .if !defined(BEFOREPORTMK) && !defined(INOPTIONSMK)
1608
1609 .if defined(_POSTMKINCLUDED)
1610 DEV_ERROR+=     "${PKGNAME}: Makefile error: you cannot include bsd.port[.post].mk twice"
1611         @${FALSE}
1612 .endif
1613
1614 _POSTMKINCLUDED=        yes
1615
1616 WRKDIR?=                ${WRKDIRPREFIX}/${.CURDIR:H:T}/${.CURDIR:T}/work
1617 .if !defined(IGNORE_MASTER_SITE_GITHUB) && defined(USE_GITHUB)
1618 WRKSRC?=                ${WRKDIR}/${GH_ACCOUNT}-${GH_PROJECT}-${GH_COMMIT}
1619 .endif
1620 .if defined(NO_WRKSUBDIR)
1621 WRKSRC?=                ${WRKDIR}
1622 .else
1623 WRKSRC?=                ${WRKDIR}/${DISTNAME}
1624 .endif
1625 .if defined(WRKSRC_SUBDIR)
1626 WRKSRC:=                ${WRKSRC}/${WRKSRC_SUBDIR}
1627 .endif
1628
1629 PATCH_WRKSRC?=  ${WRKSRC}
1630 CONFIGURE_WRKSRC?=      ${WRKSRC}
1631 BUILD_WRKSRC?=  ${WRKSRC}
1632 INSTALL_WRKSRC?=${WRKSRC}
1633
1634 PLIST_SUB+=     OSREL=${OSREL} PREFIX=%D LOCALBASE=${LOCALBASE}
1635 SUB_LIST+=      PREFIX=${PREFIX} LOCALBASE=${LOCALBASE} \
1636                 DATADIR=${DATADIR} DOCSDIR=${DOCSDIR} EXAMPLESDIR=${EXAMPLESDIR} \
1637                 WWWDIR=${WWWDIR} ETCDIR=${ETCDIR}
1638
1639 PLIST_REINPLACE+=       dirrmtry stopdaemon rmtry
1640 PLIST_REINPLACE_DIRRMTRY=s!^@dirrmtry \(.*\)!@unexec rmdir "%D/\1" 2>/dev/null || true!
1641 PLIST_REINPLACE_RMTRY=s!^@rmtry \(.*\)!@unexec rm -f %D/\1 2>/dev/null || true!
1642 PLIST_REINPLACE_STOPDAEMON=s!^@stopdaemon \(.*\)!@unexec %D/etc/rc.d/\1 forcestop 2>/dev/null || true!
1643
1644 # kludge to strip trailing whitespace from CFLAGS;
1645 # sub-configure will not # survive double space
1646 # remove -O from /usr/share/mk/sys.mk and replace with -O2
1647 CFLAGS:=        ${CFLAGS:C/ $//:N-O}
1648 CFLAGS+=        -O2
1649
1650 .if defined(WITHOUT_CPU_CFLAGS)
1651 .if defined(_CPUCFLAGS)
1652 .if !empty(_CPUCFLAGS)
1653 CFLAGS:=        ${CFLAGS:C/${_CPUCFLAGS}//}
1654 .endif
1655 .endif
1656 .endif
1657
1658 # Reset value from bsd.own.mk.
1659 .if defined(WITH_DEBUG) && !defined(WITHOUT_DEBUG)
1660 STRIP=  #none
1661 MAKE_ENV+=      DONTSTRIP=yes
1662 STRIP_CMD=      ${TRUE}
1663 DEBUG_FLAGS?=   -g
1664 CFLAGS:=                ${CFLAGS:N-O*:N-fno-strict*} ${DEBUG_FLAGS}
1665 .if defined(INSTALL_TARGET)
1666 INSTALL_TARGET:=        ${INSTALL_TARGET:S/^install-strip$/install/g}
1667 .endif
1668 .endif
1669
1670 .if defined(WITH_SSP) || defined(WITH_SSP_PORTS)
1671 .include "${PORTSDIR}/Mk/bsd.ssp.mk"
1672 .endif
1673
1674 .if defined(NOPORTDOCS)
1675 PLIST_SUB+=             PORTDOCS="@comment "
1676 .else
1677 PLIST_SUB+=             PORTDOCS=""
1678 .endif
1679
1680 .if defined(NOPORTEXAMPLES)
1681 PLIST_SUB+=             PORTEXAMPLES="@comment "
1682 .else
1683 PLIST_SUB+=             PORTEXAMPLES=""
1684 .endif
1685
1686 .if defined(NOPORTDATA)
1687 PLIST_SUB+=             PORTDATA="@comment "
1688 .else
1689 PLIST_SUB+=             PORTDATA=""
1690 .endif
1691
1692 CONFIGURE_SHELL?=       ${SH}
1693 MAKE_SHELL?=    ${SH}
1694
1695 CONFIGURE_ENV+= SHELL=${SH} CONFIG_SHELL=${SH}
1696 MAKE_ENV+=              SHELL=${SH} NO_LINT=YES
1697
1698 .if defined(MANCOMPRESSED)
1699 .if ${MANCOMPRESSED} != yes && ${MANCOMPRESSED} != no && \
1700         ${MANCOMPRESSED} != maybe
1701 check-makevars::
1702         @${ECHO_MSG} "${PKGNAME}: Makefile error: value of MANCOMPRESSED (is \"${MANCOMPRESSED}\") can only be \"yes\", \"no\" or \"maybe\"".
1703         @${FALSE}
1704 .endif
1705 .endif
1706
1707 MANCOMPRESSED?= no
1708
1709 .if defined(PATCHFILES)
1710 .if ${PATCHFILES:M*.zip}x != x
1711 PATCH_DEPENDS+=         ${LOCALBASE}/bin/unzip:${PORTSDIR}/archivers/unzip
1712 .endif
1713 .endif
1714
1715 # Check the compatibility layer for amd64/ia64
1716
1717 .if ${ARCH} == "amd64" || ${ARCH} =="ia64"
1718 .if exists(/usr/lib32)
1719 HAVE_COMPAT_IA32_LIBS?=  YES
1720 .endif
1721 .if !defined(HAVE_COMPAT_IA32_KERN)
1722 HAVE_COMPAT_IA32_KERN!= if ${SYSCTL} -n compat.ia32.maxvmem >/dev/null 2>&1; then echo YES; fi; echo
1723 .if empty(HAVE_COMPAT_IA32_KERN)
1724 .undef HAVE_COMPAT_IA32_KERN
1725 .endif
1726 .endif
1727 .endif
1728
1729 .if defined(IA32_BINARY_PORT) && ${ARCH} != "i386"
1730 .if ${ARCH} == "amd64" || ${ARCH} == "ia64"
1731 .if !defined(HAVE_COMPAT_IA32_KERN)
1732 IGNORE=         requires a kernel with compiled-in IA32 compatibility
1733 .elif !defined(HAVE_COMPAT_IA32_LIBS)
1734 IGNORE=         requires 32-bit libraries installed under /usr/lib32
1735 .endif
1736 _LDCONFIG_FLAGS=-32
1737 LIB32DIR=       lib32
1738 .else
1739 IGNORE=         requires i386 (or compatible) platform to run
1740 .endif
1741 .else
1742 LIB32DIR=       lib
1743 .endif
1744 PLIST_SUB+=     LIB32DIR=${LIB32DIR}
1745
1746 PKGNG_ORIGIN?=  ports-mgmt/pkg
1747 .if defined(WITH_PKGNG)
1748 .if ${WITH_PKGNG} == devel
1749 PKGNG_ORIGIN=           ports-mgmt/pkg-devel
1750 .endif
1751 .if !defined(PKG_DEPENDS)
1752 .if !defined(CLEAN_FETCH_ENV)
1753 PKG_DEPENDS+=           ${LOCALBASE}/sbin/pkg:${PORTSDIR}/${PKGNG_ORIGIN}
1754 .endif
1755 .endif
1756 .endif
1757
1758 .if defined(USE_GCC)
1759 .include "${PORTSDIR}/Mk/bsd.gcc.mk"
1760 .else
1761 .  if !defined(USE_GNUSTEP)
1762 CONFIGURE_ENV+=         CCVER=gcc47
1763 MAKE_ENV+=              CCVER=gcc47
1764 .  endif
1765 .endif
1766
1767 .if defined(USE_BINUTILS) && !defined(DISABLE_BINUTILS)
1768 BUILD_DEPENDS+= ${LOCALBASE}/bin/as:${PORTSDIR}/devel/binutils
1769 BINUTILS?=      ADDR2LINE AR AS CPPFILT GPROF LD NM OBJCOPY OBJDUMP RANLIB \
1770         READELF SIZE STRINGS
1771 BINUTILS_NO_MAKE_ENV?=
1772 . for b in ${BINUTILS}
1773 ${b}=   ${LOCALBASE}/bin/${b:C/PP/++/:tl}
1774 .  if defined(GNU_CONFIGURE) || defined(BINUTILS_CONFIGURE)
1775 CONFIGURE_ENV+= ${b}="${${b}}"
1776 .  endif
1777 .  if ${BINUTILS_NO_MAKE_ENV:M${b}} == ""
1778 MAKE_ENV+=      ${b}="${${b}}"
1779 .  endif
1780 . endfor
1781 .endif
1782
1783 .if defined(USE_OPENLDAP) || defined(WANT_OPENLDAP_VER)
1784 .include "${PORTSDIR}/Mk/bsd.ldap.mk"
1785 .endif
1786
1787 .if defined(USE_RC_SUBR) && ${USE_RC_SUBR:tu} != "YES"
1788 SUB_FILES+=     ${USE_RC_SUBR}
1789 .endif
1790
1791 .if defined(USE_RCORDER)
1792 SUB_FILES+=     ${USE_RCORDER}
1793 .endif
1794
1795 .if defined(USE_LDCONFIG) && ${USE_LDCONFIG:tl} == "yes"
1796 USE_LDCONFIG=   ${PREFIX}/lib
1797 .endif
1798 .if defined(USE_LDCONFIG32) && ${USE_LDCONFIG32:tl} == "yes"
1799 IGNORE=                 has USE_LDCONFIG32 set to yes, which is not correct
1800 .endif
1801
1802 .if defined(USE_LINUX_PREFIX) && defined(USE_LDCONFIG)
1803 # we need ${LINUXBASE}/sbin/ldconfig
1804 USE_LINUX?=     yes
1805 .endif
1806
1807 .if defined(USE_LINUX)
1808
1809 .  if !defined(LINUX_OSRELEASE)
1810 LINUX_OSRELEASE!=       ${ECHO_CMD} `${SYSCTL} -n compat.linux.osrelease 2>/dev/null`
1811 .  endif
1812
1813 # install(1) also does a brandelf on strip, so don't strip with FreeBSD tools.
1814 STRIP=
1815 .       if exists(${LINUXBASE}/usr/bin/strip)
1816 STRIP_CMD=      ${LINUXBASE}/usr/bin/strip
1817 .       else
1818 STRIP_CMD=      ${TRUE}
1819 .       endif
1820
1821 # Allow the user to specify another linux_base version.
1822 .       if defined(OVERRIDE_LINUX_BASE_PORT)
1823 .               if ${USE_LINUX:tl} == yes
1824 USE_LINUX=      ${OVERRIDE_LINUX_BASE_PORT}
1825 .               endif
1826 .       endif
1827
1828 # NOTE: when you update the default linux_base version (case "yes"),
1829 # don't forget to update the Handbook!
1830
1831 .       if exists(${PORTSDIR}/emulators/linux_base-${USE_LINUX})
1832 LINUX_BASE_PORT=        ${LINUXBASE}/bin/sh:${PORTSDIR}/emulators/linux_base-${USE_LINUX}
1833 .       else
1834 .               if ${USE_LINUX:tl} == "yes"
1835 LINUX_BASE_PORT=        ${LINUXBASE}/etc/fedora-release:${PORTSDIR}/emulators/linux_base-f10
1836 .               else
1837 IGNORE=         cannot be built: there is no emulators/linux_base-${USE_LINUX}, perhaps wrong use of USE_LINUX or OVERRIDE_LINUX_BASE_PORT
1838 .               endif
1839 .       endif
1840
1841 RUN_DEPENDS+=   ${LINUX_BASE_PORT}
1842 .endif
1843
1844 .if defined(USE_DISPLAY)
1845 USES+=  display
1846 .endif
1847
1848 PKG_IGNORE_DEPENDS?=            'this_port_does_not_exist'
1849
1850 _GL_glesv2_LIB_DEPENDS=         libGLESv2.so:${PORTSDIR}/graphics/libglesv2
1851 _GL_egl_LIB_DEPENDS=            libEGL.so:${PORTSDIR}/graphics/libEGL
1852 _GL_gl_LIB_DEPENDS=             libGL.so:${PORTSDIR}/graphics/libGL
1853 _GL_gl_USE_XORG=                glproto dri2proto
1854 _GL_glew_LIB_DEPENDS=           libGLEW.so:${PORTSDIR}/graphics/glew
1855 _GL_glu_LIB_DEPENDS=            libGLU.so:${PORTSDIR}/graphics/libGLU
1856 _GL_glu_USE_XORG=               glproto dri2proto
1857 _GL_glw_LIB_DEPENDS=            libGLw.so:${PORTSDIR}/graphics/libGLw
1858 _GL_glut_LIB_DEPENDS=           libglut.so:${PORTSDIR}/graphics/freeglut
1859
1860 .if defined(USE_GL)
1861 . if ${USE_GL:tl} == "yes"
1862 USE_GL=         glu
1863 . endif
1864 . for _component in ${USE_GL}
1865 .  if !defined(_GL_${_component}_LIB_DEPENDS) && \
1866                 !defined(_GL_${_component}_RUN_DEPENDS)
1867 IGNORE=         uses unknown GL component
1868 .  else
1869 USE_XORG+=      ${_GL_${_component}_USE_XORG}
1870 BUILD_DEPENDS+= ${_GL_${_component}_BUILD_DEPENDS}
1871 LIB_DEPENDS+=   ${_GL_${_component}_LIB_DEPENDS}
1872 RUN_DEPENDS+=   ${_GL_${_component}_RUN_DEPENDS}
1873 .  endif
1874 . endfor
1875 .endif
1876
1877 .if !defined(NO_STAGE)
1878 .include "${PORTSDIR}/Mk/bsd.stage.mk"
1879 .else
1880 # Ignore STAGEDIR if set from make.conf
1881 .undef STAGEDIR
1882 # From command line it is impossible to undefined so we must raise an error
1883 .if defined(STAGEDIR)
1884 IGNORE= Do not define STAGEDIR in command line
1885 .endif
1886 .endif
1887
1888 .if defined(WITH_PKGNG)
1889 .include "${PORTSDIR}/Mk/bsd.pkgng.mk"
1890 .endif
1891
1892 .if defined(USE_LOCAL_MK)
1893 .include "${PORTSDIR}/Mk/bsd.local.mk"
1894 .endif
1895
1896 .if defined(USE_XORG) || defined(XORG_CAT)
1897 .include "${PORTSDIR}/Mk/bsd.xorg.mk"
1898 .endif
1899
1900 .if defined(USE_MYSQL) || defined(WANT_MYSQL_VER) || \
1901         defined(USE_PGSQL) || defined(WANT_PGSQL_VER) || \
1902         defined(USE_BDB) || defined(USE_SQLITE) || defined(USE_FIREBIRD)
1903 .include "${PORTSDIR}/Mk/bsd.database.mk"
1904 .endif
1905
1906 .if defined(WANT_GSTREAMER) || defined(USE_GSTREAMER) || defined(USE_GSTREAMER1)
1907 .include "${PORTSDIR}/Mk/bsd.gstreamer.mk"
1908 .endif
1909
1910 .if defined(USE_EFL) || defined(WANT_EFL) || defined(USE_EFL_ESMART)
1911 .include "${PORTSDIR}/Mk/bsd.efl.mk"
1912 .endif
1913
1914 .if defined(USE_JAVA)
1915 .include "${PORTSDIR}/Mk/bsd.java.mk"
1916 .endif
1917
1918 .if defined(USE_OCAML)
1919 .include "${PORTSDIR}/Mk/bsd.ocaml.mk"
1920 .endif
1921
1922 .if defined(USE_LINUX_RPM)
1923 .include "${PORTSDIR}/Mk/bsd.linux-rpm.mk"
1924 .endif
1925
1926 .if defined(USE_LINUX_APPS)
1927 .include "${PORTSDIR}/Mk/bsd.linux-apps.mk"
1928 .endif
1929
1930 .if defined(USE_QT4) || defined(USE_QT5)
1931 .include "${PORTSDIR}/Mk/bsd.qt.mk"
1932 .endif
1933
1934 .if defined(USE_SCONS)
1935 .include "${PORTSDIR}/Mk/bsd.scons.mk"
1936 .endif
1937
1938 .if defined(USE_SDL) || defined(WANT_SDL)
1939 .include "${PORTSDIR}/Mk/bsd.sdl.mk"
1940 .endif
1941
1942 .if defined(USE_PHP)
1943 .include "${PORTSDIR}/Mk/bsd.php.mk"
1944 .endif
1945
1946 .if defined(USE_PYTHON)
1947 .include "${PORTSDIR}/Mk/bsd.python.mk"
1948 .endif
1949
1950 .if defined(USE_LUA) || defined(USE_LUA_NOT)
1951 .include "${PORTSDIR}/Mk/bsd.lua.mk"
1952 .endif
1953
1954 .if defined(USE_WX) || defined(USE_WX_NOT)
1955 .include "${PORTSDIR}/Mk/bsd.wx.mk"
1956 .endif
1957
1958 .if defined(USE_APACHE) || defined(USE_APACHE_BUILD) || defined(USE_APACHE_RUN)
1959 .include "${PORTSDIR}/Mk/bsd.apache.mk"
1960 .endif
1961
1962 .if defined(USE_AUTOTOOLS)
1963 .include "${PORTSDIR}/Mk/bsd.autotools.mk"
1964 .endif
1965
1966 .if defined(USE_FPC) || defined(WANT_FPC_BASE) || defined(WANT_FPC_ALL)
1967 .include "${PORTSDIR}/Mk/bsd.fpc.mk"
1968 .endif
1969
1970 .if defined(WANT_GECKO) || defined(USE_GECKO)
1971 .include "${PORTSDIR}/Mk/bsd.gecko.mk"
1972 .endif
1973
1974 .if defined(WANT_GNOME) || defined(USE_GNOME)
1975 .include "${PORTSDIR}/Mk/bsd.gnome.mk"
1976 .endif
1977
1978 .if defined(USE_MATE)
1979 .include "${PORTSDIR}/Mk/bsd.mate.mk"
1980 .endif
1981
1982 .if defined(USE_XFCE)
1983 .include "${PORTSDIR}/Mk/bsd.xfce.mk"
1984 .endif
1985
1986 .if defined(USE_KDE4)
1987 .include "${PORTSDIR}/Mk/bsd.kde4.mk"
1988 .endif
1989
1990 .if exists(${PORTSDIR}/Makefile.inc)
1991 .include "${PORTSDIR}/Makefile.inc"
1992 USE_SUBMAKE=    yes
1993 .endif
1994
1995 # Loading features
1996 .for f in ${_USES_POST}
1997 _f=${f:C/\:.*//g}
1998 .if ${_f} != ${f}
1999 ${_f}_ARGS:=    ${f:C/^[^\:]*\://g}
2000 .endif
2001 .include "${USESDIR}/${_f}.mk"
2002 .endfor
2003
2004 .if defined(USE_XORG)
2005 # Add explicit X options to avoid problems with false positives in configure
2006 .if defined(GNU_CONFIGURE)
2007 CONFIGURE_ARGS+=--x-libraries=${LOCALBASE}/lib --x-includes=${LOCALBASE}/include
2008 .endif
2009 .endif
2010
2011 # Set the default for the installation of Postscript(TM)-
2012 # compatible functionality.
2013 .if !defined(USE_GHOSTSCRIPT)
2014 .       if defined(USE_GHOSTSCRIPT_BUILD)
2015 _USE_GHOSTSCRIPT=       ${USE_GHOSTSCRIPT_BUILD}
2016 .       elif defined(USE_GHOSTSCRIPT_RUN)
2017 _USE_GHOSTSCRIPT=       ${USE_GHOSTSCRIPT_RUN}
2018 .       endif
2019 .else
2020 _USE_GHOSTSCRIPT=       ${USE_GHOSTSCRIPT}
2021 .endif
2022
2023 .if defined(WITH_GHOSTSCRIPT_VER) && !empty(WITH_GHOSTSCRIPT_VER:M[789])
2024 _USE_GHOSTSCRIPT_DEFAULT_VER=   ${WITH_GHOSTSCRIPT_VER}
2025 .else
2026 _USE_GHOSTSCRIPT_DEFAULT_VER=   9
2027 .endif
2028
2029 .if defined(_USE_GHOSTSCRIPT)
2030 .       if !defined(WITHOUT_X11)
2031 _USE_GHOSTSCRIPT_PKGNAME_SUFFIX=
2032 .       else
2033 _USE_GHOSTSCRIPT_PKGNAME_SUFFIX=-nox11
2034 .       endif
2035 .       if !empty(_USE_GHOSTSCRIPT:M[789])
2036 _USE_GHOSTSCRIPT_VER=${_USE_GHOSTSCRIPT:M[789]}
2037 .       else
2038 _USE_GHOSTSCRIPT_VER=${_USE_GHOSTSCRIPT_DEFAULT_VER}
2039 .       endif
2040 .else
2041 _USE_GHOSTSCRIPT_VER=${_USE_GHOSTSCRIPT_DEFAULT_VER}
2042 .endif
2043
2044 # Sanity check
2045 .if defined(_USE_GHOSTSCRIPT) && defined(WITH_GHOSTSCRIPT_VER)
2046 .       if empty(WITH_GHOSTSCRIPT_VER:M[789])
2047 .               error You set an invalid value "${WITH_GHOSTSCRIPT_VER}" in WITH_GHOSTSCRIPT_VER.  Abort.
2048 .       elif ${_USE_GHOSTSCRIPT_VER} != ${WITH_GHOSTSCRIPT_VER}
2049 .               error You set WITH_GHOSTSCRIPT_VER as ${WITH_GHOSTSCRIPT_VER} but ${PKGNAME} requires print/ghostscript${_USE_GHOSTSCRIPT_VER}.  Abort.
2050 .       endif
2051 .endif
2052
2053 GHOSTSCRIPT_PORT?=      print/ghostscript${_USE_GHOSTSCRIPT_VER}${_USE_GHOSTSCRIPT_PKGNAME_SUFFIX}
2054
2055 # Set up the ghostscript dependencies.
2056 .if defined(USE_GHOSTSCRIPT) || defined(USE_GHOSTSCRIPT_BUILD)
2057 BUILD_DEPENDS+= gs:${PORTSDIR}/${GHOSTSCRIPT_PORT}
2058 .endif
2059 .if defined(USE_GHOSTSCRIPT) || defined(USE_GHOSTSCRIPT_RUN)
2060 RUN_DEPENDS+=   gs:${PORTSDIR}/${GHOSTSCRIPT_PORT}
2061 .endif
2062
2063 # Macro for doing in-place file editing using regexps
2064 REINPLACE_ARGS?=        -i.bak
2065 REINPLACE_CMD?= ${SED} ${REINPLACE_ARGS}
2066
2067 # Names of cookies used to skip already completed stages
2068 EXTRACT_COOKIE?=        ${WRKDIR}/.extract_done.${PORTNAME}.${PREFIX:S/\//_/g}
2069 CONFIGURE_COOKIE?=      ${WRKDIR}/.configure_done.${PORTNAME}.${PREFIX:S/\//_/g}
2070 INSTALL_COOKIE?=        ${WRKDIR}/.install_done.${PORTNAME}.${PREFIX:S/\//_/g}
2071 BUILD_COOKIE?=          ${WRKDIR}/.build_done.${PORTNAME}.${PREFIX:S/\//_/g}
2072 PATCH_COOKIE?=          ${WRKDIR}/.patch_done.${PORTNAME}.${PREFIX:S/\//_/g}
2073 PACKAGE_COOKIE?=        ${WRKDIR}/.package_done.${PORTNAME}.${PREFIX:S/\//_/g}
2074 STAGE_COOKIE?=          ${WRKDIR}/.stage_done.${PORTNAME}.${PREFIX:S/\//_/g}
2075
2076 # How to do nothing.  Override if you, for some strange reason, would rather
2077 # do something.
2078 DO_NADA?=               ${TRUE}
2079
2080 # Use this as the first operand to always build dependency.
2081 NONEXISTENT?=   /nonexistent
2082
2083 CHECKSUM_ALGORITHMS?= sha256
2084
2085 DISTINFO_FILE?=         ${MASTERDIR}/distinfo
2086
2087 MAKE_FLAGS?=    -f
2088 MAKEFILE?=              Makefile
2089 MAKE_CMD?=              /usr/bin/make
2090 MAKE_ENV+=              PREFIX=${PREFIX} \
2091                         LOCALBASE=${LOCALBASE} \
2092                         LIBDIR="${LIBDIR}" \
2093                         CC="${CC}" CFLAGS="${CFLAGS}" \
2094                         CPP="${CPP}" CPPFLAGS="${CPPFLAGS}" \
2095                         LDFLAGS="${LDFLAGS}" \
2096                         CXX="${CXX}" CXXFLAGS="${CXXFLAGS}" \
2097                         MANPREFIX="${MANPREFIX}"
2098
2099 # Add -fno-strict-aliasing to CFLAGS with optimization level -O2 or higher.
2100 # gcc 4.x enable strict aliasing optimization with -O2 which is known to break
2101 # a lot of ports.
2102 .if !defined(WITHOUT_NO_STRICT_ALIASING)
2103 .if ${CC} != "icc"
2104 .if !empty(CFLAGS:M-O[23s]) && empty(CFLAGS:M-fno-strict-aliasing)
2105 CFLAGS+=       -fno-strict-aliasing
2106 .endif
2107 .endif
2108 .endif
2109
2110 .if defined(USE_CSTD)
2111 CFLAGS:=        ${CFLAGS:N-std=*} -std=${USE_CSTD}
2112 .endif
2113
2114 .if defined(CFLAGS_${ARCH})
2115 CFLAGS+=        ${CFLAGS_${ARCH}}
2116 .endif
2117
2118 .if defined(USE_CXXSTD)
2119 CXXFLAGS:=      ${CXXFLAGS:N-std=*} -std=${USE_CXXSTD}
2120 .endif
2121
2122 .if defined(CXXFLAGS_${ARCH})
2123 CXXFLAGS+=      ${CXXFLAGS_${ARCH}}
2124 .endif
2125
2126 # ccache support
2127 # Support NO_CCACHE for common setups, require WITH_CCACHE_BUILD, and
2128 # don't use if ccache already set in CC
2129 .if !defined(NO_CCACHE) && defined(WITH_CCACHE_BUILD) && !${CC:M*ccache*} && \
2130   !defined(NO_BUILD) && !defined(NOCCACHE)
2131 # Avoid depends loops between pkg and ccache
2132 .       if !${.CURDIR:M*/devel/ccache} && !${.CURDIR:M*/ports-mgmt/pkg}
2133 BUILD_DEPENDS+=         ${LOCALBASE}/bin/ccache:${PORTSDIR}/devel/ccache
2134 .       endif
2135
2136 _CCACHE_PATH=   ${LOCALBASE}/libexec/ccache
2137
2138 # Prepend the ccache dir into the PATH and setup ccache env
2139 PATH:=  ${_CCACHE_PATH}:${PATH}
2140 .if !${MAKE_ENV:MPATH=*} && !${CONFIGURE_ENV:MPATH=*}
2141 MAKE_ENV+=                      PATH=${PATH}
2142 CONFIGURE_ENV+=         PATH=${PATH}
2143 .endif
2144
2145 .       if defined(CCACHE_DIR)
2146 MAKE_ENV+=              CCACHE_DIR="${CCACHE_DIR}"
2147 CONFIGURE_ENV+= CCACHE_DIR="${CCACHE_DIR}"
2148 .       endif
2149 .endif
2150
2151 PTHREAD_CFLAGS?=
2152 PTHREAD_LIBS?=          -pthread
2153
2154 FETCH_ENV?=             SSL_NO_VERIFY_PEER=1 SSL_NO_VERIFY_HOSTNAME=1
2155 FETCH_BINARY?=  /usr/bin/fetch
2156 FETCH_ARGS?=    -Fpr
2157 FETCH_REGET?=   1
2158 .if !defined(DISABLE_SIZE)
2159 FETCH_BEFORE_ARGS+=     $${CKSIZE:+-S $$CKSIZE}
2160 .endif
2161 FETCH_CMD?=             ${FETCH_BINARY} ${FETCH_ARGS}
2162
2163 .if defined(RANDOMIZE_MASTER_SITES)
2164 .if exists(/usr/games/random)
2165 RANDOM_CMD?=    /usr/games/random
2166 RANDOM_ARGS?=   "-w -f -"
2167 _RANDOMIZE_SITES=       " |${RANDOM_CMD} ${RANDOM_ARGS}"
2168 .endif
2169 .endif
2170
2171 TOUCH?=                 /usr/bin/touch
2172 TOUCH_FLAGS?=   -f
2173
2174 DISTORIG?=      .bak.orig
2175 PATCH?=                 /usr/bin/patch
2176 PATCH_STRIP?=   -p0
2177 PATCH_DIST_STRIP?=      -p0
2178 .if defined(PATCH_DEBUG)
2179 PATCH_DEBUG_TMP=        yes
2180 PATCH_ARGS?=    -d ${PATCH_WRKSRC} -E ${PATCH_STRIP}
2181 PATCH_DIST_ARGS?=       --suffix ${DISTORIG} -d ${PATCH_WRKSRC} -E ${PATCH_DIST_STRIP}
2182 .else
2183 PATCH_DEBUG_TMP=        no
2184 PATCH_ARGS?=    -d ${PATCH_WRKSRC} --forward --quiet -E ${PATCH_STRIP}
2185 PATCH_DIST_ARGS?=       --suffix ${DISTORIG} -d ${PATCH_WRKSRC} --forward --quiet -E ${PATCH_DIST_STRIP}
2186 .endif
2187 .if !defined(QUIET)
2188 PATCH_SILENT=           PATCH_SILENT=yes
2189 .endif
2190 .if defined(BATCH)
2191 PATCH_ARGS+=            --batch
2192 PATCH_DIST_ARGS+=       --batch
2193 .endif
2194
2195 # Prevent breakage with VERSION_CONTROL=numbered
2196 PATCH_ARGS+=    -V simple
2197
2198 .if defined(PATCH_CHECK_ONLY)
2199 PATCH_ARGS+=    -C
2200 PATCH_DIST_ARGS+=       -C
2201 .endif
2202
2203 .if ${PATCH} == "/usr/bin/patch"
2204 PATCH_ARGS+=    --suffix .orig
2205 PATCH_DIST_ARGS+=       --suffix .orig
2206 .endif
2207
2208 TAR?=   /usr/bin/tar
2209
2210 # EXTRACT_SUFX is defined in .pre.mk section
2211 EXTRACT_CMD?=   ${TAR}
2212 EXTRACT_BEFORE_ARGS?=   -xf
2213 .if defined(EXTRACT_PRESERVE_OWNERSHIP)
2214 EXTRACT_AFTER_ARGS?=
2215 .else
2216 EXTRACT_AFTER_ARGS?=    --no-same-owner --no-same-permissions
2217 .endif
2218
2219 # Figure out where the local mtree file is
2220 .if !defined(MTREE_FILE) && !defined(NO_MTREE)
2221 .if ${PREFIX} == /usr
2222 MTREE_FILE=     /etc/mtree/BSD.usr.dist
2223 .else
2224 MTREE_FILE=     ${PORTSDIR}/Templates/BSD.local.dist
2225 .endif
2226 MTREE_FILE_DEFAULT=yes
2227 .endif
2228 MTREE_CMD?=     /usr/sbin/mtree
2229 MTREE_ARGS?=    -U ${MTREE_FOLLOWS_SYMLINKS} -f ${MTREE_FILE} -d -e -p
2230
2231 READLINK_CMD?=  /usr/bin/readlink
2232
2233 # Determine whether or not we can use rootly owner/group functions.
2234 .if ${UID} == 0
2235 _BINOWNGRP=     -o ${BINOWN} -g ${BINGRP}
2236 _SHROWNGRP=     -o ${SHAREOWN} -g ${SHAREGRP}
2237 _MANOWNGRP=     -o ${MANOWN} -g ${MANGRP}
2238 .else
2239 _BINOWNGRP=
2240 _SHROWNGRP=
2241 _MANOWNGRP=
2242 .endif
2243
2244 # A few aliases for *-install targets
2245 INSTALL_PROGRAM= \
2246         ${INSTALL} ${COPY} ${STRIP} ${_BINOWNGRP} -m ${BINMODE}
2247 INSTALL_KLD= \
2248         ${INSTALL} ${COPY} ${_BINOWNGRP} -m ${BINMODE}
2249 INSTALL_LIB= \
2250         ${INSTALL} ${COPY} ${STRIP} ${_SHROWNGRP} -m ${SHAREMODE}
2251 INSTALL_SCRIPT= \
2252         ${INSTALL} ${COPY} ${_BINOWNGRP} -m ${BINMODE}
2253 INSTALL_DATA= \
2254         ${INSTALL} ${COPY} ${_SHROWNGRP} -m ${SHAREMODE}
2255 INSTALL_MAN= \
2256         ${INSTALL} ${COPY} ${_MANOWNGRP} -m ${MANMODE}
2257
2258 INSTALL_MACROS= BSD_INSTALL_PROGRAM="${INSTALL_PROGRAM}" \
2259                         BSD_INSTALL_LIB="${INSTALL_LIB}" \
2260                         BSD_INSTALL_SCRIPT="${INSTALL_SCRIPT}" \
2261                         BSD_INSTALL_DATA="${INSTALL_DATA}" \
2262                         BSD_INSTALL_MAN="${INSTALL_MAN}"
2263 MAKE_ENV+=      ${INSTALL_MACROS}
2264 SCRIPTS_ENV+=   ${INSTALL_MACROS}
2265
2266 # Macro for copying entire directory tree with correct permissions
2267 .if ${UID} == 0
2268 COPYTREE_BIN=   ${SH} -c '(${FIND} -d $$0 $$2 | ${CPIO} -dumpl $$1 >/dev/null \
2269                                         2>&1) && \
2270                                         ${CHOWN} -Rh ${BINOWN}:${BINGRP} $$1 && \
2271                                         ${FIND} -d $$0 $$2 -type d -exec chmod 755 $$1/{} \; && \
2272                                         ${FIND} -d $$0 $$2 -type f -exec chmod ${BINMODE} $$1/{} \;' --
2273 COPYTREE_SHARE= ${SH} -c '(${FIND} -d $$0 $$2 | ${CPIO} -dumpl $$1 >/dev/null \
2274                                         2>&1) && \
2275                                         ${CHOWN} -Rh ${SHAREOWN}:${SHAREGRP} $$1 && \
2276                                         ${FIND} -d $$0 $$2 -type d -exec chmod 755 $$1/{} \; && \
2277                                         ${FIND} -d $$0 $$2 -type f -exec chmod ${SHAREMODE} $$1/{} \;' --
2278 .else
2279 COPYTREE_BIN=   ${SH} -c '(${FIND} -d $$0 $$2 | ${CPIO} -dumpl $$1 >/dev/null \
2280                                         2>&1) && \
2281                                         ${FIND} -d $$0 $$2 -type d -exec chmod 755 $$1/{} \; && \
2282                                         ${FIND} -d $$0 $$2 -type f -exec chmod ${BINMODE} $$1/{} \;' --
2283 COPYTREE_SHARE= ${SH} -c '(${FIND} -d $$0 $$2 | ${CPIO} -dumpl $$1 >/dev/null \
2284                                         2>&1) && \
2285                                         ${FIND} -d $$0 $$2 -type d -exec chmod 755 $$1/{} \; && \
2286                                         ${FIND} -d $$0 $$2 -type f -exec chmod ${SHAREMODE} $$1/{} \;' --
2287 .endif
2288
2289 # The user can override the NO_PACKAGE by specifying this from
2290 # the make command line
2291 .if defined(FORCE_PACKAGE)
2292 .undef NO_PACKAGE
2293 .endif
2294
2295 DESCR?=                 ${PKGDIR}/pkg-descr
2296 PLIST?=                 ${PKGDIR}/pkg-plist
2297 PKGHELP?=               ${PKGDIR}/pkg-help
2298 PKGINSTALL?=    ${PKGDIR}/pkg-install
2299 PKGDEINSTALL?=  ${PKGDIR}/pkg-deinstall
2300 PKGREQ?=                ${PKGDIR}/pkg-req
2301 PKGMESSAGE?=    ${PKGDIR}/pkg-message
2302
2303 TMPPLIST?=      ${WRKDIR}/.PLIST.mktmp
2304 TMPPLIST_SORT?= ${WRKDIR}/.PLIST.mktmp.sorted
2305 TMPGUCMD?=      ${WRKDIR}/.PLIST.gucmd
2306
2307 .if !defined(PKG_ARGS)
2308 PKG_ARGS=               -v -c -${COMMENT:Q} -d ${DESCR} -f ${TMPPLIST} -p ${PREFIX} -P "`cd ${.CURDIR} && ${MAKE} actual-package-depends | ${GREP} -v -E ${PKG_IGNORE_DEPENDS} | ${SORT} -u -t : -k 2`" ${EXTRA_PKG_ARGS} $${_LATE_PKG_ARGS}
2309 .if !defined(NO_MTREE)
2310 PKG_ARGS+=              -m ${MTREE_FILE}
2311 .endif
2312 .if defined(PKGORIGIN)
2313 PKG_ARGS+=              -o ${PKGORIGIN}
2314 .endif
2315 .if defined(CONFLICTS) && !defined(DISABLE_CONFLICTS)
2316 PKG_ARGS+=              -C "${CONFLICTS}"
2317 .endif
2318 .if defined(CONFLICTS_INSTALL) && !defined(DISABLE_CONFLICTS)
2319 PKG_ARGS+=              -C "${CONFLICTS_INSTALL}"
2320 .endif
2321 .endif
2322 .if defined(PKG_NOCOMPRESS)
2323 PKG_SUFX?=              .tar
2324 .else
2325 .if defined(WITH_PKGNG)
2326 PKG_SUFX?=              .txz
2327 .else
2328 PKG_SUFX?=              .tbz
2329 .endif
2330 .endif
2331 # where pkg_add records its dirty deeds.
2332 PKG_DBDIR?=             /var/db/pkg
2333
2334 ALL_TARGET?=            all
2335 INSTALL_TARGET?=        install
2336 INSTALL_TARGET+=        ${LATE_INSTALL_ARGS}
2337
2338 # Integrate with the license auditing framework
2339 .if !defined (DISABLE_LICENSES)
2340 .include "${PORTSDIR}/Mk/bsd.licenses.mk"
2341 .endif
2342
2343 # Popular master sites
2344 .include "${PORTSDIR}/Mk/bsd.sites.mk"
2345
2346 # Empty declaration to avoid "variable MASTER_SITES recursive" error
2347 MASTER_SITES?=
2348 PATCH_SITES?=
2349 _MASTER_SITES_DEFAULT?=
2350 _PATCH_SITES_DEFAULT?=
2351
2352 # Feed internal _{MASTER,PATCH}_SITES_n where n is a group designation
2353 # as per grouping rules (:something)
2354 # Organize _{MASTER,PATCH}_SITES_{DEFAULT,[^/:]+} according to grouping
2355 # rules (:something)
2356 .for _S in ${MASTER_SITES}
2357 _S_TEMP=        ${_S:S/^${_S:C@/?:[^/:]+$@/@}//:S/^://}
2358 .       if !empty(_S_TEMP)
2359 .               for _group in ${_S_TEMP:S/,/ /g}
2360 _G_TEMP=        ${_group}
2361 .                       if ${_G_TEMP} == all || ${_G_TEMP} == ALL || ${_G_TEMP} == default
2362 check-makevars::
2363                                 @${ECHO_MSG} "Makefile error: the words all, ALL and default are reserved and cannot be"
2364                                 @${ECHO_MSG} "used in group definitions. Please fix your MASTER_SITES"
2365                                 @${FALSE}
2366 .                       endif
2367 _MASTER_SITES_${_group}+=       ${_S:C@^(.*/):[^/:]+$@\1@}
2368 .               endfor
2369 .       else
2370 _MASTER_SITES_DEFAULT+= ${_S:C@^(.*/):[^/:]+$@\1@}
2371 .       endif
2372 .endfor
2373 .for _S in ${PATCH_SITES}
2374 _S_TEMP=        ${_S:S/^${_S:C@/:[^/:]+$@/@}//:S/^://}
2375 .       if !empty(_S_TEMP)
2376 .               for _group in ${_S_TEMP:S/,/ /g}
2377 _G_TEMP=        ${_group}
2378 .                       if ${_G_TEMP} == all || ${_G_TEMP} == ALL || ${_G_TEMP} == default
2379 check-makevars::
2380                                 @${ECHO_MSG} "The words all, ALL and default are reserved and cannot be"
2381                                 @${ECHO_MSG} "used in group definitions. Please fix your PATCH_SITES"
2382                                 @${FALSE}
2383 .                       endif
2384 _PATCH_SITES_${_group}+=        ${_S:C@^(.*/):[^/:]+$@\1@}
2385 .               endfor
2386 .       else
2387 _PATCH_SITES_DEFAULT+=  ${_S:C@^(.*/):[^/:]+$@\1@}
2388 .       endif
2389 .endfor
2390
2391 # Feed internal _{MASTER,PATCH}_SITE_SUBDIR_n where n is a group designation
2392 # as per grouping rules (:something)
2393 # Organize _{MASTER,PATCH}_SITE_SUBDIR_{DEFAULT,[^/:]+} according to grouping
2394 # rules (:something)
2395 .for _S in ${MASTER_SITE_SUBDIR}
2396 _S_TEMP=        ${_S:S/^${_S:C@/:[^/:]+$@/@}//:S/^://}
2397 .       if !empty(_S_TEMP)
2398 .               for _group in ${_S_TEMP:S/,/ /g}
2399 _G_TEMP=        ${_group}
2400 .                       if ${_G_TEMP} == all || ${_G_TEMP} == ALL || ${_G_TEMP} == default
2401 check-makevars::
2402                                 @${ECHO_MSG} "Makefile error: the words all, ALL and default are reserved and cannot be"
2403                                 @${ECHO_MSG} "used in group definitions. Please fix your MASTER_SITE_SUBDIR"
2404                                 @${FALSE}
2405 .                       endif
2406 .                       if defined(_MASTER_SITES_${_group})
2407 _MASTER_SITE_SUBDIR_${_group}+= ${_S:C@^(.*)/:[^/:]+$@\1@}
2408 .                       endif
2409 .               endfor
2410 .       else
2411 .               if defined(_MASTER_SITES_DEFAULT)
2412 _MASTER_SITE_SUBDIR_DEFAULT+=   ${_S:C@^(.*)/:[^/:]+$@\1@}
2413 .               endif
2414 .       endif
2415 .endfor
2416 .for _S in ${PATCH_SITE_SUBDIR}
2417 _S_TEMP=        ${_S:S/^${_S:C@/:[^/:]+$@/@}//:S/^://}
2418 .       if !empty(_S_TEMP)
2419 .               for _group in ${_S_TEMP:S/,/ /g}
2420 _G_TEMP=        ${_group}
2421 .                       if ${_G_TEMP} == all || ${_G_TEMP} == ALL || ${_G_TEMP} == default
2422 check-makevars::
2423                                 @${ECHO_MSG} "Makefile error: the words all, ALL and default are reserved and cannot be"
2424                                 @${ECHO_MSG} "used in group definitions. Please fix your PATCH_SITE_SUBDIR"
2425                                 @${FALSE}
2426 .                       endif
2427 .                       if defined(_PATCH_SITES_${_group})
2428 _PATCH_SITE_SUBDIR_${_group}+= ${_S:C@^(.*)/:[^/:]+$@\1@}
2429 .                       endif
2430 .               endfor
2431 .       else
2432 .               if defined(_PATCH_SITES_DEFAULT)
2433 _PATCH_SITE_SUBDIR_DEFAULT+=    ${_S:C@^(.*)/:[^/:]+$@\1@}
2434 .               endif
2435 .       endif
2436 .endfor
2437
2438 # Substitute subdirectory names
2439 # XXX simpler/faster solution but not the best space wise, suggestions please
2440 .for _S in ${MASTER_SITES}
2441 _S_TEMP=        ${_S:S/^${_S:C@/:[^/:]+$@/@}//:S/^://}
2442 .       if !empty(_S_TEMP)
2443 .               for _group in ${_S_TEMP:S/,/ /g}
2444 .                       if !defined(_MASTER_SITE_SUBDIR_${_group})
2445 MASTER_SITES_TMP=       ${_MASTER_SITES_${_group}:S^%SUBDIR%/^^}
2446 .                       else
2447 _S_TEMP_TEMP=           ${_MASTER_SITES_${_group}:M*%SUBDIR%/*}
2448 .                               if empty(_S_TEMP_TEMP)
2449 MASTER_SITES_TMP=       ${_MASTER_SITES_${_group}}
2450 .                               else
2451 MASTER_SITES_TMP=
2452 .                                       for site in ${_MASTER_SITES_${_group}}
2453 _S_TEMP_TEMP=   ${site:M*%SUBDIR%/*}
2454 .                                               if empty(_S_TEMP_TEMP)
2455 MASTER_SITES_TMP+=      ${site}
2456 .                                               else
2457 .                                                       for dir in ${_MASTER_SITE_SUBDIR_${_group}}
2458 MASTER_SITES_TMP+=      ${site:S^%SUBDIR%^\${dir}^}
2459 .                                                       endfor
2460 .                                               endif
2461 .                                       endfor
2462 .                               endif
2463 .                       endif
2464 _MASTER_SITES_${_group}:=       ${MASTER_SITES_TMP}
2465 .               endfor
2466 .       endif
2467 .endfor
2468 .if defined(_MASTER_SITE_SUBDIR_DEFAULT)
2469 _S_TEMP=        ${_MASTER_SITES_DEFAULT:M*%SUBDIR%/*}
2470 .       if empty(_S_TEMP)
2471 MASTER_SITES_TMP=       ${_MASTER_SITES_DEFAULT}
2472 .       else
2473 MASTER_SITES_TMP=
2474 .               for site in ${_MASTER_SITES_DEFAULT}
2475 _S_TEMP_TEMP=           ${site:M*%SUBDIR%/*}
2476 .                       if empty(_S_TEMP_TEMP)
2477 MASTER_SITES_TMP+=      ${site}
2478 .                       else
2479 .                               for dir in ${_MASTER_SITE_SUBDIR_DEFAULT}
2480 MASTER_SITES_TMP+=      ${site:S^%SUBDIR%^\${dir}^}
2481 .                               endfor
2482 .                       endif
2483 .               endfor
2484 .       endif
2485 .else
2486 MASTER_SITES_TMP=       ${_MASTER_SITES_DEFAULT:S^%SUBDIR%/^^}
2487 .endif
2488 _MASTER_SITES_DEFAULT:= ${MASTER_SITES_TMP}
2489 MASTER_SITES_TMP=
2490 .for _S in ${PATCH_SITES}
2491 _S_TEMP=        ${_S:S/^${_S:C@/:[^/:]+$@/@}//:S/^://}
2492 .       if !empty(_S_TEMP)
2493 .               for _group in ${_S_TEMP:S/,/ /g}
2494 .                       if !defined(_PATCH_SITE_SUBDIR_${_group})
2495 PATCH_SITES_TMP=        ${_PATCH_SITES_${_group}:S^%SUBDIR%/^^}
2496 .                       else
2497 _S_TEMP_TEMP=           ${_PATCH_SITES_${_group}:M*%SUBDIR%/*}
2498 .                               if empty(_S_TEMP_TEMP)
2499 PATCH_SITES_TMP=        ${_PATCH_SITES_${_group}}
2500 .                               else
2501 PATCH_SITES_TMP=
2502 .                                       for site in ${_PATCH_SITES_${_group}}
2503 _S_TEMP_TEMP=   ${site:M*%SUBDIR%/*}
2504 .                                               if empty(_S_TEMP_TEMP)
2505 PATCH_SITES_TMP+=       ${site}
2506 .                                               else
2507 .                                                       for dir in ${_PATCH_SITE_SUBDIR_${_group}}
2508 PATCH_SITES_TMP+=       ${site:S^%SUBDIR%^\${dir}^}
2509 .                                                       endfor
2510 .                                               endif
2511 .                                       endfor
2512 .                               endif
2513 .                       endif
2514 _PATCH_SITES_${_group}:=        ${PATCH_SITES_TMP}
2515 .               endfor
2516 .       endif
2517 .endfor
2518 .if defined(_PATCH_SITE_SUBDIR_DEFAULT)
2519 _S_TEMP=        ${_PATCH_SITES_DEFAULT:M*%SUBDIR%/*}
2520 .       if empty(_S_TEMP)
2521 PATCH_SITES_TMP=        ${_PATCH_SITES_DEFAULT}
2522 .       else
2523 PATCH_SITES_TMP=
2524 .               for site in ${_PATCH_SITES_DEFAULT}
2525 _S_TEMP_TEMP=           ${site:M*%SUBDIR%/*}
2526 .                       if empty(_S_TEMP_TEMP)
2527 PATCH_SITES_TMP+=       ${site}
2528 .                       else
2529 .                               for dir in ${_PATCH_SITE_SUBDIR_DEFAULT}
2530 PATCH_SITES_TMP+=       ${site:S^%SUBDIR%^\${dir}^}
2531 .                               endfor
2532 .                       endif
2533 .               endfor
2534 .       endif
2535 .else
2536 PATCH_SITES_TMP=        ${_PATCH_SITES_DEFAULT:S^%SUBDIR%/^^}
2537 .endif
2538 _PATCH_SITES_DEFAULT:=  ${PATCH_SITES_TMP}
2539 PATCH_SITES_TMP=
2540
2541 # The primary backup site.
2542 MASTER_SITE_BACKUP?=    \
2543         ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/distfiles/${DIST_SUBDIR}/
2544 MASTER_SITE_BACKUP:=    ${MASTER_SITE_BACKUP:S^\${DIST_SUBDIR}/^^}
2545
2546 # If the user has MASTER_SITE_FREEBSD set, go to the FreeBSD repository
2547 # for everything, but don't search it twice by appending it to the end.
2548 .if defined(MASTER_SITE_FREEBSD)
2549 _MASTER_SITE_OVERRIDE:= ${MASTER_SITE_BACKUP}
2550 _MASTER_SITE_BACKUP:=   # empty
2551 .else
2552 _MASTER_SITE_OVERRIDE=  ${MASTER_SITE_OVERRIDE}
2553 _MASTER_SITE_BACKUP=    ${MASTER_SITE_BACKUP}
2554 .endif
2555
2556 # Search CDROM first if mounted, symlink instead of copy if
2557 # FETCH_SYMLINK_DISTFILES is set
2558 .for MOUNTPT in ${CD_MOUNTPTS}
2559 .if exists(${MOUNTPT}/ports/distfiles)
2560 _MASTER_SITE_OVERRIDE:= file:${MOUNTPT}/ports/distfiles/${DIST_SUBDIR}/ ${_MASTER_SITE_OVERRIDE}
2561 .if defined(FETCH_SYMLINK_DISTFILES)
2562 FETCH_BEFORE_ARGS+=     -l
2563 .endif
2564 .endif
2565 .endfor
2566
2567 NOFETCHFILES?=
2568
2569 # Organize DISTFILES, PATCHFILES, _MASTER_SITES_ALL, _PATCH_SITES_ALL
2570 # according to grouping rules (:something)
2571 DISTFILES?=             ${DISTNAME}${EXTRACT_SUFX}
2572 _MASTER_SITES_ALL=      ${_MASTER_SITES_DEFAULT}
2573 _PATCH_SITES_ALL=       ${_PATCH_SITES_DEFAULT}
2574 _G_TEMP=        DEFAULT
2575 .for _D in ${DISTFILES}
2576 _D_TEMP=        ${_D:S/^${_D:C/:[^:]+$//}//}
2577 .       if !empty(_D_TEMP)
2578 .               for _group in ${_D_TEMP:S/^://:S/,/ /g}
2579 .                       if !defined(_MASTER_SITES_${_group})
2580 _G_TEMP_TEMP=   ${_G_TEMP:M/${_group}/}
2581 .                               if empty(_G_TEMP_TEMP)
2582 _G_TEMP+=       ${_group}
2583 _MASTER_SITES_ALL+=     ${_MASTER_SITES_${_group}}
2584 .                               endif
2585 .                       endif
2586 .               endfor
2587 _DISTFILES+=    ${_D:C/:[^:]+$//}
2588 .       else
2589 _DISTFILES+=    ${_D}
2590 .       endif
2591 .endfor
2592 _G_TEMP=        DEFAULT
2593 .for _P in ${PATCHFILES}
2594 _P_TEMP=        ${_P:C/:[^-:][^:]*$//}
2595 _P_groups=      ${_P:S/^${_P:C/:[^:]+$//}//:S/^://}
2596 _P_file=        ${_P_TEMP:C/:-[^:]+$//}
2597 _P_strip=       ${_P_TEMP:S/^${_P_TEMP:C/:-[^:]*$//}//:S/^://}
2598 .       if !empty(_P_groups)
2599 .               for _group in ${_P_groups:S/,/ /g}
2600 .                       if !defined(_PATCH_SITES_${_group})
2601 _G_TEMP_TEMP=   ${_G_TEMP:M/${_group}/}
2602 .                               if empty(_G_TEMP_TEMP)
2603 _G_TEMP+=       ${_group}
2604 _PATCH_SITES_ALL+=      ${_PATCH_SITES_${_group}}
2605 .                               endif
2606 .                       endif
2607 .               endfor
2608 .       endif
2609 _PATCHFILES:=   ${_PATCHFILES} ${_P_file}
2610 .       if !empty(_P_strip)
2611 _PATCH_DIST_STRIP_CASES:=       ${_PATCH_DIST_STRIP_CASES} ("${_P_file}") printf %s "${_P_strip}" ;;
2612 .       endif
2613 .endfor
2614 _P_groups=
2615 _P_file=
2616 _P_strip=
2617 _G_TEMP=
2618 _G_TEMP_TEMP=
2619 ALLFILES?=      ${_DISTFILES} ${_PATCHFILES}
2620
2621 #
2622 # Sort the master site list according to the patterns in MASTER_SORT
2623 #
2624 MASTER_SORT?=
2625 MASTER_SORT_REGEX?=
2626 MASTER_SORT_REGEX+=     ${MASTER_SORT:S|.|\\.|g:S|^|://[^/]*|:S|$|/|}
2627
2628 MASTER_SORT_AWK=        BEGIN { RS = " "; ORS = " "; IGNORECASE = 1 ; gl = "${MASTER_SORT_REGEX:S|\\|\\\\|g}"; }
2629 .for srt in ${MASTER_SORT_REGEX}
2630 MASTER_SORT_AWK+=       /${srt:S|/|\\/|g}/ { good["${srt:S|\\|\\\\|g}"] = good["${srt:S|\\|\\\\|g}"] " " $$0 ; next; }
2631 .endfor
2632 MASTER_SORT_AWK+=       { rest = rest " " $$0; } END { n=split(gl, gla); for(i=1;i<=n;i++) { print good[gla[i]]; } print rest; }
2633
2634 SORTED_MASTER_SITES_DEFAULT_CMD=        cd ${.CURDIR} && ${MAKE} master-sites-DEFAULT
2635 SORTED_PATCH_SITES_DEFAULT_CMD=         cd ${.CURDIR} && ${MAKE} patch-sites-DEFAULT
2636 SORTED_MASTER_SITES_ALL_CMD=    cd ${.CURDIR} && ${MAKE} master-sites-ALL
2637 SORTED_PATCH_SITES_ALL_CMD=     cd ${.CURDIR} && ${MAKE} patch-sites-ALL
2638
2639 # has similar effect to old targets, i.e., access only {MASTER,PATCH}_SITES, not working with the new _n variables
2640 master-sites-DEFAULT:
2641         @${ECHO_CMD} ${_MASTER_SITE_OVERRIDE} `${ECHO_CMD} '${_MASTER_SITES_DEFAULT}' | ${AWK} '${MASTER_SORT_AWK:S|\\|\\\\|g}'` ${_MASTER_SITE_BACKUP}
2642 patch-sites-DEFAULT:
2643         @${ECHO_CMD} ${_MASTER_SITE_OVERRIDE} `${ECHO_CMD} '${_PATCH_SITES_DEFAULT}' | ${AWK} '${MASTER_SORT_AWK:S|\\|\\\\|g}'` ${_MASTER_SITE_BACKUP}
2644
2645 #
2646 # Sort the master site list according to the patterns in MASTER_SORT
2647 # according to grouping rules (:something)
2648 #
2649 # for use in the fetch targets
2650 .for _S in ${MASTER_SITES}
2651 _S_TEMP=        ${_S:S/^${_S:C@/:[^/:]+$@/@}//}
2652 .       if !empty(_S_TEMP)
2653 .               for _group in ${_S_TEMP:S/^://:S/,/ /g}
2654 .                       if !target(master-sites-${_group})
2655 SORTED_MASTER_SITES_${_group}_CMD=      cd ${.CURDIR} && ${MAKE} master-sites-${_group}
2656 master-sites-${_group}:
2657         @${ECHO_CMD} ${_MASTER_SITE_OVERRIDE} `${ECHO_CMD} '${_MASTER_SITES_${_group}}' | ${AWK} '${MASTER_SORT_AWK:S|\\|\\\\|g}'` ${_MASTER_SITE_BACKUP}
2658 .                       endif
2659 .               endfor
2660 .       endif
2661 .endfor
2662 .for _S in ${PATCH_SITES}
2663 _S_TEMP=        ${_S:S/^${_S:C@/:[^/:]+$@/@}//}
2664 .       if !empty(_S_TEMP)
2665 .               for _group in ${_S_TEMP:S/^://:S/,/ /g}
2666 .                       if !target(patch-sites-${_group})
2667 SORTED_PATCH_SITES_${_group}_CMD=       cd ${.CURDIR} && ${MAKE} patch-sites-${_group}
2668 patch-sites-${_group}:
2669         @${ECHO_CMD} ${_MASTER_SITE_OVERRIDE} `${ECHO_CMD} '${_PATCH_SITES_${_group}}' | ${AWK} '${MASTER_SORT_AWK:S|\\|\\\\|g}'` ${_MASTER_SITE_BACKUP}
2670 .                       endif
2671 .               endfor
2672 .       endif
2673 .endfor
2674
2675 #
2676 # Hackery to enable simple fetch targets with several dynamic MASTER_SITES
2677 #
2678 _MASTER_SITES_ENV=      _MASTER_SITES_DEFAULT="${_MASTER_SITES_DEFAULT}"
2679 .for _F in ${DISTFILES}
2680 _F_TEMP=        ${_F:S/^${_F:C/:[^:]+$//}//:S/^://}
2681 .       if !empty(_F_TEMP)
2682 .               for _group in ${_F_TEMP:S/,/ /g}
2683 .                       if defined(_MASTER_SITES_${_group})
2684 _MASTER_SITES_ENV+=     _MASTER_SITES_${_group}="${_MASTER_SITES_${_group}}"
2685 .                       endif
2686 .               endfor
2687 .       endif
2688 .endfor
2689 _PATCH_SITES_ENV=       _PATCH_SITES_DEFAULT="${_PATCH_SITES_DEFAULT}"
2690 .for _F in ${PATCHFILES}
2691 _F_TEMP=        ${_F:S/^${_F:C/:[^-:][^:]*$//}//:S/^://}
2692 .       if !empty(_F_TEMP)
2693 .               for _group in ${_F_TEMP:S/,/ /g}
2694 .                       if defined(_PATCH_SITES_${_group})
2695 _PATCH_SITES_ENV+=      _PATCH_SITES_${_group}="${_PATCH_SITES_${_group}}"
2696 .                       endif
2697 .               endfor
2698 .       endif
2699 .endfor
2700
2701 master-sites-ALL:
2702         @${ECHO_CMD} ${_MASTER_SITE_OVERRIDE} `${ECHO_CMD} '${_MASTER_SITES_ALL}' | ${AWK} '${MASTER_SORT_AWK:S|\\|\\\\|g}'` ${_MASTER_SITE_BACKUP}
2703 patch-sites-ALL:
2704         @${ECHO_CMD} ${_MASTER_SITE_OVERRIDE} `${ECHO_CMD} '${_PATCH_SITES_ALL}' | ${AWK} '${MASTER_SORT_AWK:S|\\|\\\\|g}'` ${_MASTER_SITE_BACKUP}
2705
2706 # synonyms, mnemonics
2707 master-sites-all: master-sites-ALL
2708 patch-sites-all: patch-sites-ALL
2709 master-sites-default: master-sites-DEFAULT
2710 patch-sites-default: patch-sites-DEFAULT
2711
2712 # compatibility with old behavior
2713 master-sites: master-sites-DEFAULT
2714 patch-sites: patch-sites-DEFAULT
2715
2716 .if defined(IGNOREFILES)
2717 .if !defined(CKSUMFILES)
2718 .  for _f in ${ALLFILES}
2719 .    if ! ${IGNOREFILES:M${_f}}
2720 CKSUMFILES+=    ${_f}
2721 .   endif
2722 .  endfor
2723 .  undef _f
2724 .endif
2725 .else
2726 CKSUMFILES=             ${ALLFILES}
2727 .endif
2728
2729 # List of all files, with ${DIST_SUBDIR} in front.  Used for checksum.
2730 .if defined(DIST_SUBDIR)
2731 .if defined(CKSUMFILES) && ${CKSUMFILES}!=""
2732 _CKSUMFILES?=   ${CKSUMFILES:S/^/${DIST_SUBDIR}\//}
2733 .endif
2734 .if defined(IGNOREFILES) && ${IGNOREFILES}!=""
2735 _IGNOREFILES?=  ${IGNOREFILES:S/^/${DIST_SUBDIR}\//}
2736 .endif
2737 .else
2738 _CKSUMFILES?=   ${CKSUMFILES}
2739 _IGNOREFILES?=  ${IGNOREFILES}
2740 .endif
2741
2742 # This is what is actually going to be extracted, and is overridable
2743 #  by user.
2744 EXTRACT_ONLY?=  ${_DISTFILES}
2745
2746 .if !target(maintainer)
2747 maintainer:
2748         @${ECHO_CMD} "${MAINTAINER}"
2749 .endif
2750
2751 .if !defined(CATEGORIES)
2752 check-categories:
2753         @${ECHO_MSG} "${PKGNAME}: Makefile error: CATEGORIES is mandatory."
2754         @${FALSE}
2755 .else
2756
2757 VALID_CATEGORIES+= accessibility afterstep arabic archivers astro audio \
2758         benchmarks biology cad chinese comms converters databases \
2759         deskutils devel docs dns editors elisp emulators enlightenment finance french ftp \
2760         games geography german gnome gnustep graphics hamradio haskell hebrew hungarian \
2761         ipv6 irc japanese java kde kld korean lang linux lisp \
2762         mail mate math mbone misc multimedia net net-im net-mgmt net-p2p news \
2763         palm parallel pear perl5 plan9 polish portuguese ports-mgmt \
2764         print python ruby rubygems russian \
2765         scheme science security shells spanish sysutils \
2766         tcl textproc tk \
2767         ukrainian vietnamese windowmaker www \
2768         x11 x11-clocks x11-drivers x11-fm x11-fonts x11-servers x11-themes \
2769         x11-toolkits x11-wm xfce zope
2770
2771 check-categories:
2772 .for cat in ${CATEGORIES}
2773 .       if empty(VALID_CATEGORIES:M${cat})
2774                 @${ECHO_MSG} "${PKGNAME}: Makefile error: category ${cat} not in list of valid categories."; \
2775                 ${FALSE};
2776 .       endif
2777 .endfor
2778 .endif
2779
2780 PKGREPOSITORYSUBDIR?=   All
2781 PKGREPOSITORY?=         ${PACKAGES}/${PKGREPOSITORYSUBDIR}
2782 .if exists(${PACKAGES})
2783 PKGFILE?=               ${PKGREPOSITORY}/${PKGNAME}${PKG_SUFX}
2784 .else
2785 PKGFILE?=               ${.CURDIR}/${PKGNAME}${PKG_SUFX}
2786 .endif
2787
2788 # The "latest version" link -- ${PKGNAME} minus everthing after the last '-'
2789 PKGLATESTREPOSITORY?=   ${PACKAGES}/Latest
2790 PKGBASE?=                       ${PKGNAMEPREFIX}${PORTNAME}${PKGNAMESUFFIX}
2791 LATEST_LINK?=           ${PKGBASE}
2792 PKGLATESTFILE=          ${PKGLATESTREPOSITORY}/${LATEST_LINK}${PKG_SUFX}
2793
2794 CONFIGURE_SCRIPT?=      configure
2795 CONFIGURE_TARGET?=      ${ARCH}-dports-dragonfly${OSREL}
2796 CONFIGURE_TARGET:=      ${CONFIGURE_TARGET:S/--build=//}
2797 CONFIGURE_LOG?=         config.log
2798
2799 # A default message to print if do-configure fails.
2800 CONFIGURE_FAIL_MESSAGE?=        "Please report the problem to ${MAINTAINER} [maintainer] and attach the \"${CONFIGURE_WRKSRC}/${CONFIGURE_LOG}\" including the output of the failure of your make command. Also, it might be a good idea to provide an overview of all packages installed on your system (e.g. a ${PKG_INFO} -Ea)."
2801
2802 .if defined(GNU_CONFIGURE)
2803 # Maximum command line length
2804 .if !defined(CONFIGURE_MAX_CMD_LEN)
2805 CONFIGURE_MAX_CMD_LEN!= ${SYSCTL} -n kern.argmax
2806 .endif
2807 GNU_CONFIGURE_PREFIX?=  ${PREFIX}
2808 GNU_CONFIGURE_MANPREFIX?=       ${MANPREFIX}
2809 CONFIG_SITE?=           ${PORTSDIR}/Templates/config.site
2810 CONFIGURE_ARGS+=        --prefix=${GNU_CONFIGURE_PREFIX} $${_LATE_CONFIGURE_ARGS}
2811 .if defined(X_BUILD_FOR)
2812 CONFIGURE_ARGS+=        --host=${X_BUILD_FOR}
2813 .endif
2814 CONFIGURE_ENV+=         CONFIG_SITE=${CONFIG_SITE} lt_cv_sys_max_cmd_len=${CONFIGURE_MAX_CMD_LEN}
2815 HAS_CONFIGURE=          yes
2816
2817 SET_LATE_CONFIGURE_ARGS= \
2818      _LATE_CONFIGURE_ARGS="" ; \
2819         if [ ! -z "`./${CONFIGURE_SCRIPT} --help 2>&1 | ${GREP} -- '--mandir'`" ]; then \
2820             _LATE_CONFIGURE_ARGS="$${_LATE_CONFIGURE_ARGS} --mandir=${GNU_CONFIGURE_MANPREFIX}/man" ; \
2821         fi ; \
2822         if [ ! -z "`./${CONFIGURE_SCRIPT} --help 2>&1 | ${GREP} -- '--infodir'`" ]; then \
2823             _LATE_CONFIGURE_ARGS="$${_LATE_CONFIGURE_ARGS} --infodir=${GNU_CONFIGURE_PREFIX}/${INFO_PATH}/${INFO_SUBDIR}" ; \
2824         fi ; \
2825         if [ -z "`./${CONFIGURE_SCRIPT} --version 2>&1 | ${EGREP} -i '(autoconf.*2\.13|Unrecognized option)'`" ]; then \
2826                 _LATE_CONFIGURE_ARGS="$${_LATE_CONFIGURE_ARGS} --build=${CONFIGURE_TARGET}" ; \
2827         else \
2828                 _LATE_CONFIGURE_ARGS="$${_LATE_CONFIGURE_ARGS} ${CONFIGURE_TARGET}" ; \
2829         fi ;
2830 .endif
2831
2832 # Passed to most of script invocations
2833 SCRIPTS_ENV+=   CURDIR=${MASTERDIR} DISTDIR=${DISTDIR} \
2834                   WRKDIR=${WRKDIR} WRKSRC=${WRKSRC} PATCHDIR=${PATCHDIR} \
2835                   SCRIPTDIR=${SCRIPTDIR} FILESDIR=${FILESDIR} \
2836                   DFLY_PATCHDIR=${DFLY_PATCHDIR} \
2837                   DFLY_FILESDIR=${DFLY_FILESDIR} \
2838                   PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} LOCALBASE=${LOCALBASE}
2839
2840 .if defined(BATCH)
2841 SCRIPTS_ENV+=   BATCH=yes
2842 .endif
2843
2844 .if ${PREFIX} == /usr
2845 MANPREFIX?=     /usr/share
2846 .else
2847 MANPREFIX?=     ${PREFIX}
2848 .endif
2849
2850 MANDIRS+=       ${MANPREFIX}/man
2851 .for sect in 1 2 3 4 5 6 7 8 9
2852 MAN${sect}PREFIX?=      ${MANPREFIX}
2853 .endfor
2854 MANLPREFIX?=    ${MANPREFIX}
2855 MANNPREFIX?=    ${MANPREFIX}
2856
2857 MANLANG?=       ""      # english only by default
2858
2859 .if !defined(NO_MANCOMPRESS)
2860 MANEXT= .gz
2861 .endif
2862
2863 .if (defined(MLINKS) || defined(_MLINKS_PREPEND)) && !defined(_MLINKS)
2864
2865 .if defined(.PARSEDIR)
2866 _MLINKS=         ${_MLINKS_PREPEND} \
2867                  ${MANLANG:S,^,man/,:S,/"",,:@m@${MLINKS:@p@${MAN${p:E:C/(.).*/\1/g}PREFIX}/$m/man${p:E:C/(.).*/\1/g}/$p${MANEXT}@}@}
2868 .else
2869 __pmlinks!=     ${ECHO_CMD} '${MLINKS:S/        / /}' | ${AWK} \
2870  '{ if (NF % 2 != 0) { print "broken"; exit; } \
2871         for (i=1; i<=NF; i++) { \
2872                 if ($$i ~ /^-$$/ && i != 1 && i % 2 != 0) \
2873                         { $$i = $$(i-2); printf " " $$i " "; } \
2874                 else if ($$i ~ /^[^ ]+\.[1-9ln][^. ]*$$/ || $$i ~ /^\//) \
2875                         printf " " $$i " "; \
2876                 else \
2877                         { print "broken"; exit; } \
2878         } \
2879   }' | ${SED} -e 's\b \([^/ ][^ ]*\.\(.\)[^. ]*\)\b $${MAN\2PREFIX}/___LANG___/man\2/\1${MANEXT}\bg' -e 's/ /\b/g' -e 's/MANlPREFIX/MANLPREFIX/g' -e 's/MANnPREFIX/MANNPREFIX/g'
2880 .if ${__pmlinks:Mbroken} == "broken"
2881 check-makevars::
2882         @${ECHO_MSG} "${PKGNAME}: Makefile error: unable to parse MLINKS."
2883         @${FALSE}
2884 .endif
2885 _MLINKS=        ${_MLINKS_PREPEND}
2886
2887 .for lang in ${MANLANG:S%^%man/%:S%^man/""$%man%}
2888 .for ___pmlinks in ${__pmlinks}
2889 .for __lang in ${lang}
2890 _MLINKS+=       ${___pmlinks:S/\b/ /g:S/___LANG___/${__lang}/}
2891 .endfor
2892 .endfor
2893 .endfor
2894 .endif
2895 .endif
2896 _COUNT=0
2897 .for ___tpmlinks in ${_MLINKS}
2898 .if ${_COUNT} == "1"
2899 _TMLINKS+=      ${___tpmlinks}
2900 _COUNT=0
2901 .else
2902 _COUNT=1
2903 .endif
2904 .endfor
2905
2906 .for manlang in ${MANLANG:S%^%man/%:S%^man/""$%man%}
2907
2908 .for sect in 1 2 3 4 5 6 7 8 9 L N
2909 # MAN${sect} is for man pages installed for all languages in MANLANG for a given
2910 # section.
2911 .if defined(MAN${sect})
2912 _MANPAGES+=     ${MAN${sect}:S%^%${MAN${sect}PREFIX}/${manlang}/man${sect:tl}/%}
2913 .endif
2914
2915 # Language specific MAN${sect} variables are for man pages installed in that
2916 # language, but not necessarily all languages in MANLANG.
2917 .if defined(MAN${sect}_${manlang:S%^man/%%:tu})
2918 _MANPAGES+=     ${MAN${sect}_${manlang:S%^man/%%:tu}:S%^%${MAN${sect}PREFIX}/${manlang}/man${sect:tl}/%}
2919 .endif
2920
2921 .endfor
2922
2923 .endfor
2924
2925 # Special case for English, since it is defined with "" in MANLANG rather than
2926 # a language name and does not have man pages installed in a lang subdirectory
2927 # of MAN${sect}PREFIX.
2928 .for sect in 1 2 3 4 5 6 7 8 9 L N
2929 .if defined(MAN${sect}_EN)
2930 _MANPAGES+=     ${MAN${sect}_EN:S%^%${MAN${sect}PREFIX}/man/man${sect:tl}/%}
2931 .endif
2932 .endfor
2933
2934 .if !defined(_TMLINKS)
2935 _TMLINKS=
2936 .endif
2937
2938 .if defined(_MANPAGES)
2939
2940 .if defined(NO_MANCOMPRESS)
2941 __MANPAGES:=    ${_MANPAGES:S%^${PREFIX}/%%}
2942 .else
2943 __MANPAGES:=    ${_MANPAGES:S%^${PREFIX}/%%:S%$%.gz%}
2944 .endif
2945
2946 .if ${MANCOMPRESSED} == "yes"
2947 _MANPAGES:=     ${_MANPAGES:S%$%.gz%}
2948 .endif
2949
2950 .endif
2951
2952 .if ${PREFIX} == /usr
2953 INFO_PATH?=     share/info
2954 .else
2955 INFO_PATH?=     info
2956 .endif
2957
2958 .if defined(INFO)
2959 . for D in ${INFO:H}
2960 RD:=    ${D}
2961 .  if ${RD} != "."
2962 .   if !defined(INFO_SUBDIR)
2963 INFO_SUBDIR:=   ${RD}
2964 .   elif ${INFO_SUBDIR} != ${RD}
2965 BROKEN=         only one subdirectory in INFO is allowed
2966 .   endif
2967 .  endif
2968 .undef RD
2969 . endfor
2970 .endif
2971
2972 DOCSDIR_REL?=   ${DOCSDIR:S,^${PREFIX}/,,}
2973 EXAMPLESDIR_REL?=       ${EXAMPLESDIR:S,^${PREFIX}/,,}
2974 DATADIR_REL?=   ${DATADIR:S,^${PREFIX}/,,}
2975 WWWDIR_REL?=    ${WWWDIR:S,^${PREFIX}/,,}
2976 ETCDIR_REL?=    ${ETCDIR:S,^${PREFIX}/,,}
2977
2978 PLIST_SUB+=     DOCSDIR="${DOCSDIR_REL}" \
2979                 EXAMPLESDIR="${EXAMPLESDIR_REL}" \
2980                 DATADIR="${DATADIR_REL}" \
2981                 WWWDIR="${WWWDIR_REL}" \
2982                 ETCDIR="${ETCDIR_REL}"
2983
2984 DESKTOPDIR?=            ${PREFIX}/share/applications
2985 _DESKTOPDIR_REL=        ${DESKTOPDIR:S,^${PREFIX}/,,}/
2986
2987 .if ${_DESKTOPDIR_REL} == ${DESKTOPDIR}/
2988 # DESKTOPDIR is not beneath PREFIX
2989 _DESKTOPDIR_REL=
2990 .endif
2991
2992 .MAIN: all
2993
2994 ################################################################
2995 # Many ways to disable a port.
2996 #
2997 # If we're in BATCH mode and the port is interactive, or we're
2998 # in interactive mode and the port is non-interactive, skip all
2999 # the important targets.  The reason we have two modes is that
3000 # one might want to leave a build in BATCH mode running
3001 # overnight, then come back in the morning and do _only_ the
3002 # interactive ones that required your intervention.
3003 #
3004 # Ignore ports that can't be resold if building for a CDROM.
3005 #
3006 # Don't build a port if it's restricted and we don't want to get
3007 # into that.
3008 #
3009 # Don't build a port if it's broken, unless we're running a parallel
3010 # build (in case it's fixed).
3011 #
3012 # Don't build a port if it's forbidden for whatever reason.
3013 #
3014 # Don't build a port if the system is too old.
3015 ################################################################
3016
3017 # Check the machine architectures
3018 .if defined(ONLY_FOR_ARCHS)
3019 .for __ARCH in ${ONLY_FOR_ARCHS:S/amd64/x86_64/}
3020 .if ${ARCH:M${__ARCH}} != ""
3021 __ARCH_OK?=             1
3022 .endif
3023 .endfor
3024 .else
3025 __ARCH_OK?=             1
3026 .endif
3027
3028 .if defined(NOT_FOR_ARCHS)
3029 .for __NARCH in ${NOT_FOR_ARCHS:S/amd64/x86_64/}
3030 .if ${ARCH:M${__NARCH}} != ""
3031 .undef __ARCH_OK
3032 .endif
3033 .endfor
3034 .endif
3035
3036 .if !defined(__ARCH_OK)
3037 .if defined(ONLY_FOR_ARCHS)
3038 IGNORE=         is only for ${ONLY_FOR_ARCHS:S/amd64/x86_64/},
3039 .else # defined(NOT_FOR_ARCHS)
3040 IGNORE=         does not run on ${NOT_FOR_ARCHS:S/amd64/x86_64/},
3041 .endif
3042 IGNORE+=        while you are running ${ARCH}
3043
3044 .if defined(ONLY_FOR_ARCHS_REASON_${ARCH})
3045 IGNORE+=        (reason: ${ONLY_FOR_ARCHS_REASON_${ARCH}})
3046 .elif defined(ONLY_FOR_ARCHS_REASON)
3047 IGNORE+=        (reason: ${ONLY_FOR_ARCHS_REASON})
3048 .endif
3049
3050 .if defined(NOT_FOR_ARCHS_REASON_${ARCH})
3051 IGNORE+=        (reason: ${NOT_FOR_ARCHS_REASON_${ARCH}})
3052 .elif defined(NOT_FOR_ARCHS_REASON)
3053 IGNORE+=        (reason: ${NOT_FOR_ARCHS_REASON})
3054 .endif
3055
3056 .endif
3057
3058 # Check the user interaction and legal issues
3059 .if !defined(NO_IGNORE)
3060 .if (defined(IS_INTERACTIVE) && defined(BATCH))
3061 IGNORE=         is an interactive port
3062 .elif (!defined(IS_INTERACTIVE) && defined(INTERACTIVE))
3063 IGNORE=         is not an interactive port
3064 .elif (defined(NO_CDROM) && defined(FOR_CDROM))
3065 IGNORE=         may not be placed on a CDROM: ${NO_CDROM}
3066 .elif (defined(RESTRICTED) && defined(NO_RESTRICTED))
3067 IGNORE=         is restricted: ${RESTRICTED}
3068 .elif defined(BROKEN)
3069 .if !defined(TRYBROKEN)
3070 IGNORE=         is marked as broken: ${BROKEN}
3071 .endif
3072 .elif defined(BROKEN_${ARCH})
3073 .if !defined(TRYBROKEN)
3074 IGNORE=         is marked as broken on ${ARCH}: ${BROKEN_${ARCH}}
3075 .endif
3076 .elif defined(FORBIDDEN)
3077 IGNORE=         is forbidden: ${FORBIDDEN}
3078 .endif
3079
3080 # Define the text to be output to LEGAL
3081 .if defined(LEGAL_TEXT)
3082 LEGAL= ${LEGAL_TEXT}
3083 .elif defined(RESTRICTED)
3084 LEGAL= ${RESTRICTED}
3085 .elif defined(NO_CDROM)
3086 LEGAL= ${NO_CDROM}
3087 .elif defined(NO_PACKAGE) && ! defined(LEGAL_PACKAGE)
3088 LEGAL= ${NO_PACKAGE}
3089 .endif
3090
3091 .if (defined(MANUAL_PACKAGE_BUILD) && defined(PACKAGE_BUILDING))
3092 IGNORE=         has to be built manually: ${MANUAL_PACKAGE_BUILD}
3093 clean:
3094         @${IGNORECMD}
3095 .endif
3096
3097 .if defined(IGNORE)
3098 .if defined(IGNORE_SILENT)
3099 IGNORECMD=      ${DO_NADA}
3100 .else
3101 IGNORECMD=      ${ECHO_MSG} "===>  ${PKGNAME} "${IGNORE:Q}.;exit 1
3102 .endif
3103
3104 _TARGETS=       check-sanity fetch checksum extract patch configure all build install reinstall package
3105 .if !defined(NO_STAGE)
3106 _TARGETS+=      stage restage
3107 .endif
3108 .for target in ${_TARGETS}
3109 .if !target(${target})
3110 ${target}:
3111         @${IGNORECMD}
3112 .if defined(INSTALLS_DEPENDS)
3113         @${FALSE}
3114 .endif
3115 .endif
3116 .endfor
3117
3118 .endif
3119
3120 .endif
3121
3122 .if defined(IGNORE) || defined(NO_PACKAGE)
3123 ignorelist: package-name
3124 .else
3125 ignorelist:
3126         @${DO_NADA}
3127 .endif
3128
3129 .if defined(IGNORE) || defined(NO_PACKAGE)
3130 ignorelist-verbose:
3131 .if defined(IGNORE)
3132         @${ECHO_CMD} "${PKGNAME}|IGNORE: "${IGNORE:Q}
3133 .else
3134         @${ECHO_CMD} "${PKGNAME}|NO_PACKAGE: "${NO_PACKAGE:Q}
3135 .endif
3136 .else
3137 ignorelist-verbose:
3138         @${DO_NADA}
3139 .endif
3140
3141 ################################################################
3142 # Clean directories for ftp or CDROM.
3143 ################################################################
3144
3145 .if !defined(LICENSE)
3146
3147 .if defined(RESTRICTED)
3148 clean-restricted:       delete-distfiles delete-package
3149 clean-restricted-list: delete-distfiles-list delete-package-list
3150 RESTRICTED_FILES?=      ${_DISTFILES} ${_PATCHFILES}
3151 .else
3152 clean-restricted:
3153 clean-restricted-list:
3154 .endif
3155
3156 .if defined(NO_CDROM)
3157 clean-for-cdrom:        delete-distfiles delete-package
3158 clean-for-cdrom-list:   delete-distfiles-list delete-package-list
3159 RESTRICTED_FILES?=      ${_DISTFILES} ${_PATCHFILES}
3160 .else
3161 clean-for-cdrom:
3162 clean-for-cdrom-list:
3163 .endif
3164
3165 .endif # !defined(LICENSE)
3166
3167 .if defined(ALL_HOOK)
3168 all:
3169         @cd ${.CURDIR} && ${SETENV} CURDIR=${.CURDIR} DISTNAME=${DISTNAME} \
3170           DISTDIR=${DISTDIR} WRKDIR=${WRKDIR} WRKSRC=${WRKSRC} \
3171           PATCHDIR=${PATCHDIR} SCRIPTDIR=${SCRIPTDIR} \
3172           FILESDIR=${FILESDIR} PORTSDIR=${PORTSDIR} PREFIX=${PREFIX} \
3173           DFLY_PATCHDIR=${DFLY_PATCHDIR} DFLY_FILESDIR=${DFLY_FILESDIR} \
3174           BUILD_DEPENDS="${BUILD_DEPENDS}" RUN_DEPENDS="${RUN_DEPENDS}" \
3175           CONFLICTS="${CONFLICTS}" \
3176         ${ALL_HOOK}
3177 .else
3178 all: build
3179 .endif
3180
3181 .if !defined(DEPENDS_TARGET)
3182 .if defined(DEPENDS_PRECLEAN)
3183 DEPENDS_TARGET= clean
3184 DEPENDS_ARGS=   NOCLEANDEPENDS=yes
3185 .endif
3186 .if make(reinstall)
3187 DEPENDS_TARGET+=        reinstall
3188 .else
3189 DEPENDS_TARGET+=        install
3190 .endif
3191 .if defined(DEPENDS_CLEAN)
3192 DEPENDS_TARGET+=        clean
3193 DEPENDS_ARGS+=  NOCLEANDEPENDS=yes
3194 .endif
3195 .endif
3196
3197 ################################################################
3198 #
3199 # Do preliminary work to detect if we need to run the config
3200 # target or not.
3201 #
3202 ################################################################
3203 .if ((!defined(OPTIONS_DEFINE) && !defined(OPTIONS_SINGLE) && !defined(OPTIONS_MULTI)) \
3204         && !defined(OPTIONS_GROUP) && !defined(OPTIONS_RADIO) \
3205         || defined(CONFIG_DONE_${UNIQUENAME:tu}) || \
3206         defined(PACKAGE_BUILDING) || defined(BATCH))
3207 _OPTIONS_OK=yes
3208 .endif
3209
3210 ################################################################
3211 # The following are used to create easy dummy targets for
3212 # disabling some bit of default target behavior you don't want.
3213 # They still check to see if the target exists, and if so don't
3214 # do anything, since you might want to set this globally for a
3215 # group of ports in a Makefile.inc, but still be able to
3216 # override from an individual Makefile.
3217 ################################################################
3218
3219 # Disable checksum
3220 .if defined(NO_CHECKSUM) && !target(checksum)
3221 checksum: fetch
3222         @${DO_NADA}
3223 .endif
3224
3225 # Disable build
3226 .if defined(NO_BUILD) && !target(build)
3227 build: configure
3228         @${TOUCH} ${TOUCH_FLAGS} ${BUILD_COOKIE}
3229 .endif
3230
3231 # Disable staging. Be non-fatal here as some scripts may just call it as a
3232 # matter of correctness in their ordering.
3233 .if defined(NO_STAGE) && !target(stage)
3234 stage:
3235         @${ECHO_MSG} "===>   This port does not yet support staging"
3236 .endif
3237
3238 # Disable install
3239 .if defined(NO_INSTALL) && !target(do-install)
3240 do-install:
3241         @${DO_NADA}
3242 .endif
3243
3244 # Disable package
3245 .if defined(NO_PACKAGE) && !target(package)
3246 package:
3247 .if defined(IGNORE_SILENT)
3248         @${DO_NADA}
3249 .else
3250         @${ECHO_MSG} "===>  ${PKGNAME} may not be packaged: "${NO_PACKAGE:Q}.
3251 .endif
3252 .endif
3253
3254 # Disable describe
3255 .if defined(NO_DESCRIBE) && !target(describe)
3256 describe:
3257         @${DO_NADA}
3258 .endif
3259
3260 ################################################################
3261 # More standard targets start here.
3262 #
3263 # These are the body of the build/install framework.  If you are
3264 # not happy with the default actions, and you can't solve it by
3265 # adding pre-* or post-* targets/scripts, override these.
3266 ################################################################
3267
3268 # Pre-everything
3269
3270 pre-everything::
3271         @${DO_NADA}
3272
3273 .if defined(TRYBROKEN) && defined(BROKEN)
3274 buildanyway-message:
3275         @${ECHO_MSG} "Trying build of ${PKGNAME} even though it is marked BROKEN."
3276 .endif
3277
3278 options-message:
3279 .if defined(GNOME_OPTION_MSG) && (!defined(PACKAGE_BUILDING) || !defined(BATCH))
3280         @for m in ${GNOME_OPTION_MSG}; do \
3281                 ${ECHO_MSG} $$m; \
3282         done
3283 .else
3284         @${DO_NADA}
3285 .endif
3286 .if defined(_OPTIONS_READ)
3287         @${ECHO_MSG} "===>  Found saved configuration for ${_OPTIONS_READ}"
3288 .endif
3289
3290
3291 # Warn user about deprecated packages.  Advisory only.
3292
3293 .if !target(check-deprecated)
3294 check-deprecated:
3295 .if defined(DEPRECATED)
3296         @${ECHO_MSG} "===>   NOTICE:"
3297         @${ECHO_MSG}
3298         @${ECHO_MSG} "This port is deprecated; you may wish to reconsider installing it:"
3299         @${ECHO_MSG}
3300         @${ECHO_MSG} ${DEPRECATED:Q}.
3301         @${ECHO_MSG}
3302 .if defined(EXPIRATION_DATE)
3303         @${ECHO_MSG} "It is scheduled to be removed on or after ${EXPIRATION_DATE}."
3304         @${ECHO_MSG}
3305 .endif
3306 .endif
3307 .endif
3308
3309 # Check if the port is listed in the vulnerability database
3310
3311 .if defined(WITH_PKGNG)
3312 AUDITFILE?=             ${PKG_DBDIR}/vuln.xml
3313 _EXTRACT_AUDITFILE=     ${CAT} "${AUDITFILE}"
3314 .else
3315 AUDITFILE?=             /var/db/portaudit/auditfile.tbz
3316 _EXTRACT_AUDITFILE=     ${TAR} -jxOf "${AUDITFILE}" auditfile
3317 .endif
3318
3319 check-vulnerable:
3320 .if !defined(DISABLE_VULNERABILITIES) && !defined(PACKAGE_BUILDING)
3321         @if [ -f "${AUDITFILE}" ]; then \
3322                 if [ -n "${WITH_PKGNG}" ]; then \
3323                         vlist=`${PKG_BIN} audit "${PKGNAME}"`; \
3324                 elif [ -x "${LOCALBASE}/sbin/portaudit" ]; then \
3325                         vlist=`${LOCALBASE}/sbin/portaudit -X 14 "${PKGNAME}" \
3326                                 2>&1 | grep -vE '^[0-9]+ problem\(s\) found.' \
3327                                 || true`; \
3328                         if [ -n "$$vlist" ]; then \
3329                                 vlist=`${LOCALBASE}/sbin/portaudit -X 14 "${PKGNAME}" \
3330                                         2>&1 | grep -vE '^[0-9]+ problem\(s\) found.' \
3331                                         || true`; \
3332                         fi ; \
3333                 else \
3334                         ${ECHO_MSG} "===>  portaudit database exists, however, portaudit is not installed!"; \
3335                 fi; \
3336                 if [ -n "$$vlist" ]; then \
3337                         ${ECHO_MSG} "===>  ${PKGNAME} has known vulnerabilities:"; \
3338                         ${ECHO_MSG} "$$vlist"; \
3339                         ${ECHO_MSG} "=> Please update your ports tree and try again."; \
3340                         exit 1; \
3341                 fi; \
3342         fi
3343 .endif
3344
3345 # set alg to any of SIZE, SHA256 (or any other checksum algorithm):
3346 DISTINFO_DATA?= if [ \( -n "${DISABLE_SIZE}" -a -n "${NO_CHECKSUM}" \) -o ! -f "${DISTINFO_FILE}" ]; then exit; fi; \
3347         DIR=${DIST_SUBDIR}; ${AWK} -v alg=$$alg -v file=$${DIR:+$$DIR/}$${file} \
3348                 '$$1 == alg && $$2 == "(" file ")" {print $$4}' ${DISTINFO_FILE}
3349
3350 # Fetch
3351
3352 .if !target(do-fetch)
3353 do-fetch:
3354         @${MKDIR} ${_DISTDIR}
3355         @cd ${_DISTDIR};\
3356         ${_MASTER_SITES_ENV} ; \
3357         for _file in ${DISTFILES}; do \
3358                 file=$${_file%%:*}; \
3359                 if [ $$_file = $$file ]; then   \
3360                         select='';      \
3361                 else    \
3362                         select=`${ECHO_CMD} $${_file##*:} | ${SED} -e 's/,/ /g'` ;      \
3363                 fi;     \
3364                 force_fetch=false; \
3365                 filebasename=$${file##*/}; \
3366                 for afile in ${FORCE_FETCH}; do \
3367                         afile=$${afile##*/}; \
3368                         if [ "x$$afile" = "x$$filebasename" ]; then \
3369                                 force_fetch=true; \
3370                         fi; \
3371                 done; \
3372                 if [ ! -f $$file -a ! -f $$filebasename -o "$$force_fetch" = "true" ]; then \
3373                         if [ -L $$file -o -L $$filebasename ]; then \
3374                                 ${ECHO_MSG} "=> ${_DISTDIR}/$$file is a broken symlink."; \
3375                                 ${ECHO_MSG} "=> Perhaps a filesystem (most likely a CD) isn't mounted?"; \
3376                                 ${ECHO_MSG} "=> Please correct this problem and try again."; \
3377                                 exit 1; \
3378                         fi; \
3379                         if [ -f ${DISTINFO_FILE} -a "x${NO_CHECKSUM}" = "x" ]; then \
3380                                 _sha256sum=`alg=SHA256; ${DISTINFO_DATA}`; \
3381                                 if [ -z "$$_sha256sum" ]; then \
3382                                         ${ECHO_MSG} "=> $${DIR:+$$DIR/}$$file is not in ${DISTINFO_FILE}."; \
3383                                         ${ECHO_MSG} "=> Either ${DISTINFO_FILE} is out of date, or"; \
3384                                         ${ECHO_MSG} "=> $${DIR:+$$DIR/}$$file is spelled incorrectly."; \
3385                                         exit 1; \
3386                                 fi; \
3387                         fi; \
3388                         ${ECHO_MSG} "=> $$file doesn't seem to exist in ${_DISTDIR}."; \
3389                         if [ ! -w ${DISTDIR} ]; then \
3390                            ${ECHO_MSG} "=> ${DISTDIR} is not writable by you; cannot fetch."; \
3391                            exit 1; \
3392                         fi; \
3393                         if [ ! -z "$$select" ] ; then \
3394                                 __MASTER_SITES_TMP= ; \
3395                                 for group in $$select; do \
3396                                         if [ ! -z \$${_MASTER_SITES_$${group}} ] ; then \
3397                                                 eval ___MASTER_SITES_TMP="\$${_MASTER_SITES_$${group}}" ; \
3398                                                 __MASTER_SITES_TMP="$${__MASTER_SITES_TMP} $${___MASTER_SITES_TMP}" ; \
3399                                         fi; \
3400                                 done; \
3401                                 ___MASTER_SITES_TMP= ; \
3402                                 SORTED_MASTER_SITES_CMD_TMP="${ECHO_CMD} ${_MASTER_SITE_OVERRIDE} `${ECHO_CMD} $${__MASTER_SITES_TMP} | ${AWK} '${MASTER_SORT_AWK:S|\\|\\\\|g}'` ${_MASTER_SITE_BACKUP}" ; \
3403                         else \
3404                                 SORTED_MASTER_SITES_CMD_TMP="${SORTED_MASTER_SITES_DEFAULT_CMD}" ; \
3405                         fi; \
3406                         sites_remaining=0; \
3407                         sites="`eval $$SORTED_MASTER_SITES_CMD_TMP ${_RANDOMIZE_SITES}`"; \
3408                         for site in $${sites}; do \
3409                                 sites_remaining=$$(($${sites_remaining} + 1)); \
3410                         done; \
3411                         for site in $${sites}; do \
3412                                 sites_remaining=$$(($${sites_remaining} - 1)); \
3413                             ${ECHO_MSG} "=> Attempting to fetch $${site}$${file}"; \
3414                                 CKSIZE=`alg=SIZE; ${DISTINFO_DATA}`; \
3415                                 case $${file} in \
3416                                 */*)    ${MKDIR} $${file%/*}; \
3417                                                 args="-o $${file} $${site}$${file}";; \
3418                                 *)              args=$${site}$${file};; \
3419                                 esac; \
3420                                 if ${SETENV} ${FETCH_ENV} ${FETCH_CMD} ${FETCH_BEFORE_ARGS} $${args} ${FETCH_AFTER_ARGS}; then \
3421                                         actual_size=`stat -f %z "$${file}"`; \
3422                                         if [ -n "${DISABLE_SIZE}" ] || [ -z "$${CKSIZE}" ] || [ $${actual_size} -eq $${CKSIZE} ]; then \
3423                                                 continue 2; \
3424                                         else \
3425                                                 ${ECHO_MSG} "=> Fetched file size mismatch (expected $${CKSIZE}, actual $${actual_size})"; \
3426                                                 if [ $${sites_remaining} -gt 1 ]; then \
3427                                                         ${ECHO_MSG} "=> Trying next site"; \
3428                                                         ${RM} -f $${file}; \
3429                                                 fi; \
3430                                         fi; \
3431                                 fi; \
3432                         done; \
3433                         ${ECHO_MSG} "=> Couldn't fetch it - please try to retrieve this";\
3434                         ${ECHO_MSG} "=> port manually into ${_DISTDIR} and try again."; \
3435                         exit 1; \
3436             fi; \
3437          done
3438 .if defined(PATCHFILES)
3439         @cd ${_DISTDIR};\
3440         ${_PATCH_SITES_ENV} ; \
3441         for _file in ${PATCHFILES}; do \
3442                 file=`${ECHO_CMD} $$_file | ${SED} -E -e 's/:[^-:][^:]*$$//'` ; \
3443                 select=`${ECHO_CMD} $${_file#$${file}} | ${SED} -e 's/^://' -e 's/,/ /g'` ; \
3444                 file=`${ECHO_CMD} $$file | ${SED} -E -e 's/:-[^:]+$$//'` ; \
3445                 force_fetch=false; \
3446                 filebasename=$${file##*/}; \
3447                 for afile in ${FORCE_FETCH}; do \
3448                         afile=$${afile##*/}; \
3449                         if [ "x$$afile" = "x$$filebasename" ]; then \
3450                                 force_fetch=true; \
3451                         fi; \
3452                 done; \
3453                 if [ ! -f $$file -a ! -f $$filebasename -o "$$force_fetch" = "true" ]; then \
3454                         if [ -L $$file -o -L $${file##*/} ]; then \
3455                                 ${ECHO_MSG} "=> ${_DISTDIR}/$$file is a broken symlink."; \
3456                                 ${ECHO_MSG} "=> Perhaps a filesystem (most likely a CD) isn't mounted?"; \
3457                                 ${ECHO_MSG} "=> Please correct this problem and try again."; \
3458                                 exit 1; \
3459                         fi; \
3460                         ${ECHO_MSG} "=> $$file doesn't seem to exist in ${_DISTDIR}."; \
3461                         if [ ! -z "$$select" ] ; then \
3462                                 __PATCH_SITES_TMP= ; \
3463                                 for group in $$select; do \
3464                                         if [ ! -z \$${_PATCH_SITES_$${group}} ] ; then \
3465                                                 eval ___PATCH_SITES_TMP="\$${_PATCH_SITES_$${group}}" ; \
3466                                                 __PATCH_SITES_TMP="$${__PATCH_SITES_TMP} $${___PATCH_SITES_TMP}" ; \
3467                                         fi; \
3468                                 done; \
3469                                 ___PATCH_SITES_TMP= ; \
3470                                 SORTED_PATCH_SITES_CMD_TMP="${ECHO_CMD} ${_MASTER_SITE_OVERRIDE} `${ECHO_CMD} $${__PATCH_SITES_TMP} | ${AWK} '${MASTER_SORT_AWK:S|\\|\\\\|g}'` ${_MASTER_SITE_BACKUP}" ; \
3471                         else \
3472                                 SORTED_PATCH_SITES_CMD_TMP="${SORTED_PATCH_SITES_DEFAULT_CMD}" ; \
3473                         fi; \
3474                         sites_remaining=0; \
3475                         sites="`eval $$SORTED_PATCH_SITES_CMD_TMP`"; \
3476                         for site in $${sites}; do \
3477                                 sites_remaining=$$(($${sites_remaining} + 1)); \
3478                         done; \
3479                         for site in $${sites}; do \
3480                                 sites_remaining=$$(($${sites_remaining} - 1)); \
3481                             ${ECHO_MSG} "=> Attempting to fetch $${site}$${file}"; \
3482                                 CKSIZE=`alg=SIZE; ${DISTINFO_DATA}`; \
3483                                 case $${file} in \
3484                                 */*)    ${MKDIR} $${file%/*}; \
3485                                                 args="-o $${file} $${site}$${file}";; \
3486                                 *)              args=$${site}$${file};; \
3487                                 esac; \
3488                                 if ${SETENV} ${FETCH_ENV} ${FETCH_CMD} ${FETCH_BEFORE_ARGS} $${args} ${FETCH_AFTER_ARGS}; then \
3489                                         actual_size=`stat -f %z "$${file}"`; \
3490                                         if [ -n "${DISABLE_SIZE}" ] || [ -z "$${CKSIZE}" ] || [ $${actual_size} -eq $${CKSIZE} ]; then \
3491                                                 continue 2; \
3492                                         else \
3493                                                 ${ECHO_MSG} "=> Fetched file size mismatch (expected $${CKSIZE}, actual $${actual_size})"; \
3494                                                 if [ $${sites_remaining} -gt 1 ]; then \
3495                                                         ${ECHO_MSG} "=> Trying next site"; \
3496                                                         ${RM} -f $${file}; \
3497                                                 fi; \
3498                                         fi; \
3499                                 fi; \
3500                         done; \
3501                         ${ECHO_MSG} "=> Couldn't fetch it - please try to retrieve this";\
3502                         ${ECHO_MSG} "=> port manually into ${_DISTDIR} and try again."; \
3503                         exit 1; \
3504                 fi; \
3505          done
3506 .endif
3507 .endif
3508
3509 # Extract
3510
3511 .if !target(do-extract)
3512 do-extract:
3513         @${RM} -rf ${WRKDIR}
3514         @${MKDIR} ${WRKDIR}
3515         @for file in ${EXTRACT_ONLY}; do \
3516                 if ! (cd ${WRKDIR} && ${EXTRACT_CMD} ${EXTRACT_BEFORE_ARGS} ${_DISTDIR}/$$file ${EXTRACT_AFTER_ARGS});\
3517                 then \
3518                         exit 1; \
3519                 fi; \
3520         done
3521 .if !defined(EXTRACT_PRESERVE_OWNERSHIP)
3522         @if [ ${UID} = 0 ]; then \
3523                 ${CHMOD} -R ug-s ${WRKDIR}; \
3524                 ${CHOWN} -R 0:0 ${WRKDIR}; \
3525         fi
3526 .endif
3527 .endif
3528
3529 # Patch
3530
3531 .if !target(do-patch)
3532 do-patch:
3533 .if defined(PATCHFILES)
3534         @${ECHO_MSG} "===>  Applying distribution patches for ${PKGNAME}"
3535         @(set -e; \
3536         cd ${_DISTDIR}; \
3537         patch_dist_strip () { \
3538                 case "$$1" in \
3539                 ${_PATCH_DIST_STRIP_CASES} \
3540                 esac; \
3541         }; \
3542         for i in ${_PATCHFILES}; do \
3543                 if [ ${PATCH_DEBUG_TMP} = yes ]; then \
3544                         ${ECHO_MSG} "===>   Applying distribution patch $$i" ; \
3545                 fi ; \
3546                 case $$i in \
3547                 *.Z|*.gz) ${GZCAT} $$i ;; \
3548                 *.bz2) ${BZCAT} $$i ;; \
3549                 *.xz) ${XZCAT} $$i ;; \
3550                 *) ${CAT} $$i ;; \
3551                 esac | ${PATCH} ${PATCH_DIST_ARGS} `patch_dist_strip $$i` ; \
3552         done )
3553 .endif
3554 .if defined(EXTRA_PATCHES)
3555         @set -e ; \
3556         for i in ${EXTRA_PATCHES}; do \
3557                 ${ECHO_MSG} "===>  Applying extra patch $$i" ; \
3558                 case $$i in \
3559                 *.Z|*.gz) ${GZCAT} $$i ;; \
3560                 *.bz2) ${BZCAT} $$i ;; \
3561                 *.xz) ${XZCAT} $$i ;; \
3562                 *) ${CAT} $$i ;; \
3563                 esac | ${PATCH} ${PATCH_ARGS} ; \
3564         done
3565 .endif
3566         @set -e ;\
3567         if [ -d ${PATCHDIR} ]; then \
3568                 if [ "`${ECHO_CMD} ${PATCHDIR}/patch-*`" != "${PATCHDIR}/patch-*" ]; then \
3569                         ${ECHO_MSG} "===>  Applying ports patches for ${PKGNAME}" ; \
3570                         PATCHES_APPLIED="" ; \
3571                         for i in ${PATCHDIR}/patch-*; do \
3572                                 case $$i in \
3573                                         *.orig|*.rej|*~|*,v) \
3574                                                 ${ECHO_MSG} "===>   Ignoring patchfile $$i" ; \
3575                                                 ;; \
3576                                         *) \
3577                                                 if [ ${PATCH_DEBUG_TMP} = yes ]; then \
3578                                                         ${ECHO_MSG} "===>   Applying ${OPSYS} patch $$i" ; \
3579                                                 fi; \
3580                                                 if ${PATCH} ${PATCH_ARGS} < $$i ; then \
3581                                                         PATCHES_APPLIED="$$PATCHES_APPLIED $$i" ; \
3582                                                 else \
3583                                                         ${ECHO_MSG} `${ECHO_CMD} "=> Patch $$i failed to apply cleanly." | ${SED} "s|${PATCHDIR}/||"` ; \
3584                                                         if [ x"$$PATCHES_APPLIED" != x"" -a ${PATCH_SILENT} != "yes" ]; then \
3585                                                                 ${ECHO_MSG} `${ECHO_CMD} "=> Patch(es) $$PATCHES_APPLIED applied cleanly." | ${SED} "s|${PATCHDIR}/||g"` ; \
3586                                                         fi; \
3587                                                         ${FALSE} ; \
3588                                                 fi; \
3589                                                 ;; \
3590                                 esac; \
3591                         done; \
3592                 fi; \
3593         fi
3594         @set -e ; if [ -d ${DFLY_PATCHDIR} ]; then \
3595                 if [ "`${ECHO_CMD} ${DFLY_PATCHDIR}/patch-*`" != "${DFLY_PATCHDIR}/patch-*" ]; then \
3596                         ${ECHO_MSG} "===>  Applying ${OPSYS} patches for ${PKGNAME}" ; \
3597                         PATCHES_APPLIED="" ; \
3598                         for i in ${DFLY_PATCHDIR}/patch-*; do \
3599                                 case $$i in \
3600                                         *.orig|*.rej|*~|*,v) \
3601                                                 ${ECHO_MSG} "===>   Ignoring patchfile $$i" ; \
3602                                                 ;; \
3603                                         *) \
3604                                                 if [ ${PATCH_DEBUG_TMP} = yes ]; then \
3605                                                         ${ECHO_MSG} "===>   Applying ${OPSYS} patch $$i" ; \
3606                                                 fi; \
3607                                                 if ${PATCH} ${PATCH_ARGS} < $$i ; then \
3608                                                         PATCHES_APPLIED="$$PATCHES_APPLIED $$i" ; \
3609                                                 else \
3610                                                         ${ECHO_MSG} `${ECHO_CMD} "=> Patch $$i failed to apply cleanly." | ${SED} "s|${DFLY_PATCHDIR}/||"` ; \
3611                                                         if [ x"$$PATCHES_APPLIED" != x"" ]; then \
3612                                                                 ${ECHO_MSG} `${ECHO_CMD} "=> Patch(es) $$PATCHES_APPLIED applied cleanly." | ${SED} "s|${DFLY_PATCHDIR}/||g"` ; \
3613                                                         fi; \
3614                                                         ${FALSE} ; \
3615                                                 fi; \
3616                                                 ;; \
3617                                 esac; \
3618                         done; \
3619                 fi; \
3620         fi
3621 .endif
3622
3623 .if !target(run-autotools-fixup)
3624 run-autotools-fixup:
3625 # Work around an issue where FreeBSD 10.0 is detected as FreeBSD 1.x.
3626 .if ${OSVERSION} >= 1000000 && !defined(WITHOUT_FBSD10_FIX)
3627         -@for f in `${FIND} ${WRKDIR} -type f \( -name config.libpath -o \
3628                 -name config.rpath -o -name configure -o -name libtool.m4 -o \
3629                 -name ltconfig -o -name libtool -o -name aclocal.m4 -o \
3630                 -name acinclude.m4 \)` ; do \
3631                         ${SED} -i.fbsd10bak \
3632                                 -e 's|freebsd1\*)|freebsd1.\*)|g' \
3633                                 -e 's|freebsd\[12\]\*)|freebsd[12].*)|g' \
3634                                 -e 's|freebsd\[123\]\*)|freebsd[123].*)|g' \
3635                                 -e 's|freebsd\[\[12\]\]\*)|freebsd[[12]].*)|g' \
3636                                 -e 's|freebsd\[\[123\]\]\*)|freebsd[[123]].*)|g' \
3637                                         $${f} ; \
3638                         ${TOUCH} ${TOUCH_FLAGS} -mr $${f}.fbsd10bak $${f} ; \
3639                         ${RM} -f $${f}.fbsd10bak ; \
3640                         ${ECHO_MSG} "===>   FreeBSD 10 autotools fix applied to $${f}"; \
3641                 done
3642 .endif
3643 .endif
3644
3645 # Configure
3646
3647 .if !target(do-configure)
3648 do-configure:
3649         @if [ -f ${SCRIPTDIR}/configure ]; then \
3650                 cd ${.CURDIR} && ${SETENV} ${SCRIPTS_ENV} ${SH} \
3651                   ${SCRIPTDIR}/configure; \
3652         fi
3653 .if defined(GNU_CONFIGURE)
3654         @CONFIG_GUESS_DIRS=$$(${FIND} ${WRKDIR} -name config.guess -o -name config.sub \
3655                 | ${XARGS} -n 1 ${DIRNAME}); \
3656         for _D in $${CONFIG_GUESS_DIRS}; do \
3657                 ${CP} -f ${TEMPLATES}/config.guess $${_D}/config.guess; \
3658                 ${CHMOD} a+rx $${_D}/config.guess; \
3659             ${CP} -f ${TEMPLATES}/config.sub $${_D}/config.sub; \
3660                 ${CHMOD} a+rx $${_D}/config.sub; \
3661         done
3662 .endif
3663 .if defined(HAS_CONFIGURE)
3664         @(cd ${CONFIGURE_WRKSRC} && \
3665             ${SET_LATE_CONFIGURE_ARGS} \
3666                 if ! ${SETENV} CC="${CC}" CPP="${CPP}" CXX="${CXX}" \
3667             CFLAGS="${CFLAGS}" CPPFLAGS="${CPPFLAGS}" CXXFLAGS="${CXXFLAGS}" \
3668             LDFLAGS="${LDFLAGS}" \
3669             INSTALL="/usr/bin/install -c ${_BINOWNGRP}" \
3670             INSTALL_DATA="${INSTALL_DATA}" \
3671             INSTALL_LIB="${INSTALL_LIB}" \
3672             INSTALL_PROGRAM="${INSTALL_PROGRAM}" \
3673             INSTALL_SCRIPT="${INSTALL_SCRIPT}" \
3674             ${CONFIGURE_ENV} ./${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS}; then \
3675                          ${ECHO_MSG} "===>  Script \"${CONFIGURE_SCRIPT}\" failed unexpectedly."; \
3676                          (${ECHO_CMD} ${CONFIGURE_FAIL_MESSAGE}) | ${FMT} 75 79 ; \
3677                          ${FALSE}; \
3678                 fi)
3679 .endif
3680 .endif
3681
3682 # Build
3683 # XXX: ${MAKE_ARGS:N${DESTDIRNAME}=*} would be easier but it is not valid with the old fmake
3684 .if !target(do-build)
3685 do-build:
3686         @(cd ${BUILD_WRKSRC}; if ! ${SETENV} ${MAKE_ENV} ${MAKE_CMD} ${MAKE_FLAGS} ${MAKEFILE} ${_MAKE_JOBS} ${MAKE_ARGS:C,^${DESTDIRNAME}=.*,,g} ${ALL_TARGET}; then \
3687                 if [ -n "${BUILD_FAIL_MESSAGE}" ] ; then \
3688                         ${ECHO_MSG} "===> Compilation failed unexpectedly."; \
3689                         (${ECHO_CMD} "${BUILD_FAIL_MESSAGE}") | ${FMT} 75 79 ; \
3690                         fi; \
3691                 ${FALSE}; \
3692                 fi)
3693 .endif
3694
3695 # Check conflicts
3696
3697 .if !target(check-conflicts)
3698 check-conflicts: check-build-conflicts check-install-conflicts
3699 .endif
3700
3701 .if !target(check-build-conflicts)
3702 check-build-conflicts:
3703 .if ( defined(CONFLICTS) || defined(CONFLICTS_BUILD) ) && !defined(DISABLE_CONFLICTS) && !defined(DEFER_CONFLICTS_CHECK)
3704         @found=`${PKG_INFO} -I ${CONFLICTS:C/.+/'&'/} ${CONFLICTS_BUILD:C/.+/'&'/} 2>/dev/null | ${AWK} '{print $$1}'`; \
3705         conflicts_with=; \
3706         for entry in $${found}; do \
3707                 if ${PKG_INFO} -e $${entry} ; then \
3708                         prfx=`${PKG_INFO} -q -p "$${entry}" 2> /dev/null | ${SED} -ne '1s/^@cwd //p'`; \
3709                         orgn=`${PKG_INFO} -q -o "$${entry}" 2> /dev/null`; \
3710                         if [ "/${PREFIX}" = "/$${prfx}" -a "/${PKGORIGIN}" != "/$${orgn}" ]; then \
3711                                 conflicts_with="$${conflicts_with} $${entry}"; \
3712                         fi; \
3713                 fi; \
3714         done; \
3715         if [ -n "$${conflicts_with}" ]; then \
3716                 ${ECHO_MSG}; \
3717                 ${ECHO_MSG} "===>  ${PKGNAME} conflicts with installed package(s): "; \
3718                 for entry in $${conflicts_with}; do \
3719                         ${ECHO_MSG} "      $${entry}"; \
3720                 done; \
3721                 ${ECHO_MSG}; \
3722                 ${ECHO_MSG} "      They will not build together."; \
3723                 ${ECHO_MSG} "      Please remove them first with pkg_delete(1)."; \
3724                 exit 1; \
3725         fi
3726 .endif
3727 .endif
3728
3729 .if !target(identify-install-conflicts)
3730 identify-install-conflicts:
3731 .if ( defined(CONFLICTS) || defined(CONFLICTS_INSTALL) ) && !defined(DISABLE_CONFLICTS)
3732         @found=`${PKG_INFO} -I ${CONFLICTS:C/.+/'&'/} ${CONFLICTS_INSTALL:C/.+/'&'/} 2>/dev/null | ${AWK} '{print $$1}'`; \
3733         conflicts_with=; \
3734         for entry in $${found}; do \
3735                 if ${PKG_INFO} -e $${entry} ; then \
3736                         prfx=`${PKG_INFO} -q -p "$${entry}" 2> /dev/null | ${SED} -ne '1s/^@cwd //p'`; \
3737                         orgn=`${PKG_INFO} -q -o "$${entry}" 2> /dev/null`; \
3738                         if [ "/${PREFIX}" = "/$${prfx}" -a "/${PKGORIGIN}" != "/$${orgn}" ]; then \
3739                                 conflicts_with="$${conflicts_with} $${entry}"; \
3740                         fi; \
3741                 fi; \
3742         done; \
3743         if [ -n "$${conflicts_with}" ]; then \
3744                 ${ECHO_MSG}; \
3745                 ${ECHO_MSG} "===>  ${PKGNAME} conflicts with installed package(s): "; \
3746                 for entry in $${conflicts_with}; do \
3747                         ${ECHO_MSG} "      $${entry}"; \
3748                 done; \
3749                 ${ECHO_MSG}; \
3750                 ${ECHO_MSG} "      They install files into the same place."; \
3751                 ${ECHO_MSG} "      You may want to stop build with Ctrl + C."; \
3752                 sleep 10; \
3753         fi
3754 .endif
3755 .endif
3756
3757 .if !target(check-install-conflicts)
3758 check-install-conflicts:
3759 .if ( defined(CONFLICTS) || defined(CONFLICTS_INSTALL) || ( defined(CONFLICTS_BUILD) && defined(DEFER_CONFLICTS_CHECK) ) ) && !defined(DISABLE_CONFLICTS) 
3760 .if defined(DEFER_CONFLICTS_CHECK)
3761         @found=`${PKG_INFO} -I ${CONFLICTS:C/.+/'&'/} ${CONFLICTS_BUILD:C/.+/'&'/} ${CONFLICTS_INSTALL:C/.+/'&'/} 2>/dev/null | ${AWK} '{print $$1}'`; \
3762         conflicts_with=; \
3763         for entry in $${found}; do \
3764                 if ${PKG_INFO} -e $${entry} ; then \
3765                         prfx=`${PKG_INFO} -q -p "$${entry}" 2> /dev/null | ${SED} -ne '1s/^@cwd //p'`; \
3766                         orgn=`${PKG_INFO} -q -o "$${entry}" 2> /dev/null`; \
3767                         if [ "/${PREFIX}" = "/$${prfx}" -a "/${PKGORIGIN}" != "/$${orgn}" ]; then \
3768                                 conflicts_with="$${conflicts_with} $${entry}"; \
3769                         fi; \
3770                 fi; \
3771         done; \
3772         if [ -n "$${conflicts_with}" ]; then \
3773                 ${ECHO_MSG}; \
3774                 ${ECHO_MSG} "===>  ${PKGNAME} conflicts with installed package(s): "; \
3775                 for entry in $${conflicts_with}; do \
3776                         ${ECHO_MSG} "      $${entry}"; \
3777                 done; \
3778                 ${ECHO_MSG}; \
3779                 ${ECHO_MSG} "      Please remove them first with pkg_delete(1)."; \
3780                 exit 1; \
3781         fi
3782 .else
3783         @found=`${PKG_INFO} -I ${CONFLICTS:C/.+/'&'/} ${CONFLICTS_INSTALL:C/.+/'&'/} 2>/dev/null | ${AWK} '{print $$1}'`; \
3784         conflicts_with=; \
3785         for entry in $${found}; do \
3786                 if ${PKG_INFO} -e $${entry} ; then \
3787                         prfx=`${PKG_INFO} -q -p "$${entry}" 2> /dev/null | ${SED} -ne '1s/^@cwd //p'`; \
3788                         orgn=`${PKG_INFO} -q -o "$${entry}" 2> /dev/null`; \
3789                         if [ "/${PREFIX}" = "/$${prfx}" -a "/${PKGORIGIN}" != "/$${orgn}" ]; then \
3790                                 conflicts_with="$${conflicts_with} $${entry}"; \
3791                         fi; \
3792                 fi; \
3793         done; \
3794         if [ -n "$${conflicts_with}" ]; then \
3795                 ${ECHO_MSG}; \
3796                 ${ECHO_MSG} "===>  ${PKGNAME} conflicts with installed package(s): "; \
3797                 for entry in $${conflicts_with}; do \
3798                         ${ECHO_MSG} "      $${entry}"; \
3799                 done; \
3800                 ${ECHO_MSG}; \
3801                 ${ECHO_MSG} "      They install files into the same place."; \
3802                 ${ECHO_MSG} "      Please remove them first with pkg_delete(1)."; \
3803                 exit 1; \
3804         fi
3805 .endif # defined(DEFER_CONFLICTS_CHECK)
3806 .endif
3807 .endif
3808
3809 # Install
3810
3811 .if !target(do-install)
3812 do-install:
3813         @(cd ${INSTALL_WRKSRC} && ${SETENV} ${MAKE_ENV} ${MAKE_CMD} ${MAKE_FLAGS} ${MAKEFILE} ${MAKE_ARGS} ${INSTALL_TARGET})
3814 .endif
3815
3816 # Package
3817
3818 .if !target(do-package)
3819 do-package: ${TMPPLIST}
3820         @if [ -d ${PACKAGES} ]; then \
3821                 if [ ! -d ${PKGREPOSITORY} ]; then \
3822                         if ! ${MKDIR} ${PKGREPOSITORY}; then \
3823                                 ${ECHO_MSG} "=> Can't create directory ${PKGREPOSITORY}."; \
3824                                 exit 1; \
3825                         fi; \
3826                 fi; \
3827         fi
3828 .if defined(NO_STAGE)
3829         @if ${PKG_CMD} -b ${PKGNAME} ${PKGFILE}; then \
3830                 if [ -d ${PACKAGES} ]; then \
3831                         cd ${.CURDIR} && eval ${MAKE} package-links; \
3832                 fi; \
3833         else \
3834                 cd ${.CURDIR} && eval ${MAKE} delete-package; \
3835                 exit 1; \
3836         fi
3837 .else
3838         @_LATE_PKG_ARGS=""; \
3839         if [ -f ${PKGINSTALL} ]; then \
3840                 _LATE_PKG_ARGS="$${_LATE_PKG_ARGS} -i ${PKGINSTALL}"; \
3841         fi; \
3842         if [ -f ${PKGDEINSTALL} ]; then \
3843                 _LATE_PKG_ARGS="$${_LATE_PKG_ARGS} -k ${PKGDEINSTALL}"; \
3844         fi; \
3845         if [ -f ${PKGREQ} ]; then \
3846                 _LATE_PKG_ARGS="$${_LATE_PKG_ARGS} -r ${PKGREQ}"; \
3847         fi; \
3848         if [ -f ${PKGMESSAGE} ]; then \
3849                 _LATE_PKG_ARGS="$${_LATE_PKG_ARGS} -D ${PKGMESSAGE}"; \
3850         fi; \
3851         ${MKDIR} ${WRKDIR}/pkg; \
3852         if ${PKG_CMD} -S ${STAGEDIR} ${PKG_ARGS} ${WRKDIR}/pkg/${PKGNAME}${PKG_SUFX}; then \
3853                 if [ -d ${PKGREPOSITORY} -a -w ${PKGREPOSITORY} ]; then \
3854                         ${LN} -f ${WRKDIR}/pkg/${PKGNAME}${PKG_SUFX} ${PKGFILE} 2>/dev/null || \
3855                             ${CP} -af ${WRKDIR}/pkg/${PKGNAME}${PKG_SUFX} ${PKGFILE}; \
3856                         cd ${.CURDIR} && eval ${MAKE} package-links; \
3857                 fi; \
3858         else \
3859                 cd ${.CURDIR} && eval ${MAKE} delete-package; \
3860                 exit 1; \
3861         fi
3862 .endif
3863 .endif
3864
3865 # Some support rules for do-package
3866
3867 .if !target(package-links)
3868 package-links: delete-package-links
3869         @for cat in ${CATEGORIES}; do \
3870                 if [ ! -d ${PACKAGES}/$$cat ]; then \
3871                         if ! ${MKDIR} ${PACKAGES}/$$cat; then \
3872                                 ${ECHO_MSG} "=> Can't create directory ${PACKAGES}/$$cat."; \
3873                                 exit 1; \
3874                         fi; \
3875                 fi; \
3876                 ${LN} -sf `${ECHO_CMD} $$cat | ${SED} -e 'sa[^/]*a..ag'`/${PKGREPOSITORYSUBDIR}/${PKGNAME}${PKG_SUFX} ${PACKAGES}/$$cat; \
3877         done
3878 .if !defined(NO_LATEST_LINK)
3879         @if [ ! -d ${PKGLATESTREPOSITORY} ]; then \
3880                 if ! ${MKDIR} ${PKGLATESTREPOSITORY}; then \
3881                         ${ECHO_MSG} "=> Can't create directory ${PKGLATESTREPOSITORY}."; \
3882                         exit 1; \
3883                 fi; \
3884         fi
3885         @${LN} -s ../${PKGREPOSITORYSUBDIR}/${PKGNAME}${PKG_SUFX} ${PKGLATESTFILE}
3886 .endif
3887 .endif
3888
3889 .if !target(delete-package-links)
3890 delete-package-links:
3891         @for cat in ${CATEGORIES}; do \
3892                 ${RM} -f ${PACKAGES}/$$cat/${PKGNAME}${PKG_SUFX}; \
3893         done
3894 .if !defined(NO_LATEST_LINK)
3895         @${RM} -f ${PKGLATESTFILE}
3896 .endif
3897 .endif
3898
3899 .if !target(delete-package)
3900 delete-package: delete-package-links
3901 .       if defined(NO_STAGE)
3902         @${RM} -f ${PKGFILE}
3903 .       else
3904 # When staging, the package may only be in the workdir if not root
3905         @${RM} -f ${PKGFILE} ${WRKDIR}/pkg/${PKGNAME}${PKG_SUFX} 2>/dev/null || :
3906 .       endif
3907 .endif
3908
3909 .if !target(delete-package-links-list)
3910 delete-package-links-list:
3911         @for cat in ${CATEGORIES}; do \
3912                 ${ECHO_CMD} ${RM} -f ${PACKAGES}/$$cat/${PKGNAME}${PKG_SUFX}; \
3913         done
3914 .if !defined(NO_LATEST_LINK)
3915         @${ECHO_CMD} ${RM} -f ${PKGLATESTFILE}
3916 .endif
3917 .endif
3918
3919 .if !target(delete-package-list)
3920 delete-package-list: delete-package-links-list
3921         @${ECHO_CMD} "[ -f ${PKGFILE} ] && (${ECHO_CMD} deleting ${PKGFILE}; ${RM} -f ${PKGFILE})"
3922 .endif
3923
3924 # Used if !defined(NO_STAGE) during install, or manually to install package
3925 # from local repository.
3926 .if !target(install-package)
3927 .if defined(FORCE_PKG_REGISTER)
3928 _INSTALL_PKG_ARGS=      -f
3929 .endif
3930 .if defined(INSTALLS_DEPENDS) && defined(WITH_PKGNG)
3931 _INSTALL_PKG_ARGS+=     -A
3932 .endif
3933 install-package:
3934         @if [ -f "${WRKDIR}/pkg/${PKGNAME}${PKG_SUFX}" ]; then \
3935             _pkgfile="${WRKDIR}/pkg/${PKGNAME}${PKG_SUFX}"; \
3936         else \
3937             _pkgfile="${PKGFILE}"; \
3938         fi; \
3939         ${PKG_ADD} ${_INSTALL_PKG_ARGS} $${_pkgfile}
3940 .endif
3941
3942
3943 # Utility targets follow
3944
3945 .if !target(check-already-installed)
3946 .if !defined(NO_PKG_REGISTER) && !defined(FORCE_PKG_REGISTER)
3947 check-already-installed: ${TMPPLIST_SORT}
3948                 @${ECHO_MSG} "===>  Checking if ${PKGORIGIN} already installed"; \
3949                 ${MKDIR} ${PKG_DBDIR}; \
3950                 already_installed=`${PKG_INFO} -q -O ${PKGORIGIN}`; \
3951                 if [ -n "$${already_installed}" ]; then \
3952                                 for p in $${already_installed}; do \
3953                                                 prfx=`${PKG_INFO} -q -p $${p} 2> /dev/null | ${SED} -ne '1s|^@cwd ||p'`; \
3954                                                 if [ "x${PREFIX}" = "x$${prfx}" ]; then \
3955                                                                 df=`${PKG_INFO} -q -f $${p} 2> /dev/null | ${GREP} -v "^@" | ${SORT} -u | ${COMM} -12 - ${TMPPLIST_SORT}`; \
3956                                                                 if [ -n "$${df}" ]; then \
3957                                                                                 found_package=$${p}; \
3958                                                                                 break; \
3959                                                                 fi; \
3960                                                 fi; \
3961                                 done; \
3962                 fi; \
3963                 if [ -d ${PKG_DBDIR}/${PKGNAME} -o -n "$${found_package}" ]; then \
3964                                 if [ -d ${PKG_DBDIR}/${PKGNAME} ]; then \
3965                                         ${ECHO_CMD} "===>   ${PKGNAME} is already installed"; \
3966                                 else \
3967                                         ${ECHO_CMD} "===>   An older version of ${PKGORIGIN} is already installed ($${found_package})"; \
3968                                 fi; \
3969                                 ${ECHO_MSG} "      You may wish to \`\`make deinstall'' and install this port again"; \
3970                                 ${ECHO_MSG} "      by \`\`make reinstall'' to upgrade it properly."; \
3971                                 ${ECHO_MSG} "      If you really wish to overwrite the old port of ${PKGORIGIN}"; \
3972                                 ${ECHO_MSG} "      without deleting it first, set the variable \"FORCE_PKG_REGISTER\""; \
3973                                 ${ECHO_MSG} "      in your environment or the \"make install\" command line."; \
3974                                 exit 1; \
3975                 fi
3976 .endif
3977 .endif
3978
3979 .if !target(check-umask)
3980 check-umask:
3981         @if [ `${SH} -c umask` != 0022 ]; then \
3982                 ${ECHO_MSG} "===>  Warning: your umask is \"`${SH} -c umask`"\".; \
3983                 ${ECHO_MSG} "      If this is not desired, set it to an appropriate value"; \
3984                 ${ECHO_MSG} "      and install this port again by \`\`make reinstall''."; \
3985         fi
3986 .endif
3987
3988 .if !target(install-mtree)
3989 install-mtree:
3990         @${MKDIR} ${PREFIX}
3991         @if [ ${UID} != 0 ]; then \
3992                 if [ -w ${PREFIX}/ ]; then \
3993                         ${ECHO_MSG} "Warning: not superuser, you may get some errors during installation."; \
3994                 else \
3995                         ${ECHO_MSG} "Error: ${PREFIX}/ not writable."; \
3996                         ${FALSE}; \
3997                 fi; \
3998         fi
3999 .if !defined(NO_MTREE)
4000         @if [ ${UID} = 0 ]; then \
4001                 if [ ! -f ${MTREE_FILE} ]; then \
4002                         ${ECHO_MSG} "Error: mtree file \"${MTREE_FILE}\" is missing."; \
4003                         ${ECHO_MSG} "Copy it from a suitable location (e.g., ${SRC_BASE}/etc/mtree) and try again."; \
4004                         exit 1; \
4005                 else \
4006                         ${MTREE_CMD} ${MTREE_ARGS} ${PREFIX}/ >/dev/null; \
4007                         if [ ${PREFIX} = ${LOCALBASE} -a "${MTREE_FILE_DEFAULT}" = "yes" ]; then \
4008                                 cd ${PREFIX}/share/nls; \
4009                                 for link in POSIX en_US.US-ASCII; \
4010                                 do \
4011                                         if [ x"`${READLINK_CMD} $${link}`" != x"C" ]; \
4012                                         then \
4013                                                 ${LN} -shf C $${link}; \
4014                                         fi; \
4015                                 done; \
4016                         fi; \
4017                 fi; \
4018         else \
4019                 ${ECHO_MSG} "Warning: not superuser, can't run mtree."; \
4020                 ${ECHO_MSG} "You may want to become root and try again to ensure correct permissions."; \
4021         fi
4022 .endif
4023 .endif
4024
4025 .if !target(install-ldconfig-file)
4026 install-ldconfig-file:
4027 .if defined(USE_LDCONFIG) || defined(USE_LDCONFIG32)
4028 .if defined(USE_LDCONFIG)
4029 .if defined(USE_LINUX_PREFIX)
4030 .if defined(NO_STAGE)
4031         @${ECHO_MSG} "===>   Running linux ldconfig"
4032         ${LDCONFIG_CMD}
4033 .endif
4034 .else
4035 .if defined(NO_STAGE)
4036 .if !defined(INSTALL_AS_USER)
4037         @${ECHO_MSG} "===>   Running ldconfig"
4038         ${LDCONFIG} -m ${USE_LDCONFIG}
4039 .else
4040         @${ECHO_MSG} "===>   Running ldconfig (errors are ignored)"
4041         -${LDCONFIG} -m ${USE_LDCONFIG}
4042 .endif
4043 .endif
4044 .if ${USE_LDCONFIG} != "${PREFIX}/lib" && !defined(INSTALL_AS_USER)
4045         @${ECHO_MSG} "===>   Installing ldconfig configuration file"
4046 .if defined(NO_LDCONFIG_MTREE)
4047         @${MKDIR} ${STAGEDIR}${PREFIX}/${LDCONFIG_DIR}
4048 .endif
4049         @${ECHO_CMD} ${USE_LDCONFIG} | ${TR} ' ' '\n' \
4050                 > ${STAGEDIR}${PREFIX}/${LDCONFIG_DIR}/${UNIQUENAME}
4051         @${ECHO_CMD} "@cwd ${PREFIX}" >> ${TMPPLIST}
4052         @${ECHO_CMD} ${LDCONFIG_DIR}/${UNIQUENAME} >> ${TMPPLIST}
4053 .if defined(NO_LDCONFIG_MTREE)
4054         @${ECHO_CMD} "@unexec rmdir ${LDCONFIG_DIR} >/dev/null 2>&1 || true" >> ${TMPPLIST}
4055 .endif
4056 .endif
4057 .endif
4058 .endif
4059 .if defined(USE_LDCONFIG32)
4060 .if defined(NO_STAGE)
4061 .if !defined(INSTALL_AS_USER)
4062         @${ECHO_MSG} "===>   Running ldconfig"
4063         ${LDCONFIG} -32 -m ${USE_LDCONFIG32}
4064 .else
4065         @${ECHO_MSG} "===>   Running ldconfig (errors are ignored)"
4066         -${LDCONFIG} -32 -m ${USE_LDCONFIG32}
4067 .endif
4068 .endif
4069 .if !defined(INSTALL_AS_USER)
4070         @${ECHO_MSG} "===>   Installing 32-bit ldconfig configuration file"
4071 .if defined(NO_LDCONFIG_MTREE)
4072         @${MKDIR} ${STAGEDIR}${PREFIX}/${LDCONFIG_32DIR}
4073 .endif
4074         @${ECHO_CMD} ${USE_LDCONFIG32} | ${TR} ' ' '\n' \
4075                 > ${STAGEDIR}${PREFIX}/${LDCONFIG32_DIR}/${UNIQUENAME}
4076         @${ECHO_CMD} "@cwd ${PREFIX}" >> ${TMPPLIST}
4077         @${ECHO_CMD} ${LDCONFIG32_DIR}/${UNIQUENAME} >> ${TMPPLIST}
4078 .if defined(NO_LDCONFIG_MTREE)
4079         @${ECHO_CMD} "@unexec rmdir ${LDCONFIG32_DIR} >/dev/null 2>&1" >> ${TMPPLIST}
4080 .endif
4081 .endif
4082 .endif
4083 .if defined(INSTALLS_SHLIB)
4084         @${ECHO_MSG} "INSTALLS_SHLIB is deprecated. Use USE_LDCONFIG instead."
4085 .endif
4086 .endif
4087 .endif
4088
4089 .if !target(create-users-groups)
4090 .if defined(GROUPS) || defined(USERS)
4091 .if defined(WITH_PKGNG)
4092 _UG_OUTPUT=     ${WRKDIR}/users-groups.sh
4093 PKGPREINSTALL+= ${_UG_OUTPUT}
4094 .else
4095 _UG_OUTPUT=     /dev/null
4096 .endif
4097 .endif
4098 .if defined(GROUPS) || defined(USERS)
4099 create-users-groups:
4100 .if defined(GROUPS)
4101 .for _file in ${GID_FILES}
4102 .if !exists(${_file})
4103         @${ECHO_CMD} "** ${_file} doesn't exist. Exiting."; exit 1
4104 .endif
4105 .endfor
4106 .if defined(WITH_PKGNG)
4107                 @${RM} -f ${_UG_OUTPUT} || ${TRUE}
4108 .endif
4109         @${ECHO_MSG} "===> Creating users and/or groups."
4110 .if defined(WITH_PKGNG)
4111         @${ECHO_CMD} "echo \"===> Creating users and/or groups.\"" >> ${_UG_OUTPUT}
4112 .else
4113         @${ECHO_CMD} "@exec echo \"===> Creating users and/or groups.\"" >> ${TMPPLIST}
4114 .endif
4115 .for _group in ${GROUPS}
4116 # _bgpd:*:130:
4117         @if ! ${GREP} -h ^${_group}: ${GID_FILES} >/dev/null 2>&1; then \
4118                 ${ECHO_CMD} "** Cannot find any information about group \`${_group}' in ${GID_FILES}."; \
4119                 exit 1; \
4120         fi
4121         @IFS=":"; ${GREP} -h ^${_group}: ${GID_FILES} | head -n 1 | while read group foo gid members; do \
4122                 gid=$$(($$gid+${GID_OFFSET})); \
4123                 if [ "${NO_STAGE}" = "yes" ]; then \
4124                 if ! ${PW} groupshow $$group >/dev/null 2>&1; then \
4125                         ${ECHO_MSG} "Creating group \`$$group' with gid \`$$gid'."; \
4126                         ${PW} groupadd $$group -g $$gid; \
4127                 else \
4128                         ${ECHO_MSG} "Using existing group \`$$group'."; \
4129                 fi; \
4130                 fi ; \
4131                 if [ -z "${WITH_PKGNG}" ]; then \
4132                                 ${ECHO_CMD} "@exec if ! ${PW} groupshow $$group >/dev/null 2>&1; then \
4133                                         echo \"Creating group '$$group' with gid '$$gid'.\"; \
4134                                         ${PW} groupadd $$group -g $$gid; else echo \"Using existing group '$$group'.\"; fi" >> ${TMPPLIST}; \
4135                 else \
4136                                 ${ECHO_CMD} -e "if ! ${PW} groupshow $$group >/dev/null 2>&1; then \n \
4137                                         echo \"Creating group '$$group' with gid '$$gid'.\" \n \
4138                                         ${PW} groupadd $$group -g $$gid; else echo \"Using existing group '$$group'.\"\nfi" >> ${_UG_OUTPUT}; \
4139                 fi ; \
4140         done
4141 .endfor
4142 .endif
4143 .if defined(USERS)
4144 .for _file in ${UID_FILES}
4145 .if !exists(${_file})
4146         @${ECHO_CMD} "** ${_file} doesn't exist. Exiting."; exit 1
4147 .endif
4148 .endfor
4149 .for _user in ${USERS}
4150 # _bgpd:*:130:130:BGP Daemon:/var/empty:/sbin/nologin
4151         @if ! ${GREP} -h ^${_user}: ${UID_FILES} >/dev/null 2>&1; then \
4152                 ${ECHO_CMD} "** Cannot find any information about user \`${_user}' in ${UID_FILES}."; \
4153                 exit 1; \
4154         fi
4155         @IFS=":"; ${GREP} -h ^${_user}: ${UID_FILES} | head -n 1 | while read login passwd uid gid class change expire gecos homedir shell; do \
4156                 uid=$$(($$uid+${UID_OFFSET})); \
4157                 gid=$$(($$gid+${GID_OFFSET})); \
4158                 class="$${class:+-L }$$class"; \
4159                 homedir=$$(echo $$homedir | sed "s|^/usr/local|${PREFIX}|"); \
4160                 if [ "${NO_STAGE}" = "yes" ]; then \
4161                 if ! ${PW} usershow $$login >/dev/null 2>&1; then \
4162                         ${ECHO_MSG}  "Creating user \`$$login' with uid \`$$uid'."; \
4163                         eval ${PW} useradd $$login -u $$uid -g $$gid $$class -c \"$$gecos\" -d $$homedir -s $$shell; \
4164                         case $$homedir in /nonexistent|/var/empty) ;; *) ${INSTALL} -d -g $$gid -o $$uid $$homedir;; esac; \
4165                 else \
4166                         ${ECHO_MSG} "Using existing user \`$$login'."; \
4167                 fi; \
4168                 fi; \
4169                 if [ -z "${WITH_PKGNG}" ]; then \
4170                         ${ECHO_CMD} "@exec if ! ${PW} usershow $$login >/dev/null 2>&1; then \
4171                                 echo \"Creating user '$$login' with uid '$$uid'.\"; \
4172                                 ${PW} useradd $$login -u $$uid -g $$gid $$class -c \"$$gecos\" -d $$homedir -s $$shell; \
4173                                 else echo \"Using existing user '$$login'.\"; fi" >> ${TMPPLIST}; \
4174                 else \
4175                         ${ECHO_CMD} -e "if ! ${PW} usershow $$login >/dev/null 2>&1; then \n \
4176                                 echo \"Creating user '$$login' with uid '$$uid'.\" \n \
4177                                 ${PW} useradd $$login -u $$uid -g $$gid $$class -c \"$$gecos\" -d $$homedir -s $$shell \n \
4178                                 else \necho \"Using existing user '$$login'.\" \nfi" >> ${_UG_OUTPUT}; \
4179                 fi ; \
4180                 case $$homedir in /nonexistent|/var/empty) ;; *) ${ECHO_CMD} "@exec ${INSTALL} -d -g $$gid -o $$uid $$homedir" >> ${TMPPLIST};; esac; \
4181         done
4182 .endfor
4183 .if defined(GROUPS)
4184 .for _group in ${GROUPS}
4185 # mail:*:6:postfix,clamav
4186         @IFS=":"; ${GREP} -h ^${_group}: ${GID_FILES} | head -n 1 | while read group foo gid members; do \
4187                 gid=$$(($$gid+${GID_OFFSET})); \
4188                 IFS=","; for _login in $$members; do \
4189                         for _user in ${USERS}; do \
4190                                 if [ "x$${_user}" = "x$${_login}" ]; then \
4191                                         if [ "${NO_STAGE}" = "yes" ]; then \
4192                                         if ! ${PW} groupshow ${_group} | ${GREP} -qw $${_login}; then \
4193                                                 ${ECHO_MSG} "Adding user \`$${_login}' to group \`${_group}'."; \
4194                                                 ${PW} groupmod ${_group} -m $${_login}; \
4195                                         fi; \
4196                                         fi; \
4197                                         if [ -z "${WITH_PKGNG}" ]; then \
4198                                                         ${ECHO_CMD} "@exec if ! ${PW} groupshow ${_group} | ${GREP} -qw $${_login}; then \
4199                                                                 echo \"Adding user '$${_login}' to group '${_group}'.\"; \
4200                                                                 ${PW} groupmod ${_group} -m $${_login}; fi" >> ${TMPPLIST}; \
4201                                         else \
4202                                                         ${ECHO_CMD} -e "if ! ${PW} groupshow ${_group} | ${GREP} -qw $${_login}; then \n \
4203                                                                 echo \"Adding user '$${_login}' to group '${_group}'.\" \n \
4204                                                                 ${PW} groupmod ${_group} -m $${_login} \nfi" >> ${_UG_OUTPUT}; \
4205                                         fi ; \
4206                                 fi; \
4207                         done; \
4208                 done; \
4209         done
4210 .endfor
4211 .endif
4212 .if defined(USERS)
4213 .for _user in ${USERS}
4214         @if [ ! ${USERS_BLACKLIST:M${_user}} ]; then \
4215                 ${ECHO_CMD} "@unexec if ${PW} usershow ${_user} >/dev/null 2>&1; then \
4216                 echo \"==> You should manually remove the \\\"${_user}\\\" user. \"; fi" >> ${TMPPLIST}; \
4217         fi
4218 .endfor
4219 .endif
4220 .endif
4221 .endif
4222 .endif
4223
4224 # PR ports/152498
4225 # XXX Make sure the commands to create group(s)
4226 # and user(s) are the first in pkg-plist
4227 .if !target(fix-plist-sequence)
4228 fix-plist-sequence: ${TMPPLIST}
4229 .if !defined(WITH_PKGNG) && (defined(GROUPS) || defined(USERS))
4230         @${ECHO_CMD} "===> Correct pkg-plist sequence to create group(s) and user(s)"
4231         @${EGREP} -e '^@exec echo.*Creating users and' -e '^@exec.*${PW}' -e '^@exec ${INSTALL} -d -g' ${TMPPLIST} > ${TMPGUCMD}
4232         @${EGREP} -v -e '^@exec echo.*Creating users and' -e '^@exec.*${PW}' -e '^@exec ${INSTALL} -d -g' ${TMPPLIST} >> ${TMPGUCMD}
4233         @${MV} -f ${TMPGUCMD} ${TMPPLIST}
4234 .endif
4235 .if !defined(WITH_PKGNG)
4236         @${ECHO_CMD} "@exec echo pkg_install EOL is scheduled for 2014-09-01. Please consider migrating to pkgng" >> ${TMPPLIST}
4237         @${ECHO_CMD} "@exec echo http://blogs.freebsdish.org/portmgr/2014/02/03/time-to-bid-farewell-to-the-old-pkg_-tools/" >> ${TMPPLIST}
4238 .endif
4239 .endif
4240
4241 .if !defined(DISABLE_SECURITY_CHECK)
4242 .if !target(security-check)
4243 security-check:
4244 # Scan PLIST for:
4245 #   1.  setugid files
4246 #   2.  accept()/recvfrom() which indicates network listening capability
4247 #   3.  insecure functions (gets/mktemp/tempnam/[XXX])
4248 #   4.  startup scripts, in conjunction with 2.
4249 #   5.  world-writable files/dirs
4250 #
4251         -@${RM} -f ${WRKDIR}/.PLIST.setuid ${WRKDIR}/.PLIST.writable ${WRKDIR}/.PLIST.objdump; \
4252         ${AWK} -v prefix='${PREFIX}' ' \
4253                 match($$0, /^@cwd /) { prefix = substr($$0, RSTART + RLENGTH); if (prefix == "/") prefix=""; next; } \
4254                 /^@/ { next; } \
4255                 /^\// { print; next; } \
4256                 { print prefix "/" $$0; } \
4257         ' ${TMPPLIST} > ${WRKDIR}/.PLIST.flattened; \
4258         ${TR} '\n' '\0' < ${WRKDIR}/.PLIST.flattened \
4259         | ${XARGS} -0 -J % ${FIND} % -prune ! -type l -type f \( -perm -4000 -o -perm -2000 \) \( -perm -0010 -o -perm -0001 \) 2> /dev/null > ${WRKDIR}/.PLIST.setuid; \
4260         ${TR} '\n' '\0' < ${WRKDIR}/.PLIST.flattened \
4261         | ${XARGS} -0 -J % ${FIND} % -prune -perm -0002 \! -type l 2> /dev/null > ${WRKDIR}/.PLIST.writable; \
4262         ${TR} '\n' '\0' < ${WRKDIR}/.PLIST.flattened \
4263         | ${XARGS} -0 -J % ${FIND} % -prune ! -type l -type f -print0 2> /dev/null \
4264         | ${XARGS} -0 -n 1 ${OBJDUMP} -R 2> /dev/null > ${WRKDIR}/.PLIST.objdump; \
4265         if \
4266                 ! ${AWK} -v audit="$${PORTS_AUDIT}" -f ${PORTSDIR}/Tools/scripts/security-check.awk \
4267                   ${WRKDIR}/.PLIST.flattened ${WRKDIR}/.PLIST.objdump ${WRKDIR}/.PLIST.setuid ${WRKDIR}/.PLIST.writable; \
4268         then \
4269                 www_site=$$(cd ${.CURDIR} && ${MAKE} www-site); \
4270             if [ ! -z "$${www_site}" ]; then \
4271                         ${ECHO_MSG}; \
4272                         ${ECHO_MSG} "      For more information, and contact details about the security"; \
4273                         ${ECHO_MSG} "      status of this software, see the following webpage: "; \
4274                         ${ECHO_MSG} "$${www_site}"; \
4275                 fi; \
4276         fi
4277 .endif
4278 .else # i.e. defined(DISABLE_SECURITY_CHECK)
4279 security-check:
4280         @${ECHO_MSG} "      WARNING: Security check has been disabled."
4281 .endif # !defined(DISABLE_SECURITY_CHECK)
4282
4283 ################################################################
4284 # Skeleton targets start here
4285 #
4286 # You shouldn't have to change these.  Either add the pre-* or
4287 # post-* targets/scripts or redefine the do-* targets.  These
4288 # targets don't do anything other than checking for cookies and
4289 # call the necessary targets/scripts.
4290 ################################################################
4291
4292 extract-message:
4293         @${ECHO_MSG} "===>  Extracting for ${PKGNAME}"
4294 patch-message:
4295         @${ECHO_MSG} "===>  Patching for ${PKGNAME}"
4296 configure-message:
4297         @${ECHO_MSG} "===>  Configuring for ${PKGNAME}"
4298 build-message:
4299         @${ECHO_MSG} "===>  Building for ${PKGNAME}"
4300 stage-message:
4301         @${ECHO_MSG} "===>  Staging for ${PKGNAME}"
4302 install-message:
4303         @${ECHO_MSG} "===>  Installing for ${PKGNAME}"
4304 package-message:
4305         @${ECHO_MSG} "===>  Building package for ${PKGNAME}"
4306
4307 # Empty pre-* and post-* targets
4308
4309 .for stage in pre post
4310 .for name in pkg check-sanity fetch extract patch configure build stage install package
4311
4312 .if exists(${SCRIPTDIR}/${stage}-${name})
4313 .if !target(${stage}-${name}-script)
4314 ${stage}-${name}-script:
4315         @ cd ${.CURDIR} && ${SETENV} ${SCRIPTS_ENV} ${SH} \
4316                         ${SCRIPTDIR}/${.TARGET:S/-script$//}
4317 .endif
4318 .endif
4319
4320 .endfor
4321 .endfor
4322
4323 .if !target(pretty-print-www-site)
4324 pretty-print-www-site:
4325         @www_site=$$(cd ${.CURDIR} && ${MAKE} www-site); \
4326         if [ -n "$${www_site}" ]; then \
4327                 ${ECHO_MSG} -n " and/or visit the "; \
4328                 ${ECHO_MSG} -n "<a href=\"$${www_site}\">web site</a>"; \
4329                 ${ECHO_MSG} " for further information"; \
4330         fi
4331 .endif
4332
4333 ################################################################
4334 # Some more targets supplied for users' convenience
4335 ################################################################
4336
4337 # Checkpatch
4338 #
4339 # Special target to verify patches
4340
4341 .if !target(checkpatch)
4342 checkpatch:
4343         @cd ${.CURDIR} && ${MAKE} ${PATCH_SILENT} PATCH_CHECK_ONLY=yes ${_PATCH_DEP} ${_PATCH_REAL_SEQ}
4344 .endif
4345
4346 # Reinstall
4347 #
4348 # Special target to re-run install
4349
4350 .if !target(reinstall)
4351 reinstall:
4352         @${RM} -f ${INSTALL_COOKIE} ${PACKAGE_COOKIE}
4353         @cd ${.CURDIR} && DEPENDS_TARGET="${DEPENDS_TARGET}" ${MAKE} -DFORCE_PKG_REGISTER install
4354 .endif
4355
4356 .if !target(restage)
4357 restage:
4358         @${RM} -rf ${STAGEDIR} ${STAGE_COOKIE} ${INSTALL_COOKIE} ${PACKAGE_COOKIE}
4359         @cd ${.CURDIR} && ${MAKE} stage
4360 .endif
4361
4362 # Deinstall
4363 #
4364 # Special target to remove installation
4365
4366 .if !target(deinstall)
4367 deinstall:
4368 .if ${UID} != 0 && !defined(INSTALL_AS_USER)
4369         @${ECHO_MSG} "===>  Switching to root credentials for '${.TARGET}' target"
4370         @cd ${.CURDIR} && \
4371                 ${SU_CMD} "${MAKE} ${.TARGET}"
4372         @${ECHO_MSG} "===>  Returning to user credentials"
4373 .else
4374         @${ECHO_MSG} "===>  Deinstalling for ${PKGORIGIN}"
4375         @found_names=`${PKG_INFO} -q -O ${PKGORIGIN}`; \
4376         for p in $${found_names}; do \
4377                         check_name=`${ECHO_CMD} $${p} | ${SED} -e 's/-[^-]*$$//'`; \
4378                         if [ "$${check_name}" = "${PKGBASE}" ]; then \
4379                                         prfx=`${PKG_INFO} -q -p $${p} 2> /dev/null | ${SED} -ne '1s|^@cwd ||p'`; \
4380                                         if [ "x${PREFIX}" = "x$${prfx}" ]; then \
4381                                                         ${ECHO_MSG} "===>   Deinstalling $${p}"; \
4382                                                         ${PKG_DELETE} -f $${p}; \
4383                                         else \
4384                                                         ${ECHO_MSG} "===>   $${p} has a different PREFIX: $${prfx}, skipping"; \
4385                                         fi; \
4386                         fi; \
4387         done; \
4388         if [ -z "$${found_names}" ]; then \
4389                 ${ECHO_MSG} "===>   ${PKGBASE} not installed, skipping"; \
4390         fi
4391         @${RM} -f ${INSTALL_COOKIE} ${PACKAGE_COOKIE}
4392 .endif
4393 .endif
4394
4395 # Deinstall-all
4396 #
4397 # Special target to remove installation of all ports of the same origin
4398
4399 .if !target(deinstall-all)
4400 deinstall-all:
4401 .if ${UID} != 0 && !defined(INSTALL_AS_USER)
4402         @${ECHO_MSG} "===>  Switching to root credentials for '${.TARGET}' target"
4403         @cd ${.CURDIR} && \
4404                 ${SU_CMD} "${MAKE} ${.TARGET}"
4405         @${ECHO_MSG} "===>  Returning to user credentials"
4406 .else
4407         @${ECHO_MSG} "===>  Deinstalling for ${PKGORIGIN}"
4408         @deinstall_names=`${PKG_INFO} -q -O ${PKGORIGIN}`; \
4409         for oldpkgorigin in $$(${GREP} "|${PKGORIGIN}|" ${PORTSDIR}/MOVED | ${CUT} -f 1 -d '|' | ${SORT} -u); do \
4410                 deinstall_names="$${deinstall_names} $$(${PKG_INFO} -q -O $${oldpkgorigin})"; \
4411         done; \
4412         if [ -n "$${deinstall_names}" ]; then \
4413                 for d in $${deinstall_names}; do \
4414                         ${ECHO_MSG} "===>   Deinstalling $${d}"; \
4415                         ${PKG_DELETE} -f $${d}; \
4416                 done; \
4417         else \
4418                 ${ECHO_MSG} "===>   ${PKGORIGIN} not installed, skipping"; \
4419         fi; \
4420         ${RM} -f ${INSTALL_COOKIE} ${PACKAGE_COOKIE}
4421 .endif
4422 .endif
4423
4424 # Cleaning up
4425
4426 .if !target(do-clean)
4427 do-clean:
4428 .if !defined(NO_STAGE) && defined(NEED_ROOT) && ${UID} != 0 && !defined(INSTALL_AS_USER) && exists(${STAGE_COOKIE})
4429         @${ECHO_MSG} "===>  Switching to root credentials for '${.TARGET}' target"
4430         @cd ${.CURDIR} && \
4431                 ${SU_CMD} "${MAKE} ${.TARGET}"
4432         @${ECHO_MSG} "===>  Returning to user credentials"
4433 .else
4434         @if [ -d ${WRKDIR} ]; then \
4435                 if [ -w ${WRKDIR} ]; then \
4436                         ${RM} -rf ${WRKDIR}; \
4437                 else \
4438                         ${ECHO_MSG} "===>   ${WRKDIR} not writable, skipping"; \
4439                 fi; \
4440         fi
4441 .endif
4442 .endif
4443
4444 .if !target(clean)
4445 clean:
4446 .if !defined(NOCLEANDEPENDS)
4447         @cd ${.CURDIR} && ${MAKE} limited-clean-depends
4448 .endif
4449         @${ECHO_MSG} "===>  Cleaning for ${PKGNAME}"
4450 .if target(pre-clean)
4451         @cd ${.CURDIR} && ${MAKE} pre-clean
4452 .endif
4453         @cd ${.CURDIR} && ${MAKE} do-clean
4454 .if target(post-clean)
4455         @cd ${.CURDIR} && ${MAKE} post-clean
4456 .endif
4457 .endif
4458
4459 .if !target(pre-distclean)
4460 pre-distclean:
4461         @${DO_NADA}
4462 .endif
4463
4464 .if !target(distclean)
4465 distclean: pre-distclean clean
4466         @cd ${.CURDIR} && ${MAKE} delete-distfiles RESTRICTED_FILES="${_DISTFILES} ${_PATCHFILES}"
4467 .endif
4468
4469 .if !target(delete-distfiles)
4470 delete-distfiles:
4471         @${ECHO_MSG} "===>  Deleting distfiles for ${PKGNAME}"
4472         @(if [ "X${RESTRICTED_FILES}" != "X" -a -d ${_DISTDIR} ]; then \
4473                 cd ${_DISTDIR}; \
4474                 for file in ${RESTRICTED_FILES}; do \
4475                         ${RM} -f $${file}; \
4476                         dir=$${file%/*}; \
4477                         if [ "$${dir}" != "$${file}" ]; then \
4478                                 ${RMDIR} -p $${dir} >/dev/null 2>&1 || :; \
4479                         fi; \
4480                 done; \
4481         fi)
4482 .if defined(DIST_SUBDIR)
4483         -@${RMDIR} ${_DISTDIR} >/dev/null 2>&1 || ${TRUE}
4484 .endif
4485 .endif
4486
4487 .if !target(delete-distfiles-list)
4488 delete-distfiles-list:
4489         @${ECHO_CMD} "# ${PKGNAME}"
4490         @if [ "X${RESTRICTED_FILES}" != "X" ]; then \
4491                 for file in ${RESTRICTED_FILES}; do \
4492                         ${ECHO_CMD} "[ -f ${_DISTDIR}/$$file ] && (${ECHO_CMD} deleting ${_DISTDIR}/$$file; ${RM} -f ${_DISTDIR}/$$file)"; \
4493                         dir=$${file%/*}; \
4494                         if [ "$${dir}" != "$${file}" ]; then \
4495                                 ${ECHO_CMD} "(cd ${_DISTDIR} && ${RMDIR} -p $${dir} 2>/dev/null)"; \
4496                         fi; \
4497                 done; \
4498         fi
4499 .if defined(DIST_SUBDIR)
4500         @${ECHO_CMD} "${RMDIR} ${_DISTDIR} 2>/dev/null || ${TRUE}"
4501 .endif
4502 .endif
4503
4504 # Prints out a list of files to fetch (useful to do a batch fetch)
4505
4506 .if !target(fetch-list)
4507 fetch-list:
4508         @${MKDIR} ${_DISTDIR}
4509         @(cd ${_DISTDIR}; \
4510          ${_MASTER_SITES_ENV} ; \
4511          for _file in ${DISTFILES}; do \
4512                 file=`${ECHO_CMD} $$_file | ${SED} -E -e 's/:[^:]+$$//'` ; \
4513                 select=`${ECHO_CMD} $${_file#$${file}} | ${SED} -e 's/^://' -e 's/,/ /g'` ; \
4514                 if [ ! -f $$file -a ! -f $${file##*/} ]; then \
4515                         if [ ! -z "$$select" ] ; then \
4516                                 __MASTER_SITES_TMP= ; \
4517                                 for group in $$select; do \
4518                                         if [ ! -z \$${_MASTER_SITES_$${group}} ] ; then \
4519                                                 eval ___MASTER_SITES_TMP=\$${_MASTER_SITES_$${group}} ; \
4520                                                 __MASTER_SITES_TMP="$${__MASTER_SITES_TMP} $${___MASTER_SITES_TMP}" ; \
4521                                         fi; \
4522                                 done; \
4523                                 ___MASTER_SITES_TMP= ; \
4524                                 SORTED_MASTER_SITES_CMD_TMP="${ECHO_CMD} ${_MASTER_SITE_OVERRIDE} `${ECHO_CMD} $${__MASTER_SITES_TMP} | ${AWK} '${MASTER_SORT_AWK:S|\\|\\\\|g}'` ${_MASTER_SITE_BACKUP}" ; \
4525                         else \
4526                                 SORTED_MASTER_SITES_CMD_TMP="${SORTED_MASTER_SITES_DEFAULT_CMD}" ; \
4527                         fi; \
4528                         for site in `eval $$SORTED_MASTER_SITES_CMD_TMP ${_RANDOMIZE_SITES}`; do \
4529                                 if [ ! -z "`${ECHO_CMD} ${NOFETCHFILES} | ${GREP} -w $${file}`" ]; then \
4530                                         if [ -z "`${ECHO_CMD} ${MASTER_SITE_OVERRIDE} | ${GREP} -w $${site}`" ]; then \
4531                                                 continue; \
4532                                         fi; \
4533                                 fi; \
4534                                 DIR=${DIST_SUBDIR};\
4535                                 CKSIZE=`alg=SIZE; ${DISTINFO_DATA}`; \
4536                                 case $${file} in \
4537                                 */*)    args="-o $${file} $${site}$${file}";; \
4538                                 *)              args=$${site}$${file};; \
4539                                 esac; \
4540                                 ${ECHO_CMD} -n ${SETENV} ${FETCH_ENV} ${FETCH_CMD} ${FETCH_BEFORE_ARGS} $${args} "${FETCH_AFTER_ARGS}" '|| ' ; \
4541                         done; \
4542                         ${ECHO_CMD} "${ECHO_CMD} $${file} not fetched" ; \
4543                 fi; \
4544         done)
4545 .if defined(PATCHFILES)
4546         @(cd ${_DISTDIR}; \
4547          ${_PATCH_SITES_ENV} ; \
4548          for _file in ${PATCHFILES}; do \
4549                 file=`${ECHO_CMD} $$_file | ${SED} -E -e 's/:[^-:][^:]*$$//'` ; \
4550                 select=`${ECHO_CMD} $${_file#$${file}} | ${SED} -e 's/^://' -e 's/,/ /g'` ; \
4551                 file=`${ECHO_CMD} $$file | ${SED} -E -e 's/:-[^:]+$$//'` ; \
4552                 if [ ! -f $$file -a ! -f $${file##*/} ]; then \
4553                         if [ ! -z "$$select" ] ; then \
4554                                 __PATCH_SITES_TMP= ; \
4555                                 for group in $$select; do \
4556                                         if [ ! -z \$${_PATCH_SITES_$${group}} ] ; then \
4557                                                 eval ___PATCH_SITES_TMP=\$${_PATCH_SITES_$${group}} ; \
4558                                                 __PATCH_SITES_TMP="$${__PATCH_SITES_TMP} $${___PATCH_SITES_TMP}" ; \
4559                                 fi; \
4560                                 done; \
4561                                 ___PATCH_SITES_TMP= ; \
4562                                 SORTED_PATCH_SITES_CMD_TMP="${ECHO_CMD} ${_MASTER_SITE_OVERRIDE} `${ECHO_CMD} $${__PATCH_SITES_TMP} | ${AWK} '${MASTER_SORT_AWK:S|\\|\\\\|g}'` ${_MASTER_SITE_BACKUP}" ; \
4563                         else \
4564                                 SORTED_PATCH_SITES_CMD_TMP="${SORTED_PATCH_SITES_DEFAULT_CMD}" ; \
4565                         fi; \
4566                         for site in `eval $$SORTED_PATCH_SITES_CMD_TMP ${_RANDOMIZE_SITES}`; do \
4567                                 CKSIZE=`alg=SIZE; ${DISTINFO_DATA}`; \
4568                                 case $${file} in \
4569                                 */*)    args="-o $${file} $${site}$${file}";; \
4570                                 *)              args=$${site}$${file};; \
4571                                 esac; \
4572                                 ${ECHO_CMD} -n ${SETENV} ${FETCH_ENV} ${FETCH_CMD} ${FETCH_BEFORE_ARGS} $${args} "${FETCH_AFTER_ARGS}" '|| ' ; \
4573                         done; \
4574                         ${ECHO_CMD} "${ECHO_CMD} $${file} not fetched" ; \
4575                 fi; \
4576          done)
4577 .endif
4578 .endif
4579
4580 .if !target(fetch-url-list-int)
4581 fetch-url-list-int:
4582         @${MKDIR} ${_DISTDIR}
4583         @(cd ${_DISTDIR}; \
4584         ${_MASTER_SITES_ENV}; \
4585         for _file in ${DISTFILES}; do \
4586                 file=`${ECHO_CMD} $$_file | ${SED} -E -e 's/:[^:]+$$//'` ; \
4587                         fileptn=`${ECHO_CMD} $$file | ${SED} 's|/|\\\\/|g;s/\./\\\\./g;s/\+/\\\\+/g;s/\?/\\\\?/g'` ; \
4588                 select=`${ECHO_CMD} $${_file#$${file}} | ${SED} -e 's/^://' -e 's/,/ /g'` ; \
4589                 if [ ! -z "${LISTALL}" -o ! -f $$file -a ! -f $${file##*/} ]; then \
4590                         if [ ! -z "$$select" ] ; then \
4591                                 __MASTER_SITES_TMP= ; \
4592                                 for group in $$select; do \
4593                                         if [ ! -z \$${_MASTER_SITES_$${group}} ] ; then \
4594                                                 eval ___MASTER_SITES_TMP=\$${_MASTER_SITES_$${group}} ; \
4595                                                 __MASTER_SITES_TMP="$${__MASTER_SITES_TMP} $${___MASTER_SITES_TMP}" ; \
4596                                         fi \
4597                                 done; \
4598                                 ___MASTER_SITES_TMP= ; \
4599                                 SORTED_MASTER_SITES_CMD_TMP="${ECHO_CMD} ${_MASTER_SITE_OVERRIDE} `${ECHO_CMD} $${__MASTER_SITES_TMP} | ${AWK} '${MASTER_SORT_AWK:S|\\|\\\\|g}'` ${_MASTER_SITE_BACKUP}" ; \
4600                         else \
4601                                 SORTED_MASTER_SITES_CMD_TMP="${SORTED_MASTER_SITES_DEFAULT_CMD}" ; \
4602                         fi ; \
4603                         for site in `eval $$SORTED_MASTER_SITES_CMD_TMP ${_RANDOMIZE_SITES}`; do \
4604                                 case $${file} in \
4605                                 */*)    args="-o $${file} $${site}$${file}";; \
4606                                 *)              args=$${site}$${file};; \
4607                                 esac; \
4608                                 ${ECHO_CMD} $${args} ; \
4609                         done; \
4610                 fi \
4611         done)
4612 .if defined(PATCHFILES)
4613         @(cd ${_DISTDIR}; \
4614         ${_PATCH_SITES_ENV} ; \
4615         for _file in ${PATCHFILES}; do \
4616                 file=`${ECHO_CMD} $$_file | ${SED} -E -e 's/:[^-:][^:]*$$//'` ; \
4617                 select=`${ECHO_CMD} $${_file#$${file}} | ${SED} -e 's/^://' -e 's/,/ /g'` ; \
4618                 file=`${ECHO_CMD} $$file | ${SED} -E -e 's/:-[^:]+$$//'` ; \
4619                 fileptn=`${ECHO_CMD} $$file | ${SED} 's|/|\\\\/|g;s/\./\\\\./g;s/\+/\\\\+/g;s/\?/\\\\?/g'` ; \
4620                 if [ ! -z "${LISTALL}" -o ! -f $$file -a ! -f $${file##*/} ]; then \
4621                         if [ ! -z "$$select" ] ; then \
4622                                 __PATCH_SITES_TMP= ; \
4623                                 for group in $$select; do \
4624                                         if [ ! -z \$${_PATCH_SITES_$${group}} ] ; then \
4625                                                 eval ___PATCH_SITES_TMP=\$${_PATCH_SITES_$${group}} ; \
4626                                                 __PATCH_SITES_TMP="$${__PATCH_SITES_TMP} $${___PATCH_SITES_TMP}" ; \
4627                                         fi \
4628                                 done; \
4629                                 ___PATCH_SITES_TMP= ; \
4630                                 SORTED_PATCH_SITES_CMD_TMP="${ECHO_CMD} ${_MASTER_SITE_OVERRIDE} `${ECHO_CMD} $${__PATCH_SITES_TMP} | ${AWK} '${MASTER_SORT_AWK:S|\\|\\\\|g}'` ${_MASTER_SITE_BACKUP}" ; \
4631                         else \
4632                                 SORTED_PATCH_SITES_CMD_TMP="${SORTED_PATCH_SITES_DEFAULT_CMD}" ; \
4633                         fi ; \
4634                         for site in `eval $$SORTED_PATCH_SITES_CMD_TMP ${_RANDOMIZE_SITES}`; do \
4635                                 case $${file} in \
4636                                 */*)    args="-o $${file} $${site}$${file}";; \
4637                                 *)              args=$${site}$${file};; \
4638                                 esac; \
4639                                 ${ECHO_CMD} $${args} ; \
4640                         done; \
4641                 fi \
4642          done)
4643 .endif
4644 .endif
4645
4646 .if !target(fetch-urlall-list)
4647 fetch-urlall-list:
4648         @cd ${.CURDIR} && LISTALL=yes ${MAKE} fetch-url-list-int
4649 .endif
4650
4651 .if !target(fetch-url-list)
4652 fetch-url-list:
4653         @cd ${.CURDIR} && ${MAKE} fetch-url-list-int
4654 .endif
4655
4656 # Generates patches.
4657
4658 update-patches:
4659         @toedit=`PATCH_WRKSRC=${PATCH_WRKSRC} \
4660                 PATCHDIR=${PATCHDIR} \
4661                 PATCH_LIST=${PATCHDIR}/patch-* \
4662                 DIFF_ARGS=${DIFF_ARGS} \
4663                 DISTORIG=${DISTORIG} \
4664                 ${SH} ${PORTSDIR}/Tools/scripts/update-patches`; \
4665         case $$toedit in "");; \
4666         *) ${ECHO_CMD} -n 'edit patches: '; read i; \
4667         cd ${PATCHDIR} && $${VISUAL:-$${EDIT:-/usr/bin/vi}} $$toedit;; esac
4668
4669 # Checksumming utilities
4670
4671 check-checksum-algorithms:
4672         @ \
4673         ${checksum_init} \
4674         \
4675         for alg in ${CHECKSUM_ALGORITHMS:tu}; do \
4676                 eval alg_executable=\$$$$alg; \
4677                 if [ -z "$$alg_executable" ]; then \
4678                         ${ECHO_MSG} "Checksum algorithm $$alg: Couldn't find the executable."; \
4679                         ${ECHO_MSG} "Set $$alg=/path/to/$$alg in /etc/make.conf and try again."; \
4680                         exit 1; \
4681                 fi; \
4682         done; \
4683
4684 checksum_init=\
4685         SHA256=${SHA256};
4686
4687 .if !target(makesum)
4688 makesum: check-checksum-algorithms
4689         @cd ${.CURDIR} && ${MAKE} fetch NO_CHECKSUM=yes \
4690                 DISABLE_SIZE=yes
4691         @if [ -f ${DISTINFO_FILE} ]; then ${CAT} /dev/null > ${DISTINFO_FILE}; fi
4692         @( \
4693                 cd ${DISTDIR}; \
4694                 \
4695                 ${checksum_init} \
4696                 \
4697                 for file in ${_CKSUMFILES}; do \
4698                         for alg in ${CHECKSUM_ALGORITHMS:tu}; do \
4699                                 eval alg_executable=\$$$$alg; \
4700                                 \
4701                                 if [ $$alg_executable != "NO" ]; then \
4702                                         $$alg_executable $$file >> ${DISTINFO_FILE}; \
4703                                 fi; \
4704                         done; \
4705                         ${ECHO_CMD} "SIZE ($$file) = `${STAT} -f \"%z\" $$file`" >> ${DISTINFO_FILE}; \
4706                 done \
4707         )
4708         @for file in ${_IGNOREFILES}; do \
4709                 for alg in ${CHECKSUM_ALGORITHMS:tu}; do \
4710                         ${ECHO_CMD} "$$alg ($$file) = IGNORE" >> ${DISTINFO_FILE}; \
4711                 done; \
4712         done
4713 .endif
4714
4715 .if !target(checksum)
4716 checksum: fetch check-checksum-algorithms
4717         @set -e ; \
4718         ${checksum_init} \
4719         if [ -f ${DISTINFO_FILE} ]; then \
4720                 cd ${DISTDIR}; OK="";\
4721                 for file in ${_CKSUMFILES}; do \
4722                         ignored="true"; \
4723                         _file=$${file#${DIST_SUBDIR}/*};        \
4724                         for alg in ${CHECKSUM_ALGORITHMS:tu}; do \
4725                                 ignore="false"; \
4726                                 eval alg_executable=\$$$$alg; \
4727                                 \
4728                                 if [ $$alg_executable != "NO" ]; then \
4729                                         MKSUM=`$$alg_executable < $$file`; \
4730                                         CKSUM=`file=$$_file; ${DISTINFO_DATA}`; \
4731                                 else \
4732                                         ignore="true"; \
4733                                 fi; \
4734                                 \
4735                                 if [ $$ignore = "false" -a -z "$$CKSUM" ]; then \
4736                                         ${ECHO_MSG} "=> No $$alg checksum recorded for $$file."; \
4737                                         ignore="true"; \
4738                                 fi; \
4739                                 \
4740                                 if [ "$$CKSUM" = "IGNORE" ]; then \
4741                                         ${ECHO_MSG} "=> $$alg Checksum for $$file is set to IGNORE in distinfo file even though"; \
4742                                         ${ECHO_MSG} "   the file is not in the "'$$'"{IGNOREFILES} list."; \
4743                                         ignore="true"; \
4744                                         OK=${FALSE}; \
4745                                 fi; \
4746                                 \
4747                                 if [ $$ignore = "false" ]; then \
4748                                         match="false"; \
4749                                         for chksum in $$CKSUM; do \
4750                                                 if [ "$$chksum" = "$$MKSUM" ]; then \
4751                                                         match="true"; \
4752                                                         break; \
4753                                                 fi; \
4754                                         done; \
4755                                         if [ $$match = "true" ]; then \
4756                                                 ${ECHO_MSG} "=> $$alg Checksum OK for $$file."; \
4757                                                 ignored="false"; \
4758                                         else \
4759                                                 ${ECHO_MSG} "=> $$alg Checksum mismatch for $$file."; \
4760                                                 refetchlist="$$refetchlist$$file "; \
4761                                                 OK="$${OK:-retry}"; \
4762                                                 [ "$${OK}" = "retry" -a ${FETCH_REGET} -gt 0 ] && ${RM} -f $${file}; \
4763                                                 ignored="false"; \
4764                                         fi; \
4765                                 fi; \
4766                         done; \
4767                         \
4768                         if [ $$ignored = "true" ]; then \
4769                                 ${ECHO_MSG} "=> No suitable checksum found for $$file."; \
4770                                 OK="${FALSE}"; \
4771                         fi; \
4772                         \
4773                 done; \
4774                 \
4775                 for file in ${_IGNOREFILES}; do \
4776                         _file=$${file#${DIST_SUBDIR}/*};        \
4777                         ignored="true"; \
4778                         alreadymatched="false"; \
4779                         for alg in ${CHECKSUM_ALGORITHMS:tu}; do \
4780                                 ignore="false"; \
4781                                 eval alg_executable=\$$$$alg; \
4782                                 \
4783                                 if [ $$alg_executable != "NO" ]; then \
4784                                         CKSUM=`file=$$_file; ${DISTINFO_DATA}`; \
4785                                 else \
4786                                         ignore="true"; \
4787                                 fi; \
4788                                 \
4789                                 if [ $$ignore = "false" ]; then \
4790                                         if [ -z "$$CKSUM" ]; then \
4791                                                 ${ECHO_MSG} "=> No $$alg checksum for $$file recorded (expected IGNORE)"; \
4792                                                 OK="$$alreadymatched"; \
4793                                         elif [ $$CKSUM != "IGNORE" ]; then \
4794                                                 ${ECHO_MSG} "=> $$alg Checksum for $$file is not set to IGNORE in distinfo file even though"; \
4795                                                 ${ECHO_MSG} "   the file is in the "'$$'"{IGNOREFILES} list."; \
4796                                                 OK="false"; \
4797                                         else \
4798                                                 ignored="false"; \
4799                                                 alreadymatched="true"; \
4800                                         fi; \
4801                                 fi; \
4802                         done; \
4803                         \
4804                         if ( [ $$ignored = "true" ]) ; then \
4805                                 ${ECHO_MSG} "=> No suitable checksum found for $$file."; \
4806                                 OK="false"; \
4807                         fi; \
4808                         \
4809                 done; \
4810                 \
4811                 if [ "$${OK:=true}" = "retry" ] && [ ${FETCH_REGET} -gt 0 ]; then \
4812                         ${ECHO_MSG} "===>  Refetch for ${FETCH_REGET} more times files: $$refetchlist"; \
4813                         if ( cd ${.CURDIR} && \
4814                             ${MAKE} ${.MAKEFLAGS} FORCE_FETCH="$$refetchlist" FETCH_REGET="`${EXPR} ${FETCH_REGET} - 1`" fetch); then \
4815                                   if ( cd ${.CURDIR} && \
4816                                 ${MAKE} ${.MAKEFLAGS} FETCH_REGET="`${EXPR} ${FETCH_REGET} - 1`" checksum ); then \
4817                                       OK="true"; \
4818                                   fi; \
4819                         fi; \
4820                 fi; \
4821                 \
4822                 if [ "$$OK" != "true" -a ${FETCH_REGET} -eq 0 ]; then \
4823                         ${ECHO_MSG} "===>  Giving up on fetching files: $$refetchlist"; \
4824                         ${ECHO_MSG} "Make sure the Makefile and distinfo file (${DISTINFO_FILE})"; \
4825                         ${ECHO_MSG} "are up to date.  If you are absolutely sure you want to override this"; \
4826                         ${ECHO_MSG} "check, type \"make NO_CHECKSUM=yes [other args]\"."; \
4827                         exit 1; \
4828                 fi; \
4829                 if [ "$$OK" != "true" ]; then \
4830                         exit 1; \
4831                 fi; \
4832         elif [ -n "${_CKSUMFILES:M*}" ]; then \
4833                 ${ECHO_MSG} "=> No checksum file (${DISTINFO_FILE})."; \
4834         fi
4835 .endif
4836
4837 ################################################################
4838 # The special package-building targets
4839 # You probably won't need to touch these
4840 ################################################################
4841
4842 # Nobody should want to override this unless PKGNAME is simply bogus.
4843
4844 .if !target(package-name)
4845 package-name:
4846         @${ECHO_CMD} ${PKGNAME}
4847 .endif
4848
4849 # Build a package but don't check the package cookie
4850
4851 .if !target(repackage)
4852 repackage: pre-repackage package
4853
4854 pre-repackage:
4855         @${RM} -f ${PACKAGE_COOKIE}
4856 .endif
4857
4858 # Build a package but don't check the cookie for installation, also don't
4859 # install package cookie
4860
4861 .if !target(package-noinstall)
4862 package-noinstall:
4863 .if defined(NO_STAGE)
4864         @${MKDIR} ${WRKDIR}
4865         @cd ${.CURDIR} && ${MAKE} ${_PACKAGE_REAL_SEQ}
4866         @${RM} -f ${TMPPLIST}
4867         -@${RMDIR} ${WRKDIR}
4868 .else
4869         @cd ${.CURDIR} && ${MAKE} package
4870 .endif
4871 .endif
4872
4873 ################################################################
4874 # Dependency checking
4875 ################################################################
4876
4877 .if !target(depends)
4878 depends: pkg-depends extract-depends patch-depends lib-depends fetch-depends build-depends run-depends
4879
4880 .if defined(ALWAYS_BUILD_DEPENDS)
4881 _DEPEND_ALWAYS= 1
4882 .else
4883 _DEPEND_ALWAYS= 0
4884 .endif
4885
4886 _INSTALL_DEPENDS=       \
4887                 if [ -n "${USE_PACKAGE_DEPENDS}" -o -n "${USE_PACKAGE_DEPENDS_ONLY}" ]; then \
4888                         subpkgfile=`(cd $$dir; ${MAKE} $$depends_args -V '$${PKGFILE}')`; \
4889                         subpkgname=$${subpkgfile%-*} ; \
4890                         subpkgname=$${subpkgname\#\#*/} ; \
4891                         if [ -r "$${subpkgfile}" -a "$$target" = "${DEPENDS_TARGET}" ]; then \
4892                                 ${ECHO_MSG} "===>   Installing existing package $${subpkgfile}"; \
4893                                 if [ -n "${WITH_PKGNG}" -a $${subpkgname} = "pkg" ]; then \
4894                                         [ -d ${WRKDIR} ] || ${MKDIR} ${WRKDIR} ; \
4895                                         ${TAR} -xf $${subpkgfile} -C ${WRKDIR} -s ",/.*/,,g" "*/pkg-static" ; \
4896                                         ${WRKDIR}/pkg-static add $${subpkgfile}; \
4897                                         ${RM} -f ${WRKDIR}/pkg-static; \
4898                                 else \
4899                                         if [ -n "${WITH_PKGNG}" ]; then \
4900                                                 _pkg_add_a="-A"; \
4901                                         fi; \
4902                                         ${PKG_ADD} $${_pkg_add_a} $${subpkgfile}; \
4903                                 fi; \
4904                         elif [ -n "${USE_PACKAGE_DEPENDS_ONLY}" -a "$${target}" = "${DEPENDS_TARGET}" ]; then \
4905                                 ${ECHO_MSG} "===>   ${PKGNAME} depends on package: $${subpkgfile} - not found"; \
4906                                 ${ECHO_MSG} "===>   USE_PACKAGE_DEPENDS_ONLY set - not building missing dependency from source"; \
4907                                 exit 1; \
4908                         else \
4909                           (cd $$dir; ${MAKE} -DINSTALLS_DEPENDS $$target $$depends_args) ; \
4910                         fi; \
4911                 else \
4912                         (cd $$dir; ${MAKE} -DINSTALLS_DEPENDS $$target $$depends_args) ; \
4913                 fi; \
4914                 ${ECHO_MSG} "===>   Returning to build of ${PKGNAME}";
4915
4916 .for deptype in PKG EXTRACT PATCH FETCH BUILD RUN
4917 ${deptype:tl}-depends:
4918 .if defined(${deptype}_DEPENDS)
4919 .if !defined(NO_DEPENDS)
4920         @set -e ; for i in `${ECHO_CMD} "${${deptype}_DEPENDS}"`; do \
4921                 prog=$${i%%:*}; \
4922                 if [ -z "$$prog" ]; then \
4923                         ${ECHO_MSG} "Error: there is an empty port dependency in ${deptype}_DEPENDS."; \
4924                         break; \
4925                 fi; \
4926                 dir=`${ECHO_CMD} $$i | ${SED} -e 's/[^:]*://'`; \
4927                 if ${EXPR} "$$dir" : '.*:' > /dev/null; then \
4928                         target=$${dir##*:}; \
4929                         dir=$${dir%%:*}; \
4930                         if [ X${DEPENDS_PRECLEAN} != "X" ]; then \
4931                                 target="clean $$target"; \
4932                                 depends_args="$$depends_args NOCLEANDEPENDS=yes"; \
4933                         fi; \
4934                         if [ X${DEPENDS_CLEAN} != "X" ]; then \
4935                                 target="$$target clean"; \
4936                                 depends_args="$$depends_args NOCLEANDEPENDS=yes"; \
4937                         fi; \
4938                 else \
4939                         target="${DEPENDS_TARGET}"; \
4940                         depends_args="${DEPENDS_ARGS}"; \
4941                 fi; \
4942                 if ${EXPR} "$$prog" : \\/ >/dev/null; then \
4943                         if [ -e "$$prog" ]; then \
4944                                 if [ "$$prog" = "${NONEXISTENT}" ]; then \
4945                                         ${ECHO_MSG} "Error: ${NONEXISTENT} exists.  Please remove it, and restart the build."; \
4946                                         ${FALSE}; \
4947                                 else \
4948                                         ${ECHO_MSG} "===>   ${PKGNAME} depends on file: $$prog - found"; \
4949                                         if [ ${_DEPEND_ALWAYS} = 1 ]; then \
4950                                                 ${ECHO_MSG} "       (but building it anyway)"; \
4951                                                 notfound=1; \
4952                                         else \
4953                                                 notfound=0; \
4954                                         fi; \
4955                                 fi; \
4956                         else \
4957                                 ${ECHO_MSG} "===>   ${PKGNAME} depends on file: $$prog - not found"; \
4958                                 notfound=1; \
4959                         fi; \
4960                 else \
4961                         case $${prog} in \
4962                                 *\>*|*\<*|*=*)  pkg=yes;; \
4963                                 *)              pkg="";; \
4964                         esac; \
4965                         if [ "$$pkg" != "" ]; then \
4966                                 if ${PKG_INFO} "$$prog" > /dev/null 2>&1 ; then \
4967                                         ${ECHO_MSG} "===>   ${PKGNAME} depends on package: $$prog - found"; \
4968                                         if [ ${_DEPEND_ALWAYS} = 1 ]; then \
4969                                                 ${ECHO_MSG} "       (but building it anyway)"; \
4970                                                 notfound=1; \
4971                                         else \
4972                                                 notfound=0; \
4973                                         fi; \
4974                                 else \
4975                                         ${ECHO_MSG} "===>   ${PKGNAME} depends on package: $$prog - not found"; \
4976                                         notfound=1; \
4977                                 fi; \
4978                                 if [ $$notfound != 0 ]; then \
4979                                         inverse_dep=`${ECHO_CMD} $$prog | ${SED} \
4980                                                 -e 's/<=/=gt=/; s/</=ge=/; s/>=/=lt=/; s/>/=le=/' \
4981                                                 -e 's/=gt=/>/; s/=ge=/>=/; s/=lt=/</; s/=le=/<=/'`; \
4982                                         pkg_info=`${PKG_INFO} -E "$$inverse_dep" || ${TRUE}`; \
4983                                         if [ "$$pkg_info" != "" ]; then \
4984                                                 ${ECHO_MSG} "===>   Found $$pkg_info, but you need to upgrade to $$prog."; \
4985                                                 exit 1; \
4986                                         fi; \
4987                                 fi; \
4988                         elif ${WHICH} "$$prog" > /dev/null 2>&1 ; then \
4989                                 ${ECHO_MSG} "===>   ${PKGNAME} depends on executable: $$prog - found"; \
4990                                 if [ ${_DEPEND_ALWAYS} = 1 ]; then \
4991                                         ${ECHO_MSG} "       (but building it anyway)"; \
4992                                         notfound=1; \
4993                                 else \
4994                                         notfound=0; \
4995                                 fi; \
4996                         else \
4997                                 ${ECHO_MSG} "===>   ${PKGNAME} depends on executable: $$prog - not found"; \
4998                                 notfound=1; \
4999                         fi; \
5000                 fi; \
5001                 if [ $$notfound != 0 ]; then \
5002                         ${ECHO_MSG} "===>    Verifying $$target for $$prog in $$dir"; \
5003                         if [ ! -d "$$dir" ]; then \
5004                                 ${ECHO_MSG} "     => No directory for $$prog.  Skipping.."; \
5005                         else \
5006                                 ${_INSTALL_DEPENDS} \
5007                         fi; \
5008                 fi; \
5009         done
5010 .endif
5011 .else
5012         @${DO_NADA}
5013 .endif
5014 .endfor
5015
5016 lib-depends:
5017 .if defined(LIB_DEPENDS) && !defined(NO_DEPENDS)
5018         @set -e ; \
5019         for i in ${LIB_DEPENDS:M*.so*\:*}; do \
5020                 lib=$${i%%:*} ; \
5021                 dir=$${i#*:}  ; \
5022                 target="${DEPENDS_TARGET}"; \
5023                 depends_args="${DEPENDS_ARGS}"; \
5024                 ${ECHO_MSG}  -n "===>   ${PKGNAME} depends on shared library: $${lib}" ; \
5025                 found=0 ; \
5026                 dirs="${LIB_DIRS} `${CAT} ${LOCALBASE}/libdata/ldconfig/* 2>/dev/null || : `" ; \
5027                 for libdir in $$dirs; do \
5028                         test -f $${libdir}/$${lib} || continue; \
5029                         if [ -x /usr/bin/file ]; then \
5030                                 _LIB_FILE=`realpath $${libdir}/$${lib}`; \
5031                                 [ `file -b -L --mime-type $${_LIB_FILE}` = "application/x-sharedlib" ] || continue ; \
5032                         fi ; \
5033                         found=1 ; \
5034                         ${ECHO_MSG} " - found"; \
5035                 done ; \
5036                 if [ $${found} -eq 0 ]; then \
5037                         ${ECHO_MSG} " - not found"; \
5038                         ${ECHO_MSG} "===>    Verifying for $$lib in $$dir"; \
5039                         if [ ! -d "$$dir" ] ; then \
5040                                 ${ECHO_MSG} "    => No directory for $$lib.  Skipping.."; \
5041                         else \
5042                                 ${_INSTALL_DEPENDS} \
5043                         fi ; \
5044                 fi ; \
5045         done
5046         @set -e ; for i in ${LIB_DEPENDS:N*.so*\:*}; do \
5047                 lib=$${i%%:*}; \
5048                 pattern="`${ECHO_CMD} $$lib | ${SED} -E -e 's/\./\\\\./g' -e 's/(\\\\)?\+/\\\\+/g'`"\
5049                 dir=$${i#*:}; \
5050                 target=$${i##*:}; \
5051                 if ${TEST} $$dir = $$target; then \
5052                         target="${DEPENDS_TARGET}"; \
5053                         depends_args="${DEPENDS_ARGS}"; \
5054                 else \
5055                         dir=$${dir%%:*}; \
5056                 fi; \
5057                 ${ECHO_MSG} -n "===>   ${PKGNAME} depends on shared library: $$lib"; \
5058                 if ${LDCONFIG} ${_LDCONFIG_FLAGS} -r | ${GREP} -vwF -e "${PKGCOMPATDIR}" | ${GREP} -qwE -e "-l$$pattern"; then \
5059                         ${ECHO_MSG} " - found"; \
5060                         if [ ${_DEPEND_ALWAYS} = 1 ]; then \
5061                                 ${ECHO_MSG} "       (but building it anyway)"; \
5062                                 notfound=1; \
5063                         else \
5064                                 notfound=0; \
5065                         fi; \
5066                 else \
5067                         ${ECHO_MSG} " - not found"; \
5068                         notfound=1; \
5069                 fi; \
5070                 if [ $$notfound != 0 ]; then \
5071                         ${ECHO_MSG} "===>    Verifying $$target for $$lib in $$dir"; \
5072                         if [ ! -d "$$dir" ]; then \
5073                                 ${ECHO_MSG} "     => No directory for $$lib.  Skipping.."; \
5074                         else \
5075                                 ${_INSTALL_DEPENDS} \
5076                                 if ! ${LDCONFIG} ${_LDCONFIG_FLAGS} -r | ${GREP} -vwF -e "${PKGCOMPATDIR}" | ${GREP} -qwE -e "-l$$pattern"; then \
5077                                         ${ECHO_MSG} "Error: shared library \"$$lib\" does not exist"; \
5078                                         ${FALSE}; \
5079                                 fi; \
5080                         fi; \
5081                 fi; \
5082         done
5083 .endif
5084
5085 .endif
5086
5087 # Dependency lists: both build and runtime, recursive.  Print out directory names.
5088
5089 _UNIFIED_DEPENDS=${PKG_DEPENDS} ${EXTRACT_DEPENDS} ${PATCH_DEPENDS} ${FETCH_DEPENDS} ${BUILD_DEPENDS} ${LIB_DEPENDS} ${RUN_DEPENDS}
5090 _DEPEND_DIRS=   ${_UNIFIED_DEPENDS:C,^[^:]*:([^:]*).*$,\1,}
5091 _DEPEND_SPECIALS=       ${_UNIFIED_DEPENDS:M*\:*\:*:C,^[^:]*:([^:]*):.*$,\1,}
5092
5093 all-depends-list:
5094         @${ALL-DEPENDS-LIST}
5095
5096 ALL-DEPENDS-LIST= \
5097         L="${_DEPEND_DIRS}";                                            \
5098         checked="";                                                     \
5099         while [ -n "$$L" ]; do                                          \
5100                 l="";                                                   \
5101                 for d in $$L; do                                        \
5102                         case $$checked in                               \
5103                         $$d\ *|*\ $$d\ *|*\ $$d)                        \
5104                                 continue;;                              \
5105                         esac;                                           \
5106                         checked="$$checked $$d";                        \
5107                         if [ ! -d $$d ]; then                           \
5108                                 ${ECHO_MSG} "${PKGNAME}: \"$$d\" non-existent -- dependency list incomplete" >&2; \
5109                                 continue;                               \
5110                         fi;                                             \
5111                         ${ECHO_CMD} $$d;                                \
5112                         if ! children=$$(cd $$d && ${MAKE} -V '$${_DEPEND_DIRS}'); then\
5113                                 ${ECHO_MSG} "${PKGNAME}: \"$$d\" erroneous -- dependency list incomplete" >&2; \
5114                                 continue;                               \
5115                         fi;                                             \
5116                         for child in $$children; do                     \
5117                                 case "$$checked $$l" in                 \
5118                                 $$child\ *|*\ $$child\ *|*\ $$child)    \
5119                                         continue;;                      \
5120                                 esac;                                   \
5121                                 l="$$l $$child";                        \
5122                         done;                                           \
5123                 done;                                                   \
5124                 L=$$l;                                                  \
5125         done
5126
5127 CLEAN-DEPENDS-FULL= \
5128         L="${_DEPEND_DIRS}";                                            \
5129         checked="";                                                     \
5130         while [ -n "$$L" ]; do                                          \
5131                 l="";                                                   \
5132                 for d in $$L; do                                        \
5133                         case $$checked in                               \
5134                         $$d\ *|*\ $$d\ *|*\ $$d)                        \
5135                                 continue;;                              \
5136                         esac;                                           \
5137                         checked="$$checked $$d";                        \
5138                         if [ ! -d $$d ]; then                           \
5139                                 ${ECHO_MSG} "${PKGNAME}: \"$$d\" non-existent -- dependency list incomplete" >&2; \
5140                                 continue;                               \
5141                         fi;                                             \
5142                         if ! children=$$(cd $$d && ${MAKE} -V '$${WRKDIR}' -V '$${_DEPEND_DIRS}'); then \
5143                                 ${ECHO_MSG} "${PKGNAME}: \"$$d\" erroneous -- dependency list incomplete" >&2; \
5144                                 continue;                               \
5145                         fi;                                             \
5146                         state=0;                                        \
5147                         for child in $$children; do                     \
5148                                 case $$state in                         \
5149                                 0)                                      \
5150                                         if [ -d $$child ]; then         \
5151                                                 ${ECHO_CMD} $$d;        \
5152                                         fi;                             \
5153                                         state=1;;                       \
5154                                 1)                                      \
5155                                         case "$$checked $$l" in         \
5156                                         $$child\ *|*\ $$child\ *|*\ $$child) \
5157                                                 continue;;              \
5158                                         esac;                           \
5159                                         l="$$l $$child";;               \
5160                                 esac;                                   \
5161                         done;                                           \
5162                 done;                                                   \
5163                 L=$$l;                                                  \
5164         done
5165
5166 CLEAN-DEPENDS-LIMITED= \
5167         L="${_DEPEND_DIRS}";                                            \
5168         checked="";                                                     \
5169         while [ -n "$$L" ]; do                                          \
5170                 l="";                                                   \
5171                 for d in $$L; do                                        \
5172                         case $$checked in                               \
5173                         $$d\ *|*\ $$d\ *|*\ $$d)                        \
5174                                 continue;;                              \
5175                         esac;                                           \
5176                         checked="$$checked $$d";                        \
5177                         if [ ! -d $$d ]; then                           \
5178                                 ${ECHO_MSG} "${PKGNAME}: \"$$d\" non-existent -- dependency list incomplete" >&2; \
5179                                 continue;                               \
5180                         fi;                                             \
5181                         if ! children=$$(cd $$d && ${MAKE} -V '$${WRKDIR}' -V '$${_DEPEND_DIRS}'); then \
5182                                 ${ECHO_MSG} "${PKGNAME}: \"$$d\" erroneous -- dependency list incomplete" >&2; \
5183                                 continue;                               \
5184                         fi;                                             \
5185                         state=0;                                        \
5186                         for child in $$children; do                     \
5187                                 case $$state in                         \
5188                                 0)                                      \
5189                                         if [ ! -d $$child ]; then       \
5190                                                 break;          \
5191                                         fi;                             \
5192                                         state=1;                        \
5193                                         ${ECHO_CMD} $$d;;               \
5194                                 1)                                      \
5195                                         case "$$checked $$l" in         \
5196                                         $$child\ *|*\ $$child\ *|*\ $$child) \
5197                                                 continue;;              \
5198                                         esac;                           \
5199                                         l="$$l $$child";;               \
5200                                 esac;                                   \
5201                         done;                                           \
5202                 done;                                                   \
5203                 L=$$l;                                                  \
5204         done
5205
5206 .if !target(clean-depends)
5207 clean-depends:
5208         @for dir in $$(${CLEAN-DEPENDS-FULL}); do \
5209                 (cd $$dir; ${MAKE} NOCLEANDEPENDS=yes clean); \
5210         done
5211 .endif
5212
5213 .if !target(limited-clean-depends)
5214 limited-clean-depends:
5215         @for dir in $$(${CLEAN-DEPENDS-LIMITED}); do \
5216                 (cd $$dir; ${MAKE} NOCLEANDEPENDS=yes clean); \
5217         done
5218 .endif
5219
5220 .if !target(deinstall-depends)
5221 deinstall-depends:
5222         @for dir in $$(${ALL-DEPENDS-LIST}); do \
5223                 (cd $$dir; ${MAKE} deinstall); \
5224         done
5225 .endif
5226
5227 .if !target(fetch-specials)
5228 fetch-specials:
5229         @${ECHO_MSG} "===> Fetching all distfiles required by ${PKGNAME} for building"
5230         @for dir in ${_DEPEND_SPECIALS}; do \
5231                 (cd $$dir; ${MAKE} fetch); \
5232         done
5233 .endif
5234
5235 .if !target(fetch-recursive)
5236 fetch-recursive:
5237         @${ECHO_MSG} "===> Fetching all distfiles for ${PKGNAME} and dependencies"
5238         @for dir in ${.CURDIR} $$(${ALL-DEPENDS-LIST}); do \
5239                 (cd $$dir; ${MAKE} fetch); \
5240         done
5241 .endif
5242
5243 .if !target(fetch-recursive-list)
5244 fetch-recursive-list:
5245         @for dir in ${.CURDIR} $$(${ALL-DEPENDS-LIST}); do \
5246                 (cd $$dir; ${MAKE} fetch-list); \
5247         done
5248 .endif
5249
5250 # Used by fetch-required and fetch-required list, this script looks
5251 # at each of the dependencies. If 3 items are specified in the tuple,
5252 # such as foo:${PORTSDIR}/graphics/foo:extract, the first item (foo)
5253 # is examined. Only if it begins with a / and does not exist on the
5254 # file-system will ``make targ'' proceed.
5255 # For more usual (dual-item) dependency tuples, the ``make targ''
5256 # proceeds, if the exact package, which the directory WOULD'VE installed,
5257 # is not yet installed.
5258 # This is the exact behaviour of the old code, and it may need
5259 # revisiting. For example, the entire first case seems dubious, and in
5260 # the second case we, probably, should be satisfied with _any_ (earlier)
5261 # package, with the same origin as that of the dir.
5262 #
5263 #       -mi
5264 FETCH_LIST?=    for i in $$deps; do \
5265                 prog=$${i%%:*}; dir=$${i\#*:}; \
5266                 case $$dir in   \
5267                 *:*) if [ $$prog != $${prog\#/} -o ! -e $$prog ]; then  \
5268                                 dir=$${dir%%:*};        \
5269                         else    \
5270                                 continue;       \
5271                         fi;;    \
5272                 *) if [ -d ${PKG_DBDIR}/$$(cd $$dir; ${MAKE} -V '$${PKGNAME}') ]; then \
5273                                 continue;       \
5274                         fi;;    \
5275                 esac;   \
5276                 echo cd $$dir; cd $$dir; ${MAKE} $$targ; \
5277         done
5278
5279 .if !target(fetch-required)
5280 fetch-required: fetch
5281 .if defined(NO_DEPENDS)
5282         @${ECHO_MSG} "===> NO_DEPENDS is set, not fetching any other distfiles for ${PKGNAME}"
5283 .else
5284         @${ECHO_MSG} "===> Fetching all required distfiles for ${PKGNAME} and dependencies"
5285 .for deptype in PKG EXTRACT PATCH FETCH BUILD RUN
5286 .if defined(${deptype}_DEPENDS)
5287         @targ=fetch; deps="${${deptype}_DEPENDS}"; ${FETCH_LIST}
5288 .endif
5289 .endfor
5290 .endif
5291
5292 .endif
5293
5294 .if !target(fetch-required-list)
5295 fetch-required-list: fetch-list
5296 .if !defined(NO_DEPENDS)
5297 .for deptype in PKG EXTRACT PATCH FETCH BUILD RUN
5298 .if defined(${deptype}_DEPENDS)
5299         @targ=fetch-list; deps="${${deptype}_DEPENDS}"; ${FETCH_LIST}
5300 .endif
5301 .endfor
5302 .endif
5303 .endif
5304
5305 .if !target(checksum-recursive)
5306 checksum-recursive:
5307         @${ECHO_MSG} "===> Fetching and checking checksums for ${PKGNAME} and dependencies"
5308         @for dir in ${.CURDIR} $$(${ALL-DEPENDS-LIST}); do \
5309                 (cd $$dir; ${MAKE} checksum); \
5310         done
5311 .endif
5312
5313 # Dependency lists: build and runtime.  Print out directory names.
5314
5315 build-depends-list:
5316 .if defined(PKG_DEPENDS) || defined(EXTRACT_DEPENDS) || defined(PATCH_DEPENDS) || defined(FETCH_DEPENDS) || defined(BUILD_DEPENDS) || defined(LIB_DEPENDS)
5317         @${BUILD-DEPENDS-LIST}
5318 .endif
5319
5320 BUILD-DEPENDS-LIST= \
5321         for dir in $$(${ECHO_CMD} "${PKG_DEPENDS} ${EXTRACT_DEPENDS} ${PATCH_DEPENDS} ${FETCH_DEPENDS} ${BUILD_DEPENDS} ${LIB_DEPENDS}" | ${SED} -E -e 's,([^: ]*):([^: ]*)(:[^ ]*)?,\2,g' -e 'y/ /\n/'| ${SORT} -u); do \
5322                 if [ -d $$dir ]; then \
5323                         ${ECHO_CMD} $$dir; \
5324                 else \
5325                         ${ECHO_MSG} "${PKGNAME}: \"$$dir\" non-existent -- dependency list incomplete" >&2; \
5326                 fi; \
5327         done | ${SORT} -u
5328
5329 run-depends-list:
5330 .if defined(LIB_DEPENDS) || defined(RUN_DEPENDS)
5331         @${RUN-DEPENDS-LIST}
5332 .endif
5333
5334 RUN-DEPENDS-LIST= \
5335         for dir in $$(${ECHO_CMD} "${_LIB_RUN_DEPENDS:C,.*:([^:]*).*,\1,}" | ${SED} -e 'y/ /\n/' | ${SORT} -u); do \
5336                 if [ -d $$dir ]; then \
5337                         ${ECHO_CMD} $$dir; \
5338                 else \
5339                         ${ECHO_MSG} "${PKGNAME}: \"$$dir\" non-existent -- dependency list incomplete" >&2; \
5340                 fi; \
5341         done | ${SORT} -u
5342
5343 # Package (recursive runtime) dependency list.  Print out both directory names
5344 # and package names.
5345
5346 package-depends-list:
5347 .if defined(CHILD_DEPENDS) || defined(LIB_DEPENDS) || defined(RUN_DEPENDS)
5348         @${PACKAGE-DEPENDS-LIST}
5349 .endif
5350
5351 _LIB_RUN_DEPENDS=       ${LIB_DEPENDS} ${RUN_DEPENDS}
5352 PACKAGE-DEPENDS-LIST?= \
5353         if [ "${CHILD_DEPENDS}" ]; then \
5354                 installed=$$(${PKG_INFO} -qO ${PKGORIGIN} 2>/dev/null || \
5355                         ${TRUE}); \
5356                 if [ "$$installed" ]; then \
5357                         break; \
5358                 fi; \
5359                 if [ -z "$$installed" ]; then \
5360                         installed="${PKGNAME}"; \
5361                 fi; \
5362                 for pkgname in $$installed; do \
5363                         ${ECHO_CMD} "$$pkgname ${.CURDIR} ${PKGORIGIN}"; \
5364                 done; \
5365         fi; \
5366         checked="${PARENT_CHECKED}"; \
5367         for dir in ${_LIB_RUN_DEPENDS:C,[^:]*:([^:]*):?.*,\1,}; do \
5368                 dir=$$(${REALPATH} $$dir); \
5369                 if [ -d $$dir ]; then \
5370                         case $$checked in       \
5371                         $$dir|$$dir\ *|*\ $$dir|*\ $$dir\ *) continue;; \
5372                         esac;   \
5373                         childout=$$(cd $$dir; ${MAKE} CHILD_DEPENDS=yes PARENT_CHECKED="$$checked" package-depends-list); \
5374                         set -- $$childout; \
5375                         childdir=""; \
5376                         while [ $$\# != 0 ]; do \
5377                                 childdir="$$childdir $$2"; \
5378                                 ${ECHO_CMD} "$$1 $$2 $$3"; \
5379                                 shift 3; \
5380                         done; \
5381                         checked="$$dir $$childdir $$checked"; \
5382                 else \
5383                         ${ECHO_MSG} "${PKGNAME}: \"$$dir\" non-existent -- dependency list incomplete" >&2; \
5384                 fi; \
5385         done
5386
5387 ACTUAL-PACKAGE-DEPENDS?= \
5388         if [ "${_LIB_RUN_DEPENDS}" != "  " ]; then \
5389                 origins=$$(for pkgname in ${PKG_DBDIR}/*; do \
5390                         if [ -e $$pkgname/+CONTENTS ]; then \
5391                                 ${ECHO_CMD} $${pkgname\#\#*/}; \
5392                                 ${SED} -n -e "s/@comment ORIGIN://p" $$pkgname/+CONTENTS; \
5393                         fi; \
5394                 done); \
5395                 for dir in ${_LIB_RUN_DEPENDS:C,[^:]*:([^:]*):?.*,\1,}; do \
5396                         tmp=$${dir\#${PORTSDIR}/}; \
5397                         if [ "$$tmp" = "$$dir" ]; then \
5398                                 tmp=$${dir%/*}; \
5399                                 dir=$${tmp\#\#*/}/$${dir\#\#*/}; \
5400                         else \
5401                                 dir=$$tmp; \
5402                         fi; \
5403                         set -- $$origins; \
5404                         while [ $$\# -gt 1 ]; do \
5405                                 if [ ! -d "${PORTSDIR}/$$2" ]; then \
5406                                         shift; \
5407                                         continue; \
5408                                 fi; \
5409                                 if [ "$$dir" = "$$2" ]; then \
5410                                         ${ECHO_CMD} $$1:$$dir; \
5411                                         if [ -e ${PKG_DBDIR}/$$1/+CONTENTS -a -z "${EXPLICIT_PACKAGE_DEPENDS}" ]; then \
5412                                                 packagelist="$$packagelist ${PKG_DBDIR}/$$1/+CONTENTS"; \
5413                                         fi; \
5414                                         break; \
5415                                 fi; \
5416                                 shift 2; \
5417                         done; \
5418                 done; \
5419                 [ -z "$$packagelist" ] || ${AWK} -F '( |:)' 'BEGIN { pkgname="broken_contents" } /@pkgdep / { pkgname=$$2 } /@comment DEPORIGIN:/ { printf "%s:%s\n", pkgname, $$3; pkgname="broken_contents" }' $$packagelist; \
5420         fi
5421
5422 # Print out package names.
5423
5424 package-depends:
5425         @${PACKAGE-DEPENDS-LIST} | ${AWK} '{print $$1":"$$3}'
5426
5427 actual-package-depends:
5428         @${ACTUAL-PACKAGE-DEPENDS}
5429
5430 # Build packages for port and dependencies
5431
5432 package-recursive: package
5433         @for dir in $$(${ALL-DEPENDS-LIST}); do \
5434                 (cd $$dir; ${MAKE} package-noinstall); \
5435         done
5436
5437 # Show missing dependencies
5438 missing:
5439         @_origins=$$(${PKG_INFO} -aoq); \
5440         for dir in $$(${ALL-DEPENDS-LIST}); do \
5441                 _origin=$${dir##${PORTSDIR}/}; \
5442                 if ! $$(${ECHO_CMD} $${_origins} | ${GREP} -q $${_origin}); then \
5443                         ${ECHO_CMD} $${_origin}; \
5444                 fi; \
5445         done
5446
5447 ################################################################
5448 # Everything after here are internal targets and really
5449 # shouldn't be touched by anybody but the release engineers.
5450 ################################################################
5451
5452 # This target generates an index entry suitable for aggregation into
5453 # a large index.  Format is:
5454 #
5455 # distribution-name|port-path|installation-prefix|comment| \
5456 #  description-file|maintainer|categories|extract-depends| \
5457 #  patch-depends|fetch-depends|build-depends|run-depends|www site
5458 #
5459 # If this ever changes, portmgr should contact the portsnap maintainer
5460 # first to avoid gratuitous breakage.
5461
5462 . if !target(describe)
5463 _EXTRACT_DEPENDS=${EXTRACT_DEPENDS:C/^[^ :]+:([^ :]+)(:[^ :]+)?/\1/:O:u}
5464 _PATCH_DEPENDS=${PATCH_DEPENDS:C/^[^ :]+:([^ :]+)(:[^ :]+)?/\1/:O:u}
5465 _FETCH_DEPENDS=${FETCH_DEPENDS:C/^[^ :]+:([^ :]+)(:[^ :]+)?/\1/:O:u}
5466 _LIB_DEPENDS=${LIB_DEPENDS:C/^[^ :]+:([^ :]+)(:[^ :]+)?/\1/:O:u}
5467 _BUILD_DEPENDS=${BUILD_DEPENDS:C/^[^ :]+:([^ :]+)(:[^ :]+)?/\1/:O:u} ${_LIB_DEPENDS}
5468 _RUN_DEPENDS=${RUN_DEPENDS:C/^[^ :]+:([^ :]+)(:[^ :]+)?/\1/:O:u} ${_LIB_DEPENDS}
5469 . if exists(${DESCR})
5470 _DESCR=${DESCR}
5471 . else
5472 _DESCR=/dev/null
5473 . endif
5474
5475 .  if defined(BUILDING_INDEX) && defined(INDEX_PORTS)
5476 INDEX_OUT=${INDEX_TMPDIR}/${INDEXFILE}.desc.aggr
5477 .  else
5478 INDEX_OUT=/dev/stdout
5479 .  endif
5480
5481 describe:
5482         @(${ECHO_CMD} -n "${PKGNAME}|${.CURDIR}|${PREFIX}|"; \
5483         ${ECHO_CMD} -n ${COMMENT:Q}; \
5484         ${ECHO_CMD} -n "|${_DESCR}|${MAINTAINER}|${CATEGORIES}|${_EXTRACT_DEPENDS}|${_PATCH_DEPENDS}|${_FETCH_DEPENDS}|${_BUILD_DEPENDS:O:u}|${_RUN_DEPENDS:O:u}|"; \
5485         while read one two discard; do \
5486                 case "$$one" in \
5487                 WWW:)   case "$$two" in \
5488                         https://*|http://*|ftp://*) ${ECHO_CMD} -n "$$two" ;; \
5489                         *) ${ECHO_CMD} -n "http://$$two" ;; \
5490                         esac; \
5491                         break; \
5492                         ;; \
5493                 esac; \
5494         done < ${DESCR}; ${ECHO_CMD}) >>${INDEX_OUT}
5495 . endif
5496
5497 www-site:
5498 .if exists(${DESCR})
5499         @${AWK} '$$1 ~ /^WWW:/ {print $$2}' ${DESCR} | ${HEAD} -1
5500 .else
5501         @${ECHO_CMD}
5502 .endif
5503
5504 .if !target(readmes)
5505 readmes:        readme
5506 .endif
5507
5508 .if !target(readme)
5509 readme:
5510         @${RM} -f ${.CURDIR}/README.html
5511         @cd ${.CURDIR} && ${MAKE} ${.CURDIR}/README.html
5512 .endif
5513
5514 ${.CURDIR}/README.html:
5515         @${ECHO_MSG} "===>   Creating README.html for ${PKGNAME}"
5516         @${SED} -e 's|%%PORT%%|'$$(${ECHO_CMD} ${.CURDIR} | \
5517                                                           ${SED} -e 's|.*/\([^/]*/[^/]*\)$$|\1|')'|g' \
5518                         -e 's|%%PKG%%|${PKGNAME}|g' \
5519                         -e 's|%%COMMENT%%|'"$$(${ECHO_CMD} ${COMMENT:Q})"'|' \
5520                         -e '/%%COMMENT%%/d' \
5521                         -e 's|%%DESCR%%|'"$$(${ECHO_CMD} ${DESCR} | \
5522                                                                  ${SED} -e 's|${.CURDIR}/||')"'|' \
5523                         -e 's|%%EMAIL%%|'"$$(${ECHO_CMD} "${MAINTAINER}" | \
5524                                                                  ${SED} -e 's/([^)]*)//;s/.*<//;s/>.*//')"'|g' \
5525                         -e 's|%%MAINTAINER%%|${MAINTAINER}|g' \
5526                         -e 's|%%WEBSITE%%|'"$$(cd ${.CURDIR} && eval ${MAKE} pretty-print-www-site)"'|' \
5527                         -e 's|%%BUILD_DEPENDS%%|'"$$(cd ${.CURDIR} && eval ${MAKE} pretty-print-build-depends-list)"'|' \
5528                         -e 's|%%RUN_DEPENDS%%|'"$$(cd ${.CURDIR} && eval ${MAKE} pretty-print-run-depends-list)"'|' \
5529                         -e 's|%%TOP%%|'"$$(${ECHO_CMD} ${CATEGORIES} | \
5530                                                            ${SED} -e 's| .*||' -e 's|[^/]*|..|g')"'/..|' \
5531                 ${TEMPLATES}/README.port >> ${.TARGET}
5532
5533 # The following two targets require an up-to-date INDEX in ${PORTSDIR}
5534
5535 _PRETTY_PRINT_DEPENDS_LIST=\
5536         if [ ! -r ${INDEXDIR}/${INDEXFILE} ] ; then \
5537                 ${ECHO_MSG} "${.TARGET} requires an INDEX file (${INDEXFILE}). Please run make index or make fetchindex."; \
5538         else \
5539                 target=${.TARGET:C/pretty-print-(.*)-depends-list/\1/} ; \
5540                 if [ "$$target" = "build" ] ; then fldnum=8 ; else fldnum=9 ; fi; \
5541                 ${ECHO_MSG} -n 'This port requires package(s) "' ; \
5542                 ${ECHO_MSG} -n `${AWK} -F\| "\\$$1 ~ /^${PKGNAME}/ {print \\$$$${fldnum};}" ${INDEXDIR}/${INDEXFILE}` ; \
5543                 ${ECHO_MSG} "\" to $$target."; \
5544         fi;
5545
5546
5547 .if !target(pretty-print-build-depends-list)
5548 pretty-print-build-depends-list:
5549 .if defined(PKG_DEPENDS) || defined(EXTRACT_DEPENDS) || defined(PATCH_DEPENDS) || \
5550         defined(FETCH_DEPENDS) || defined(BUILD_DEPENDS) || defined(LIB_DEPENDS)
5551         @${_PRETTY_PRINT_DEPENDS_LIST}
5552 .endif
5553 .endif
5554
5555 .if !target(pretty-print-run-depends-list)
5556 pretty-print-run-depends-list:
5557 .if defined(RUN_DEPENDS) || defined(LIB_DEPENDS)
5558         @${_PRETTY_PRINT_DEPENDS_LIST}
5559 .endif
5560 .endif
5561
5562 _SUB_LIST_TEMP= ${SUB_LIST:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/}
5563 .if !target(apply-slist)
5564 apply-slist:
5565 .if defined(SUB_FILES)
5566 .for file in ${SUB_FILES}
5567 .if exists(${FILESDIR}/${file}.in)
5568         @${SED} ${_SUB_LIST_TEMP} -e '/^@comment /d' ${FILESDIR}/${file}.in > ${WRKDIR}/${file}
5569 .elif exists(${DFLY_FILESDIR}/${file}.in)
5570         @${SED} ${_SUB_LIST_TEMP} -e '/^@comment /d' ${DFLY_FILESDIR}/${file}.in > ${WRKDIR}/${file}
5571 .else
5572         @${ECHO_MSG} "** Checked ${FILESDIR}:"; \
5573         @${ECHO_MSG} "** Checked ${DFLY_FILESDIR}:"; \
5574         @${ECHO_MSG} "** Missing ${file}.in for ${PKGNAME}."; \
5575         exit 1
5576 .endif
5577 .endfor
5578 .for i in pkg-message pkg-install pkg-deinstall pkg-req
5579 .if ${SUB_FILES:M${i}*}!=""
5580 ${i:S/-//:tu}=  ${WRKDIR}/${SUB_FILES:M${i}*}
5581 .endif
5582 .endfor
5583 .endif
5584 .endif
5585
5586 # Generate packing list.  Also tests to make sure all required package
5587 # files exist.
5588
5589 .if !target(generate-plist)
5590 generate-plist:
5591         @${ECHO_MSG} "===>   Generating temporary packing list"
5592         @${MKDIR} `${DIRNAME} ${TMPPLIST}`
5593         @if [ ! -f ${DESCR} ]; then ${ECHO_MSG} "** Missing pkg-descr for ${PKGNAME}."; exit 1; fi
5594 .if defined(NO_STAGE) || defined(NEED_ROOT)
5595         @>${TMPPLIST}
5596 .else
5597         @${ECHO_CMD} -e "@owner root\n@group wheel" >${TMPPLIST}
5598 .endif
5599         @for file in ${PLIST_FILES}; do \
5600                 ${ECHO_CMD} $${file} | ${SED} ${PLIST_SUB:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/} >> ${TMPPLIST}; \
5601         done
5602 .if defined(NO_STAGE)
5603         @for man in ${__MANPAGES}; do \
5604                 ${ECHO_CMD} $${man} >> ${TMPPLIST}; \
5605         done
5606 .for _PREFIX in ${PREFIX}
5607 .if ${_TMLINKS:M${_PREFIX}*}x != x
5608         @for i in ${_TMLINKS:M${_PREFIX}*:S|^${_PREFIX}/||}; do \
5609                 ${ECHO_CMD} "$$i" >> ${TMPPLIST}; \
5610         done
5611 .endif
5612 .if ${_TMLINKS:N${_PREFIX}*}x != x
5613         @${ECHO_CMD} @cwd / >> ${TMPPLIST}
5614         @for i in ${_TMLINKS:N${_PREFIX}*:S|^/||}; do \
5615                 ${ECHO_CMD} "$$i" >> ${TMPPLIST}; \
5616         done
5617         @${ECHO_CMD} '@cwd ${PREFIX}' >> ${TMPPLIST}
5618 .endif
5619 .endfor
5620 .endif
5621         @if [ -f ${PLIST} ]; then \
5622                 ${SED} ${PLIST_SUB:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/} ${PLIST} >> ${TMPPLIST}; \
5623         fi
5624
5625 .for dir in ${PLIST_DIRS}
5626         @${ECHO_CMD} ${dir} | ${SED} ${PLIST_SUB:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/} -e 's,^,@dirrm ,' >> ${TMPPLIST}
5627 .endfor
5628 .for dir in ${PLIST_DIRSTRY}
5629         @${ECHO_CMD} ${dir} | ${SED} ${PLIST_SUB:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/} -e 's,^,@dirrmtry ,' >> ${TMPPLIST}
5630 .endfor
5631
5632 .for reinplace in ${PLIST_REINPLACE}
5633 .if defined(PLIST_REINPLACE_${reinplace:tu})
5634         @${SED} -i "" -e '${PLIST_REINPLACE_${reinplace:tu}}' ${TMPPLIST}
5635 .endif
5636 .endfor
5637
5638 .if defined(USE_LINUX_PREFIX)
5639 .if defined(USE_LDCONFIG)
5640         @${ECHO_CMD} "@exec ${LDCONFIG_CMD}" >> ${TMPPLIST}
5641         @${ECHO_CMD} "@unexec ${LDCONFIG_CMD}" >> ${TMPPLIST}
5642 .endif
5643 .else
5644 .if defined(USE_LDCONFIG)
5645 .if !defined(INSTALL_AS_USER)
5646         @${ECHO_CMD} "@exec ${LDCONFIG} -m ${USE_LDCONFIG}" >> ${TMPPLIST}
5647         @${ECHO_CMD} "@unexec ${LDCONFIG} -R" >> ${TMPPLIST}
5648 .else
5649         @${ECHO_CMD} "@exec ${LDCONFIG} -m ${USE_LDCONFIG} || ${TRUE}" >> ${TMPPLIST}
5650         @${ECHO_CMD} "@unexec ${LDCONFIG} -R || ${TRUE}" >> ${TMPPLIST}
5651 .endif
5652 .endif
5653 .if defined(USE_LDCONFIG32)
5654 .if !defined(INSTALL_AS_USER)
5655         @${ECHO_CMD} "@exec ${LDCONFIG} -32 -m ${USE_LDCONFIG32}" >> ${TMPPLIST}
5656         @${ECHO_CMD} "@unexec ${LDCONFIG} -32 -R" >> ${TMPPLIST}
5657 .else
5658         @${ECHO_CMD} "@exec ${LDCONFIG} -32 -m ${USE_LDCONFIG32} || ${TRUE}" >> ${TMPPLIST}
5659         @${ECHO_CMD} "@unexec ${LDCONFIG} -32 -R || ${TRUE}" >> ${TMPPLIST}
5660 .endif
5661 .endif
5662 .endif
5663 .if !defined(WITH_PKGNG)
5664         @cd ${.CURDIR} && { ${MAKE} pretty-print-config | fold -sw 120 | ${SED} -e 's/^/@comment OPTIONS:/'; } >> ${TMPPLIST}
5665         @${AWK} -f ${KEYWORDS}/pkg_install.awk ${TMPPLIST} > ${TMPPLIST}.keyword && \
5666             ${MV} -f ${TMPPLIST}.keyword ${TMPPLIST}
5667 .endif
5668 .endif
5669
5670 ${TMPPLIST}:
5671         @cd ${.CURDIR} && ${MAKE} generate-plist
5672
5673 ${TMPPLIST_SORT}: ${TMPPLIST}
5674         @${SORT} -u ${TMPPLIST} >${TMPPLIST_SORT}
5675
5676 .if !target(add-plist-docs)
5677 .if defined(PORTDOCS) && !defined(NOPORTDOCS)
5678 add-plist-docs:
5679         @if ${EGREP} -qe '^@cw?d' ${TMPPLIST} && \
5680                 [ "`${SED} -En -e '/^@cw?d[     ]*/s,,,p' ${TMPPLIST} | ${TAIL} -n 1`" != "${PREFIX}" ]; then \
5681                 ${ECHO_CMD} "@cwd ${PREFIX}" >> ${TMPPLIST}; \
5682         fi
5683 .for x in ${PORTDOCS}
5684         @if ${ECHO_CMD} "${x}"| ${AWK} '$$1 ~ /(\*|\||\[|\]|\?|\{|\}|\$$)/ { exit 1};'; then \
5685                 if [ ! -e ${STAGEDIR}${DOCSDIR}/${x} ]; then \
5686                 ${ECHO_CMD} ${DOCSDIR_REL}/${x} >> ${TMPPLIST}; \
5687         fi;fi
5688 .endfor
5689         @${FIND} -P ${PORTDOCS:S/^/${STAGEDIR}${DOCSDIR}\//} ! -type d 2>/dev/null | \
5690                 ${SED} -ne 's,^${STAGEDIR}${PREFIX}/,,p' >> ${TMPPLIST}
5691         @${FIND} -P -d ${PORTDOCS:S/^/${STAGEDIR}${DOCSDIR}\//} -type d 2>/dev/null | \
5692                 ${SED} -ne 's,^${STAGEDIR}${PREFIX}/,@dirrm ,p' >> ${TMPPLIST}
5693         @${ECHO_CMD} "@dirrm ${DOCSDIR_REL}" >> ${TMPPLIST}
5694 .endif
5695 .endif
5696
5697 .if !target(add-plist-examples)
5698 .if defined(PORTEXAMPLES) && !defined(NOPORTEXAMPLES)
5699 add-plist-examples:
5700         @if ${EGREP} -qe '^@cw?d' ${TMPPLIST} && \
5701                 [ "`${SED} -En -e '/^@cw?d[     ]*/s,,,p' ${TMPPLIST} | ${TAIL} -n 1`" != "${PREFIX}" ]; then \
5702                 ${ECHO_CMD} "@cwd ${PREFIX}" >> ${TMPPLIST}; \
5703         fi
5704 .for x in ${PORTEXAMPLES}
5705         @if ${ECHO_CMD} "${x}"| ${AWK} '$$1 ~ /(\*|\||\[|\]|\?|\{|\}|\$$)/ { exit 1};'; then \
5706                 if [ ! -e ${STAGEDIR}${EXAMPLESDIR}/${x} ]; then \
5707                 ${ECHO_CMD} ${EXAMPLESDIR}/${x} | \
5708                         ${SED} -e 's,^${PREFIX}/,,' >> ${TMPPLIST}; \
5709         fi;fi
5710 .endfor
5711         @${FIND} -P ${PORTEXAMPLES:S/^/${STAGEDIR}${EXAMPLESDIR}\//} ! -type d 2>/dev/null | \
5712                 ${SED} -ne 's,^${STAGEDIR}${PREFIX}/,,p' >> ${TMPPLIST}
5713         @${FIND} -P -d ${PORTEXAMPLES:S/^/${STAGEDIR}${EXAMPLESDIR}\//} -type d 2>/dev/null | \
5714                 ${SED} -ne 's,^${STAGEDIR}${PREFIX}/,@dirrm ,p' >> ${TMPPLIST}
5715         @${ECHO_CMD} "@dirrm ${EXAMPLESDIR_REL}" >> ${TMPPLIST}
5716 .endif
5717 .endif
5718
5719 .if !target(add-plist-data)
5720 .if defined(PORTDATA) && !defined(NOPORTDATA)
5721 add-plist-data:
5722         @if ${EGREP} -qe '^@cw?d' ${TMPPLIST} && \
5723                 [ "`${SED} -En -e '/^@cw?d[     ]*/s,,,p' ${TMPPLIST} | ${TAIL} -n 1`" != "${PREFIX}" ]; then \
5724                 ${ECHO_CMD} "@cwd ${PREFIX}" >> ${TMPPLIST}; \
5725         fi
5726 .for x in ${PORTDATA}
5727         @if ${ECHO_CMD} "${x}"| ${AWK} '$$1 ~ /(\*|\||\[|\]|\?|\{|\}|\$$)/ { exit 1};'; then \
5728                 if [ ! -e ${STAGEDIR}${DATADIR}/${x} ]; then \
5729                 ${ECHO_CMD} ${DATADIR}/${x} | \
5730                         ${SED} -e 's,^${PREFIX}/,,' >> ${TMPPLIST}; \
5731         fi;fi
5732 .endfor
5733         @${FIND} -P ${PORTDATA:S/^/${STAGEDIR}${DATADIR}\//} ! -type d 2>/dev/null | \
5734                 ${SED} -ne 's,^${STAGEDIR}${PREFIX}/,,p' >> ${TMPPLIST}
5735         @${FIND} -P -d ${PORTDATA:S/^/${STAGEDIR}${DATADIR}\//} -type d 2>/dev/null | \
5736                 ${SED} -ne 's,^${STAGEDIR}${PREFIX}/,@dirrm ,p' >> ${TMPPLIST}
5737         @${ECHO_CMD} "@dirrm ${DATADIR_REL}" >> ${TMPPLIST}
5738 .endif
5739 .endif
5740
5741 .if !target(add-plist-buildinfo)
5742 add-plist-buildinfo:
5743 .if defined(PACKAGE_BUILDING)
5744         @${ECHO_CMD} "@comment Build details:  ${BUILDHOST}|${JAIL}|${BUILD}|${PORTSTREE}|${BUILDDATE}" >> ${TMPPLIST}
5745 .endif
5746 .endif
5747
5748 .if !target(add-plist-info)
5749 .if defined(INFO)
5750 add-plist-info:
5751 # Process GNU INFO files at package install/deinstall time
5752 .for i in ${INFO}
5753 .if defined(NO_STAGE)
5754         install-info --quiet ${PREFIX}/${INFO_PATH}/$i.info ${PREFIX}/${INFO_PATH}/dir
5755 .endif
5756 .if !defined(WITH_PKGNG)
5757         @${ECHO_CMD} "@unexec install-info --quiet --delete %D/${INFO_PATH}/$i.info %D/${INFO_PATH}/dir" \
5758                 >> ${TMPPLIST}
5759         @${ECHO_CMD} "@unexec [ \`info -d %D/${INFO_PATH}  --output - 2>/dev/null | grep -c '^*'\` -eq 1 ] && rm -f %D/${INFO_PATH}/dir || :"\
5760                 >> ${TMPPLIST}
5761         @${LS} ${STAGEDIR}${PREFIX}/${INFO_PATH}/$i.info* | ${SED} -e s:${STAGEDIR}${PREFIX}/::g >> ${TMPPLIST}
5762         @${ECHO_CMD} "@exec install-info --quiet %D/${INFO_PATH}/$i.info %D/${INFO_PATH}/dir" \
5763                 >> ${TMPPLIST}
5764 .else
5765         @${LS} ${STAGEDIR}${PREFIX}/${INFO_PATH}/$i.info* 2>/dev/null | ${SED} -e s:${STAGEDIR}${PREFIX}/:@info\ :g >> ${TMPPLIST}
5766 .endif
5767 .endfor
5768 .if defined(INFO_SUBDIR)
5769 .if !defined(WITH_PKGNG)
5770         @${ECHO_CMD} "@unexec ${RMDIR} %D/${INFO_PATH}/${INFO_SUBDIR} 2> /dev/null || true" >> ${TMPPLIST}
5771 .else
5772         @${ECHO_CMD} "@dirrmtry ${INFO_PATH}/${INFO_SUBDIR}" >> ${TMPPLIST}
5773 .endif
5774 .endif
5775 .if (${PREFIX} != "/usr")
5776         @${ECHO_CMD} "@unexec if [ -f %D/${INFO_PATH}/dir ]; then if sed -e '1,/Menu:/d' %D/${INFO_PATH}/dir | grep -q '^[*] '; then true; else rm %D/${INFO_PATH}/dir; fi; fi" >> ${TMPPLIST}
5777 .if (${PREFIX} != ${LOCALBASE} && ${PREFIX} != ${LINUXBASE})
5778         @${ECHO_CMD} "@unexec rmdir %D/${INFO_PATH} 2>/dev/null || true" >> ${TMPPLIST}
5779 .endif
5780 .endif
5781 .endif
5782 .endif
5783
5784 # If we're installing into a non-standard PREFIX, we need to remove that directory at
5785 # deinstall-time
5786 .if !target(add-plist-post)
5787 .if (${PREFIX} != ${LOCALBASE} && ${PREFIX} != ${LINUXBASE} && \
5788     ${PREFIX} != "/usr" && !defined(NO_PREFIX_RMDIR))
5789 add-plist-post:
5790         @${ECHO_CMD} "@unexec rmdir %D 2> /dev/null || true" >> ${TMPPLIST}
5791 .endif
5792 .endif
5793
5794 .if !target(install-rc-script)
5795 .if defined(USE_RCORDER) || defined(USE_RC_SUBR) && ${USE_RC_SUBR:tu} != "YES"
5796 install-rc-script:
5797 .if defined(USE_RCORDER)
5798         @${ECHO_MSG} "===> Staging early rc.d startup script(s)"
5799         @${ECHO_CMD} "@cwd /" >> ${TMPPLIST}
5800         @for i in ${USE_RCORDER}; do \
5801                 ${INSTALL_SCRIPT} ${WRKDIR}/$${i} ${STAGEDIR}/etc/rc.d/$${i%.sh}; \
5802                 ${ECHO_CMD} "etc/rc.d/$${i%.sh}" >> ${TMPPLIST}; \
5803         done
5804         @${ECHO_CMD} "@cwd ${PREFIX}" >> ${TMPPLIST}
5805 .endif
5806 .if defined(USE_RC_SUBR) && ${USE_RC_SUBR:tu} != "YES"
5807         @${ECHO_MSG} "===> Staging rc.d startup script(s)"
5808         @${ECHO_CMD} "@cwd ${PREFIX}" >> ${TMPPLIST}
5809         @for i in ${USE_RC_SUBR}; do \
5810                 ${INSTALL_SCRIPT} ${WRKDIR}/$${i} ${STAGEDIR}${PREFIX}/etc/rc.d/$${i%.sh}; \
5811                 ${ECHO_CMD} "etc/rc.d/$${i%.sh}" >> ${TMPPLIST}; \
5812         done
5813 .endif
5814 .endif
5815 .endif
5816
5817 # Compress (or uncompress) and symlink manpages.
5818 .if !target(compress-man)
5819 .if defined(_MANPAGES) || defined(_MLINKS)
5820 compress-man:
5821 .if ${MANCOMPRESSED} == yes && defined(NO_MANCOMPRESS)
5822         @${ECHO_MSG} "===>   Uncompressing manual pages for ${PKGNAME}"
5823         @_manpages='${_MANPAGES:S/'/'\''/g}' && [ "$${_manpages}" != "" ] && ( eval ${GUNZIP_CMD} $${_manpages} ) || ${TRUE}
5824 .elif ${MANCOMPRESSED} == no && !defined(NO_MANCOMPRESS)
5825         @${ECHO_MSG} "===>   Compressing manual pages for ${PKGNAME}"
5826         @_manpages='${_MANPAGES:S/'/'\''/g}' && [ "$${_manpages}" != "" ] && ( eval ${GZIP_CMD} $${_manpages} ) || ${TRUE}
5827 .endif
5828 .if defined(_MLINKS)
5829         @set -- ${_MLINKS}; \
5830         while :; do \
5831                 [ $$# -eq 0 ] && break || ${TRUE}; \
5832                 ${RM} -f $${2%.gz}; ${RM} -f $$2.gz; \
5833                 ${LN} -fs `${ECHO_CMD} $$1 $$2 | ${AWK} '{ \
5834                                         z=split($$1, a, /\//); x=split($$2, b, /\//); \
5835                                         while (a[i] == b[i]) i++; \
5836                                         for (q=i; q<x; q++) printf "../"; \
5837                                         for (; i<z; i++) printf a[i] "/"; printf a[z]; }'` $$2; \
5838                 shift; shift; \
5839         done
5840 .endif
5841 .endif
5842 .endif
5843
5844 # Fake installation of package so that user can pkg_delete it later.
5845 # Also, make sure that an installed port is recognized correctly in
5846 # accordance to the @pkgdep directive in the packing lists
5847
5848 .if !target(fake-pkg)
5849 .if !defined(NO_PKG_REGISTER)
5850 fake-pkg:
5851         @if [ ! -d ${PKG_DBDIR} ]; then ${RM} -f ${PKG_DBDIR}; ${MKDIR} ${PKG_DBDIR}; fi
5852         @${RM} -f /tmp/${PKGNAME}-required-by
5853 .if defined(FORCE_PKG_REGISTER)
5854         @if [ -e ${PKG_DBDIR}/${PKGNAME}/+REQUIRED_BY ]; then \
5855                 ${CP} ${PKG_DBDIR}/${PKGNAME}/+REQUIRED_BY /tmp/${PKGNAME}-required-by; \
5856         fi
5857         @${RM} -rf ${PKG_DBDIR}/${PKGNAME}
5858 .endif
5859         @if [ ! -d ${PKG_DBDIR}/${PKGNAME} ]; then \
5860                 ${ECHO_MSG} "===>   Registering installation for ${PKGNAME}"; \
5861                 ${MKDIR} ${PKG_DBDIR}/${PKGNAME}; \
5862                 ${PKG_CMD} ${PKG_ARGS} -O ${PKGFILE} > ${PKG_DBDIR}/${PKGNAME}/+CONTENTS; \
5863                 ${CP} ${DESCR} ${PKG_DBDIR}/${PKGNAME}/+DESC; \
5864                 ${ECHO_CMD} ${COMMENT:Q} > ${PKG_DBDIR}/${PKGNAME}/+COMMENT; \
5865                 if [ -f ${PKGINSTALL} ]; then \
5866                         ${CP} ${PKGINSTALL} ${PKG_DBDIR}/${PKGNAME}/+INSTALL; \
5867                 fi; \
5868                 if [ -f ${PKGDEINSTALL} ]; then \
5869                         ${CP} ${PKGDEINSTALL} ${PKG_DBDIR}/${PKGNAME}/+DEINSTALL; \
5870                 fi; \
5871                 if [ -f ${PKGREQ} ]; then \
5872                         ${CP} ${PKGREQ} ${PKG_DBDIR}/${PKGNAME}/+REQUIRE; \
5873                 fi; \
5874                 if [ -f ${PKGMESSAGE} ]; then \
5875                         ${CP} ${PKGMESSAGE} ${PKG_DBDIR}/${PKGNAME}/+DISPLAY; \
5876                         ${ECHO_CMD} "@display +DISPLAY" >> ${PKG_DBDIR}/${PKGNAME}/+CONTENTS; \
5877                 fi; \
5878                 for dep in `${PKG_INFO} -qf ${PKGNAME} | ${AWK} '/^@pkgdep / {print $$2}' | ${SORT} -u`; do \
5879                         if [ -d ${PKG_DBDIR}/$$dep -a -z `${ECHO_CMD} $$dep | ${GREP} -E ${PKG_IGNORE_DEPENDS}` ]; then \
5880                                 if ! ${GREP} ^${PKGNAME}$$ ${PKG_DBDIR}/$$dep/+REQUIRED_BY \
5881                                         >/dev/null 2>&1; then \
5882                                         ${ECHO_CMD} ${PKGNAME} >> ${PKG_DBDIR}/$$dep/+REQUIRED_BY; \
5883                                 fi; \
5884                         fi; \
5885                 done; \
5886         fi
5887 .if !defined(NO_MTREE)
5888         @if [ -f ${MTREE_FILE} ]; then \
5889                 ${CP} ${MTREE_FILE} ${PKG_DBDIR}/${PKGNAME}/+MTREE_DIRS; \
5890         fi
5891 .endif
5892         @if [ -e /tmp/${PKGNAME}-required-by ]; then \
5893                 ${CAT} /tmp/${PKGNAME}-required-by >> ${PKG_DBDIR}/${PKGNAME}/+REQUIRED_BY; \
5894                 ${RM} -f /tmp/${PKGNAME}-required-by; \
5895         fi
5896 .endif
5897 .endif
5898
5899 # Depend is generally meaningless for arbitrary ports, but if someone wants
5900 # one they can override this.  This is just to catch people who've gotten into
5901 # the habit of typing `make depend all install' as a matter of course.
5902 #
5903 .if !target(depend)
5904 depend:
5905 .endif
5906
5907 # Same goes for tags
5908 .if !target(tags)
5909 tags:
5910 .endif
5911
5912 .if !defined(NOPRECIOUSMAKEVARS)
5913 # These won't change, so we can pass them through the environment
5914 .MAKEFLAGS: \
5915         ARCH="${ARCH:S/"/"'"'"/g:S/\$/\$\$/g:S/\\/\\\\/g}" \
5916         OPSYS="${OPSYS:S/"/"'"'"/g:S/\$/\$\$/g:S/\\/\\\\/g}" \
5917         OSREL="${OSREL:S/"/"'"'"/g:S/\$/\$\$/g:S/\\/\\\\/g}" \
5918         OSVERSION="${OSVERSION:S/"/"'"'"/g:S/\$/\$\$/g:S/\\/\\\\/g}" \
5919         DFLYVERSION="${DFLYVERSION:Q}" \
5920         SYSTEMVERSION="${SYSTEMVERSION:S/"/"'"'"/g:S/\$/\$\$/g:S/\\/\\\\/g}"
5921 .endif
5922
5923 .if !target(pre-check-config)
5924 pre-check-config:
5925 .for single in ${OPTIONS_SINGLE}
5926 .  for opt in ${OPTIONS_SINGLE_${single}}
5927 .    if empty(ALL_OPTIONS:M${single}) || !empty(PORT_OPTIONS:M${single})
5928 .      if !empty(PORT_OPTIONS:M${opt})
5929 .        if defined(OPTFOUND)
5930 OPTIONS_WRONG_SINGLE+=  ${single}
5931 .        else
5932 OPTFOUND=       true
5933 .        endif
5934 .      endif
5935 .    else
5936 # if conditional and if the condition is unchecked, remove opt from the list of
5937 # set options
5938 PORT_OPTIONS:=  ${PORT_OPTIONS:N${opt}}
5939 OPTNOCHECK=     true
5940 .    endif
5941 .  endfor
5942 .  if !defined(OPTFOUND) && !defined(OPTNOCHECK)
5943 OPTIONS_WRONG_SINGLE+=  ${single}
5944 .  endif
5945 .  undef OPTFOUND
5946 .  undef OPTNOCHECK
5947 .endfor
5948 .undef single
5949
5950 .for radio in ${OPTIONS_RADIO}
5951 .  for opt in ${OPTIONS_RADIO_${radio}}
5952 .    if !empty(PORT_OPTIONS:M${opt})
5953 .      if defined(OPTFOUND)
5954 OPTIONS_WRONG_RADIO+=   ${radio}
5955 .      else
5956 OPTFOUND=       true
5957 .      endif
5958 .    endif
5959 .  endfor
5960 .  undef OPTFOUND
5961 .endfor
5962
5963 .for multi in ${OPTIONS_MULTI}
5964 .  for opt in ${OPTIONS_MULTI_${multi}}
5965 .    if empty(ALL_OPTIONS:M${multi}) || !empty(PORT_OPTIONS:M${multi})
5966 .      if !empty(PORT_OPTIONS:M${opt})
5967 OPTFOUND=       true
5968 .      endif
5969 .    else
5970 # if conditional and if the condition is unchecked, remove opt from the list of
5971 # set options
5972 PORT_OPTIONS:=  ${PORT_OPTIONS:N${opt}}
5973 OPTNOCHECK=     true
5974 .    endif
5975 .  endfor
5976 .  if !defined(OPTFOUND) && !defined(OPTNOCHECK)
5977 OPTIONS_WRONG_MULTI+=   ${multi}
5978 .  endif
5979 .  undef OPTFOUND
5980 .  undef OPTNOCHECK
5981 .endfor
5982 .undef multi
5983 .undef opt
5984 .endif #pre-check-config
5985
5986 .if !target(_check-config)
5987 _check-config: pre-check-config
5988 .for multi in ${OPTIONS_WRONG_MULTI}
5989         @${ECHO_MSG} "====> You must check at least one option in the ${multi} multi"
5990 .endfor
5991 .for single in ${OPTIONS_WRONG_SINGLE}
5992         @${ECHO_MSG} "====> You must select one and only one option from the ${single} single"
5993 .endfor
5994 .for radio in ${OPTIONS_WRONG_RADIO}
5995         @${ECHO_MSG} "====> You cannot select multiple options from the ${radio} radio"
5996 .endfor
5997 .if !empty(OPTIONS_WRONG_MULTI) || !empty(OPTIONS_WRONG_SINGLE) || !empty(OPTIONS_WRONG_RADIO)
5998 _CHECK_CONFIG_ERROR=    true
5999 .endif
6000 .endif # _check-config
6001
6002 .if !target(check-config)
6003 check-config: _check-config
6004 .if !empty(_CHECK_CONFIG_ERROR)
6005         @${FALSE}
6006 .endif
6007 .endif # check-config
6008
6009 .if !target(sanity-config)
6010 sanity-config: _check-config
6011 .if !empty(_CHECK_CONFIG_ERROR)
6012         @echo -n "Config is invalid. Re-edit? [Y/n] "; \
6013         read answer; \
6014         case $$answer in \
6015         [Nn]|[Nn][Oo]) \
6016                 exit 0; \
6017         esac; \
6018         cd ${.CURDIR} && ${MAKE} config
6019 .endif
6020 .endif # sanity-config
6021
6022 .if !target(pre-config)
6023 pre-config:
6024 D4P_ENV=        PKGNAME="${PKGNAME}" \
6025                 PORT_OPTIONS="${PORT_OPTIONS}" \
6026                 ALL_OPTIONS="${ALL_OPTIONS}" \
6027                 OPTIONS_MULTI="${OPTIONS_MULTI}" \
6028                 OPTIONS_SINGLE="${OPTIONS_SINGLE}" \
6029                 OPTIONS_RADIO="${OPTIONS_RADIO}" \
6030                 OPTIONS_GROUP="${OPTIONS_GROUP}" \
6031                 NEW_OPTIONS="${NEW_OPTIONS}" \
6032                 DIALOG4PORTS="${DIALOG4PORTS}" \
6033                 PREFIX="${PREFIX}" \
6034                 LOCALBASE="${LOCALBASE}" \
6035                 PORTSDIR="${PORTSDIR}" \
6036                 MAKE="${MAKE}" \
6037                 D4PHEIGHT="${D4PHEIGHT}" \
6038                 D4PWIDTH="${D4PWIDTH}" \
6039                 D4PFULLSCREEN="${D4PFULLSCREEN}"
6040 .if exists(${PKGHELP})
6041 D4P_ENV+=       PKGHELP="${PKGHELP}"
6042 .endif
6043 .for opt in ${ALL_OPTIONS}
6044 D4P_ENV+=        ${opt}_DESC=""${${opt}_DESC:Q}""
6045 .endfor
6046 .for otype in MULTI GROUP SINGLE RADIO
6047 .  for m in ${OPTIONS_${otype}}
6048 D4P_ENV+=       OPTIONS_${otype}_${m}="${OPTIONS_${otype}_${m}}" \
6049                 ${m}_DESC=""${${m}_DESC:Q}""
6050 .    for opt in ${OPTIONS_${otype}_${m}}
6051 D4P_ENV+=        ${opt}_DESC=""${${opt}_DESC:Q}""
6052 .    endfor
6053 .  endfor
6054 .endfor
6055 .undef m
6056 .undef otype
6057 .undef opt
6058 .endif # pre-config
6059
6060 .if !target(do-config)
6061 do-config:
6062 .if empty(ALL_OPTIONS) && empty(OPTIONS_SINGLE) && empty(OPTIONS_MULTI) && empty(OPTIONS_RADIO) && empty(OPTIONS_GROUP)
6063         @${ECHO_MSG} "===> No options to configure"
6064 .else
6065 .if ${UID} != 0 && !defined(INSTALL_AS_USER)
6066         @optionsdir=${OPTIONS_FILE}; optionsdir=$${optionsdir%/*}; \
6067         oldoptionsdir=${OPTIONSFILE}; oldoptionsdir=$${oldoptionsdir%/*}; \
6068         ${ECHO_MSG} "===>  Switching to root credentials to create $${optionsdir}"; \
6069         (${SU_CMD} "${SH} -c \"if [ -d $${oldoptionsdir} -a ! -d $${optionsdir} ]; then ${MV} $${oldoptionsdir} $${optionsdir}; elif [ -d $${oldoptionsdir} -a -d $${optionsdir} ]; then ${RM} -rf $${oldoptionsdir} ; fi ; ${MKDIR} $${optionsdir} 2> /dev/null\"") || \
6070                 (${ECHO_MSG} "===> Cannot create $${optionsdir}, check permissions"; exit 1); \
6071         ${ECHO_MSG} "===>  Returning to user credentials"
6072 .else
6073         @optionsdir=${OPTIONS_FILE}; optionsdir=$${optionsdir%/*}; \
6074         oldoptionsdir=${OPTIONSFILE}; oldoptionsdir=$${oldoptionsdir%/*}; \
6075         if [ -d $${oldoptionsdir} -a ! -d $${optionsdir} ]; then \
6076                 ${MV} $${oldoptionsdir} $${optionsdir}; \
6077         elif [ -d $${oldoptionsdir} -a -d $${optionsdir} ]; then \
6078                 ${RM} -rf $${oldoptionsdir} ; \
6079         fi ; \
6080         ${MKDIR} $${optionsdir} 2> /dev/null || \
6081         (${ECHO_MSG} "===> Cannot create $${optionsdir}, check permissions"; exit 1)
6082 .endif
6083         @TMPOPTIONSFILE=$$(mktemp -t portoptions); \
6084         trap "${RM} -f $${TMPOPTIONSFILE}; exit 1" 1 2 3 5 10 13 15; \
6085         ${SETENV} ${D4P_ENV} ${SH} ${SCRIPTSDIR}/dialog4ports.sh $${TMPOPTIONSFILE} || { \
6086                 ${RM} -f $${TMPOPTIONSFILE}; \
6087                 ${ECHO_MSG} "===> Options unchanged"; \
6088                 exit 0; \
6089         }; \
6090         ${ECHO_CMD}; \
6091         if [ ! -e $${TMPOPTIONSFILE} ]; then \
6092                 ${ECHO_MSG} "===> No user-specified options to save for ${PKGNAME}"; \
6093                 exit 0; \
6094         fi; \
6095         SELOPTIONS=$$(${CAT} $${TMPOPTIONSFILE}); \
6096         ${RM} -f $${TMPOPTIONSFILE}; \
6097         TMPOPTIONSFILE=$$(mktemp -t portoptions); \
6098         trap "${RM} -f $${TMPOPTIONSFILE}; exit 1" 1 2 3 5 10 13 15; \
6099         ${ECHO_CMD} "# This file is auto-generated by 'make config'." > $${TMPOPTIONSFILE}; \
6100         ${ECHO_CMD} "# Options for ${PKGNAME}" >> $${TMPOPTIONSFILE}; \
6101         ${ECHO_CMD} "_OPTIONS_READ=${PKGNAME}" >> $${TMPOPTIONSFILE}; \
6102         ${ECHO_CMD} "_FILE_COMPLETE_OPTIONS_LIST=${COMPLETE_OPTIONS_LIST}" >> $${TMPOPTIONSFILE}; \
6103         for i in ${COMPLETE_OPTIONS_LIST}; do \
6104                 if ${ECHO_CMD} $${SELOPTIONS} | ${GREP} -qw $${i}; then \
6105                         ${ECHO_CMD} "OPTIONS_FILE_SET+=$${i}" >> $${TMPOPTIONSFILE}; \
6106                 else \
6107                         ${ECHO_CMD} "OPTIONS_FILE_UNSET+=$${i}" >> $${TMPOPTIONSFILE}; \
6108                 fi; \
6109         done; \
6110         if [ ${UID} != 0 -a "x${INSTALL_AS_USER}" = "x" ]; then \
6111                 ${ECHO_MSG} "===>  Switching to root credentials to write ${OPTIONS_FILE}"; \
6112                 ${SU_CMD} "${CAT} $${TMPOPTIONSFILE} > ${OPTIONS_FILE}"; \
6113                 ${ECHO_MSG} "===>  Returning to user credentials"; \
6114         else \
6115                 ${CAT} $${TMPOPTIONSFILE} > ${OPTIONS_FILE}; \
6116         fi; \
6117         ${RM} -f $${TMPOPTIONSFILE}
6118         @cd ${.CURDIR} && ${MAKE} sanity-config
6119 .endif
6120 .endif # do-config
6121
6122 .if !target(config)
6123 .if !defined(NO_DIALOG)
6124 config: pre-config do-config
6125 .else
6126 config:
6127         @${ECHO_MSG} "===> Skipping 'config' as NO_DIALOG is defined"
6128 .endif
6129 .endif # config
6130
6131 .if !target(config-recursive)
6132 config-recursive:
6133         @${ECHO_MSG} "===> Setting user-specified options for ${PKGNAME} and dependencies";
6134         @for dir in ${.CURDIR} $$(${ALL-DEPENDS-LIST}); do \
6135                 (cd $$dir; ${MAKE} config-conditional); \
6136         done
6137 .endif # config-recursive
6138
6139 .if !target(config-conditional)
6140 config-conditional:
6141 .if !empty(NEW_OPTIONS)
6142         @cd ${.CURDIR} && ${MAKE} config;
6143 .endif
6144 .endif # config-conditional
6145
6146 .if !target(showconfig)
6147 .include "${PORTSDIR}/Mk/bsd.options.desc.mk"
6148 MULTI_EOL=      : you have to choose at least one of them
6149 SINGLE_EOL=     : you have to select exactly one of them
6150 RADIO_EOL=      : you can only select none or one of them
6151 showconfig:
6152 .if !empty(COMPLETE_OPTIONS_LIST)
6153         @${ECHO_MSG} "===> The following configuration options are available for ${PKGNAME}":
6154 .for opt in ${ALL_OPTIONS}
6155         @[ -z "${PORT_OPTIONS:M${opt}}" ] || match="on" ; ${ECHO_MSG} -n "     ${opt}=$${match:-off}"
6156 .  if !empty(${opt}_DESC)
6157         @${ECHO_MSG} -n ": "${${opt}_DESC:Q}
6158 .  endif
6159         @${ECHO_MSG} ""
6160 .endfor
6161
6162 #multi and conditional multis
6163 .for otype in MULTI GROUP SINGLE RADIO
6164 .  for m in ${OPTIONS_${otype}}
6165 .    if empty(${m}_DESC)
6166                 @${ECHO_MSG} "====> Options available for the ${otype:tl} ${m}${${otype}_EOL}"
6167 .    else
6168                 @${ECHO_MSG} "====> ${${m}_DESC}${${otype}_EOL}"
6169 .    endif
6170 .    for opt in ${OPTIONS_${otype}_${m}}
6171         @[ -z "${PORT_OPTIONS:M${opt}}" ] || match="on" ; ${ECHO_MSG} -n "     ${opt}=$${match:-off}"
6172 .      if !empty(${opt}_DESC)
6173         @${ECHO_MSG} -n ": "${${opt}_DESC:Q}
6174 .      endif
6175         @${ECHO_MSG} ""
6176 .    endfor
6177 .  endfor
6178 .endfor
6179
6180 .undef otype
6181 .undef m
6182 .undef opt
6183         @${ECHO_MSG} "===> Use 'make config' to modify these settings"
6184 .endif
6185 .endif # showconfig
6186
6187 .if !target(showconfig-recursive)
6188 showconfig-recursive:
6189         @${ECHO_MSG} "===> The following configuration options are available for ${PKGNAME} and dependencies";
6190         @for dir in ${.CURDIR} $$(${ALL-DEPENDS-LIST}); do \
6191                 (cd $$dir; ${MAKE} showconfig); \
6192         done
6193 .endif # showconfig-recursive
6194
6195 .if !target(rmconfig)
6196 rmconfig:
6197 .if exists(${OPTIONSFILE})
6198         -@${ECHO_MSG} "===> Removing user-configured options for ${PKGNAME}"; \
6199         optionsdir=${OPTIONSFILE}; optionsdir=$${optionsdir%/*}; \
6200         if [ ${UID} != 0 -a "x${INSTALL_AS_USER}" = "x" ]; then \
6201                 ${ECHO_MSG} "===> Switching to root credentials to remove ${OPTIONSFILE} and $${optionsdir}"; \
6202                 ${SU_CMD} "${RM} -f ${OPTIONSFILE} ; \
6203                         ${RMDIR} $${optionsdir}"; \
6204                 ${ECHO_MSG} "===> Returning to user credentials"; \
6205         else \
6206                 ${RM} -f ${OPTIONSFILE}; \
6207                 ${RMDIR} $${optionsdir} 2>/dev/null || return 0; \
6208         fi
6209 .endif
6210 .if exists(${OPTIONS_FILE})
6211         -@${ECHO_MSG} "===> Removing user-configured options for ${PKGNAME}"; \
6212         optionsdir=${OPTIONS_FILE}; optionsdir=$${optionsdir%/*}; \
6213         if [ ${UID} != 0 -a "x${INSTALL_AS_USER}" = "x" ]; then \
6214                 ${ECHO_MSG} "===> Switching to root credentials to remove ${OPTIONS_FILE} and $${optionsdir}"; \
6215                 ${SU_CMD} "${RM} -f ${OPTIONS_FILE} ; \
6216                         ${RMDIR} $${optionsdir}"; \
6217                 ${ECHO_MSG} "===> Returning to user credentials"; \
6218         else \
6219                 ${RM} -f ${OPTIONS_FILE}; \
6220                 ${RMDIR} $${optionsdir} 2>/dev/null || return 0; \
6221         fi
6222 .else
6223         @${ECHO_MSG} "===> No user-specified options configured for ${PKGNAME}"
6224 .endif
6225 .endif # rmconfig
6226
6227 .if !target(rmconfig-recursive)
6228 rmconfig-recursive:
6229         @${ECHO_MSG} "===> Removing user-specified options for ${PKGNAME} and dependencies";
6230         @for dir in ${.CURDIR} $$(${ALL-DEPENDS-LIST}); do \
6231                 (cd $$dir; ${MAKE} rmconfig); \
6232         done
6233 .endif # rmconfig-recursive
6234
6235 .if !target(pretty-print-config)
6236 MULTI_START=    [
6237 MULTI_END=      ]
6238 GROUP_START=    [
6239 GROUP_END=      ]
6240 SINGLE_START=   (
6241 SINGLE_END=     )
6242 RADIO_START=    (
6243 RADIO_END=      )
6244 pretty-print-config:
6245 .for opt in ${ALL_OPTIONS}
6246         @[ -z "${PORT_OPTIONS:M${opt}}" ] || match="+" ; ${ECHO_MSG} -n "$${match:--}${opt} "
6247 .endfor
6248 .for otype in MULTI GROUP SINGLE RADIO
6249 .  for m in ${OPTIONS_${otype}}
6250         @${ECHO_MSG} -n "${m}${${otype}_START} "
6251 .    for opt in ${OPTIONS_${otype}_${m}}
6252                 @[ -z "${PORT_OPTIONS:M${opt}}" ] || match="+" ; ${ECHO_MSG} -n "$${match:--}${opt} "
6253 .    endfor
6254         @${ECHO_MSG} -n "${${otype}_END} "
6255 .  endfor
6256 .endfor
6257 .undef otype
6258 .undef m
6259 .undef opt
6260         @${ECHO_MSG} ""
6261 .endif # pretty-print-config
6262
6263 desktop-categories:
6264         @categories=""; \
6265         for native_category in ${CATEGORIES}; do \
6266                 c=""; \
6267                 case $$native_category in \
6268                         accessibility)  c="Utility Accessibility"               ;; \
6269                         archivers)              c="Utility Archiving"                   ;; \
6270                         astro)                  c="Education Science Astronomy" ;; \
6271                         audio)                  c="AudioVideo Audio"                    ;; \
6272                         benchmarks)             c="System"                                              ;; \
6273                         biology)                c="Education Science Biology"   ;; \
6274                         cad)                    c="Graphics Engineering"                ;; \
6275                         comms)                  c="Utility"                                             ;; \
6276                         converters)             c="Utility"                                             ;; \
6277                         databases)              c="Office Database"                             ;; \
6278                         deskutils)              c="Utility"                                             ;; \
6279                         devel)                  c="Development"                                 ;; \
6280                         dns)                    c="Network"                                             ;; \
6281                         elisp)                  c="Development"                                 ;; \
6282                         editors)                c="Utility"                                             ;; \
6283                         emulators)              c="System Emulator"                             ;; \
6284                         finance)                c="Office Finance"                              ;; \
6285                         ftp)                    c="Network FileTransfer"                ;; \
6286                         games)                  c="Game"                                                ;; \
6287                         geography)              c="Education Science Geography" ;; \
6288                         gnome)                  c="GNOME GTK"                                   ;; \
6289                         graphics)               c="Graphics"                                    ;; \
6290                         hamradio)               c="HamRadio"                                    ;; \
6291                         haskell)                c="Development"                                 ;; \
6292                         irc)                    c="Network IRCClient"                   ;; \
6293                         java)                   c="Development Java"                    ;; \
6294                         kde)                    c="KDE Qt"                                              ;; \
6295                         lang)                   c="Development"                                 ;; \
6296                         lisp)                   c="Development"                                 ;; \
6297                         mail)                   c="Office Email"                                ;; \
6298                         mate)                   c="MATE GTK"            ;; \
6299                         math)                   c="Education Science Math"              ;; \
6300                         mbone)                  c="Network AudioVideo"                  ;; \
6301                         multimedia)             c="AudioVideo"                                  ;; \
6302                         net)                    c="Network"                                             ;; \
6303                         net-im)                 c="Network InstantMessaging"    ;; \
6304                         net-mgmt)               c="Network"                                             ;; \
6305                         net-p2p)                c="Network P2P"                                 ;; \
6306                         news)                   c="Network News"                                ;; \
6307                         palm)                   c="Office PDA"                                  ;; \
6308                         parallel)               c="ParallelComputing"                   ;; \
6309                         pear)                   c="Development WebDevelopment"  ;; \
6310                         perl5)                  c="Development"                                 ;; \
6311                         python)                 c="Development"                                 ;; \
6312                         ruby)                   c="Development"                                 ;; \
6313                         rubygems)               c="Development"                                 ;; \
6314                         scheme)                 c="Development"                                 ;; \
6315                         science)                c="Science Education"                   ;; \
6316                         security)               c="System Security"                             ;; \
6317                         shells)                 c="System Shell"                                ;; \
6318                         sysutils)               c="System"                                              ;; \
6319                         tcl*|tk*)               c="Development"                                 ;; \
6320                         textproc)               c="Utility TextTools"                   ;; \
6321                         www)                    c="Network"                                             ;; \
6322                         x11-clocks)             c="Utility Clock"                               ;; \
6323                         x11-fm)                 c="System FileManager"                  ;; \
6324                         xfce)                   c="GTK XFCE"                                    ;; \
6325                         zope)                   c="Development WebDevelopment"  ;; \
6326                 esac; \
6327                 if [ -n "$$c" ]; then \
6328                         categories="$$categories $$c"; \
6329                 fi; \
6330         done; \
6331         if [ -n "$$categories" ]; then \
6332                 for c in $$categories; do ${ECHO_MSG} "$$c"; done \
6333                         | ${SORT} -u | ${TR} '\n' ';'; \
6334                 ${ECHO_MSG}; \
6335         fi
6336
6337 # http://standards.freedesktop.org/menu-spec/menu-spec-latest.html
6338 DESKTOP_CATEGORIES_MAIN=        AudioVideo Audio Video Development Education \
6339         Game Graphics Network Office Science Settings System Utility
6340 DESKTOP_CATEGORIES_ADDITIONAL=  Building Debugger IDE GUIDesigner Profiling \
6341         RevisionControl Translation Calendar ContactManagement Database \
6342         Dictionary Chart Email Finance FlowChart PDA ProjectManagement \
6343         Presentation Spreadsheet WordProcessor 2DGraphics VectorGraphics \
6344         RasterGraphics 3DGraphics Scanning OCR Photography Publishing Viewer \
6345         TextTools DesktopSettings HardwareSettings Printing PackageManager \
6346         Dialup InstantMessaging Chat IRCClient Feed FileTransfer HamRadio News \
6347         P2P RemoteAccess Telephony TelephonyTools VideoConference WebBrowser \
6348         WebDevelopment Midi Mixer Sequencer Tuner TV AudioVideoEditing Player \
6349         Recorder DiscBurning ActionGame AdventureGame ArcadeGame BoardGame \
6350         BlocksGame CardGame KidsGame LogicGame RolePlaying Shooter Simulation \
6351         SportsGame StrategyGame Art Construction Music Languages \
6352         ArtificialIntelligence Astronomy Biology Chemistry ComputerScience \
6353         DataVisualization Economy Electricity Geography Geology Geoscience \
6354         History Humanities ImageProcessing Literature Maps Math \
6355         NumericalAnalysis MedicalSoftware Physics Robotics Spirituality Sports \
6356         ParallelComputing Amusement Archiving Compression Electronics Emulator \
6357         Engineering FileTools FileManager TerminalEmulator Filesystem Monitor \
6358         Security Accessibility Calculator Clock TextEditor Documentation Adult \
6359         Core KDE GNOME MATE XFCE GTK Qt Motif Java ConsoleOnly
6360 DESKTOP_CATEGORIES_RESERVED=    Screensaver TrayIcon Applet Shell
6361
6362 VALID_DESKTOP_CATEGORIES+=      ${DESKTOP_CATEGORIES_MAIN} \
6363         ${DESKTOP_CATEGORIES_ADDITIONAL} \
6364         ${DESKTOP_CATEGORIES_RESERVED}
6365
6366 .if defined(DESKTOP_ENTRIES)
6367 check-desktop-entries:
6368         @set -- ${DESKTOP_ENTRIES} XXX; \
6369         if [ `${EXPR} \( $$# - 1 \) % 6` -ne 0 ]; then \
6370                 ${ECHO_MSG} "${PKGNAME}: Makefile error: the DESKTOP_ENTRIES list must contain one or more groups of 6 elements"; \
6371                 exit 1; \
6372         fi; \
6373         num=1; \
6374         while [ $$# -gt 6 ]; do \
6375                 entry="#$$num"; \
6376                 if [ -n "$$4" ]; then \
6377                         entry="$$entry ($$4)"; \
6378                 elif [ -n "$$1" ]; then \
6379                         entry="$$entry ($$1)"; \
6380                 fi; \
6381                 if [ -z "$$1" ]; then \
6382                         ${ECHO_MSG} "${PKGNAME}: Makefile error: in desktop entry $$entry: field 1 (Name) is empty"; \
6383                         exit 1; \
6384                 fi; \
6385                 if ${ECHO_CMD} "$$3" | ${GREP} -iq '.\(png\|svg\|xpm\)$$'; then \
6386                         if ! ${ECHO_CMD} "$$3" | ${GREP} -iq '^/'; then \
6387                                 ${ECHO_MSG} "${PKGNAME}: Makefile warning: in desktop entry $$entry: field 3 (Icon) should be either absolute path or icon name without extension if installed icons follow Icon Theme Specification"; \
6388                         fi; \
6389                 fi; \
6390                 if [ -z "$$4" ]; then \
6391                         ${ECHO_MSG} "${PKGNAME}: Makefile error: in desktop entry $$entry: field 4 (Exec) is empty"; \
6392                         exit 1; \
6393                 fi; \
6394                 if [ -n "$$5" ]; then \
6395                         for c in `${ECHO_CMD} "$$5" | ${TR} ';' ' '`; do \
6396                                 if ! ${ECHO_CMD} ${VALID_DESKTOP_CATEGORIES} | ${GREP} -wq $$c; then \
6397                                         ${ECHO_CMD} "${PKGNAME}: Makefile warning: in desktop entry $$entry: category $$c is not a valid desktop category"; \
6398                                 fi; \
6399                         done; \
6400                         if ! ${ECHO_CMD} "$$5" | ${GREP} -q "`${ECHO_CMD} ${DESKTOP_CATEGORIES_MAIN} | ${SED} -E 's,[[:blank:]]+,\\\|,g'`"; then \
6401                                 ${ECHO_CMD} "${PKGNAME}: Makefile warning: in desktop entry $$entry: field 5 (Categories) must contain at least one main desktop category (make -VDESKTOP_CATEGORIES_MAIN)"; \
6402                         fi; \
6403                         if ! ${ECHO_CMD} "$$5" | ${GREP} -q ';$$'; then \
6404                                 ${ECHO_MSG} "${PKGNAME}: Makefile error: in desktop entry $$entry: field 5 (Categories) does not end with a semicolon"; \
6405                                 exit 1; \
6406                         fi; \
6407                 else \
6408                         if [ -z "`cd ${.CURDIR} && ${MAKE} desktop-categories`" ]; then \
6409                                 ${ECHO_MSG} "${PKGNAME}: Makefile error: in desktop entry $$entry: field 5 (Categories) is empty and could not be deduced from the CATEGORIES variable"; \
6410                                 exit 1; \
6411                         fi; \
6412                 fi; \
6413                 if [ "x$$6" != "xtrue" ] && [ "x$$6" != "xfalse" ] && [ "x$$6" != "x" ]; then \
6414                         ${ECHO_MSG} "${PKGNAME}: Makefile error: in desktop entry $$entry: field 6 (StartupNotify) is not \"true\", \"false\" or \"\"(empty)"; \
6415                         exit 1; \
6416                 fi; \
6417                 shift 6; \
6418                 num=`${EXPR} $$num + 1`; \
6419         done
6420 .endif
6421
6422 .if !target(install-desktop-entries)
6423 .if defined(DESKTOP_ENTRIES)
6424 install-desktop-entries:
6425         @set -- ${DESKTOP_ENTRIES} XXX; \
6426         if [ -z "${_DESKTOPDIR_REL}" ]; then \
6427                 ${ECHO_CMD} "@cwd ${DESKTOPDIR}" >> ${TMPPLIST}; \
6428         fi; \
6429         while [ $$# -gt 6 ]; do \
6430                 filename="`${ECHO_CMD} "$$4" | ${SED} -e 's,^/,,g;s,[/ ],_,g;s,[^_[:alnum:]],,g'`.desktop"; \
6431                 pathname="${STAGEDIR}${DESKTOPDIR}/$$filename"; \
6432                 categories="$$5"; \
6433                 if [ -z "$$categories" ]; then \
6434                         categories="`cd ${.CURDIR} && ${MAKE} desktop-categories`"; \
6435                 fi; \
6436                 ${ECHO_CMD} "${_DESKTOPDIR_REL}$$filename" >> ${TMPPLIST}; \
6437                 ${ECHO_CMD} "[Desktop Entry]" > $$pathname; \
6438                 ${ECHO_CMD} "Type=Application" >> $$pathname; \
6439                 ${ECHO_CMD} "Version=1.0" >> $$pathname; \
6440                 ${ECHO_CMD} "Name=$$1" >> $$pathname; \
6441                 comment="$$2"; \
6442                 if [ -z "$$2" ]; then \
6443                         comment="`cd ${.CURDIR} && ${MAKE} -VCOMMENT`"; \
6444                 fi; \
6445                 ${ECHO_CMD} "GenericName=$$comment" >> $$pathname; \
6446                 ${ECHO_CMD} "Comment=$$comment" >> $$pathname; \
6447                 if [ -n "$$3" ]; then \
6448                         ${ECHO_CMD} "Icon=$$3" >> $$pathname; \
6449                 fi; \
6450                 ${ECHO_CMD} "Exec=$$4" >> $$pathname; \
6451                 ${ECHO_CMD} "Categories=$$categories" >> $$pathname; \
6452                 if [ -n "$$6" ]; then \
6453                         ${ECHO_CMD} "StartupNotify=$$6" >> $$pathname; \
6454                 fi; \
6455                 shift 6; \
6456         done; \
6457         if [ -z "${_DESKTOPDIR_REL}" ]; then \
6458                 ${ECHO_CMD} "@cwd ${PREFIX}" >> ${TMPPLIST}; \
6459         fi
6460 .endif
6461 .endif
6462
6463 .if defined(WARNING)
6464 WARNING_WAIT?=  10
6465 show-warnings:
6466         @${ECHO_MSG} "/!\\ WARNING /!\\"
6467 .for m in ${WARNING}
6468         @${ECHO_MSG} "${m}"
6469 .endfor
6470         @${ECHO_MSG}
6471         @sleep ${WARNING_WAIT}
6472 .endif
6473
6474 .if defined(DEVELOPER)
6475 .if defined(DEV_WARNING)
6476 DEV_WARNING_WAIT?=      10
6477 show-dev-warnings:
6478         @${ECHO_MSG} "/!\\ ${PKGNAME}: Makefile warnings, please consider fixing /!\\"
6479         @${ECHO_MSG}
6480 .for m in ${DEV_WARNING}
6481         @${ECHO_MSG} "${m}"
6482 .endfor
6483         @${ECHO_MSG}
6484         @sleep ${DEV_WARNING_WAIT}
6485 .endif
6486
6487 .if defined(DEV_ERROR)
6488 show-dev-errors:
6489         @${ECHO_MSG} "/!\\ ${PKGNAME}: Makefile errors /!\\"
6490         @${ECHO_MSG}
6491 .for m in ${DEV_ERROR}
6492         @${ECHO_MSG} "${m}"
6493 .endfor
6494         @${ECHO_MSG}
6495         @${FALSE}
6496 .endif
6497 .endif #DEVELOPER
6498
6499 # Please note that the order of the following targets is important, and
6500 # should not be modified.
6501
6502 _TARGETS_STAGES=        SANITY PKG FETCH EXTRACT PATCH CONFIGURE BUILD INSTALL PACKAGE
6503 .if !defined(NO_STAGE)
6504 _TARGETS_STAGES+=       STAGE
6505 .endif
6506
6507 # Define the SEQ of actions to take when each target is ran, and which targets
6508 # it depends on before running its SEQ.
6509
6510 _SANITY_SEQ=    post-chroot pre-everything check-makefile \
6511                                 show-warnings show-dev-warnings show-dev-errors \
6512                                 check-categories check-makevars check-desktop-entries \
6513                                 check-depends identify-install-conflicts check-deprecated \
6514                                 check-vulnerable check-license check-config buildanyway-message \
6515                                 options-message
6516
6517 _PKG_DEP=               check-sanity
6518 _PKG_SEQ=               pkg-depends
6519 _FETCH_DEP=             pkg
6520 _FETCH_SEQ=             fetch-depends pre-fetch pre-fetch-script \
6521                                 do-fetch fetch-specials post-fetch post-fetch-script
6522 _EXTRACT_DEP=   fetch
6523 _EXTRACT_SEQ=   check-build-conflicts extract-message checksum extract-depends \
6524                                 pre-extract pre-extract-script do-extract \
6525                                 post-extract post-extract-script
6526 _PATCH_DEP=             extract
6527 _PATCH_SEQ=             ask-license patch-message patch-depends pathfix-pre-patch dos2unix fix-shebang \
6528                                 pre-patch \
6529                                 pre-patch-script do-patch charsetfix-post-patch post-patch post-patch-script
6530 _CONFIGURE_DEP= patch
6531 _CONFIGURE_SEQ= build-depends lib-depends configure-message run-autotools-fixup \
6532                                 configure-autotools pre-configure pre-configure-script \
6533                                 run-autotools patch-libtool do-configure post-configure \
6534                                 post-configure-script
6535 _BUILD_DEP=             configure
6536 _BUILD_SEQ=             build-message pre-build pre-build-script do-build \
6537                                 post-build post-build-script
6538 .if !defined(NO_STAGE)
6539
6540 _STAGE_DEP=             build
6541 _STAGE_SEQ=             stage-message stage-dir run-depends lib-depends apply-slist pre-install generate-plist \
6542                                 pre-su-install
6543 .if defined(NEED_ROOT)
6544 _STAGE_SUSEQ=   create-users-groups do-install desktop-file-post-install kmod-post-install \
6545                                 shared-mime-post-install webplugin-post-install \
6546                                 post-install post-install-script move-uniquefiles post-stage compress-man \
6547                                 install-rc-script install-ldconfig-file install-license \
6548                                 install-desktop-entries add-plist-info add-plist-docs add-plist-examples \
6549                                 add-plist-data add-plist-post move-uniquefiles-plist fix-plist-sequence
6550 .if defined(DEVELOPER)
6551 _STAGE_SUSEQ+=  stage-qa
6552 .endif
6553 .else
6554 _STAGE_SEQ+=    create-users-groups do-install desktop-file-post-install kmod-post-install \
6555                                 shared-mime-post-install webplugin-post-install post-install post-install-script \
6556                                 move-uniquefiles post-stage compress-man install-rc-script install-ldconfig-file \
6557                                 install-license install-desktop-entries add-plist-info add-plist-docs \
6558                                 add-plist-examples add-plist-data add-plist-post move-uniquefiles-plist \
6559                                 fix-plist-sequence
6560 .if defined(DEVELOPER)
6561 _STAGE_SEQ+=    stage-qa
6562 .endif
6563 .endif
6564 .if defined(WITH_PKGNG)
6565 _INSTALL_DEP=   stage
6566 _INSTALL_SEQ=   install-message run-depends lib-depends check-already-installed
6567 _INSTALL_SUSEQ= fake-pkg security-check
6568
6569 _PACKAGE_DEP=   stage
6570 _PACKAGE_SEQ=   package-message pre-package pre-package-script do-package post-package-script
6571
6572 .else # pkg_install
6573
6574 _PACKAGE_DEP=   stage
6575 _PACKAGE_SEQ=   package-message pre-package pre-package-script do-package post-package-script
6576
6577 _INSTALL_DEP=   package
6578 _INSTALL_SEQ=   install-message run-depends lib-depends check-already-installed
6579 _INSTALL_SUSEQ= install-package security-check
6580 .endif
6581
6582 .else # NO_STAGE
6583
6584 _INSTALL_DEP=   build
6585 _INSTALL_SEQ=   install-message check-install-conflicts run-depends lib-depends apply-slist pre-install \
6586                                 pre-install-script generate-plist check-already-installed
6587 _INSTALL_SUSEQ= check-umask install-mtree pre-su-install \
6588                                 pre-su-install-script create-users-groups do-install \
6589                                 install-desktop-entries install-license install-rc-script \
6590                                 desktop-file-post-install kmod-post-install shared-mime-post-install webplugin-post-install \
6591                                 post-install post-install-script add-plist-buildinfo \
6592                                 add-plist-info add-plist-docs add-plist-examples \
6593                                 add-plist-data add-plist-post fix-plist-sequence \
6594                                 compress-man install-ldconfig-file fake-pkg security-check
6595 _PACKAGE_DEP=   install
6596 _PACKAGE_SEQ=   package-message pre-package pre-package-script \
6597                                 do-package post-package-script
6598 .endif
6599
6600 # Enforce order for -jN builds
6601
6602 .for _t in ${_TARGETS_STAGES}
6603 .  for s in ${_${_t}_SEQ}
6604 .    if target(${s})
6605 .      if ! ${NOTPHONY:M${s}}
6606 _PHONY_TARGETS+= ${s}
6607 .      endif
6608 _${_t}_REAL_SEQ+=       ${s}
6609 .    endif
6610 .  endfor
6611 .  for s in ${_${_t}_SUSEQ}
6612 .    if target(${s})
6613 .      if ! ${NOTPHONY:M${s}}
6614 _PHONY_TARGETS+= ${s}
6615 .       endif
6616 _${_t}_REAL_SUSEQ+=     ${s}
6617 .    endif
6618 .  endfor
6619 .ORDER: ${_${_t}_DEP} ${_${_t}_REAL_SEQ}
6620 .endfor
6621
6622 # Define all of the main targets which depend on a sequence of other targets.
6623 # See above *_SEQ and *_DEP. The _DEP will run before this defined target is
6624 # ran. The _SEQ will run as this target once _DEP is satisfied.
6625
6626 .for target in extract patch configure build stage install package
6627
6628 # Check if config dialog needs to show and execute it if needed. If is it not
6629 # needed (_OPTIONS_OK), then just depend on the cookie which is defined later
6630 # to depend on the *_DEP and execute the *_SEQ.
6631 # If options are required, execute config-conditional and then re-execute the
6632 # target noting that config is no longer needed.
6633 .if !target(${target}) && defined(_OPTIONS_OK)
6634 _PHONY_TARGETS+= ${target}
6635 ${target}: ${${target:tu}_COOKIE}
6636 .elif !target(${target})
6637 ${target}: config-conditional
6638         @cd ${.CURDIR} && ${MAKE} CONFIG_DONE_${UNIQUENAME:tu}=1 ${${target:tu}_COOKIE}
6639 .elif target(${target}) && defined(IGNORE)
6640 .endif
6641
6642 .if !exists(${${target:tu}_COOKIE})
6643
6644 # Define the real target behavior. Depend on the target's *_DEP. Execute
6645 # the target's *_SEQ. Also handle su and USE_SUBMAKE needs.
6646 .if ${UID} != 0 && defined(_${target:tu}_REAL_SUSEQ) && !defined(INSTALL_AS_USER)
6647 .  if defined(USE_SUBMAKE)
6648 ${${target:tu}_COOKIE}: ${_${target:tu}_DEP}
6649         @cd ${.CURDIR} && ${MAKE} ${_${target:tu}_REAL_SEQ}
6650 .  else  # !USE_SUBMAKE
6651 ${${target:tu}_COOKIE}: ${_${target:tu}_DEP} ${_${target:tu}_REAL_SEQ}
6652 .  endif # USE_SUBMAKE
6653         @${ECHO_MSG} "===>  Switching to root credentials for '${target}' target"
6654         @cd ${.CURDIR} && \
6655                 ${SU_CMD} "${MAKE} ${_${target:tu}_REAL_SUSEQ}"
6656         @${ECHO_MSG} "===>  Returning to user credentials"
6657         @${TOUCH} ${TOUCH_FLAGS} ${.TARGET}
6658 .else # No SU needed
6659 .  if defined(USE_SUBMAKE)
6660 ${${target:tu}_COOKIE}: ${_${target:tu}_DEP}
6661         @cd ${.CURDIR} && \
6662                 ${MAKE} ${_${target:tu}_REAL_SEQ} ${_${target:tu}_REAL_SUSEQ}
6663         @${TOUCH} ${TOUCH_FLAGS} ${.TARGET}
6664 .  else # !USE_SUBMAKE
6665 ${${target:tu}_COOKIE}: ${_${target:tu}_DEP} ${_${target:tu}_REAL_SEQ} ${_${target:tu}_REAL_SUSEQ}
6666         @${TOUCH} ${TOUCH_FLAGS} ${.TARGET}
6667 .  endif # USE_SUBMAKE
6668 .endif # SU needed
6669
6670 .else # exists(cookie)
6671 ${${target:tu}_COOKIE}::
6672         @if [ -e ${.TARGET} ]; then \
6673                 ${DO_NADA}; \
6674         else \
6675                 cd ${.CURDIR} && ${MAKE} ${.TARGET}; \
6676         fi
6677 .endif # !exists(cookie)
6678
6679 .endfor # foreach(targets)
6680
6681 .PHONY: ${_PHONY_TARGETS} check-sanity fetch pkg
6682
6683 .if !target(check-sanity)
6684 check-sanity: ${_SANITY_REAL_SEQ}
6685 .endif
6686
6687 .if !target(fetch)
6688 fetch: ${_FETCH_DEP} ${_FETCH_REAL_SEQ}
6689 .endif
6690
6691 .if !target(pkg)
6692 pkg: ${_PKG_DEP} ${_PKG_REAL_SEQ}
6693 .endif
6694
6695 .endif
6696 # End of post-makefile section.
6697
6698 .endif
6699 # End of the DESTDIR if statement