xref: /openbsd-src/share/man/man5/bsd.port.mk.5 (revision b2ea75c1b17e1a9a339660e7ed45cd24946b230e)
1.\" $OpenBSD: bsd.port.mk.5,v 1.43 2001/08/12 11:47:19 espie Exp $
2.\"
3.\" Copyright (c) 2000 Marc Espie
4.\"
5.\" All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\"    notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\"    notice, this list of conditions and the following disclaimer in the
14.\"    documentation and/or other materials provided with the distribution.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
17.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
20.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26.\"
27.Dd June 10 2000
28.Dt BSD.PORT.MK 5
29.Os
30.Sh NAME
31.Nm bsd.port.mk
32.Nd ports tree master Makefile fragment
33.Sh SYNOPSIS
34.Fd #include <bsd.port.mk>
35.Sh DESCRIPTION
36.Nm
37holds all the standard routines used by the ports tree.
38Some variables and targets are for its internal use only.
39The rest is documented here.
40.Pp
41Other BSD variants, as well as older versions of
42.Nm bsd.port.mk ,
43include other targets and variables.
44Conversion methods are outlined here.
45.Pp
46This is still incomplete; some variables and targets are not yet documented.
47Mostly because undocumented stuff has fuzzy semantics, and it hasn't been
48decided yet how to define it.
49.Sh TARGETS
50.Bl -tag -width do-configure
51.It Ar addsum
52Complete the ${CHECKSUM_FILE} record of checksums with files that have been
53added since
54.Ar makesum .
55Complain if anything does not match.
56.It Ar build , Ar all
57Default target.
58Build the port.
59Essentially invoke
60.Bd -literal
61env -i ${MAKE_ENV} ${MAKE_PROGRAM} ${MAKE_FLAGS} \\
62.Ed
63.Bd -literal
64	-f ${MAKE_FILE} ${ALL_TARGET}
65.Ed
66.It Ar checkpatch
67Debugging version of the
68.Ar patch
69target that simulates invoking
70.Xr patch 1 .
71.It Ar checksum
72Check distribution archives and distribution patches control sum against
73the results recorded in ${CHECKSUM_FILE},
74using the cryptographic signature utilities listed in ${PREFERRED_CIPHERS}.
75Normally ${ALLFILES}
76are checksummed, unless
77.Ev IGNOREFILES
78is set to a list of files to ignore.
79Invoking
80.Ar checksum
81with REFETCH=true
82will try to fetch a version of with mismatched checksums off the OpenBSD
83main archive site.
84.It Ar configure
85Configure the port.
86Might be a void operation.
87Unless overridden, configure creates the ${WRKBUILD}
88directory (see SEPARATE_BUILD), runs ${SCRIPTDIR}/configure if it exists,
89and runs whatever configuration methods are recorded in
90.Ev CONFIGURE_STYLE .
91.It Ar distpatch
92Apply distribution patches only.
93.It Ar do-patch
94Override for the default behavior of
95.Ar patch .
96It is usually better to override
97.Ar post-patch ,
98as
99.Ar patch
100needs to invoke
101.Ar distpatch
102directly for historical reasons.
103.It Ar extract
104Extract the distfiles under
105.Pa ${WRKDIST}
106(but see
107.Ev EXTRACT_ONLY ) .
108Refer to
109.Ev EXTRACT_CASES
110for a complete description.
111.It Ar fake
112Do a fake port installation, that is, simulate the port installation under
113${WRKINST}.
114Described in a separate section below.
115.It Ar fetch
116Fetch the distfiles and patchfiles.
117Each file of the
118.Ev DISTFILES
119and
120.Ev PATCHFILES
121lists is retrieved, if necessary, from the list of sites in
122.Ev MASTER_SITES ,
123with %SUBDIR% substituted with
124.Ev MASTER_SITE_SUBDIR .
125If a filename ends with a
126.Sq :0
127to
128.Sq :9
129extension, it will be retrieved from
130.Ev MASTER_SITES0
131to
132.Ev MASTER_SITES9
133instead.
134The ports framework uses
135.Pa ${DISTDIR}/${DIST_SUBDIR}
136(aliased to
137.Pa ${FULLDISTDIR} )
138to cache the ports distribution files and patch files.
139Note that this framework is also used by mirroring scripts,
140which will also retrieve
141.Ev SUPDISTFILES ,
142to fill with supplementary distribution files which are not needed for
143every configuration.
144See
145.Ev ALLFILES ,
146.Ev CDROM_SITE ,
147.Ev DISTDIR ,
148.Ev DISTFILES ,
149.Ev DIST_SUBDIR ,
150.Ev FETCH_SYMLINK_DISTFILES ,
151.Ev FULL_DISTDIR ,
152.Ev MASTER_SITES ,
153.Ev MASTER_SITES0 , ... ,
154.Ev MASTER_SITES9 ,
155.Ev PATCH_FILES ,
156.Ev SUPDISTFILES ,
157.Ev REFETCH .
158.It Ar makesum
159Create the ${CHECKSUM_FILE} list of recorded checksums by running the
160cryptographic fingerprints sha1, md5 and rmd160 on ${ALLFILES} minus
161${IGNOREFILES}.
162.It Ar patch
163Apply distribution and
164.Ox
165specific patches.
166Because of historical accident,
167.Ar patch
168does not follow the exact same scheme other standard targets do.
169Namely,
170.Ar patch
171invokes
172.Ar pre-patch
173(if defined),
174.Ar do-patch ,
175and
176.Ar post-patch ,
177but the default
178.Ar do-patch
179target recurses through
180.Ar distpatch
181So, if the
182.Ar do-patch
183target is overridden, it should still begin by calling
184make distpatch, before applying
185.Ox
186specific patches.
187See
188.Ar distpatch
189for the distribution patches-specific description.
190If
191.Pa ${PATCHDIR}
192exists, the files described under
193.Ev PATCH_LIST
194will be applied under
195.Ev WRKDIST .
196.It Ar rebuild
197Force rebuild of the port.
198.It Ar show
199Invoked with VARNAME=name, show the contents of VARNAME.
200Mostly used from recursive makes, or to know the contents of another
201port's variables without guessing wrong.
202.El
203.Sh VARIABLES
204.Bl -tag -width MASTER_SITES
205.It Ev show
206Invoked as make show=name, show the contents of variable name.
207.It Ev ALLFILES
208List of all files that need to be retrieved by
209.Ar fetch ,
210with master site selection extension removed. Read-only.
211.It Ev ALL_TARGET
212Target used to build software.
213Default is
214.Sq all .
215Can be set to empty, to yield a package's default target.
216.It Ev ARCH
217Current machine architecture (read-only).
218.It Ev AUTOCONF
219Location of the autoconf binary if needed.
220Defaults to autoconf (though make autoreconf might be more appropriate).
221.It Ev AUTOCONF_DIR
222Where to invoke autoconf if ${CONFIGURE_STYLE} includes autoconf.
223Defaults to ${WRKSRC}.
224.\" AUTOCONF_DIR should probably be a list, and be renamed to AUTOCONF_DIRS ?
225.It Ev BSD_INSTALL_{PROGRAM,SCRIPT,DATA,MAN}[_DIR]
226Macros passed to make and configure invocations.
227Set based on corresponding INSTALL_* variables.
228.It Ev BUILD_DEPENDS
229List of other ports the current port needs to build correctly.
230Each item has the form
231.Sq file_to_test::directory[,-subpackage][,flavor ...][:target] .
232The double :: is designed to allow wedging a package specification in the
233near future.
234.Sq target
235defaults to
236.Sq install
237if it is not specified.
238.Sq file_to_test
239is checked against the current path for ports (see PORTPATH), or as an absolute
240file name.
241The special name /nonexistent can be used to force a build
242dependency (see the ghostscript port for an example).
243.Sq directory
244is set relative to ${PORTSDIR}.
245.Sq subpackage
246is an optional subpackage name, to install instead of the default main
247package name.
248.Sq flavor ...
249is a comma separated list of flavors.
250By default, the dependency will build the default flavor.
251Build dependencies are checked at the beginning of the extract stage.
252.It Ev BZIP2
253Name of the bzip2 binary.
254.It Ev CATEGORIES
255List of descriptive categories into which this port falls.
256Mandatory.
257See
258.Ar link-categories ,
259.Ar unlink-categories .
260.It Ev CDROM_PACKAGES
261Base location where packages suitable for a CDROM (see
262PERMIT_PACKAGE_CDROM) will be placed
263(default: ${PORTSDIR}/cdrom-packages/${ARCH})
264.It Ev CDROM_SITE
265Path to a local database that holds distribution files (usually a CD-Rom
266or other similar media), used to retrieve distribution files before going
267to the network.
268Defaults to
269.Pa /cdrom/distfiles
270if this path exists.
271Distribution files are still copied or linked (see
272.Ev FETCH_SYMLINK_DISFILES )
273into
274.Ev DISTDIR
275if they are found under CDROM_SITE.
276.It Ev CFLAGS
277Default flags passed to the compiler for building.
278Many ports ignore it.
279See also
280.Ev COPTS .
281.It Ev CHECKSUM_FILE
282Location for this port checksums, used by
283.Ar addsum ,
284.Ar checksum ,
285and
286.Ar makesum .
287Defaults to ${FILESDIR}/md5.
288.It Ev CLEANDEPENDS
289If set to
290.Sq Yes
291.Sq make clean
292will also clean dependencies.
293Note that distclean never recurses down to dependencies.
294.It Ev COMMENT
295Comment used for the package, and in the INDEX.
296.It Ev COMMENT-foo
297Comment used for sub package foo in a multi-package set up.
298.It Ev COMMENT-vanilla
299Comment used for a flavored package, if the non-flavored comment is
300inappropriate.
301.It Ev COMMENT-foo-vanilla
302Comment used for a sub-, flavored package.
303.It Ev CONFIGURE_ARGS
304Arguments to pass to configure script.
305Defaults are empty, except for
306gnu-style configure, where prefix and sysconfdir are set.
307.It Ev CONFIGURE_ENV
308Basic environment passed to configure script (path and libtool setup).
309gnu-style configure adds a lot more variables.
310.It Ev CONFIGURE_SCRIPT
311Set to name of script invoked by
312.Ar configure
313target, if appropriate.
314Should be relative to ${WRKSRC}.
315.It Ev CONFIGURE_SHARED
316Set to --enable-shared or --disable-shared, depending whether the
317architecture supports shared libraries.
318Should be appended to CONFIGURE_ARGS, for ports that build dynamic libraries
319and whose configure script supports these options.
320.It Ev CONFIGURE_STYLE
321Set to style of configuration that needs to happen.
322If
323.Sq perl ,
324assume
325.Xr perl 1
326.Xr ExtUtils::MakeMaker 3p
327style.
328If
329.Sq gnu ,
330assume
331gnu configure style.
332Add
333.Sq dest
334if port does not handle DESTDIR correctly, and needs to be configured to
335add DESTDIR to prefixes
336.Po
337see also
338.Ev DESTDIRNAME
339.Pc .
340Add
341.Sq old
342if port is an older autoconf port, that does not recognize --sysconfdir.
343Add
344.Sq autoconf
345if autoconf needs to be rerun first.
346If
347.Sq imake ,
348assume port configures using X11 ports Imakefile framework.
349Add
350.Sq noman
351if port has no man pages the Imakefile should try installing.
352If
353.Sq simple ,
354there is a configure script, but it does not fit the normal gnu configure
355conventions.
356.It Ev COPTS
357Supplementary options appended to ${CFLAGS} for building.
358Since most ports ignore the COPTS convention, they are actually told to use
359${CFLAGS} ${COPTS} as CFLAGS.
360.It Ev CXXOPTS
361Supplementary options appended to ${CXXFLAGS} for building.
362.It Ev DEF_UMASK
363Correct value of umask for the port to build and package correctly.
364Tested against the actual umask at
365.Ar fake
366time.
367Default is 022.
368Don't override.
369.It Ev DESTDIRNAME
370Name of variable to set to ${WRKINST} while faking.
371Usually DESTDIR.
372To be used in the rare cases where a port heeds DESTDIR in a few
373directories and needs to be configured with
374.Sq gnu dest ,
375so that those few directories do not get in the way.
376.It Ev DISTDIR
377Directory where all ports distfiles and patchfiles are stashed.
378Defaults to
379.Pa ${PORTSDIR}/distfiles.
380Override if distfiles are stored elsewhere.
381Always use
382.Ev FULLDISTDIR
383to refer to ports' distfiles location, as it takes an eventual
384.Ev DIST_SUBDIR
385into account.
386.It Ev DISTFILES
387The main port distribution files (the actual software source, except
388for binary-only ports).
389Will be retrieved from the MASTER_SITES (see
390.Ar fetch ) ,
391checksummed and extracted (see
392.Ar checksum ,
393.Ar extract ) .
394normally holds a list of files, possibly with :0
395.Ev DISTFILES
396normally holds a list of files, possibly with
397.Sq 0
398to
399.Sq 9
400appended to select a different
401.Ev MASTER_SITES .
402See also
403.Ev SUPDISTFILES .
404.It Ev DISTNAME
405Name used to identify the port.
406See
407.Ev DISTFILES
408and
409.Ev PKGNAME .
410.It Ev DISTORIG
411Suffix used by
412.Ar distpatch
413to rename original files.
414Defaults to
415.Pa .bak.orig .
416Distinct from
417.Pa .orig
418to avoid confusing
419.Ar update-patches .
420.It Ev DIST_SUBDIR
421Optional subdirectory of ${DISTDIR} where the current port's distfiles
422and patchfiles will be located.
423See target
424.Ar fetch.
425.It Ev ECHO_MSG
426Used to display
427.Sq ===> Configuring for foo
428and similar informative messages.
429Override to turn off, for instance.
430.It Ev ERRORS
431List of errors found while parsing the port's Makefile.
432Display the errors before making any target, and if any error starts with
433.Qq Fatal: ,
434do not make anything.
435For instance:
436.Bd -literal -indent
437\&.if !defined(COMMENT)
438ERRORS+="Fatal: Missing comment"
439\&.endif
440.Ed
441.It Ev EXTRACT_CASES
442In the normal extraction stage (when
443.Ev EXTRACT_ONLY
444is not empty), this is the contents of a case statement, used to extract files.
445Fragments are automatically appended to extract tar and zip
446archives, so that the default case is equivalent to the following shell
447fragment:
448.Bd -literal -indent
449set -e
450cd ${WRKDIR}
451for archive in ${EXTRACT_ONLY}
452do
453    case $$archive in
454	*.zip)
455	  unzip -q ${FULLDISTDIR}/$$archive -d ${WRKDIR};;
456	*.tar.bz2)
457	  bzip2 -dc ${FULLDISTDIR}/$$archive| tar xf -;;
458	*.shar.gz|*.shar.Z|*.sh.Z|*.sh.gz)
459	  gzcat ${FULLDISTDIR}/$$archive | /bin/sh;;
460	*.shar|*.sh)
461	  /bin/sh ${FULLDISTDIR}/$$archive;;
462	*.tar)
463	  tar xf ${FULLDISTDIR}/$$archive;;
464	*)
465	  gzip -dc ${FULLDISTDIR}/$$archive | tar xf -;;
466    esac
467done
468.Ed
469.It Ev EXTRACT_ONLY
470Set if not all ${DISTFILES} should be extracted at do-extract stage.
471Default value is ${DISTFILES}.
472.It Ev EXTRACT_SUFX
473Used to set DISTFILES default value to ${DISTNAME}${EXTRACT_SUFX}.
474Default value is .tar.gz.
475.It Ev FAKE
476Automatically set to
477.Sq Yes
478for most ports (and all new ports).
479Indicates that the port, using
480.Ev FAKE_FLAGS
481magic, will properly fake installation into ${WRKINST}, to be packaged
482and properly installed from the package.
483Set to
484.Sq No
485in very rare cases, and during port creation.
486.It Ev FAKE_FLAGS
487Flags passed to ${MAKE_PROGRAM} on fake invocation.
488By default, ${DESTDIRNAME}=${WRKINST}.
489.It Ev FETCH_CMD
490Command used to fetch distfiles for this port.
491Defaults to
492.Pa /usr/bin/ftp .
493No current port overrides the default.
494.It Ev FETCH_DEPENDS
495See BUILD_DEPENDS for specification.
496Fetch dependencies are checked at the beginning of the extract stage.
497No current port uses FETCH_DEPENDS.
498.It Ev FETCH_SYMLINK_DISTFILES
499Set to
500.Sq Yes
501to link distribution files off
502.Ev CDROM_DISTSITE
503instead of copying them.
504.It Ev FILESDIR
505Location of other files related to the current ports.
506Holds at least the checksum file, sometimes other files
507(default: files.${ARCH} or files).
508.It Ev FLAVOR
509The port current options.
510Set by the user, and tested by the port to activate wanted functionalities.
511.It Ev FLAVORS
512List of all flavors keywords a port may match.
513Used to sort FLAVOR into a canonical order to build the package name,
514or to select the packing-list, and as a quick validity check.
515.It Ev FLAVOR_EXT
516Canonical list of flavors being set for the current build, dash-separated.
517See
518.Ev FULLPKGNAME .
519.It Ev FTP_PACKAGES
520Base location where packages suitable for ftp (see
521PERMIT_PACKAGE_FTP) will be placed
522(default: ${PORTSDIR}/ftp-packages/${ARCH})
523.It Ev FULLPKGNAME
524Full name of the main created package, taking flavors into account.
525Defaults to ${PKGNAME}${FLAVOR_EXT}.
526.It Ev FULLPKGNAME-foo
527Full package name for sub-package foo, if the default value is not
528appropriate.
529.It Ev GMAKE
530Location of the gnu make binary, if needed.
531Defaults to gmake.
532.It Ev IGNOREFILES
533Set to the list of files that cannot be checksummed.
534For use by ports which
535fetch dynamically generated archives that can't be checksummed.
536.It Ev LIB_DEPENDS
537Libraries this port depends upon.
538Similar to BUILD_DEPENDS, except that
539.Sq file_to_test
540is replaced by a
541.Sq lib_spec
542of the form:
543.Sq libname.[version.[subversion]] .
544See BUGS AND LIMITATIONS as well.
545.Pp
546On architectures that use dynamic libraries,
547.Ev LIB_DEPENDS
548is also used as a running time dependency, and recorded in the package as
549such.
550.It Ev FULLDISTDIR
551Complete path to directory where ${DISTFILES} and ${PATCHFILES} will be
552located, to be used in hand-crafted extraction targets (read-only).
553.It Ev INSTALL_{PROGRAM,SCRIPT,DATA,MAN}[_DIR]
554Macros to use to install a program, a script, a man page, or data (or the
555corresponding directory, respectively).
556.It Ev INSTALL_TARGET
557Target invoked to install the software, during fake installation.
558Default is
559.Sq install .
560.It Ev IS_INTERACTIVE
561Set to
562.Sq Yes
563if port needs human interaction to build.
564Usually implies NO_PACKAGE as well.
565Porters should strive to minimize IS_INTERACTIVE ports, by using
566FLAVORS for multiple choice ports, and by postponing human intervention
567to package installation time.
568.It Ev LIBTOOL
569Location of the libtool binary for ports that set
570.Ev USE_LIBTOOL
571(default: ${LOCALBASE}/bin/libtool).
572.It Ev LIBTOOL_FLAGS
573Arguments to pass to libtool.
574If USE_LIBTOOL is set, the environment variable LIBTOOL is set
575to ${LIBTOOL} ${LIBTOOL_FLAGS}.
576.It Ev LOCALBASE
577where other ports have already been installed (default: /usr/local)
578.It Ev MAINTAINER
579E-mail address with full name of the port's maintainer.
580Defaults to ports@openbsd.org.
581.It Ev MAKE_ENV
582Environment variables passed to make invocations.
583Sets at least PATH, PREFIX, LOCALBASE, X11BASE, CFLAGS, TRUEPREFIX, DESTDIR,
584and the BSD_INSTALL_* macros.
585.It Ev MAKE_FLAGS
586Flags used for all make invocations, except for the fake stage, which uses
587FAKE_FLAGS.
588.It Ev MAKE_FILE
589Name of the Makefile used for ports building.
590Defaults to Makefile.
591Used after changing directory to ${WRKBUILD}.
592.It Ev MAKE_PROGRAM
593The make program that is used for building the port.
594Set to ${MAKE} or ${GMAKE} depending on USE_GMAKE.
595Read-only.
596.It Ev MESSAGE
597File recorded in the package and displayed during installation.
598Defaults to ${PKGDIR}/MESSAGE if this file exists.
599Leave empty if no message is needed.
600.It Ev MTREE_FILE
601.Xr mtree 8
602specification to check when creating a PLIST with the
603.Ar plist
604target.
605.Ev MTREE_FILE
606can hold a list of file names, to which
607.Pa ${PORTSDIR}/infrastructure/db/fake.mtree
608is always appended.
609These specifications are rooted at
610.Pa ${WRKINST} ,
611and are subject to
612.Ev SUBST_VARS
613substitution, to ease
614.Pa ${PREFIX}
615independence.
616This feature is primarily intended for large, interconnected ports,
617such as the kde suite, where a base package sets up a large, extra
618directory hierarchy that would make the manual checking of packing lists
619tedious.
620.It Ev MULTI_PACKAGES
621Set to a list of package extensions for ports that create multiple packages.
622See
623.Qq Flavors and multi-packages
624below.
625.Pp
626.It Ev NEED_VERSION
627Specific revision of
628.Nm
629needed by this ports tree.
630Usually set to the current version of
631.Nm
632when port was built, and updated by port maintainers when needed.
633.It Ev NOT_FOR_ARCHS
634List of architectures on which this port does not build.
635See also
636.Ev ONLY_FOR_ARCHS .
637.It Ev NO_BUILD
638Port does not need any build stage.
639.It Ev NO_DEPENDS
640Don't verify build of dependencies.
641Do not use in any ports Makefile.
642This is only meant as a user convenience when, e.g., you just want to browse
643through a given port's source and do not wish to trigger the build of
644dependencies.
645.It Ev NO_SHARED_ARCHS
646Set to the list of platforms that do not support shared libraries.
647Use with
648.Ev NOT_FOR_ARCHS .
649.It Ev NO_SHARED_LIBS
650Set to
651.Sq Yes
652if platform does not support shared libraries.
653To be tested after including
654.Nm bsd.port.mk ,
655if neither PFRAG.shared nor CONFIGURE_SHARED are enough.
656.It Ev ONLY_FOR_ARCHS
657List of architectures on which this port builds.
658Can hold both processor-specific information (e.g., m68k), and more
659specific model information (e.g., amiga).
660.It Ev OPSYS
661Always
662.Ox
663(read-only).
664.It Ev OPSYS_VER
665Revision number of
666.Ox
667(read-only).
668.It Ev PACKAGES
669Base location for packages built (default: ${PORTSDIR}/packages/${ARCH}).
670.It Ev PATCH
671Command to use to apply all patches.
672Defaults to
673.Pa /usr/bin/patch .
674.It Ev PATCH_CASES
675In the normal distpatch stage (when
676.Ev PATCHFILES
677is not empty), this is the contents of a case statement, used to apply
678distribution patches.
679Fragments are automatically appended to handle gzip'ed and bzip'ed
680patches, so that the default case is equivalent to the following shell
681fragment:
682.Bd -literal -indent
683set -e
684cd ${FULLDISTDIR}
685for patchfile in ${_PATCHFILES}
686do
687    case $$patchfile in
688	*.bz2)
689	  bzip2 -dc $$patchfile | ${PATCH} ${PATCH_DIST_ARGS};;
690	*.Z|*.gz)
691	  gzcat $$patchfile | ${PATCH} ${PATCH_DIST_ARGS};;
692	*)
693	  ${PATCH} ${PATCH_DIST_ARGS} <$$patchfile;;
694    esac
695done
696.Ed
697.It Ev PATCHDIR
698Location for patches applied by patch target (default: patches.${ARCH} or
699patches).
700.It Ev PATCHFILES
701Files to fetch from the master sites like
702.Ev DISTFILES ,
703but serving a different purpose, as they hold distribution patches that
704will be applied at the
705.Ar patch
706stage.
707See also
708.Ev SUPDISTFILES .
709.It Ev PATCH_ARGS
710Full list of options used while applying port's patches.
711.It Ev PATCH_CHECK_ONLY
712Set to Yes by the
713.Ar checkpatch
714target.
715Don't touch unless the default
716.Ar checkpatch
717target needs to be redefined.
718Ideally, user-defined patch subtargets ought to test checkpatch.
719In practice, they don't.
720.It Ev PATCH_DEBUG
721If set to
722.Sq Yes ,
723the
724.Ar patch
725stage will output extra debug information.
726.It Ev PATCH_DIST_ARGS
727Full list of options used while applying distribution patches.
728.It Ev PATCH_DIST_STRIP
729Patch option used to strip directory levels while applying distribution
730patches.
731Defaults to -p0 .
732.It Ev PATCH_LIST
733Wildcard pattern of patches to select under ${PATCHDIR} (default: patch-*).
734Note that filenames ending in .orig, or ~ are never applied.
735.It Ev PATCH_STRIP
736Patch option used to strip directory levels while applying port's patches.
737Defaults to -p0 .
738.It Ev PORTPATH
739Path used by most shell invocations.
740Don't override unless really needed.
741.It Ev PORTSDIR
742Root of the ports tree (default: /usr/ports).
743.It Ev PKGDIR
744Location for packaging information (packing list, port description, port
745short description).
746Default: pkg.${ARCH} or pkg.
747.It Ev PKGNAME
748Name of the main created package.
749Default is ${DISTNAME} for the main package,
750and ${DISTNAME} for multi-packages ports.
751This does not take flavors into account.
752See
753.Ev FULLPKGNAME
754for that.
755.It Ev PKGNAME-foo
756Package name for sub-package foo, if the default value
757of ${PKGNAME}${SUBPACKAGE} is not appropriate.
758.It Ev PKGPATH
759Path to the current port's directory, relative to ${PORTSDIR}.
760Read-only.
761.It Ev PREFERRED_CIPHERS
762List of cryptographic ciphers to use, in order of preference.
763Default is
764.Sq sha1 rmd160 md5 .
765The first cipher that matches in ${CHECKSUM_FILE} is verified.
766.It Ev PREFIX
767Base directory for the current port installation.
768Usually ${LOCALBASE}, though some ports may elect a location under /var,
769and some multi-package ports may install under several locations.
770.It Ev REFETCH
771If set to true,
772.Ar checksum
773will analyze ${CHECKSUM_FILE}, and try retrieving files with the correct
774checksum off ftp.openbsd.org, in the directory
775.Pa /pub/OpenBSD/distfiles/$cipher/$value/$file .
776.It Ev RUN_DEPENDS
777Specification of ports this port needs installed to be functional.
778Same format as BUILD_DEPENDS.
779The corresponding packages will be built at
780.Ar install
781stage, and
782.Xr pkg_add 1
783will take care of installing them.
784.It Ev SED_PLIST
785Pipeline of commands used to create the actual packing list from the
786PLIST template (usually ${PKGDIR}/PLIST).
787.Nm
788appends to it substitution commands corresponding to the port's
789FLAVOR and variables from SUBST_VARS.
790${SED_PLIST} is invoked as a pipeline after inserting PFRAG.shared fragments.
791.It Ev SCRIPTDIR
792Location for scripts related to the current port (default: scripts.${ARCH}
793or scripts).
794.It Ev SEPARATE_BUILD
795Many gnu configure ports can be built in a directory distinct from the
796place they were unpacked.
797For some specific ports, this is even mandatory.
798Set to
799.Sq simple
800if this is the case.
801The ports infrastructure will generate a separate ${WRKBUILD} directory
802in which the port will be configured and built.
803Wipe ${WRKBUILD} to start anew, but skipping the extract/patch stage.
804Set to
805.Sq concurrent
806if the build process does not modify anything under ${WRKSRC}.
807The build process can then be run concurrently on different architectures.
808Set to
809.Sq flavored
810if distinct flavors of the port may share a common source tree.
811.It Ev SUBPACKAGE
812Set to the sub package suffix when building a package in a multi-package port.
813Read-only.
814Used to test for dependencies or to adjust the package name.
815.It Ev SUBST_VARS
816Make variables whole values get substituted to create the actual package
817information.
818Always holds
819.Ev ARCH ,
820.Ev HOMEPAGE ,
821.Ev PREFIX ,
822and
823.Ev SYSCONFDIR .
824The special construct
825.Sq ${FLAVORS}
826can be used in the packing-list to specify the current list of dash
827separated flavors the port is compiled with (useful for cross-dependencies
828in
829.Ev MULTI_PACKAGES ) .
830Add other
831variables as needed.
832.It Ev SUPDISTFILES
833Supplementary files that need to be retrieved under some specific
834circumstances. For instance, a port might need architecture-specific files.
835.Ev SUPDISTFILES
836should hold a list of all distfiles and patchfiles that are not always
837needed, so that a mirror will be able to grab all files, or that
838.Ar makesum
839will work.
840Having an overlap between
841.Ev SUPDISTFILES
842and
843.Ev DISTFILES ,
844.Ev PATCHFILES
845is admissible, and in fact, expected, as it is much simpler to build
846an error-free list of files to retrieve in that way.
847See the xanim port for an example.
848.It Ev SYSCONFDIR
849Location for ports system configuration files.
850Defaults to
851.Pa /etc ,
852should never be set to
853.Pa /usr/local/etc .
854.It Ev TAR
855Name of the tar binary.
856.It Ev TEMPLATES
857Base location for the templates used in the
858.Ar readme
859target.
860.It Ev UNZIP
861Name of the unzip binary.
862.It Ev WRKBUILD
863Subdirectory of ${WRKDIR} where the actual build occurs.
864Defaults to ${WRKSRC}, unless SEPARATE_BUILD is involved, in which case
865it is set to an appropriate value.
866.It Ev WRKDIR
867Location where all port activity occurs.
868Apart from the actual port, may
869hold all kinds of cookies that checkpoint the port's build.
870Read-only.
871Ports that need to know the WRKDIR of another port must use
872cd that_port_dir && make show VARNAME=WRKDIR for this.
873Note that WRKDIR may be a symbolic link.
874.It Ev WRKDIST
875Subdirectory of ${WRKDIR} where the source normally unpacked.
876Base for all patches (default: ${WRKDIR}/${DISTNAME}).
877Note that WRKDIST may be a symbolic link, if set to ${WRKDIR}.
878.It Ev WRKSRC
879Subdirectory of ${WRKDIR} where the actual source is.
880Base for configuration (default: ${WRKDIST})
881Note that WRKSRC may be a symbolic link, if set to ${WRKDIR}.
882.It Ev WRKPKG
883Subdirectory of ${WRKBUILD} where package information gets generated.
884Defaults to ${WKRBUILD}/pkg, do not override unless
885.Sq pkg
886conflicts with the port's conventions.
887.It Ev WRKINST
888Subdirectory of ${WRKDIR} where port normally installs (see
889.Ar fake
890target).
891.It Ev WRKOBJDIR
892If defined, used as a base for the actual port working directory.
893The real working directory is created there, and the port ${WRKDIR} is
894just a link.
895.It Ev X11BASE
896Where X11 has been installed (default: /usr/X11R6).
897.It Ev USE_GMAKE
898Set to
899.Sq Yes
900if gnu make (${GMAKE}) is needed for correct behavior of this port.
901.It Ev USE_LIBTOOL
902Set to
903.Sq Yes
904if libtool is required for correct behavior of this port.
905Add correct dependencies, and passes LIBTOOL environment variable to
906scripts invocations.
907.It Ev USE_MOTIF
908Set to
909.Sq any
910if port works with any version of motif;
911.Sq lesstif
912if port requires lesstif to work;
913.Sq openmotif
914if ports requires openmotif to work.
915The
916.Sq any
917setting creates an extra flavor choice of
918.Sq lesstif .
919.It Ev XMKMF
920Invocation of xmkmf for CONFIGURE_STYLE=imake port.
921Defaults to xmkf -a -DPorts.
922The -DPorts is specific to
923.Ox
924and is always appended.
925.It Ev YACC
926Name of yacc program to pass to gnu-configure, defaults to yacc.
927(gnu-configure would always try to use bison otherwise, which leads to
928unreproducible builds.)
929Set to bison if needed.
930.El
931.Sh FILES
932.Bl -tag -width files/md5
933.It Pa ../Makefile.inc
934Common Makefile fragment for a set of ports, included automatically.
935.It Pa /cdrom/distfiles
936Default path to a CD-Rom (or other media) full of distribution files.
937.It Pa Makefile.${ARCH}
938Arch-dependent Makefile fragment, included automatically.
939.It Pa ${DISTDIR}
940cache of all distribution files.
941.It Pa ${FILESDIR}/md5
942Checksum file.
943Holds the output of
944.Xr md5 1 ,
945.Xr sha1 1 ,
946and
947.Xr rmd160 1
948for the ports ${DISTFILES} and ${PATCHFILES}.
949.It Pa ${FULLDISTDIR}/${ALLFILES}
950cache of distribution files for a given port.
951.It Pa ${PKGDIR}/DESCR
952Description for the port.
953Variables such as ${HOMEPAGE} will be expanded
954(see SUBST_VARS).
955Multi-package ports will use DESCR${SUBPACKAGE}.
956.It Pa ${PKGDIR}/COMMENT
957Short, one line description of the port, that is displayed by
958.Xr pkg_info 1 ,
959and appears in
960.Pa ${PORTSDIR}/INDEX .
961Name will be adjusted for flavored and multi-packages ports.
962.It Pa ${PORTSDIR}/infrastructure/db/fake.mtree
963Specification used for populating ${WRKINST} at the start of
964.Ar fake .
965Use
966.Ar pre-fake
967if this is incomplete.
968.El
969.Sh OBSOLETE TARGETS
970.Bl -tag -width do-configure
971.It Ar {pre,do}-extract
972Don't override.
973Set
974.Ev EXTRACT_ONLY
975to nothing and override
976.Ar post-extract
977instead.
978.It Ar fetch-all , Ar fetch-list , Ar mirror-distfiles
979See
980.Xr mirroring-ports 7
981for more efficient and flexible ways to build mirrors.
982.El
983.Sh OBSOLETE VARIABLES
984.Bl -tag -width MASTER_SITES
985.It Ev COMMENT
986Used to be the name of the comment file for a package.
987It now holds the comment itself.
988Some magic has been put in to allow for a seamless transition.
989.It Ev DESCR_SRC
990From
991.Nx .
992This is DESCR.
993.Ox
994does not give a specific name to the generated file.
995It is not recommended to try to access them directly.
996.It Ev EXTRACT_AFTER_ARGS
997Was used to cobble together the normal extraction command, as
998${EXTRACT_CMD} ${EXTRACT_BEFORE_ARGS} ${EXTRACT_AFTER_ARGS}.
999Use
1000.Ev EXTRACT_CASES
1001instead.
1002.It Ev EXTRACT_BEFORE_ARGS
1003Likewise, use
1004.Ev EXTRACT_CASES
1005instead.
1006.It Ev EXTRACT_CMD
1007Likewise, use
1008.Ev EXTRACT_CASES
1009instead.
1010.It Ev USE_BZIP2
1011Use
1012.Ev EXTRACT_SUFX
1013or
1014.Ev EXTRACT_CASES
1015instead.
1016.It Ev USE_ZIP
1017Use
1018.Ev EXTRACT_SUFX
1019or
1020.Ev EXTRACT_CASES
1021instead.
1022.It Ev GNU_CONFIGURE
1023Use
1024.Ev CONFIGURE_STYLE
1025instead.
1026.It Ev HAS_CONFIGURE
1027Use
1028.Ev CONFIGURE_STYLE
1029instead.
1030.It Ev MASTERDIR
1031From
1032.Fx .
1033Used to organize a collection of ports that share most files.
1034.Ox
1035uses a single port with flavors or multi-packages to produce
1036package variations instead.
1037.It Ev MD5_FILE
1038Use
1039.Ev CHECKSUM_FILE
1040instead.
1041.It Ev MIRROR_DISTFILE
1042Use
1043.Ev PERMIT_DISTFILES_FTP
1044and
1045.Ev PERMIT_DISTFILES_CDROM
1046to determine which files can be mirrored instead.
1047See
1048.Xr mirroring-ports 7 .
1049.It Ev NO_CONFIGURE
1050If ${FILESDIR}/configure does not exist, no automatic configuration will
1051be done anyway.
1052.It Ev NO_EXTRACT
1053Set EXTRACT_ONLY= instead.
1054.It Ev NO_INSTALL_MANPAGES
1055Use
1056.Ev CONFIGURE_STYLE
1057instead.
1058.It Ev NO_MTREE
1059Starting with
1060.Ox 2.7 ,
1061the operating system installation script runs the /usr/local specification
1062globally, instead of embedding it in each package.
1063So packages no longer record an
1064.Xr mtree 8
1065specification.
1066Use an explicit
1067.Sq @exec
1068command if needed.
1069.It Ev NO_PATCH
1070The absence of a patches directory does the same.
1071Use PATCHDIR and PATCH_LIST if patches need to be changed dynamically.
1072.It Ev NO_WRKDIR
1073All ports should have a working directory, as this is necessary to store
1074cookies and keep state.
1075.It Ev NO_WRKSUBDIR
1076The same functionality is obtained by setting WRKDIST=${WRKDIR} .
1077.It Ev NOCLEANDEPENDS
1078Use CLEANDEPENDS instead.
1079.It Ev NOMANCOMPRESS
1080.Fx
1081ships with compressed man pages, and uses this variable to control
1082that behavior.
1083.It Ev PATCH_SITES
1084.Ev PATCHFILES
1085used to be retrieved from a separate site list.
1086For greater flexibility, all files are now retrieved from
1087.Ev MASTER_SITES ,
1088.Ev MASTER_SITES0 , ...,
1089.Ev MASTER_SITES9 ,
1090using a
1091.Sq :0
1092to
1093.Sq :9
1094extension to the file name, e.g.,
1095.Bd -literal -offset indent
1096PATCH_FILES=foo.diff.gz
1097PATCH_SITES=ftp://ftp.zoinx.org/pub/
1098.Ed
1099.Pp
1100becomes
1101.Bd -literal -offset indent
1102PATCH_FILES=foo.diff.gz:0
1103MASTER_SITES0=ftp://ftp.zoinx.org/pub/
1104.Ed
1105.It Ev PLIST_SRC
1106From
1107.Nx .
1108This is PLIST.
1109.Ox
1110does not give a specific name to the generated file.
1111It is not recommended to try to access them directly.
1112.It Ev PKGNAME
1113Used to refer to the full package name, has been superseded by
1114.Ev FULLPKGNAME-foo ,
1115for
1116.Ev SUBPACKAGE
1117-foo .
1118.Ev PKGNAME
1119now holds the package name, not taking multi-packages nor flavors
1120into account.
1121Most ports are not concerned by this change.
1122.It Ev PLIST_SUBST
1123From
1124.Nx
1125and
1126.Fx .
1127Use SUBST_VARS instead.
1128.Ox
1129does not allow general substitutions of the form VAR=value, but uses
1130only a list of variables instead.
1131Most package files gets transformed, instead of only the packing list.
1132.It Ev USE_AUTOCONF
1133Use
1134.Ev CONFIGURE_STYLE
1135instead.
1136.It Ev USE_IMAKE
1137Use
1138.Ev CONFIGURE_STYLE
1139instead.
1140.El
1141.Sh OBSOLETE FILES
1142.Bl -tag -width files/md5
1143.It Pa ${SCRIPTDIR}/{pre,do,post}-*
1144Identical functionality can be obtained through a {pre,do,post}-* target,
1145invoking the script manually if necessary.
1146.It Pa ${PKGDIR}/PLIST.noshared
1147Use PFRAG.shared or PFRAG.no-shared instead.
1148PLIST.noshared was too easy to forget when updating ports.
1149.It Pa ${PKGDIR}/PLIST.sed
1150Use PLIST directly.
1151Until revision 1.295,
1152.Nm
1153did not substitute variables in the packing list unless this special form
1154was used.
1155.It Pa /usr/share/mk/bsd.port.mk
1156Original location of
1157.Nm bsd.port.mk .
1158The current file lives under ${PORTSDIR}/infrastructure/mk/bsd.port.mk,
1159whereas /usr/share/mk/bsd.port.mk is just a stub.
1160.It Pa {scripts,files,patches}.${OPSYS}
1161The
1162.Ox
1163ports tree focuses on robustness, not on being portable to other operating
1164systems.
1165In any case, portability should not need to depend on operating
1166system dependent patches.
1167.It Pa /usr/local/etc
1168Used by
1169.Fx
1170to marshall system configuration files.
1171All
1172.Ox
1173system configuration files are located in
1174.Pa /etc ,
1175or in a subdirectory of
1176.Pa /etc .
1177.El
1178.Sh THE FAKE FRAMEWORK
1179The
1180.Ar fake
1181target is used to install the port in a private directory first, package
1182that false installation, so that the real installation will use the
1183package.
1184.Pp
1185Essentially,
1186.Ar fake
1187invokes a real
1188.Ar install
1189process after tweaking a few variables.
1190.Pp
1191.Ar fake
1192first creates a skeleton tree under ${WRKINST}, using the
1193.Xr mtree 8
1194specification
1195.Pa ${PORTSDIR}/infrastructure/db/fake.mtree .
1196.Pp
1197A
1198.Ar pre-fake
1199target may be used to complete that skeleton tree.
1200For instance, a few ports may need supplementary stuff to be present (as
1201it would be installed if the ports' dependencies were present).
1202.Pp
1203If {pre,do,post}-install overrides are present, they are used with some
1204important changes: PREFIX is set to ${WRKINST}${PREFIX}, ${DESTDIRNAME}
1205is set to ${WRKINST}, and TRUEPREFIX is set to ${PREFIX}.
1206Essentially, old install targets work transparently, except for a need to
1207change PREFIX to TRUEPREFIX for symbolic links and similar path lookups.
1208Specific traditional post install work can be simply removed, as it will
1209be taken care of by the package itself (for instance, ldconfig, or
1210texinfo's install-info).
1211.Pp
1212If no do-install override is present, the port is installed using
1213.Bd -literal -indent offset
1214    env -i ${MAKE_ENV}
1215    PREFIX=${WRKINST}${PREFIX} ${DESTDIRNAME}=${WRKINST} TRUEPREFIX=${PREFIX}
1216    ${MAKE_PROGRAM} ${FAKE_FLAGS} -f ${MAKE_FILE} ${FAKE_TARGET}
1217.Ed
1218.Pp
1219Note that this does set both PREFIX and ${DESTDIRNAME}.
1220If a port's Makefile both heeds ${DESTDIRNAME},
1221and references PREFIX explicitly,
1222FAKE_FLAGS may rectify the problem by setting PREFIX=${PREFIX}
1223(which will do the right thing, since ${PREFIX} is a
1224.Xr make 1
1225construct which will not be seen by the shell).
1226.Pp
1227${FAKE_FLAGS} is used to set variables on
1228.Xr make 1
1229command line, which will override the port Makefile contents.
1230Thus, a port that mentions DESTDIR= does not need any patch to work with fake.
1231.Sh FLAVORS AND MULTI_PACKAGES
1232Starting with
1233.Ox 2.7 ,
1234each port can generate several packages through two orthogonal mechanisms:
1235FLAVORS and MULTI_PACKAGES.
1236.Pp
1237If a port can be compiled with several options, set FLAVORS to the list of
1238possible options in the Makefile.
1239When building the port, set
1240.Li "FLAVOR='option1 option2...'"
1241to build a specific flavor of the port.
1242The Makefile should test the value of FLAVOR as follows:
1243.Bd -literal
1244    FLAVOR?=
1245    .if ${FLAVOR:L:Moption1}
1246    # what to do if option1
1247    .endif
1248    .if ${FLAVOR:L:Moption2}
1249    # what to do if option2
1250    .endif
1251.Ed
1252.Pp
1253.Pa bsd.port.mk
1254takes care of a few details, such as generating a distinct work directory for
1255each flavor, or adding a dash separated list of options to the package
1256name.
1257The order in which FLAVOR is specified does not matter: the generated list,
1258called the canonical package extension, matches the ordering of FLAVORS.
1259Also, it is an error to specify an option in FLAVOR that does not appear
1260in FLAVORS.
1261.Pp
1262In recursive package building, flavors can be specified as a comma
1263separated list after the package directory, e.g., SUBDIR+=vim,no_x11.
1264.Pp
1265Finally, packing information will use templates with the canonical package
1266extension if they are available: if FLAVOR='option1 option2' and both
1267COMMENT and COMMENT-option1-option2 are available, COMMENT-option1-option2 will
1268be used.
1269.Pp
1270If a port can generate several useful packages, set MULTI_PACKAGES
1271accordingly.
1272Each extension of a MULTI_PACKAGES name should start with a dash, so that
1273they cannot be confused with FLAVORS.
1274In dependency checking and recursive builds, a subpackage can be
1275specified after a comma, e.g., SUBDIR+=quake,-server.
1276MULTI_PACKAGES only affects the actual package building step (and the
1277describe step, since a MULTI_PACKAGES port will produce several
1278descriptions).
1279.Pp
1280If MULTI_PACKAGES is set, each element of MULTI_PACKAGES triggers a
1281recursive make package, with SUBPACKAGE set to the right value, and
1282PACKAGING defined.
1283For instance, if MULTI_PACKAGES=-lib -server,
1284make package will work as follows:
1285.Pp
1286.Bl -bullet -compact
1287.It
1288Run make package SUBPACKAGE= PACKAGING=,
1289.It
1290Run make package SUBPACKAGE=-lib PACKAGING=-lib,
1291.It
1292Run make package SUBPACKAGE=-server PACKAGING=-server,
1293.El
1294.Pp
1295The port's Makefile can test the value of SUBPACKAGE to specialize
1296processing for all sub packages.
1297Note that SUBPACKAGE can also be set for dependency checking, so be
1298careful to also test PACKAGING: the build stage is shared among all
1299subpackages, and tests often only make sense during the packaging stage.
1300All packing information is derived from
1301templates with SUBPACKAGE appended.
1302In the preceding example, the packing-list template for pkgname-foo
1303must be in PLIST-foo.
1304.Sh THE GENERATION OF PACKING INFORMATION
1305Starting after
1306.Ox 2.7
1307(around revision 1.300 of bsd.port.mk), all packing information is
1308generated from templates in ${PKGDIR}.
1309.Pp
1310.Bl -bullet -compact
1311.It
1312If not overridden by the user, determine which set of templates to use,
1313depending on the current SUBPACKAGE and FLAVOR information.
1314Set ${PLIST}, ${DESCR}, ${COMMENT}, ${MESSAGE} accordingly.
1315.It
1316Detect the existence of ${PKGDIR}/{REQ,INSTALL,DEINSTALL}${SUBPACKAGE}.
1317Modify PKG_ARGS accordingly, to use the generated files, and add
1318dependencies to regenerate the files if the templates change.
1319.It
1320Generate the actual DESCR, and if needed, MESSAGE, REQ, INSTALL, DEINSTALL
1321from the templates in ${DESCR}, ${MESSAGE}, ${PKGDIR}/REQ${SUBPACKAGE},
1322${PKGDIR}/INSTALL${SUBPACKAGE}, ${PKGDIR}/DEINSTALL${SUBPACKAGE}, by
1323substituting the variables in ${SUBST_VARS}, and by substituting
1324${FLAVORS} with the canonical flavor extension for this port,
1325e.g, if FLAVORS=no_map gfx qt2, if FLAVOR=gfx no_map, this is
1326.Sq -no_map-gfx .
1327.It
1328Generate the actual PLIST from the template ${PLIST},
1329by inserting shared/no-shared fragments, applying a possible user-supplied
1330pipeline, merging other fragments, applying the same variable
1331substitutions as other packing information, and finally handling
1332dynamic libraries macros.
1333.El
1334.Pp
1335Note that ${COMMENT} is currently not substituted, to speed up
1336.Ar describe
1337generation.
1338.Pp
1339To avoid substitution, variables can be escaped as follows:
1340.Li "$\e{PREFIX}"
1341.Pp
1342Constructs such as the line
1343.Li "%%SHARED%%"
1344or
1345.Li "!%%SHARED%%"
1346in the packing-list template trigger the inclusion of the
1347.Pa ${PKGDIR}/PFRAG.shared${SUBPACKAGE}
1348or
1349.Pa ${PKGDIR}/PFRAG.no-shared${SUBPACKAGE} .
1350.br
1351Similarly, if FLAVORS lists flav1, then the line
1352.Li "%%flav1%%"
1353(resp.
1354.Li "!%%flav1%%" )
1355will trigger the inclusion of
1356.Pa ${PKGDIR}/PFRAG.flav1${SUBPACKAGE}
1357(resp.
1358.Pa ${PKGDIR}/PFRAG.no-flav1${SUBPACKAGE} )
1359in the packing-list.
1360Fragments that cannot be handled by these simple rules
1361can always be specified in a custom SED_PLIST.
1362.Pp
1363The constructs
1364.Li "DYNLIBDIR(directory)"
1365and
1366.Li "NEWDYNLIBDIR(directory)"
1367should be used in
1368.Pa ${PKGDIR}/PFRAG.shared${SUBPACKAGE}
1369to register directories that hold dynamic libraries (see
1370.Xr ldconfig 8 ).
1371.Li "NEWDYNLIBDIR"
1372is meant for directories that will go away when the package is deleted.
1373If possible, it should not be used, because users also have to edit
1374.Pa rc.conf
1375to add the directory.
1376It is usually better to also let libraries be visible as a link
1377under ${LOCALBASE}.
1378Having a separate directory is enough to trick
1379.Xr ld 1
1380into grabbing the right version.
1381Note that libraries used only for
1382.Xr dlopen 3
1383do not need NEWDYNLIDIR.
1384.Pp
1385The special
1386.Ar plist
1387target does a fairly good job of automatically generating PLIST and
1388PFRAG.shared fragments.
1389.Pp
1390In MULTI_PACKAGES mode, there must be separate COMMENT, DESCR, and PLIST
1391templates for each SUBPACKAGE (and optional distinct MESSAGE, REQ, INSTALL,
1392DEINSTALL files in a similar way).
1393This contrasts with the FLAVORS
1394situation, where all these files will automatically default to the
1395non-flavor version if there is no flavor-specific file around.
1396.Sh BUGS AND LIMITATIONS
1397.Ev LOCALBASE ,
1398.Ev X11BASE
1399and
1400.Ev PREFIX
1401are not heeded consistently.
1402Most of the ports tree will probably fall
1403apart if one tries to build/use stuff elsewhere.
1404.Pp
1405.Ev LIB_DEPENDS
1406is automatically both a BUILD_DEPENDS and a RUN_DEPENDS, whereas some
1407smarter, more intricate mechanism could be designed to minimize dependencies.
1408.Sh HISTORY
1409The ports mechanism originally came from
1410.Fx .
1411A lot of additions were taken from
1412.Nx
1413over the years.
1414.Pp
1415When the file grew too large, it was cleaned up to restore some of
1416its speed and remove a lot of bugs.
1417.Pp
1418FLAVORS, MULTI_PACKAGES and FAKE are
1419.Ox
1420improvements.
1421.\" Voluntarily undocumented:
1422.\" AUTOCONF_ENV: probably not needed anyway, should be internal.
1423.\"
1424.\" Todo: OBJMACHINE
1425.Sh SEE ALSO
1426.Xr packages-specs 7
1427