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