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