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