gettexticonvrc
      Scripts)This section explains the most common things to consider when creating a port.
bsd.port.mk expects ports to work
      with a “stage directory”.  This means that a port
      must not install files directly to the regular destination
      directories (that is, under PREFIX, for
      example) but instead into a separate directory from which the
      package is then built.  In many cases, this does not require
      root privileges, making it possible to build packages as an
      unprivileged user.  With staging, the port is built and
      installed into the stage directory,
      STAGEDIR.  A package is created from the
      stage directory and then installed on the system.  Automake
      tools refer to this concept as DESTDIR, but
      in FreeBSD, DESTDIR has a different meaning
      (see Section 10.4, “PREFIX and
      DESTDIR”).
No port really needs to be root.  It
	can mostly be avoided by using USES=uidfix.
	If the port still runs commands like chown(8),
	chgrp(1), or forces owner or group with install(1)
	then use USES=fakeroot
	to fake those calls.  Some patching of the port's
	Makefiles will be needed.
Meta ports, or ports that do not install files themselves but only depend on other ports, must avoid needlessly extracting the mtree(8) to the stage directory. This is the basic directory layout of the package, and these empty directories will be seen as orphans. To prevent mtree(8) extraction, add this line:
NO_MTREE= yes
Metaports should use USES=metaport.
	It sets up defaults for ports that do not fetch, build, or
	install anything.
Staging is enabled by prepending
      STAGEDIR to paths used in the
      pre-install,
      do-install, and
      post-install targets (see the
      examples through the book).  Typically, this includes
      PREFIX, ETCDIR,
      DATADIR, EXAMPLESDIR,
      MANPREFIX, DOCSDIR, and
      so on.  Directories should be created as part of the
      post-install target.  Avoid using
      absolute paths whenever possible.
Ports that install kernel modules must prepend
	STAGEDIR to their destination, by default
	/boot/modules.
When creating a symbolic link, relative ones are strongly
	recommended.  Use ${RLN} to create relative
	symbolic links.  It uses install(1) under the hood to
	automatically figure out the relative link to create.
${RLN} uses install(1)'s
	  relative symbolic feature which frees the porter of
	  computing the relative path.
${RLN} ${STAGEDIR}${PREFIX}/lib/libfoo.so.42 ${STAGEDIR}${PREFIX}/lib/libfoo.so
${RLN} ${STAGEDIR}${PREFIX}/libexec/foo/bar ${STAGEDIR}${PREFIX}/bin/bar
${RLN} ${STAGEDIR}/var/cache/foo ${STAGEDIR}${PREFIX}/share/fooWill generate:
%ls -lF ${STAGEDIR}${PREFIX}/liblrwxr-xr-x 1 nobody nobody 181 Aug 3 11:27 libfoo.so@ -> libfoo.so.42 -rwxr-xr-x 1 nobody nobody 15 Aug 3 11:24 libfoo.so.42*%ls -lF ${STAGEDIR}${PREFIX}/binlrwxr-xr-x 1 nobody nobody 181 Aug 3 11:27 bar@ -> ../libexec/foo/bar%ls -lF ${STAGEDIRDIR}${PREFIX}/sharelrwxr-xr-x 1 nobody nobody 181 Aug 3 11:27 foo@ -> ../../../var/cache/foo
All FreeBSD documents are available for download at https://download.freebsd.org/ftp/doc/
Questions that are not answered by the
    documentation may be
    sent to <freebsd-questions@FreeBSD.org>.
    Send questions about this document to <freebsd-doc@FreeBSD.org>.