1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
<!-- $NetBSD: tools.xml,v 1.2 2006/01/16 00:29:23 rillig 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>BUILD_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 :pkgsrc means to use the pkgsrc version
and not the native version for a build dependency.
And the :run means that it is used for a
run-time dependencies also (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+= mktemp:pkgsrc
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>
<!-- todo: also document how to add a new tool -->
</chapter>
|