Welcome to ftp.nluug.nl Current directory: /pub/ftp/ftp/NetBSD/NetBSD-current/src/tools/ |
|
Contents of README:$NetBSD: README,v 1.6 2024/09/25 16:24:58 christos 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 release build. Tools are relevant only when the make(1) variable USETOOLS=yes, which is the default for most NetBSD builds. 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. Most tools should restrict themselves to C language features that are defined in C99 (ISO/IEC 9899-1999); they should avoid using C11 language features, such as <threads.h>, _Alignof, <uchar.h>, _Generic, static_assert, anonymous structures and unions. Tools may use library features such as functions, macros, and types, that are defined in C99 and in POSIX (IEEE Std 1003.1) (XXX year?), and features that are provided by the compatibility framework (src/tools/compat) described in a separate section below. If a tool attempts to use a feature that is not available on the host platform, then the tools build will fail. This can be addressed by changing the tool to avoid that feature, or by adding the feature to the src/tools/compat framework. It is usually easy to add new macros or functions to src/tools/compat, and that is usually better than adding compatibility definitions to individual tools. 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/compat/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 the HOSTPROG variable. 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 can test whether or not the HOSTPROG variable is defined, in order tell the difference between building a tool and building part of a NetBSD release, and they may alter their behavior 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 # exclude feature X from tools build .else CPPFLAGS+= -DWITH_FEATURE_X=1 # include feature X in release build .endif Adapting Programs for use with tools ==================================== When a tool is being built, the C compiler should automatically be invoked with -DHAVE_NBTOOL_CONFIG_H=1. This is done 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. A C source file can test whether the HAVE_NBTOOL_CONFIG_H macro is defined, in order to tell whether or not it is being compiled as part of a tool. In order to obtain the definitions provided by the tools compatibility framework, almost every C source file that is built as part of a tool should have lines like these as the first non-comment lines: #if HAVE_NBTOOL_CONFIG_H #include "nbtool_config.h" #endif To omit features from the tools version of a program, the program may test the HAVE_NBTOOL_CONFIG_H macro, like this: #if HAVE_NBTOOL_CONFIG_H ... code to be used when built as a tool #else ... code to be used when built as part of a release #endif It is often preferable to use macros whose names refer to the features that should be included or omitted. See the section on "Adapting Makefiles for use with tools" for an example in which the Makefile passes -DWITH_FEATURE_X=0 or -DWITH_FEATURE_X=1 to the compiler according to whether or not the program is being built as a tool. Then the program can use code like this: #if WITH_FEATURE_X ... code to be used when FEATURE X is desired, ... e.g. when being built as part of a release. #else ... code to be used when FEATURE X is not desired, ... e.g. when being built as a tool. #endif |
Name Last modified Size
Parent Directory - CVS/ 09-Nov-2024 04:01 - amiga-elf2bb/ 25-Dec-2009 07:54 - amiga-txlt/ 25-Dec-2009 07:54 - arm-elf2aout/ 01-Jan-2019 04:01 - asn1_compile/ 30-Jan-2017 04:01 - autoconf/ 08-Aug-2013 05:02 - awk/ 21-Sep-2024 05:01 - binstall/ 02-May-2018 05:01 - binutils/ 09-Nov-2024 04:01 - cap_mkdb/ 05-Jun-2012 05:02 - cat/ 25-Dec-2009 07:54 - cksum/ 25-Dec-2009 07:54 - compat/ 09-Nov-2024 04:01 - compile_et/ 30-Jan-2017 04:01 - config/ 25-Dec-2009 07:54 - crunchgen/ 25-Dec-2009 07:54 - ctags/ 25-Dec-2009 07:54 - ctfconvert/ 02-Apr-2024 05:01 - ctfmerge/ 02-Apr-2024 05:01 - cvslatest/ 02-May-2018 05:01 - date/ 28-May-2021 05:02 - db/ 25-Dec-2009 07:54 - dbsym/ 01-Jul-2024 05:02 - disklabel/ 18-May-2019 05:01 - dtc/ 02-May-2018 05:01 - elftoolchain/ 31-Mar-2024 05:01 - elftosb/ 20-May-2018 05:01 - fdisk/ 18-Sep-2021 05:01 - fgen/ 25-Dec-2009 07:54 - file/ 29-Sep-2018 05:01 - gcc/ 11-Aug-2024 05:01 - gdb/ 01-Sep-2024 05:01 - genassym/ 02-May-2018 05:01 - gencat/ 25-Dec-2009 07:54 - gettext/ 02-May-2018 05:01 - gmake/ 19-Aug-2014 05:04 - gmp/ 29-Sep-2024 05:01 - gpt/ 18-May-2019 05:01 - grep/ 13-Aug-2018 05:01 - groff/ 14-Jan-2016 04:00 - gzip/ 01-Apr-2024 05:01 - hexdump/ 25-Dec-2009 07:54 - host-mkdep/ 11-Jul-2023 05:01 - hp300-mkboot/ 25-Dec-2009 07:54 - hppa-mkboot/ 25-Feb-2014 04:04 - ibmnws-ncdcs/ 25-Dec-2009 07:54 - installboot/ 09-Nov-2024 04:01 - isl/ 24-Feb-2024 04:01 - join/ 25-Dec-2009 07:54 - lex/ 24-Aug-2018 05:01 - libctf/ 02-Apr-2024 05:01 - libfdt/ 02-May-2018 05:01 - libmopcopy/ 23-Oct-2024 05:01 - libprop/ 08-May-2019 05:01 - lint/ 25-Jan-2021 04:02 - lint1/ 25-Dec-2009 07:54 - lint2/ 25-Dec-2009 07:54 - llvm-clang-tblgen/ 12-Nov-2019 04:02 - llvm-clang/ 12-Nov-2019 04:02 - llvm-include/ 18-Jun-2012 05:01 - llvm-lib/ 09-Nov-2024 04:01 - llvm-tblgen/ 12-Nov-2019 04:02 - llvm/ 30-May-2021 05:02 - lorder/ 02-May-2018 05:01 - m4/ 25-Dec-2009 07:54 - m68k-elf2aout/ 28-Jan-2019 04:01 - macppc-fixcoff/ 25-Dec-2009 07:54 - macppc_installboot/ 16-Sep-2024 05:01 - macppc_mkboothfs/ 16-Sep-2024 05:01 - make/ 21-Jul-2023 05:01 - makefs/ 08-Mar-2011 05:51 - makekeys/ 02-May-2018 05:01 - makestrs/ 25-Jun-2015 07:28 - makewhatis/ 25-Dec-2009 07:54 - mandoc/ 16-Aug-2018 05:01 - mdsetimage/ 01-Jul-2024 05:02 - menuc/ 25-Dec-2009 07:54 - mips-elf2ecoff/ 09-Nov-2024 04:01 - mkcsmapper/ 25-Dec-2009 07:54 - mkdep/ 25-Dec-2009 07:54 - mkesdb/ 25-Dec-2009 07:54 - mkhybrid/ 01-Jun-2024 05:01 - mklocale/ 19-Mar-2011 04:02 - mknod/ 25-Dec-2009 07:54 - mktemp/ 25-Dec-2009 07:54 - mkubootimage/ 19-Jun-2010 05:04 - mpc/ 29-Nov-2013 04:04 - mpfr/ 16-Apr-2012 05:03 - msgc/ 25-Dec-2009 07:54 - mtree/ 06-Feb-2013 04:03 - mvme68k-wrtvid/ 07-May-2021 05:01 - nbperf/ 02-Nov-2011 04:03 - pax/ 25-Dec-2009 07:54 - paxctl/ 20-Jun-2010 05:02 - pcc/ 31-Mar-2016 05:01 - pigz/ 19-Jun-2010 05:04 - pkg_install/ 18-Jan-2020 04:02 - powerpc-mkbootimage/ 25-Dec-2009 07:54 - pwd_mkdb/ 25-Dec-2009 07:54 - rpcgen/ 23-Jun-2019 05:01 - sed/ 25-Dec-2009 07:54 - sgivol/ 25-Dec-2009 07:54 - slc/ 15-Apr-2011 05:01 - sortinfo/ 09-Jan-2016 04:01 - sparkcrc/ 25-Dec-2009 07:54 - stat/ 25-Dec-2009 07:54 - strfile/ 25-Dec-2009 07:54 - sunlabel/ 18-Sep-2021 05:01 - texinfo/ 15-Jun-2013 05:01 - tic/ 06-Apr-2020 05:01 - tsort/ 25-Dec-2009 07:54 - uudecode/ 18-Sep-2021 05:01 - vax-mopcopy/ 23-Oct-2024 05:01 - veriexecgen/ 25-Dec-2009 07:54 - vgrind/ 18-Sep-2021 05:01 - xz-bin/ 20-Nov-2018 04:01 - xz-include/ 03-Jun-2023 05:01 - xz-lib/ 26-Sep-2018 05:01 - yacc/ 25-Dec-2009 07:54 - zic/ 30-Oct-2022 04:01 - Makefile 23-Oct-2024 05:01 6.9K Makefile.gmakehost 21-Jan-2012 04:03 830 Makefile.gnuhost 20-May-2023 05:01 4.6K Makefile.gnuwrap 14-Mar-2003 06:22 925 Makefile.host 18-Aug-2024 05:01 2.0K Makefile.nbincludes 20-May-2024 05:01 1.9K README 26-Sep-2024 05:01 5.3K headerlist 04-Jan-2024 04:01 4.4K mkheaderlist.sh 24-Feb-2016 04:01 508
NLUUG - Open Systems. Open Standards
Become a member
and get discounts on conferences and more, see the NLUUG website!