README.mknative revision 1.11
11.11Sskrll$NetBSD: README.mknative,v 1.11 2012/09/25 06:55:10 skrll Exp $
21.1Smrg
31.2SskrllThis file describes how to bootstrap the native toolchain on a new NetBSD
41.2Sskrllplatform (and how to update the new toolchain files, if needed).  These
51.2Sskrllfiles may be generated on a cross-compile host without problems.
61.1Smrg
71.2SskrllNOTE:  DO NOT RUN "mknative" BY HAND!  It requires the Makefile in this
81.2Sskrlldirectory to set up certain environments first.
91.2Sskrll
101.2SskrllSince libc's features change over time, the config.h files can change as a
111.2Sskrllresult; thus the instructions below are the same no matter whether
121.2Sskrllbootstrapping on a cross or native host.  This is important: even on a
131.2Sskrll"native" host, you should bootstrap the toolchain by building from an
141.2Sskrllup-to-date source tree to a $DESTDIR using the exact same instructions.
151.2Sskrll
161.2SskrllIn these notes, MACHINE is the $MACHINE of the target.  These files can be
171.2Sskrllcross-generated.  Though a $MACHINE_ARCH all uses the same config files, you
181.2Sskrllmust pick a specific $MACHINE so that building the requisite bits below will
191.2Sskrllwork.
201.2Sskrll
211.2Sskrll1. Set MKMAINTAINERTOOLS=yes in mk.conf.  (Needed so that src/tools/gettext
221.2Sskrll   gets built, eliciting proper HAVE_*GETTEXT* defns in config.h files.)
231.2Sskrll
241.2Sskrll2. Build and install a cross toolchain (via "build.sh -m MACHINE tools").
251.2Sskrll
261.2Sskrll3. In src/tools/gcc, do "nbmake-MACHINE bootstrap-libgcc".
271.2Sskrll
281.10Sskrll   This will create just enough glue in src/external/gpl3/gcc/lib/libgcc/arch
291.10Sskrll   to make it possible to build, based on the toolchain built in
301.10Sskrll   ${.OBJDIR}/build.
311.2Sskrll   Because the files generated in this step contain things like
321.4Smartin   -DCROSS_COMPILE, they are not suitable for committing.  Step 8 below
331.2Sskrll   will regenerate the "proper" libgcc config files.
341.2Sskrll
351.2Sskrll4. At top level, do
361.11Sskrll   "nbmake-MACHINE obj do-distrib-dirs includes MKGCC=no MKBINUTILS=no".
371.2Sskrll
381.11Sskrll5. In src/external/gpl3/gcc/lib/libgcc, do
391.11Sskrll   "nbmake-MACHINE obj includes dependall install MKPIC=no".
401.10Sskrll
411.10Sskrll6. If the platform sets USE_COMPILERCRTSTUFF=yes, then in
421.11Sskrll   src/external/gpl3/gcc/lib/crtstuff/ do
431.11Sskrll   "nbmake-MACHINE obj dependall install"
441.2Sskrll
451.11Sskrll7. In src/lib/csu, do
461.11Sskrll   "nbmake-MACHINE obj includes dependall install".
471.4Smartin
481.11Sskrll8. In each of src/external/lgpl3/gmp/lib/libgmp,
491.11Sskrll   src/external/lgpl3/mpfr/lib/libmpfr, src/external/lgpl2/mpc/lib/libmpc
501.11Sskrll   do "nbmake-MACHINE obj includes LIBISPRIVATE=no", and
511.11Sskrll   "nbmake-MACHINE obj includes dependall install".
521.11Sskrll
531.11Sskrll   It is important to have LIBISPRIVATE=no while doing includes as this
541.11Sskrll   installs a header file that is not part of standard build.
551.11Sskrll
561.11Sskrll9. In src/lib, do
571.11Sskrll   "nbmake-MACHINE obj includes dependall install MKGCC=no".
581.2Sskrll
591.2Sskrll   Optionally, all of the following may be set in the environment to reduce
601.2Sskrll   the amount of code needed to build at this step.  Basically, it must be
611.2Sskrll   possible for static binaries to build and base system libs to exist so
621.2Sskrll   that "configure" can do its job for the target--these MK* options omit
631.11Sskrll   the rest for this stage of the build. 
641.2Sskrll
651.2Sskrll   MKCRYPTO=no
661.2Sskrll   MKLINT=no
671.2Sskrll   MKPROFILE=no
681.2Sskrll   MKSHARE=no
691.2Sskrll
701.11Sskrll10. In src/tools/gcc, do "nbmake-MACHINE native-gcc".
711.2Sskrll
721.2Sskrll   This will do a full configury in ${.OBJDIR}/.native that is a "Canadian"
731.2Sskrll   cross toolchain (--build reflects the host platform, but --host and
741.2Sskrll   --target are the target).  The result is a tree that would build a
751.2Sskrll   native-to-NetBSD compiler on a cross host, and mknative pulls glue data
761.2Sskrll   from this.
771.2Sskrll
781.11Sskrll11. Try out a full build using "nbmake-MACHINE"; the result should include
791.2Sskrll   a native compiler.
801.2Sskrll
811.11Sskrll12. If all is well, commit the glue files added to src/gnu/{lib,usr.bin}/*.
82