NetBSD/tools
matt 58bfd92e80 Add sys/arch/riscv. 2014-09-19 17:30:13 +00:00
..
amiga-elf2bb Remove the borked definition of ELF64_Shalf from some more places. 2014-01-03 16:50:54 +00:00
amiga-txlt
asn1_compile Upgrade Heimdal to 1.5pre1 by switching the build from crypto/dist/heimdal 2011-04-15 18:05:42 +00:00
autoconf Revert previous change to tools/Makefile.gnuhost. When getenv("M4") 2013-08-07 17:50:55 +00:00
awk hook to the new awk in external 2010-12-12 04:06:19 +00:00
binstall no man pages for tools build. 2013-03-16 22:32:50 +00:00
binutils No need to specify ${.OBJDIR} for target files. 2014-02-15 13:34:28 +00:00
cap_mkdb Build getcap.c only once. 2012-06-04 18:53:02 +00:00
cat
cksum
compat Fix problem reading the last line when it did not contain a delimiter 2014-09-16 17:23:50 +00:00
compile_et Upgrade Heimdal to 1.5pre1 by switching the build from crypto/dist/heimdal 2011-04-15 18:05:42 +00:00
config
crunchgen
ctags
ctfconvert switch to the new libelf and libdwarf 2014-03-09 17:12:03 +00:00
ctfmerge switch to the new libelf and libdwarf 2014-03-09 17:12:03 +00:00
db
dbsym obsolete now useless (and wrongly set to "219" :-) HAVE_BINUTILS. 2011-10-31 08:14:43 +00:00
disklabel Make disklabel a MI tool. It will use MACHINE/MACHINE_ARCH to determine 2013-05-03 16:05:11 +00:00
elftosb Add elftosb tools to evbarm userland and toolchain. 2012-11-15 19:49:11 +00:00
fdisk Use ${DESTDIR}/usr/mdec for DEFAULT_BOOTDIR on tools fdisk(8) 2012-06-05 13:41:23 +00:00
fgen
file force set ac_cv_mkdir_path to our install -d program. 2012-04-15 08:37:32 +00:00
gcc or1k does not support --with-float 2014-09-03 19:25:29 +00:00
gdb more files needed 2013-10-03 18:58:37 +00:00
genassym Make most things under src/tools use the TOOLDIR version of compat/defs.mk, 2012-12-02 12:48:32 +00:00
gencat
gettext Prevent the tools/gettext build from trying to run emacs. 2013-03-06 14:34:01 +00:00
gmake switch to the new gmake 2014-08-18 06:58:51 +00:00
gmp force ac_cv_path_mkdir to be set to nbinstall -d. this will avoid 2012-04-12 01:05:31 +00:00
grep BSD grep is good enough if someone really needs src/tools/grep. 2011-04-21 14:27:11 +00:00
groff Make most things under src/tools use the TOOLDIR version of compat/defs.mk, 2012-12-02 12:48:32 +00:00
hexdump
host-mkdep Preserve -std=* options as they may change the dependency list. 2013-09-02 08:37:11 +00:00
hp300-mkboot
hppa-mkboot Rename NetBSD/hp700 to NetBSD/hppa. 2014-02-24 07:23:38 +00:00
ibmnws-ncdcs Point to the new ncdcs directory. 2009-11-13 08:14:53 +00:00
installboot merge the bouyer-quota2 branch. This adds a new on-disk format 2011-03-06 18:15:30 +00:00
join
lex short circuit lex and yacc rules. 2009-10-30 00:30:20 +00:00
libctf If you are going to append things to CPPFLAGS and then transfer 2012-12-16 06:47:39 +00:00
libdwarf switch to the new libdwarf 2014-03-09 17:10:38 +00:00
libelf switch to the new libelf 2014-03-09 17:10:12 +00:00
lint
lint1
lint2
llvm Pass HOST_CXX to llvm configure as CXX=${HOST_CXX:Q} since llvm wants c++ 2014-01-16 09:00:55 +00:00
llvm-clang Update LLVM snapshot. This allows deriving the target from the binary 2011-03-18 23:32:01 +00:00
llvm-clang-tblgen Update LLVM/Clang snapshot to r141658. This primarily fixes a regression 2011-10-11 13:53:56 +00:00
llvm-include Fix version string returned by clang --version. 2012-06-17 07:40:25 +00:00
llvm-lib Update build glue for LLVM/Clang 3.6svn r215315. Changes include various 2014-08-10 17:32:54 +00:00
llvm-lld Update LLVM/Clang snapshot to r189662. This includes many improvements 2013-09-02 14:34:55 +00:00
llvm-mcld Add infrastructure for building MCLinker. 2013-02-27 21:25:05 +00:00
llvm-tblgen Update LLVM/Clang snapshot to r141658. This primarily fixes a regression 2011-10-11 13:53:56 +00:00
lorder Make most things under src/tools use the TOOLDIR version of compat/defs.mk, 2012-12-02 12:48:32 +00:00
m4 Adjust #line directive paths so that make depend works correctly. 2009-11-24 15:09:10 +00:00
m68k-elf2aout Remove the borked definition of ELF64_Shalf from some more places. 2014-01-03 16:50:54 +00:00
macppc-fixcoff
make
makefs This tool now depends on updated target includes in the tools build 2011-03-07 13:28:06 +00:00
makewhatis
mandoc eliminate use of bsd.sys.mk from Makefiles 2014-01-16 01:15:32 +00:00
mdsetimage obsolete now useless (and wrongly set to "219" :-) HAVE_BINUTILS. 2011-10-31 08:14:43 +00:00
menuc
mips-elf2ecoff Remove the borked definition of ELF64_Shalf from some more places. 2014-01-03 16:50:54 +00:00
mkcsmapper
mkdep
mkesdb
mklocale tools/mklocale has not required ctype_bits.h since the following fix: 2011-03-18 15:13:54 +00:00
mknod
mktemp
mkubootimage hook mkubootimage into the build 2010-06-18 18:57:27 +00:00
mpc update to MPC 1.0.1. 2013-11-28 12:08:56 +00:00
mpfr force set ac_cv_mkdir_path to our install -d program. 2012-04-15 08:37:32 +00:00
msgc
mtree Don't create a crippled mtree with no hashes. We have hash support in 2013-02-06 01:01:48 +00:00
nbperf Hook up nbperf into the normal tool build. 2011-11-01 21:16:28 +00:00
pax
paxctl Rename Makefile.disklabel to Makefile.nbincludes, as this file has 2010-06-19 23:11:10 +00:00
pcc because we use --sysroot, force the default paths to be normal 2011-06-13 12:29:16 +00:00
pigz add support to build pigz as a host tool. 2010-06-18 05:26:12 +00:00
pkg_install Add pkg_install as a tool. 2009-12-01 09:01:45 +00:00
powerpc-mkbootimage
pwd_mkdb
rpcgen
sed
sgivol
slc Tool for slc, a command built during the Heimdal build. 2011-04-14 19:38:21 +00:00
sparkcrc
stat
strfile
sunlabel
texinfo Invoke tools/binstall/mkmanifest for Cygwin via ${HOST_SH}. 2013-06-14 16:10:02 +00:00
tic Handle auto-generating hash.c 2011-11-02 17:49:20 +00:00
tsort
uudecode
veriexecgen
vgrind use host rules for files. 2014-07-15 16:04:35 +00:00
yacc use new yacc 2009-10-29 01:01:27 +00:00
zic Fix build on Solaris 10. 2011-03-03 14:53:01 +00:00
Makefile Changes to existing files to enable building AARCH64 userland. 2014-08-10 05:56:36 +00:00
Makefile.gmakehost Merge the two Makefiles that were mostly copies of each others. 2012-01-20 23:01:05 +00:00
Makefile.gnuhost pass HOST_SH to the build, to keep it from picking up a "bash" 2013-08-13 20:41:25 +00:00
Makefile.gnuwrap
Makefile.host Invoke tools/binstall/mkmanifest for Cygwin via ${HOST_SH}. 2013-06-14 16:10:02 +00:00
Makefile.nbincludes add -I${TOOLDIR}/include/nbinclude to fix the build (find arm/elf_machdep.h). 2012-08-05 06:20:14 +00:00
README Add tools/README, to collect hints like how to use 2014-09-01 13:50:15 +00:00
headerlist Add sys/arch/riscv. 2014-09-19 17:30:13 +00:00
mkheaderlist.sh comment 2011-02-05 13:30:26 +00:00

README

$NetBSD: README,v 1.1 2014/09/01 13:50:15 apb Exp $

Notes for NetBSD src/tools


Background
==========

Several programs that are part of NetBSD are also built as tools.  Such
programs are typically built twice, once as a tool and once as part of
the main build.  Tools are relevant only when USETOOLS=yes, which is the
default.

Tools are built on the host platform, using the host compiler,
and will run on the host platform during the cross-build of the
remainder of NetBSD.  They are built near the beginning of a NetBSD
build (e.g. "build.sh tools" or "make tools" from the top level src
directory), and installed in ${TOOLDIR}.

Tools are executed during the main part of the build, when several
TOOL_* variables defined in src/share/mk/bsd.*.mk will refer to the
tools installed in ${TOOLDIR}.


Portability
===========

Programs that are built as tools need to be more portable than other
parts of NetBSD, because they will need to run on the host platform.
They should restrict themselves to features that are defined in relevant
standards, and features that are provided by the src/tools/compat
framework.


Compatibility framework
=======================

src/tools/compat provides a compatibility framework for use by tools.
It installs the following components, and more:

${TOOLDIR}/lib/libnbcompat.a

    A library containing functions that are needed by some tools.

${TOOLDIR}/include/nbtool_compat.h

    A header file defining macros that are needed by some tools.

${TOOLDIR}/share/compat/defs.mk

    A makefile fragment, to be included by other makefiles,
    to define make variables appropriate for building tools.

    Among other things, this makefile fragment automatically adds
    the libnbcompat.a library to the LDADD and DPADD variables,
    so that tools will be linked with that library, and adds
    -I${NETBSDSRCDIR}/tools/compat and -DHAVE_NBTOOL_CONFIG_H=1 to the
    HOST_CPPFLAGS variable, so that compiled programs can detect when
    they are being built as tools.


Adapting Makefiles for use with tools
=====================================

Makefiles under src/tools/*/Makefile should define HOSTPROG in the
make environment.  This is typically done by tools/Makefile.hostprog,
which is directly or indirectly included by all Makefiles in
src/tools/*/Makefile.

Makefiles in the non-tools part of the src tree make use tests such as
".if defined(HOSTPROG)" to test whether or not the associated program
is being built as a tool, and to modify their behaviour accordingly.
For example, the Makefile may conditionally refrain from compiling and
linking certain files, and the Makefile may conditionally pass macros to
the compiler via constructs like this:

    .if defined(HOSTPROG)
    CPPFLAGS+= -DWITH_FEATURE_X=0
    .else
    CPPFLAGS+= -DWITH_FEATURE_X=1
    .endif

Adapting Programs for use with tools
====================================

The compiler should automatically be invoked with
-DHAVE_NBTOOL_CONFIG_H=1, as a result of settings in
${TOOLDIR}/share/compat/defs.mk, which should be included from
src/tools/Makefile.host, which should be included directly or indirectly
from src/tools/*/Makefile.

In order to obtain the compatibility macros provided by the tools
compatibility framework, almost every C source file that is built as
part of a tool should have lines like this as the first non-comment
lines:

    #if HAVE_NBTOOL_CONFIG_H
    #include "nbtool_config.h"
    #endif /* HAVE_NBTOOL_CONFIG_H */

To omit features from the tools version of a program, the program's
source code should use preprocessor macros that are conditionally passed
from its Makefile via CPPFLAGS.  For example, it could use something
like this:

    #if WITH_FEATURE_X 
       ...
    #endif /* WITH_FEATURE_X */