pkgsrc/doc/guide/files/tools.xml
leot 40cad5e0ac guide: Document TOOL_DEPENDS
Document TOOL_DEPENDS and clarify the differencies with BUILD_DEPENDS.
Adjust previous BUILD_DEPENDS examples (all of them were actually
TOOL_DEPENDS).

XXX: No BUILD_DEPENDS example is provided, if you have any good and common
XXX: BUILD_DEPENDS example please add it (a TODO comment was added regarding
XXX: that).  At least according a quick grep of BUILD_DEPENDS probably most of
XXX: them are actually BUILD_DEPENDS and maybe all real BUILD_DEPENDS are via
XXX: buildlink3.mk inclusion.
2019-05-20 18:14:24 +00:00

93 lines
3.3 KiB
XML

<!-- $NetBSD: tools.xml,v 1.8 2019/05/20 18:14:24 leot Exp $ -->
<chapter id="tools">
<title>Tools needed for building or running</title>
<para>The <varname>USE_TOOLS</varname> definition is used both internally
by pkgsrc and also for individual packages to define what commands
are needed for building a package (like <varname>TOOL_DEPENDS</varname>)
or for later run-time of an installed packaged (such as
<varname>DEPENDS</varname>).
If the native system provides an adequate tool, then in many cases, a pkgsrc
package will not be used.</para>
<para>When building a package, the replacement tools are
made available in a directory (as symlinks or wrapper scripts)
that is early in the executable search path. Just like the buildlink
system, this helps with consistent builds.</para>
<para>A tool may be needed to help build a specific package. For example,
perl, GNU make (gmake) or yacc may be needed.</para>
<para>Also a tool may be needed, for example, because the native system's supplied
tool may be inefficient for building a package with pkgsrc.
For example, a package may need GNU awk, bison (instead of
yacc) or a better sed.</para>
<para>The tools used by a package can be listed by running
<command>make show-tools</command>.</para>
<sect1 id="pkgsrc-tools">
<title>Tools for pkgsrc builds</title>
<para>The default set of tools used by pkgsrc is defined in
<filename>bsd.pkg.mk</filename>. This includes standard Unix tools,
such as: <command>cat</command>, <command>awk</command>,
<command>chmod</command>, <command>test</command>, and so on.
These can be seen by running:
<command>make show-var VARNAME=USE_TOOLS</command>.</para>
<para>If a package needs a specific program to build
then the <varname>USE_TOOLS</varname> variable can be used
to define the tools needed.</para>
</sect1>
<sect1 id="package-tools">
<title>Tools needed by packages</title>
<para>In the following examples, the :run means that it is needed at
run-time (and becomes a DEPENDS).
The default is a build dependency which can be set with
:build. (So in this example, it is the same as gmake:build
and pkg-config:build.)</para>
<programlisting>
USE_TOOLS+= gmake perl:run pkg-config
</programlisting>
<para>When using the tools framework, a
<varname>TOOLS_PATH.foo</varname> variable is defined
which contains the full path to the appropriate tool. For example,
<varname>TOOLS_PATH.bash</varname> could be <quote>/bin/bash</quote>
on Linux systems.</para>
<para>If you always need a pkgsrc version of the
tool at run-time, then just use <varname>DEPENDS</varname> instead.
<!-- jlam said: This is not to
say that we can't extend the tools framework to do that, but it hasn't been
something that's come up frequently enough to make it worthwhile to do.
--></para>
</sect1>
<sect1 id="platform-tools">
<title>Tools provided by platforms</title>
<para>When improving or porting pkgsrc to a new platform, have a look
at (or create) the corresponding platform specific make file fragment under
<filename>pkgsrc/mk/tools/tools.${OPSYS}.mk</filename> which defines
the name of the common tools. For example:</para>
<programlisting>
.if exists(/usr/bin/bzcat)
TOOLS_PLATFORM.bzcat?= /usr/bin/bzcat
.elif exists(/usr/bin/bzip2)
TOOLS_PLATFORM.bzcat?= /usr/bin/bzip2 -cd
.endif
TOOLS_PLATFORM.true?= true # shell builtin
</programlisting>
</sect1>
</chapter>